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

using namespace std;

int n;

inline bool Prim(int x)
{
    int i;
    if(x<=1)
        return false;
    if(x==2)
        return true;
    if(x%2==0)
        return false;
    for(i=3;i*i<=x;i+=2)
        if(x%i==0)
            return false;
    return true;
}

int main()
{
    int i;
    cin>>n;
    for(i=n;!Prim(i);i++)
        ;
    cout<<i<<"\n";
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;

    return 0;
}

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

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

    int ans = 0;
    for(int i=1;i<n;i++){
        int cnt = 0;
        for(char c='a';c<='z';c++){
            bool left=false,right=false;
            for(int j=0;j<i;j++){
                if(s[j] == c){
                    left = true;
                }
            }
            for(int j=i;j<n;j++){
                if(s[j] == c){
                    right = true;
                }
            }
            if(left && right){
                cnt++;
            }
        }
        if(ans < cnt){
            ans = cnt;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 764
n = int(input())
x = []
y = []
for _ in range(n):
    X,Y = map(int,input().split())
    x.append(X)
    y.append(Y)

res = 0
for p, q in [[1, 1], [1, -1], [-1, 1], [-1, -1]]:
    smallest = p * x[0] + q * y[0] + 0
    for i in range(n):
        cur = p * x[i] + q * y[i]
        res = max(res, cur - smallest)
        smallest = min(smallest, cur)
print(res)



Measured memory_bytes: 100528
S1=input()
S1=S1.split()
S2=input()
S2=S2.split()
move=0
N=int(S1[0])
A=int(S1[1])
B=int(S1[2])
for i in range(N-1):
    if (int(S2[i+1])-int(S2[i]))*A>=B:
        move+=B
    else:
        move+=A*(int(S2[i+1])-int(S2[i]))
print(move)

Measured memory_bytes: 11100
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    string n;
    cin >> n;
    for(int i=0;i<3;i++){
        if(n.at(i) == '9'){
            cout << '1';
        }else{
            cout << '9';
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,M;
  cin >> N >> M;
  vector<int> A(M);
  vector<int> C(N,0);
  for(int a = 0;a < M;a++){
    cin >> A[a];
   C[A[a]] = 1; 
  }
  vector<long long> B(N + 10);
  B[N] = 1;
    for(int a = N-1;a >= 0;a--){
    if(C[a] == 1){
      B[a] = 0;
    }else{
     B[a] = B[a+1]+B[a+2];
      B[a] %= 1000000007;
    }
  }
  cout << B[0] << endl;
}


Measured memory_bytes: 4840
#include<stdio.h>
int main(void){
int n,k;
  scanf("%d%d",&n,&k);
  long long a[n],sum=0;
  for(int i=0;i<n;i++){
	scanf("%lld",&a[i]);
    if(i<k)sum+=a[i];
  }
  for(int i=k;i<n;i++){
	if(sum<sum-a[i-k]+a[i])printf("Yes\n");
    else printf("No\n");
    sum-=a[i-k];
    sum+=a[i];
  }
  
  return 0;
}

Measured memory_bytes: 3108
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
AB = sorted(AB, key=lambda x: x[1])
A_sum=0
hantei = True
for i in range(N):
  A_sum += AB[i][0]
  if A_sum>AB[i][1]:
    hantei=False
    break
print('Yes' if hantei else 'No')

Measured memory_bytes: 55196
#include <stdio.h>
#include <math.h>
 
int main() {
 
  double d1,d2,d3,d4;
  int i,j,k,l,n;
  double x[1020] = {0};
  double y[1020] = {0};
  double z[1020] = {0};
  double o,p,q,max;
  max = -1;
  o=0;
  p=0;
  q=0;
  d1 = 0;
  d2 = 0;
  d3 = 0;
  d4 = 0;
 
  scanf("%d",&n);
 
  for(i=0; i<n; i++) {
    scanf("%lf",&x[i]);
  }
 
  for(i=0; i<n; i++) {
    scanf("%lf",&y[i]);
  }
 
  for(i=0; i<n;i++) {
 
    o = (x[i] - y[i]) * (x[i] - y[i]);
    p = (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
    p = p*p;
    p = sqrt(p);
   
    d3 = d3 + p;
    d2 = d2+o;
    d1 = d1 + sqrt(o); 
 
    if(max < sqrt(o)) {
      max = sqrt(o);
    }
 
    
  }
 
  d2 = pow(d2,1.0/2);
  d3 = pow(d3,1.0/3);
  d4 = max;
 
  printf("%.11lf\n%.11lf\n%.11lf\n%.11lf\n" ,d1,d2,d3,d4);
 
  return 0;
 
}


Measured memory_bytes: 2132
n,a,b = map(int,input().split())

v = list(map(int,input().split()))

v.sort(reverse=True)
d = dict()
for c in v:
    if d.__contains__(c):
        d[c]+=1
    else:
        d[c]=1

def C(x,y):
    if y>x:
        return 0
    if y>x//2:
        y = x-y
    res = 1
    for i in range(x,x-y,-1):
        res *= i
    for i in range(1,y+1):
        res //= i
    return res
m_sum = 0
m_cnt = 1
for i in range(a,b+1):
    if sum(v[:i])*m_cnt > i*m_sum:
        m_sum = sum(v[:i])
        m_cnt = i
m_idx = []
for i in range(a,b+1):
    if sum(v[:i])*m_cnt == i*m_sum:
        m_idx.append(i)
print("%0.6f"%(m_sum/m_cnt))

res_cnt = 0
for idx in m_idx:
    cnt_in = 0
    for i in range(idx-1,-1,-1):
        if v[i]==v[idx-1]:
            cnt_in+=1
        else:
            break
    res_cnt += C(d[v[idx-1]],cnt_in)
print(res_cnt)


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int N;
  cin>>N;
  vector<ll> data(N);
  for(int i=0;i<N;i++)cin>>data[i];
  sort(data.begin(),data.end());
  cout<<abs(data[0]-data.back())<<endl;
}

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

bool binary_search(int target, int low, int high, vector<int>& S) {
	int mid=low+(high-low)/2;
	if(S.at(mid)==target) {
		return true;
	}
	if(low>=high) return false;
	if(S.at(mid)>target) {
		return binary_search(target, low, mid-1, S);
	} else {
		return binary_search(target, mid+1, high, S);
	}
}

int main() {
	int n,q,a,c=0,i,j;
	vector<int> S;
	scanf("%d",&n);
	S.resize(n);
	for(i=0; i<n; ++i) {
		scanf("%d",&S[i]);
	}

	scanf("%d",&q);
	for(j=0; j<q; ++j) {
		scanf("%d",&a);
		if(binary_search(a,0,n-1,S)) ++c;
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 2788
#include <cstdio>

const int MOD = 924844033;
const int MAXN = 2000;

inline int add(int x, int y) {return (x + y >= MOD ? x + y - MOD : x + y);}
inline int sub(int x, int y) {return (x - y < 0 ? x - y + MOD : x - y);}
inline int mul(int x, int y) {return 1LL * x * y % MOD;}

int fct[MAXN + 5];
int f[2][2][MAXN + 5], h[2][2][MAXN + 5], g[MAXN + 5], t;
void init() {
	fct[0] = 1;
	for(int i=1;i<=MAXN;i++)
		fct[i] = mul(fct[i-1], i);
	g[t = 0] = 1;
}

void insert(int m) {
	for(int i=0;i<=t;i++)
		f[0][0][i] = f[0][1][i] = f[1][1][i] = 0, f[1][0][i] = g[i];
	for(int i=1;i<=m;i++) {
		for(int j=0;j<=t;j++)
			for(int p=0;p<=1;p++)
				for(int q=0;q<=1;q++)
					h[p][q][j] = f[p][q][j], f[p][q][j] = 0;
		t++, f[0][0][t] = f[0][1][t] = f[1][0][t] = f[1][1][t] = 0;
		for(int j=0;j<=t;j++)
			for(int p=0;p<=1;p++)
				for(int q=0;q<=1;q++) {
					f[q][0][j] = add(f[q][0][j], h[p][q][j]);
					if( p == 0 ) {
						f[q][0][j+1] = sub(f[q][0][j+1], h[p][q][j]);
						f[q][1][j+1] = sub(f[q][1][j+1], h[p][q][j]);
					}
					else f[q][1][j+1] = sub(f[q][1][j+1], h[p][q][j]);
				}
	}
	for(int i=0;i<=t;i++) g[i] = add(f[0][0][i], f[1][0][i]);
}

int a[MAXN + 5], N, K;
int main() {
	init(), scanf("%d%d", &N, &K);
	for(int i=1;i<=N;i++) a[i % K]++;
	for(int i=0;i<K;i++) insert(a[i]);
	int ans = 0;
	for(int i=0;i<=N;i++)
		ans = add(ans, mul(fct[N-i], g[i]));
	printf("%d\n", ans);
}

Measured memory_bytes: 256
INF = 10 ** 60

def li():
    return [int(x) for x in input().split()]


N = int(input())
h = li() + [INF] * 10

dp = [INF] * (N+10)

# 初期条件
dp[0] = 0
for i in range(N):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))

print(dp[N-1])

Measured memory_bytes: 89548
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void) {
	int i,n;
	unsigned int wa,tmp;
	int milk[10000];
	
	while(scanf("%d",&n)*n){
		for(i = 0;i < n;i++){
			scanf("%d",&milk[i]);
		}
		qsort(milk,n,sizeof(int),compare_int);
		wa = 0;
		tmp = 0;
		for(i = 0;i < n;i++){
			wa += tmp;
			tmp += milk[i];
		}
		
		printf("%u\n",wa);
	}
	return 0;
}

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

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

    vector<int> A;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        A.push_back(a);
    }

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

    vector<pair<int, int>> bc(m); 

    for(int i=0;i<m;i++){
        int b, c;
        cin >> b >> c;
         bc[i].first = c;
         bc[i].second = b;
    }

    sort(bc.begin(), bc.end(), greater<pair<int,int>>());

    //cの大きさ順で並び替え
    /*
    cout << A[0] << A[1] << A[2] << endl;
    /*
    cout << bc[0].first;
    cout << bc[1].first;
    */


    int itr=0;
    
    for(int i=0;i<m;i++){
        for(int j=0;j<bc[i].second;j++){
            if(A[itr] < bc[i].first){
                A[itr] = bc[i].first;
                itr++;
                if(itr >= n) break;
            }else{
                break;
            }
        }
        if(itr >= n) break;
    }

    long long ans = 0;

    rep(i, n){
        ans += A[i];
    }

    cout << ans << endl;

    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
typedef long long unsigned int ll;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int cnt = 1;
	char x = s[0];
	FOR(i, 1, s.size()) {
		if (x != s[i]) {
			cnt++;
			x = s[i];
		}
	}
	cout << cnt;
}

