akhauriyash/Code-Regression huggingface dataset:
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int a; string s;
  cin >> a >> s;

  if(a >= 3200) cout << s << endl;
  else cout << "red" << endl;

  return 0;
}

Measured memory_bytes: 256
def solve():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        x = A[i] + A[i + 1]
        ans += min(B[i], x)
        A[i + 1] = min(A[i + 1], max(x - B[i], 0))
    print(ans)


solve()


Measured memory_bytes: 24092
#include<stdio.h>
#include<math.h>
long long int keta(long long int n){
  long long int i=0;
  while(n){
    n/=10;
    i++;
  }
  return i-1;
}
long long int root(long long int n){
  long long int i=1,j,s;
  /*j=keta(n)-1;
  j/=2;
  while(j){
    i*=10;
  }*/
  while(i*i<n){
    s=++i;
  }
//  printf("%lld",s);
  return s;
}
int main(void){
  long long int n,i,c=1,d=1;
//  double a;
  scanf("%lld",&n);
  //a=(double)n;
  //a=sqrt(a);
  for(i=root(n);i>=2;i--){
    if(n%i==0){
      c=i;
      break;
    }
  }
  d=n/c;
  printf("%lld\n",d+c-2);
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int t = 0, ans = 0;
  for(int i = 0; i < (int)s.length(); ++i){
    if(s[i] == 'R') ++t;
    else --t;
    if(t == 4) ++ans, t = 0;
    if(t == -4) t = 0;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a;
    cin >> a;
    if(a < 1200) puts("ABC");
    else if(a < 2800) puts("ARC");
    else puts("AGC");
    return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
	//freopen("t.txt","r",stdin);
	int n,k;
	string s;
	cin>>n>>k>>s;
	s[k-1] = s[k-1]-'A'+'a';
	cout<<s;
	
}

Measured memory_bytes: 256
import sys

# sys.stdin = open('b1.in')
from collections import Counter

n, m = map(int, input().split())

res = Counter()
for i in range(m):
    a, b = map(int, input().split())
    res[b] += 1
    res[a] += 1
for i in range(1, n + 1):
    print(res[i])


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		int A = io.nextInt();
		int B = io.nextInt();
		int C = io.nextInt();
		
		System.out.println((C>=A&&C<=B)?"Yes":"No");
		
	}
}

Measured memory_bytes: 21972
#include <stdio.h>

int main(){
int X=0;
  scanf("%d",&X);
  if(((X/3==1)&&(X%3==0))||((X/5==1)&&(X%5==0))||((X/7==1)&&(X%7==0))){
  printf("YES");
  }else {
  printf("NO");
  }
  
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        long K = sc.nextInt();
        long ans = 1;
      
      if(N<=1){System.out.print(K);}
      else{
        for(int i = 0; i<N-1 ;i++){
        ans *=K-1;  
        }
        System.out.print(K*ans);
      }

      
    }
}

Measured memory_bytes: 21588
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		ArrayList<String> list = new ArrayList<String>();
		String pre = "";
		String result = "Yes";
	    for(int i = 0; i < n; i++){
	        String now = sc.next();
	        if(i > 0){
	            if(list.contains(now)) result = "No";
	            if(pre.charAt(pre.length()-1) != now.charAt(0)) result = "No";
	        }
	        list.add(now);
	        pre = now;
	    }
		
		// 計算
		
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 21844
fn main() {
    let nk: Vec<u32> = read_vec();
    let (n, k) = (nk[0], nk[1]);
    
    let ans = n % k;
    println!("{}", ans);
}


// ########################################################################################### //

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0;
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

#define MAX 100
#define NIL -1 

struct Node{int p,l,r;};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int i,int d){
  if(i==NIL) return;
  D[i]=d;
  setDepth(T[i].l,d+1);
  setDepth(T[i].r,d+1);
}

int setHeight(int i){
  int h1=0,h2=0;
  if(T[i].l!=NIL) h1=setHeight(T[i].l)+1;
  if(T[i].r!=NIL) h2=setHeight(T[i].r)+1;
  return H[i]=(h1>h2 ? h1 : h2);
}

int getSibling(int i){
  if(T[i].p==NIL) return NIL;
  if(T[T[i].p].l!=i && T[T[i].p].l!=NIL)
    return T[T[i].p].l;
  if(T[T[i].p].r!=i && T[T[i].p].r!=NIL)
    return T[T[i].p].r;
  return NIL;
}

