malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void in(int &x) {     register int c = getchar();     x = 0;     for (; (c < 48 || c > 57); c = getchar())       ;     for (; c > 47 && c < 58; c = getchar()) {       x = (x << 1) + (x << 3) + c - 48;     }   }   long long mod;   bool prime(int n) {     int i;     if (n % 2 == 0 && n > 2) return false;     for (i = 3; i * i <= n; i += 2)       if (n % i == 0) return false;     return true;   }   long long powmod(long long base, long long exp) {     long long res = 1;     while (exp) {       if (exp & 1) res = (res * base) % mod;       base = (base * base) % mod;       exp >>= 1;     }     return res;   }   int main() {     int n, i, x;     in(n);     if (n == 1) {       puts( YES n1 );       return 0;     }     if (n == 4) {       puts( YES n1 n3 n2 n4 );       return 0;     }     if (!prime(n)) {       puts( NO );       return 0;     }     mod = n;     puts( YES n1 );     for (i = 2; i < n; i++) printf( %lld n , i * powmod(i - 1, n - 2) % n);     printf( %d n , n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = (int)1e9;   const int mod = (int)1e9 + 7;   const double PI = acos(-1.0);   const int MAX = 400009;   int n;   char s[MAX], ans[MAX];   int occ[250];   int main(int argc, char* argv[]) {     scanf( %d , &n);     scanf( %s , s);     for (int i = 0; i < n; i++) occ[s[i]]++;     int odd = 0;     vector<char> a;     for (int i = 0; i < 130; i++) {       odd += (occ[i] & 1);       if (occ[i] & 1) {         a.push_back(i);         --occ[i];       }     }     for (int i = 0; i < 130; i++)       while (occ[i]--) a.push_back(i);     reverse((a).begin(), (a).end());     for (int i = 0; i < n; i++) ans[i] =  * ;     for (int d = 1; d <= n; d++)       if (n % d == 0 && d >= odd && (!odd || ((n / d) % 2 == 1))) {         int nbr = d, len = n / d;         for (int i = 0; i < nbr && odd; i++) {           ans[len * i + len / 2] = a.back();           a.pop_back();         }         cout << nbr << endl;         for (int i = 0; i < nbr; i++)           for (int j = 0; j < len / 2; j++) {             ans[len * i + j] = a.back();             a.pop_back();             ans[len * i + len - 1 - j] = a.back();             a.pop_back();           }         for (int i = 0; i < nbr; i++) {           if (i) cout <<    ;           for (int j = 0; j < len; j++) cout << ans[i * len + j];         }         cout << endl;         return 0;       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, p, i, t, ans, a[101];   char s[101];   int main() {     scanf( %I64d%I64d , &n, &p);     for (i = 1; i <= n; i++) {       scanf( %s n , &s);       if (strlen(s) > 4) a[i] = 1;     }     for (i = n; i; i--) {       ans += t * p;       if (a[i]) ans += p / 2;       t = t * 2 + a[i];     }     printf( %I64d , ans);   }
#include <bits/stdc++.h>   using namespace std;   char str[5009];   int main() {     int a = 0, b = 0, c = 0, i;     scanf( %s , str);     int n = strlen(str);     for (i = 0; str[i] ==  a ; i++) a++;     for (; str[i] ==  b ; i++) b++;     for (; str[i] ==  c ; i++) c++;     if (a && b && n == a + b + c && (a == c || c == b)) {       printf( YES n );     } else {       printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, temp;     cin >> n;     temp = n;     vector<pair<long long, int> > v;     for (int i = 2; i <= sqrt(n); i++) {       int count = 0;       while (temp % i == 0) {         temp /= i;         count++;       }       if (count != 0) v.push_back(make_pair(i, count));     }     long long num = 0, flag = 0;     if (temp != 1) v.push_back(make_pair(temp, 1));     if ((v.size() == 2 and v[0].second == 1 and v[1].second == 1) or         (v.size() == 1 and v[0].second == 2))       cout <<  2  << endl;     else {       cout <<  1 n ;       for (int i = 0; i < v.size(); i++) {         if (v[i].second > 2) {           num = v[i].first * v[i].first;           flag = 1;           break;         }       }       if (flag == 0 and v.size() >= 2) num = v[0].first * v[1].first;       cout << num << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int k = 0;       int i = 1;       while (k < n) {         if (i % 3 == 0 || to_string(i).back() ==  3 ) {         } else           ++k;         ++i;       }       cout << --i << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[100000];   int n;   priority_queue<pair<int, int>, vector<pair<int, int> >,                  greater<pair<int, int> > >       q;   int rankHash[100000];   int indHash[100000];   vector<pair<int, int> > ans;   int main(void) {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , arr + i);     bool isSorted = true;     int lucky = -1;     for (int i = 0; i < n - 1; i++) {       if (arr[i + 1] < arr[i]) {         isSorted = false;         break;       }     }     if (isSorted) {       printf( 0 n );       return 0;     }     for (int i = 0; i < n; i++) {       int tar = arr[i];       bool isLucky = true;       while (tar) {         if (tar % 10 != 4 && tar % 10 != 7) {           isLucky = false;           break;         }         tar /= 10;       }       if (isLucky) {         lucky = i;         break;       }     }     if (lucky == -1) {       printf( -1 n );       return 0;     }     for (int i = 0; i < n; i++) q.push(make_pair(arr[i], i));     for (int i = 0; i < n; i++) {       rankHash[i] = q.top().second;       q.pop();     }     for (int i = 0; i < n; i++) indHash[rankHash[i]] = i;     for (int i = 0; i < n; i++) {       if (i != lucky) {         ans.push_back(make_pair(i + 1, lucky + 1));         rankHash[indHash[i]] = lucky;         rankHash[indHash[lucky]] = i;         swap(indHash[i], indHash[lucky]);         lucky = i;       }       if (lucky != rankHash[i]) {         ans.push_back(make_pair(lucky + 1, rankHash[i] + 1));         int r1 = i;         int r2 = indHash[lucky];         int i1 = rankHash[r1];         int i2 = rankHash[r2];         rankHash[r2] = i1;         rankHash[r1] = lucky;         swap(indHash[i1], indHash[i2]);         lucky = i1;       }     }     printf( %d n , (int)ans.size());     for (int i = 0; i < ans.size(); i++)       printf( %d %d n , ans[i].first, ans[i].second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     string str;     cin >> n >> str;     int a = 0;     int d = 0;     for (int i = 0; i < n; i++) {       if (str[i] ==  A ) {         a++;       } else {         d++;       }     }     if (a > d) {       cout <<  Anton  << endl;     } else if (a < d) {       cout <<  Danik  << endl;     } else {       cout <<  Friendship  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> cnt;   int n;   int m;   int dp[500][100005];   vector<int> num;   map<int, int> can;   int ind = 0;   int dpnum[500];   map<int, int> mpind;   map<int, int> mpvis;   int main() {     scanf( %d%d , &n, &m);     int x;     for (int i = 0; i < n; i++) {       scanf( %d , &x);       num.push_back(x);       if (can[x] == 0) {         if (cnt[x] < x) {           cnt[x]++;         }         if (cnt[x] == x) {           can[x] = 1;         }       }     }     for (int i = 0; i < n; i++) {       if (!can[num[i]]) continue;       if (mpind[num[i]] != 0) continue;       if (mpind[num[i]] == 0) {         ind++;         mpind[num[i]] = ind;         dpnum[ind] = num[i];       }       int tind = mpind[num[i]];       for (int j = 0; j < n; j++) {         if (j == 0) {           if (num[j] == num[i])             dp[tind][j + 1] = 1;           else             dp[tind][j + 1] = 0;         } else {           if (num[j] == num[i])             dp[tind][j + 1] = dp[tind][j] + 1;           else             dp[tind][j + 1] = dp[tind][j];         }       }     }     int l, r;     for (int i = 0; i < m; i++) {       scanf( %d%d , &l, &r);       int ans = 0;       for (int i = 1; i <= ind; i++) {         if (dp[i][r] - dp[i][l - 1] == dpnum[i]) {           ans++;         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long s[110000], a[110000];   int main() {     int n;     scanf( %d , &n);     a[0] = 1;     for (int i = 1; i <= 500; i++) a[i] = a[i - 1] * 2 % 1000000007;     memset(s, 0, sizeof(s));     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       if (x != -1) s[x]++;     }     long long now = 0;     for (int i = 1; i <= n; i++)       if (s[i] > 0) {         now = now + a[s[i]] - 1;         now = (now % 1000000007 + 1000000007) % 1000000007;       }     long long ans = a[n - 1] - 1 - now;     ans = (ans % 1000000007 + 1000000007) % 1000000007;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     long long x, y;     point(long long _x, long long _y) {       x = _x;       y = _y;     }     point() {}   };   struct cmp {     bool operator()(point a, point b) { return (a.x < b.x); }   };   struct vec {     long long x, y;     vec(long long _x, long long _y) {       x = _x;       y = _y;     }     vec() {}   };   set<point, cmp> daftar;   int q, jenis, last = 0;   long long totalmana, a, b;   bool ans;   long double gradien(point p1, point p2) {     return (long double)(p1.y - p2.y) / (p1.x - p2.x);   }   long double manacost(long double indeks) {     set<point, cmp>::iterator it1, it2;     it1 = daftar.lower_bound(point((long long)indeks, 0));     it2 = daftar.upper_bound(point((long long)indeks, 0));     if (it1 == it2) it1--;     if (it2 == daftar.end()) return 1000000000001LL;     return (long double)it1->y +            gradien(*it1, *it2) * ((long double)indeks - it1->x);   }   vec toVec(point awal, point akhir) {     return vec(akhir.x - awal.x, akhir.y - awal.y);   }   long double cross(vec v1, vec v2) {     return (long double)v1.x * (long double)v2.y -            (long double)v1.y * (long double)v2.x;   }   long double cross(point p1, point p2, point p3) {     return cross(toVec(p1, p2), toVec(p1, p3));   }   int keatas(int pembilang, int penyebut) {     int ret = pembilang / penyebut;     if ((pembilang % penyebut) != 0) ret++;     return ret;   }   void seimbangkan(point baru) {     auto it = daftar.find(baru);     while (prev(it) != daftar.begin()) {       auto it2 = prev(it);       auto it3 = prev(it2);       if (cross(*it3, *it2, *it) > 1e-9) break;       daftar.erase(it2);     }     while (next(it) != daftar.end()) {       auto it2 = next(it);       auto it3 = next(it2);       if (cross(*it, *it2, *it3) > 1e-9) break;       daftar.erase(it2);     }   }   int main() {     daftar.insert(point(0, 0));     scanf( %d%lld , &q, &totalmana);     for (int query = 1; query <= q; query++) {       scanf( %d%lld%lld , &jenis, &a, &b);       a = (a + last) % 1000000 + 1;       b = (b + last) % 1000000 + 1;       if (jenis == 1) {         if (manacost(a) > (long double)b + 1e-9) {           daftar.insert(point(a, b));           seimbangkan(point(a, b));         }       } else {         swap(a, b);         auto it = daftar.lower_bound(point((a + b - 1) / b, 0));         ans = false;         if (it != daftar.end()) {           if (it->y * b <= totalmana)             ans = true;           else {             auto it2 = prev(it);             if ((cross(toVec(point(it2->x * b, it2->y * b), point(a, totalmana)),                        toVec(point(it2->x * b, it2->y * b),                              point(it->x * b, it->y * b)))) < 1e-9)               ans = true;           }         }         if (ans)           printf( YES n ), last = query;         else           printf( NO n );       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int maxn = 125;   const int maxm = 305;   const int mod = 20090717;   vector<int> v;   int main() {     long long x;     scanf( %lld , &x);     while (x > 0) v.push_back(x % 2), x /= 2;     while (v.size() < 6) v.push_back(0);     long long ans = 0;     reverse(v.begin(), v.end());     ans = ans * 2 + v[0];     ans = ans * 2 + v[5];     ans = ans * 2 + v[3];     ans = ans * 2 + v[2];     ans = ans * 2 + v[4];     ans = ans * 2 + v[1];     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   void Solve();   int main() { Solve(); }   using namespace std;   const int INF = 1e9;   const int N = 20;   const double e = 1E-10;   int hm, am, dm;   int check(int ay, int dy) {     int m = max(0, ay - dm), y = max(0, am - dy);     if (!m) return -1;     return (hm / m + (hm % m != 0)) * y + 1;   }   void Solve() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int hy, ay, dy, h, a, d, mn = 1e9;     cin >> hy >> ay >> dy >> hm >> am >> dm >> h >> a >> d;     for (int i = 0; i <= 200; i++) {       for (int j = 0; j <= 200; j++) {         int hp = check(ay + i, dy + j);         if (hp == -1) continue;         mn = min(mn, max(0, hp - hy) * h + i * a + j * d);       }     }     cout << mn;   }
#include <bits/stdc++.h>   using namespace std;   const long long Ar[20] = {1,                             1,                             2,                             3,                             6,                             40,                             80,                             1260,                             2520,                             72576,                             145152,                             6652800,                             13305600,                             889574400,                             1779148800,                             163459296000,                             326918592000,                             39520825344000,                             79041650688000,                             12164510040883200};   void Input() {     long long n;     cin >> n;     cout << Ar[n - 1];   }   int main() {     if (fopen( trash.inp ,  r ))       freopen( trash.inp ,  r , stdin), freopen( trash.out ,  w , stdout);     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     Input();   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void read(T &k) {     k = 0;     int flag = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) flag = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       k = k * 10 + c -  0 ;       c = getchar();     }     k *= flag;   }   const int N = 105;   int n, m, k, s, t, a[N];   char c[N];   long long f[N][N][N][2];   inline long long max3(long long a, long long b, long long c) {     return max(max(a, b), c);   }   int main() {     read(n);     cin >> c + 1;     for (int i = 1; i <= n; ++i) read(a[i]);     memset(f, -0x3f, sizeof(f));     for (int i = 1; i <= n; ++i)       for (int j = i + 1; j <= n; ++j) a[j] = max(a[j], a[j - i] + a[i]);     for (int i = 1; i <= n; ++i) {       f[i][i][1][c[i] -  0 ] = 0;       f[i][i][0][0] = a[1];     }     for (int l = 1; l < n; ++l)       for (int i = 1; i + l <= n; ++i) {         int j = i + l;         for (int k = i; k < j; ++k) {           f[i][j][0][0] = max(f[i][j][0][0], f[i][k][0][0] + f[k + 1][j][0][0]);           f[i][j][1][0] = max3(f[i][j][1][0], f[i][k][1][0] + f[k + 1][j][0][0],                                f[i][k][0][0] + f[k + 1][j][1][0]);           f[i][j][1][1] = max3(f[i][j][1][1], f[i][k][1][1] + f[k + 1][j][0][0],                                f[i][k][0][0] + f[k + 1][j][1][1]);         }         for (int p = 2; p <= l + 1; ++p)           for (int k = i; k < j; ++k) {             f[i][j][p][0] =                 max(f[i][j][p][0], f[i][k][1][0] + f[k + 1][j][p - 1][0]);             f[i][j][p][1] =                 max(f[i][j][p][1], f[i][k][1][1] + f[k + 1][j][p - 1][1]);           }         for (int p = 1; p <= l + 1; ++p)           f[i][j][0][0] =               max3(f[i][j][0][0], f[i][j][p][0] + a[p], f[i][j][p][1] + a[p]);       }     cout << f[1][n][0][0] << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   int a[15][110], b[15][110], c[15][110];   char buf[15];   int calc(int p, int q) {     static pair<int, int> d[110];     int cnt = k, res = 0;     for (int i = 1; i <= m; i++)       d[i].first = b[q][i] - a[p][i], d[i].second = c[p][i];     sort(d + 1, d + m + 1, greater<pair<int, int> >());     for (int i = 1; i <= m && d[i].first > 0; i++) {       if (cnt <= d[i].second) {         res += d[i].first * cnt;         break;       }       res += d[i].first * d[i].second;       cnt -= d[i].second;     }     return res;   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; i++) {       scanf( %s , buf);       for (int j = 1; j <= m; j++) scanf( %d%d%d , &a[i][j], &b[i][j], &c[i][j]);     }     int ans = 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (i != j) ans = max(ans, calc(i, j));     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   #define ll long long int   using namespace std;      int main() {         ll t;    cin>>t;    while(t--)    {       ll x,y;       cin>>x>>y;       if(x==y)       {           cout<<x+y<<  n ;       }       else       {           cout<<2*max(x,y)-1<<  n ;       }    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int x = 1;     map<int, int> m;     int y = 1;     m[x] = 1;     while (y < 1001) {       m[y] = 1;       int temp = y + x;       x = y;       y = temp;     }     m[y] = 1;     for (int i = 1; i <= n; i++) {       if (m[i] == 1) {         cout <<  O ;       } else         cout <<  o ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000100;   const int INF = 1e9 + 10;   int c, n;   int a[maxn], b[maxn];   int cnt[maxn];   bool check(int anow, int &now) {     int bnow = b[now] - anow;     if (bnow <= 0) {       if (now <= n && anow + 1 > a[now]) now++;       return 0;     }     int tmp = bnow;     for (int i = now - 1; i >= 1; i--) {       tmp -= min(tmp / a[i], cnt[i]) * a[i];       if (tmp == 0) {         if (now <= n && anow + 1 > a[now]) now++;         return 0;       }     }     return 1;   }   int main() {     while (cin >> c >> n) {       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       sort(a + 1, a + n + 1);       memset(cnt, 0, sizeof(cnt));       int m = 1;       cnt[1] = 1;       for (int i = 2; i <= n; i++) {         if (a[i] != a[i - 1])           a[++m] = a[i], cnt[m] = 1;         else           cnt[m]++;       }       n = m;       int tmp = c;       b[n + 1] = tmp;       for (int i = n; i >= 1; i--) {         tmp -= min(tmp / a[i], cnt[i]) * a[i];         b[i] = tmp;       }       if (tmp) {         puts( 0 );         continue;       }       int res = 0;       int now = 1;       for (int i = 1; i <= c; i++) {         if (check(i, now)) {           res = i;           break;         }       }       if (res)         printf( %d n , res);       else         puts( Greed is good );     }     return 0;   }
#include <bits/stdc++.h>   const int MAXN = int(2e5);   int n, k, cnt, A, tot[2 * MAXN + 5];   bool flag;   long long ans;   int read(int &x) {     char c = getchar();     int a = 0, b = 1;     while ( 0  > c || c >  9 ) b = c ==  -  ? -1 : b, c = getchar();     while ( 0  <= c && c <=  9 ) a = a * 10 + c -  0 , c = getchar();     return x = a * b;   }   int main() {     read(n);     read(k);     tot[MAXN]++;     for (int i = 0; i < n; i++) {       read(A);       if (A == k) flag = true;       if (A > k) cnt++;       if (A < k) cnt--;       if (!flag)         tot[cnt + MAXN]++;       else         ans += tot[cnt + MAXN] + tot[cnt + MAXN - 1];     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   int n, m, k;   const int maxn = 1100000;   int has[maxn];   pair<int, int> buy[maxn];   int tmp[maxn * 2];   bool test(int mid) {     for (int i = 1; i <= n; i++) tmp[i] = has[i];     for (int i = 1; i <= mid; i++) {       tmp[i + n] = buy[i].first;     }     sort(tmp + 1, tmp + 1 + n + mid);     int dd = 0;     int cnt = 0;     bool du = true;     for (int i = 1; i <= n + mid; i++) {       if (dd > tmp[i]) {         du = false;         break;       }       cnt++;       if (cnt == k) {         dd++;         cnt = 0;       }     }     return du;   }   void solve() {     int dd = 0;     int cnt = 0;     bool du = true;     for (int i = 1; i <= n; i++) {       if (dd > has[i]) {         du = false;         break;       }       cnt++;       if (cnt == k) {         dd++;         cnt = 0;       }     }     if (du == false) {       cout << -1 << endl;       return;     }     int l = 0;     int r = m;     int ans = 0;     while (l <= r) {       int mid = (l + r) / 2;       if (test(mid)) {         ans = max(ans, mid);         l = mid + 1;       } else         r = mid - 1;     }     cout << ans << endl;     for (int i = 1; i <= ans; i++) {       if (i == 1)         printf( %d , buy[i].second);       else         printf(  %d , buy[i].second);     }     cout << endl;   }   int main() {     while (cin >> n >> m >> k) {       for (int i = 1; i <= n; i++) scanf( %d , &has[i]);       for (int i = 1; i <= m; i++) {         int x;         scanf( %d , &x);         buy[i].first = x;         buy[i].second = i;       }       sort(has + 1, has + n + 1);       sort(buy + 1, buy + m + 1);       reverse(buy + 1, buy + m + 1);       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, i, a, b, j, pos = 0, neg = 0, flag = 0, temp;     string st, st2, st3;     vector<long long int> v2, v;     long long int ar[100001] = {0};     cin >> a >> b;     if (a == 1) {       cout << b;       return 0;     } else if (b == 1) {       cout << a;       return 0;     }     while (a > 0 && b > 0) {       if (a == b) {         a = 0;         b = 0;         flag++;       } else if (a < b) {         flag += b / a;         b = b % a;       } else if (b < a) {         flag += a / b;         a = a % b;       }     }     cout << flag;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ne(long long a) {     long long k = pow(a, 0.5);     if (k * k == a) {       return 0;     }     return min(a - (k * k), (k + 1) * (k + 1) - a);   }   int main() {     long long n;     cin >> n;     vector<pair<long long, long long> > a(n, make_pair(0, 0));     for (long long i = 0; i < n; i++) {       cin >> a[i].second;       a[i].first = ne(a[i].second);     }     sort(a.begin(), a.end());     if (a[n / 2].first == 0) {       long long c = 0;       long long u = n / 2;       long long count = 0;       while (u < n && a[u].first == 0) {         c++;         u++;       }       u = c;       for (long long i = 0; i < n; i++) {         if (a[i].first == 0 && a[i].second != 0) {           u--;           count++;         }         if (u == 0) {           break;         }       }       while (u--) {         count += 2;       }       cout << count << endl;     } else {       long long count = 0;       for (long long i = 0; i < n / 2; i++) {         count = count + a[i].first;       }       cout << count << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int nax = 1e6 + 10;   vector<int> tree(4 * nax);   long long i, j, x, y, k, val;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t--) {       long long r, g, b;       cin >> r >> g >> b;       vector<long long> v;       v.push_back(r), v.push_back(g), v.push_back(b);       sort(v.begin(), v.end());       if (v[2] >= v[1] + v[0])         cout << v[1] + v[0] << endl;       else         cout << (v[0] + v[1] + v[2]) / 2 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c, d;   long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }   int main() {     scanf( %lld %lld %lld %lld , &a, &b, &c, &d);     long long ans = gcd(c, d);     long long ans1 = c / ans;     long long ans2 = d / ans;     ans = min(a / ans1, b / ans2);     printf( %lld n , ans);     return 0;   }