akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 1000000007;
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

vector<ll> yakusu(ll n){
    vector<ll> ret;
    for(ll i = 1; i*i <= n; i++){
        if(n % i != 0) continue;
        ret.push_back(i);
        if(i*i != n) ret.push_back(n/i);
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    ll ans = 0;
    rep(a, 1, n) {
        rep(b, 1, n) {
            if(a * b >= n) break;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#if 0
date +%Y.%m.%d

这。。。O(k) 能过？
我本来只是想验证个猜想来着，一不小心就 AC 了。。。

不难归纳出串 S 经过一次碰撞后有两种情况：
1) S 的开头就是 A ，球直接弹飞，S 的开头变为 B
2) S 的开头不是 A ，球一定可以经过所有点，此后 S 取反后循环左移一位即为新的 S
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 200005;
char s[maxn];

int main() {
	int n = read, k = read;
	scanf("%s", s + 1);

	int p = 1, A = 'A';
	while(k --) {
		if(s[p] == A)
			s[p] = 'A' + 'B' - s[p];
		else {
			A = 'A' + 'B' - A;
			++ p;
			if(p > n) p = 1;
		}
	}

	for(int i = p; i <= n; i ++)
		printf("%c", "BA"[s[i] == A]);
	for(int i = 1; i < p; i ++)
		printf("%c", "BA"[s[i] == A]);
	puts("");
}


Measured memory_bytes: 640
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	b = zeros(Int,k,k)
	w = zeros(Int,k,k)
	for i in 1:n
		x,y,c = readline() |> chomp |> split
		x = parseInt(x)
		y = parseInt(y)
		s = div(x,k)+div(y,k)
		if s%2==0
			if c[1]=='B'
				b[x%k+1,y%k+1]+=1
			else
				w[x%k+1,y%k+1]+=1
			end
		else
			if c[1]=='W'
				b[x%k+1,y%k+1]+=1
			else
				w[x%k+1,y%k+1]+=1
			end
		end
	end
	bb = zeros(Int,k+1,k+1)
	ww = zeros(Int,k+1,k+1)
	for i in 1:k
		for j in 1:k
			bb[i+1,j+1]=bb[i+1,j]+b[i,j]
			ww[i+1,j+1]=ww[i+1,j]+w[i,j]
		end
	end
	for i in 1:k
		for j in 1:k
			bb[i+1,j+1]+=bb[i,j+1]
			ww[i+1,j+1]+=ww[i,j+1]
		end
	end
	s = 0
	for i in 1:k
		for j in 1:k
			s = max(s,bb[k+1,k+1]-bb[i,k+1]-bb[k+1,j]+2*bb[i,j]+ww[i,k+1]+ww[k+1,j]-2*ww[i,j],ww[k+1,k+1]-ww[i,k+1]-ww[k+1,j]+2*ww[i,j]+bb[i,k+1]+bb[k+1,j]-2*bb[i,j])
		end
	end
	println(s)
end

main()

Measured memory_bytes: 156144
def main():
    N = int(input())
    li = 'abcdefghijklmnopqrstuvwxyz'

    def condition(t,char):
        nonlocal li
        if li.index(sorted(t)[-1]) + 1 >= li.index(char):
            return True
        else:
            return False
    def f(k):
        nonlocal li
        if k == 1:
            return ['a']
        else:
            temp = f(k-1)
            return [t+char for t in temp for char in li[:k] if condition(t, char)]

    result = f(N)
    for t in sorted(result):
        print(t)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13892
#include <stdio.h>
   
int main(void){
  int i,num,temp,min,max;
  long sum=0;
   
  scanf("%d",&num);
  scanf("%d",&temp);
  min=temp;  max=temp;
  sum+=temp;
   
  for(i=1;i<num;i++){
    scanf("%d",&temp);
    if(min>temp)  min=temp;
    else if(max<temp)  max=temp;
    sum+=temp;
  }
  printf("%d %d %ld\n",min,max,sum);
  
  return 0;
}

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

const int N=1000005;
const int mod=1000000007;

int n,ans,sum;
int fac[N],inv[N],f[N];

int quickpow(int x,int y){
	int s=1;
	for (;y;y>>=1,x=1ll*x*x%mod)
		if (y&1) s=1ll*s*x%mod;
	return s;
}

void init(int n){
	int i;
	fac[0]=inv[0]=1;
	for (i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=quickpow(fac[n],mod-2);
	for (i=n-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

int C(int x,int y){
	if (x<y) return 0;
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}

int main(){
	int i;
	scanf("%d",&n);
	init(n);
	for (i=1;i<n;i++){
		sum=C(i-1,n-1-i);
		f[i]=1ll*sum*fac[i]%mod*fac[n-1-i]%mod;
	}
	for (i=1;i<n;i++) (ans+=1ll*(f[i]-f[i-1])*i%mod)%=mod;
	ans=(ans%mod+mod)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11904
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//?????¶????????±?????????
		int n = sc.nextInt();
		//3?¬?????????? ?£? ??? ??¨?±??????? ?????°??????????????????
		//?????? 4?£? 3????????? 10??¨?±?
		int  [][][] list = new int[4][3][10];
		//??¨????????¨?±??????????
		//b ?£?
		for(int i = 0; i < 4; i++){
			//f ???
			for(int j= 0 ; j< 3; j++){
				//r ??¨?±???????
				for(int k =0; k < 10; k++ ){
					//?£? ??? ??¨?±??????????
					list [i][j][k] = 0;
				}
			}
		}
		//???????????¨???
		for(int i =0; i <n;i++){
			//?????????0?????????????§????????????? ?£? ??? ??¨?±??????????????????????v ?????°???????´?
			list [sc.nextInt() - 1][sc.nextInt() - 1][sc.nextInt() - 1] +=  sc.nextInt();
		}
		//??¨???
		//b ?£?
		for(int i = 0; i < 4; i++){
			//f ???
			for(int j= 0 ; j< 3; j++){
				//r ??¨?±???????
				for(int k =0; k < 10;k++ ){
					//?£? ??? ??¨?±??????????
					System.out.print(" " + list [i][j][k] );
				}
				System.out.println();
			}
			if(i < 3){
				System.out.println("####################");
			}
		}
	}
}

Measured memory_bytes: 29548
import collections
n=input()
a=list(map(int, input().split()))

b=map(lambda x: x+1, a)
c=map(lambda x: x-1, a)
b=list(b)
c=list(c)

for num in range(len(a)):
    a.append(b[num])
    a.append(c[num])

d=collections.Counter(a)
values,counts=zip(*d.most_common())
print(counts[0])

Measured memory_bytes: 37844
#include<stdio.h>

int main(){
  int h, w;
  h = w = 100;
  
  char grid[h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < (w >> 1); j++){
      grid[i][j] = '.';
    }
    for(int j = (w >> 1); j < w; j++){
      grid[i][j] = '#';
    }
  }
  
  int A, B;
  scanf("%d %d", &A, &B);
  A--; B--;
  
  for(int i = 0; i < h; i += 2){
    for(int j = 0; j < (w >> 1) - 1; j += 2){
      if(B){
        grid[i][j] = '#';
        B--;
      }
    }
    for(int j = (w >> 1) + 1; j < w; j += 2){
      if(A){
        grid[i][j] = '.';
        A--;
      }
    }
  }
  
  printf("%d %d\n", h, w);
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      printf("%c", grid[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  cin>>N;
  
  if(1<=N && N<=9){
    cout<<N<<endl;
  }
  else if(10<=N && N<=99){
    cout<<9<<endl;
  }
  else if(100<=N && N<=999){
    cout<<(N-99)+9<<endl;
  }
  else if(1000<=N && N<=9999){
    cout<<909<<endl;
  }
  else if(10000<=N && N<=99999){
    cout<<(N-9999)+909<<endl;
  }
  else if(N==100000){
    cout<<90909<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn=100000;

int main(){
    
    int num[maxn];
    queue<int> restp;
    int ans=0;
    int n;
    
    cin >> n;
    rep(i,n){
        cin >> num[i];
        num[i]--;
        if(i==num[i])restp.push(i);
    }
    
    while(!restp.empty()){
        int pite=restp.front();
        restp.pop();
        
        if(pite+1<n&&num[pite+1]==pite+1){
            swap(num[pite],num[pite+1]);
            ans++;
            restp.pop();
        }else if(pite+1<n){
            swap(num[pite],num[pite+1]);
            ans++;
        }else{
            //一番最後、入れ替えなくてもいいか
            ans++;
        }
        
    }
    
    cout << ans<<endl;
    
    return 0;
}


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

int main(){
  string tmp;
  while(getline(cin,tmp),tmp.size()!=0){
    if(tmp.size()>=5){
      for(int i=0; tmp.size()-i>=5; ++i){
        if(tmp[i]=='a' && tmp[i+1]=='p' && tmp[i+2]=='p' && tmp[i+3]=='l' && tmp[i+4]=='e'){
          tmp[i]='p';tmp[i+1]='e';tmp[i+2]='a';tmp[i+3]='c';tmp[i+4]='h';
        }else if(tmp[i]=='p' && tmp[i+1]=='e' && tmp[i+2]=='a' && tmp[i+3]=='c' && tmp[i+4]=='h'){
          tmp[i]='a';tmp[i+1]='p';tmp[i+2]='p';tmp[i+3]='l';tmp[i+4]='e';
        }
      }
    }
    cout  << tmp << endl; 
  }  
}





Measured memory_bytes: 3172
#include <iostream>
using namespace std;
#define mod 1000000007
int l[200005],dp[200005];
int main()
{
	int n;
	scanf("%d",&n);
	dp[0]=1;
	for (int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		dp[i]=dp[i-1];
		if (l[a] && l[a]!=i-1)
		dp[i]=(dp[i]+dp[l[a]])%mod;
		l[a]=i;
	}
	printf("%d",dp[n]);
}

Measured memory_bytes: 1920
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();
      int l = sc.nextInt();
      int[] data = new int[n];
      int sum = 0;
      for (int i = 0;i<n ;i++ ) {
        data[i] = l+i;
        sum += data[i];
      }

      if(data[n-1]<0){
        System.out.println(sum-data[n-1]);
        System.exit(0);
      }

      if(l>0){
        sum -= data[0];
        System.out.println(sum);
      }else{
        System.out.println(sum);
      }


}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;   
    int n,k;
    cin>>n>>k;
    int dp[n+2][2],sum=0,count=0,i;
    for(int i=0;i<=n;++i)
    {
        sum+=i;
        if(i+1>=k)
        {
            dp[i+1][0]=sum;
        }
    }
    sum=0;
    for(i=n;i>=0;--i)
    {
        sum+=i;
        if(n-i+1>=k)
        {
            dp[n-i+1][1]=sum;
        }
    }
    for(i=k;i<=n+1;++i)
    {
        count+=(dp[i][1]-dp[i][0]+1)%MOD;
        count%=MOD;   
    }
    cout<<count;
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[100010];
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    int light=1;
    int pushcount=0;
    for(int i=0; i<=n; i++){
        light = a[light];
        pushcount++;
        if(light==2){
            break;
        }
    }
    if(pushcount==n+1){
        cout << -1 << endl;
    }else{
        cout << pushcount << endl;
    }
    return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
      Scanner sc=new Scanner(System.in);
       int a=sc.nextInt();
       int b=sc.nextInt();
       if(a>b)System.out.println("a > b");
       else{
           if(a<b)System.out.println("a < b");
           else System.out.println("a == b");
       }
      }
    }


Measured memory_bytes: 26144
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
struct T{int n, p;};
int main()
{
	int a, n, m, i, j;
	while (cin >> n >> m)
	{
		if (n == 0 && m == 0) break;
		T p[100] = {{0, 0}}, t;
		for (i = 0; i < m; i++)
			p[i].n = i+1, p[i].p = 0;
		for (i = 0; i < n; i++)
		{
			for (j = 0; j < m; j++)
			{
				cin >> a;
				if (a == 1) p[j].p++;
			}
		}
		for (i = 0; i < m; i++)
			for (j = 0; j < m-1; j++)
				if (p[j].p < p[j+1].p)
					t = p[j], p[j] = p[j+1], p[j+1] = t;
		for (i = 0; i < m; i++)
		{
			cout << p[i].n;
			if (i < m-1)
				cout << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
typedef struct{
  int p,l,r,d,h,s;
}Node;
Node A[30];
int rec(int r,int p){
  A[r].d = p;
  if(A[r].r!=-1) rec(A[r].r,p+1);
  if(A[r].l!=-1) rec(A[r].l,p+1);
}
int rec2(int a){
  int l,r;
  if(a==-1) return 0;
  if(A[a].l==-1 && A[a].r==-1) return 0;
  l = rec2(A[a].l)+1;
  r = rec2(A[a].r)+1;
  return l > r ? l : r;
}
int main(){
  
  int n,id,l,r;
  int i;
  int degree;
  int a;
  scanf("%d",&n);
  for(i=0;i<n;i++) A[i].r = A[i].l = A[i].p = A[i].s = -1;
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&l,&r);
    A[id].l = l;
    A[id].r = r;
    A[l].p = A[r].p = id;
    A[l].s = r;
    A[r].s = l;
  }
  for(i=0;i<n;i++) if(A[i].p==-1) a = i;
  rec(a,0);
  for(i=0;i<n;i++) A[i].h = rec2(i);
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, ",i,A[i].p,A[i].s);
    degree = 0;
    if(A[i].l!=-1) degree++;
    if(A[i].r!=-1) degree++;
    printf("degree = %d, depth = %d, height = %d, ",degree,A[i].d,A[i].h);
    if(A[i].p==-1) printf("root");
    else if(A[i].r!=-1 || A[i].l!=-1) printf("internal node");
    else printf("leaf");
    printf("\n");
  }
    
  return 0;
}




Measured memory_bytes: 2704
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        long K = int.Parse(str[1]);
        str = Console.ReadLine().Split(' ');
        long[] A = new long[N];
        for(int i=0;i<N;i++){
            A[i] = int.Parse(str[i]);
        }
        long G = A[0];
        long max = A[0];
        for(int i=1;i<N;i++){
            G = GCD(G,A[i]);
            max = Math.Max(max,A[i]);
        }
        if(K % G == 0 && K <= max){
            sb.Append("POSSIBLE\n");
        }
        else{
            sb.Append("IMPOSSIBLE\n");
        }
    }
    long GCD(long x,long y){
        if(y == 0){
            return x;
        }
        else{
            return GCD(y,x%y);
        }
    }
}

Measured memory_bytes: 18784
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ll>(a, b)(rng)
 
typedef long double             ld;
typedef long long               ll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>
#define vpll vector<pll> 
#define ull unsigned long long

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return abs(a); }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll N = 1e6+7;
const ll T = 1<<20;
const ld inf = 1e18;

ll n, m, q, k, r;

int ile(ll a, ll b, ll c){
    int ret = 0;
    while(b <= a){
        ret ++;
        b *= 2;
    }
    while(c <= b){
        ret ++;
        c *= 2;
    }
    return ret;
}

void solve(){
    ll a, b, c;
    cin >> a >> b >> c >> k;
    cout << (ile(a, b, c) <= k ? "Yes" : "No") << '\n';
}

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

  q = 1;
  // cin >> q;

  for(int i = 1; i <= q; i++)
    solve();
} 

