akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
const int N=55,mo=1e9+7;
int n,i,j,k,l,o,x,d,f[N][N][N],fac[N],inv[N],vf[N];
int main(){
	for(i=*fac=*vf=1;i<N;++i)fac[i]=1ll*fac[i-1]*i%mo,
		inv[i]=i==1?1:1ll*(mo-mo/i)*inv[mo%i]%mo,vf[i]=1ll*vf[i-1]*inv[i]%mo;
	scanf("%d",&n);for(i=0;i<=n;++i)for(j=0;i+j<=n;++j)f[i+j][i][j]=1ll*vf[i]*vf[j]%mo;
	for(i=1;i<n;++i)for(j=0;j<=i;++j)for(k=0;j+k<=i;++k)if(x=f[i][j][k])
		for(d=j-k,l=d>0?0:-d;i+l<=n;++l)for(o=d>0?d:0;i+l+o<=n;++o)if(l|o)
			f[i+l+o][l+d][o-d]=(f[i+l+o][l+d][o-d]+1ll*vf[l]*vf[o]%mo*x)%mo;
	printf("%lld\n",1ll*fac[n]*f[n][1][0]%mo);
	return 0;
}

Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long A[100000];
pair <long long, int> CB[100000];
int main(void){
  int N;
  int M;
  cin >> N >> M;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  for(int i = 0; i < M; i++){
    cin >> CB[i].second >> CB[i].first;
  }

  sort(A, A + N);
  sort(CB, CB + M);
  reverse(CB, CB + M);

  int cur_ind = 0;
  for(int i = 0; i < M; i++){
    for(int j = 0; j < CB[i].second &&  cur_ind < N; j++){
      if(A[cur_ind] < CB[i].first){
        A[cur_ind] = CB[i].first;
        cur_ind ++;
      } else {
        break;
      }
    }
  }

  long long ans = 0;
  ans = accumulate(A, A + N, (long long) 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long 
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=4e6+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
ll cnt[MAX];
ll fact[MAX];
void precoumpute(){
  fact[0]=1;
  for(ll i=1;i<MAX;i++)
    fact[i]=((i%MOD)*(fact[i-1]%MOD))%MOD;
}
ll mexp(ll a , ll b , ll mod){
  ll res=1;
  while(b){
    if(b%2)
      res=(res%mod)*(a%mod);
    a=(a%mod)*(a%mod);
    res=res%mod;
    a=a%mod;
    b=b/2;
  }
  return res;
}
ll ncr(ll n , ll r){
  ll d=(fact[r]%MOD)*(fact[n-r]%MOD);
  d=d%MOD;
  d=mexp(d, MOD-2, MOD);
 ll nm=fact[n];
  ll ans=(nm%MOD)*(d%MOD);
  ans=ans%MOD;
  return ans;
}
int main() 
{

	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    string s;
    int m;
    precoumpute();
    cin>>m;
    cin>>s;
    int len = (int)(s.size());
    int n=len+m;
    ll bad=0;
    ll pw[n+1];
    pw[0]=1;
    for(int i=1;i<=n;i++)
      pw[i]=((pw[i-1]%MOD)*((ll)25%MOD))%MOD;

    for(ll i=0;i<=len-1;i++){
      ll u=ncr(n,i);
      u=(u%MOD)*(pw[n-i]%MOD);
      u=u%MOD;
      bad=(bad+u+MOD)%MOD;
      bad=bad%MOD;
    }
  //  cout<<ncr(5, 3);
    ll ans=mexp((ll)(26) , n , MOD);
    ans=ans-bad+MOD;
    ans=ans%MOD;
    cout<<ans;
}

Measured memory_bytes: 51028
#include<iostream>
using namespace std;
int main() {
  long long a,b,c;
  cin >> a >> b >> c;
  long long f = a*a + b*b + c*c -2*(a*b+b*c+c*a);
  if(f>0 && a+b<c)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
cnt4 = 0
cnt2 = 0
for i in a:
    if i % 4 == 0:
        cnt4 += 1
    elif i % 2 == 0:
        cnt2 += 1
if cnt4 * 2 + cnt2 >= N:
    print("Yes")
elif cnt4 * 2 >= N - 1:
    print("Yes")
else:
    print("No")


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

typedef long long ll;

int n, q;
long long dp[1028][100009];
ll v[300009];
ll w[300009];

int limit=1024;

int main() {
	cin>>n;
  for(int i=1; i<=n; i++)
  {
    cin>>v[i]>>w[i];
  }
  for(int i=1; i<limit; i++)
  {
    for(int j=0; j<=100000; j++)
    {
      dp[i][j]=dp[i/2][j];
      if(j>=w[i])
      {
        dp[i][j]=max(dp[i][j], dp[i/2][j-w[i]]+v[i]);
      }
    }
  }
  cin>>q;
  for(int tt=1; tt<=q; tt++)
  {
    int s, L;
    cin>>s>>L;
    if(s<512)
    {
      cout<<dp[s][L]<<'\n';
      continue;
    }
    ll best=0;
    int extra=0;
    int u=s;
    while(u>=limit)
    {
      extra++;
      u/=2;
    }
    for(int msk=0; msk<(1<<extra); msk++)
    {
      ll wsum=0;
      ll vsum=0;
      u=s;
      int mm=msk;
      for(int d=0; d<extra; d++)
      {
        if(mm%2)
        {
          vsum+=v[u];
          wsum+=w[u];
        }
        mm/=2;
        u/=2;
      }
      if(wsum>L) continue;
      best=max(best, vsum+dp[u][L-wsum]);
    }
    cout<<best<<'\n';
  }
	return 0;
}


Measured memory_bytes: 807036
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 998244353
#define floop(i,a,b) for (int i=(a);i<(b);i++)
#define rloop(i,a,b) for (int i=(a);i>=(b);i--)
#define floopeq(i,a,b) for (int i=(a);i<(b);i++)
#define pa pair<int,int>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll modInverse(ll a, ll m) 
{ ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0; while (a > 1){ ll q = a / m; ll t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; } 
    if (x < 0) x += m0; return x; 
}
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b){if(a.fi==b.fi)return b.se>a.se;return a.fi>b.fi;}
void run(vector<int>v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}
void solve()
{
   ll n,ans;
   cin>>n;

   int a[n],b[n];
   floop(i,0,n){
    cin>>a[i]>>b[i];
   }
   int a1 = *max_element(a,a+n);
   int a2 = *min_element(a,a+n);
   int b2 = *min_element(b,b+n);
   int b1 = *max_element(b,b+n);
   sort(a,a+n);
    sort(b,b+n);
   if(n&1)
   {
        ans = abs(b[n/2]-a[n/2])+1;
   }
   else
   {
        ans = (((double)b[n/2]+(double)b[(n/2)-1])/2.0 - ((double)a[n/2]+(double)a[(n/2)-1])/2.0)*2+1;
   }
   cout<<ans<<endl;
   return;
}

int main() 
{ 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    
        solve();
        
    
    
    return 0; 
} 

Measured memory_bytes: 5208
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <algorithm>
#include <queue>
#define ll long long
using namespace std;

#define MOD 1000000007

class LiningUp
{
public:
	int n;
	vector<int> a;

	LiningUp(){
		cin >> n;
		for (int i = 0; i < n; ++i)
		{
			int  tmp;
			cin >> tmp;
			a.push_back(tmp);

		}
	}

	ll pow(ll num, ll e){
	    ll tmp = 1;
	    while(e > 0){
	        if( e & 1ll){
	            tmp = tmp * num % MOD;
	        }
	        num = num * num % MOD;
	        e >>= 1; 
	    }
	    return tmp % MOD;
	}

	void exec(){
		vector<ll> check;
		check.resize(n+1);
		for (int i = 0; i < n; ++i)
		 {
		 	check[i] = 0;
		 }
		if(n % 2 == 0){
			for (int i = 0; i < n; ++i)
			{
				// cout << i << " " << a[i] << endl;

				if(a[i] % 2 == 0 || a[i] >= n){
					cout << "0" << endl;
					return;
				}else{
					check[a[i]]++;
					if(check[a[i]] > 2){
						cout << "0" << endl;
						return;
					}
				}
				// cout << i << " " << a[i] << endl;
			}
		} else {
			for (int i = 0; i < n; ++i)
			{
				if(a[i] % 2 == 1 || a[i] >= n){
					cout << "0" << endl;
					return;
				}else{
					check[a[i]]++;
					if(a[i] == 0 && check[a[i]] == 2){
						cout << "0" << endl;
						return;
					}
					if(check[a[i]] > 2){
						cout << "0" << endl;
						return;
					}
				}
			}

		}

		cout << pow(2, n/2) << endl;

	}
};

int main(){
	LiningUp lu = LiningUp();
	lu.exec();
}


Measured memory_bytes: 1528
#include<stdio.h>
int main()
{
	int a[101], b[101][101], masatoy = 0, koutay = 0, aho[101] = { 0 };
	scanf("%d", &masatoy);
	scanf("%d", &koutay);
	for (int i = 1; i <= koutay; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= koutay; i++) {
		for (int j = 1; j <= masatoy; j++) {
			scanf("%d", &b[i][j]);
			if (a[i] == j) {
				aho[j] += masatoy;
			}
		}
	}
	for (int i = 1; i <= koutay; i++) {
		for (int j = 1; j <= masatoy; j++) {
			if (a[i] == b[i][j]) {
				aho[j]++;
				for (int x = 1; x <= masatoy; x++) {
					if (a[i] == x) {
						aho[x]--;
						break;
					}
				}
			}
		}
	}
	for (int i = 1; i <= masatoy; i++) {
		printf("%d\n", aho[i]);
	}
	return 0;
}

Measured memory_bytes: 2756
#!/usr/bin/env python3
from functools import reduce

x, y = map(int, input().split())

mod = 10**9 + 7


def cmb(n, r, m):
    def mul(a, b):
        return a * b % m

    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return (over * pow(under, m - 2, m))%m


r = abs(x - y)
l = (min(x, y) - r) // 3
r += l
if (x+y)%3 < 1 and l >= 0:
    print(cmb(r + l, l, mod))
else:
    print(0)


Measured memory_bytes: 73072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
全部Dにするのが最善？
*/

string s;

int main(void){
	cin>>s;
	rep(i,s.size()){
		if(s[i]=='P')cout<<"P";
		if(s[i]=='D')cout<<"D";
		if(s[i]=='?')cout<<"D";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3756
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}

int a[101];

int main()
{
	for (int i=1;i<=4;i++) read(a[i]);
	sort(a+1,a+5);
	if (a[1]==1&&a[2]==4&&a[3]==7&&a[4]==9) puts("YES");
	else puts("NO");
	return 0;
}









Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define L long long
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define aa first
#define bb second
#define xx aa.aa
#define yy aa.bb
#define zz bb
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
const int q=1000000007;
int n,f[110][110][110],x[110],w[110];
inline void add(int &a,int b)
{
	a=(a+b)%q;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k,l;
	scanf("%d",&n);
	for(i=1;i<=2*n-1;i++)
	  scanf("%d",&x[i]);
	sort(x+1,x+2*n);
	for(i=1;i<n;i++)
	  if(x[i]!=x[i+1])
	    w[i]=1;
	for(i++;i<=2*n-1;i++)
	  if(x[i]!=x[i-1])
	    w[i]=1;
	f[1][1][1]=1;
	for(i=2;i<=n;i++)
	  for(j=1;j<=2*n-1;j++)
	    for(k=1;k<=j;k++)
	      if(f[i-1][j][k])
	        {
			 int jj=j+w[n-i+1]+w[n+i-1],kk=k+w[n-i+1];
			 for(l=1;l<=jj;l++)
			   if(l<kk)
			     add(f[i][jj-(kk-l-1)][l],f[i-1][j][k]);
			   else if(l==kk)
			     add(f[i][jj][kk],f[i-1][j][k]);
			   else
			     add(f[i][jj-(l-kk-1)][kk+1],f[i-1][j][k]);
			}
	k=0;
	for(i=1;i<=2*n-1;i++)
	  for(j=1;j<=i;j++)
	    add(k,f[n][i][j]);
	printf("%d\n",k);
	return 0;
}


Measured memory_bytes: 3200
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let it = stdin.lock().bytes().map(|c| c.unwrap() as char);
    let (fs, ft) = (|c: &char| c.is_whitespace(), |c: &char| !c.is_whitespace());
    let token = it.skip_while(fs).take_while(ft).collect::<String>();
    token.parse().ok().unwrap()
}
#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    f(std::io::BufWriter::new(out.lock()));
}
#[allow(unused_macros)]
macro_rules! debug {
    ($($var:expr),*) => { #[cfg(debug_assertions)] {
        $({ match &$var { v => eprint!("{}={:?} ", stringify!($var), v) } })*
        eprintln!();
    }};
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();
    let t: Vec<char> = input::<String>().chars().collect();

    let mut ans = 0;
    for i in 0..3 {
        if s[i] == t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define ll long long
template<typename T, typename U> 
static inline void amin(T &x, U y){
	if(x>y)
		x = y;
}
template<typename T, typename U> 
static inline void amax(T &x, U y){
	if(x<y)
		x = y;
}
#define rep(i,n) for(int i = 0; i < n; ++i)
#define REP(i,k,n) for(int i = k; i <= n; ++i)
#define REPR(i,k,n) for(int i = k; i >= n; --i)

int inf = 2e9;
ll INF = 2e18;
const int mod = 1e9+7;

int main(){
	int n;
	cin >> n;
	double p[n];
	for(int i=0;i<n;++i)	
		cin >> p[i];
	double dp[n][n/2+2];
	int reqHeads = n/2+1;
	dp[0][0] = 1 - p[0];
	dp[0][1] = p[0];
	for(int i=1;i<n;++i){
		dp[i][0] = dp[i-1][0]*(1-p[i]);
		for(int j=1;j<=reqHeads;++j){
			dp[i][j] = p[i]*dp[i-1][j-1] + (1.0-p[i])*dp[i-1][j];
		}
	}
	double ptail = 0;
	for(int j=0;j<reqHeads;++j)
		ptail += dp[n-1][j];
	
	cout<<fixed<<setprecision(10)<<(1-ptail)<<endl;
	return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    int ans = n * (n-1) / 2 + m * (m-1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <iterator>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <unordered_map>

using namespace std;

bool month(string s){
    return "01" <= s && s <= "12";
}

bool year(string s){
    return "00" <= s && s <= "99";
}

void solve() {
    string s; cin >> s;
    string bef = s.substr(0,2);
    string aft = s.substr(2,2);

    string msg;
    if(month(bef) && month(aft)) msg = "AMBIGUOUS";
    else if(month(bef) && year(aft)) msg = "MMYY";
    else if(year(bef) && month(aft)) msg = "YYMM";
    else msg = "NA";

    cout << msg << endl;
}

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

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n , k; 
    cin >> n >> k ;
    vector<int> a(n) ;
    vector<bool> vis(n) ;
    for(int i = 0; i < n; i++){
        cin >> a[i] ;
        a[i]--;
    }
    int start = 0 ;
    vis[start] = true ;
    while(k >= 0){
        k--;
        if ( k == 0 ){
            cout << a[start] + 1 << endl;
            return 0 ;
        }
        if ( vis[a[start]] ) break ; 
        vis[a[start]] = true ;
        start = a[start] ;
    }
    int current = a[start] ;
    vis.clear() ;
    vis = vector<bool>(n) ;
    int len = 0 ;
    while(not vis[a[start]]) {
        vis[a[start]] = true ;
        len++;
        start = a[start] ;
    }
    debug() << imie(len) ;
    k %= len ;
    while(k >= 0){
        if ( k == 0 ){
            cout << current + 1 << endl;
            return 0 ;
        }
        k--;
        current = a[current] ;
    }
    assert(false) ;
    return 0;
}

Measured memory_bytes: 4784
a,b,k =map(int,input().split())

ans =[]
dai = 0
if a>b:
    dai = a
else:
    dai = b
for i in range(1,dai+1):
    if a %i ==0 and b%i==0:
        ans.append(i)
ans.sort(reverse=True)
print(ans[k-1])

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll a; string s;
	cin>>a>>s;
	ll b = (s[0] - '0')*100 + (s[2] - '0')*10 + (s[3] - '0');
	ll tmp = a*b;
	tmp /= 100;
	cout<<tmp<<endl;

	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(void)
{
	int a[10];
	int b, c, d;
	
	for (b = 0; b < 10; b++) {
		scanf("%d", &a[b]);
	}
	
	for (b = 0; b < 10; b++) {
		for (c = 0; c < 10; c++) {
			if (a[b] < a[c]) {
				d = a[c];
				a[c] = a[b];
				a[b] = d;
			}
		}
	}
	
	for (b = 9; b > 6; b--) {
		printf("%d\n", a[b]);
	}
	
	return (0);
}	

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

#define M 244140624
#define L 12

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int find(char str[]){
  return strcmp(H[getKey(str)], str) == 0;
}

void insert(char str[]){
  strcpy(H[getKey(str)], str);
}

int main(){
  int i, n, h;
  char str[L], com[9];
  //for ( i = 0; i < M; i++ ) H[i][0] = '\0';

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}

Measured memory_bytes: 100040
#include <vector>
#include <iostream>
using namespace std;
vector<int> vals;
void enumeration(int x, int bit, int d) {
	if (d == 0) {
		if (bit == 7) vals.push_back(x);
		return;
	}
	enumeration(x * 10 + 3, bit | 1, d - 1);
	enumeration(x * 10 + 5, bit | 2, d - 1);
	enumeration(x * 10 + 7, bit | 4, d - 1);
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= 9; ++i) {
		enumeration(0, 0, i);
	}
	int ans = 0;
	for (int i : vals) {
		if (i <= n) ++ans;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 512
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X == i*500+j*100+k*50:
                cnt += 1
print(cnt)

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1001001001;

const int mod = 1000000007;

int main() {
    string s;

    cin >> s;

    map<char, int> m;

    for (int i = 0; i < 4; i++) {
        char c = s[i];
        m[c]++;
    }

    if (m.size() == 2 && (*m.begin()).second == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
const int MR=2e5+10;
typedef long long LL;

int a[MR],p[MR],ans[MR],plen;
bool vis[MR];
vector<int> d[MR];

void dfs(int idx){
	int rawplen=plen,rawlow,rawp;
	int* low=lower_bound (p, p+plen, a[idx]); 
	if(low==p+plen) {
		p[plen]=a[idx];
		plen++;
	}
	else{
		rawlow=low-p;
		rawp=p[rawlow];
		p[rawlow]=a[idx];
	}
	ans[idx]=plen;
	vis[idx]=true;
	int len=d[idx].size();
	for(int j=0;j<len;j++){
		if(vis[d[idx][j]]) continue;
		dfs(d[idx][j]);
	}


	if(plen!=rawplen) plen--;
	else p[rawlow]=rawp;
}

int main() {
	int n,u,v;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<n;i++){
		cin>>u>>v;
		d[u].push_back(v);
		d[v].push_back(u);
	}
	plen=0;
	dfs(1);
	for(int i=1;i<=n;i++){
		printf("%d\n",ans[i]);
	}
    return 0;
}

Measured memory_bytes: 30532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int n, l;
  cin >> n >> l;
  
  vector<string> s(n);
  for ( int i = 0; i < n; i++ )
    cin >> s[i];
  
  sort(s.begin(), s.end());
  
  for( auto x: s )
    cout << x;
  
  cout << endl;
  
}

Measured memory_bytes: 256
import copy
n=int(input())
list=[int(input()) for i in range(n)]
temp_list = copy.copy(list)
temp_list.sort(reverse=True)

max = 0
for c in list:
    if(c == temp_list[0]):
        print(temp_list[1])
    else:
        print(temp_list[0])

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

using namespace std;
const int MAX = 100000 + 5;
int height[MAX];
vector<int> path[MAX];



int main()
{
    int n, m;
    cin >> n >> m;

    for (int i = 0; i < n; i++)
    {
        cin >> height[i];
    }
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j : path[i])
        {
            if(height[i]<=height[j])
            {
                cnt++;
                break;
            }
        }
    }
    cout << n - cnt << endl;
    return 0;
}

Measured memory_bytes: 9160
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=505;
int sum[2][N][N],f[N][N],n,ans=1e15;

int calc(int o,int l1,int r1,int l2,int r2){
	return sum[o][r1][r2]-sum[o][l1][r2]-sum[o][r1][l2]+sum[o][l1][l2];
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++){
		int x=0;
		if(i^j) read(x);
		for(int o:{0,1}) sum[o][i][j]=sum[o][i-1][j]+sum[o][i][j-1]-sum[o][i-1][j-1]+((i<j)^o)*x;
	}
	for(int i=0;i<=n;i++) for(int j=0;j<=i;j++) f[i][j]=1e15;
	f[0][0]=0;
	for(int i=0;i<n;i++) for(int j=0;j<=i;j++) for(int k=i+1;k<=n;k++)
		f[k][i]=min(f[k][i],f[i][j]+calc(0,i,k,i,k)+calc(1,i,k,0,j));
	for(int i=0;i<n;i++) ans=min(ans,f[n][i]);
	write(ans);
}

Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
#include <atcoder/math>
using namespace atcoder;
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
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; }
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a / gcd(a, b) * b;}
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion
const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;
const int MAX = 2000005;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int t; cin >> t;
	while(t--){
		ll n, m, a, b; cin >> n >> m >> a >> b;
		cout << floor_sum(n, m, a, b) << endl;
	}
	
} 


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

