akhauriyash/Code-Regression huggingface dataset:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N, K, Q = input_nums()

    score = {}
    for i in range(N):
        score[i] = 0

    for i in range(Q):
        A = int(input())
        score[A-1] += 1

    for k, v in score.items():
        # print(k, v)
        if K + v - Q > 0:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 15084
import java.util.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int [] A = new int[N];
    for(int  i= 0;i<N;i++){
      A[i] = sc.nextInt();
    }
    Arrays.sort(A);
    System.out.println(Math.abs(A[N-1]-A[0]));
  }
}
    


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

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

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

int main() {
	int a, b, t; scanf("%d%d%d", &a, &b, &t);
	
	printf("%d\n", t / a * b);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {

int al[30] = {0};
char b[2000]= {0};
int i,j,n;

i=0;

while( scanf("%c",&b[i]) != EOF) {

if (b[i] >= 'A' && 'Z' >= b[i] ) {
n = b[i] - 'A';
al[n] += 1;

} else if(b[i] >=  'a' && b[i] <= 'z' ) {
n = b[i] - 'a';
al[n] += 1;
}
i=i+1;
}

for(j=97; j<=122; j++) {
n = j - 'a';
printf("%c : %d\n",j,al[n]);
}

return 0;

}



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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
int inf = 1e9 + 7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> H(101000);
    rp(i, 0, n) scanf("%d", &H.at(i));
    vector<int> dp(101000, inf);
    dp.at(0) = 0;
    rp(i, 0, n) {
        rp(j, 1, k+1) {
            chmin(dp.at(i+j), dp.at(i) + abs(H.at(i) - H.at(i+j)));
        }
    }
    printf("%d", dp.at(n-1));
    return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  
  cin >> A >> B;
  
  int count = 1;
  int hole = A;
  
  while(hole < B){
    hole += A-1;
    count++;
  }
  if(B>1) cout << count << endl;
  else cout << 0 << endl;
  
}

Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;

vector<int> g[201];
int n;

int color[201];

bool bfs() { 
  for (int i = 0; i < n; ++i) {
    color[i] = -1;
  }
  color[0] = 0;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int v = q.front();q.pop();
    for (int to: g[v]) {
      if (color[to] >= 0) { 
        if (color[v]==color[to]) return false;
        continue;
      }
      color[to] = 1 - color[v];
      q.push(to);
    }
  }
  return true;
}

int bfs2(int s) { 
  vector<int> level(n, -1);
  level[s] = 1;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int v = q.front();q.pop();
    assert(level[v] != -1);
    for (int to: g[v]) {
      if (level[to] != -1) {
        assert(abs(level[v]-level[to]) == 1);
        continue;
      }
      level[to] = level[v] + 1;
      // cout << v << " " << to << " " << level[to] << endl;
      q.push(to);
    }
  }
  int ret = 1;
  for (int i = 0; i < n; ++i) { 
    assert(level[i] != -1);
    assert(level[i] <= n);
    ret = max(ret, level[i]);
  }
  return ret;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    assert(s.size() == n);
    for (int j = 0; j < n; ++j) { 
      if (j >= i) continue;
      if (s[j] == '1') { 
        g[i].push_back(j);
        g[j].push_back(i);
      }
    }
  }

  bool can_build = bfs();
  if (!can_build) {
    cout << "-1" << endl;
    return 0;
  }
  int ans = 1;
  for (int i = 0; i < n; ++i) {
    int l = bfs2(i);
    ans = max(ans, l);
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=200005;
int n,empty,m; 
int a[maxn],cnt[maxn],b[maxn];

int main(){
	scanf("%d%d",&n,&m);
	empty=n; 
	REP(i,n){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
		int pos=a[i]-cnt[a[i]]+1;
		if(pos>=1){
			if(b[pos]==0)empty--;
			b[pos]++;
		}
	}
	while(m--){
		int x,y;
		scanf("%d%d",&x,&y);
		int pos=a[x]-cnt[a[x]]+1;
		if(pos>=1){
			b[pos]--;
			if(b[pos]==0)empty++;
		}
		cnt[a[x]]--;
		a[x]=y;
		cnt[a[x]]++;
		pos=a[x]-cnt[a[x]]+1;
		if(pos>=1){
			if(b[pos]==0)empty--;
			b[pos]++;
		}
		printf("%d\n",empty);
	}
	return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long c = 1;
		long d = x;
		long e = b / x;
		long f = 0;
		if (a % x == 0) {
			f = a / x - 1;
		}else{
			f = a / x;
		}
		System.out.println(e - f);
	}
}


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

public class Main {

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

	final int MAX = 100000;

