akhauriyash/Code-Regression huggingface dataset:
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
using namespace std;
 
int N;
int A[20];
int x[20][20];
int y[20][20];
 
int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}
 
void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
/*実装上は,0<=j<2^Nについて「1 以上 N 以下の整数 k について, 人 k が正直者であることと,
j を 2 進数表記した際に k − 1 桁目が 1 であることが同値」という状態を表すことと定義すると, 容
易に全ての場合を試すことが出来ます.*/
    //a = a << 2 はaを2bit左シフトする
    //a = a >> 2 はaを2bit右シフトする
    int ans = 0;//正直者の数の最大値
    for(int bits = 1; bits < (1 << N); bits++) {
        //bitsが上の説明でのjに相当
        bool ok = true;//矛盾なしを表す
        //i番目の人間がなんと言っているかに注目する
        for(int i = 1; i <= N; i++) {//N人いるのでN回繰り返す
            if(!(bits & (1 << (i-1)))){
                continue;
                //1をi-1回左シフトしたものと、bitsの論理積が0なら
                //つまりは2進数表示でbitのi桁目が0であれば
                //＝i番目の人が不親切であれば
                //この先の処理をスキップして次のループへ
            }
            //i番目の人が正直者とされていればこの先の処理をする
            for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]){
                    //(bits >> (x[i][j]-1)) & 1
                    //でbitsのx[i][j]桁目、つまりx[i][j]番目の人が正直かどうか表す
                    //x[i][j]番目の人が正直ならy[i][j]=1、不親切なら0
                    //if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j])は
                    //if(((bits >> (x[i][j]-1)) & 1)==y[i][j])と同値
                    //x[i][j]番目の人が正直と仮定されていて、かつi番目の人間がx[i][j]番目の人間を正直だと言っている
                    //もしくは
                    //x[i][j]番目の人が不親切と仮定されていて、かつi番目の人間がx[i][j]番目の人間を不親切だと言っている
                    //なら矛盾はなくなるので、その時はこのifの中は実行しない
                    //このif文が実行される(＝仮定が間違っている)のは以下のようなとき
                    //x[i][j]番目の人が正直と仮定されていて、かつi番目の人間がx[i][j]番目の人間を不親切だと言っている
                    //x[i][j]番目の人が不親切と仮定されていて、かつi番目の人間がx[i][j]番目の人間を正直だと言っている
                    ok = false;//矛盾あり
                }
            }
        }
        //counter(x)でxをビット列で表した時の1が立っている数を表せる
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int N, ans = 0;
    scanf("%d", &N);

    int A[N];
    for (int i = 0; i < N; i++) {
        if (ans < 1) { scanf("%d", &A[i]); }
        if (A[i] % 2 == 0) {
            A[i] = A[i] / 2;
        } else {
            break;
        }
        if (i == N-1) {
            ans++;
            i = 0;
        }
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 128
s = input()

odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

c = 0

for i in range(len(s)):
    if (i+1) % 2 == 1:
        if s[i] in odd:
            c += 1
    else:
        if s[i] in even:
            c += 1

            
    
if len(s) == c:
    print('Yes')

else:
    print('No')
    

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h,n;
	cin >> h >> n;
	vector <int> A(n);
	vector <int> B(n);
	for(int i=0;i<n;i++) cin >> A[i] >> B[i];
	int dp[n][10001]= {0};
	for(int i=0;i<n;i++){
		for(int j=1;j<=h;j++){
			int b = B[i];
			if(j-A[i]>=0) b = B[i] + dp[i][j-A[i]];
			if(i>=1) dp[i][j] = min(dp[i-1][j],b);
			else dp[i][j] = b;
			// cout << dp[i][j] << " ";
		}
		// cout << endl;
	}
	cout << dp[n-1][h];
	return 0;
}


Measured memory_bytes: 39296
fun main(args: Array<String>) = p2_abc106b()

fun p2_abc106b() {
    val n = readLine()!!.toInt()

    var answer = 0

    for (i in 1..n) {
        if (i % 2 == 0) continue

        val divCount = (1..n).count { i % it == 0 }
        if (divCount == 8) answer++
    }

    println(answer)
}



