akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>//toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\n"
using namespace std;
typedef long long ll;

void solve(){
    int n;
    cin >> n;
    vector<ll> a(n);
    forn(i,n) cin >> a[i];
    vector<ll> ans(n);
    int i,j;
    ans[0] = 0;
    for(i=1;i<n;i++){
        ans[0] = ans[0]^a[i];
    }
    ll temp = ans[0];
    for(i=1;i<n;i++){
        temp = temp^a[i];
        temp = temp^a[i-1];
        ans[i] = temp;
    }
    for(auto x : ans){
        cout << x << " ";
    }
    cout << endl;
}   

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 6364
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

    let ReadList n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop (ReadNext () :: acc) (c-1)
        loop [] n

open InputUtility

module ABC064 =
    let private ``Colorful Leaderboard`` () =
        let un = 8
        let n = ReadNextInt ()
        let a =
            ReadListOf int n
            |> Seq.map (fun d -> d / 400)
            |> Seq.where ((>) un)
            |> Seq.cache
        //printfn "a:\t%s" (System.String.Join(" ", a |> Seq.sort))
        //printfn "da:\t%s" (System.String.Join(" ", a |> Seq.sort |> Seq.distinct))
        let m = a |> Seq.distinct |> Seq.length
        let u = m + n - Seq.length a
        printfn "%d %d" (max m 1) u

    let Entry = ``Colorful Leaderboard``

ABC064.Entry ()

Measured memory_bytes: 15196
from bisect import bisect_left

n=int(input())
L=list(map(int,input().split()))
L=sorted(L)
ans=0
for i in range(n-2):
    a=L[i]
    for j in range(i+1,n-1):
        ans+=bisect_left(L,a+L[j])-j-1
print(ans)


