malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int arr[n];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     sort(arr, arr + n);     int runsum = 0;     int pen = 0;     int k = 0;     while (runsum <= 350 && ((runsum + arr[k]) <= 710) && k < n)       runsum += arr[k++];     if (runsum <= 350) {       cout << k <<   0  << endl;     } else {       runsum -= 350;       pen += runsum;       while ((runsum + arr[k]) <= 360 && k < n) {         runsum += arr[k++];         pen += runsum;       }       cout << k <<     << pen << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int temp1[26];   int temp2[1001][26];   set<int> myset[1001];   set<int> empty;   vector<int> myvec;   int main() {     int n;     cin >> n;     string str;     cin >> str;     int m;     cin >> m;     string arr[m];     for (int i = 0; i < m; i++) {       cin >> arr[i];     }     for (int i = 0; i < n; i++) {       if (str[i] !=  * ) {         temp1[str[i] -  a ] = 1;       }     }     for (int i = 0; i < m; i++) {       for (int j = 0; j < n; j++) {         if (str[j] ==  * ) {           if (temp1[arr[i][j] -  a ] == 1) {             myset[i] = empty;             break;           } else {             myset[i].insert(arr[i][j] -  a );             temp2[i][arr[i][j] -  a ] = 1;           }         } else {           if (str[j] != arr[i][j]) {             myset[i] = empty;             break;           }         }       }     }     for (int i = 0; i < m; i++) {       if (myset[i].empty() == false) {         myvec.push_back(i);       }     }     int ans = 0;     int size = myvec.size();     for (int j = 0; j < 26; j++) {       int cnt = 0;       for (int i = 0; i < size; i++) {         if (temp2[myvec[i]][j] == 1) {           cnt++;         }       }       if (cnt == size) {         ans++;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 100;   vector<int> G[MAXN];   map<int, int> cnt;   bool vis[MAXN];   int sz;   int cN, c[MAXN], b[MAXN];   int dp[MAXN];   void dfs(int u) {     vis[u] = true;     sz++;     for (int i = 0; i < G[u].size(); i++) {       int v = G[u][i];       if (!vis[v]) dfs(v);     }   }   inline int smin(int &a, int b) { return a = min(a, b); }   bool lucky(int x) {     while (x) {       if (x % 10 != 7 && x % 10 != 4) return false;       x /= 10;     }     return true;   }   int main() {     ios::sync_with_stdio(false);     cout.tie(0);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       G[a].push_back(b);       G[b].push_back(a);     }     for (int u = 0; u < n; u++)       if (!vis[u]) {         sz = 0;         dfs(u);         cnt[sz]++;       }     for (map<int, int>::iterator iter = cnt.begin(); iter != cnt.end(); iter++) {       int x = iter->first, pw = 1;       int temp = iter->second;       while (temp >= pw) {         c[cN++] = x * pw, b[cN - 1] = pw, temp -= pw;         pw *= 2;       }       if (temp) {         c[cN++] = x * temp;         b[cN - 1] = temp;       }     }     fill(dp, dp + MAXN, -1u / 4);     dp[0] = 0;     for (int i = 0; i < cN; i++) {       int val = c[i];       for (int j = MAXN - 1; j >= 0; j--)         if (val + j < MAXN) smin(dp[j + val], dp[j] + b[i]);     }     int ans = -1u / 4;     for (int i = 1; i < MAXN; i++)       if (lucky(i)) smin(ans, dp[i]);     cout << (ans < MAXN ? ans - 1 : -1) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int xx = 0, ff = 1;     char ch = getchar();     while (ch >  9  || ch <  0 ) {       if (ch ==  - ) ff = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       xx = xx * 10 + ch -  0 ;       ch = getchar();     }     return xx * ff;   }   int N, K, f[110][100010];   struct Segment {     int L, R;   } S[110];   int q[100010], head, tail;   int main() {     N = read(), K = read();     for (int i = 1; i <= K; i++) S[i].L = read(), S[i].R = read();     for (int j = 0; j <= N; j++) f[0][j] = (1 << 29);     f[0][0] = 0;     for (int i = 1; i <= K; i++) {       for (int j = 0; j <= N; j++) f[i][j] = f[i - 1][j];       head = 1, tail = 0;       for (int j = 0; j <= S[i].R; j++) {         if (j <= N) {           while (head <= tail && f[i - 1][j] <= f[i - 1][q[tail]]) tail--;           q[++tail] = j;         }         while (head <= tail && q[head] <= j - (S[i].R - S[i].L + 1)) head++;         if (head <= tail) f[i][j] = min(f[i][j], f[i - 1][q[head]] + 2);       }       head = 1, tail = 0;       for (int j = S[i].R; j >= 0; j--) {         if (S[i].R - j <= N) {           while (head <= tail && f[i - 1][S[i].R - j] <= f[i - 1][q[tail]])             tail--;           q[++tail] = S[i].R - j;         }         while (head <= tail && q[head] <= S[i].L - (j + 1)) head++;         if (head <= tail) f[i][j] = min(f[i][j], f[i][q[head]] + 1);       }     }     if (f[K][N] >= (1 << 29))       puts( Hungry );     else {       puts( Full );       printf( %d n , f[K][N]);     }     return 0;   }
#include<bits/stdc++.h>   #define pb push_back   using namespace std;   typedef long long ll;   const int maxn=1e6+100;   const int M=1000000007;   typedef array<int,41> A;   bool vis[50];   int f[50],n,mx,F[50][50],G[50][50],p[50],nf[50],inv[50];   int ways[50][50][50];   map<A,int> dp[41][41][41];   void add(int &x,int y){x+=y;if (x>=M)x-=M;}   int C(int x,int y){    if (y<0||y>x) return 0;    return 1ll*f[x]*nf[y]%M*nf[x-y]%M;   }   void init(){    inv[1]=1; for (int i=2;i<=n;i++) inv[i]=M-1ll*(M/i)*inv[M%i]%M;    f[0]=nf[0]=1; for (int i=1;i<=n;i++) f[i]=1ll*f[i-1]*i%M,nf[i]=1ll*nf[i-1]*inv[i]%M;    F[0][0]=f[n-1];    for (int i=0;i<=n-1;i++)    for (int j=1;j+i<=n-1;j++){           F[i][j]=0;           for (int x=0;x<=i;x++)      for (int y=0;y<=j;y++){       add(F[i][j],1ll*C(i,x)*C(j,y)%M*f[n-1-x-y]%M*f[x+y]%M);       if (!y) add(G[i][j],1ll*C(i,x)*C(j,y)%M*f[n-1-x-y]%M*f[x+y]%M);      }    }    for (int i=0;i<=n-1;i++)    for (int j=0;j+i<=n-1;j++){     int x=1,y=1;     for (int k=1;k<=n;k++){      x=1ll*x*F[i][j]%M;      y=1ll*y*G[i][j]%M;      ways[i][j][k]=(x-y+M)%M;     }    }   }   int solve(int lasttot,int tot,int block,A a){       if (dp[lasttot][tot][block].find(a)!=dp[lasttot][tot][block].end()){     return dp[lasttot][tot][block][a];       }       int ret=0,sum=n;       for (int i=1;i<=mx;i++) sum-=a[i]*i;       if (sum==n) return dp[lasttot][tot][block][a]=nf[block];    A tmp=a;       for (int i=1;i<=mx;i++) {     if (a[i]){      tmp[i]--;               add(ret,1ll*ways[sum-tot-lasttot][lasttot][i]*a[i]%M*solve(lasttot,tot+i,block+1,tmp)%M);               if (block) add(ret,1ll*ways[sum-tot][tot][i]*a[i]%M*nf[block]%M*solve(tot,i,1,tmp)%M);      tmp[i]++;     }       }       return dp[lasttot][tot][block][a]=ret;   }   int main(){    scanf( %d ,&n);    init();    for (int i=1;i<=n;i++) scanf( %d ,&p[i]);    A a;    for (int i=0;i<=40;i++) a[i]=0;    for (int i=1;i<=n;i++) if (!vis[i]){     int w=0,tmp=i;     while (!vis[tmp]){      w++;      vis[tmp]=1;      tmp=p[tmp];     }     a[w]++;     mx=max(mx,w);    }    printf( %d n ,solve(0,0,0,a));    return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s;     cin >> s;     long long l = s.length();     vector<char> s1;     long long pos = -1;     for (long long i = 0; i < l; i++) {       if (s[i] ==  a )         pos = i;       else         s1.push_back(s[i]);     }     long long l2 = s1.size();     long long ri = l - 1 - pos;     long long le = l2 - ri;     if (l2 % 2 != 0 || le > ri)       cout <<  :( ;     else {       long long j = l2 / 2;       bool flag = true;       for (long long i = 0; i < j; i++) {         if (s1[i] != s1[i + j]) {           flag = false;           break;         }       }       if (!flag)         cout <<  :( ;       else {         for (long long i = 0; i < l - j; i++) cout << s[i];       }     }   }
#include <bits/stdc++.h>   using namespace std;   struct node {     long long x, y;     int id;     bool operator<(const node& b) const {       if (y != b.y)         return y < b.y;       else         return x < b.x;     }   } a[210000], b[210000], c, d[210000];   vector<node> q;   int n, num, last;   int ans[210000];   set<node> s;   int main() {     cin >> n;     for (int i = 1; i <= n; i++)       cin >> a[i].x >> a[i].y, a[i].id = i, d[i] = a[i];     sort(a + 1, a + 1 + n);     for (int i = n; i >= 1; i--)       if (a[i].x > last) last = a[i].x, b[++num] = a[i];     reverse(b + 1, b + 1 + num);     for (int i = 1; i <= num; i++) {       while (q.size() > 1) {         node c = q[q.size() - 1], d = q[q.size() - 2];         if ((c.y - d.y) * d.x * b[i].y * (c.x - b[i].x) <             (b[i].y - c.y) * b[i].x * d.y * (d.x - c.x))           q.pop_back();         else           break;       }       q.push_back(b[i]);     }     num = 0;     for (int i = 0; i < q.size(); i++) s.insert(q[i]);     for (int i = 1; i <= n; i++)       if (s.count(d[i])) printf( %d  , i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, a, b;       cin >> n >> a >> b;       int N = n;       if (abs(a - b) > 1) {         cout << -1 <<   n ;         continue;       }       if (a + b > n - 2) {         cout << -1 <<   n ;         continue;       }       bool flag = false;       if (a < b) {         swap(a, b);         flag = true;       }       int A = a;       int B = b;       int sol[n];       int i = 1;       while (a--) {         sol[i] = n;         i += 2;         n--;       }       i = 2;       int temp = 1;       while (b--) {         sol[i] = temp;         i += 2;         temp++;       }       sol[0] = B + 1;       temp = B + 2;       int index = A + B + 1;       if (B == A) {         while (index != N) {           sol[index] = temp;           temp++;           index++;         }       } else {         temp = N - A;         while (index != N) {           sol[index] = temp;           temp--;           index++;         }       }       if (flag) {         for (int i = 0; i < N; i++) {           sol[i] = N + 1 - sol[i];         }       }       for (int i = 0; i < N; i++) {         cout << sol[i] <<    ;       }       cout <<   n ;     }     cerr <<  Time :   << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC          <<  ms n ;     return 0;   }
#include <bits/stdc++.h>   char str[110];   int main() {     int len, t, _max = 0;     scanf( %s , str);     len = strlen(str);     for (int i = 0; i < len; i++)       for (int j = i + 1; j < len; j++) {         t = 0;         while (str[i + t] == str[j + t]) t++;         if (t > _max) _max = t;       }     printf( %d , _max);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 100;   long long n, m, dp[N][N], a[N][N], b[N][N], c[N], len;   char go[N][N][N];   char str[N << 1];   inline long long read() {     long long sym = 0, res = 0;     char ch = 0;     while (!isdigit(ch)) sym |= (ch ==  - ), ch = getchar();     while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();     return sym ? -res : res;   }   void file() {     freopen( read.in ,  r , stdin);     freopen( write.out ,  w , stdout);   }   long long power(long long a, long long x) {     long long res = 1;     while (x) {       if (x & 1) res *= a;       a *= a;       x >>= 1;     }     return res;   }   void write(long long now, long long x, long long y, char ch) {     if (now == 0) {       printf( %c , ch);       return;     }     if (go[now][x][y] ==  H )       write(now - 1, x - 1, y,  H );     else       write(now - 1, x, y - 1,  M );     if (now != len) printf( %c , ch);   }   signed main() {     n = read();     len = n << 1;     scanf( %s , str + 1);     for (long long i = 1; i <= len; i++) {       c[i] = str[i] -  0 ;     }     for (long long i = 1; i <= n; i++) {       a[i][i] = a[i - 1][i - 1] + c[i] * power(10, n - i);       go[i][i][0] =  H ;       b[i][i] = b[i - 1][i - 1] + c[i] * power(10, n - i);       go[i][0][i] =  M ;     }     for (long long i = 1; i <= len; i++) {       for (long long j = max(i - n, 1ll); j <= min(i - 1ll, n); j++) {         long long k = i - j, ta = c[i] * power(10, n - j),                   tb = c[i] * power(10, n - k);         if (a[i - 1][j - 1] + ta + b[i - 1][k] >             b[i - 1][k - 1] + tb + a[i - 1][j]) {           a[i][j] = a[i - 1][j - 1] + ta;           b[i][k] = b[i - 1][k];           go[i][j][k] =  H ;         } else {           b[i][k] = b[i - 1][k - 1] + tb;           a[i][j] = a[i - 1][j];           go[i][j][k] =  M ;         }       }     }     write(len, n, n,    );     return 0;   }
#include<bits/stdc++.h>   #define ll long long   #define vi vector<int>   #define vl vector<ll>    #define pb push_back   #define FASTANDFURIOUS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);   #define rep(i,a,b) for(ll i=a;i<b;i++)   #define For(i,n) for(ll i=0;i<n;i++)   #define MOD 1000000007   #define MAX 100001   #define pll pair <ll,ll>   #define pii pair <int,int>   #define dbg(x)    cout << #x <<  :   << x << endl;   #define fi first   #define se second   #define read(n,v) For(i,n)cin>>v[i]   #define mkp make_pair   #define YES cout<< YES n ;   #define NO cout<< NO n ;   #define No cout<< No n ;   #define Yes cout<< Yes n ;   #define INF 1e18   using namespace std;        ll ncr2(ll n, ll k )   {       if (k > n) return 0;       if (k * 2 > n) k = n-k;       if (k == 0) return 1;           ll result = n;       for(ll i = 2; i <= k; ++i ) {           result = result * (n-i+1);           result /= i;       }       return result;   }   ll pow(ll x, unsigned int y, int p){       ll res=1;       x=x%p;       if (x==0) return 0;       while (y > 0)       {           if (y & 1)               res = (res*x) % p;           y = y>>1;           x = (x*x) % p;       }       return res;   }   ll _pow(ll a, ll b){       if(!b)           return 1;       ll temp = _pow(a, b / 2);       temp = (temp * temp);       if(b % 2)           return (a * temp);       return temp;   }   ll invmod(ll a,ll m){       return pow(a,m-2,m);   }   ll feelthepower(ll x,ll y){       ll res = 1LL;       while(y){           if(y&1){               res = (res*1LL*x)%MOD;           }           x = (x*1LL*x)%MOD;           y/=2;       }       return res;   }   // ll ncr(ll n,ll r)   // {   //     if(n<r)   //         return 0;   //     ll ans=fac[n];   //     ans*=invmod(fac[n-r],MOD);   //     ans%=MOD;   //     ans*=invmod(fac[r],MOD);   //     ans%=MOD;   //     return ans;   // }   bool has(int kek,int d){       while(kek){           int temp = kek%10;           if(temp == d){               return true;           }           kek/=10;       }       return false;   }   signed main(){       FASTANDFURIOUS;       #ifndef ONLINE_JUDGE       freopen( input.txt ,  r , stdin);       freopen( output.txt ,  w , stdout);       #endif       int tc=1;       cin>>tc;       For(ti,tc){           int n,d;           cin>>n>>d;           For(i,n){               string s;               cin>>s;               if(s.length()>2){                   cout<< YES n ;               }               else{                   int req = stoi(s);                   int flag=0;                   while(req>=0){                       if(has(req,d)){                           flag=1;                           break;                       }                       else{                           req-=d;                      }                   }                   if(flag){                       cout<< YES n ;                   }                   else{                       cout<< NO n ;                   }               }           }       }   }
#include <bits/stdc++.h>   using namespace std;   long long int a1, b1, a2, b2;   int main() {     scanf( %lld %lld , &a1, &b1);     scanf( %lld %lld , &a2, &b2);     long long int p, q, ans = 0;     p = (a1 * b1);     q = (a2 * b2);     long long int tp = 0, tq = 0, thp = 0, thq = 0;     while ((p % 3) == 0) {       p = (p / 3);       thp++;     }     while ((q % 3) == 0) {       q = (q / 3);       thq++;     }     while ((p % 2) == 0) {       p = (p / 2);       tp++;     }     while ((q % 2) == 0) {       q = (q / 2);       tq++;     }     p = (a1 * b1);     q = (a2 * b2);     long long int x;     if (thp > thq) {       tp = tp + (thp - thq);       ans = ans + (thp - thq);       x = (thp - thq);       while (x--) {         if ((a1 % 3) == 0)           a1 = ((a1 / 3) * 2);         else           b1 = ((b1 / 3) * 2);       }     } else if (thq > thp) {       tq = tq + (thq - thp);       ans = ans + (thq - thp);       x = (thq - thp);       while (x--) {         if ((a2 % 3) == 0)           a2 = ((a2 / 3) * 2);         else           b2 = ((b2 / 3) * 2);       }     }     if (tp > tq) {       ans = ans + (tp - tq);       x = (tp - tq);       while (x--) {         if ((a1 % 2) == 0)           a1 = (a1 / 2);         else           b1 = (b1 / 2);       }     } else {       ans = ans + (tq - tp);       x = (tq - tp);       while (x--) {         if ((a2 % 2) == 0)           a2 = (a2 / 2);         else           b2 = (b2 / 2);       }     }     if ((a1 * b1) == (a2 * b2)) {       printf( %lld n , ans);       printf( %lld %lld n , a1, b1);       printf( %lld %lld n , a2, b2);     } else       printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   int t, k, l[1005], r[1005], lenl, lenr;   long long f[1005][1005][2];   long long dfs(int *x, int Index, int d, int q, int lim) {     if (Index < 1) return (long long)q;     if (!lim && f[Index][d][q] != -1) return f[Index][d][q];     long long res = 0;     int up = lim ? x[Index] : 9;     for (int i = 0; i <= up; i++) {       if (i != 4 && i != 7)         res = (res + dfs(x, Index - 1, max(d - 1, 0), q, lim && i == up)) % mod;       else         res = (res + dfs(x, Index - 1, k, q || d, lim && i == up)) % mod;     }     if (!lim) f[Index][d][q] = res;     return res;   }   long long solve(int *x, int len) { return dfs(x, len, 0, 0, 1); }   int main() {     scanf( %d %d , &t, &k);     memset(f, -1, sizeof f);     while (t--) {       char now[1005];       scanf( %s , now + 1);       lenl = strlen(now + 1);       for (int i = 1; i <= lenl; i++) l[lenl - i + 1] = now[i] - 48;       scanf( %s , now + 1);       lenr = strlen(now + 1);       for (int i = 1; i <= lenr; i++) r[lenr - i + 1] = now[i] - 48;       l[1]--;       int Index = 1;       while (l[Index] < 0) {         l[Index] = 9;         l[Index + 1]--;         Index++;       }       if (Index == lenl && !l[Index]) lenl--;       printf( %lld n , (solve(r, lenr) - solve(l, lenl) + mod) % mod);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<pair<int, int>, int> a[100001];   pair<int, int> ans[100001];   int n, m, i, j, k, l, r, t, last, b[100001], x, y;   map<int, pair<int, int> > mp;   int main() {     cin >> n >> m;     for (i = 0; i < m; i++) {       cin >> a[i].first.first >> a[i].first.second;       a[i].first.second = 1 - a[i].first.second;       b[i] = a[i].first.first;       a[i].second = i;     }     sort(a, a + m);     if (a[0].first.second || a[1].first.second) {       cout << -1;       return 0;     }     k = 3;     for (i = 2; i < m; i++) {       if (a[i].first.second) {         if (t == (k - 2) * (k - 1) / 2) {           cout << -1;           return 0;         }         t++;         continue;       }       k++;     }     t = 2;     for (i = 0; i < m; i++) {       if (!a[i].first.second) {         ans[a[i].second].first = t - 1;         ans[a[i].second].second = t;         t++;       }     }     x = 3;     y = 1;     for (i = 0; i < m; i++) {       if (!a[i].first.second) continue;       ans[a[i].second].first = y;       ans[a[i].second].second = x;       y++;       if (x == y + 1) {         x++;         y = 1;       }     }     for (i = 0; i < m; i++) {       cout << ans[i].first <<     << ans[i].second << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int inv = 1000000000;   const int minv = -inv;   const int max_n = 500000 + 5;   const int max_cn2 = max_n / 2 + 5;   int n, cn2, fn2;   int a[max_cn2];   int x;   long long q[max_cn2];   int main() {     scanf( %d , &n);     cn2 = (n + 1) / 2;     fn2 = n / 2;     long long suma = 0ll;     for (int i = 0; i < cn2; ++i) {       scanf( %d , &a[i]);       suma += ((long long)(a[i]));     }     scanf( %d , &x);     suma += ((long long)(fn2)) * ((long long)(x));     if (suma > 0ll) {       printf( %d n , n);       return 0;     }     if (x >= 0) {       printf( %d n , -1);       return 0;     }     q[0] = 0ll;     for (int i = 1; i < n - fn2; ++i)       q[i] = min(q[i - 1] + ((long long)(a[i - 1] - x)), 0ll);     long long rsum = ((long long)(fn2)) * ((long long)(x));     for (int k = fn2 + 1; k < n; ++k) {       rsum += ((long long)(a[n - k]));       if (rsum + q[n - k] > 0ll) {         printf( %d n , k);         return 0;       }     }     printf( %d n , -1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000 * 1000 * 1000 + 7;   const long long LINF = 1LL * INF * INF;   const int MAX = 1e5 + 7;   const double PI = acos(-1.);   const double EPS = 1e-7;   const int MOD = 998244353;   const int MAXF = 1000000000;   int dx[] = {1, -1, 0, 0};   int dy[] = {0, 0, -1, 1};   bool isInField(int x, int y) {     return 1 <= x && x <= MAXF && 1 <= y && y <= MAXF;   }   bool isWhite(int x, int y) { return x % 2 == y % 2; }   void solve() {     int black, white;     cin >> black >> white;     map<pair<int, int>, int> was;     vector<pair<int, int> > ans;     int sX = 200000, sY = 200000;     if (black > white) {       sX++;       --black;     } else {       --white;     }     ans.emplace_back(sX, sY);     was[{sX, sY}] = 1;     while (black > 0 && white > 0) {       --black;       --white;       ++sX;       ans.emplace_back(sX, sY);       was[{sX, sY}] = 1;       ++sX;       ans.emplace_back(sX, sY);       was[{sX, sY}] = 1;     }     for (int i = 0; i < (((int)ans.size())); ++i) {       int x = ans[i].first;       int y = ans[i].second;       for (int j = 0; j < (4); ++j) {         int a = x + dx[j];         int b = y + dy[j];         if (black > 0) {           if (!was.count({a, b}) && !isWhite(a, b)) {             --black;             ans.emplace_back(a, b);             was[{a, b}] = 1;           }         } else if (white > 0) {           if (!was.count({a, b}) && isWhite(a, b)) {             --white;             ans.emplace_back(a, b);             was[{a, b}] = 1;           }         }       }     }     if (black != 0 || white != 0) {       cout <<  NO n ;       return;     }     cout <<  YES n ;     for (auto [x, y] : ans) {       cout << x <<     << y << endl;     }   }   int main() {     ios_base::sync_with_stdio(0);     int q;     cin >> q;     while (q--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef long long ll;   #define mod 1000000007      int main(){       int n;cin>>n;       int summ = 0;       while(n>9){           int summ = 0;           while(n>9){               summ = summ + n%10;               n = n/10;           }           summ = summ + n;           n = summ;       }       cout<<n;       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     double d, L, v1, v2;     cin >> d >> L >> v1 >> v2;     double distance;     int i, r;     cout << fixed << setprecision(20) << (L - d) / (v1 + v2);     return 0;   }