Measured memory_bytes: 33656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define fi first
#define se second
//#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
typedef pair<int,int> P;
#define REP(i,x,y) for(int i=x;i<=y;i++)
#define abs(x) ((x)>0?(x):-(x))
#define y1 hhf
#define mp make_pair
const int mod=1e9+7;
const int maxn = 200005;
int n,t;
int a[maxn];
int main(){
	cin>>n>>t;
	for(int i=0;i<n;i++) cin>>a[i];
//	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n;i++){
		if(i&&a[i-1]+t>a[i])
		 	ans -= a[i-1]+t-a[i];
		ans += t;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
struct node{
	int id;
	int nu;
}b[maxn];
int n;
int a[maxn];
int main()
{
	int i,j;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		sort(a,a+n);
		i=n-1;
		int cnt=0;
		int num=0;
		while(i>=0)
		{
			num++;
			for(j=i;j>=0;j--)
			{
				if(a[j]!=a[i])
					break;
				else cnt++;
			}
			b[num].id=a[i];
			b[num].nu=cnt;
			cnt=0;
			i=j;
		}
		int c[2];
		int s=0;
		c[0]=-1;
		c[1]=-1;
	     for(i=1;i<=num;i++)
		{	
			 if(b[i].nu>=4)
			{
				c[s]=b[i].id;
				s++;
				if(s>=2) break;
				c[s]=b[i].id;
				break;
			}
			if(b[i].nu>=2)
			{
			   c[s]=b[i].id;
			   	s++;
			}
			if(s>=2) break;
		}
		if(c[0]==-1||c[1]==-1) 
		printf("0\n");
		else printf("%lld\n",1ll*c[0]*c[1]);
	}
}



