akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<SegmentTree<int>> seg(26, SegmentTree<int>(n, [](int a, int b){return a + b;}, 0));
    for(int i = 0; i < n; ++i){
        int id = s[i] - 'a';
        seg[id].update(i, 1);
    }
    for(int i = 0; i < q; ++i){
        int query;
        cin >> query;
        if(query == 1){
            int id;
            char c;
            cin >> id >> c;
            --id;
            if(s[id] == c)  continue;

            int pre = s[id] - 'a';
            seg[pre].update(id, 0);
            int foo = c - 'a';
            seg[foo].update(id, 1);
            s[id] = c;
        }
        else{
            int left, right;
            cin >> left >> right;
            --left;
            int res = 0;
            for(int j = 0; j < 26; ++j){
                res += (seg[j].query(left, right) > 0);
            }
            cout << res << "\n";
        }
    }
}

Measured memory_bytes: 111516
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int h, w, n, a[10000];
    cin >> h >> w >> n;
    for(int i=0; i<n; i++) cin >> a[i];

    int ans[100][100] = {}, tmp = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(a[tmp]){
                ans[i][j] = tmp + 1;
                a[tmp]--;
            }
            if(!a[tmp]) tmp++;
        }
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << (i%2 ? ans[i][w-j-1] : ans[i][j]) << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 384
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const S = readln.chomp;
    2.iota.map!(j => 
        S.length.iota
        .map!(i => to!string((i+j) % 2))
        .join
        .zip(S)
        .filter!(t => t[0] != t[1])
        .walkLength)
    .reduce!min
    .writeln;
}



Measured memory_bytes: 3608
#include<iostream>
#include<vector>
using namespace std;

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> point(n,k);
    for(int i=0;i<q;i++){
        int a;
        cin >> a;
        a--;
        point.at(a)++;
    }
    for(int i=0;i<n;i++){
        if(point.at(i)-q>0){
            cout << "Yes";
        }else{
            cout << "No";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
	while(ch>'9' || ch<'0'){
        if(ch=='-') f=-1;
	    ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}

int n,a[20000010];

int small(int i,int j,int k) {
	return a[i]<=k && a[j]<=k;
}

int big(int i,int j,int k){
	return a[i]>k && a[j]>k;
} 

int check(int k){
	for(int i=0;i<n-1;i++){
		if(big(n+i,n+i+1,k) || big(n-i,n-i-1,k)) return 0;
		if(small(n+i,n+i+1,k) || small(n-i,n-i-1,k)) return 1;
	}
	return small(1,1,k);
}

int main(){
	n=read();
	for(int i=1;i<=2*n-1;i++){
		a[i]=read();
	}
	int l=1,r=2*n-1,ans;
	while(l<r){
		int mid=l+r>>1;
		if(check(mid)) {
			r=mid;
		}
		else l=mid+1;
	}
	cout<<r;
	return 0; 
}


Measured memory_bytes: 1024
def is_ok(arg):
    cnt = 0 
    for i in range(N):
        cnt += -(-A[i]//arg) - 1
    return K < cnt

def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

N,K = map(int, input().split())
A = list(map(int, input().split()))
print(meguru_bisect(max(A)+1, 0)+1)



Measured memory_bytes: 93748
#include<bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL; 
typedef long double dd; 
#define endl "\n"
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};
LL dp[2000001];
LL mod=1e9+7;
bool vis[100000],ok=1;
using namespace std;
bool isPrime(LL n) {
  LL j; 
  for( j=2;j<=sqrt(n);j++){
    if(n%j==0){
      break;  
    } 
  }
  if(j>sqrt(n)){
    return 1; 
  }
  else{
    return 0; }
}
LL modexpo(LL a, LL b) {
  LL ans=1;
  a=a%mod;
  while(b>0){
    if((b&1)==1){
      ans=((ans%mod)*(a%mod))%mod;
    }
    b=b>>1;
    a=((a%mod)*(a%mod))%mod;
  }
  return ans; 
}
LL invmod(LL n){
  return modexpo(n,mod-2);
}
LL comb(LL n,LL r){
  if(r==0){
    return 1;
  }
  LL fact[n+1];
  fact[0] = 1; 
    for (LL i = 1; i <= n; i++){
       fact[i] = (fact[i - 1] * i) %mod;}
    return (fact[n] * invmod(fact[r]) % mod * invmod(fact[n - r]) % mod) %mod; 
}
LL gcd(LL a, LL b) {
  if (a == 0){
       return b;
       }  
    return gcd(b % a, a);  
}
LL lcm(LL a, LL b) {
  return (a*b)/gcd(a,b);
}
void solve(LL k){
  LL n; cin>>n; 
  LL a[n],b[n];
  for(LL i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  for(LL i=0;i<n-2;i++){
    if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
      cout<<"Yes"<<endl; 
      return;
    }
  }
  cout<<"No"<<endl; 
}
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
 LL t=1;
//cin>>t;
 LL k=1;
while(k<=t){
  if(ok==0){
    break; 
  }
   solve(k);
  k++;
  }
   return 0;
   }

Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;


vector<int> nx={-1,1 ,0 ,0};
vector<int> ny={0 ,0 ,-1,1};
int h,w;

int mawari(vector<vector<int> > &m,int i, int j, int &n0, int &n1){
  if(m[i][j]==2) return 0;
  if(m[i][j]==0) n0++;
  else if (m[i][j]==1) n1++;
  int mij=m[i][j];
  m[i][j]=2;
  
  for(int l=0;l<4;l++){
    if(0<=i+nx[l] && i+nx[l]<h && 0<=j+ny[l] && j+ny[l]<w){
      if(mij!=m[i+nx[l]][j+ny[l]]) mawari(m,i+nx[l], j+ny[l],n0,n1);
    }
  }

  return 0;
}
  

int main(){
  cin >> h >> w;

  vector<vector<int> > m(h,vector<int>(w,0));
  
  string s;
  for(int i=0;i<h;i++){
    cin >> s;
    for(int j=0;j<w;j++){
      m[i][j]=(s[j]=='#');
      //cout << m[i][j];
    }
    //cout << endl;
  }

  ll ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(m[i][j]==1){
	int n0=0,n1=0;
	mawari(m,i,j,n0,n1);
	//cout << n0 << " " << n1 << endl;
	/*
	for(int ti=0;ti<h;ti++){
	  for(int tj=0;tj<w;tj++){
	    cout << m[ti][tj];
	  }
	  cout << endl;
	}
	*/

	ans+=(ll)n0*(ll)n1;
      }
    }
  }

  cout << ans << endl;

  return 0;
    
}


