malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long N;   long long F[20][10][10] = {{{0}}};   int to[20][10][10] = {{{0}}};   long long Ans[20][10] = {{0}};   void done() {     for (int i = 0; i <= 9; i++) {       for (int j = 0; j <= 9; j++) {         int x = max(i, j);         if (i == 0 || i < x) {           F[1][i][j] = 0;           to[1][i][j] = i;           continue;         }         F[1][i][j] = F[1][i - x][j] + 1;         to[1][i][j] = to[1][i - x][j];       }     }     for (int l = 2; l <= 18; l++) {       for (int i = 0; i <= 9; i++)         for (int j = 0; j <= 9; j++) {           long long cost = 0;           int cnt = i;           for (int x = 9; x >= 1; x--) {             cost += F[l - 1][cnt][max(x, j)];             cnt = to[l - 1][cnt][max(x, j)];             cost++;             cnt = 10 + cnt - max(max(j, x), cnt);           }           cost += F[l - 1][cnt][j];           cnt = to[l - 1][cnt][j];           F[l][i][j] = cost;           to[l][i][j] = cnt;         }     }     long long Ans = 0;     int Len = 0;     long long Cnt = N;     for (; Cnt > 0; Cnt /= 10, Len++)       ;     int remains = N % 10;     N /= 10;     for (int i = 1; i <= Len - 1; i++) {       int Need = N % 10;       N /= 10;       int Max = 0;       for (Cnt = N; Cnt > 0; Cnt /= 10) Max = max((long long)Max, Cnt % 10);       for (; Need >= 0; Need--) {         Ans += F[i][remains][max(Max, Need)];         remains = to[i][remains][max(Max, Need)];         if (Need > 0 || N > 0) {           Ans++;           remains = remains + 10 - max(max(Max, Need), remains);         }       }       N--;     }     cout << Ans << endl;     return;   }   int main() {     cin >> N;     if (N <= 9)       cout << (N > 0) << endl;     else       done();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int testcases;     cin >> testcases;     while (testcases--) {       long long int n, m;       cin >> n >> m;       char a[n][m];       for (long long int(i) = 0; (i) < (n); (i)++) {         for (long long int(j) = 0; (j) < (m); (j)++) cin >> a[i][j];       }       long long int cnt = 0;       for (long long int j = 0; j < m - 1; j++) {         if (a[n - 1][j] ==  D ) cnt++;       }       for (long long int(i) = 0; (i) < (n - 1); (i)++) {         if (a[i][m - 1] ==  R ) cnt++;       }       cout << cnt <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {-1, 1, 0, 0, 1, -1, 1, -1};   int dy[] = {0, -0, -1, 1, 1, -1, -1, 1};   void run() {}   int fixMod(int a, int b) { return ((a % b) + b) % b; }   long long gcd(long long a, long long b) {     return (b == 0 ? abs(a) : gcd(b, a % b));   }   void fast() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int n, m;   vector<vector<char>> grid;   bool flag = 0;   pair<int, int> per[1510][1510];   bool vis[1510][1510];   int stx, sty;   bool dfs(int x, int y) {     int xm = (x + n * 2000) % n;     int ym = (y + m * 2000) % m;     if (grid[xm][ym] ==  # ) return 0;     if (vis[xm][ym]) {       return per[xm][ym] != make_pair(x, y);     }     vis[xm][ym] = 1;     per[xm][ym] = {x, y};     bool ret = 0;     for (int i = 0; i < 4; i++) {       ret |= dfs(x + dx[i], y + dy[i]);     }     return ret;   }   int main() {     run();     fast();     cin >> n >> m;     grid.resize(n);     for (int i = 0; i < n; i++) {       grid[i].resize(m);       for (int j = 0; j < m; j++) {         cin >> grid[i][j];         if (grid[i][j] ==  S ) stx = i, sty = j;       }     }     if (dfs(stx, sty))       cout <<  YES             <<   n ;     else       cout <<  NO             <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     double x, y, r;   };   double dis(node a, node b) {     double dx = a.x - b.x, dy = a.y - b.y;     return sqrt(dx * dx + dy * dy);   }   double R, d;   node origin = {0, 0};   bool check(node a) {     double distance = dis(a, origin);     if (distance - a.r >= R - d && distance + a.r <= R) return true;     return false;   }   int main() {     scanf( %lf%lf , &R, &d);     int k, ans = 0;     scanf( %d , &k);     while (k--) {       node now;       scanf( %lf%lf%lf , &now.x, &now.y, &now.r);       if (check(now)) ans++;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[200200], w[200200], dp[3030][3030], ep[3030][3030], X, Y, Z,       ans[200200], Inv[2 * 3030 + 5];   const int mod = 998244353;   int expmod(int x, int n) {     int rlt = 1;     while (n) {       if (n & 1) rlt = 1ll * rlt * x % mod;       x = 1ll * x * x % mod, n >>= 1;     }     return rlt;   }   inline int inv(int x) { return expmod(x, mod - 2); }   inline void add(int &x, long long y) { x = (x + y) % mod; }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i++) scanf( %d , &w[i]);     for (int i = 1; i <= n; i++) {       if (a[i])         X += w[i];       else         Y += w[i];     }     Z = X + Y;     dp[0][0] = 1;     for (int i = -3030; i <= 3030; i++) Inv[i + 3030] = inv(i + Z);     for (int i = 0; i <= m; i++) {       for (int j = 0; j <= m - i; j++) {         int s = 0;         if (i) {           add(dp[i][j],               1ll * dp[i - 1][j] * (i - 1 + X) % mod * Inv[i - 1 - j + 3030]);           add(ep[i][j],               1ll * ep[i - 1][j] * (i - 1 + X) % mod * Inv[i - 1 - j + 3030]);           add(s, 1ll * dp[i - 1][j] * Inv[i - 1 - j + 3030]);           add(s, 1ll * ep[i - 1][j] * Inv[i - 1 - j + 3030]);         }         if (j) {           add(dp[i][j],               1ll * dp[i][j - 1] * (Y - j) % mod * Inv[i - j + 1 + 3030]);           add(ep[i][j],               1ll * ep[i][j - 1] * (Y - j) % mod * Inv[i - j + 1 + 3030]);           add(s, 1ll * dp[i][j - 1] * Inv[i - j + 1 + 3030]);           add(s, 1ll * ep[i][j - 1] * Inv[i - j + 1 + 3030]);         }         add(ep[i][j], s);       }     }     int L = 0, R = 0;     for (int i = 0; i <= m; i++) add(L, dp[i][m - i]), add(R, ep[i][m - i]);     for (int k = 1; k <= n; k++) {       printf( %d n , (1ll * w[k] * (L + a[k] * R) % mod + mod) % mod);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x, s;   int a[105];   double f[105][10005];   int main() {     cin >> n >> x;     for (int i = 1; i <= n; i++) cin >> a[i], s += a[i];     f[0][0] = 1;     for (int i = 1; i <= n; i++)       for (int j = i; j >= 1; j--)         for (int k = s; k >= a[i]; k--)           f[j][k] += f[j - 1][k - a[i]] * j / (n - j + 1);     double ans = 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= s; j++)         ans += f[i][j] * (min((n + i) * x, j * 2) / 2.0) / i;     printf( %.10lf , ans);     return 0;   }
#include <bits/stdc++.h>   const int INF = 1e6;   using namespace std;   const int maxn = 1e5 + 5;   const int N = 1e6;   const int big = 1e9;   long long int get(long long int a, long long int b, long long int x,                     long long int y) {     x--;     y--;     long long int temp = (y * (y - 1) - x * (x - 1)) / 2;     return a * (y - x) + b * temp;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long int a, b, n, i, l, m, t;     cin >> a >> b >> n;     for (i = 0; i < n; i++) {       cin >> l >> t >> m;       long long int st = l;       long long int en = 2e6 + 5;       while (en - st > 1) {         long long int mid = st + (en - st) / 2;         if ((a + (mid - 2) * b) <= t && get(a, b, l, mid) <= m * t)           st = mid;         else           en = mid;       }       if (st == l) st = 0;       cout << st - 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   queue<pair<int, int> > q;   vector<pair<int, int> > v;   vector<vector<int> > g;   set<pair<int, int> > out;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       v.push_back({x, y});       if (x == 1) q.push({i, y});     }     while (!q.empty()) {       pair<int, int> x = q.front();       q.pop();       int y = x.second;       v[y].second ^= x.first;       v[y].first--;       out.insert({min(x.first, y), max(x.first, y)});       if (v[y].first == 1) {         q.push({y, v[y].second});       }     }     cout << out.size() <<   n ;     for (auto a : out) {       cout << a.first <<     << a.second <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, x, y, i, s = 0, k = 0;     vector<pair<long long int, long long int> > v;     cin >> n >> m;     for (i = 0; i < m; i++) {       cin >> x >> y;       v.push_back(make_pair(y, x));     }     sort(v.begin(), v.end());     for (i = v.size() - 1; i >= 0; i--) {       if (n > 0) {         if (v[i].second >= n) {           s = s + n * v[i].first;           n = 0;         } else {           s = s + v[i].second * v[i].first;           n = n - v[i].second;         }       } else {         k = -1;         cout << s << endl;         break;       }     }     if (k == 0) cout << s << endl;   }
#include <bits/stdc++.h>   using namespace std;   int v[100010];   int main() {     int n, k;     scanf( %d %d , &n, &k);     int low = 1000000001;     for (int i = 0; i < n; i++) {       scanf( %d , &v[i]);       low = min(low, v[i]);     }     long long ans = 0;     for (int i = 0; i < n && ans != -1; i++) {       if ((v[i] - low) % k == 0) {         ans += (v[i] - low) / k;       } else         ans = -1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     stack<char> a;     int count = 0, flag = 0;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  {  || s[i] ==  [  || s[i] ==  <  || s[i] ==  ( )         a.push(s[i]);       else {         if (a.size() == 0) {           cout <<  Impossible ;           return 0;         }         if (a.top() ==  (  && s[i] !=  )  || a.top() ==  {  && s[i] !=  }  ||             a.top() ==  [  && s[i] !=  ]  || a.top() ==  <  && s[i] !=  > )           count++;         a.pop();       }     }     if (a.size() == 0 && flag == 0)       cout << count;     else       cout <<  Impossible ;     return 0;   }
#include <bits/stdc++.h>      using namespace std;   using ll = long long;      #ifdef LOCAL   #define debug(...) {       std::cout <<  [  << __FUNCTION__ <<  :  << __LINE__ <<  ]   << #__VA_ARGS__ <<      << __VA_ARGS__ << std::endl;       }   #else   #define debug(...)   #endif      const long long mod = 1000000007;   #define MOD(x) ((x)%mod)   struct UnionFind {    vector<int> par;    vector<int> siz;    vector<int> val;    UnionFind(int N) {     par.resize(N);     siz.resize(N);     val.resize(N);        for (int i = 0; i < N; i++) {      par[i] = i;      siz[i] = 1;         val[i] = 0;     }    }    int& operator[](const int &x) {     return val[getParent(x)];    }    int getParent(int x) {     int t = x;        while (par[x] != x) {      x = par[x];     }        par[t] = x;     return x;    }    int getSize(const int &x) {     return siz[getParent(x)];    }    bool merge(int x, int y) {     x = getParent(x);     y = getParent(y);        if (x == y) {      return false;     }        if (val[x] and val[y]) {      return false;     }        if (siz[x] > siz[y]) {      swap(x, y);    // siz[x] is smaller     }        par[x] = y;     siz[y] += siz[x];     val[y] = val[x] or val[y];     return true;       }    bool connected(const int &x, const int &y) {     return getParent(x) == getParent(y);    }   };   long long power(long long x, long long n) {    int i = 0;    long long d = x;    long long ats = 1;       while (n > 0) {     if (n & (1ll << i)) {      n ^= (1ll << i);      ats *= d;      ats %= mod;     }        i++;     d = (d * d) % mod;    }       return ats;   }   /*input   3 2   1 1   1 2   2 2 1   */   /*input   2 3   2 1 3   2 1 2   */   /*input   3 5   2 1 2   1 3   1 4   */   int main() {    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);    long long n, m;    cin >> n >> m;       UnionFind par(m);       set<int> imt;       for (int i = 0; i < n; ++i) {     int k;     cin >> k;        if (k == 1) {      int a;      cin >> a;      a--;         if (!par[a]) {       par[a] = true;       imt.insert(i);      }     }     else if (k == 2) {      int a, b;      cin >> a >> b;      a--, b--;         if (par.merge(a, b)) {       imt.insert(i);      }     }    }       long long vis = 0;       for (int i = 0; i < m; ++i) {     if (par.getParent(i) == i) {      if (par.val[i]) {       vis += par.siz[i];      }      else {       vis += par.siz[i] - 1;      }     }    }       cout << power(2, vis) <<     << imt.size() <<   n ;       for (auto &&i : imt) {     cout << i + 1 <<    ;    }   }
#include <bits/stdc++.h>   using namespace std;   int const maxn = int(2 * 1e5 + 5);   int dp1[maxn], dp2[maxn], dp3[maxn], n, k, t;   string second;   char chuyen(char c) {     if (c ==  R ) return  G ;     if (c ==  G ) return  B ;     if (c ==  B ) return  R ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> t;     while (t--) {       cin >> n >> k >> second;       second =     + second;       for (int i = 0; i <= second.length(); i++) {         dp1[i] = dp2[i] = dp3[i] = 0;       }       char c =  R ;       for (int i = 1; i <= second.length() - 1; i++) {         if (second[i] != c)           dp1[i] = dp1[i - 1] + 1;         else           dp1[i] = dp1[i - 1];         c = chuyen(c);       }       c =  G ;       for (int i = 1; i <= second.length() - 1; i++) {         if (second[i] != c)           dp2[i] = dp2[i - 1] + 1;         else           dp2[i] = dp2[i - 1];         c = chuyen(c);       }       c =  B ;       for (int i = 1; i <= second.length() - 1; i++) {         if (second[i] != c)           dp3[i] = dp3[i - 1] + 1;         else           dp3[i] = dp3[i - 1];         c = chuyen(c);       }       int res = int(1e9 + 5);       for (int i = 1; i <= second.length() - k; i++) {         res = min(res, dp1[i + k - 1] - dp1[i - 1]);         res = min(res, dp2[i + k - 1] - dp2[i - 1]);         res = min(res, dp3[i + k - 1] - dp3[i - 1]);       }       cout << res <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   int main() {     int h, w, k, count = 0;     scanf( %d %d %d , &h, &w, &k);     for (size_t i = 0; i < k; i++) {       if (h == 1 && w == 1) {         count++;       } else if (h == 1) {         count += w;       } else if (w == 1) {         count += h;       } else {         count += (h * 2) + (w - 2) * 2;       }       h -= 4;       w -= 4;     }     printf( %d n , count);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N;   int x[2001], y[2001];   bool sameLine(int i, int j, int k) {     return (y[i] - y[j]) * (x[k] - x[j]) == (y[k] - y[j]) * (x[i] - x[j]);   }   int main() {     scanf( %d , &N);     for (int i = 0; i < N; i++) scanf( %d %d , &x[i], &y[i]);     long long ans = 0;     for (int i = 0; i < N; i++) {       for (int j = i + 1; j < N; j++) {         for (int k = j + 1; k < N; k++) {           if (!sameLine(i, j, k)) ans++;         }       }     }     printf( %I64d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f(long long p) {     int ans = 0;     while (p) {       ans += p % 10;       p /= 10;     }     return ans;   }   long long g(long long a) {     if (a == 0) return 0;     int digit = 0;     long long b = a;     while (b >= 10) {       digit++;       b /= 10;     }     int b_digit = b;     long long ans = b * digit;     for (int i = 0; i < digit; i++) ans *= 10, b *= 10;     ans *= 9;     ans /= 2;     for (int i = 0; i < b_digit; i++) ans += i * (b / b_digit);     ans += g(a - b) + b_digit * (a - b + 1);     return ans;   }   int main() {     long long a;     scanf( %lld , &a);     long long l = 1, r = 20000000000000000LL;     while (l < r) {       long long mid = (l + r) / 2;       if (g(mid) >= a)         r = mid;       else         l = mid + 1;     }     l = 1;     long long cur = g(r);     while (cur != a) {       if (cur > a) {         cur -= f(l);         l++;       } else {         cur += f(r + 1);         r++;       }     }     printf( %lld %lld , l, r);   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T euclideanistance(T x1, T x2, T y1, T y2) {     return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));   }   template <class T>   T digitSum(T n) {     T sum = 0;     while (n > 0) sum += n % 10, n /= 10;     return sum;   }   const double INF = 1e+9;   const double EPS = 1e-9;   const double PI = 3.1415926;   const int knightDir[8][2] = {{-2, -1}, {-2, 1}, {-1, 2},  {1, 2},                                {2, -1},  {2, 1},  {-1, -2}, {1, -2}};   const int dx[] = {-1, 0, 1, 0};   const int dy[] = {0, 1, 0, -1};   int chk(pair<int, int> a, pair<int, int> b) {     if (a.first == b.first && a.first != b.second && a.second != b.first &&         a.second != b.second)       return 1;     if (a.first != b.first && a.first == b.second && a.second != b.first &&         a.second != b.second)       return 1;     if (a.first != b.first && a.first != b.second && a.second == b.first &&         a.second != b.second)       return 1;     if (a.first != b.first && a.first != b.second && a.second != b.first &&         a.second == b.second)       return 1;     return 0;   }   int getIndex(pair<int, int> a, pair<int, int> b) {     if (a.first == b.first && a.first != b.second && a.second != b.first &&         a.second != b.second)       return a.first;     if (a.first != b.first && a.first == b.second && a.second != b.first &&         a.second != b.second)       return a.first;     if (a.first != b.first && a.first != b.second && a.second == b.first &&         a.second != b.second)       return a.second;     if (a.first != b.first && a.first != b.second && a.second != b.first &&         a.second == b.second)       return a.second;   }   int main() {     int n, m, can = 0, all = 0;     vector<pair<int, int> > a, b;     scanf( %d%d , &n, &m);     a.resize(n);     b.resize(m);     for (int i = 0; i < n; i++) scanf( %d%d , &a[i].first, &a[i].second);     for (int i = 0; i < m; i++) scanf( %d%d , &b[i].first, &b[i].second);     vector<int> alls(10);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (chk(a[i], b[j])) {           vector<int> c1(10);           vector<int> c2(10);           for (int k = 0; k < m; k++) {             if (chk(a[i], b[k])) {               c1[getIndex(a[i], b[k])] = 1;             }           }           for (int k = 0; k < n; k++) {             if (chk(a[k], b[j])) {               c2[getIndex(a[k], b[j])] = 1;             }           }           if (count(c1.begin(), c1.end(), 1) == 1 &&               count(c2.begin(), c2.end(), 1) == 1)             can++;           alls[getIndex(a[i], b[j])] = 1;           all++;         }       }     }     if (count(alls.begin(), alls.end(), 1) == 1) {       for (int i = 1; i <= 10; i++) {         if (alls[i]) {           printf( %d n , i);           return 0;         }       }     }     if (can == all) {       printf( 0 n );       return 0;     }     printf( -1 n );   }
#include <bits/stdc++.h>   using namespace std;   long long lcis(long long a[], long long n) {     unordered_map<long long, long long> make_pair;     long long dp[n], lastIndex;     memset(dp, 0, sizeof(dp));     ;     long long mx = INT_MIN;     for (long long i = 0; i < n; i++) {       if (make_pair.find(a[i] - 1) != make_pair.end())         lastIndex = make_pair[a[i] - 1] - 1, dp[i] = 1 + dp[lastIndex];       else         dp[i] = 1;       make_pair[a[i]] = i + 1;       mx = max(mx, dp[i]);     }     return mx;   }   int main() {     long long n;     cin >> n;     long long arr[n];     for (long long i = 0; i < n; i++) cin >> arr[i];     long long li = lcis(arr, n);     cout << n - li << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e16 + 3;   const int mod = 1e9 + 7;   const int lim = 2e5 + 2;   int q, ni;   string str;   void solve() {     cin >> q;     while (q--) {       cin >> ni >> str;       if (ni > 2) {         cout <<  YES               <<   n ;         cout << 2 <<   n ;         cout << str[0] <<    ;         for (int i = 1; i < ni; i++) cout << str[i];         cout <<   n ;       } else {         int f = str[0] -  0 ;         int s = str[1] -  0 ;         if (f < s) {           cout <<  YES                 <<   n ;           cout << 2 <<   n ;           cout << str[0] <<     << str[1] <<   n ;         } else           cout <<  NO                 <<   n ;       }     }   }   void fastIO() {     cin.sync_with_stdio(false);     cin.tie(0);   }   void IO() {     if (fopen( d:  lmo.in ,  r ) != NULL) {       freopen( d:  lmo.in ,  r , stdin);     } else if (fopen( /media/luismo/Pablo s Destruction/lmo.in ,  r ) != NULL) {       freopen( /media/luismo/Pablo s Destruction/lmo.in ,  r , stdin);     }   }   int main() {     IO();     fastIO();     solve();   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2e9;   const long long LINF = 2e18;   void inv(bool e);   template <typename T>   void die(T& a);   bool brute, alter;   int cnt_tests = 1;   const int N = (1 << 17) + 1;   int degree[N], xr[N];   int n;   void inp() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> degree[i] >> xr[i];     }   }   set<int> friends[N];   void solve() {     for (int i = 0; i < n; i++) {       friends[degree[i]].insert(i);     }     int newbie, parent;     auto& cur = friends[1];     vector<pair<int, int> > ans;     while (!cur.empty()) {       newbie = *cur.begin();       cur.erase(cur.begin());       parent = xr[newbie];       friends[degree[parent]].erase(parent);       friends[degree[parent] - 1].insert(parent);       degree[parent]--;       ans.push_back({newbie, parent});       xr[parent] ^= newbie;     }     cout << ((int)(ans).size()) << endl;     for (auto x : ans) {       cout << x.first <<     << x.second << endl;     }   }   void stress() {}   void naive() {}   void run();   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     if (0) {       freopen( stack.in ,  r , stdin);       freopen( stack.out ,  w , stdout);     }     brute = false;     for (int i = 0; (i < cnt_tests); i++) {       run();     }     cerr << endl <<  Time:   << clock() / 1000.0 <<   ms ;     return 0;   }   void run() {     if (!brute) {       inp();     } else {       stress();     }     solve();   }   template <typename T>   void die(T& a) {     cout << a;     exit(0);   }   void inv(bool e) {     if (!e) {       vector<int> a;       a[-1] += 1;     }   }
#include <bits/stdc++.h>   using namespace std;   void ga(int N, int *A) {     for (int i(0); i < N; i++) scanf( %d , A + i);   }   char s[64][64];   int N, M, x = int(1e9 + 1), X, y = int(1e9 + 1), Y;   int main(void) {     scanf( %d%d , &N, &M);     for (int i(0); i < N; i++) scanf( %s , s[i]);     for (int i(0); i < N; i++)       for (int j(0); j < M; j++)         if (s[i][j] == 42)           x = min(x, i), X = max(X, i), y = min(y, j), Y = max(Y, j);     for (int k(x); k < X + 1; k++) {       for (int l(y); l < Y + 1; l++) putchar(s[k][l]);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 10;   int mapp[110][110];   int b[110][110];   int main() {     int Cas = 1;     scanf( %d , &Cas);     while (Cas--) {       int n, m;       scanf( %d%d , &n, &m);       memset(mapp, 0, sizeof(mapp));       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) {           scanf( %d , &mapp[i][j]);           int flag = (i + j) % 2;           if (mapp[i][j] % 2 == flag)             b[i][j] = mapp[i][j];           else             b[i][j] = mapp[i][j] + 1;         }       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) printf( %d%c , b[i][j], j == m ?   n  :    );     }     return 0;   }