akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

void P(int u) {
  if ( u == NIL ) return;
  printf(" %d", u);
  P(T[u].l);
  P(T[u].r);
}

void iP(int u) {
  if ( u == NIL ) return;
  iP(T[u].l);
  printf(" %d", u);
  iP(T[u].r);
}

void pP(int u) {
  if ( u == NIL ) return;
  pP(T[u].l);
  pP(T[u].r);
  printf(" %d", u);
}

int main() {
  int i, v, l, r, root;

  scanf("%d", &n);
  for( i = 0; i < n; i++ )
    T[i].p = NIL;

  for ( i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ) if ( T[i].p == NIL ) root = i;

  printf("Preorder\n");
  P(root);
  printf("\n");
  printf("Inorder\n");
  iP(root);
  printf("\n");
  printf("Postorder\n");
  pP(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 1996
#include <iostream>
#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>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int a;
    REP(i, N){
        cin >> a;
        A[a-1] = i + 1;
    }
    //sort(A.begin(), A.end());
    REP(i, N) cout << A[i] << " ";
    cout << endl;


    return 0;
}

Measured memory_bytes: 1152
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            li = []
            while self.parents[x] >= 0:
                if self.parents[self.parents[x]] >= 0:
                    self.parents[x] = self.parents[self.parents[x]]
                x = self.parents[x]
            return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

import sys
input = sys.stdin.buffer.readline
N,Q = map(int,input().split())
uf = UnionFind(N)
for i in range(Q):
    t,u,v = map(int,input().split())
    if t == 0:
        uf.union(u,v)
    else:
        if uf.same(u,v):
            print(1)
        else:
            print(0)


Measured memory_bytes: 77200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
     
int main(void){
  ios::sync_with_stdio(false);
  int n = 0;
  int a = 0;
  int b = 0;
  int answer = 0;
  
  cin >> n >> a >> b;
 
 for(int i = 1; i <= n; i++){
  int sum = 0;
  int tmp = 0;
  int dig = 0;
   
   tmp = i;
    while(tmp > 0){
      dig = tmp % 10;
      sum = sum + dig;
      tmp = tmp / 10;
    }
    
    if(sum >= a && sum <= b){
      answer = answer + i;
    }
 }
 
  cout << answer << endl;
 
  return 0;
}

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

using namespace std;

typedef pair<int,int> pi;
typedef pair<pi,string> pis;

int N;
vector<pi> good, bad;
string s;

bool cmp(pi A, pi B){
	return A.second + A.first > B.second + B.first;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie();
	cin >> N;
	for (int i = 1; i <= N; ++i){
		cin >> s;
		int op = 0, clo = 0, dep = 0;
		for (auto it : s){
			((it == '(') ? op++ : clo++);
			dep = max(dep,clo-op);
		}
		if (op >= clo){
			good.push_back(pi(dep,op-clo));
		}
		else bad.push_back(pi(dep,op-clo));
	}
	sort(good.begin(),good.end());
	sort(bad.begin(),bad.end(),cmp);
	int num = 0;
	for (auto it : good){
		if (num < it.first){
			cout << "No\n";
			return 0;
		}
		num += it.second;
	}
	for (auto it : bad){	
		if (num < it.first){
			cout << "No\n";
			return 0;
		}
		num += it.second;
	}
	if (num == 0){
		cout << "Yes\n";
	}
	else cout << "No\n";
}

Measured memory_bytes: 11276
def solve():
    # 方針
    # 範囲で並べ方の個数を足し合わせるDP
    
    N = int(input())
    X = [int(input()) for _ in range(N)]
    MOD = int(1e9)+7
    
    colors = set()
    NoDouble = [-1]
    for x in X:
        colors.add(x)
        if x == NoDouble[-1]:
            continue
        NoDouble.append(x)
    del NoDouble[0]
    N = len(NoDouble)
    C = len(colors)

    ForIdxLastNum = [-1] * N # N番目の要素まで見たとき、その色は直前にどこに出現したか
    # 上記を作成するために、inplace な色の出現の位置を記憶
    Onetime_colors = [-1] * (2*10**5+1)

    for e,c in enumerate(NoDouble):
        if Onetime_colors[c] == -1:
            # その色は初出
            Onetime_colors[c] = e
        else:
            ForIdxLastNum[e] = Onetime_colors[c]
            Onetime_colors[c] = e
    
    
    DP = [0] * (N+1) # dp[i], i個目まで見たときの並べ方の個数
    DP[0] = 1

    for e,c in enumerate(NoDouble):
        if ForIdxLastNum[e] == -1:
            # その色は初出
            DP[e+1] = DP[e]
        else:
            lastIdx = ForIdxLastNum[e]
            DP[e+1] = (DP[lastIdx+1] + DP[e]) % MOD
    
    print(DP[N] % MOD)

            
    
    


if __name__ == "__main__":
    solve()

Measured memory_bytes: 31644
#include<bits/stdc++.h>
using namespace std;
#define y1 ___y1
const int N=300005;
int rt[N],n,x1,y1,x2,tot1,tot2,tot,y2,cnt,num,a[N],ans;
struct Ask{
	int x,y,z;
	Ask(int _x=0,int _y=0,int _z=0){x=_x;y=_y;z=_z;}
}A[N],B[N];
struct Tree{
	int lson,rson,num;
}T[N*40];
void build(int x,int l,int r){
	if (l==r)return;
	int mid=(l+r)/2;
	build(T[x].lson=++cnt,l,mid);
	build(T[x].rson=++cnt,mid+1,r);
}
int ef(int x){
	int l=1,r=num;
	while (l<r){
		int mid=(l+r)/2;
		if (a[mid]<x)l=mid+1;
		else r=mid;
	}
	return l;
}
void insert(int x,int y,int l,int r,int z,int v){
	T[x]=T[y];T[x].num+=v;
	if (l==r)return;
	int mid=(l+r)/2;
	if (z<=mid)insert(T[x].lson=++cnt,T[y].lson,l,mid,z,v);
	else insert(T[x].rson=++cnt,T[y].rson,mid+1,r,z,v);
}
int find(int x,int l,int r,int z){
	if (l==r)return T[x].num;
	int mid=(l+r)/2;
	if (z<=mid)return find(T[x].lson,l,mid,z);
	else return find(T[x].rson,mid+1,r,z)+T[T[x].lson].num;
}
int cmp(Ask x,Ask y){
	return x.x<y.x;
}
int main(){
	scanf("%d",&n);
	while (n--){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2); 
		if (x1==x2){
			if (y1>y2)swap(y1,y2);
			a[++tot]=x1;
			A[++tot1]=Ask(x1,y1,y2);
		}
		else {
			if (x1>x2)swap(x1,x2);
			a[++tot]=x1;
			a[++tot]=x2;
			B[++tot2]=Ask(y1,x1,x2);
		}
	}
	sort(a+1,a+tot+1);
	num=1;
	for (int i=2;i<=tot;i++)
		if (a[i]!=a[num])a[++num]=a[i];
	for (int i=1;i<=tot1;i++)A[i].x=ef(A[i].x);
	for (int i=1;i<=tot2;i++)B[i].y=ef(B[i].y),B[i].z=ef(B[i].z);
	sort(B+1,B+tot2+1,cmp);
	num++;
	rt[0]=++cnt;build(1,1,num);
	for (int i=1;i<=tot2;i++){
		rt[i]=++cnt;insert(rt[i],rt[i-1],1,num,B[i].y,1);
		int k=rt[i];rt[i]=++cnt;insert(rt[i],k,1,num,B[i].z+1,-1);
	}
	for (int i=1,j=1;i<=tot1;i++){
		int L=1,R=tot2+1;
		while (L<R){
			int mid=(L+R)/2;
			if (B[mid].x<A[i].y)L=mid+1;
			else R=mid;
		}
		int l=L;
		L=0;R=tot2;
		while (L<R){
			int mid=(L+R+1)/2;
			if (B[mid].x<=A[i].z)L=mid;
			else R=mid-1;
		}
		int r=L;
		ans+=find(rt[r],1,num,A[i].x)-find(rt[l-1],1,num,A[i].x);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 29784
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
int main(){
    int h,n;
    cin >> h >> n;
    pair<long long,long long> arr[n];
    long long a,b;
    rep(i,n){
        cin >> a >> b;
        arr[i]=(make_pair(a,b));
    }
    long long dp[h+10002];
    rep(i,h+10002) dp[i]=1e10;
    dp[0]=0;
    rep(i,h+10002){
        rep(j,n){
            int now = i+1;
            if(now-arr[j].first>=0) dp[now]=min(dp[now-arr[j].first]+arr[j].second,dp[now]);
        }
    }
    long long ans = 1e10;
    for(int i = h;i<h+10002;i++) ans = min(ans,dp[i]);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

vector<int> v;

int main(void){
	int d,i,n;
	ll ans=INFLL,p[15],c[15],g,t,ac,tmp,x;
	cin >> d >> g;
	for(i=1; i<=d; ++i){
		cin >> p[i] >> c[i];
		v.push_back(i);
	}
	do{
		tmp = 0ll; t = g;
		for(i=0; i<d; ++i){
			n = v[i];
			if(t >= p[n]*n*100){
				tmp += p[n];
				t -= p[n]*n*100;
				t -= c[n];
			}else{
				x = (t-1)/(n*100)+1;
				tmp += x;
				t -= x*n*100;
			}
			if(t<=0){
				break;
			}
		}
		ans = min(ans,tmp);
	}while(next_permutation(v.begin(), v.end()));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define MAX_N 200010

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

int main() {
  int n, p[MAX_N], q[MAX_N];

  scanf("%d", &n);
  for(int i = 1; i <= n; ++i) {
    scanf("%d", &p[i]);
    q[p[i]] = i;
  }
  int mark = 0, maxk = 0;
  /*
  for(int i = 1; i < n; ++i) {
    if(q[i] < q[i + 1]) k++;
    else {
      if(k > maxk) {
        maxk = k;
        k = 1;
      }
    }
  }
  */
  for(int i = 1; i <= n; ++i) {
    if(i == n || q[i] > q[i + 1]) {
      maxk = max(maxk, i - mark);
      mark = i;
    }
  }
  printf("%d\n", n - maxk);
  return 0;
}


Measured memory_bytes: 1792
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
vll va(n+1);
read(va);
vll vb(n);
read(vb);
ll sum=0;
for(int i=0;i<n;i++)
{
 temp=min(va[i],vb[i]);
 vb[i]-=temp;
 sum+=temp;
 temp=min(va[i+1],vb[i]);
 va[i+1]-=temp;
 sum+=temp;
 vb[i]-=temp;
}
cout<<sum;






return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

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

const char cs[] = {'R','G','B'};

signed main(){
	string s;
	int n,dp[200010][2];
	cin >> s;
	n = s.length();
	for(int i = 0;i <= n;i++){
		dp[i][0] = -INF;
		dp[i][1] = -INF;
	}
	dp[0][0] = 0;
	for(int i = 0;i < n;i++){
		if(!i){
			dp[i + 1][0] = 1;
		}else if(i == 1){
			if(s[i] != s[i - 1]) dp[i + 1][0] = 2;
			dp[i + 1][1] = 1;
		}else{
			if(s[i] != s[i - 1]) chmax(dp[i + 1][0],dp[i][0] + 1);
			chmax(dp[i + 1][0],dp[i][1] + 1);
			chmax(dp[i + 1][1],dp[i - 1][0] + 1);
			if(i >= 3 && s.substr(i - 1,2) != s.substr(i - 3,2)) chmax(dp[i + 1][1],dp[i - 1][1] + 1);
		}
	}
	cout << max(dp[n][0],dp[n][1]) << endl;
}

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

#define MOD 1000000007

int main(){
    int n;
    cin >> n;

    map<int, int> m;
    int x;
    bool flag = true;

    for(int i = 0; i < n; i++){
        cin >> x;
        m[x]++;
        if(m[x] > 2){
            flag = false;
            break;
        }
    }

    if(!flag){
        cout << 0 << endl;
        return 0;
    }

    if(n%2 == 1){
        if(m[0] != 1){
            flag = false;
        }
        for(int i = 2; i <= n/2*2; i += 2){
            if(m[i] != 2)   flag = false;
        }
    }else{
        if(m[0] != 0){
            flag = false;
        }
        for(int i = 1; i <= 2*(n/2-1)+1; i += 2){
            if(m[i] != 2)   flag = false;
        }
    }

    if(!flag){
        cout << 0 << endl;
        return 0;
    }

    int ans = 1;
    for(int i = 0; i < n/2; i++){
        ans *= 2;
        ans %= MOD;
    }

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

Measured memory_bytes: 2560
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
a = list(stdin.readline().rstrip())
num = int(len(a) / 2)
res = 0
for el in range(num):
    f = a[el]
    b = a[len(a) - 1 - el]
    if not f == b:
        res += 1
print(res)

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	VVI a(3,VI(3));
    REP(i,3)REP(j,3)cin >> a[i][j];
    int n; cin >> n;
    vector<vector<bool>> f(3,vector<bool>(3,0));
    REP(i,n){
        int b; cin >> b;
        REP(j,3)REP(k,3){
            if(a[j][k] == b)
                f[j][k] = 1;
        }
    }
    bool ans = 0;
    REP(i,3){
        if(f[0][i]&&f[1][i]&&f[2][i])
            ans = 1;
    }
    REP(i,3){
        if(f[i][0]&&f[i][1]&&f[i][2])
            ans = 1;
    }
    if(f[0][0]&&f[1][1]&&f[2][2])
        ans = 1;
    if(f[0][2]&&f[1][1]&&f[2][0])
        ans = 1;
    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);

        double res = a[0];
        for(int i=1; i<n; i++) {
            res = (res + a[i]) / 2;
        }
        System.out.println(res);


    }

}


Measured memory_bytes: 22100
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    int c[3][3];
    REP(i,3)REP(j,3)cin>>c[i][j];
    REP(a0,101){
        int a[3];
        int b[3];
        REP(i,3){
            b[i]=c[0][i]-a0;
            if(b[i]<0)break;
        }
        REP(i,3){
            a[i]=(i!=0?c[i][0]-b[0]:a0);
            if(a[i]<0)break;
        }
        /*cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "
            <<b[0]<<" "<<b[1]<<" "<<b[2]<<"\n";*/
        bool f=true;
        FOR(i,1,3){
            FOR(j,1,3){
                if(!f)break;
                //cout<<"("<<i<<","<<j<<"): c: "<<c[i][j]<<" a,b,a+b: "<<a[i]<<" "<<b[j]<<" "<<a[i]+b[j]<<"\n";
                if(c[i][j]==a[i]+b[j])continue;
                f=false;
            }
        }
        if(f){
            cout<<"Yes\n";
            exit(0);
        }
    }
    cout<<"No\n";
}

Measured memory_bytes: 384
#include <iostream>
#include <list>
#include <random>

#define llong long long
#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i++))

using namespace std;

int main(){
	int N; cin >> N;
	string judge[4]={"AC","WA","TLE","RE"};
	int count[4]={0};
	rep(i,0,N){
		string temp; cin >> temp;
		rep(j,0,4){
			if( temp==judge[j] ){
				count[j]++;
			}
		}
	}
	rep(i,0,4){
		cout << judge[i] << " x " << count[i] << endl;
	}
	return 0;
}


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

int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	if (a == b){
		printf("%d\n", c);
	}
	else if (a == c){
		printf("%d\n", b);
	}
	else {
		printf("%d\n", a);
	}
	
	return 0;
}

