akhauriyash/Code-Regression huggingface dataset:
/*
 * author :Sadik Hassan(_sad_)
 *
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
using   ld =          long double;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define MP            make_pair
#define PI            (acos(-1.0))
#define rep1(i,n)     for(int i=1;i<=n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         (int)s.size()
#define all(x)        (x).begin(), (x).end()
#define rall(x)       (x).rbegin(), (x).rend()
#define w(t)          int t;cin>>t;while(t--)
#define TSU(s)        transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSL(s)        transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(15);

typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = (int)2e5+5;
const ll MOD =(ll)1e9+7;
const ll INF = (ll)1e18+5;
const int nn=1e5+5;

int main()
{
    _SAD()
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    int ans=0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]&&(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]))
                {
                    ans++;
                }
            }
        }
    }
    cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <set>
#define rep(i, N) for (int i = 0; i <= (int)N; i++)
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INTINF = 2147483647;
const int MOD = 1000000007;

int main() {
  int A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;
  A *= 100; B *= 100;

  set<int> water, sugar;
  for (int i=0; i*A<=F; i++) {
    for (int j=0; i*A+j*B<=F; j++) {
      water.insert(i*A+j*B);
    }
  }
  for (int i=0; i*C<=F; i++) {
    for (int j=0; i*C+j*D<=F; j++) {
      sugar.insert(i*C+j*D);
    }
  }

  // for (auto x: water) cout << x << " "; cout << endl;
  int rw = 0, rs = 0;
  double den = 0;
  for (auto w: water) for (auto s: sugar) {
    // cout << s << " " << s+w << " " << (double)s/(s+w)*100 << endl;
    if (w!=0 && w+s<=F && w*E>=s*100 && den <= (double)s/(s+w)*100) {
      rw = w+s; rs = s;
      den = (double)s/(s+w)*100;
    }
  }

  cout << rw << " " << rs << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S; cin>>S;
    int N=S.size();
    int maximum=0;
    for(int i=0;i<N;i++){
        int count=0;
        for(int j=i;j<N;j++){
            if(S[j]=='A'||S[j]=='C'||S[j]=='G'||S[j]=='T'){
                count++;
                maximum=max(maximum,count);
            }
            else{
                maximum=max(maximum,count);
                break;
            }
        }
    }
    cout<<maximum;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MIN(a,b) ((a)<(b)?(a):(b));
#define MAX(a,b) ((a)>(b)?(a):(b));

typedef long long int64;

int main(void){
    int a[5];

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

    int sum;
    for(int i=0;i<5;i++){
        if(a[i]%10==0){
            sum+=a[i];
        }else{
            sum+=a[i]-a[i]%10+10;
        }
    }

    int dif=10;

    for(int i=0;i<5;i++){
        if(a[i]%10==0) continue;
        dif=MIN(a[i]%10,dif);
    }

    printf("%d",sum-10+dif);
    
    
    
    return 0;
}

Measured memory_bytes: 128
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int a[N] , n;
vi g[N];

int dfs(int c,int fa) {
  vi deps;
  for(auto t : g[c]) if(t != fa) {
    deps.pb(dfs(t , c));
  }
  int maxdep = 0;
  sort(all(deps));
  reverse(all(deps));
  rep(i,0,sz(deps))
    maxdep = max(maxdep , i + 1 + deps[i]);
  return maxdep;
}

int main(){
  scanf("%d",&n);
  rep(i,2,n+1) scanf("%d",a+i) , g[a[i]].pb(i);
  printf("%d\n",dfs(1,0));
  return 0;
}


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

int main() {
    long double a,b,c;
    cin >> a >> b >> c; 
    long double eps = 1.0e-14;
    if(sqrt(a)+sqrt(b)+eps < sqrt(c)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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(int argc, char const *argv[]) {
  int n;
  cin >> n ;
  vector<int> h(n) ;
  rep(i,n) cin >> h[i] ;
  int ans=1;

  for(int i=n-1; i>0; i--){
    bool can=true;
    int c=h[i];
    for(int j=i-1; j>=0; j--){
      if(c<h[j]) can=false;
    }
    if(can) ans++;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int i, a, b, c, t = 0;

  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);

  for(i = a; i <= b; i++) {
    if(c % i == 0) {
      t++;
    }
  }
  printf("%d\n",t);

  return 0;
}

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

int main(void)
{
    int x, n, tmp, ans, j, k, f=0;
    cin >> x >> n;
    if(n==0){
        ans=x;
    }else{
        int num=103;
        int p[num];
        rep(i, num){
            p[i]=i-1;
        }
        rep(i, n){
            cin >> tmp;
            p[tmp+1]=FORBIDDEN;
        }
        for(j=x,k=x;;j--,k++){
            if(p[j+1]!=FORBIDDEN){
                ans=j;
                break;
            }else if(p[k+1]!=FORBIDDEN){
                ans=k;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM=MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};

ll cnt[65][65];
int main(){
	int n;
	scanf("%d",&n);
	fup(i,0,n-1,1){
		db x;
		scanf("%lf",&x);
		ll a=(ll)round(x*1e9);
		int t2=0,t5=0;
		while(a%2==0){
			t2++;
			a/=2;
		}
		while(a%5==0){
			t5++;
			a/=5;
		}
		cnt[t2][t5]++;
	}
	ll ans=0;
	fup(i1,0,64,1)fup(j1,0,64,1)fup(i2,0,64,1)fup(j2,0,64,1){
		if(mp(i1,j1)<mp(i2,j2) && i1+i2>=18 && j1+j2>=18)ans+=cnt[i1][j1]*cnt[i2][j2];
	}
	fup(i,9,64,1)fup(j,9,64,1){
		ll t=cnt[i][j];
		ans+=t*(t-1)/2;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using ll = long long;
int main(){ 
    ll n;
    string s,t;
    cin>>n;
    cin>>s>>t;
    rep(i,n){
        cout<<s[i]<<t[i];
    }
    return 0;
}


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

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

using namespace std;


struct Point{ ll x, y; };

vector<ll> g[205];
bool match(ll s, vector<ll>& p, ll n, vector<bool>& v){
    if(s<0) return true;
    rep(i, g[s].size()){
        if(!v[g[s][i]]){
            v[g[s][i]] = true;
            if(match(p[g[s][i]], p, n, v)){
                p[s] = g[s][i];
                p[g[s][i]] = s;
                return true;
            }
        }
    }
    return false;
}

int main() {
    ll n;
    cin >> n;
    vector<Point> red(n);
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        red[i] = {a, b};
    }

    vector<Point> blue(n);
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        blue[i] = {a, b};
    }

    rep(rx, n){
        rep(bx, n){
            if(red[rx].x < blue[bx].x && red[rx].y < blue[bx].y){
                g[rx].push_back(bx+n);
                g[bx+n].push_back(rx);
            }
        }
    }
     
    ll ans=0;
    vector<ll> p(2*n, -1);
    rep(i,n){
        vector<bool> v(2*n, false);
        if(match(i, p, n, v)) ans++;
    }
    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const int N = 1e5 + 18;



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

        int x;
        cin >> x;

        if (x >= 30)cout << "Yes";
        else cout << "No";
        cout << endl;

    }
    return 0;

}



Measured memory_bytes: 3588
#include <assert.h>

#include <iostream>
#include <vector>

using namespace std;
using LL = long long;

vector<int> s[500];

int bs(int n) {
  int l = 1, r = n + 1;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if ((LL)mid * (mid - 1) <= n)
      l = mid;
    else
      r = mid;
  }
  return l;
}

void solve(int n) {
  int k = bs(n + n);
  if ((LL)k * (k - 1) != n + n) {
    cout << "No" << endl;
    return ;
  }
  int cur = 1;
  for (int i = 1; i <= k; ++i) {
    for (int j = i + 1; j <= k; ++j) {
      s[i].push_back(cur);
      s[j].push_back(cur++);
    }
  }
  assert(cur == n + 1);
  cout << "Yes" << endl;
  cout << k << endl;
  for (int i = 1; i <= k; ++i) {
    cout << k - 1 << " ";
    for (int j = 0; j < k - 1; ++j) {
      cout << s[i][j] << (j == k - 2 ? '\n' : ' ');
    }
  }
  return ;
}

int main() {
  int n;
  cin >> n;
  solve(n);
  return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"

int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n>>m;
	ll arr[n+1]={};
	
	for(ll i=0;i<m;i++){
		cin>>x>>y;
		arr[x]++;
		arr[y]++;
	}
	for(ll i=1;i<=n;i++)
		cout<<arr[i]<<nw;

	

}

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

int main() {
	int n;
	cin >> n;
	int a[100];
	for (int i = 0;i < n;i++)cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	int ans, alice = 0, bob = 0;
	for (int i = 0;i < n;i++) {
		if (i % 2 == 0)alice += a[i];
		else bob += a[i];
	}
	ans = alice - bob;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <bitset>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;
const int maxn = 1e5+5;

int n,a[maxn];

void solve(){
	int even = 0;
	int odd = 0;
	for(int i = 1;i <= n;i++){
		if(a[i]&1) odd++;
		else even++;
	}
	if(even) even = 1;
	if(odd&1) odd = 1;
	else{
		if(odd) even++;
		odd = 0;
	}
	//printf("odd = %d even = %d\n",odd,even);
	if(odd == 1 && even == 0){
		puts("YES");
		return;
	}
	if(odd == 0 && even <= 2){
		puts("YES");
		return;
	}
	puts("NO");
}

int main(){
	while(scanf("%d",&n) != EOF){
		for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
		solve();
	}
	return 0;
}

/*w*
【题意】


【类型】


【分析】


【时间复杂度】


【数据】

*/


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>