Measured memory_bytes: 43628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <unordered_map>
#include <cstdio>
#include <climits>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, a[300000];
int ans[300000];
int ma[300000];

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n;
	n = (1 << n);
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j = (j + 1) | i) {
			ans[j] = max(ans[j], ma[j] + a[i]);
			ma[j] = max(ma[j], a[i]);
		}
	}
	for (int i = 1; i < n; i++) {
		ans[i] = max(ans[i], ans[i - 1]);
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 6716
# coding: utf-8

import collections

# 標準入力 <int><int>
N, X, Y = map(int, input().split())

br = []

for i in range(N - 1):
  for j in range(i + 1, N):
    """
    #print("(" , i+1, j+1, ")", j-i, abs(X - (i + 1)) + 1 + abs(Y - (j + 1)), abs(Y - (i + 1)) + 1 + abs(X - (j + 1)))
    """
    br.append(min(j - i, abs(X - (i + 1)) + 1 + abs(Y - (j + 1)), abs(Y - (i + 1)) + 1 + abs(X - (j + 1))))

c = collections.Counter(br)

for k, v in c.items():
  print(v)

for _ in range(N - 1 - len(c)):
  print(0)


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

main(){
  string S, T;
  cin >> S;
  cin >> T;
  int count = 0;
  for(int i = 0; i < 3; i++){
    if(S.at(i) == T.at(i)){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int w, n;
	cin >> w >> n;
	int s[w];

	for(int i=0; i<w; i++){
		s[i] = i+1;
	}

	for(int t=0; t<n; t++){
		int a, b;
		char c;
		cin >> a >> c >> b;
		swap(s[a-1], s[b-1]);
	}

	for(int i=0; i<w; i++){
		cout << s[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var n = s.Length - 1;
        var nL = (int)Math.Pow(2, n);
        var ret = 0L;
        for (int i = 0; i < nL; i++)
        {
            var tlist = new List<int>();
            for (int j = 0; j < n; j++)
                if (((i >> j) & 1) == 1) tlist.Add(j);
            ret += getSum(s, tlist);
        }
        Console.WriteLine(ret);
    }
    public static long getSum(string s, List<int> c)
    {
        if (c.Count() == 0) return long.Parse(s);
        var ret = 0L;
        var p = 0;
        var pre = c[0];
        ret += long.Parse(s.Substring(0, pre + 1));
        p += pre + 1;
        for (int i = 1; i < c.Count(); i++)
        {
            var t = c[i];
            var w = s.Substring(p, t - pre);
            ret += int.Parse(w);
            p += t - pre;
            pre = t;
        }
        ret += int.Parse(s.Substring(p));
        return ret;
    }
}


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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    ll X[N+1],S[N+1];
    X[0] = S[0] = 0;
    for(int i=0;i<N;i++){
        X[i+1] = X[i]^ A[i];
        S[i+1] = S[i]+A[i];
    }
    ll ans =0;
    ll r=1;
    for(ll l=1;l<=N;l++){
        ll oldr =r;
        while(r<=N&& (S[r]-S[l-1])==(X[r]^X[l-1])){
            r++;
        }
        ll diff = r-oldr;
        // cerr <<"l=" << l <<", r=" << r << endl;
        ans += (diff*(diff+1))/2;
        ans += (diff*(oldr-l));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
open List;;
Scanf.scanf "%d %d" @@ fun x y -> print_endline @@
  if x = 2 || y = 2 then "No"
  else if exists (fun g -> mem x g && mem y g) [[1; 3; 5; 7; 8; 10; 12]; [4; 6; 9; 11]] then "Yes"
  else "No"

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

void swap(int arr[])
{
  int temp =0;
  temp = arr[0];
  arr[0] = arr[2];
  arr[2] = arr[1];
  arr[1] = temp;
}

void printArray(int arr[])
{
  for(int i=0; i<3; i++)
    cout << arr[i] << " ";
}

int main()
{
  int arr[3];
  for(int i=0; i<3; i++)
  	cin >> arr[i];
  swap(arr);
  printArray(arr);
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<set>
#include<string.h>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
//~#include<algorithm>
#include<iomanip>
#include<limits>
#include<string.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
 
#define pb push_back
#define ii pair<int, int>
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second

const ll INF = 1e18;
const double dinf = 12345678;
const int MOD = 1000000007;
const int maxn = 1e2 +10; 


//~ output :5 4 4 8

int n , m;
char mat[maxn][maxn];

int oy[] = {-1,0, 1, 0};
int ox[] = {0, 1, 0,-1};
int w;
void f( int i, int j ){
	if ( i < 0 ||  j < 0 || i == n || j == m || mat[i][j] == '.')  return;
	
	mat[i][j] = '.';
	++w;
	for(int k = 0 ;k < 4; k++){
		f(i  + oy[k], j + ox[k] );
	}
}

signed main (){ 
	//~ ios_base::sync_with_stdio(0); cin.tie(nullptr);  
	//~ vai
	scanf("%d %d ",&n,&m);
	
	for(int i = 0 ;i < n;i++){
		scanf("%s",mat[i]);
	}
	
	int c = 0;
	
	for(int i = 0 ;i < n;i++){
		for(int j = 0;j < m ;j++){
			if(mat[i][j] == '#')++c;
		}
	}
	
	for(int i = 0 ;i < n;i++){
		for(int j = 0 ;j < m;j++){
			w = 0;
			f( i , j );
			if( w  == 1){
				printf("No\n"); return 0;
			}
		}
	}
	
	printf("Yes\n"); 
	
	return 0;
	 
}


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

int n,m;


int main(){
	cin >> n >> m;
	vector<vector<int> > g(n*3);
	int f[n*3];
	for(int i =0;i<n*3;++i) f[i] = -1;
	
	int u,v;
	for(int i=0;i<m;++i){
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v+n);
		g[u+n].push_back(v+n*2);
		g[u+n*2].push_back(v);
	}
	
	int s,t;
	cin >> s >> t;
	s--;t--;
	s = s + n*2;
	queue<int> q;
	q.push(s);
	f[s] = 0;
	while(!q.empty()){
		int c = q.front();q.pop();
		for(int i=0;i<g[c].size();++i){
			int next = g[c][i];
//			cout << next << endl;
			if(f[next] == -1){
				q.push(next);
				f[next] = f[c] + 1;
			}
		}
	}
	
	if(f[t+2*n] == -1) cout << -1 << endl;
	else cout << f[t+2*n]/3 << endl;
	/*
	for(int i =0;i<n;++i){
		cout << f[i] << " " << f[i+n] << " " << f[i+2*n] <<endl;
	}*/

	return 0;
}



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

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;++i){
    cin >> a[i];
  }
  int cost_sum=0;
  int res;
  for(int cost=-100;cost<101;++cost){
    for(int i=0;i<N;++i){
    cost_sum+=pow(a[i]-cost,2);
    if(i==N-1){
      if(res>cost_sum){
        res=cost_sum;
        cost_sum=0;
        continue;
      }
      else{
        cost_sum=0;
        continue;
      }
    }
  }
    }

  cout << res;
}


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

using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> costs(n);
    for (int i = 0; i < n; i++) {
        cin >> costs[i];
    }

    vector<ll> costTo(n, LLONG_MAX);    //costTo[i] is the min cost required to get to i
    costTo[0] = 0;
    costTo[1] = abs(costs[1] - costs[0]);
    for (int i = 2; i < n; i++) {
        //cost is min of jump from 2 back or 1 back
        costTo[i] = min(
            costTo[i-2] + abs(costs[i] - costs[i-2]),    //jump by 2
            costTo[i-1] + abs(costs[i] - costs[i-1])    //jump by 1
            );
    }
    
    cout << costTo[n-1];

    return 0;
}

Measured memory_bytes: 1408
n, k = gets.chomp.split.map(&:to_i)

@fa_cache = []
@fa_cache[0] = 1

def fa(n)
    @fa_cache[n] || @fa_cache[n] = n * fa(n - 1)
end

cnt = []
(1..k).each do |i|
    cuts = i - 1
    base = fa(k - 1) / (fa(cuts) * fa(k - 1 - cuts))
    cnt[i] = base

    rem = (n - k) - cuts
    slits = cuts + 1
    ptns = fa(rem + slits) / (fa(rem) * fa(slits))

    cnt[i] = base * ptns
end

mod = 10 ** 9 + 7
cnt.drop(1).each { |c| puts c % mod }


Measured memory_bytes: 11132
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;

int n,a,b;
char s[100005];

int main(){
  scanf("%d%d%d",&n,&a,&b);
  scanf("%s",s);
  int len=strlen(s);
  int koku=0;
  int kai=0;
  for(int i=0;i<len;i++){
    if(s[i]=='a' && koku < a+b){
      printf("Yes\n");
      koku++;
    }else if(s[i]=='b' && koku < a+b && kai < b){
      printf("Yes\n");
      koku++;
      kai++;
    }else{
      printf("No\n");
    }
  }


  return 0;

}


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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int k,s,x,y,z,ans = 0;
    cin >> k >> s;
    for(x=0;x<=k;x++){
    	for(y=0;y<=k;y++){
    		int z = s-x-y;
    		if(z>=0 && z<=k) ans++;
		}
	}
	cout << ans << endl;
    
	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;

ll INF = LLONG_MAX;
ll MOD = 1e9 + 7;

using vc = vector<char>;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
    // lol wasnt expecting this to work
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll N, M; cin >> N >> M;
    vll XS (N);
    vll YS (M);    
    F0R(i, N) cin >> XS[i];
    F0R(i, M) cin >> YS[i];
    sort(XS.begin(), XS.end());
    sort(YS.begin(), YS.end());
    
    vll cumsumX (N); cumsumX[N-1] = XS[N-1];
    vll cumsumY (M); cumsumY[M-1] = YS[M-1];

    R0F(i, N-1) cumsumX[i] = cumsumX[i+1] + XS[i];
    R0F(i, M-1) cumsumY[i] = cumsumY[i+1] + YS[i];

    ll allX = 0;
    F0R(i, N - 1) allX += cumsumX[i+1] - (N - 1 - i) * XS[i], allX %= MOD;
    //ld EX = allX / (N * (N-1) / 2);

    ll allY = 0;
    F0R(i, M - 1) allY += cumsumY[i+1] - (M - 1 - i) * YS[i], allY %= MOD;
    //ld EY = allY / (N * (N-1) / 2);

    cout << allX * allY % MOD << endl;
    /*
    cout << allX << " " << allY << " " << allX * allY % MOD << endl;
    cout << EX << " " << EY << endl;
    cout << EX * EY * N * (N - 1) * M * (M - 1) / 4 << endl;
    */
}

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

using namespace std;

using ll = long long;

const ll INF = 1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll t;
    cin >> n >> t;
    vector<ll> a(n), b(n);
    vector<int> ids(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i1, int i2){
        if (a[i1] != a[i2]) return a[i1] < a[i2];
        return b[i1] > b[i2];
    });
    
    vector< vector<ll> > dp(n + 1, vector<ll>(t + 1, -INF));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        int ii = ids[i];
        for (int j = t - 1; j >= 0; j--) {
            if (dp[i][j] == -INF) continue;
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            dp[i + 1][min(j + a[ii], t)] = max(dp[i + 1][min(j + a[ii], t)], dp[i][j] + b[ii]);
        }
    }
    
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= t; j++) {
            if (dp[i][j] == -INF) continue;
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

alias Pair = Tuple!(int, "x", int, "y");

void main() {
    while (1) {
        int n;
        scan(n);

        if (!n) return;

        auto a = new Pair[](n);

        foreach (i ; 1 .. n) {
            int ni, di;
            scan(ni, di);
            if (di == 0) {
                a[i] = Pair(a[ni].x-1, a[ni].y);
            }
            else if (di == 1) {
                a[i] = Pair(a[ni].x, a[ni].y - 1);
            }
            else if (di == 2) {
                a[i] = Pair(a[ni].x+1, a[ni].y);
            }
            else {
                a[i] = Pair(a[ni].x, a[ni].y+1);
            }
        }

        int lm = 1000, rm = -1000;
        int bm = 1000, tm = -1000;

        foreach (ai ; a) {
            lm = min(lm, ai.x);
            rm = max(rm, ai.x);
            bm = min(bm, ai.y);
            tm = max(tm, ai.y);
        }

        writeln(rm - lm + 1, " ", tm - bm + 1);
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 3160
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 1e9+7;
// a^b % MOD;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
// 逆元 1/a % MOD
ll inversemod(ll a) { return powmod(a,MOD - 2);}

template<class Type>
Type solve(Type res = Type()){
    ll N,K; cin >> N >> K;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    
    for(int i = 0; i < N;i++){
        
        for(int j = 0; j < N;j++){
            if(i == j) continue;
            if(A[i] < A[j]){
                if(j < i){
                    (res += K*(K+1)/2)%=MOD;
                }else{
                    (res += (K-1)*K/2) %=MOD;
                }
            }
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

const int N = (int)1e5;

int dat[N+5];
pair<int,int> bats[N+5];
pair<int,int> vols[N+5];

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

    dat[0] = 0;
    bats[0] = vols[0] = make_pair(0,x);
    for (int i=1; i<=k; i++) {
        scanf("%d", dat+i);
        int diff = dat[i] - dat[i-1];

        bats[i] = bats[i-1];
        vols[i] = vols[i-1];
        if (i % 2 == 1) {
            int delta = vols[i].first - 0;
            bats[i].first += max(0, diff - delta);
            vols[i].first = max(0, vols[i].first - diff);
            vols[i].second = max(0, vols[i].second - diff);
        } else {
            int delta = x - vols[i].second;
            bats[i].second -= max(0, diff - delta);
            vols[i].first = min(x, vols[i].first + diff);
            vols[i].second = min(x, vols[i].second + diff);
        }
    }
    dat[k+1] = (int)1e9 + 7;

    int q; scanf("%d", &q);

    int idx = 1;
    for (int i=1; i<=q; i++) {
        int t,a; scanf("%d %d", &t, &a);
        while (dat[idx] <= t) idx++;

        int diff = t - dat[idx-1];
        int curr = vols[idx-1].first + (a - bats[idx-1].first);
        if (a <= bats[idx-1].first) {
            curr = vols[idx-1].first;
        } else if (a >= bats[idx-1].second) {
            curr = vols[idx-1].second;
        }

        if (idx % 2 == 1) {
            curr = max(0, curr - diff);
        } else {
            curr = min(x, curr + diff);
        }
        printf("%d\n", curr);
    }
    return 0;
}


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

int main(){
  
  int n;
  cin >>n;
  int w[n];
  int sa,sb;
  for(int i=0; i<n; i++){
    cin >> w[i];
    sa+=w[i];
    sb+=w[i];
  }
  
  sa=w[0];
  sb-=w[0];
  int ans=abs(sa-sb);
  for(int i=1; i<n; i++){
  	sa+=w[i];
    sb-=w[i];
    ans=min(ans,abs(sa-sb));
  }
  cout << ans << endl;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int X, T; cin >> X >> T;
  cout << max(X - T, 0) << endl;

  return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,b;
    cin >> n;
    vector<ll> a(n),dp(n,INF);
    rep(i,n){
        cin >> b;
        a[n-i-1] = b;
    }
    rep(i,n){
        *upper_bound(all(dp),a[i]) = a[i];
    }
    ll c = 0;
    while(c <= n-1 && dp[c] != INF){
        c++;
    }
    PRINT(c);
}


Measured memory_bytes: 1792
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N;
double v[100];
double ans;

int main() {
	cin >> N;
	REP(i, N) cin >> v[i];
	sort(v, v + N);
	ans = v[0];

	REP(i, N - 1) {
		ans = (ans + v[i + 1]) / 2;
	}

	cout << fixed;
	cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int n;
    cin >> n;
    vi d(n);
    rep(i,n){
        cin >> d[i];
    }
    sort(all(d));
    int ans = 0;
    if(d[n/2] == d[n/2-1]){cout << 0 <<endl; return 0;}
    ans = d[n/2] - d[n/2-1];
    cout<< ans <<endl;
    return 0;
}

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

int main(void) {
    int N, M;
    cin >> N >> M;

    int A[110];
    long long sum = 0;
    for (int i=0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }

    sort(A, A+N, greater<>());

    long long judge = sum / (4 * M);
    long long amari = sum % (4 * M);
    if (amari != 0) judge += 1;

    bool ans = true;

    for (int i=0; i<M; i++) {
        if (A[i] < judge) {
            ans = false;
            break;
        }
    }

    if (ans == false) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define INF 100000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = inx(x, y)
#define print(x) cout << x << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

void solve(){
	
	string S;
	cin >> S;
	ll length = S.size();
	vvl v(60, vl(length));
	vl ans(length);
	rep(i, length){
		if(S[i] == 'R') v[0][i] = i + 1;
		else v[0][i] = i - 1;
	}
	rep(i, 59) rep(j, length) v[i + 1][j] = v[i][v[i][j]];
	rep(i, length) ans[v[59][i]] += 1;
	printv(ans);
	
}	

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
    
	return 0;
	
}

Measured memory_bytes: 51488
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main(){
	readln.split.map!(s => s.capitalize.array[0]).array.writeln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N, Q;
  cin >> N >> Q;
  i64 ans = (N - 2) * (N - 2);
  vector<i64> a(N + 1, N), b(N + 1, N);
  i64 H = N, W = N;
  for (i64 _ = 0; _ < Q; _++)
  {
    i64 t, x;
    cin >> t >> x;
    if (t == 1)
    {
      if (x < W)
      {
        for (i64 i = x; i < W; i++)
          b[i] = H;
        W = x;
      }
      ans -= b[x] - 2;
    }
    else
    {
      if (x < H)
      {
        for (i64 i = x; i < H; i++)
          a[i] = W;
        H = x;
      }
      ans -= a[x] - 2;
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        s='#'+s;
        if(s[3]==s[4] and s[5]==s[6])
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }
    }
    return 0;
}


















Measured memory_bytes: 256
#include<iostream>
#include<cstring>

using namespace std;

int max(int a,int b)
{
  if(a>=b)
    return a;
  return b;
}
  
int main()
{

  int n;
  cin>>n;
  int dp[n][3];
  
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
    {
      cin>>dp[i][j];   
    }
  }
  
 
  for(int i=1;i<n;i++)
  {
    dp[i][0]=dp[i][0]+max(dp[i-1][1],dp[i-1][2]);                          
    dp[i][1]=dp[i][1]+max(dp[i-1][0],dp[i-1][2]);                          
    dp[i][2]=dp[i][2]+max(dp[i-1][0],dp[i-1][1]);
  }
  
   int m=max(dp[n-1][0],dp[n-1][1]);
        m=max(m,dp[n-1][2]);
        cout<<m;
  
  return 0;  
  }



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

struct LIST{
	int x;
	struct LIST *pre,*next;
};

void show(struct LIST *L){
	L=L->next;
	while(1){
		if(L->next==NULL){
			break;
		}
		printf("%d",L->x);
		L=L->next;
		if(L->next==NULL){
			printf("\n");
			break;
		}else{
			printf(" ");
		}
	}
}

void insert(struct LIST *head,int x,struct LIST *tail){
	struct LIST *add=(struct LIST*)malloc(sizeof(struct LIST));
	
	head->next->pre=add;
	
	add->next=head->next;
	add->pre=head;
	add->x=x;

	head->next=add;
}

void Delete(struct LIST *L,int x,struct LIST *tail){
	L=L->next;
	while(1){
		if(L->x==x){
			L->next->pre=L->pre;
			L->pre->next=L->next;
			break;
		}
		L=L->next;
		if(L->x==tail->x){
			break;
		}
	}
}

void deleteFirst(struct LIST *head){
	head=head->next;
	head->next->pre=head->pre;
	head->pre->next=head->next;
}

void deleteLast(struct LIST *tail){
	tail=tail->pre;
	tail->next->pre=tail->pre;
	tail->pre->next=tail->next;
}

int main(){
	int n;
	char command[120];
	int x;
	struct LIST *head=(struct LIST*)malloc(sizeof(struct LIST));
	struct LIST *tail=(struct LIST*)malloc(sizeof(struct LIST));
	head->x=-1;
	head->pre=NULL;
	tail->x=-2;
	tail->next=NULL;
	head->next=tail;
	tail->pre=head;

	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s",command);
		if(strcmp(command,"insert")==0){
			scanf("%d",&x);
			insert(head,x,tail);
		}else if(strcmp(command,"delete")==0){
			scanf("%d",&x);
			Delete(head,x,tail);
		}else if(strcmp(command,"deleteFirst")==0){
			deleteFirst(head);
		}else{
			deleteLast(tail);
		}
		
	}
	show(head);	

   return 0;
}


Measured memory_bytes: 36072
#include <stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d\n",&a,&b);
	if(a>=10||b>=10)
	{
		printf("-1\n");
	}else
	{
		c=a*b;
		printf("%d\n",c);
	}
	return 0;
	}

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


int main() {
    string s;
    cin >> s;
    int cnt = s.size();
    for(int i=0;i<s.size()-1;i++){
        if(s[i]!=s[i+1])
        cnt = min(cnt,max(i+1,(int) s.size()-i-1));
    }
    cout << cnt << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=300005,mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int n;
char s[N];
int dp[N][2][3][3];
//dp[i][a][b][c]: first i char, there's a 1s, stage b, last c 0s
int main(){
	cin>>s+1;
	n=strlen(s+1);
	s[n+1]='1';
	dp[0][0][0][0]=1;
	For(i,1,n+1) For(a,0,1) For(b,0,2) For(c,0,2){
		int v=dp[i-1][a][b][c],lb,ub;
		if (!v)
			continue;
		if (s[i]=='0')
			lb=ub=0;
		else if (s[i]=='1')
			lb=ub=1;
		else
			lb=0,ub=1;
		For(now,lb,ub){
			if (now==0){
				int C=c+1;
				if (C>2)
					C-=2;
				Add(dp[i][a][b][C],v);
			}
			else if (now==1){
				if (c==1)
					Add(dp[i][a][b][0],v);
				else if (a==0&&b<2&&c==0)
					Add(dp[i][0][b+1][0],v);
				else
					Add(dp[i][a^1][b][0],v);
			}
		}
	}
	int ans=0;
	For(a,0,1) For(b,2,2) For(c,0,2)
		Add(ans,dp[n+1][a][b][c]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 21632
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

int N;
string S;
int ans = 0;
void check(string T) {
	int i = 0;
	for (int j = 0; j < S.size(); j++) {
		if (T[i] == S[j]) i++;
		if (i == 3) {
			ans++;
			break;
		}
	}
}

int main()
{
	cin >> N >> S;
	for (int k = 0; k < 1000; k++) {
		int tmp = k;
		string t;
		for (int r = 0; r < 3; r++) {
			int num = tmp % 10;
			t += '0' + num;
			tmp /= 10;
		}
		reverse(t.begin(), t.end());
		check(t);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int cnt = 0;
    long long ans  = 0;
    string s;
    cin >> s;
    for(int i = 0;i<s.size();i++){
        if(s[i] == 'W'){
            ans += i-cnt;
            cnt++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll H, W, K;
    cin >> H >> W >> K;

    constexpr ll MOD = (ll)1e9 + 7;

    vector<ll> free(W, 0);
    free[0] = 1;
    free[1] = 2;
    for (ll i = 2; i < W; i++) {
        free[i] = free[i - 2] + free[i - 1];
    }

    vector<vector<ll>> dp(H + 1, vector<ll>(W + 1, 0));
    dp[0][0] = 1;
    for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
            //左右の自由度
            ll left_free = max(j - 1, (ll)0);
            ll right_free = max(W - 2 - j, (ll)0);

            //まっすぐ落ちる
            (dp[i + 1][j] += dp[i][j] * free[left_free] * free[right_free] % MOD) %= MOD;

            //左に行く
            if (j > 0) {
                (dp[i + 1][j - 1] += dp[i][j] * free[max(left_free - 1, (ll)0)] * free[right_free] % MOD) %= MOD;
            }
            //右に行く
            if (j < W - 1) {
                (dp[i + 1][j + 1] += dp[i][j] * free[left_free] * free[max(right_free - 1, (ll)0)] % MOD) %= MOD;
            }
        }
    }

    cout << dp[H][K - 1] << endl;
}

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

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    if (n < 105) cout << "0" << endl;
    else
    {
        int ans = 0;
        for (int i = 105; i <= n; i+=2)
        {  
            int c = 0;
            for (int j = 1; j <= i; ++j)
            {
                if (i%j == 0) ++c;
            }
            if (c == 8) ++ans;
        }
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

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

	vector<int> p(N), B(N), C(N - 1);

	int ans = 0;

	rep(i, N)
	{
		cin >> p[i];
	}

	rep(i, N)
	{
		cin >> B[i];
		ans += B[i];
	}

	rep(i, N - 1)
	{
		cin >> C[i];
	}

	rep(i, N - 1)
	{
		if (p[i] + 1 == p[i + 1])
		{
			ans += C[p[i] - 1];
		}
	}

	cout << ans << endl;

	return 0;
}


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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

typedef long long ll;
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;
}

#pragma endregion

int main() {
  int n = in();
  vector<int> v(n, 0);
  rep(i, n - 1) {
    int tmp = in();
    v[tmp - 1]++;
  }
  rep(i, n) { cout << v[i] << endl; }
  return 0;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,h[100003],l,r,tmp[100003];
bool check(long long times){
	for(int i=0;i<n;i++)tmp[i]=max(h[i]-b*times,0ll);
	for(int i=0;i<n;i++)
		if(tmp[i]>0)
			times=times-(tmp[i]-1)/(a-b)-1;
	return times>=0;
}
int main(){
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)cin>>h[i];
	l=1,r=1000000000;
	while(l!=r){
		long long mid=(l+r)/2;
		if(check(mid))
			r=mid;
		else
			l=mid+1;
	}
	cout<<l;
}

Measured memory_bytes: 1792
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <list>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator> 
#include <limits>
#include <cstring>

#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define ALL(a) (a).begin(),(a).end()
#define RALL(A) (a).rbegin(),(a).rend()
#define PB push_back
#define MP make_pair

#define dump(x) cerr << #x << " = " << (x) << endl;

using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
//const int INF = numeric_limits<int>::max() / 2;
const long long INF = numeric_limits<long long>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define MAX_E 2010
#define MAX_V 1010
// from - (cost) - to
struct edge {LL from, to, cost; };
edge es[MAX_E];
LL d[MAX_V]; // minimum distance
int V, E;

// find minimum distance from s to the others
void shortest_path(int s) {
    for (int i = 0; i < V; i++) {
        d[i] = INF;
    }
    d[s] = 0;
    for (int u = 0; u < V; u++) {
        for (int i = 0; i < E; i++) {
            edge e = es[i];
            if (d[e.from] != INF and d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    /*
    while (true) {
        bool update = false;
        for (int i = 0; i < E; i++) {
            edge e = es[i];
            if (d[e.from] != INF and d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        // no change
        if (!update) {
            break;
        }
    }
    */
}

// whether negative loop exists or not
bool find_negative_loop() {
    memset(d, 0, sizeof(d));
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < E; j++) {
            edge e = es[j];
            if (d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (i == V - 1) {
                    //cout << e.to << endl;
                    if (e.to != V - 1) {
                        continue;
                    }
                    return true;
                }
            }
        }
    }
    return false;
}

int main(int argc, char const* argv[])
{
    cin >> V >> E;
    REP(e, E) {
        LL a, b, c;
        cin >> a >> b >> c;
        a -= 1;
        b -= 1;
        c = -c;
        edge ed = {a, b, c};
        es[e] = ed;
    }
    if (find_negative_loop()) {
        cout << "inf" << endl;
        return 0;
    }
    shortest_path(0);
    cout <<  -d[V - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define ll long long
#define mset(s, _) memset(s, _, sizeof s)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
int main(void) {
  int MAX = 2 * pow(10, 5) + 1;
  int N;
  cin >> N;
  vector<int> P;
  vector<int> min_P;
  int min_p = MAX;
  rep(i, 1, N) {
    int p;
    cin >> p;
    P.push_back(p);
    min_p = min(min_p, p);
    min_P.push_back(min_p);
  }

  int ans = 0;
  rep(i, 0, N - 1) {
    if (P[i] == min_P[i]) ans++;
    // cout << P[i] << ' ' << min_P[i] << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5020
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int h,w; cin>>h>>w;
    vector<vector<char>> m(h+2,vector<char>(w+2,'#'));
    vector<vector<pp>> p(h+2,vector<pp>(w+2,mk(0,0)));
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>m[i][j];
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(m[i][j]=='.' && m[i][j-1]=='#'){
                p[i][j].first=1;
            }
            else if((m[i][j]=='.' && m[i][j-1]=='.')){
                p[i][j].first=p[i][j-1].first+1;
            }
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=w;j>=0;j--){
            if(m[i][j]=='.' && p[i][j+1].first>0)
            p[i][j].first=p[i][j+1].first;
        }
    }
    for(int j=1;j<=w;j++){
        for(int i=1;i<=h;i++){
            if(m[i][j]=='.' && m[i-1][j]=='#'){
                p[i][j].second=1;
            }
            else if((m[i][j]=='.' && m[i-1][j]=='.')){
                p[i][j].second=p[i-1][j].second+1;
            }
        }
    }
    for(int j=1;j<=w;j++){
        for(int i=h;i>=0;i--){
            if(m[i][j]=='.' && p[i+1][j].second>0)
            p[i][j].second=p[i+1][j].second;
        }
    }
    int ans=0;
    rep(i,h+2){
        rep(j,w+2){
            ans=max(ans,p[i][j].first+p[i][j].second-1);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 35584
// ABC 061 D Score Attack

using System;
using System.Linq;

class Program
{
    static int N;
    static int M;
    static int[] a; // a[i] : a_(i + 1) - 1
    static int[] b; // b[i] : b_(i + 1) - 1
    static int[] c; // c[i] : -c_(i + 1)

    static void Main()
    {
        /* 入力の受け取り */
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        N = input[0];
        M = input[1];
        a = new int[M];
        b = new int[M];
        c = new int[M];
        for (int i = 0; i < M; i++)
        {
            input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            a[i] = input[0] - 1;
            b[i] = input[1] - 1;
            c[i] = -input[2];
        }

        /* (辺の重みを-1倍してあるので)BellmanFord法により最短経路および負閉路の存在を判定 */
        long[] dis = new long[N];
        for (int i = 1; i < N; i++)
            dis[i] = (long)1e18;
        for (int i = 1; i < N; i++)
        {
            for (int j = 0; j < M; j++)
            {
                if (dis[a[j]] == (long)1e18) continue;
                if (dis[b[j]] > dis[a[j]] + c[j])
                    dis[b[j]] = dis[a[j]] + c[j];
            }
        }
        long ans = -dis[N - 1];
        for (int i = 1; i < N; i++)
        {
            for (int j = 0; j < M; j++)
            {
                if (dis[a[j]] == (long)1e18) continue;
                if (dis[b[j]] > dis[a[j]] + c[j])
                    dis[b[j]] = dis[a[j]] + c[j];
            }
        }
        if (ans == -dis[N - 1]) Console.WriteLine(ans);
        else Console.WriteLine("inf");
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
    string S;
    cin >> S;
    const string ss = "CODEFESTIVAL2016";
    int ans = 0;
    rep(i,16) if (S[i] != ss[i]) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, k;
  readf("%s %s\n", &n, &k);
  int res;
  while (n) {
    n /= k;
    res++;
  }
  res.writeln;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int a, b, x;
  cin >> a >> b >> x;
  cout << ((a + b >= x && x >= a) ? "YES" : "NO");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3636