Measured memory_bytes: 3652
import java.io.*;
import java.util.*;


public class Main {

  public static void main(String[] args) throws Exception {
    int x, a, b;
    FastScanner fs = new FastScanner();
    x = fs.nextInt();
    a = fs.nextInt();
    b = fs.nextInt();
    
    System.out.println(solve(x, a, b));
    return;
  }
  
  static int solve(int x, int a, int b) {
    x -= a;
    x -= (x/b) * b;
    return x;
  }
}

class FastScanner {
    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;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    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();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 20692
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  int m = n % 10;
  if(m == 3) cout <<  "bon" << endl;
  else if(m == 0 || m == 1 || m == 6 || m == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
  return 0;
}

Measured memory_bytes: 3596
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] s1 = sc.nextLine().split(" ");
    String[] s2 = sc.nextLine().split(" ");
    int[][] candies = new int[N][2];
    
    for(int i  = 0; i < N; i++){
      candies[i][0] = Integer.parseInt(s1[i]);
      candies[i][1] = Integer.parseInt(s2[i]);
    }
    
    int[][] dp = new int[N][2];
    dp[0][0] = candies[0][0];
    dp[0][1] = dp[0][0] + candies[0][1];
    
    
    for(int i = 1; i < N; i++){
      dp[i][0] = dp[i-1][0] + candies[i][0];
      if(candies[i][1]+dp[i-1][1] > candies[i][1]+dp[i][0]){
        dp[i][1] = candies[i][1]+dp[i-1][1];
      }else{
        dp[i][1] = candies[i][1]+dp[i][0];
      }
    }
    
    System.out.println(dp[N-1][1]);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;