int main(){
  srand((unsigned int)time(NULL)); 
  int D,M=365*500;
  int c[30];
  int s[370][30];
  int t[370];
  int last[30];
  int ans=0;
  int ans_max=0;
  int old_t,old_d;
  
  scanf("%d",&D);
  for(int i=1;i<=26;i++)
    scanf("%d",c+i);
  for(int i=1;i<=D;i++)
   for(int j=1;j<=26;j++)
     scanf("%d",&s[i][j]);
  
  for(int i=1;i<=D;i++)
    t[i]=rand()%26+1;
  
  ans_max=0;
  for(int k=1;k<=26;k++)
    last[k]=0;
  for(int d=1;d<=D;d++){
    ans_max+=s[d][t[d]];
    last[t[d]]=d;
    for(int j=1;j<=26;j++){
      ans_max-=c[j]*(d-last[j]);
    }
  }
  
  for(int i=1;i<=M;i++){
    ans=0;
    old_d=rand()%D+1;
    old_t=t[old_d];
    t[old_d]=rand()%26+1;
    for(int k=1;k<=26;k++)
      last[k]=0;
    for(int d=1;d<=D;d++){
      ans+=s[d][t[d]];
      last[t[d]]=d;
      for(int j=1;j<=26;j++){
        ans-=c[j]*(d-last[j]);
      }
    }
    if(ans<ans_max){
      t[old_d]=old_t;
    }else{
      ans_max=ans;
    }
  }
  
  for(int i=1;i<=D;i++)
    printf("%d\n",t[i]);
  return 0;
}

