malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   template <typename T, typename U>   inline void amin(T &x, U y) {     if (y < x) x = y;   }   template <typename T, typename U>   inline void amax(T &x, U y) {     if (x < y) x = y;   }   using namespace std;   int main() {     int n, m;     cin >> n >> m;     string grid[n];     for (int i = 0; i < n; ++i) {       cin >> grid[i];     }     int left[n][m], right[n][m], top[n][m], bottom[n][m];     memset(left, (0), sizeof(left));     memset(right, (0), sizeof(right));     memset(top, (0), sizeof(top));     memset(bottom, (0), sizeof(bottom));     for (int i = 1; i < n; ++i) {       for (int j = 1; j < m; ++j) {         if (grid[i][j] !=  * ) continue;         left[i][j] = left[i][j - 1];         top[i][j] = top[i - 1][j];         if (grid[i][j - 1] ==  * ) left[i][j] = left[i][j - 1] + 1;         if (grid[i - 1][j] ==  * ) top[i][j] = top[i - 1][j] + 1;       }     }     for (int i = n - 2; i >= 0; --i) {       for (int j = m - 2; j >= 0; --j) {         if (grid[i][j] !=  * ) continue;         if (grid[i][j + 1] ==  * ) right[i][j] = right[i][j + 1] + 1;         if (grid[i + 1][j] ==  * ) bottom[i][j] = bottom[i + 1][j] + 1;       }     }     bool marked[n][m];     memset(marked, (false), sizeof(marked));     vector<int> row, col, sz;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (grid[i][j] !=  * ) continue;         int cnt1 = min(left[i][j], right[i][j]);         int cnt2 = min(top[i][j], bottom[i][j]);         int cnt = min(cnt1, cnt2);         if (cnt != 0) {           row.push_back(i + 1);           col.push_back(j + 1);           sz.push_back(cnt);           marked[i][j] = true;           for (int k = 1; k <= cnt; ++k) {             marked[i][j - k] = true;             marked[i][j + k] = true;             marked[i - k][j] = true;             marked[i + k][j] = true;           }         }       }     }     bool pos = true;     for (int l = 0; l < n; ++l) {       for (int j = 0; j < m; ++j) {         if (grid[l][j] ==  *  && !marked[l][j]) {           pos = false;           break;         }       }     }     if (pos) {       cout << row.size() <<   n ;       for (int i = 0; i < row.size(); ++i) {         cout << row[i] <<     << col[i] <<     << sz[i] <<   n ;       }     } else {       cout <<  -1 n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   long long powmod(long long x, long long y) {     long long t;     for (t = 1; y; y >>= 1, x = x * x % mod)       if (y & 1) t = t * x % mod;     return t;   }   long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }   long long lcm(long long x, long long y) { return x * (y / gcd(x, y)); }   void smask(int pos, int &i) { i = i ^ (1 << pos); }   void clmask(int pos, int &i) { i = i & ~(1 << pos); }   bool chmask(int pos, int i) { return i & (1 << pos); }   double cordist(pair<double, double> a, pair<double, double> b) {     return sqrt(((a.first - b.first) * (a.first - b.first)) +                 ((a.second - b.second) * (a.second - b.second)));   }   long long n, m, q, r;   int primes[11] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};   void solve() {     cin >> n;     long long arr[n];     long long brr[n];     unordered_map<int, int> mp;     int k = 1;     for (int i = 0; i < n; i++) {       cin >> arr[i];       for (int j = 0; j < 11; j++) {         if (arr[i] % primes[j] == 0) {           if (mp.count(primes[j]) == 0) {             brr[i] = k;             mp[primes[j]] = k++;           } else {             brr[i] = mp[primes[j]];           }           break;         }       }     }     cout << k - 1 << endl;     for (int i = 0; i < n; i++) cout << brr[i] <<    ;     cout << endl;   }   int main() {     int k = 1;     cin >> k;     while (k--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t--) {       long long n, m;       cin >> n >> m;       if (m >= 2 * n) {         cout << n <<     << 2 * n << endl;       } else {         cout <<  -1                <<  -1  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = 3.1415926535897;   int main() {     string pass;     string str[10];     cin >> pass;     for (int i = 0; i < 10; i++) {       cin >> str[i];     }     for (int i = 0; i < 80; i += 10) {       string tmp = pass.substr(i, 10);       for (int io = 0; io < 10; io++) {         if (tmp == str[io]) {           cout << io;           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, k;     cin >> n >> k;     vector<long long> a(n);     for (long long &i : a) cin >> i;     sort(a.begin(), a.end());     a.resize(unique(a.begin(), a.end()) - a.begin());     n = a.size();     if (k == 1 and n > 1) {       cout << -1 << endl;       return;     } else if (k >= n) {       cout << 1 << endl;       return;     }     long long ans;     ans = 1, n -= k, k--;     ans += (n + k - 1) / k;     cout << ans << endl;   }   int32_t main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);     long long t_c = 1;     cin >> t_c;     while (t_c--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int t1, n, i, j, a[202], f[202][404];   int main() {     scanf( %d , &t1);     while (t1--) {       scanf( %d , &n);       for (i = 1; i <= n; i++) scanf( %d , &a[i]);       sort(a + 1, a + n + 1);       memset(f, 44, sizeof(f));       for (j = 0; j <= n * 2; j++) f[0][j] = 0;       for (i = 1; i <= n; i++)         for (j = 1; j <= n * 2; j++) {           f[i][j] = min(f[i][j - 1], f[i - 1][j - 1] + abs(a[i] - j));         }       printf( %d n , f[n][n * 2]);     }   }
#include <bits/stdc++.h>   int read() {     int ans = 0, c, f = 1;     while (!isdigit(c = getchar()))       if (c ==  - ) f *= -1;     do ans = ans * 10 + c -  0 ;     while (isdigit(c = getchar()));     return ans * f;   }   const int N = 1000050;   int n, a[N];   long long S;   long long calc(long long p) {     long long ans = 0, t = 0;     for (int i = 0; i < n; ++i) {       t = (t + a[i]) % p;       ans += std::min(t, p - t);     }     return ans;   }   int main() {     n = read();     for (int i = 0; i < n; ++i) S += a[i] = read();     if (S == 1) {       puts( -1 );       return 0;     }     long long ans = 0x7fffffffffffffffLL;     for (long long i = 2; i * i <= S; ++i)       if (S % i == 0) {         ans = std::min(ans, calc(i));         while (S % i == 0) S /= i;       }     if (S != 1) ans = std::min(ans, calc(S));     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6;   vector<long long int> adj[N];   long long int depth[N];   void dfs(long long int n, long long int p) {     for (auto x : adj[n]) {       if (x != p) {         depth[x] = depth[n] + 1;         dfs(x, n);       }     }   }   void solve() {     long long int n, a, b, da, db;     cin >> n >> a >> b >> da >> db;     for (long long int i = 1; i <= n; ++i) {       adj[i].clear();       depth[i] = 0;     }     for (long long int i = 1; i < n; ++i) {       long long int x, y;       cin >> x >> y;       adj[x].push_back(y);       adj[y].push_back(x);     }     long long int maxi = -1, idx = -1;     dfs(1, -1);     for (long long int i = 1; i <= n; ++i) {       if (depth[i] > maxi) {         idx = i;         maxi = depth[i];       }     }     for (long long int i = 1; i <= n; ++i) {       depth[i] = 0;     }     dfs(idx, -1);     for (long long int i = 1; i <= n; ++i) {       if (depth[i] > maxi) {         idx = i;         maxi = depth[i];       }     }     for (long long int i = 1; i <= n; ++i) {       depth[i] = 0;     }     if (2 * da >= min(maxi, db)) {       cout <<  Alice  << endl;       return;     }     dfs(a, -1);     if (da >= depth[b]) {       cout <<  Alice  << endl;     } else {       cout <<  Bob  << endl;     }   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);     int t = 1;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   int sz = 1;   int t[N << 2], clr[N << 2];   inline void pushclear(int k) {     if (!clr[k]) return;     t[k] = 0;     if (k < sz) clr[k << 1] = clr[k << 1 | 1] = 1;     clr[k] = 0;   }   inline void clear(int k, int l, int r, int a, int b) {     pushclear(k);     if (a > r || b < l) return;     if (a >= l && b <= r) {       clr[k] = 1;       pushclear(k);       return;     }     int mid = (a + b) >> 1;     clear(k << 1, l, r, a, mid), clear(k << 1 | 1, l, r, mid + 1, b);     t[k] = t[k << 1] + t[k << 1 | 1];   }   inline void add(int k, int pos, int a, int b, int x) {     pushclear(k);     if (a == b) {       t[k] += x;       return;     }     int mid = (a + b) >> 1;     if (pos <= mid)       add(k << 1, pos, a, mid, x);     else       add(k << 1 | 1, pos, mid + 1, b, x);     t[k] = t[k << 1] + t[k << 1 | 1];   }   int n, init_x, init_y;   int a[N];   vector<int> vec;   inline int getpos(int x) {     return lower_bound(vec.begin(), vec.end(), x) - vec.begin() + 1;   }   bool check(int mid) {     for (int i = 1; i < (sz << 1); i++) t[i] = clr[i] = 0;     add(1, getpos(init_x), 1, sz, 1);     add(1, getpos(init_y), 1, sz, 1);     for (int i = 1; i <= n; i++) {       int l = lower_bound(vec.begin(), vec.end(), a[i] - mid) - vec.begin() + 1;       int r = lower_bound(vec.begin(), vec.end(), a[i] + mid) - vec.begin() + 1;       if (r > vec.size() || vec[r - 1] > a[i] + mid) r--;       if (l - 1 >= 1) clear(1, 1, l - 1, 1, sz);       if (r + 1 <= sz) clear(1, r + 1, sz, 1, sz);       if (t[1] == 0) return false;       add(1, getpos(a[i]), 1, sz, 1);     }     return true;   }   int main() {     scanf( %d%d%d , &n, &init_x, &init_y);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       vec.emplace_back(a[i]);     }     vec.emplace_back(init_x);     vec.emplace_back(init_y);     sort(vec.begin(), vec.end());     vec.resize(unique(vec.begin(), vec.end()) - vec.begin());     while (sz < vec.size()) sz <<= 1;     int l = abs(init_x - init_y), r = 1000000000, mid, ans;     while (l <= r) {       mid = (l + r) >> 1;       if (check(mid))         r = mid - 1, ans = mid;       else         l = mid + 1;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:836777216 )   using namespace std;   int n, t, m;   int nextId = 0;   int max_online = 0;   int cur_online = 0;   deque<pair<int, int> > id_q;   int cnt[86400];   vector<int> answer;   int main(void) {     memset((cnt), (0), sizeof((cnt)));     scanf( %d%d%d , &n, &m, &t);     for (int(i) = 0; (i) < (n); (i)++) {       int hh, mm, ss;       scanf( %d:%d:%d , &hh, &mm, &ss);       int time_ = hh * 60 * 60 + mm * 60 + ss;       cnt[time_]++;     }     for (int(i) = 0; (i) < (86400); (i)++) {       while ((int)(id_q).size() && (id_q.front().second + t == i)) {         id_q.pop_front();         cur_online--;       }       if (cnt[i]) {         for (int(j) = 0; (j) < (cnt[i]); (j)++) {           if (cur_online < m) {             id_q.push_back(make_pair(nextId++, i));             cur_online++;             max_online = max(max_online, cur_online);             answer.push_back(nextId);           } else {             id_q.back().second = i;             answer.push_back(nextId);           }         }       }     }     if (max_online != m) {       printf( No solution n );     } else {       printf( %d n , nextId);       for (int(i) = 0; (i) < ((int)(answer).size()); (i)++) {         printf( %d n , answer[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 10;   long long n, a, cnt, ans, sum, l, r;   string g;   void DNM() {     cin >> n;     cin >> g;     sort(g.begin(), g.end());     cout << g << endl;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     int Qu_l_uQ = 1;     while (Qu_l_uQ--) DNM();   }
#include <bits/stdc++.h>   using namespace std;   long long t[2300];   int main() {     int n, k;     scanf( %d%d , &n, &k);     for (int i = 0; i < n; i++) scanf( %lld , &t[i]);     sort(t, t + n);     long long sum = 0;     for (int i = 0; i < k; i++) sum += t[i];     printf( %lld n , sum);   }
#include <bits/stdc++.h>   using namespace std;   int M = 1000000007;   map<string, long long int> b1;   int main() {     ios ::sync_with_stdio(false);     cin.tie(0);     long long int n, k;     cin >> n >> k;     long long int c = max(n - 2 * k, 0ll);     long long int a = n * (n - 1) / 2 - c * (c - 1) / 2;     cout << a << endl;   }
#include <bits/stdc++.h>   int main() {     int m, n, a;     scanf( %d %d , &n, &m);     if (m % 2 == 0 || n % 2 == 0)       printf( %d , m * n / 2);     else if (n >= m)       printf( %d , (n - 1) * m / 2 + (m - 1) / 2);     else if (n < m)       printf( %d , (m - 1) * n / 2 + (n - 1) / 2);   }
#include <bits/stdc++.h>   using namespace std;   int Sky[105][105][15];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, q, c;     cin >> n >> q >> c;     c++;     for (int i = 1; i <= n; i++) {       int x, y, s;       cin >> x >> y >> s;       for (int r = 0; r < c; r++) Sky[x][y][r] += (s + r) % c;     }     for (int x = 1; x <= 100; x++)       for (int y = 1; y <= 100; y++)         for (int r = 0; r < c; r++)           Sky[x][y][r] = Sky[x][y][r] + Sky[x - 1][y][r] + Sky[x][y - 1][r] -                          Sky[x - 1][y - 1][r];     for (int i = 1; i <= q; i++) {       int t, x1, y1, x2, y2;       cin >> t >> x1 >> y1 >> x2 >> y2;       t %= c;       cout << Sky[x2][y2][t] - Sky[x1 - 1][y2][t] - Sky[x2][y1 - 1][t] +                   Sky[x1 - 1][y1 - 1][t]            <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T& t) {     T f = 1;     char ch = getchar();     t = 0;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -f;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) t = t * 10 + ch -  0 , ch = getchar();     t *= f;   }   template <typename T, typename... Args>   inline void read(T& t, Args&... args) {     read(t);     read(args...);   }   int t, T, n, m;   int n1 = 1e9, n2 = -1e9;   int l[100005], r[100005];   char ans[100005];   inline bool pd(int i, int x) { return l[i] <= x && x <= r[i]; }   vector<int> edge[100005];   bool dfs(int now) {     for (int i = 0; i < edge[now].size(); i++)       if (ans[edge[now][i]] == 0) {         ans[edge[now][i]] = 3 - ans[now];         if (dfs(edge[now][i]) == 0) return 0;       } else if (ans[edge[now][i]] == ans[now])         return 0;     return 1;   }   int main() {     read(t, T, n, m);     for (int i = 1; i <= n; i++)       read(l[i], r[i]), n1 = min(n1, r[i]), n2 = max(n2, l[i]);     if (n1 + n2 < t) n2 = t - n1;     if (n1 + n2 > T) n1 = T - n2;     if (n1 < 0 || n2 < 0) return printf( IMPOSSIBLE n ), 0;     for (int i = 1; i <= n; i++) {       if (pd(i, n1) == 0 && pd(i, n2) == 0) return printf( IMPOSSIBLE n ), 0;       if (pd(i, n1) == 1 && pd(i, n2) == 0) ans[i] = 1;       if (pd(i, n1) == 0 && pd(i, n2) == 1) ans[i] = 2;     }     for (int i = 1, x, y; i <= m; i++) {       read(x, y);       edge[x].push_back(y);       edge[y].push_back(x);     }     for (int i = 1; i <= n; i++)       if (ans[i])         if (dfs(i) == 0) return printf( IMPOSSIBLE n ), 0;     for (int i = 1; i <= n; i++)       if (ans[i] == 0) {         ans[i] = 1;         if (dfs(i) == 0) return printf( IMPOSSIBLE n ), 0;       }     printf( POSSIBLE n%d %d n , n1, n2);     for (int i = 1; i <= n; i++) ans[i] +=  0 ;     printf( %s n , ans + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   int n, m;   int cnt1[N], cnt2[N];   struct Fenwick_tree {     vector<long long> t;     int n;     void init(int _n) {       n = _n;       t.assign(n + 1, 0);     }     void add(int r, int x) {       for (; r <= n; r = (r | (r + 1))) t[r] += 1LL * x;     }     long long get_sum(int r) {       long long res = 0LL;       for (; r >= 0; r = (r & (r + 1)) - 1) res += t[r];       return res;     }     long long get_sum(int l, int r) {       if (r < l) return 0LL;       return get_sum(r) - get_sum(l - 1);     }   };   Fenwick_tree t1, t2;   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m;     t1.init(n);     t2.init(n);     long long free = 1LL * n * n;     for (int i = 0; i < m; ++i) {       int x, y;       cin >> x >> y;       if (cnt2[y] == 0)         free -= (n - 1 - t1.get_sum(1, x - 1) - t1.get_sum(x + 1, n));       if (cnt1[x] == 0)         free -= (n - 1 - t2.get_sum(1, y - 1) - t2.get_sum(y + 1, n));       if (cnt1[x] == 0 && cnt2[y] == 0) free--;       cnt1[x] = cnt2[y] = true;       if (t1.get_sum(x, x) == 0) t1.add(x, 1);       if (t2.get_sum(y, y) == 0) t2.add(y, 1);       cout << free <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int NMAX = 200010, ALPHA = 30;   int N;   long long Sum[ALPHA];   double Ans;   char A[NMAX], B[NMAX];   int main() {     scanf( %i n , &N);     gets(A + 1);     gets(B + 1);     long long Posib = (1LL * N * (N + 1) * (2 * N + 1)) / 6;     for (int i = N; i; --i) {       int C = B[i] -  A  + 1;       Sum[C] += N - i + 1;       C = A[i] -  A  + 1;       Ans += (1LL * i * Sum[C]) / (1.0 * Posib);     }     for (int i = 0; i < ALPHA; ++i) Sum[i] = 0;     for (int i = N; i; --i) {       int C = B[i] -  A  + 1;       Ans += (1LL * i * Sum[C]) / (1.0 * Posib);       C = A[i] -  A  + 1;       Sum[C] += N - i + 1;     }     printf( %.9f n , 1.0 * Ans);   }
#include <bits/stdc++.h>   using namespace std;   long long v[2][200005];   long long c[2][200005];   int n, k, a, b, q, e, day, ord;   const int maxn = 200005;   void add(int i, int value, int z) {     for (; i < maxn; i += (i + 1) & -(i + 1)) v[z][i] += value;   }   long long get(int i, int z) {     long long res = 0;     for (; i >= 0; i -= (i + 1) & -(i + 1)) res += v[z][i];     return res;   }   long long g = 0;   int main() {     scanf( %d%d%d%d%d , &n, &k, &a, &b, &q);     while (q--) {       scanf( %d , &e);       if (e == 1) {         scanf( %d %d , &day, &ord);         long long ord1 = ord, ord2 = ord;         if (c[0][day] <= b) {           long long need = (long long)b - c[0][day];           if (need <= ord1) {             ord1 = need;             c[0][day] = b;           } else             c[0][day] += (long long)ord1;           add(day, ord1, 0);         }         if (c[1][day] <= a) {           long long need = (long long)a - c[1][day];           if (need <= ord2) {             ord2 = need;             c[1][day] = a;           } else             c[1][day] += ord2;           add(day, ord2, 1);         }       } else {         scanf( %d , &day);         g = 0;         if (day - 1) g = get(day - 1, 0);         g += (long long)(get(200004, 1) - get(day + k - 1, 1));         printf( %I64d n , g);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1 << 18;   const int inf = 1e9;   int a[N], b[N], c[N], d[N];   int dp[19][N];   bool pr[19][N];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       b[i] = (a[i] % N + N) % N;     }     dp[0][0] = 0;     for (int i = 1; i <= 18; i++) {       int mod = 1 << i, _mod = 1 << i - 1;       for (int j = 1; j <= n; j++) {         c[j] = b[j] % mod;         d[j] = b[j] % _mod;       }       int L = _mod, R = -1;       for (int j = 1; j <= n; j++)         if (d[j] != c[j]) L = min(L, d[j]);       for (int j = 1; j <= n; j++)         if (d[j] == c[j]) R = max(R, d[j]);       for (int s = 0; s < mod; s++) dp[i][s] = inf, pr[i][s] = 1;       for (int s = 0; s < _mod; s++) {         if (dp[i - 1][s] < inf) {           for (int j = 0; j < 2; j++) {             int t = s + (_mod * j);             if (dp[i - 1][s] + 1 < dp[i][t]) {               dp[i][t] = dp[i - 1][s] + 1;             }             if (s == 0) {               if (j == 0 && L == _mod) {                 if (dp[i - 1][s] < dp[i][t]) {                   dp[i][t] = dp[i - 1][s];                   pr[i][t] = 0;                 }               }             } else if (R < s && s <= L) {               if (j) {                 if (dp[i - 1][s] < dp[i][t]) {                   dp[i][t] = dp[i - 1][s];                   pr[i][t] = 0;                 }               }             }           }         }       }     }     int L = 1 << 18, R = -1;     for (int i = 1; i <= n; i++) {       if (a[i] < 0)         L = min(L, b[i]);       else         R = max(R, b[i]);     }     int s = -1;     for (int t = 0; t < 1 << 18; t++) {       if (t == 0 && L != (1 << 18)) continue;       if (t && t > L) continue;       if (t && t <= R) continue;       if (s == -1 || dp[18][t] < dp[18][s]) s = t;     }     int ret = dp[18][s];     vector<int> ans;     for (int i = 18; i > 0; i--) {       int x = 1 << i - 1;       if (s && s <= x) {         ans.push_back(-x);       } else {         if (pr[i][s]) ans.push_back(x);       }       s %= x;     }     assert(ans.size() == ret);     reverse(ans.begin(), ans.end());     cout << ans.size() << endl;     for (int x : ans) printf( %d  , x);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int main() {     cin >> s;     long long n = s.size();     long long b = n / 2;     if (n % 2) {       while (1) {         if (s[b] ==  A ) break;         if (s[b] ==  H ) break;         if (s[b] ==  I ) break;         if (s[b] ==  M ) break;         if (s[b] ==  U ) break;         if (s[b] ==  T ) break;         if (s[b] ==  O ) break;         if (s[b] ==  I ) break;         if (s[b] ==  W ) break;         if (s[b] ==  V ) break;         if (s[b] ==  Y ) break;         if (s[b] ==  X ) break;         cout <<  NO  << endl;         return 0;       }     }     for (int i = 0; i < n; i++) {       if (s[i] ==  A ) {         continue;       } else if (s[i] ==  W ) {         continue;       } else if (s[i] ==  T ) {         continue;       } else if (s[i] ==  Y ) {         continue;       } else if (s[i] ==  U ) {         continue;       } else if (s[i] ==  I ) {         continue;       } else if (s[i] ==  O ) {         continue;       } else if (s[i] ==  H ) {         continue;       } else if (s[i] ==  X ) {         continue;       } else if (s[i] ==  V ) {         continue;       } else if (s[i] ==  M ) {         continue;       } else {         cout <<  NO  << endl;         return 0;       }     }     for (int i = 0; i < n / 2; i++) {       if (s[i] != s[n - i - 1]) {         cout <<  NO  << endl;         return 0;       }     }     cout <<  YES  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000;   long long n, ans;   int main() {     while (~scanf( %lld , &n)) {       n--;       int l = 0;       for (int i = 0; i < 50; i++)         if ((1ll << i) & n) l = i;       ans = n / 2 + n % 2;       int f = l;       for (; f > 0; f--) {         if ((1ll << f) & n) {           int k = f;           ans += (1ll << f);           for (int i = 1; i < k; i++) {             ans += (1ll << i) * (1ll << (k - 1 - i));           }         }       }       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, ans = 0;   int main() {     cin >> n;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         int x;         cin >> x;         if (i == j || (i + j) == (n + 1) || i == (n + 1) / 2 || j == (n + 1) / 2)           ans += x;       }     cout << ans << endl;     return 0;   }