long long pwr(long long x, long long e){
    if(e==0)
        return 1;
    long long tmp=pwr(x,e/2);
    tmp=(tmp*tmp)%mod;
    if(e%2)
        tmp=(tmp*x)%mod;
    return tmp;
}
ll dp[100010];
int main(){
    ll n, k;
    while(cin>>k){
    	n=3;
        ll ans=0;
        for(ll i=k; i>=1; --i){
        	dp[i]=pwr(k/i, n);
        	for(int j=i+i; j<=k; j+=i){
        		dp[i]-=dp[j];
        	}
        	ans+=i*dp[i];
        	ans%=mod;
        }
        if(ans<0){
        	ans+=mod;
        }
        printf("%lld\n",ans);
    }
  return 0;
}




Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <cmath>

#define PI 3.14159265

using namespace std;

void func_A() {

    double r;
    cin >> r;

    cout << 2 * PI * r;
}

void func_B() {

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

    for (int i = 0; i < m; ++i) {
        n -= a[i];
        if (n < 0) {
            cout << -1;
            return;
        }
    }

    cout << n;
}

void func_C() {

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

    vector<long long> buka(n);
    for (int i = 0; i < n-1; ++i) buka[i] = 0;

    for (int i = 0; i < n-1; ++i) ++buka[a[i] - 1];
    
    for (int i = 0; i < n; ++i) cout << buka[i] << "\n";


}

