import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; void main() { auto N = readln.chomp.to!int; auto A = N.iota.map!(_ => readln.split.map!(to!int).array).array; auto used = new bool[](N); auto tied = new int[](N); int point = 0; foreach (i; 0..N/2) { int x, y; do { x = uniform(0, N); } while (used[x]); used[x] = true; do { y = uniform(0, N); } while (used[y]); used[y] = true; tied[x] = y; tied[y] = x; } foreach (_; 0..10^^6) { int x, y; do { x = uniform(0, N); y = uniform(0, N); } while (x == y || tied[x] == y); int xx = tied[x]; int yy = tied[y]; if (A[x][xx] + A[y][yy] < A[x][y] + A[xx][yy]) { tied[x] = y; tied[y] = x; tied[xx] = yy; tied[yy] = xx; } } point = 0; fill(used, false); foreach (i; 0..N) { if (!used[i]) point += A[i][tied[i]]; used[i] = used[tied[i]] = true; } point.writeln; }