#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
template <int MAXV, class T = int> struct Dinic {
const static bool SCALING = true; // non-scaling = V^2E, Scaling=VElog(U) with higher constant
int lim = 1;
const T INF = numeric_limits<T>::max();
struct edge {
int to, rev;
T cap, flow;
};
int s = MAXV - 2, t = MAXV - 1;
int level[MAXV], ptr[MAXV];
vector<edge> adj[MAXV];
void addEdge(int a, int b, T cap, bool isDirected = true) {
adj[a].push_back({b, adj[b].size(), cap, 0});
adj[b].push_back({a, adj[a].size() - 1, isDirected ? 0 : cap, 0});
}
bool bfs() {
queue<int> q({s});
fill(all(level), -1);
level[s] = 0;
while (!q.empty() && level[t] == -1) {
int v = q.front();
q.pop();
for (auto e : adj[v]) {
if (level[e.to] == -1 && e.flow < e.cap && (!SCALING || e.cap - e.flow >= lim)) {
q.push(e.to);
level[e.to] = level[v] + 1;
}
}
}
return level[t] != -1;
}
T dfs(int v, T flow) {
if (v == t || !flow)
return flow;
for (; ptr[v] < adj[v].size(); ptr[v]++) {
edge &e = adj[v][ptr[v]];
if (level[e.to] != level[v] + 1)
continue;
if (T pushed = dfs(e.to, min(flow, e.cap - e.flow))) {
e.flow += pushed;
adj[e.to][e.rev].flow -= pushed;
return pushed;
}
}
return 0;
}
long long calc() {
long long flow = 0;
for (lim = SCALING ? (1 << 30) : 1; lim > 0; lim >>= 1) {
while (bfs()) {
fill(all(ptr), 0);
while (T pushed = dfs(s, INF))
flow += pushed;
}
}
return flow;
}
};
Dinic<1001> dinic;
int main() { cin.tie(NULL);
int n = 1000;
for(int i=1; i<=n-2; i++){
dinic.addEdge(i, i+1, 100000000);
dinic.addEdge(i, n, 10000);
for(int j=i+3; j<=n-2; j++){
dinic.addEdge(i, j, 1);
dinic.addEdge(j, i, 1);
}
}
dinic.s = 1, dinic.t = n;
cout << dinic.calc() << '\n';
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIG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AgaWYgKGxldmVsW2UudG9dID09IC0xICYmIGUuZmxvdyA8IGUuY2FwICYmICghU0NBTElORyB8fCBlLmNhcCAtIGUuZmxvdyA+PSBsaW0pKSB7CiAgICAgICAgICAgICAgICAgICAgcS5wdXNoKGUudG8pOwogICAgICAgICAgICAgICAgICAgIGxldmVsW2UudG9dID0gbGV2ZWxbdl0gKyAxOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBsZXZlbFt0XSAhPSAtMTsKICAgIH0KICAgIFQgZGZzKGludCB2LCBUIGZsb3cpIHsKICAgICAgICBpZiAodiA9PSB0IHx8ICFmbG93KQogICAgICAgICAgICByZXR1cm4gZmxvdzsKICAgICAgICBmb3IgKDsgcHRyW3ZdIDwgYWRqW3ZdLnNpemUoKTsgcHRyW3ZdKyspIHsKICAgICAgICAgICAgZWRnZSAmZSA9IGFkalt2XVtwdHJbdl1dOwogICAgICAgICAgICBpZiAobGV2ZWxbZS50b10gIT0gbGV2ZWxbdl0gKyAxKQogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIGlmIChUIHB1c2hlZCA9IGRmcyhlLnRvLCBtaW4oZmxvdywgZS5jYXAgLSBlLmZsb3cpKSkgewogICAgICAgICAgICAgICAgZS5mbG93ICs9IHB1c2hlZDsKICAgICAgICAgICAgICAgIGFkaltlLnRvXVtlLnJldl0uZmxvdyAtPSBwdXNoZWQ7CiAgICAgICAgICAgICAgICByZXR1cm4gcHVzaGVkOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiAwOwogICAgfQogICAgbG9uZyBsb25nIGNhbGMoKSB7CiAgICAgICAgbG9uZyBsb25nIGZsb3cgPSAwOwogICAgICAgIGZvciAobGltID0gU0NBTElORyA/ICgxIDw8IDMwKSA6IDE7IGxpbSA+IDA7IGxpbSA+Pj0gMSkgewogICAgICAgICAgICB3aGlsZSAoYmZzKCkpIHsKICAgICAgICAgICAgICAgIGZpbGwoYWxsKHB0ciksIDApOwogICAgICAgICAgICAgICAgd2hpbGUgKFQgcHVzaGVkID0gZGZzKHMsIElORikpCiAgICAgICAgICAgICAgICAgICAgZmxvdyArPSBwdXNoZWQ7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIGZsb3c7CiAgICB9Cn07CgpEaW5pYzwxMDAxPiBkaW5pYzsKCmludCBtYWluKCkgeyBjaW4udGllKE5VTEwpOwogICAgaW50IG4gPSAxMDAwOwogICAgZm9yKGludCBpPTE7IGk8PW4tMjsgaSsrKXsKICAgICAgICBkaW5pYy5hZGRFZGdlKGksIGkrMSwgMTAwMDAwMDAwKTsKICAgICAgICBkaW5pYy5hZGRFZGdlKGksIG4sIDEwMDAwKTsKICAgICAgICBmb3IoaW50IGo9aSszOyBqPD1uLTI7IGorKyl7CiAgICAgICAgICAgIGRpbmljLmFkZEVkZ2UoaSwgaiwgMSk7CiAgICAgICAgICAgIGRpbmljLmFkZEVkZ2UoaiwgaSwgMSk7CiAgICAgICAgfQogICAgfQogICAgZGluaWMucyA9IDEsIGRpbmljLnQgPSBuOwogICAgY291dCA8PCBkaW5pYy5jYWxjKCkgPDwgJ1xuJzsKfQ==