Measured memory_bytes: 256
X,Y=parse.(split(readline()))
F(x)=factorial(big(x))
s=div(X+Y,3)
if s*3!=X+Y||2X<Y||2Y<X
  println(0)
else
  println(div(F(s),F(X-s)*F(Y-s))%(10^9+7))
end

Measured memory_bytes: 176692
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

class CThREE {
public:
    vector<vector<int>> G;
    map<int, int> cnt, types;
    int one, two;

    void dfs(int v, int p, int n) {
        cnt[n]++;
        types[v] = n;
        n == 0 ? one++ : two++;
        for (auto to : G[v]) {
            if (to == p) continue;
            dfs(to, v, n ^ 1);
        }
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        G.resize(N);
        REP(i, N - 1) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }

        one = 0, two = 0;
        dfs(0, -1, 0);

        int oneNum = N / 3;
        if (N % 3 >= 1) oneNum++;
        int twoNum = N / 3;
        if (N % 3 >= 2) twoNum++;

        vector<int> res(N, 0);
        if (one < oneNum || two < twoNum) {
            int t = 0;
            if (two < one) t = 1;
            int cur = 1;
            set<int> used;
            REP(i, N) {
                if (types[i] == t) {
                    res[i] = cur * 3;
                    used.insert(res[i]);
                    cur++;
                }
            }
            int id = 1;
            REP(i, N) {
                if (res[i] == 0) {
                    res[i] = id;
                    id++;
                    if (used.count(id)) id++;
                }
            }
        } else {
            int c1 = 0;
            int c2 = 0;
            REP(i, N) {
                if (types[i] == 0 && c1 * 3 + 1 <= N) {
                    res[i] = c1 * 3 + 1;
                    c1++;
                } else if (types[i] == 1 && c2 * 3 + 2 <= N) {
                    res[i] = c2 * 3 + 2;
                    c2++;
                }
            }
            int c0 = 1;
            REP(i, N) {
                if (res[i] == 0) {
                    res[i] = c0 * 3;
                    c0++;
                }
            }
        }
        REP(i, N) {
            cout << res[i] << " ";
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CThREE solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 28416
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

x, k, d = map(int, input().split())
x = abs(x)
init = x // d
x -= min(init, k) * d
k -= min(init, k)

if d == 0:
    print(x)
else:
    if k % 2 == 0:
        print(x)
    else:
        print(abs(x - d))

Measured memory_bytes: 9184
using System;
using System.Linq;
using System.Collections.Generic;

public class Test
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		string[] line = Console.ReadLine().Split(' ');
		int min = 99999999;
		int kaisuu;
		int target;
		for(int i = 0; i < n ; i++){
			kaisuu = 0;
			target = int.Parse(line[i]);
			while(target % 2 == 0 || target < 1){
				target = target / 2;
				kaisuu++;
			}
			if(min > kaisuu){
				min = kaisuu;
			}
		}
		Console.WriteLine(min);
		
	}                                                                                                                                                                       
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long unsigned int ll;
using namespace std;
int main()
{
  ll x, y;
  cin >> x >> y;
  int ans = 0;
  // ll c = y/x;
  // ans = (int)log2(c) + 1 << endl;
  REP(i, 10000000){
    if((ll)pow(2, i)*x <= y){
      ans ++;
    }else{break;}
  }
  cout << ans << endl;
}


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

int main() {
	int money,A,B;
	cin>>money>>A>>B;
    money-=A;
    while(money>B-1){
    	money-=B;
    }
    cout<<money<<endl;
    
    
    
    
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    b = list(map(int, input().split()))
    ans = b[0] + b[-1]

    if n >= 3:
        for i in range(n - 2):
            ans += min(b[i], b[i + 1])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define up(i,a,b) for(int i=a;i<=b;i++)
#define down(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a-1;i>=b;i--)
#define CL(x) (x<<1)
#define CR(x) (x<<1)+1
#define pb push_back
#define bit1(x) __builtin_popcount(x)
#define self (*this)
#define y1 Kami

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,pii> plii;
#define x first
#define y second

template<typename T> inline void _read(T &x){
    char ch; x=0; bool neg=false;
    for(ch=getchar();ch<'0'||ch>'9';ch=getchar())
        if(ch=='-') neg=true;
    for(;ch>='0'&&ch<='9';ch=getchar()) x=10*x+ch-'0';
    if(neg) x=-x;
}
#define read(a) _read(a)
#define Read(a,b) _read(a),_read(b)
#define READ(a,b,c) _read(a),_read(b),_read(c)

const int maxn=3e5+7;
const int Nblocks=400;
const int maxS=(1<<5)+7;
const ll mod=9901;
const int inf=1e9+7;
const ll linf=1e16+9;
const double pi=4*atan(1);
const ll Radix=1e9;
const int Length=9;
const int MaxDigit=2e4+1;
const int nDigits=MaxDigit/Length+1;

int n,m,a[501][501],res;
int x1[maxn],x2[maxn],y1[maxn],y2[maxn];

inline void Enter(){
    cin>>m>>n;
    up(i,1,m) up(j,1,n) cin>>a[i][j];
}

inline void Solve(){
    #define Kamisama
    rep(i,1,m) up(j,1,n) if(a[i][j]&1)
        x1[++res]=i,y1[res]=j,x2[res]=i+1,y2[res]=j,a[i][j]--,a[i+1][j]++;
    rep(i,1,n) if(a[m][i]&1) x1[++res]=m,y1[res]=i,x2[res]=m,y2[res]=i+1,a[m][i]--,a[m][i+1]++;
    cout<<res<<'\n';
    up(i,1,res) cout<<x1[i]<<' '<<y1[i]<<' '<<x2[i]<<' '<<y2[i]<<'\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    #ifndef Kamisama
    freopen("TEST.INP","r",stdin);
    freopen("TEST.OUT","w",stdout);
    #endif // Kamisama

    Enter();
    Solve();

    return 0;
}


Measured memory_bytes: 6144
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
static const int FREE = -1;
static const int NOT_FREE = 1;
static const int N=8;

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N -1];
bool X[N][N];

void init() {
    for (int i = 0; i < N; i++) row[i] = col[i] = FREE;
    for (int i = 0; i < 2 * N - 1; i++) dpos[i] = dneg[i] = FREE;
    memset(X, 0, sizeof (X));
}

void printBoard() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (X[i][j] && row[i] != j) return;
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j  < N; j++)
            (row[i] == j) ? printf("Q") : printf(".");
        printf("\n");
    }
}