Measured memory_bytes: 1408
#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
const int N=1e5+10;
int f[N];
vector<int> graph[N];
int max(int a,int b){return a>b?a:b;}
int dp(int n){
  if(f[n]>=0)return f[n];
  for(int i:graph[n])f[n]=max(f[n],dp(i)+1);
  return f[n]=max(f[n],0);
}
int main(){
  int n,m,l,r,ans=0;
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++)f[i]=-1;
  while(m--){
  	scanf("%d%d",&l,&r);
    graph[l].PB(r);
  }
  for(int i=1;i<=n;i++)ans=max(ans,dp(i));
  printf("%d\n",ans);
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
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;
}
int main(){
    ll n;cin >> n;
    vvl v(9,vl(9,0));
    ll i=1;
    while(i<=n){
        ll p=i;
        ll x=log10(p);
        ll b=p%10;
        ll c=1;
        rep(i,x)c*=10;
        ll a=p/c;
        a--;b--;
        if(b!=-1)v[a][b]++;
        i++;
    }
    ll ans=0;
    rep(i,9){
        rep(j,9){
            ans+=v[i][j]*v[j][i];
        }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 512
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 200005
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<pair<ll,ll> >adj[MAX+10];
ll dp[MAX+10];
int main()
{
    fast;
    cin>>n>>k;
    FOR(i,n)
    {
        cin>>a;
        v.p_b(a);
    }
    sort(v.begin(),v.end());
    memset(dp,-1,sizeof dp);
    dp[0]=0;
    FOR1(i,k)
    {
        bool flag=0;
        ll x=1;
        FOR(j,n)
        {
            ll prev=i-v[j];
            if(prev<0) continue;
            x=x&dp[prev];
            ///if(x==0) break;
        }
        if(i<v[0]) dp[i]=0;
        if(x==1) dp[i]=0;
        else dp[i]=1;

    }
    if(dp[k]==1) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 6528
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  ulong N = readln.chomp.to!ulong;
  ulong[] A = readln.chomp.split.to!(ulong[]);
  ulong ans;

  foreach (a; A) {
    while (a % 2 == 0) {
      a /= 2;
      ans++;
    }
  }

  writeln(ans);
}


Measured memory_bytes: 2556
package main

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

var sc = bufio.NewScanner(os.Stdin)
var ans int = 0

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func scanStrings(n int) []string {
	sl := make([]string, n)
	for i := range sl {
		sl[i] = scanString()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func check(now []bool, next_idx int, N int, data map[int][]int, correct []bool) {
	// if index N is on
	now_on := make([]bool, len(now))
	now_off := make([]bool, len(now))
	copy(now_on, now)
	copy(now_off, now)

	if _, ok := data[next_idx]; ok {
		for _, i := range data[next_idx] {
			now_on[i-1] = !now_on[i-1]
		}
	}
	ok := true
	for i := range now_on {
		if correct[i] != now_on[i] {
			ok = false
			break
		}
	}
	if ok == true {
		ans++
	}

	if next_idx == 1 {
		ok := true
		for i := range now_off {
			if correct[i] != now_off[i] {
				ok = false
				break
			}
		}
		if ok == true {
			ans++
		}
	}

	//fmt.Printf("%v => %v %v\n", now, now_on, now_off)
	if next_idx != N {
		// if index N is off
		check(now_off, next_idx+1, N, data, correct)
		check(now_on, next_idx+1, N, data, correct)
	}
}

func main() {
	N, M := scanInt(), scanInt()
	data := map[int][]int{}
	for i := 0; i < M; i++ {
		k := scanInt()
		for j := 0; j < k; j++ {
			s := scanInt()
			if _, ok := data[s]; ok {
				data[s] = append(data[s], i+1)
			} else {
				data[s] = []int{i + 1}
			}
		}
	}
	//fmt.Printf("%v\n", data)
	correct := make([]bool, M)
	for i := 0; i < M; i++ {
		if scanInt() == 0 {
			correct[i] = false
		} else {
			correct[i] = true
		}
	}
	state := make([]bool, M)
	//fmt.Printf("init: %v\n", state)
	check(state, 1, N, data, correct)
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using ll = long long;

int main()
{
    double a,b,h,m;
    cin >> a >> b >> h >> m;

    double d=(h*60.0-11.0*m)/2.0;
    d = min(d,360.0-d);
    d = 2*M_PI * d / 360.0;

    double ans=sqrt( a*a+b*b - 2.0*a*b*cos(d) );
    cout << fixed << setprecision(15) << ans << endl;

    return 0;
}

Measured memory_bytes: 4128
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
k.times do
  b = Array.new(n, 0)
  for i in 0...n do
    l = [i - a[i], 0].max
    r = [i + a[i], n - 1].min
    b[l] += 1
    b[r + 1] -= 1 if r + 1 < n
  end
  sum = b[0]
  for i in 0...(n - 1) do
    b[i + 1] += b[i]
    sum += b[i + 1]
  end
  a = b
  break if sum == n * n
end
puts a.join(" ")


Measured memory_bytes: 80708
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(1,n):
  if a[i]<a[i-1]:
    cnt+=a[i-1]-a[i]
    a[i]=a[i-1]
    cnt+=a[i-1]-a[i]
print(cnt)

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

using namespace std;
using ll = long long;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  stringstream ss(s);
  string item;
  while (getline(ss, item, delim)) {
    if (!item.empty()) {
      elems.push_back(item);
    }
  }
  return elems;
}

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

  string s;
  cin >> s;

  int n = s.size();

  ll ans = 0;

  function<void(int, string)> dfs = [&](int i, string t) {
    if (i == n) {
      auto sp = split(t, '+');
      for (auto x : sp) {
        ans += stoll(x);
      }
      return;
    }

    dfs(i + 1, t + s[i]);
    if (i > 0)
      dfs(i + 1, t + '+' + s[i]);
  };

  dfs(0, "");

  cout << ans << endl;

  return 0;
}


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

const int N = 100010;
int n;

vector<pair<int, int>> G[N];
int ans[N];

void dfs(int now, int back, int back_color){
    int cnt = 1;
    for(auto x : G[now]){

        // もし次の頂点と前見た頂点が同じだった抜ける
        if(x.first == back) continue;

        // 今の色と前塗った色が同じだったら色を変える（cntがKより大きくなることはない）
        if(cnt == back_color) cnt++;

        ans[x.second] = cnt;
        dfs(x.first, now, cnt);
        cnt++;
    }
}

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

    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back({b, i});
        G[b].push_back({a, i});
    }

    // 色の数は最大次数
    int K = 0;
    for(int i = 0; i < n; i++){
        K = max(K, int(G[i].size()));
    }

    dfs(0, -1, 0);

    cout << K << endl;
    for(int i = 0; i < n - 1; i++){
        cout << ans[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 9344
from itertools import combinations
n=int(input())
v=list(map(int, input().split()))
c=list(map(int, input().split()))
v_c=[v[i]-c[i] for i in range(n)]

x_y=0
for i in range(n):
	if v_c[i]>=0:
		x_y+=v_c[i]

print(x_y)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n=0;
    scanf("%d",&n);
    int h[n];
    for(int i=0;i<n;i++)scanf("%d",&h[i]);
    int c=0;
    int ch=0;
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1]){
            c++;
        }else{
            if(ch<c){
                ch=c;
            }
            c=0;
        }
    }
    if(ch<c){
        ch=c;
    }
    printf("%d",ch);
    return 0;
}

