akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

VL primes(int n){
    vector<bool> a(n+1, 1);
    VL p;
    FOR(x,2,n){
        if (!a[x]) continue;
        p.push_back(x);
        for (int y = 2 * x; y <= n; y += x) a[y] = 0;
    }
    return p;
}

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

int main() {
    int n;
    cin >> n;
    VI a(n + 1);
    REP(i,n + 1){
        a[n - i] = in();
    }

    VL ps = primes(n + 1);
    set<ll> ans;
    for (ll p : ps){
        VL cof(p);
        cof[0] = a[0];
        FOR(i,1,n){
            cof[(i - 1) % (p - 1) + 1] += a[i];
        }
        bool ok = true;
        REP(i,p) if (cof[i] % p != 0) ok = false;
        if (ok) ans.insert(p);
    }
    ll d = abs(a[n]);
    REP(i,n){
        if (a[i] != 0) d = gcd(d, abs(a[i]));
    }

    for (ll x = 2; x * x <= d; x++){
        if (d % x == 0){
            ans.insert(x);
            while (d % x == 0) d /= x;
        }
    }
    if (d > 1) ans.insert(d);

    for (ll x : ans) cout << x << endl;


    return 0;
}

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


int main()
{
	long N,A,B,ans;
	char S[11],T[11],U[11];
	
	scanf("%s%s%ld%ld%s",S,T,&A,&B,U);
	
	if(strcmp(S,U)==0){
		A--;
	}
	if(strcmp(T,U)==0){
		B--;
	}
	
	printf("%ld %ld\n",A,B);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int func(int n){
    if(n%2==0){
        return n/2;
    }else{
        return 3*n+1;
    }
}

int main()
{
    int s,cnt=0,index=0;
    cin>>s;
    if(s==1||s==2){
        cout<<4<<endl;
        return 0;
    }
    while(cnt!=2){
        index++;
        if(s==4)cnt++;
        // cout<<cnt<<": "<<s<<endl;
        s = func(s);
    }
    cout<<index<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int INF=1e9+5;
const int N=2e3+5;
const int mod=998244353;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll a,b,c;
	cin>>a>>b>>c;
	ll d=c-a-b;
	if(d<=0) return cout<<"No",0;
	if(d*d>4*a*b) return cout<<"Yes",0;
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
// ConsoleApplication.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#define _USE_MATH_DEFINES

#include "stdio.h"
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <unordered_set>
#include <functional>
#include <array>

using namespace std;

int partition(vector<int>& A, int p, int r)
{
	int& x = A.at(r);
	for (int j = p; j != r; ++j) if (A.at(j) <= x) swap(A.at(p++), A.at(j));
	swap(A.at(p), x);
	return p;
}

int main()
{
	int n;
	cin >> n;
	vector<int> A(n);
	for (auto& i : A)cin >> i;
	const int index = partition(A, 0, A.size()-1);
	for (int i = 0; i != n ; ++i) {
		if (i != 0) cout << " ";
		if (i != index) cout << A.at(i);
		else cout << "[" << A.at(i) << "]";
		
	}
	cout << endl;

	

	return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    string S;
    cin >> S;

    bool ans = true;
    if (S[0] != 'A') ans = false;
    int cnt = 0;
    for (int i = 2; i < S.length() - 1; i++) {
        if (S[i] == 'C') cnt++;
    }
    if (cnt != 1) ans = false;
    int cnt2 = 0;
    for (int i = 1; i < S.length(); i++) {
        if (S[i] - 'a' >= 0 && S[i] - 'a' < 26) {
            continue;
        } else {
            cnt2++;
        }
    }
    if (cnt2 != 1) ans = false;

    if (ans) {
        print("AC");
    } else {
        print("WA");
    }
}

signed main() {
    solve();
}


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


int main() {
    long long a,b,k;
    cin>>a>>b>>k;
    if(a-k<0){
        k-=a;
        a=0;
        b=max(b-k,(long long)0);
    }else a-=k;
    cout << a<<" " <<b<<endl;

}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
      	int a = int.Parse(input[0]);
      	int b = int.Parse(input[1]);
      	
      	int ans = -1;
      	int i = 1;
      
      	while(i < 1001){
            double p = i*0.08;
          	double q = i*0.10;
          
            if((int)p==a && (int)q==b){
                ans = i;
                break;
            }
          
            i++;
        }
        
      	
		Console.WriteLine(ans);
	}
}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll h,ans=1,cnt=1;
	cin>>h;
	while(h!=1){
		h/=2;
		cnt*=2;
		ans+=cnt;
	}
	cout<<ans<<"\n";
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 


Measured memory_bytes: 3656
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
using namespace std;

