akhauriyash/Code-Regression huggingface dataset:
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <stack>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

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

	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	ll ans = 0;

	for (ll i = 0; i < 60; i++){
		ll cntzero = 0;
		ll cntone = 0;

		for (int j = 0; j < n; j++){
			if ((a[j] >> i) & 1 == 1){
				cntone++;
			}
			else {
				cntzero++;
			}
		}

		ll tmp = ((cntone * cntzero) % MOD) * ((ll)pow(2, i) % MOD);
		tmp %= MOD;

		ans += tmp;
		ans %= MOD;

	}

	cout << ans << endl;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll mod = 1000000007;

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

    ll n, m;
    cin >> n >> m;

    vll a(m);
    vll ng(n + 1);
    REP(i, m){
        cin >> a[i];
        ng[a[i]]++;
    }
    REP(i, m - 1){
        if(a[i + 1] - a[i] == 1){
            cout << 0 << endl;
            return 0;
        }
    }
    vll dp(n + 1);
    dp[0] = 1;
    REP(i, n){
        if(ng[i]) continue;
        if(!ng[i + 1]){
            dp[i + 1] += dp[i];
            dp[i + 1] %= mod;
        }
        if(i + 2 <= n && !ng[i + 2]){
            dp[i + 2] += dp[i];
            dp[i + 2] %= mod;
        }
    }
    ll res = dp[n] % mod;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define motherfucker  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);
inline void yes(){cout<<"Yes\n";}
inline void no(){ cout<<"No\n";}
inline void notposs(){cout<<-1<<endl;}
bool tests = 0;


void solve(){
	int n;cin>>n;
	vi arr(n);
	for0(i, n) cin>>arr[i];
	ll ans = INT_MAX;
	for1(i, 100){
		ll temp = 0;
		for0(j, n){
			temp += (arr[j]-i)*(arr[j]-i);
		}
		ans = min(temp, ans);
	}
	cout<<ans<<endl;
}
 
int main(){
	
	motherfucker
	ll t = 1;
	if(tests) cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	llong a,b,c; cin >> a >> b >> c;
	if(c > (a+b)+1){
		cout << (b+a+b+1) << endl;
	}
	else{
		cout << (b+c) << endl;
	}


	return 0;
}



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

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

	sort(a,a+N,greater<int>());

	int totem=a[0],count=1;
	for (int i = 1; i < N; ++i){
		if(totem>a[i]){
			totem=a[i];
			count++;
		}
	}

	cout<<count<<endl;

}


Measured memory_bytes: 256
N = int(input())
s_list = [input() for _ in range(N)]
dic = {ord("a")+i: i for i in range(26)}
counter = {}
for s in s_list:
    str_cnt = [0]*26
    for char in s:
        str_cnt[dic[ord(char)]] += 1
    str_cnt = ''.join([str(i) for i in str_cnt])
    if (str_cnt in counter):
        counter[str_cnt] += 1
    else:
        counter[str_cnt] = 1
cnt = 0
for k, v in counter.items():
    if (v >= 2):
        cnt += v*(v-1)//2
print(cnt)            


Measured memory_bytes: 80344
MOD = 1000000007;
 
s = [int(x) if x!="?" else -1 for x in input()]
#print(s)
n=len(s)
 
r=[0]*13
 
c=s[0]
if (c!=-1):
    r[c]=1
else:
    for i in range(10):r[i]=1
for i in range(1,n):
    dp=[0]*26
    for j in range(13):dp[j*10%13]+=(r[j]%MOD)
    dp[13:26]=dp[0:13]
    c=s[i]
    r=[0]*13
    if (c==-1):
        w=sum(dp[4:14])
        for j in range(13):
            r[j]+=w
            w=w+dp[j+1]-dp[4+j]
    else:
        for j in range(13):
            r[j]+=dp[13-c+j]
print (r[5]%MOD)

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

using namespace std;

#define int long long

const int INF = (1<<30);

int solve2(vector<int>& L){
	int res = INF;
	int N = L.size();
	int NUM = 101;
	
	sort(L.begin(), L.end(), greater<int>());
	
	int con = 0;
	
	
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			for(int l = j+1; l <= N; l++){
				int sum1 = 0, sum2 = 0;
				int MAX = NUM*(N-l+3);
				int sum = 0, con1 = 0, con2 = 0, con3 = 0;
				vector<int> dp(MAX);
				dp[0] = true;
				
				
				for(int k = 0; k < N; k++){
					if(k <= i) sum1 += L[k], con1++;
					else if(k <= j) sum2 += L[k], con2++;
					else if(k <= l) sum1 += L[k], con1++;
					else if(k == l+1) sum2 += L[k], con2++;
					else {
						for(int m = MAX-1; m >= 0; m--){
							if(dp[m]) dp[m + L[k]] = true;
						}
						sum += L[k];
						con3++;
					}
				}
				
				for(int m = MAX-1, flag = false; m >= 0; m--){
					if(dp[m]){
						if(!m){
							if(con1 >= 3 && con2+con3 >= 3 &&L[0] < (sum1+m) - L[0] && L[i+1] < (sum2+sum-m) - L[i+1]){
								res = min(res, abs((sum1+m)-(sum2+sum-m)));
							}
						} else if(flag){
							if(L[0] < (sum1+m) - L[0] && L[i+1] < (sum2+sum-m) - L[i+1]){
								res = min(res, abs((sum1+m)-(sum2+sum-m)));
							}
						} else {
							sum = m;
							flag = true;
							if(con1+con3 >= 3 && con2 >= 3 &&L[0] < (sum1+m) - L[0] && L[i+1] < (sum2+sum-m) - L[i+1]){
								res = min(res, abs((sum1+m)-(sum2+sum-m)));
							}
						}
					}
				}
			}
		}
	}
	
	return res==INF?-1:res;
}