void print(int i){
  cout<<"node "<<i<<": parent = ";
  cout<<T[i].p<<", sibling = ";
  cout<<getSibling(i)<<", degree = ";
  if(T[i].l!=NIL && T[i].r!=NIL) cout<<2;
  else if(T[i].l==NIL && T[i].r==NIL) cout<<0;
  else cout<<1;
  cout<<", depth = ";
  cout<<D[i]<<", height = ";
  cout<<H[i]<<", ";
  if(D[i]==0) cout<<"root"<<endl;
  else if(H[i]==0) cout<<"leaf"<<endl;
  else cout<<"internal node"<<endl;
}
  
int main() {
  int a,b,c,r;
  cin>>n;
  
  rep(i,n) T[i].p=NIL;
  
  rep(i,n){
    cin>>a>>b>>c;
    T[a].l=b;
    T[a].r=c;
    if(b!=NIL) T[b].p=a;
    if(c!=NIL) T[c].p=a;
  }
  
  rep(i,n) if(T[i].p==NIL) r=i;
  
  setDepth(r,0);
  setHeight(r);
  
  rep(i,n) print(i);
    
  return 0;
}


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

int main(void){
  string s; cin >> s;
  vector<int> vec;
  vec.push_back(-1);
  for(int i = 1; i < s.size(); i++){
    if(s[i-1] == 'R' && s[i] == 'L'){
      vec.push_back(i-1);
    }
    else if(s[i-1] == 'L' && s[i] == 'R'){
      vec.push_back(i-1);
    }
  }
  vec.push_back(s.size()-1);
  int via[s.size()];
  vector<int> ans(s.size(),0);
  for(int i = 0; i < vec.size();i++){
    if(i % 2 == 1){
      via[vec[i]] = vec[i] - vec[i-1];
      via[vec[i]+1] = vec[i+1] -vec[i];
      if(via[vec[i]] % 2 == 1){
        ans[vec[i]] += via[vec[i]]/2+1;
        ans[vec[i]+1] += via[vec[i]]/2;
      }
      else if(via[vec[i]] % 2 == 0){
        ans[vec[i]] += via[vec[i]]/2;
        ans[vec[i]+1] += via[vec[i]]/2;
      }
      if(via[vec[i]+1] % 2 == 1){
        ans[vec[i]+1] +=via[vec[i]+1]/2+1;
        ans[vec[i]] += via[vec[i]+1]/2;
      }
      else if(via[vec[i]+1] % 2 == 0){
        ans[vec[i]+1] +=via[vec[i]+1]/2;
        ans[vec[i]] += via[vec[i]+1]/2;
      }
    }
  }
  rep(i,s.size()) cout << ans[i] << " ";
  cout << endl;
  return 0;
}


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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   100005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/









int main()
{
    ll n,i,x,y;
    ll a[N],dp[N];
    cin>>n;
    for1(i,n)
        cin>>a[i];
    a[0]=0,dp[1]=0,dp[2]=abs(a[2]-a[1]);
    for(i=3;i<=n;i++)
    {
        x=abs(a[i]-a[i-2]);
        y=abs(a[i]-a[i-1]);
        dp[i]=min(x+dp[i-2],y+dp[i-1]);
        //cout<<dp[i]<<endl;
    }
    cout<<dp[n]<<endl;
	return 0;
}

































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

using namespace std;

struct Point {
    double x, y;

    Point(double x = 0, double y = 0) : x(x), y(y) {}
};

typedef Point Vector;

Vector operator-(Point A, Point B) {
    return Vector(A.x + B.x, A.y + B.y);
}

Vector operator+(Vector A, Vector B) {
    return Vector(A.x + B.x, A.y + B.y);
}

Vector operator*(Vector A, double p) {
    return Vector(A.x * p, A.y * p);
}

Vector operator/(Vector A, double p) {
    return Vector(A.x / p, A.y / p);
}




const double eps = 1e-7;

int dcmp(double x) {
    if (fabs(x) < eps) return 0;
    else
        return x < 0 ? -1 : 1;
}

bool operator<(const Point &a, const Point &b) {
    return a.x < b.x || (a.x == b.x && a.y < b.y);
}

bool operator==(const Point &a, const Point &b) {
    return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0;
}

struct Circle {
    Point c;
    double r;

    Circle() {};

    Circle(Point c, double r) : c(c), r(r) {}

    Point point(double a) {
        return Point(c.x + cos(a) * r, c.y + sin(a) * r);
    }
} cir[100];

