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

using namespace std;

int n, m, cnt, a[1005][1005];

struct S {
	int x, y, z, w;
}s[250005];

signed main() {
	cin >> n >> m;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j) cin >> a[i][j];
	for(int i = 1; i <= n-1; ++i)
		for(int j = 1; j <= m; ++j)
			if(a[i][j]&1) a[i+1][j]++, ++cnt, s[cnt] = S{i, j, i+1, j};
	for(int j = 1; j < m; ++j)
		if(a[n][j]&1)
			a[n][j+1]++, ++cnt, s[cnt] = S{n, j, n, j+1};
	cout << cnt << endl;
	for(int i = 1; i <= cnt; ++i) {
		cout << s[i].x << " " << s[i].y << " " << s[i].z << " " << s[i].w << endl;
	}
	return 0;
}

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

void initialize(int K, const auto& f, auto& V, auto& index) {
  int id = 0;
  vector<int> e(K);
  iota(begin(e), end(e), 0);
  do {
    index[e] = id++;
    V.emplace_back([e, &f](auto l, auto r) {
      for(auto i: e) if(f[l][i] != f[r][i]) return f[l][i] > f[r][i];
      return false;
    });
  } while(next_permutation(begin(e), end(e)));
}

int main() {
  int N, K;
  cin >> N >> K;

  vector<vector<int>> f(N, vector<int>(K));
  for(auto& i: f) for(auto& j: i) cin >> j;

  vector<set<int, function<bool(int, int)>>> V;
  map<vector<int>, int> index;
  initialize(K, f, V, index);

  int D;
  cin >> D;
  vector<vector<int>> G(N);
  vector<int> indegree(N);
  for(auto i = 0; i < D; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].emplace_back(b);
    ++indegree[b];
  }

  vector<int> e(K);
  for(auto& i: e) cin >> i, --i;
  auto order = index[e];

  int R;
  cin >> R;
  queue<pair<int, int>> update;
  for(auto i = 0; i < R; ++i) {
    int m;
    cin >> m;
    vector<int> e(K);
    for(auto& i: e) cin >> i, --i;
    update.emplace(m, index[e]);
  }
  update.emplace(N + 1, -1);

  vector<bool> used(N);
  for(auto i = 0; i < N; ++i) if(!indegree[i]) for(auto& j: V) j.insert(i);
  for(auto step = 0; step < N; ++step) {
    if(update.front().first <= step) {
      order = update.front().second;
      update.pop();
    }
    while(used[*begin(V[order])]) V[order].erase(*begin(V[order]));
    auto v = *begin(V[order]);
    used[v] = true;
    cout << v + 1 << endl;
    for(auto i: G[v]) if(!used[i]) if(! --indegree[i]) for(auto& j: V) j.insert(i);
  }
}

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

int main() {
	string s;
	cin >> s;
	long long l = s.size();
	
	string  s1 = "";
	for (auto i = s.rbegin(); i != s.rend(); i++) {
		s1 += *i;
	}
	
	if (s1 == s) {
		string s2 = s, s3 = "";
		s2.erase((l - 1) / 2, l);
		//cout << s2 << endl;
		for (auto i = s2.rbegin(); i != s2.rend(); i++) {
			s3 += *i;
		}
		//cout << s3 << endl;
		if (s3 == s2) {
			string s2 = s, s3 = "";
			s2.erase(0, ((l - 1) / 2)+1);
			//cout << s2 << endl;
			for (auto i = s2.rbegin(); i != s2.rend(); i++) {
				s3 += *i;
			}
			//cout << s3 << endl;
			if (s3 == s2) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;


}

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

using namespace std;

int main(){
    int n,l;
    cin>>n>>l;
    vector<long long> tura(n);
    queue<int> lq;
    queue<int> sq;
    for (int i = 0; i < n; ++i) {
        cin>>tura[i];
    }
    if(tura[0]>tura[1])lq.push(0);
    for (int i = 1; i < n-1; ++i) {
        if(tura[i]>tura[i-1]&&tura[i]>tura[i+1])lq.push(i);
        if(tura[i]<tura[i+1]&&tura[i]<tura[i-1])sq.push(i);
    }
    if(tura[n-1]>tura[n-2])lq.push(n-1);
    vector<long long> ans(n,-1);
    ans[lq.front()]=l-tura[lq.front()];
    int tl=n,ts=n;
    for (int i = lq.front()-1; i >= 0; --i) {
        ans[i]=ans[i+1]+l-tura[i];
    }
    if(sq.empty())ts=n;
    else ts=sq.front();
    for (int i = lq.front()+1; i < ts; ++i) {
        ans[i]=ans[i-1]+l-tura[i];
    }
    lq.pop();
    while(!lq.empty()){
        tl=lq.front();
        ts=sq.front();
        ans[tl]=l-tura[tl];
        for (int i = tl-1; i > ts; --i) {
            ans[i]=ans[i+1]+l-tura[i];
        }
        ans[ts]=max(ans[ts-1],ans[ts+1])+l-tura[ts];
        sq.pop();
        ts=sq.front();
        for (int i = tl+1; i < ts; ++i) {
            ans[i]=ans[i-1]+l-tura[i];
        }
        lq.pop();
    }

    for (int i = tl+1; i < n; ++i) {
        ans[i]=ans[i-1]+l-tura[i];
    }

    long long mans=-1;
    for (int i = 0; i < n; ++i) {
        mans=max(mans,ans[i]);
    }
    cout<<mans<<endl;
    return 0;
}


Measured memory_bytes: 4720
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static int a[];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        a=new int[3];
        a[0]=sc.nextInt();
        a[1]=sc.nextInt();
        a[2]=sc.nextInt();
        Arrays.sort(a);
        System.out.printf("%d %d %d\n",a[0],a[1],a[2]);
        sc.close();
    }
}