Measured memory_bytes: 1780
import java.util.*;

public class Main {
    static int fun(int a){
        int ans=0;
        while(a/10>0){ans++;a=a/10;}
        return ans+1;
    }
    public static void main(String[] args) throws Exception {
        Scanner s=new Scanner(System.in);
        while(s.hasNext()){
            System.out.println(fun(s.nextInt()+s.nextInt()));
        }
        
    }
}


Measured memory_bytes: 26240
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long LL;
const int INF = 1 << 30;
const int MaxN = 1e5;

int a, b, c, d;
int num[105];
int main()
{
	while(scanf("%d %d %d %d", &a, &b, &c, &d) != EOF)
	{
		for(int i = a; i <= b - 1; i++) 
			num[i]++;
		for(int i = c; i <= d - 1; i++)
			num[i]++;
		int ans = 0;
		for(int i = 0; i <= 100; i++)
			if(num[i] == 2)
				ans++;
		printf("%d\n", ans);
		memset(num, 0, sizeof(num));
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a%b){
        cout << a/b*c+c<<endl;
    }
    else
        cout << a/b*c<< endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>

using namespace std;

const int N = 1000;

int w, h, n;
int X1[N], X2[N], Y1[N], Y2[N];

bool fld[N*6][N*6];

int compress(int* x1, int* x2, int w){
  vector<int> xs;
  for(int i=0;i<n;i++){
    for(int d=-1;d<=1;d++){
      int tx1 = x1[i] + d, tx2 = x2[i] + d;
      if(0 <= tx1 && tx1 < w) xs.push_back(tx1);
      if(0 <= tx2 && tx2 < w) xs.push_back(tx2);
    }
  }
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  for(int i=0;i<n;i++){
    x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
    x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
  }
  return xs.size();
}


main(){
  while(cin >> w >> h && (w|h)){
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
      X2[i]--;
      Y2[i]--;
    }

    w = compress(X1, X2, w);
    h = compress(Y1, Y2, h);

    memset(fld, 0, sizeof(fld));
    for(int i=0;i<n;i++){
      for(int y=Y1[i];y<=Y2[i];y++){
        for(int x=X1[i];x<=X2[i];x++){
          fld[y][x] = true;
        }
      }
    }

    int ans = 0;
    for(int y=0;y<h;y++){
      for(int x=0;x<w;x++){
        if(fld[y][x]) continue;
        ans++;
        queue<pair<int, int> > que;
        que.push(make_pair(x, y));
        while(!que.empty()){
          int sx = que.front().first, sy = que.front().second;
          que.pop();
          for(int i=0;i<4;i++){
            static int dx[4] = {0, 1, 0, -1};
            static int dy[4] = {-1, 0, 1, 0};
            int tx = sx + dx[i], ty = sy + dy[i];
            if(tx < 0 || w <= tx || ty < 0 || h <= ty) continue;
            if(fld[ty][tx]) continue;
            que.push(make_pair(tx, ty));
            fld[ty][tx] = true;
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 36412
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
ll a[200050];
char c[200050];
ll u;
ll powmi(ll a,ll n,ll mod)
{
    ll ans=1;
    a%=mod;
    while(n)
    {
        if(n&1)
            ans=(ans*a)%mod;
        a=(a*a)%mod;
        n=n>>1;
    }
    return ans;
}
void chuli(ll k)
{
    u++;
    ll ci=0;
    ll h=k;
    while(h!=0)
    {
        if(h&1)
            ci++;
        h>>=1;
    }
    k=k%ci;
    if(k!=0)
        chuli(k);
}
int main()
{
    ll i,k,n,ci=0;
    ll cs=0,ct=0;
    scanf("%lld",&n);
    scanf("%s",c);
    for(i=n-1;i>=0;i--)
    {
        if(c[n-1-i]=='1')
            a[i]=1;
        else
            a[i]=0;
        if(a[i]==1)
            ci++;
    }

    if(ci==0)
    {
        for(i=n-1;i>=0;i--)
            printf("1\n");
        return 0;
    }

    for(i=n-1;i>=0;i--)
    {
        if(a[i]==1)
        {
            cs=(cs+powmi(2,i,ci+1))%(ci+1);
            if(ci!=1)
            ct=(ct+powmi(2,i,ci-1))%(ci-1);
        }
    }

    for(i=n-1;i>=0;i--)
    {
        u=1;
        if(a[i]==1&&ci==1)
            u=0;
        else if(a[i]==1)
        {
            k=(ct+(ci-1))-powmi(2,i,ci-1);
            k=k%(ci-1);
            if(k!=0)
               chuli(k);
        }
        else
        {
            k=cs+powmi(2,i,ci+1);
            k=k%(ci+1);
            if(k!=0)
               chuli(k);
        }
        printf("%lld\n",u);
    }
    return 0;
}


Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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 D;
vector<int> c(26); 
vector<vector<int>> s(365, vector<int>(26));

int cal_score(vector<int> t){
    int satis = 0;
    vector<int> last(26, 0);
    rep(d, D){
        satis += s[d][t[d] - 1];
        last[t[d] - 1] = d + 1;
        rep(i, 26){
            satis -= c[i] * (d - last[i] + 1);
        }
    }
    return satis;
}

int ch_sch(vector<int> t, int d, int q, int score){
    // change t[d - 1] -> q
    // calculate the score
    int old = t[d - 1];
    score -= s[d - 1][old - 1];
    score += s[d - 1][q - 1];

    int last_old = 0, last_new = 0;
    rep(i, D){
        if(t[i] == old ) last_old = i + 1;
        else if(t[i] == q) last_new = i + 1;
        score += c[old - 1] * (i - last_old + 1);
        score += c[q - 1] * (i - last_new + 1);
    }

    t[d - 1] = q;

    last_old = 0, last_new = 0;
    rep(i, D){
        if(t[i] == old) last_old = i + 1;
        else if(t[i] == q) last_new = i + 1;
        score -= c[old - 1] * (i - last_old + 1);
        score -= c[q - 1] * (i - last_new + 1);
    }
    return score;
}

int main(){
    srand((unsigned)time(NULL));

    // input 
    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D){
        rep(j, 26){
            cin >> s[i][j];
        }
    }

    // greedy
    vector<int> last(26, 0);
    vector<int> res(D);

    rep(d, D){
        int max_plus = -10000;
        int use = -1;
        rep(i, 26){
            int tmp = s[d][i] + c[i] * (d - last[i] + 1);
            if(max_plus < tmp){
                max_plus = tmp;
                use = i;
            }
        }
        last[use] = d + 1;
        res[d] = use + 1;
    }

    int cur_score = cal_score(res);

    while((clock() / (double)CLOCKS_PER_SEC) <= 1.98){
        int ch_d = rand() % D + 1;
        int ch_c = rand() % 26 + 1;
        int ifch = rand() % 100;
        int new_score = ch_sch(res, ch_d, ch_c, cur_score);
        if(cur_score < new_score || ifch < 20){
            cur_score = new_score;
            res[ch_d - 1] = ch_c;
        }
    }

    rep(i, D){
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <cmath>

using namespace std;

bool isPrime(int x)
{
	int i = 3;

	if(x == 2)	return true;

	if( (x < 2) || (x % 2 == 0) ) return false;

	while( i <= (int)sqrt(x) )
	{
		if( (x % i) == 0)
		{
			return false;
		}
		i += 2;
	}

	return true;
}

int main(void)
{
	int n;
	int prime_num = 0;

	cin >> n;
	for(int i = 0; i < n; i++)
	{
		int input_num;

		cin >> input_num;
		if( isPrime(input_num) )  prime_num++;
	}

	cout << prime_num << endl;
	return 0;
}



Measured memory_bytes: 3092
a = int(input())
if a == 2:
    print(2)
    exit()
if a % 2 == 0:
    a += 1
while True:
    count = 0
    for i in range(3,a,2):
        if a % i == 0:
            a += 1
            count += 1
            break
    if count == 0:
        print(a)
        exit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

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

#define S second
#define F first
#define int long long  

///////////// 
	int ans[3001][3001]={};
	pair<int,int> pr[3001][3001]={};
	pair<int,int> pr2[3001][3001]={};

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	string s;
	cin>>s;
	string t;
	cin>>t;
	int n=s.length();
	int m=t.length();
	s=" "+s;
	t=" "+t;
	pair<int,int> fp={-1,-1};
	int fva=0;
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			if(s[i]==t[j])
			{
				ans[i][j]=ans[i-1][j-1]+1;
				pr[i][j]=pr2[i-1][j-1];
				pr2[i][j]={i,j};
				if(ans[i][j]>fva)
				{
					fva=ans[i][j];
					fp={i,j};
				}
			}
			else
			{
				if(ans[i][j-1]>ans[i-1][j])
				{
					ans[i][j]=ans[i][j-1];
					pr[i][j]=pr2[i][j-1];
					pr2[i][j]=pr2[i][j-1];
				}
				else
				{
					ans[i][j]=ans[i-1][j];
					pr[i][j]=pr2[i-1][j];
					pr2[i][j]=pr2[i-1][j];
				}
			}
			// cout<<ans[i][j]<<" ";
		}
		// cout<<"\n";
	}
	string an="";
	while(fp.F>=1)
	{
		an.append(char_to_str(s[fp.F]));
		fp=pr[fp.F][fp.S];
	}
	reverse(an.begin(),an.end());
	cout<<an;
}

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

public class Main {
    void run() {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = scan.nextInt();
        Arrays.sort(a);
        System.out.println(a[n - 1] - a[0]);
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 21972
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, W;
  cin >> N >> W;
  vector<int64_t> total_value(W + 1, 0);
  for (int64_t i = 0; i < N; ++i) {
    int64_t value, weight;
    cin >> value >> weight;
    for (int64_t w = 0; w < W; ++w) {
      const int64_t next_weight = w + weight;
      if (next_weight <= W) {
        total_value[next_weight] = max(total_value[next_weight], total_value[w] + value);
      }
    }
  }
  cout << total_value[W] << endl;
  return 0;
}



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

int main() {
    int A, B, C, X, Y;
    scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
    int64_t ttl = 10000000000000000;
    for(int i=0; i<=2*max(X, Y); i+=2){
        int a=0, b=0, c;
        c=i;
        if(X-c/2>=0) a=X-c/2;
        if(Y-c/2>=0) b=Y-c/2;
        if (ttl > A*a+B*b+C*c)  ttl = A*a+B*b+C*c; 
    }
    cout << ttl << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  double n,t,a;
  cin>>n>>t>>a;
  double min_of = INT_MAX;
  int ans;
  for(double i=0;i<n;i++){
    double x;
    cin>>x;
    if(abs(2*a-(a+(t-(x*0.006))))<min_of){
        ans=i+1;
        min_of=abs(2*a-(a+(t-(x*0.006))));
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define maxn 100001
#define maxa 2000005
#define MOD  998244353 //1000000007
#define INF 1000000000000000000

using namespace std;

#define int int64_t
#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define mem(a, b) memset(a, b, sizeof(a))
#define sort(v) sort(v.begin(), v.end())
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout << setprecision(10) << fixed;
}
ll ceil(ll a, ll b){ return (a+ b-1)/b; }
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
// power and modulo inverse
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}
// factorial
ll fact[maxa], finv[maxa];
void calf(){
    fact[0] = finv[0] = 1;
    for(ll i = 1; i < maxa; i++){fact[i] = (fact[i-1]*i) %MOD;finv[i] = (finv[i-1]*power(i))%MOD;}
}
// nCr
ll ncr(ll N, ll R){ if(R > N) return 0; return (fact[N]*((finv[R]*finv[N-R])%MOD))%MOD;}

ll mn= 1000005,k=0;
bool prime[1000005];
vector<ll>vec;
ll seive(){
    ll i, j;
    memset(prime,  true, sizeof(prime));
    prime[0]= prime[1]= false;
    for(i=2; i*i<=mn;i++){
        if(prime[i]){
            //
            for(j = i*i;j<=mn; j+= i){
                prime[j] = false;
            }
        }
    }
    for(i=0; i<mn;i++){
        if(prime[i]) {vec.push_back(i); }
    }
}



vector<int>v;

int pos(int i,int x){

   int l = -1;int r = v.size();
   int mid;
   while(l+1<r)
   {
        mid = (l+r)/2;
        if(v[i]*v[mid]<x)
          l = mid;
        else
          r =mid;
   }
   return r;

}
int neg(int i,int x)
{
   int l = -1;int r = v.size();
   int mid;
   while(l+1<r)
   {
        mid = (l+r)/2;
        if(v[i]*v[mid]<x)
          r = mid;
        else
          l = mid;
   }
   return v.size()-r;

}
int calculate(int x)
{
      int val = 0; int sum =0;
      for(int  i =0;i<v.size();i++)
      {
          if(v[i]<0)
             val = neg(i,x);
          else
             val = pos(i,x);

          if(v[i]*v[i]<x)
            val--;

          sum+= val;
      }

      return sum/2;
}
signed main(void)
{
  int n,k,a;
   cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a;
    v.push_back(a);
  }

  sort(v);

  int l = -INF; int r = INF;
  int mid;
       while(l+1<r)
       {
            mid = (l+r)/2;

            if(calculate(mid)<k)
              l = mid;
            else
              r = mid;

       }

    cout<<l<<endl;

}


Measured memory_bytes: 2548
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    ll ans=0;
    ll sum=0;
    ll r=0;
    rep(i,n){
        while(r<n&&sum+a[r]==(sum^a[r])){
            sum+=a[r++];
        }
        ans+=r-i;
        sum-=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#ifdef _MSC_VER
#include <conio.h>
#else
#define getch()
#endif

int main(){
	int A=0;
	int B=0;
	int C=0;
	scanf(" %d %d %d",&A,&B,&C);
	if(C>=A&&C<=B){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	getch();
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = input()
B = input()
C = input()

res = 0
for i in range(N):
  ab = (A[i] == B[i])
  bc = (B[i] == C[i])
  ca = (C[i] == A[i])
  s = ab*1 + bc*1 + ca*1

  if (0 == s):
    res += 2
  elif (1 == s):
    res += 1
print(res)


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

int n,m,cnt;

vector<int>a[1000];

int main() {
	scanf("%d",&n);
	
	for(int i=1;i*(i-1)<=2*n;i++) if(i*(i-1)==n*2) m=i;
	
	if(!m) {
		puts("No");return 0;
	}
	
	puts("Yes");printf("%d\n",m);
	
	for(int i=1;i<=m;i++) for(int j=i+1;j<=m;j++) cnt++,a[i].pb(cnt),a[j].pb(cnt);
	
	for(int i=1;i<=m;i++) {
		printf("%d ",a[i].size());
		for(int j=0;j<a[i].size();j++) printf("%d ",a[i][j]);puts("");
	}
	
	return 0;
}

Measured memory_bytes: 2304
n = gets.to_i
orders = gets.split.map(&:to_i)
satisfactions = gets.split.map(&:to_i)
additions = gets.split.map(&:to_i)
previous = -1
sum = 0
orders.each do |order|
  sum += satisfactions[order - 1]
  sum += additions[order - 2] if previous + 1 == order
  previous = order
end
puts sum


Measured memory_bytes: 1788
a,b,c = gets.split.map(&:to_f)

rad =  c * Math::PI/ 180.0
s = a*b/2.0*Math.sin(rad)
puts s
l = a+b+Math.sqrt(a*a+b*b-2*a*b*Math.cos(rad))
puts l
h = b*Math.sin(rad)
puts h

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

typedef long long ll;
const int MOD = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  for(int i = 0; i < N; i++){
    cin >> P[i];
  }
  for(int i = 0; i < N; i++){
    cin >> Q[i];
  }
  vector<int> v(N);
  for(int i = 0; i < N; i++){
    v[i] = i + 1;
  }
  map<vector<int>, int> ord;
  int iter = 0;
  do{
    ord[v] = iter++;
  }while(next_permutation(v.begin(), v.end()));
  cout << abs(ord[P] - ord[Q]) << endl;
}


Measured memory_bytes: 5248
#include <iostream>
using namespace std;
int a[30][30];
int like_cnt[31];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> a[i][j];
      like_cnt[a[i][j]]++;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    if (like_cnt[i]==n) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    vi vec(3);
    rep(i, 3) std::cin >> vec[i];
    sort(rng(vec));
    int ans = vec[2] - vec[1];
    ans += ((vec[2]-(vec[0]+ans))&1) + ((vec[2]-(vec[0]+ans))+1)/2;
    std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define inf (int)(3e18)
#define all(v) v.begin(),v.end()
#define mod (int)(1e9+7)

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}


signed main() {
	int x;cin>>x;
	int ans=x/500*1000;
	x%=500;
	ans+=x/5*5;
	cout<<ans<<endl;
}



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

int n, k;
vector<int> et[100000];
int inCnt[100000];

int main() {
	int i;
	
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		int a;
		cin >> a; a--;
		if (a >= 0) {
			et[i].push_back(a);
			inCnt[a]++;
		}
	}
	
	static int minDist[100000];
	queue<int> que;
	for (i = 0; i < n; i++) {
		minDist[i] = 11451419;
		if (et[i].size() == 0 || inCnt[i] == 0) {
			que.push(i);
			minDist[i] = 0;
		}
	}
	
	while (!que.empty()) {
		int v = que.front(); que.pop();
		for (i = 0; i < et[v].size(); i++) {
			if (minDist[et[v][i]] > minDist[v] + 1) {
				minDist[et[v][i]] = minDist[v] + 1;
				que.push(et[v][i]);
			}
		}
	}
	
	int ans = 0;
	for (i = 0; i < n; i++) {
		if (minDist[i] < k) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9520
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int i,x,n;
	x=0;
	string s;
	cin>>n;
	cin>>s;
	n=s.length();
	int arr[n];
	for(i=0;i<n;i++)
	{
		if(s.at(i)=='I')
		{
			x=x+1;
		}
		else 
		{
		x=x-1;
	    }
		arr[i]=x;
	}
	for(i=0;i<n;i++)
	{
		if(arr[0]<arr[i])
		arr[0]=arr[i];
	}
	if(arr[0]>0)
	cout<<arr[0];
	else 
	cout<<0;
}
	

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

#define MAX 244140625

int Hash[MAX];
char str[13];

int getChar(char ch){
	if(ch == 'A') return 1;
	else if(ch == 'C') return 2;
	else if(ch == 'G') return 3;
	return 4;
};
int getKey(){
	int sum = 0, p = 1;
	for (int ix = 0 ; ix < strlen(str) ; ix++){
		sum += p*( getChar(str[ix]) );
		p *= 5;
	}
	return sum;
};
int find(){
	int key = getKey();
	if (Hash[key])
		return 1;
	return 0;
};
void insert(){
	Hash[getKey()] = 1;
};

int main(){
	int n;
	char com[7];
	scanf("%d\n",&n);
	while (n--){
		scanf("%s %s",com,str);
		if (com[0] == 'i') insert();
		else{
			if (find()) printf("yes\n");
			else printf("no\n");
		}
    }
	return 0;
}


Measured memory_bytes: 18680
N = int(input())
P = [float(p) for p in input().split()]

DP = [[0 for n in range(N+1)] for _ in range(N)]
DP[0][0] = 1-P[0]
DP[0][1] = P[0]

for i in range(1, N):
    use = P[i]
    DP[i][0] = DP[i-1][0] * (1-use)
    for j in range(1, i+2):
        DP[i][j] = DP[i-1][j] * (1-use) + DP[i-1][j-1] * use

print(sum(DP[N-1][N//2+1:]))



Measured memory_bytes: 263560
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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(){
  ll n;
  cin >> n;
  vi a(n);
  double b = 0;
  rep(i, n){
    cin >> a[i];
    b += (double)1 / (double)a[i];
  }
  cout << setprecision(10) << (double)1/b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int n,m,i,c[100005],a,b,v,k,t[100005];
set<int> g[100005];
vector<int>first_half;
vector<int>second_half;
vector<int>total;
int par[209],group[209];
int arra[150000];
vector<int>arr;
map<char,int>cp;
map<int,int>mp;
deque<char>stp1;
deque<char>stp2;
map<int,int>pos;
map<string,int>check;
map<string,string>server;
vector<string>ans1;
vector<string>ans2;
vector<string>ans3;
string server1[1009];
string ip1[1009];
string server2[1009];
string ip2[1009];
ll cashier[109];
ll fir[109];
ll sec[100009];
int main()
{
  	
  ll a,b,c=1,d,e,f,g,h,i,j,k,l,n,s1=1,s2=1,m1=5,m2=15,t,m;
  //cin>>t;
  
  cin>>n;
  for(i=1;i<n;i++)
  {
    cin>>a;
    mp[a]++;	
  }
  for(i=1;i<=n;i++)
    cout<<mp[i]<<'\n';
  
       
  
 
    	
  }
  
  
  
  	

Measured memory_bytes: 17808
import java.awt.*;
import java.io.*;
import java.util.*;

public class Main {
    static int qd[][];
    static int q;
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        n=sc.nextInt();m=sc.nextInt();q=sc.nextInt();
        a=new int[n];
        qd=new int[q][4];
        for (int i=0;i<q;i++){
            for (int j=0;j<4;j++){
                qd[i][j]=sc.nextInt();
            }
            qd[i][0]--;
            qd[i][1]--;
        }
        per(0,1);
        System.out.println(ans);
    }
    static int sum(){
        int sum=0;
        for (int i=0;i<q;i++){
            if (qd[i][0]<n && qd[i][1]<n && a[qd[i][1]]-a[qd[i][0]]==qd[i][2]){
                sum+=qd[i][3];
            }
        }
        return sum;
    }
    static int a[];
    static int m;
    static int n;
    static int ans=0;
    static void per(int i,int k) {
        if (i==n){
            ans=Math.max(ans,sum());
            return;
        }
        for (int j=k;j<=m;j++){
            a[i]=j;
            per(i+1,j);
        }
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 26572
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
using namespace std;
class Integer {
	int value;
public:
	Integer() : value(0) {}
	Integer(int x) : value(x) {}
	operator int() const {return value;}
};
const int dx[] = {1, 0, -1, -1, 0, 1};
const int dy[] = {0, -1, -1, 0, 1, 1};

int main () {
	int t, n;
	while (cin >> t >> n, t || n) {
		map<int, map<int, Integer> > blocks;
		map<int, map<int, Integer> > visited;
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			blocks[x][y] = 1;
		}
		int count = 0;
		queue<pair<int, pair<int, int> > > que;
		pair<int, int> pos;
		cin >> pos.first >> pos.second;
		que.push(make_pair(0, pos));
		while (!que.empty()) {
			pair<int, pair<int, int> > current = que.front();
			const int s = current.first;
			const int x = current.second.first;
			const int y = current.second.second;
			que.pop();
			if (visited[x][y]) continue;
			visited[x][y] = 1;
			count++;
			if (s == t) continue;
			for (int i = 0; i < 6; i++) {
				const int nx = x + dx[i];
				const int ny = y + dy[i];
				if (!blocks[nx][ny]) {
					que.push(make_pair(s + 1, make_pair(nx, ny)));
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll H, W, N;
    cin >> H >> W >> N;
    ll h, w;
    cin >> h >> w; // 1 - H, 1 - W
    string S, T;
    cin >> S >> T;
    
    // 上下 U, D
    ll lp = 1, gp = H;
    repr(i,N){
        if (T[i] == 'D')
            lp = max(1ll, lp - 1);
        else if(T[i]=='U')
            gp = min(H, gp + 1);
        
        if(S[i]=='U')
            lp++;
        else if(S[i]=='D')
            gp--;
        
        if(gp<lp){
            cout << "NO" << endl;
            return 0;
        }
    }
    if(h<lp or gp < h){
        cout << "NO" << endl;
        return 0;
    }
    
    // 左右
    lp = 1, gp = W;
    repr(i,N){
        if(T[i]=='R')
            lp = max(1ll, lp - 1);
        else if(T[i]=='L')
            gp = min(W,gp+1);
        
        if(S[i]=='L')
            lp++;
        else if (S[i]=='R')
            gp--;
        if(gp<lp){
            cout << "NO" << endl;
            return 0;
        }
    }
    if(w<lp or gp<w){
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 4016
n, y = map(int, input().split())

ok = False
for i in range(n + 1):
    for j in range(n - i + 1):
        s = 10000 * i + 5000 * j + 1000 * (n - i - j)
        if y == s:
            res = ' '.join(map(str, [i, j, n - i - j]))
            ok = True
            break
    if ok:
        break
if ok:
    print(res)
else:
    print('-1 -1 -1')

Measured memory_bytes: 40812
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin >> s;
	int n = s.size(), ans = 0;
	for(int i = 1; i < n; ++i) {
		if(s[i] != s[i - 1]) {
			++ans;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 512
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int> > A(H, vector<int>(W));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> A[i][j];
		}
	}
	int ans = 1000000000;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int sum = 0;
			for (int k = 0; k < H; ++k) {
				for (int l = 0; l < W; ++l) {
					sum += min(abs(k - i), abs(l - j)) * A[k][l];
				}
			}
			ans = min(ans, sum);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int i,j,k,n,m,l,count1=0;
void ABC140(void);
void ABC141(void);
void ABC142(void);
void ABC143(void);
void ABC144(void);
void ABC145(void);
void ABC146(void);
void ABC147(void);
void ABC148(void);
void ABC149(void);

int main(void){
    ABC144();
}

void ABC144(){
    int ans=0;
    cin>>n;
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            if(i*j==n)ans=1;
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256