void solve(int i) {
    if (i == N) { printBoard(); return; }
    for (int j = 0; j < N; j++) {
        if (col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE) continue;
        row[i] = j; col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
        solve(i+1);
        row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
    }
}

int main()
{
    int k, r, c;
    init();
    scanf("%d", &k);
    for (int i = 0; i < k; i++) {
        scanf("%d %d", &r, &c);
        X[r][c] = true;
    }
    solve(0);
    return 0;
}



Measured memory_bytes: 2588
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	int N; cin >> N;
	vi v(N+1); rep(i, N+1) cin >> v[i];
	int ans = 0;
 	rep(i, N){
		int b; cin >> b;
		if (b <= v[i]) {
			ans += b;
		}
		else if (b <= v[i] + v[i+1]) {
			ans += b;
			v[i+1] -= b - v[i];
		}
		else {
			ans += v[i] + v[i+1];
			v[i+1] = 0;
		}
	}
	cout << ans << endl;

	/*--------------------------*/
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  
  long long a[n+1];
  long long b[n];
  
  for(int i = 0;i<n+1;i++){
    scanf("%lld",&a[i]);
  }
  for(int j = 0;j<n;j++){
    scanf("%lld",&b[j]);
  }
  long long s=0;
  for(int m = n-1;m>=0;m--){
    if(a[m+1] >b[m]){
      s = s+b[m]; 
      b[m] = 0;
    }else{
      s = s+a[m+1];
      b[m] = b[m]-a[m+1];
    }
    if(b[m]>0){
      if(b[m]>a[m]){
        s = s+a[m];
        a[m] = 0;
      }else{
        s = s +b[m];
        a[m] = a[m]-b[m];
      }
    }//ifbm
  }//for
  printf("%lld\n",s);
  
  return 0;
}
      