Measured memory_bytes: 640
import sys 

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_C = sum(A)

if sum_C < sum(B):
    print(-1)
    sys.exit()

lack_sum = 0
surplus_sum = []
count = 0

for i in range(N):
    if B[i] > A[i]:
        lack_sum = lack_sum + (B[i] - A[i])
        count = count + 1
    elif B[i] <= A[i]:
        surplus_sum.append(A[i]-B[i])

surplus_sum = sorted(surplus_sum,reverse=True)

if len(surplus_sum) == N:
    print(0)
    sys.exit()


for j in surplus_sum:
    lack_sum = lack_sum - j
    count = count + 1

    if lack_sum <= 0:
        print(count)
        sys.exit()

    

         



Measured memory_bytes: 24044
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
  ll n,a,b,sum=0;
  cin>>n>>a>>b;
  for(int i=1;i<=n;i++)
  {
    ll ds=0,d=i;
    while(d>0)
    {
      ds+=(d%10);
      d/=10;

    }
    if(ds>=a&&ds<=b)
      sum+=i;


  }
  cout<<sum<<endl;
    
}
return 0;
}

Measured memory_bytes: 256
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

lld fac[200001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=200000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


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

//vector< vector <lld > > v(100001);
lld p1=1000000007,p2=998244353;
lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,n1,a,b,n2,h,z,c;
queue<lld> q;
lld d,p=1000000000;

void solve()
{
    cin>>n>>m;
    if(n>=10) 
    {
        cout<<"-1";
    }   
    else if(m>=10)
    {
        cout<<"-1";
    }
    else cout<<n*m;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
    //getfac(p2);
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
            solve();
        cout<<"\n";
    }

    return 0;
}

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

use std::thread;
use std::io::{ self, Read };
use std::iter::Iterator;
use std::cmp::*;
use std::collections::*;
use std::str;

#[derive(Default)]
struct Input {
    buf: Vec<String>
}

impl Input {
    fn new() -> Input {
        Input { buf: Vec::new() }
    }

    fn next(&mut self) -> String {
        while self.buf.is_empty() {
            let mut s = String::new();
            let _res = io::stdin().read_line(&mut s);
            self.buf = s.split_whitespace().map(|s| s.to_owned()).collect::<Vec<_>>();
            self.buf.reverse();
        }
        self.buf.pop().unwrap()
    }

    fn next_int(&mut self) -> i64 {
        self.next().parse::<i64>().unwrap()
    }

    fn next_int_n(&mut self, n: usize) -> Vec<i64> {
        let mut v = Vec::<i64>::new();
        for _ in 0..n { v.push(self.next_int()); }
        v
    }
}

fn run() {
    let mut input = Input::new();
    let n = input.next_int();
    let a = input.next_int_n(n as usize);
    let mut e = 1;
    let mut y = 1;
    for x in a {
        y *= 3;
        e *= if x % 2 == 0 { 2 } else { 1 };
    }
    println!("{}", y - e);
}

fn main() {
    let _ = thread::Builder::new()
        .stack_size(10 * 1024 * 1024)
        .spawn(run).unwrap()
        .join();
}

Measured memory_bytes: 8572
n = int(input())
h = list(map(int, input().split()))
ans = 0
for i in range(100):
	on_the_island = False
	for j in range(n):
		if h[j] != 0:
			h[j] -= 1
			on_the_island = True
		else:
			if on_the_island:
				ans += 1
			on_the_island = False
	if on_the_island:
		ans += 1
print(ans)

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

