malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long MXN = 2e5 + 10;   long long n, m, sum, maxi;   long long A[MXN], Ans[MXN], Max[MXN];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= m; i++) cin >> A[i], sum += A[i];     if (sum < n) return cout << -1, 0;     for (int i = 1; i <= m; i++) {       if (i > n - A[i] + 1) return cout << -1, 0;       Ans[i] = i;       Max[i] = max(Max[i - 1], i + A[i] - 1);     }     long long l = Max[m] + 1, r = n, p = m;     while (p >= 1 && l <= r) {       Ans[p] = r - A[p] + 1;       r = r - A[p];       l = Max[p - 1] + 1;       p--;     }     for (int i = 1; i <= m; i++) cout << Ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   const int MOD = 1e9 + 7;   vector<pair<int, int> > G[maxn];   int vis[maxn];   int dp[maxn];   int dfs(int x, int v) {     vis[x] = 1;     dp[x] = v;     for (pair<int, int> e : G[x]) {       int a = e.first;       int b = 1 - e.second;       if (vis[a]) {         if (dp[a] != (dp[x] ^ b)) return 0;       } else {         if (!dfs(a, v ^ b)) return 0;       }     }     return 1;   }   int main() {     int n, m;     cin >> n >> m;     for (int i = 1; i <= m; i++) {       int x, y, v;       scanf( %d%d%d , &x, &y, &v);       G[x].push_back(make_pair(y, v));       G[y].push_back(make_pair(x, v));     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       if (!vis[i]) {         if (!dfs(i, 0)) {           puts( 0 );           return 0;         } else {           if (!ans)             ans = 1;           else             ans = ans * 2 % MOD;         }       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   string t;   int ct, z;   vector<int> vi;   int gcd(int a, int b) {     if (!b) return a;     if (a % b == 0) return b;     return gcd(b, a % b);   }   int main() {     int a, b, k;     cin >> a >> b >> k;     if (a + k < b) {       printf( 0.0000000 n );       exit(0);     }     if (!b) {       printf( 1.000000 n );       exit(0);     }     double p = 1;     for (int i = 0; i <= k; ++i) {       p *= (1.0 * (b - i)) / (a + i + 1);     }     printf( %.6lf n , 1 - p);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 505;   int a[N];   int dp[N][N];   int deal(int L, int R) {     if (L >= R) return 1;     if (dp[L][R] != N) return dp[L][R];     if (a[L] == a[R]) dp[L][R] = min(dp[L][R], deal(L + 1, R - 1));     for (int i = L; i < R; ++i) {       dp[L][R] = min(dp[L][R], deal(L, i) + deal(i + 1, R));     }     return dp[L][R];   }   void gao(int n) {     for (int i = 0; i < N; ++i)       for (int j = 0; j < N; ++j) dp[i][j] = N;     int ans = deal(0, n - 1);     cout << ans << endl;   }   int main() {     int n;     while (cin >> n) {       for (int i = 0; i < n; ++i) {         cin >> a[i];       }       gao(n);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   const int MAX = (int)(2e5) + 7;   const int MOD = (int)(1e9) + 7;   const int INF_I = (int)(1e9) + 7;   const ll INF_LL = (ll)(1e18);   template <typename T>   void info(T& v) {     for (const auto& i : v) cout << i <<    ;     cout << endl;   }   template <typename T>   bool chkmin(T& a, T b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <typename T>   bool chkmax(T& a, T b) {     if (a < b) {       a = b;       return true;     }     return false;   }   void boot_up() {     cin.tie(nullptr);     cout.tie(nullptr);     ios_base::sync_with_stdio(false);   }   int q;   int n, k;   void solve();   signed main() {     boot_up();     cin >> q;     while (cin >> n >> k) solve();   }   void solve() {     string s;     cin >> s;     int curr_pos = 0;     string a =   , b =   , c =   ;     vector<string> mask = { R ,  G ,  B };     for (int i = 0; i < n; ++i) {       a += mask[curr_pos % 3];       b += mask[(curr_pos + 1) % 3];       c += mask[(curr_pos + 2) % 3];       curr_pos = (curr_pos + 1) % 3;     }     vector<int> pref_a(n);     vector<int> pref_b(n);     vector<int> pref_c(n);     pref_a[0] = (s[0] ==  R  ? 0 : 1);     pref_b[0] = (s[0] ==  G  ? 0 : 1);     pref_c[0] = (s[0] ==  B  ? 0 : 1);     for (int i = 1; i < n; ++i) {       pref_a[i] = pref_a[i - 1] + 1 - (int)(s[i] == a[i]);       pref_b[i] = pref_b[i - 1] + 1 - (int)(s[i] == b[i]);       pref_c[i] = pref_c[i - 1] + 1 - (int)(s[i] == c[i]);     }     int ans = INF_I;     for (int i = 0; i < n - k + 1; ++i) {       chkmin(ans, pref_a[i + k - 1] - (i == 0 ? 0 : pref_a[i - 1]));       chkmin(ans, pref_b[i + k - 1] - (i == 0 ? 0 : pref_b[i - 1]));       chkmin(ans, pref_c[i + k - 1] - (i == 0 ? 0 : pref_c[i - 1]));     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     long long n;     long long t1(0), t2(0);     long long mn = 0, mx = 0;     cin >> n;     vector<long> vec(n, 0);     for (long i = 0; i < n; i++) {       cin >> vec[i];     }     sort(vec.begin(), vec.end());     mn = vec[0];     mx = vec[n - 1];     for (long i = 0; i < vec.size(); i++) {       t1 += (vec[i] == mn);       t2 += (vec[i] == mx);     }     cout << mx - mn <<    ;     if (mx - mn == 0)       cout << n * (n - 1) / 2 << endl;     else       cout << t1 * t2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int NMAX = 1000000 + 5;   int N;   int p[2 * NMAX];   int main() {     cin >> N;     iota(p + 1, p + N + 1, 1);     int st = 1, dr = N;     for (int phase = 2; phase <= N; ++phase, ++st) {       int old = 0;       for (int i = st; i <= dr; i += phase) {         int aux = p[i];         p[i] = old;         old = aux;       }       p[++dr] = old;     }     for (int i = st; i <= dr; ++i) cout << p[i] <<    n [i == dr];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 7;   int n;   long long a[maxn];   long long work(long long m) {     long long res = 0;     while (m) {       if (m & 1) res++;       m >>= 1;     }     return res;   }   long long dp[maxn][2];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %lld , &a[i]);       a[i] = work(a[i]);     }     dp[0][0] = 0;     dp[0][1] = 0;     dp[1][0] = 0;     dp[1][1] = 0;     for (int i = 2; i <= n; ++i) {       if (a[i] & 1) {         dp[i][0] = dp[i - 1][1] + (a[i - 1] & 1);         dp[i][1] = dp[i - 1][0] + !(a[i - 1] & 1);       } else {         dp[i][0] = dp[i - 1][0] + !(a[i - 1] & 1);         dp[i][1] = dp[i - 1][1] + (a[i - 1] & 1);       }     }     long long ans = 0;     for (int i = 2; i <= n; ++i) {       int l_ = max(1, i - 119);       long long max_ = a[i], cnt = 0, sum = a[i];       for (int j = i - 1; j >= l_; --j) {         sum += a[j];         max_ = max(max_, a[j]);         if (sum & 1) continue;         if (max_ > sum / 2) cnt++;       }       ans += (dp[i][0] - cnt);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     unsigned long int val;     long int index;     unsigned long int other;   };   bool cmp(node& a, node& b) {     if (a.val != b.val)       return a.val < b.val;     else       return a.other > b.other;   }   struct node2 {     bool operator()(const node& a, const node& b) const {       if (a.other != b.other)         return a.other < b.other;       else if (a.val != b.val)         return a.val < b.val;       else         return a.index < b.index;     }   };   int main() {     unsigned long int n;     scanf( %lu , &n);     vector<node> all(n);     for (unsigned long int i = 0; i < n; i++) {       scanf( %lu , &all[i].other);       scanf( %lu , &all[i].val);       if (all[i].other > all[i].val) swap(all[i].other, all[i].val);       all[i].index = i + 1;     }     sort(all.begin(), all.end(), cmp);     unsigned long int outer = 0, id = 0;     set<node, node2> ended;     for (unsigned long int i = 0; i < n; i++) {       auto it = ended.insert(all[i]).first;       auto it1 = it, it2 = it;       it1++;       if (it1 != ended.end()) {         outer = (*it).index;         id = (*it1).index;         break;       } else if (it2 != ended.begin()) {         it2--;         if ((*it2).other >= (*it).other) {           outer = (*it).index;           id = (*it2).index;         }       }     }     if (outer == 0)       printf( -1 -1 n );     else       printf( %lu %lu n , id, outer);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void printvec(vector<T>& x, int a, int b) {     for (int i = (a); i <= (b); i++) cout << x[i] <<    ;     cout <<   n ;   }   const double PI = acos((double)-1);   const double EPSILON = 1e-7;   const int N = 1e6 + 1;   const int NN = 1e3 + 1;   const long long MOD = 998244353;   const long long oo = LLONG_MAX;   const int BASE = 10000;   void query() {     int n, x;     cin >> n >> x;     vector<vector<int>> g(n + 1);     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       g[u].push_back(v);       g[v].push_back(u);     }     if ((int)(g[x]).size() <= 1) {       cout <<  Ayush             <<   n ;       return;     }     if (n % 2) {       cout <<  Ashish             <<   n ;     } else {       cout <<  Ayush             <<   n ;     }   }   void solve() {     int q;     cin >> q;     while (q--) {       query();     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(nullptr);     cout.tie(nullptr);     cout << fixed << setprecision(10);     solve();     cerr <<  Time elapsed:   << 1.0 * clock() / CLOCKS_PER_SEC <<   s. n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   string s;   int cnt;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     cin >> s;     for (int i = 0; i < n; i++) {       if (s[i] ==  # ) {         cnt++;       } else {         if (cnt >= k) {           cout <<  NO  << endl;           return 0;         }         cnt = 0;       }     }     if (cnt >= k) {       cout <<  NO  << endl;       return 0;     } else {       cout <<  YES  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, A[100], i, j;   bool w;   string S;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> N;     for (i = 0; i < N; i++) {       cin >> A[i];     }     getline(cin, S);     for (j = 0; j < N; j++) {       getline(cin, S);       if (!w) {         for (i = S.length() - 1; i >= 0; i--) {           if (S[i] ==  a  || S[i] ==  i  || S[i] ==  u  || S[i] ==  e  ||               S[i] ==  o  || S[i] ==  y ) {             A[j]--;           }         }         if (A[j] != 0) {           w = 1;         }       }     }     if (w) {       cout <<  NO  << endl;     } else       cout <<  YES  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   int n, k;   vector<int> g[N];   int fa[N];   int dep[N];   bool vis[N];   int anc[N][35];   void dfs(int u, int f) {     fa[u] = f;     anc[u][0] = fa[u];     for (int i = 0; i < g[u].size(); i++) {       int v = g[u][i];       if (v != f) {         dep[v] = dep[u] + 1;         dfs(v, u);       }     }   }   void rdfs(int u, int f) {     vis[u] = 1;     if (u == f) return;     rdfs(fa[u], f);   }   void preprocess() {     for (int j = 1; (1 << j) < n; j++) {       for (int i = 0; i < n; i++) {         if (anc[i][j - 1] != -1) {           int a = anc[i][j - 1];           anc[i][j] = anc[a][j - 1];         }       }     }   }   int main() {     memset(anc, -1, sizeof(anc));     scanf( %d%d , &n, &k);     k = n - k;     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       x--, y--;       g[x].push_back(y);       g[y].push_back(x);     }     dfs(n - 1, -1);     preprocess();     int num = 1;     vis[n - 1] = 1;     for (int i = n - 2; i >= 0; i--) {       if (vis[i]) continue;       int t = i;       for (int j = 20; j >= 0; j--) {         if (anc[t][j] == -1)           continue;         else {           if (!vis[anc[t][j]]) {             t = anc[t][j];           }         }       }       if (dep[i] - dep[t] + 1 + num <= k) {         num += dep[i] - dep[t] + 1;         rdfs(i, t);       }     }     for (int i = 0; i < n; i++) {       if (!vis[i]) printf( %d  , i + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     char ch = getchar();     long long x = 0;     int op = 1;     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) op = -1;     for (; isdigit(ch); ch = getchar()) x = x * 10 + ch -  0 ;     return x * op;   }   inline void write(long long a) {     if (a < 0) putchar( - ), a = -a;     if (a >= 10) write(a / 10);     putchar( 0  + a % 10);   }   const int N = 1010;   int n, m, k;   long long a[N][N], s1[N][N], s2[N][N];   int main() {     n = read(), m = read(), k = read();     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1] + read();     for (int i = 1; i <= n; i++)       for (int j = 0; j <= m; j++) {         s1[i][j] = s1[i - 1][j + 1] + a[i][j] -                    ((i - k >= 0 && j + k <= m) ? a[i - k][j + k] : 0);         if (j)           s2[i][j] = s2[i - 1][j - 1] + a[i][j] -                      ((i - k >= 0 && j - k >= 0) ? a[i - k][j - k] : 0);       }     long long mx = -1, x, y;     for (int i = k; i <= n - k + 1; i++)       for (int j = k; j <= m - k + 1; j++) {         long long tmp = s1[i + k - 1][j] + s1[i - 1][j - k] -                         s2[i - 1][j + k - 1] - s2[i + k - 1][j - 1];         if (tmp > mx) {           mx = tmp;           x = i;           y = j;         }       }     write(x);     putchar(   );     write(y);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int sum = 2 * n - 1 + a[0];     if (n > 1) {       if (a[0] > a[1]) sum += a[0] - a[1];       for (int i = 1; i < n - 1; i++) {         if (a[i] > a[i - 1]) sum += a[i] - a[i - 1];         if (a[i] > a[i + 1]) sum += a[i] - a[i + 1];       }       if (a[n - 1] > a[n - 2]) sum += a[n - 1] - a[n - 2];     }     cout << sum << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = (int)1e9;   const double PI = 2 * acos(0);   const double eps = 1e-9;   inline int comp(const double &a, const double &b) {     if (fabs(a - b) < eps) return 0;     return a > b ? 1 : -1;   }   int di[] = {1, -1, 0, 0, 1, -1, 1, -1};   int dj[] = {0, 0, 1, -1, 1, -1, -1, 1};   int diK[] = {-2, -2, -1, 1, 2, 2, 1, -1};   int djK[] = {-1, 1, 2, 2, 1, -1, -2, -2};   int I, J;   inline bool val(const int &i, const int &j) {     if (i < 0 || j < 0 || i >= I || j >= J) return false;     return true;   }   int N;   int n;   int ret[109][109];   bool val() {     for (int i = 0; i < (int)(I); i++)       for (int j = 0; j < (int)(J); j++)         for (int k = 0; k < (int)(4); k++) {           int ni = i + di[k];           int nj = j + dj[k];           if (val(ni, nj) && abs(ret[i][j] - ret[ni][nj] == 1)) return 0;         }     return 1;   }   bool vis[10009];   bool dfs(int i, int j) {     if (i == I) return 1;     if (j == J) return dfs(i + 1, 0);     for (int a = 1; a <= I * J; a++)       if (!vis[a]) {         if (i && abs(a - ret[i - 1][j]) == 1) continue;         if (j && abs(a - ret[i][j - 1]) == 1) continue;         vis[a] = 1;         ret[i][j] = a;         if (dfs(i, j + 1)) return 1;         vis[a] = 0;       }     return 0;   }   int main() {     cin >> I >> J;     if (I * J <= 1000000) {       if (dfs(0, 0)) {         for (int i = 0; i < (int)(I); i++) {           for (int j = 0; j < (int)(J); j++) {             if (j) printf(   );             printf( %d , ret[i][j]);           }           printf(  n );         }       } else         cout << -1 << endl;       return 0;     }     vector<pair<int, int> > v;     for (int i = 0; i < (int)(I); i++)       for (int j = 0; j < (int)(J); j++) v.push_back(make_pair(i, j));     int cc = 1;     for (int i = 1; i < I * J; i += 2) ret[v[i].first][v[i].second] = cc++;     for (int i = 0; i < I * J; i += 2) ret[v[i].first][v[i].second] = cc++;     if (!val()) {       cc = 1;       for (int i = 0; i < I * J; i += 2) ret[v[i].first][v[i].second] = cc++;       for (int i = 1; i < I * J; i += 2) ret[v[i].first][v[i].second] = cc++;       if (!val()) {         cout << -1 << endl;         return 0;       }     }     for (int i = 0; i < (int)(I); i++) {       for (int j = 0; j < (int)(J); j++) {         if (j) printf(   );         printf( %d , ret[i][j]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string a;   int n;   int main() {     cin >> a;     scanf( %d , &n);     int i;     for (i = 0; i < a.size(); i++)       if (a[i] >=  A  && a[i] <=  Z ) a[i] =  a  + a[i] -  A ;     for (i = 0; i < a.size(); i++)       if (a[i] -  a  + 1 <= n) a[i] =  A  + a[i] -  a ;     cout << a;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[4] = {1, -1, 0, 0};   int dy[4] = {0, 0, 1, -1};   void fast() {     ios_base::sync_with_stdio(NULL);     cin.tie(0);     cout.tie(0);   }   void online_judge() {     freopen( input.txt ,  r , stdin);     freopen( output.txt ,  w , stdout);   }   const int flag_max = 0x3f3f3f3f;   const long long OO = 2e9 + 10;   const double EPS = (1e-8);   int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }   long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }   const long long MOD = 1e14 + 7;   long long Power(long long n, long long deg) {     if (!deg)       return 1;     else if (deg & 1)       return (Power(n, deg - 1) * n);     else {       long long half = Power(n, deg / 2);       return ((half * half));     }   }   int k, ans = 0;   string s;   vector<pair<char, char> > pr;   int main() {     fast();     cin >> s;     cin >> k;     for (int i = 0; i < k; i++) {       string q;       cin >> q;       int F = 0, S = 0;       for (int i = 0; i < s.size(); i++) {         if (s[i] == q[0] || s[i] == q[1])           if (s[i] == q[0])             F++;           else             S++;         else           ans += min(F, S), S = F = 0;       }       ans += min(F, S);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   long long BASE = 101;   bool is_enough(int h, int n, int m) {     int n1 = h / 2;     int m1 = h / 3;     int mn1 = h / 6;     if (n1 - mn1 >= n && m1 - mn1 >= m) {       return true;     }     int need_n = max(0, n - (n1 - mn1));     int need_m = max(0, m - (m1 - mn1));     if (need_n + need_m <= mn1) {       return true;     }     return false;   }   int main() {     std::cout.precision(15);     std::ios_base::sync_with_stdio(false);     int n, m;     cin >> n >> m;     int l = 2;     int r = 6000000;     while (r - l > 1000) {       int mid = l + (r - l) / 2;       if (is_enough(mid, n, m)) {         r = mid;       } else {         l = mid;       }     }     for (int i = l; i <= r; ++i) {       if ((i % 2 == 0 || i % 3 == 0) && is_enough(i, n, m)) {         cout << i;         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200500;   const int inf = 2e9;   const double eps = 1e-8;   const int base = 1073676287;   long long a[maxn];   int b[maxn];   int c[maxn];   int bit[64];   int bits2[64];   void check(int n) {     long long sum = 0LL;     for (int j = 0; j < n; j++) {       sum += a[j];       int x = a[j];       int pos = 0;       while (x) {         bit[pos++] += x % 2;         x /= 2;       }     }     for (int j = 0; j < n; j++) {       int x = a[j];       int pos = 0;       for (int i = 0; i < 64; i++) bits2[i] = 0;       while (x) {         bits2[pos++] = x % 2;         x /= 2;       }       long long cnt = 0LL;       long long deg = 1LL;       for (int i = 0; i < 60; i++) {         if (bits2[i]) cnt += 1LL * bit[i] * deg;         deg *= 2LL;       }       if (cnt != b[j]) {         puts( -1 );         exit(0);       }       if (1LL * a[j] * n + sum != 1LL * b[j] + 1LL * c[j]) {         puts( -1 );         exit(0);       }     }   }   int main() {     srand(time(0));     int n;     long long sum = 0LL;     scanf( %d , &n);     for (int j = 0; j < n; j++) {       scanf( %d , &b[j]);       sum += 1LL * b[j];     }     for (int j = 0; j < n; j++) {       scanf( %d , &c[j]);       sum += 1LL * c[j];     }     if (sum % (2LL * n) != 0LL) {       puts( -1 );       return 0;     }     sum /= 2LL * n;     for (int j = 0; j < n; j++) {       int cur = b[j] + c[j];       a[j] = cur - sum;       if (a[j] < 0LL) {         puts( -1 );         return 0;       }       if (1LL * a[j] % n != 0LL) {         puts( -1 );         return 0;       }       a[j] /= 1LL * n;     }     check(n);     for (int j = 0; j < n; j++) cout << a[j] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct wor {     int x, y;     bool start;   };   struct node {     int maxN;     int plus;   };   vector<node> t(16 * 1000000 + 1000, {0, 0});   int m = 4 * 1000000 + 5;   bool operator<(wor a, wor b) { return a.y < b.y or a.y == b.y and a.x < b.x; }   void update(int v, int l, int r, int a, int b, int val) {     if (l >= b or r <= a) {       return;     } else if (a <= l and r <= b) {       t[v].plus += val;     } else {       int m = (l + r) / 2;       update(2 * v + 1, l, m, a, b, val);       update(2 * v + 2, m, r, a, b, val);       t[v].maxN = max(t[2 * v + 1].maxN + t[2 * v + 1].plus,                       t[2 * v + 2].maxN + t[2 * v + 2].plus);     }   }   int query(int v, int l, int r, int a, int b) {     if (l >= b or r <= a) {       return -1;     } else if (a <= l and r <= b) {       return t[v].maxN + t[v].plus;     } else {       int m = (l + r) / 2;       return max(query(2 * v + 1, l, m, a, b), query(2 * v + 2, m, r, a, b)) +              t[v].plus;     }   }   int main() {     int add = 1000000;     ios_base ::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int r;     cin >> r;     r *= 2;     vector<wor> a(2 * n);     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       int newX = x + y;       int newY = x - y;       newX += add;       newY += add;       a[2 * i] = {newX, newY, true};       a[2 * i + 1] = {newX, newY + r + 1, false};     }     int best = 0;     sort(a.begin(), a.end());     for (auto e : a) {       if (e.start) {         update(0, 0, m, e.x, e.x + r + 1, 1);         int q = query(0, 0, m, e.x, e.x + r + 1);         best = max(best, q);       } else {         update(0, 0, m, e.x, e.x + r + 1, -1);       }     }     cout << best;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t;   typedef long long LL;   set<LL>a;   int main(){    for(LL i = 1;i <= 10000;i++)a.insert(i*i*i);    scanf( %d ,&t);    while(t--){     LL x;     cin >> x;     int flag = 0;     for(LL i = 1;i <= 10000;i++)      if(a.count(x-i*i*i)){       puts( YES );       flag = 1;       break;      }     if(!flag)puts( NO );    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[100 + 10][100 + 10];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> a[i][j];       }     }     int sum = 0;     for (int i = 0; i < n; i++) {       sum += a[i][i];     }     for (int i = n - 1; i >= 0; i--) {       sum += a[i][n - i - 1];     }     for (int i = 0; i < n; i++) {       sum += a[i][n / 2];     }     for (int i = 0; i < n; i++) {       sum += a[n / 2][i];     }     sum -= a[n / 2][n / 2] * 3;     cout << sum;   }