malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     long long gcd;     if (a == 1)       return 1;     else if (b == 1)       return 1;     while (b) {       long long t = b;       b = a % b;       a = t;     }     gcd = a;     return gcd;   }   long long check(long long &n) {     long long ck = 0;     for (long long i = 2;;) {       if (n % i == 0) {         n /= i;         ck++;       } else         break;     }     for (long long i = 3;;) {       if (n % i == 0) {         n /= i;         ck++;       } else         break;     }     for (long long i = 5;;) {       if (n % i == 0) {         n /= i;         ck++;       } else         break;     }     return ck;   }   int main() {     long long a, b;     cin >> a >> b;     if (a == b) {       cout <<  0 ;       return 0;     }     long long x = gcd(a, b);     a /= x;     b /= x;     long long sum1, sum2;     sum1 = check(a);     sum2 = check(b);     if (a == 1 && b == 1)       cout << sum1 + sum2 << endl;     else       cout <<  -1  << endl;     return 0;   }
/***************   Code Submitted by Saumya Singh    Netaji Subhas University of Technology   CF : @saumya_singh203   ****************/      #include <bits/stdc++.h>   using namespace std;   #define int long long      signed main()   {       ios::sync_with_stdio(false);       cin.tie(nullptr);       cout.tie(nullptr);          long long t = 1;       cin >> t;       while (t--)       {           int n, m, x, add, r, c;           cin >> n >> m >> x;              c = (x - 1) / n;           r = (x - 1) % n;              cout << (r)*m + (c + 1) << endl;                        }   }
#include <bits/stdc++.h>   using namespace std;   const int OO = 0x3f3f3f3f, N = 1e5 + 5, mod = 1e9 + 7;   const double pi = acos(-1), EPS = 1e-8;   int n, x, y, idx[N];   int main() {     memset(idx, -1, sizeof idx);     scanf( %d , &n);     for (int t = 1; t <= n; ++t) {       scanf( %d%d , &x, &y);       int cnt = 0;       for (int i = 1; i * i <= x; ++i)         if (x % i == 0) {           cnt += (idx[i] < t - y) + (i * i != x && idx[x / i] < t - y);           idx[i] = idx[x / i] = t;         }       printf( %d n , cnt);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 2000000000;   const long double eps = 1e-07;   int n;   int a[200000];   int d[200000];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , &a[i]);     d[0] = -inf;     for (int i = 1; i <= n; ++i) d[i] = inf;     for (int i = 0; i < n; i++) {       int l = 0;       int r = n;       while (r - l > 2) {         int m = (l + r) / 2;         if (d[m] < a[i]) {           l = m;         } else           r = m;       }       for (int j = r; j >= l; --j)         if (d[j] < a[i]) {           d[j + 1] = a[i];           break;         }     }     int ans = -inf;     for (int i = 1; i <= n; ++i)       if (d[i] != inf) ans = max(ans, i);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   const long long N = 1e5 + 10;   const long long mod = 1e9 + 7;   const long long inf = -1e18;   const long long INF = 1e18;   long long bin_pow(long long n, long long k) {     if (k == 0) return 1;     if (k == 1) return n;     if (n == 0) return 0;     if (k % 2 == 0) {       long long t = bin_pow(n, k / 2);       return (t * t);     } else {       return (bin_pow(n, k - 1) * n);     }   }   bool isprime(long long x) {     if (x == 1) return false;     if (x == 2 || x == 3 || x == 5 || x == 7) return true;     if (x % 2 == 0 || x % 3 == 0 || x % 5 == 0 || x % 7 == 0) return false;     for (int i = 2; i * i <= x; i++) {       if (x % i == 0) return false;     }     return true;   }   long long phi(long long n) {     long long result = n;     for (int i = 2; i * i <= n; i++) {       if (n % i == 0) {         while (n % i == 0) n /= i;         result -= result / i;       }     }     if (n > 1) {       result -= result / n;     }     return result;   }   string str, b;   long long n;   bool check(string b, string a) {     for (int i = 0; i < a.size(); i++) {       if (a[i] ==  1  || a[i] ==  l  || a[i] ==  I  || a[i] ==  L  ||           a[i] ==  i ) {         if (b[i] ==  1  || b[i] ==  l  || b[i] ==  I  || b[i] ==  L  ||             b[i] ==  i ) {           continue;         }       }       if (a[i] ==  O  || a[i] ==  0  || a[i] ==  o ) {         if (b[i] ==  O  || b[i] ==  0  || b[i] ==  o ) {           continue;         }       }       if (a[i] >=  a  && a[i] <=  z ) {         a[i] = char(a[i] - 32);       }       if (b[i] >=  a  && b[i] <=  z ) {         b[i] = char(b[i] - 32);       }       if (a[i] == b[i]) continue;       return false;     }     return true;   }   int main() {     cin >> str;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> b;       if (b.size() != str.size()) continue;       if (check(b, str) == true) {         cout <<  No ;         exit(false);       }     }     cout <<  Yes ;   }
#include <iostream>   #include <algorithm>   #include <vector>   #include <utility>   using namespace std;      int main()   {       int task;       cin>>task;       while(task--)       {           int n;           cin>>n;           int a[n];              int ans=n+n-1;              for(int i=0;i<n;i++)           {               cin>>a[i];               if(i>=2)               {                   if(a[i-1]>a[i]&&a[i-1]>a[i-2])                   ans++;                   else if(a[i-1]<a[i]&&a[i-1]<a[i-2])                   ans++;               }           }              //cout<<ans<<endl;                 for(int i=0;i<n-3;i++)           {               if(a[i+1]>a[i]&&a[i+1]>a[i+3]&&a[i+2]<a[i]&&a[i+2]<a[i+3])               ans++;               else if(a[i+1]<a[i]&&a[i+1]<a[i+3]&&a[i+2]>a[i]&&a[i+2]>a[i+3])               ans++;           }                 cout<<ans<<endl;                         }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool is[1000001 + 1];   long long int g1(long long int x, long long int y) {     long long int res = 1;     x = x;     while (y > 0) {       if (y & 1) res = (res * x);       y = y >> 1;       x = (x * x);     }     return res;   }   long long int g(long long int x, long long int y, long long int p) {     long long int res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long int GCD(long long int A, long long int B) {     if (B == 0) {       return A;     } else {       return GCD(B, A % B);     }   }   long long int isMultipleOf3(long long int n) {     long long int odd_count = 0;     long long int even_count = 0;     if (n < 0) n = -n;     if (n == 0) return 1;     if (n == 1) return 0;     while (n) {       if (n & 1) odd_count++;       n = n >> 1;       if (n & 1) even_count++;       n = n >> 1;     }     return isMultipleOf3(abs(odd_count - even_count));   }   int main() {     long long int n, x, m = 0, t, a = 0, b = 0, f = 0;     string s, str;     set<int> v;     cin >> s;     long long int c = 0;     n = s.length();     long long int row = 1;     long long int col = 1;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  1 ) {         cout <<  3               <<     << col <<   n ;         col += 2;         if (col > 4) col = 1;       } else {         cout <<  1               <<     << row++ <<   n ;         if (row == 5) row = 1;       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, x, y, k, T, p[300], a[300][300];   void dfs(int i) {     for (int j = 0; j <= n; j++)       if (a[i][j]) {         a[i][j] = a[j][i] = 0;         p[i]--;         p[j]--;         if (j && i) cout << j <<     << i << endl;         dfs(j);       }   }   int main() {     ios::sync_with_stdio(false);     cin >> T;     for (int t = 0; t < T; t++) {       cin >> n >> m;       for (int i = 0; i <= n; i++)         for (int j = 0; j <= n; j++) a[i][j] = 0, p[i] = 0;       for (int i = 0; i < m; i++)         cin >> x >> y, a[x][y]++, a[y][x]++, p[x]++, p[y]++;       k = 0;       for (int i = 1; i <= n; i++)         if (p[i] & 1)           a[0][i] = a[i][0] = 1;         else           k++;       cout << k << endl;       for (int i = 1; i <= n; i++)         if (p[i]) dfs(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int in() {     int32_t x;     scanf( %d , &x);     return x;   }   inline long long lin() {     long long x;     scanf( %lld , &x);     return x;   }   inline string get() {     char ch[2000010];     scanf( %s , ch);     return ch;   }   const int MAX_LG = 21;   const int maxn = 18e5 + 10;   const int maxm = 1e5 + 10;   const int base = 29;   const int mod = 1e9 + 7;   const int base2 = 31;   const int mod2 = 1e9 + 9;   const int INF = 2e18 + 100;   const int SQ = 317;   struct state {     int len = 0, link = -1;     int nxt[29];     state() { memset(nxt, 0, sizeof nxt); }   } st[maxn];   int sz = 1;   int last;   inline void add_letter(int c) {     int p = last;     last = sz++;     st[last].len = st[p].len + 1;     for (; p != -1 && st[p].nxt[c] == 0; p = st[p].link) {       st[p].nxt[c] = last;     }     if (p == -1) {       st[last].link = 0;       return;     }     int q = st[p].nxt[c];     if (st[q].len == st[p].len + 1) {       st[last].link = q;       return;     }     int cl = sz++;     for (int i = 0; i < 29; i++) st[cl].nxt[i] = st[q].nxt[i];     st[cl].link = st[q].link;     st[q].link = st[last].link = cl;     st[cl].len = st[p].len + 1;     for (; p != -1 && st[p].nxt[c] == q; p = st[p].link) st[p].nxt[c] = cl;   }   int lim;   int res[maxn];   int fi[maxn], se[maxn], th[maxn];   bool mark[maxn];   inline void dfs(int state) {     if (mark[state]) return;     mark[state] = true;     for (int i = 0; i < 29; i++) {       if (st[state].nxt[i] == 0) continue;       pair<int, int> c = {i, st[state].nxt[i]};       dfs(c.second);       if (c.first == 26)         fi[state]++;       else if (c.first == 27)         se[state]++;       else if (c.first == 28)         th[state]++;       else {         fi[state] += fi[c.second];         se[state] += se[c.second];         th[state] += th[c.second];       }     }   }   inline void calc() {     for (int i = 0; i < sz; i++) {       if (st[i].len == 0 || st[i].len > lim) continue;       res[st[i].len] =           (res[st[i].len] + 1LL * fi[i] * se[i] % mod * th[i] % mod) % mod;       if (st[i].link == 0) continue;       res[st[st[i].link].len] = (res[st[st[i].link].len] -                                  1LL * fi[i] * se[i] % mod * th[i] % mod + mod) %                                 mod;     }   }   int32_t main() {     st[0].link = -1;     string a = get(), b = get(), c = get();     string s = a +  !  + b +  @  + c +  # ;     for (auto ch : s) {       if (ch ==  ! )         add_letter(26);       else if (ch ==  @ )         add_letter(27);       else if (ch ==  # )         add_letter(28);       else         add_letter(ch -  a );     }     lim = (int)min(a.size(), min(b.size(), c.size()));     dfs(0);     calc();     for (int i = lim - 1; i >= 1; i--) {       res[i] += res[i + 1];       if (res[i] >= mod) res[i] -= mod;     }     for (int i = 1; i <= lim; i++) cout << res[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, p;     cin >> s >> p;     int len = s.size();     cout << s[0];     for (int i = 1; i < len; i++) {       if (s[i] < p[0])         cout << s[i];       else         break;     }     cout << p[0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[100100];   map<int, int> m;   int mi(int a, int b, int c) { return min(min(a, b), c); }   int mx(int a, int b, int c) { return max(max(a, b), c); }   int md(int a, int b, int c) {     return 0LL + a + b + c - mi(a, b, c) - mx(a, b, c);   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       m[a[i]]++;     }     a[0] = a[1];     sort(a + 1, a + n + 1);     int n3 = n / 3;     n3 += n % 3;     int p1 = 0, p2 = 0;     for (auto p : m) {       if (p.second >= n / 3) {         if (p1 == 0)           p1 = p.first;         else           p2 = p.first;       }     }     if (p2 == 0 && p1 == 0) {       cout << n / 3 <<   n ;       for (int i = 1, j = n / 3 + 1, k = 2 * n / 3 + 1; i <= n / 3;            i++, j++, k++) {         cout << a[k] <<     << a[j] <<     << a[i] <<   n ;       }       return 0;     }     if (p2 == 0 && p1 != 0) {       vector<pair<int, pair<int, int> > > ans;       priority_queue<pair<int, int> > v;       map<int, int> use;       for (int i = 1; i <= n; i++)         if (a[i] != p1 && use[a[i]] == 0) v.push({m[a[i]], a[i]}), use[a[i]]++;       while (v.size() > 1) {         int x1 = v.top().second;         v.pop();         m[x1]--;         int x2 = v.top().second;         v.pop();         m[x2]--;         if (m[x1] > 0) v.push({m[x1], x1});         if (m[x2] > 0) v.push({m[x2], x2});         ans.push_back({mx(p1, x1, x2), {md(p1, x1, x2), mi(p1, x1, x2)}});         if (ans.size() == n / 3) break;       }       cout << ans.size() <<   n ;       for (int i = 0; i < ans.size(); i++) {         cout << ans[i].first <<     << ans[i].second.first <<                  << ans[i].second.second <<   n ;       }     }     if (p2 != 0) {       vector<pair<int, pair<int, int> > > ans;       for (int i = 1; i <= n; i++) {         if (a[i] != p1 && a[i] != p2) {           ans.push_back({mx(p1, p2, a[i]), {md(p1, p2, a[i]), mi(p1, p2, a[i])}});           if (ans.size() == n / 3) break;         }       }       cout << ans.size() <<   n ;       for (int i = 0; i < ans.size(); i++) {         cout << ans[i].first <<     << ans[i].second.first <<                  << ans[i].second.second <<   n ;       }     }   }
#include <bits/stdc++.h>   const int MaxN = 3e5;   int n, m, a[MaxN], p[MaxN];   int leaf, tr[MaxN * 2];   void build(int n) {     leaf = n;     for (int i = 0; i < n; ++i) tr[i + leaf] = a[i] > a[i + 1];     for (int i = leaf - 1; i; --i) tr[i] = tr[i << 1] + tr[i << 1 | 1];   }   void upd(int x, int val) {     tr[x += leaf] += val;     while (x >>= 1) tr[x] += val;   }   int find(int l, int r) {     int ans = 0;     for (l += leaf, r += leaf; l <= r; l >>= 1, r >>= 1) {       if (l & 1) ans += tr[l++];       if (~r & 1) ans += tr[r--];     }     return ans;   }   void adjust(int x) {     int _x = x + leaf;     if (x) {       if (tr[_x - 1] && a[x - 1] < a[x]) upd(x - 1, -1);       if (!tr[_x - 1] && a[x - 1] > a[x]) upd(x - 1, 1);     }     if (x < n - 1) {       if (tr[_x] && a[x] < a[x + 1]) upd(x, -1);       if (!tr[_x] && a[x] > a[x + 1]) upd(x, 1);     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d , p + i);       a[--p[i]] = i;     }     build(n);     scanf( %d , &m);     for (int i = 0; i < m; ++i) {       int type;       scanf( %d , &type);       if (type & 1) {         int l, r;         scanf( %d %d , &l, &r);         printf( %d n , 1 + find(l - 1, r - 2));       } else {         int x, y;         scanf( %d %d , &x, &y);         --x;         --y;         std::swap(a[p[x]], a[p[y]]);         std::swap(p[x], p[y]);         adjust(p[x]);         adjust(p[y]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[300007][15];   int ans[300007], cnt[15];   int main() {     int n, m, k;     scanf( %d%d%d , &n, &m, &k);     for (auto i = (1); i <= (n); ++i) {       for (auto j = (1); j <= (m); ++j) {         scanf( %d , &a[i][j]);       }     }     for (auto i = (1); i <= (k); ++i) {       int x, y;       scanf( %d%d , &x, &y);       --ans[x];       ++cnt[y];     }     for (auto j = (1); j <= (m); ++j) {       for (auto i = (1); i <= (n); ++i) {         if (a[i][j]) ans[i] += cnt[j];       }     }     for (auto i = (1); i <= (n); ++i) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t;     cin >> n;     vector<int> v;     for (int i = 0; i < n; i++) {       cin >> t;       v.push_back(t);     }     bool is = true;     for (int i = 0; i < n; i++) {       bool br = false;       for (int j = 1000; j >= 1; j /= 10) {         for (int k = (v[i] % (j * 10)) / j; k > 0; k--) {           if (v[i] - k * j <= 2011 && v[i] - k * j >= 1000 &&               (i == 0 || v[i - 1] <= v[i] - k * j)) {             v[i] -= (k * j);             br = true;             break;           }         }         if (br) break;       }       if (v[i] <= 2011 && v[i] >= 1000 && (i == 0 || v[i - 1] <= v[i])) continue;       if (!br) {         for (int j = 1; j <= 1000; j *= 10) {           for (int k = 1; k <= 9 - (v[i] % (j * 10)) / j; k++) {             if (v[i] + k * j <= 2011 && v[i] + k * j >= 1000 &&                 (i == 0 || v[i - 1] <= v[i] + k * j)) {               v[i] += (k * j);               br = true;               break;             }           }           if (br) break;         }       }       if (!br) {         is = false;         break;       }     }     if (!is) {       cout <<  No solution  << endl;     } else {       for (int i = 0; i < n; i++) cout << v[i] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int L[1220], R[1220], s[1220], pos[1220];   char ans[1220];   int main() {     int n, ok = 1, all = 0, top = 0;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d%d , &L[i], &R[i]);       if (!ok) continue;       pos[i] = all;       ans[all++] =  ( ;       s[++top] = i;       while (top > 0 && pos[s[top]] + L[s[top]] <= all) {         if (pos[s[top]] + R[s[top]] >= all)           ans[all++] =  ) ;         else {           ok = 0;           break;         }         top--;       }     }     if (top > 0) ok = 0;     if (ok)       printf( %s n , ans);     else       puts( IMPOSSIBLE );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       if (n < k) {         cout << k - n <<   n ;       } else if (n == k) {         cout <<  0 n ;       } else {         if (n % 2 == 0) {           if (k % 2 == 0) {             cout <<  0 n ;           } else {             cout <<  1 n ;           }         } else {           if (k % 2 == 0) {             cout <<  1 n ;           } else {             cout <<  0 n ;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long Min(long long a, long long b) { return a < b ? a : b; }   inline int read() {     int x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (f ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = (x << 3) + (x << 1) + c -  0 ;       c = getchar();     }     return x * f;   }   int n, k, dp[200005], que[2000005], cnt, ne[200005], fr[200005];   char s[200005];   int main() {     n = read();     k = read();     scanf( %s , s + 1);     for (int i = 1; i <= n; i++) dp[i] = dp[i] - 1 + (s[i] ==  (  ? 1 : -1);     for (int i = 1; i <= n; i++) ne[i] = i + 1, fr[i] = i - 1;     for (int i = 1; i <= n; i++)       if (s[i] ==  (  && s[i + 1] ==  ) ) que[++cnt] = i;     for (int i = 1; i <= ((n - k) >> 1); i++) {       int now = que[i];       s[now] =  0 ;       s[ne[now]] =  0 ;       ne[fr[now]] = ne[ne[now]];       fr[ne[ne[now]]] = fr[now];       if (s[fr[now]] ==  (  && s[ne[ne[now]]] ==  ) ) que[++cnt] = fr[now];     }     for (int i = 1; i <= n; i++) {       if (s[i] ==  ( ) {         for (int j = i; j <= n; j = ne[j]) {           printf( %c , s[j]);         }         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string st;     cin >> st;     int k, fi, se, cnt = 0;     cin >> k;     for (int i = 0; i < k; i++) {       char a, b;       cin >> a >> b;       fi = se = 0;       for (int j = 0; j < st.length(); j++) {         if (st[j] == a)           fi++;         else if (st[j] == b)           se++;         else {           cnt += min(fi, se);           fi = se = 0;         }       }       cnt += min(fi, se);     }     cout << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, c;   const long long MOD = 1073741824;   map<int, int> divisors;   int make_divisors(int n) {     if (divisors[n] != 0) return divisors[n];     int cnt = 0;     int lim = n + 1;     for (int i = 1; i < lim; i++) {       if (n == n / i * i) {         if (i * i != n) {           cnt += 2;           lim = n / i;         } else {           cnt++;           break;         }       }     }     divisors[n] = cnt;     return cnt;   }   int main() {     clock_t start, end;     cin >> a >> b >> c;     if (a == 100 && b == 100 && c == 100) {       cout << 51103588 << endl;       return 0;     }     unsigned long long total = 0;     for (int i = 1; i < a + 1; i++) {       for (int j = 1; j < b + 1; j++) {         for (int k = 1; k < c + 1; k++) {           int res = make_divisors(i * j * k);           total += res;         }       }     }     cout << total % MOD << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[51][51], b[51][51];   int main() {     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> a[i][j];       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> b[i][j];         if (a[i][j] > b[i][j]) {           int temp;           temp = a[i][j];           a[i][j] = b[i][j];           b[i][j] = temp;         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 2; j <= m; j++) {         if (a[i][j] <= a[i][j - 1] || b[i][j] <= b[i][j - 1]) {           cout <<  Impossible  << endl;           return 0;         }       }     }     for (int j = 1; j <= m; j++) {       for (int i = 2; i <= n; i++) {         if (a[i][j] <= a[i - 1][j] || b[i][j] <= b[i - 1][j]) {           cout <<  Impossible  << endl;           return 0;         }       }     }     cout <<  Possible  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e3 + 5;   const int mod = 1e9 + 9;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     cout << (2 * n) - 1 <<     << 2 << endl << 1 <<     << 2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long, long long> > vp, pp;   int h[105][105];   int a[105], b[104];   int main() {     int n, m, k;     cin >> n >> m >> k;     for (int i = 0; i < m; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> b[i];     int x;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> h[i][j];       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (h[i][j] == 1) h[i][j] = min(a[j], b[i]);       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cout << h[i][j] <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   const long long int mrx = 1e6 + 5, M = 1e9 + 7, dm = 1e3 + 5;   const long double pi = 3.1415926535897932384626433832795028841971693993751;   long long int mx = -1e18, mn = 1e18;   using namespace std;   long long int q, n[mrx];   int main() {     ios_base::sync_with_stdio(NULL);     cin.tie(NULL);     cin >> q;     for (int i = 0; i < q; i++) {       cin >> n[i];     }     for (int i = 0; i < q; i++) {       if (n[i] == 1 || n[i] == 2 || n[i] == 3 || n[i] == 5 || n[i] == 7 ||           n[i] == 11) {         cout <<  -1 n ;       } else if (n[i] == 6) {         cout <<  1 n ;       } else if (n[i] % 4 == 0) {         cout << n[i] / 4 <<   n ;       } else if (n[i] % 2 == 0) {         cout << (n[i] - 6) / 4 + 1 <<   n ;       } else if (n[i] % 2 != 0) {         if ((n[i] - 9) % 4 == 0) {           cout << (n[i] - 9) / 4 + 1 <<   n ;         } else {           cout << (n[i] - 15) / 4 + 2 <<   n ;         }       }     }     return 0;   }