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

int main(void) {
  int N;
  bool isReverse = false;
  deque<int> deq;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (isReverse)
      deq.push_front(a);
    else
      deq.push_back(a);
    isReverse = !isReverse;
  }

  int size = deq.size();
  auto start = (isReverse ? deq.end() - 1 : deq.begin());
  auto end = (isReverse ? deq.begin() - 1 : deq.end());
  cout << (*start);
  start += (isReverse ? -1 : 1);
  for (; start != end; start += (isReverse ? -1 : 1)) {
    cout << " " << (*start);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3072
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
n = int(input())
ans = []
div_n = make_divisors(n)
for divisor in div_n:
    if divisor == 1:
        continue
    n_ = n
    while n_%divisor == 0:
        n_ = n_//divisor
    if n_ % divisor == 1:
        ans.append(divisor)
ans.extend(make_divisors(n-1))
answer = list(set(ans))
answer.remove(1)

print(len(answer))

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll m, d; cin>>m>>d;
	ll ans=0;
	for(int i=1; i<=m; i++){
		for(int j=1; j<=d; j++){
			 if (i==(j%10)*(j/10) && (j/10)>=2 && (j%10)>=2){
			 	ans++;
			 }
		}
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    if (s[0] != 'A') {
        cout << "WA" << endl;
        return;
    }
    int cnt = 0;
    if (!(s[1] >= 'a' && s[1] <= 'z') || !(s[s.size()-1] >= 'a' && s[s.size()-1] <= 'z')) {
        cout << "WA" << endl;
        return;
    }
    REP(i,2,s.size()-1) {
        if (s[i] >= 'a' && s[i] <= 'z') continue;
        if (s[i] == 'C') ++cnt;
        else {
            cout << "WA" << endl;
            return;
        }
    }
    if (cnt == 1) cout << "AC" << endl;
    else cout << "WA" << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> p(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());

	int ans = accumulate(p.begin(), p.begin() + k, 0);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	vector<int> dam(n,0);
	for(int &i:dam){
		scanf("%d",&i);
	}
	vector<int> mou(n,0);
	long long int sum=0ll;
	for(int i:dam){
		sum+=(i+0ll);
	}
	sum/=2;
	for(int i=n-1;i>=0;i-=2){
		sum-=(dam[i-1]);
	}
	mou[0]=(int)(sum);
	for(int i=1;i<n;i++){
		mou[i]=dam[i-1]-mou[i-1];
	}
	for(int i:mou){
		printf("%d ",i*2);
	}
	printf("\n");
	return 0;
}

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

int main(){
    int n;cin>>n;
    int d;
    int ans=0;

    for(int i=1;i<=n;i+=2){
        d=0;
        for(int j=1;j<=i;j++){
            if(i%j==0){
                d++;
            }
        }
        if(d==8){
            ans++;
        }
    }

    cout<<ans<<endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/05  Problem: 079_arc_b / Link: https://arc079.contest.atcoder.jp/tasks/arc079_b?lang=en  ----- */
/* ------問題------

長さ N の非負整数列 ai に対し、数列の最大値が N−1 以下になるまで以下の操作を繰り返し行うことを考えます。
数列のうち最も大きい要素を求める、複数ある場合はどれか 1 つ選ぶ。この要素の値を N 減らす。これ以外の要素の値を 1 増やす。
なお、この操作を行い続けると、いつかは数列の最大値が N−1 以下になることが証明できます。
ここで、整数 K が与えられるので、この操作を行う回数がちょうど K 回になるような数列 ai を 1 つ求めてください。なお、この問題の入出力の制約下では、かならず 1 つは条件を満たすような数列が存在することが示せます。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N,K;

LL ans = 0LL;

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

	cin >> K;
	N = 50;
	VL a(50, 49);
	LL base = K/N;
	LL modulo = K%N;
	FOR(i, 0, N) {
		a[i] += base;
	}
	FOR(m, 0, modulo) {
		FOR(i, 0, N) {
			if (i == m) a[i]+=N;
			else a[i]--;
		}
	}

	cout << N << endl;
	FOR(i, 0, N) {
		cout << a[i] << " ";
	}cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define reps(i, s, n) for(int i = (s); i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, s, n) for(int i = (n) - 1; i >= (s); i--)
#define INF ~(1 << 31)
#define INFL ~(1LL << 63)

int main()
{
    string s;
    cin >> s;
    int l = s.size();
    if(s[l-1] == 's'){
        s += "es";
    }else{
        s += 's';
    }
    cout << s << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    vector<P> p(n);
    rep(i, n) {
        ll x, l;
        cin >> x >> l;
        p[i] = make_pair(x+l, x-l);
    }
    sort(all(p));

    ll ans = 0;
    ll t = -INF;
    rep(i, n) {
        if(t <= p[i].second) {
            ans++;
            t = p[i].first;
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
    int n;
    int sum = 100000, is;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        is = ((sum / 20) % 1000 == 0) ? sum / 20 : (sum/20+1000)/1000*1000;
        sum += is;
    }
    printf("%d\n", sum);
}



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

#define ll long long int
#define ull unsigned long long int
#define Max 1000005
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define pi acos(-1.0)
#define pb push_back
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define endl '\n'

#define sc(n) scanf("%d",&n)
#define scan(n) scanf("%lld",&n)
/*        speed up       */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() _fastio;int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define fi first
#define se second

struct HASH{
size_t operator()(const pair<int,int>&x)const{
return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
}
};


//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
template <typename T> T gcd(T a,T b){if(a < 0)return gcd(-a,b);if(b < 0)return gcd(a,-b);return (b == 0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a < 0)return lcm(-a,b);if(b < 0)return lcm(a,-b);return a*(b/gcd(a,b));}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;
typedef tuple<ll,ll,ll>tpl;
typedef unordered_map<pair<int,int>,int,HASH>u_map;

int main()
{
    // ll n,x,t;
    // cin>> n>> x>> t;
    // int d=n/x;
    // if(n%x!=0)d++;
    // cout<<d*t<<endl;
    // string s;
    // cin>> s;
    // int ss=0;
    // for(char c:s)ss+=(c-'0');
    // cout<<(ss%9==0?"Yes":"No")<<endl;
    int n;
    cin>> n;
    ll arr[n+10];load(arr,n);
    ll sum=0;
    ll mx=arr[0];
    for (int i = 1; i <n; ++i)
    {
    	mx=max(mx,arr[i]);
    	if(arr[i]<mx)sum+=(mx-arr[i]);
    }
    cout<<sum<<endl;

}
/*
    remember:
    ll vs int
    array size
    case for 1 2 3 
*/



Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int,int>
#define X first
#define Y second
#define PB push_back
#define SORT(a) sort(a.begin(), a.end())
#define CLR(a) memset(a, 0, sizeof(a))
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FOE(i,a,b) for (int i=(a);i<=(b);i++)
#define FOREACH(i,a) for (auto i = (a).begin(); i != (a).end(); i++)
#define TRA(i,a,b) for (int i = (a); i != -1; i = (b)[i])
#define INF (1 << 30)
#define EPS (1e-9)
#define REP(i,n) FOR(i,0,n)
#define LL long long
#define MOD 1000000007
#define N 2001010
int n, m;
int a[N] = {0};
int main(){
        ios::sync_with_stdio(false);
        cin >> n;
        FOR(i,0,n) cin >> a[i];
        LL ans = 0;
        for (int i = n - 1; i >= 0; i--){
                if (a[i] > i || a[i] < a[i + 1] - 1){
                        cout << "-1\n";
                        return 0;
                }
                if (a[i] > a[i + 1] - 1)
                        ans += a[i];
        }
        cout << ans << '\n';
        return 0;
}


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

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

Measured memory_bytes: 256
import numpy as np

num = input()
num = int(num)

str = input()
list_in = list(map(int, str.split()))

count_arr = [0]*num

for item in list_in:
    count_arr[item-1] += 1

sum = 0
for i in range(num):
    tmp = count_arr[i-1]
    tmp = (tmp * (tmp -1))//2
    sum += tmp

for item in list_in:
    tmp = count_arr[item-1]
    result = sum - (tmp - 1)
    print(result)


Measured memory_bytes: 35416
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	
	s := scanText()
	a := []string{"Sunny","Cloudy","Rainy"}

	if s == a[0] {
		fmt.Println(a[1])
	} else if s == a[1] {
		fmt.Println(a[2])
	} else {
		fmt.Println(a[0])
	}
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;

namespace ALDS1_3_B
{
    class HogeTask
    {
        public string name;
        public int duration;
        public HogeTask(string line)
        {
            name = line.Split(null)[0];
            duration = int.Parse(line.Split(null)[1]);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Queue<HogeTask> save = new Queue<HogeTask>();
            string str = Console.ReadLine();
            int n = int.Parse(str.Split(null)[0]);
            int q = int.Parse(str.Split(null)[1]);
            int time = 0;

            while(n-->0)
            {
                string input = Console.ReadLine();
                HogeTask ht = new HogeTask(input);
                save.Enqueue(ht);
            }

            while (save.Count > 0)
            {
                HogeTask work = save.Dequeue();
                if(work.duration<=q)
                {
                    time += work.duration;
                    Console.WriteLine("{0} {1}",work.name,time);
                }
                else
                {
                    work.duration -= q;
                    time += q;
                    save.Enqueue(work);
                }
            }
        }
    }
}


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

class Main{
	static int N;

	static int[] memo;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		N = sc.nextInt();

		memo = new int[N + 1];
		Arrays.fill(memo, -1);
		memo[0] = 0;

		System.out.println(dp(N));
		sc.close();
	}

	static int dp(int n){
		if(memo[n] == -1) {
			int min = Integer.MAX_VALUE;
			for(int i = 9; i <= n; i *= 9) {
				if(dp(n - i) < min)
					min = dp(n - i);
			}
			for(int i = 6; i <= n; i *= 6) {
				if(dp(n - i) < min)
					min = dp(n - i);
			}
			if(min == Integer.MAX_VALUE)
				min = dp(n - 1);
			memo[n] = min + 1;
		}
		return memo[n];
	}
}

Measured memory_bytes: 24260
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
using namespace std;

typedef long long ll;

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

void solve(){
}

int main(){
  int sum = 0;

  rep(i,4){
    int x;
    cin>>x;
    sum += x;
  }

  cout<<sum/60<<endl<<sum%60<<endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<pair<ll,ll>> v;
    int w,h;cin >> w >> h;
    for(int i=0;i<w;i++){
        ll p;cin >> p;
        v.push_back({p,0});
    }
    for(int i=0;i<h;i++){
        ll q;cin >> q;
        v.push_back({q,1});
    }
    sort(v.begin(),v.end());
    ll ans=0,r=h+1,c=w+1;
    for(int i=0;i<v.size();i++){
        if(!v[i].second){
            ans+=r*v[i].first;
            c--;
        }
        else{
            ans+=c*v[i].first;
            r--;
        }
    }
    cout << ans << endl;
}

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

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

    int n;
    cin >> n;
    int top = 0;
    int result = 0;
    for(int i = 0; i < n; i++){
        int val;
        cin >> val;
        if(val >= top){
            result ++;
            top = val;
        }
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  if( (S.at(2) == S.at(3)) && (S.at(4) == S.at(5)) ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int maxn = 2e5 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int turn = 1;
    while(true)
    {
        if(turn == 1)
        {
            c -= b;
            if(c <= 0) return cout << "Yes", 0;
        }
        else
        {
            a -= d;
            if(a <= 0) return cout << "No", 0;
        }
        turn = 1 - turn;
    }
}

Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    int cnt[26] = {};
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        cnt[s[i] - 'a']++;
//        cout << s[i] - 'a' << endl;
    }
    for(int i = 0; i < 26; i++){
        if(cnt[i] % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a=[list(map(int, list(input().split()))) for i in range(n)]

a = sorted(a, key=lambda x: x[1])

ans = 0

for i in range(n):
  ans += a[i][0]
  
  if ans > a[i][1]:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 55188
import java.util.Scanner;
public class Main {
		public static void main(String[] args){
			Scanner sc =new Scanner(System.in);
			int A = sc.nextInt();	
			int B = sc.nextInt();	
			int C = sc.nextInt();
	    		int D = sc.nextInt();
	    		if(A + B == C + D) {
	    			System.out.println("Balanced");
	    		}
	    		else if(A + B < C + D) {
	    			System.out.println("Right");
	    		}
	    		else {
	    			System.out.println("Left");
	    		}
		}
}

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

ll x = 1e9 + 7; 
const int INF = 1001001001;

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a), q(b), r(c);
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  rep(i,c) cin >> r[i];
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  vector<ll> d;
  rep(i,x) d.push_back(p[i]);
  rep(i,y) d.push_back(q[i]);
  rep(i,c) d.push_back(r[i]);
  ll ans = 0;
  sort(d.rbegin(), d.rend());
  rep(i,x+y) ans += d[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9796
#include <stdio.h>

#define MAX_NUM 1000000007

int main(void) {
	int number[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	scanf("%d", &K);
	printf("%d\n", number[K - 1]);
	return 0; 

}

Measured memory_bytes: 128
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	char a[100];
	for (int i = 0; i < 6; i++)cin >> a[i];
	if (a[0] == a[5] && a[1] == a[4] && a[2] == a[3])cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
module Main where

import Data.Functor

main :: IO ()
main = do
  { [x] <- getInts
  ; putInts [x^3]
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

Measured memory_bytes: 3624
#[allow(non_snake_case)]

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let A = iter.next().unwrap().parse::<isize>().unwrap();
    let B = iter.next().unwrap().parse::<isize>().unwrap();

    if A < B {
        println!("a < b");
    } else if A > B {
        println!("a > b");
    } else {
        println!("a == b");
    }
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

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

    int ans = 700;
    string s;

    cin >> s;

    if (s[0] == 'o') ans += 100;
    if (s[1] == 'o') ans += 100;
    if (s[2] == 'o') ans += 100;

    Out(ans);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

const int d[4][2] = {{0, 1},{0, -1}, {-1, 0}, {1, 0}};
char G[100][100];
int h, w;
inline int ok(int x, int y){return x >= 0 && x < h && y >= 0 && y < w;}
int f(){
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++) if(G[i][j] == '#'){
			int flag = 0;
			for(int k = 0; k < 4; k++){
				int tx = i + d[k][0], ty = j + d[k][1];
				if(ok(tx, ty) && G[tx][ty] == '#'){
					flag = 1;
					break;
				}
			}
			if(!flag) return 0;
		}
	}
	return 1;
}
int main(int argc, char const *argv[])
{
	//freopen("in.txt", "r", stdin);
	scanf("%d%d", &h, &w);
	for(int i = 0; i < h; i++){
		scanf("%s", G[i]);
		// printf("%s\n", G[i]);
	}
	if(f()) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define REP1(i, N) for (int i = 1; i < N; i++)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ANS(a) cout << a << endl
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())
#define DBG(V) for (auto v : V) cout << v << " "; cout << endl

int N, K;
vector<int> P;

int
main()
{
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    P.push_back(p);
  }

  sort(P.begin(), P.end());

  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += P[i];
  }

  cout << ans << endl;

  return 0;
}

/*
4, 1, 10, 2, 16, 3, 22, 

8, f(8), f(f(8)), 
8, 4, 2, 1, 4, 2, 1, 4, 2, 1, 
7, f(7), f(f(7)), 
7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1
*/


Measured memory_bytes: 3604
n = list(input())

if n[0]=='1':
    n[0]='9'
elif n[0]=='9':
    n[0]='1'
    
    
if n[1]=='1':
    n[1]='9'
elif n[1]=='9':
    n[1]='1'

if n[2]=='1':
    n[2]='9'
elif n[2]=='9':
    n[2]='1'
    
print(n[0]+n[1]+n[2])

Measured memory_bytes: 3064
w,h,n=map(int,input().split())
a,b,c,d=0,0,w,h
for i in range(n):
 x,y,A=map(int,input().split())
 if A==1:a=max(x,a)
 if A==2:c=min(x,c)
 if A==3:b=max(y,b)
 if A==4:d=min(y,d)
print(max(0,c-a)*max(0,d-b))

Measured memory_bytes: 9140
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll ans[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    ll K ; cin >> K;
    cout << ans[K-1] << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

#define int long long

using namespace std;

signed main() {
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    char a[n][m];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    int dp[n][m];
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(i == 0 && j == 0) continue;

            bool up = false, left = false;
            if(j != 0 && a[i][j - 1] == '.'){
                left = true;
            }
            if(i != 0 && a[i - 1][j] == '.'){
                up = true;
            }
            int sum = 0;
            if(up) sum += dp[i - 1][j];
            if(left) sum += dp[i][j - 1];
            dp[i][j] = sum;
            dp[i][j] %= (long long) (1e9 + 7);
        }
    }
    cout << dp[n - 1][m - 1];
    return 0;
}