Point a[100];
double c[100];

int n, k;

double dis(Point a, Point b) {
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

vector<pair<double, double> > cal(double x1, double y1, double r1, double x2, double y2, double r2) {//两圆交点
    x1 -= x2, y1 -= y2;
    double S = x1 * x1 + y1 * y1, a = (S + r2 * r2 - r1 * r1) / 2, D = S * r2 * r2 - a * a;
    if (D < 0) return {};
    double A1 = a * x1, B1 = y1 * sqrt(D);
    double A2 = a * y1, B2 = x1 * sqrt(D);
    return {{(A1 + B1) / S + x2, (A2 - B2) / S + y2},
            {(A1 - B1) / S + x2, (A2 + B2) / S + y2}};
}

bool check(double t) {
    for (int i = 1; i <= n; i++) {
        cir[i].c = a[i];
        cir[i].r = t / c[i];
    }
    vector<Point> p;
    for (int i = 1; i <= n; i++) {
        p.emplace_back(a[i]);
        for (int j = 1; j < i; j++) {
            // getCircleCircleIntersection(cir[i], cir[j], p);
            auto it = cal(cir[i].c.x, cir[i].c.y, cir[i].r, cir[j].c.x, cir[j].c.y, cir[j].r);
            for (auto v:it)
                p.emplace_back(Point(v.first, v.second));
        }
    }

    for (Point v:p) {
        int cnt = 0;
        for (int i = 1; i <= n; i++) {
            if (cir[i].r + eps >= dis(v, cir[i].c)) cnt++;
        }
        if (cnt >= k) return true;
    }
    return false;
}

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%lf %lf %lf", &a[i].x, &a[i].y, &c[i]);
    }

    double l = 0, r = 1e9;
    while (r - l > eps) {
        double mid = (r + l) / 2;
        if (check(mid)) r = mid;
        else l = mid;
    }
    printf("%.6f\n", l);
    return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 1000000007;
const int MX = 100010;
const int MN = 210;

ll powmod(ll x, ll k) {
	ll res = 1;
	for (; k; x = x * x % MOD, k /= 2) {
		if (k & 1) {
			res = res * x % MOD;
		}
	}
	return res;
}

int N, X;
ll dp[MX];
int S[MN];
ll inv[MN];

int main() {
	cin >> N >> X;
	rep(i, N) cin >> S[i];

	for (int i = 1; i <= N; ++i) {
		inv[i] = powmod(i, MOD - 2);
	}

	sort(S, S + N);
	dp[X] = 1;

	for (int i = X; i >= 0; --i) if (dp[i] > 0) {
		bool f = 0;

		rep(j, N) {
			if (S[j] <= i) {
				f = 1;
				int nx = i % S[j];
				int num = upper_bound(S, S + N, i) - S;
				//cerr << i << " " << S[j] << " " << num << " " << nx << endl; 
				ll add = dp[i] * inv[num] % MOD;
				dp[nx] = (dp[nx] + add) % MOD;
			}
		}
		if (f) {
			dp[i] = 0;
		}
	}

	ll f = 1;
	for (int i = 1; i <= N; ++i) {
		f = f * i % MOD;
	}

	ll ans = 0;
	rep(i, X + 1) {
		ans += dp[i] * i;
		ans %= MOD;
	}
	ans = ans * f % MOD;

	cout << ans << endl;

	return 0;
}

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

using namespace std;

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

typedef long long ll;
ll mod=998244353;

int main()
{
	string s;
	cin >> s;
	int k=s.size();
	int ans=15-k;
	rep(i, k)
	{
		if(s[i]=='o') ans++;
	}
	if(ans>=8) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for (int i = 0; i < n - 2; ++i) {
        if (s.substr(i, 3) == "ABC") ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for(int z = 0; z < t; z++)
		{
			int n = sc.nextInt();
			int k = sc.nextInt();
			int house[] = new int[n];
			int length[] = new int[n-1];
			int ret;
			for(int i = 0; i < n; i++)
			{
				house[i] = sc.nextInt();
			}
			for(int i = 0;i < n-1; i++)
			{
				length[i] = house[i+1] - house[i];
			}
			ret = house[n-1] - house[0];
			Arrays.sort(length);
			for(int i = 0; i < k -1 ; i++)
			{
				if(n - 2 - i < 0) 
				{
					ret = 0;
					break;
				}
				ret -= length[n - 2 - i];
			}
			System.out.println(ret);
		}
	}
}

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

