malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MOD = int(1e9) + 7;   const long long int MOD64 = (long long int)(1e18) + 7;   const int INF = 0x7fffffff;   const long long int INF64 = 0x7fffffffffffffff;   const int N = 5000 + 10;   int a[N], lnum[N], rnum[N];   int n, m;   vector<int> H[N];   long long int cal(int x, int val) {     int l = 0, r = H[x].size() - 1, ans = -1;     while (l <= r) {       int mid = (l + r) / 2;       if (H[x][mid] <= val) {         ans = mid;         l = mid + 1;       } else         r = mid - 1;     }     return ans + 1;   }   pair<int, long long int> solve() {     int ans = 0;     long long int num = 1;     for (int i = int(1); i < int(n + 1); i++) {       long long int tmp = 0;       tmp = cal(i, lnum[i]) * cal(i, rnum[i]) - cal(i, min(lnum[i], rnum[i]));       if (tmp > 0) {         ans += 2;         num = (num * tmp) % MOD;         continue;       }       tmp = cal(i, lnum[i]) + cal(i, rnum[i]);       if (tmp != 0) {         ans += 1;         num = (num * tmp) % MOD;       }     }     return {ans, num};   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = int(1); i < int(n + 1); i++) {       cin >> a[i];       rnum[a[i]]++;     }     for (int i = int(0); i < int(m); i++) {       int f, h;       cin >> f >> h;       H[f].push_back(h);     }     for (int i = int(1); i < int(n + 1); i++) sort((H[i]).begin(), (H[i]).end());     int ans = 0;     long long int num = 0;     for (int i = int(0); i < int(n + 1); i++) {       rnum[a[i]]--;       lnum[a[i]]++;       pair<int, long long int> tmp = solve();       if (ans < tmp.first) {         ans = tmp.first;         num = tmp.second;       } else if (ans == tmp.first) {         num = (num + tmp.second) % MOD;       }     }     memset(lnum, 0, sizeof(lnum));     memset(rnum, 0, sizeof(rnum));     for (int i = int(1); i < int(n + 1); i++) rnum[a[i]]++;     for (int i = int(0); i < int(n); i++) {       rnum[a[i + 1]]--;       lnum[a[i]]++;       pair<int, long long int> tmp = solve();       if (tmp.first == ans) num = (num - tmp.second + MOD) % MOD;     }     cout << ans <<     << num << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1000];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     double ans = 0;     for (int i = 1; i <= m; ++i) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       ans = max(ans, ((double)a[x] + a[y]) / z);     }     printf( %.15f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int num;     int num_num;   } num[105];   int main() {     int N, M;     scanf( %d%d , &N, &M);     num[0].num = 0;     num[0].num_num = 0;     for (int i = 1; i <= N; i++) {       int flag;       scanf( %d , &flag);       num[i].num = num[i - 1].num + flag;       num[i].num_num = 0;     }     while (M--) {       int left, right;       scanf( %d%d , &left, &right);       if (left == right && num[left].num - num[left - 1].num > 0)         num[left].num_num++;       else if (left < right && num[right].num - num[left - 1].num >= 0) {         for (int i = left; i <= right; i++) num[i].num_num++;       }     }     long long int sum = 0;     for (int i = 1; i <= N; i++) {       sum += (num[i].num - num[i - 1].num) * num[i].num_num;     }     printf( %I64d n , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   long long ar[maxn];   int main() {     long long n, m;     cin >> n >> m;     long long a, b, c;     cin >> a >> b >> c;     ar[a] = 1, ar[b] = 2, ar[c] = 3;     for (int i = 1; i < m; ++i) {       cin >> a >> b >> c;       if (!ar[a] and !ar[b] and !ar[c])         ar[a] = 1, ar[b] = 2, ar[c] = 3;       else {         if (ar[a]) {           if (ar[a] == 1)             ar[b] = 2, ar[c] = 3;           else if (ar[a] == 2)             ar[b] = 1, ar[c] = 3;           else             ar[b] = 1, ar[c] = 2;         } else if (ar[b]) {           if (ar[b] == 1)             ar[a] = 2, ar[c] = 3;           else if (ar[b] == 2)             ar[a] = 1, ar[c] = 3;           else             ar[a] = 1, ar[c] = 2;         } else if (ar[c]) {           if (ar[c] == 1)             ar[a] = 2, ar[b] = 3;           else if (ar[c] == 2)             ar[a] = 1, ar[b] = 3;           else             ar[a] = 1, ar[b] = 2;         }       }     }     for (int i = 1; i < n + 1; ++i) cout << ar[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double fs = 6e-2, Pi = acos(-1.0);   struct point {     double x, y;   } p[4];   double a, b, c, r, S, C, P, C1, A1, B1, R1, Ans;   double s(point a, point b) {     return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));   }   double gcd(double a, double b) {     return (fabs(b) > fs) ? gcd(b, fmod(a, b)) : a;   }   int main() {     for (int i = 1; i <= 3; ++i) scanf( %lf%lf , &p[i].x, &p[i].y);     a = s(p[1], p[2]), b = s(p[2], p[3]), c = s(p[1], p[3]), P = (a + b + c) / 2;     S = sqrt(P * (P - a) * (P - b) * (P - c)), r = a * b * c / (4 * S);     C1 = acos(1 - c * c / (2 * r * r)), A1 = acos(1 - a * a / (2 * r * r)),     B1 = 2 * Pi - A1 - C1;     R1 = gcd(A1, gcd(B1, C1));     return printf( %.6lf , (Pi * r * r * sin(R1)) / R1), 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[4] = {0, -1, 0, 1};   int dy[4] = {1, 0, -1, 0};   int x[100000], y[100000], DP[100000], CP[100000], R, C, used[50][50][4][4];   char s[64][64];   bool Out(int xx, int yy) { return xx < 0 || yy < 0 || xx >= R || yy >= C; }   void next(int x1, int y1, int DP1, int CP1, int &x2, int &y2, int &DP2,             int &CP2) {     int i;     for (i = 1;; i++) {       int nx = x1 + dx[DP1] * i;       int ny = y1 + dy[DP1] * i;       if (Out(nx, ny) || s[nx][ny] != s[x1][y1]) break;     }     i--;     x1 += dx[DP1] * i;     y1 += dy[DP1] * i;     for (i = 1;; i++) {       int nx = x1 + dx[(DP1 + CP1) & 3] * i;       int ny = y1 + dy[(DP1 + CP1) & 3] * i;       if (Out(nx, ny) || s[nx][ny] != s[x1][y1]) break;     }     i--;     x1 += dx[(DP1 + CP1) & 3] * i;     y1 += dy[(DP1 + CP1) & 3] * i;     int nx = x1 + dx[DP1];     int ny = y1 + dy[DP1];     if (Out(nx, ny) || !s[nx][ny]) {       x2 = x1;       y2 = y1;       if (CP1 == 1) {         CP2 = 3;         DP2 = DP1;       } else {         CP2 = 1;         DP2 = (DP1 + 3) & 3;       }     } else {       x2 = nx;       y2 = ny;       DP2 = DP1;       CP2 = CP1;     }   }   int main() {     int i, j, k, m;     scanf( %d%d , &R, &m);     for (i = 0; i < R; i++) scanf( %s , s[i]);     C = strlen(s[0]);     for (i = 0; i < R; i++)       for (j = 0; j < C; j++) s[i][j] -=  0 ;     CP[0] = 1;     memset(used, -1, sizeof(used));     used[0][0][0][1] = 0;     for (i = 1;; i++) {       next(x[i - 1], y[i - 1], DP[i - 1], CP[i - 1], x[i], y[i], DP[i], CP[i]);       if (used[x[i]][y[i]][DP[i]][CP[i]] >= 0) {         break;       }       used[x[i]][y[i]][DP[i]][CP[i]] = i;     }     int tmp = used[x[i]][y[i]][DP[i]][CP[i]];     if (m < i)       printf( %d n , (int)s[x[m]][y[m]]);     else       printf(            %d n ,           (int)s[x[tmp + (m - tmp) % (i - tmp)]][y[tmp + (m - tmp) % (i - tmp)]]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string eq(string c) {     string s =   ;     for (int i = 0; i < c.size(); i++) {       if (c[i] ==  2 )         s +=  2 ;       else if (c[i] ==  3 )         s +=  3 ;       else if (c[i] ==  4 )         s +=  223 ;       else if (c[i] ==  5 )         s +=  5 ;       else if (c[i] ==  6 )         s +=  53 ;       else if (c[i] ==  7 )         s +=  7 ;       else if (c[i] ==  8 )         s +=  7222 ;       else if (c[i] ==  9 )         s +=  7332 ;     }     sort(s.begin(), s.end());     reverse(s.begin(), s.end());     return s;   }   int main() {     int n;     string s;     cin >> n >> s;     cout << eq(s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[4], num, sum;   string s[4], str;   bool check(char ch) {     return ch ==  a  || ch ==  e  || ch ==  i  || ch ==  o  || ch ==  u ;   }   int work() {     sum = 0;     for (int i = str.length() - 1; i >= 0; i--) {       sum += check(str[i]);       if (sum == m) return i;     }     return -1;   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       for (int j = 0; j < 4; j++) {         cin >> str;         num = work();         if (!~num) {           puts( NO );           return 0;         }         s[j] = str.substr(num);       }       if (s[0] == s[1] && s[1] == s[2] && s[2] == s[3])         a[0] = 1;       else if (s[0] == s[1] && s[2] == s[3])         a[1] = 1;       else if (s[0] == s[2] && s[1] == s[3])         a[2] = 1;       else if (s[0] == s[3] && s[1] == s[2])         a[3] = 1;       else {         puts( NO );         return 0;       }     }     if (a[0] && !(a[1] || a[2] || a[3]))       puts( aaaa );     else if (a[1] && !(a[2] || a[3]))       puts( aabb );     else if (a[2] && !(a[1] || a[3]))       puts( abab );     else if (a[3] && !(a[1] || a[2]))       puts( abba );     else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   int main() {     long int n, a[100001], i, flag;     char c[100001], c1;     while (scanf( %ld , &n) == 1) {       flag = 0;       long int a1[100001] = {0};       c1 = getchar();       gets(c);       for (i = 0; i < n; i++) {         scanf( %ld , &a[i]);       }       i = 0;       while (1) {         if (c[i] ==  >  && a1[i] == 0) {           a1[i] = 1;           i += a[i];           if (i >= n) {             flag = 1;             break;           }         } else if (c[i] ==  <  && a1[i] == 0) {           a1[i] = 1;           i -= a[i];           if (i < 0) {             flag = 1;             break;           }         } else {           flag = 0;           break;         }       }       if (flag == 1) {         printf( FINITE n );       } else {         printf( INFINITE n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void chmin(T &x, const T &y) {     if (x > y) x = y;   }   template <typename T>   void chmax(T &x, const T &y) {     if (x < y) x = y;   }   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch - 48;       ch = getchar();     }     return x * f;   }   const int N = 5000 + 10;   const int mod = 1e9 + 7;   int n, dp[N][30], len, a[N], C[N][N], ans;   signed main() {     n = read();     for (int i = 1; i <= n; i++) {       int ch;       ch = getchar() -  a  + 1;       if (ch != a[len]) a[++len] = ch;     }     C[0][0] = 1;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= i; j++)         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;     dp[0][0] = 1;     for (int i = 1; i <= len; i++)       for (int j = i; j; j--) {         int cur = a[i];         dp[j][cur] = 0;         for (int k = 0; k <= 26; k++)           if (k != cur) dp[j][cur] = (dp[j][cur] + dp[j - 1][k]) % mod;       }     for (int i = 1; i <= len; i++) {       int tmp = 0;       for (int j = 1; j <= 26; j++) tmp = (tmp + dp[i][j]) % mod;       (ans += 1LL * tmp * C[n][i] % mod) %= mod;     }     cout << ans;     return 0;     ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int x = 2 * n, y = 3 * m;     int k = 1;     while (6 * k <= x && 6 * k <= y) {       if (x + 2 <= y + 3)         x += 2;       else         y += 3;       k += 1;     }     cout << max(x, y);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int res = 0, w = 1;     char ch = getchar();     while (ch <  0  || ch >  9 )       ch ==  -  ? w = -1, ch = getchar() : ch = getchar();     while (ch >=  0  && ch <=  9 ) {       res = res * 10 + ch -  0 ;       ch = getchar();     }     return w * res;   }   int n, a, b, c, d, e, f;   int main() {     a = read();     b = read();     c = read();     d = read();     e = read();     f = read();     int flag = 0;     flag |= (b * d * f) > (a * c * e);     flag |= (!c && d);     flag |= (!a && b && c && d);     flag |= (!e && f && a && b && c && d);     flag ? printf( Ron n ) : printf( Hermione n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios_base::sync_with_stdio(0);     cin.tie(NULL), cout.tie(NULL);   }   int main() {     fast();     int n, k;     cin >> n >> k;     vector<int> v(n), vc(k + 1);     for (int i = 0; i < n; i++) {       cin >> v[i];     }     auto it = unique(v.begin(), v.end());     v.resize(distance(v.begin(), it));     for (int i = 0; i < v.size(); i++) {       vc[v[i]]++;       if (i > 0 && i < v.size() - 1) {         vc[v[i]] += (v[i - 1] == v[i + 1]);       }     }     int pos = 1;     for (int i = 1; i <= k; i++) {       if (vc[i] > vc[pos]) {         pos = i;       }     }     cout << pos;     return 0;   }
#include <bits/stdc++.h>   long long p[16];   void F() {     p[1] = 10;     for (int i = 2; i <= 14; i++) p[i] = p[i - 1] * 10;   }   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     F();     long long n, ans = 0;     cin >> n;     if (n < 10) {       cout << n;       return 0;     }     for (int i = 1; i <= 14; i++) {       if (n / p[i] == 0) {         long long a = p[i - 1] - 1;         long long b = n - a;         ostringstream str1, str2;         str1 << a;         str2 << b;         string sa = str1.str();         string sb = str2.str();         for (auto x : sa) ans += x -  0 ;         for (auto x : sb) ans += x -  0 ;         cout << ans;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization( unroll-loops )   using namespace std;   array<long long, 2> parent[1000][1000];   long long sze[1000][1000];   array<long long, 2> p(array<long long, 2> x) {     if (x == parent[x[0]][x[1]]) {       return x;     } else {       return parent[x[0]][x[1]] = p(parent[x[0]][x[1]]);     }   }   void unite(array<long long, 2> x, array<long long, 2> y) {     array<long long, 2> a = p(x);     array<long long, 2> b = p(y);     if (a != b) {       if (sze[a[0]][a[1]] < sze[b[0]][b[1]]) {         swap(a, b);       }       parent[b[0]][b[1]] = a;       sze[a[0]][a[1]] += sze[b[0]][b[1]];     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long n;     cin >> n;     unordered_map<long long, vector<array<long long, 2>>> m1;     unordered_map<long long, vector<array<long long, 2>>> m2;     vector<array<long long, 2>> a(n);     for (long long i = 0; i < n; ++i) {       long long x, y;       cin >> x >> y;       x--;       y--;       a[i] = {x, y};       m1[x].push_back({x, y});       m2[y].push_back({x, y});     }     for (long long i = 0; i < 1000; ++i) {       for (long long j = 0; j < 1000; ++j) {         parent[i][j] = {i, j};         sze[i][j] = 1;       }     }     for (auto i : a) {       for (auto j : m1[i[0]]) {         if (j == i) {           continue;         }         unite(i, j);       }       for (auto j : m2[i[1]]) {         if (j == i) {           continue;         }         unite(i, j);       }     }     long long ans = 0;     for (auto i : a) {       if (i == parent[i[0]][i[1]]) {         ans++;       }     }     cout << ans - 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     int r, c, n, k;     cin >> r >> c >> n >> k;     int tab[r][c];     for (int i = 0; i < r; i++)       for (int j = 0; j < c; j++) tab[i][j] = 0;     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       --x;       --y;       tab[x][y] = 1;     }     int wyn = 0;     for (int x1 = 0; x1 < r; x1++)       for (int y1 = 0; y1 < c; y1++)         for (int x2 = x1; x2 < r; x2++)           for (int y2 = y1; y2 < c; y2++) {             int v = 0;             for (int i = x1; i <= x2; i++)               for (int j = y1; j <= y2; j++) v += tab[i][j];             if (v >= k) wyn++;           }     cout << wyn;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   int mod = 998244353;   int T;   int a[N], b[N], p[N];   bool vis[N];   int main() {     scanf( %d , &T);     while (T--) {       int n, k;       scanf( %d%d , &n, &k);       for (int i = 1; i <= n; ++i) {         scanf( %d , &a[i]);         p[a[i]] = i;         vis[i] = 0;       }       for (int i = 1; i <= k; ++i) {         scanf( %d , &b[i]);       }       int ans = 1;       for (int i = k; i >= 1; --i) {         int t = p[b[i]];         int kk = 0;         if (t > 1 && !vis[t - 1]) kk++;         if (t < n && !vis[t + 1]) kk++;         vis[t] = 1;         ans = (ans * kk) % mod;       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int tc;     scanf( %d , &tc);     for (int i = 0; i < tc; i++) {       int N, K;       scanf( %d %d , &N, &K);       if (N < K) {         printf( NO n );         continue;       }       if (N % 2 == 0) {         if (2 * K <= N) {           printf( YES n );           for (int j = 0; j < K - 1; j++) {             if (j != 0) printf(   );             printf( %d , 2);           }           printf(  %d n , N - (2 * (K - 1)));         } else if (N == K) {           printf( YES n );           for (int j = 0; j < K; j++) {             if (j != 0) printf(   );             printf( %d , 1);           }           printf(  n );         } else if (K % 2 != 0) {           printf( NO n );         } else {           bool flag = false;           int count = 0;           while (N > K) {             count++;             N -= 3;             K -= 1;             if (N == K) {               flag = true;               printf( YES n );               for (int l = 0; l < count; l++) {                 if (l != 0) printf(   );                 printf( %d , 3);               }               for (int l = 0; l < N; l++) {                 printf(  %d , 1);               }               printf(  n );               break;             }           }           if (!flag) {             printf( NO n );           }         }       } else {         if (K % 2 != 1) {           printf( NO n );         } else {           printf( YES n );           for (int j = 0; j < K - 1; j++) {             if (j != 0) printf(   );             printf( %d , 1);           }           printf(  %d n , N - ((K - 1)));         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   int n, m, q;   long long ans, in[N], out[N];   vector<int> f[N];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; ++i) {       int x, y;       scanf( %d%d , &x, &y);       if (x > y) swap(x, y);       f[x].push_back(y);       in[y]++, out[x]++;     }     for (int i = 1; i <= n; ++i) ans += in[i] * out[i];     printf( %lld n , ans);     scanf( %d , &q);     while (q--) {       int x;       scanf( %d , &x);       ans -= in[x] * out[x];       in[x] += out[x], out[x] = 0;       for (int i = 0; i < f[x].size(); ++i) {         int y = f[x][i];         ans -= in[y] * out[y];         out[y]++, in[y]--;         ans += in[y] * out[y];         f[y].push_back(x);       }       f[x].clear();       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, c;     long double x1, y1, x2, y2, s, x3, y3, x4, y4, x5, y5, x6, y6;     cin >> a >> b >> c;     cin >> x1 >> y1 >> x2 >> y2;     x3 = x1;     y3 = (-a * x3 - c) / b;     y4 = y1;     x4 = (-b * y4 - c) / a;     x5 = x2;     y5 = (-a * x5 - c) / b;     y6 = y2;     x6 = (-b * y6 - c) / a;     s = min(min(min((abs(x1 - x2) + abs(y1 - y2)),                     (abs(y1 - y3) + abs(y2 - y5) +                      sqrt((y3 - y5) * (y3 - y5) + (x3 - x5) * (x3 - x5)))),                 min((abs(y1 - y3) + abs(x2 - x6) +                      sqrt((y3 - y6) * (y3 - y6) + (x3 - x6) * (x3 - x6))),                     (abs(x1 - x4) + abs(y2 - y5) +                      sqrt((y4 - y5) * (y4 - y5) + (x4 - x5) * (x4 - x5))))),             (abs(x1 - x4) + abs(x2 - x6) +              sqrt((y4 - y6) * (y4 - y6) + (x4 - x6) * (x4 - x6))));     cout << setprecision(19) << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, ai, nb = 0;     map<int, int> dict;     map<int, int>::iterator it;     cin >> n;     int i = 0;     while (i < n) {       cin >> ai;       dict[ai]++;       i++;     }     for (it = dict.begin(); it != dict.end(); it++) {       while ((it->second) > 1) {         it->second = (it->second) - 2;         nb++;       }     }     cout << (nb / 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 7;   int a[N];   int b[N];   int main() {     int n;     cin >> n;     a[1] = 0;     for (int i = 2; i <= n; ++i) {       int k;       cin >> k;       a[i] = a[i - 1] + k;     }     int x = 1e6;     for (int j = 1; j <= n; ++j) {       x = min(x, a[j]);     }     for (int i = 1; i <= n; ++i) {       if (a[i] - x + 1 >= 1 && a[i] - x + 1 <= n) {         b[a[i] - x + 1] = 1;       }     }     for (int i = 1; i <= n; ++i) {       if (b[i] == 0) {         cout << -1 << endl;         return 0;       }     }     for (int i = 1; i <= n; ++i) {       cout << a[i] - x + 1 <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   queue<pair<int, int> > q;   int c[2048][2048];   int dr[4] = {-1, 0, 1, 0};   int dc[4] = {0, 1, 0, -1}, nr, nc;   int main() {     int n, t, x, y;     scanf( %d%d , &n, &t);     c[1023][1023] = n;     q.push(make_pair(1023, 1023));     pair<int, int> s;     int mxr = 1023, mxc = 1023;     while (!q.empty()) {       s = q.front();       q.pop();       if (c[s.first][s.second] < 4) continue;       for (int k = 0; k < 4; ++k) {         nr = s.first + dr[k];         nc = s.second + dc[k];         c[nr][nc] += c[s.first][s.second] / 4;         if (c[nr][nc] >= 4) q.push(make_pair(nr, nc));       }       c[s.first][s.second] %= 4;     }     ++t;     while (--t) {       scanf( %d%d , &x, &y);       x += 1023;       y += 1023;       if (x < 0 || x > 2047 || y < 0 || y > 2047)         printf( 0 n );       else         printf( %d n , c[y][x]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   long long a[15];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       a[x]++;     }     long long ans = 0;     for (int i = 1; i <= m; i++)       for (int j = i + 1; j <= m; j++) ans += a[i] * a[j];     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   pair<int, int> p[maxn];   int a[maxn];   int b[maxn];   int n, k, cnt;   bool F(int a, int b) { return a > b; }   void solve() {     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 1; i <= n; i++) scanf( %d , b + i);     sort(a + 1, a + n + 1);     sort(b + 1, b + n + 1, F);     int i = 1, t = 1;     while (true) {       if (b[t] + a[i++] >= k) cnt++, t++;       if (t > n || i > n) break;     }     printf( 1 %d , cnt);   }   int main() { solve(); }