int main() {

    //func_A();
    //func_B();
    func_C();

    return 0;
}


Measured memory_bytes: 6372
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,M; cin>>N>>M;
    cout<<N*M<<endl;
    
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
 
  int N; cin >> N;
  vector<int> v(N);
  for(int i = 0; i<N; i++){
    cin >> v.at(i);
  }

  vector<int> color(9);
  for(int i = 0; i<N; i++){
    if(v.at(i) <= 399) color.at(0)++;
    else if(400 <= v.at(i) && v.at(i) <= 799) color.at(1)++;
    else if(800 <= v.at(i) && v.at(i) <= 1199) color.at(2)++;
    else if(1200 <= v.at(i) && v.at(i) <= 1599) color.at(3)++;
    else if(1600 <= v.at(i) && v.at(i) <= 1999) color.at(4)++;
    else if(2000 <= v.at(i) && v.at(i) <= 2399) color.at(5)++;
    else if(2400 <= v.at(i) && v.at(i) <= 2799) color.at(6)++;
    else if(2800 <= v.at(i) && v.at(i) <= 3199) color.at(7)++;
    else if(3200 <= v.at(i)) color.at(8)++;
  }
  
  int under = 0;
  for(int i = 0; i<8; i++){
    if(color.at(i) > 0) under++;
  }
  
  if(under == 0) cout << '1' << " " << color.at(8) << endl;
  else cout << under << " " << under + color.at(8) << endl;
  
  /*
  for(int i = 0; i<N; i++){
    cout << v.at(i) << " " ;
  }
  
  for(int i = 0; i<9; i++){
    cout << color.at(i) << " " ;
  }
  */
  
}

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