using namespace std;

#define FOR(i,l,r) for (int i=(l); i<(r); ++i)
#define sz(x) (int)(x).size()
#define dbg(x) cout << (#x) << ' ' << (x) << endl
#define memfill(x, a) memset((x), (a), sizeof(x))
#define all(x) (x).begin(), (x).end()

typedef string str;
typedef long long int64;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const int64 LLINF = 1LL << 60LL;

/*-------- END OF TEMPLATE --------*/

int N, A;
vector<int> arr(1e6, 0);

int main() {
    scanf("%i",&N);
    for (int i = 0; i < N-1; i++) {
        scanf("%i",&A);
        arr[A]++;
    }
    for (int i = 1; i <= N; i++) {
        printf("%i\n",arr[i]);
    }
}


Measured memory_bytes: 7008
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	double N, M; cin >> N >> M;
	cout << ((N - M) * 100.0 + M * 1900.0) / pow(0.5, M) << endl;
}

Measured memory_bytes: 4272
package main

/*
N A B
*/
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	line := strings.Split(stdin.Text(), " ")
	n, _ := strconv.Atoi(line[0])
	k, _ := strconv.Atoi(line[1])

	if n%k == 0 {
		fmt.Println(0)
	}
	if n%k != 0 {
		fmt.Println(1)
	}
}


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

int main(void){
	int m;
	int i, j;
	int pos;
	int ct1 = 0;
	int ct2 = 0;
	int ct3 = 0;
	int ct4 = 0;
	int ct5 = 0;
	int flag = 0;
	char ch[40][11] = {{'\0'}};
	
	while(1){
		scanf("%d", &m);
		if ( m == 0 ) {
			break;
		}
		for ( i = 0; i < m; i++ ) {
			scanf("%s", ch[i]);
		}
	
		for ( i = 0; i < m; i++ ) {
			pos = i;
			ct1 = strlen(ch[i]);;
			ct2 = 0;
			ct3 = 0;
			ct4 = 0;
			ct5 = 0;
			flag = 0;
			for ( j = i + 1; j < m; j++ ) {
				if ( ct1 < 5 ) {
					ct1 += strlen(ch[j]);
				} else if ( ct2 < 7 ) {
					ct2 += strlen(ch[j]);
				} else if ( ct3 < 5 ) {
					ct3 += strlen(ch[j]);
				} else if ( ct4 < 7 ) {
					ct4 += strlen(ch[j]);
				} else if ( ct5 < 7 ) {
					ct5 += strlen(ch[j]);
				}
				if ( ct1 == 5 && ct2 == 7 && ct3 == 5 && ct4 == 7 && ct5 == 7 ) {
					flag = 1;
					break;
				} else if ( ct1 > 5 || ct2 > 7 || ct3 > 5 || ct4 > 7 || ct5 > 7 ) {
					break;
				}
			}
			if ( flag ) {
				break;
			}
		}
		printf("%d\n", pos+1);
	}
	return 0;
}


Measured memory_bytes: 2100
N,M,X,Y = gets.chomp.split(" ").map(&:to_i)

x = gets.chomp.split(" ").map(&:to_i)
y = gets.chomp.split(" ").map(&:to_i)

ok = false


(X+1..Y).each do |num|
  if x.select{|n| n < num}.length == x.length && y.select{|n| n >= num}.length == y.length
    ok = true
  end
end


if ok
  puts "No War"
else
  puts "War"
end


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

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

  string S;
  cin >> S;

  char a = S.at(K-1);

  if(a == 'A')
    S.at(K-1) = 'a';
  else if(a == 'B')
    S.at(K-1) = 'b';
  else
    S.at(K-1) = 'c';
  
  cout << S << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	N := ReadInt()
	A := ReadInts(N)
	max := 1
	ans := A[0] - 1
	for i := 1; i < N; i++ {
		if A[i] > max+1 {
			if A[i]%(max+1) == 0 {
				ans += A[i]/(max+1) - 1
			} else {
				ans += A[i] / (max + 1)
			}
		} else {
			max = Max(max, A[i])
		}
	}
	fmt.Println(ans)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4364
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    ll a, b; cin >> a >> b;
    b++;
    vector<ll> aa(40,0);
    vector<ll> ab(40,0);
    ll c = 1LL;
    rep(i,40){
        ll da = a / (c*2LL);
        ll ma = a % (c*2LL);
        aa[i] = c * da + max(0LL,ma-c);
        ll db = b / (c*2LL);
        ll mb = b % (c*2LL);
        ab[i] = c * db + max(0LL,mb-c);
        c *= 2LL;
    }
    ll p = 1LL;
    ll ans = 0LL;
    rep(i,40){
        if ((ab[i] - aa[i]) % 2 == 1) ans += p;
        p *= 2LL;
    }
    //printvec(aa); printvec(ab);
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
	vector<int> a(3);
	r(i,3)cin>>a[i];
	int ans=1e17;
	sort(a.begin(),a.end());
	do{
		ans=min(ans,abs(a[1]-a[0])+abs(a[2]-a[1]));
	}while(next_permutation(a.begin(),a.end()));
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
ll k (ll a){
    a--;
    ll ans =0;
    while(a != 0){
        ans += a;
        a--;
        
    }
    return ans;
}