Measured memory_bytes: 12308
x = int(input())

for a in range(130):
    for b in range(130):
        if a**5 - b**5 == x:
            print(a,b) 
            exit()
for a in range(130):
    for b in range(130):
        if a**5 + b**5 == x:
            print(a,-b)
            exit()

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    Vec v(n+1);
    ll a;
    rep(i,n){
        cin>>a;
        v[a]=i;
    }
    REP(i,1,n+1){
            cout<<v[i]+1<<" ";

    }
    return  0;
}


Measured memory_bytes: 1664
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    auto n = lread();
    long cnt;
    foreach (i; 1 .. n + 1)
    {
        string s;
        s = i.to!string();

        if (s.length % 2 != 0)
        {
            cnt += 1;
        }
    }
    writeln(cnt);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 4424
#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,ll> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
    int N,M;cin>>N>>M;
    // vector<vector<P>> g(N,vector<P>());
    vector<ll> dist(N,INF);
    vector<int> a(M,0),b(M,0);
    vector<ll> c(M,0);
    rep(i,M) {
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;b[i]--;
        c[i] = -c[i];
        // g[a].push_back(P(b,-c));
    }
    dist[0] = 0;
    rep(i,N) {
        rep(j,M) {
            if(dist[b[j]] > dist[a[j]] + c[j]) {
                if(i==N-1 && b[j]==N-1) {
                    cout<<"inf"<<endl;
                    return 0;
                }
                dist[b[j]] = dist[a[j]] + c[j];
            }
        }
    }
    cout<<-dist[N-1]<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    ll h,w;
    ll ans=1000100010001000;
    cin>>h>>w;
    ll mx,mn1,mn2;
    if((h*w)%3==0){
        cout<<0<<endl;return 0;
    }
    else{    
        ans=min(ans,(h/3+1)*w-h/3*w);
        ans=min(ans,(w/3+1)*h-w/3*h);
        FOR(i,1,h){
            mx=i*w;
            if(w%2==0)mn1=mn2=(h-i)*(w/2);
            else{
                mn2=(h-i)*(w/2+1);
                mn1=(h-i)*(w/2);
            }
            mn1=min(mx,mn1);
            mx=max(mx,mn2);
            ans=min(ans,abs(mx-mn1));
        }
        FOR(i,1,w){
            mx=i*h;
            if(h%2==0)mn1=mn2=(w-i)*(h/2);
            else{
                mn2=(w-i)*(h/2+1);
                mn1=(w-i)*(h/2);
            }
            mn1=min(mx,mn1);
            mx=max(mx,mn2);
            ans=min(ans,abs(mx-mn1));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative

type Data = (Int, Int, Int, Int)

type Floor = [Int]

type Building = [Floor]

type Problem = [Data]

type Result = [Building]

calcValue :: Problem -> Int -> Int -> Int -> Int

calcValue xs b f r
    = sum [vx | (bx, fx, rx, vx) <- xs, bx == b, fx == f, rx == r]

solve :: Problem -> Result

solve xs
    = [[[calcValue xs b f r | r <- [1..10]] | f <- [1..3]] | b <- [1..4]]

input :: IO Problem

input
    = do
        n <- read <$> getLine
        xs <- inputData n []
        return xs
        
inputData :: Int -> Problem -> IO Problem

inputData 0 xs
    = return xs
    
inputData n xs
    = do
        [b, f, r, v] <- map read.words <$> getLine
        inputData (n - 1) $ (b, f, r, v) : xs
    
output :: Result -> String

output xs
    = concat.init.concat $ separated where
        separated = [[building, separate] | building <- buildings]
        separate = replicate 20 '#' ++ "\n"
        buildings = [outputBuilding b | b <- xs]

outputBuilding :: Building -> String

outputBuilding b
    = concat [concat [" " ++ show r | r <- f] ++ "\n" | f <- b]
    
main :: IO ()

main = putStr.output =<< solve <$> input

Measured memory_bytes: 4148
#include <bits/stdc++.h>
#define op_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fo(i,a,b) for(int i=a; i <b; i++)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<int,int> mpii;
typedef map<ll,ll> mpll;
typedef map<int,ll> mpil;
typedef map<ll,int> mpli;

int solve(int a, int b, int c, int k){
  int res = 0;
  int a_count = min(a, k);
  res += a_count;
  k -= a_count;
  int b_count = min(b, k);
  k -= b_count;
  int c_count = min(c, k);
  res -= c_count;
  return res;
}

int main(){
  op_io;
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  cout<<solve(a,b,c,k)<<endl;
  return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 ans = 0;
  i32 max = 0;
  while (n--) {
    i32 h;
    scanf ("%" SCNi32, &h);
    if (max <= h) {
      ans++;
      max = h;
    }
  }
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run ();
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,res,a[105];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		if(i%2==1&&a[i]%2==1)
			res++;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;


int main() {

	ll N;

	cin >> N;

	vector<ll> oX(N), X(N);

	rep(i, N) {
		cin >> oX[i];
		X[i] = oX[i];
	}

	sort(X.begin(), X.end());

	ll c, M, L, H;

	c = (N + 1) / 2;


	if (N == 2) {
		cout << oX[1] << endl;
		cout << oX[0] << endl;
	}
	else {
		M = X[c - 1];
		L = X[c - 2];
		H = X[c];

		rep(i, N) {

			if (N % 2 == 0) {
				if (M >= oX[i]) {
					cout << H << endl;
				}
				else {
					cout << M << endl;
				}
			}
			else {
				if (M <= oX[i]) {
					cout << L << endl;
				}
				else {
					cout << M << endl;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 6320
from collections import deque
N,M = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
col = [-1 for _ in range(N+1)]
cnt = 0
for i in range(1,N+1):
    if col[i]<0:
        col[i] = cnt
        que = deque([i])
        while que:
            x = que.popleft()
            for y in G[x]:
                if col[y]<0:
                    col[y]=cnt
                    que.append(y)
        cnt += 1
cmax = max(col)
print(cmax)

Measured memory_bytes: 88920
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

Measured memory_bytes: 6788
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  cout << (n+m-1)/m << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
std::vector<int>g[100005];
std::vector<int>child[100005];
int in[100005];
int vis[100005];
int queue[100005];
int parent[100005];

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i = 0; i < n-1+m; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        g[v].push_back(u);
        in[u]++;
    }
    int h = 0, t = -1;
    for(int i = 1; i <= n; i++){
        if(in[i]==0) queue[++t] = i;
    }
    while(h<=t){
        int u = queue[h++];
        for(int i = 0; i < (int)child[u].size(); i++){
            int v = child[u][i];
            if(!vis[v]){
                vis[v] = 1;
                parent[v] = u;
            }
        }
        for(int i = 0; i < (int)g[u].size(); i++){
            int v = g[u][i];
            in[v]--;
            child[v].push_back(u);
            if(in[v]==0) queue[++t] = v;
        }
    }
    for(int i = 1; i <= n; i++) printf("%d\n",parent[i]);
    return 0;
}


Measured memory_bytes: 15756
#!/usr/bin/env python3
from collections import*
(n,), a, q, *d = [list(map(int, o.split())) for o in open(0)]
C = Counter(a)
s = sum(a)
for b, c in d:
    bf = C[b]
    C[c] += bf
    C[b] = 0
    s += (c - b) * bf
    print(s)

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long n, m;
	cin >> n;
	m = n - 1;
	for(long long i = 2; i <= sqrt(n); ++i){
		if(!(n % i)) m = min(m, i + n / i - 2);
	}
	cout << m;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? ((x) : -(x)))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
char str[105];
vector<int> vec;

int main()
{
	int i, j;
	scanf("%s%d", str, &M);
	N = 0;
	while (str[N] != 0) ++N;
	int cnt = 1;
	for (i = 0; i <= N - 1; ++i) {
		if (i == N - 1 || str[i] != str[i + 1]) {
			vec.push_back(cnt);
			cnt = 1;
		}
		else ++cnt;
	}
	if (str[0] == str[N - 1]) {
		if (vec.size() == 1) printf("%lld", ((ll)vec[0] * (ll)M) /2ll );
		else {
			ll ans = vec[0]/2 + vec.back()/2;
			ll len = ((vec[0] + vec.back())/2)*(ll)(M - 1);
			for (i = 1; i <= vec.size() - 2; ++i) {
				len = len + (ll)(M)*((ll)vec[i] / 2ll);
			}
			printf("%lld", ans + len);
		}
	}
	else {
		ll ans = 0ll;
		for (i = 0; i < vec.size(); ++i) {
			ans = ans + (ll)(vec[i] / 2);
		}
		printf("%lld", M*ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string reverse(string s) {
    for(int i = 0, j = s.size() - 1; i < j; i ++, j --)swap(s[i], s[j]);
    return s;
}
string s;
int main() {
    cin >> s;
    int n = s.size();
    if(s != reverse(s)) {
        cout << "No\n";
        return 0;
    }
    string t = s.substr(0, (n - 1) / 2);
    if(t != reverse(t)) {
        cout << "No\n";
        return 0;
    }
    string u = s.substr((n + 3) / 2 - 1, n - (n + 3) / 2 + 1);
    if(u != reverse(u)) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let mut v = vec![Vec::new(); 4];
    for _ in 0..3 {
        let (mut a, mut b) = get!(usize, usize);
        a -= 1;
        b -= 1;
        v[a].push(b);
        v[b].push(a);
    }
    //eprintln!("{:?}", v);
    let mut flag = false;
    for i in 0..4 {
        if 3 <= v[i].len() {
            flag = true;
            break;
        }
    }
    if flag {
        println!("NO");
    } else {
        println!("YES");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<fixed<<setprecision(12)<<w*h/2<<" "<<(w==x*2&&h==y*2?1:0)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
string s;

int solve() {
    int res = inf;
    int w[2] = {0, 0}, e[2] = {0, 0};
    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') e[1]++;
        else w[1]++;
    }

    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') {
            e[1]--;
        } else {
            w[1]--;
        }
        res = min(res, w[0] + e[1]);
        if (s[i] == 'E') e[0]++;
        else w[0]++;
    }
    
    return res;
}

void input() {
    cin >> n >> s;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 720
n = int(input())
a = [list(map(int, input().split())) for i in range(2)]

l = [0 for i in range(n)]
r = [0 for i in range(n)]
l[0], r[-1] = a[0][0], a[1][-1]
for i in range(1, n):
  l[i] = l[i-1] + a[0][i]
  r[-(i+1)] = r[-i] + a[1][-(i+1)]

ans = 0
for i in range(n):
  ans = max(ans, l[i]+r[i])
print(ans)


Measured memory_bytes: 3064