int main()
{
    std::string s;
    int q;

    std::cin >> s;
    std::cin >> q;

    std::vector<int> rotations_count(q+1, 0);
    std::vector<char> front_char(q+1, ' ');
    std::vector<char> back_char(q+1, ' ');
    for (int i = 0; i < q; ++i) {
        int t;
        std::cin >> t;
        if (t == 1) rotations_count[i+1] = rotations_count[i] + 1;
        if (t == 2) {
            int f;
            char c;
            std::cin >> f;
            std::cin >> c;
            if (f == 1) front_char[i+1] = c;
            if (f == 2) back_char[i+1] = c;
            rotations_count[i+1] = rotations_count[i];
        }
    }

    int left_index = 0;
    int right_index = q-1;
    std::string final_string(q, ' ');
    bool opposite = false;
    for (int i = q; i > 0; --i) {
        if (rotations_count[i] != rotations_count[i-1]) opposite = !opposite;

        if (front_char[i] != ' ') {
            if (opposite) final_string[right_index--] = front_char[i];
            else final_string[left_index++] = front_char[i];
        } else if (back_char[i] != ' ') {
            if (opposite) final_string[left_index++] = back_char[i];
            else final_string[right_index--] = back_char[i];
        }
    }
    for (int i = 0; i < left_index; ++i) std::cout << final_string[i];
    opposite = rotations_count[q] % 2 == 1;
    int s_length = s.size();
    if (opposite) { for (int i = s_length-1; i >= 0; --i) std::cout << s[i]; }
    else { for (int i = 0; i < s_length; ++i) std::cout << s[i]; }
    for (int i = right_index+1; i < q; ++i) std::cout << final_string[i];
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<iomanip>
#define INF INT_MAX
using namespace std;

int N;
int L[12];
int ans;

int main(){
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> L[i];
		ans += L[i];
	}
	sort(L, L + N);
	
	ans -= L[N-1];
	
	if (L[N-1] < ans){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    for i in range(1, 50001):
        if int(i * 1.08) == n:
            print(i)
            exit()
    print(":(")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39408
count = int(input())
l = []

for i in range(count):
    l.append(int(input()))

maxv = l[-1]- l[0]
minv = l[0]

for i in range(1, len(l)):
    maxv = max(maxv, l[i] - minv)
    minv = min(minv, l[i])

print(maxv)


Measured memory_bytes: 13588
/* Dynamic Programming implementation of LCS problem */
#include<iostream>
#include<bits/stdc++.h>
#include<cstring>
#include<cstdlib>
using namespace std;

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */

char lc[3005];
void lcs( char *X, char *Y, int m, int n )
{
int L[m+1][n+1];

/* Following steps build L[m+1][n+1] in bottom up fashion. Note
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
for (int i=0; i<=m; i++)
{
	for (int j=0; j<=n; j++)
	{
	if (i == 0 || j == 0)
		L[i][j] = 0;
	else if (X[i-1] == Y[j-1])
		L[i][j] = L[i-1][j-1] + 1;
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]);
	}
}

// Following code is used to print LCS
int index = L[m][n];

// Create a character array to store the lcs string

 // Set the terminating character

// Start from the right-most-bottom-most corner and
// one by one store characters in lcs[]
int i = m, j = n;
while (i > 0 && j > 0)
{
	// If current character in X[] and Y are same, then
	// current character is part of LCS
	if (X[i-1] == Y[j-1])
	{
		lc[index-1] = X[i-1]; // Put current character in result
		i--; j--; index--;	 // reduce values of i, j and index
	}

	// If not same, then find the larger of two and
	// go in the direction of larger value
	else if (L[i-1][j] > L[i][j-1])
		i--;
	else
		j--;
}

// Print the lcs
cout << lc<<endl;
}

/* Driver program to test above function */
int main()
{
char X[3005],Y[3005];
scanf("%s %s",X,Y);
int m = strlen(X);
int n = strlen(Y);
lcs(X, Y, m, n);
return 0;
}


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

int main() {
    int a;
    string s;
    cin >> a >> s;

    if (3200 <= a) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B; 
  int S = 0;
  for (int i = 0; i < B - A + 1; i++) {
    int a, b, c, d;
    a = ( A + i ) / 10000;
    b = ( A + i ) / 1000 % 10;
    c = ( A + i ) / 10 % 10;
    d = ( A + i ) % 10;
    if ( a == d && b == c) {S++;}
  }
  cout << S << endl;
}

Measured memory_bytes: 3520
H, W, M = map(int, input().split())
#H, W, M = 300000, 300000, 300000
HL = [0 for _ in range(H)]
WL = [0 for _ in range(W)]
X = [list(map(int, input().split())) for i in range(M)]
#X = [[1, i+1] for i in range(M)]
for i in X:
  HL[i[0]-1] += 1
  WL[i[1]-1] += 1
HM, WM = max(HL), max(WL)
HF = [False for _ in range(H)]
WF = [False for _ in range(W)]
for i in range(H):
  if HL[i] == HM:
    HF[i] = True
for i in range(W):
  if WL[i] == WM:
    WF[i] = True
cnt = 0
for i in range(M):
  if HF[X[i][0]-1] * WF[X[i][1]-1]:
    cnt += 1
print(HM+WM-((sum(HF)*sum(WF))==cnt))

Measured memory_bytes: 73172
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int c1 = (N + K / 2) / K;
    int c2 = N / K;
    if(K % 2 == 0) {
        cout << c1 * c1 * c1 + c2 * c2 * c2 << endl;
    } else {
        cout << c2 * c2 * c2 << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
def main():
    N, W = map(int, input().split())
    value = []
    weight = []
    for i in range(N):
        a, b = map(int, input().split())
        value.append(a)
        weight.append(b)
    dp = [[-float("inf") for i in range(W+1)] for j in range(N+1)]
    for w in range(W+1):
        dp[0][w] = 0

    for i in range(N):
        for w in range(W+1):
            if w >= weight[i]:
                dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    return dp[N][W]

if __name__ == '__main__':
    print(main())



Measured memory_bytes: 42476
#include<bits/stdc++.h>
using namespace std;
#define maxn 2500
#define maxm 5000
#define LL long long
#define inf 1e15
struct Edge{
	int next,to,w;
}edge[maxm+5],edge1[maxm+5];
int fi[maxn+5],se,n,fi1[maxn+5];
inline void add_edge(int u,int v,int w){
	edge[++se].next=fi[u],fi[u]=se,edge[se].to=v,edge[se].w=w;
	edge1[se].next=fi1[v],fi1[v]=se,edge1[se].to=u;
}
queue<int>q;
bool vis[maxn+5],vis1[maxn+5];int num[maxn+5];LL dis[maxn+5];
bool spfa(){
	q.push(1),vis[1]=1,num[1]=1;
	for(int i=2;i<=n;i++)dis[i]=inf;
	while(!q.empty()){
		int u=q.front();q.pop();vis[u]=0;
		for(int i=fi[u];i;i=edge[i].next){
			int v=edge[i].to;
			if(!vis1[v])continue;
			if(edge[i].w+dis[u]<dis[v]){
				dis[v]=edge[i].w+dis[u];
				if(!vis[v])vis[v]=1,q.push(v),num[v]++;
				if(num[v]>=n)return 0;
			}
		} 
	}
	return 1;
}
void dfs(int x){
	vis1[x]=1;
	for(int i=fi1[x];i;i=edge1[i].next){
		int v=edge1[i].to;
		if(vis1[v])continue;
		dfs(v);
	}
}
int main(){
	int m,p,u,v,w;scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<m;i++)scanf("%d%d%d",&u,&v,&w),add_edge(u,v,p-w);
	dfs(n);
	if(spfa())printf("%lld\n",max(0ll,-dis[n]));
	else puts("-1");
	return 0;
}

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

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


Measured memory_bytes: 3712
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    for (auto e: v) os << e << ",";
    os << "]";
    return os;
}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// print floating-point number
// cout << fixed << setprecision(12) <<

// }}}

ll H;
unordered_map<ll, ll> m;

ll rec(ll hp)
{
    if (hp <= 1) return 1;
    if (m.find(hp) != m.end()) return m[hp];
    return m[hp] = 1 + 2 * rec(hp/2);
}

void solve()
{
    cout << rec(H) << endl;
}

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

// vim:set foldmethod=marker:


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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var sum = vals.Sum();

        if (sum >= 22)
        {
            Console.WriteLine("bust");
        }
        else
        {
            Console.WriteLine("win");
        }
    }
}