//global val ^^

int main(){
   int a,b,cnt = 1;
   cin >> a  >>b;
    if(b == 1){
        cout << 0 <<endl;
        return 0;
    }
    int ans = a;

    while(ans < b){
        cnt ++;
        ans --;
        ans += a;
    }
    cout << cnt <<endl;
}






Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        String result = "";
        String alp = "abcdefghijklmnopqrstuvwxyz";


        while (true) {
            long syou = num / alp.length();
            long mod = num % alp.length();
            
            String tmp = alp.substring((int)mod, (int)mod + 1);

            result = tmp + result;

            num = syou - 1;
            if (syou == 0) {
                break;
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 39380
N, T = map(int, input().split())
c = []
t = []
for i in range(N):
    c_i, t_i = map(int, input().split())
    c.append(c_i)
    t.append(t_i)
indx =  [i for i, x in enumerate(t) if x <= T]
if len(indx)==0:
    print('TLE')
else:
    c_pass = []
    for i in range(len(indx)):
        c_pass.append(c[indx[i]])
    print(min(c_pass))


Measured memory_bytes: 3060
def main():
    _ = int(input())
    a = [int(s) for s in input().split()]
    print(*solve(a))

def solve(a):
    if len(a) % 2 == 0:
        return a[-1::-2] + a[0::2]
    else:
        return a[-1::-2] + a[1::2]

main()


Measured memory_bytes: 26020
#include<stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p, int r){
    int x,i,j,t;
    x=A[r];
    i=p-1;
    for(j=p; j<r; j++){
        if(A[j]<=x){
            i++;
            t=A[i]; A[i]=A[j]; A[j]=t;
        }
    }
    t=A[i+1]; A[i+1]=A[r]; A[r]=t;
    return i+1;
}

int main(){
    int i,q;
    
    scanf("%d",&n );
    for(i=0; i<n; i++) scanf("%d",&A[i]);
    
    q=partition(0,n-1);
    for(i=0; i<n; i++){
        if(i) printf(" ");
        if(i==q)printf("[");
        printf("%d",A[i]);
        if(i==q)printf("]");
    }
    printf("\n");
    
    return 0;
        
}


Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int N = 0;
        int M = 0;
        int mod = 1000000007;
        int[] StarNum = null;
        try (Scanner sc = new Scanner(System.in)) {
            N = (sc.nextInt()) +1;
            M = sc.nextInt();
            //0でオール初期化
            StarNum = new int[N];
            for (int i = 0; i < M; i++) {
                //壊れている段数は
                int m = sc.nextInt();
                //-1で初期化
                StarNum[m] = -1;
            }
        }
        for (int i = 0; i < N; i++) {
            if (StarNum[i] == -1 && StarNum[i + 1] == -1) {
                //連続して壊れていたら解なし
                System.out.println(0);
                return;
            }
        }
        //0段目と1段目を初期化
        StarNum[0] = 1;
        if (StarNum[1] != -1) {
            StarNum[1] = 1;
        }
        //N段目の組み合わせを計算する
        for (int i = 2; i < N; i++) {
            if (StarNum[i] == -1) {
                //壊れているなら計算しない
                continue;
            }
            //1段前の組み合わせの数
            int a = 0;
            //2段前の組み合わせの数1
            int b = 0;
            if (StarNum[i - 1] != -1) {
                a = StarNum[i - 1];
            }
            if (StarNum[i - 2] != -1) {
                b = StarNum[i - 2];
            }
            //足し合わせた数がその段までに幾組み合わせの数
            //とりあえず1000000007こいつで割ったあまりを使用する
            StarNum[i] = (a + b) % mod;
        }
        //最後にN段目の数を出して終了
        System.out.println(StarNum[N-1]);

    }

}