	public Main() {
		Scanner sc = new Scanner(System.in);
		boolean sieve[] = new boolean[MAX + 1];
		Arrays.fill(sieve, true);
		Arrays.fill(sieve, 0, 2, false);
		for (int i = 2;i < sieve.length;++ i) if (sieve[i]) for (int j = 2 * i;j < sieve.length;j += i) sieve[j] = false; // エラトステネスの篩
		int cumsum[] = new int[MAX + 1];
		cumsum[0] = 0;
		for (int i = 1;i < cumsum.length;++ i) cumsum[i] = cumsum[i - 1] + (sieve[i] & sieve[(i + 1)/ 2] ? 1 : 0); // 累積和
		int Q = sc.nextInt();
		while(Q-- != 0) {
			int l = sc.nextInt(), r = sc.nextInt();
			System.out.println(cumsum[r] - cumsum[l - 1]);
		}
		sc.close();
	}
}


Measured memory_bytes: 64144
//貪欲に置くシミュレーションで実験すると、0-indexedで「偶数行, 奇数列」には置けなさそうなことが分かる。
//…他の場所は置けるんじゃない？
#include <iostream>
using namespace std;

int q;
int a, b, c, d;

int main() {
	int i;
	
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> a >> b >> c >> d;
		a--; b--;
		
		int i, j;
		int ans = 0;
		for (i = a; i < c; i++) {
			for (j = b; j < d; j++) {
				if (i % 2 == 0 && j % 2 == 1) continue;
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
 int n;
 cin >> n;
 for(int i=1;i<=n;i++){
  if(i%3==0)cout << " " << i ;
  else{
   for(int x=i;x!=0;x/=10){
    if(x%10==3){
     cout << " " << i ;
     break;
    }
   }
  }
 }
 cout << endl;

 return 0;
}

Measured memory_bytes: 3076
$<.map{|s|
    a=s.split.map &:to_i;
    next if a.size<3;
    if a[0]==100||a[1]==100||a[2]==100;puts"A";
    elsif (a[0]+a[1])/2>=90;puts"A";
    elsif a.inject(:+)/3>=80;puts"A";
    elsif a.inject(:+)/3>=70;puts"B";
    elsif a.inject(:+)/3>=50&&(a[0]>=80||a[1]>=80);puts"B";
    else;puts"C";
    end
}


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

typedef pair<int,int> pii;

const int N = 1e5;

vector<pii> cek;
vector<int> adj[N+5];
int par[N+5];

int find_par(int x){
	if(par[x] == x) return x;
	return par[x] = find_par(par[x]);
}

int n,m;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i=1;i<=n;i++) par[i] = i;
	for(int i=1;i<=m;i++){
		int u,v,w;
		cin >> u >> v >> w;
		int pu = find_par(u);
		int pv = find_par(v);
		if(pu!=pv){
			par[pu] = pv;
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(find_par(i) == i) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long 

int main()
{
	string s,t;
	cin>>s;
	cin>>t;
	ll score=0;
	for(ll i=0;i<s.length();i++)
		if(s[i]!=t[i])
			score++;
	cout<<score;
}


Measured memory_bytes: 3852
n = int(input())
ls = list( map(int,input().split()) )

ans = 0
tmp = 0
for i in range(n-1):
  if ls[i] >= ls[i+1]:
    tmp +=1
  else:
    ans = max(ans,tmp)
    tmp=0
ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 14252
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<unordered_set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (200000)

unordered_set<long long>sm[N];
int ism[N];
long long a[N];
int p[N];
int d[N];
int from[N];
int to[N];
long long dis[N];
bool v[N];

void init(void){
	f(i, N){
		ism[i] = i;
		p[i] = i;
		d[i] = 1;
		a[i] = 0;
		from[i] = 0;
		to[i] = 0;
		dis[i] = 0;
		v[i] = false;
	}
	return;
}

int pa(int x){
	if (p[x] == x)return x;
	else return p[x] = pa(p[x]);
}


void uni(int z){
	int x = from[z];
	int y = to[z];
	int px = pa(x);
	int py = pa(y);
	long long ss;
	int iism;
	if (px == py){
		ss = a[px];
		iism = ism[px];
	}
	else{
		if (sm[ism[px]].size() > sm[ism[py]].size()){
			if (sm[ism[py]].size() > 0){
				auto itr = sm[ism[py]].begin();
				while (itr != sm[ism[py]].end()){
					sm[ism[px]].insert(*itr);
					itr++;
				}
			}
			iism = ism[px];
			if (d[px] < d[py]){
				p[px] = py;
				d[py] = max(d[py], d[px] + 1);
				a[py] += a[px];
				ss = a[py];
				ism[py] = ism[px];
				a[px] = 0;
			}
			else{
				p[py] = px;
				d[px] = max(d[px], d[py] + 1);
				a[px] += a[py];
				ss = a[px];
				a[py] = 0;
			}
		}
		else{
			if (sm[ism[px]].size() > 0){
				auto itr = sm[ism[px]].begin();
				while (itr != sm[ism[px]].end()){
					sm[ism[py]].insert(*itr);
					itr++;
				}
			}
			iism = ism[py];
			if (d[px] < d[py]){
				p[px] = py;
				d[py] = max(d[py], d[px] + 1);
				a[py] += a[px];
				ss = a[py];
				a[px] = 0;
			}
			else{
				p[py] = px;
				d[px] = max(d[px], d[py] + 1);
				a[px] += a[py];
				ss = a[px];
				ism[px] = ism[py];
				a[py] = 0;
			}
		}
}
	sm[iism].insert(z);
	if (dis[z] <= ss){
		if (sm[iism].size()>0){
			auto itr2 = sm[iism].begin();
			while (itr2 != sm[iism].end()){
				v[*itr2] = true;
				itr2++;
			}
		}
		sm[iism].clear();
	}


	return;
}





int main(void){
	int n, m, ans;
	vector<pair<long long, int> >as;
	init();
	scanf("%d %d", &n, &m);
	f(i, n)scanf("%lld", &a[i]);
	f(i, m){
		scanf("%d %d %lld", &from[i], &to[i], &dis[i]);
		from[i]--;
		to[i]--;
		as.push_back(make_pair(dis[i], i));
	}
	sort(as.begin(), as.end());
	f(i, m){
		uni(as[i].second);
	}
	ans = 0;
	f(i, m){
		if (!v[i])ans++;
	}
	printf("%d\n", ans);


	return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  
  for(int i=0;i<N;i++)cin>>a[i];
  
  int ans=0;
  for(int i=0;i<N;i+=2){
    if(a[i]%2!=0)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

#define int ll

int n;
int x[N], y[N];
int mx;
vector <int> ans;
int32_t main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	cin >> n;
	set <int> st;
	rep(i, 1, n) {
		cin >> x[i] >> y[i];
		st.insert((x[i] + y[i]) & 1);
		mx = max(mx, x[i] + y[i]);
	}
	if (sz(st) == 2) cout << -1, ioi
	ll sum = 0;
	if (*st.begin() == 0) {
		ans.pb(1);
		++sum;
	}
	ll id = 1;
	while (sum < mx) {
		ans.pb(id);
		sum += id;
		id <<= 1;
	}
	cout << sz(ans) << nl;
	for (auto it : ans) cout << it << ' ';
	cout << nl;
	reverse(all(ans));

	auto good = [&] (int x, int y, int z) {
		return abs(x) + abs(y) <= z;
	};

	rep(i, 1, n) {
		int cur = sum;
		int cx = x[i], cy = y[i];
		string s;
		for (auto it : ans) {
			cur -= it;
			if (good(cx + it, cy, cur)) {
				cx += it;
				s += 'L';
			} else if (good(cx - it, cy, cur)) {
				cx -= it;
				s += 'R';
			} else if (good(cx, cy + it, cur)) {
				cy += it;
				s += 'D';
			} else {
				cy -= it;
				s += 'U';
			}
		}
		reverse(all(s));
		cout << s << nl;
	}
	ioi
}


Measured memory_bytes: 2304
N,Y=map(int,input().split())
Y//=1000
x,y,z=-1,-1,-1
for i in range(min(N,Y//10),-1,-1):
    n=N-i
    t=Y-10*i
    for j in range(min(n,t//5),-1,-1):
        if n-j==t-5*j:
            x,y,z=i,j,n-j
            break
    else:continue
    break
print(x,y,z)

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

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

    ll N, D;
    cin >> N >> D;
    vector<pair<ll, ll>> xys(N, {0, 0});
    for (auto &xy : xys) cin >> xy.first >> xy.second;

    const ll d2 = D * D;
    int ans = 0;
    for (const auto [x, y] : xys) {
        const ll p2 = x * x + y * y;
        if (p2 <= d2) ++ans;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 6348
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){

  int C[VMAX+1];
  int n, i, j;
  int *A, *B;
  
  scanf("%d", &n);

  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);

  for (i=0;i<=VMAX;i++) C[i] = 0;

  for (i=0;i<n;i++){
    scanf("%d", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for (i =1;i<=VMAX;i++) C[i] = C[i] + C[i - 1];

  for (j=1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for (i=1;i<=n;i++){
    if (i>1) printf(" ");
    printf("%d", B[i]);
  }

  printf("\n");

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  char unit;
  unit = N%10;
  if(unit==0||unit ==1||unit ==6||unit ==8){
    cout << "pon" << endl;
  }else if(unit == 2||unit == 4|| unit == 5|| unit==7 ||unit == 9){
    cout << "hon" << endl;
  }else{
    cout << "bon" << endl;
  }
  
  return 0;
}

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

#define reps(i, a, b) for (int i = (a); i < (b); i++)
#define rreps(i, a, b) for (int i = (int) (a) - 1; i >= (b); i--)

vector<pair<int, char>> b(int N, const vector<pair<int, char>>& v) {
	auto res = v;
    reps(i, 0, N) {
        rreps(j, N, i+1) {
            if (res[j].first < res[j-1].first) {
                swap(res[j], res[j-1]);
            }
        }
    }
	return res;
}

vector<pair<int, char>> s(int N, const vector<pair<int, char>>& v) {
	auto res = v;
    reps(i, 0, N) {
        int mi = i;
        reps(j, i, N) {
            if (res[j].first < res[mi].first) {
                mi = j;
            }
        }
        if (i != mi) swap(res[i], res[mi]);
    }
	return res;
}

int main() {
    int N;
	cin >> N;
    vector<pair<int, char>> v;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        v.emplace_back(s[1]-'0', s[0]);
    }
    auto a = b(N, v);
    auto w = s(N, v);
    for (int i = 0; i < N; i++) {
		if (i) cout << " ";
        cout << a[i].second << a[i].first;
    }
    cout << endl << "Stable" << endl;
    for (int i = 0; i < N; i++) {
		if (i) cout << " ";
        cout << w[i].second << w[i].first;
	}
	cout << endl;
    if (a == w) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
}



Measured memory_bytes: 3160
#0926
class UnionFind(): # 0インデックス
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

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

        if x == y:
            return

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

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

    def size(self, x):
        return -self.parents[self.find(x)]
    
    def test(self):
        return self.parents
    def test2(self):
        return sum(z <0 for z in self.parents)
    
N, M = map(int, input().split()) # N人、M個の関係
uf = UnionFind(N)
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    uf.union(A, B)
    
print(uf.test2()-1)

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

#define int long long

using namespace std;

const int maxn = 2e5 + 10;
int ans, n, m;
vector<pair<int, int>> event[maxn];

#define lc (v << 1)
#define rc (lc | 1)
#define tm (tl + tr >> 1)

int t[maxn << 2], lazy[maxn << 2];

void shift(int v)
{
    t[lc] += lazy[v];
    t[rc] += lazy[v];
    lazy[lc] += lazy[v];
    lazy[rc] += lazy[v];

    lazy[v] = 0;
}

void update(int l, int r, int x, int v = 1, int tl = 0, int tr = n - 1)
{
    if (l > r)
        return;
    if (tl == l && tr == r)
        t[v] += x, lazy[v] += x;
    else
    {
        shift(v);
        update(l, min(r, tm), x, lc, tl, tm);
        update(max(l, tm + 1), r, x, rc, tm + 1, tr);
        t[v] = max(t[lc], t[rc]);
    }
}

int get(int l, int r, int v = 1, int tl = 0, int tr = n - 1)
{
    if (l > r)
        return 0;
    if (tl == l && tr == r)
        return t[v];
    shift(v);
    return max(get(l, min(r, tm), lc, tl, tm), get(max(l, tm + 1), r, rc, tm + 1, tr));
}

signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;

    for (int i = 0, l, r, w; i < m; i++)
        cin >> l >> r >> w, event[r - 1].push_back({l - 1, w});
    for (int i = 0; i < n; i++)
    {
        update(i, i, ans);
        for (auto u : event[i])
            update(u.first, i, u.second);
        ans = max(0ll, get(0, i));
    }

    cout << ans;

    return 0;
}


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

int main(int argc, char *argv[])
{
    int in, i;
    char line[256];

    for (i=1; ; i++) {

        memset(line, 0, sizeof(line));
        if (!fgets(line, sizeof(line), stdin)) {
            fprintf(stderr, "error input val\n");
            return -1;
        }

        if (sscanf(line, "%d", &in) != 1) {
            fprintf(stderr, "error input format\n");
            return -1;
        }

        if (!in) {
            break;
        }
        printf("Case %d: %d\n", i, in);
    }

    return 0;
}

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

struct dsu {
	vector<int> chot;
	int n;
	dsu(int n) : n(n) {
		chot.resize(n + 1,-1);
	}
	int find(int u) {
		return chot[u] < 0 ? u : chot[u] = find(chot[u]);
	}
	void combine(int u,int v) {
		if ((u = find(u)) != (v = find(v))) {
			if (-chot[u] < -chot[v]) swap(u,v);
			chot[u] += chot[v];
			chot[v] = u;
		}
	}
};
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
	vector<int> id(n);
	iota(id.begin(),id.end(),0);
  sort(id.begin(),id.end(),[&](int i,int j) {
  	return x[i] < x[j];
	});
  dsu d(n);
  vector<int> s;
  for (int i = 0; i < n; i++) {
  	int mx = -1;
  	while ((int)s.size() && y[s.back()] <= y[id[i]]) {
  		if (mx == -1) mx = s.back();
  		d.combine(id[i],s.back());
  		s.pop_back();
		}
		if (mx == -1) s.push_back(id[i]);
		else s.push_back(mx);
	}
	s.clear();
	for (int i = n-1; i >= 0; i--) {
		int mx = -1;
  	while ((int)s.size() && y[s.back()] >= y[id[i]]) {
  		if (mx == -1) mx = s.back();
  		d.combine(id[i],s.back());
  		s.pop_back();
		}
		if (mx == -1) s.push_back(id[i]);
		else s.push_back(mx);
	}
	for (int i = 0; i < n; i++) cout << -d.chot[d.find(i)] <<"\n";
} 

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

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

    ll n, k, q;
    cin >> n >> k >> q;
    vll p(n, (k - q));
    ll a;
    REP(i, q){
        cin >> a;
        a--;
        p[a]++;
    }
    ll res = 0;
    REP(i, n){
        if(p[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define LL_INF (numeric_limits<long long>::max()/2)
#define int long long

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

const int kMaxN = 100;

int N;
int x[kMaxN], y[kMaxN], h[kMaxN];
int ans = 0;

void Swap(int a[], int i, int j) {
  int tmp = a[i];
  a[i] = a[j];
  a[j] = tmp;
}

signed main() {
  cin >> N;
  REP(i, N) { cin >> x[i] >> y[i] >> h[i]; }

  int idx = 0;
  while (h[idx] == 0) { ++idx; }
  Swap(x, 0, idx);
  Swap(y, 0, idx);
  Swap(h, 0, idx);

  int Cx, Cy, H;
  FOR(i, 0, 100) {
    FOR(j, 0, 100) {
      Cx = i; Cy = j;
      H = h[0] + ABS(x[0]-Cx) + ABS(y[0]-Cy);
      bool f = true;
      REP(k, N-1) {
        // cout << h[1+k] << endl;
        // cout << H-ABS(x[1+k]-Cx)-ABS(y[1+k]-Cy) << endl;
        if (h[1+k] != MAX(H-ABS(x[1+k]-Cx)-ABS(y[1+k]-Cy), 0)) {
          f = false;
          break;
        }
      }
      if (f) { goto r;}
    }
  }

r:
  cout << Cx << " " << Cy << " " << H << endl;
  return 0;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

template<typename T>
bool chmax(T& a,T b){ if(a<b){ a=b;return true; }return false; }
template<typename T>
bool chmin(T& a,T b){ if(a>b){ a=b;return true; }return false; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in();
	set<int> use;
	
	ll X=0,K=1;
	while(true){
		if(!((10ll*X+7ll)%N)){
			out(K);
			return 0;
		}
		X = (10ll*X+7ll)%N;
		auto res = use.insert(X);
		if(!res.second){
			out(-1);
			return 0;
		}
		K++;
	}

	return 0;
}


Measured memory_bytes: 50408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemA
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();
            S = S.Distinct().ToArray();
            Console.WriteLine(S.Count() == 2 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13280
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
#pragma endregion

int main()
{
  init_main();

  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  bool used[200010] = {};

  rep(i, n)
  {
    cin >> a[i];
    a[i]--;
  }
  if (a[0] == 0)
  {
    cout << 1 << endl;
    return 0;
  }

  int now = 0;
  ll cnt = 0;
  vector<int> v;
  while (!used[now] && cnt < k)
  {
    v.emplace_back(now);
    cnt++;
    used[now] = true;
    now = a[now];
  }
  if (k == cnt)
  {
    cout << now + 1 << endl;
    return 0;
  }
  k -= cnt;
  int pos;
  rep(i, v.size())
  {
    if (now == v[i])
    {
      pos = i;
      break;
    }
  }
  
  ll len = v.size() - pos;
  k %= len;
  rep(i, k)
  {
    now = a[now];
  }
  cout << now + 1 << "\n";
  return 0;
}


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

int main()
{
    string a,b;
    int i,l,c=0;
    cin>>a>>b;
    l=a.length();
    for(i=0;i<l;i++)
    {
        if(a[i]!=b[i])
        {
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

struct UnionFind {
    vector<ll> par, s, w;
    UnionFind(int n, vector<ll> a) : par(n), s(n, 1), w(a) {
        iota(par.begin(), par.end(), 0);
    }
    ll find(int x) {
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(s[x] < s[y]) par[x] = y, s[y] += s[x], w[y] += w[x];
        else par[y] = x, s[x] += s[y], w[x] += w[y];
    }
    bool same(int x, int y) { return find(x) == find(y); }
    ll size(int x) { return s[find(x)]; }
    ll weight(int x) { return w[find(x)]; }
};

int main(void) {
    ll n, m;
    cin >> n >> m;
    vector<ll> x(n);
    REP(i, n) cin >> x[i];
    vector<ll> a(m), b(m), y(m);
    vector<vector<PII>> g(n);
    REP(i, m) {
        cin >> a[i] >> b[i] >> y[i];
        a[i]--, b[i]--;
        g[a[i]].push_back({b[i], i});
        g[b[i]].push_back({a[i], i});
    }

    vector<ll> ord(m);
    iota(ALL(ord), 0LL);
    sort(ALL(ord), [&](ll l, ll r){ return y[l] < y[r]; });

    // 重みがy[i]以下の辺が全て追加された状態 
    // 辺iが属する連結成分の頂点重みがy[i]以上 → iから重みy[i]以下の辺をたどって到達できる辺は残せる 
    vector<ll> ok;
    UnionFind uf(n, x);
    for(auto i: ord) {
        uf.unite(a[i], b[i]);
        if(uf.weight(a[i]) >= y[i]) ok.push_back(i);
    }
    dump(ok);

    // 残せる辺の和集合を取る
    ll ret = 0;
    vector<bool> used(m);
    function<void(ll,ll)> dfs = [&](ll v, ll ub) {
        for(auto to: g[v]) {
            if(y[to.second] <= ub && !used[to.second]) {
                ret++;
                used[to.second] = true;
                dfs(to.first, ub);
            }
        }
    };
    reverse(ALL(ok));
    for(auto i: ok) if(!used[i]) dfs(a[i],y[i]);

    cout << m-ret << endl;    

    return 0;
}


Measured memory_bytes: 22000
def spaceinput():
    return list(map(int,input().split(" ")))


N=int(input())
a=spaceinput()

a.insert(0,0)

count=0
for i in range(1,len(a)-1):
    #print(i,a)
    if i==len(a)-2:
        #print(a,N)
        if a[-1]==N:
            count+=1
            break

    if i==a[i]:
        count+=1
        s=a[i]
        a[i]=a[i+1]
        a[i+1]=s


print(count)

Measured memory_bytes: 14008
#include<stdio.h>

int main(void)
{
	int S, h, m, s;
	
	scanf("%d", &S);
	
	h = S / 3600;
	m = S % 3600 / 60;
	s = S % 3600 % 60;
	
	printf("%d:%d:%d\n", h, m, s);
	
	return(0);
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

int N;

void dfs(string s, char mx) {
  if (N == s.size()) {
    cout << s << endl;
  } else {
    for (char c = 'a'; c <= mx; c++) {
      dfs(s + c, (c == mx) ? (mx + 1) : mx);
    }
  }
}

void solve() {
  cin >> N;
  dfs("", 'a');
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 1536
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define pll pair <lli,lli> 
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=1e7+1;
const lli INF=2e18;
const ld PI=acos(-1);
 
int main(){
    rapgame
    //freopen("brokeday.in", "r", stdin);
    //freopen("richday.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        lli a,b,c;
        cin >> a >> b >> c;
        if(a%2==0 || b%2==0 || c%2==0) cout << 0;
        else cout << min(min(a*c,b*c),a*b);
    }
    return 0;
}

Measured memory_bytes: 3604
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define out(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define out2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define min(v) *min_element(all(v))
#define max(v) *max_element(all(v))
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    lint n,k;
    cin>>n>>k;
    vec a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    pvec p(n);
    rep(i,n)p[i]=make_pair(a[i],b[i]);
    sort(all(p));
    rep(i,n){
        if(p[i].second>=k){
            cout<<p[i].first;
            return 0;
        }
        else k-=p[i].second;
    }
}

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

int main(){
  int a, b, c, d, e, k;
  scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &k);
  if(e - a > k){
    printf(":(");
  }
  else{
    printf("Yay!");
  }
  return 0;
}

Measured memory_bytes: 3792
n = int(input())
p = list(map(int, input().split()))

ans = 0
min_n = 0
for i in range(len(p)):
    if i==0:
        ans += 1
        min_n = p[i]
    else:
        if p[i] <= min_n:
            ans += 1
            min_n = p[i]
        else:
            pass

print(ans)

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

int main(){
  int k,s;
  int ans=0;
  cin >> k >> s;
  for(int x=0; x<=k; x++){
    for(int y=0; y<=k; y++){
      int z = s-x-y;
      if(0<=z&&z<=k) ans++;
    }
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N, K, Q = [int(x) for x in input().split()]
A = []
for _ in range(Q):
    A.append(int(input()))

score = [0] * N
for i in A:
    score[i - 1] += 1


for i in score:
    if K - Q + i <= 0:
        print("No")
    else:
        print("Yes")


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

int main(){
    string ss;
    int sum = 0;
    while( cin >> ss ){
        for( string::iterator it = ss.begin(); it != ss.end(); it++){
            if( isdigit(*it) ){
                int a = *it - '0';
                while( ++it != ss.end() && isdigit(*it) ){
                    a *= 10;
                    a += *it - '0';
                }
                if( it == ss.end() ) it--;
                sum += a;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1184
def main():
    s=input()
    while len(s)>0:
        if s[-5:]=='dream':
            s=s[:-5]
        elif s[-7:]=='dreamer':
            s=s[:-7]
        elif s[-5:]=='erase':
            s=s[:-5]
        elif s[-6:]=='eraser':
            s=s[:-6]
        else:
            print('NO')
            exit()
    print('YES')
main()

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

int main(void) {
	int r, D, x;
	scanf("%d %d %d", &r, &D, &x);
	for (int i = 0; i < 10; i++) {
		x = r * x - D;
		printf("%d\n", x);
	}

	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  long int n;
  int i;
  int a[200001];
  int sum[200001] = {0};
  
  do {
    scanf("%ld",&n);
  } while(n<2 || n>200000);
  
  for(i=2; i<=n; i++){
    do {
      scanf("%d ",&a[i]);
    } while(a[i]<1 || a[i]>=i);
      sum[a[i]]++;
  }
  for(i=1; i<=n; i++)
    printf("%d\n",sum[i]);
  
  return 0;
}


Measured memory_bytes: 3300
n = gets.chop.to_i

a = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)

asum = a.inject(:+)
n.times do |i|
  if a[i] > b[i]
    a[i] = a[i] - b[i]
  else
    b[i] = b[i] - a[i]
    a[i] = 0
    if a[i+1] > b[i]
      a[i+1] = a[i+1] - b[i]
    else
      a[i+1] = 0
    end
  end
end

asumresult = a.inject(:+)

if asum > asumresult
  puts asum - asumresult
else
  puts asumresult.inject(:+)
end


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

int main(){

    int a,b,c;
    cin >> a >> b >> c;

    if(a<=b){
        if(a<=c&&c<=b){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;            
        }
    }else{
        if(b<=c&&c<=a){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	ll a,b,x;
    cin >> a >> b >> x;
    cout << (a%x==0?b/x-a/x+1:b/x-a/x) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<numeric>
#include<limits>
using namespace std;
int main(){
    long a, b;
    cin >> a >> b;
    long ans;
    ans = a*b;
    int tmp;
    if( a < b){
        tmp = a;
        a = b;
        b = tmp;
    }
    long r;
    r = a%b;
    while(r!=0){
        a =b;
        b= r;
        r = a%b;
    }
    cout << ans/b << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  string S; cin>>S;
  if(S.size()==1){
    cout<<1<<endl;
    return 0;
  }
  vector<ll>A(S.size()+1);
  ll keep=0;
  for(int i=0; i<S.size(); i++){
//    cout<<"i:"<<i<<" keep:"<<keep<<endl;
    if(i==S.size()-1 && S[i]=='>'){
      keep++;
      for(int j=i-keep+1; j<=i+1; j++){    
        A[j]=max(A[j],keep);
        keep--;
      }
    }
    if(S[i]=='<'){
      if(keep!=0){
        for(int j=i-keep; j<=i; j++){
          A[j]=max(A[j],keep);
          keep--;
        }
      }
      keep=0;
      A[i+1]=A[i]+1;
    }    
    else if(S[i]=='>'){
      keep++;
    }
  }
  ll ans=0;
  for(int i=0; i<A.size(); i++){
    ans+=A[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4740
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,m,i,c=0;
    cin>>n>>m;
    long long int a[n+1],b[n+1]={0};
    for(i=1;i<=n;i++)
    cin>>a[i];
    while(m--){
    	long long int x,y;
    	cin>>x>>y;
    	if(a[x]==a[y])
    	{
    		b[x]=-1;
    		b[y]=-1;
		}
    	else if(a[x]>a[y]){
    		b[y]=-1;
		}
		else if(a[x]<a[y]){
			b[x]=-1;
		}
	}
	for(i=1;i<=n;i++){
		if(b[i]==0){
			c++;
		}
	}
    cout<<c;
    return 0;
}

Measured memory_bytes: 5156
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

ll a[100003], b[100003];

int main() {
	int n; ll h; cin >> n >> h;
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	sort(a, a + n);
	sort(b, b + n);
	ll cnt = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (b[i] < a[n - 1]) break;
		cnt++;
		h -= b[i];
		if (h <= 0) {
			cout << cnt << endl;
			return 0;
		}
	}
	cout << cnt + h / a[n - 1] + (h%a[n - 1] == 0 ? 0 : 1) << endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val k = sc.nextInt()
  val q = sc.nextInt()
  val a = (1..q).map { sc.nextInt() }

  val array = Array(n) { k }

  for (ai in a) {
    array[ai - 1] += 1
  }

  val ans = Array(n) { "Yes" }
  for (i in 0 until n) {
    val tmp = array[i] - q
    if (tmp <= 0) {
      ans[i] = "No"
    }
  }

  println(ans.joinToString("\n"))

}


Measured memory_bytes: 55904
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

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

typedef long long ll;

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    if(1 <= A && A <= 9 && 1 <= B && B <= 9)
        cout << A * B << endl;
    else cout << "-1" << endl;
    

    return 0;
}

Measured memory_bytes: 256
def funcDP(n):
    dp = [float('inf')] * (n + 10)
    dp[0] = 0
    for i in range(1, n + 1):
        for base in [6, 9]:
            powered = 1
            while powered <= i:
                dp[i] = min(dp[i], dp[i - powered] + 1)
                powered *= base
    return dp[n]

if __name__ == '__main__':
    print(funcDP(int(input())))

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int h, w;
    cin >> h >> w;
    int h2, w2;
    cin >> h2 >> w2;
    vector<vi> board(h, vi(w, 1));
    rep(i, h) rep(j, w) {
        if (i < h2 || j < w2) board[i][j] = 0;
    }
    int ans = 0;
    rep(i, h) rep(j, w) {
        if (board[i][j] == 1) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# maxNum = int(input())
# print(maxNum//2)
# num = 1

# ans = 0
# while num <= maxNum:  
#     yakusu = 0
#     for i in range(maxNum//2):
#         yakusu = 0
#         if (i == 0) or (i == 1):
#             continue
#         if maxNum % i == 0:
#             yakusu += 1
#     if yakusu == 8:
#         ans += 1
#     num += 1

# print(ans)

maxNum = int(input())
i = 1
ansNum = 0
# ある数の約数を調べる
while i <= maxNum:
    numOfYakusu = 0

    warukazu = 1
    while warukazu <= i:
        # 偶数の場合
        if i % 2 == 0:
            break
        if i % warukazu == 0:
            numOfYakusu += 1
        warukazu += 1
        # print(warukazu)
    # print("i = {} , numOfYakusu = {}".format(i, numOfYakusu))
    if numOfYakusu == 8:
        ansNum += 1
    i += 1

# print("ansNum : {}".format(ansNum))
print(ansNum)

Measured memory_bytes: 3060
# coding: utf-8
# Your code here!

n=int(input())
a=list()
for i in range(n):
    x,y=input().split()
    y=int(y)
    if x=='S':
        a.append(y)
    if x=='H':
        a.append(y+13)
    if x=='C':
        a.append(y+26)
    if x=='D':
        a.append(y+39)
for i in range(1,53):
    if not (i in a):
        if i<=13:
            print("S {}".format(i))
        elif i<=26:
            print("H {}".format(i-13))
        elif i<=39:
            print("C {}".format(i-26))
        else:
            print("D {}".format(i-39))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int a;
  int cnt = 0;
  cin >> a;
  vector<int> ans(a);
  vector<int> v(2);
  cin >> v[0] >> v[1];
  ans[0] = v[0];
  ans[1] = v[1];
  if(v[0] == v[1]){
      v[0] = 0;
      cnt++;
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(int i=0;i<a-2;i++){
      int d;
      cin >> d;
      ans[i+2] = d;
     if(d>v[0]){
         cnt = 0;
         v[1] = v[0];
         v[0] = d;
     }else if(d>v[1]){
         v[1] = d;
     }else if(d == v[0])cnt++;
  }
  for(int i=0;i<a;i++){
      if(cnt > 0) cout << v[0] << endl;
      else{
          if(ans[i] == v[0])cout << v[1] << endl;
          else cout << v[0] << endl;
      }
  }
}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
using namespace std;

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

	long a,b,c,i,j;
	vector<long> v;
	cin>>a>>b;
	for(i=0;i<a;i++){
		cin>>c;
		v.push_back(c);
	}
	std::sort(v.begin(),v.end(),std::greater<int>());//降順ソー
	for(i=0;i<b;i++){
		if(i >= v.size())break;
		v[i]=0;
	}
	c=0;
	for(j = i; j<v.size(); j++){
		c += v[j];
	}
	cout<<c;

    return 0;
}


Measured memory_bytes: 2420