using namespace std;
const int N = 1e5+5;
long long x[N],v[N],lm[N],rm[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    long long c,sum=0;
    cin >> n >> c;
    for (int i = 1; i<=n; i++)
        cin >> x[i] >> v[i];
    long long m = 0;
    for (int i = 1; i<=n; i++)
    {
        sum+=v[i];
        lm[i] = max(sum-x[i],m);
        m = max(m,lm[i]);
    }
    sum = m = 0;
    for (int i = n; i>=1; i--)
    {
        sum+=v[i];
        rm[i] = max(sum-(c-x[i]),m);
        m = max(m,rm[i]);
    }
    long long ans = 0;
    for (int i = 1; i<=n; i++)
    {
        ans = max(ans,lm[i]);
        ans = max(ans,rm[i]);
    }
    for (int i = 1; i<=n; i++)
    {
        ans = max(ans,lm[i]-x[i]+rm[i+1]);
        ans = max(ans,rm[i]-(c-x[i])+lm[i-1]);
    }
    cout << ans;
}


Measured memory_bytes: 3328
import sys;      from decimal import Decimal
import math;     from itertools import combinations, product
import bisect;   from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

import numpy as np

def Main():
    s = read_str()
    dp = np.zeros(2019, dtype=np.int64)
    dp[0] = 1

    cur = 0
    digit = 1

    for i in reversed(s):
        cur = (cur + int(i) * digit) % 2019
        dp[cur] += 1
        digit = digit * 10 % 2019
    
    print(np.sum([x * (x - 1) // 2 for x in dp]))

if __name__ ==  '__main__':
    Main()

Measured memory_bytes: 27476
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int K;

void solve(){
    vector<vector<int>> hyo(K+1,vector<int>(K+1,0));
    for(int a=1;a<=K;a++){
        for(int b=1;b<=K;b++){
            hyo.at(a).at(b) = gcd(a,b);
        }
    }

    int64_t ans =0;
    for(int a=1;a<=K;a++){
        for(int b=1;b<=K;b++){
            for(int c=1;c<=K;c++){
                ans += hyo.at(hyo.at(a).at(b)).at(c);
            }
        }
    }
    cout << ans << endl;
}

int main(){
    cin >> K;
    solve();
}   

Measured memory_bytes: 3756
#include <stdio.h>

int connect[101][101]={0};
int d[101]={0};
int f[101]={0};
int used[101] = {0};
int n;
int cd = 0;

void dfs(int now)
{
  int i;
  cd++;
  d[now] = cd;

  for(i = 0; i < n; i++){
    if(connect[now][i]){
       if(d[i] == 0){
	dfs(i);
       }
    }
  }
  cd++;
  f[now] = cd;
}

int main(void)
{
  int u, k, v;
  int i, j;
 
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d %d", &u, &k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      v--;
      connect[u][v] = 1;
    }
  }
  for(i = 0; i < n; i++){
    if(d[i] == 0) dfs(i);
  }
  for(i = 0; i < n; i++)
    printf("%d %d %d\n", i+1, d[i], f[i]);

  return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	char str[1001], str2[1001], tmp[1001], m[10];
	int slen, tlen, a, b, i, j, q;
	cin >> str >> q;
	while (q--) {
		cin >> m >> a >> b;
		if (strcmp(m, "print") == 0) {
			for (i = a; i <= b; i++) {
				cout << str[i];
			}
			cout << endl;
		}
		if (strcmp(m, "reverse") == 0) {
			strncpy(tmp, &str[a], b-a+1);
			tmp[b-a+1] = '\0';
			for (i = a, j = strlen(tmp)-1; i <= b;) {
				str[i++] = tmp[j--];
			}
		}
		if (strcmp(m, "replace") == 0) {
			cin >> str2;
			for (i = a, j = 0; i <= b;) {
				str[i++] = str2[j++];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll mod=1000000007;

int main(){
    int N, count = 0;
    cin >> N;
    for(int i=0; i<N; i++) {
        int a, b;
        cin >> a >> b;
        if(a == b) count++;
        if(a != b) count = 0;
        if(count >= 3)  {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

}

Measured memory_bytes: 3600
H, W, K = map(int, input().split())

C = [input() for i in range(H)]
C_b = [[0]*W for h in range(H)]

for i, c in enumerate(C):
    for j, c_b in enumerate(c):
        C_b[i][j] = 0 if c_b =="." else 1

ans =0
for h in range(2**H):
    for w in range(2**W):
        h_s = bin(h)[:1:-1] + "000000"
        w_s = bin(w)[:1:-1] + "000000"
        cnt = 0
        for i, c in enumerate(C_b):
            for j, n in enumerate(c):
                if h_s[i] == "0":
                    if w_s[j] =="0":
                        if C_b[i][j] == 1:
                            cnt += 1
        if cnt == K:
            ans += 1

print(ans)

Measured memory_bytes: 8932
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
bool solve(int n)
{
	bool ret = false;
	if (n == 0) {
		return true;
	} else if(n < 0) {
		return false;
	}
	ret = solve(n - 4);
	if (ret == false) {
		ret = solve(n - 7);
	}
	return ret;
}
int main()
{
	int n;
	cin >> n;
	if (solve(n)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
hl = list(map(int, input().split()))

cost = [0] * n
cost[0] = 0
cost[1] = abs(hl[0] - hl[1])

for i in range(2, n):
    cost[i] = (min(cost[i-1] + abs(hl[i] - hl[i-1]),
                       (cost[i-2] + abs(hl[i] - hl[i-2]))))


print(cost[-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  for (int i = 1; i < s.size(); i++) {
    if (s[i - 1] == s[i]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 256
import sys
from heapq import heappush, heappop
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

N, M, L = inpl()
G = [[] for _ in range(N)]
G2 = [[999]*(N) for _ in range(N)]

for _ in range(M):
    a, b, c = inpl()
    if c <= L:
        G[a-1].append([b-1, c])
        G[b-1].append([a-1, c])

for i in range(N):
    supply = [999]*N
    remain = [0]*N
    supply[i] = 1
    remain[i] = L
    Q = [(1, -L, i)]
    while Q:
        s, r, p = heappop(Q)
        r = -r
        if s > supply[p]:
            continue
        if (s == supply[p]) and (r < remain[p]):
            continue
        for q, c in G[p]:
            if r >= c:
                if supply[q] > s:
                    supply[q] = s
                    remain[q] = r - c
                    heappush(Q, (s, c-r, q))
                elif (supply[q] == s) & (remain[q] < r - c):
                    remain[q] = r-c
                    heappush(Q, (s, c-r, q))
            else:
                if supply[q] > (s + 1):
                    supply[q] = s + 1
                    remain[q] = L - c
                    heappush(Q, (s+1, c-L, q))
                elif (supply[q] == (s+1)) & (remain[q] < L - c):
                    supply[q] = s+1
                    remain[q] = L-c
                    heappush(Q, (s+1, c-L, q))
    for j in range(N):
        G2[i][j] = supply[j]


for _ in range(int(input())):
    s, t = inpl()
    if G2[s-1][t-1] == 999:
        print(-1)
    else:
        print(G2[s-1][t-1]-1)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

int main(){
    string S, T;
    cin >> S >> T;

    string ans = T + S;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,count = 0,pow_n=0,count_n=0,count_for=0,N_c=0;
  cin >> N;
  N_c = N;
  pow_n = to_string(N).length();
  count_for = to_string(N).length();
  
  
  for(int i = 0; i < count_for; i++){
    count += N / pow(10,pow_n-1);
    count_n= N / pow(10,pow_n-1);
    N -= count_n * pow(10,pow_n-1);
    pow_n-=1;
  }

  if(N_c % count == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()

	from1, toN := make([]bool, n), make([]bool, n)
	for i := 0; i < m; i++ {
		a, b := nextInt(), nextInt()
		switch {
		case a == 1:
			from1[b-1] = true
		case b == n:
			toN[a-1] = true
		}
	}

	for j := 1; j < n-1; j++ {
		if from1[j] && toN[j] {
			fmt.Println("POSSIBLE")
			return
		}
	}

	fmt.Println("IMPOSSIBLE")
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	while (true) {
		int N, M;	cin >> N >> M;
		if (N == 0 && M == 0) break;
		vi c(N), d(M);
		rep(i, N) cin >> c.at(i);
		rep(i, M) cin >> d.at(i);
		int x = 0;
		rep(i, M) {
			x += d.at(i);
			if (x >= N - 1) {
				cout << i + 1 << endl;
				break;
			}
			x += c.at(x);
			if (x >= N - 1) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 3028
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int x,a,b; cin >> x >> a >> b;
	if (a >= b){
		cout << "delicious" << endl;
	} else if (a+x >= b){
		cout << "safe" << endl;
	} else {
		cout << "dangerous" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    double A, B, X; cin >> A >> B >> X;
    double volume = A * A * B;
    if(X < volume / 2){//角度は鈍角
        double theta = atan(2*X / (A*B*B));
        theta = theta *180.0 /M_PI;
        cout << fixed << setprecision(10) << 90.0 - theta << endl;
    }else{//こっちは鋭角
        double x_dash = volume - X;
        double theta = atan(2*x_dash /(A*A*A));
        theta = theta*180/M_PI;
        cout <<fixed << setprecision(10) << theta << endl;
    }
}


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

using namespace std;
typedef long long int ll;
typedef long  double lld;
int main() {
	ll n;
	lld a[1000006];
	ll i,j;
	lld dp[3006][3006],ans=0;
	cin>>n;
	for(i=0;i<n;i++)
	cin>>a[i];
	memset(dp,0,sizeof(dp));
	dp[1][0]=1-a[0];
	dp[1][1]=a[0];
	
	for(i=2;i<=n;i++)
	{
		dp[i][0]=dp[i-1][0]*(1-a[i-1]);
		for(j=1;j<=i;j++)
		{
			dp[i][j]=dp[i-1][j]*(1-a[i-1])+dp[i-1][j-1]*(a[i-1]);
		}
	}
	for(i=(n+1)/2;i<=n;i++)
	ans+=dp[n][i];
	printf("%.10llf",ans);
	cout<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 143488
#include<bits/stdc++.h>
#include<unordered_set>
#define FAST_IO   ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Relocate freopen("./in.txt","r",stdin),freopen("./out.txt","w",stdout)
#define up(mi,a,b) for(mi=a;mi<=b;++mi)
#define down(mi,b,a) for(mi=b;mi>=a;--mi)
#define mfill(a,v) memset(a,v,sizeof(a))
#define INF 0x3f3f3f3f
#define MAX  2000005
#define v_n 5005
#define LL long long
#define ULL unsigned long long 
#define e_n 50005
#define eps 1e-12
#define Blen 32
const LL MOD = 998244353;
using namespace std;
int main(void)
{
	int i, j, k;
	FAST_IO;
	//Relocate;
	LL N, K;
	cin >> N >> K;
	cout << N - K + 1 << endl;
	return 0;
}

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

  using namespace std;

  long long int N;

  int main()
  {
      cin>>N;
      long long int x=N,sum=0;
      while(x>0)
      {
          sum+=x%10;
          x/=10;
      }
      if(N%sum==0)
      {
          cout<<"Yes\n";
      }
      else
      {
          cout<<"No\n";
      }
      return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<int> cnt(n+1);
    rep(i,n-1) {
        int a; cin>>a;
        cnt[a]++;
    }

    for (int i = 1; i <= n; ++i) cout << cnt[i] << '\n';
    return 0;
}

Measured memory_bytes: 3996
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

int a,b,c;
cin>>a>>b>>c;
int ans=c;
if(b/a<c)c=b/a;

cout<<c<<endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a,b,c,k,ans=0;
	cin>>a>>b>>c>>k;
	ans+=min(k,a);
	k-=min(k,a);
	k-=min(k,b);
	ans-=min(k,c);
	k-=min(k,c);
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<char> vec(n);
  for (auto &v : vec)
    cin >> v;
  vec[k-1] = vec[k-1] + 'a' - 'A';

  for (auto &v : vec)
    cout << v;
  cout << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

//JOI Flag
public class Main{

	void run(){
		int MOD = 100000;
		char[] ch = {'J','O','I'};
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt();
		int MASK = (1<<w)-1, mask = 1<<(w-1);
		int ALL = 1;
		char[][] map = new char[h][];
		for(int i=0;i<h;i++){
			map[i]=sc.next().toCharArray();
			for(int j=0;j<w;j++)if(map[i][j]=='?')ALL=(ALL*3)%MOD;
		}
		int[] ref = new int[15000], rev = new int[1<<w];
		int ID = 0;
		for(int S=0;S<1<<w;S++){
			if((S&1)>0)continue;
			boolean ok = true;
			for(int j=0;j+1<w;j++)if(((S>>j)&1)>0&&((S>>(j+1))&1)>0)ok = false;
			if(ok){
				rev[S] = ID;
				ref[ID++] = S;
			}
		}
		int[][][] dp = new int[2][ID][2];
		int X = 0;
		dp[1][0][0] = 1;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++){
			for(int k=0;k<ID;k++)for(int J=0;J<2;J++)dp[X][k][J] = 0;
			for(int k=0;k<ID;k++)for(int J=0;J<2;J++){
				int S = ref[k];
				int D = dp[1-X][k][J];
				if(D==0)continue;
				if(map[i][j]!='?'){
					if((S&mask)>0&&map[i][j]=='I')continue;
					int ns = S;
					if(J==1&&map[i][j]=='O')ns++;
					ns<<=1;
					dp[X][rev[ns&MASK]][j==w-1?0:map[i][j]=='J'?1:0] = (dp[X][rev[ns&MASK]][j==w-1?0:map[i][j]=='J'?1:0]+D)%MOD;
				}
				else{
					for(int c=0;c<3;c++){
						char use = ch[c];
						if(use=='J'){
							int ns = S<<1;
							dp[X][rev[ns&MASK]][j==w-1?0:1] = (dp[X][rev[ns&MASK]][j==w-1?0:1]+D)%MOD;
						}
						else if(use=='O'){
							int ns = S;
							if(J==1)ns++;
							ns<<=1;
							dp[X][rev[ns&MASK]][0] = (dp[X][rev[ns&MASK]][0]+D)%MOD;
						}
						else{
							int ns = S<<1;
							if((S&mask)>0)continue;
							dp[X][rev[ns&MASK]][0] = (dp[X][rev[ns&MASK]][0]+D)%MOD;
						}
					}
				}
			}
			X = 1-X;
		}
		int res = 0;
		for(int k=0;k<ID;k++)for(int J=0;J<2;J++)res=(res+dp[1-X][k][J])%MOD;
		System.out.println((ALL-res+MOD)%MOD);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 16000
i = [int(input()) for i in range(5)]
i2 = [i2 for i2 in i if i2%10 != 0]

if not i2:
    min = i[len(i)-1]

else:
    min = i2[len(i2)-1]

count = 0
for x in i:
    if 0 < x % 10 < min % 10:
        min = x
        count += 1
i.remove(min)

for x in i:
    if x % 10 != 0:
        index = i.index(x)
        x += 10 - x % 10
        i[index] = x

i.append(min)

print(sum(i))


Measured memory_bytes: 3064
(function(stdin) {
  var lines = stdin.trim().split('\n');
  var n = parseInt(lines.shift().trim(), 10);
  var m = lines.map(function(row) {
    return row.trim().split(' ').map(Number);
  });
  var color = [], d = [], p = [];
  for (var i = 0; i < n; i++) {
    color[i] = 'WHITE';
    d[i] = Infinity;
    p[i] = -1;
  }
  d[0] = 0;
  p[0] = -1;
  var u, minv;
  while (1) {
    minv = Infinity;
    for (var i = 0; i < n; i++) {
      if (minv > d[i] && color[i] != 'BLACK') {
        u = i;
        minv = d[u];
      }
    }
    if (minv == Infinity) {
      break;
    }
    color[u] = 'BLACK';
    for (var v = 0; v < n; v++) {
      if (color[v] != 'BLACK' && m[u][v] != -1) {
        if (m[u][v] < d[v]) {
          d[v] = m[u][v];
          p[v] = u;
          color[v] = 'GRAY';
        }
      }
    }
  }
  var sum = 0;
  for (var i = 0; i < n; i++) {
    if (p[i] != -1) {
      //sum += m[i][p[i]];
      sum += d[i];
    }
  }
  console.log(sum);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 17372
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  string s,t;
  cin >> s;
  for (int i=0;i<(1<<3);i++){
    int sum=s.at(0)-'0';
    t="";
    for (int j=0;j<3;j++){
      if (i&(1<<j)){
        sum=sum+(s.at(j+1)-'0');
        t+='+';
      }
      else{
        sum=sum-(s.at(j+1)-'0');
        t+='-';
      }
    }
    if (sum==7){
      break;
    }
  }
  for(int i=0;i<3;i++){
    cout << s.at(i) << t.at(i);
  }
  cout << s.at(3) << "=7" << endl;
}
      
      

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	long long int n,m;
	cin>>n>>m;
	if(n!=1 && m!=1)cout<<n*m-(n*2+m*2-4)<<endl;
	else if(n*m!=1)cout<<n*m-2<<endl;
	else if(n*m==1)cout<<1<<endl;
			
			
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt(),f=0;
  	for(int i=a;i<=b;i++){
  		if(i%n==0){
  			f++;
  			System.out.print("OK");
  			break;
  		}
  	}
  	if(f==0){
  		System.out.print("NG");
  	}
  }
}

Measured memory_bytes: 35780
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define ppll pair <pll, pll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
int main(){
	string s, t; ll a, b; string u;
	cin >> s >> t >> a >> b >> u;
	if (s == u) a--; else b--;
	cout << a << " " << b << endl;	
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    int w = 0;
    rep(i, m) w += a.at(i);
    if (n < w) cout << -1 << endl;
    else cout << n - w << endl;
    return 0;
}

Measured memory_bytes: 7184
#include<stdio.h>
 int main(){
   int i;
   int x;
   for(i = 0 ;i < 10000 ;i++ ){
     scanf("%d",&x);
     if (x == 0) break;
     
     printf("Case %d: %d\n",i+1, x);
      }return 0;
 }
     


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

typedef long long ll;
typedef vector<ll> vi;

vi v;
int n;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll lo,hi;
    bool posible;
    while(cin >> n)
    {
        v = vi(n);
        for(int i = 0; i < n; i++)
            cin >> v[n-1-i];

        lo = hi = 2; posible = 1;
        for(int i = 0; i < n; i++)
        {
            hi = (hi / v[i]) * v[i] + v[i] - 1;
            lo = ceil(lo * 1.0 / v[i]) * v[i];
            if(hi < lo)
                posible = false;
        }
        if(!posible)
            cout << -1 << '\n';
        else
            cout << lo << " " << hi << '\n';
    }
    return 0;
}

Measured memory_bytes: 1024