Measured memory_bytes: 48480
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
 
 
def main():
    X, Y = map(int, input().split())
 
    if (X + Y) % 3 or X > Y*2 or Y > X*2:
        return 0
 
    n = (X + Y) // 3
    r = Y - n
    return(combination(n, r))
 
 
print(main())


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

class SegTreeSum {
public:
    int n;
    vector< int > node;

    SegTreeSum(vector< int > v) {
        int sz = v.size();
        n = 1;
        while( n < sz ) n <<= 1;
        node.resize(2 * n - 1, INF);

        for( int i = 0; i < sz; ++i ) {
                node[i + n - 1] = v[i];

        }
        for( int i = n - 2; i >= 0; --i ) {
            node[i] = node[2 * i + 1] + node[2 * i + 2];

        }
    }

    void Update(int x, int val) {
        x += n - 1;
        node[x] += val;
        while( x > 0 ) {
            x = (x - 1) >> 1;
            node[x] = node[2 * x + 1] + node[2 * x + 2];

        }
    }

    int Query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if( r < 0 ) {
            r = n;

        }

        if( r <= a || b <= l ) {
            return 0;

        }
        if( a <= l && r <= b ) {
            return node[k];

        }

        int vl = Query(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = Query(a, b, 2 * k + 2, (l + r) / 2, r);
        return vl + vr;

    }

};

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

    int n, q;
    cin >> n >> q;
    vector< int > v(n);
    for( int i = 0; i < n; ++i ) {
        v[i] = 0;

    }

    SegTreeSum seg(v);

    while( q-- ) {
        int com, x, y;
        cin >> com >> x >> y;

        if( com == 0 ) {
            --x;
            seg.Update(x, y);

        } else {
            --x; --y;
            cout << seg.Query(x, y + 1) << endl;

        }
    }
    return 0;
}




Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin >> s >> t;
    int s_count[26] = {},t_count[26] = {};
    for(int i = 0;i < s.size();i++)
    {
        s_count[s[i] - 'a']++;
        t_count[t[i] - 'a']++;
    }
    sort(s_count,s_count + 26);
    sort(t_count, t_count + 26);
    for(int i = 0;i < 26;i++)
    {
        if(s_count[i] != t_count[i])
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
 
    return 0;
}

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

int main()
{
	ll x;
	cin>>x;
	ll n=100;
	ll i=0;
	while(x>n)
	{
		n*=1.01;
		i++;
	}
	cout<<i;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,m,i,p=0,ans=10000;
	scanf("%lld %lld",&n,&m);
	int b,k,q;
	q=n/0.08;
	k=m/0.1;
	for(i=0;i<=100000;i++)
	{
		if(int(i*0.08)==n&&int(i*0.1)==m)
		{
			p=1;
			break;
		}
	}
	if(p)
	printf("%lld",i);
	else
	printf("-1");
}

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

string getNext(char before, char current, char say)
{
    bool flag = say == 'o';
    flag = before == 'S' ? flag : !flag;
    flag = current == 'S' ? flag : !flag;
    return flag ? "S" : "W";
}

int main()
{
    int N;
    string s;
    bool flag = false;
    
    cin >> N >> s;
    string start = "SSWWS";
    
    for (int i = 0; i < 4; i++)
    {
        string ans = start.substr(i,2);
        for (int j = 1; j < N; j++)
        {
            ans = ans + getNext(ans[j-1], ans[j], s[j]);
        }
        if (ans.front() == ans.back())
        {
            if (getNext(ans[ans.size() - 2], ans[0], s[0]) == ans.substr(1, 1))
            {
                cout << ans.substr(0, ans.size() - 1) << endl;
                flag = true;
                break;
            }
        }
    }

    if (!flag)
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 716
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  int r,d,x;
  cin>>r>>d>>x;
  int a[15];
  
  a[0]=r*x-d;
  for(int i=1; i<10; i++){
    a[i]=r*a[i-1]-d;
  }
  for(int i=0; i<10; i++){
    cout<<a[i]<<endl;
  }
}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  vector<bool> contains(26, false);
  for (int i = 0; i < (int)S.size(); ++i) {
    int s = S[i] - '0';
    if (contains[s]) {
      cout << "no" << endl;
      return 0;
    }
    contains[s] = true;
  }
  cout << "yes" << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int AB, CD;
		AB = A*B;
		CD = C*D;
		if(AB > CD){
			System.out.print(AB);
		}else{
			System.out.print(CD);			
		}
		sc.close();
	} 
}