Measured memory_bytes: 13440
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int dp[60][60];
char mp[60][60];
int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0;i < h;i++)
		for (int j = 0;j < w;j++)cin >> mp[i][j];

	dp[0][0] = 0;
	for (int i = 1;i < h;i++) dp[i][0] = dp[i-1][0]+(mp[i][0] - '0');

	for (int i = 1;i < w;i++)dp[0][i] = dp[0][i-1]+(mp[0][i] - '0');

	for (int i = 1;i < h;i++) {
		for (int j = 1;j < w;j++) {
			dp[i][j] = min(dp[i][j - 1] + (mp[i][j] - '0'), dp[i - 1][j] + (mp[i][j] - '0'));
		}
	}
	cout << dp[h-1][w-1] << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

const ll MOD = 1000000007LL;
const int MAX_N = 200005;

int n;
ll a[MAX_N];

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n;
	ll suffSum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		suffSum += a[i];
		while (suffSum >= MOD)
			suffSum -= MOD;
	}

	ll result = 0;
	for (int i = 0; i < n; i++)
	{
		suffSum -= a[i];
		while (suffSum < 0)
			suffSum += MOD;
		result += (a[i] * suffSum) % MOD;
		while (result >= MOD)
			result -= MOD;
	}
	cout << result << '\n';

	return 0;
}