signed main(){
	int N;
	vector<int> l;
	
	cin>>N;
	
	l.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>l[i];
	}

	cout<<solve2(l)<<endl;
	
}


Measured memory_bytes: 3188
#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>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    
int main(){
    int n;
    cin >> n;
    ll mae, ato;
    ll ans = 0;
    cin >> mae;
    rep(i,n-1){
        cin >> ato;
        if(mae>ato){
            ll tmp;
            tmp = mae - ato;
            ans += tmp;
            mae = ato + tmp;
            continue;
        }
        mae = ato;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b = LI()
    for i in range(1000000):
        if int(i*0.08) == a and int(i*0.10) == b:
            print(i)
            return
    print(-1)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39280
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	int N, H, W;
	vector<int> A, B;
	void ans() {
		cin >> N >> H >> W;
		A.resize(N);
		B.resize(N);
		int res = 0;
		REP(i, N) {
			cin >> A[i] >> B[i];
			if (A[i] >= H && B[i] >= W) res++;
		}
		cout << res << "\n";
	}
};

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

	question q;
	q.ans();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <limits.h>

using namespace std;

int map[100][100];
int dx[4] = { 1, -1, 0, 0 };
int dy[4] = { 0, 0, 1, -1 };
int w, h, out;

void rec(int x, int y, int num)
{
	int nx, ny;
	if( num >= out )
		return;
	
	for(int i = 0 ; i <= 3 ; i++)
	{
		nx = x + dx[i];
		ny = y + dy[i];
		if( map[ny][nx] == 1 )
			continue;
		if( nx < 0 || nx >= w )
			continue;
		if( ny < 0 || ny >= h )
			continue;
		
		
		while(1)
		{

			if( map[ny][nx] == 3 )
			{
					out = num;
					return;
			}
			
			nx += dx[i];
			ny += dy[i];
			
			if( nx < 0 || nx >= w || ny < 0 || ny >= h)
				break;
			
			if( map[ny][nx] == 1 )
			{
				map[ny][nx] = 0;
				rec(nx-dx[i], ny-dy[i], num+1);
				map[ny][nx] = 1;
				break;
			}
			
		}
		
	}
	
}



int main()
{
	while( cin >> w >> h, (w||h))
	{
		int sx,sy;
		
		for( int j = 0; j < h; j++)
		{
			for( int i = 0; i < w; i++)
			{
				cin >> map[j][i];
				
				if(  map[j][i] == 2 )
				{
					sx = i;
					sy = j;
					
				}
			}
		}
		
		out = 11;
		rec( sx, sy, 1);
		
		if( out > 10)
			out = -1;

		cout << out << endl;
	}
	
	return 0;
}

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

int main() {
  int n; cin >> n;
  vector<ll> a(n); rep(i, n) cin >> a[i];
  ll ans = 1;
  rep(i, n) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i, n) {
    if (ans > 1000000000000000000 / a[i]) {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  if (ans > 1000000000000000000)
    cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll n;
  cin >> n;
  ll sum = n*(n+1)/2;
  print(sum-n);
  return 0;
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int main(){
    int n; cin >> n;
    vector<vector<int>> lis(n, vector<int>(2, 0));
    REP(i, 0, n){cin >> lis[i][0]; lis[i][1] = i+1;}
    sort(ALL(lis), [](auto &x, auto &y){return x[0] < y[0];});
    REP(i, 0, n){cout << lis[i][1] << " ";}
}

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

int main(int , char **)
{
	ll A,B,C,D,E,F;
	ll maxS=0 , maxW=0;
	cin >> A >> B >> C >> D >> E >> F;
	A*=100;
	B*=100;
	long double maxSW = -1;
	for(int ia=0; ia*A<=F; ++ia){
		for(int ib=0; ia*A + ib*B<=F; ++ib){
			int water = ia*A + ib*B;
			if (water == 0){continue;}

			for(int ic=0; water+ic*C <=F; ++ic){
				for(int id=0; water+ ic*C + id*D <= F; ++id){
					int sugar = ic*C + id*D;

					if (sugar*100 <= (water*E)){
						long double sw = 100.0*sugar/(sugar+water);
						if ( maxSW  < sw ){
							maxSW = sw;
							maxS = sugar;
							maxW = water;
						}
					}
				}
			}
		}
	}
	printf("%ld %ld\n",maxW+maxS,maxS);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>

int main()
{
	unsigned int N;
	std::cin >> N;

	std::string tmp;
	std::set<std::string> items;

	while (N--) {
		std::cin >> tmp;
		items.insert(tmp);
	}

	printf("%u", items.size());

	return 0;
}

Measured memory_bytes: 19324
n,t=map(int,input().split())
p=list(map(int,input().split()))
a=0
for i in range(1,n):
    if p[i-1]+t<p[i]:
        a+=t
        s=p[i] 
    else:
        a+=p[i]-p[i-1]
print(a+t)

Measured memory_bytes: 25200
#include <stdio.h>

int main(){
    int i, j, k;
    int n, x, s;
    
    while(scanf("%d %d", &n, &x), n > 0){
        s = 0;
        
        for(i = 1; i <= n; ++i){
            for(j = i + 1; j <= n; ++j){
                for(k = j + 1; k <= n; ++k){
                    if(i + j + k == x){
                        ++s;
                    }
                }
            }
        }
        
        printf("%d\n", s);
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  ll n, T; cin >> n >> T;
  vector<ll> t(n); rep(i, n) cin >> t[i];
  ll sum = 0;
  for (int i = 1; i < n; i++) {
    sum += min(t[i] - t[i - 1], T);
  }
  outl(sum + T);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    bool flag = false;
    for (int i = 1; i < 10 && !flag; i++) {
        for (int j = i; j < 10; j++) {
            if (i*j == n) {
                cout << "Yes" << E;
                flag = true;
                break;
            }
        }
    }
    if (!flag) cout << "No" << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		PriorityQueue<Record> queue = new PriorityQueue<>();
		int last = 0;
		for (int i = 0; i < n; i++) {
		    Record r = new Record(sc.nextInt() - 1, sc.nextInt(), sc.nextInt());
		    last = Math.max(last, r.end);
		    queue.add(r);
		}
		int[] imos = new int[last + 1];
		Record prev = queue.poll();
		while (queue.size() > 0) {
		    Record x = queue.poll();
		    if (prev.channel == x.channel && prev.end >= x.start) {
		        prev.end = x.end;
		    } else {
		        imos[prev.start]++;
		        imos[prev.end]--;
		        prev = x;
		    }
		}
        imos[prev.start]++;
        imos[prev.end]--;
        int max = imos[0];
        for (int i = 1; i < last; i++) {
            imos[i] += imos[i - 1];
            max = Math.max(max, imos[i]);
        }
       System.out.println(max);
   }
   
   static class Record implements Comparable<Record> {
       int start;
       int end;
       int channel;
       
       public Record(int start, int end, int channel) {
           this.start = start;
           this.end = end;
           this.channel = channel;
       }
       
       public int compareTo(Record another) {
           if (channel == another.channel) {
               return start - another.start;
           } else {
               return channel - another.channel;
           }
       }
   }
}




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

#define int long long int
#define main signed main()
#define bye return 0

#define rep(i, n) for (int i = 0; i < (n); i++)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define sum(v) accumulate(all(v), 0)
#define cinv(v, n) rep(i, n) cin >> v[i]
#define prec(n) fixed << setprecision(n)
#define stlice(s, l) substr(s, s + l + 1)
#define odd(n) ((n) % 2)
#define even(n) (!((n) % 2))

#define INF 1e9
#define MOD (1e9 + 7)

#define pb push_back
#define mt make_tuple
#define fi first
#define se second
#define str string
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<str>

using namespace std;

main {
  int n;
  str s, t;
  cin >> n >> s >> t;
  rep(i, n) {
    str sd = s.stlice(i, n - 1);
    str td = t.stlice(0, n - 1 - i);
    if (sd == td) {
      cout << n + i << endl;
      bye;
    }
  }
  cout << n * 2 << endl;
  bye;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	std::vector<int> x(3), y(3);
	for(int i = 0; i < 3; i++) scanf("%d%d", &x[i], &y[i]);
	
	std::vector<double> latte;
	for(int i = 0; i < 3; i++) {
		double X = x[i] - x[(i + 1) % 3];
		double Y = y[i] - y[(i + 1) % 3];
		latte.push_back(sqrt(X * X + Y * Y));
	}
	sort(begin(latte), end(latte)); reverse(begin(latte), end(latte));

	double s = (latte[0] + latte[1] + latte[2]) / 2;
	double S = sqrt(s * (s - latte[0]) * (s - latte[1]) * (s - latte[2]));
	double R = 2 * S / (s * 2);
	double ans = latte[0] / (2 + latte[0] / R);
	
	printf("%.12lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
signed main(){
    int H,W;
    cin >> H >> W;
    int c[10][10],A[H][W];
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            cin >> c[i][j];
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> A[i][j];
        }
    }
    for(int k=0;k<=9;k++){
        for(int i=0;i<=9;i++){
            for(int j=0;j<=9;j++){
                if(c[i][j] > c[i][k] + c[k][j]){
                    c[i][j] = c[i][k] + c[k][j];
                }
            }
        }
    }
    int ans = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(A[i][j]==-1 || A[i][j]==1){
            }else{
                ans = ans + c[A[i][j]][1] ;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll n; cin>>n;
    vector<ll> s(10050,0);
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                ll x = i*i + j*j + k*k + i*j + j*k + k*i;
                if(x <= n) s[x]++;
            }
        }
    }
    rep(i,n) cout<<s[i+1]<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
     long long n;
     cin>>n;
     vector<int>v(20000+3,0);
     int c=0;
     /*for(int i=1;i<=20;i++)
     {
         int k=pow(i,2)*6;
         v[k]=1;
     }*/
     for(int x=1;x<=100;x++)
     {
         for(int y=1;y<=100;y++)
         {
             for(int z=1;z<=100;z++)
             {
                    int k=pow(x,2)+pow(y,2)+pow(z,2)+x*y+y*z+z*x;
                     if(k<10050)
                        v[k]++;
             }
         }
     }
     for(int i=1;i<=n;i++)
        cout<<v[i]<<endl;
}


Measured memory_bytes: 3676
#! usr/bin/perl

use strict;
use warnings;

chomp(my $N = <STDIN>);
chomp(my $line = <STDIN>);
my @cards = split ' ',$line;

my $sum = 0;
my $abssum = 0;
foreach my $i (0..$N-1) {
    $sum += $cards[$i];
    $abssum += abs($cards[$i]);
}

my $result = $abssum;
my $sunuku = 0;
foreach my $i (0..$N-2) {
    $sunuku += $cards[$i];
    my $kuma = $sum - $sunuku;
    my $try = abs($sunuku - $kuma);
    if ($try < $result) { $result = $try; } 
}

print "$result\n";

Measured memory_bytes: 33444
#include<bits/stdc++.h>
using namespace std;
int main(){

  int h,w;
  
  cin>>h>>w;
  
  char mp[52][52];

 
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>mp[i][j];
    }
  }


  int judge=0;
  
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(mp[i][j]=='#'){
	if(i==1){
	  if(mp[i+1][j]=='.'&&mp[i][j+1]=='.'&&mp[i][j-1]=='.'){
	    judge=1;
	  }
	}else if(i==h){
	  if(mp[i-1][j]=='.'&&mp[i][j+1]=='.'&&mp[i][j-1]=='.'){
	    judge=1;
	  }
	}else if(j==1){
	  if(mp[i+1][j]=='.'&&mp[i-1][j]=='.'&&mp[i][j+1]=='.'){
	    judge=1;
	  }
	}else if(j==w){
	  if(mp[i+1][j]=='.'&&mp[i-1][j]=='.'&&mp[i][j-1]=='.'){
	    judge=1;
	  }
	}
	else{
	  if(mp[i+1][j]=='.'&&mp[i-1][j]=='.'&&mp[i][j+1]=='.'&&mp[i][j-1]=='.'){
	    judge=1;
	  }
	}
      }
    }
  }
  
  if(judge){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(void){
    int n,m,ans=0;string s[100],t[100];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>t[i];
    }
    
    for(int i=0;i<n;i++){
        int an=0;
        string a=s[i];
        for(int j=i;j<n;j++){
            if(a==s[j])an++;
        }
        for(int k=0;k<m;k++){
            if(a==t[k])an--;
        }
        ans=max(ans,an);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from operator import itemgetter
N,M = map(int,readline().split())
m = map(int,read().split())
AB = zip(m,m)
AB = [(a,b) for a,b in AB]
AB.sort(key = itemgetter(1))
INF = 10 ** 18
prev_cut = -INF
cnt = 0
for a,b in AB:
    if a<=prev_cut:
        continue
    cnt += 1
    prev_cut = b-1
print(cnt)

Measured memory_bytes: 26744
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int a;
int b;
int c;
cin >> a >> b >> c;
int i = 3;
i = i - (a==b);
i = i - (b==c);
i = i - (c==a);
if(i == 0){
  i = 1;}
  
cout << i;
return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $h, $n);
$as = explode(' ', trim(fgets(STDIN)));

$sum = 0;
foreach ($as as $a) {
  $sum += $a;
}

if ($h <= $sum) {
  echo 'Yes';
} else {
  echo 'No';
}


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

int main()
{
  int n;
  while (cin >> n) {
    for (int t = 0; t < n; ++t) {
      string s;
      cin >> s;
      int maxN = atoi(s.c_str()), minN = atoi(s.c_str());
      sort(s.begin(), s.end());
      do {
	int tmp = atoi(s.c_str());
	if (maxN < tmp)
	  maxN = tmp;
	if (minN > tmp)
	  minN = tmp;
      } while (next_permutation(s.begin(), s.end()));
      cout << maxN - minN << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main() {
	int n, q, t;
	string name;
	queue<pair<string, int> > Q;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> name >> t;
		Q.push(make_pair(name, t));
	}
	pair<string, int> u;
	int elaps = 0, a;
	while (!Q.empty()) {
		u = Q.front(); Q.pop();
		a = min(u.second, q);
		u.second -= a;
		elaps += a;
		if (u.second > 0) {
			Q.push(u);
		}
		else {
			cout << u.first << " " << elaps << endl;
		}
	}
}


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

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n+1);
	REP(i,n) cin >> a[i];
	map<ll,ll> b;
	map<ll,ll> c;
	REP(i,n){
		b[a[i] + i]++;
		c[i - a[i]]++;
	}
	ll ans = 0;
	for(auto p: b){
		ans += p.second*c[p.first];
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 39076
h = {'a' => [], 'b' => [], 'c' => []}
h['a'] = gets.chomp.split(//)
h['b'] = gets.chomp.split(//)
h['c'] = gets.chomp.split(//)

card = 'a'
while h[card][0] != nil
    card = h[card].shift
end
puts card.upcase

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	n, _ := sc.NextInt()
	a, _ := sc.NextInts(n)
	fmt.Println(solve(n, a))
}

func solve(n int, a []int) (ans int) {
	max := Max(a...)
	divisorCount := make([]int, max+1)

	for _, ai := range a {
		for j := ai; j <= max; j += ai {
			divisorCount[j]++
		}
	}

	for _, ai := range a {
		if divisorCount[ai] == 1 {
			ans++
		}
	}

	return ans
}

// Max returns max value of inputs
func Max(a ...int) (max int) {
	for i, ai := range a {
		if i == 0 || ai > max {
			max = ai
		}
	}
	return max
}

// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}

// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}

// NextInt reads a integer from io stream.
func (sc *Scanner) NextInt() (int, error) {
	if !sc.Scan() {
		return -1, errors.New("failed to scan")
	}
	return strconv.Atoi(sc.Text())
}

// NextInts reads n integers from io stream.
func (sc *Scanner) NextInts(n int) (arr []int, e error) {
	arr = make([]int, n)
	for i := 0; i < n; i++ {
		v, e := sc.NextInt()
		if e != nil {
			return nil, e
		}
		arr[i] = v
	}
	return arr, nil
}


Measured memory_bytes: 13116
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();

		String q_str = sc.nextLine();
		int q = Integer.parseInt(q_str);

		String[] com = new String[q];

		for (int i = 0; i < q; i++) {
			com[i] = sc.nextLine();
		}

		for (int i = 0; i < q; i++) {
			String[] command = com[i].split(" ");

			int a = Integer.parseInt(command[1]);
			int b = Integer.parseInt(command[2]);

			if (command[0].equals("print")) {
				System.out.println(str.substring(a, b + 1));
			} else if (command[0].equals("reverse")) {
				String X = str.substring(0, a);
				String Y = str.substring(b + 1);

				StringBuilder s = new StringBuilder(str.substring(a, b + 1));
				s = s.reverse();

				str = X + s.toString() + Y;
			} else if (command[0].equals("replace")) {
				String X = str.substring(0, a);
				String Y = str.substring(b + 1);

				str = X + command[3] + Y;
			}
		}

	}

}

Measured memory_bytes: 29124
#include <stdio.h>

int main() {
    int i,j,h,w;
    while (1){
        scanf("%d%d",&h,&w);
        if((h+w)==0) break;
        for(i=1;i<=h;i++){
            for(j=1;j<=w;j++){
                if(((i+j)%2)==0){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
    
}


Measured memory_bytes: 2104
#include <cstdio>

int n;
inline int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int main() {
    int i, x, ans;

    scanf("%d", &n);
    scanf("%d", &ans);
    n--;
    while (n) {
        scanf("%d", &x);
        ans = gcd(ans, x);
        n--;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
// #include <prettyprint.hpp>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
static const ll max_n = 200010;
static const ll mod = 1000000007;
static const ll max_value = 100000000000100;
static const ll max_d = 10000000000;


vector<vector<ll>> edge_list(max_n);
vector<pair<ll, ll>> distance_table;

void dijkstra(ll st){
    priority_queue<pair<ll, pair<ll,ll>>, vector<pair<ll, pair<ll,ll>>>, greater<pair<ll, pair<ll,ll>>>> PQ;

    fill(distance_table.begin(), distance_table.end(), make_pair(max_d, -1));
    distance_table[st] = make_pair(0, -1);
    for(auto &p:edge_list[st]){
        // distance_table[p.first] = p.second.first;
        PQ.push(make_pair(1, make_pair(p, st)));
    }

    


    while(!PQ.empty()){
        auto u = PQ.top(); PQ.pop();
        // cout << " u  = " << u.first << ", " << u.second.first << "p="<<u.second.second <<endl;
        if(u.first>distance_table[u.second.first].first){
            // cout << "continue, distance table = " << distance_table[u.second.first].first <<endl;
            continue;
        }
        distance_table[u.second.first] = make_pair(u.first, u.second.second);
        for(auto &p:edge_list[u.second.first]){
            // distance_table[p.first] = p.second.first;
            ll new_cost = 1 + u.first;
            if(new_cost < distance_table[p].first){
                // cout << "push to queue, new cost = " << new_cost << " p=" << p <<endl;
                distance_table[p] = make_pair(new_cost, u.second.first);
                PQ.push(make_pair(new_cost, make_pair(p, u.second.first)));
            }

        }

        
    }



}

void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    ll N, M, a, b;
    sll(N);
    sll(M);
    distance_table.resize(N);
    rep(i,M){
        sll(a);
        sll(b);
        -- a;
        -- b;
        edge_list[a].emplace_back(b);
        edge_list[b].emplace_back(a);
    }

    dijkstra(0);
    
    bool is_ok = true;
    rep(i,N){
        if(distance_table[i].first == max_d){
            is_ok = false;
            break;
        }
    }

    if(is_ok){
        printf("Yes\n");
        for(ll i=1;i<N;i++){
            printf("%lld\n", distance_table[i].second+1);
        }
    }else{
        printf("No\n");
    }
    // cout << junkan<<endl;

    // ll index = (K % junkan.size());
    // printf("%lld\n", junkan[index]+1);
    

    // printf("%lld\n", ans);


    // cout<<fixed<<setprecision(10)<<num<<endl;
    // cout << num << endl;

}

int main(){
    Main();

    return 0;

}

Measured memory_bytes: 18592
#include <iostream>
#include<cstdio>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;

int main()
{
    int y,m,d;
    scanf("%d/%d/%d",&y,&m,&d);
    if(m>4)
        printf("TBD\n");
    else
        printf("Heisei\n");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define REP(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1001001001;
const double EPS = 1e-10;


template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
  return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
  os<<'[';
  rep(i,a.size()) os<<(i?" ":"")<<a[i];
  return os<<']';
}

int main() {
  for (int n; cin >> n, n != 0; ) {
    int ans = 0;
    rep(i, n / 2) {
      string a, b; cin >> a >> b;
      if (a > b) swap(a, b);
      if (ans & 1) {
        if (a == "ld" && b == "rd") ans++;
      }
      else {
        if (a == "lu" && b == "ru") ans++;
      }
    }
    if (n & 1) {
      string t; cin >> t;
    }

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

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

int check(int c[3][3],int a[]){
  int b[3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      if(c[i][j]-a[i]<0||c[i][j]-a[i]>100){
        return 0;
      }else{
        if(i==0){
          b[j]=c[i][j]-a[i];
        }else{
          if(b[j]!=c[i][j]-a[i]){
            return 0;
          }
        }
      }
    }
  }
  return 1;
}

int main(){
  int c[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>c[i][j];
    }
  }
  for(int a1=0;a1<=100;a1++){
    for(int a2=0;a2<=100;a2++){
      for(int a3=0;a3<=100;a3++){
        int a[3]={a1,a2,a3};
        if(check(c,a)==1){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
    int n, x, y;
    cin >> n >> x >> y;
        int rec[2005] = {0};
        int ans[2005] = {0};
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j < i ; ++j) {
                if (i <= x) ans[i - j]++;
                else if (j >= y) ans[i - j] ++;
                else if (i <= y && j >= x) {
                    int dis = min(i - j, y - i + j - x + 1);
                    ans[dis]++;
                } else if (i <= y && j < x) {
                    int dis = min(i - j, x - j + 1 + y - i);
                    ans[dis]++;
                }
                else if (i > y && j < x) {
                    int dis = i - y + x - j + 1; 
                    ans[dis]++;
                } 
                else if (i > y && j >= x) {
                    int dis = min(i - j, i - y + 1 +j - x);
                    ans[dis]++;
                }
            }
        }
    for (int k = 1; k <= n-1; ++k) 
    cout << ans[k] << endl;
    
    return 0;
}

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

using namespace std;

long long teleport(long long k, long long start, const vector<long long>& A) {
    long long curr = start;
    for (int i = 1; i <= k; ++i) {
        curr = A[curr];
    }
    return curr;
}

void Main() {
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N, 0LL);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] -= 1;
    }

    long long periodInterval = 0LL;
    long long periodStartTiming = 0LL;
    long long periodStartTown = 0LL;
    long long periodLastTown = 0LL;
    map<long long, long long> firstReachTiming;
    long long curr = 0LL;
    firstReachTiming.insert(make_pair(0LL, 0LL));
    for (long long i = 1; i <= N; ++i) {
        if (firstReachTiming.count(A[curr]) == 0) {
            firstReachTiming.insert(make_pair(A[curr], i));
            curr = A[curr];
        }
        else {
            long long firstTiming = firstReachTiming[A[curr]];
            periodInterval = i - firstTiming;
            periodStartTiming = firstTiming;
            periodStartTown = A[curr];
            periodLastTown = curr;
            break;
        }
    }

    long long ans = 0LL;
    if (K <= periodStartTiming) {
        ans = teleport(K, 0LL, A);
    }
    else {
        K -= periodStartTiming;
        K = K % periodInterval;
        ans = teleport(K, periodStartTown, A);
    }
    cout << (ans + 1) << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 17036
#include<iostream>
#define rep(i,n) for(int i=1;i<n;i++)
using namespace std;
int main()
{
    int n;
    cin>>n;
    rep(i,10)
    {
        rep(j,10)
        {
            if(i*j==n)
            {
                cout<<"Yes\n";
                return 0;
            }
        }
    }
    cout<<"No\n";

    return 0;
}

Measured memory_bytes: 256
n = int(input())
P = [[int(x) for x in input().split()] for _ in range(n)]

diffs = [(P[j][0] - P[i][0], P[j][1] - P[i][1]) for i in range(n) for j in range(n) if i != j]

mini = 1e100
for p,q in diffs:
    if (p,q) == (0,0):
        continue
    count = n
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            if (P[i][0]+p, P[i][1]+q) == (P[j][0], P[j][1]):
                count -= 1
    mini = min(count, mini)

if n == 1:
    print(1)
else:
    print(mini)


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

using namespace std;
int main()
{
    int a, b, c, d, e, f, g, h, i;
    cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;

    if (a + e == b + d and b + f == e + c and d + h == e + g and e + i == f + h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vull = vector<ull>;
#define rep(i, n) for (ull i = 0; i < n; ++i)
#define rep1(i, n) for (ull i = 1; i < n; ++i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define fi first
#define se second
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}

vector<vi> E;
vi tour,be,en;
int k=0;
void dfs(int v,int p){
  be[v]=k;
  tour[k]=v;
  k++;
  for(auto u:E[v]){
    if(u==p) continue;
    dfs(u,v);
    tour[k]=v;
    k++;
  }
  en[v]=k;
}

void solve() {
  // input
  int n,q; cin>>n>>q;
  E.resize(n);
  tour.resize(2*n-1);
  be.resize(n); en.resize(n);
  rep(i,n-1) {
    int a,b; cin>>a>>b;
    a--; b--;
    E[a].pb(b); E[b].pb(a);
  }
  // Euler tour
  int root=0;
  dfs(root,-1);
  // imos
  vi imos(2*n,0);
  rep(i,q){
    int p,x; cin>>p>>x;
    p--;
    imos[be[p]]+=x;
    imos[en[p]]-=x;
  }
  rep1(i,2*n){
    imos[i]+=imos[i-1];
  }
  rep(i,n) cout<<imos[be[i]]<<endl;
}

int main() {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<string>s(n);
	string common_trial, common_ans;
	cin >> s[0];
	sort(s[0].begin(), s[0].end());
	common_trial = s[0];
	for (int i = 1; i < n; ++i) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
		int h = 0;
		for (int j = 0; j < common_trial.size(); ++j) {
			for(int k=h;k<s[i].size();++k){
				if (common_trial[j] == s[i][k]) {
					common_ans.push_back(s[i][k]);
					h = k+1;
					break;
				}
			}
		}
		common_trial = common_ans;
		common_ans = "";
	}
	cout << common_trial << endl;
	return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

ll dp[51][51][2501];

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	int n;
	int a;
	cin >> n >> a;
	vector<int> x;

	x.pb(0);
	for(int i=0; i<n; i++){
		int t;
		cin >> t;
		x.pb(t);
	}

	for(int i=0; i<=n; i++){
		dp[i][0][0] = 1;
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			for(int k=0; k<=2500; k++){
				if(k-x[i] >= 0){
					dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i]];
				}else{
					dp[i][j][k] = dp[i-1][j][k];
				}
			}
		}

		/*
		for(int j=0; j<=n; j++){
			for(int k=0; k<=25; k++){
				printf("%d ", dp[i][j][k]);
			}
			puts("");
		}
		puts("");
		*/

	}

	ll ans = 0;
	for(int j=1; j<=n; j++){
		for(int k=0; k<=2500; k++){
			if((k % j == 0) && (k / j == a)){
				ans += dp[n][j][k];
			}
		}
	}

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


Measured memory_bytes: 50048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

ll MOD = (ll)pow(10,9)+7;

ll spow(ll a,ll p){
  if(p == 0) return 1;
  if(p == 1) return a;
  return (a*spow(a,p-1))%MOD;
}

int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n){
    int x;
    cin >> x;
    mp[x] ++;
  }
  int m = mp.size();
  if(n%2 == 0){
    if(n != 2*m){
      cout << 0 << endl;
      return 0;
    }
    for(int i=1;i<=2*m-1;i += 2){
      if(mp[i] != 2){
        cout << 0 << endl;
        return 0;
      }
    }
    cout << spow(2,m) << endl;
    return 0;
  }
  if(n%2 == 1){
    if(n != 2*m-1){
      cout << 0 << endl;
      return 0;
    }
    for(int i=0;i<=2*(m-1);i += 2){
      if(i == 0){
        if(mp[i] != 1){
          cout << 0 << endl;
          return 0;
        }
      }//if_mp
      if(i > 0){
        if(mp[i] != 2){
          cout << 0 << endl;
          return 0;
        }
      }//if_mp
    }//for_i
    cout << spow(2,m-1) << endl;
    return 0;
  }//if_m%2
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

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

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, l[202];

int main(){
	cin >> n;
	for(int i = 0; i < n*2; i++){
		cin >> l[i];
	}
	sort(l, l+n*2);
	
	int ans = 0;
	for(int i = n*2-1; i >= 0; i -= 2){
		ans += l[i-1];
	}
	cout << ans << endl;
	
	return 0;
}

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

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

	int sameCount = 0;
	bool same3flg = false;

	for (int i = 0; i < numN; i++)
	{
		int tmpD1, tmpD2;
		cin >> tmpD1 >> tmpD2;

		if(tmpD1 == tmpD2){
			sameCount++;
		}else
		{
			sameCount = 0;
		}

		if(sameCount == 3){
			same3flg = true;
		}
	}
	

	string ans = same3flg ? "Yes" : "No";
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 110
#define ll long long
int n,m,K,mo;
ll pw[N][N*N],w[N][N][N],C[N][N];
ll f[N][N][N],g[N][N][N];
//transform --- f:go down g:go right
//f[k]->g[k] g[k]->f[k+1]
inline void add(ll &a,ll b){a=(a+b)%mo;}
int main(){
	scanf("%d%d%d%d",&n,&m,&K,&mo);
	for (int x=0;x<=K;++x){
		pw[x][0]=1;
		for (int i=1;i<=n*m;++i)
			pw[x][i]=pw[x][i-1]*x%mo;
	}
	for (int x=1;x<=K;++x)
		for (int i=0;i<=max(n,m);++i){
			ll p=(pw[x][i]-pw[x-1][i]+mo)%mo;
			w[x][i][0]=1;
			for (int j=1;j<=max(n,m);++j)
				w[x][i][j]=w[x][i][j-1]*p%mo;
		}
	for (int i=0;i<=max(n,m);++i){
		C[i][0]=1;
		for (int j=1;j<=i;++j)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}
	f[0][0][0]=1;
	for (int k=0;k<K;++k)
		for (int i=0;i<=n;++i)
			for (int j=0;j<=m;++j){
				if (f[k][i][j]){
					ll s=f[k][i][j];
					add(g[k][i][j],s);
					if (j<m)
						for (int t=1;i+t<=n;++t)
							add(g[k][i+t][j],s*w[k+1][m-j][t]%mo*pw[K-k][t*j]%mo*C[i+t][t]);
				}
				if (g[k][i][j]){
					ll s=g[k][i][j];
					add(f[k+1][i][j],s);
					if (i)
						for (int t=1;j+t<=m;++t)
							add(f[k+1][i][j+t],s*w[K-k][i][t]%mo*pw[k+1][t*(n-i)]%mo*C[j+t][t]);
				}
			}
	printf("%lld\n",f[K][n][m]);
	return 0;
}















Measured memory_bytes: 37204
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
// vector<vector<int>> data(i, vector<int>(j))
// vector<vector<vector<char>>> data(N, vector<vector<char>>(3, vector<char>(3)))


int main() {
  int n,max=0,num=0;
  string str;
  cin >> n;
  vector<string> dic(n);
  vector<string> ans;
  rep(i,n){
    cin >> dic.at(i);
  }
  sort(dic.begin(), dic.end());
  str = dic[0];
  rep(i,n){
    if(dic.at(i) == str){
      num++;
    }else{
      if(max<num){
        ans.clear();
        ans.push_back(str);
        max = num;
      }else if(max == num){
        ans.push_back(str);
      }
      num = 1;
      str = dic.at(i);
    }
  }
  if(max<num){
    ans.clear();
    ans.push_back(str);
    max = num;
  }else if(max == num){
    ans.push_back(str);
  }
  rep(i,ans.size()){
    cout << ans.at(i) << endl;
  }

  return 0;
}


Measured memory_bytes: 17140