akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

int main()
{   
    int x, n;
    cin >> x >> n;
    set<int> s;
    rep(i, n) {
        int a;
        cin >> a;
        s.insert(a);
    }

    int min = 114514;
    int ans = 114514;
    rep(i, 102) {
        if(s.count(i)) continue;
        int t = abs(x-i);
        if(t < min) {
            min = t;
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3524
ans=[]
while True:
    scMax=0
    scMin=500
    n=input()
    if n==0:
        break
    for i in xrange(n):
        score=sum(map(int,raw_input().split()))
        if score > scMax:
            scMax=score
        if score < scMin:
            scMin=score
    ans.append(str(scMax)+' '+str(scMin))
    
for i in ans:
    print i

Measured memory_bytes: 4224
from collections import defaultdict
n = int(input())

d = defaultdict(int)
for _ in range(n):
    key = input()
    d[key] += 1

dict = sorted(d.items(), key=lambda x:x[1], reverse=True)
max_v = max(d.values())

dict_li = []
for a in dict:
    if a[1]==max_v:
        dict_li.append(a[0])

dict_li.sort()
print(*dict_li, sep='\n')


Measured memory_bytes: 48888
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[210000];
int to[60][210000];
int main(){
	int a;
	long long b;scanf("%d%lld",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
		p[i]--;
		to[0][i]=p[i];
	}
	for(int i=1;i<60;i++){
		for(int j=0;j<a;j++){
			to[i][j]=to[i-1][to[i-1][j]];
		}
	}
	int at=0;
	for(int i=0;i<60;i++){
		if(b&(1LL<<i)){
			at=to[i][at];
		}
	}
	printf("%d\n",at+1);
}

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

using namespace std;

using ll = long long;

int main(){
   ll n, k;
   cin >> n >> k;
   vector<ll> v(n);
   for(ll i = 0; i < n; ++i){
    cin >> v[i];
   }
   ll ans = 0;
   for(ll i = 0; i < n; ++i){
    if(v[i] >= k)ans++;
   }
   cout << ans;
   return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>


using namespace std;


int main() {

	string S;
	int N, K;
	cin >> N >> K >> S;
	K -= 1;
	S[K] = S[K] + 32;

	cout << S << endl;

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 1e5 + 5;

int main()
{
	int n,k,q,a[N],b[N] = {0};
	cin >> n >> k >> q;
	for(int i = 1;i <= n;i++){
		a[i] = k;
	}
	int tot = 0;
	while(q--){
		int t;
		scanf("%d",&t);
		tot++;
		b[t]++;
	}
	for(int i = 1;i <= n;i++){
		a[i] -= (tot - b[i]);
		if(a[i] <= 0)
			printf("No\n");
		else
			printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<string,pair<int,int> > x,pair<string,pair<int,int> > y)
{
	if(x.first<y.first)
	{
		return true;
	}
	else if(x.first>y.first)
	{
		return false;
	}
	if(x.second.first>y.second.first)
	{
		return true;
	}
	else
	{
		return false;
	}
}
int main(){
	vector<pair<string,pair<int,int> > > ans;
	int n,i,p;
	string s;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>s>>p;
		ans.push_back(make_pair(s,make_pair(p,i)));
	}
	sort(ans.begin(),ans.end(),cmp);
	for(i=0;i<ans.size();i++)
	{
		cout<<ans[i].second.second<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
a, b, m = map(int, input().split())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
ml = []

ml = [input().split() for i in range(m)]

mp = min(al) + min(bl)
mpl = []

for i in range(m):
    aa = int(ml[i][0])
    bb = int(ml[i][1])

    mpl.append(int(al[aa - 1]) + int(bl[bb - 1]) - int(ml[i][2]))

print(min(mp, min(mpl)))

Measured memory_bytes: 50184
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>
#include<chrono>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
    ll gcd(ll a, ll b) {
        return (a == 0 ? b : gcd(b % a, a));
    }
    ll gcdex(ll a, ll b, ll& x, ll& y) {
        if (a == 0) {
            x = 0; y = 1;
            return b;
        }
        ll x1, y1;
        ll d = gcdex(b % a, a, x1, y1);
        x = y1 - (b / a) * x1;
        y = x1;
        return d;
    }

    ll inv_eu(ll a, ll m) {
        ll x, y;
        ll g = gcdex(a, m, x, y);
        if (g != 1)
            assert(0);
        else {
            x = (x % m + m) % m;
            return x;
        }
    }
}

ll const maxn = 3e5 + 5;

ll dp[2005];

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

    ll n; cin >> n;
    ll rofl = poww(10, n);
    ll kek = poww(9, n);
    ll kek1 = poww(8, n);
    cout << ((rofl - 2*kek + kek1) % mod + mod) % mod << endl;

    return 0;
}

/*

*/


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    string s;
    cin >> s;
    for(char& c: s) {
        if (c == '1')
            c = '9';
        else if (c == '9')
            c = '1';
    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
double math_max(double v1,double v2){
	if(v1>v2){
		return v1;
	}
	return v2;
}

double math_min(double v1,double v2){
	if(v1<v2){
		return v1;
	}
	return v2;
}
double math_abs(double v1){
	if(v1<0){
		return v1*-1;
	}
	return v1;
}
main(){
	int n;
	cin>>n;
	for(int loop=0;loop<n;++loop){
		int d,max=0,min=0,tmp;
		cin>>d;
		cin>>tmp;
		for(int i=0;i<d-1;++i){
			int k;
			cin>>k;
			max=math_max(max,k-tmp);
			min=math_min(min,k-tmp);
			tmp=k;
		}
		if(min==102)min=0;
		cout<<max<<" "<<math_abs(min)<<endl;
	}
}

Measured memory_bytes: 1236
#include <iostream>

using namespace std;

int call(int n){
	int i=0;
	for (i = 1; i <= n; i++){
		int x=i;
		if(x%3==0) cout<<" "<<i;
		else{
			while(x>0){
				if(x%10==3){
					cout<<" "<<i;
					break;
				}
				x/=10;
			}
		}
	}
	cout<<endl;
}

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

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a, v;
    cin >> a >> v;
    int b, w;
    cin >> b >> w;
    int t;
    cin >> t;
    if (v <= w)
        print("NO");
    else {
        if (abs(a - b) <= (v - w) * t)
            print("YES");
        else
            print("NO");
    }

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>

using namespace std;

int main() {


	string s, t,u;
	int a, b;

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if (s == u) {
		cout << a - 1 << " " << b<<endl;
	}
	else {
		cout << a << " " << b-1 << endl;
	}

	return 0;
	
}

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

struct PrimalDual{
  const int INF = 1<<28;
  typedef pair<int,int> P;
  struct edge{
    int to,cap,cost,rev;
    edge(){}
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<int> h,dist,prevv,preve;

  PrimalDual(){}
  PrimalDual(int sz):n(sz),G(sz),h(sz),dist(sz),prevv(sz),preve(sz){}
  
  void add_edge(int from,int to,int cap,int cost){
    G[from].push_back(edge(to,cap,cost,G[to].size()));
    G[to].push_back(edge(from,0,-cost,G[from].size()-1));
  }

  int flow(int s,int t,int f){
    int res=0;
    fill(h.begin(),h.end(),0);
    while(f>0){
      priority_queue<P,vector<P>,greater<P> > que;
      fill(dist.begin(),dist.end(),INF);
      dist[s]=0;
      que.push(P(0,s));
      while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(dist[v]<p.first) continue;
        for(int i=0;i<(int)G[v].size();i++){
          edge &e=G[v][i];
          if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
            dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
            prevv[e.to]=v;
            preve[e.to]=i;
            que.push(P(dist[e.to],e.to));
          }
        }
      }
      if(dist[t]==INF) return -1;
      for(int v=0;v<n;v++) h[v]+=dist[v];
      int d=f;
      for(int v=t;v!=s;v=prevv[v]){
        d=min(d,G[prevv[v]][preve[v]].cap);
      }
      f-=d;
      res+=d*h[t];
      for(int v=t;v!=s;v=prevv[v]){
        edge &e=G[prevv[v]][preve[v]];
        e.cap-=d;
        G[v][e.rev].cap+=d;
      }
    }
    return res;
  }
};

int main(){
  vector<int>v;
  int x;
  while(cin>>x){
    v.push_back(x);
  }
  sort(v.begin(),v.end(),greater<int>());
  std::vector<int> g;
  r(i,min((int)v.size(),100))g.push_back(v[i]);
  int n=g.size();
  PrimalDual p(n+3);
  r(i,n)p.add_edge(n,i,1,0);
  r(i,n)p.add_edge(i,n+1,1,-g[i]);
  p.add_edge(n+1,n+2,3,0);
  p.flow(n,n+2,3);
  r(i,n){
    r(j,p.G[i].size()){
      if(p.G[i][j].to==n+1&&p.G[i][j].cap==0){
        cout<<p.G[i][j].cost*-1<<endl;
      }
    }
  }
}


Measured memory_bytes: 3160
#include <iostream>
using namespace std;
int main(){
  int n,a,b,ap,bp,i;
  while(1){
    cin >> n;
    if(n==0) break;
    ap=bp=0;
    for(i=0;i<n;i++){
      cin >> a >> b;
      if(a>b) ap+=a+b;
      else if(b>a) bp+=a+b;
      else ap+=a,bp+=b;
    }
    cout << ap << ' ' << bp << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
H, W, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

place = [[0, 0] for _ in range(H * W)]
for h in range(H):
	for w in range(W):
		place[a[h][w] - 1] = [h, w]

cost = [abs(place[i][0] - place[i + d][0]) + abs(place[i][1] - place[i + d][1]) for i in range(H * W - d)]

ans = [0 for _ in range(H * W)]

for i in range(d, H * W):
	ans[i] = ans[i - d] + cost[i - d]

Q = int(input())

for q in range(Q):
	l, r = map(int, input().split())
	print(ans[r - 1] - ans[l - 1])

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

using namespace std;

int main(){
    long long int a, b, x, n;
    cin >> a >> b >> x;
    long long int ans=0;
    if(a%x!=0){
        a+=(x-a%x);
    }
    if(a<b){
        n=b-a;
        ans=n/x+1;
    }else if(a==b){
        if(a%x==0)
            ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n,r,p,c,t[50],s[50];
	while(true){
		cin >> n >> r;
		if(n==0 && r==0) return 0;
		for(int i=0;i<n;i++)
			t[i]= n-i;
		for(int i=0;i<r;i++){
			cin >> p >> c;
			for(int j=0;j<c;j++)
				s[j]=t[p-1+j];
			for(int j=0;j<p-1;j++)
				s[j+c]=t[j];
			for(int j=p+c-1;j<n;j++)
				s[j]= t[j];
			for(int j=0;j<n;j++)
				t[j]=s[j];

		}
		cout << t[0]<< endl;
	}

}


Measured memory_bytes: 2984
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a,b,c,d; cin>>a>>b>>c>>d;
  if (a+b>c+d) cout << "Left\n";
  else if (a+b==c+d) cout << "Balanced\n";
  else cout << "Right\n";
  return 0;
}


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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) { s >> x; } return s;}
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    string S; cin >>S;

    cout << (
        S[0] == 'A'
        && count(S.begin()+2, S.end()-1, 'C') == 1
        && count_if(ALL(S), [](char c) { return isupper(c); }) == 2
        ? "AC" : "WA"
    ) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc045/tasks/arc061_a

int main() {
    string S; cin >> S;
    int len = S.length();

    ll ans = 0;
    for (int msk = 0; msk < 1 << (len - 1); msk++) {

        ll num = S[0] - '0';
        for (int i = 0; i < len - 1; i++) {
            if (msk & 1 << i) {
                ans += num;
                num = 0;
            }
            num = num * 10 + (S[i+1] - '0');
        }
        ans += num;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

    public static void main(String[] args){

        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();

        while(N > 1000){
            N = N - 1000;
        }
        N = 1000 - N;
        System.out.println(N);
        scan.close();
    }

}

Measured memory_bytes: 35688
#include <stdio.h>
int main(){
    int n;
    int i;
    int* list;

    scanf( "%d", &n );
    
    list = ( int* )malloc( sizeof( int ) * n );
    
    for( i = 0; i < n; i++ ){
        scanf( "%d", list + i );
    }

    for( i = 1; i < n; i++ ){
        printf( "%d ", *( list + n - i ));
    }
    printf( "%d\n", *list );
    return 0;
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    vector <int> b(n);
    int cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        if(a[i]==b[i]){
            cnt++;
        }else{
            if(cnt<3){
                cnt = 0;
            }
        }
    }
    if(cnt>=3){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    } 
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define speed ios::sync_with_stdio(0); cin.tie(0);
int const N = 1e5 + 1;

int main(){
	speed
	int n, h, w;
	cin >> n >> h >> w;
	int ans = (n - h + 1) * (n - w + 1);
	cout << ans << endl;
}


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

void solve() {
	double N, K; cin >> N >> K;

	double ans = 0.0;
	for (int i = 1; i <= N; i++) {
		double eye = i;
		double tmp = 1.0;
		while (eye < K) {
			eye *= 2;
			tmp /= 2.0;
		}
		ans += tmp;
	}
	ans /= N;
	cout << fixed << setprecision(10) << ans << endl;
}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

N, X = map(int, input().split())
a,p=[1],[1]
for i in range(N):
  a.append(a[i] * 2 + 3) 
  p.append(p[i] * 2 + 1)

def f(N,X):
  if N == 0:
    return 0 if X <= 0 else 1 
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1) 
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))


Measured memory_bytes: 31264
import java.util.Scanner;
import java.util.TreeSet;

import static java.lang.System.in;

public class Main {
	static Scanner sc = new Scanner(in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] P = new int[N];
		for (int i = 0; i < N; i++) {
			P[i] = Integer.parseInt(sc.next());
		}
		boolean[] unchange = new boolean[N];
		int prev = 0;
		int unc = 0;
		for (int i = 1; i < N; i++) {
			if (P[i - 1] >= P[i]) {
				for (int j = prev; j <= i - K; j++) {
					unchange[j] = true;
					unc++;
				}
				prev = i;
			}
		}
		for (int j = prev; j <= N - K; j++) {
			unchange[j] = true;
			unc++;
		}
		TreeSet<Integer> set = new TreeSet<>();
		int ans = N - K + 1;
		for (int i = 0; i < K; i++) {
			set.add(P[i]);
		}
		for (int i = K; i < N; i++) {
			if (set.first() == P[i - K] && set.last() < P[i]) {
				if (!unchange[i - K]) {
					System.err.println(i);
					ans--;
				}
			}
			set.remove(P[i - K]);
			set.add(P[i]);
		}
		if (unc > 0) {
			ans -= unc - 1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 67544
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

int main() {
  ll n, x;
  while (true) {
    cin >> n >> x;
    if (n == 0 && x == 0) break;

    ll ans = 0;
    for (ll i = 1; i <= n; i++)
      for (ll j = i + 1; j <= n; j++) {
        ll k = x - i - j;
        bool cond = j < k && k <= n;
        if (cond) ans++;
      }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3092
import sys,heapq,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
R = 10**9 + 7
def ddprint(x):
  if DBG:
    print(x)

def perm(k,d):
    x = k
    for i in range(1,d):
        x = (x * (k-i)) % R
    return x

def dfs(prev, cur):
    d = len(dst[cur])-1
    if d==0:
        return 1
    x = perm(k-2,d)
    for nd in dst[cur]:
        if nd==prev:
            continue
        x = (x * dfs(cur,nd)) % R
    return x

def setrlim():
    sys.setrecursionlimit(250000)
    soft,hard = resource.getrlimit(resource.RLIMIT_STACK)
    resource.setrlimit(resource.RLIMIT_STACK,(128*1024*1024,hard))

setrlim()
n,k = inm()
dst = [ [] for i in range(n) ]
for i in range(n-1):
    a,b = inm()
    a -= 1
    b -= 1
    dst[a].append(b)
    dst[b].append(a)

for i in range(n):
    if len(dst[i]) >= k:
        print(0)
        exit()

d = len(dst[0])
x = perm(k,d+1)
for nd in dst[0]:
    x = (x * dfs(0,nd)) % R
print(x)


Measured memory_bytes: 87676
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  // a>bとする
  if(b==0)return a;
  else gcd(b,a%b);
}
int gcd(vector<int> x){
  int ans=x[0];
  for(int i=1;i<x.size();++i){
    ans=gcd(ans,x[i]);
  }
  return ans;
}
int main(){
  int n;cin>>n;
  vector<int> x(n);
  for(int i=0;i<n;++i)cin>>x[i];
  cout<<gcd(x);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, k;
	cin >> n >> k;
	vector<lli> h(n);
	rep(i,n){
		cin >> h[i];
	}
	sort(all(h));
	lli min = INF;
	for(lli i=0; i+(k-1) < n; i++){
		lli dist = h[i+(k-1)] - h[i];
		if(dist < min) min = dist;
	}
	cout << min << endl;
	return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	int N; cin>>N;
	vector<int> a(N+1,0);
	rep(i,N) cin>>a[i+1];

	int now=1, count=0;
	set<int> old;
	old.insert(now);
	bool flg = false;
	while(!old.count(a[now])){
		now = a[now];
		old.insert(now);
		count++;
		if(now==2){
			flg = true;
			break;
		}
	}

	if(flg){
		cout << count << endl;
	}else{
		cout << -1 << endl;
	}
}


Measured memory_bytes: 8264
num_count = Hash.new(0)

while line = gets
  num_count[line.to_i] += 1
end

max_count = num_count.max_by { |_, val| val }[1]
num_count.select { |_, val|  val == max_count }
  .sort_by { |ary| ary[0] }.each { |ary| puts ary[0] }

Measured memory_bytes: 8708
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
int main()
{
    ll a,b;cin>>a>>b;
    if(a <= 0 && b >= 0) cout << "Zero" << endl;
    else if(a > 0) cout << "Positive" << endl;
    else cout << ((b - a)%2 == 0 ? "Negative" : "Positive") << endl;
    return 0;
}


Measured memory_bytes: 256
stair, bre_num = list(map(int,input().split()))
bre_stairs = []
mae = -1
dekiru = True
for _ in range(bre_num):
	b = int(input())
	if b-mae==1:
		dekiru = False
	bre_stairs.append(b)
	mae = b

bre_stairs.insert(0,-1)
bre_stairs.append(stair+1)

sosu = 1

def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

if dekiru:
	for saki,ato in zip(bre_stairs[1:],bre_stairs[:-1]):
		pat = saki-ato-1
		sosu = sosu * Fib(pat)
	print(sosu % 1000000007)

else:
	print(0)




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

// in-short-use macros

#define all(c) (c).begin(),(c).end()
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010



//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC\n";
    else
        cout<<"ABC\n";
    return 0;
}

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

using namespace std;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
unordered_map<int,int> A;
int tmp;

cin>>N;
for(int i=0;i<N;i++){
    cin>>tmp;
    if(A.count(tmp)==0){
        A[tmp]=1;
    }
    else{
        A.erase(tmp);
    }
}

cout<<A.size()<<endl;

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

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

#define ff first
#define ss second
#define pb push_back


void solve() {
	ll n, mx = 0, ans = 0; cin>>n;
	vector<ll>arr(n);
	for(int i=0;i<n;i++) {
		cin>>arr[i];
		mx = max(mx, arr[i]);
		ans += abs(arr[i]-mx);
	}
	cout<<ans<<endl;
}

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

    int t = 1, no = 0;
    // cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main() {
    string s; cin >> s;
    int n = s.size();
    int i = 0, j = n-1,ans = 0;

    while(i < j){
        if(s[i] == s[j]){
            i++;
            j--;
        }else{
            if(s[i] == 'x'){
                ans++;
                i++;
            }else if(s[j] == 'x'){
                ans++;
                j--;
            }else{
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3692
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        
        String S = null;
        
        S = scanner.next();
        
        int count;
        String small = "";
        
        for(count=0 ; count < S.length() ; count++){
            if(count == K - 1){
                small += String.valueOf(S.charAt(count)).toLowerCase();
            }else{
                small += String.valueOf(S.charAt(count));
            }
        }
        
        System.out.println(small);
        
    }
}

Measured memory_bytes: 22612
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<map>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
#include<algorithm>
using namespace std;

#define debug(x) cout << #x << " = " << x << endl
#define lowbit(x) (x & (-x))

typedef long long LL;
typedef pair<int, int>PII;
const int maxn = 1e5 + 10;

char a[maxn];
int main(){
	scanf("%s", a + 1);
	int len = strlen(a + 1);
	bool vis = true;
	int con = 0;
	for(int i = 1; i <= len ; i ++){
		if(i == 1 && a[i] != 'A') vis = false;
		else if(i >= 3 && i <= len - 1 && a[i] == 'C') con++;
		else if(a[i] != 'C' && a[i] != 'A' && (a[i] > 'z' || a[i] < 'a')) vis = false;
	}
	if(con != 1) vis = false;
	if(vis) printf("AC\n");
	else printf("WA\n");
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, k = LI()
    a = LI()
    for i in range(k, n):
        if a[i] > a[i-k]:
            print('Yes')
        else:
            print('No')
    return


# Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 104064
n = gets.to_i
data = n.times.map { gets.strip.split.map(&:to_i) }

def is_reachable(current, next_data)
    # 次の地点までのマンハッタン距離
    tc, xc, yc = current
    tn, xn, yn = next_data
    dist = (xc - xn).abs + (yc - yn).abs

    # 最短距離でも間に合わない
    return false if dist > tn - tc

    # 行ったり来たりでちょうど到着できるか
    (dist - (tn - tc)).even?
end

current = [0, 0, 0]
data.each do |d|
    unless is_reachable(current, d)
        puts 'No'
        exit 0
    end
    current = d
end

puts 'Yes'

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

const int N = 1e5;

int n;
int nxt[N][333];

int main() {
	vector<int> bits{100,104,105,106,107,111,113,114,115,117,123,125,127,131,136,137,142,145,148,149,151,153,155,157,159,162,163,164,165,166,169,171,172,176,181,185,186,187,191,198,201,202,203,206,207,209,211,215,216,217,220,221,222,223,224,225,227,233,234,235,238,239,242,246,247,250,255,256,257,258,261,264,265,267,272,273,275,277,278,279,282,283,284,285,286,288,289,294,295,298,300,303,304,306,309,312,314,315,317,319,320,323,326,329,332};

	string s;
	cin >> s;

	n = s.size();
	for (int i = 0; i < n; i++) {
		nxt[i][0] = s[i] == 'L' ? i-1 : i+1;
	}
	for (int k = 1; k < 333; k++) {
		for (int i = 0; i < n; i++) {
			nxt[i][k] = nxt[nxt[i][k-1]][k-1];
		}
	}

	vector<int> ans(n);
	for (int i = 0; i < n; i++) {
		int j = i;
		for (int k : bits) {
			j = nxt[j][k];
		}
		ans[j]++;
	}

	for (int x : ans) {
		cout << x << ' ';
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 131200
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    X, K, D = readnums()
    if X > 0:
        if X // D >= K:
            print(X - K * D)
        else:
            a1 = X % D
            a2 = D - X % D
            if (K - X // D) % 2:
                print(a2)
            else:
                print(a1)
    else:
        X = -X
        if X // D >= K:
            print(X - K * D)
        else:
            a1 = X % D
            a2 = D - X % D
            if (K - X // D) % 2:
                print(a2)
            else:
                print(a1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  int n;
  cin >> n;
  vi ans(n);
  REP(i, n-1) {
    int a;
    cin >> a;
    ans[a-1]++;
  }
  for (int x : ans) {
    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 4000
#include<iostream>

using namespace std;

int main() {
	unsigned int N = 0;
	unsigned int min = 0;
	cin >> N;

	while (1) {
		min += N % 10;
		N /= 10;
		if (N == 0) break;
	}

	if (min == 1) min *= 10;
	cout << min << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    bool AC=true;
    int cnt=0;
    int OMOJI=0;
    if(s[0] != 'A' || s[1] == 'C' || s[s.size()-1] == 'C')AC=false;
    for(int i=0;i<s.size();i++){
        if(s[i]>='A' && s[i]<='Z')OMOJI++;
        if(i>1 && i<s.size()-1 && s[i]=='C')cnt++;
    }
    if(cnt!=1 || OMOJI>2)AC=false;

    cout << (AC ? "AC" : "WA");
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1000005;
int n,tot;
struct Str
{
	int a,b,c;
	inline bool operator < (const Str& b)const
	{
		if(1ll*c*b.c<=0) return c>b.c;
		if(c<0) return this->b>b.b;
		return a<b.a;
	}
}A[maxn];
inline Str read()
{
	Str ret=(Str){0,0};char ch=getchar();
	while(ch!='('&&ch!=')') ch=getchar();
	while(ch=='('||ch==')')
	{
		if(ch==')') ret.b?ret.b--:ret.a++;
		else ret.b++;
		ch=getchar();
	}
	ret.c=ret.b-ret.a;
	return ret;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		A[i]=read();
		if(A[i].a==0)
		{
			tot+=A[i].b;
			i--;n--;continue;
		}
	}
	sort(A+1,A+1+n);
	for(int i=1;i<=n;i++)
	{
		tot-=A[i].a;
		if(tot<0)
		{
			printf("No\n");
			return 0;
		}
		tot+=A[i].b;
	}
	printf("%s\n",tot?"No":"Yes");
	return 0;
}

Measured memory_bytes: 7524
#include <iostream> 
#include <cctype> 
#include <bits/stdc++.h>
using namespace std; 
int main() 
{ 
    char x; 
    cin >> x; 
    if (isupper(x))  
        cout << "A"; 
    else 
        cout << "a";     
    return 0; 
} 

Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n, a, b,ans;
    cin >> n >> a >> b;
    if((b-a-1)%2!=0){
        ans = (b-a-1) / 2 + 1;
    }
    else{
        ((a - 1) > (n - b) ? ans = n - b : ans = a - 1);
        ans++;
        (b - a == 1 ? ans += 0 : ans += (b - a - 2) / 2 + 1);
    }
    out(ans);
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	int len = s.size();
	int ans = 0;
	for (int i = 0; i < len; i++) {
		ans += s[i] - '0';
		ans %= 9;
	}
	if (ans == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

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

//Start
typedef long long ll;
typedef double db;
#define mp(a,b) make_pair((a),(b))
#define x first
#define y second
#define be(a) (a).begin()
#define en(a) (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define R(i,a,b) for(int i=(a),I=(b);i<I;i++)
#define L(i,a,b) for(int i=(b)-1,I=(a)-1;i>I;i--)
const int iinf=0x3f3f3f3f;
const ll linf=0x3f3f3f3f3f3f3f3f;

//Data
const int N=2e5;
int n,ans=0;
pair<int,int> p[N];
pair<int,int> lu(iinf,-iinf);
pair<int,int> ru(-iinf,-iinf);
pair<int,int> ld(iinf,iinf);
pair<int,int> rd(-iinf,iinf);

//Main
int main(){
	scanf("%d",&n);
	R(i,0,n){
		scanf("%d%d",&p[i].x,&p[i].y);
		if(p[i].x+p[i].y>ru.x+ru.y) ru=p[i];
		if(p[i].x-p[i].y>rd.x-rd.y) rd=p[i];
		if(-p[i].x+p[i].y>-lu.x+lu.y) lu=p[i];
		if(-p[i].x-p[i].y>-ld.x-ld.y) ld=p[i];
	}
	R(i,0,n){
		ans=max(ans,abs(p[i].x-lu.x)+abs(p[i].y-lu.y));
		ans=max(ans,abs(p[i].x-ru.x)+abs(p[i].y-ru.y));
		ans=max(ans,abs(p[i].x-ld.x)+abs(p[i].y-ld.y));
		ans=max(ans,abs(p[i].x-rd.x)+abs(p[i].y-rd.y));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5320
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	s <- getLine
	putStrLn $ if length s == 2
		then s
		else reverse s

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<int, int> P;
ll modnum = 1e9+7;



int main() {
    int n; cin >> n;
    deque<int> ans;
    rep(i, n) {
        int a; cin >> a;
        int itr = lower_bound(ans.begin(), ans.end(), a) - ans.begin();
        if(itr == 0) ans.push_front(a);
        else ans[itr-1] = a;
    }

//    rep(i, ans.size()) {
//        cout << ans[i] << endl;
//    }

    cout << ans.size() << endl;

    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.collections.ArrayList

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val t = readInteger()
    repeat(t) {
        val (n, m, a, b) = readLongList()
        out.println(floorSum(n, m, a, b))
    }
}

fun floorSum(n: Long, m: Long, a: Long, b: Long): Long {
    var a = a
    var b = b
    var ans: Long = 0
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2
        a %= m
    }
    if (b >= m) {
        ans += n * (b / m)
        b %= m
    }
    val yMax = (a * n + b) / m
    val xMax = yMax * m - b
    if (yMax == 0L) return ans
    ans += (n - (xMax + a - 1) / a) * yMax
    ans += floorSum(yMax, a, m, (a - xMax % a) % a)
    return ans
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 57260
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
ll mod= 1e9 + 7;

int main() {
  int n,a;
  cin >>n >> a;
  if(n<a){cout << 0 << endl;}else{cout << 10 << endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m,ans;cin>>n>>m;ll pow=(1<<m);
  ans=pow*(100*(n-m)+1900*m);
  print(ans);
  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    idx = -1
    cnt = -1
    for i in range(1,n+1):
        tmp = (bin(i)[2:])[::-1].find('1')
        if tmp > cnt:
            cnt = tmp
            idx = i
    print(idx)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256