Measured memory_bytes: 26464
const fs = require('fs');

function main(input) {
  var s = input.split('')
  var cnt = 0;
  for (var i = 0; i < 3; i++) {
    if (s[i] == '1') {
      cnt++
    }
  }
  console.log(cnt)
}

input = fs.readFileSync('/dev/stdin', 'utf8');
main(input);

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

int main(){
  int n;
  cin >> n;
  map<ll, ll> A;
  vector<ll> memo(n);
  for (int i=0; i<n; i++){
    ll a;
    cin >> a;
    memo[i] = a;
    if (A.count(a)) A[a]++;
    else A[a] = 1;
  }
  ll sum = 0;
  for (auto a: A){
    sum += a.second * (a.second - 1) / 2;
  }

  for (int i=0; i<n; i++){
    ll a = A[memo[i]];
    cout << sum - (a-1) << endl;
  }

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 200 * 1000 + 7;

int nxt[MAXN][26];
char s[MAXN];
int dp[MAXN];
char res[MAXN];

void p(int x) {
	printf("%c", (char)(x + 'a'));
}
int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	scanf("%s", s);
	int n = strlen(s);
	for (int i = n; i >= 1; i--) s[i] = s[i - 1];
	for (int i = 0; i < 26; i++) {
		nxt[n][i] = -1;
	}
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j < 26; j++) {
			nxt[i][j] = nxt[i + 1][j];
		}
		nxt[i][s[i + 1] - 'a'] = i + 1;
	}
	for (int i = n; i >= 0; i--) {
		dp[i] = n + 7;
		for (int j = 0; j < 26; j++) {
			if (nxt[i][j] == -1) {
				dp[i] = 1;
			} else {
				dp[i] = min(dp[i], dp[nxt[i][j]] + 1);
			}
		}
	}
	int pos = 0;
	while (pos != -1) {
		for (int i = 0; i < 26; i++) {
			if (nxt[pos][i] == -1 || dp[nxt[pos][i]] == dp[pos] - 1) {
				p(i);
				pos = nxt[pos][i];
				break;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 21504
S=input()
N=len(S)
S_1=S[0:(N-1)//2]
S_2=S[(N+3)//2:-1]

if S!=S[::-1]:
    print('No')
    exit()
else:
    pass
if S_1!=S_1[::-1]:
    print('No')
    exit()
else:
    pass
if S_2!=S_2[::-1]:
    print('No')
    exit()
else:
    print('Yes')

Measured memory_bytes: 3064
n=int(input())
hlist=list(map(int,input().split()))

maemae=0

for i in range(1,n):
	if i == 1:
		mae=abs(hlist[i]-hlist[0])
		ima=mae
		continue
	
	tmp=min(mae+abs(hlist[i]-hlist[i-1]),maemae+abs(hlist[i]-hlist[i-2]))
	maemae=mae
	mae=tmp
	ima=tmp

print(ima)






Measured memory_bytes: 13908
import math as ma
import sys
from sys import exit
from decimal import Decimal as dec
from itertools import permutations


def li():
	return list(map(int , input().split()))


def num():
	return map(int , input().split())


def nu():
	return int(input())


def find_gcd(x , y):
	while (y):
		x , y = y , x % y
	return x


s=input()
k=nu()
n=len(s)
m=k
z=set()
for i in range(n):
	pp=""
	for j in range(i,i+m):
		if(j>=n):
			break
		pp+=s[j]
		z.add(pp)
fin=list(z)
fin.sort()
print(fin[k-1])


Measured memory_bytes: 62256
S=input()

if "a" not in S:
    print("a")
elif "b"  not in S:
    print("b")
elif "c"  not in S:
    print("c")
elif "d"  not in S:
    print("d")
elif "e"  not in S:
    print("e")
elif "f"  not in S:
    print("f")
elif "g"  not in S:
    print("g")
elif "h"  not in S:
    print("h")
elif "i"  not in S:
    print("i")
elif "j"  not in S:
    print("j")
elif "k"  not in S:
    print("k")
elif "l"  not in S:
    print("l")
elif "m"  not in S:
    print("m")
elif "n"  not in S:
    print("n")
elif "o"  not in S:
    print("o")
elif "p"  not in S:
    print("p")
elif "q"  not in S:
    print("q")
elif "r"  not in S:
    print("r")
elif "s"  not in S:
    print("s")
elif "t"  not in S:
    print("t")
elif "u"  not in S:
    print("u")
elif "v"  not in S:
    print("v")
elif "w"  not in S:
    print("w")
elif "x"  not in S:
    print("x")
elif "y"  not in S:
    print("y")
elif "z"  not in S:
    print("z")
else:
    print("None")

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

int main()
{
	long long int X;
	cin >> X;
	for (long long int i = 0; i <= 200; ++i)
	{
		long long int now;
		for (long long int j = -200; j <= i; ++j)
		{
			if (i - j != 0 && X % (i - j) == 0)
			{
				now = pow(i, 5) - pow(j, 5);
				if (now == X)
				{
					cout << i << " " << j << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4096
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[] p = new int[n];
		
		for(int i=0;i<n;i++) {
			p[i]=sc.nextInt();
		}
		
		Arrays.parallelSort(p);

		int sum=0;
		
		for(int i=0;i<k;i++) {
			sum+=p[i];
		}
		System.out.println(sum);
		sc.close();
	}
}

Measured memory_bytes: 39008
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    double t = l / 3.0;

    printf("%.12f\n", t * t * t);

    return 0;
}

Measured memory_bytes: 256
class dice:
    def __init__(self, pip):
        self.pip = pip
        
    def move(self,dir):
        if str(dir) == "E":
            self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[3],self.pip[0],self.pip[5],self.pip[2]
        elif str(dir) == "W":
            self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[2],self.pip[5],self.pip[0],self.pip[3]
        elif str(dir) == "N":
            self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[1],self.pip[5],self.pip[0],self.pip[4]
        elif str(dir) == "S":
            self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[4],self.pip[0],self.pip[5],self.pip[1]

d = dice(list(map(int,input().split())))
n = int(input())

for i in range(n):
    
    top, front = map(int,input().split())
    
    for op in "EEENEEENEEESEEESEEENEEEN":
        if d.pip[0] == top and d.pip[1] == front:
            break
        d.move(op)    
    print(d.pip[2])

Measured memory_bytes: 7764
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.La;
		Array.Sort(s);
		Console.WriteLine("{0}",(s[1]+s[0])%2==0?((s[1]+s[0])/2).ToString():"IMPOSSIBLE");
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 13268
// #pragma GCC optimize("no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC diagnostic ignored "-W"

#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<sstream>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<utility>
#include<functional>
#include<complex>
#include<climits>
#include<random>
#include<thread>

#if __cplusplus >= 201103L
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#endif

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/rope>

using namespace std;
// using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vint vector<int>
#define vpii vector<pair<int,int>>
#define SS stringstream
#define PQ priority_queue
#define MS(x,v) memset((x),(v),sizeof(x))
#define RZUNI(x) sort(x.begin(),x.end()), x.resize(unique(x.begin(),x.end())-x.begin())
#define FLH fflush(stdout)
#define CPPinput ios_base::sync_with_stdio(0); cin.tie(0)
#define FIN(fname) freopen(fname,"r",stdin)
#define FOUT(fname) freopen(fname,"w",stdout)

#define tm Ovuvuevuevue
#define y1 Enyetuenwuevue
#define left Ugbemugbem
#define ws Osas
#define dec tetteterette
#define expl explexplexpl

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl

#ifdef WEAK
#include"/home/edison/Coding/cpp/template/debug.cpp"
#define DEB(...) printf(__VA_ARGS__),fflush(stdout)
#define WHR() printf("%s: Line %d",__PRETTY_FUNCTION__,__LINE__),fflush(stdout)
#define LOG(...) printf("%s: Line %d ",__PRETTY_FUNCTION__,__LINE__),printf(__VA_ARGS__),fflush(stdout)
#define DEBUG 1
#define exit(x) cout<<"exit code "<<x<<endl, exit(0)
#else
#define PDE(...) ;
#define DEB(...) ;
#define WHR() ;
#define LOG(...) ;
#define DEBUG 0
#endif

#define lowbit(x) ((x)&(-(x)))

void JIZZ(string output=""){cout<<output; exit(0);}

const ld PI=3.14159265358979323846264338327950288;
const ld eps=1e-10;
const ll mod=1e9+7;

int rec[100005][12];
vector<int> G[100005];

void dfs(int now,int d,int c){
    if(d<0)return;
    if(rec[now][d])return;
    for(int z=d;z>=0;--z)if(!rec[now][z])rec[now][z]=c;
    for(int i:G[now])dfs(i,d-1,c);
}

int main(){
    CPPinput;
    int n,m,q; cin>>n>>m;
    while(m--){
        int u,v; cin>>u>>v;
        G[u].pb(v);
        G[v].pb(u);
    }
    cin>>q;
    vector<int> o;
    while(q--){
        int z,x,c; cin>>z>>x>>c;
        o.pb(c); o.pb(x); o.pb(z);
    }
    while(o.size()){
        int v,d,c;
        v=o.back(); o.pop_back();
        d=o.back(); o.pop_back();
        c=o.back(); o.pop_back();
        dfs(v,d,c);
    }
    for(int i=1;i<=n;++i)cout<<rec[i][0]<<'\n';
}


Measured memory_bytes: 12528
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    int X,Y;cin>>X>>Y;
    cout<<X+Y/2<<endl;
}

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

using namespace std;

//文字列から全部分文字列を生成する
//string -> vector<string>
vector<string> subStringMaker(string);

//文字列がA, T, C, Gだけで構成されているかを判定する
//string -> bool
bool isInDomain(string);

int main()
{
    string S;
    int substringLength = 0;
    vector<string> subString;

    cin >> S;
    subString = subStringMaker(S);
    for (auto& v : subString){
        if (isInDomain(v)) {
            if (v.length() > substringLength) substringLength = v.length();
        }
    }
    cout << substringLength << endl;
}

vector<string> subStringMaker(string S)
{
    int limit = S.length();
    vector<string> subStringVector;

    for (int i = 0; i < limit; i++){
        for (int j = 1; j <= limit - i; j++){
            subStringVector.push_back(S.substr(i, j));
        }
    }
    return subStringVector;
}

bool isInDomain(string S)
{
    for (int i = 0; i < S.length(); i++){
        char c = S.at(i);
        if (c != 'A' && c != 'T' && c != 'C' && c != 'G') return false;
    }
    return true;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using  namespace std;
int a[1001];
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
      cin>>a[i];
  ll mi = 2e9;
  for(int i=1;i<=200;i++){
      ll sum=0;
      for(int j=0;j<n;j++){
          sum+=(a[j]-i)*(a[j]-i);
      }
      mi =min(mi,sum);
  }
  cout<<mi;
}


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

void f(int n, int now, int nmax);

string ans = "a";

int main() {
    int n;
    cin >> n;
    
    if (n != 1) f(n, 1, 0);
    else cout << 'a' << endl;
}

void f(int n, int now, int nmax) {
    if (now == n-1) {
        int i = 0;
        while (i <= nmax+1) {
            ans += 'a' + i;
            cout << ans << endl;
            ans = ans.substr(0, now);
            i++;
        }
    } else {
        int j = 0;
        int nmaxnow = nmax;
        while (j <= nmax + 1) {
            ans += 'a' + j;
            if (j == nmax+1) f(n, now+1, j);
            else f(n, now+1, nmax);
            ans = ans.substr(0, now);
            j++;
        }
    }
    return;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
using namespace std;
ll a[114]; ll n, ans = 0, cnt = 0;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		if (a[i] == a[i + 1])cnt++;
		if (a[i] != a[i + 1]) {
			ans += (cnt + 1) / 2;
			cnt = 0;
		}
	}
	cout << ans << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define MOD 1e9+7;
using namespace std;
using Graph = vector<vector<int>>;
typedef vector<vector<char>> field_t;
typedef long long ll;
typedef pair<int, int> point_t;
vector<vector<pair<int,int>>> z(100010);


signed main()
{
    ll A,B,ans;
    cin >> A >> B;
    ans=A*B;
    cout << ans <<endl;
  


    return 0;
}

Measured memory_bytes: 5484
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

void solve() {
	lli n;
	cin >> n;
	map <lli, lli> m;
	for (lli i = 1, x; i < n; i++) {
		cin >> x;
		m[x]++;
	}
	for (lli i = 1; i <= n; i++) {
		cout << m[i] << endl;
	}
}
int main()
{
	zanj0();
	solve();
	return 0;
}

Measured memory_bytes: 16188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから

 struct UF {
	vector<int>par;//親
	vector<int>Rank;//木の深さ
    vector<int>sz;//要素数

    UF(int n){init(n);}

	//初期化
	void init(int n) {
		par.resize(n); Rank.resize(n);sz.resize(n);
		for (int i = 0; i < n; i++) {
			par[i]= i;
			Rank[i] = 0;
            sz[i]=1;
		}
	}

	//木の根を求める
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	//xとyの属する集合を併合
	bool unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return false;//すでに同じ集合に属している

		if (Rank[x] < Rank[y]) {//高さが小さい方を下に
			par[x] = y;
            sz[y]+=sz[x];
		}
		else {
			par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;//同じだとrankが変わらないままになるので増やす（それ以外は大きい方のrankが採用される）
            sz[x]+=sz[y];
		}
		return true;
	}

	//xとyが同じ集合に属するかを判定
	bool same(int x, int y) {
		return find(x) == find(y);
	}

    int size(int k){//要素数を求める
        return sz[find(k)];
    }
};

using P=pair<int,int>;
void solve(){
  ll n,m,k;
  cin>>n>>m>>k;
  map<P,int>mp;
  UF tree(n);
  vector<vector<int>>g(n),g2(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
    if(a>b)swap(a,b);
    mp[P{a,b}]++;
    tree.unite(a,b);
  }
  rep(i,k){
    int c,d;
    cin>>c>>d;
    c--;d--;
    if(c>d)swap(c,d);
    if(mp[P{c,d}]==0&&tree.same(c,d)){
      g2[c].pb(d);
      g2[d].pb(c);
    }
  }
  rep(i,n){
    if(i)cout<<" ";
    cout<<tree.size(i)-g[i].size()-g2[i].size()-1;
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

Measured memory_bytes: 25464
#include <stdio.h>
      
int main(void) {
	int n, k;
	int l[50];
	int i, j, m, max, sum;

    scanf("%d%d", &n, &k);
    
    for (i = 0; i < n; i++) {
		scanf("%d", &l[i]);
	}
    
    sum = 0;
    for (i = 0; i < k; i++) {
    	max = l[0];
    	m = 0;
    	for (j = 1; j < n; j++) {
        	if (max < l[j]) {
            	max = l[j];
            	m = j;
        	}
    	}
    	l[m] = 0;
    	sum += max;
    }
    
    printf("%d\n", sum);
    
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int n;
	cin >> n;
	vs s(n);
	rep(i, n) cin >> s[i];

	sort(ASC(s));
	s.erase(unique(ASC(s)), s.end());
	cout << s.size() << endl;
}


Measured memory_bytes: 9596
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

using namespace std;

typedef pair<int, int> pii;

#define NUM 2147483647

int N = 1;
int st[270000];

void init(int first_N) {
	while (N < first_N)N *= 2;
}

void update(int update_left, int update_right, int new_value, int node_id, int node_left, int node_right) {
	if (update_right < node_left || update_left > node_right)return;
	else if (update_left <= node_left && update_right >= node_right) {
		st[node_id] = new_value;
	}
	else {
		if (st[node_id] >= 0) {
			update(node_left, node_right, st[node_id], 2 * node_id + 1, node_left, (node_left + node_right) / 2);
			update(node_left, node_right, st[node_id], 2 * node_id + 2, (node_left + node_right) / 2 + 1, node_right);
			st[node_id] = -1;
		}
		update(update_left, update_right, new_value, 2 * node_id + 1, node_left, (node_left + node_right) / 2);
		update(update_left, update_right, new_value, 2 * node_id + 2, (node_left + node_right) / 2 + 1, node_right);
	}
}

int query(int search_left, int search_right, int node_id, int node_left, int node_right) {
	if (search_right < node_left || search_left > node_right) {
		return NUM;
	}
	else {
		if (st[node_id] != -1)return st[node_id];
		else {
			int left = query(search_left, search_right, 2 * node_id + 1, node_left, (node_left + node_right) / 2);
			int right = query(search_left, search_right, 2 * node_id + 2, (node_left + node_right) / 2 + 1, node_right);
			return min(left, right);
		}
	}
}

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

	init(first_N);

	for (int i = 0; i <= 2 * N - 2; i++)st[i] = NUM;

	int command, left, right, value;

	for (int i = 0; i < Q; i++) {
		scanf("%d", &command);

		if (command == 0) {
			scanf("%d %d %d", &left, &right, &value);
			update(left, right, value, 0, 0, N - 1);
		}
		else {
			scanf("%d %d", &left, &right);
			printf("%d\n", query(left, right, 0, 0, N - 1));
		}
	}
}


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

using namespace std;
using ll = long long;
// #define int ll
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> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    string s;
    cin >> s;
    const int n = s.size();

    ll a=0, b=0;
    REP(i, n) {
        if(s[i]=='0') a++;
        else b++;
    }
    cout << min(a, b)*2 << endl;

    return 0;
}


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


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    cumrative_AC_count = [0]
    count = 0
    for i, s in enumerate(S):
        if i == 0:
            continue
        else:
            if S[i-1]=='A' and S[i]=='C':
                count += 1
        cumrative_AC_count.append(count)
    l = [x-1 for x in l]
    r = [x-1 for x in r]

    for left, right in zip(l, r):
        result = cumrative_AC_count[right]  - cumrative_AC_count[left]
        print(result)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]" 
    r = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)

if __name__ == '__main__':
    main()


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int now = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        now += s.at(i) == 'I' ? 1: -1;
        ans = max(ans, now);
    }
    cout << ans << endl;
}   

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc011/tasks/agc011_a
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,c,k;cin>>n>>c>>k;
    vector<int> ar(n);
    for(int &i:ar) cin>>i;
    sort(ar.begin(), ar.end());
    int x=0, ans=0;
    for(int i=0;i<n;i++) {
        while(ar[x] + k < ar[i]) {
            ans++;
            x = min(x + c, i);
        }
    }
    while(x < n) {
        ans++;
        x = min(x + c, n);
    }
    cout<<ans<<"\n";
}   

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int CMAX = 35;

