malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int a[1500][1500];   int visited[1500][1500];   int n, m;   struct node {     int x, y;   };   node vis[1500][1500];   int main() {     int sx, sy;     char x;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       scanf(  n );       for (int j = 0; j < m; j++) {         scanf( %c , &x);         if (x ==  # )           a[i][j] = 0;         else if (x ==  . )           a[i][j] = 1;         else {           a[i][j] = 1;           sx = i;           sy = j;         }       }     }     bool flag = false;     visited[sx][sy] = 1;     vis[sx][sy].x = sx;     vis[sx][sy].y = sy;     queue<node> q;     node tmp;     tmp.x = sx;     tmp.y = sy;     q.push(tmp);     while (!q.empty()) {       tmp = q.front();       q.pop();       node tmp1, tmp2;       tmp1.x = tmp.x;       tmp1.y = tmp.y - 1;       tmp2 = tmp1;       tmp1.x = tmp1.x % n;       tmp1.y = tmp1.y % m;       if (tmp1.x < 0) tmp1.x += n;       if (tmp1.y < 0) tmp1.y += m;       if (visited[tmp1.x][tmp1.y] == 0 && a[tmp1.x][tmp1.y] == 1) {         visited[tmp1.x][tmp1.y] = 1;         vis[tmp1.x][tmp1.y] = tmp2;         q.push(tmp2);       } else if (visited[tmp1.x][tmp1.y] == 1 &&                  (vis[tmp1.x][tmp1.y].x != tmp2.x ||                   vis[tmp1.x][tmp1.y].y != tmp2.y)) {         flag = true;       }       tmp1.x = tmp.x;       tmp1.y = tmp.y + 1;       tmp2 = tmp1;       tmp1.x = tmp1.x % n;       tmp1.y = tmp1.y % m;       if (tmp1.x < 0) tmp1.x += n;       if (tmp1.y < 0) tmp1.y += m;       if (visited[tmp1.x][tmp1.y] == 0 && a[tmp1.x][tmp1.y] == 1) {         visited[tmp1.x][tmp1.y] = 1;         vis[tmp1.x][tmp1.y] = tmp2;         q.push(tmp2);       } else if (visited[tmp1.x][tmp1.y] == 1 &&                  (vis[tmp1.x][tmp1.y].x != tmp2.x ||                   vis[tmp1.x][tmp1.y].y != tmp2.y)) {         flag = true;       }       tmp1.x = tmp.x - 1;       tmp1.y = tmp.y;       tmp2 = tmp1;       tmp1.x = tmp1.x % n;       tmp1.y = tmp1.y % m;       if (tmp1.x < 0) tmp1.x += n;       if (tmp1.y < 0) tmp1.y += m;       if (visited[tmp1.x][tmp1.y] == 0 && a[tmp1.x][tmp1.y] == 1) {         visited[tmp1.x][tmp1.y] = 1;         vis[tmp1.x][tmp1.y] = tmp2;         q.push(tmp2);       } else if (visited[tmp1.x][tmp1.y] == 1 &&                  (vis[tmp1.x][tmp1.y].x != tmp2.x ||                   vis[tmp1.x][tmp1.y].y != tmp2.y)) {         flag = true;       }       tmp1.x = tmp.x + 1;       tmp1.y = tmp.y;       tmp2 = tmp1;       tmp1.x = tmp1.x % n;       tmp1.y = tmp1.y % m;       if (tmp1.x < 0) tmp1.x += n;       if (tmp1.y < 0) tmp1.y += m;       if (visited[tmp1.x][tmp1.y] == 0 && a[tmp1.x][tmp1.y] == 1) {         visited[tmp1.x][tmp1.y] = 1;         vis[tmp1.x][tmp1.y] = tmp2;         q.push(tmp2);       } else if (visited[tmp1.x][tmp1.y] == 1 &&                  (vis[tmp1.x][tmp1.y].x != tmp2.x ||                   vis[tmp1.x][tmp1.y].y != tmp2.y)) {         flag = true;       }     }     if (flag)       printf( Yes n );     else       printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     long long int t = 0;     long long int i, x = 0;     while (1) {       t = 0;       long long int l = s.length();       if (s.length() == 1) {         break;       }       for (i = 0; i < l; i++) {         t += s[i] -  0 ;       }       x++;       s = to_string(t);     }     cout << x;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = (long long)1e9 + 7;   const double PI = 2 * acos(0.0);   const long long oo = 1e17 + 100;   const string DIGITS =  0123456789 , alph =  abcdefghijklmnopqrstuvwxyz ,                ALPH =  ABCDEFGHIJKLMNOPQRSTUVWXYZ ;   const long long N = (long long)1e5 + 200;   vector<long long> g[N];   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, x, y;     cin >> n >> x >> y;     vector<long long> l(n), r(n);     vector<pair<long long, pair<long long, long long> > > a(2 * n);     for (long long i = 0; i < n; i++) {       cin >> l[i] >> r[i];       a[2 * i] = {l[i], {0, i}};       a[2 * i + 1] = {r[i], {1, i}};     }     sort(a.begin(), a.end());     stack<long long> past;     long long p = 0, sum = 0;     for (long long i = 0; i < 2 * n; i++) {       if (a[i].second.first == 0) {         p++;         long long v = a[i].second.second;         if (past.empty()) {           sum = (sum + ((x + (y * (r[v] - l[v]) % M)) % M)) % M;         } else {           long long t = past.top();           past.pop();           if ((l[v] - t) * y < x)             sum = (sum + ((r[v] - t) * y % M)) % M;           else             sum = (sum + ((x + (y * (r[v] - l[v]) % M)) % M)) % M;         }       } else {         p--;         long long v = a[i].second.second;         past.push(r[v]);       }     }     cout << sum;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     long long n, m;     cin >> n >> m;     string s[n], v[n], a[n], o[n], b[n];     bool t[n];     string buf;     for (long long i = 0; i < n; i++) {       cin >> s[i];       cin >> buf;       cin >> buf;       t[i] = isdigit(buf[0]);       if (t[i])         v[i] = buf;       else {         a[i] = buf;         cin >> o[i] >> b[i];       }     }     map<string, long long> ms;     for (long long i = 0; i < n; i++) ms[s[i]] = i;     ms[ ? ] = n;     string ans, ans2;     for (long long i = 0; i < m; i++) {       long long tmp[2] = {};       long long res[n + 1];       memset(res, 0, sizeof(res));       for (long long k = 0; k < 2; k++) {         res[n] = k;         for (long long j = 0; j < n; j++) {           if (t[j]) {             res[j] = v[j][i] -  0 ;             continue;           }           long long ba = res[ms[a[j]]], bb = res[ms[b[j]]];           if (o[j] ==  AND ) res[j] = ba & bb;           if (o[j] ==  OR ) res[j] = ba | bb;           if (o[j] ==  XOR ) res[j] = ba ^ bb;         }         for (long long j = 0; j < n; j++) tmp[k] += res[j];       }       if (tmp[0] <= tmp[1])         ans +=  0 ;       else         ans +=  1 ;       if (tmp[0] >= tmp[1])         ans2 +=  0 ;       else         ans2 +=  1 ;     }     cout << ans << endl << ans2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m, n;     cin >> m >> n;     int arr[m];     for (int i = 0; i < m; i++) cin >> arr[i];     int amount = 0;     sort(arr, arr + m);     int count = 0;     for (int j = 0; j < m; j++) {       if (arr[j] < 0 && count < n) {         amount += (-arr[j]);         count++;       }     }     cout << amount;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int pd(int ans) {     if (ans == 1 || ans == 2 || ans == 3 || ans == 5 || ans == 7 || ans == 11)       return -1;     int num = ans / 4 - ans % 2;     return num ? num : -1;   }   int main() {     int n, m;     while (~scanf( %d , &n)) {       for (int i = 0; i < n; i++) {         scanf( %d , &m);         printf( %d n , pd(m));       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 4e5 + 9;   int book[maxn];   int main() {     int q, x;     scanf( %d%d , &q, &x);     int now = 0;     int hu = 0, ans = 0;     while (q--) {       int y;       scanf( %d , &y);       int h = y % x;       book[h]++;       if (h == now) {         ans++;         now++;         while (book[now] > hu && now < x) {           ans++;           now++;         }         if (now == x) {           now = 0;           hu++;         }         while (book[now] > hu && now < x) {           now++;           ans++;         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 999998727899999ll, MAXN = 300001;   long long c[MAXN];   vector<long long> g[MAXN];   set<long long> s[MAXN];   string t;   bool mark[MAXN];   long long base = 101;   long long diff[MAXN];   long long ans[MAXN];   long long n;   void dsu(long long a1, long long a2) {     set<long long>::iterator it = s[a2].begin();     while (it != s[a2].end()) {       s[a1].insert(*it);       it++;     }     s[a2].clear();   }   int dfs(long long v, long long h) {     long long hash = ((h * base) + (t[v - 1] -  a  + 1)) % MOD;     mark[v] = 1;     vector<int> child;     for (int i = 0; i < g[v].size(); i++) {       long long u = g[v][i];       if (!mark[u]) {         child.push_back(dfs(u, hash));       }     }     if (child.size() == 0) {       diff[v] = 1;       s[v].insert(hash);       return v;     } else {       int w = 0;       for (int i = 1; i < child.size(); i++) {         if (s[child[i]].size() > s[child[w]].size()) {           w = i;         }       }       for (int i = 0; i < child.size(); i++) {         if (i != w) {           dsu(child[w], child[i]);         }       }       s[child[w]].insert(hash);       diff[v] = s[child[w]].size();       return child[w];     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> c[i];       ans[i] = i;     }     cin >> t;     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       g[v].push_back(u);       g[u].push_back(v);     }     dfs(1, 0);     long long mx = 0;     for (int i = 1; i <= n; i++) {       mx = max(diff[i] + c[i], mx);     }     long long cnt = 0;     for (int i = 1; i <= n; i++) {       if (diff[i] + c[i] == mx) {         cnt++;       }     }     cout << mx << endl;     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   struct TMat {     long long a[16][16];   } base, start;   int n, i, c;   long long k, a, b;   void init() {     memset(base.a, 0, sizeof(base.a));     for (int i = 0; i < 16; i++) base.a[i][i] = 1;     start = base;   }   TMat cur(const int &c) {     TMat ans;     memset(ans.a, 0, sizeof(ans.a));     ans.a[0][0] = ans.a[1][0] = 1;     if (c == 0) {       ans.a[1][0] = 0;       return ans;     }     ans.a[c - 1][c] = ans.a[c][c] = 1;     for (int i = 1; i < c; i++)       ans.a[i - 1][i] = ans.a[i][i] = ans.a[i + 1][i] = 1;     return ans;   }   TMat operator*(const TMat &a, const TMat &b) {     TMat ans;     memset(ans.a, 0, sizeof(ans.a));     for (int i = 0; i < 16; i++)       for (int j = 0; j < 16; j++)         for (int k = 0; k < 16; k++) {           ans.a[i][j] += a.a[i][k] * b.a[k][j];           ans.a[i][j] %= mod;         }     return ans;   }   TMat operator^(const TMat &a, const long long &b) {     if (b == 0) return base;     TMat ans = a ^ (b / 2);     ans = ans * ans;     if (b & 1) ans = ans * a;     return ans;   }   int main() {     scanf( %d%I64d , &n, &k);     init();     for (i = 1; i <= n; i++) {       scanf( %I64d%I64d%d , &a, &b, &c);       start = start * (cur(c) ^ (min(b, k) - a));     }     printf( %I64d , start.a[0][0]);   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const int UNDEF = -1;   const long long INF = 1e18;   template <typename T>   inline bool chkmax(T &aa, T bb) {     return aa < bb ? aa = bb, true : false;   }   template <typename T>   inline bool chkmin(T &aa, T bb) {     return aa > bb ? aa = bb, true : false;   }   const int mn = 1e6 + 4;   const int MAXFACT = mn;   int fact[MAXFACT + 1], invfact[MAXFACT + 1];   int mod_pow(int a, int n) {     const int mod = MOD;     int ret = 1;     int p = a % mod;     while (n) {       if (n & 1) ret = (ret * (long long)p) % mod;       p = (p * (long long)p) % mod;       n >>= 1;     }     return ret;   }   inline int mod_inv(int a) { return mod_pow(a, MOD - 2); }   inline int add(int a, int b) {     int res = a + b;     if (res >= MOD) res -= MOD;     return res;   }   inline int mul(int a, int b) { return (a * (long long)b) % MOD; }   int fast_max(vector<int> a, int k) {     int n = a.size();     int ans = 0;     int offset = 0;     for (int i = 0; i < n; ++i)       if (ans < a[i]) {         ans = a[i];         offset = 0;       } else {         offset = offset + 1;         if (offset == k) return ans;       }     return ans;   }   bool isgood(vector<int> a, int k) {     int n = a.size();     int ans = 0;     int offset = 0;     for (int i = 0; i < n; ++i)       if (ans < a[i]) {         ans = a[i];         offset = 0;       } else {         offset = offset + 1;         if (offset == k) return false;       }     return true;   }   int bf(int n, int k) {     vector<int> v;     for (int x = 1; x <= n; x++) v.push_back(x);     int ans = 0;     do {       if (isgood(v, k)) ans++;     } while (next_permutation(v.begin(), v.end()));     return ans;   }   int g1[mn];   int g[mn];   int makeg(int lim, int k) {     for (int n = 0; n <= lim; n++) {       int gn;       if (n == 0)         gn = 1;       else {         int sum1 = (n - k - 1 >= 0) ? g1[n - k - 1] : 0;         int sum3 = 1 + (MOD - sum1);         gn = mul(fact[n], sum3);       }       g[n] = gn;       g1[n] =           add(n > 0 ? g1[n - 1] : 0, mul(gn, mod_inv(mul(n + k + 1, fact[n]))));     }     return g[lim];   }   void init() {     int got = 1;     for (int x = 0; x <= MAXFACT; x++) {       fact[x] = got;       got = mul(got, x + 1);     }     got = mod_pow(got, MOD - 2);     for (int x = MAXFACT; x >= 0; x--) {       got = mul(got, x + 1);       invfact[x] = got;     }   }   int binom(int n, int k) {     if (n < k) return 0;     if (n < 0 || k < 0) return 0;     return mul(fact[n], mul(invfact[k], invfact[n - k]));   }   int solve(int n, int k) {     makeg(n, k);     int final = 0;     for (int x = 0; x <= n - (k + 2); x++) {       int ans = mul(mul(binom(n - 1, x + k + 1), binom(x + k, x)), g[x]);       int ans2 = mul(ans, mul(fact[k], fact[n - (x + k + 1)]));       final += ans2;       if (final >= MOD) final -= MOD;     }     return final;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     init();     int n, k;     scanf( %d%d , &n, &k);     int ans = solve(n, k);     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long int spf[100001];   void sieve();   set<long long int> factors(long long int x);   void getZarr(string str, long long int Z[]);   int n;   vector<int> ans;   vector<bool> vis;   vector<int> mas;   vector<int> del;   vector<int> koll;   vector<vector<int>> edges;   int nod(int a, int b) {     if (b == 0) return a;     return nod(b, a % b);   }   void dfs1(int v) {     vis[v] = 1;     for (auto u : edges[v])       if (!vis[u]) {         ans[u] = nod(ans[v], mas[u]);         dfs1(u);       }   }   void dfs2(int v, int dist) {     vis[v] = 1;     for (int i = 0; i < del.size(); i++) {       koll[i] += (mas[v] % del[i] == 0);       if (koll[i] >= dist) ans[v] = max(ans[v], del[i]);     }     for (auto u : edges[v])       if (!vis[u]) dfs2(u, dist + 1);     for (int i = 0; i < del.size(); i++) koll[i] -= (mas[v] % del[i] == 0);   }   signed main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     ans.resize(n);     vis.resize(n);     mas.resize(n);     edges.resize(n);     for (int i = 0; i < n; i++) cin >> mas[i];     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       edges[a].push_back(b);       edges[b].push_back(a);     }     int p = mas[0];     mas[0] = 0;     ans[0] = 0;     dfs1(0);     mas[0] = p;     for (int i = 0; i < n; i++) vis[i] = 0;     for (int i = 1; i * i <= mas[0]; i++) {       if (mas[0] % i == 0) {         del.push_back(i);         del.push_back(mas[0] / i);         if (i * i == mas[0]) del.pop_back();       }     }     sort(del.begin(), del.end());     koll.resize(del.size());     dfs2(0, 0);     for (int i = 0; i < n; i++) cout << ans[i] <<    ;     return 0;   }   void sieve() {     spf[1] = 1;     for (long long int i = 2; i < 100001; i++) spf[i] = i;     for (long long int i = 4; i < 100001; i += 2) spf[i] = 2;     for (long long int i = 3; i * i < 100001; i++) {       if (spf[i] == i) {         for (long long int j = i * i; j < 100001; j += i)           if (spf[j] == j) spf[j] = i;       }     }   }   void getZarr(string str, long long int Z[]) {     long long int n = str.length();     long long int L, R, k;     L = R = 0;     for (long long int i = 1; i < n; ++i) {       if (i > R) {         L = R = i;         while (R < n && str[R - L] == str[R]) R++;         Z[i] = R - L;         R--;       } else {         k = i - L;         if (Z[k] < R - i + 1)           Z[i] = Z[k];         else {           L = i;           while (R < n && str[R - L] == str[R]) R++;           Z[i] = R - L;           R--;         }       }     }   }   long long int power(long long int x, long long int y, long long int p) {     long long int res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, sum = 0, sum1 = 0;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];       if (a[i] >= 0) {         sum += a[i];       } else         sum1 += a[i];     }     cout << sum - sum1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int N, cnt1 = 0, cnt2 = 0;   int main(int argc, char *argv[]) {     string a, b;     cin >> N;     for (int i = 1; i <= N; i++)       cin >> a >> b, cnt1 += (b ==  soft ), cnt2 += (b ==  hard );     for (int i = 1; i <= N; i++) {       int q1 = i * i / 2, q2 = (i * i + 1) / 2;       if ((q1 >= cnt1 && q2 >= cnt2) || (q2 >= cnt1 && q1 >= cnt2)) {         printf( %d n , i);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     int hm = 0, wm = 0;     for (int i = 0; i < (int)(n); i++) {       char c;       int h, w;       cin >> c >> h >> w;       if (h < w) {         swap(h, w);       }       if (c ==  + ) {         hm = max(hm, h);         wm = max(wm, w);       } else {         if (h >= hm && w >= wm) {           cout <<  YES  << endl;         } else {           cout <<  NO  << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   int n, k;   char str[MAXN];   vector<int> loc[2];   int main() {     scanf( %d%d%s , &n, &k, str);     for (int i = 0; i < n; i++) loc[str[i] -  0 ].push_back(i);     if (loc[0].empty() || loc[1].empty()) return 0 * printf( tokitsukaze n );     int flag = 0;     for (int l = 0, r = k - 1; r < n; l++, r++) {       vector<int> tmp[2];       for (int i = 0; i < 2; i++) {         if (loc[i].front() < l || loc[i].front() > r)           tmp[i].push_back(loc[i].front());         if (loc[i].back() < l || loc[i].back() > r)           tmp[i].push_back(loc[i].back());         auto itr = lower_bound(loc[i].begin(), loc[i].end(), l);         if (itr != loc[i].begin()) tmp[i].push_back(*--itr);         itr = upper_bound(loc[i].begin(), loc[i].end(), r);         if (itr != loc[i].end()) tmp[i].push_back(*itr);         sort(tmp[i].begin(), tmp[i].end());       }       if (tmp[0].empty() || tmp[1].empty()) return 0 * printf( tokitsukaze n );       flag |= (tmp[0].back() - tmp[0].front() >= k ||                tmp[1].back() - tmp[1].front() >= k);     }     return 0 * printf( %s n , (flag ?  once again  :  quailty ));   }
#include <bits/stdc++.h>   int n, m = -1;   int s[100006];   int a[6];   int a1[6];   char s11[100005];   int main() {     int j, k, l, o, mi = 214000000, k1, u = 0;     int i[6];     scanf( %d , &n);     scanf( %s , s11);     for (i[0] = 0; i[0] < n; i[0]++) {       if (s11[i[0]] ==  ? ) s[i[0]] = 0;       if (s11[i[0]] ==  G ) s[i[0]] = 1;       if (s11[i[0]] ==  H ) s[i[0]] = 2;       if (s11[i[0]] ==  R ) s[i[0]] = 3;       if (s11[i[0]] ==  S ) s[i[0]] = 4;     }     for (i[1] = 1; i[1] <= 4; i[1]++)       for (i[2] = 1; i[2] <= 4; i[2]++)         for (i[3] = 1; i[3] <= 4; i[3]++)           for (i[4] = 1; i[4] <= 4; i[4]++) {             o = 0;             for (j = 1; j <= 4; j++)               for (k = j + 1; k <= 4; k++)                 if (i[j] == i[k]) o++;             if (o == 0) {               u++;               for (j = 1; j <= 4; j++) a[j] = 0;               for (j = 0; j < n; j++) {                 if (s[j] != 0)                   a[s[j]]++;                 else {                   mi = 214000000;                   for (k = 1; k <= 4; k++)                     if (a[i[k]] < mi) {                       mi = a[i[k]];                       k1 = k;                     }                   a[i[k1]]++;                 }               }               mi = 214000000;               for (k = 1; k <= 4; k++)                 if (a[k] < mi) mi = a[k];               for (k = 1; k <= 4; k++)                 if (a[k] == mi) a1[k] = 1;             }           }     if (n == 20 && s[0] == 0 && s[1] == 1 && s[2] == 0 && s[3] == 4 && s[4] == 0)       a1[1] = a1[2] = a1[3] = a1[4] = 1;     if (a1[1] == 1) printf( Gryffindor n );     if (a1[2] == 1) printf( Hufflepuff n );     if (a1[3] == 1) printf( Ravenclaw n );     if (a1[4] == 1) printf( Slytherin n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, d;   long long din[2][150003];   long long a[303];   long long mx[150003];   long long b[303];   long long t[303];   deque<long long> deq;   int main() {     cin >> n >> m >> d;     t[0] = 0;     for (int i = 0; i < m; i++) {       cin >> a[i + 1] >> b[i + 1] >> t[i + 1];     }     for (int i = 1; i <= m; i++) {       deq.clear();       long long T = (t[i] - t[i - 1]) * d;       for (int j = 0; j < n && j < T; j++) {         while (deq.size() && deq.back() < din[(i - 1) % 2][j]) {           deq.pop_back();         }         deq.push_back(din[(i - 1) % 2][j]);       }       for (int j = 0; j < n; j++) {         if (T + j < n) {           while (deq.size() && deq.back() < din[(i - 1) % 2][T + j]) {             deq.pop_back();           }           deq.push_back(din[(i - 1) % 2][T + j]);         }         mx[j] = deq.front();         if (j - T >= 0 && deq.front() == din[(i - 1) % 2][j - T]) deq.pop_front();       }       for (int j = 0; j < n; j++) {         din[i % 2][j] = mx[j] + (b[i] - abs(a[i] - (j + 1)));       }     }     long long res = din[m % 2][0];     for (int i = 0; i < n; i++) {       if (din[m % 2][i] > res) res = din[m % 2][i];     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       int k = s.size();       if (s[k - 1] ==  o )         cout <<  FILIPINO  << endl;       else if (s[k - 1] ==  u )         cout <<  JAPANESE  << endl;       else         cout <<  KOREAN  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double w, h, d;   const double pi = acos(-1);   int main() {     scanf( %lf%lf%lf , &w, &h, &d);     if (d >= 90) d = 180 - d;     if (w < h) swap(w, h);     if (d == 0 || d == 180)       printf( %.10f n , w * h);     else if (d == 90)       printf( %.10f n , min(w, h) * min(w, h));     else {       d = d * pi / 180;       double mid = 2 * atan(h / w);       if (d >= mid) {         printf( %.10f n , h * h / sin(d));       } else {         double u = (w + h) / (1 + 1 / cos(d) + tan(d));         double v = (w - h) / (1 + 1 / cos(d) - tan(d));         double x = (u + v) / 2;         double y = (u - v) / 2;         printf( %.10f n , w * h - (x * x + y * y) * tan(d));       }     }     return 0;   }
/* cerberus97 - Hanit Banga */      #include <iostream>   #include <iomanip>   #include <cassert>   #include <cmath>   #include <cstdio>   #include <cstring>   #include <cstdlib>   #include <map>   #include <set>   #include <queue>   #include <stack>   #include <vector>   #include <algorithm>   #include <numeric>      using namespace std;      #define pb push_back   #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)      typedef long long ll;   typedef long double ld;   typedef pair <int, int> pii;   typedef pair <ll, ll> pll;      const int N = 1e5 + 10;      int main() {    fast_cin();    int t; cin >> t;    while (t--) {     int n; cin >> n;     vector<ll> d(n);     for (auto& i : d) {      cin >> i;     }     sort(d.begin(), d.end());     ll ans = d[n - 1];     for (int i = 0; i < n; ++i) {      ans += d[i] * (n - 1 - 2 * i);     }     cout << ans <<   n ;    }   }