malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int min(int a, int b) {     int min = a;     if (b < a) {       min = b;     }     return min;   }   int main() {     int a, b, c, ans, min;     cin >> a;     cin >> b;     cin >> c;     if (a == 1 && b != 1 && c != 1) {       ans = (a + b) * c;     } else if (a != 1 && b != 1 && c == 1) {       ans = a * (b + c);     } else if (a != 1 && b == 1 && c != 1) {       if (a < c) {         ans = (a + b) * c;       } else {         ans = a * (b + c);       }     } else if (a == 1 && b == 1 && c != 1) {       ans = (a + b) * c;     } else if (a != 1 && b == 1 && c == 1) {       ans = a * (b + c);     } else if (a == 1 && c == 1) {       ans = a + b + c;     } else {       ans = a * b * c;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dx[] = {0, 1, 0, -1};   const int dy[] = {1, 0, -1, 0};   inline 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;   }   inline long long read1() {     long long 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 ans;   long long w[20], ansa, ansb, ansc;   void dfs(long long a, long long b, long long c, long long nowa, long long nowb,            long long jin, int nowl, int wei) {     if (nowl >= ans) return;     if (!a && !b && !c && !jin) {       ans = nowl;       ansa = nowa;       ansb = nowb;       return;     }     if (!c) {       int tot = 0;       long long nw = jin + a + b;       while (nw) {         tot++;         nw /= 10;       }       dfs(0, 0, 0, nowa + a * w[wei], nowb + b * w[wei], 0, nowl + tot, wei);       return;     }     if ((a + b + jin) % 10 == c % 10)       dfs(a / 10, b / 10, c / 10, nowa + a % 10 * w[wei], nowb + b % 10 * w[wei],           (a % 10 + b % 10 + jin) / 10, nowl, wei + 1);     else {       dfs(a * 10 + (c + 10 - b % 10 - jin) % 10, b, c, nowa, nowb, jin, nowl + 1,           wei);       dfs(a, b * 10 + (c + 10 - a % 10 - jin) % 10, c, nowa, nowb, jin, nowl + 1,           wei);       dfs(a, b, c * 10 + (a + b + jin) % 10, nowa, nowb, jin, nowl + 1, wei);     }   }   int a, b, c;   int main() {     scanf( %d+%d=%d , &a, &b, &c);     w[0] = 1;     ans = 12;     for (int i = 1; i <= 18; i++) w[i] = w[i - 1] * 10;     dfs(a, b, c, 0, 0, 0, 0, 0);     printf( %I64d+%I64d=%I64d , ansa, ansb, ansa + ansb);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char t[5][13] = { S ,  M ,  L ,  XL ,  XXL };   char s[13];   int a[5], p[] = {0, 1, -1, 2, -2, 3, -3, 4, -4};   int main() {     for (int i = 0; i < (5); ++i) scanf( %d , &a[i]);     int n;     scanf( %d , &n);     while (n--) {       scanf( %s , s);       int x = 0;       for (int i = 0; i < (5); ++i)         if (!strcmp(t[i], s)) x = i;       for (int i = 0; i < (9); ++i)         if (x + p[i] >= 0 && x + p[i] < 5 && a[x + p[i]]) {           puts(t[x + p[i]]);           a[x + p[i]]--;           break;         }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   int n, dp[MAXN], ans[MAXN], mx[4 * MAXN], lz[4 * MAXN];   vector<pair<int, int> > v, id;   void refresh(int pos, int bg, int ed) {     if (lz[pos] == 0) return;     int LZ = lz[pos];     lz[pos] = 0;     mx[pos] += LZ;     if (bg == ed) return;     lz[2 * pos] += LZ;     lz[2 * pos + 1] += LZ;   }   void upd(int pos, int bg, int ed, int p, int q, int val) {     refresh(pos, bg, ed);     if (q < bg || ed < p) return;     if (p <= bg && ed <= q) {       lz[pos] += val;       refresh(pos, bg, ed);       return;     }     int mid = (bg + ed) >> 1, l = 2 * pos, r = 2 * pos + 1;     upd(l, bg, mid, p, q, val);     upd(r, mid + 1, ed, p, q, val);     mx[pos] = max(mx[l], mx[r]);   }   int qry(int pos, int bg, int ed, int p, int q) {     refresh(pos, bg, ed);     if (q < bg || ed < p) return 0;     if (p <= bg && ed <= q) return mx[pos];     int mid = (bg + ed) >> 1, l = 2 * pos, r = 2 * pos + 1;     return max(qry(l, bg, mid, p, q), qry(r, mid + 1, ed, p, q));   }   int main() {     scanf( %d , &n);     for (int i = 0, x, h; i < n; i++) {       scanf( %d %d , &x, &h);       v.push_back(make_pair(x, x + h - 1));       id.push_back(make_pair(x, i));     }     sort(v.begin(), v.end());     sort(id.begin(), id.end());     dp[n - 1] = 1;     ans[id[n - 1].second] = 1;     upd(1, 0, n - 1, n - 1, n - 1, 1);     for (int i = n - 2; i >= 0; i--) {       int a = v[i].first;       int b = v[i].second;       int t = lower_bound(v.begin(), v.end(), make_pair(b + 1, (int)-1e9)) -               v.begin();       t--;       if (t == i)         dp[i] = 1;       else         dp[i] = qry(1, 0, n - 1, i + 1, t) + 1;       upd(1, 0, n - 1, i, i, dp[i]);       upd(1, 0, n - 1, i + 1, n - 1, 1);       ans[id[i].second] = dp[i];     }     for (int i = 0; i < n; i++) printf( %d  , ans[i]);     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e3 + 20;   const int MOD = 1e9 + 7;   const int INF = 0x3f3f3f3f;   const long long LLINF = 0x3f3f3f3f3f3f3f3f;   const double PI = acos(-1.0);   const double RATE = 0.995;   const double eps = 1e-4;   int arr[MAXN][MAXN];   signed main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         scanf( %d , &arr[i][j]);       }     }     int a1a2 = arr[1][2];     int a2 = sqrt(1ll * a1a2 * arr[2][3] / arr[1][3]);     printf( %d  , arr[1][2] / a2);     printf( %d , a2);     for (int i = 3; i <= n; ++i) printf(  %d , arr[2][i] / a2);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n;     cin >> n;     vector<pair<long long, long long>> ans;     long long i = 0;     long long j = 0;     ans.push_back({0, -1});     ans.push_back({-1, 0});     ans.push_back({-1, -1});     for (long long k = 0; k < n; k++) {       ans.push_back({i, j});       ans.push_back({i, j + 1});       ans.push_back({i + 1, j});       i++;       j++;     }     ans.push_back({i, j});     cout << ans.size() << endl;     for (long long i = 0; i < ans.size(); i++)       cout << ans[i].first <<     << ans[i].second << endl;   }   signed main() {     long long t;     t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k;     cin >> n >> k;     long long int prices[n];     for (long long int i = 0; i < n; i++) {       cin >> prices[i];     }     long long int minimum = prices[0];     long long int ans = 0;     for (long long int i = 1; i < n; i++) {       if (prices[i] < minimum) {         minimum = prices[i];       }     }     for (long long int i = 0; i < n; i++) {       prices[i] -= minimum;     }     for (long long int i = 0; i < n; i++) {       if (prices[i] % k != 0) {         cout << -1 << endl;         return 0;       }     }     for (long long int i = 0; i < n; i++) {       ans += prices[i] / k;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   char a[N], b[N];   int n, T;   int ans[N * 2], ct, rev;   int rt, ch[N][2], fa[N], tg[N], col[N], sz[N];   int get(int x) { return ch[fa[x]][1] == x; }   void pushdown(int x) {     swap(ch[x][0], ch[x][1]), col[ch[x][0]] ^= 1, col[ch[x][1]] ^= 1,         tg[ch[x][0]] ^= 1, tg[ch[x][1]] ^= 1;     tg[x] = 0;   }   int s(int x, int k) {     if (tg[x]) pushdown(x);     if (sz[ch[x][0]] >= k) return s(ch[x][0], k);     if (sz[ch[x][0]] + 1 == k) return x;     return s(ch[x][1], k - sz[ch[x][0]] - 1);   }   char sc(int k) { return col[s(rt, k)] +  0 ; }   void updata(int x) { sz[x] = sz[ch[x][0]] + sz[ch[x][1]] + 1; }   void rotate(int x) {     int k = get(x), y = fa[x];     ch[y][k] = ch[x][k ^ 1];     fa[ch[y][k]] = y;     if (fa[y]) ch[fa[y]][ch[fa[y]][1] == y] = x;     fa[x] = fa[y];     fa[y] = x;     ch[x][k ^ 1] = y;     updata(y);     updata(x);   }   int q[N], cnt;   void splay(int x) {     int y;     q[cnt = 1] = x;     for (int i = x; fa[i]; i = fa[i]) q[++cnt] = fa[i];     for (int i = cnt; i >= 1; i--)       if (tg[q[i]]) pushdown(q[i]);     while (fa[x]) {       y = fa[x];       if (fa[y]) rotate(get(x) == get(y) ? y : x);       rotate(x);     }   }   void work(int k) {     if (k == n) {       col[rt] ^= 1;       tg[rt] ^= 1;       return;     }     int y = s(rt, k + 1);     splay(y);     rt = y;     col[ch[y][0]] ^= 1, tg[ch[y][0]] ^= 1;   }   void clr() {     for (int i = 1; i <= n; i++) fa[i] = tg[i] = sz[i] = ch[i][0] = ch[i][1] = 0;   }   int ins(int l, int r) {     if (l > r) return 0;     int mid = l + r >> 1;     col[mid] = a[mid] -  0 ;     ch[mid][0] = ins(l, mid - 1);     fa[ch[mid][0]] = mid;     ch[mid][1] = ins(mid + 1, r);     fa[ch[mid][1]] = mid;     sz[mid] = sz[ch[mid][0]] + sz[ch[mid][1]] + 1;     return mid;   }   int main() {     scanf( %d , &T);     while (T--) {       ct = rev = 0;       clr();       char c;       int aaa = 1;       scanf( %d%s%s , &n, a + 1, b + 1);       rt = ins(1, n);       for (int i = n; i; i--)         if ((c = sc(i)) != b[i]) {           if (sc(1) != c) ans[++ct] = 1, work(1);           ans[++ct] = i;           work(i);         }       sc(1);       printf( %d , ct);       for (int i = 1; i <= ct; i++) printf(  %d , ans[i]);       puts(  );     }   }
#include <bits/stdc++.h>   using namespace std;   constexpr int N = 2e5 + 10;   int x, y;   string cc;   vector<string> s[10][10];   bool can(int a, int b) {     for (auto i : s[a][b]) {       for (auto j : i)         if (j ==  . ) return true;     }     return false;   }   void color(int a, int b) {     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         if (s[a][b][i][j] ==  . ) s[a][b][i][j] =  ! ;       }     }   }   void call() {     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         for (int k = 0; k < 3; k++) {           for (int l = 0; l < 3; l++) {             if (s[i][j][k][l] ==  . ) s[i][j][k][l] =  ! ;           }         }       }     }   }   void print() {     for (int k = 0; k < 3; k++) {       for (int i = 0; i < 3; i++) {         for (int j = 0; j < 3; j++) {           cout << s[k][j][i] <<    ;         }         cout <<   n ;       }       cout <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     for (int i = 0; i < 9; i++) {       for (int j = 0; j < 3; j++) {         cin >> cc;         s[i / 3][j].push_back(cc);       }     }     cin >> x >> y;     x--;     y--;     x %= 3;     y %= 3;     if (can(x, y)) {       color(x, y);       print();     } else {       call();       print();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void ifree() { freopen( in ,  r , stdin); }   void ofree() { freopen( out ,  w , stdout); }   double min(double a, double b) { return a < b ? a : b; }   int main() {     int n, w;     while (cin >> n >> w) {       int arr[2 * n];       for (int i = 0; i < 2 * n; i++) cin >> arr[i];       sort(arr, arr + 2 * n);       double ans;       if (2 * arr[0] < arr[n])         ans = 3 * n * arr[0];       else         ans = 3 * n * ((double)arr[n]) / 2;       printf( %lf n , min((double)w, ans));     }   }
#include <bits/stdc++.h>   using namespace std;   long long a[102], b[102];   long long cn[103];   int main() {     long long n, m;     cin >> n >> m;     long long k;     memset(a, -1, sizeof(a));     for (long long i = 1; i <= m; i++)       for (long long j = 1; j <= n; j++) {         cin >> k;         if (k > a[i]) {           a[i] = k;           b[i] = j;         }       }     for (long long i = 1; i <= m; i++) {       cn[b[i]]++;     }     long long mx = 0, win = 1;     for (long long i = 1; i <= n; i++) {       if (cn[i] > mx) {         mx = cn[i];         win = i;       }     }     cout << win << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string input;   int main() {     cin >> input;     int last = -1;     for (char i =  z ; i >=  a ; i--)       for (int j = last + 1; j < input.length(); j++)         if (input[j] == i) {           cout << input[j];           last = j;         }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int l[1 << 12];   int in[1 << 12];   int sm[1 << 12];   void go(int now) {     if (now * 2 > ((1 << n) - 1)) return;     int a = now * 2;     int b = now * 2 + 1;     go(a);     go(b);     int al = l[a] + in[a];     int bl = l[b] + in[b];     l[now] = max(al, bl);     sm[now] = sm[a] + sm[b] + abs(al - bl);   };   int main() {     cin >> n;     n++;     for (int i = 2; i <= (1 << n) - 1; i++) {       cin >> in[i];     }     go(1);     cout << sm[1] << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, t, sum;     cin >> s >> t;     string n = to_string(stoi(s) + stoi(t));     s.erase(remove(s.begin(), s.end(),  0 ), s.end());     t.erase(remove(t.begin(), t.end(),  0 ), t.end());     n.erase(remove(n.begin(), n.end(),  0 ), n.end());     if (stoi(s) + stoi(t) == stoi(n))       cout <<  YES  << endl;     else       cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6;   const long long oo = 1e18;   long long a[N], w[N], k, n, t, l[N], r[N], res;   string s;   vector<long long> b;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       t += a[i];     }     cin >> k;     for (int i = 1; i <= k; ++i) cin >> l[i] >> r[i];     sort(l + 1, l + 1 + k);     sort(r + 1, r + 1 + k);     int i = 0;     for (i = k; i >= 1; --i) {       if (l[i] <= t && t <= r[i])         res = t;       else if (r[i] < t)         break;     }     if (res == 0 && i != k && k != 0)       res = l[i + 1];     else if (res == 0)       res = -1;     if (res == 0) res = -1;     cout << res <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   void test() {     string s;     cin >> s;     const int len = s.size();     stack<char> a;     for (int i = 0; i < len; ++i) {       if (a.empty()) {         a.push(s[i]);       } else if (s[i] ==  B ) {         a.pop();       } else {         a.push(s[i]);       }     }     cout << a.size() <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       test();     }     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define ll long long int     #define vi vector<int>    #define vll vector<ll>   /*int gcd(int a,int b){       if(b==0)           return a;       else           return gcd(b,a%b);   }   */   void solve(){       int n;       cin>>n;       int a[n];       for(int i=0;i<n;i++){           cin>>a[i];       }       int cnt=0;       for(int i=0;i<n;i++){           if(a[i]!=i+1)               cnt=1;       }       if(a[0]==n && a[n-1]==1){           cout<< 3 <<endl;           return;       }       if(cnt==0){           cout<< 0 <<endl;       }       else if(a[0]==1 || a[n-1]==n){           cout<< 1 <<endl;           return;       }       else           cout<< 2 <<endl;                   }   int main(){       cin.tie(NULL);       #ifndef ONLINE_JUDGE       freopen( input.txt ,  r , stdin);       freopen( output.txt ,  w , stdout);       #endif           int n;       cin>>n;       while(n--){           solve();       }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x[100002] = {0}, j, t;     cin >> n;     t = n;     for (int i = 0; i < n; i++) {       cin >> j;       x[j] = 1;       while (t >= 1 && x[t] == 1) {         cout << t <<    ;         t--;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e3 + 5;   long long n, m, c, cur, loc;   long long a[N];   void work() {     long long lim = c / 2 + c % 2;     if (cur > lim) {       for (long long i = n; i >= 1; i--) {         if (cur > a[i] || !a[i]) {           loc = i;           return;         }       }       loc = 1;       return;     } else {       for (long long i = 1; i <= n; i++) {         if (cur < a[i] || !a[i]) {           loc = i;           return;         }       }       loc = n;       return;     }   }   bool check() {     for (long long i = 1; i <= n; i++) {       if (!a[i]) return 0;     }     for (long long i = 2; i <= n; i++) {       if (a[i] < a[i - 1]) return 0;     }     return 1;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> m >> c;     for (long long i = 1; i <= m; i++) {       cin >> cur;       work();       a[loc] = cur;       cout << loc << endl;       if (check()) {         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   static const double EPS = 1e-13;   int ROUND(double x) { return (int)(x + 0.5); }   bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }   bool ISEQUAL(double x, double y) {     return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y)));   }   double SQSUM(double x, double y) { return x * x + y * y; }   template <class T>   bool INRANGE(T x, T a, T b) {     return a <= x && x <= b;   }   int main() {     long long n, l, t;     scanf( %lld %lld %lld n , &n, &l, &t);     vector<long long> a(n);     for (int i = 0; i < n; i++) {       scanf( %lld  n , &a[i]);     }     long long count = 0;     long long base = 2 * t / l;     long long boundary = (2 * t) % l;     {       int x = 1;       for (int y = 0; y < n - 1; y++) {         x = max(x, y + 1);         while (x < n) {           if (a[x] - a[y] > boundary) {             break;           }           x++;         }         count += (x - (y + 1));       }     }     {       int x = 1;       for (int y = 0; y < n - 1; y++) {         x = max(x, y + 1);         while (x < n) {           if (l - (a[x] - a[y]) <= boundary) {             break;           }           x++;         }         count += (n - x);       }     }     double ans = 0.0;     double masu = n * (n - 1) * 0.5;     ans += (double)base * masu * 2;     ans += 1.0 * count;     ans /= 4;     printf( %.16f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[5];   int kiemtra(int x, int y, int z) {     if (x < y + z && y < z + x && z < x + y) return 1;     if (x == y + z || y == x + z || z == x + y) return 2;     return 0;   }   void solve() {     int i, j, k, x, gan;     gan = 0;     for (i = 0; i < 4; i++)       for (j = 0; j < 4; j++)         for (k = 0; k < 4; k++)           if (i != j && j != k && i != k) {             x = kiemtra(a[i], a[j], a[k]);             if (x == 1) {               cout <<  TRIANGLE n ;               return;             }             if (x == 2) gan = 1;           }     if (gan == 1) {       cout <<  SEGMENT n ;       return;     }     cout <<  IMPOSSIBLE n ;   }   void input() {     int i;     while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {       solve();     }   }   int main() {     input();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int MAX(long long int a, long long int b) {     if (a > b) {       return a;     } else {       return b;     }   }   int MIN(long long int a, long long int b) {     if (a < b) {       return a;     } else {       return b;     }   }   int gcd(long long int a, long long int b) {     long long int c;     while (a != 0) {       c = a;       a = b % a;       b = c;     }     return b;   }   int main() {     int n;     cin >> n;     cout << (6 * n * (n - 1)) + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int node_max = 3000;   struct network {     struct node {       int v, c, w, b;       node(int _v = 0, int _c = 0, int _w = 0, int _b = 0)           : v(_v), c(_c), w(_w), b(_b) {}     };     int n, pre[node_max];     vector<node> nd[node_max];     void clear() {       for (int i = 0; i < n; ++i) nd[i].clear();       n = 0;     }     void insert(int u, int v, int c, int w, bool d = false) {       n = max(n, max(u, v) + 1);       nd[u].push_back(node(v, c, w, nd[v].size()));       nd[v].push_back(node(u, 0, -w, nd[u].size() - 1));       if (d) {         nd[v].push_back(node(u, c, w, nd[u].size()));         nd[u].push_back(node(v, 0, -w, nd[v].size() - 1));       }     }     pair<int, int> get_max_flow_min_cost(int src, int dst) {       pair<int, int> res;       int flow;       while ((flow = get_min_path(src, dst)) != 0) {         res.first += flow;         for (int i = dst; i != src; i = nd[i][pre[i]].v) {           res.second += nd[nd[i][pre[i]].v][nd[i][pre[i]].b].w * flow;           nd[nd[i][pre[i]].v][nd[i][pre[i]].b].c -= flow;           nd[i][pre[i]].c += flow;         }       }       return res;     }     int get_min_path(int src, int dst) {       int dis[node_max], bfs[node_max];       bool visited[node_max] = {};       fill(dis, dis + n, INT_MAX);       visited[src] = true;       dis[src] = 0;       bfs[0] = src;       for (int s = 0, t = 1; s != t; visited[bfs[s]] = 0, s = (s + 1) % n) {         int v = bfs[s];         for (vector<node>::iterator i = nd[v].begin(); i != nd[v].end(); ++i) {           if (i->c <= 0 || dis[v] + i->w >= dis[i->v]) continue;           dis[i->v] = dis[v] + i->w;           pre[i->v] = i->b;           if (!visited[i->v]) {             visited[i->v] = true;             bfs[t] = i->v;             t = (t + 1) % n;           }         }       }       if (dis[dst] == INT_MAX) return 0;       int res = INT_MAX;       for (int i = dst; i != src; i = nd[i][pre[i]].v)         res = min(res, nd[nd[i][pre[i]].v][nd[i][pre[i]].b].c);       return res;     }   };   int n, m, s[1024], t[1024], c[1024], ans[1024];   network g;   bool solve() {     if (scanf( %d%d , &n, &m) == EOF) return false;     for (int i = 0; i < n; ++i) scanf( %d%d%d , &s[i], &t[i], &c[i]);     g.clear();     int S = n * 2, T = n * 2 + 2;     g.insert(S, S + 1, m, 0);     for (int i = 0; i < n; ++i) {       g.insert(S + 1, i, 1, 0);       g.insert(i + n, T, 1, 0);       g.insert(i, i + n, 1, -c[i]);       for (int j = 0; j < n; ++j) {         if (i != j && s[i] + t[i] <= s[j]) {           g.insert(i + n, j, 1, 0);         }       }     }     g.get_max_flow_min_cost(S, T);     for (int i = 0; i < n; ++i) {       ans[i] = 0;       for (vector<network::node>::iterator j = g.nd[i].begin();            j != g.nd[i].end(); ++j) {         if (j->v == i + n && j->c == 0) {           ans[i] = 1;         }       }       printf(i == n - 1 ?  %d n  :  %d  , ans[i]);     }     return true;   }   int main() {     while (solve())       ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int a, b;       cin >> a >> b;       int c = 2 * min(a, b);       int d = max(a, b);       if (c > max(a, b)) {         cout << c * c << endl;       } else {         cout << d * d << endl;       }     }     return 0;   }