// B - Ringo's Favorite Numbers
int main(){
    int D, N;
    cin >> D >> N;
    
    int ans = N * pow((double)100, (double)D);
    if(N == 100) ans = (N+1) * pow((double)100, (double)D);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=500005;
const int maxn=N*5;

int tot,a[maxn+5];
char str[N];

void mul(int x)
{
    int s,g=0;
    for (int i=maxn;i>=1;i--)
    {
        s=a[i]*x+g;
        a[i]=s%10;
        g=s/10;
    }
}

void add(int x)
{
    a[maxn]+=x;tot+=x;
    for (int i=maxn;i>=1&&a[i]>=10;i--)
    {
        tot-=a[i-1]+a[i];
        a[i-1]++;a[i]-=10;
        tot+=a[i-1]+a[i];
    }
}

int main()
{
    scanf("%s",str);
    int len=strlen(str);
    for (int i=0;i<len;i++) a[maxn-i]=str[len-i-1]-'0';
    mul(9);
    for (int i=1;i<=maxn;i++) tot+=a[i];
    for (int k=1;;k++)
    {
        add(9);
        if (k*9>=tot) {printf("%d",k);break;}
    }
    return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <vector>

#define FAST_IO                  \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define MOD 1000000007
#define MAX 1e9
#define MIN -1e9

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<vl> vvl;

const double EPS = 1e-9;
#ifdef int
const int INF = 1e16;
#else
const int INF = 1e9;
#endif

int main()
{

    ll n, k;
    cin >> n >> k;
    vl v(n + 1, 0), dp(n + 1, INF);
    for (ll i = 1; i <= n; i++)
        cin >> v[i];
    dp[0] = 0;
    dp[1] = 0;
    // dp[1] = abs(v[1] - v[0]);
    // dp[2] = abs(v[2] - v[0]);
    for (ll i = 2; i <= n; i++)
    {
        for (ll j = i - 1; j >= 1 and (i - j) <= k; j--)
        {
            dp[i] = min(abs(v[i] - v[j]) + dp[j], dp[i]);
        }
        // cost += v[i + 1];
        // cout << "dp" << dp[i] << endl;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1792
#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int MN = 100010;
bool used[MN];
int n;
int x[MN], y[MN];
P p[MN], p1[MN], p2[MN];

bool solve(int m) {
    fill_n(used, MN, false);
    int mx = p1[0].first, my = p2[0].first;
    for (int i = 0; i < n; i++) {
        P pp = p[i];
        if (pp.first <= mx+m && pp.second <= my+m) {
            used[i] = true;
        }
    }
    for (int i = 0; i < n; i++) {
        if (!used[p1[i].second]) {
            mx = p1[i].first;
            break;
        }
    }
    for (int i = 0; i < n; i++) {
        if (!used[p2[i].second]) {
            my = p2[i].first;
            break;
        }
    }
    for (int i = 0; i < n; i++) {
        P pp = p[i];
        if (pp.first <= mx+m && pp.second <= my+m) {
            used[i] = true;
        }
    }
    bool f = true;
    for (int i = 0; i < n; i++) {
        f &= used[i];
    }
    if (f) return true;
    fill_n(used, MN, false);
    mx = p1[0].first, my = p2[n-1].first;
    for (int i = 0; i < n; i++) {
        P pp = p[i];
        if (pp.first <= mx+m && pp.second >= my-m) {
            used[i] = true;
        }
    }
    for (int i = 0; i < n; i++) {
        if (!used[p1[i].second]) {
            mx = p1[i].first;
            break;
        }
    }
    for (int i = 0; i < n; i++) {
        if (!used[p2[i].second]) {
            my = p2[i].first;
            break;
        }
    }
    for (int i = 0; i < n; i++) {
        P pp = p[i];
        if (pp.first <= mx+m && pp.second <= my+m) {
            used[i] = true;
        }
    }
    f = true;
    for (int i = 0; i < n; i++) {
        f &= used[i];
    }
    if (f) return true;
    return false;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x2, y2;
        scanf("%d %d", &x2, &y2);
        x[i] = x2; y[i] = y2;
        p[i] = P(x2+y2, x2-y2);
        p1[i] = P(x2+y2, i);
        p2[i] = P(x2-y2, i);
    }
    sort(p1, p1+n); sort(p2, p2+n);
    int l = 1, r = 100010*3;
    while (r - l > 1) {
        int md = (l+r)/2;
        if (solve(md)) {
            r = md;
        } else {
            l = md;
        }
    }
    printf("%d\n", r);
    return 0;
}

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

int getTax(int price,int p){
	return price * (100+p) / 100;
}

int getMaxPrice(int x, int y, int s){
	int rowPrice1, rowPrice2;
	int taxPrice;
	int max=0;
	for(int i=1;i<s;i++){
		for(int j=1;j<s;j++){
			if(getTax(i,x) + getTax(j,x) == s){
				// cout << i << " " << j << endl;
				taxPrice = getTax(i,y) + getTax(j,y);
				max = (max < taxPrice) ? taxPrice : max;
			}
		}
	}
	return max;
}

int main(){
	int x, y, s;
	while(1){
		cin >> x >> y >>s;
		if(x+y+x==0) break;
		cout << getMaxPrice(x,y,s) << endl;
	}
	return 0;
}

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

int main() {
    int64_t n; cin>>n;
    int64_t a=2,b=1,c=1;
    rep(i,n-1) {
        c=a+b;
        a=b; b=c;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main { 
	static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) { 

    	int n = scan.nextInt();
    	String str = "";
    	
    	for(int i=0; i<n; i++) {
    		str += scan.nextInt();	//WARNING
    		if (i != n-1) str += " ";
    	}
    	
    	String str2 = "";
    	List<String> list = new ArrayList<String>();
    	for(int i=1; i<n+1; i++) {
    		str2 += i;
    	}
    	list =permutation(list, str2, "");
    	
    	int a = -1;
    	for(int i=0; i<list.size(); i++) {
    		if(list.get(i).equals(str)) {
    			a = i;
    			break;
    		}
    	}
    	if(a != 0) {
    		System.out.println(list.get(a - 1));
    	}
    	System.out.println(list.get(a));
    	if(a != list.size()-1) System.out.println(list.get(a + 1));
    }
	
    public static List<String> permutation(List<String> list, String q, String ans){
    	if(q.length() <= 1) {
    		list.add(ans + q);
    	}else {
    		for (int i = 0; i < q.length(); i++) {
    			permutation(list, q.substring(0, i) + q.substring(i + 1), ans + q.charAt(i) + " ");
    		}
    	}
    	return list;
    }    	
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 3e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertback(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}
// To compute x^y under modulo m
llt power(llt x, llt y, llt m)
{
    if (y == 0)
        return 1;
    llt p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}
llt dp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(dp[x] != -1) return dp[x];
  return dp[x] = (x*fact(x-1))%M;
}

llt findans(llt x, llt y)
{
  llt aa = fact(x + y);
  llt ab = fact(x);
  llt ac = fact(y);
  llt abinv = power(ab, M-2, M);
  llt acinv = power(ac, M-2, M);
  return ((((aa*abinv)%M)*acinv)%M);
}

int main()
{
  llt h, w, a, b;
  cin>>h>>w>>a>>b;
  llt ans = 0;
  memset(dp, -1, sizeof(dp));
  for(int i=b; i<w;i++)
  {
    //cout<<findans(h-a-1, i)<<endl;
    //cout<<findans(a-1, w-i-1)<<endl;
    ans = (ans + (findans(h-a-1, i)*findans(a-1, w-i-1))%M)%M;
    //cout<<ans<<" xx  "<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 13440
#include <stdio.h>

int
main(int argc, char *argv[])
{
    unsigned long a, b;

    while (EOF != scanf("%lu %lu\n", &a, &b)) {
        unsigned long i, gcd, lcm;

        for (gcd = 1, i = 2; (i <= a) && (i <= b); i++) {
            while (1) {
                if (a % i) break;
                if (b % i) break;
                gcd *= i;
                a /= i, b /= i;
            }
        }
        lcm = a * b * gcd;

        printf("%lu %lu\n", gcd, lcm);
    }

    return 0;
}

Measured memory_bytes: 608
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||(require'rubygems';exec({Z=>'50000000'},Gem.ruby,$0));def f(i)a=H[i].map{|e|-f(e)}.sort;r=0;a.size.times{|i|x=i+1-a[i];r<x&&r=x};r end;H=Hash.new{|h,k|h[k]=[]};2.upto(gets.to_i){|i|H[gets.to_i]<<i};p f 1

Measured memory_bytes: 224648
n=int(raw_input())
a=[int(raw_input()) for _ in xrange(n)]
ans=a[0]-1
maxa=2
for i in xrange(1,n):
    if maxa==a[i]:
        maxa=a[i]+1
    else:
        if maxa<a[i]:
            if a[i]%maxa==0:
                ans+=a[i]/maxa-1
            else:
                ans+=a[i]/maxa
print(ans)

Measured memory_bytes: 5764
C = [[] for i in range(3)]
a = [0] * 3
b = [0] * 3
for i in range(3):
    q = list(map(int, input().split()))
    C[i] = q

flag = False
for i in range(101):
    a[0], b[0] = i, C[0][0] - i
    if a[0] < 0 or b[0] < 0:
        continue

    for m in range(1, 3):
        a[m] = C[m][0] - b[0]

    for n in range(1, 3):
        b[n] = C[0][n] - a[0]

    if min(a) < 0 or min(b) < 0:
        continue

    rec = True
    for j in range(3):
        for k in range(3):
            if a[j] + b[k] != C[j][k]:
                rec = False

    if rec:
        flag = True
        break


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

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

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

const int MN = 100010;

int N;
ll D[MN];
vector<pair<ll, int> > ord;
int inv[MN], sz[MN];
vector<pii> edge;
vector<int> adj[MN];
int dep[MN];

void dfs(int u, int p) {
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        dep[v] = dep[u] + 1;
        dfs(v, u);
    }
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%lld", &D[i]);
        ord.push_back({ D[i], i });
    }

    sort(ord.begin(), ord.end());
    for(int i = 0; i < N; i++) inv[i] = ord[i].second;
    sort(D, D + N);

    for(int i = 0; i < N; i++) sz[i] = 1;
    for(int i = N - 1; i >= 1; i--) {
        if(2 * sz[i] >= N) {
            printf("-1");
            return 0;
        }
        if(D[i] - N + 2 * sz[i] <= 0) {
            printf("-1");
            return 0;
        }
        int a = lower_bound(D, D + N, D[i] - N + 2 * sz[i]) - D;
        if(D[a] != D[i] - N + 2 * sz[i]) {
            printf("-1");
            return 0;
        }

        edge.push_back(pii(inv[a], inv[i]));
        sz[a] += sz[i];
        adj[a].push_back(i);
    }
    if(sz[0] != N) {
        printf("-1");
        return 0;
    }

    dfs(0, -1);

    ll sum = 0;
    for(int i = 0; i < N; i++) sum += dep[i];
    if(sum != D[0]) {
        printf("-1");
        return 0;
    }

    for(int i = 0; i < N - 1; i++) {
        printf("%d %d\n", edge[i].first + 1, edge[i].second + 1);
    }
}


Measured memory_bytes: 14320
#include<iostream>
using namespace std;
int main(){
  double v,y,t;
  int n,h[1000];
  for(int i=0; i<1000; i++)
    h[i] = i*5-5;
  while(cin >> v){
    t = v/9.8;
    y = 4.9 * t * t;
    for(int j=0; j<1000; j++){
      if(h[j] >= y){
	cout << j << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 0
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
		int n,y,r,t;
		String b;
		n=scan.nextInt();
		if(n==0)break;
		y=scan.nextInt();
		String num[]=new String[n];
		double max=0;
		
		String most="";
		for(int i=0;i<n;i++)
		    {
			b=scan.next();
			r=scan.nextInt();
			t=scan.nextInt();
			double gankin=0;
			if(t==1)
			    {
				
				gankin=1+(y*((double)r/100));
				    
			    }
			else if(t==2)
			    {
				
				gankin=(Math.pow(1+((double)r/100),y));
				    
			    }
			
			if(max<gankin)
			    {
				max=gankin;
				most=b;
			    }
			
		    }
		
		System.out.println(most);
	    }
    }
}

Measured memory_bytes: 35272
#include <iostream>
#include <math.h>
#include <vector>
#include <memory>
#include <time.h>
#include <thread>
#include <chrono>

using namespace std;

int main()
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	int t1, t2;

	if (a < c)
		t1 = c;
	else
		t1 = a;

	if(b<d)
		t2 = b;
	else
		t2 = d;

	int time = t2 - t1;

	if(time>0){
		cout << time;
	}
	else{
		cout << 0;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp    make_pair
#define pb    push_back
#define F     first
#define pi 	  3.14159265358979323846
#define S     second
#define ll    long long
#define ld    long double
#define sz(s) (ll)s.size() 
#define vl    vector < ll >
#define pll   pair < ll, ll >
#define ml    map < ll, ll >
#define mod   1000000007
#define q	998244353
#define MAXN  50005 
#define mx 10000005
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define inv(i,a,b)  for(ll i=a;i>=b;i--)
#define all(a)  (a).begin(),(a).end()
using namespace std;
int main(){
	IOS;
	ll t,n,l;
	ll i,j,m,mn,d,x=0,y=0,ans=mod,temp=0,p=0,k=0,c;
	string s,s1;
	cin>>n;
	rep(i,0,n){
		cin>>s;
		if(s=="AC")x++;
		else if(s=="WA")y++;
		else if(s=="TLE")p++;
		else k++;
	}
	cout<<"AC x "<<x<<endl;
	cout<<"WA x "<<y<<endl;
	cout<<"TLE x "<<p<<endl;
	cout<<"RE x "<<k<<endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SORT(V) sort((V).begin(), (V).end())
#define ll long long

const string YES = "Yes";
const string NO = "No";
int main()
{
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;

  T = T.substr(0, S.length());
  if (S == T)
  {
    cout << YES << endl;
  }
  else
  {
    cout << NO << endl;
  }

  return 0;
}


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

int main() {
	int N;
  	cin >> N;
  
  	int ans = 0;
  
  	for(int i = 1; i <= (N + 1) / 2;i++) {
    	int Odd = 2 * i - 1;
      	int num = 0;
      for(int j = 1; j <= Odd; j++) {
      	if(Odd % j == 0) num++;
      }
      if(num == 8) ans++; 
    }
  
  	cout << ans << endl;
  
  
}

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

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;




int main(){
	int n;
	while (cin >> n){
		if (n == -1)break;
		double x = 1.0, y = 0.0;
		rep(i, n - 1){
			double a = x, b = y;
			x = sqrt(x*x + y*y);
			y = 1.0;
			double c = x, d = y;
			x = (a*c - b*d) / sqrt(a*a + b*b);
			y = (a*d + c*b) / sqrt(a*a + b*b);
		}
		printf("%.15lf\n%.15lf\n", x, y);
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl a = 1;
    rep(i,n){
        a += min(a,m);
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
/*
# ??????
"Equal Total Scores"
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1153&lang=jp

# ?§£?????????
????????????????????????????????????????????????????????????????????????????????????????????????????£???¨?????????
????£??????????????????????????????´????????¶????????????????????\?????????????????°???????????°???O(N+M)??§??????????±??????????
- ????¨??????°??????????????????         => ??????????£????????????????????????????????????¨??????
- ??????????????°??????????????§???????????? => ?????????????£??????????????£?????¬??????§????????????????????????
- ??±???????????°??????????????§???????????? => ??±??????????£??????????????£?????¬??????§????????????????????????
???????????§????£?????????????????????????????????£??????????????¶??????????????????????????¨????????????

????¨????????????????????????????????????????????????????????????????????¨????????±??????????????????????????????????????¨??????????????±?????????????
??°?????????????¨????????????¨?????????????£?????????£??????????????????????????°????????¨??????????????°?????°????????§????????§?????????

# ????????????
10????¨????

# ?????´???????????¨
????????????

# ????????????
?????????????????¨??????????????????????§£???????????\??±????????£??¨??£?????????????????????????????????

*/

using namespace std;
#include <algorithm>
#include <cstdio>

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

#define MAX_N 100
#define MAX_M 100

int N, M;
int t_cards[MAX_N];
int h_cards[MAX_M];


void load1() {
  scanf("%d %d", &N, &M);
  REP(i, N) {
    scanf("%d", &t_cards[i]);
  }
  REP(i, M) {
    scanf("%d", &h_cards[i]);
  }
}

int solve1() {
  if( N == 0 and M == 0 ) {
    return 0;
  }
  int diff = 0;
  REP(i, N) {
    diff += t_cards[i];
  }
  REP(i, M) {
    diff -= h_cards[i];
  }
  
  sort(t_cards, t_cards+N);
  sort(h_cards, h_cards+M);
  int i = 0;
  int j = 0;
  
  while(i < N and j < M) {
    int d = (t_cards[i] - h_cards[j])*2;
    if( d == diff ) {
      printf("%d %d\n", t_cards[i], h_cards[j]);
      return 1;
    }
    if( d > diff ) {
      ++j;
      continue;
    } else {
      ++i;
      continue;
    }
  }
  printf("-1\n");
  return 1;
}

int main() {
  do {
    load1();
  } while( solve1() );
  return 0;
}

Measured memory_bytes: 1056
#include<stdio.h>
#include<memory.h>
#include<stdlib.h>
#include<string.h>


int main(void){

        int a,b;

        scanf("%d %d",&a,&b);

        if(a > 9 || b > 9){ 
                printf("-1\n");
        }else{
                printf("%d\n",a*b);
        }   

        return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
int main()
{
    int x,y,x1,y1,a,b,i;
    scanf("%d %d %d %d",&x,&y,&x1,&y1);
    a=y1-y;
    b=x1-x;
    for(i=0;i<a;i++)
    {
        printf("U");
    }
    for(i=0;i<b;i++)
    {
        printf("R");
    }
    for(i=0;i<a;i++)
    {
        printf("D");
    }
    for(i=0;i<=b;i++)
    {
        printf("L");
    }
    for(i=0;i<=a;i++)
    {
        printf("U");
    }
    for(i=0;i<=b;i++)
    {
        printf("R");
    }
    printf("DR");
    for(i=0;i<=a;i++)
    {
        printf("D");
    }
    for(i=0;i<=b;i++)
    {
        printf("L");
    }
    printf("U");
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int n,m;
int cnt[55];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i = 1; i <= m; i++){
		int a, b;
		scanf("%d%d",&a,&b);
		cnt[a]++;
		cnt[b]++;
	}
	for(int i = 1; i <= n; i++)
		printf("%d\n",cnt[i]);
	return 0;
}

Measured memory_bytes: 128
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def main():
	k = int(input())
	h = [2,4,5,7,9]
	p = [0,1,6,8]
	b = [3]
	v = int(str(k)[-1])
	if v in h:
		print('hon')
	elif v in p:
		print('pon')
	else:
		print('bon')
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 62068
s=input()
t=input()

n=len(s)
az=list('abcdefghijklmnopqrstuvwxyz')
ls=[set() for i in range(26)]
ls2=[set() for i in range(26)]
ans='Yes'
di=dict()
for i in range(n):
    ls[az.index(t[i])].add(s[i])
    ls2[az.index(s[i])].add(t[i])
for i in range(26):
    if len(ls[i])>1:
        ans='No'
    if len(ls2[i])>1:
        ans='No'
print(ans)



Measured memory_bytes: 41968
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

typedef long long ll;

const int MAXN = 200005;
const ll MOD = 1000000007;

int n;
int lst[MAXN];

ll f[MAXN];

int main()
{
	scanf("%d",&n);
	f[0] = 1;
	for (int c,i = 1;i <= n;i++)
	{
		scanf("%d",&c);
		f[i] = f[i - 1];
		if (lst[c] && lst[c] != i - 1)
			(f[i] += f[lst[c]]) %= MOD;
		lst[c] = i;
	}
	printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=100005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

int n;
vi a,b,c;

int main(){
	cin>>n;
	a=b=c=vi(n);
	for(auto &i:a){
		cin>>i;
		c[i-1]++;
	}
	for(auto &i:b){
		cin>>i;
		c[i-1]++;
	}
	for(int i=0;i<n;i++) if(c[i]>n){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	reverse(b.begin(),b.end());
	vi d;
	int x=-1;
	for(int i=0;i<n;i++) if(a[i]==b[i]) x=b[i];
	for(int i=0;i<n;i++) if(a[i]!=x&&b[i]!=x) d.push_back(i);
	for(int i=0;i<n;i++) if(a[i]==b[i]){
		assert(!d.empty());
		int t=d.back();
		d.pop_back();
		swap(b[i],b[t]);
	}
	for(int i=0;i<n;i++) cout<<b[i]<<" \n"[i==n-1];
}

Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <list>
#include <math.h>

using namespace std;

typedef long long int ll;

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

inline bool check(int mask,int p)
{
    int z = 1<<p;
    z &= mask;

    return z;
}

inline void set_bit(int& mask,int p)
{
    int z = 1<<p;
    mask |= z;
}

inline void clear_bit(int& mask,int p)
{
    int z = 1<<p;
    mask ^= z;
}


ll helper(vector<list<int>>& adj,vector<ll>& dp,int& mask,int woman)
{
    int n = adj.size();

    if (mask == (1<<n)-1) return 1;
    //if (woman == n) return 0;

    if (dp[mask] != -1) return dp[mask];

    ll ans = 0;

    for (int man: adj[woman])
    {
        if (!check(mask,man))
        {
            set_bit(mask,man);
            ans += helper(adj,dp,mask,woman+1);
            ans %= MOD;
            clear_bit(mask,man);
        }
    }

    dp[mask] = ans;

    return ans;
}

ll solve(vector<list<int>>& adj)
{
    int mask = 0;
    int n = adj.size();
    vector<ll> dp((1<<n),-1);

    ll ans = helper(adj,dp,mask,0);

    return ans;
}



int main()
{
    ll N;
    cin>>N;
    vector<vector<bool>> G(N,vector<bool>(N));

    for (int i=0;i<N;++i)
    {
        for (int j=0;j<N;++j)
        {
            bool b;
            cin>>b;
            G[i][j] = b;
        }
    }

    //Woman: Rows
    //Man: Col

    vector<list<int>> adj(N);

    for (ll i=0;i<N;++i)
    {
        for (ll j=0;j<N;++j)
        {
            if (G[i][j]) adj[j].push_back(i);
        }
    }

    cout<<solve(adj)<<endl;

    return 0;
}


Measured memory_bytes: 19608
#include<cstdio>
#include<map>
#include<vector>
#include<cstring>
#include<algorithm>
struct node {
	int x,y;
};
using namespace std;
node R[1000],B[1000];
bool vis[1000];
int mat[1000];
int N,ans;
vector<int>G[1000];
bool dfs(int u) {
	for(int i=0;i<G[u].size();i++) {
		int v=G[u][i];
		if(vis[v]) continue;
		vis[v]=1;
		if(! mat[v]||dfs(mat[v])) {
			mat[v]=u;
			mat[u]=v;
			return 1;
		}
	}
	return 0;
}
int main()
{
	scanf("%d",&N);
	for(int i=1;i<=N*2;i++)
		scanf("%d%d",&R[i].x,&R[i].y);
	for(int i=1;i<=N;i++)
		for(int j=N+1;j<=2*N;j++)
			if(R[i].x<R[j].x&&R[i].y<R[j].y) {
				G[i].push_back(j);
				G[j].push_back(i);
			}
	for(int i=1;i<=2*N;i++) {
		memset(vis,0,sizeof(vis));
		if(!mat[i]&&dfs(i))
			ans++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  string N; cin>>N;
  if(N[0]=='7'||N[1]=='7'||N[2]=='7')cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		
		int[][] x =new int[n+1][d+1];
		
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= d; j++) {
				x[i][j] = sc.nextInt();
			}
		}
	int sum = 0;	
	int count = 0;
	for (int i = 1; i <= n-1; i++) {
		for (int j = i+1; j <= n; j++) {
			for(int k = 1; k <= d; k++) {
				//System.out.println(i+" "+j+" "+k);
				sum += Math.pow((x[i][k]-x[j][k]),2);
			}
			double dist= Math.sqrt(sum);
			//System.out.println(dist+" "+(int)dist);
			if(dist-(int)dist == 0) count++;
			sum = 0;
	}
	}	
		System.out.println(count);
	}
}


Measured memory_bytes: 21716
#define _USE_MATH_DEFINES
#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>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n+1, 0);
    for(int i=0; i<n; ++i)
        cin >> a[i];
    sort(a.rbegin(), a.rend());

    int i = 0;
    while(i < a[i])
        ++ i;
    -- i;

    if((a[i] - i) % 2 == 0){
        cout << "First" << endl;
        return 0;
    }

    int j = i + 1;
    while(i < a[j])
        ++ j;

    if((j - i) % 2 == 0)
        cout << "First" << endl;
    else
        cout << "Second" << endl;

    return 0;
}

Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        int N;
        static long MOD = (long) (1e9 + 7);
        private static int MAX = 1000001;
        private static long[] xs = new long[MAX + 1];
        private static long[] ys = new long[MAX + 1];

        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            N = in.Int();
            if (N == 1) {
                out.println(0);
                return;
            }

            long ans = 0;
            for (int i = 2; i <= N; i++) {
                long a = modpow(2, i) - 2;
                long b = modpow(8, N - i);
                long c = comb(N, i);
                ans += (((a * b) % MOD) * c) % MOD;
                ans %= MOD;
            }
            out.println(ans);
        }

        private long comb(int n, int r) {
            if (r < 0 || r > n) return 0;
            if (xs[0] == 0) {
                xs[0] = 1;
                for (int i = 1; i <= MAX; i++) {
                    xs[i] = xs[i - 1] * i % MOD;
                }
                long inv = modpow(xs[MAX]);
                ys[MAX] = inv;
                for (int i = MAX; i >= 1; i--) {
                    inv = inv * i % MOD;
                    ys[i - 1] = inv;
                }
            }
            return xs[n] * (ys[r] * ys[n - r] % MOD) % MOD;
        }

        private long modpow(long a) {
            return modpow(a, MOD - 2);
        }

        private long modpow(long a, long n) {
            long r = 1;
            while (n > 0) {
                r = r * ((n % 2) != 0 ? a : 1) % MOD;
                a = a * a % MOD;
                n >>= 1;
            }
            return r;
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 50004
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n, q, arr[200001], a, b;
vector<int> adj[200001];

void dfs(int src, int p) {
    arr[src] += arr[p];
    for (int ch : adj[src]) {
        if (ch != p) {
            dfs(ch, src);
        }
    }
}
int main() {
    IOS
    cin >> n >> q;
    for (int i = 0; i < n-1; ++i) {
        cin >> a >> b;
        adj[a].emplace_back(b);
        adj[b].emplace_back(a);
    }
    while (q--) {
        cin >> a >> b;
        arr[a] += b;
    }
    dfs(1, 0);
    for (int i = 1; i <= n; ++i) {
        cout << arr[i] << " \n"[i==n];
    }
    return 0;


}


Measured memory_bytes: 23552
S=list(input())
N=len(S)

count=0
def change_string(S):

  if S=="0":
    S="1"
  elif S=="1":
    S="0"
  return S
    
if N!=1:
  for i in range(1,N):
    if S[i-1]==S[i]:
      count=count+1
      S[i]=change_string(S[i])
      #print(i)
     # print(S)
    elif S[i-1]!=S[i]:
      continue
      
print(count)
      
    
  
  


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

int main() {
  int n, diff = 0;
  std::cin >> n;
  std::vector<int> x(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> x.at(i);
  }
  
  std::sort(x.begin(), x.end(), std::greater<>());
  
  for(int i = 0; i < n; i++) {
    if(i % 2) {
      diff -= x.at(i);
    } else {
      diff += x.at(i);
    }
  }
  
  std::cout << diff << std::endl;
  return 0;
}


Measured memory_bytes: 256
a,b,c,x,y = map(int, raw_input().split())
s = 0
if a + b > 2 * c:
    s += min(x,y) * 2 * c
else:
    s += min(x,y) * (a+b)
if x > y:
    if a > 2 * c:
        s += (x-y) * 2 * c
    else:
        s += (x-y) * a
elif y > x:
    if b > 2 * c:
        s += (y-x) * 2 * c
    else:
        s += (y-x) * b
print s


Measured memory_bytes: 2568
#abc_151_e
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()

mod = 10**9 + 7

ans = 0

#precalculation of the factorial
#fact[i] = i!
num = 10**5 + 1
fact = [0] * num
fact[0] = 1
for i in range(1,num):
    fact[i] = (fact[i-1] * i) % mod
    
for i in range(k-1, n):
    f = fact[i] * pow(fact[k-1]*fact[i-k+1], mod-2, mod)
    ans += (a[i] * f) % mod
    
for i in range(0, n-k+1):
    f = fact[n-i-1] * pow(fact[k-1]*fact[n-k-i], mod-2, mod)
    ans -= (a[i] * f) % mod
    
print(ans%mod)
    
    

Measured memory_bytes: 14040
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#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 repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    vector<int> v(3);
    rep(i, n) {
        if (A[i] % 4 == 0) {
            v[2]++;
        }
        else if (A[i] % 2 == 0) {
            v[1]++;
        }
        else {
            v[0]++;
        }
    }

    if (v[1] >= 1) {
        yorn(v[0] <= v[2]);
    }
    else {
        yorn(v[0] - 1 <= v[2]);
    }

    return 0;
}

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

int main(){
    int m, d;cin>>m>>d;
    int acc = 0;
    for (int i=1;i<=m;i++){
        for (int j=10;j<=d;j++){
            int ten = j / 10;
            int one = j % 10;
            if (ten >= 2 && one >= 2 && ten * one == i){
                acc++;
            }
            
        }
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var a     = long.Parse(spl[0]);
        var b     = long.Parse(spl[1]);
        var x     = long.Parse(spl[2]);

        if(x > b) {
            return a==0 ? 1 : 0;
        }

        long aa = 0;
        if(x >= a){
            aa = x;
        } else {
            aa = a / x * x;
            if(a % x != 0) aa += x;
        }

        if(aa > b){
            return a==0 ? 1 : 0;
        }

        return (b - aa) / x + 1 + (a==0 ? 1 : 0);

    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
////////////////////////////////////////////////
int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    int cnt = 0;
    int ma;
    for (int i = 0; i < n - 2; i++)
    {
        for (int j = i + 1; j < n - 1; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                if (l[i] != l[j] && l[j] != l[k] && l[i] != l[k])
                {
                    vector<int> ans = {l[i], l[j], l[k]};
                    sort(ans.begin(), ans.end());
                    if (ans[0] + ans[1] > ans[2])
                        cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3624
W, H, N = list(map(int, input().split(" ")))
point = []
square = [[1 for i in range(W)] for j in range(H)]
for i in range(N):
  x, y, a = list(map(int, input().split(" ")))
  if a == 1:
    for i in range(H):
      for j in range(x):
        square[i][j] = 0
  if a == 2:
    for i in range(H):
      for j in range(W - 1, x - 1, -1):
        square[i][j] = 0
  if a == 3:
    for i in range(y):
      square[i] = [0 for j in range(W)]
  if a == 4:
    for i in range(H - 1, y - 1, -1):
      square[i] = [0 for j in range(W)]

area = 0
for i in range(H):
  for j in range(W):
    if square[i][j] == 1:
      area += 1
print(area)

Measured memory_bytes: 3188
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  string s;cin>>s;
  ll n=s.size();
  map<char,ll>M;
  rep(i,n)M[s[i]]++;
  //cout<<M['a']<<" "<<M['b']<<" "<<M['c']<<endl;
  if((M['a']-M['b']==0||M['a']-M['b']==1)&&(M['c']-M['b']==0||M['c']-M['b']==1)){
    cout<<"YES"<<endl;
    return 0;
  }
  if((M['a']-M['b']==0||M['a']-M['b']==-1)&&(M['c']-M['b']==0||M['c']-M['b']==-1)){
    cout<<"YES"<<endl;
    return 0;
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 512