int main(void){
    int N, C; scanf("%d %d", &N, &C);
    int D[C+1][C+1];
    int cmemo[3][CMAX] = {0};
    for(int i=1; i<=C; i++){
        for(int j=1; j<=C; j++) scanf("%d", &D[i][j]);
    }

    vector<int> X, Y, Z;
    for(int i=1; i<=N; i++){
        for(int j=1; j<=N; j++){
            int c; scanf("%d", &c);
            if((i+j)%3 == 0){
                X.push_back(c); cmemo[0][c]++;
            }
            else if((i+j)%3 == 1){
                Y.push_back(c); cmemo[1][c]++;
            }
            else{
                Z.push_back(c); cmemo[2][c]++;
            } 
        }
    }

    ll ans = 1LL<<60;
    for(int i=1; i<=C; i++){
        for(int j=1; j<=C; j++){
            for(int k=1; k<=C; k++){
                if(i == k || i == j || j == k) continue;

                ll tmp = 0;
                for(int l=1; l<=C; l++){
                    tmp += D[l][i] * cmemo[0][l];
                    tmp += D[l][j] * cmemo[1][l];
                    tmp += D[l][k] * cmemo[2][l];
                }
                ans = min(ans, tmp);
                
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 1520
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;

const int LOOP = 10000; //??????????????°
const double EPS = 1e-6; //??????????????¨(?°??????????????????????)
int L;
int N; //???????????±???????????°

//???????????±????????????????????????????????¨?????¨???????¨????????¨??????????
double Evaluate(int r[12]) {
	double val = r[0] + r[N-1];
	for (int i = 0; i < N - 1; i++)
	{
		int a = abs(r[i] - r[i+1]), c = r[i] + r[i+1];
		val += sqrt(c*c - a*a);
	}
	return val;
}

//?????¨?????????????????°???????????¨??????????????????????§???????????±???????
//(????§?????????????true)
bool Changes(int cnt) {
	return cnt < rand()%LOOP;
}

void Swap(int r[12],int L,int R){
    int temp=r[L];
    r[L]=r[R];
    r[R]=temp;
}

//?????????????????????????????¢??°
//?????????????°??????????????¨?????????????
//int r[12] : ???????????±?????????0??????N-1???????????????????????????????????????????????????????´???????
double Solve(int r[12]) {
	double score = Evaluate(r); //?????¨?????¶???r[]????¨???????????´????????????°
	double mi = score; //???????????§?????¶???????¨???????????°???????????´????????????°
	for (int cnt = 0; cnt < LOOP; cnt++)
	{
	    int L=rand()%N;
	    int R=rand()%N;
	    Swap(r,L,R);
	    if(mi>=Evaluate(r)){
            mi=Evaluate(r);
            continue;
	    }
	    else if(Changes(cnt)){
            mi=Evaluate(r);
	    }
	    else Swap(r,L,R);
	}
	return mi; //????°?????????????
}

//??\?????¢????????????????????¢????????£????????§???????????????
int main() {
	while (cin >> L)
	{
		N = 0;
		int r[12];
		string S;
		getline(cin, S);
		stringstream SS(S);
		while (!SS.eof()) SS >> r[N++];

		double ans;
		if (N == 1) ans = r[0]*2;
		else ans = Solve(r);

		if (L - ans + EPS > 0) puts("OK");
		else puts("NA");
	}
	return 0;
}

Measured memory_bytes: 1212
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
N = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

count = 0
for el in range(N):
    if el + 2 >= N:
        break
    if s[el] == 'A' and s[el+1] == 'B' and s[el+2] == 'C':
        count += 1
print(count)


Measured memory_bytes: 3568
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

A, B, C = map(int, input().split())
K = int(input())

def chk(A, B, C):
    if A < B < C:
        return True
    else:
        return False

for _ in range(K):
    # print(' A, B, C', A, B, C)
    if A >= B:
        B *= 2
    elif B >= C:
        C *= 2
    if chk(A, B, C):
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 65328
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

class Mod:
    def __init__(self, m):
        self.m = m
    
    def add(self, a, b):
        return (a + b ) % self.m

    def sub(self, a, b):
        return (a - b) % self.m
    
    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, self.pow(b, self.m-2))

    def pow(self, x, y):
        if y == 0: 
            return 1
        elif y == 1: 
            return x % self.m
        elif y % 2 == 0: 
            return self.pow(x, y//2)**2 % self.m
        else: 
            return self.pow(x, y//2)**2 * x % self.m


@mt
def slv(N):
    if N==3:
        return 61

    m = Mod(10**9+7)
    dp = {}
    iv = [
        'agc',
        'acg',
        'gac',
        'aggc'
        'acgc',
        'atgc',
        'agac',
        'aggc',
        'agtc',
    ]
    for s in product('agct', repeat=4):
        s = ''.join(s)
        if not any(map(lambda x: x in s, iv)):
            dp[s] = 1

    for _ in range(N-4):
        dp_ = Counter()
        for k, v in dp.items():
            for c in 'agct':
                s = k + c
                s = s[1:]
                if s in dp:
                    dp_[s] = m.add(v, dp_[s])
        dp = dp_
    
    ans = 0
    for k, v in dp.items():
        ans = m.add(ans, v)


    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7992
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min} ;

fn main() {
    input! {
        a: i64,
        b: i64,
    }

    if a*b <= 0 { println!("Zero") }
    else if a > 0 || (b-a) % 2 == 1 || a == b { println!("Positive") }
    else { println!("Negative") }
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int simulation(int n,int p){
	int res=p;
	vector<int> a(n);
	int pos=0;
	while(p>0){
		a[pos]++;
		p--;
		pos++;
		pos%=n;
	}

	while(true){
		if(p==0){
			p+=a[pos];
			a[pos]=0;
		}else{
			p--;
			a[pos]++;
		}
		if(a[pos]==res)break;

		pos++;
		pos%=n;
	}
	return pos;
}

int main()
{
	int n,p;
	while(cin>>n>>p,(n!=0&p!=0)){
		cout<<simulation(n,p)<<endl;
	}

	// int n=10;

	// repi(p,2,51){
	// 	cout<<p<<" "<<simulation(n,p)<<endl;
	// }

	return 0;
}


Measured memory_bytes: 3044
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>

using namespace std;

int main(void)
{
    string neko;
    cin >> neko;
    int sum = 0;
    for (int i = 0; i < neko.length(); i++)
    {
        if (neko[i] == 'x')
        {
            sum++;
        }
    }
    if ((15 - sum) < 8)
    {
        cout << "NO";
    }
    else
    {
        cout << "YES";
    }
}

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

int main(){
    int N; cin >> N;
    multiset<Int> S;
    rep(i,N){
        Int A; cin >> A;
        S.insert(A);
    }

    vector<Int> pow2 = {2};
    rep(i,30) pow2.push_back(pow2.back() * 2);

    int ans = 0;
    while(!S.empty()){
        Int now = *(--S.end()); 
        S.erase(--S.end());

        rep(j,31){
            auto it = S.find(pow2[j] - now);
            if(it != S.end()) {
                ans++;
                S.erase(it);
                break;
            }
        }
        cout << endl;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
int n,a,k,ans;
int find(int a,int k){
	if(!(a%k))return a/k;
	if(a < k)return 0;
	int by = a/k + 1;
	int to = a%k + by - 1;
	return find(a - to/by*by,k);
}
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		scanf("%d%d",&a,&k);
		ans^=find(a,k);
	}
	puts(ans ? "Takahashi" : "Aoki");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//节点从0到n-1
#define maxn 100006
struct node { double x, y; };
int n;//有多少个点
int tot;//凸包上的点
node p[maxn];//所有点数组从0开始
node P[maxn];//凸包上的点
const double pi = acos(-1.0);
//三点差积	 
double X(node A, node B, node C) { return (B.x - A.x)*(C.y - A.y) - (C.x - A.x)*(B.y - A.y); }
//两点距离
double len(node A, node B) { return sqrt((A.x - B.x)*(A.x - B.x) + (A.y - B.y)*(A.y - B.y)); }
//角度小的在前面,相同的话距离小的在前面
bool cmp(node A, node B) {
	double pp = X(p[0], A, B);
	if (pp > 0)return true;
	if (pp < 0)return false;
	if (pp == 0)return len(p[0], A) < len(p[0], B);
}
const double eps = 1e-9;
//三点点积	 
double dian(node A, node B, node C) { return (B.x - A.x)*(C.x - A.x) + (C.y - A.y)*(B.y - A.y); }
//建立凸包存到P里//以下是n>=3的情况,n=1,2要特判
void build() {
	//找左下角的点
	for (int i = 0; i < n; i++) {
		if (p[i].y < p[0].y) swap(p[i], p[0]);
		if (p[i].y == p[0].y&&p[i].x < p[0].x) swap(p[i], p[0]);
	}
	sort(p + 1, p + n, cmp);
	P[0] = p[0];
	P[1] = p[1];
	tot = 1;//初始两个点
	for (int i = 2; i < n; i++) {
		//如果需要边上的点 
		while (tot > 0 && X(P[tot - 1], P[tot], p[i]) < 0)tot--;
//		while (tot > 0 && X(P[tot - 1], P[tot], p[i]) <= 0)tot--;//P[tot]在左边 舍弃
		tot++;
		P[tot] = p[i];
	}
	// 如果需要边上点 要这块 
	node endd = P[tot];
	for (int i = n - 1; i >= 0; i--) {
		if (abs(X(P[0], endd, p[i])) <= eps) {
			if (dian(p[i], P[0], endd) < 0) {
				tot++;
				P[tot] = p[i];
			}
		}
		else break;
	}
	// 到这上面是需要注释掉的 
	tot++;
}
int main(){
//	freopen("a.txt","r",stdin);
	scanf("%d",&n);
	for(int i=0;i<n;i++)cin>>p[i].x>>p[i].y;
	build();
	printf("%d\n",tot);
	for(int i=0;i<tot;i++){
		cout<<P[i].x<<' '<<P[i].y<<endl;
	}
	return 0;
}


Measured memory_bytes: 5712
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 10100000000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

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

signed main() {
  int n;cin>>n;
  vector<int> d = divisor(n);
  int ans = INF;
  rep(i,d.size()){
    ans = min(ans, d[i]+(n/d[i])-2);
  }
  cout << ans << endl;
}




Measured memory_bytes: 384
#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<double, double>;

int main(){
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  P ss(a*sin(h*M_PI/6+m*M_PI/360), -a*cos(h*M_PI/6+m*M_PI/360));
  P ls(b*sin(m*M_PI/30), -b*cos(m*M_PI/30));
  double dx=ss.first-ls.first;
  double dy=ss.second-ls.second;
  double ans = sqrt(dx*dx+dy*dy);
  printf("%.10lf\n", ans);
}

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

int main() {
  ll n; cin >> n;
  ll res = 0;
  for (ll i = 0; i < n; i++) {
    ll x; cin >> x; res += x;
  }
  res -= n;
  cout << res << endl;
}
    
     

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
static string[] input = Console.ReadLine().Split(' ');
static int n = int.Parse(input[0]);
static int q = int.Parse(input[1]);
static List<int>[] nextList = new List<int>[n];//隣接リスト（リストの入った配列）
static long[] pluses = new long[n];
static long[] answers = new long[n];
static bool[] usedVertexes = new bool[n];

	static void Main()
	{
    for(int i = 0; i < n; i++)
    {
      nextList[i] = new List<int>();//リストの宣言
    }
    for(int i = 0; i < n-1; i++)
    {
      int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
      nextList[nums[0]-1].Add(nums[1]-1);//隣接リストへ追加。
      nextList[nums[1]-1].Add(nums[0]-1);
    }

    for(int i = 0; i < q; i++)
    {
      long[] numsa = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      pluses[numsa[0]-1] += numsa[1];
    }

    DP(0,pluses[0]);
    
		Console.WriteLine(string.Join(" ", answers));
	}

  static void DP(int vertexNum, long plusCount)
  {
    usedVertexes[vertexNum] = true;
    answers[vertexNum] += plusCount;

    for(int i = 0; i < nextList[vertexNum].Count; i++)
    {
      if(!usedVertexes[nextList[vertexNum][i]])
      {
        DP(nextList[vertexNum][i], plusCount+pluses[nextList[vertexNum][i]]);
      }
    }
  }
}

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

# define PI 3.14159265358979323846

int main() {
	
	double r;
	cin >> r;

	cout << fixed << setprecision(6) << r * r * PI;
	cout << ' ';
	cout << fixed << setprecision(6) << 2 * r * PI;

	return 0;
}


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

int main(){
    int R, G, B, N, r, g, b, sum = 0;
    vector<int> rgb(3);
    cin >> rgb.at(0) >> rgb.at(1) >> rgb.at(2) >> N;
    sort(rgb.begin(), rgb.end());
    R = rgb.at(0);
    G = rgb.at(1);
    B = rgb.at(2);
    for(int r=0; r<N/R+1; r++){
        int N1 = (N-R*r)/G;
        for(int g=0; g<N1+1; g++){
            if((N-R*r-G*g)%B==0) sum ++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256