malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long powmod(long long a, long long b) {     long long res = 1;     a %= 1000000007;     for (; b; b >>= 1) {       if (b & 1) res = res * a % 1000000007;       a = a * a % 1000000007;     }     return res;   }   template <typename T>   inline bool chkmin(T &a, const T &b) {     return a > b ? a = b, 1 : 0;   }   template <typename T>   inline bool chkmax(T &a, const T &b) {     return a < b ? a = b, 1 : 0;   }   int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   int a[100005], n;   const int mx = 30;   long long m;   struct trie_node {     int num[30], siz, ch[2];   } t[100005 * 20];   const int head = 1;   int tot = 1;   void insert(int x) {     int p = head;     for (int i = mx - 1; i >= 0; i--) {       int bit = x >> i & 1;       if (!t[p].ch[bit]) t[p].ch[bit] = ++tot;       p = t[p].ch[bit];       for (int i = 0; i < mx; i++) t[p].num[i] += x >> i & 1;       t[p].siz++;     }   }   int now[100005];   int num[30], all[30];   int main() {     scanf( %d%lld , &n, &m);     m <<= 1;     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), insert(a[i]);     for (int i = 1; i <= n; i++) now[i] = head;     memset(num, 0, sizeof num);     for (int i = mx - 1; i >= 0; i--) {       long long tmp = 0;       for (int j = 1; j <= n; j++) tmp += t[t[now[j]].ch[!(a[j] >> i & 1)]].siz;       if (tmp <= m) {         for (int j = 1; j <= n; j++) {           for (int k = mx - 1; k >= 0; k--) {             if (a[j] >> k & 1)               num[k] += t[t[now[j]].ch[!(a[j] >> i & 1)]].siz -                         t[t[now[j]].ch[!(a[j] >> i & 1)]].num[k];             else               num[k] += t[t[now[j]].ch[!(a[j] >> i & 1)]].num[k];           }           now[j] = t[now[j]].ch[a[j] >> i & 1];         }         m -= tmp;       } else {         for (int j = 1; j <= n; j++)           now[j] = t[now[j]].ch[!(a[j] >> i & 1)], all[i] = 1;       }     }     for (int i = 0; i < mx; i++) num[i] += all[i] * m;     long long ans = 0;     for (int i = 0; i < mx; i++) {       ans += (1LL << i) * (num[i] / 2);     }     ans %= 1000000007;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x;     cin >> n >> x;     int sum = 0, y;     for (int i = 0; i < n; i++) {       cin >> y;       sum += y;     }     if (sum == 0) {       cout <<  0 n ;       return 0;     }     if (abs(sum) <= x) {       cout <<  1 n ;       return 0;     } else if (sum < 0)       sum = -sum;     cout << ceil((double)sum / x);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int countDigit(long long n) {     int count = 0;     while (n != 0) {       n = n / 10;       ++count;     }     return count;   }   int main() {     long long int t;     cin >> t;     while (t--) {       int k, s;       cin >> s;       int n = s % 10, ans;       k = countDigit(s);       ans = ((n - 1) * 10) + ((k * (k + 1)) / 2);       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   const long long INF = mod * mod;   const long double eps = 1e-8;   bitset<7001> memo[100000];   bitset<7001> for_query[7001];   bitset<7001> for_set[7001];   void init() {     vector<int> v;     for (int i = 2; i <= 90; i++) {       v.push_back(i * i);     }     bool divsqr[7001] = {};     for (int i = 1; i <= 7000; i++) {       for (int j = 0; j < v.size(); j++) {         if (i % v[j] == 0) {           divsqr[i] = true;           break;         }       }     }     for (int i = 1; i <= 7000; i++) {       for (int j = i; j <= 7000; j += i) {         if (!divsqr[j / i]) {           for_query[i][j] = 1;         }         for_set[j][i] = 1;       }     }   }   void solve() {     int n, q;     cin >> n >> q;     for (int i = 0; i < q; i++) {       int t;       cin >> t;       if (t == 1) {         int x, v;         cin >> x >> v;         x--;         memo[x] = for_set[v];       } else if (t == 2) {         int x, y, z;         cin >> x >> y >> z;         x--;         y--;         z--;         memo[x] = memo[y] ^ memo[z];       } else if (t == 3) {         int x, y, z;         cin >> x >> y >> z;         x--;         y--;         z--;         memo[x] = memo[y] & memo[z];       } else {         int x, v;         cin >> x >> v;         x--;         int num = (memo[x] & for_query[v]).count();         cout << num % 2;       }     }     cout << endl;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   constexpr int N = 1e5 + 5;   string s;   int n;   int f(int x, int y) {     int z = x;     int res = 0;     for (int i = 0; i < n; i++) {       if (s[i] == z) {         res++;         z = x + y - z;       }     }     if (res & 1) res -= (x != y);     return res;   }   void solve() {     cin >> s;     n = s.size();     for (char &c : s) c -=  0 ;     int res = 0;     for (int i = 0; i < 10; i++) {       for (int j = 0; j < 10; j++) {         res = max(res, f(i, j));       }     }     cout << n - res <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   inline int Int() {     int x;     scanf( %d , &x);     return x;   }   inline long long Long() {     long long x;     scanf( %lld , &x);     return x;   }   void err(istream_iterator<string> it) { cout << endl; }   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a <<    ;     err(++it, args...);   }   const int N = (int)2e5 + 5;   const int maxN = (int)1e6 + 6;   const long long Mod = (long long)1e9 + 7;   const int inf = (int)2e9;   const long long Inf = (long long)1e18;   const int mod = (int)1e9 + 7;   inline int add(int a, int b) {     a += b;     return a >= mod ? a - mod : a;   }   inline int sub(int a, int b) {     a -= b;     return a < 0 ? a + mod : a;   }   inline int mul(int a, int b) { return (long long)a * b % mod; }   long long a[N], s[N], p[N];   struct CHT {     vector<long long> m, c;     bool bad(int f1, int f2, int f3, int tp) {       if (tp == 1)         return 1.0 * (c[f3] - c[f1]) * (m[f1] - m[f2]) >=                1.0 * (c[f2] - c[f1]) * (m[f1] - m[f3]);       else         return 1.0 * (c[f3] - c[f1]) * (m[f1] - m[f2]) <=                1.0 * (c[f2] - c[f1]) * (m[f1] - m[f3]);     }     void add(long long _m, long long _c, int tp) {       m.push_back(_m), c.push_back(_c);       int second = (int)m.size();       while (second >= 3 and bad(second - 3, second - 2, second - 1, tp)) {         m.erase(m.end() - 2);         c.erase(c.end() - 2);         --second;       }     }     long long f(long long x, int i) { return x * m[i] + c[i]; }     long long query(long long x) {       int l = 0, r = (int)m.size() - 1, id = 0;       while (l <= r) {         int del = (r - l) / 3;         int mid1 = l + del, mid2 = r - del;         if (f(x, mid1) > f(x, mid2))           id = mid1, r = mid2 - 1;         else           id = mid2, l = mid1 + 1;       }       return f(x, id);     }   } ds, ds1;   int main() {     int test = 1, tc = 0;     while (test--) {       int n = Int();       long long ans = 0;       for (int i = 1; i <= n; ++i) {         a[i] = Int();         p[i] = p[i - 1] + a[i];         ans += (1LL * i * a[i]);       }       long long res = 0;       ds.add(n, -p[n], 1);       for (int i = n - 1; i >= 1; --i) {         res = max(res, ds.query(a[i]) + p[i] - i * a[i]);         ds.add(i, -p[i], 1);       }       ds1.add(1, 0, 2);       for (int i = 2; i <= n; ++i) {         res = max(res, ds1.query(a[i]) + p[i] - (i + 1) * a[i]);         ds1.add(i, -p[i - 1], 2);       }       cout << res + ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline bool chkmin(T &a, const T &b) {     return a > b ? a = b, 1 : 0;   }   template <typename T>   inline bool chkmax(T &a, const T &b) {     return a < b ? a = b, 1 : 0;   }   const int oo = 0x3f3f3f3f;   const int maxn = 200100;   int n;   int a[maxn + 5][2];   bool bbig[maxn + 5];   bool take[maxn + 5][2];   int delta[maxn + 5][2];   int pos[maxn + 5];   bool vis[maxn + 5];   long long income[2];   inline void pick(bool player, int id) {     income[player] += a[id][player];     vis[id] = 1;   }   int main() {     scanf( %d , &n);     for (int i = (0), i_end_ = (n); i < i_end_; ++i)       scanf( %d%d%d%d , a[i], a[i] + 1, a[n + i], a[n + i] + 1);     for (int i = (0), i_end_ = (n); i < i_end_; ++i) {       delta[i][0] = a[i][0] - a[n + i][1];       delta[i][1] = a[i][1] - a[n + i][0];       if (a[n + i][0] + a[n + i][1] >= a[i][0] + a[i][1]) bbig[i] = 1;       for (int j = (0), j_end_ = (2); j < j_end_; ++j)         take[i][j] = !(delta[i][j] <= 0 && -delta[i][!j] >= delta[i][j]);     }     for (int i = (0), i_end_ = (n << 1); i < i_end_; ++i) pos[i] = i;     sort(pos, pos + (n << 1), [&](int first, int second) {       return a[first][0] + a[first][1] > a[second][0] + a[second][1];     });     int p[2] = {0, 0};     for (int i = (0), i_end_ = (n << 1); i < i_end_; ++i) {       bool now = i & 1;       while (p[now] < (n << 1)) {         int first = pos[p[now]];         if (!vis[first]) {           if (first >= n) {             if (vis[first - n]) {               pick(now, first);               break;             }           } else if (take[first][now]) {             pick(now, first);             if (bbig[first])               pick(!now, first + n);             else               break;           }         }         ++p[now];       }     }     printf( %I64d n , income[0] - income[1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 7;   const int inf = 0x3f3f3f3f;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const int mod = 1e9 + 7;   const double eps = 1e-8;   const double PI = acos(-1);   template <class T, class S>   inline void add(T &a, S b) {     a += b;     if (a >= mod) a -= mod;   }   template <class T, class S>   inline void sub(T &a, S b) {     a -= b;     if (a < 0) a += mod;   }   template <class T, class S>   inline bool chkmax(T &a, S b) {     return a < b ? a = b, true : false;   }   template <class T, class S>   inline bool chkmin(T &a, S b) {     return a > b ? a = b, true : false;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   int n;   long long dp[N];   long long w[N];   long long ans;   vector<pair<long long, int> > G[N];   void dfs(int u, int fa) {     vector<long long> V;     for (auto &e : G[u]) {       int v = e.second;       long long w = e.first;       if (v == fa) continue;       dfs(v, u);       if (dp[v] - e.first > 0) V.push_back(dp[v] - e.first);     }     sort(V.rbegin(), V.rend());     if (((int)V.size()) >= 2) {       chkmax(ans, V[0] + V[1] + w[u]);       dp[u] = V[0] + w[u];     } else if (((int)V.size()) >= 1) {       chkmax(ans, V[0] + w[u]);       dp[u] = V[0] + w[u];     } else {       chkmax(ans, w[u]);       dp[u] = w[u];     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %lld , &w[i]);     }     for (int i = 1; i < n; i++) {       int u, v, c;       scanf( %d%d%d , &u, &v, &c);       G[u].push_back(make_pair(c, v));       G[v].push_back(make_pair(c, u));     }     dfs(1, 0);     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5e3 + 3;   map<int, int> mapa;   vector<int> v;   int mw[103030];   int main() {     int n, m, a, maxi = 0;     scanf( %d %d , &n, &m);     for (int i = (int)0; i < (int)n; i++) {       scanf( %d , &a);       mapa[a] = 1;       mw[i] = a;       if (maxi > a) maxi = a;     }     int o = 1;     while (m) {       if (m - o < 0) break;       if (!mapa[o]) v.push_back(o), m -= o;       o++;     }     printf( %d n , v.size());     for (int i = (int)0; i < (int)v.size(); i++) printf( %d  , v[i]);     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   int n, U, a[MAXN];   double ans = 0;   int main() {     cin >> n >> U;     for (int i = 1; i <= n; i++) cin >> a[i];     int now = 1;     for (int i = 1; i <= n; i++) {       while (now <= n && a[now] - a[i] <= U) now++;       now--;       if (now - i + 1 < 3) continue;       ans = max(ans, (a[now] - a[i + 1]) * 1.0 / (a[now] - a[i]));     }     if (ans == 0)       cout << -1 << endl;     else       printf( %.10lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef struct node_t {     string name;     int h;   } node_t;   int n;   node_t node[3010];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> node[i].name >> node[i].h;     }     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         if (node[i].h > node[j].h) {           string str = node[i].name;           int h = node[i].h;           node[i].name = node[j].name;           node[i].h = node[j].h;           node[j].name = str;           node[j].h = h;         }       }     }     bool flag = true;     for (int i = 1; i <= n; i++) {       if (i - node[i].h < 1) {         flag = false;         break;       }       node[i].h = i - node[i].h;       for (int j = 1; j < i; j++) {         if (node[j].h >= node[i].h) {           node[j].h = node[j].h + 1;         }       }     }     if (!flag) {       cout << -1;     } else {       for (int i = 1; i <= n; i++) {         cout << node[i].name <<     << node[i].h << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int d, n, m;   int i, j;   vector<pair<int, int> > gas;   struct cmp {     bool operator()(const pair<int, int> &p1, const pair<int, int> &p2) {       return p1.second > p2.second;     }   };   priority_queue<pair<int, int>, vector<pair<int, int> >, cmp> q;   int main() {     scanf( %d%d%d , &d, &n, &m);     gas.push_back(make_pair(0, 0));     gas.push_back(make_pair(n, -1));     for (i = 0; i < m; i++) {       int x, p;       scanf( %d%d , &x, &p);       gas.push_back(make_pair(x, p));       if (x + n < d) gas.push_back(make_pair(x + n, -1));     }     gas.push_back(make_pair(d, -1));     sort(gas.begin(), gas.end());     int sz = gas.size();     long long ans = 0, pos = 0;     q.push(gas[0]);     for (i = 1; i < sz; i++) {       int lim = gas[i].first - n;       if (pos < lim) return puts( -1 ), 0;       while (q.top().first < lim) q.pop();       ans += (long long)(gas[i].first - gas[i - 1].first) * q.top().second;       if (gas[i].second != -1) {         q.push(gas[i]);         pos = gas[i].first;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &num) {     num = 0;     char ch;     int flag = 1;     while ((ch = getchar()) <  0  || ch >  9 )       if (ch ==  - ) flag *= -1;     while (ch >=  0  && ch <=  9 ) num = num * 10 + ch -  0 , ch = getchar();     num *= flag;   }   const int MAXN = 200005;   int n, num[MAXN], v[MAXN], st[MAXN], tot;   long long ans;   bool vis[MAXN], had[MAXN];   void dfs(int u) {     if (vis[u]) {       int mn = 0x7f7f7f7f;       do {         mn = min(mn, num[st[tot]]);         had[st[tot]] = 1;       } while (st[tot--] != u);       ans += mn;       return;     }     vis[u] = 1;     st[++tot] = u;     if (had[v[u]]) {       had[u] = 1;       return;     }     dfs(v[u]);     had[u] |= had[v[u]];   }   int main() {     read(n);     for (int i = 1; i <= n; i++) scanf( %d , &num[i]);     for (int i = 1; i <= n; i++) scanf( %d , &v[i]);     for (int i = 1; i <= n; i++)       if (!vis[i]) dfs(i);     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[15];   long long M[5][5];   long long s;   long long check() {     long long rs[5], cs[5];     memset(rs, 0, sizeof(rs));     memset(cs, 0, sizeof(cs));     long long d1 = 0, d2 = 0;     for (long long i = 1; i <= n; i++) {       for (long long j = 1; j <= n; j++) {         rs[i] += M[i][j];         cs[j] += M[i][j];         if (i == j) d1 += M[i][j];         if (i + j == n + 1) d2 += M[i][j];       }     }     set<long long> st;     for (long long i = 1; i <= n; i++) st.insert(rs[i]), st.insert(cs[i]);     st.insert(d1);     st.insert(d2);     if (st.size() == 1) {       s = d1;       return 1;     }     return 0;   }   int main() {     cin >> n;     for (long long i = 0; i < n * n; i++) cin >> a[i];     sort(a, a + n * n);     do {       memset(M, 0, sizeof(M));       long long j = 1, k = 1;       for (long long i = 0, cnt = 1; i < n * n; i++, cnt++) {         M[j][k] = a[i];         k++;         if (cnt % n == 0) j++, k = 1;       }       if (check()) {         cout << s <<   n ;         for (long long i = 1; i <= n; i++) {           for (long long j = 1; j <= n; j++) cout << M[i][j] <<    ;           cout <<   n ;         }         return 0;       }     } while (next_permutation(a, a + n * n));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unordered_map<int, int> mp;   int cnt[200005];   int a[200005];   int num[200005];   int l, r, t;   int tot = 0;   int lz[200005];   int ans[200005];   int A, B;   int be[200005];   struct Query {     int l, r, id, t;     Query() {}     Query(int _l, int _r, int _id, int _t) { l = _l, r = _r, id = _id, t = _t; }     bool operator<(const Query &rhs) const {       return be[l] == be[rhs.l] ? (be[r] == be[rhs.r] ? t < rhs.t : r < rhs.r)                                 : l < rhs.l;     }   } q[200005];   struct Change {     int x, y, lz;     Change() {}     Change(int _x, int _y, int _lz) { x = _x, y = _y, lz = _lz; }   } p[200005];   int getid(int x) {     if (!mp.count(x)) mp[x] = ++tot;     return mp[x];   }   void add(int x, int k) {     if (num[x]) cnt[num[x]]--;     num[x] += k;     if (num[x]) cnt[num[x]]++;   }   void change(int x, int k) {     if (l <= x && r >= x) {       add(a[x], -1);       add(k, 1);     }     a[x] = k;   }   int getres() {     for (int i = 1;; i++) {       if (cnt[i] == 0) return i;     }   }   int main() {     int n, m;     cin >> n >> m;     int len = pow(n, 0.6666);     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       lz[i] = a[i] = getid(x);       be[i] = (i - 1) / len + 1;     }     for (int i = 1; i <= m; i++) {       int op, x, y;       scanf( %d%d%d , &op, &x, &y);       if (op == 1) {         q[++A] = Query(x, y, A, B);       } else {         y = getid(y);         p[++B] = Change(x, y, lz[x]);         lz[x] = y;       }     }     sort(q + 1, q + 1 + A);     l = 1, r = 0, t = 0;     for (int i = 1; i <= A; i++) {       while (t < q[i].t) change(p[t + 1].x, p[t + 1].y), t++;       while (t > q[i].t) change(p[t].x, p[t].lz), t--;       while (l < q[i].l) add(a[l], -1), l++;       while (l > q[i].l) add(a[l - 1], 1), l--;       while (r < q[i].r) add(a[r + 1], 1), r++;       while (r > q[i].r) add(a[r], -1), r--;       ans[q[i].id] = getres();     }     for (int i = 1; i <= A; i++) {       cout << ans[i] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int N, M, K;   int Ar[110][110];   int Temp[110][110];   int Dn[110];   int Res = -1;   int f() {     int rev = 0;     for (int i = 1, a, b; i <= N; i++) {       a = 0;       b = 0;       for (int j = 1; j <= M; j++) {         a += (Ar[i][j] == Dn[j]);         b += (Ar[i][j] != Dn[j]);       }       rev += min(a, b);     }     return rev;   }   int main() {     scanf( %d%d%d , &N, &M, &K);     for (int i = 1; i <= N; i++)       for (int j = 1; j <= M; j++) scanf( %d , &Temp[i][j]);     if (N < M) {       for (int i = 1; i <= N; i++)         for (int j = 1; j <= M; j++) Ar[j][i] = Temp[i][j];       int temp = N;       N = M;       M = temp;     } else       for (int i = 1; i <= N; i++)         for (int j = 1; j <= M; j++) Ar[i][j] = Temp[i][j];     if (N <= K) {       for (int i = 0, mi = (1 << M); i < mi; i++) {         for (int j = 1; j <= M; j++) Dn[j] = (i & (1 << (j - 1))) != 0;         int temp = f();         if (temp <= K && (Res == -1 || temp < Res)) Res = temp;       }     } else {       for (int i = 1; i <= N; i++) {         for (int j = 1; j <= M; j++) Dn[j] = Ar[i][j];         int temp = f();         if (temp <= K && (Res == -1 || temp < Res)) Res = temp;       }     }     printf( %d n , Res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 4;   int n, c[maxn];   string s[maxn];   long long dp[maxn][2];   long long best(int ind, bool rev) {     if (ind == n) {       return 0;     }     if (dp[ind][rev] != -1) {       return dp[ind][rev];     }     string t = s[ind - 1];     if (rev) {       reverse(t.begin(), t.end());     }     string v = s[ind];     reverse(v.begin(), v.end());     if (s[ind] < t && v < t) {       return dp[ind][rev] = 1e17;     }     if (s[ind] >= t && v >= t) {       return dp[ind][rev] =                  min(c[ind] + best(ind + 1, true), best(ind + 1, false));     }     if (s[ind] >= t) {       return dp[ind][rev] = best(ind + 1, false);     }     return dp[ind][rev] = c[ind] + best(ind + 1, true);   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> c[i];     }     for (int i = 0; i < n; i++) {       cin >> s[i];     }     memset(dp, -1, sizeof dp);     long long res1 = c[0] + best(1, true);     long long res2 = best(1, false);     long long res = min(res1, res2);     if (res > 1e15) {       res = -1;     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T abs(T x) {     return x < 0 ? -x : x;   }   const double EPS = 1e-9;   int n, m, a[55], b[55], mx, ans, x;   double cur;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , a + i);     scanf( %d , &m);     for (int i = 0; i < m; ++i) scanf( %d , b + i);     mx = 0;     ans = 0;     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) {         cur = (b[j] + 0.) / a[i];         if (abs((int)cur - cur) < EPS) {           x = (int)cur;           if (x > mx) {             mx = x;             ans = 1;           } else if (x == mx)             ++ans;         }       }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> get(int n) {     if (n == 1) {       return {1};     }     if (n == 2) {       return {3, 4};     }     vector<int> a;     if (n % 2 == 0) {       int k = n / 2;       for (int i = 1; i <= 2 * k - 1; i++) {         a.push_back(1);       }       a.push_back(k - 1);     } else {       int k = n / 2;       for (int i = 1; i <= 2 * k - 1; i++) {         a.push_back(1);       }       a.push_back(2);       a.push_back(k + 1);     }     return a;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<int> a = get(n), b = get(m);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cout << a[i] * b[j] <<    ;       }       cout <<   n ;     }   }