Measured memory_bytes: 13396
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    a[0]--;
    for(int i=1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {
            cout<<"No";
            return 0;
        }
        if(a[i]>a[i-1])
            a[i]--;
    }
    cout<<"Yes";
}
//.........

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

int N, K, ans;
int par[100010], dp[100010];
vector<int> adj[100010];

void dfs(int u) {
    dp[u] = 0;
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        dfs(v);
        dp[u] = max(dp[u], 1 + dp[v]);
    }
    if(par[u] && dp[u] == K - 1) {
        ans++;
        dp[u] = -1;
    }
}

int main() {
    scanf("%d %d", &N, &K);

    for(int i = 0; i < N; i++) {
        scanf("%d", &par[i]);
        par[i]--;
    }

    ans = par[0] != 0;
    par[0] = 0;

    for(int i = 1; i < N; i++) {
        adj[ par[i] ].push_back(i);
    }

    dfs(0);
    cout << ans;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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


char c[6][6];

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << H); i++) {
        for (int j = 0; j < (1 << W); j++){
            int p = 0;
            for (int y = 0; y < H; y++) {
                for (int x = 0; x < W; x++) {
                    if (c[y][x] == '#' && (i >> y & 1) && (j >> x & 1)) {
                        p++;
                    }
                }
            }
            if( p == K ){
                ans++;
            }
        }
    }
    cout << ans << endl;
    // Failed to predict input format
    return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

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

    int h, w, d;
    cin >> h >> w >> d;
    vector<pair<int,int>> num(h * w);
    int a;
    FOR(i, 0, h)FOR(j, 0, w) {
        cin >> a;
        num[--a] = { i,j };
    }

    vector<ll> ans(h * w);
    FOR(i, 0, d) {
        ans[i] = 0;
        for (int j = i; j + d < h * w; j += d) {
            ans[j + d] = ans[j];
            ans[j + d] += abs(num[j].first - num[j + d].first);
            ans[j + d] += abs(num[j].second - num[j + d].second);
        }
    }

    int q;
    cin >> q;
    int l, r;
    FOR(i, 0, q) {
        cin >> l >> r;
        cout << ans[--r] - ans[--l] << "\n";
    }
}