Measured memory_bytes: 21844
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
using lld =long long int;

template<typename T>
vector<T> smallest_prime_factors(T n) {

    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++) spf[i] = i;


    for (T i = 2; i * i <= n; i++) {

        // 素数だったら
        if (spf[i] == i) {

            for (T j = i * i; j <= n; j += i) {

                // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }

    return spf;
}

int factolization(int  x, vector<int> &spf) {
    int now=0;
    vector<int> r;
    r.push_back(0);
    int alc=0;
    now=spf[x];
    while (x != 1) {
        x /= spf[x];
        r[alc]++;
        if(now==spf[x]){
        }else{
            now=spf[x];
            r.push_back(0);
            alc++;
        }
        
    }
    int ans=1;
    for(int i=0;i<=alc;i++){
        ans*=(r[i]+1);
    }

    return ans;
}

int main(){
    lld ans=0;
    int N;
    cin >> N;
    auto spf=smallest_prime_factors(N+1);
    for(int i=2;i<N;i++){
        ans+=factolization(i,spf);
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 7192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int d[N];
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    int t = d[0];
    for (int i = 1; i < N; i++) {
        if (t - 10 < 0) {
            cout << "no\n";
            return 0;
        }
        t = max(d[i], t - 10);
    }
    t = d[N - 1];
    for (int i = N - 2; i >= 0; i--) {
        if (t - 10 < 0) {
            cout << "no\n";
            return 0;
        }
        t = max(d[i], t - 10);
    }
    cout << "yes\n";
    return 0;
}


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

public class Hello
{
    public static void Main()
    {
        var line1 = Console.ReadLine().Split(' ');
        var h = int.Parse(line1[0]);
        var w = int.Parse(line1[1]);
        var n = int.Parse(line1[2]);

        var line2 = Console.ReadLine().Split(' ');
        var sr = int.Parse(line2[0]);
        var sc = int.Parse(line2[1]);

        var s = Console.ReadLine();
        var t = Console.ReadLine();

        var l = sc;
        var r = sc;
        var u = sr;
        var d = sr;

        for (int i = 0; i < n; ++i)
        {
            switch (s[i])
            {
                case 'L':
                    --l;
                    if (l < 1)
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                    break;
                case 'R':
                    ++r;
                    if (r > w)
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                    break;
                case 'U':
                    --u;
                    if (u < 1)
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                    break;
                case 'D':
                    ++d;
                    if (d > h)
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                    break;
            }

            switch (t[i])
            {
                case 'L':
                    if (r > 1)
                        --r;
                    break;
                case 'R':
                    if (l < w)
                        ++l;
                    break;
                case 'U':
                    if (d > 1)
                        --d;
                    break;
                case 'D':
                    if (u < h)
                        ++u;
                    break;
            }
        }

        Console.WriteLine("YES");
    }
}


Measured memory_bytes: 14304
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {};
	Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
	int n;
	bool directed;
	vector<vector<Edge<T>>> edges;
public:

	Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)) {};
	Graph() {};

	void add(int to, T cost) {
		emplace_back(to, cost);
	}

	int size() {
		return n;
	}
};


