akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

bool contain(int mask,int pos){
  return (mask&(1<<pos))!=0;
}

int main(){
  int D, G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  for(int i = 0; i < D; i++) cin >> p[i] >> c[i];
  int ans = INT_MAX;
  for(int mask = 0; mask < (1 << D); mask++){
    int sum = 0;
    int cnt = 0;
    for(int i = 0; i < D; i++){
      if(contain(mask, i)){
	sum += p[i] * (i + 1) * 100 + c[i];
	cnt += p[i];
      }
    }
    if(sum < G){
      for(int i = D - 1; i >= 0; i--){
	if(contain(mask, i)) continue;
	for(int j = 0; j < p[i]; j++){
	  if(G <= sum)break;
	  sum += (i + 1) * 100, cnt++;
	}
      }
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
#define M 200005

using namespace std;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    int n,x,t;
    cin >>n >> x >> t;

    int d = ceil(double(n)/x);
    cout << d*t << endl;
    return 0;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] dishes = new int[n];
        for (int i = 0; i < n; i++) {
            dishes[i] = sc.nextInt()-1;
        }
        int[] utility = new int[n];
        for (int i = 0; i < n; i++) {
            utility[i] = sc.nextInt();
        }
        int[] additionalUtility = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            additionalUtility[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += utility[dishes[i]];
            if (i > 0 && dishes[i] == dishes[i-1]+1) {
                ans += additionalUtility[dishes[i-1]];
            }
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;
using std::abs;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

template<typename T>
std::ostream& operator<<(std::ostream& os, const vector<T>& vec) {
	os << '[';
	int fst = 1;

	for(auto& elem: vec) {
		if(fst == 0) {
			os << ' ';
		}

		os << elem;
		fst = 0;
	}

	os << ']';
	return os;
}

const int MAX_N = 55555;

int sieve[MAX_N], used[MAX_N];
int stack[MAX_N], head = 0;

void precalc() {
	for(int i = 2; i < MAX_N; ++i) {
		if(sieve[i] == 0) {
			for(int j = 2 * i; j < MAX_N; j += i) {
				sieve[j] = 1;
			}
		}
	}
}

void solve() {
	int n;
	cin >> n;

	for(int i = 2; i < MAX_N; i += 5) {
		if(n == 0)
			break;

		if(sieve[i] == 0) {
			cout << i << ' ';
			--n;
		}
	}

	cout << '\n';
}

int main() {
	init_IO();

	precalc();
	solve();

	return 0;
}


Measured memory_bytes: 512
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑


int main() {

	int a, b, x, ans = (1 << 30);
	cin >> a >> b >> x;
	for (int i = 0; i <= 20; ++i) {
		for (int j = 0; j <= 40; ++j) {
			if (i * 1000 + j * 500 < x) {
				continue;
			}
			if (i * a + j * b < ans) { ans = a * i + b * j; }
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3112
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<string> v(n);
    for(auto &x:v)
    {
        cin>>x;
        sort(x.begin(),x.end());
    }
    sort(v.begin(),v.end());
    ll temp=1;
    ll ans=0;
    for(ll i=1;i<n;i++)
    {
        if(v[i]==v[i-1])
        {
            temp++;
        }
        else
        {
            ans+=(temp)*(temp-1)/2;
            temp=1;
        }
    }
    ans+=(temp)*(temp-1)/2;
    cout<<ans;
    return 0;
}



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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pdd;

int main()
{
    double xa, ya, xb, yb, xc, yc, xd, yd;
    char c;
    while (cin >> xa >> c >> ya >> c >> xb >> c >> yb >> c >> xc >> c >> yc >> c >> xd >> c >> yd)
    {
        deque<pdd> q;
        q.push_back(pdd(xa, ya));
        q.push_back(pdd(xb, yb));
        q.push_back(pdd(xc, yc));
        q.push_back(pdd(xd, yd));

        bool flag = 0;

        rep(i, 4)
        {
            vector<pdd> v(3);

            rep(k, 3)
            {
                v[k].first = q[3].first - q[k].first;
                v[k].second = q[3].second - q[k].second;
            }

            auto v_pro = [](pdd p, pdd q) {
                return p.first * q.second - p.second * q.first;
            };

            if ((v_pro(v[0], v[1]) > 0 && v_pro(v[1], v[2]) > 0 && v_pro(v[2], v[0]) > 0) || (v_pro(v[0], v[1]) < 0 && v_pro(v[1], v[2]) < 0 && v_pro(v[2], v[0]) < 0))
                flag = 1;

            q.push_back(q.front());
            q.pop_front();
        }

        if (flag == 1)
            OP("NO");
        else
            OP("YES");
    }

    return 0;
}


Measured memory_bytes: 3100
N, M = map(int, input().split())
A_list=[input()for i in range(N)]
B_list=[input()for i in range(M)]

whole_flag = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        flag = 0
        for k in range(M):
            if B_list[k] == A_list[i+k][j:j+M]:
                flag += 1
            else:
                pass
        if flag == M:
            whole_flag += 1
            
print("Yes" if whole_flag >0 else "No")

Measured memory_bytes: 3060
#include <iostream>
#include <memory>
#include <string>
#include <vector>

struct node {
  int key;
  std::shared_ptr<node> parent;
  std::shared_ptr<node> left;
  std::shared_ptr<node> right;
  node(int k) : key(k), parent(nullptr), left(nullptr), right(nullptr) {};
};

class bst {
private:
  std::shared_ptr<node> root;
  void r_inorder(std::shared_ptr<node> n);
  void r_preorder(std::shared_ptr<node> n);
public:
  bst() : root(nullptr) {};
  void insert(int v);
  void print();
};

void bst::insert(int k) {
  std::shared_ptr<node> y = nullptr;
  std::shared_ptr<node> x = root;
  std::shared_ptr<node> z(new node(k));
  while (x != nullptr) {
    y = x;
    if (z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;
  if (y == nullptr)
    root = z;
  else if (z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

void bst::r_inorder(std::shared_ptr<node> n) {
  if (n == nullptr)
    return;
  r_inorder(n->left);
  std::cout << " " << n->key;
  r_inorder(n->right);
}

void bst::r_preorder(std::shared_ptr<node> n) {
  if (n == nullptr)
    return;
  std::cout << " " << n->key;
  r_preorder(n->left);
  r_preorder(n->right);
}

void bst::print() {
  r_inorder(root);
  std::cout << std::endl;
  r_preorder(root);
  std::cout << std::endl;
}

int main() {
  int n;
  std::cin >> n;
  bst tree;
  for (int i = 0; i < n; ++i) {
    std::string str;
    std::cin >> str;
    if (str == "insert") {
      int k;
      std::cin >> k;
      tree.insert(k);
    }
    else
      tree.print();
  }
}

Measured memory_bytes: 49944
n,m=map(int,input().split())
L=[0]*m
R=[0]*m
table=[0]*(n+2)
for i in range(m):
    L[i],R[i]=map(int,input().split())
    table[L[i]]+=1
    table[R[i]+1]-=1
s=[0]*(n+2)#累積和をするリスト
for i in range(1,n+2):
    s[i]=s[i-1]+table[i]
print(s.count(m))


Measured memory_bytes: 15836
#include <iostream>
#include <vector>
#include <cstring>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;

const int INF = 1 << 30;

struct P{
	int top;
	int bottom;
};
int d[101][101];
int s[101][101];

vector <P> y;

int f (int a, int b, int c, int d )
{
	return (a*b*c*d);
}

void init_memo (int n )
{
	rep (i, n ){
		rep (j, n ){
			d[i][j] = INF;
		} // end rep
	} // end rep
}

int memoize (int i, int j )
{
	if (d[i][j] != INF )
		return d[i][j];

	int res = -1;
	if (i == j ){
		res = 0;
	}else{
		for (int k = i; k < j; k++ ){
			int q = memoize (i, k ) + memoize (k+1, j ) + f(y[i].top, y[k].bottom, y[k+1].top, y[j].bottom );
			if (q < d[i][j] ){
				res = q;
				d[i][j] = q;
				s[i][j] = k;
			} // end if
		} // end for
	} // end if

	return d[i][j] = res;
}

int main()
{
	int n;

	while (cin >> n && n ){
		init_memo (n );
		memset (s, 0, sizeof (s ) );
		y.resize(n );	
		for (int i = 0; i < n; i++ ){
			cin >> y[i].top >> y[i].bottom;
		} // end for
		memoize (0, n-1 );
		cout << d[0][n-1] << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
/**
   Solution by Abil
**/
# include <bits/stdc++.h>

# define fr first
# define sc second
# define pb push_back
# define mk make_pair
# define sz(s) s.size()
# define all(s) s.begin(),s.end()
# define int long long

using namespace std;

const long long N = (1e6 + 10);
const long long mod = (1e9 + 7);
const long long inf = (1e9 + 7);

int arr[N],t[N * 4], h[N];

void update(int v,int tl,int tr,int pos,int jany)
{
  if(tl == tr)
  {
    t[v] = t[v] + jany;
  }
  else
  {
    int mid = (tl + tr)/2;
    if(pos <= mid)
    {
      update(v + v,tl,mid,pos,jany);
    }
    else
    {
      update(v+v+1,mid+1,tr,pos,jany);
    }
    t[v] = max(t[v+v],t[v+v+1]);
  }
}
int get(int v,int tl,int tr,int l,int r)
{
  if(l > tr || r < tl)
  {
    return -1;
  }
  else
  if(l <= tl && r >= tr)
  {
    return t[v];
  }
  else
  {
    int mid = (tl + tr)/2;
    return max(get(v+v,tl,mid,l,r),get(v+v+1,mid+1,tr,l,r));
  }
}
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    for(int i = 1;i <= n; i++){
      cin >> arr[i];
    }
    for(int i = 1;i <= n; i++){
      cin >> h[i];
    }
    for(int i = 1;i <= n; i++){
      update(1,1,n,arr[i],get(1,1,n,1,arr[i]) + h[i]);
    }
    int ans = 0;
    for(int i = 1;i <= n; i++){
      ans = max(ans,get(1,1,n,1,arr[i]));
    }
    cout << ans;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
using namespace std;
int main()
{
	string s;
	int f=0;
	cin>>s;
	for(int i=0;i<3;i++)
	{
		if (s[i]=='7')
		{
			cout<<"Yes"<<endl;
			f=1;
			break;
		}
	}
	if (f==0)
	cout<<"No"<<endl;
	
}
	



Measured memory_bytes: 3628
#include<stdio.h>

int gcd( int x, int y )
{
	int res=0;
	if( 1 < y && y < x ) {
		res=gcd( y, x%y );
	} else {
		if( 0==y ) {
			return x;
		} else {
			return y;
		}
	}
	return res;
}


int main( void ) 
{
	int a,b;
	
	scanf( "%d%d", &a, &b );
	
	int tmp;
	if( b < a ) {
		tmp=a;
		a=b;
		b=tmp;
	}
	
	printf( "%d\n", gcd( b, a ) );
	
	return 0;
}

Measured memory_bytes: 592
#include<stdio.h>

#define N 10000

int main(void)
{
  int prime[N],n,i,j=1,count=0;
  scanf("%d",&n);
  for(i=0 ; i < n ; i++)
    {
      scanf("%d",&prime[i]);
    }
  for(i=0 ; i < n ; i++)
    {
      for(j=1 ; j < n ; j++)
	{
	  if(2*j == prime[i]) break;
	  else if(prime[i]%(2*j) == 0)
	    {
	      count++;
	      break;
	    }
	  else if(2*j+1 == prime[i]) break;
	  else if(prime[i]%(2*j+1)==0)
	    {
	      count++;
	      break;
	    }
	}
    }
  printf("%d\n",n-count);
  return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int mod = 1000000007;
int main()
{
    ll n, m;
    cin >> n >> m;
    ll list[max(n, m) + 1];
    list[1] = 1;
    list[0] = 1;
    for (int i = 0; i < max(n, m); i++)
    {
        list[i + 1] = (list[i] * (i+1)) % mod;
    }
    if (abs(n - m) >= 2)
    {
        cout << 0 << endl;
    }
    else
    {
        if(n!=m){
            cout << (list[n] * list[m] % mod) << endl;
        }else{
            cout << (2 * list[n] * list[m]) % mod << endl;
        }
    }
}

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

typedef long long ll;

int main(){
	int x;
	cin >> x;
	int sum = 0;
	for(int i = 1 ; ; i ++){
		sum += i;
		if(x <= sum){
			printf("%d\n",i);
			return 0;
		}
	}
}

Measured memory_bytes: 256
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 a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		// 計算
		int result = max(0, c - (a - b));
		
		// 出力
		System.out.println(result);
	}
}


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

using namespace std;

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

int main() {
	int N;
	cin >> N;
	REP(n, N) {
		string str;
		int type = 0, pos = 0;
		cin >> str;
		
		if (str[pos] == '>') {
			pos++;
			if (str[pos] == '\'') {
				pos++;
				int cnt = 0;
				while (pos < str.size() && str[pos] == '=') { cnt++; pos++; }
				
				if (cnt != 0 && str[pos] == '#') {
					pos++;
					while (pos < str.size() && str[pos] == '=') { cnt--; pos++; }
					if (cnt == 0 && str[pos] == '~') type = 1;
				}
				
			}
			else if (str[pos] == '^') {
				bool f = false;
				pos++;
				while (pos + 1 < str.size()) {
					if (str[pos] == 'Q' && str[pos + 1] == '=') { pos += 2; f = true; }
					else break;
				}
				if (f && pos + 2 == str.size() && str[pos] == '~' && str[pos + 1] == '~')
					type = 2;
			}
		}
		
		
		switch (type) {
		case 0: cout << "NA" << endl; break;
		case 1: cout << "A" << endl; break;
		case 2: cout << "B" << endl; break;
		}
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n;
	cin >> n;
	vector<string>s(n);
	pair<string, ll>p;
	map<string,ll>mp;
	rep(i, n) {
		cin >> s[i];
		mp[s[i]]++;
	}
	ll maxNum = -INF;
	for (auto i = mp.begin(); i != mp.end(); ++i) {
		maxNum = max(maxNum, i->second);
	}
	ll valN = 0,cnt=0;
	for (auto i = mp.begin(); i != mp.end(); ++i) {
		if (i->second == maxNum) {
			cout << i-> first << " " << endl;
		}
	}
}


Measured memory_bytes: 27008
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    A, B = rl().split()
    A = int(A)
    B = B.split('.')
    B = int(B[0] + B[1])
    ans = A * B // 100
    print(ans)


if __name__ == '__main__':
    solve()


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

using namespace std;

const int mod1 = 998244353,mod2 = 1000000007;

struct Hsh
{
	long long m1,m2;
	Hsh operator + (const Hsh &a) const
	{
		return (Hsh){(m1 + a.m1) % mod1,(m2 + a.m2) % mod2};
	}
	Hsh operator - (const Hsh &a) const
	{
		return (Hsh){(m1 - a.m1 + mod1) % mod1,(m2 - a.m2 + mod2) % mod2};
	}
	Hsh operator * (const Hsh &a) const
	{
		return (Hsh){m1 * a.m1 % mod1,m2 * a.m2 % mod2};
	}
	bool operator < (const Hsh &a) const
	{
		return m1 == a.m1 ? m2 < a.m2 : m1 < a.m1;
	}
}ha[250050],pos[500050];

map<Hsh,int> mp;
int N;
const int bas1 = 131,bas2 = 1331;
char s[250005];

long long qpow(long long base,int tms,int mod)
{
	long long tmp = 1;
	while(tms)
	{
		if(tms & 1) tmp = tmp * base % mod;
		base = base * base % mod;
		tms >>= 1;
	}
	return tmp;
}

int main()
{
	Hsh x,inv;
	int n;
	x.m1 = bas1,x.m2 = bas2;
	inv.m1 = qpow(bas1,mod1 - 2,mod1),inv.m2 = qpow(bas2,mod2 - 2,mod2);
	pos[0].m1 = pos[0].m2 = 1; scanf("%d",&n); scanf("%s",s + 1);
	for(int i = 1;i <= n; ++ i)
	{
		pos[i] = pos[i - 1];
		if(s[i] == '<') pos[i] = pos[i - 1] * inv;
		else if(s[i] == '>') pos[i] = pos[i - 1] * x;
	}
	for(int i = n;i >= 1; -- i)
	{
		ha[i] = ha[i + 1];
		if(s[i] == '+') ha[i] = ha[i] + pos[i];
		else if(s[i] == '-') ha[i] = ha[i] - pos[i];
	}
	mp[ha[n + 1]] = 1;
	long long ans = 0;
	for(int i = n;i >= 1; -- i)
	{
		Hsh cur = ha[i] - ha[1] * pos[i - 1];
		ans += mp[cur];
		mp[ha[i]] ++;
	}
	printf("%lld\n",ans);
}

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

struct point
{
    int x, y;
    point( )
    {
        x = y = 0;
    }
};

int n;
point p[11];
point ara[11];
int used[11];
double ss = 0;
int cc = 0;

double dist(point a, point b)
{
    double dx, dy, t;
    dx = a.x - b.x; dx *= dx;
    dy = a.y - b.y; dy *= dy;
    t = sqrt(dx + dy);
    return t;
}

double calculate( )
{
    int i, j, k;
    double s = 0, t;
    for (i = 1; i < n; i++)
    {
        t = dist(ara[i], ara[i + 1]);
        s += t;
    }
    return s;
}

void permutation(int at, int taken, point ara[])
{
    if (taken == n)
    {
        cc++;
        ss += calculate( );
        return ;
    }
    for (int i = 1; i <= n; i++)
    {
        if (used[i] == 0)
        {
            used[i] = 1;
            ara[at] = p[i];
            permutation(at + 1, taken + 1, ara);
            used[i] = 0;
        }
    }
}

int main( )
{
    cin >> n;
    int i, j, k;
    for (i = 1; i <= n; i++)
        cin >> p[i].x >> p[i].y;
    permutation(1, 0, ara);
    printf("%.10lf\n", ss / cc);
    return 0;
}


Measured memory_bytes: 256
import collections
class Dinic:
    def __init__(self, vnum):
        self.edge = [[] for i in range(vnum)]
        self.n = vnum
        self.inf = float('inf')
    def addedge(self, st, en, c):
        self.edge[st].append([en, c, len(self.edge[en])])
        self.edge[en].append([st, 0, len(self.edge[st])-1])
    def bfs(self, vst):
        dist = [-1]*self.n
        dist[vst] = 0
        Q = collections.deque([vst])
        while Q:
            nv = Q.popleft()
            for vt, c, r in self.edge[nv]:
                if dist[vt] == -1 and c > 0:
                    dist[vt] = dist[nv] + 1
                    Q.append(vt)
        self.dist = dist
    def dfs(self, nv, en, nf):
        nextv = self.nextv
        if nv == en:
            return nf
        dist = self.dist
        ist = nextv[nv]
        for i, (vt, c, r) in enumerate(self.edge[nv][ist:], ist):
            if dist[nv] < dist[vt] and c > 0:
                df = self.dfs(vt, en, min(nf, c))
                if df > 0:
                    self.edge[nv][i][1] -= df
                    self.edge[vt][r][1] += df
                    return df
            nextv[nv] += 1
        return 0
    def getmf(self, st, en):
        mf = 0
        while True:
            self.bfs(st)
            if self.dist[en] == -1:
                break
            self.nextv = [0]*self.n
            while True:
                fl = self.dfs(st, en, self.inf)
                if fl > 0:
                    mf += fl
                else:
                    break
        return mf

def inpl(): return [int(i) for i in input().split()]
N = int(input())
a = inpl()
K = Dinic(N+2)
inf = float('inf')
for i, v in enumerate(a,1):
    if v > 0:
        K.addedge(i, N+1, v)
    else:
        K.addedge(0, i, -v)
for i in range(1,N+1):
    for j in range(2*i, N+1, i):
        K.addedge(i, j, inf)

print(sum([i for i in a if i > 0]) - K.getmf(0, N+1))

Measured memory_bytes: 3436
N, M = map(int, input().split())
head, tail = map(int, input().split())
for i in range(1, M):
    if head > tail:
        print(0)
        exit()
    x, y = map(int, input().split())
    if x > head:
        head = x
    if y < tail:
        tail = y

print(tail - head + 1)


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ll n, a, b, sum;
  cin >> n >> a >> b;
  
  sum = n/(a+b)*a;
  if (n%(a+b)-a >= 0) sum += a;
  else sum += n%(a+b);
  
  cout << sum << endl;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	vector<ll> s(n + 1);
	s[0] = 0;
	REP(i, n) {
		s[i + 1] = s[i] + a[i];
	}
	vector<ll> b;
	REP(i, n) {
		FOR(j, i+1, n+1) {
			b.push_back(s[j] - s[i]);
		}
	}
	ll res = 0;
	RREP(i, 40) {
		int cnt = 0;
		bool flag = false;
		ll ba = 1ll << i;
		for (auto v : b) {
			ll t1 = res + ba;
			ll t2 = t1 & v;
			if (t1 == t2) {
				cnt++;
				if (cnt >= k) {
					break;
				}
			}
		}
		if (cnt >= k) {
			res += ba;
		}
	}
	put(res);
	return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,u,vv,w,ans[100000];
vector<pair<int,int>> v[100000];
bool visited[100000]={true};
queue<pair<int,int>> que;

signed main() {
    cin >> n;
    rep(i,n-1) cin >> u >> vv >> w, u--, vv--, v[u].pb(mp(vv,w)), v[vv].pb(mp(u,w));
    ans[0] = 0;
    rep(i,v[0].size()) {
        int to = v[0][i].fi, cost = v[0][i].se;
        if (cost%2) ans[to] = 1;
        que.push(v[0][i]);
    }
    while(!que.empty()) {
        int to = que.front().fi, cost = que.front().se;que.pop();
        if (visited[to]) continue;
        rep(i,v[to].size()) {
            int tto = v[to][i].fi, ccost = v[to][i].se;
            if (visited[tto]) continue;
            if (ccost%2) ans[tto] = (ans[to]+1)%2;
            else ans[tto] = ans[to];
            que.push(v[to][i]);
        }
        visited[to] = true;
    }
    rep(i,n) cout << ans[i] << endl;
}


Measured memory_bytes: 8704
import itertools
while 1:
	n = input()
	if n == 0: break
	a = map(int,raw_input().split())
	all = sum(a)
	ans = all
	for i in range((n+1)/2+1):
		for party in itertools.combinations(a,i):
			ans = min(ans,abs(all-2*sum(party)))
	print ans

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  string s;

  cin>>s;
  cin>>s;

  cout << "A"<< s[0]<< "C"<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
  int n; cin >> n;
  vector<pair<ll, ll> > v(1);
  cin >> v[0].fi, v[0].se = v[0].fi;
  rep(i, 1, n) {
  	char op; int a; cin >> op >> a;
  	if (op == '+') v.back().se += a;
  	else v.pb({a, a});
	}
	//rep(i, 0, sz(v)) cout << v[i].fi << " " << v[i].se << endl;
	ll ans = -LLONG_MAX, drop = 0, sum = 0;
	rep(i, 0, sz(v)) sum += v[i].se;
	rep(i, 1, sz(v)) {
		ans = max(ans, sum - drop * 2- v[i].se * 2);
		drop += v[i].fi;
	}
	ans = max(ans, sum - drop * 2);
	cout << ans;
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define ll long long
#define L long
#define endl "\n"
#define ___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

const int N = (int)1e5;

int main()
{   
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ___
    
    ll int n = 0, k, x = 0, limit = (int)(1e8 + 1e7);
    cin >> k;
    while (1)
    {
        n = ((n * 10) + 7) % k;
        x++;
        if (n == 0)
            break;
        if (x == limit)
        {
            cout<< -1;
            return 0;
        }
    }
    cout<< x;
    
    return 0;
}

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

using namespace std;

int main()
{
    long long  n,a,b;
    long long ans;
    cin>>n>>a>>b;
    long long max=a+(n-1)*b;
    long long min=(n-1)*a+b;
    if(max<min)
        ans=0;
    else
        ans=max-min+1;
    cout<<ans<<endl;

    return 0;
}


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

int main() {
	// your code goes here
	long X;
	cin >>X;
	
	int f=0;
	long x=X;
	while(x>0){
		f+=x%10;
		x/=10;
	}
	
	if(X%f){cout<<"No"<<endl;}
	else{cout<<"Yes"<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  vector<string>v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++){
    cout<<v[i];
  }
  return 0;
}

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

int main(){
   int A,B;
   cin >> A >> B;
   if(A == 1){
       A=A+13;
   }
   if(B == 1){
       B=B+13;
   }
   string ans;
    if(A > B){
        ans="Alice";
    }else if(B > A){
        ans="Bob";
    }else{
        ans="Draw";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
        int a, b;
        int d, r;
        double f;

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

        d = a / b;
        r = a % b;
        f = (double)a / b;

        printf("%d %d %.5f\n", d, r, f);

        return 0;
}

Measured memory_bytes: 640
s=input()
l=int(s[:2])
r=int(s[2:])
if 1<=l<=12 and 1<=r<=12:
    print("AMBIGUOUS")
elif 1<=l<=12:
    print("MMYY")
elif 1<=r<=12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 2940
import java.util.*;
public class Main {

	class Team implements Comparable<Team>{
		int number;
		int time;

		public Team(int num, int hour, int sec){
			this.number = num;
			int temphour = hour + sec / 60;
			int tempsec = sec % 60;
			this.time = temphour * 100 + tempsec;
		}

		public int compareTo(Team team) {
			if(this.time < team.time){
				return -1;
			}
			if(this.time > team.time){
				return 1;
			}
			return 0;
		}

	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n != 0){
			Team [] list = new Team[n];
			int num = 0;
			for(int i=0; i < n; i++){
				num = sc.nextInt();
				int sumh = 0, sums = 0;
				for(int j=0; j < 4; j++){
					sumh += sc.nextInt();
					sums += sc.nextInt();
				}
				list[i] = new Team(num, sumh, sums);
			}
			Arrays.sort(list);
			System.out.println(list[0].number);
			System.out.println(list[1].number);
			System.out.println(list[list.length - 2].number);

			n = sc.nextInt();
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

Measured memory_bytes: 13000
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
	int tmp;
	int asum = 0;
	int bsum = 0;


	for (int i = 0; i < 4; i++) {
		cin >> tmp;
		asum += tmp;
	}
	for (int i = 0; i < 4; i++) {
		cin >> tmp;
		bsum += tmp;
	}

	if (asum > bsum) {
		cout << asum;
	}
	else cout << bsum;

	cout << endl;



	//system("pause");
    return 0;
}




Measured memory_bytes: 3100
using System;
class ss
{
  static void Main()
  {
    var n=Console.ReadLine();
    var m=Console.ReadLine();
    int length=n.Length;
    bool flag=true;
    if(m.Length-length==1)
    {
    for(int i=0;i<length;i++)
    {
      if(n[i]!=m[i])
      {
        flag=false;
        break;
      }
    }
    }
    else
      flag=false;
    if(flag)
    Console.WriteLine("Yes");
    else
      Console.WriteLine("No");
  }
}

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

#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    if(n%2 == 1){
        cout << 0 << endl;
        return 0;
    }
    ll shift = 5;
    ll cnt  = 0;
    while(shift < n){
       // cnt += n/shift;
        cnt += n/(shift*2);
        shift*=5;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int value = 700;
  string S;
  cin >> S ;
  if (S[0] == 'o') value += 100;
  if (S[1] == 'o') value += 100;
  if (S[2] == 'o') value += 100;
  cout << value << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n,d;
  cin >> n >> d;
  int ans = 0;
  rep(i, n){
    ll x,y;
    cin >> x >> y;
    if(sqrt(x*x + y*y) <= d) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  string s; cin >> s;
  int n = s.size();
  for(int i = 2; i < n; i += 2){
    string s1, s2;
    s1 = s.substr(0, (n - i) / 2);
    s2 = s.substr((n - i) / 2, (n - i) / 2);
    if(s1 == s2){
      cout << n - i << endl;
      return;
    }
  }
  return;
}

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


Measured memory_bytes: 256
N, K = map(int,input().split())
S = input()
lstS = list(S)
block = [0]

cnt = 1
for i in range(len(S)):
    if S[i:i+1] == S[i+1:i+2]:
        cnt += 1
    else:
        block.append(cnt)
        cnt = 1
block.append(0)

acc = [0, 0]
for i in range(1, len(block)):
    wa = acc[-1]+block[i]
    acc.append(wa)

if S[0] == '0':
    start = 0
else:
    start = 1
end = len(acc) - (2*K+1)

max = 0
for i in range(start, end, 2):
    if max < acc[i+(2*K+1)] - acc[i]:
        max = acc[i+(2*K+1)] - acc[i]

if start >= end:
    max = N

if len(S) == 1:
    if K == 0 and S =='0':
        max = 0
    else:
        max = 1

print(max)

Measured memory_bytes: 8696
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
ll n;
void dfs(string s,ll depth,ll use){
  //  cout<<depth<<endl;
    if(depth==n){
        cout<<s<<endl;
        return;
    }
    ll temp=0;
    rep(i,s.size()){
        chmax(temp,(ll)s[i]-'a');
    }
    rep(i,temp+2){
        string t=s;
        char c=(char)(i+'a');
        
        t.push_back(c);
        dfs(t,depth+1,temp+1);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    dfs("a",1,1);
}


Measured memory_bytes: 1536
function main()
  
  A, V = map(x -> parse(Int, x), split(readline()))
  B, W = map(x -> parse(Int, x), split(readline()))
  T = parse(Int, readline())
  
  if V <= W || abs(V - W) * T < abs(A - B)
    println("NO")
  else
    println("YES")
  end
  
end

main()

Measured memory_bytes: 163728
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
  input! {
    n: usize,
    av: [Usize1; n - 1]
  };

  let mut res = vec![0; n];
  for i in 1..n {
    res[av[i - 1]] += 1;
  }
  for i in 0..n {
    println!("{}", res[i]);
  }
}


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

public class Main {

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

		int W = sc.nextInt();
		int H = sc.nextInt();

		char[][] a = new char[W][H];

		for (int i=0;i<W;i++) {
			a[i] = sc.next().toCharArray();
		}

		boolean[] hb = new boolean[H];
		boolean[] wb = new boolean[W];
		Arrays.fill(hb, false);
		Arrays.fill(wb, false);

		for (int i=0;i<H;i++) {
			for (int j=0;j<W;j++) {
				if (a[j][i] == '#') {
					hb[i] = true;
				}
			}
		}

		for (int i=0;i<W;i++) {
			for (int j=0;j<H;j++) {
				if (a[i][j] == '#') {
					wb[i] = true;
				}
			}
		}

		int H2 = H;
		for (int i=0;i<H;i++) {
			if (!hb[i]) {
				H2 -= 1;
			}
		}

		int W2 = W;
		for (int i=0;i<W;i++) {
			if (!wb[i]) {
				W2 -= 1;
			}
		}

//		System.out.println("H2="+H2+",W2="+W2);
		char[][] a2 = new char[W2][H2];

		int l=0;
		for (int i=0;i<W;i++) {
			int k=0;
			if (wb[i]) {
				for (int j=0;j<H;j++) {
					if (hb[j]) {
						//System.out.println(hb[i] | wb[j]);
						//System.out.println("k="+k+",l="+l);
						a2[l][k++] = a[i][j];
					}
				}
				l++;
			}

		}

		for (int i=0;i<W2;i++) {
			System.out.println(String.valueOf(a2[i]));
		}

	}

}


Measured memory_bytes: 23892
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll zero(64,0),one(64,0) ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		bitset<64> bit(a) ;
		for(int i=0;i<64;i++){
			if(bit[i]) one.at(i)++ ;
			else zero.at(i)++ ;
		}
	}
	ll ans = 0 ;
	ll two = 1 ;
	for(int i=0;i<64;i++){
		ll sub = zero.at(i)*one.at(i) ;
		sub %= mod ;
		two %= mod ;
		ans += sub*two ;
		two *= 2 ;
		ans %= mod ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


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

    int n;
    string s;
    cin >> n >> s;
    char prev = ' ';
    int ans = 0;
    rep(i, n) {
        if (prev != s[i]) ans += 1;
        prev = s[i];
    }

    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    
    ll n;cin>>n;
    map<ll,ll> mp;
    vll a(n); 
    ll ans=0;
    REP(i,n) {
        cin>>a[i];
        mp[a[i]]++;
        ans += a[i];
    }
    ll q;cin>>q;
    
    REP(i,q){
        ll b,c;cin>>b>>c;
        ans -= b*mp[b];
        ans += c*mp[b];
        mp[c] += mp[b];
        mp[b]=0;
        cout<<ans<<' ';
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 9948
K = int(input())
S = input()
s = len(S)
base = 10 ** 9 + 7

L26 = [ 1 for i in range(K+1)] # 26^i mod base 
for i in range(K):
  L26[i+1] = (L26[i] * 26) % base

T1 = 1
T2 = 1
ans = 0
for i in range( s, s+K+1):
  T3 = L26[K + s - i]
  #T4 = pow(26, K + s - i, base)
  #print(T3, T4)
  p = (T1 * T2) % base
  p = (p * T3) % base
  ans += p
  ans %= base
  #print(ans, T1, T2, T3)
  T1 *= 25
  T1 %= base
#  T2 = (T2 * i ) // (i+1-s) # T2 = (i, s-1) = (i-1, s-1) * i // (i+1-s)
  T2 *= i
  T2 %= base
  T2 *= pow(i+1-s, base-2, base)
  T2 %= base
  
print(ans % base)

Measured memory_bytes: 149408
#include<cstdio>
#include<cstring>
#include<cstdlib>

int main(void){
	int a[100000];
	int c;
	int x;
	int n;
	int w;
	int t;
	int p[100000];
	int q[100000];
	scanf("%d %d", &n, &t);
	for (int i = 0; i < t; i++){
		scanf("%d %d", &p[i], &q[i]);
		p[i]--;
		q[i]--;
	}
	for (int i = 0; i < 100000; i++)a[i] = 0;
	a[0] = 2;
	a[1] = 1;
x=0;
	for (int i = 0; i < t; i++){
		w = a[p[i]];
		a[p[i]] = a[q[i]];
		a[q[i]] = w;
		if (a[p[i]] == 2) x=p[i];
if(a[q[i]]==2)x=q[i];
			if (x > 0)a[x-1] = 1;
			if (x< n - 1)a[x+1] = 1;
	}
	c = 0;
	for(int i = 0; i < n; i++){
		if (a[i] > 0)c++;
}
	printf("%d\n",c);

	return 0;
}

Measured memory_bytes: 1280