Measured memory_bytes: 1664
s =input()

ol=[]
lo=[]
for i in range(len(s)):
  if i%2==0:
    ol.append('0')
    lo.append('1')
  else:
    ol.append('1')
    lo.append('0')

dif_ol=0
dif_lo=0
for i in range(len(s)):
  if ol[i]!=s[i]:
    dif_ol+=1
  if lo[i]!=s[i]:
    dif_lo+=1

print(min(dif_ol,dif_lo))    

Measured memory_bytes: 4852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int count = 0;

		for (int i = a; i < b + 1; i++) {
			if (i / 10000 == i % 10) {
				if (i / 1000 - (i / 10000) * 10 == (i % 100 - i % 10) / 10) {
					count++;
				}
			}

		}
		System.out.println(count);

	}
}

Measured memory_bytes: 22612
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;++i)
#define END(x) (*(x.end()-1))

using namespace std;
typedef long long ll;


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

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

int main(void){
    int n;
    cin>>n;
    cout<<lcm(n,360)/n;
}
/*

*/


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll n;
ll f(ll x,ll y,ll a){
	ll w = y/a;
	w -= (x-1)/a;
	return w;
}
ll func(ll a){
	if(a == 0) return 0;
	int num = 1;
	ll ret = 0;
	for(ll x=1;;x*=10){
		ll y = x*10-1;
		//[x,y]
		if(y < a){
			ret += f(x,y,15)*8;
			ret += (f(x,y,5)-f(x,y,15))*4;
			ret += (f(x,y,3)-f(x,y,15))*4;
			ret += (f(x,y,1)-f(x,y,3)-f(x,y,5)+f(x,y,15))*num;
		}
		else{
			ret += f(x,a,15)*8;
			ret += (f(x,a,5)-f(x,a,15))*4;
			ret += (f(x,a,3)-f(x,a,15))*4;
			ret += (f(x,a,1)-f(x,a,3)-f(x,a,5)+f(x,a,15))*num;
			break;
		}
		num++;
	}
	return ret;
}
int main(){
	cin>>n;
	ll lb = 0,ub = 500000000000000000LL;
	while(ub-lb > 1){
		ll mid = (lb+ub)/2;
		ll S = func(mid);
		if(S < n) lb = mid;
		else ub = mid;
	}
	string str = "";
	ll cur = func(lb);
	for(ll x=lb+1;str.size()<20+(int)(n-cur-1);x++){
		if(x%15 == 0){
			str += "FizzBuzz";
		}
		else if(x%3 == 0){
			str += "Fizz";
		}
		else if(x%5 == 0){
			str += "Buzz";
		}
		else{
			ll y = x;
			string sss = "";
			while(y){
				sss.pb('0'+y%10);
				y /= 10;
			}
			reverse(sss.begin(),sss.end());
			str += sss;
		}
	}
	rep(i,20) cout<<str[i+(int)(n-cur-1)];
	cout<<endl;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <ios>
#include <iomanip>

using namespace std;

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

// x^y%p
long long modpow(long long x, long long y, long long p=1) {
    long long res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0) {
        if (y & 1) res = res * x % p;
        y = y>>1;
        x = x * x % p;
    }
    return res;
}

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

  long long N, M;
  cin >> N >> M;
  vector<long long> P(M), Y(M);
  vector<vector<long long>> prefecture(N+1);
  for(long long i = 0; i < M; i++) {
    cin >> P[i] >> Y[i];
    prefecture[P[i]].push_back(Y[i]);
  }

  for(long long i = 0; i < N; i++) {
    sort(prefecture[i+1].begin(), prefecture[i+1].end());
  }

  for(long long i = 0; i < M; i++) {
    cout << setfill('0') << setw(12) << P[i]*1000000+int(lower_bound(prefecture[P[i]].begin(), prefecture[P[i]].end(), Y[i])-prefecture[P[i]].begin())+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 10216
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/5/30 20:00:18
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int h1=read(),m1=read(),h2=read(),m2=read(),k=read();
	m2+=h2*60;
	m1+=h1*60;
	k=m2-m1-k;
	if(k<=0) printf("0");
	else printf("%d\n",k);

	return 0;
}


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

