akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    int N,K; cin >> N >> K;
    vi A(N);
    rep(i,N) cin >> A[i];

    rep(i,K){
        bool flag = true;
        vi B(N, 0);
        rep(j,N){
            if(flag && A[j] < N) flag = false;
            B[max(0,(int)j-A[j])]++;
            if((int)j+A[j] < N-1) B[(int)j+A[j]+1]--;
        }

        rep(j,N-1) B[j+1] += B[j]; 
        rep(j,N) A[j] = B[j];
        if(flag) break;
    }
    
    rep(i,N) {
        cout << A[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    rep(i,h) cin >> c[i];
    int ans = 0;

    rep(bit1, 1<<h){
        vector<int> flag(h,0);
        rep(i,h){
            if(bit1&(1<<i)){
                flag[i] = 1;
            }
        }

        rep(bit2, 1<<w){
            int black = 0;
            vector<int> flag2(w,0);
            rep(i,w){
                if(bit2&(1<<i)){
                    flag2[i] = 1;
                    }
                }

            rep(i,h){
                rep(j,w){
                    if(flag[i] || flag2[j]) continue;
                    if(c[i][j]=='#') black++;
                }
            }   
            if(black==k) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3572
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s;
  cin>>s;
  if(s.back()=='s'){
    s+="es";
  } else s += "s";
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
int i,ans1=0,ans2=0;
char s[111111];
for(i=0;i<111111;i++)
s[i]='\0';
cin>>s;
for(i=0;s[i]!='\0';i++){
if(s[i]=='0'){
if(i%2==0)
ans1++;
else
ans2++;
}
else{
if(i%2==1)
ans1++;
else
ans2++;
}
}
if(ans1>ans2)
ans1=ans2;
cout<<ans1<<endl;
}


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

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

void solve(long long N, long long M, std::vector<long long> A){
    int cnt = 0;
    ll sum = accumulate(A.begin(), A.end(), 0LL);
    for(int i = 0;i < N;i++)if(4 * M * A[i] >= sum)cnt++;
    if(cnt >= M){
        cout<<YES<<endl;
    }else{
        cout<<NO<<endl;
    }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    ll n, k; cin >> n >> k;
    vector<ll> a(n), f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());

    ll sum = 0;
    rep(i, n) sum += a[i];
    if (sum <= k) { cout << 0 << endl; return 0; };

    ll ng = 0, ok = 1e13;
    auto check = [&](ll mid) {
        if(mid == -1) return false;
        ll cnt = 0;
        rep(i, n) if(a[i]*f[i]>mid) {
            cnt += (a[i]*f[i]-mid + f[i]-1) / f[i];            
        }
        return cnt <= k;
    };
    while(ok-ng > 1) {
        ll mid = (ok+ng) / 2;
        (check(mid)? ok:ng) = mid;
    }
    cout << ok << endl;
    
    return 0;
}

Measured memory_bytes: 3456
from decimal import Decimal
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if v==w:
    print("NO")
    exit()
atai = Decimal(abs(b-a))/Decimal(abs(v-w))
if atai<=t and a+v*t>=b+w*t:
    print("YES")
else:
    print("NO")


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int N;
	vector<llong> dp;

	cin >> N;
	dp.resize(400,0);
	// j = {0A, 1G, 2C, 3T}
	for(int i = 0; i < 4; i++)
		for(int j = 0; j < 4; j++)
			for(int k = 0; k < 4; k++){
				int check = i*100 + j*10 + k;
				if(check == 12 || check == 21 || check == 102)
					continue;
				else
					dp[check] = 1;
			}

	for(int i = 3; i < N; i++){
		vector<llong> next(400,0);
		int cnt = 0;
		for(int j = 0; j < 4; j++){
			for(int k = 0; k < 4; k++){
				for(int l = 0; l < 4; l++){
					for(int m = 0; m < 4; m++){
						int check = j*100+k*10+l;
						int now = k*100+l*10+m;
						if(m == 1){
							if(k == 0 && l == 2)
								continue;
						}else if(m == 2){
							if(k == 0 && l == 1)
								continue;
							if(k == 1 && l == 0)
								continue;
							if(j == 0 && l == 1)
								continue;
							if(j == 0 && k == 1)
								continue;
						}
						cnt++;
						next[now] += dp[check];
						next[now] %= mod;
					}
				}
			}
		}
		cerr << cnt << endl;
		dp = next;
	}

	llong ans = 0;
	for(int i = 0; i < 4; i++)
		for(int j = 0; j < 4; j++)
			for(int k = 0; k < 4; k++){
				int check = i * 100 + j*10 + k;
				// if(dp[check] == 0)
				ans = (ans + dp[check]) % mod;
			}
	cout << ans << endl;

	return 0;
}

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

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m)); 
  vector<int> xtotal(m,0);
  int ans = 0;
  for(int i=0; i<n; i++){
    cin >> c[i];
    ans += c[i];
    for(int j=0; j<m; j++){
      cin >> a[i][j];
      xtotal[j] += a[i][j];
    }
  }
  for(int i=0; i<m; i++){
    if(xtotal[i] < x){
      cout << -1 << endl;
      return 0;
    }
  }  
  
  vector<bool> b(n,true);
  int l = 0;
  
  while(l<(int)pow(2,n)){
    int ctotal = 0;
    vector<int> xtotal(m,0);
    bool kuriage = true;
    int k = 0;
    
    while(kuriage && k<n){
      //cout << "くりあげ" << endl;
      if(b[k]) b[k] = false;
      else b[k] = true;
      
      if(b[k] == false){
        kuriage = false;
      }
      k++;
    }
    
    for(int i=0; i<n; i++){
      if(b[i]){
        ctotal += c[i];
        for(int j=0; j<m; j++){
          xtotal[j] += a[i][j];
        }
      }
    }  
    bool xclear = true;
    for(int i=0; i<m; i++){
      if(xtotal[i] < x){
        xclear = false;
        break;
      }
    }
    if(xclear){
      ans = min(ans,ctotal);
    }
    l++;
    //cout << ctotal << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
vector<ll> divs(ll n){
	vector<ll>ret;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(i*i==n){
				ret.push_back(i);
			}
			else{
				ret.push_back(i);
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
unordered_map<ll,ll>m;
inline ll val(ll x,ll y,ll z){
	return x*x+y*y+z*z+x*y+y*z+z*x;
}
void pre(){
	ll i,j,k;
	sfl(i,1,1000){
		sfl(j,1,1000){
			sfl(k,1,1000){
				m[val(i,j,k)]++;
				if(val(i,j,k)>11000){
					break;
				}
			}
		}
	}
}
void solve(){
	ll n,i,x;
	cin>>n;
	sfl(i,1,n+1){
		cout<<m[i]<<endl;
	}
	

}	
int main(){
	gear_change;
	ll test=1;
	pre();
	// in(test);
	while(test--){
		solve();
	}
}	

Measured memory_bytes: 19856
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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 main() {
  int x; cin >> x;
  int ans = abs(x-1);
  cout << ans << endl;
}


Measured memory_bytes: 3548
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    
		int S = sc.nextInt();
		
		int h = S / 3600;
		S = S % 3600;
		
		int m = S / 60;
		S = S % 60;
		
		System.out.printf("%d:%d:%d\n", h, m, S);


	}
}

Measured memory_bytes: 17332
package main

import "fmt"

const inf = 1 << 60

func max(a []int) int {
	x := a[0]
	for i := range a {
		if a[i] > x {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := range a {
		if a[i] < x {
			x = a[i]
		}
	}
	return x
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	f := func(h, w int) int {
		minDiff := inf
		if h == 2 {
			return minDiff
		}

		switch h % 3 {
		case 0:
			minDiff = 0
		case 1, 2:
			minDiff = w
		}
		return minDiff
	}
	g := func(h, w int) int {
		minDiff := inf
		for i := 1; i <= (w/2 + 1); i++ {
			area1 := h * i
			var area2, area3 int
			if h%2 == 0 {
				area2 = (h / 2) * (w - i)
				area3 = (h / 2) * (w - i)
			} else {
				area2 = (h / 2) * (w - i)
				area3 = ((h / 2) + 1) * (w - i)
			}

			largestArea := max([]int{area1, area2, area3})
			smallestArea := min([]int{area1, area2, area3})
			tmp := largestArea - smallestArea
			if tmp < minDiff {
				minDiff = tmp
			}
		}
		return minDiff
	}

	a := f(h, w)
	b := f(w, h)
	c := g(h, w)
	d := g(w, h)
	ans := min([]int{a, b, c, d})
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	long a;
	long b;
	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long h[] = new long[n];
		a=sc.nextLong();
		b=sc.nextLong();
		for(int i=0; i<n; i++) {
			h[i]=sc.nextLong();
		}
		Arrays.sort(h);
		int ans = s(h);
		System.out.println(ans);

		sc.close();
	}

	private int s(long h[]) {
		int l=-1;
		int r=2000000000;
		while(l+1<r) {
			int m=(l+r)/2;
			if(e(h, m)) {
				r=m;
			}else {
				l=m;
			}
		}
		return l+1;

	}
	private boolean e(long h[], int t) {
		int s = lb(h,b*t);
		long cnt = 0;
		//long cnt2 = 0;
		for(int i=s; i<h.length; i++) {
			cnt += ((h[i]-b*t)+(a-b-1))/(a-b);
			//cnt2 += Math.ceil(h[i]-b*t)/(a-b);
			//if(cnt != cnt2) {
			//	System.out.println("i="+i+", cnt="+cnt+", cnt2="+cnt2);
			//}
		}
		if(cnt > t) {
			return false;
		}
		return true;
	}
	private int lb(long h[], long v) {
		int l=-1;
		int r=h.length;
		while(l+1<r) {
			int m=(l+r)/2;
			if(h[m]<v) {
				l=m;
			}else {
				r=m;
			}
		}
		return l+1;
	}


}


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

int main(){
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a), q(b), r(c);
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  rep(i,c) cin >> r[i];
  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  sort(r.rbegin(),r.rend());
  vector<ll> px(x), qy(y);
  rep(i,x) px[i] = p[i];
  rep(i,y) qy[i] = q[i];
  ll ans = 0;
  int cnta=0, cntb=0, cntc=0; 
  rep(i,x+y){
    if(px[cnta] >= qy[cntb] && px[cnta] >= r[cntc]){
      ans += px[cnta];
      cnta++;
    }
    else if(qy[cntb] >= px[cnta] && qy[cntb] >= r[cntc]){
      ans += qy[cntb];
      cntb++;
    }
    else {
      ans += r[cntc];
      cntc++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6876
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[13]={0,1,2,1,0,1,0,1,1,0,1,0,1};
	int n,m;
	cin>>n>>m;
	if(a[n]==a[m]) cout<<"Yes";
	else cout<<"No";
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> P;
 
int main(){
  int N;
  long long int a, ans=0;
  cin >> N;
  long long int A[N+1],B[N];
  for(int i=0; i<N+1; i++){
    cin >> a;
    A[i] = a;
  }
  for(int i=0; i<N; i++){
    cin >> a;
    B[i] = a;
  }
  for(int i=0; i<N+1; i++){
    if(i==0){
      if(A[i]<=B[i]){
        ans += A[i];
        B[i] -= A[i];
      }else{
        ans += B[i];
        B[i] = 0;
      }
    }else if(i==N){
      if(A[i]<=B[i-1]){
        ans += A[i];
      }else{
        ans += B[i-1];
      }
    }else{
      if(A[i]<=B[i-1]){
        ans += A[i];
      }else if(A[i]>B[i-1]&&A[i]<=B[i-1]+B[i]){
        ans += A[i];
        B[i] -= A[i]-B[i-1];
      }else{
        ans += B[i-1];
        ans += B[i];
        B[i] = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  int f(0);
  for(int i(0);i<b;i++){
    int m=a*i;
    if(m%b==c)f++;
  }
  if(f==0)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define DEBUG

#ifndef DEBUG 
#define fprintf (void)
#endif 

double absval(double x);

int main(void){

	double a,b,C;
	double s,l,c,h;
	
	scanf("%lf",&a);
	scanf("%lf",&b);
	scanf("%lf",&C);
	
	C=C*M_PI/180;
	
	s=a*b*sin(C)/2;
	c=sqrt(a*a+b*b-2*a*b*cos(C));
	l=a+b+c;
	h=2*s/a;
	
	printf("%lf\n%lf\n%lf\n",s,l,h);
	
	return 0;
}

Measured memory_bytes: 3124
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
//        sc.useDelimiter("\n");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        long n = Long.parseLong(sc.next());
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = a + b;
        long div = n / c;
        long rem = Math.min(n % c, a);
        long ans = a * div + rem;
        pw.println(ans);
        
        pw.flush();
    }
}

Measured memory_bytes: 23636
while True:
	N, x = map(int,input().split())
	if N == 0 and x == 0:
		break
	
	ctr = 0
	
	for i in range(1, N+1):
		for j in range(i+1, N+1):
			k = x - i -j
			if k <= j:
				break
			elif k <= N and j < k:
				ctr += 1
				#print("{} {} {}".format(i, j, k))
			
	print(ctr)

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

int main()
{
    int n;
    cin>>n;
    for (int k=1;k<=n;k++){
            int cnt=0;
    for (int i=1;i*i<=k;i++)
    {
        for (int j=1;j*j<=k;j++)
        {
            int x=i;
            int y=j;
            double c = (k-(x*x+y*y+x*y));
            c*=-1;
            int b = y+x;
            int z = max ( (-1*b+sqrt(b*b-4*c))/2 , (-1*b-sqrt(b*b-4*c))/2 );
            if ((x*x+y*y+z*z+x*z+x*y+y*z)==k&&z>0)
                cnt++;
        }
    }
    cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 3644
import numpy as np 

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

li = []
ls = []
pre = "X"
for i in range(len(s)):
    if pre!=s[i]:
        li.append(i)
        ls.append(s[i])
    pre=s[i]
# print(li)
# print(ls)

for _ in range(K*2+1):
    li.append(N)

maxv = 0
for i in range(len(ls)):
    if ls[i] == "0":
        maxv = max(maxv, li[i+K*2]-li[i])
    else:
        maxv = max(maxv, li[i+K*2+1]-li[i])

print(maxv)


Measured memory_bytes: 17416
#include <fstream>
#include <iostream>
#include<string>
 
using namespace std;
 
int main() {
	string s;
	cin >> s;
	bool flag1 = false;
	for (auto &i : s) {
		if (i == 'C' && !flag1) {
			flag1 = true;
		}
		if (flag1 &&i == 'F') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44


/*const int MOD = 998244353;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}*/

/*int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}*/

using namespace std;



int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int a, b;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> a >> b;

    if((a + b) % 2 == 0) {
        cout << (a + b) / 2;
    }
    else {
        cout << "IMPOSSIBLE";
    }

    return 0;
}


Measured memory_bytes: 892
# -*- coding: utf-8 -*-
# 整数の入力


def main():
    # a, b
    a, b = (map(int, input().split()))
    print(process(a, b))


def process(a, b):
    plus = a + b
    minus = a - b
    multi = a * b
    return max(max(plus, minus), multi)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int m=0,l;
char s[200005];
int main(){
    scanf("%s",s);
    l=strlen(s) ;
    if(s[0]=='0'){
    	puts("-1");
		return 0;
	}
    if(s[l-1]=='1'){
    	puts("-1");
		return 0;
	}
    for(int i=0;i<l-1;i++)
        if(s[i]!=s[l-i-2]){
    		puts("-1");
			return 0;
		}
    for(int i=0;i<l-1;i++){
        printf("%d %d\n",m+1,i+2);
        if(s[i]=='1')m=i+1;
    }
    return 0 ;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <string.h>

#define ll long long

ll min(ll a, ll b){
  if(a < b)
    return a;
  return b;
}

void solve(){
  char s[100007];
  scanf("%s", s);
  ll zero = 0, one = 0;
  for(ll i=0; i<strlen(s); ++i){
    if(s[i] == '1')
      ++one;
    else
      ++zero;
  }
  ll ans = min(zero, one);
  ans <<= 1;
  printf("%lld\n", ans);
}

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


Measured memory_bytes: 1784
#include <iostream>

using namespace std;

long long five(long long x) {
    return x * x * x * x * x;
}

int main() {
    long long X;
    cin >> X;

    for (long long i = 0; i < 120; ++i) {
        for (long long j = i; j < 120; ++j) {
            if (five(j) - five(i) == X) {
                cout << j << " " << i << endl;
                return 0;
            } else if (five(j) - five(-i) == X) {
                cout << j << " " << -i << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;
using ll = long long;
const int maxn = 2020, mod = 924844033;
int get(int a, int b) {
	return abs(a-b) + (a>b)*2;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	cout << min({get(a, b), get(a, -b)+1, get(-a, b)+1, get(-a, -b)+2});
}


Measured memory_bytes: 256
from sys import stdin
from collections import deque, defaultdict as ddic
from itertools import combinations, permutations, product
import bisect
import heapq


rs = lambda: stdin.readline().strip()
ri = lambda: int(rs())
rsl = lambda: stdin.readline().split()
rim = lambda: map(int, rsl())
ril = lambda: list(rim())

N = ri()
values = list(rim())
costs = list(rim())
maximum = 0
for i in range(len(values)):
    psum = values[i] - costs[i]
    if psum > 0:
        maximum += psum

print(maximum)

Measured memory_bytes: 3564
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#define REP(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define REPN(i,n) for(int(i)=1;(i)<(int)(n);(i)++)
#define _abs(x) ((x)>0?(x):-(x))
#define ll  long long 
using namespace std;   
int main()
{
    int x,a;
    cin>>x>>a;
    if(x<a)
    {
        cout<<"0"<<endl;
    }
    else
    {
        cout<<"10"<<endl;
    }
    //system("pause");
    return 0;
} 

Measured memory_bytes: 256
import sys
N, K = map(int, sys.stdin.readline().split())
d = []
A = []
for i in range(2 * K):
    if i % 2 == 0:
        d.append(int(input()))
    else:
        A.append(list(map(int, input().split())))
B = set(sum(A, []))
print(N - len(B))

Measured memory_bytes: 9388
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,t;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s>>t;
    rep(i,Size(s)){
        cout<<s[i];
        if(i==Size(t))continue;
        cout<<t[i];
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

//
//bool is_chokaku(int a, int b, int c) {
//	return (a*a + b * b == c * c);
//}
int num_t = 0;
int num_ei = 0;
int num_don = 0;
int num_cyokaku = 0;

//最大角の大きさで三角形を決める
// 0　鋭角　1 鈍角　２　直角
double yogen(int c, int b, int a) {

	return double(b * b + c * c - a * a) / double(2 * b*c);
}

void tri(int a, int b, int c) {
	double yo = yogen(a, b, c);

	if (abs(yo) < EPS) {
		num_cyokaku++;
	}
	else if (yo < 0) {
		num_don++;
	}
	else if (yo > 0) {
		num_ei++;
	}
}
int main() {

	vector<int> a(3);
	while (true)
	{
		cin >> a[0] >> a[1] >> a[2];
		sort(ALL(a), less<int>());
		if (a[2] < a[0] + a[1]) {
			num_t++;
			tri(a[0], a[1], a[2]);
		}
		else {
			cout << num_t << " " << num_cyokaku << " " << num_ei << " " << num_don << endl;
			break;
		}
	}


}	



Measured memory_bytes: 3140
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <bitset>
#include <queue>
#include <algorithm>
using namespace std;
 
int const MAX_N = 256 * 1024;
 
struct edge {
	int end_v;
	int dst;
	edge(){}
	edge(int end_v, int dst):end_v(end_v),dst(dst) {}
};

vector<edge> e[MAX_N], back_e[MAX_N];
int num, nnew[MAX_N], lst[MAX_N];
long long final_X[MAX_N];

void dfs(int v) {
	nnew[v]=1;
	for (int j=0; j<(int) e[v].size(); j++) {
		int i = e[v][j].end_v;
		if (nnew[i]==0) dfs(i);
		else if (nnew[i]==1) {
			cout<<"No";
			exit(0);
		}
	}
	lst[num]=v;
	num--;
	nnew[v]=2;
}

int const INT_INF = 1000000000;
long long mem_dst[MAX_N];

void dfs_2(int v, long long dst) {
	mem_dst[v] = dst;
	nnew[v] = 1;
	for (int j=0; j<(int) e[v].size(); j++) {
		int i = e[v][j].end_v;
		if (nnew[i] == 0)
			dfs_2(i, dst + e[v][j].dst);
		else if (nnew[i] == 1) {
			if (dst + e[v][j].dst != mem_dst[i]) {
				cout<<"No";
				exit(0);
			}
		}
	}
}

int main() {
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=0; i<m; i++) {
		int a,b,dst;
		scanf("%d%d%d",&a,&b,&dst);
		e[a].push_back(edge(b,dst));
		back_e[b].push_back(edge(a,dst));
	}

	num=n;
	for (int i=1; i<=n; i++)
		if (!nnew[i]) dfs(i);

	for (int i=1; i<=n; i++) {
		int v = lst[i];
		for (int j=0; j<(int) back_e[v].size(); j++) {
			int from_v = back_e[v][j].end_v;
			final_X[v] = max(final_X[v], final_X[from_v] + back_e[v][j].dst);
		}
	}
	for (int i=1; i<=n; i++)
		if (final_X[i] > INT_INF) {
			cout<<"No";
			exit(0);
		}

	for (int i=1; i<=n; i++) nnew[i] = 0;
	for (int i=1; i<=n; i++)
		if (!nnew[lst[i]])
			dfs_2(lst[i], 0);

	cout<<"Yes";
    return 0;
}  


Measured memory_bytes: 29696
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int x, y;
    cin >> x >> y;
    println(x + y / 2);
    return 0;
}

Measured memory_bytes: 3608
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    s=list(input())
    t=list(input())
#    print(t[0:-1])
    if t[0:-1]==s:
        print("Yes")
    else:
        print("No")






if __name__ == "__main__":

    main()

Measured memory_bytes: 68100
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    
    long long h, w;
    cin >> h >> w;
    
    long long ans = h*w;
    
    vector<long long> s(3);
    
    for (int i = 0; i < 2; i++){
        for (long long t = 1; t < h; t++){
            
            // 縦割りを試す
            s[0] = t * w;
            s[1] = (h-t)*(w/2);
            s[2] = h*w - s[0] - s[1];
            
            sort(s.begin(),s.end());
            ans = min (ans, s[2]-s[0]); // mmax - minと現在までの答えを比較せよ
            
            
            // 横割りを試す
            s[0] = t*w;
            s[1] = ((h-t)/2) * w;
            s[2] = h*w - s[0] - s[1];
            
            sort(s.begin(),s.end());
            ans = min(ans, s[2]-s[0]);
        }
        
        // チョコレートの回転を忘れない!!!
        swap(h,w);
    }
    
    cout << ans << endl;
    return 0;
}

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

int main()
{  
	long long M;
	cin >> M;

	vector<long long> x(M,0);
	for(long long i=0;i<M-1;i++){
		long long c;
		cin >> c;
		x[c-1]++;
	}

	for(long long i=0;i<M;i++){
		cout<<x[i] <<endl;
	
	}
	return 0;
}


Measured memory_bytes: 4788
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    String c1 = sc.next();
    String c2 = sc.next();
    String c3 = sc.next();

    String c11 = c1.substring(0,1);
    String c22 = c2.substring(1,2);
    String c33 = c3.substring(2,3);

    System.out.println(c11 + c22 + c33);

  }
}

Measured memory_bytes: 21204
// AGC 007 A
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define ll long long
using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    char A[H][W];
    REP(i,H){
        REP(k,W){
            cin >> A[i][k];}}
    int c = 0;
    REP(i,H){
        REP(k,W){
            if (A[i][k]=='#') c++;}}
    cout << (c==H+W-1?"Possible":"Impossible") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(s==u)
    {
        cout<<a-1<<" "<<b<<endl;
    }
    else
    {
        cout<<a<<" "<<b-1<<endl;
    }
     
    return 0;
}



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

int main() {
	int n;
	cin >> n;
	std::vector<int> v(n);
	for(int i=0;i<n;i++)cin >> v[i];
	
	vector<int> dp(n+1,0);
	dp[0] = 0;
	dp[1] = abs(v[0]-v[1]);
	for(int i=2;i<=n;i++)
	 dp[i] = min((dp[i-1] + abs(v[i]-v[i-1])),(dp[i-2] + abs(v[i]-v[i-2])));
	
	cout << dp[n-1];
	return 0;
}


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

int main(){
  int N;
  double x, sum;
  string S;
  
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> x >> S;
    if(S == "JPY"){
      sum +=x;
    }
    else{
      sum +=x*380000.0;
    }
  }
  
  cout << sum << endl;
}

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

int digit_sum(int n){
   if(n < 10)  return n;
   return digit_sum(n/10) + n%10;
}

int main(void){
   
    int N,A,B,sum = 0;
    cin >> N >> A >> B;
    
    for(int i=1;i<=N;i++){
        int k = digit_sum(i);
        if(A <= k && k <= B) sum += i;
    }
    
    cout << sum <<endl;
}


Measured memory_bytes: 3556
import sys

s=input()
s=list(s)

N=len(s)
m=int((N-1)/2)

kaibun=True
for i in range(m):
    if s[N-1-i]!=s[i] or s[i]!=s[m-i-1] or s[N-1-i]!=s[m+1+i]:
        kaibun=False
        break

if kaibun:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
        int x1,x2,x3,x4,x5;
        cin>>x1>>x2>>x3>>x4>>x5;
        if(x1==0) cout<<1<<endl;
        else if(x2==0) cout<<2<<endl;
        else if(x3==0) cout<<3<<endl;
        else if(x4==0) cout<<4<<endl;
        else cout<<5<<endl;
}

Measured memory_bytes: 3588
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val s = sc.next.toCharArray
    val N = s.length
    val ans = (N / 2) - s.count(_ == 'p')
    println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 27260
from collections import Counter
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
A = list(map(int, input().split()))

a = [0 for _ in range(N)]
a[0] = A[0]

for i in range(N-1):
    a[i+1] += a[i] + A[i+1]

ans = 0
# print(Counter(a))
for key, val in Counter(a).items():
    if key == 0:
        ans += val
    if val >= 2:
        ans += combinations_count(val, 2)

print(ans)

Measured memory_bytes: 41028
#include <iostream>

int main()
{
    int a,b,c,d,e;
    std::cin >> a >> b >> c >> d >> e;
    
    if(a==0){
        std::cout << "1" <<std::endl;
    }
    if(b==0){
        std::cout << "2" <<std::endl;
    }
    if(c==0 ){
        std::cout << "3" <<std::endl;
    }
    if(d==0 ){
        std::cout << "4" <<std::endl;
    }
    if(e==0 ){
        std::cout << "5" <<std::endl;
    }

}

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

#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";
#define int long long int 

int n,m ;
vector< pair< int , pair< int , int > > > orig ,dup ;
bool cmp( pair< int , pair< int , int > >a , pair< int , pair< int , int > >b)
{
	return ((a.first + a.second.first + a.second.second) > (b.first + b.second.first + b.second.second)) ; 
}
int solve( int x )
{
	int co[4],i;
	memset(co,-1,sizeof co) ;
	if( x & 1 )
		co[1] = 1 ;
	if( x & 2 )
		co[2] = 1 ;
	if( x & 4 )
		co[3] = 1 ;
	int answer = 0 ;
	for(i=0;i<n;i++)
	{
		orig[i].first *= co[1] ;
		orig[i].second.first *= co[2] ;
		orig[i].second.second *= co[3] ;
	}
	sort( orig.begin() , orig.end() , cmp ) ; 
	
	int  tutu[4] = {0} ;
	for(i=0;i<m ;i++)
	{
		tutu[1] += orig[i].first ; 
		tutu[2] += orig[i].second.first ;
		tutu[3] += orig[i].second.second ;
	}
	return ( abs( tutu[1] ) + abs( tutu[2] ) + abs( tutu[3] ) );

}

main()
{
	int i,j ;
	cin >> n >> m ;
	for( i = 1 ; i <= n ;i++)
	{
		int xx,yy,zz ;
		cin >> xx >> yy >> zz ;
		orig.pb( { xx,{yy,zz} } ) ;
		dup.pb( { xx,{yy,zz} }  ) ;
	}
	int answer = 0 ;
	for(i=0;i<8;i++)
	{
		for(j=0;j<n;j++)
			orig[j] = { dup[j].first, { dup[j].second.first,dup[j].second.second } } ;
		answer = max( answer , solve( i ) ) ;	
	}
	

	cout<<answer<<endl ;
	return 0;
}

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

import sys


sys.setrecursionlimit(10**6)


def main():
    n, q = map(int, sys.stdin.readline().split())

    tree = [[] for x in range(n + 1)]
    data = [0 for x in range(n + 1)]

    for _ in range(n - 1):
        a, b = map(int, sys.stdin.readline().split())
        tree[a].append(b)
        tree[b].append(a)

    for _ in range(q):
        p, x = map(int, sys.stdin.readline().split())
        data[p] += x

    def dfs(p, p2, x):
        data[p] += x
        for p3 in tree[p]:
            if p3 == p2:
                continue
            dfs(p3, p, data[p])

    dfs(1, 0, 0)

    print(" ".join([str(x) for x in data[1:]]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 284152
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
string s;

signed main() {
	cin >> n >> s;
	
	int i, cnt = 0;
	for (i = 0; i < n; i++) {
		if (s[i] == 'R') cnt++;
		else cnt--;
	}
	if (cnt > 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int, input().split())
ab=[list(map(int, input().split())) for _ in range(m)]
ab.sort()
xy=[[ab[0][0], ab[0][1]]]
for i in range(1,m):
    if ab[i][0]<xy[-1][1]:
        xy[-1][0],xy[-1][1]=ab[i][0],min(xy[-1][1],ab[i][1])
    else:
        xy.append([ab[i][0], ab[i][1]])
print(len(xy))

Measured memory_bytes: 27932
#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {
	int n,ans = 0;
	cin >> n ;
	vector<vector<int>> a(n,vector<int>(2));

	for (int i = 0; i < n; i++) {
		cin >> a[i][0];
		a[i][1] = i + 1;
	}

	sort(a.begin(), a.end());

	for (int i = 0; i < n; i++) {
		cout << a[i][1]<<" ";
	}

	return 0;
}

Measured memory_bytes: 6272
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=Integer.parseInt(sc.next());
int y=Integer.parseInt(sc.next());
boolean f=false;
for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
    if(10000*i+5000*j+1000*(n-j-i)==y){
    System.out.println(i+" "+j+" "+(n-i-j));
    f=true;
    break;
    }
    }
    if(f)break;
}
if(!f)System.out.println("-1 -1 -1");
}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
 
int main(){
  char w[10], t[1000], c = 0, i;
  scanf("%s", w);
  while(scanf("%s", t) && strcmp(t, "END_OF_TEXT") != 0){
    for(i = 0;i < strlen(t);i++) t[i] = 'A' <= t[i] && 'Z' >= t[i] ? t[i] - 'A' + 'a' : t[i];
    if(strcmp(t, w) == 0) c++;
  }
  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 2088
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n;
	int tmp;
	vector<int> a;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&tmp);
		a.push_back(tmp);
	}
	int min = *min_element(a.begin(), a.end());
	int max = *max_element(a.begin(), a.end());
	int ans = 2147483647;
	for(int i=min;i<=max;i++){
		int cost=0;
		for(int k=0;k<n;k++){
			cost+=((a[k]-i)*(a[k]-i));
		}
		if(cost<ans)ans=cost;
	}
	cout<<ans<<endl;
}

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


int main() {
   int n,m;
   cin>>n>>m;
   int h[n+1];
   for(int i=1;i<=n;i++) cin>>h[i];
   int vis[n+1]={0};
   int x,y;
   for(int i=0;i<m;i++){
   	cin>>x>>y;
   	if(h[x]<=h[y]) {
	   vis[x]=-1;}
   	if(h[y]<=h[x]){
	   vis[y]=-1;}
   }
   int c=0;
   for(int i=1;i<n+1;i++){
   	if(vis[i]==0) 
	   c++;
   }
   cout<<c;
}

Measured memory_bytes: 4372
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val D = ni()
    val ans = D match {
      case 22 => "Christmas Eve Eve Eve"
      case 23 => "Christmas Eve Eve"
      case 24 => "Christmas Eve"
      case 25 => "Christmas"
    }

    out.println(ans)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Int](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

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

const int inf = 1001001000;

int n, m;
int c[1010];
int d[1010];

int ei133333[1010][1010];

int beet(int i=0, int j=0){
  if (i == n) {
    return 0;
  }
  if (j == m) {
    return inf;
  }

  int &latte = ei133333[i][j];
  if (~latte) return latte;
  latte = min(beet(i, j + 1), beet(i + 1, j + 1) + d[i] * c[j]);

  return latte;
}

int main() {
  memset(ei133333, -1, sizeof(ei133333));
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> c[i];
  }

  //n++;
  cout << beet() << endl;
}

Measured memory_bytes: 7116
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;

public class Main {
	static int[] honsuu = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	static int[][] bou = {
			{1, 2},
			{7, 3},
			{4, 4},
			{5, 5},
			{3, 5},
			{2, 5},
			{9, 6},
			{6, 6},
			{8, 7}
			};

	public static void main(String[] args) throws Exception {
		// 1桁当たりの本数、その本数を使う桁数
		TreeMap<Integer, Integer> honsuuMap = new TreeMap<Integer, Integer>();

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Set<Integer> aSet = new HashSet<Integer>();
		for (int i = 0; i < m; i++) {
			Integer ai = sc.nextInt();
			aSet.add(ai);
			honsuuMap.put(honsuu[ai], 0);
		}
		sc.close();

		// 各桁の数字配列（使用本数の少ない順）
		Integer[] array = honsuuMap.keySet().toArray(new Integer[0]);

		editHonsuuMap(n, array, 0, honsuuMap);
//		for (Entry<Integer, Integer> entry : honsuuMap.entrySet()) {
//			System.out.print(entry.getKey() + " " + entry.getValue());
//			System.out.println();
//		}

		int totalKetasuu = 0;
		for (int val : honsuuMap.values()) {
			totalKetasuu += val;
		}

		int[] ketasuuArray = new int[10];
		editKetasuuArray(n, totalKetasuu, aSet, 9, honsuuMap, ketasuuArray);
//		for (int val : ketasuuArray) {
//			System.out.print(val + " ");
//		}
//		System.out.println();

		for (int i = 9; i >= 1; i--) {
			for (int j = 0; j < ketasuuArray[i]; j++) {
				System.out.print(i);
			}
		}
		System.out.println();
	}

	/**
	 * 合計桁数が最大になるように本数の内訳を設定
	 */
	private static boolean editHonsuuMap(
			int n, Integer[] array, int startIdx, TreeMap<Integer, Integer> honsuuMap) {
		for (int i = startIdx; i < array.length; i++) {
			if (n % array[i] == 0) {
				honsuuMap.put(array[i], n / array[i]);
				return true;
			}

			for (int j = (n / array[i]) - 1; j >= 0; j--) {
				int tempN = n - (array[i] * j);
				boolean flg = editHonsuuMap(tempN, array, i + 1, honsuuMap);
				if (flg) {
					honsuuMap.put(array[i], j);
					return true;
				}
			}
		}
		return false;
	}

	/**
	 * 決まった合計桁数の中で、より大きい値の桁数が最多になるように本数の内訳を設定
	 */
	private static boolean editKetasuuArray(
			int n, int totalKetasuu, Set<Integer> aSet, int startVal, TreeMap<Integer, Integer> honsuuMap,
			int[] ketasuuArray) {
		for (int i = startVal; i >= 0; i--) {
			if (!aSet.contains(i)) {
				continue;
			}
			if (honsuu[i] * totalKetasuu == n) {
				ketasuuArray[i] += totalKetasuu;
				return true;
			}

			int zanHonsuu = n - honsuu[i];
			int zanKetasuu = totalKetasuu - 1;
			if (zanHonsuu < 0 || zanKetasuu < 0
					|| zanKetasuu * honsuuMap.lastKey() < zanHonsuu
					|| zanHonsuu < zanKetasuu * honsuuMap.firstKey()) {
				continue;
			}

			boolean flg = editKetasuuArray(zanHonsuu, zanKetasuu, aSet, i, honsuuMap, ketasuuArray);
			if (flg) {
				ketasuuArray[i]++;
				return true;
			}
		}
		return false;
	}
}


Measured memory_bytes: 24532