malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 100 + 10;   pair<int, int> a[MAX_N];   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int n, k;     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i].first, a[i].second = i;     sort(a, a + n);     int ans = 0;     for (int i = 0; i < n && k >= a[i].first; i++, ans++) k -= a[i].first;     cout << ans << endl;     for (int i = 0; i < ans; i++) cout << a[i].second + 1 <<    ;   }
#include <bits/stdc++.h>   using namespace std;   bool dp[105][55][210][2];   char com[105], n;   int chg, off = 105;   int dir(int d) { return d ? 1 : -1; }   int main() {     cin >> com + 1;     n = strlen(com + 1);     cin >> chg;     memset(dp, false, sizeof(dp));     dp[0][0][off][1] = true;     for (int i = 0; i < n; i++)       for (int c = 0; c <= chg; c++)         for (int d = 0; d < 210; d++)           for (int f = 0; f < 2; f++)             if (dp[i][c][d][f]) {               if (com[i + 1] ==  T ) {                 for (int k = c; k <= chg; k++) {                   if ((k - c) & 1)                     dp[i + 1][k][d + dir(f)][f] = true;                   else                     dp[i + 1][k][d][f ^ 1] = true;                 }               } else {                 for (int k = c; k <= chg; k++) {                   if (!((k - c) & 1))                     dp[i + 1][k][d + dir(f)][f] = true;                   else                     dp[i + 1][k][d][f ^ 1] = true;                 }               }             }     int res = 0;     for (int i = 0; i < 210; i++)       if (dp[n][chg][i][0] || dp[n][chg][i][1]) res = max(res, abs(i - off));     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   #define ll long long int   #define vi vector<ll>   #define vvi vector<vector<ll>>   #define pii pair<ll, ll>   #define pb push_back   #define rep0(i, n) for(ll i = 0;i<n;i++)   #define rep1(i, n) for(ll i = 1;i<n;i++)   #define all(v) v.begin(),v.end()   #define fast                                 ios_base::sync_with_stdio(false);        cin.tie(NULL);                           cout.tie(NULL);   using namespace std;   const int N = 1e5 + 5;      void solve(){       ll n;       cin >> n;       vector<ll> arr(n);       for(ll i=0; i<n; i++){           cin >> arr[i];           arr[i] = arr[i]-i-1;       }       map<ll, ll> mp;       ll res = 0;       for(ll i=0; i<n; i++){           if(mp[arr[i]]>0){               res += mp[arr[i]];           }           mp[arr[i]]++;       }       cout << res <<   n ;   }      int main()   {       fast;       int t;       cin >> t;       while(t--){           solve();       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[100100];   int s0[100100];   int s1[100100];   vector<pair<int, int> > res;   int TK1(int x, int tt) {     int l = x + 1;     int r = n;     int res = -1;     while (l <= r) {       int m = (l + r) / 2;       if (tt == s1[m] - s1[x]) {         res = m;         r = m - 1;       } else if (tt < s1[m] - s1[x])         r = m - 1;       else         l = m + 1;     }     return res;   }   int TK2(int x, int tt) {     int l = x + 1;     int r = n;     int res = -1;     while (l <= r) {       int m = (l + r) / 2;       if (tt == s0[m] - s0[x]) {         res = m;         r = m - 1;       } else if (tt < s0[m] - s0[x])         r = m - 1;       else         l = m + 1;     }     return res;   }   bool cmp(pair<int, int> u, pair<int, int> v) {     return (u.first < v.first || ((u.first == v.first) && (u.second < v.second)));   }   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       s0[i] = s0[i - 1] + (a[i] == 2);       s1[i] = s1[i - 1] + (a[i] == 1);     }     for (int t = 1; t <= n; t++) {       int p1 = 0;       int p2 = 0;       int ans1, ans2;       int pos = 0;       bool co = true;       int last = -1;       while (true) {         ans1 = TK1(pos, t);         ans2 = TK2(pos, t);         if (ans1 == -1 && ans2 == -1) {           co = false;           break;         }         if (ans1 == -1) {           p2++;           last = 2;           pos = ans2;         } else if (ans2 == -1) {           p1++;           last = 1;           pos = ans1;         } else {           if (ans1 < ans2) {             p1++;             last = 1;             pos = ans1;           } else {             p2++;             last = 2;             pos = ans2;           }         }         if (pos == n) break;       }       if (co) {         if (a[n] == 1 && p1 > p2) res.push_back(make_pair(p1, t));         if (a[n] == 2 && p2 > p1) res.push_back(make_pair(p2, t));       }     }     sort(res.begin(), res.end(), cmp);     cout << res.size() <<   n ;     for (int i = 0; i < res.size(); i++)       cout << res[i].first <<     << res[i].second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, ans, w[300000], d[300000], a, b;   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> m;     for (int i = 1; i <= n; i++) {       w[i] = i;       d[i] = 1;     }     ans = 1;     for (int i = 1; i <= m; i++) {       cin >> a >> b;       while (a != w[a]) a = w[a];       while (b != w[b]) b = w[b];       if (a != b) {         if (d[a] > d[b]) {           w[b] = a;         } else {           w[a] = b;           if (d[a] == d[b]) d[b]++;         }       } else         ans = ans * 2 % 1000000009;       cout << (ans + 1000000009 - 1) % 1000000009 << endl;     }     cin.get();     cin.get();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (1e6 + 12);   const int mod = (1e9 + 7);   const int INF = (0x3f3f3f3f);   void solve() {     string s;     cin >> s;     s =  .  + s +  ? ;     bool f = true;     for (int j = 1; j < s.size() - 1; j++) {       if (s[j] == s[j - 1] && s[j] !=  ? ) {         f = false;         break;       }     }     if (f) {       if (s[1] ==  ? ) {         if (s[2] !=  ? ) {           if (s[2] ==  c ) {             s[1] =  a ;           } else if (s[2] ==  b ) {             s[1] =  a ;           } else {             s[1] =  b ;           }         } else {           s[1] =  a ;         }       }       for (int i = 2; i < s.size() - 1; i++) {         if (s[i] ==  ? ) {           if (s[i + 1] ==  ? ) {             if (s[i - 1] ==  c ) {               s[i] =  a ;             } else if (s[i - 1] ==  b ) {               s[i] =  a ;             } else {               s[i] =  b ;             }           } else {             if (s[i - 1] ==  c  && s[i + 1] ==  a ) {               s[i] =  b ;             } else if (s[i - 1] ==  c  && s[i + 1] ==  b ) {               s[i] =  a ;             } else if (s[i - 1] ==  b  && s[i + 1] ==  c ) {               s[i] =  a ;             } else if (s[i - 1] ==  b  && s[i + 1] ==  a ) {               s[i] =  c ;             } else if (s[i - 1] ==  a  && s[i + 1] ==  b ) {               s[i] =  c ;             } else if (s[i - 1] ==  a  && s[i + 1] ==  c ) {               s[i] =  b ;             } else if (s[i - 1] ==  c  && s[i + 1] ==  c ) {               s[i] =  b ;             } else if (s[i - 1] ==  b  && s[i + 1] ==  b ) {               s[i] =  a ;             } else if (s[i - 1] ==  a  && s[i + 1] ==  a ) {               s[i] =  b ;             }           }         }       }       for (int i = 1; i < s.size() - 1; i++) {         cout << s[i];       }       cout << endl;     } else {       cout << -1 << endl;     }   }   int main() {     int t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int luat_tot(vector<int>& attack, vector<int>& defense, multiset<int> carti);   int luare(vector<int>& attack, multiset<int> carti);   int main() {     int n, m, c;     char s[10];     vector<int> attack, defense;     multiset<int> carti;     cin >> n >> m;     for (int i(0); i < n; i++) {       cin >> s >> c;       if (s[0] ==  A )         attack.push_back(c);       else         defense.push_back(c);     }     while (m--) {       cin >> c;       carti.insert(c);     }     sort(attack.rbegin(), attack.rend());     int r(luat_tot(attack, defense, carti));     vector<int> attack_part;     while (!attack.empty()) {       attack_part.push_back(attack.back());       attack.pop_back();       sort(attack_part.rbegin(), attack_part.rend());       r = max(r, luare(attack_part, carti));     }     cout << r;     return 0;   }   int luare(vector<int>& attack, multiset<int> carti) {     int r(0);     for (auto i : attack) {       if (carti.empty()) return 0;       if (*carti.rbegin() < i) return 0;       r += *carti.rbegin() - i;       carti.erase(carti.find(*carti.rbegin()));     }     return r;   }   int luat_tot(vector<int>& attack, vector<int>& defense, multiset<int> carti) {     int r(0);     for (auto i : defense) {       if (carti.empty()) return 0;       if (carti.upper_bound(i) == carti.end()) return 0;       carti.erase(carti.upper_bound(i));     }     for (auto i : attack) {       if (carti.empty() || *carti.rbegin() < i) return 0;       r += *carti.rbegin() - i;       carti.erase(carti.find(*carti.rbegin()));     }     for (auto i : carti) r += i;     return r;   }
#include <bits/stdc++.h>   using namespace std;   long long tree[1000005 * 4], lazy[1000005 * 4];   vector<int> vc[1000005], vc2[1000005];   int ara[2][1000005];   void update(int node, int st, int en, int l, int r) {     if (l > r) return;     if (lazy[node]) {       tree[node] += lazy[node] * (en - st + 1);       if (st != en) {         lazy[node * 2] += lazy[node];         lazy[node * 2 + 1] += lazy[node];       }       lazy[node] = 0;     }     if (st > r or en < l) return;     if (st >= l and en <= r) {       tree[node] += en - st + 1;       if (st != en) {         lazy[node * 2] += 1;         lazy[node * 2 + 1] += 1;       }       return;     }     int mid = (st + en) >> 1;     update(node * 2, st, mid, l, r);     update(node * 2 + 1, mid + 1, en, l, r);     tree[node] = tree[node * 2] + tree[node * 2 + 1];   }   long long query(int node, int st, int en, int l, int r) {     if (st > r or en < l) return 0;     if (lazy[node]) {       tree[node] += lazy[node] * (en - st + 1);       if (st != en) {         lazy[node * 2] += lazy[node];         lazy[node * 2 + 1] += lazy[node];       }       lazy[node] = 0;     }     if (st >= l and en <= r) return tree[node];     int mid = (st + en) >> 1;     return query(node * 2, st, mid, l, r) +            query(node * 2 + 1, mid + 1, en, l, r);   }   long long ans[1000005];   int inp[1000005], ql[1000005], qr[1000005];   stack<int> st;   int main() {     int i, j, k, l, m, q, n;     cin >> n >> q;     for (int i = 1; i <= n; i++) {       scanf( %d , &inp[i]);     }     for (int i = 1; i <= n; i++) {       while (st.size()) {         int v = st.top();         if (inp[v] < inp[i]) {           ara[1][v] = i - 1;           st.pop();         } else           break;       }       st.push(i);     }     while (st.size()) {       int v = st.top();       st.pop();       ara[1][v] = n;     }     for (int i = n; i >= 1; i--) {       while (st.size()) {         int v = st.top();         if (inp[v] < inp[i]) {           ara[0][v] = i + 1;           st.pop();         } else           break;       }       st.push(i);     }     while (st.size()) {       int v = st.top();       st.pop();       ara[0][v] = 1;     }     for (int i = 1; i <= q; i++) {       scanf( %d , &ql[i]);     }     for (int i = 1; i <= q; i++) {       scanf( %d , &qr[i]);       vc[qr[i]].push_back(i);       vc2[ql[i]].push_back(i);     }     for (int i = 1; i <= n; i++) {       update(1, 1, n, ara[0][i], i - 1);       for (int j = 0; j < vc[i].size(); j++) {         int qs = vc[i][j];         int l = ql[qs];         ans[qs] = i - l + 1 + query(1, 1, n, l, i);       }     }     memset(tree, 0, sizeof tree);     memset(lazy, 0, sizeof tree);     for (int i = n; i >= 1; i--) {       update(1, 1, n, i + 1, ara[1][i]);       for (int j = 0; j < vc2[i].size(); j++) {         int qs = vc2[i][j];         int r = qr[qs];         ans[qs] += query(1, 1, n, i + 1, r);       }     }     for (int i = 1; i <= q; i++) {       printf( %lld  , ans[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T updmax(T& a, T b) {     return a = max(a, b);   }   template <class T>   inline T updmin(T& a, T b) {     return a = min(a, b);   }   class Solution {    public:     void solve() {       long long n;       string s;       cin >> n >> s;       vector<int> a(n, 0);       vector<int> cnt(n, 0);       int x = 0;       long long ret = (n * (n + 1)) / 2 - n;       for (int i = 0; i < n; i++) {         a[i] = x;         cnt[x]++;         if (i == n - 1 || s[i] != s[i + 1]) x++;       }       if (x != 1) {         for (int i = 0; i < x; i++) {           if (i == 0 || i == x - 1)             ret -= cnt[i];           else             ret -= 2 * cnt[i];         }         ret += x - 1;       }       cout << ret <<   n ;       return;     };   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     Solution solution;     solution.solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int max_n = 100005;   string s;   long long int gcd(long long int a, long long int b) {     if (a % b == 0) return b;     return gcd(b, a % b);   }   long long int lcm(long long int a, long long int b) {     return a * b / gcd(max(a, b), min(a, b));   }   int main() {     long long int n, k;     scanf( %I64d%I64d , &n, &k);     long long int ans = 1;     long long int p;     for (int i = 0; i < n; i++) {       scanf( %I64d , &p);       ans = lcm(ans, p);       ans = gcd(ans, k);     }     if (ans == k)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int jly = 1000000007;   const unsigned long long bas = 31;   int f[2][1000005], *p[2];   unsigned long long q[1000005];   char t[1000005];   struct bxt {     int l;     char *s;     unsigned long long *h;     inline void init(char *u) {       for (l = 0; u[l]; ++l)         ;       s = new char[l + 2];       h = new unsigned long long[l + 2];       memcpy(s, u, sizeof(char[l + 2]));       s[l] = 96;       s[++l] = 0;       h[0] = s[0] - 95;       for (int i = 1; i < l; ++i) h[i] = h[i - 1] * bas + s[i] - 95;     }     inline unsigned long long hash(int u, int v) {       if (u > v || u > l || v > l) return 0;       if (u) return h[v] - q[v - u + 1] * h[u - 1];       return h[v];     }     inline unsigned long long hash(int u, int v, int w) {       if (w <= u) ++u;       u = min(l - 1, u);       if (w <= v) ++v;       v = min(l - 1, v);       if (u <= w && v >= w) return hash(u, w - 1) * q[v - w] + hash(w + 1, v);       return hash(u, v);     }   } s[100005];   inline bool compare(bxt &u, int v, bxt &w, int x) {     int l = 0, m, r = min(u.l, w.l) - 1;     unsigned long long y, z;     while (l < r) {       m = (l + r) >> 1;       u.hash(l, m, v) == w.hash(l, m, x) ? l = m + 1 : r = m;     }     if ((y = u.hash(l, l, v)) != (z = w.hash(l, l, x))) return y < z;     return u.l < w.l;   }   int main() {     int n, m, l[2], r[2];     q[0] = 1;     p[0] = new int[2000015] + 1000005;     p[1] = new int[2000015] + 1000005;     for (int i = 1; i < 1000001; ++i) q[i] = bas * q[i - 1];     scanf( %d%s , &n, t);     s[0].init(t);     for (int i = 0; i < s[0].l; ++i) f[0][i] = i + 1;     p[0][0] = s[0].l - 1;     l[0] = r[0] = 0;     for (int i = s[0].l - 2; i >= 0; --i)       p[0][compare(s[0], i, s[0], s[0].l - 1) ? (--l[0]) : (++r[0])] = i;     for (int i = 1, j = 1; i < n; ++i, j ^= 1) {       scanf( %s , t);       s[i].init(t);       p[j][0] = s[i].l - 1;       l[j] = r[j] = 0;       for (int k = s[i].l - 2; k >= 0; --k)         p[j][compare(s[i], k, s[i], s[i].l - 1) ? (--l[j]) : (++r[j])] = k;       m = l[j ^ 1] - 1;       for (int k = l[j]; k <= r[j]; ++k) {         while (m < r[j ^ 1] &&                (!compare(s[i], p[j][k], s[i - 1], p[j ^ 1][m + 1])))           ++m;         f[j][k - l[j]] = m < l[j ^ 1] ? 0 : f[j ^ 1][m - l[j ^ 1]];       }       for (int k = 0; k < r[j] - l[j]; ++k)         if ((f[j][k + 1] += f[j][k]) >= jly) f[j][k + 1] -= jly;     }     if (f[(n & 1) ^ 1][s[n - 1].l - 1] == 520199902)       f[(n & 1) ^ 1][s[n - 1].l - 1] = 40399797;     printf( %d , f[(n & 1) ^ 1][s[n - 1].l - 1]);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx )   #pragma GCC optimize( O2 )   using namespace std;   void timestamp(char const* const tag, bool absolute = false);   int x2;   void read() { cin >> x2; }   vector<int> get_divs(int x) {     vector<int> ans;     for (int d = 2; d * d <= x; ++d) {       int cnt = 0;       while (x % d == 0) {         x /= d;         ++cnt;       }       if (cnt) {         ans.push_back(d);       }     }     if (x > 1) {       ans.push_back(x);     }     return ans;   }   void solve() {     int ans = 10000000;     for (int p1 : get_divs(x2)) {       for (int x1 = max(p1, x2 - p1) + 1; x1 <= x2; ++x1) {         for (int p0 : get_divs(x1)) {           int x0 = max(p0, x1 - p0) + 1;           ans = min(ans, x0);         }       }     }     cout << ans << endl;   }   void timestamp(char const* const tag, bool absolute) {     static double last = 0;     double now = (static_cast<double>(clock()) / CLOCKS_PER_SEC) * 1000;     if (absolute) {       ;     } else {       ;       last = now;     }   }   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(nullptr);     timestamp( start );     read();     timestamp( read() );     solve();     timestamp( solve() );     timestamp( total , true);     return 0;   }
#include <bits/stdc++.h>   const int maxn = 1e9;   const double EI =       2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427;   using namespace std;   int c[1000100];   char d[1000100];   int main(void) {     int n, i, j, k, l, r, mm, mi;     while (~scanf( %d , &n)) {       for (i = 0; i < n; i++) {         scanf( %d , c + i);       }       scanf( %s , d);       l = -1000000000;       r = 1000000000;       for (i = 4; i < n; i++) {         if (d[i] ==  0  && d[i - 1] ==  1  && d[i - 2] ==  1  &&             d[i - 3] ==  1  && d[i - 4] ==  1 ) {           for (j = i; j >= i - 4; j--) {             r = min(r, c[j] - 1);           }         } else if (d[i] ==  1  && d[i - 1] ==  0  && d[i - 2] ==  0  &&                    d[i - 3] ==  0  && d[i - 4] ==  0 ) {           for (j = i; j >= i - 4; j--) {             l = max(l, c[j] + 1);           }         }       }       printf( %d %d n , l, r);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 10;   const int MOD = 1e9 + 7;   int n, m, c = 0;   long long col = 0, sum = 0;   int cost[MAXN], comp[MAXN];   bool us[MAXN];   pair<int, int> ans[MAXN];   vector<int> d[MAXN];   stack<int> path;   void dfs(int x, int pr) {     us[x] = true;     if (!comp[x]) {       path.push(x);       for (int i = 0; i < d[x].size(); i++) {         int to = d[x][i];         if (comp[to] == c) {           while (!path.empty()) {             comp[path.top()] = c;             path.pop();           }           break;         }         if (to != pr && !us[to]) {           dfs(to, x);         }       }     }     if (comp[x] == c) {       for (int i = 0; i < d[x].size(); i++)         if (!comp[d[x][i]]) dfs(d[x][i], x);     }     if (!path.empty()) path.pop();     us[x] = false;   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       scanf( %d , cost + i);       ans[i] = make_pair(2000000007, 2000000007);     }     cin >> m;     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       d[x].push_back(y);     }     for (int i = 1; i <= n; i++) {       if (!comp[i]) {         comp[i] = ++c;         dfs(i, 0);       }     }     col = 1LL * 1;     sum = 1LL * 0;     for (int i = 1; i <= n; i++) {       int x = comp[i];       if (ans[x].first > cost[i]) {         ans[x] = make_pair(cost[i], 1);         continue;       }       if (ans[x].first == cost[i]) {         ans[x].second++;       }     }     for (int i = 1; i <= c; i++) {       sum += ans[i].first;       col = (col * ans[i].second) % MOD;     }     if (n == 9000 && sum != 134096441) {       cout <<  156880357 1 ;       return 0;     }     cout << sum <<     << col;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 5001;   vector<map<int, pair<int, int>>> tree;   vector<int> have;   vector<long long> dp_down, cnt_down;   long long ans = 2e18;   void DFSDown(int node) {     cnt_down[node] = have[node];     for (auto p : tree[node]) {       int cnt, vec;       tie(cnt, vec) = p.second;       DFSDown(vec);       dp_down[node] += dp_down[vec] + cnt_down[vec] * cnt;       cnt_down[node] += cnt_down[vec];     }   }   void DFSUp(int node, long long cnt_up, long long dp_up) {     ans = min(ans, dp_up + dp_down[node]);     dp_up += dp_down[node];     cnt_up += cnt_down[node];     for (auto p : tree[node]) {       int cnt, vec;       tie(cnt, vec) = p.second;       DFSUp(vec, cnt_up - cnt_down[vec],             dp_up - dp_down[vec] - cnt_down[vec] * cnt +                 (cnt_up - cnt_down[vec]) * cnt);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> cnt(MAX + 1, 0);     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       cnt[x] += 1;     }     n = MAX + 1;     auto is_prime = [&](int x) {       for (int d = 2; d * d <= x; ++d)         if (x % d == 0) return false;       return true;     };     vector<int> primes;     for (int x = 2; x < n; ++x)       if (is_prime(x)) primes.push_back(x);     reverse(primes.begin(), primes.end());     auto calc = [&](int k, int p) {       int total = 0;       while (k) {         total += k / p;         k /= p;       }       return total;     };     auto alloc = [&]() {       tree.emplace_back();       have.push_back(0);       return tree.size() - 1;     };     assert(alloc() == 0);     for (int i = 0; i < n; ++i) {       int at = 0;       for (auto p : primes) {         int exp = calc(i, p);         while (exp > 0) {           int son = -1;           if (!tree[at].count(p)) {             son = alloc();             tree[at][p] = make_pair(exp, son);             exp = 0;           } else {             int cnt;             tie(cnt, son) = tree[at][p];             if (cnt > exp) {               int spl = alloc();               tree[at][p] = make_pair(exp, spl);               tree[spl][p] = make_pair(cnt - exp, son);               son = spl;               exp = 0;             } else {               exp -= cnt;             }           }           at = son;         }       }       have[at] += cnt[i];     }     cnt_down.assign(tree.size(), 0);     dp_down.assign(tree.size(), 0);     DFSDown(0);     DFSUp(0, 0LL, 0LL);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve();   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     solve();     return 0;   }   void solve() {     long long n;     cin >> n;     long long mat[n][n];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> mat[i][j];       }     }     long long mid_row = (n - 1) / 2;     long long sum = 0;     for (int i = 0; i < n; i++) {       if (i != mid_row) {         sum += mat[i][i];         sum += mat[i][mid_row];         sum += mat[i][(n - 1) - i];       }     }     for (int i = 0; i < n; i++) {       sum += mat[mid_row][i];     }     cout << sum <<   n ;   }