akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	int n;
	cin >> n;
	vector<P> a(n);
	rep(i, n) {
		int z; cin >> z;
		a[i] = mp(z, i);
	}
	SORT(a);
	REVERSE(a);

	vector<vector<ll>> dp(n + 1);
	rep(i, n+1) {
		dp[i].resize(n + 1);
	}
	dp[0][0] = 0;
	ll ans = 0;
	FOR(k, 1, n + 1) {
		auto t = a[k - 1];
		FOR(i, 0, k + 1) {
			int j = k - i;
			if (i == 0) {
				dp[i][j] = dp[i][j - 1] + (ll)t.first * abs(t.second - n + j);
			}
			else if (j == 0) {
				dp[i][j] = dp[i - 1][j] + (ll)t.first * abs(t.second - i + 1);
			}
			else {
				dp[i][j] = max(dp[i][j - 1] + (ll)t.first * abs(t.second - n + j),
					dp[i - 1][j] + (ll)t.first * abs(t.second - i + 1));
			}
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
}




Measured memory_bytes: 35060
def main(a: int, b: int, c: int):
    if a < c < b:
        print('Yes')
    elif a > c > b:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    a, b, c = map(int, input().split())

    main(a, b, c)


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

int main(){
	int h,r;
	cin>>h>>r;
	if(h<0){
		if(h+r==0)cout << 0;
		else if(h+r<0)cout << -1;
		else cout <<1;
	}else {
		 cout<<1;
	}cout<<endl;
	return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
int main()
{
    int H,W,i,j;
    while(1)
    {
        scanf("%d %d",&H,&W);
        if(H==0 && W==0)
        {
            break;
        }
        for(i=0;i<H;i++)
        {
            for(j=0;j<W;j++)
            {
                if(i%2==1 && j%2==1)
                {
                    printf("#");
                }

                if(i%2==0 && j%2==0)
                {
                    printf("#");
                }

                if(i%2==0 && j%2==1)
                {
                    printf(".");
                }

                if(i%2==1 && j%2==0)
                {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



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

int main()
{
    int a, b;
    cin >> a >> b;

    if(a >= b+1)
    {
        cout << 2*a -1 << endl;
    }
    else if(a+1 <= b)
    {
        cout << 2*b - 1 << endl;
    }
    else if(a == b)
    {
        cout << a+b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int r,D,x;
  int i;
  
  scanf("%d%d%d",&r,&D,&x);
  
  int array[]={x};
  if((2<=r && r<=5) && (1<=D && D <=100) && (D<x && x<=200)){ 
  	for(i=0;i<10;i++){
    	array[i+1]=r*array[i]-D;
  		printf("%d\n",array[i]);
  	}
  }
  return 0;
}

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

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

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define si(a)           scanf("%d",&a)
#define sii(a,b)        scanf("%d %d",&a,&b)
#define siii(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define sl(a)           scanf("%lld",&a)
#define sll(a,b)        scanf("%lld %lld",&a,&b)
#define slll(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define PI              acos(-1.0)

//inline int setBit(int n,int pos) { return n = n | (1 << pos); }
//inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
//inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }
//inline int countBit(ll n) { return __builtin_popcountll(n); }


//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

/******************************************************************************************/

const int MAX = 3010;
const int INF = 0x3f3f3f3f;
//const double inf = 1.0/0.0;
//const int MOD = 1000000007;

bool vis[MAX][MAX];
double dp[MAX][MAX];
double p[MAX];

int n;

double call(int pos,int baki) {
    if(baki<0) return 0;
    if(pos>n) return (baki==0);
    if(vis[pos][baki]) return dp[pos][baki];
    vis[pos][baki] = true;
    double ret = 0;
    ret = p[pos] * call(pos+1,baki-1) + (1.0-p[pos]) * call(pos+1,baki);
    return dp[pos][baki] = ret;
}




int main() {
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    si(n);
    for(int i=1;i<=n;i++) cin >> p[i];

    double ans = 0;
    for(int i=(n/2)+1;i<=n;i++) ans += call(1,i);

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

    return 0;
}



Measured memory_bytes: 79360
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    int best = INT_MAX;
    if(n == 2)
    {
        cout << 2;
        return 0;
    }
    for(int i = 1; i < n/2; i++)
    {
        int cnt = 0;
        int a = i;
        int b = n - i;
        while(a > 0)
        {
            cnt += a % 10;
            a /= 10;
        }
        while(b > 0)
        {
            cnt += b % 10;
            b /= 10;
        }
        best = min(best, cnt);
    }
    cout << best;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1046527
#define nil (-1)
#define L 14

char H[M][L];

//文字から数値に変換
int gh(char ch){
    if(ch=='A')return 1;
    if(ch=='C')return 2;
    if(ch=='G')return 3;
    if(ch=='T')return 4;
    else return 0;
}

//文字列から数値に変換してkeyを生成する
long long gk(char str[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++){
        sum+=p*(gh(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
    long long key,i,h;
    key=gk(str);//文字列を数値に変換
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key,i,h;
    key=gk(str);//文字列を数値に変換
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i,n;
    char str[L],com[9];
    for(i=0;i<M;i++){
        H[i][0]='\0';
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",com,str);
        if(com[0]=='i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 17044
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<set>
#include<vector>
#define INF 100000000

#define MAX_N 100

typedef long long int ll;
using namespace std;


int main(){

	int mountain[10];

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

	for(int i = 0; i < 10; i++){
		for(int j = i+1; j < 10; j++){
			if(mountain[i] < mountain[j]){
				int kari = mountain[i];
				mountain[i] = mountain[j];
				mountain[j] = kari;
			}
		}
	}

	for(int i = 0; i < 3; i++){
		printf("%d\n", mountain[i]);
	}

	return 0;

}

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

int main(){
    int x;cin>>x;
    int a = 360;
    
    while(a%x!=0){
        a %= x;
        swap(a,x);
    }
    
    cout << 360/x << endl;
    
    return 0;
}

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

int main()
{
  int m, d;
  while (1){
    cin >> m >> d;
    if (m == 0){
      break;
    }
    if (m == 2){
      d += 31;
    }
    if (m == 3){
      d += 60;
    }
    if (m == 4){
      d += 91;
    }
    if (m == 5){
      d += 121;
    }
    if (m == 6){
      d += 152; 
    }
    if (m == 7){
      d += 182;
    }
    if (m == 8){
      d += 213;
    }
    if (m == 9){
      d += 244;
    }
    if (m == 10){
      d += 274;
    }
    if (m == 11){
      d += 305;
    }
    if (m == 12){
      d += 335;
    }

    if (d % 7 == 0){
      cout << "Wednesday";
    }
    else if (d % 7 == 1){
      cout << "Thursday";
    }
    else if (d % 7 == 2){
      cout << "Friday";
    }
    else if (d % 7 == 3){
      cout << "Saturday";
    }
    else if (d % 7 == 4){
      cout << "Sunday";
    }
    else if (d % 7 == 5){
      cout << "Monday";
    }
    else {
      cout << "Tuesday";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int D=365;
vector<int> c(26);
vector<vector<int>> s(365, vector<int>(26));

ll calc(const vector<int>& t, int d, int q){
  ll res = 0;
  vector<int> lst(26,-1);
  rep(i,D){
    if(i!=d){
      if(t[i]!=-1){
        res += s[i][t[i]];
        lst[t[i]] = i;
      }
    }
    else{
      res += s[i][q];
      lst[q]=i;
    }
    rep(j,26){
      res -= c[j]*(i-lst[j]);
    }
  }
  //cerr << res << '\n';
  return res;
}

ll calc2(const vector<int>& t, int d1, int d2){
  ll res = 0;
  vector<int> lst(26,-1);
  rep(i,D){
    if(i!=d1 && i!=d2){
      res += s[i][t[i]];
      lst[t[i]] = i;
    }
    else if(i==d1){
      res += s[i][t[d2]];
      lst[t[d2]]=i;
    }
    else if(i==d2){
      res += s[i][t[d1]];
      lst[t[d1]]=i;
    }
    rep(j,26){
      res -= c[j]*(i-lst[j]);
    }
  }
  //cerr << res << '\n';
  return res;
}

int main(){
  /*
  ifstream in("input.in");
  cin.rdbuf(in.rdbuf());
  ofstream ofs("output.txt");
  cout.rdbuf(ofs.rdbuf());
  //*/
  chrono::system_clock::time_point start, end;
  start = chrono::system_clock::now();
  mt19937 mt(184);
  cin >> D;
  rep(i,26) cin >> c[i];
  rep(y,D) rep(x,26) cin >> s[y][x];
  vector<int> t(D,-1);


  rep(d,D){
    int m=0;
    rep(x,26){
      if(chmax(m,s[d][x])) t[d]=x;
    }
  }
  ll now = calc(t,-1,-1);
  while(1){
    int d=mt()%365, q=mt()%26;
    if(chmax(now,calc(t,d,q))){
      t[d]=q;
    }
    end = chrono::system_clock::now();
    double ela = chrono::duration_cast<chrono::milliseconds> (end-start).count();
    if(ela>1970) break;
  }
  while(0){
    int d1=mt()%365, d2=mt()%365;
    if(d1==d2) continue;
    if(chmax(now,calc2(t,d1,d2))){
      int tmp = t[d1];
      t[d1]=t[d2];
      t[d2]=tmp;
    }
    end = chrono::system_clock::now();
    double ela = chrono::duration_cast<chrono::milliseconds> (end-start).count();
    if(ela>1970) break;
  }
  rep(i,D) cout << t[i]+1 << '\n';
  return 0;
}


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

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

template <class Key>
using rb_tree_set =
    __gnu_pbds::tree<Key, __gnu_pbds::null_type, std::less<Key>,
                     __gnu_pbds::rb_tree_tag,
                     __gnu_pbds::tree_order_statistics_node_update>;

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, Q;
  cin >> N >> Q;
  vector<int> colors(N);
  REP(i, N) cin >> colors[i];
  vector<int> lefts(Q), rights(Q), ids(Q);
  REP(i, Q) {
    cin >> lefts[i] >> rights[i];
    --lefts[i];
    --rights[i];
    ids[i] = i;
  }
  sort(ids.begin(), ids.end(),
       [&](int i, int j) { return rights[i] < rights[j]; });

  rb_tree_set<pair<int, int>> st;
  vector<int> prev(500'005, -1);
  vector<int> res(Q);
  int j = 0;
  for (int i = 0; i < N; ++i) {
    int pc = prev[colors[i]];
    if (pc >= 0) st.insert({pc, i});
    for (; j < Q && rights[ids[j]] == i; ++j) {
      auto it = st.lower_bound(make_pair(lefts[ids[j]], -1));
      int dup_count = 0;
      if (it != st.end()) {
        dup_count = st.size() - st.order_of_key(*it);
      }
      res[ids[j]] = rights[ids[j]] - lefts[ids[j]] + 1 - dup_count;
      DEBUG(j, ids[j], lefts[ids[j]], rights[ids[j]], dup_count, res[ids[j]]);
    }
    prev[colors[i]] = i;
  }
  for (int i = 0; i < Q; ++i) cout << res[i] << '\n';
}


Measured memory_bytes: 46208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mod=1000000007;


int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  int n; cin >> n;
        ll ans = 0;
        for (int mul = 1; mul <= n; mul++) {
                int k = n / mul;
                ans += (ll) k * mul * (1 + k) / 2;
        }
 
        cout << ans;
  return 0;
}

Measured memory_bytes: 3644
'use strict';
function main(input) {
  const X = parseInt(input);
  var x = X;
  var D = true;
  while (D) {
    D = false;
    for (let i = 2; i < x; ++i) {
      if (x % i === 0) {
        D = true;
        ++x;
        break;
      }
    }
  }
  console.log(x);
}

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

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
string s="aaaaaaaaaa";
int n;
void dfs(int i,int j)
{
	if(i>=n)
	{
		for(int k=0;k<n;k++)putchar(s[k]);
		putchar(10);
		return;
	}
	s[i]='a'-1;
	for(int k=0;k<=j;k++)
	{
		++s[i];
		dfs(i+1,max(k,j-1)+1);
		
	}
}
int main()
{
	scanf("%d",&n);
	dfs(0,0);
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main(){
	string s1[110],s2[110];
	int n,m,i,j,d=0,x;
	cin >> n ;
	for(i=0;i<n;i++){
		cin >> s1[i];
	}
	cin >> m;
	for(i=0;i<m;i++){
		cin >> s2[i];
	}
	for(i=0;i<n;i++){
		x=0;
		for(j=0;j<n;j++){
			if(s1[i]==s1[j]){
				x++;
			}
		}
		for(j=0;j<m;j++){
			if(s1[i]==s2[j]){
				x--;
			}
		}
		if(x>d){
			d=x;
		}
	}
    cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
takoyaki = gets.split(' ').map(&:to_i)

oishisa_total = 0
oishisa = 0
a = 0

while a < N do

    b = a + 1

    while b < N do
    
        oishisa = oishisa + takoyaki[a] * takoyaki[b] 

        b = b + 1

    end

    oishisa_total = oishisa_total + oishisa
    oishisa = 0
    a = a + 1

end

puts oishisa_total

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

using namespace std;

typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}

int main(void){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e - a <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//A - Parking
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int price1 = n*a;
  int price2 = b;
  
  if (price1 <= price2)
    cout << price1 << endl;
  else
    cout << price2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
vector<vector<pair<int,int>>> tree;
vector<int> node;


int main() {
    int N;
    cin >> N;
    tree.resize(N);
    node.resize(N,-1);
    for(int i=0;i<N-1;i++){
        int a,b,c;
        cin >> a >> b >>c;
        --a;--b;
        tree[a].emplace_back(b,c);
        tree[b].emplace_back(a,c);
    }
    queue<int> q;
    q.push(0);
    node[0] =0;
    while(!q.empty()){
        int p = q.front();
        q.pop();
        for(auto child:tree[p]){
            if(p==child.first){
                continue;
            }
            if(node[child.first] != -1){
                continue;
            }
            q.push(child.first);
            if(child.second%2==0){
                node[child.first] = node[p]; 
            }else{
                node[child.first] = 1-node[p];
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 6784
def topological_sort(tree: list, root) -> list:
    """根付き木をトポロジカルソートする"""
    n = len(tree)
    visited = [False] * n
    visited[root] = True
    tp_sorted = [root]
    stack = [root]
    while stack:
        v = stack.pop()
        for nxt_v in tree[v]:
            if visited[nxt_v]:
                continue
            visited[nxt_v] = True
            stack.append(nxt_v)
            tp_sorted.append(nxt_v)
    return tp_sorted


def get_par(tree: list, root: int) -> list:
    """根付き木の頂点それぞれの親を求める"""
    n = len(tree)
    visited = [False] * n
    visited[root] = True
    par = [-1] * n
    stack = [root]
    while stack:
        v = stack.pop()
        for nxt_v in tree[v]:
            if visited[nxt_v]:
                continue
            visited[nxt_v] = True
            stack.append(nxt_v)
            par[nxt_v] = v
    return par


n = int(input())
edges = [list(map(int, input().split())) for i in range(n - 1)]


tree = [[] for i in range(n)]
root = 0
for a, b in edges:
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)

tp_sorted = topological_sort(tree, root)
par = get_par(tree, root)
grandy = [0] * n

for v in tp_sorted[::-1]:
    par_v = par[v]
    if par_v == -1:
        continue
    grandy[par_v] ^= grandy[v] + 1

if grandy[0] != 0:
    print("Alice")
else:
    print("Bob")

Measured memory_bytes: 109572
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	int N;
	cin >> N;

	vector<int> cnt(N, 0);

	int A;
	for (int i = 1; i < N; i++) {
		cin >> A;
		cnt[A - 1] += 1;
	}

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

	return 0;
}



Measured memory_bytes: 4048
#include <iostream>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

typedef vector<int> VI;
typedef vector< VI > VVI;
typedef vector< VVI > VVVI;


int MAP(VVI &m, int i, int j){

	int w = m[0].size();
	int h = m.size();

	if(!( 0 <= i && i <= h && 0 <= j && j <= w)){
		return 0;
	}

	if(m[i][j] == 0){
		return 0;
	}
	else if(m[i][j] == 1){
		m[i][j] = 0;
		MAP(m, i - 1, j - 1);
		MAP(m, i, j - 1);
		MAP(m, i + 1, j - 1);
		MAP(m, i - 1, j);
		MAP(m, i + 1, j);
		MAP(m, i - 1, j + 1);
		MAP(m, i, j + 1);
		MAP(m, i + 1, j + 1);
	}

	return 1;
}

int main(){
	int w, h;

	while(true){
		cin >> w >> h;

		if(w == 0 && h == 0){
			break;
		}

		VVI map(h + 1, VI(w + 1, 0));

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> map[i][j];
			}
		}

		int count = 0;

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				count += MAP(map, i, j);
			}
		}

		cout << count << endl;
	}
}

Measured memory_bytes: 1416
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;

#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define mp(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define all(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define pb push_back
#define pf push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


void solve(){
    ll a, b;
    int ans;
    
    ans = 0;
    cin >> a >> b;
    for(ll i=a;i<=b;i*=2){
        ans++;
    }
    cout << ans << '\n';
}

int main(){
    IOS;
    
    solve();
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;
 
typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
 
#define N 100000+5

lli maxSubarrayXOR(lli set[],lli n) 
{ 
    lli index = 0; 
   
    for (lli i = 60; i >= 0; i--) 
    {  
        lli maxInd = index; 
        lli maxEle = -1*inf; 
        for (lli j = index; j < n; j++) 
        {  
            if ( (set[j] & (1ll << i)) != 0  
                     && set[j] > maxEle ) 
                maxEle = set[j], maxInd = j; 
        } 
  
        if (maxEle == -1*inf) 
        continue; 
  
        swap(set[index], set[maxInd]); 
  		maxInd = index; 
  		for (lli j=0; j<n; j++) 
        { 
            if (j != maxInd && 
               (set[j] & (1ll << i)) != 0) 
                set[j] = set[j] ^ set[maxInd]; 
        } 
  
        index++; 
    } 
  
    lli res = 0; 
    for (lli i = 0; i < n; i++) 
        res ^= set[i]; 
    return res; 
} 

int main () 
{
/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////    
 
	lli n;
	cin>>n;

	lli a[n],b[n];
	loopl(i,0,n) 
	{
		cin>>a[i];
		b[i]=a[i];
	}

	lli ans=0,cnt[61]={0};

	loopl(i,0,n)
	{
		loopl(j,0,61)
		{
			if(a[i]&(1ll<<j)) cnt[j]++;
		}
	}

	loopl(j,0,61)
	{
		if(cnt[j]%2 == 1)
		{
			// cout<<j<<" "<<(1ll<<j)<<endl;
			ans += (1ll<<j);
			loopl(i,0,n)
			{
				if(b[i]&(1ll<<j))
					b[i] = (b[i]&(~(1ll<<j)));
			}
		}
	}
	ans += 2*maxSubarrayXOR(b,n);
	cout<<ans;
}	

Measured memory_bytes: 1792
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

template <typename T> using vec = std::vector<T>;
using vi = vec<int>;
using ll = long long;
using ld = long double;
// constexpr auto mod = 1000000007;
using namespace std;

int main() {
  string s;
  cin >> s;
  const auto size = s.size();
  vi changed = {0, 0};
  REP(i, size) {
    if (s[i] != (i % 2 == 0 ? '0' : '1')) {
      changed[0] += 1;
    } else {
      changed[1] += 1;
    }
  }
  cout << min(changed[0], changed[1]) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int M[2][2] = { {1,1},{0,1} };

int main(void)
{
	int N;
	cin >> N;
	char B;
	cin >> B;
	int A = (B == 'T');
	for (int i = 1; i < N; ++i) {
		char p; cin >> p;
		int q = (p == 'T');
		A = M[A][q];
	}
	cout << (A ? 'T' : 'F') << endl;
	return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
int main() {
    int n; cin >> n;
    vector<int> ans(4, 0);
    rep(i, n){
        string s; cin >> s;
        if(s == "AC") ans[0]++;
        else if(s == "WA") ans[1]++;
        else if(s == "TLE") ans[2]++;
        else ans[3]++;
    }
    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
char c[60006];
int a[8806],b[8888],tota=1,totb=0;
int dp[2][18800];
int x,y,n;
int main(){
	scanf("%s",c+1);n=strlen(c+1);
	scanf("%d%d",&x,&y);
	for(int i=1,j=1;i<=n;++i){
		if(c[i]=='T'){j^=1;if(j)++tota;else ++totb;} 
		else if(j)++a[tota];else ++b[totb];
	}
//	sort(a+1,a+tota+1);sort(b+1,b+totb+1);
	int fa=0,fb=0;
	dp[1][8004+a[1]]=1;
	for(int j=2;j<=tota;++j){
		for(int i=1;i<=16010;++i){
			if(i+a[j]<=16010)dp[j&1][i+a[j]]|=dp[(1+j)&1][i];
			if(i-a[j]>0)dp[j&1][i-a[j]]|=dp[(1+j)&1][i];
		}
		memset(dp[(1+j)&1],0,sizeof dp[(1+j)&1]);
	}
	fa=dp[tota&1][x+8004];
	memset(dp,0,sizeof dp);
	dp[0][8004]=1;
	for(int j=1;j<=totb;++j){
		for(int i=1;i<=16010;++i){
			if(i+b[j]<=16010)dp[j&1][i+b[j]]|=dp[(1+j)&1][i];
			if(i-b[j]>0)dp[j&1][i-b[j]]|=dp[(1+j)&1][i];
		}
		memset(dp[(1+j)&1],0,sizeof dp[(1+j)&1]);
	}
	fb=dp[totb&1][y+8004];
	puts((fa&&fb)?"Yes":"No");
	return 0; 
}

Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    double x, X, y, Y, a, b, l;
    scanf("%lf %lf %lf %lf", &x, &y, &X, &Y);
    a = fabs(X - x);
    b = fabs(Y - y);
    l = sqrt(a * a + b * b); 
    printf("%f", l);
}


Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define lowbit(x) (x&(-x))
const int maxn = 5e5+5;

struct Bit {
    int bit[30][maxn];

    void init() {
        memset(bit, 0, sizeof(bit));
    }
    void add(int type,int x,int val) {
        for(int i=x; i<maxn; i+=lowbit(i)) {
            bit[type][i] += val;
        }
    }

    int query(int type,int l,int r) {
        int ret = 0;
        for(int i=r; i>0; i-=lowbit(i)) {
            ret += bit[type][i];
        }

        for(int i=l-1; i>0; i-=lowbit(i)) {
            ret -= bit[type][i];
        }
        return ret;
    }

} bit;
string s;

main() {
    IOS
    int n;
    cin >> n >> s;
    bit.init();
    for(int i=0; i<n; i++) {
        bit.add((s[i]-'a'), i+1, 1);
    }
    int Q;
    cin >> Q;

    while(Q--) {
        int type;
        cin >> type;
        if(type == 2) {
            int l, r, ans = 0;
            cin >> l >> r;
            for(int i=0; i<26; i++) {
                if(bit.query(i, l, r))
                    ans++;
            }
            cout << ans << "\n";
        }
        else {
            int st;char c;
            cin >> st >> c;
            bit.add((s[st-1]-'a'), st, -1);
            bit.add(c-'a', st, 1);
            s[st-1] = c;
        }
    }

}





Measured memory_bytes: 118172
#include <stdio.h>
#include <math.h>

int main(void){
    int a, b;
    scanf("%d%d", &a, &b);

    int number;
    if (b < 10){
        number = a * 10 + b;
    }
    if (10 <= b && b < 100){
        number = a * 100 + b;
    }
    if (b == 100){
        number = a * 1000 + b;
    }

    
    int flag = 0;
    int z = sqrt(number);
    if (sqrt(number) == z){
        flag = 1;
    }

    if (flag){
        printf("%s\n", "Yes");
    }
    else {
        printf("%s\n", "No");
    }

    return 0;
}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class EGluttony {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        lint K;
        in>>N>>K;
        vc<int> A(N), F(N);
        for(auto& a : A) in>>a;
        for(auto& f : F) in>>f;
        sort(ALL(A));
        sort(RALL(F));
        lint left = -1, right = ten(13);
        while(1<right-left){
            lint mid = (left+right) >> 1, r = K;
            REP(i, N){
                r -= max(0ll, A[i]-mid/F[i]);
            }
            if(r>=0) right = mid;
            else left = mid;
        }
        out<<right<<'\n';
    }
};


int main() {
	EGluttony solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 10005;

int N, U, V;
vector<int> graph[MX], a;
int num[MX];
int cnt, ans;

void dfs(int v, int p) {
	num[v] = a[cnt];
	cnt++;
	if (p != -1) ans += num[v];
	for (auto& u : graph[v]) {
		if (u != p) dfs(u, v);
	}
}

void solve() {
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
		cin >> U >> V;
		graph[U].push_back(V);
		graph[V].push_back(U);
	}
	a.resize(N);
	for(auto& i : a) cin >> i;
	sort(a.begin(), a.end(), greater<int>());
	
	dfs(1, -1);
	cout << ans << "\n";
	for (int i = 1; i <= N; i++) cout << num[i] << " ";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


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

int n,m;
int stone_num[160];
int stones[160][10][2];

int memo[160][100][10];

int tansaku(int ypos,int tobasi_num,int xpos) {
	int i;
	int now,min;
	if(ypos>n)return 0;
	if(memo[ypos][tobasi_num][xpos]>0)return memo[ypos][tobasi_num][xpos]-1;
	min=0x3fffffff;
	for(i=0;i<stone_num[ypos+1];i++) {
		now=tansaku(ypos+1,tobasi_num,i);
		if(ypos>0 && ypos+1<=n) {
			now+=abs(stones[ypos][xpos][0]-stones[ypos+1][i][0])*
				(stones[ypos][xpos][1]+stones[ypos+1][i][1]);
		}
		if(now<min)min=now;
	}
	if(tobasi_num>0) {
		for(i=0;i<stone_num[ypos+2];i++) {
			now=tansaku(ypos+2,tobasi_num-1,i);
			if(ypos>0 && ypos+2<=n) {
				now+=abs(stones[ypos][xpos][0]-stones[ypos+2][i][0])*
					(stones[ypos][xpos][1]+stones[ypos+2][i][1]);
			}
			if(now<min)min=now;
		}
	}
	memo[ypos][tobasi_num][xpos]=min+1;
	return min;
}

int main(void) {
	int i,j;
	while(1) {
		scanf("%d%d",&n,&m);
		if(n==0 && m==0)break;
		stone_num[0]=1;
		stones[0][0][0]=stones[0][0][1]=0;
		for(i=1;i<=n;i++) {
			scanf("%d",&stone_num[i]);
			for(j=0;j<stone_num[i];j++) {
				scanf("%d%d",&stones[i][j][0],&stones[i][j][1]);
			}
		}
		stone_num[n+1]=1;
		stones[n+1][0][0]=stones[n+1][0][1]=0;
		stone_num[n+2]=1;
		stones[n+2][0][0]=stones[n+2][0][1]=0;
		memset(memo,0,sizeof(memo));
		printf("%d\n",tansaku(0,m,0));
	}
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

int  N, M;
int k[15];
int s[15][15];
int p[15];

int bb[15];
int ba;

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

  cin >> N >> M;
  rep(i,M) {
    cin >> k[i];
    rep(j,k[i]) {
      cin >> s[i][j];
      bb[s[i][j]-1] += 1 << i;
    }
  }
  rep(i,M) {
    cin >> p[i];
    ba += (1 << i) * p[i];
  }

  int ans = 0;

  rep(bi,1<<N){
    int bs = 0;
    rep (j,N) if(bi & (1<<j)) bs ^= bb[j];
    if (bs==ba) ans ++;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#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>;

const int MOD = 1000000007;
ll dp[2005][2005];

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> S(n);
    vector<int> T(m);
    rep(i, n) cin >> S[i];
    rep(i, m) cin >> T[i];
    rep(i, n+1) dp[i][0] = 1;
    rep(i, m+1) dp[0][i] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
            if (S[i-1] != T[j-1]) dp[i][j] -= dp[i-1][j-1];
            dp[i][j] += MOD;
            dp[i][j] %= MOD;
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}

Measured memory_bytes: 31616
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 n;
	cin >> n;
	vector<int> x(n), y(n), h(n);
	rep(i,n) cin >> x[i] >> y[i] >> h[i];
	rep(cy, 101)rep(cx,101){
		int H = 0;
		rep(i,n){
			if(h[i]){
				H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
				break;
			}
		}
		bool ok = true;
		rep(i,n){
			int height = H - abs(x[i] - cx) - abs(y[i] - cy);
			chmax(height, 0);
			if(h[i] != height) ok = false;
		}
		if(ok){
			cout << cx << " " << cy << " " << H << endl;
			return 0;
		}
	}
	return 0;
}

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

int main()
{
    size_t R, C, K;
    cin >> R >> C >> K;

    vector<vector<vector<size_t>>> dp(R + 1, vector<vector<size_t>>(C + 1, vector<size_t>(4, 0)));
    vector<vector<size_t>> rc(R + 1, vector<size_t>(C + 1, 0));
    for (size_t i = 0; i < K; i++)
    {
        size_t r, c;
        size_t v;
        cin >> r >> c >> v;
        rc[r][c] = v;
    }

    for (size_t r = 1; r <= R; r++)
    {
        for (size_t c = 1; c <= C; c++)
        {
            for (size_t k = 0; k <= 3; k++)
            {
                dp[r][c][0] = max(dp[r][c][0], dp[r - 1][c][k]);
                dp[r][c][1] = max(dp[r][c][1], dp[r - 1][c][k] + rc[r][c]);
                dp[r][c][k] = max(dp[r][c][k], dp[r][c - 1][k]);
            }

            for (size_t k = 1; k <= 3; k++)
            {
                dp[r][c][k] = max(dp[r][c][k], dp[r][c - 1][k - 1] + rc[r][c]);
            }
        }
    }
    cout << max({dp.back().back()[0], dp.back().back()[1], dp.back().back()[2], dp.back().back()[3]}) << endl;
}


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

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

struct UnionFind(T)
{
	void init(T n) { par = new T[](n); foreach (i; 0..n) par[i] = i; cnt = new T[](n); fill(cnt, 1); }
	T root(T i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(T i, T j) { return root(i) == root(j); }
	void unite(T i, T j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; cnt[j] += cnt[i]; }
	T size(T i) { return cnt[root(i)]; }
	T[] par, cnt;
}

void main()
{
	auto N = RD;
	auto X = new long[](N);
	auto Y = new long[](N);
	foreach (i; 0..N)
	{
		X[i] = RD-1;
		Y[i] = RD-1;
	}

	UnionFind!long uf;
	uf.init(N);
	auto index = X.MAKE_IDX();
	auto rbt = new RedBlackTree!(long[], "a[0] < b[0]")();
	auto rootY = new long[](N);
	foreach (i; 0..N)
	{
		rootY[i] = Y[i];
	}
	foreach (i; index)
	{
		bool add = true;
		long lastY = Y[i];
		if (!rbt.empty)
		{
			auto r = rbt.lowerBound([Y[i], 0]);
			long[][] rmList;
			foreach (e; r)
			{
				uf.unite(i, e[1]);
				if (e[0] > lastY)
					rmList ~= e;
				else
				{
					lastY = e[0];
					add = false;
				}
			}
			rbt.removeKey(rmList);
		}
		if (add)
			rbt.insert([lastY, cast(long)i]);
	}

	foreach (i; 0..N)
		writeln(uf.size(i));
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 26220
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int x=2*n;
int a[x];
for(int i=0;i<x;i++)
cin>>a[i];
sort(a,a+x);
int sum=0;
for(int i=0;i<x;i+=2)
sum+=a[i];
cout<<sum<<endl;
}

Measured memory_bytes: 256
a = list(map(int,input().split()))
b = [input() for l in range(a[0])]
ans = 0
cnt = 0
allcnt = 0
nongyou = []
cnt2 = 0
for i in range(a[0]):
    allcnt += b[i].count('#')

for i in range(2 ** a[0]):
    cnt = allcnt
    nongyou = []
    for j in range(a[0]):
        if ((i >> j) & 1):
            cnt -= b[j].count('#')
            nongyou.append(j)
    for m in range(2 ** a[1]):
        cnt2 = cnt
        for n in range(a[1]):
            if ((m >> n) & 1):
                for k in range(a[0]):
                    if k in nongyou:
                        continue
                    else:
                        cnt2 -= b[k][n].count('#')                  
        if cnt2 == a[2]:
            ans += 1

print(str(ans))

Measured memory_bytes: 73648
x, y = map(int, input().split())

group_1 = set([1, 3, 5, 7, 8, 10, 12])
group_2 = set([4, 6, 9, 11])
group_3 = set([2])

if x in group_1 and y in group_1:
    print("Yes")
elif x in group_2 and y in group_2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
n = int(input())
l = []
for _ in range(n):
    l.append(int(input()))

l.sort()
ans = sum(l)
if ans%10 != 0:
    print (ans)
    exit ()
else:
    for i in l:
        tmp = ans - i
        if tmp%10 != 0:
            print (tmp)
            exit ()
print (0)


Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  if(s[0] != s[1] && s[1] != s[2]&& s[2] != s[0]){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define pb(b) push_back(b) 
#define all(a) a.begin(),a.end()
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
const int mod=1e9+7;
/* 
UnionFind：素集合系管理の構造体(union by size)
isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
treeSize(x): x を含む集合の要素数。
*/
struct UnionFind{
 vector<int>size,parents;
 UnionFind(){}
 UnionFind(int n){//make n trees.
  size.resize(n,0);
  parents.resize(n,0);
  for(int i=0;i<n;i++)makeTree(i);
 }
 void makeTree(int x){
   parents[x]=x;//the parent of x is x
   size[x]=1;
  }
 bool isSame(int x,int y){return findRoot(x)==findRoot(y);}
 bool unite(int x,int y){
  x = findRoot(x);
  y = findRoot(y);
  if(x==y)return false;
  if(size[x]>size[y]){
   parents[y]=x;
   size[x]+=size[y];
  } 
  else{
   parents[x]=y;
   size[y]+=size[x];
  }
  return true;
 }
 int findRoot(int x){//木の根を探す,計算量削減のため低く
  if(x!=parents[x])parents[x]=findRoot(parents[x]);
  return parents[x];
 }
 int treeSize(int x){return size[findRoot(x)];}
};
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*迷路移動*/const int dx[4]={1,0,-1,0};const int dy[4]={0,1,0,-1};
llfor;////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 ll tmp=1;
 ll ans=llpow(3,n);
 ll a;
 rep(i,0,n){
  cin>>a;
  if(a%2==0)tmp*=2;
 }
 pr(ans-tmp);
return 0;}

Measured memory_bytes: 3612
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int main(){
  int N,M,K;
  cin>>N>>M>>K;
  int par[100001];
  for(int i=1;i<=N;i++) par[i]=i;
  vector<int> fri[100001],brock[100001];
  for(int i=0;i<M;i++){
    int A,B;
    cin>>A>>B;
    fri[A].push_back(B);
    fri[B].push_back(A);
  }
  for(int i=0;i<K;i++){
    int C,D;
    cin>>C>>D;
    brock[C].push_back(D);
    brock[D].push_back(C);
  }
  for(int i=1;i<=N;i++){
    if(par[i]==i){
      queue<int> que;
      que.push(i);
      while(!que.empty()){
        int n=que.front();
        que.pop();
        for(int j=0;j<fri[n].size();j++){
          int x=fri[n][j];
          if(par[x]==x){
            par[x]=par[n];
            que.push(x);
          }
        }
      }
    }
  }
  int member[100001];
  for(int i=1;i<=N;i++) member[i]=0;
  for(int i=1;i<=N;i++) member[par[i]]++;
  for(int i=1;i<=N;i++){
    int answer=member[par[i]]-fri[i].size()-1;
    for(int j=0;j<brock[i].size();j++){
      if(par[brock[i][j]]==par[i]) answer--;
    }
    cout<<answer<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 14992
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a;i < b; i++)

int main() {

	string s;

	cin >> s;

	ll count = 0;
	ll i = 0;
	while (i < s.size()) {
		if (i % 2 == 0) {
			if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {
				count++;
			}
		}
		else if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
			count++;
		}
		i++;
	}

	if (count == s.size()) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256