Measured memory_bytes: 5160
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { rep(i,v.size())os<<v[i]<<(i==v.size()-1?"\n":" "); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vvi dist(n,vi(n)),ex(n,vi(n,1));
    rep(i,n) rep(j,n) dist[i][j] = min({i,j,n-1-i,n-1-j});
    ll ans = 0;
    rep(_,n*n) {
        int p;
        cin >> p;
        p--;
        int i = p/n,j = p%n;
        ans += dist[i][j];
        queue<P> q;
        q.emplace(i,j);
        ex[i][j] = 0;
        while(!q.empty()) {
            auto [x,y] = q.front();
            q.pop();
            rep(k,4) {
                int nx = x+dx[k],ny = y+dy[k];
                if(nx < 0 || nx >= n || ny < 0 || ny >= n) continue;
                if(ex[x][y]) {
                    if(chmin(dist[nx][ny],dist[x][y]+1)) q.emplace(nx,ny);
                } else {
                    if(chmin(dist[nx][ny],dist[x][y])) q.emplace(nx,ny);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5628
#include <iostream>
using namespace std;
const int N = 55;
int q[N];
int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i ++) cin >> q[i];
  int sum = 0;
  for(int i = 0; i < n; i ++){
    for (int j = i+1; j < n; j ++){
      sum += q[i]*q[j];
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<int> monster(n);
    rep(i, n) cin >> monster[i];

    int at_monster = min_element(all(monster)) - monster.begin();
    int die_monster = 0;
    while(die_monster < n-1){
        die_monster = 0;
        at_monster = min_element(all(monster)) - monster.begin();

        rep(i, n){
            if(i != at_monster && monster[i] != INF) monster[i] %= monster[at_monster];
            if(monster[i] == 0 || monster[i] == INF){
                monster[i] = INF;
                die_monster ++;
                continue;
            }
        }

    }

    cout << monster[at_monster] << endl;
}

Measured memory_bytes: 640
N = int(input())

lst = []
for _ in range(N):
    tmp = list(input())
    tmp.sort()
    lst.append(tmp)
lst.sort()
tmp = lst[0]
count = 1
ans = 0
for i in range(1, N):
    if tmp == lst[i]:
        count += 1
    else:
        ans = ans + (count * (count - 1))//2
        count = 1
        tmp = lst[i]
ans = ans + (count * (count - 1))//2
print (ans)

Measured memory_bytes: 99160
#!/bin/perl

use strict;

my $st = <STDIN>;
chomp $st;
my ($a, $b) = split(/\s+/, $st);

my $ports = $a;
my $tap = 1;
if ( $b == 1 ) {
	print "0\n";
	exit 0;
}

for ($tap=1; $tap<=100; $tap++ ) {
	$ports = ($tap*$a) - ($tap-1);
	print STDERR "$tap: $ports\n";
	if ( $b <= $ports ) {
		last;
	}
}
print "$tap\n";


Measured memory_bytes: 512
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    cout << c << endl;
  }
  if(b==c){
    cout << a << endl;
  }  
  if(a==c){
    cout << b << endl;
  }
  return 0;
}






Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in a,b,n;
    cin>>a>>b>>n;
    in t=min(b-(in)1,n);
    cout<<(a*t)/b<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3592
#include <iostream>
#include <bitset>
using namespace std;

int main() {
    
    int H, W;
    cin >> H >> W;

    char table[H][W];

    for (int i = 0; i < H; i++) {
        string line;
        cin >> line;
        for (int j = 0; j < line.size(); j++) {
            table[i][j] = line.at(j);
        }

    }

    for (int i = 0; i < H; i++) {

        for (int j = 0; j < W; j++) {

            int cnt = 0;
            if (table[i][j] == '.'){
                //cout << "HIT" << endl;;

                 // 爆弾カウントここから
                
                for (int hi = -1; hi <= 1; hi++) {
                    for (int wj = -1; wj <= 1; wj++) {

                        int target_i = i + hi;
                        int target_j = j + wj;

                        if (target_i < 0 || target_i >= H){
                            continue;
                        }
                        if (target_j < 0 || target_j >= W){
                            continue;
                        }

                        if (table[target_i][target_j] == '#' ){
                            cnt++;
                        }
                    }
                }

                //  爆弾カウントここまで
                table[i][j] = char(cnt + '0');

            }
        }
    }

    for (int i = 0; i < H; i++) {

        for (int j = 0; j < W; j++) {

            cout << table[i][j];
        }
        cout << endl;

    }
}




Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(void){
  int N, X;
  cin >> N >> X;
  int x[N];
  rep(i, N)
    cin >> x[i];
  //ここまで入力

  //Xからn回のD移動でx[i]に移動する時とき
  //X+nD=x[i], X-nD=x[i]
  //nD=abs(x[i]-X)
  //このようなDの最大を求めるために，nを決定する

  //abs(x[i]-X)を順に計算する
  int array[N];
  rep(i, N)
    array[i] = abs(x[i] - X);

  //全てのGCDをとれば上記のnが決定する
  int is_gcd;
  is_gcd = array[0];
  rep(i, N)
    is_gcd = __gcd(is_gcd, array[i] );

  cout << is_gcd << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>

using namespace std;

string alphabet = "abcdefghijklmnopqrstuvwxyz";

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	string s;
	
	cin>>s;
	
	if (s.size() == 26)
	{
		string s2;
		s2.push_back(s.back());
		s.pop_back();
		while (!s.empty() && s.back() > s2.back())
		{
			s2.push_back(s.back());
			s.pop_back();
		}
		if (s.empty())
		{
			cout<<"-1\n";
		}
		else
		{
			s.back() = *upper_bound(s2.begin(), s2.end(), s.back());
			cout<<s<<'\n';
		}
	}
	else
	{
		for (char c: alphabet) if (s.find(c) == string::npos)
		{
			s.push_back(c);
			break;
		}
		cout<<s<<'\n';
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

int main(){
    string s;
    cin >> s;
    if(s[1] == 'B')cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3532
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <string>
#include <algorithm>
#include <limits.h>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
  
int main() 
{
    int n;
    int ans = 0, q, a;
    cin >> n;
    vector<int> vc(n);
  
    for (int i = 0; i < n; i++)
        cin >> vc[i];
  
    cin >> q;
      
    sort(vc.begin(), vc.end());
      
    while (q--)
    {
        cin >> a;
        if (binary_search(vc.begin(), vc.end(), a)) 
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3140
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

alias T = Tuple!(long, long);

void main() {
  int n;
  readf (" %d", &n);
  auto a = new int[n];
  foreach (t; 0 .. n) {
    readf (" %d", &a[t]);
  }
  a.sort ();
  auto b = a.map!(to!long).array;
  T[] r;
  foreach (i; 1 .. n - 1) {
    if (b[i] > 0) {
      r ~= tuple (b[0], b[i]);
      b[0] -= b[i];
    } else {
      r ~= tuple (b[n-1], b[i]);
      b[n-1] -= b[i];
    }
  }
  r ~= tuple (b[n-1], b[0]);
  writeln (b[n-1] - b[0]);
  foreach (p; r) {
    writeln (p[0], ' ', p[1]);
  }
}


Measured memory_bytes: 5884
from math import atan, degrees

a, b, x = map(int, input().split())

if x < a * a * b / 2:
  ans = 90 - degrees(atan(x * 2 / (b * a) / b))
else:
  ans = degrees(atan((a * a * b - x) * 2 / (a**2) / a))
  
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define alpha_size 26

const int N = 1e5 + 5;

string s;
int east = 0;
int west = 0;
int north = 0;
int south = 0;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    
     
    cin >> s;
    for (auto it : s){
      if (it == 'N') north++;
      if (it == 'E') east++;
      if (it == 'W') west++;
      if (it == 'S') south++;
    }
    if (north && south == 0){
      cout << "No" << endl;
      return 0;
    }
    if (south && north == 0){
      cout << "No" << endl;
      return 0;
    }
    if (east && west == 0){
      cout << "No" << endl;
      return 0;
    }
    if (west && east == 0){
      cout << "No" << endl;
      return 0;
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;

bool comp(const int& a, const int& b) {
	return a > b;
}

int main()
{
	ll N, M, SUM = 0,A=0;
	vector<ll> vec;
	cin >> N >> M;

	fore(i, 0, N) {
		ll t;
		cin >> t;
		SUM = SUM + t;
		vec.push_back(t);
	}
	fore(i, 0, vec.size()) {
		if (vec[i] * 4 * M >= SUM)A++;
	}
	if (A >= M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>

bool prime(int number) {
    int sq = sqrt(number);
    if (number % 2 == 0) {
        return false;
    }
    for (int i = 3; i <= sq; i += 2) {
        if (number % i == 0) {
            return false;
        }
    }
    return true;
}

int main(void) {
    int n;
    std::vector<int> count(246913, 0);
    count[2] = 1;
    for (int i = 3; i <= 246912; i++) {
        count[i] = count[i - 1];
        if (prime(i) == true) {
            count[i]++;    
        }
    }

    while (std::cin >> n) {
        if (n == 0) {
            break;
        }
        std::cout << count[2 * n] - count[n] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3640
C=[]
for i in range(1,100):
    if 6**i<=10**5:
        C.append(6**i)
for i in range(1,100):
    if 9**i<=10**5:
        C.append(9**i)
        
N=int(input())
dp=[i for i in range(N+1)]
for c in C:
    for i in range(N+1):
        if i-c>=0:
            dp[i]=min(dp[i],dp[i-c]+1)
print(dp[N])


Measured memory_bytes: 44912
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
typedef pair<int, int> P;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    P p1[110], p2[110];
    rep(i, N) cin >> p1[i].first >> p1[i].second;
    rep(i, N) cin >> p2[i].second >> p2[i].first;
    //rep(i, N) p2[i].second = -p2[i].second;
    sort(p1, p1 + N); sort(p2, p2 + N);
    int ans = 0;
    bool used[110] = {};
    RREP(i, N - 1, 0) {
        rep(j, N) {
            if(used[j]) continue;
            if(p1[i].first < p2[j].second && p1[i].second < p2[j].first) {
                used[j] = true;
                ans++;
                //cerr << "*" << i << " " << j << endl;
                break;
            }
        }
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    int flag=0;
    cin>>n;
    for(int i=0;i<=n;i+=4)
    {
        for(int j=0;j<=n-i;j+=7)
        {
            if(i+j==n)
            {
                flag=1;
            }
        }
    }
    if(flag==0)
    {
        cout<<"No"<<endl;
    }else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
	CIN(h,w);
	vector<V> a(h, V(w,0));
	REP(i,h)
		VECCIN(a[i]);
	vector<V> out;
	REP(i,h){
		bool flag = false;
		REP(j,w-1){
			flag ^= a[i][j] & 1;
			if(flag)
				out.emplace_back(V({i + 1, j + 1, i + 1, j + 2}));
		}
		a[i][w-1]+=flag;
	}
	bool flag = false;
	REP(i,h-1){
		flag ^= a[i][w-1] & 1;
		if(flag)
			out.emplace_back(V({i + 1, w, i + 2, w}));
	}
	COUT(out.size());
	FOREACH(xx,out)VECCOUT(xx);
	ENDL;

}


Measured memory_bytes: 12848
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int h, int w) {

    long _calc(long h, long w) {
        long ans = long.max;

        for (int i = 1; i < w; i++) {
            long a = h * i;

            // h を分割
            long h1 = h / 2;
            long h2 = h - h1;
            long b = h1 * (w - i);
            long c = h2 * (w - i);
            ans = min(ans, max(a, b, c) - min(a, b, c));
        }

        for (int i = 1; i < w - 1; i++) {
            long a = h * i;

            // w を分割
            long w1 = (w - i) / 2;
            long w2 = (w - i) - w1;
            long b = h * w1;
            long c = h * w2;
            ans = min(ans, max(a, b, c) - min(a, b, c));
        }
        return ans;
    }

    return min(_calc(h, w), _calc(w, h));
}

void main() {
    auto hw = readints;
    int h = hw[0], w = hw[1];
    writeln(calc(h, w));
}


Measured memory_bytes: 256
#include<iostream>
#define ll long long
using namespace std;

ll a[200050],ans[200050];
void solve(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		if(i%2==1)ans[1]+=a[i];
		else ans[1]-=a[i];
	}
	for(int i=2;i<=n;i++){
		ans[i]=-ans[i-1]+2*a[i-1];
	}
	for(int i=1;i<=n;i++){
		printf("%lld ",ans[i]);
	}
}

signed main(){
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5404
#include <bits/stdc++.h>
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pair<int,int>> piii;

const int N= 1e5+5, L = 14, OO = 0x3f3f3f3f;
const ll M=10 ;
const double ESP = 1e-8;

int n, k;
piii A[N];
int dp[N][5];
int solve(int idx, int prev){
    if(idx == n)
        return 0;

    int& ret = dp[idx][prev];
    if(~ret)
        return ret;

    ret = max(ret, (prev != 1)? solve(idx+1, 1)+A[idx].F : -1);
    ret = max(ret, (prev != 2)? solve(idx+1, 2)+A[idx].T : -1);
    return ret = max(ret, (prev != 3)? solve(idx+1, 3)+A[idx].C : -1);

}

int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    cin>>n;
    for(int i=0; i<n; i++)cin>>A[i].F>>A[i].T>>A[i].C;
    memset(dp, -1, sizeof dp);
    cout<<solve(0,4);
}


Measured memory_bytes: 11264
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String r = br.readLine();
            int in = Integer.parseInt(r);
            int h = Math.floorDiv(in, 3600);
            int m = Math.floorDiv(Math.floorMod(in, 3600), 60);
            int s = Math.floorMod(Math.floorMod(in, 3600), 60);
            System.out.println(h + ":" + m + ":" + s);
        } catch (IOException e) {
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24316
#include<iostream>
using namespace std;

int main(){
  int H,W,h,w,s,srow,scolumn,scap;
  cin >> H >> W >> h >> w;
  s=H*W;
  srow=h*W;
  scolumn=H*w;
  scap=h*w;
  cout << s-(srow + scolumn - scap) << endl;  
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;

int main(){
	bool a[4000001];
	for (int i = 0; i < 4000001; i++)a[i] = false;
	vector<int> b;
	int c[2001];
	int n, k;
	int x, y, z;
	int s, ans;
	int m;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	s = 0;
	for (int i = 0; i < n; i++){
		scanf("%d", &x);
		s += x;
      b.push_back(x);
	}
	s = (s+1) / 2;
	a[0] = true;
	m = 0;
	k = 0;
	sort(b.begin(), b.end());
	for (int i = n - 1; i >= 0; i--){
		k += b[i];
		c[i] = k;
	}
	for (int i = 0; i < n; i++){
		for (int j = min(m,s); j >=max(s-c[i],0); j--){
			if (a[j]){
				a[j] = true;
				a[j + b[i]] = true;
				if (m < j + b[i])m = j + b[i];
			}
		}
	}
	for (int i = s; i <= 2*s; i++){
		if (a[i]){
			printf("%d\n", i);
			return 0;
		}
	}


	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< pair< int, int > > A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i].first;
    A[i].second = i;
  }
  sort(A.rbegin(), A.rend());
  auto dp = make_v< int64 >(N + 1, N + 1);
  fill_v(dp, -infll);
  dp[0][0] = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 0; i + j < N; j++) {
      chmax(dp[i + 1][j], dp[i][j] + 1LL * A[i + j].first * abs(i - A[i + j].second));
      chmax(dp[i][j + 1], dp[i][j] + 1LL * A[i + j].first * abs((N - j - 1) - A[i + j].second));
    }
  }
  int64 ret = 0;
  for(int i = 0; i <= N; i++) chmax(ret, dp[i][N - i]);
  cout << ret << "\n";
}


Measured memory_bytes: 34616
#include<bits/stdc++.h>

#define HAS_TEST_CASE 0

namespace rG{

typedef long long ll;

const int N=5e5;
const ll P=1e9+7;

int n,m,k;
ll a[N+10];
char s[N+10];
ll sum[N+10],ans;

inline void main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",a+i);
	for(int i=1;i<=n;i++)
		sum[i]=(sum[i-1]+a[i])%P;
	for(int i=1;i<=n;i++)
		(ans+=1LL*a[i]*(((sum[n]-sum[i])%P+P)%P)%P)%=P;
	printf("%lld\n",ans);
}

} // namespace rG

int main(){
#if defined(LOCAL)&&HAS_TEST_CASE
	freopen("tmp.out","w",stdout);
#endif
#if HAS_TEST_CASE
	int T;
	scanf("%d",&T);
	while(T--)rG::main();
#else
	rG::main();
#endif
	return 0;
}


Measured memory_bytes: 6952
let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( -^ ) x y = x +^ (m - y)
let ( *^ ) x y = (x * y) mod m
let perm n k =
  Array.fold_left ( *^ ) 1 @@
  Array.init k @@ ( + ) (n - k + 1)

let () =
  let n = read_int () in
  Printf.printf "%d\n" @@
  power ( *^ ) 1 10 n -^ 2 *^ power ( *^ ) 1 9 n +^ power ( *^ ) 1 8 n

Measured memory_bytes: 3644
a = [int(_) for _ in input().split()]
if len(a) == 2 and -1000 <= a[0] <= 1000 and -1000 <= a[1] <= 1000:
    print(max(a[0] + a[1], a[0] - a[1], a[0] * a[1]))
else:
    print('hoge!')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A){
    if(H - accumulate(A.begin(), A.end(), 0LL) <= 0) cout << YES << endl;
    else cout << NO << endl;
    return;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


Measured memory_bytes: 4028
#include<iostream>
using namespace std;

int main(){
	int a,b,c;
	
	cin>>a;
	cin>>b;
	cin>>c;
	
	int minus=a-b;
		int r=minus/c;
	int price=r*c;
	
	int last= minus-price;
	
		cout<<last<<endl;
}



Measured memory_bytes: 888
N = int(input())
a1_list = list(map(int, input().split()))
a2_list = list(map(int, input().split()))

sum_list = []
for i in range(N):
    sum_list.append(sum(a1_list[:i+1]) + sum(a2_list[i:]))
print(max(sum_list))

Measured memory_bytes: 3060
N=int(input())
from collections import defaultdict
branch=defaultdict(set)
for i in range(N-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    branch[a]|={b}
    branch[b]|={a}
C=list(map(int,input().split()))
C.sort()
ans=[0]*N
used={0}
check={0}
M=sum(C[:-1])
while len(check)>0:
    now=check.pop()
    ans[now]=C.pop()
    for nex in branch[now]:
        if nex not in used:
            check|={nex}
            used|={nex}
print(M)
print(" ".join([str(x) for x in ans]))

Measured memory_bytes: 8284
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  string O,E;
  cin>>O>>E;

  string out;
  int cnt_e=0,cnt_o=0;
  for(int i=0;i<O.size()+E.size();i++){
    if(i%2!=0){
      cout<<E.at(cnt_o);
      cnt_o++;
    }
    else{
      cout<<O.at(cnt_e);
      cnt_e++;
    }
  }

    cout<<endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>

#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
/*
int main(){
  ll n,a=1,b=1;
  cin>>n;
  bool p=true;
  while(n>1){
    rep(i,2,1+sqrt(n)){
      while(n%i==0){
        if(p){a*=i;p=false;n/=i;}
        else {b*=i;p=true;n/=i;}
      }
    }
    if(n>1){b*=a;a=n;n=1;}
  }
  cout<<a+b-2;
}*/


int main(){
  ld a,b,x,ans=0;
  cin>>a>>b>>x;
  ld p=(2.0*x/(a*a))-b;
  ld y=b-p;
  if(p>=0)ans=90-atan((ld)a/y)*180/M_PI;
  else{
    p=2.0*x/(a*b);
     ans=90-atan((ld)(p)/b)*180/M_PI;
  }
  cout<<fixed<<setprecision(16)<<ans;

}










Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = []
m1 = n//2
if n%2==0:
  
  for i in range(m1):
    b.append(a[n-1-2*i])
  for i in range(m1):
    b.append(a[2*i])
else:
  
  for i in range(m1+1):
    b.append(a[n-1-2*i])
  for i in range(m1):
    b.append(a[1+2*i])
  
  
  
b=[str(c) for c in b]
b=" ".join(b)
print(b)

Measured memory_bytes: 29764
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
int test[123456], uiop[123456], atai[123456];
using namespace std;
int main() {
	long long n, k, l; cin >> n >> k >> l;
  if(n+k+l<=21){
    cout<<"win"<<endl;
  }
  else{
   cout<<"bust"<<endl; 
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
using namespace std;

void dfs(const vector<vector<pair<int,int>>> &G, int v, int p, int c, vector<int> &E){
  int c_ = 1;
  for(auto e : G[v]){
    int v_, e_idx;
    tie(v_,e_idx) = e;
    if(v_ == p) continue;
    if(c_ == c) ++c_;
    E[e_idx] = c_;
    dfs(G,v_,v,c_,E);
    ++c_;
  }
}

int main(){
  int N;
  cin >> N;
  vector<vector<pair<int,int>>> G(N);
  for(int i = 0; i < N-1; ++i){
    int a, b;
    cin >> a >> b;
    --a,--b;
    G[a].emplace_back(b,i);
    G[b].emplace_back(a,i);
  }
  vector<int> E(N-1,-1);
  dfs(G,0,-1,-1,E);
  int K = *max_element(E.begin(), E.end());
  cout << K << endl;
  for(auto e : E)
    cout << e << endl;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)

typedef pair<int,int> P;
typedef long long ll;

const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll H,W;
    cin >> H >> W;

    ll ans=INF;

    if (H%3==0) {
        ans = 0;
    }
    else  {
        ans = min(ans,W);
    }

    if (W%3==0) {
        ans = 0;
    }
    else {
        ans = min(ans,H);
    }

    ll w,h;

    w = W/3;
    if (H%2==0) {
        ll a,b,c;
        a = w*H;
        b = H/2*(W-w);
        c = b;
        ll a_max = max(a,max(b,c));
        ll a_min = min(a,min(b,c));
        ans = min(ans,a_max-a_min);
    }
    else {
        ll a,b,c;
        a = w*H;
        b = H/2*(W-w);
        c = (H/2+1)*(W-w);
        ll a_max = max(a,max(b,c));
        ll a_min = min(a,min(b,c));
        ans = min(ans,a_max-a_min);
    }

    w = W/3+1;
    if (H%2==0) {
        ll a,b,c;
        a = w*H;
        b = H/2*(W-w);
        c = b;
        ll a_max = max(a,max(b,c));
        ll a_min = min(a,min(b,c));
        ans = min(ans,a_max-a_min);
    }
    else {
        ll a,b,c;
        a = w*H;
        b = H/2*(W-w);
        c = (H/2+1)*(W-w);
        ll a_max = max(a,max(b,c));
        ll a_min = min(a,min(b,c));
        ans = min(ans,a_max-a_min);
    }

    h = H/3;
    if (W%2==0) {
        ll a,b,c;
        a = h*W;
        b = W/2*(H-h);
        c = b;
        ll a_max = max(a,max(b,c));
        ll a_min = min(a,min(b,c));
        ans = min(ans,a_max-a_min);
    }
    else {
        ll a,b,c;
        a = h*W;
        b = W/2*(H-h);
        c = (W/2+1)*(W-w);
        ll a_max = max(a,max(b,c));
        ll a_min = min(a,min(b,c));
        ans = min(ans,a_max-a_min);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    int a[105],b[105];
    long long sum_a=0,sum_b=0;
    rep(i,0,n){
      cin>>a[i];
      sum_a+=a[i];
    }
    rep(i,0,m){
     cin>>b[i];
     sum_b+=b[i];
    }
    bool ok=true;

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(sum_a-a[i]+b[j]==sum_b-b[j]+a[i]&&ok){
	  cout<<a[i]<<" "<<b[j]<<endl;
	  ok=false;
	}
      }
    }
    if(ok)cout<<-1<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)
const int intinf = numeric_limits<int>::max();

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define MOD 1000000007

const int M = 1 << 19;
set<char> seg[2 * M - 1];

void update(int i, char c_inserted) // 0-indexed
{
    int k = i + M - 1;
    char c_erased = *seg[k].begin();
    if (c_erased == c_inserted)
        return;
    seg[k].erase(c_erased);
    seg[k].insert(c_inserted);
    bool is_erase = true, is_insert = true;
    while (k > 0)
    {
        int k_child_prev = k;
        k = (k - 1) / 2;
        int k_child_another = ((k_child_prev == k * 2 + 1) ? k * 2 + 2 : k * 2 + 1);
        set<char> &child_another = seg[k_child_another];
        if (is_erase)
        {
            if (child_another.find(c_erased) == child_another.end())
                seg[k].erase(c_erased);
            else
                is_erase = false;
        }
        if (is_insert)
        {
            if (child_another.find(c_inserted) == child_another.end())
                seg[k].insert(c_inserted);
            else
                is_insert = false;
        }
    }
}

set<char> query(int a, int b, int k, int l, int r)
{
    if (r <= a || b <= l)
        return set<char>();

    if (a <= l && r <= b)
        return seg[k];

    int m = (l + r) / 2;
    set<char> vl = query(a, b, k * 2 + 1, l, m);
    set<char> vr = query(a, b, k * 2 + 2, m, r);
    set<char> result;
    set_union(vl.begin(), vl.end(), vr.begin(), vr.end(), inserter(result, end(result)));
    return result;
}

void solve()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int Q;
    cin >> Q;

    rep(i, N)
    {
        update(i, S[i]);
    }

    rep(i, Q)
    {
        int type;
        cin >> type;
        switch (type)
        {
        case 1:
        {
            int i;
            char c;
            cin >> i >> c;
            i--;
            update(i, c);
            break;
        }
        case 2:
        {
            int l, r;
            cin >> l >> r;
            l--;
            r--;
            int ans = query(l, r + 1, 0, 0, M).size();
            cout << ans << endl;
            break;
        }
        default:
            break;
        }
    }
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 188676
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

class UnionFind {
public:
	vector<int>par, rank;
	UnionFind(int n) :par(n+1), rank(n, 0){
		for (int i = 1;i <= n;i++)par[i] = i;
	}

	int find(int x) {
		return par[x] == x ? x : par[x] = find(par[x]);
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	void unite_tree(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	int root_size(int x){
		return rank[find(x)];
	}
};


int main(void){
    int n,k,l;
    int p,q;
    map<P,int>num;
    cin>>n>>k>>l;
    UnionFind uf(n),uf1(n);
    for(int i=0;i<k;i++){
        cin>>p>>q;
        uf.unite_tree(p,q);
    }
    for(int i=0;i<l;i++){
        cin>>p>>q;
        uf1.unite_tree(p,q);
    }
    for(int i=1;i<=n;i++){
        p=uf.find(i);
        q=uf1.find(i);
        num[P(p,q)]++;
    }
    for(int i=1;i<=n;i++){
        if(i==n){
            p=uf.find(i);
            q=uf1.find(i);
            cout<<num[P(p,q)]<<endl;
        }
        else{
            p=uf.find(i);
            q=uf1.find(i);
            cout<<num[P(p,q)]<<" ";
        }
    }
    return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
    long n,k;
    cin>>n>>k;
    long m=1;
    for(int i=1;i<=n;i++)
    {
        m=min(m*2,m+k);
    }
    cout<<m;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[3010];long long dp[3010];
const int mod=998244353;
int main()
{
	int n,s;
	cin>>n>>s;
	for(int i=1;i<=n;i++) 
		scanf("%d",&a[i]);
    long long ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=s-a[i];j>=0;j--)
			dp[j+a[i]]=(dp[j+a[i]]+dp[j])%mod;
		dp[a[i]]+=i;
		ans=(ans+dp[s])%mod;
	}
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<char> > c(h,vector<char>(w,0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
        }
    }
    vector<vector<char> > ans(2*h,vector<char>(w,0));
    for(int i = 0; i < 2*h; i++){
        for(int j = 0; j < w; j++){
            ans[i][j] = c[i/2][j];
        }
    }
    for(int i = 0; i < 2*h; i++){
        for(int j = 0; j < w; j++){
            cout << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256