int main() {

	int N;

	cin >> N;

	vi A(N-1);

	REP(i, N-1) {
		cin >> A[i];
	}

	vi ans(N);

	REP(i, N) {
		ans[i] = 0;
	}

	REP(i, N-1) {
		ans[--A[i]]++;
	}

	REP(i, N) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 4840
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define mod 1000000007
typedef long long ll;
using namespace std;


int main(){
  int n,m; cin >> n >> m;
  if(n==m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define sci(x) scanf("%d",&x)
#define scs(s) scanf("%s",s)
#define scc(c) scanf("%c",c)
#define scd(d) scanf("%lf",&d)
#define scld(ld) scanf("%Lf",&ld)
using namespace std;

//********************************************
//Error tracking
#define show(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
    err(++it, args...);
}
//********************************************

const int NMAX = 505;
const int XMAX = 300005;

int n,a[NMAX],ans[XMAX];
bitset<XMAX>viz;

int main()
{
   // freopen("input","r",stdin);
  // freopen("output","w",stdout);
    cin.sync_with_stdio(false);

    int i;
    cin >> n;
    for (i = 1; i <= n; i++) 
        {
            cin >> a[i];
            ans[a[i]] = i;
            viz[a[i]] = 1;
        }

    int len = n*n, top = 1, ok = 1;
    for (i = 1; i <= len && ok; i++)
        if (ans[i])
        {
            int aux = ans[i] - 1;
            while (aux && top <= i)
            {
                while (ans[top]) top++;
                ans[top] = ans[i];
                aux--;
            }

            if (top > i) ok = 0;
        }
    
    if (!ok) { cout << "No\n"; return 0;}

    top = len;
    for (i = len; i >= 1; i--)
        if (ans[i] && viz[i])
        {
            int aux = n - ans[i];
            while (aux && top >= i)
            {
                while (ans[top]) top--;
                ans[top] = ans[i];
                aux--;
            }

            if (top < i) ok = 0;
        }

    if (!ok) { cout << "No\n"; return 0;}
    cout << "Yes\n";
    for (i = 1; i <= len; i++) cout << ans[i] << " ";
    cout << "\n";
    return 0;   
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
using namespace std;
int main(){
    int i,n; string s;
    cin >> n >> s;
    int r = 0,w = 0;
    for(i=0;i<n;i++){
        if(s[i]=='R') r++;
        if(s[i]=='W') w++;
    }
    int diff = w,ans = w;
    for(i=1;i<=n;i++){
        if(s[n - i]=='R') diff++;
        else diff--;
        int d = max(i - w,w - i);
        ans = min(ans,d + (diff - d)/2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3748
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
#Union Find
N,M,K = inputlist()
graph = [[] for _ in range(N)]
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1]*(N)
for i in range(M):
    A,B = inputlist()
    graph[A-1].append(B-1)
    graph[B-1].append(A-1)
    unite(A-1,B-1)
bgraph = [[] for _ in range(N)]
for i in range(K):
    C,D = inputlist()
    if same(C-1,D-1):
        bgraph[C-1].append(D-1)
        bgraph[D-1].append(C-1)
li = [0]*N
for i in range(N):
    k = size(i)
    n = len(graph[i])
    m = len(bgraph[i])
    li[i] = k-n-m-1
print(*li)

Measured memory_bytes: 50300
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(size_t i = (j); i < (n); ++i)

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

	int n; cin >> n;
	ll a;
	vector<ll> s(n + 1);
	map<ll, ll> cnt;

	ll ans = 0;
	rep(i, 0, n) {
		cin >> a;
		s[i + 1] = s[i] + a;
		ans += cnt[s[i]]++;
	}
	ans += cnt[s[n]];
	cout << ans;
	return 0;

}


Measured memory_bytes: 17188
N = int(input())
a = list(map(int,input().split()))
ans = set()
other = 0

for i in a:
    if i <400:
        ans.add("gray")
    elif i <800:
        ans.add("green")
    elif i < 1200:
        ans.add("brown")
    elif i <1600:
        ans.add("light_blue")
    elif i<2000:
        ans.add("blue")
    elif i<2400:
        ans.add("yellow")
    elif i <2800:
        ans.add("orange")
    elif i <3200:
        ans.add("red")
    else:
        other += 1

color = len(ans)
if other == N:
    print(1," ",min(other,8))
else:
    print(color, " " ,min(N,color +other))

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#define SWAP(type, a, b) {type tmp=a; a=b; b=tmp;}

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

  int G[100], k=0, h=1;
  for (int h_tmp=1; h_tmp<=n; h_tmp=h_tmp*3+1) {
    G[k++]=h_tmp;
    h=h_tmp;
  }

  printf("%d\n", k);
  for (int i=k-1; i>=0; i--) {
    if (i>0) printf("%d ", G[i]);
    else printf("%d\n", G[i]);
  }
  
  int cnt=0;
  while (h) {
    for (int i=h; i<n; i++) {
      for (int j=i; j>=h && arr[j-h]>arr[j]; j-=h) {
        SWAP(int, arr[j], arr[j-h])
        cnt++;
      }
    }
    h/=3;
  }

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


Measured memory_bytes: 5692
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
    int x;
    cin >> x;
    int ans = 0;
  	if ( x < 4 ){
      cout << 1 << endl;
      return 0;
    }
    for ( int i = 2 ; i <= x ; i++ ){
        for ( double j = 2 ; j < 100 ; j++ ){
        	if ( pow(i,j) <= x ) {
                if ( pow(i,j) > ans ) ans = pow(i,j);
            }
          	else break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256