Measured memory_bytes: 512
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

Q = int(input())

L = []
R = []
for i in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)


def primes(max_r):
    is_prime = [True] * (max_r + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(max_r**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, max_r + 1, i):
            is_prime[j] = False
    return [i for i in range(max_r + 1) if is_prime[i] and is_prime[(i+1)//2]]


max_r = max(R)
ps = primes(max_r)

S = [0]
for i in range(1, max_r+1):
    if i in ps:
        S.append(S[i-1]+1)
    else:
        S.append(S[i-1])


for i in range(Q):
    print(S[R[i]] - S[L[i]-1])




Measured memory_bytes: 18076
#include <cstdio>
#include <cstring>
int w,h;
int f[22][22];
int dp[22][22];
int dx[] = {-1,0,1};
int solve(int x,int y){
  if(f[x][y] == 1) return 0;
  if(y >= h)return 1;
  if(f[x][y] == 1) return 0;
  if(dp[x][y] >= 0) return dp[x][y];
  if(f[x][y] == 2)return dp[x][y] = solve(x,y + 2);

  int ret = 0;
  for(int i = 0; i < 3; i++){
    int nx = x + dx[i];
    if(!f[nx][y+1] || (!dx[i] && f[nx][y+1] == 2)){
      ret += solve(nx,y+1);
    }
  }
  return dp[x][y] = ret;
}
int main(void){
  while(1){
    scanf("%d%d",&w,&h); if(!w) break;
    memset(f,-1,sizeof(f));
    memset(dp,-1,sizeof(dp));
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
	scanf("%d",&f[j][i]);
      }
    }
    int ans = 0;
    for(int j = 1; j <= w; j++){
      ans += solve(j,1);
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll N;
    cin >> N;
    ll A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    ll move = min({A, B, C, D, E});

    ll ans = ((N + move - 1) / move) + 4; // 切り上げ
    cout << ans << endl;
}

Measured memory_bytes: 256
S = gets.chomp
cnt = 0
for i in 0..S.length+1
	for j in 1..S.length-1
		if (S[i]==S[j])&&(i!=j)
			print "no"
			cnt = 1
			break
		end
	end
	break if cnt==1
	print "yes" if i==S.length+1
end

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);
    vector<pair<string,pair<int,int> > > s(N);
    Rep(i,N){
        cin >> s[i].first;
        Scd(s[i].second.first );
        s[i].second.second = i+1;
    }

    sort( s.begin(), s.end(), []( const pair<string,pair<int,int> > a, const pair<string,pair<int,int> > b){
           if( a.first.compare( b.first ) > 0 ) return false;
           if( a.first.compare( b.first ) < 0 ) return true;
           if( a.second.first > b.second.first ) return true;
           if( a.second.first < b.second.first ) return false;
    });

    Rep(i,N){
        printf ("%d\n", s[i].second.second );
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <queue>
#include <cmath>

#define INF 922337203685477580
typedef long long ll;

using namespace std;

typedef struct {
  double x, y;
} Point;

void solve(int d, Point p1, Point p2) {
  if (d == 0) return;

  Point s, t, u;
  t.x = (p1.x + 2 * p2.x) / 3;
  t.y = (p1.y + 2 * p2.y) / 3;
  s.x = (p1.x * 2 + p2.x) / 3;
  s.y = (p1.y * 2 + p2.y) / 3;

  double r3 = sqrt(3);
  u.x = (double)1/2*t.x - r3/2*t.y + (double)1/2*s.x + r3/2*s.y;
  u.y = r3/2*t.x + (double)1/2*t.y - r3/2*s.x + (double)1/2*s.y;

  solve(d - 1, p1, s);
  // print s,
  cout << s.x << " " << s.y << endl;
  solve(d - 1, s, u);
  // print u,
  cout << u.x << " " << u.y << endl;
  solve(d - 1, u, t);
  // print t,
  cout << t.x << " " << t.y << endl;
  solve(d - 1, t, p2);
}
int main() {
  int n;
  cin >> n;

  Point p1 = {0, 0};
  Point p2 = {100, 0};

  cout << p1.x << " " << p1.y << endl;
  solve(n, p1, p2);
  cout << p2.x << " " << p2.y << endl;
  return 0;
}

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

using ll = long long;

int main () {
    ll N, D, c = 0;
    cin >> N >> D;
    for (int i = 0; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= D * D) {
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
  int a;scanf("%d",&a);
  int L=a/100;
  int R=a%100;
  if(1<=L&&L<=12){
    if(1<=R&&R<=12)
      printf("AMBIGUOUS\n");
    else printf("MMYY\n");
  }
  else{
    if(1<=R&&R<=12)
      printf("YYMM\n");
    else printf("NA\n");
  }
  return 0;
  
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,i,l[9],ans;
void dfs(int x,int A,int B,int C,int s){
	if(x>n){
		if(A&&B&&C)ans=min(ans,s+abs(a-A)+abs(b-B)+abs(c-C));
		return;
	}
	dfs(x+1,A,B,C,s);
	dfs(x+1,A+l[x],B,C,s+10*(A>0));
	dfs(x+1,A,B+l[x],C,s+10*(B>0));
	dfs(x+1,A,B,C+l[x],s+10*(C>0));
}
int main(){
	ans=1e9;
	cin>>n>>a>>b>>c;
	for(i=1;i<=n;i++)cin>>l[i];
	dfs(1,0,0,0,0);
	cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int A, B;
	cin >> A >> B;
	for (int i = 1; i <= 100000; i++) {
		if ((int)(i * 0.08) == A && (int)(i /10) == B) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


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

#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,n) for(long long i=1;i<=(n);i++)
#define rep3(i,i0,n) for(long long i=i0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力
vector<ll> ans(100);
/*void renew(vector<vector<ll>> tree,ll key,ll parent,ll flag, ll p, ll x){//TLE
    if(flag == 1 || key == p){
        ans[key]+=x;
        flag = 1;
    }
    rep(i,tree[key].size()){
        //cout <<tree[key][i] << endl;
        if(tree[key][i] != parent){
            
            renew(tree,tree[key][i],key,flag,p,x);
        }
    }
}*/

/*vector<ll> parents(100);
void know_parent(vector<vector<ll>> tree, ll key, ll root){
    parents[key] = root;
    rep(i,tree[key].size()){
        if(tree[key][i] != root){
            know_parent(tree,tree[key][i],key);
        }
    }
}*/
vector<vector<ll>> t(100);
void renew(ll key,ll parent){
    rep(i,t[key].size()){
        if(t[key][i] != parent){
            ans[t[key][i]] += ans[key];
            renew(t[key][i],key);
        }
    }
}

int main() {
    
    ll N,Q;
    cin >> N >> Q;
    
    ans.resize(N);
    t.resize(N);
    ll a,b;
    rep(i,N-1){
        cin >>a>>b;
        a--;
        b--;
        t[b].pb(a);
        t[a].pb(b);
    }

    ll p,x;
    rep(i,Q){
        cin >> p >>x;
        p--;
        ans[p] += x;
    }

    
    //know_parent(t,0,-1);
    renew(0,-1);
 

    rep(i,N){
        cout << ans[i] << " ";
    }
    cout << endl;
    
    
    
    
    return 0;
    

}

Measured memory_bytes: 28272
import std.stdio : readf, readln, writefln;
import std.algorithm : map, reduce, max;
import std.array : split, array;
import std.conv : to;
import std.string : chomp;
import std.math : abs;

void main() {
	immutable numsCount = readln(). chomp.to!int;
	int[int] numSet;
	int[int] testSet;
	foreach(n; readln().chomp.split.map!(to!int)) {
		++numSet[n - 1];
		++numSet[n];
		++numSet[n + 1];
	}
	writefln("%d", numSet.byValue().reduce!(max));
}


Measured memory_bytes: 9148
import math
N = int(input())
character = list('abcdefghijklmnopqrstuvwxyz')
len_S = int(math.log(N*25+1, 26))
order = N - (26**(len_S)-1) / 25
ans = []
for i in range(len_S):
  c = int(order / 26 **(len_S-i-1))
  order -= 26 **(len_S-i-1) * c
  ans.append(character[c])
print("".join(ans))

Measured memory_bytes: 9128
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))

int Cn2(int n) {
	if (n < 2) {
		return 0;
	}

	return n * (n - 1) / 2;
}

int main(void) {
	int n, m;
	scanf("%d%d", &n, &m);
	printf("%d\n", Cn2(n) + Cn2(m));
	return 0;
}

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

int main() {
    long long N, x;
    cin >> N >> x;
    vector<long long> a(N), b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    b = a;
    long long ans = INF;
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            b[i] = min(b[i], a[(i - k + N) % N]);
        }
        long long tmp = x * k;
        for (int i = 0; i < N; i++) {
            tmp += b[i];
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<string> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    sort(all(vec));
    vec.push_back("");
    int c1 = 1;
    rep(i,N){
        if (i != N - 1 && vec[i] != vec[i + 1]){
            c1++;
        }
    }
    cout << c1 << endl;
}


Measured memory_bytes: 15668
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

MOD = 10**9+7

a,b,n = get_nums_l()

def f(a,b,x):
    return (a*x)//b - a * (x//b)

def solve(a,b,n):
    m = -999999999999
    mi = 0
    for x in range(n+1):
        y = f(a,b,x)
        if m < y:
            m = y
            mi = x
    return m,mi

print(f(a,b,min(n,b-1)))


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll r, g, b;
    cin >> r >> g >> b;
    if((100*r + 10*g + b)%4 ==0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

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

using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0 && c>0)
	{
		c = c-b;
		if(c<=0)
		break;
		a = a-d;
	}
	if(a>0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3632
import math

n=int(input())
s=[input() for i in range(n)]

std=[]
for i in range(n):
    std.append(sorted(s[i]))
stdx=[]
stdx=sorted(std)

cnt=0
k=1
for i in range(n-1):
    if stdx[i]==stdx[i+1]:
        k+=1
        if k>1 and i==n-2:
            cnt+=math.factorial(k)//math.factorial(k-2)//math.factorial(2)
    else:
        if k>1:
            cnt+=math.factorial(k)//math.factorial(k-2)//math.factorial(2)
            k=1

print(cnt)

Measured memory_bytes: 33472
#include <stdio.h>

int mystlen(char str[]);

int main(void)
{
	int x[10000], i, j=0;
	
	scanf("%d", &x[0]);
	
	while (x[j] != 0) {
		j++;
		
		if (j == 10000) {
			break;
		}
		scanf("%d", &x[j]);
	}
	for (i=1; i<=j; i++) {
				printf("Case %d: %d\n", i, x[i-1]);
	}
	return 0;
}

Measured memory_bytes: 636
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

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

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> ans(n);
    long i;
    for(i=0; i<n; i++) {
        ll a, b, c, d;
        scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

        if(a<b || d<b) {
            
        }
        else if (d==b) {
            ans[i] = (a%b <= c? 1: 0);
        }
        else {
            ll x = gcd(d, b);
            ans[i] = (b - x + (a % x) <= c? 1: 0);
        }
    }

    for(i=0; i<n; i++) {
        if(ans[i]) printf("Yes\n");
        else       printf("No\n");
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
const int MOD=1000000007;
vector<int>G[200005];
int main() {
  int N,M;
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  queue<int>q;
  q.push(0);
  vector<int>BACK(N,-1);
  while(!q.empty()){
    int NOW=q.front();q.pop();
    for(auto NEXT:G[NOW]){
      if(BACK[NEXT]!=-1){continue;}
      BACK[NEXT]=NOW;
      q.push(NEXT);
    }
  }
  cout<<"Yes"<<endl;
  for(int i=1;i<N;i++){
    cout<<BACK[i]+1<<endl;
  }

  return 0;
}

Measured memory_bytes: 12460
N,M=map(int,input().split())
ST=['WA'] * N
WA=[0]*N
OK=0
NG=0
for i in range(M):
  c,s = map(str,input().split())
  c = int(c)
  if s == 'WA':
    if ST[c-1] != 'AC':
      WA[c-1] += 1
  else:
    if ST[c-1] != 'AC':
      ST[c-1] = 'AC'
      OK += 1

for i,s in enumerate(ST):
  if s != 'AC':
    WA[i] = 0

print("{} {}".format(OK, sum(WA)))

Measured memory_bytes: 4596
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()

# 逆に考える
"""
X = gcd(A_1, A_2,...A_K)
となるようなXを考えると溶ける
X = 3の時その個数は
[K/3]**N
"""

x_cnt = [0] * (K + 1)
for x in range(K, 0, -1):
    # print(x)
    tmp = pow(K // x, N, mod)
    for j in range(x + x, K+1, x):
        tmp -= x_cnt[j]
    x_cnt[x] = tmp

ans = 0
for i in range(1,K+1):
    ans += i * x_cnt[i]
    ans %= mod
print(ans)


    



Measured memory_bytes: 13144
#include <bits/stdc++.h>
using namespace std;
int a[555555];
string st;
int gs(int x)
{
	int ans=0;
	while (x)
	{
		ans+=x%10;
		x/=10;
	}
	return ans;
}
int main()
{
	int n,m;
	int i,j,ans=0x7fffffff;
	cin>>n;
	for (i=1;i<n;i++)
	{
		j=n-i;
		ans=min(ans,gs(i)+gs(j));
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ll long long
#define pb push_back
#define fs first
#define se second
#define M 1000000007


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

bool check(int x,int y)
{
	return x>=0 && y>=0 && x<=2000 && y<=2000;
}
int fun()
{
	static int num = 16;
	return num--;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s,t;
	cin>>s>>t;
	int f=0;
	if(t[t.size()-1]>='a' && t[t.size()-1]<='z')
	{
		for(int i=0;i<s.size();i++)
		{
			if(s[i]!=t[i])
			{
				f=1;
				break;
			}
		}
	}
	else
		f=1;
	if(f==0)
		cout<<"Yes";
	else
		cout<<"No";
	cout<<endl;
	


}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,a[25],b,c,sum=0;
	bool flag[25]={};
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(i!=0&&a[i-1]==a[i]-1)flag[a[i-1]]=true;
	}
	for(int i=0;i<n;i++)
	{
		cin>>b;
		sum+=b;
	}
	for(int i=1;i<=n;i++)
	{
		cin>>c;
		if(flag[i])sum+=c;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	d := nextInts(n)

	sort.Ints(d)

	i1 := n/2 - 1
	i2 := n / 2

	if d[i1] != d[i2] {
		fmt.Println(d[i2] - d[i1])
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 2048
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

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

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int a = nextInt();
		int b = nextInt();

		if (a <= 5) {
			out.println(0);
		} else if (a <= 12) {
			out.println(b / 2);
		} else {
			out.println(b);
		}
	}

	private void solveB() {
		int r = nextInt();
		int d = nextInt();
		int x2000 = nextInt();

		int pre = x2000;
		for (int i = 1; i <= 10; i++) {
			out.println(r * pre - d);
			pre = r * pre - d;
		}

	}

	private void solveC() {
		int n = nextInt();

		out.println("");
	}

	private void solveD() {
		int n = nextInt();

		out.println("");
	}

	private void solveE() {
		int n = nextInt();

		out.println("");
	}

	private void solveF() {
		int n = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 21076
from collections import defaultdict
import heapq


def main():
    N, M = list(map(int, input().split(' ')))
    adj_nodes = defaultdict(list)
    for _ in range(M):
        a, b = list(map(lambda x: int(x) - 1, input().split(' ')))
        adj_nodes[a].append(b)
        adj_nodes[b].append(a)
    # Dijkstra
    INF = N + 1
    prevs = [i for i in range(N)]
    dist = [INF for _ in range(N)]
    dist[0] = 0
    frontier = [(0, 0)]  # cost, node
    while len(frontier) > 0:
        d, node = heapq.heappop(frontier)
        for next_node in adj_nodes[node]:
            if dist[next_node] > d + 1:
                dist[next_node] = d + 1
                prevs[next_node] = node
                frontier.append((d + 1, next_node))
    print('Yes')
    for i in range(1, N):
        print(prevs[i] + 1)


if __name__ == '__main__':
    main()


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

using namespace std;

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

    const int N = n+1;
    vector<int> city(N);
    int a, b;
    for (int i=0; i<m; ++i) {
        cin>>a>>b;
        city[a] += 1;
        city[b] += 1;
    }

    for (int i=1; i<N; ++i) {
        cout<<city[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum uint64

func main() {
	var N, K uint64
	fmt.Scan(&N, &K)
	A := make([]uint64, 2*N)
	var i uint64
	for i = 0; i < N; i++ {
		fmt.Scan(&A[i])
	}
	for i = 0; i < N; i++ {
		A[i+N] = A[i]
	}
	var j uint64
	for i = 0; i < 2*N-1; i++ {
		for j = i + 1; j < 2*N; j++ {
			if A[i] > A[j] && i < N && j < N {
				ans += (K * (K + 1) / 2)
				ans %= Umod
			}
			if A[i] > A[j] && j%N < i%N && N <= j {
				ans += (K * (K - 1) / 2)
				ans %= Umod
			}
		}
	}
	fmt.Println(ans % Umod)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


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

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

int main() {
    int n, x; cin >> n >> x;
    vector<int> dir(n);
    for (int i = 0; i < n; i++) {
        int X; cin >> X;
        dir.at(i) = abs(X - x);
    }
    int ans = dir.at(0);
    for (int i = 1; i < n; i++) {
        ans = gcd(ans, dir.at(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pb push_back
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string N;
  cin >> N;
  ll sum = 0;
  for (ll i = 0; i < N.size(); ++i) {
    sum += N.at(i) - '0';
  }
  if (sum % 9 == 0) {
    cout << "Yes" << "\n";
  }
  else {
    cout << "No" << "\n";
  }
}


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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    string s;
    cin >> s;
    if(s == "SUN") {
        cout << 7 << endl;
    } else if(s == "MON") {
        cout << 6 << endl;
    } else if(s == "TUE") {
        cout << 5 << endl;
    } else if(s == "WED") {
        cout << 4 << endl;
    } else if(s == "THU") {
        cout << 3 << endl;
    } else if(s == "FRI") {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  ll a,b,c=0,d=0,e,n,m,ans=0;
  string s,t;
  cin>>n;
  rep(i,1,n+1){
    rep(j,1,n+1){
      rep(k,1,n+1){
        a=gcd(i,j);
        c+=gcd(a,k);
      }
    }
  }
  co(c);
  
  return 0;
}

Measured memory_bytes: 3628
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i

xs = [a, b, c, d, e]
x = xs.min_by { |y| z = y - (y / 10 * 10); z == 0 ? 1000 : z }
idx = xs.find_index(x)
xs.delete_at(idx)

def round(n)
  return n if (n / 10 * 10) == n
  ((n / 10) + 1) * 10
end

puts x + xs.map { |y| round(y) }.inject(:+)


Measured memory_bytes: 1788
use std::str::FromStr;
use std::io;
use std::cmp;

fn main() {

    let mut line = String::new();
    io::stdin().read_line(&mut line);

    let mut count : i32 = 1;
    let mut result = String::new();

    for c in line.chars() {
        if count % 2 == 1 {
            result.push(c);
        }
        count += 1;
    }

    println!("{}", result);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n ; cin >> n;
    vector<vector<ll>> s(n,vector<ll>(n,0));
    rep(i,n){
        string t;
        cin >> t;
        rep(j,n){
          char c = t.at(j);
          if(c=='0') s.at(i).at(j) = INF; else s.at(i).at(j) = 1;
        }
    }
    rep(i,n){
        s.at(i).at(i) = 0;
    }
    vector<vector<ll>> wf = s;
    rep(k,n) rep(i,n) rep(j,n) wf.at(i).at(j) = min(wf.at(i).at(j) , wf.at(i).at(k) + wf.at(k).at(j));
    ll ans = 0;
    rep(i,n) rep(j,n) ans = max(ans,wf.at(i).at(j));
    
    /*
    rep(i,n){
      rep(j,n){
        cout << wf.at(i).at(j) << " ";
      }
      cout << endl;
    }
    */    

    rep(i,n){
        rep(j,n){
            if(s.at(i).at(j)==1){
                if(wf.at(0).at(i) == wf.at(0).at(j)){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    cout << ans + 1<< endl;
    return 0;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
int main(){
	int n,a[11],ans=1,res=1;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		ans*=3;
		res*=(2-a[i]%2);
	}
	printf("%d\n",ans-res);
	return 0;
}

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

static int N=1000;

int lcs(string x,string y){
  int num[N+5][N+5];
  int ans=0;
  int leng_x=x.size();
  int leng_y=y.size();  
  
  x=' '+x;
  y=' '+y;

  for(int i=1;i<=leng_x;i++)num[i][0]=0;
  for(int i=1;i<=leng_y;i++)num[0][i]=0;
  

  for(int i=1;i<=leng_x;i++){
    for(int j=1;j<=leng_y;j++){
      if(x[i]==y[j]) num[i][j]=num[i-1][j-1]+1;
      else num[i][j]=max(num[i][j-1],num[i-1][j]);
      ans=max(ans,num[i][j]);
    }
  }
  return ans;
}

int main(){
  string s1,s2;
  int q;

  cin>>q;
  for(int i=0;i<q;i++){
    cin>>s1>>s2;
    cout<<lcs(s1,s2)<<endl;
  }

  return 0;
}

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

using namespace std;

string s[333];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	int c = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < j; k++)
				if (s[(i + j) % n][k] != s[(i + k) % n][j])
					goto pnz;
		}
		c++;
	pnz:;
	}
	cout << n * c << endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
  int N;
  int K;
  int tmp = 1;

  scanf("%d\n", &N);
  scanf("%d", &K);

  for (int i = 0; i < N; ++i) {
    if (tmp < K) {
      tmp *= 2;
    } else {
      tmp += K;
    }
  }

  printf("%d", tmp);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdlib>
#define MAX 100
using namespace std;
int main()
{
	int n; cin >> n;
  	vector<int> x(n), y(n), h(n);
  	for (int i = 0; i < n; i++){
    	cin >> x[i] >> y[i] >> h[i];
    }
  	for (int posY = 0; posY <= MAX; posY++){
    	for (int posX = 0; posX <= MAX; posX++){
    		int needH = -1;
          	for (int i = 0; i < n; i++){
            	if (h[i] > 0){
                	int tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i]);
                  	if (needH == -1){
                    	needH = tmp;
                    } else {
                    	if (needH != tmp){
                        	needH = -2;
                          	break;
                        }
                    }
                }
            }
          	if (needH == -2){
            	continue;
            }
          	for (int i = 0; i < n; i++){
            	if (h[i] == 0){
                	int dist = abs(posY - y[i]) + abs(posX - x[i]);
                  	if (needH > dist){
                    	needH = -2;
                      	break;
                    }
                }
            }
          	if (needH == -2){
            	continue;
            }
          	cout << posX << " " << posY << " " << needH;
    	}	
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    lint H;
    cin >> H;
    lint keisu=1;
    lint atk=0;
    while(H>1){
        H/=2;
        atk+=keisu;
        keisu*=2;
    }
    atk+=keisu;
    cout << atk << endl;
}

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

int main() {
  string s;
  cin >> s;
  int counter = 0;
  for( int i = 0; i < 3; i++ ) {
    if( s[i] == 'o' )
      counter++;
  }
  cout << 700 + 100 * counter << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long ll;
 ll  pp=1e9+7; 
double pi=3.141592653589793238;
  
 int main() {
        ff;
        int x;
        cin>>x;
        if(x>=30){
            cout<<"Yes"<<endl;
        }else cout<<"No"<<endl;
		
    return 0;
}

            
		
        
           
  

Measured memory_bytes: 3636
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 210000;

int n;
int a[maxn];
ll sum[maxn];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+(ll)a[i];
	int las;
	for(int i=1;i<=n;i++) if(a[i]>sum[i-1]*2)
		las=i;
	printf("%d\n",n-las+1);
	
	return 0;
}


Measured memory_bytes: 1408
a,b,c,x,y = map(int,input().split())
ans = 0

if c*2 <= a+b:
    m = min(x,y)
    ans += m*c*2
    x -= m
    y -= m
    if 0 < x and c*x*2 < a*x:
        ans += (c*x*2)
    elif 0 < y and c*y*2 < b*y:
        ans += (c*y*2)
    else:
        ans += (a*x)+(b*y)
else:
    ans = (a*x)+(b*y)

print(ans)

Measured memory_bytes: 3064