const int mod = 998244353;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
    return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    int n;
    cin >> n;
    vector<int> cnt(n);
    int mx = 0;
    rep(i,n) {
        int d;
        cin >> d;
        if(i==0&&d != 0){
            cout << 0 << endl;
            return 0;
        }else if(i != 0 && d == 0){
            cout << 0 << endl;
            return 0;
        }
        cnt[d]++;
        mx = max(mx,d);
    }
    
    mint ans = 1;
    for(int i = 1;i <= mx;i++){
        ans *= mint(cnt[i-1]).pow(cnt[i]);
    }

    cout << ans << endl;

}


Measured memory_bytes: 3704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int n = fs.nextInt();
		ArrayList<Point> pointArr = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			int x = fs.nextInt();
			int y = fs.nextInt();
			int h = fs.nextInt();
			pointArr.add(new Point(x,y,h));
		}
		
		Comparator<Point> pointComparator = Comparator.comparing(Point::getH);
		pointArr.sort(pointComparator);
		
		int hCandidate;
		int i ,j;
		
		for(i = 0; i <= 100; i++) {
			for(j = 0; j <= 100; j++) {
				boolean validPoint = true;
				hCandidate = 1000001000;
				
				int l = 0;
				while(pointArr.get(l).h == 0) {
					Point point = pointArr.get(l);
					hCandidate = Math.min(hCandidate, Math.abs(i - point.x) + Math.abs(j - point.y));
					l++;
				}
				for(int k = l; k < n; k++) {
					Point point = pointArr.get(k);
					if(k == l) {
						if(hCandidate < point.h + Math.abs(i - point.x) + Math.abs(j - point.y)) {
							validPoint = false;
							break;
						}
						hCandidate = point.h + Math.abs(i - point.x) + Math.abs(j - point.y);
					}else {
						if(hCandidate != point.h + Math.abs(i - point.x) + Math.abs(j - point.y)) {
							validPoint = false;
							break;
						}
					}				
				}
				if(validPoint && hCandidate > 0) {
					System.out.println(i+" "+j+" " +hCandidate);
					return;
				}
			}
		}
	}
	
	class Point{
		int x;
		int y;
		int h;
		Point(int x, int y, int h){
			this.x = x;
			this.y = y;
			this.h = h;
		}
		int getH() {
			return h;
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 27476
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	makei(x);
	makei(y);
	say(x + y / 2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main( )//主函数
{
    char a;
    cin>>a;
    if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')      cout<<"vowel"<<endl;//判断为元音后输出
    else cout<<"consonant"<<endl;//为辅音输出这个
    return 0; 
} 

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

void input(int& rnTrgSu, int& rnTrgKin)
{
  cin >> rnTrgSu >> rnTrgKin;
}

void searchCntl(int nTrgSu, int nTrgKin)
{
  for (int n10000 = 0; n10000 <= nTrgSu; ++n10000)
    for (int n5000 = 0; n5000 <= (nTrgSu - n10000); ++n5000)
    {
      int n1000 = nTrgSu - n10000 - n5000;
      if (nTrgKin == 10000 * n10000 + 5000 * n5000 + 1000 * n1000)
      {
        cout << n10000 << " " << n5000 << " " << n1000 << endl;
        return;
      }
    }
  cout << -1 << " " << -1 << " " << -1 << endl;
}

int main()
{
  int nTrgSu, nTrgKin;
  
  input(nTrgSu, nTrgKin);
  searchCntl(nTrgSu, nTrgKin);

  return 0;
}

Measured memory_bytes: 3548
#include<iostream>
#include<set>

using namespace std;

#define NMAX 20000
#define MMAX 20000

struct S{
	int t,s,d;
};

bool operator<(S a,S b){
	return a.t<b.t;
}

int main(){

	int N,M;
	bool comp[NMAX+1];
	int t,s,d;
	set<S> p;
	S pp;
	int ans=0;

	while(1){

		cin>>N>>M;
		if(N==0&&M==0) break;

		comp[1]=true;
		for(int i=2;i<=N;i++) comp[i]=false;

		for(int i=0;i<M;i++){
			cin>>t>>s>>d;
			pp.t=t,pp.s=s,pp.d=d;
			p.insert(pp);
		}

		set<S>::iterator it=p.begin();
		while(it!=p.end()){
			//cout<<(*it).t<<","<<(*it).s<<","<<(*it).d<<endl;
			if(comp[(*it).s]==true) comp[(*it).d]=true;
			it++;
		}

		ans=0;
		for(int i=1;i<=N;i++){
			if(comp[i]==true) ans++;
		}

		cout<<ans<<endl;
		p.clear();
	}

	return 0;
}

Measured memory_bytes: 2460
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			ice = new int[h * w];
			hit = new int[h * w];
			dist = new int[h][w];
			m = new char[h][w];
			v = new boolean[h][w];
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++) {
					dist[i][j] = -1;
					m[i][j] = '#';
				}
			for (int i = 0; i < h; i++) {
				char[] c = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					m[i][j] = c[j];
					if (m[i][j] == 'S') {
						m[i][j] = '.';
						si = i;
						sj = j;
					} else if (m[i][j] == 'G') {
						m[i][j] = '.';
						gi = i;
						gj = j;
					}
				}

			}
			ice[0] = INF;
			id = new int[h][w];
			int ID = 1;
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++) {
					if (m[i][j] != 'X' || id[i][j] > 0)
						continue;
					mark(i, j, ID);
					if (ice[ID] == 1)
						m[i][j] = '#';
					ID++;
				}
			dist[gi][gj] = 0;
			Deque<int[]> deque = new ArrayDeque<int[]>();
			deque.offer(new int[] { gi, gj });
			while (!deque.isEmpty()) {
				int[] V = deque.poll();
				int pi = V[0];
				int pj = V[1];
				for (int[] mo : d) {
					int ni = pi + mo[0];
					int nj = pj + mo[1];
					if (!isOK(ni, nj))
						continue;
					if (m[ni][nj] != '#' && dist[ni][nj] == -1) {
						dist[ni][nj] = dist[pi][pj] + 1;
						deque.offer(new int[] { ni, nj });
					}
				}
			}
			res = 0;
			v[si][sj] = true;
			while (!f(si, sj, 0)) {
				Arrays.fill(hit, 0);
				for (int i = 0; i < h; i++)
					for (int j = 0; j < w; j++)
						v[i][j] = false;
				v[si][sj] = true;
				res++;
			}
			System.out.println(res);
		}
	}

	private boolean f(int i, int j, int depth) {
		if (res < depth + dist[i][j])
			return false;
		if (gi == i && gj == j)
			return true;
		for (int[] mo : d) {
			int ni = i + mo[0];
			int nj = j + mo[1];
			if (!isOK(ni, nj))
				continue;
			if (!v[ni][nj] && m[ni][nj] != '#') {
				if (ice[id[ni][nj]] /2 > hit[id[ni][nj]] ) {
					hit[id[ni][nj]]++;
					v[ni][nj] = true;
					if (f(ni, nj, depth + 1))
						return true;
					v[ni][nj] = false;
					hit[id[ni][nj]]--;
				}
			}
		}
		return false;
	}

	private void mark(int i, int j, int x) {
		id[i][j] = x;
		ice[x]++;
		for (int[] mo : d) {
			int ni = i + mo[0];
			int nj = j + mo[1];
			if (!isOK(ni, nj))
				continue;
			if (m[ni][nj] == 'X' && id[ni][nj] == 0)
				mark(ni, nj, x);
		}
	}

	private boolean isOK(int i, int j) {
		if (0 <= i && i < h && 0 <= j && j < w)
			return true;
		return false;
	}

	int w, h, si, sj, gi, gj, INF = 1 << 29, res;
	int[][] d = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };
	int[] ice, hit;
	int[][] id, dist;
	char[][] m;
	boolean[][] v;
}

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