int main() {
    int n;
    cin >> n;
    int min;
    cin >> min;
    int res = 1;
    for (int i = 1; i < n; i++) {
        int temp;
        cin >> temp;
        if (min > temp) {
            min = temp;
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define find(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

const int MAX_N = 100;
int s[MAX_N + 1], e[MAX_N + 1];
int N, t = 1;
vector<vector<int>> g(MAX_N + 1);

void dfs(int i) {
  if (s[i] > 0) return;
  // cout << "i = " << i << ", t = " << t << endl;

  s[i] = t++;
  for (int j = 0; j < g[i].size(); j++) {
    dfs(g[i][j]);
  }
  e[i] = t++;
}

void dfs() {
  for (int i = 1; i <= N; i++) {
    if (s[i] > 0) continue;
    dfs(i);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));

  cin >> N;
  for (int i = 0; i < N; i++) {
    int u; cin >> u;
    int k; cin >> k;
    for (int ki = 0; ki < k; ki++) {
      int tmp; cin >> tmp;
      g[u].push_back(tmp);
    }
    sort(g[u])
  }

  memset(s, 0, sizeof(s));
  memset(e, 0, sizeof(e));

  // outl("-------------")
  // for (int i = 1; i <= N; i++) {
  //   cout << i << " ";
  //   for (int j = 0; j < g[i].size(); j++) {
  //     cout << g[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  // outl("-------------")

  dfs();

  for (int i = 1; i <= N; i++) {
    cout << i << " " << s[i] << " " << e[i] << endl;
  }
}



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

bool aaa(long a,long b) {
  long aa=a;
  while(aa%b==0) aa=aa/b;
  if(aa%b==1) return true;
  else return false;
}
int main() {
  long n,ans=0;
  cin >> n;
  for(long i=1;i*i<=n-1;i++) {
    if((n-1)%i==0) {
      if(i!=1) ans++;
      if(i*i!=n-1) ans++;
    } 
  }
  for(long i=1;i*i<=n;i++) {
    if(n%i==0) {
      if(i!=1) if(aaa(n,i)) ans++;
      if(i*i!=n) if(aaa(n,n/i)) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	var H, W int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &H, &W)

	table := make([][]string, H+2)
	for j := 0; j < len(table); j++ {
		table[j] = make([]string, W+2)
	}
	for i := 1; i <= H; i++ {
		var str string
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%s", &str)
		chars := strings.Split(str, "")
		for j, c := range chars {
			table[i][j+1] = c
		}
	}

	ans := true
	for i := 1; i < H+1; i++ {
		for j := 1; j < W+1; j++ {
			if table[i][j] != "#" {
				continue
			}
			if table[i-1][j] != "#" &&
				table[i+1][j] != "#" &&
				table[i][j-1] != "#" &&
				table[i][j+1] != "#" {
				ans = false
				break
			}
		}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 768
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<algorithm>
using namespace std;
#define N 200005
#define mod 1000000007
#define sz(x) (int)(x).size()
#define push push_back
typedef long long ll;

//bool comp(int a, int b) {return a > b;}

int n;
vector<int> v;
char t1[N], t2[N];

int main()
{
	scanf("%d", &n);
	scanf("%s", t1+1);
	scanf("%s", t2+1);
	
	for(int i = 1; i <= n; ++i)
	{
		if(i == n || t1[i+1] != t1[i]) { 
			v.push(1);
		}
		else {
			v.push(2);
			i++;
		}
	}
	ll res = 1;
	//puts("");
	for(int i = 0; i < sz(v); ++i) {
		if(v[i] == 1) {
			if(i == 0) res *= 3;
			else if(v[i-1] == 1) res *= 2;
		}
		else {
			if(i == 0) res *= 6;
			else if(v[i-1] == 1) res *= 2;
			else res *= 3;
		} 
		res %= mod;
	}
	printf("%lld", res);
}


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

int main(){

int ans=0;
long N;
scanf("%ld",&N);

int digit[17];
for (int i = 16; i >= 0; i--){
  digit[i]=N%10;
  N/=10;
}

int s;
for (int i = 0; i < 17; i++){
  if (digit[i]!=0){
    s=i;
    break;
  }
}

ans=digit[s];
for (int i = s+1; i < 17; i++)
{
  if (digit[i]==9){
    ans+=9;
  }else{
    ans += (16-i+1)*9-1;
    break;
  }
} 

printf("%d",ans);

return 0;

}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define mp(a, b) make_pair((a), (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}



void smain();

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

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


void smain() {
    int n;
    cin >> n;
    vector<pair<string, int>> a(n);
    fori (i, n) {
        cin >> a[i].first >> a[i].second;
    }
    string x;
    int ans = 0;
    cin >> x;
    bool ok = false;
    fori (i, n) {
        if (ok)
            ans += a[i].second;
        if (a[i].first == x)
            ok = true;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<cmath>
using namespace std;
 
#define ll long long int
int main(){
  int n,k;cin>>n>>k;int a[n];int s=0;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  for(int j=0;j<k;j++)
  {
    s=s+a[j];
  }
  cout<<s;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

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

    std::cout<<std::ceil((a + b) / 2.0)<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define vi vector<int>
typedef long long llong;
using namespace std;

int main(){
	int n,t;
	cin>>n>>t;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	//a.push_back(a[n-1]+t);
	
	llong ans=0;
	REP(i,n-1){
		if(a[i+1]-a[i]<t) ans+=a[i+1]-a[i];
		else ans+=t;
	}
	ans+=t;
	
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>

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

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
	LL N,A;
	cin >> N>>A;
	if (N % 500 <= A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
    val N = readLine()!!.toInt()
    var aList = mutableListOf<Int>()
    var nextMaxA = 0;
    for (i in 1..N) {
        aList.add(readLine()!!.toInt())
    }
    var sortedList = aList.sortedDescending()
    for (i in 0..N-1) {
        if (aList[i] == sortedList[0]) {
            println(sortedList[1])
        } else {
            println(sortedList[0])
        }
    }

}


Measured memory_bytes: 68084
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
using namespace std;
int main(){

  int n,d,count=0,i=0;
  cin>>n>>d;
  while(i<n){
    i+=2*d;
    count++;
    i++;
  }
  cout<<count;

}


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

// #define int long long
#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define fro(i,j,n) for(int i = (j);i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second

int cnt[1000000];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int n;
    cin >> n;
    ffor(i,n - 1){
      int x;
      cin >> x;
      cnt[x]++;
    }
    ffor(i,n){
      cout << cnt[i + 1] << '\n';
    }
}		

Measured memory_bytes: 4436
#include<stdio.h>
int main(void){
  int sum,n,nk,k,s,r,sy,e,max,minto;
  max=0;
  minto=500;

 
  while(1){

  scanf("%d",&nk);

  if(nk==0){ break; }


    for(n=0;n<nk;n++){

  scanf("%d%d%d%d%d",&k,&s,&r,&sy,&e);

  sum=(k+s+r+sy+e);

  if(sum > max){ max=sum; }
  if(sum < minto){ minto=sum; }

    }  
  printf("%d %d\n",max,minto);
  
  max=0;
  minto=500;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.util.EnumMap;

public class Main {

  public static void main(String[] args) {
    final List<Judge> judges = new JudgeReader().read();
    final Map<Judge, Integer> countOrNull = new JudgeCounter().countOrNull(judges);
    new CountPrinter().write(countOrNull);
  }

static class JudgeCounter {
  public Map<Judge, Integer> countOrNull(final List<Judge> judges) {
    final Map<Judge, Integer> countBuilder = new EnumMap<>(Judge.class);
    for (final Judge judge : judges) {
      countBuilder.compute(judge, this::increment);
    }
    return Map.copyOf(countBuilder);
  }
  private Integer increment(final Judge judge, final Integer count) {
    if (count == null) {
      return 1;
    }
    return count + 1;
  }
}

static class JudgeReader {

  public List<Judge> read() {
    final Scanner scanner = new Scanner(System.in);
    final int testAmount = scanner.nextInt();
    final List<Judge> judgeBuilder = new ArrayList<>(testAmount);
    for (int i = 0; i < testAmount; i++) {
      judgeBuilder.add(Judge.valueOf(scanner.next()));
    }
    return List.copyOf(judgeBuilder);
  }

}

}

class CountPrinter {
  public void write(final Map<Judge, Integer> countOrNull) {
    System.out.printf("AC x %d\n", countOrNull.getOrDefault(Judge.AC, 0));
    System.out.printf("WA x %d\n", countOrNull.getOrDefault(Judge.WA, 0));
    System.out.printf("TLE x %d\n", countOrNull.getOrDefault(Judge.TLE, 0));
    System.out.printf("RE x %d\n", countOrNull.getOrDefault(Judge.RE, 0));
  }
}

enum Judge {
  AC,
  WA,
  TLE,
  RE,
  ;
}


Measured memory_bytes: 58712
N=int(input())

n=10**6
#primeに素数を保管する下準備
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
from collections import defaultdict
def prime_factorization(N):
    dic=defaultdict(int)
    for some in prime:
        if N%some==0:
            while N%some==0:
                N=N//some
                dic[some]+=1
        else:
            pass
    if N!=1:
        dic[N]=1
    return dic
ans=0
K=prime_factorization(N)
import bisect
H=[i*(i-1)//2 for i in range(10**4)]

for value in K.values():
    ans+=bisect.bisect_right(H,value)-2
print(ans)



Measured memory_bytes: 78060
#include<stdio.h>
typedef long long ll;

struct position{
    ll x;
    ll y;
};
int main(){
    ll n,d;
    scanf("%lld%lld",&n,&d);
    ll i;
    struct position pq[200005];
    for(i=0;i<n;i++){
        scanf("%lld%lld",&pq[i].x,&pq[i].y);
    }
    ll distance,key;
    ll count = 0;
    key = d*d;
    for(i=0;i<n;i++){
        distance = pq[i].x*pq[i].x + pq[i].y*pq[i].y;
        if(key>=distance){
            count++;
            //printf("x=%lld,y=%lld\n",pq[i].x,pq[i].y);
        }
    }
    printf("%lld\n",count);
    return 0;
}

Measured memory_bytes: 4856
#include<stdio.h>
#include<stdlib.h>
int main(void){
    long int N,T,*t,j,k,sum;
    scanf("%ld %ld",&N,&T);
    t=(long int *)malloc(N*sizeof(long int));
    for(int i=0;i<N;i++){
        scanf("%ld",&t[i]);
    }
    k=0;
    for(int i=1;i<N;i++){
        j=T-(t[i]-t[i-1]);
        if(j<0){
            j=0;
        }
        k=k+j;
    }
    printf("%ld",N*T-k);
    return 0;
}

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

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

long cnt(long g) {
  long res = 1;
  for (long i = 2; i*i <= g; i++) {
    if (g % i == 0) {
      res++;
      while (g % i == 0) g /= i;
    }
  }
  if (g != 1) res++;
  return res;
}

int main() {
  long a, b;
  cin >> a >> b;
  long g = gcd(a, b);
  cout << cnt(g) << endl;
  return 0;
}

Measured memory_bytes: 256
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define PI 3.14159265359

int n, m;
char grid[1001][1001];
int memo[1001][1001];
int mod = 1e9 + 7;

// int dp(int x, int y)
// {
    // if (x == n || y == m) return 0;
    // if (x == n - 1 && y == m - 1) return 1;
    // if (grid[x][y] == '#') return 0;
    // if (memo[x][y] != -1) return memo[x][y];
    // return memo[x][y] = (dp(x + 1, y) % mod + dp(x, y + 1) % mod) % mod;
// }

bool legit(int x, int y)
{
    return 0 <= x && x < n && 0 <= y && y < m && grid[x][y] != '#';
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    memset(memo, 0, sizeof(memo));
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> grid[i][j];
        }
    }
    // cout << dp(0, 0) << endl;
    memo[n - 1][m - 1] = 1;
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            if (legit(i + 1, j)) {
                memo[i][j] += memo[i + 1][j];
            }
            if (legit(i, j + 1)) {
                memo[i][j] += memo[i][j + 1];
            }
            memo[i][j] %= mod;
        }
    }
    cout << memo[0][0] << endl;

    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;





int main(){

	int N;
	scanf("%d",&N);

	char buf[4];

	int ac=0,wa=0,tle=0,re=0;

	for(int i = 0; i < N; i++){

		scanf("%s",buf);

		switch(buf[0]){
		case 'A':
			ac++;
			break;
		case 'W':
			wa++;
			break;
		case 'T':
			tle++;
			break;
		case 'R':
			re++;
			break;
		}
	}

	printf("AC x %d\n",ac);
	printf("WA x %d\n",wa);
	printf("TLE x %d\n",tle);
	printf("RE x %d\n",re);

	return 0;
}


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

main() {
  int N; cin >> N;
  int score = 0, ans = 1;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i == 0) continue;

    if (A[i] - A[i - 1] > 0) {
      if (score < 0) {
        ans++;
        score = 0;
      } else {
        score = 1;
      }
    } else if (A[i] - A[i - 1] < 0) {
      if (score > 0) {
        ans++;
        score = 0;
      } else {
        score = -1;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
    int K;
    int N;
    int A[200000];
    int max;

    scanf("%d %d", &K, &N);
    for (int i = 0; i < N; i++)
        scanf("%d", &A[i]);
    
    max = K - A[N - 1] + A[0];
    for (int j = 2; j < N; j++)
        if (max < A[j] - A[j - 1])
            max = A[j] - A[j - 1];
    printf("%d\n", K - max);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
{
string a,b,c;
cin>>a>>b>>c;
a[0] = a[0]-'a'+'A';
b[0] = b[0]-'a'+'A';
c[0] = c[0]-'a'+'A';
cout<<a[0]<<b[0]<<c[0]<<endl;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INF 0x7fffffff
#define ST_SIZE ((1 << 18) - 1)
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int LL;
LL dat[ST_SIZE];
LL input(void);
void update(LL a, LL b, LL x, LL k, LL l, LL r);
LL find(LL a, LL b, LL k, LL l, LL r);
int main (void) {
  int command, x;
  LL i, n, q, s, t;
  n = input();
  q = input();
  for (i = 0; i < n; i++) dat[i] = INF;
  for (i = 0; i < q; i++) {
    command = input();
    if (!command) {
      s = input();
      t = input();
      x = input();
      update(s, t + 1, x, 0, 0, n);
    } else {
      s = input();
      t = input();
      printf("%lld\n", find(s, t + 1, 0, 0, n));
    }
  }
}
LL input(void)
{
  LL n = 0;
  int c = getchar_unlocked();
  if (c == '-') {
    c = getchar_unlocked();
    do {
      n = 10 * n + c - '0';
      c = getchar_unlocked();
    } while (c >= '0' && c <= '9');
    return -n;
  } else {
    do {
      n = 10 * n + c - '0';
      c = getchar_unlocked();
    } while (c >= '0' && c <= '9');
    return n;
  }
}
void update(LL a, LL b, LL x, LL k, LL l, LL r)
{
  LL m = (l + r) / 2;
  if (a >= r || b <= l) return;
  else if (a <= l && b >= r) dat[k] = x;
  else {
    if (dat[k] != -1) {
      dat[k*2+1] = dat[k*2+2] = dat[k];
      dat[k] = -1;
    }
    update(a, b, x, k * 2 + 1, l ,m);
    update(a, b, x, k * 2 + 2, m, r);
  }
}
LL find(LL a, LL b, LL k, LL l, LL r)
{
  LL m = (l + r) / 2;
  if (a >= r || b <= l) return INF;
  else {
    if (dat[k] != -1) return dat[k];
    else {
      LL vl, vr;
      vl = find(a, b, k * 2 + 1, l, m);
      vr = find(a, b, k * 2 + 2, m, r);
      return min(vl, vr);
    }
  }
}


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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;


int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    u64 X;
    cin >> X;
    
    if (X >= 400 && X <= 599) {
        cout << 8 << endl;
    } else if (X >= 600 && X <= 799){
        cout << 7 << endl;
    } else if (X >= 800 && X <= 999){
        cout << 6 << endl;
    } else if (X >=1000 && X <= 1199){
        cout << 5 << endl;
    } else if (X >= 1200 && X <= 1399){
        cout << 4 << endl;
    } else if (X>= 1400 && X<= 1599){
        cout << 3 << endl;
    } else if (X>=1600 && X <= 1799){
        cout << 2 << endl;
    } else if (X >= 1800 && X<= 1999){
        cout << 1 << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3644