# CodeForces 362E Petya and Pipes

### Description

$n\le 50,0\le k\le 10^3$

### Solution

#include<bits/stdc++.h>
using namespace std;

template <class T> void read(T &x) {
x = 0; bool flag = 0; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) flag |= ch == '-';
for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48; flag ? x = ~x + 1 : 0;
}

#define N 51
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define INF 0x3f3f3f3f

int k;

int flow, cost, head[N], tot = 1, dis[N], pre[N];
struct { int v, c, w, next; }e[100010];
queue<int> q;
bool inq[N];
inline void insert(int u, int v, int c, int w) {
e[++tot].v = v, e[tot].c = c, e[tot].w = w, e[tot].next = head[u], head[u] = tot;
}
inline void add(int u, int v, int c, int w) {
insert(u, v, c, w), insert(v, u, 0, -w);
}
bool spfa(int S, int T) {
memset(dis, 0x3f, sizeof dis); dis[S] = 0, q.push(S);
while (!q.empty()) {
int u = q.front(); q.pop(), inq[u] = 0;
for (int i = head[u], v; i; i = e[i].next) e[i].c && dis[v = e[i].v] > dis[u] + e[i].w ?
dis[v] = dis[u] + e[i].w, pre[v] = i, (!inq[v] ? q.push(v), inq[v] = 1 : 0) : 0;
}
if (dis[T] >= INF) return 0;
int d = INF;
for (int i = T; i != S; i = e[pre[i] ^ 1].v) d = min(d, e[pre[i]].c);
if (cost + d * dis[T] > k) {
flow += (k - cost) / dis[T];
return 0;
}
return 1;
}
void mcf(int S, int T) {
int d = INF;
for (int i = T; i != S; i = e[pre[i] ^ 1].v) d = min(d, e[pre[i]].c);
for (int i = T; i != S; i = e[pre[i] ^ 1].v) e[pre[i]].c -= d, e[pre[i] ^ 1].c += d, cost += d * e[pre[i]].w;
flow += d;
}

int main() {
}