Measured memory_bytes: 2560
l=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
s='#'*20
n=input()
for i in range(n):b,f,r,v=map(int,raw_input().split());l[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(-3,0):print ' '+' '.join(map(str,l[i][j]))
    if i<3:print s

Measured memory_bytes: 6456
from collections import deque

def solve(n):
    queue = deque()
    while n != 0:
        r = -(n % (-2))
        #n = n // (-2) if r == 0 else (n - i) // (-2)
        n = (n - 1) // (-2)
        queue.appendleft(str(r))
    return 0 if len(queue) == 0 else "".join(queue)

if __name__ == "__main__":
    n = int(input())
    print(solve(n))


Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int n,a;
	cin >> n;
	ll cnt[n];
	REP(i,n) cnt[i] = 0;
	REP(i,n-1){
		cin >> a;
		cnt[a-1]++;
	}

	REP(i,n){
		printf("%d ",cnt[i]);
	}
	return 0;
}


Measured memory_bytes: 5324
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    int N; cin >> N;
    vector<P> A(N);
    rep(i,N){
        int a; cin >> a;
        A[i] = P(a,i);
    }
    sort(A.begin(),A.end());
    rep(i,N) cout << A[i].second + 1 << " ";

    rn 0;
}


Measured memory_bytes: 1536
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }

const ll MAX_H = 400;
const ll MAX_W = 400;
ll blocks = 0;
ll H,W;
string S[MAX_H];
// ll v[MAX_N], w[MAX_N];
ll dp[MAX_H+1][MAX_W+1]; // メモ化テーブル

void rec(ll i, ll j){
	
	if (i==0 & j==0) dp[i][j] = 0;
	else if (dp[i][j]==-1){
		// printf("%lld %lld %lld \n", i,j,blocks);
		blocks++;
		dp[i][j] = blocks;
	}
	if (j<W-1){
		if (S[i][j]!=S[i][j+1] & dp[i][j+1]==-1){
			dp[i][j+1] = dp[i][j];
			rec(i,j+1);
		}
	}
	if (j>0){
		if (S[i][j]!=S[i][j-1] & dp[i][j-1]==-1){
			dp[i][j-1] = dp[i][j];
			rec(i,j-1);
		}
	}	
	if (i<H-1){
		if (S[i][j]!=S[i+1][j] & dp[i+1][j]==-1){
			dp[i+1][j] = dp[i][j];
			rec(i+1,j);
		}
	}
		
	if (i>0){ 
		if (S[i][j]!=S[i-1][j] & dp[i-1][j]==-1){
			dp[i-1][j] = dp[i][j];
			rec(i-1,j);
		}
	}
	return;
}

int main() {
	// 入力
	cin >> H>>W;
	for (ll i = 0; i < H; ++i) cin >> S[i];
 
	// 解法
	memset(dp, -1, sizeof(dp));
	REP(i,H){
		REP(j,W){
			rec(i,j);
		}
	}
	// cout << blocks << endl;
	
	// REP(i,H){
	// 	REP(j,W){
	// 		printf("%lld ", dp[i][j]);
	// 	}
	// 	printf("\n");
	// }
	ll ans = 0;
	// printf("%lld \n", blocks);
	ll num_block[blocks+1];
	ll white[blocks+1] = {0};
	ll black[blocks+1] = {0};
	REP(i,H){
		REP(j,W){
			if (S[i][j]=='.') white[dp[i][j]]++;
			else  black[dp[i][j]]++;
		}
	}
	REP(i,blocks+1){
		ans += white[i]*black[i];
	}
	
	//出力
	cout << ans << endl;
}


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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int a,b; cin >> a >> b;
    int ans = max(a,b);
    if(a > b) a-=1;
    else b-=1;
    ans += max(a,b);
    cout << ans << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

