malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct circle {     long double x, y, r;   };   struct mod {     long double theta, op;   };   struct node {     long double x, y, theta;   };   int n, d, i, j, tot, S, ans, gg;   circle c[20005];   mod l[2000005];   node A, B;   long double D, k, t, L, R, dis1, dis2, dis3;   void getAB() {     long double x = c[i].x, y = c[i].y, r = c[i].r, delta;     if (x == 0) {       t = (r * r - x * x - y * y - D * D) / (-2 * y);       k = -x / y;       delta = (2 * t * k) * (2 * t * k) - 4 * (k * k + 1) * (t * t - D * D);       if (delta < 0) {         A.x = A.y = 0;         return;       }       A.x = (-(2 * t * k) + sqrt(delta)) / (2 * (k * k + 1));       B.x = (-(2 * t * k) - sqrt(delta)) / (2 * (k * k + 1));       A.y = (r * r - x * x - y * y - D * D + 2 * x * A.x) / (-2 * y);       B.y = (r * r - x * x - y * y - D * D + 2 * x * B.x) / (-2 * y);     } else {       t = (r * r - x * x - y * y - D * D) / (-2 * x);       k = -y / x;       delta = (2 * t * k) * (2 * t * k) - 4 * (k * k + 1) * (t * t - D * D);       if (delta < 0) {         A.x = A.y = 0;         return;       }       A.y = (-(2 * t * k) + sqrt(delta)) / (2 * (k * k + 1));       B.y = (-(2 * t * k) - sqrt(delta)) / (2 * (k * k + 1));       A.x = (r * r - x * x - y * y - D * D + 2 * y * A.y) / (-2 * x);       B.x = (r * r - x * x - y * y - D * D + 2 * y * B.y) / (-2 * x);     }   }   void insert(long double L, long double R) {     tot++;     l[tot].theta = L;     l[tot].op = 1;     tot++;     l[tot].theta = R + 0.0000000001;     l[tot].op = -1;   }   int comp(mod A, mod B) {     return ((A.theta < B.theta) || ((A.theta == B.theta) && (A.op < B.op)));   }   int main() {     scanf( %d%d , &n, &d);     for (i = 1; i <= n; i++) {       scanf( %Lf%Lf%Lf , &c[i].x, &c[i].y, &c[i].r);     }     for (i = 1; i <= n; i++) {       gg = sqrt(c[i].x * c[i].x + c[i].y * c[i].y) / d;       for (D = (long double)max(gg - 100, 1) * (long double)d;            D <= (long double)(gg + 100) * (long double)d; D += (long double)d) {         getAB();         if ((A.x == 0) && (A.y == 0)) continue;         A.theta = atan2(A.x, A.y);         B.theta = atan2(B.x, B.y);         if (A.theta > B.theta) swap(A, B);         L = A.theta;         R = B.theta;         if (R - L > 3.1415926535) swap(L, R);         if (L <= R)           insert(L, R);         else           insert(-3.1415926535, R), insert(L, 3.1415926535);       }     }     sort(l + 1, l + 1 + tot, comp);     for (i = 1; i <= tot; i++) {       S += l[i].op;       ans = max(ans, S);     }     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<int> a;     for (int i = (0); i < (n); i++) {       int t;       cin >> t;       a.push_back(t);     }     vector<int> b;     for (int i = (0); i < (n); i++) {       int t;       cin >> t;       b.push_back(t);     }     sort(a.begin(), a.end(), greater<int>());     sort(b.begin(), b.end(), greater<int>());     long long r = 0;     long long r1 = 0;     int i = 0;     int j = 0;     int nn = 2 * n;     int s = 1;     while (nn--) {       if (s == 1) {         if (i < n && j < n) {           if (a[i] > b[j]) {             r += a[i];             i++;           } else {             j++;           }         } else if (j < n) {           j++;         } else if (i < n) {           r += a[i];           i++;         }       } else {         if (i < n && j < n) {           if (b[j] > a[i]) {             r1 += b[j];             j++;           } else {             i++;           }         } else if (j < n) {           r1 += b[j];           j++;         } else if (i < n) {           i++;         }       }       s ^= 1;     }     cout << r - r1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, k;     cin >> n >> k;     if (k == 1) {       cout <<  Yes  << endl;       return;     }     vector<int> divs;     for (int i = 2; i < k; ++i)       if (!(k % i)) {         cerr << i << endl;         divs.push_back(1);         while (!(k % i)) k /= i, divs.back() *= i;       }     if (k > 1) divs.push_back(k);     set<int> div(divs.begin(), divs.end());     int a;     for (int i = 0; i < n; ++i) {       cin >> a;       set<int>::iterator it = div.begin();       while (it != div.end()) {         if (a % (*it))           ++it;         else           it = div.erase(it);       }     }     if (div.size())       cout <<  No  << endl;     else       cout <<  Yes  << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, color[510];   bool g[510][510];   vector<int> nbr[510];   bool dfs(int x, int c) {     color[x] = c;     for (int i = 0; i < nbr[x].size(); i++) {       int y = nbr[x][i];       if (color[y] == c) return 0;       if (color[y] == 0 && dfs(y, 3 - c) == 0) return 0;     }     return 1;   }   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       g[x][y] = g[y][x] = 1;     }     for (int i = 1; i < n; i++)       for (int j = i + 1; j <= n; j++)         if (g[i][j] == 0) {           nbr[i].push_back(j);           nbr[j].push_back(i);         }     for (int i = 1; i <= n; i++) {       if (color[i] || nbr[i].size() == 0) continue;       if (dfs(i, 1) == 0) {         puts( No );         return 0;       }     }     for (int i = 1; i < n; i++)       for (int j = i + 1; j <= n; j++)         if (color[i] + color[j] == 3 && g[i][j]) {           puts( No );           return 0;         }     puts( Yes );     for (int i = 1; i <= n; i++) {       if (color[i] == 0)         cout <<  b ;       else if (color[i] == 1)         cout <<  a ;       else if (color[i] == 2)         cout <<  c ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int T;     cin >> T;     int Deb = 0;     int Fin = 9;     int Tab[10];     for (int j = 0; j < 10; j++) Tab[j] = 0;     char Cuck;     for (int j = 0; j < T; j++) {       cin >> Cuck;       if (Cuck ==  L ) {         Tab[Deb] = 1;         int curDeb = Deb;         while (Tab[curDeb] == 1 && curDeb < 10) curDeb++;         Deb = curDeb;       } else if (Cuck ==  R ) {         Tab[Fin] = 1;         int curFin = Fin;         while (Tab[curFin] == 1 && curFin >= 0) curFin--;         Fin = curFin;       } else {         int Ind = Cuck - 48;         Tab[Ind] = 0;         int curDeb = 0;         while (Tab[curDeb] == 1 && curDeb < 10) curDeb++;         Deb = curDeb;         int curFin = 9;         while (Tab[curFin] == 1 && curFin >= 0) curFin--;         Fin = curFin;       }     }     for (int j = 0; j < 10; j++) cout << Tab[j];   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     char ch = getchar();     x = 0;     while (!isdigit(ch)) ch = getchar();     while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();   }   int n, m, a[238][238], x[238], y[238];   signed main() {     read(n), read(m);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) read(a[i][j]);     if (n == 1) {       puts( YES );       puts( 0 );       for (int i = 1; i <= m; ++i) a[1][i] ? putchar(48) : putchar(49);       return 0;     }     if (m == 1) {       puts( YES );       for (int i = 1; i <= n; ++i) a[i][1] ? putchar(48) : putchar(49);       puts(  );       return putchar(48), 0;     }     int ok = 1, cnt = 0, w, qwq;     for (int i = 1; i <= m; ++i) y[i] = a[1][i];     for (int i = 2; i <= n; ++i) {       int tmp = 0;       for (int j = 2; j <= m; ++j)         if ((a[i][j] ^ y[j]) != (a[i][j - 1] ^ y[j - 1]))           ++tmp, qwq = (a[i][j] ^ y[j]);       if (tmp) {         cnt += tmp, w = i;         if (cnt > 1) {           ok = 0;           break;         }       }     }     if (ok) {       puts( YES );       if (cnt) {         for (int i = 2; i < w; ++i) x[i] = a[i][1] ^ y[1];         x[w] = qwq ^ 1;         for (int i = w + 1; i <= n; ++i) x[i] = a[i][1] ^ y[1] ^ 1;       } else         for (int i = 2; i <= n; ++i) x[i] = a[i][1] ^ y[1];       for (int i = 1; i <= n; ++i) putchar(x[i] + 48);       puts(  );       for (int i = 1; i <= m; ++i) putchar(y[i] + 48);       return 0;     }     ok = 1, cnt = 0;     for (int i = 1; i <= m; ++i) y[i] = a[n][i] ^ 1;     for (int i = 1; i < n; ++i) {       int tmp = 0;       for (int j = 2; j <= m; ++j)         if ((a[i][j] ^ y[j]) != (a[i][j - 1] ^ y[j - 1]))           ++tmp, qwq = (a[i][j] ^ y[j]);       if (tmp) {         cnt += tmp, w = i;         if (cnt > 1) {           ok = 0;           break;         }       }     }     if (ok) {       puts( YES );       if (cnt) {         for (int i = 1; i < w; ++i) x[i] = a[i][1] ^ y[1];         x[w] = qwq ^ 1;         for (int i = w + 1; i < n; ++i) x[i] = a[i][1] ^ 1 ^ y[1];       } else         for (int i = 1; i < n; ++i) x[i] = a[i][1] ^ y[1];       for (int i = 1; i <= n; ++i) putchar(x[i] + 48);       puts(  );       for (int i = 1; i <= m; ++i) putchar(y[i] + 48);       return 0;     }     return puts( NO ), 0;   }
#include <bits/stdc++.h>   using namespace std;   const int PI = 3.1415926535;   const int inf = 1000111222;   const int mod = 1000000007;   const int N = 100007;   int main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<int> ar(n);     for (int i = 0; i < n; i++) cin >> ar[i];     vector<int> entries;     int ans = 0;     for (int i = 30; i >= 0; i--) {       entries.clear();       for (int j = 0; j < n; j++) {         if ((1 << i) & ar[j]) {           entries.push_back(j);         }       }       if (entries.size() == 1) {         ans = entries[0];         break;       }     }     vector<int> order;     order.push_back(ans);     for (int i = 0; i < n; i++) {       if (i != ans) order.push_back(i);     }     for (int i = 0; i < n; i++) {       cout << ar[order[i]] <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   int n, k;   long long temp[55];   long long dp[105][55], ans;   vector<int> g[105];   void dfs(int u, int fa) {     dp[u][0] = 1;     dp[u][1 + k] = 1;     for (int i = 0; i < g[u].size(); i++) {       int v = g[u][i];       if (v != fa) {         dfs(v, u);         for (int j = 0; j <= 2 * k + 1; j++) temp[j] = 0;         for (int dep1 = 0; dep1 <= 2 * k + 1; dep1++) {           for (int dep2 = 0; dep2 <= 2 * k; dep2++) {             if (dep1 + dep2 <= 2 * k)               temp[min(dep1, dep2 + 1)] =                   (temp[min(dep1, dep2 + 1)] + dp[u][dep1] * dp[v][dep2] % mod) %                   mod;             else               temp[max(dep1, dep2 + 1)] =                   (temp[max(dep1, dep2 + 1)] + dp[u][dep1] * dp[v][dep2] % mod) %                   mod;           }         }         for (int j = 0; j <= 2 * k + 1; j++) dp[u][j] = temp[j];       }     }   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> k;     for (int i = 1, u, v; i < n; i++) {       cin >> u >> v;       g[u].push_back(v);       g[v].push_back(u);     }     dfs(1, 0);     for (int i = 0; i <= k; i++) ans = (ans + dp[1][i]) % mod;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100005];   int main() {     int n, k, sum = 0;     scanf( %d%d , &n, &k);     for (int i = 0; i < n; i++) {       scanf( %d , a + i);       sum += a[i];     }     sort(a, a + n);     int res = a[n - 1];     for (int t = n - k, i = n - k - 1; i >= 0; i--, t++) {       if (res < a[i] + a[t]) {         res = a[i] + a[t];       }     }     if (k == 1)       printf( %d n , sum);     else       printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long i, n, r, S, Z, s1, s2, s3, s4, s5, s6, s7, s8, x, y, z, m, j, l, k,         t;     long long a[500005];     long long b[300045];     long long c[300001];     long long d[100001];     long long e[101][101];     pair<long long, long long> aa[200001];     pair<long long, long long> bb[200001];     double h, w, u, v, uu, vv;     string q1;     string q2;     string q3;     string q4;     string s;     string q;     string sq[50005];     string qs[3001];     map<string, long long> g;     map<string, long long>::iterator it;     cin >> n;     for (i = 1; i <= 100; i++) {       b[i] = 0;     }     for (l = 1; l <= n; l++) {       cin >> m;       for (i = 1; i <= m; i++) {         cin >> x;         b[x]++;       }     }     for (i = 1; i <= 100; i++) {       if (b[i] == n) cout << i <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 50100;   vector<int> v;   int n, k, st, x;   int nextchild[maxn], value[maxn];   void get_rand() {     int arr[n + 1];     for (int i = 0; i < n; i++) {       arr[i] = i + 1;     }     srand(time(0));     random_shuffle(arr, arr + n);     for (int i = 0; i < k; i++) {       v.push_back(arr[i]);     }   }   int main() {     cin >> n >> st >> x;     k = min(n, 1000);     get_rand();     memset(nextchild, 0, sizeof(nextchild));     memset(value, -1, sizeof(value));     cout <<  ?   << st <<   n ;     fflush(stdout);     cin >> value[st] >> nextchild[st];     int maxind = st;     int maxval = value[st];     for (int i : v) {       cout <<  ?   << i <<   n ;       fflush(stdout);       cin >> value[i] >> nextchild[i];       if (value[i] <= x && value[i] > maxval) {         maxval = value[i];         maxind = i;       }     }     int curr = maxind;     int answ = maxind;     while (true) {       cout <<  ?   << curr <<   n ;       fflush(stdout);       cin >> value[curr] >> nextchild[curr];       if (value[curr] >= x || nextchild[curr] == -1)         break;       else         curr = nextchild[curr];     }     if (value[curr] >= x) {       cout <<  !   << value[curr] <<   n ;       fflush(stdout);     } else {       cout <<  ! -1 n ;       fflush(stdout);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200005], b[200005];   int main() {     int n, m, i;     cin >> n >> m;     for (i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     for (i = 0; i < m; i++) cin >> b[i];     for (i = 0; i < m; i++) {       if (i != m - 1)         cout << upper_bound(a, a + n, b[i]) - a <<    ;       else         cout << upper_bound(a, a + n, b[i]) - a << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long K = 401, MAX = 1e18;   int n, m, k, f;   vector<pair<int, int>> adj[2 * K];   vector<pair<int, pair<int, int>>> E;   vector<long long> sp;   long long dist[2 * K];   bool vis[2 * K];   unordered_map<int, int> tb;   priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>       pq;   void dijkstra(int s) {     memset(vis, 0, sizeof(vis));     for (int i = 0; i < f; i++) dist[i] = MAX;     dist[s] = 0;     pq.push({0, s});     while (!pq.empty()) {       int v = pq.top().second, d = pq.top().first;       vis[v] = 1;       pq.pop();       for (pair<int, int> p : adj[v]) {         int u = p.second, w = p.first;         if (vis[u]) continue;         if (dist[v] + w < dist[u]) {           dist[u] = dist[v] + w;           pq.push({dist[u], u});         }       }     }     for (int i = s + 1; i < f; i++)       if (dist[i] < MAX) {         sp.push_back(dist[i]);       }   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m >> k;     for (int i = 0; i < m; i++) {       int x, y, w;       cin >> x >> y >> w;       E.push_back({w, {x, y}});     }     sort(E.begin(), E.end());     for (int i = 0; i < min(k, m); i++) {       int x = E[i].second.first, y = E[i].second.second, w = E[i].first;       if (tb.find(x) == tb.end()) tb[x] = f++;       if (tb.find(y) == tb.end()) tb[y] = f++;       adj[tb[x]].push_back({w, tb[y]});       adj[tb[y]].push_back({w, tb[x]});     }     for (int i = 0; i < f; i++) dijkstra(i);     sort(sp.begin(), sp.end());     cout << sp[k - 1];   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, k, n, t, blow, head, d, h, mx, mxd;     cin >> t;     while (t--) {       cin >> blow >> head;       mx = -1;       mxd = 0;       while (blow > 0) {         cin >> d >> h;         mx = max(mx, d - h);         mxd = max(mxd, d);         blow--;       }       if (mx <= 0 && mxd < head) {         cout << -1 << endl;         continue;       }       int val = (head - mxd) / (mx);       if ((head - mxd) % mx != 0) val++;       val++;       if (mxd >= head) val = 1;       cout << val << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char tmp[120];   int n_t, n_v, n_p;   map<string, string> lei;   vector<string> voids[1005];   vector<string> call;   inline bool cmp(vector<string>& v1, vector<string>& v2) {     int i = 0, j = 0;     while (v1[i] ==    && i < v1.size()) i++;     while (v2[j] ==    && j < v2.size()) j++;     if (v1[i] == v2[j]) {       i++;       j++;     } else {       return false;     }     while (i < v1.size() && j < v2.size()) {       if (v1[i] == v2[j]) {         i++;         j++;       } else if (v1[i] ==  T  || v2[j] ==  T ) {         i++;         j++;       } else {         return false;       }     }     return (v1.size() == i && v2.size() == j);   }   inline string readtype(string& t, int& p) {     string s =   ;     while (islower(t[p]) || isupper(t[p]) || isdigit(t[p])) s += t[p++];     return s;   }   int main() {     int i, j;     string t;     scanf( %d , &n_t);     for (i = 0; i < n_t; i++) {       scanf( %s , tmp);       gets(tmp);       t = tmp;       int l = t.size();       int p = 0;       while (t[p] ==    ) ++p;       for (; p < l; p++) {         if (t[p] ==     || t[p] ==  (  || t[p] ==  )  || t[p] ==  , ) continue;         voids[i].push_back(readtype(t, p));       }     }     scanf( %d , &n_v);     for (i = 0; i < n_v; i++) {       string l, nam;       scanf( %s , tmp), l = tmp;       scanf( %s , tmp), nam = tmp;       lei[nam] = l;     }     scanf( %d , &n_p);     gets(tmp);     for (i = 0; i < n_p; i++) {       call.clear();       gets(tmp);       t = tmp;       int p = 0, l = t.size();       while (t[p] ==    ) ++p;       for (; p < l; p++) {         if (t[p] ==     || t[p] ==  (  || t[p] ==  )  || t[p] ==  , ) continue;         string ss = readtype(t, p);         if (!call.empty())           call.push_back(lei[ss]);         else           call.push_back(ss);       }       int cnt = 0;       for (int j = 0; j < n_t; j++)         if (cmp(call, voids[j])) cnt++;       printf( %d n , cnt);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e8 + 5;   long long MAX = 1e9;   long long MOD = 1e9 + 7;   long long Mod = 1e9 + 7;   double EPS = 0.0001;   long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }   long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }   const int dx[] = {1, -1, 0, 0, 0, 0};   const int dy[] = {0, 0, 1, -1, 0, 0};   int main() {     int n;     string s1;     cin >> n;     cin >> s1;     if (n == 1 || n == 2) {       cout << s1 << endl;       return 0;     }     vector<char> ans(n,  _ );     ans[(n - 1) / 2] = s1[0];     int indx1 = n % 2 == 0 ? n / 2 : n / 2 - 1;     int indx2 = n % 2 == 0 ? n / 2 - 2 : n / 2 + 1;     int dir1 = n % 2 == 0 ? 1 : -1;     int dir2 = n % 2 == 0 ? -1 : 1;     for (int i = 1; i <= n; i++) {       if (i % 2 != 0 && indx1 >= 0 && indx1 < n) {         ans[indx1] = s1[i];         indx1 += dir1;       }       if (i % 2 == 0 && indx2 >= 0 && indx2 < n) {         ans[indx2] = s1[i];         indx2 += dir2;       }     }     for (auto c : ans) cout << c;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long(n), (m);     scanf( %lld%lld , &(n), &(m));     ;     vector<map<long long, long long>> vals(n);     long long maxi = 1;     for (long long i = 0; i < (m); i++) {       long long(a), (b), (c);       scanf( %lld%lld%lld , &(a), &(b), &(c));       ;       --a;       --b;       auto it = vals[a].lower_bound(c);       long long l;       if (!vals[a].size() || it == vals[a].begin())         l = 1;       else {         it--;         l = (*it).second + 1;       }       maxi = max(maxi, l);       auto it2 = vals[b].upper_bound(c);       if (!vals[b].size())         vals[b][c] = l;       else {         if (it2 != vals[b].begin()) {           it2--;           if ((*it2).second >= l) continue;         }         vals[b][c] = l;         it2 = vals[b].lower_bound(c);         it2++;         vector<long long> v;         while (it2 != vals[b].end() && (it2->second) <= l) {           v.push_back(it2->first);           it2++;         }         for (auto j : v) vals[b].erase(j);       }     }     printf( %lld n , maxi);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int n, l;     cin >> n >> l;     vector<int> a(n, 0), b(n, 0);     for (int i = 0; i < n; ++i) cin >> a[i];     for (int i = 0; i < n; ++i) cin >> b[i];     if (n == 1)       cout <<  YES n ;     else {       vector<int> a_diff, b_diff, result;       int check_sum = 0;       for (int i = 1; i < n; ++i) {         a_diff.push_back(a[i] - a[i - 1]);         b_diff.push_back(b[i] - b[i - 1]);       }       a_diff.push_back(l - a[n - 1] + a[0]);       b_diff.push_back(l - b[n - 1] + b[0]);       for (int i = 0; i < n; ++i) a_diff.push_back(a_diff[i]);       int i = 0, j = 0, prev_i = 0;       while (i < 2 * n && j < n) {         while (i < 2 * n && b_diff[0] != a_diff[i]) ++i;         j = 0;         prev_i = i;         while (i < 2 * n && j < n && b_diff[j] == a_diff[i]) ++i, ++j;         i = prev_i + 1;         if (j == n) {           cout <<  YES n ;           return 0;         }       }       cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 5;   long long n, m, ans, a, b, temp;   int t;   long long num[maxn];   long long mark[maxn];   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> num[i];       num[i] = abs(num[i]);     }     sort(num, num + n);     int l = 0, r = 0;     while (l < n) {       while (r < n && 2 * num[l] >= num[r]) {         r++;       }       ans += r - l - 1;       l++;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   void dk_98() {}   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   void solve() {     int n;     cin >> n;     int arr[n][n];     for (long long i = 0; i < (int)(n); i++) {       for (long long j = 0; j < (int)(n); j++) {         cin >> arr[i][j];       }     }     if (n == 1) {       cout << 0;       return;     }     int ans[n];     memset(ans, 0, sizeof(ans));     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (j != i) ans[i] = ans[i] | arr[i][j];       }     }     for (long long i = 0; i < (int)(n); i++) {       cout << ans[i] <<    ;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     dk_98();     int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1000000000 + 7;   const long long int N = 1000000 + 6;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int tc;     tc = 1;     while (tc--) {       long long int n, m;       cin >> n >> m;       string s[n];       for (long long int i = 0; i < n; i++) cin >> s[i];       long long int d[m];       for (long long int i = 0; i < m; i++) cin >> d[i];       long long int ans = 0;       for (long long int j = 0; j < m; j++) {         map<char, long long int> p;         long long int t = 0;         for (long long int i = 0; i < n; i++) {           p[s[i][j]]++;           t = max(t, p[s[i][j]]);         }         ans += t * d[j];       }       cout << ans;     }   }