malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 2e5 + 4;   int main() {     vector<pair<long long, char> > ans;     long long n, st[MAX_N],         pr[MAX_N] = {             0,         };     long long sum = 0;     scanf( %lld , &n);     for (int i = 0; i < n; i++) {       scanf( %lld , &st[i]);       pr[i] = st[i];       sum += (1ll * st[i]);     }     long long k, last[MAX_N];     scanf( %lld , &k);     for (int i = 0; i < k; i++) {       scanf( %lld , &last[i]);       sum = sum - last[i];     }     if (sum != 0) {       cout <<  NO ;       return 0;     }     int left = n - 1, left_last = k - 1, prev;     while (left >= 0 && left_last >= 0) {       if (st[left] != last[left_last]) {         if (last[left_last] < st[left]) {           cout <<  NO ;           return 0;         }         prev = left;         while (left >= 0 && st[left] < last[left_last]) {           left--;           st[left] = st[left] + st[left + 1];         }         if (left < 0 || st[left] != last[left_last]) {           cout <<  NO ;           return 0;         }         long long max_ = pr[left], find_ = left;         for (int i = left + 1; i < prev; i++)           if (max_ < pr[i]) {             max_ = pr[i];             find_ = i;           } else if (max_ == pr[i]) {             if (i < prev)               if (pr[i] > pr[i + 1]) {                 max_ = pr[i];                 find_ = i;               }           }         if (max_ < pr[prev]) {           find_ = prev;           max_ = pr[prev];         }         if (find_ == prev)           ;         else if (find_ == left && pr[find_ + 1] == pr[find_]) {           cout <<  NO ;           return 0;         }         if (find_ != left && max_ == pr[find_ - 1]) {           if (find_ < prev && pr[find_] > pr[find_ + 1])             ;           else {             cout <<  NO ;             return 0;           }         }         int kol1 = prev - find_;         int kol2 = find_ - left;         if (find_ != left && pr[find_ - 1] < pr[find_]) {           ans.push_back(make_pair(find_ + 1,  L ));           kol2--;           find_--;         }         while (kol1 > 0) {           ans.push_back(make_pair(find_ + 1,  R ));           kol1--;         }         while (kol2 > 0) {           ans.push_back(make_pair(find_ + 1,  L ));           find_--;           kol2--;         }       }       left--;       left_last--;     }     cout <<  YES  << endl;     for (auto it : ans) {       printf( %lld %c n , it.first, it.second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long x, long long y) { return x ? gcd(y % x, x) : y; }   int N;   int a[2010], b[2010], c[2010];   vector<pair<long long, long long> > v;   long long func(void) {     int i, j;     int ans = 0;     i = 0;     while (i < v.size()) {       for (j = i; j < v.size(); j++)         if (v[j] != v[i]) break;       int d = j - i;       ans += d * (d - 1) / 2;       i = j;     }     return ans;   }   int main(void) {     int i, j;     cin >> N;     for ((i) = 0; (i) < (int)(N); (i)++) scanf( %d%d%d , &a[i], &b[i], &c[i]);     long long ans = 0;     int zero = 0;     for ((i) = 0; (i) < (int)(N); (i)++)       if (c[i] == 0) zero++;     if (zero == 2) ans += N - 2;     for ((i) = 0; (i) < (int)(N); (i)++)       if (c[i] != 0) {         v.clear();         long long px = a[i] * a[i] + b[i] * b[i];         long long qx = a[i] * c[i];         long long py = a[i] * a[i] + b[i] * b[i];         long long qy = b[i] * c[i];         for ((j) = 0; (j) < (int)(i); (j)++)           if (c[j] != 0) {             long long px2 = a[j] * a[j] + b[j] * b[j];             long long qx2 = a[j] * c[j];             long long py2 = a[j] * a[j] + b[j] * b[j];             long long qy2 = b[j] * c[j];             long long rx = px * px2;             long long sx = qx * px2 - px * qx2;             long long ry = py * py2;             long long sy = qy * py2 - py * qy2;             long long g =                 gcd(((sx) > 0 ? (sx) : -(sx)), ((sy) > 0 ? (sy) : -(sy)));             sx /= g;             sy /= g;             if (sx < 0 || (sx == 0 && sy < 0)) {               sx = -sx;               sy = -sy;             }             v.push_back(make_pair(sx, sy));           }         sort(v.begin(), v.end());         long long tmp = func();         ans += tmp;       }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int test, n, i, j, a, b;     cin >> test;     for (i = 0; i < test; i++) {       cin >> n;       for (a = 2; a < n; a++) {         for (b = n - 1; b > a; b--) {           if (n % a == n % b) {             break;           }         }         if (n % a == n % b) {           cout << a <<     << b << endl;           break;         }       }     }     return 0;   }
#include <iostream>   #include <vector>   #include <cstring>   #include <algorithm>   #include <cassert>   #include <deque>   #include <map>   #include <queue>   #include <climits>   #include <set>   #include <stack>   #include <cmath>   #include <array>   #include <unordered_map>   #include <unordered_set>      using namespace std;      #define ll long long   #define MAX 100000   #define MAX1 10000   #define MAX2 100000   #define inf 1000000000   #define eps 1e-12   #define MOD 1000000007      int main() {          ios_base::sync_with_stdio(0);       cin.tie(0);   #ifndef ONLINE_JUDGE       freopen( in.txt ,  r , stdin);       freopen( out.txt ,  w , stdout);   #endif          int t;       cin >> t;       while (t-- > 00) {           int n;           cin >> n;           int a[n + 5], i;           bool is = true;           for (i = 1; i <= n; ++i) {               cin >> a[i];               is &= a[i] == i;           }           if (is) {               cout << 0 <<   n ;               continue;           }           cout << (a[1] == 1 or a[n] == n ? 1 : (a[1] == n and a[n] == 1) ? 3 : 2) <<   n ;       }          return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000 + 5;   struct stu {     int id, sc;   } a[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     int i, j;     for (i = 1; i <= n; i++) {       a[i].id = i;       a[i].sc = 0;       int x;       for (j = 0; j < 4; j++) {         cin >> x;         a[i].sc += x;       }     }     for (i = 1; i < n; i++) {       for (j = i + 1; j <= n; j++) {         if (a[i].sc < a[j].sc || (a[i].sc == a[j].sc && a[i].id > a[j].id)) {           swap(a[i], a[j]);         }       }       if (a[i].id == 1) break;     }     cout << i << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int n = s.size();     int l[n];     for (int i = 0; i < n; ++i) {       l[i] = n;     }     for (int i = 0; i < n; ++i) {       for (int j = 1; j <= min(n - i - 1, i); ++j) {         if (s[i - j] == s[i] && s[i] == s[i + j]) {           l[i - j] = min(l[i - j], i + j);           break;         }       }     }     set<pair<int, int> > h;     for (int i = 0; i < n; ++i) {       h.insert({l[i], i});     }     long long sum = 0;     for (int i = 0; i < n; ++i) {       sum += n - ((*h.begin()).first);       h.erase({l[i], i});     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }   long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); }   long long POWER(long long x, long long y, long long m) {     if (y == 0) return 1;     if (y % 2 == 0) {       long long temp = POWER(x, y / 2, m);       temp *= temp;       temp %= m;       return temp;     }     long long temp = POWER(x, y - 1, m);     temp *= x;     temp %= m;     return temp;   }   long long POWER(long long x, long long y) {     if (y == 0) return 1;     if (y % 2 == 0) {       long long temp = POWER(x, y / 2);       temp *= temp;       return temp;     }     long long temp = POWER(x, y - 1);     temp *= x;     return temp;   }   long long a[100010];   int main() {     ifstream fin( ali );     long long n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     long long id = 0;     for (long long i = 1; i <= n; i++) {       if ((i * (i + 1)) / 2 >= k) {         id = i;         break;       }     }     if ((id * (id + 1) / 2) == k) {       cout << a[id] <<   n ;       return 0;     }     id--;     id = (id * (id + 1)) / 2;     for (int i = 1; i <= n; i++) {       id++;       if (id == k) {         cout << a[i] <<   n ;         return 0;       }     }     main();   }
#include <bits/stdc++.h>   using namespace std;   struct segment {     int l, r;   };   segment s[1010];   int n, ans[1010], m, pi[1010], d[1010];   bool operator<(const segment &a, const segment &b) { return a.r < b.r; }   int main() {     int i, j;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> s[i].l >> s[i].r;       if (s[i].l > s[i].r) swap(s[i].l, s[i].r);     }     sort(s + 1, s + n + 1);     s[0].r = s[0].l = -2147483647;     pi[0] = 0;     for (i = 1; i <= n; i++) {       j = i - 1;       while (pi[j] == m) {         if (s[j].r < s[i].l) {           d[i] = -1;           break;         }         j--;       }       if (d[i] == -1)         d[i] = d[i - 1] + 1, ans[++m] = s[i].r, pi[i] = m;       else         pi[i] = m, d[i] = d[i - 1];     }     printf( %d n , d[n]);     for (i = 1; i <= m; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4e5 + 10;   const int INF = 1e9;   map<int, int> cnt;   vector<int> ind[N];   vector<int> pos(N, 0);   int main() {     int n, k;     cin >> n >> k;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];       ind[a[i]].push_back(i);     }     for (int i = 0; i < n; i++) {       ind[a[i]].push_back(INF);     }     set<pair<int, int> > s;     set<int> inSet;     int result = 0;     for (int i = 0; i < n; i++) {       int cur = a[i];       pos[cur]++;       if (inSet.find(cur) != inSet.end()) {         s.erase(make_pair(ind[cur][pos[cur] - 1], cur));         s.insert(make_pair(ind[cur][pos[cur]], cur));         continue;       }       if (inSet.size() == k) {         inSet.erase((*s.rbegin()).second);         s.erase(*s.rbegin());       }       s.insert(make_pair(ind[cur][pos[cur]], cur));       inSet.insert(cur);       result++;     }     cout << result;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100001];   int main() {     long long n, s = 0, i, k, j;     string m;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> m;       k = 0;       for (j = 0; j < n; j++)         if (m[j] ==  C ) k++, a[j + 1]++;       s += ((k - 1) * k) / 2;     }     for (i = 1; i <= n; i++) s += ((a[i] - 1) * a[i]) / 2;     cout << s;     return 0;   }
#include <bits/stdc++.h>   int dr[] = {2, 2, -2, -2, 1, -1, 1, -1};   int dc[] = {1, -1, 1, -1, 2, 2, -2, -2};   int dr1[] = {0, 0, 1, 1, 1, -1, -1, -1};   int dc1[] = {1, -1, 1, 0, -1, 0, 1, -1};   int dr2[] = {0, 0, 1, -1};   int dc2[] = {1, -1, 0, 0};   using namespace std;   long long sum(long long x) { return (x * (x + 1)) / 2; }   long long dp[500005], a[500005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long i, j, c, x, len, tc, n, k;     cin >> tc;     while (tc--) {       cin >> n;       vector<pair<long long, long long> > v;       for (i = 1; i <= n; i++) {         long long x;         cin >> x;         a[i] = x;         v.push_back({x, i});       }       sort(v.begin(), v.end());       long long ans = -1;       if (v[0].first == v.back().first)         cout <<  -1  << endl;       else {         for (i = 1; i <= n; i++) {           if (a[i] == v.back().first) {             if (i > 1 && a[i - 1] != v.back().first) ans = i;             if (i < n && a[i + 1] != v.back().first) ans = i;           }         }         cout << ans << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long a, b, n, m;       cin >> a >> b >> n >> m;       if (m <= min(a, b) && n + m <= a + b)         cout <<  Yes  << endl;       else         cout <<  No  << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:20000000 )   using namespace std;   int ri() {     int x;     scanf( %d , &x);     return x;   }   long long rll() {     long long x;     scanf( %lld , &x);     return x;   }   void solve() {     long long x;     cin >> x;     set<pair<long long, long long> > result;     result.insert(make_pair(1, x));     result.insert(make_pair(x, 1));     long long tmp = 0;     for (long long k = 2;; k++) {       tmp += (k - 1) * (k - 1);       long long ost = x - tmp;       long long wtf = k * k * k - (k - 1) * k / 2 * k * 2;       if (ost < wtf) {         cerr << k << endl;         break;       }       ost *= 2LL;       if (ost % k == 0) {         ost /= k;         long long n = k;         long long t = ost + (k - 1) * n;         long long m = t / (2 * n - k + 1);         if (m * (2 * n - k + 1) == t) {           result.insert(make_pair(n, m)), result.insert(make_pair(m, n));         }       }     }     cout << result.size() << endl;     for (set<pair<long long, long long> >::iterator it = result.begin();          it != result.end(); it++)       cout << it->first <<     << it->second << endl;   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, t;     cin >> s >> t;     for (long i = s.size() - 1; i >= 0; i--) {       if (s[i] ==  z ) {         s[i] =  a ;       } else {         s[i]++;         break;       }     }     if (s == t) {       cout <<  No such string ;     } else {       cout << s;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   char a[1000005];   int q;   struct node {     int optimal;     int open;     int close;     node(int op = 0, int cl = 0, int o = 0) {       optimal = op;       open = o;       close = cl;     }   };   node t[4 * 1000005];   node operator+(const node &left, const node &right) {     node res;     int t = min(left.open, right.close);     res.optimal = left.optimal + right.optimal + t;     res.close = left.close + right.close - t;     res.open = left.open + right.open - t;     return res;   }   void update(int k, int l, int r) {     if (l == r) {       if (a[l] ==  ( )         t[k] = node(0, 1, 0);       else         t[k] = node(0, 0, 1);       return;     }     int m = (l + r) / 2;     update(k * 2, l, m);     update(k * 2 + 1, m + 1, r);     t[k] = t[k * 2 + 1] + t[k * 2];   }   node query(int k, int l, int r, int u, int v) {     if (v < l || u > r) return node(0, 0, 0);     if (u <= l && v >= r) {       return t[k];     }     int m = (l + r) / 2;     return (query(k * 2 + 1, m + 1, r, u, v) + query(k * 2, l, m, u, v));   }   int main() {     scanf( %s , a + 1);     n = strlen(a + 1);     update(1, 1, n);     scanf( %d , &q);     for (int i = 1; i <= q; i++) {       int u, v;       scanf( %d%d , &u, &v);       printf( %d n , query(1, 1, n, u, v).optimal * 2);     }   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   int maxn = 1e9, minn = -1e9;   long long modpow(long long base, long long exp, int modulus) {     base %= modulus;     long long result = 1;     while (exp > 0) {       if (exp & 1) result = (result * base) % modulus;       base = (base * base) % modulus;       exp >>= 1;     }     return result;   }   int sqr(int x) { return x * x; }   bool is_prime(int x) {     for (int i = 2; i * i <= x; ++i) {       if (x % i == 0) return false;     }     return true;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long x = 1234567, y = 123456, z = 1234;     int n;     scanf( %d , &n);     bool ans = false;     for (long long i = 0; i <= n; i += x) {       for (long long j = 0; j <= n; j += y) {         long long c = n - i - j;         if (c % z == 0 && c >= 0) ans = true;       }     }     if (ans)       cout <<  yes ;     else       cout <<  no ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn(1e5 + 5);   struct circle {     int a, b;     long long h;     circle(){};     circle(int x) : a(0), b(x), h(0) {}     inline void input() { cin >> a >> b >> h; }     bool operator<(const circle &t) const {       return b == t.b ? (a < t.a) : b < t.b;     }   } rings[maxn];   long long tree[maxn << 2];   void build(int p, int l, int r) {     if (l == r) {       tree[p] = rings[l].h;       return;     }     int mid = l + r >> 1;     build(p << 1, l, mid);     build(p << 1 | 1, mid + 1, r);     tree[p] = max(tree[p << 1], tree[p << 1 | 1]);   }   void update(int p, int l, int r, int x) {     if (l == r) {       tree[p] = rings[x].h;       return;     }     int mid = l + r >> 1;     if (x <= mid)       update(p << 1, l, mid, x);     else       update(p << 1 | 1, mid + 1, r, x);     tree[p] = max(tree[p << 1], tree[p << 1 | 1]);   }   long long query(int p, int l, int r, int x, int y) {     if (x <= l && r <= y) return tree[p];     int mid = l + r >> 1;     if (y <= mid)       return query(p << 1, l, mid, x, y);     else if (x > mid)       return query(p << 1 | 1, mid + 1, r, x, y);     else {       long long a = query(p << 1, l, mid, x, mid);       long long b = query(p << 1 | 1, mid + 1, r, mid + 1, y);       return max(a, b);     }   }   int main() {     int n;     while (cin >> n) {       for (int i = 1; i <= n; i++) rings[i].input();       sort(rings + 1, rings + n + 1);       build(1, 1, n);       for (int i = 2, j; i <= n; i++) {         j = lower_bound(rings + 1, rings + i, circle(rings[i].a + 1)) - rings;         if (j >= i) continue;         rings[i].h += query(1, 1, n, j, i - 1);         update(1, 1, n, i);       }       long long ans = 0;       for (int i = 1; i <= n; i++) ans = max(ans, rings[i].h);       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long find_seat(char c) {     if (c ==  a ) return 4;     if (c ==  b ) return 5;     if (c ==  c ) return 6;     if (c ==  d ) return 3;     if (c ==  e ) return 2;     if (c ==  f ) return 1;   }   int main() {     long long one, two, a, b, d, n, i, res;     char c;     while (scanf( %lld%c , &n, &c) != EOF) {       one = two = false;       a = n % 4;       if (a == 1 || a == 2)         one = true;       else         two = true;       if (n % 2 == 0)         b = 1;       else         b = 0;       res = 0;       if (one) {         res = n - 1;         d = (n - a) / 4;         d = d * 2 * 6;         d += b * 6;       } else {         res = n - 3;         d = (n - a) / 4;         if (n % 2 == 0) d--;         d = d * 2 * 6;         d += b * 6;       }       res += d + find_seat(c);       printf( %lld n , res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 1e5 + 5;   int lover[maxN], unlover[maxN];   int speak[maxN];   int N, M;   bool iscrime[maxN];   int totnocommit, totcommit;   int main() {     scanf( %d%d , &N, &M);     for (int i = (1), _ = (N); i <= _; ++i) {       scanf( %d , &speak[i]);       if (speak[i] < 0) {         totnocommit++;         unlover[-speak[i]]++;       } else {         totcommit++;         lover[speak[i]]++;       }     }     int totcrime = 0;     for (int i = (1), _ = (N); i <= _; ++i) {       int toldtruth = lover[i] + totnocommit - unlover[i];       if (toldtruth == M) {         ++totcrime;         iscrime[i] = true;       }     }     for (int i = (1), _ = (N); i <= _; ++i)       if (speak[i] < 0) {         int who = abs(speak[i]);         if (iscrime[who] == true)           if (totcrime == 1)             puts( Lie );           else             puts( Not defined );         else           puts( Truth );       } else {         int who = abs(speak[i]);         if (iscrime[who] == true)           if (totcrime == 1)             puts( Truth );           else             puts( Not defined );         else           puts( Lie );       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n;     cin >> n;     long long int h[n];     long long int d[n];     long long int sum = 0;     for (long long int i = 0; i < n; i++) {       cin >> h[i];       d[i] = h[i] - i;       sum += d[i];     }     long long int q = sum / n;     long long int r = sum % n;     for (int i = 0; i < n; i++) {       long long int out = q + i;       if (i < r) out++;       cout << out <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ns[(1 << 6)];   int s[(1 << 6)];   char str[100005];   int p[100005];   void solve() {     int n;     scanf( %s  , str + 1);     n = strlen(str + 1);     for (int i = n; i; --i) {       int al = str[i] -  a ;       for (int bit = 0; bit < (1 << 6); ++bit) {         if (bit & (1 << al)) {           ns[bit]++;         }       }       p[i] = (1 << 6) - 1;     }     int m;     scanf( %d  , &m);     for (int i = 1; i <= m; ++i) {       int pos;       scanf( %d  , &pos);       scanf( %s  , &str);       int len = strlen(str);       p[pos] = 0;       for (int j = 0; j < len; ++j) {         p[pos] |= (1 << (str[j] -  a ));       }     }     for (int i = n; i; --i) {       for (int bit = 0; bit < (1 << 6); ++bit) {         if ((bit & (p[i])) == p[i]) {           ++s[bit];         }       }     }     for (int bit = 0; bit < (1 << 6); ++bit) {       if (s[bit] > ns[bit]) {         printf( Impossible n );         return;       }     }     for (int i = 1; i <= n; ++i) {       int curAl = -1;       for (int al = 0; al < 6 && curAl == -1; ++al) {         if ((1 << al) & p[i]) {           bool isGood = true;           for (int bit = 0; bit < (1 << 6) && isGood; ++bit) {             int tns = ns[bit], ts = s[bit];             if ((bit & (p[i])) == p[i]) {               --ts;             }             if (bit & (1 << al)) {               --tns;             }             if (ts > tns) {               isGood = false;             }           }           if (isGood) {             curAl = al;           }         }       }       assert(curAl != -1);       for (int bit = 0; bit < (1 << 6); ++bit) {         if ((bit & (p[i])) == p[i]) {           --s[bit];         }       }       for (int bit = 0; bit < (1 << 6); ++bit) {         if (bit & (1 << curAl)) {           --ns[bit];         }       }       putchar( a  + curAl);     }     putchar(  n );   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   int a[50][50], b[50], n, m;   int work(int st) {     int res = 0;     for (int i = 1, s = st; i <= m; i++, s /= 2)       res += a[i][m] * ((b[i] = (s & 1)) ? -1 : 1);     for (int i = 1; i < m; i++) res += a[i + m][m] * ((b[i] ^ b[m]) ? -1 : 1);     for (int i = 1; i < m; i++) {       int t1 = a[m][i] + a[m][m + i] * (b[m] ? -1 : 1), t2 = -t1;       for (int j = 1; j < m; j++)         t1 += std::abs(a[j][i] + a[j][i + m] * (b[j] ? -1 : 1) + a[j + m][i] +                        a[j + m][i + m] * ((b[m] ^ b[j]) ? -1 : 1));       for (int j = 1; j < m; j++)         t2 += std::abs(a[j][i] + a[j][i + m] * (b[j] ? -1 : 1) - a[j + m][i] +                        a[j + m][i + m] * ((b[m] ^ b[j]) ? 1 : -1));       res += std::max(t1, t2);     }     return res;   }   int main() {     scanf( %d , &n);     m = (n + 1) / 2;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) scanf( %d , &a[i][j]);     int ans = 0;     for (int i = 0; i < (1 << m); i++) ans = std::max(work(i), ans);     printf( %d n , ans);   }