public class AtCoderE
{
    static void Main()
    {
        int n;
        int y;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            y = int.Parse(words[1]);
        }

        for (int i = 0; i <= n; i++)
        {
            for (int j = 0; i + j <= n; j++)
            {
                int k = n - i - j;
                if (10000 * i + 5000 * j + 1000 * k == y)
                {
                    Console.WriteLine(i + " " + j + " " + k);
                    return;
                }
            }
        }

        Console.WriteLine("-1 -1 -1");
    }
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define int long long
const int inf = 100100100100100;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    int x;
    cin >> x;
    vector<int> arr;
    rep(i,0,n){
        int t;
        cin >> t;
        arr.push_back(t);
    }

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

    int cnt = 0;

    int i = 0;
    while (i < n &&x-arr[i] >= 0 ){
        cnt++;
        x-= arr[i];
        i++;
        
    }

    if(x == 0 && i == n){
        cout << cnt << endl;
    }else if(x== 0 && i <= n){
        cout << cnt << endl;
    }else if(i < n && x > 0){

        cout << cnt << endl;
    }else if(x > 0){
        cout << cnt -1 << endl;
    }else{
        cout << cnt << endl;
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
bool isperfect(ll n){
    ll y=sqrt(n);
    if(n%y==0&&y*y==n)return true;
    return false;
}
bool comp(pair<ll,ll> a,pair<ll,ll> b){
    return a.second<b.second;
}


int main() {
  int n,m;cin>>n>>m;
  vil h(n);
  loop(0,n)cin>>h[i];
  vector<ll > v[n+1];
  set<ll> s;
  ll c[n+1]={};
  for(int i=0;i<m;i++){
      int x,y;cin>>x>>y;
      v[x].pb(y);
      v[y].pb(x);
     if(h[x-1]>h[y-1]) c[x]++;
       if(h[x-1]<h[y-1])  c[y]++;
  }
  ll cnt=0;
  for(int i=1;i<n+1;i++){
        if(v[i].size()==c[i])cnt++;
        //else if(v[i].size()==0&&s.count(i)==0)cnt++;
  }
  cout<<cnt; 
}



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

int main() {
 int n ;
 cin >>n;
  vector<int> h(n);
 int ans =n;
 for(int i=0;i<n;i++){
   cin >>h.at(i);
 }
 int minmum =h.at(0);
 for(int i=0;i<n;i++){
    if (h.at(i)<minmum){
      ans--;
     // cout <<i<<endl;
    }
   minmum=max(h.at(i),minmum);
           }
  cout <<ans ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;
#define MAX_N 100000
typedef long long ll;
typedef pair<int, int> pii;

int N;
int lv[MAX_N+1];
int arr[MAX_N+1];
vector<int> gp[MAX_N+1];

vector<int> v;
void dfs(int x){
	lv[x] = gp[x].size();
	for(int i=0; i<gp[x].size(); i++){
		dfs(gp[x][i]);
	}
	for(int i=0; i<gp[x].size(); i++){
		v.push_back(lv[gp[x][i]]);
	}sort(v.begin(), v.end());
	int t = 1;
	while(!v.empty()){
		lv[x] = max(lv[x], v.back()+t); t++;
		v.pop_back();
	}
}

int main(){
	scanf("%d", &N);
	for(int i=2; i<=N; i++)	{
		scanf("%d", &arr[i]);
		gp[arr[i]].push_back(i);
	}
	dfs(1);
	printf("%d", lv[1]);
	return 0;
}

Measured memory_bytes: 11136
H,W= list(map(int,input().split()))
M = []

for i in range(H):
    M.append(list(input()))

Hs = []
for i in range(H):
    flag = 0
    for j in range(W):
        if M[i][j]!=".":
            flag = 1
    if flag==1:
        Hs.append(i)

Ws = []
for j in range(W):
    flag = 0
    for i in range(H):
        if M[i][j]!=".":
            flag = 1
    if flag==1:
        Ws.append(j)

for i in Hs:
    out = []
    for j in Ws:
        out.append(M[i][j])
    print("".join(out))


Measured memory_bytes: 67756