akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>a>>b>>c;
    while(1){
        if(a%2==1||b%2==1||c%2==1)break;
        tmp=a;
        tmpp=b;
        pos=c;
        a=(tmpp+pos)/2;
        b=(tmp+pos)/2;
        c=(tmp+tmpp)/2;
        ans++;
        if(ans>=100000*5){
            Cout(-1);
            return 0;
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	vector<pair<int, int>> data;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		data.push_back(make_pair(i + 1, tmp));
	}
	sort(data.begin(), data.end(), [](const pair<int, int> &a, const pair<int, int> &b) {
		return a.second < b.second;
		});

	cout << data[0].first;
	for (int i = 1; i < n; i++)
	{
		cout << " " << data[i].first;
	}
}


Measured memory_bytes: 33012
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);i <= (e);(i)++)

int n;

vector<int > a;

int main(){
  cin >> n;
  a.resize(n);
  for(int i = 0;i < n;i++) cin >> a[i];
  cout << *max_element(a.begin(),a.end()) - *min_element(a.begin(),a.end()) << endl;;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::iter::once;
#[cfg(debug_assertions)]
include! {"./debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

macro_rules! read {
    ([$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ([$t:ident]) =>
        (rl().split_whitespace().map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    (_, [$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!(_, [$t])).collect::<Vec<_>>());
    (_, [$t:ident]) =>
        (rl().split_whitespace().skip(1).map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    ($($t:ident),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ($t:ident) => (read_type!(rl(), $t));
    ($($t:ident),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(read_type!(w.next().unwrap(), $t)),*)
    }};
}

macro_rules! read_type {
    ($s:expr, chars) => {
        $s.chars().collect::<Vec<char>>()
    };
    ($s:expr, usize1) => {
        read_type!($s, usize) - 1
    };
    ($s:expr, $t:ty) => {
        $s.parse::<$t>().unwrap()
    };
}

fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

////////////////////////////////////////////////////////////////////////////////

fn main() {
    let r = read!(i64);

    let ans = 3 * r * r;

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


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

int main()
{
    long long n, k;
    cin >> n >> k;

    long long q = n % k;

    cout << min(q, abs(k - q)) << endl;
}


Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7,maxn=1<<18;

int n,x,y,z,S,ok;
int dp[42][maxn];
void solve(){
	cin>>n>>x>>y>>z;
	S=1<<x+y+z-1;
	ok=(1<<x+y+z-1)|(1<<y+z-1)|(1<<z-1);
	dp[0][0]=1;
	for(int i=0;i<n;++i){
		for(int s=0;s<S;++s){
			for(int a=1;a<=10;++a){
				int t=(s<<a)|(1<<a-1);
				if((ok&t)==ok)continue;
				(dp[i+1][t&(S-1)]+=dp[i][s])%=mod;
			}
		}
	}
	ll ans=1;
	for(int i=0;i<n;++i)
		ans=ans*10%mod; 
	for(int i=0;i<S;++i){
		ans-=dp[n][i];
	}
	ans%=mod;
	(ans+=mod)%=mod;
	cout<<ans<<endl;
}

int main(){
	solve();	
	return 0;
} 

Measured memory_bytes: 41472
#include<iostream>

using namespace std;

void swap(int &a, int &b)
{
   int temp = a;
   a = b;
   b  = temp;
}

int main()
{
	int x,y,z;
	cin>>x>>y>>z;

	swap(x,y);
	swap(x,z);

	cout<<x<<" "<<y<<" "<<z;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int N,ans=-INF;
  cin >> N;
  int F[N][10],P[N][11];
  FOR(i,0,N)FOR(j,0,10)cin >> F[i][j];
  FOR(i,0,N)FOR(j,0,11)cin >> P[i][j];
  FOR(i,1,1<<10){
    int pro = 0;
    bool open[10];
    FOR(j,0,10)open[j] = i&(1<<j);
    FOR(j,0,N){
      int bothopen=0;
      FOR(k,0,10)if(F[j][k] && open[k])bothopen++;
      pro += P[j][bothopen];
    }
    ans = max(ans,pro);
  }
  cout << ans << endl;
}


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

using namespace std;

int counter, length;
string word;

int main() {
    cin >> length >> word;

    for (int i = 0; i < length - 2; i++) {
        if (word[i] == 'A' && word[i + 1] == 'B' && word[i + 2] == 'C') {
            counter++;
            i += 2;
        }
    }

    cout << counter;
}

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

const int MAXN = 100005;

int n, a[MAXN];
int f[MAXN];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a+1, a+n+1);
	for (int i = 0; i < n; i++) {
		f[i] = a[n-i]-1;
		// cerr << f[i] << " ";
	}
	// cerr << endl;
	int pos = 0, cnt = 0;
	for (int i = 0; i < n; i++) {
		if (f[i] >= i) 
			pos = i;
		else break;
	}
	for (int j = pos+1; j < n; j++)
		if (f[j] == pos)
			cnt++;
	// cerr << cnt << " " << f[pos]-pos << endl;
	if (!(cnt&1) && !((f[pos]-pos)&1)) puts("Second");
	else puts("First");
	return 0;
}


Measured memory_bytes: 1024
L,R = map(int,input().split())
target = 2019
L_mod = L % target
R_mod = R % target
#print(L_mod,'L',R_mod,'R')
if L_mod > R_mod:
    print(0)
    exit(0)
if L_mod == R_mod and L < R:
    print(0)
    exit(0)
if L+1 == R:
    print(L * R % target)
    exit(0)
if L_mod < R_mod and R-L >= target:
    print(0)
    exit(0)

ans = 2019
for i in range(R_mod-L_mod + 1):
    for j in range(i+1,R_mod-L_mod+1):
        #print(L+j,'Lj')
        if ((L+i) * (L+j)) % target < ans:
            #print(L+i,'Li')
            #print(L+j,'Lj')
            ans = ((L+i) * (L+j)) % target
            if ans == 0:
                print(0)
                exit(0)
print(ans)

'''
2020 3000
2020 4040
2018 4040
2018 2020
'''




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
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 under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, pair<int, int>>> a(m);
	rep(i, m) {
		cin >> a[i].first >> a[i].second.first;
		a[i].second.second = i;
	}
	sort(all(a));
	vector<P<int>> ans(m);
	int back = -1;
	int now = 0;
	int count = 1;
	rep(i, m) {
		if (back != a[i].first) count = 1;
		else count++;
		back = a[i].first;
		ans[a[i].second.second] = make_pair(a[i].first, count);
	}
	rep(i, m) printf("%06d%06d\n", ans[i].first, ans[i].second);
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  string s;cin>>s;
  string t;cin>>t;
  for(int i=0;i<s.length();i++){
    if(s[i]!=t[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


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

    vector<pair<int,int>> v(N);
    REP(i,N) {
        int a,b;
        cin >> a >> b;
        v[i] = make_pair(a,b);
    }

    sort(ALL(v));

    auto last = v.back();
    cout << last.first + last.second << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#define itn int
#define reaD read
#define N 5005
#define mod 1000000007
using namespace std;

int n, head[N], cnt, g[N], f[N][N], sz[N], tmp[N << 1]; 
struct edge { int to, next; } e[N << 1]; 

inline int read()
{
	int x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	return x * w;
}

inline void add(int u, int v) { e[++cnt] = (edge) { v, head[u] }; head[u] = cnt; }

void dfs(int u, int fa)
{
	f[u][1] = 1; sz[u] = 1;
	for(int i = head[u]; i; i = e[i].next)
	{
		int v = e[i].to; if(v == fa) continue;
		dfs(v, u);
		for(int j = 0; j <= sz[u] + sz[v]; j++) tmp[j] = 0;
		for(int j = 0; j <= sz[u]; j++)
			for(int k = 0; k <= sz[v]; k++)
				tmp[j + k] = (tmp[j + k] + 1ll * f[u][j] * f[v][k] % mod) % mod;
		sz[u] += sz[v]; 
		for(int j = 0; j <= sz[u]; j++) f[u][j] = tmp[j]; 
	}
	int res = 0; 
	for(int i = 0; i <= sz[u]; i += 2) res = (res + (mod - 1ll * f[u][i] * g[i] % mod)) % mod;
	f[u][0] = res; 
}

int main()
{
	n = read(); g[0] = 1; 
	for(int i = 1; i < n; i++) { int u = read(), v = read(); add(u, v); add(v, u); }
	for(int i = 2; i <= n; i += 2) g[i] = 1ll * g[i - 2] * (i - 1) % mod;
	dfs(1, 0); 
	printf("%d\n", mod - f[1][0]); 
	return 0;
} 

Measured memory_bytes: 97280
#include<iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int c=0;
	if(n%10==2)c++;
	n/=10;
	if(n%10==2)c++;
	n/=10;
	if(n%10==2)c++;
	n/=10;
	if(n%10==2)c++;
	n/=10;
	if(n%10==2)c++;
	n/=10;
	cout << c << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
num = int(input())
s = sorted(list(map(int,input().split())) ,reverse = True)

alice,bob = 0,0
for i,j in enumerate(s):
    if i % 2 ==0:
        alice += j
    else:
        bob += j

print(alice - bob)



Measured memory_bytes: 2940
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

template<class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }


int main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    //priority_queue<pair<ll,int>> q;
    rep(i,n){
        cin>>a[i];

    }
    //sort(a.begin(),a.end());
    multiset<ll> p;
    p.insert(a[0]);


    for(int i=1;i<n;i++){
       // sort(p.begin(),p.end());
        auto c = p.lower_bound(a[i]);
       // cout<< (c-p.begin())<<"c"<<endl;
        if(c==p.begin()){
            p.insert(a[i]);
        }else{
            c--;
            p.erase(c);
            p.insert(a[i]);
        }
//        rep(i,p.size())cout<<p[i];
//        cout<<endl;

    }



  cout<<p.size()<<endl;


    return 0;
}


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

int main(){
  int n,x,t;
  cin>>n>>x>>t;
  int ans;
  
  if(n%x==0){
    cout<<(n/x)*t;
  }
  if(n%x!=0){
    cout<<(n/x+1)*t;
  }
}



Measured memory_bytes: 3548
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		//		int num = sc.nextInt();
		//		int n[][] = new int[][];

		//未受験を最初にFにする
		//A～Fをif elseで記述
		//ただしDはさらにネストで再試験50点の条件を用意する

		//前提Fの条件　mかfが-1
		//Aの条件　m+fが80以上
		//Bの条件　m+fが65以上
		//Cの条件　m+fが50以上　もしくは30<=m+f<50かつ50<=r
		//Dの条件　m+fが30以上
		//Fの条件　m+fが30未満
		//mfr全てが-1の時にループを抜ける

		//rの-1は影響を及ぼさない(無視)

		while (true) {

			int m = sc.nextInt();//中間試験
			int f = sc.nextInt();//期末試験
			int r = sc.nextInt();//再試験
			int p = m + f;

			if (m == -1 && f == -1 && r == -1) {
				break;
			} else if (m == -1 || f == -1) {//未受験
				System.out.println("F");
			} else if (p >= 80) {//A
				System.out.println("A");
			} else if (p >= 65) {//B
				System.out.println("B");
			} else if (p >= 50||(p < 50 && p >= 30 && r >= 50)) {//C
				System.out.println("C");
			} else if (p >= 30) {//D
				System.out.println("D");
			} else if (0 <= p && p < 30) {
				System.out.println("F");

			}

		}

	}

}


Measured memory_bytes: 26108
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int x = Integer.parseInt(sc.next());
    int[] m = new int[n];
    int num = 0;
    int mMin = 10000;
    for (int i = 0; i < n; i++){
      m[i] = Integer.parseInt(sc.next());
      x -= m[i];
      num++;
      if(mMin > m[i]){
        mMin = m[i];
      }
    }
    while(x >= mMin){
      num++;
      x -= mMin;
    }
    System.out.println(num);
  }
}

Measured memory_bytes: 21844
import std.stdio;
import std.conv;
import std.string;

void main() {
  int times;
  while((times = readln.chomp.to!(int)) != 0){
    char[] str = cast(char[])readln.chomp;
    for(int i = 0; i < times; i++) {
      char[] next_str;
      char prev;
      uint n = 1;
      prev = str[0];
      foreach(s; str[1..$]) {
        if (prev == s) ++n;
        else {
          next_str ~= text(n, prev);
          prev = s;
          n = 1;
        }
      }
      next_str ~= text(n, prev);
      str = next_str;
    }
    writeln(str);
  }
}

Measured memory_bytes: 2096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <set>
#include <map>

using namespace std;

int db[1005];

int main()
{
	int n , a, b,ans=0;
	cin >> n >> a >> b;
	for(int i = 1 ; i <= n ; i++){
		int sum = 0;
		int tmp = i;
		while(tmp > 9){
			sum += (tmp % 10) ;
			tmp /= 10;
		}
		sum += tmp ;
		if(sum >=  a && sum <= b){
			ans += i;
		}
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
typedef long long ll;

using namespace std;

int main(){
	int N;
  	vector<int> H;
  	cin >> N;
  	for(int i = 0; i < N; i++){
      	int a;
    	cin >> a;
      	H.push_back(a);
    }
  	H.push_back(1000000009);
  	int s = H[0];
  	int count = 0;
  	int max_nt = 0;
  	for(int i = 1; i <= N; i++){
    	if(s >= H[i]){
          count++;
        } else {
          	if(count > max_nt) max_nt = count;
          	count = 0;
        }
      	s = H[i];
    }
  	cout << max_nt << endl;
}

Measured memory_bytes: 892
#import<bits/stdc++.h>
using namespace std;long N,n;vector<long>A;main(){for(cin>>N;cin>>n;n=1LL<<50)A.push_back(n);auto a=begin(A),t=a+1,d=end(A),b=t+1;partial_sum(a,d,a);for(--d;t+1!=d;++t){for(;a+1!=t&&*a<*t-*(a+1);++a);if(b==t)++b;for(;b+1!=d&&*b-*t<*d-*(b+1);++b);n=min(n,max({*a,*t-*a,*b-*t,*d-*b})-min({*a,*t-*a,*b-*t,*d-*b}));}cout<<n<<" ";}

Measured memory_bytes: 3444
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      total = 500*i + 100*j + 50*k
      if total == x:
        cnt += 1
print(cnt)

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

int main(){
    int N;
    int l[1010], r[1010];
    cin >> N;
    for (int i = 0; i < N; ++i){
        cin >> l[i] >> r[i];
    }
    int sum = 0;
    for (int i = 0; i < N; ++i){
        sum += r[i] - l[i] + 1;
    }
    cout << sum << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define tt this->
#define ll long long
using namespace std;
int main ()
{
    int x,y;
    cin>>x>>y;
    cout<<x*y;
    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  int n; cin >> n;
  vi a(3*n); rep(i,3*n) cin >> a[i];

  priority_queue<int,vi,greater<int>> front;
  priority_queue<int> behind;
  vector<ll> red(n+1),blue(n+1);
  rep(i,n){
    red[0] += a[i];
    front.push(a[i]);
  }
  rep(i,n){
    blue[n] += a[2*n+i];
    behind.push(a[2*n+i]);
  }
  //cout << SUM(red) << endl << SUM(blue) << endl;

  rep(i,n){
    front.push(a[n+i]);
    red[i+1] = red[i] + a[n+i] - front.top();
    front.pop();
  }
  rep(i,n){
    behind.push(a[2*n-i-1]);
    blue[n-i-1] = blue[n-i] + a[2*n-i-1] - behind.top();
    behind.pop();
  }

  ll ans = red[0] - blue[0];
  rep(i,n) ans = max(ans, red[i+1] - blue[i+1]);

  //cout << SUM(red) << endl << SUM(blue) << endl;
  //rep(i,red.size()) cout << red[i] << " " << blue[i] << endl;
  cout << ans << endl;
}

Measured memory_bytes: 4088
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

typedef long long ll;
const int MAXN=30;
const int INF=0x3f3f3f3f;

int L,n,m;
vector<pair<int,int> > E[MAXN];

inline void addedge(int u,int v,int val){E[u].push_back(make_pair(v,val)); m++;}

int dfs(int x){
    if(x==0) return 1;
    int last;
    if(x&1){
        int k=(x-1)/2;
        last=dfs(k);
        addedge(last,last+1,0);
        addedge(last,last+1,k+1);
    }
    else{
        int k=x/2;
        last=dfs(k-1);
        addedge(last,last+1,k);
        addedge(last,last+1,0);
        addedge(1,last+1,x);
    }
    return last+1;
}

int main(){
    scanf("%d",&L);
    n=dfs(L-1);
    printf("%d %d\n",n,m);
    for(int u=1;u<=n;u++){
        for(int i=0;i<(int)E[u].size();i++){
            int v=E[u][i].first,val=E[u][i].second;
            printf("%d %d %d\n",u,v,val);
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
#define clr(x) memset(x, 0, sizeof(x))
#define pb push_back
#define eb emplace_back

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

using ll = long long;
using namespace std;

ll GetScore(vector<ll> &vec, ll p)
{
	ll score = 0;
	for (auto &el : vec)
	{
		ll distance = p - el;
		score += distance * distance;
	}
	return score;
}

int main()
{
	ll N, K;
	vector<ll> x;
	cin >> N;
	ll val;
	rep(i, N)
	{
		cin >> val;
		x.eb(val);
	}
	sort(all(x));
	ll left = x[0];
	ll right = x[x.size() - 1];
	ll p = (left + right) / 2;

	ll re_score = (ll)1e18;
	ll score = GetScore(x, p);
	ll score_p1 = GetScore(x, p + 1);
	if (score < score_p1)
	{
		re_score = score;
		for (ll lp = p - 1; p >= left; --lp)
		{
			ll l_score = GetScore(x, lp);
			if (l_score < re_score)
			{
				re_score = l_score;
			}
			else
			{
				break;
			}
		}
	}
	else
	{
		re_score = score_p1;
		for (ll rp = p + 2; p <= right; ++rp)
		{
			ll r_score = GetScore(x, rp);
			if (r_score < re_score)
			{
				re_score = r_score;
			}
			else
			{
				break;
			}
		}
	}

	cout << re_score << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]

n = int(input())
s = input()


alpha_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
    alpha_dict[chr(c)] = i

alpha_swap = {v:k for k, v in alpha_dict.items()}
s_val = [(alpha_dict[val] + n) % 26 for val in s]
ans = ''
for val in s_val:
    ans += alpha_swap[val]

print(ans)


Measured memory_bytes: 3064
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####		
def main():
	N,K = LI()
	A = LI()

	cnt_d=defaultdict(lambda: 0)
	for i in A:
		cnt_d[i] += 1
	
	sorted_d = sorted(cnt_d.items(), key=lambda x: x[1])
	
	ans=0
	i=0
	n = len(cnt_d)
	while n>K:
		min_k,min_v = sorted_d[i]
		i+=1
		ans+=min_v
		n-=1

	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 39516
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;


int main(){
	int A,B,C,D;
	scanf("%d %d %d %d", &A, &B, &C, &D);

	if((A+B)>(C+D)){
		printf("Left\n");
	}else if((A+B)==(C+D)){
		printf("Balanced\n");
	}else{
		printf("Right\n");
	}

	return 0;
}


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


int main(){
    int n;
    cin >> n;
    vector<int> ac(4);
    rep(i,n){
        string s;
        cin >> s;
        if(s=="AC") ac[0]++;
        if(s=="WA") ac[1]++;
        if(s=="TLE") ac[2]++;
        if(s=="RE") ac[3]++;
    }
    cout << "AC x " << ac[0] << endl;
    cout << "WA x " << ac[1] << endl;
    cout << "TLE x " << ac[2] << endl;
    cout << "RE x " << ac[3] << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const ll INF = 1e10;
int n,x;
vector<int> m(105);
int main(){
  cin>>n>>x;
  REP(i,n){cin>>m[i];x-=m[i];}
  sort(m.begin(),m.begin()+n);
  cout<<n+x/m[0]<<endl;
  return 0;
}


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

int main(){
    long double a, b, c;
    cin >> a >> b >> c;
    long double d = sqrt(a * b);
    if (a + 2 * d + b < c)
        cout << "Yes\n";
    else
        cout << "No\n";
}

Measured memory_bytes: 256
s = int(input())
fuga = []
class B:
    def __init__(self):
        self.m = 1

    def hoge(self, n):
        fix = [_n for _n in fuga if n == _n]
        if fix:
            print(int(self.m))
            exit()
        if n >= 1000000:
            exit()
        fuga.append(n)
        self.m = self.m+1
        if n%2 == 0:
            self.hoge(n / 2)
        if n%2 == 1:
            self.hoge(3*n + 1)
b = B()
b.hoge(s)


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

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  int A = P + Q;
  int B = P + R;
  int C = Q + R;
  
  int ans = min( { A, B, C } );
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;

const ll MOD = 998244353;
const ld PI = acos((long double)(-1));

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define INF 1e+9
#define EPS 0.00000001

int main() {
    int a, b;
    cin >> a >> b;
    println(a * b);
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
       

int main(){
  int n;
  cin >>n;
  ll a[200010]={};
  int b[n];
  ll ans=0;
  for(int i=0;i<n;i++){
    cin >> b[i];
    a[b[i]]++;
  }
  for(int i=0;i<=n+1;i++){
    if(a[i]>=2){ans+=a[i]*(a[i]-1)/2;}
  }
  for(int i=0;i<n;i++){
    ll p=ans;
    if(a[b[i]]>=2){p=p-a[b[i]]+1;}
    cout << p << endl;
  }
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	int count;
	string s;
	while(getline(cin,s))
	{
		if(s=="END OF INPUT")
		break;
		count = 0;
		for(int i=0;i<s.length();i++) {
			count++;
			if(s[i]==' '){
				printf("%d",count-1);
				count = 0;
			}
			if(i==s.length()-1) printf("%d",count);
		}
		printf("\n");
	}
}

Measured memory_bytes: 3192
#include<iostream>
#include<vector>
using namespace std;
int main() {
	string a;
	int i;
	cin >> a;
	i = a.size();
	while (i > 0) {
		i--;

		if (i % 2 == 1) {
			if (a[i] == 'L' || a[i] == 'U' || a[i] == 'D') {
				continue;
			}
			else {
				cout << "No";
				return 0;
			}
		}
		else {
			if (a[i] == 'R' || a[i] == 'U' || a[i] == 'D') {
				continue;
			}
			else {
				cout << "No";
				return 0;
			}
		}
		
	}
	cout << "Yes";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < h.length; i++) {
            h[i] = sc.nextInt();
        }
        for (int i = 0; i < h.length - 1; i++) {
            if(h[i] < h[i + 1]) {
                h[i + 1] -= 1;
            }
            if(h[i] > h[i + 1]) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 58976
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve(N, B):
    ans = B[0] + B[-1]
    for i in range(1, N - 1):
        ans += min(B[i - 1], B[i])
    return ans


def main():
    N = int(input())
    B = list(map(int, input().split()))
    print(solve(N, B))


if __name__ == '__main__':
    main()


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N,K;
    cin >> N >> K;
    vector<int> x(N);
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
        int d = min(abs(x[i] - 0),abs(K - x[i]));
        d *= 2;
        ans += d;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N), B(N);
    {
        vector<pair<unsigned long, unsigned long>> inp(N);
        for(unsigned long i = 0; i < N; ++i)cin >> inp[i].second;
        for(unsigned long i = 0; i < N; ++i)cin >> inp[i].first;
        sort(inp.begin(), inp.end());
        transform(inp.begin(), inp.end(), A.begin(), [](auto i){return i.second;});
        transform(inp.begin(), inp.end(), B.begin(), [](auto i){return i.first;});
    }
    vector<unsigned long> idx(N), inv(N);
    iota(idx.begin(), idx.end(), 0UL);
    sort(idx.begin(), idx.end(), [&A](auto i, auto j){return A[i] < A[j];});
    for(unsigned long i = 0; i < N; ++i)inv[idx[i]] = i;

    for(unsigned long i = 0; i < N; ++i)if(B[i] < A[idx[i]])return 0 & puts("No");

    {
        vector<unsigned long> C(A);
        sort(C.begin(), C.end());
        for(unsigned long i = 1; i < N; ++i)if(A[i] == A[i - 1] || B[i] == B[i - 1])return 0 & puts("Yes");
    }

    {
        vector<unsigned long> p(idx), ip(inv);
        for(unsigned long i = 0; i + 1 < N; ++i){
            if(p[i] == i)return 0 & puts("Yes");
            auto k = p[i], j = ip[i];
            swap(ip[i], ip[k]);
            swap(p[i], p[j]);
        }
    }
    sort(A.begin(), A.end());
    for(unsigned long i = 1; i < N; ++i)if(A[i] <= B[i - 1])return 0 & puts("Yes");
    puts("No");
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    string title[N];
    int sec[N];
    string asleepTitle;
    int asleepFlag = 0;
    int sum = 0;

    for (int i=0;i<N;i++){
        cin >> title[i] >> sec[i];
    }
    cin >> asleepTitle;
    for (int i=0;i<N;i++){
        if (asleepFlag == 1) {
            sum += sec[i];
        }
        if (title[i] == asleepTitle){
            asleepFlag = 1;
        }
    }

    cout << sum << "\n";
}

Measured memory_bytes: 256
/**
*    created: 03.07.2020 15:17:35
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    a -= c;
    cout << a / (b+c) << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main()
{
	string s;
	cin >> s;
	int y, m, d;
	sscanf(s.c_str(), "%04d/%02d/%02d", &y, &m, &d);

	if (y < 2019 ||
		y == 2019 && m < 5)
	{
		cout << "Heisei" << endl;
	}
	else
	{
		cout << "TBD" << endl;
	}
	return 0;
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n;
    cin>>n;
    Array a(n);
    REP(i,n) cin>>a[i];
    ll con=0;
    ll ret=0;
    REP(i,n){
        if(ret&&a[i]) a[i]--,con++;
        con+=a[i]/2;
        a[i]%=2;
        ret=a[i];
    }
    cout<<con<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
    vector<int> ans(n);
    int a;
    rep(i,n-1) {
        cin >> a;
        ans[a-1] += 1;
    }
    rep(i,n) {
        cout << ans[i] << endl;
    }
	return 0;
}


Measured memory_bytes: 3984
X, Y = map(int,input().split())
# 合計X匹、足Y本

if Y % 2 == 1:
  print('No')
else:
 for num_turu in range(X+1):
   num_kame = X - num_turu
   if Y == 4 * num_kame + 2 * num_turu:
     print('Yes')
     break
 else:
  print('No')

Measured memory_bytes: 9164
#include<iostream>
using namespace std;
int main()
{
	char p[2][3];
	int i,j,flag=0;
	for(i=0;i<2;i++)
	 for(j=0;j<3;j++)
	 cin>>p[i][j];
     if(p[0][0]==p[1][2])
      if(p[0][1]==p[1][1])
       if(p[0][2]==p[1][0])
        flag=1;
     if(flag)cout<<"YES";
     else cout<<"NO";
	 return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
	int n;
	char s[100];
	scanf("%d%s", &n, s);
	string r (s);
	int ans = 0;
	for (int i = 0; i < (int)r.size() - 2; i++)
		if (r.substr(i, 3) == "ABC") ans++;
	printf("%d\n", ans);
}



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

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans=a*c;
  ans=max(ans,a*d);
  ans=max(ans,b*c);
  ans=max(ans,b*d);
  cout<<ans<<endl;
}

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

int main() {
	int N;
	cin >> N;
	bool Four = false;
	for (int i = 0; i < N; i++) {
		char c;
		cin >> c;
		if (c == 'Y') Four = true;
	}
	cout << (Four ? "Four" : "Three") << endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define N 2005
#define LL long long
#define mod 924844033
#define min(a,b) (a<b?a:b)
#define rep(i,j,k) for(i=j;i<=k;++i)
#define down(i,j,k) for(i=j;i>=k;--i)
int n,m,i,j,k,K,ans,sum,t,s1,s2,val;
int h[N][N][2][2],dp[N][N],g[N],f[N],fac[N],C[N][N];
void read(int &p){
	p=0; char x=getchar();
	while(x<'0' || x>'9') x=getchar();
	while(x>='0'&&x<='9'){p=p*10+x-'0'; x=getchar();}
}
void add(int &x,int y){ 
	x=(x+y)%mod;
	if(x<0) x+=mod;
}
void getdp(int n){
	int i;
	rep(i,0,n)
	 rep(j,0,i)
	  h[i][j][0][0]=h[i][j][1][0]=h[i][j][1][1]=h[i][j][0][1]=0;
	h[1][0][0][0]=h[1][1][0][1]=1;
	rep(i,1,n-1)
	 rep(j,0,i)
	  rep(s1,0,1)
	   rep(s2,0,1){
		   val=h[i][j][s1][s2];
		   add(h[i+1][j][s2][0],val);
		   if(!s1) add(h[i+1][j+1][s2][0],val);
		   if(i+1!=n) add(h[i+1][j+1][s2][1],val);
	   }
}
int main(){
	read(n); read(K);
	dp[0][0]=1;
	rep(i,1,K){
		t=(n-i+K)/K;
		getdp(t);
		sum+=t;
		rep(j,0,sum)
		 rep(k,0,min(j,t))
			 add(dp[i][j],(dp[i-1][j-k]*1LL*((h[t][k][0][0]+h[t][k][1][0])%mod))%mod);
	}
	fac[0]=1;
	rep(i,1,n) fac[i]=(fac[i-1]*1LL*i)%mod;
	rep(i,0,n){
		C[i][0]=C[i][i]=1;
		rep(j,1,i-1) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
	down(i,n,1){
		g[i]=(dp[K][i]*1LL*fac[n-i])%mod;
		rep(j,i+1,n) 
			add(g[i],((-f[j])*1LL*(C[j][i]-1))%mod);
		f[i]=(g[i]-g[i+1])%mod;
		if(f[i]<0) f[i]+=mod;
	}
	ans=fac[n]-g[1];
	if(ans<0) ans+=mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 50;

int a[N];

int main() {
	int n;cin>>n;
	rep(i,n) cin>>a[i];
	int i_min=0,v_min=INF;
	rep(i,n) if(a[i]<v_min) {i_min=i;v_min=a[i];}
	int i_max=0,v_max=-INF;
	rep(i,n) if(a[i]>v_max) {i_max=i;v_max=a[i];}
	if(v_max+v_min>=0) {
		cout<<2*n-2<<endl;
		rep(i,n) if(i!=i_max) cout<<i_max+1<<' '<<i+1<<endl;
		rep(i,n-1) cout<<i+1<<' '<<i+2<<endl;
	}
	else {
		cout<<2*n-2<<endl;
		rep(i,n) if(i!=i_min) cout<<i_min+1<<' '<<i+1<<endl;
		rep(i,n-1) cout<<n-i<<' '<<n-i-1<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
int N, A, B, C;
int minCost = INF;
vector<int> l(MAX);
/* function */
int dfs(int cur, int a, int b, int c) {
    if (cur >= N)
        return min({a, b, c}) > 0 ? abs(a - A) + abs(b - B) + abs(c - C) - 30 : INF;
    int ret0 = dfs(cur + 1, a, b, c);
    int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
    int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
    int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
    return min({ret0, ret1, ret2, ret3});
}
/* main */
int main(){
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++) cin >> l[i];

    cout << dfs(0, 0, 0, 0) << '\n';
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(ll i=l;i<r;i++)
#define rrep(i,l,r) for(ll i=(r)-1;i>=l;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define range(i) i.begin(),i.end()
#define sum(i) accumulate(range(i),0)
struct start { start() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }start;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head, Tail&&... tail) {
	cin >> head;
	in(move(tail)...);
}
template <class T>
inline void out(T t) {
	cout << t << '\n';
}
template <class Head, class... Tail>
inline void out(Head head, Tail... tail) {
	cout << head << ' ';
	out(move(tail)...);
}
template <class T>
inline void out(vector<T> a){
    rep(i,0,a.size()-1)cout<<a[i]<<' ';
    out(a.back());
}


int main() {
    int n,m;
    in(n,m);
    vector<bool> red(n+1);
    vector<int> ball(n+1,1);
    red[1]=1;
    int a,b;
    rep(i,0,m){
        in(a,b);
        if(red[a])red[b]=1;
        if(!--ball[a])red[a]=0;
        ball[b]++;
    }
    out(sum(red));
}









Measured memory_bytes: 640
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
  let mut line: String = String::new();
  io::stdin().read_line(&mut line);
  line.trim().parse().ok().unwrap()
}

fn main() {
  let num_str: String = input();
  let mut nums: Vec<u64> = Vec::new();
  for n in num_str.chars() {
    nums.push(n as u64 - 48);
  }
  let mut ret: u64 = 0;
  for bit in 0..(1<<nums.len()-1) {
    let mut sum = 0;
    let mut buf = 0;
    //println!("-----");
    for i in 0..(nums.len()-1) {
      if bit & (1<<i) != 0 {
        buf = 10 * buf + nums[i];
      } else {
        sum += 10 * buf + nums[i];
        buf = 0;
      }
      //println!("buf = {}", buf);
    }
    sum += 10 * buf + nums[(nums.len()-1) as usize];
    ret += sum;
  }
  println!("{}", ret);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  ll t = 0;
  ll ans = -1;
  REP(i, 30000000) {
    t = (t * 10 + 7) % n;
    if(t == 0) {
      ans = i + 1;
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3636