akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto &it : A)
    cin >> it;
  ll ans = 0;
  ll cnt = A[0];
  for (int i = 1; i < N; i++)
  {
    if (A[i] == 0)
    {
      ans += cnt / 2;
      cnt = 0;
    }
    else
      cnt += A[i];
  }
  if (cnt > 0)
    ans += cnt / 2;
  cout << ans << endl;
  return 0;
}

// 0があるところが区切りとなる


Measured memory_bytes: 1152
/*input
3 1
ABC

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 998244353;
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
    int x = 1 % mod;
    while(b){
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

const int MAX = 100001;
vector <PII> adj[MAX];
int col[MAX], dis[MAX], vis[MAX];

void dfs(int s) {
  //debug(dis[s]);
  vis[s] = 1;
  if (dis[s] % 2 == 0) col[s] = 1;
  for (auto it : adj[s]) {
    if (!vis[it.first]) {
      dis[it.first] = dis[s] + it.second;
      dfs(it.first);
    }
  }
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  int u, v, w;
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v >> w;
    adj[u].pb({v, w});
    adj[v].pb({u, w});
  }
  dis[1] = 0;
  dfs(1);
  for (int i = 1; i <= n; i++) {
    cout << col[i] << endl;
  }


  return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <string>
     
int main(void){
  std::string s;
  int K;
  std::cin >> s >> K;
     
  for(int i=0; i<s.size(); i++){
    if(s[i] != 'a'){
      int cntManip = ('z'-s[i]+1)%('z'-'a'+1);
      if(cntManip<=K){
	s[i] = 'a';
	K -= cntManip;
      }
    }
  }
     
  K%=('z'-'a'+1);
  s[s.size()-1] += K;
  std::cout << s << std::endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	static int[] a;
	
	static int partition(int a[],int p,int r) {
		int x = a[r];
		int i = p-1;
		for(int j=p;j<r;j++) {
			if(a[j] <= x) {
				i++;
				int temp = a[j];
				a[j] = a[i];
				a[i] = temp;
			}
		}
		int temp = a[r];
		a[r] = a[i+1];
		a[i+1] = temp;
		return i+1;
	}
	
	void main() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		a = new int[n+1];
		for(int i=1;i<=n;i++) {
			a[i] = sc.nextInt();
		}
		int in = partition(a,1,n);
		if(in == 1) {
			System.out.print("[" + a[1] + "]");
		}else {
			System.out.print(a[1]);
		}
		for(int i=2;i<=n;i++) {
			if(i== in) {
				System.out.print(" "+"[" + a[i] + "]");
			}else {
				System.out.print(" " +a[i]);
			}
		}
		System.out.println();
		
	}
	
	public static void main(String[] args) {
		new Main().main();
	}

}





Measured memory_bytes: 70416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

vector<bool> f(int n) {
  vector<bool> res(10);
  while (n > 0) {
    res[n%10] = true;
    n /= 10;
  }
  return res;
}

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

  ll n, k;
  cin >> n >> k;
  vl d(k);
  rep(i, k) {
    cin >> d[i];
  }

  for (;;n++) {
    auto vec = f(n);
    bool f = false;
    rep(i, k) if (vec[d[i]]) f = true;
    if (f) continue;
    cout << n << endl;
    return 0;
  }
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))

good = set(range(n))
for _ in range(m):
    a_, b_ = map(int, input().split())
    a_ -= 1
    b_ -= 1
    if h[a_] == h[b_]:
        if a_ in good:
            good.remove(a_)
        if b_ in good:
            good.remove(b_)
    elif h[a_] < h[b_]:
        if a_ in good:
            good.remove(a_)
    else:
        if b_ in good:
            good.remove(b_)
print(len(good))

Measured memory_bytes: 22464
dic = {
     'SUN':0
    ,'MON':1
    ,'TUE':2
    ,'WED':3
    ,'THU':4
    ,'FRI':5
    ,'SAT':6
}
WEEK_NUM = 7
s = str(input())
dayofweek = dic[s]
print(WEEK_NUM - dayofweek)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
//typedef pair<long long,long long> P;
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  cin>>n;
  int d[n];
  int cnt[13]={};
  cnt[0]=1;
  REP(i,n){
    cin>>d[i];
    cnt[d[i]]++;
  }
  REP(i,13){
    if(i==0 || i==12){
      if(cnt[i]>=2){
        cout<<0<<endl;
        return 0;
      }
    }else{
      if(cnt[i]>=3){
        cout<<0<<endl;
        return 0;
      }
    }
  }
  
  vector<int> temp;
  int current;
  int ans=0;
  for(int i=0;i<(1<<11);i++){
    temp.clear();
    temp.push_back(0);
    if(cnt[12]==1){
      temp.push_back(12);
    }
    for(int j=1;j<=11;j++){
      if(cnt[j]==0){
        continue;
      }else if(cnt[j]==2){
        temp.push_back(j);
        temp.push_back(24-j);
      }else{
        if((i>>(j-1)) & 1){
          temp.push_back(24-j);
        }else{
          temp.push_back(j);
        }
      }
    }
    current = 24;
    REP(l,n+1){
      REP(m,l){
        current = min(current,min(abs(temp[l]-temp[m]),24-abs(temp[l]-temp[m])));
      }
    }
    ans = max(ans,current);
  }
  cout<<ans<<endl;
  return 0; 
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

vector<int> g[1010];
int col[1010];
bool ok;
int cnt=0;

void dfs(int s){
    for(int t:g[s]){
        if(col[t]==-1){
            col[t]=col[s]^1;
            if(col[t])cnt++;
            dfs(t);
        }
        else{
            if(col[t]==col[s]){
                ok=0;
                return;
            }
        }
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    while(cin >> n >> m,n){
        for(int i=0;i<n;i++){
            g[i].clear();
            col[i]=-1;
        }
        for(int i=0;i<m;i++){
            int x,y; cin >> x >> y;
            x--; y--;
            g[x].push_back(y);
            g[y].push_back(x);
        }
        ok=1;
        cnt=0;
        col[0]=0;
        dfs(0);
        if(!ok){
            printf("0\n");
        }
        else{
            vector<int> res;
            if(cnt%2==0){
                res.push_back(cnt/2);
            }
            if((n-cnt)%2==0){
                res.push_back((n-cnt)/2);
            }
            sort(res.begin(), res.end());
            res.erase(unique(res.begin(), res.end()),res.end());
            printf("%d\n",res.size());
            for(int i=0;i<res.size();i++){
                printf("%d\n",res[i]);
            }
        }
    }
}



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

const int INF = 1e9;
using lint = long long;
const lint LINF = 1e18;
#define bit(n) ((lint)1 << n);

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

template <typename T>
T gcd(T m, T n) {
    if (n == 0) {
        return m;
    } else {
        return gcd(n, m % n);
    }
}

template <typename T>
T lcm(T m, T n) {
    return m / gcd(m, n) * n;
}

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

    int n;
    cin >> n;
    vector<int> t(n);
    lint ans = 1;
    for (int i = 0; i < n; i++) {
        lint t;
        cin >> t;
        ans = lcm(ans, t);
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
S[2001*2002];
m[4][2001*2002],H,W,z,d[4]={1,-1},k,i;

f(i){
	return m[k][i]=S[i]==~'.'?m[k][i]?:1+f(i+d[k]):0;
}

main(t){
	scanf("%d%d ",&H,&W);
	for(d[2]-=d[3]=~W;S[i-~W]=~getchar();++i);
	for(;i--;z=fmax(z,t))
		for(t=k=0;k<4;++k)
			t+=f(i-~W,k);
	printf("%d",z-3);
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N, L; cin >> N >> L;
	int ans = 0;
	for (int i = 1; i < N+1; i++)
	{
		ans = ans + L + i-1;
	}
	if (L >= 0) {
		cout << ans - L << endl;
	}
	else if(-L>=N-1) {
		ans = ans - (L + N - 1);
		cout << ans << endl;
	}
	else {
		cout << ans << endl;
	}

}

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

int main() {
  vector<string> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);

  string ans = "ABC";
  int tmp = 0;
  while (true) {
    if (a.at(tmp).size() == 0) {
      cout << ans.at(tmp) << endl;
      return 0;
    }

    char head = a.at(tmp).at(0);
    a.at(tmp).erase(a.at(tmp).begin());
    if (head == 'a') {
      tmp = 0;
    } else if (head == 'b') {
      tmp = 1;
    } else {
      tmp = 2;
    }
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int H=in.nextInt(),R=in.nextInt(),res;
		
		if(H>=0)res=1;
		else if(H<-1*R)res=-1;
		else res=0;
		System.out.println(res);
	}

}



Measured memory_bytes: 26188
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const ll mod = 1e17+7;
const int maxn = 200005;
ll T,n,m;
map<pair<int,int>,int> mp1;
map<pair<int,int>,int> mp2; 
int nt = 0;
ll sum = 0;
int f(ll d,ll t){
	//cout<<d<<" "<<t<<endl; 
	if(t==1)
		return d; 
	sum+=(t/2)*mp1[{d,d}];
	int nn = f(mp2[{d,d}],t/2);
	if(t%2==1){
		sum+=mp1[{d,nn}];
		return mp2[{d,nn}];
	}
	else {
		
		return nn; 
	}
} 
int main() {
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			int sum = 1;
			int t = i+j;
			while((t/10)!=0){
				sum++;
				t = (t/10)+(t%10);
			}
			mp1[{i,j}] = sum;
			mp2[{i,j}] = t;
		}
	}
//	for(int i=0;i<=9;i++){
//		for(int j=0;j<=9;j++){
//			cout<<mp1[{i,j}]<<"  ";
//			cout<<mp2[{i,j}]<<endl;
//		}
//	}
	cin>>n;
	for(int i=1;i<=n;i++){
		ll d,c;
		cin>>d>>c;
		int t = f(d,c);
		//cout<<f(d,c)<<endl;
		if(nt)
			sum+= mp1[{t,nt}];
	//	cout<<mp1[{f(d,c),nt}]<<endl;
		nt = mp2[{t,nt}];
	} 
	cout<<sum<<endl;
    return 0;
}



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


int M, N, K;
string field[1000];
char trg[4] = "JOI";
int cnt[3][1000][1010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> M >> N >> K;
    for(int x = 0; x < M; x++){
        cin >> field[x];
    }
    for(int x = 0; x < M; x++){
        fill(cnt[0][x], cnt[0][x]+N+1, 0);
        fill(cnt[1][x], cnt[1][x]+N+1, 0);
        fill(cnt[2][x], cnt[2][x]+N+1, 0);
    }
    for(int x = 0; x < M; x++){
        for(int y = 1; y <= N; y++){
            for(int i = 0; i < 3; i++){
                cnt[i][x][y] = cnt[i][x][y-1];
                if(field[x][y-1] == trg[i]){
                    ++cnt[i][x][y];
                }
            }
        }
    }
    for(;K--;){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int res[3] = {0};
        for(int x = a-1; x < c; x++){
            for(int i = 0; i < 3; i++){
                res[i] += cnt[i][x][d] - cnt[i][x][b-1];
            }
        }
        cout << res[0] << ' ' << res[1] << ' ' << res[2] << endl;
    }
    return 0;
}

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

using namespace std;
// #define int long long
mt19937 rnd(time(0));
typedef long long ll;
typedef long double ld;

// #define _GLIBCXX_DEBUG
#define f first
#define s second
#define pb push_back
#define pii pair<int, int> 
#define vi vector<int>

void solve(){
	int n;
	cin >> n;
	pii a[n];
	for (int i = 0; i < n; ++i) {
		cin >> a[i].f;
		a[i].s = i;
	}
	sort(a, a + n);
	for (int i = 0; i < n; ++i)
		cout << a[i].s + 1 << ' ';
	cout << endl;
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int t = 1;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 1664
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char s[] = sc.next().toCharArray();
		int c = 0;
		for(int i = 0;i<s.length;i++) {
			if(s[i]=='+'){
				c+=2;
			}
			c--;
		}
		System.out.println(c);
		sc.close();
	}
}

Measured memory_bytes: 21844
import copy
N=int(input())
six = [6**i for i in range(1,8)][::-1]
nine = [9**i for i in range(1,8)] [::-1]
def DP(n):
	if n < 6:
		return n
	tmp = n
	count6 = 0
	count9 = 0
	for sixx in six:
		if sixx <= n:
			n -= sixx
			count6 = 1
			break
	count6 += DP(n)
	n = tmp
	if n < 9:
		return count6
	for ninee in nine:
		if ninee<= n:
			n -= ninee
			count9 = 1
			break
	count9 += DP(n)
	n = tmp
	return min(count6,count9)
print(DP(N))

Measured memory_bytes: 3572
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
 
int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	long long h;
	cin >> h;
	long long it = 1;
	long long ans = 0;
	while(it <= h) ans += it, it += it;
	it /= 2;
	cout << ans << endl;
}                                

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define int ll

typedef pair<int,int> pi;
typedef vector<int> vi;
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
 
template<typename T> void max_self(T &a, T b) { a = max(a,b); return;}
template<typename T> void min_self(T &a, T b) { a = min(a,b); return;}
 
const int nax = 1e5 + 5;
const int mod = 1e9 + 7;

int solve(int a,int b,int c){
	
	a = a % c;	
	if(b == 0) return 1;
	else if((b % 2) == 0) return solve((a * a) % c,b / 2,c) % c;
	else return (a * solve((a * a) % c,b / 2,c) % c) % c;
}

int n;

int dp[105][nax];
int prefix[105][nax];

signed main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int k;
	cin >> n >> k;
	
	int arr[n];
	for(int i = 0; i < n; ++i) cin >> arr[i];
	
	for(int i = 0; i < n; ++i){
		dp[i][0] = 1;
		prefix[i][0] = 1;
	}

	for(int j = 1; j <= k; ++j){	
		if(arr[0] >= j) dp[0][j] = 1; 
		prefix[0][j] = (prefix[0][j - 1] + dp[0][j]) % mod;
	}
	
	for(int i = 1; i < n; ++i){
		for(int candies = 1; candies <= k; ++candies){
			int val = min(arr[i],candies);
			if(val == candies) dp[i][candies] = prefix[i - 1][candies] % mod;
			else dp[i][candies] = (prefix[i - 1][candies] - prefix[i - 1][candies - val - 1] + mod) % mod;;
			prefix[i][candies] = (prefix[i][candies - 1] + dp[i][candies]) % mod;
		}
	}	
	cout << dp[n - 1][k];
	return 0;
}


Measured memory_bytes: 159872
n, m = map(int, raw_input().split(" "))

dp = [0 for i in range(0, n + 1)]
dp[0] = 1

for i in range(0, m):
    a = int(raw_input())
    dp[a] = -1

for step in range(1, n + 1):
    if dp[step] < 0:
        continue

    ans = 0
    for prev in [1, 2]:
        if step - prev >= 0 and dp[step - prev] >= 0:
            ans += dp[step - prev]
    dp[step] = ans

# for i in range(0, len(dp)):
#     print(dp[i])

print(dp[n] % 1000000007)


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

int main() {
  
  int A[3], sum = 0;	
	cin >> A[0] >> A[1] >> A[2];
  
  for(int i = 0;i < 3;i++){
    sum += A[i];
  }
  if(sum >= 22){
    cout << "bust" << endl;
  }
  else {
    cout << "win" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a==b&&b==c)cout<<"No\n";
	else if(a==b||b==c||a==c)cout<<"Yes\n";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var s string
    fmt.Scan(&s)
    fmt.Printf("%c%d%c\n",s[0],len(s)-2,s[len(s)-1])
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int n; string s; cin >> n >> s;
    map<char, int> mp;
    for(char c: s) mp[c]++;
    ll res = 1;
    for(auto m: mp){
        res = res * (m.second+1) % MOD;
    }
    res = (res + MOD - 1) % MOD;
    cout << res << ln;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for(int i=0; i<n; i++) {
			long temp = in.nextLong();
			List<Integer> number = new ArrayList<Integer>();
			for(int j=0; j<8; j++) {
				if(temp>0) {
					number.add((int)(temp % 10));
					temp /= 10;
				} else
					number.add(0);
			}
			Collections.sort(number);
			long min = number.get(0);
			for(int j=1; j<8; j++) {
				min = min*10 + number.get(j);
			}
			long max = number.get(number.size()-1);
			for(int j=6; j>=0; j--) {
				max = max*10 + number.get(j);
			}
			System.out.println(max-min);
		}
	}
}

Measured memory_bytes: 17176
parseInt(x) = parse(Int,x)

function main()
	n = parseInt(readline())
	x = map(parseInt, split(readline()))
	y = sort(x)
	m1 = y[div(n,2)]
	m2 = y[div(n,2)+1]
	for i in 1:n
		if x[i] <= m1
			println(m2)
		else
			println(m1)
		end
	end
end

main()

Measured memory_bytes: 167400
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<functional>
using namespace std;
long long int dp[101][4][4];
int main(void)
{
	int i,j,k,l,n,m,a,b[101],c;
	long long int sum,x;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		for(j=1;j<=3;j++){
			for(k=0;k<=3;k++) dp[i][j][k]=0;
		}
	}
	for(i=1;i<=n;i++) b[i]=0;
	for(i=1;i<=m;i++){
		cin>>a;
		cin>>b[a];
	}
	if(b[1]>0) dp[1][b[1]][0]=1;
	else{
		for(i=1;i<=3;i++) dp[1][i][0]=1;
	}
	for(i=1;i<n;i++){
		for(j=1;j<=3;j++){
			if(dp[i][j][0]+dp[i][j][1]+dp[i][j][2]+dp[i][j][3]>0){
				for(k=0;k<=3;k++){
					if(b[i+1]>0){
						if(b[i+1]!=k||b[i+1]!=j){
							dp[i+1][b[i+1]][j]+=dp[i][j][k];
							dp[i+1][b[i+1]][j]%=10000;
						}
					}
					else{
						for(l=1;l<=3;l++){
							if(k!=l||j!=l){
								dp[i+1][l][j]+=dp[i][j][k];
								dp[i+1][l][j]%=10000;
							}
						}
					}
				}
			}
		}
	}
	sum=0;
	for(i=1;i<=3;i++){
		for(j=0;j<=3;j++) sum+=dp[n][i][j];
	}
	x=sum%10000;
	cout<<x<<endl;	
	return 0;
}

Measured memory_bytes: 3040
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

ll lcm(ll x, ll y) {
	return x / gcd(x, y) * y;
}

ll gcd(ll a, ll b) {
	while (a && b) {
		if (a >= b) {
			a %= b;
		}
		else {
			b %= a;
		}
	}
	return a + b;
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

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

int main() {

    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> L(M), R(M), p(Q), q(Q);
    rep(i,M) cin >> L[i] >> R[i];
    rep(i,Q) cin >> p[i] >> q[i];

    int x[N + 1][N + 1];
    rep(i,N+1) rep(j,N+1) x[i][j] = 0;
    rep(i,M) x[L[i]][R[i]]++;
    
    int c[N + 1][N + 1];
    rep(i,N+1) rep(j,N+1) c[i][j] = (i == 0 || j == 0 ? 0 : c[i][j - 1] + x[i][j]);
    
    rep(i,Q) {
        int ans = 0;
        for (int j = p[i]; j <= q[i]; j++) {
            ans += c[j][q[i]] - c[j][p[i] - 1];
        }
        cout << ans << endl;
    }


    return 0;
}

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

int main(){
    string S;
    cin >> S;
    int count=0;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i)=='x'){
            count ++;
        }
    }
    if(count>=8){
        cout << "NO" <<endl;
    }else{
        cout << "YES" <<endl;
    }
}

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

int main(){
    int n,m;
    cin >> n >> m;
    int k = 1;
    int i = 1;
    if(m%2 != 0) k = 2;
    while(1){
        if(m%i == 0 && n <= i){
            cout << m/i << endl;
            return 0;
        } 
        i += k;
    }
    return 0;   
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    string S;cin >> S;
    if(S[2] == S[3]){
        if(S[4] == S[5]){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#include <functional>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

template<class T>
class segtree {
	int n;
	vector<T> data;
	T def;
	function<T(T, T)> operation;
	function<T(T, T)> update;
	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def;
		if (a <= l && r <= b) return data[k];
		T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
		T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
		return operation(c1, c2);
	}
    public:
		segtree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
			:def(_def), operation(_operation), update(_update) {
			n = 1;
			while (n < _n) {
				n *= 2;
			}
			data = vector<T>(2 * n - 1, def);
		}
		void change(int i, T x) {
			i += n - 1;
			data[i] = update(data[i], x);
			while (i > 0) {
				i = (i - 1) / 2;
				data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
			}
		}
		T query(int a, int b) {
			return _query(a, b, 0, 0, n);
		}
		T operator[](int i) {
			return data[i + n - 1];
		}
};

ll mod = 998244353;

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a%mod;
		a = a * a%mod;
		b >>= 1;
	}
	return ans;
}

ll modinv(ll n) {
	return modpow(n, mod - 2);
}

ll sz = 1000000;

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> cnt(sz + 3);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	vector<ll> c(sz + 3);
	for (ll i = 1; i <= sz; i++) {
		c[i] += modinv(i); c[i] %= mod;
		for (ll j = 2 * i; j <= sz; j+=i) {
			c[j] -= c[i];
			if (c[j] < 0) c[j] += mod;
		}
	}
	ll ans = 0;
	for (ll i = 1; i <= sz; i++) {
		ll x = 0, y = 0;
		for (ll j = i; j <= sz; j += i) {
			x += cnt[j] * j%mod;
			x %= mod;
			y += cnt[j] * j%mod*j%mod;
			y %= mod;
		}
		x = x * x; x %= mod;
		x -= y; if (x < 0) x += mod;
		x *= (mod + 1) / 2; x %= mod;
		x *= c[i]; x %= mod;
		ans += x; ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(b-a<=0) cout <<"delicious" << endl;
  else if(b-a<=x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
		   
  
  return 0;

}


Measured memory_bytes: 256
from heapq import heapify, heappushpop
from itertools import accumulate

N, *A = map(int, open(0).read().split())

L, C, R = A[:N], A[N:2 * N], A[2 * N:]

heapify(L)
F = accumulate([sum(L)] + [c - heappushpop(L, c) for c in C])

R = [-r for r in R]
heapify(R)
B = reversed(list(accumulate([sum(R)] + [- c - heappushpop(R, -c) for c in reversed(C)])))

print(max(f + b for f, b in zip(F, B)))

Measured memory_bytes: 40260
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n;
  cin >> n;
  double a[n];
  for (int i = 0; i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  double kotae;
  kotae = (a[0] + a[1])/2;
  for (int i=2; i<n;i++){
    kotae = (kotae + a[i])/2;
  }
  cout << kotae <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	cin >> a;
	sort(a.begin(), a.end());
	vector<int> s(n);
	rep(i, n) s[i] = a[i] < 0;
	s[0] = 1; s.back() = 0;
	int ans = 0;
	rep(i, n) ans += s[i] ? -a[i] : a[i];
	cout << ans << endl;
	for (int i = 1; s[i]; ++i) {
		cout << a.back() << ' ' << a[i] << endl;
		a.back() -= a[i];
	}
	for (int i = n - 2; !s[i]; --i) {
		cout << a[0] << ' ' << a[i] << endl;
		a[0] -= a[i];
	}
	cout << a.back() << ' ' << a[0] << endl;
	return 0;
}

Measured memory_bytes: 3976
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
       c: chars,
    }
    println!("{}", (c[0] as u8 + 1) as char)
}


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

int main(){
	while(1){
		string s1,s2;
		cin>>s1;
		if(s1==".")return 0;
		cin>>s2;
		string s11[201],s22[201];
		for(int i=0;i<201;i++){
			s11[i]=".";s22[i]=".";
		}
		s11[0]="";s22[0]="";
		int now1=0,now2=0;
		for(int i=0;i<(int)s1.length();i++){
			if(s1[i]=='"'){
				now1++;
				s11[now1]="";
			}else s11[now1]+=s1[i];
		}
		for(int i=0;i<(int)s2.length();i++){
			if(s2[i]=='"'){
				now2++;
				s22[now2]="";
			}else s22[now2]+=s2[i];
		}
		int d=0;
		for(int i=0;i<201;i++){
			if(s11[i]!=s22[i]){
				if(i&1){
					d++;
				}else d+=2;
			}
		}
		if(d==0)cout<<"IDENTICAL";
		else if(d==1)cout<<"CLOSE";
		else cout<<"DIFFERENT";
		cout<<"\n";
	}
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;

//MODをとるパターン
ll modpower(ll n,ll p){
    if(p==0){return 1;}
    if(p%2==1){return n*modpower(n,(p-1)/2)%MOD*modpower(n,(p-1)/2)%MOD;}
    else{return modpower(n,p/2)*modpower(n,p/2)%MOD;}
}

ll gcd(ll a,ll b){
    while(b!=0){
        a%=b;
        swap(a,b);
    }
    return a;
}

int main() {
    int N;
    cin>>N;
    vector<ll> A(N),B(N);
    rep(i,N){cin>>A.at(i)>>B.at(i);}
    map<pair<ll,ll>,int> mp;
    int AB0=0;
    rep(i,N){
        if(A.at(i)==0 && B.at(i)==0){
            AB0++;
        }
        else if(A.at(i)==0){
            mp[{0,1}]++;
        }
        else if(B.at(i)==0){
            mp[{-1,0}]++;
        }
        else{
            ll d=gcd(A.at(i),B.at(i));
            A.at(i)/=d;
            B.at(i)/=d;
            if(A.at(i)<0){
                A.at(i)*=-1;
                B.at(i)*=-1;
            }
            mp[{A.at(i),B.at(i)}]++;
        }
    }
    ll ans=1;
    
    int free=N-AB0;
    for(pair<pair<ll,ll>,int> p:mp){
        pair<ll,ll> key=p.first;
        int X=p.second;
        
        if(key.second>=0){
            
            key.first*=-1;
            swap(key.first,key.second);
            if(mp.count(key)){
                free-=X;
                int Y=mp[key];
                free-=Y;
                ans*=(modpower(2,X)+modpower(2,Y)-1);
                ans%=MOD;
            }
        }
    }
//cout<<ans<<" "<<free<<endl;
    ans*=modpower(2,free);
    ans%=MOD;
    ans+=AB0-1+MOD;
    ans%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 18588
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i,n) {
        rep(j,n-1) {
            cin >> a[i][j];
            a[i][j]--;
        }
        reverse(a[i].begin(), a[i].end());
    }

    typedef pair<int, int> P;
    vector<P> que;

    auto add = [&](int i) -> void {
        if (!a[i].size()) return;
        int j = a[i].back();
        if (a[j].back() == i) {
            que.emplace_back(i,j);
            if (que.back().first > que.back().second) {
                swap(que.back().first, que.back().second);
            }
        }
    };

    rep(i,n) {
        add(i);
    }

    int ans = 0;
    while (!que.empty()) {
        ans++;
        sort(que.begin(), que.end());
        que.erase(unique(que.begin(), que.end()), que.end());
        vector<P> pre;
        swap(pre, que);
        rep(i,pre.size()) {
            int j = pre[i].first;
            int k = pre[i].second;
            a[j].pop_back();
            a[k].pop_back();
            add(j);
            add(k);
        }
    }

    rep(i,n) {
        if (a[i].size()) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int A, B, K;
	scanf("%d%d%d", &A, &B, &K);

	int a[100], b[100], ans[100];
	int j = 0;
	for (int i = 0; i < K; i++) {
		if (B >= A + i) {
			a[j] = A + i;
			j++;
		}
	}
	int k = 0;
	for (int i = -K + 1; i <= 0; i++) {
		if (B + i >= A) {
			b[k] = B + i;
			k++;
		}
	}

	int l = 0;
	while (a[l] < b[0] && a[l]>0) {
		printf("%d\n", a[l]);
		l++;
	}

	int m = 0;
	while (1) {
		printf("%d\n", b[m]);
		if (b[m] == B) {
			break;
		}
		m++;
	}


#ifdef DEBUGF
	getch();
#endif
	return 0;
}


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

using namespace std;

vector<int> calcCnt(vector<int> a) {
    int n = a.size();
    vector<int> ans(n);
    vector<int> toRm(n);
    int c = 0;
    for (int i = 0; i < n; i++) {
        c++;
        int j = i + a[i];
        if (j < n) {
            toRm[j]++;
        }
        ans[i] = c;
        c -= toRm[i];
    }
    return ans;
}

vector<int> calcNxt(vector<int> a) {
    int n = a.size();
    auto cntFwd = calcCnt(a);
    reverse(a.begin(), a.end());
    auto cntBwd = calcCnt(a);
    reverse(cntBwd.begin(), cntBwd.end());
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        ans[i] = cntFwd[i] + cntBwd[i] - 1;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        //a[i] = i == 0 ? 1 : 0;
    }
    for (int qi = 0; qi < k; qi++) {
        auto ok = true;
        for (int i = 0; i < n; i++) {
            if (a[i] < n) {
                ok = false;
            }
        }
        if (ok) {
            break;
        }
        a = calcNxt(a);
    }
    for (int v: a) {
        cout << v << " ";
    }
    cout << endl;
}



Measured memory_bytes: 7956
MOD = 10 ** 9 + 7

def mod_combination(n, k):
    def extended_gcd(a, b):
        if b == 0:
            return (a, 1, 0)
        d, x, y = extended_gcd(b, a % b)
        return (d, y, x - (a // b) * y)
    p, q = 1, 1
    for i in range(n - k + 1, n + 1):
        p = (p * i) % MOD
    for i in range(2, k + 1):
        q = (q * i) % MOD
    return p * (extended_gcd(q, MOD)[1] % MOD) % MOD

def mod_pow(a, b):
    return pow(a, b, MOD)


N, M, K = map(int, input().split())

X = mod_pow(M, 2) * (mod_pow(N, 3) - N) % MOD
Y = mod_pow(N, 2) * (mod_pow(M, 3) - M) % MOD

comb = mod_combination(N * M - 2, K - 2)

ans = (X + Y) * mod_pow(6, MOD - 2) * comb % MOD

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;

int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = b-1;
    if(b-1>=n) x = n;
    ll ans = a*x/b;
    if(b==1) ans = 0;
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(){
  	int r, D, x = 0;
  	scanf("%d %d %d",&r ,&D ,&x);
  
  	for(int i = 0; i < 10; i++){
    	x = r*x - D;	
      printf("%d\n",x);
    } 
	return 0;
}

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

using namespace std;
const int MAXN = 1e3+5;
int arr[MAXN];
vector<int> res;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    while(n){
        int mx = 0;
        for(int i=1;i<=n;i++){
            if(arr[i] == i){
                mx = i;
            }
        }
        if(mx == 0){
            cout<<-1<<endl;
            return 0;
        }
        res.push_back(mx);
        for(int i=mx;i<n;i++){
            arr[i] = arr[i+1];
        }
        n--;
    }
    reverse(res.begin(),res.end());
    for(int x:res){
        cout<<x<<endl;
    }
    
}

Measured memory_bytes: 256
s = gets.chomp.chars
t = gets.chomp
i = 0
while i < s.length
  if s.join == t
    break
  end
  s.push(s[0])
  s.delete_at(0)
  i += 1
end
if i == s.length
  puts "No"
else
  puts "Yes"
end

Measured memory_bytes: 14336
#include <cstdio>
#include <cstring>

struct Trie{
    Trie* children[26];
    int is_end;
    int num[26];

    Trie(){
        for(int i = 0; i < 26; ++i){
            children[i] = NULL;
            num[i] = 0;
        }
        is_end = 0;
    }
    Trie* upsert(char ch){
        if(children[ch - 'a'] == NULL)
            children[ch - 'a'] = new Trie();
        return children[ch - 'a'];
    }
    Trie* find(char ch){
        return children[ch - 'a'];
    }
};

int main(){
    int n;
    scanf("%d", &n);
    char s[1000005];
    Trie *root = new Trie();
    Trie *p, *q;
    int len;
    int i, j;
    int d[26];
    int t;
    long long ans = 0;
    while(n--){
        scanf("%s", s);
        len = strlen(s);
        for(i = 0; i < 26; ++i)
            d[i] = 0x7FFFFFFF;
        for(i = len - 1; i >= 0; --i)
            d[s[i] - 'a'] = i; 
        for(i = 0; i < 26; ++i)
            if(d[i] < len){
                ++root->num[i];
                q = root->find('a' + i);
                if(q)
                    ans += (long long)q->is_end;
            }
        p = root;
        for(i = len - 1; i >= 1; --i){
            p = p->upsert(s[i]);
            for(j = 0; j < 26; ++j)
                if(d[j] < i){
                    ++p->num[j];
                    q = p->find('a' + j);
                    if(q)
                        ans += q->is_end;
                }
        }
        ans += (long long)(p->num[s[0] - 'a'] - 1);
        p = p->upsert(s[0]);
        ++p->is_end;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 330756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lf;

ll A[5], K;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    for (ll i = 0; i < 5; i++) {
        cin >> A[i];
    }
    cin >> K;
    for (ll i = 0; i < 5; i++) {
        for (ll j = 0; j < i; j++) {
            if (abs(A[i]-A[j]) > K) {
                cout << ":(\n";
                return 0;
            }
        }
    }
    
    cout << "Yay!\n";
}

Measured memory_bytes: 256