int ary[200100],imajun[26];
vector<int> junban[26];
//string saitan[200100];
string saitana[26];

inline string yoritan(string a,string b){
	if(a=="#") return b;
	if(b=="#") return a;
	if(a.length()>b.length()) return b;
	if(a.length()<b.length()) return a;
	if(a>b) return b;
	return a;
}

int main(){
	string str;
	cin>>str;
	for(int i=0;i<str.length();i++){
		ary[i]=(int)(str[i]-'a');
	}
	int len=str.length();

	for(int i=0;i<len;i++){
		junban[ary[i]].push_back(i);
	}
	for(int i=0;i<26;i++) junban[i].push_back(len+i);
	/*
	for(int i=0;i<len+26;i++){
		saitan[i]="#";
	}
	for(int i=0;i<26;i++){
		saitan[junban[i][0]]="";
		imajun[i]=0;
	}
	*/
	for(int i=0;i<26;i++){
		saitana[i]="";
		imajun[i]=0;
	}
	/*
	for(int i=0;i<len;i++){
		imajun[ary[i]]++;
		for(int j=0;j<26;j++){
			saitan[junban[j][imajun[j]]]=yoritan(saitan[junban[j][imajun[j]]],saitan[i]+(char)('a'+ary[i]));
		}
		saitan[i]="";
	}
	*/
	for(int i=0;i<len;i++){
		string hog=saitana[ary[i]];
		imajun[ary[i]]++;
		saitana[ary[i]]="#";
		for(int j=0;j<26;j++){
			saitana[j]=yoritan(saitana[j],hog+(char)('a'+ary[i]));
		}
	}
	string res="#";
	/*
	for(int i=len;i<len+26;i++){
		res=yoritan(res,saitan[i]+(char)(i-len+'a'));
	}
	*/
	for(int i=0;i<26;i++){
		res=yoritan(res,saitana[i]+(char)(i+'a'));
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 2636
using System;
using System.Linq;

namespace A___K_City
{
    class Program
    {
        static void Main(string[] args)
        {
            var n_m = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = n_m[0], m = n_m[1];

            Console.WriteLine((n - 1) * (m - 1));
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


void solve(long long S, long long W){
    if(S <= W){
        cout<<"unsafe"<<endl;
    }else{
        cout<<"safe"<<endl;
    }
}

int main(){
    long long S;
    scanf("%lld",&S);
    long long W;
    scanf("%lld",&W);
    solve(S, W);
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2<<"\n";
	return 0;
}

Measured memory_bytes: 3560