akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans1 = a * x + b * y;
  int ans2;
  if(x > y)
    ans2 = c * y * 2 + a * (x - y);
  else
    ans2 = c * x * 2 + b * (y - x);
  int ans3 = c * max(x, y) * 2;
  cout << min(ans1, min(ans2, ans3)) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N, d[105], h[105], i, a;
    scanf("%d", &N);
    for (i=1; i<=100; i++) {
        h[i]=0;
    }
    for (i=1; i<=N; i++) {
        scanf("%d", &d[i]);
        h[d[i]]++;
    }
    a=0;
    for (i=1; i<=100; i++) {
        if (h[i]!=0) a++;
    }
    printf("%d", a);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
const int maxn = 100;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int a[maxn],b[maxn],c[maxn];
int main(){
	n=read();
	for(register int i=1;i<=n;i++)a[i]=read();
	for(register int i=1;i<=n;i++)b[i]=read();
	for(register int i=1;i<n;i++)c[i]=read();
	int sum=b[a[1]];
	for(register int i=2;i<=n;i++){
		if(a[i]==a[i-1]+1)sum+=c[a[i-1]];
		sum+=b[a[i]];
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

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

  int max = a+b;

  if (a-b > max)
    max = a-b;
  if (a*b > max)
    max = a*b;

  cout <<  max << endl;

  return 0;
}

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

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

int main(void) {
  int a, b;
  char op;

  while(1) {
    cin >> a >> op >> b;
    switch(op) {
      case '+':
        cout << a+b << endl;
        break;
      case '-':
        cout << a-b << endl;
        break;
      case '*':
        cout << a*b << endl;
        break;
      case '/':
        cout << a/b << endl;
        break;
      default:
        return 0;
        break;
    }
  }
}



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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define Cin(x) cin >> x
#define Cin2(x,y) cin >> x >> y
#define Cin3(x,y,z) cin >> x >> y >> z
#define Cin4(w,x,y,z) cin >> w >> x >> y >> z
#define Cout(x) cout << x << "\n"
#define Cout2(x,y) cout << x << y << "\n"
#define Cout3(x,y,z) cout << x << y << z << "\n"
#define Cout4(w,x,y,z) cout << w << x << y << z << "\n"
#define Kaigyou cout << "\n"
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define Size(n) (n).size()
#define All(v) (v).begin(), (v).end()
#define Pb(i) push_back(i)

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

    ll c[3][3],a[3],b[3];
    rep(i,3){
        rep(j,3){
            Cin(c[i][j]);
        }
    }
    a[0] = 0;
    rep(j,3) b[j] = c[0][j] - a[0];
    rep(i,3) a[i] = c[i][0] - b[0];
    rep(i,3){
        rep(j,3){
            if(a[i]+b[j] != c[i][j]){
                Cout("No");
                return 0;
            }
        }
    }
    Cout("Yes");
    return 0;
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> H) {
  ll p = LINF;
  ll ans = 0;
  ll c = 0;

  rep(i, N) {
    if (H.at(i) <= p) {
      ans = max(ans, ++c);
    } else {
      c = 1;
    }
    p = H.at(i);
  }
  cout << ans - 1 << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> H(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &H[i]);
  }
  solve(N, std::move(H));
  return 0;
}


Measured memory_bytes: 4084
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
#include<cmath>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
typedef pair<int,int> pi;
int n,m;
vector<pi>ed[1005];
int u[200005],v[200005];
int bel[1005][1005][2];
bool vis[1005];
void dfs(int now,int fa,int belid,int typ)
{//cout<<"GG"<<now<<' '<<fa<<' '<<belid<<' '<<typ<<endl;
	bel[fa][now][typ]=belid;
	vis[now]=1;
	for(int i=0;i<ed[now].size();i++)
		if(!vis[ed[now][i].first])
			dfs(ed[now][i].first,fa,belid,typ);
}
int main()
{
	read(n);
	read(m);
	for(int i=1;i<=m;i++)
	{
		read(u[i]);
		read(v[i]);
		ed[u[i]].push_back(make_pair(v[i],i));
	}
	for(int i=1;i<=n;i++)
	{//cout<<"WORK"<<i<<endl;
		memset(vis,0,sizeof(vis));
		vis[i]=1;
		for(int j=0;j<ed[i].size();j++)
			if(!vis[ed[i][j].first])
				dfs(ed[i][j].first,i,ed[i][j].second,0);
		reverse(ed[i].begin(),ed[i].end());
		memset(vis,0,sizeof(vis));
		vis[i]=1;
		for(int j=0;j<ed[i].size();j++)
			if(!vis[ed[i][j].first])
				dfs(ed[i][j].first,i,ed[i][j].second,1);
	}
	for(int i=1;i<=m;i++)
	{//cout<<"A"<<u[i]<<' '<<v[i]<<' '<<bel[v[i]][u[i]][0]<<' '<<bel[u[i]][v[i]][0]<<' '<<bel[u[i]][v[i]][1]<<endl;
		if(bel[v[i]][u[i]][0]!=0 ^ (bel[u[i]][v[i]][0]!=i || bel[u[i]][v[i]][1]!=i))
			printf("diff\n");
		else
			printf("same\n");
	}
	return 0;
}

Measured memory_bytes: 13696
N,M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
if N >= M:
  print(0)
else:
  X_diff = [X[i+1]-X[i] for i in range(M-1)]
  X_diff.sort()
  print(sum(X_diff[0:M-N]))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
int a[1001];

int main(void){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<k;i++){
		ans+=a[i];
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3816
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

type intHeap []int

func (h intHeap) Len() int            { return len(h) }
func (h intHeap) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h intHeap) Less(i, j int) bool  { return h[i] > h[j] }
func (h *intHeap) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func solve() {
	n, m := getInt(), getInt()
	h := intHeap(getIntSlice(n))
	heap.Init(&h)

	for i := 0; i < m; i++ {
		h[0] /= 2
		heap.Fix(&h, 0)
	}

	ans := sum(h...)
	fmt.Fprintln(wr, ans)
}

func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=1010000;
int pre[N],maxpre[N],n;
char s[N];

int calc(int x) {
	pre[0]=0;
	rep(i,0,n) {
		if (s[i]=='0'||s[i]=='?') pre[i+1]=pre[i]-1;
		else pre[i+1]=pre[i]+1;
	}
	maxpre[n]=pre[n];
	maxpre[n+1]=-(1<<29);
	per(i,0,n) {
		maxpre[i]=max(maxpre[i+1],pre[i]);
	}
	int cur=0;
	int minpre=0;
	rep(i,0,n) {
		if (s[i]=='0') cur--;
		if (s[i]=='1') cur++;
		if (s[i]=='?') {
			if (cur+1+maxpre[i+1]-pre[i+1]<=x) cur++;
			else cur--;
		}
		minpre=min(minpre,cur);
	}
	return x-minpre;
}

int main() {
	scanf("%s",s);
	n=strlen(s);
	int minp=0,cur=0;
	rep(i,0,n) {
		if (s[i]=='0'||s[i]=='?') --cur; else ++cur;
		minp=max(minp,cur);
	}
	printf("%d\n",min(calc(minp),calc(minp+1)));
}

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

// クラス利用部 (main 関数)
int main(){

int sl,sk;
cin >>   sl >> sk;

if(sl*500>=sk)
cout << "Yes"<< endl;
else
cout << "No" << endl;



//printf("%c", (sl[0]+1));



}

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

int main(){
    long long n;cin>>n;long long R[n];
    for(int i=0;i<n;i++)cin>>R[i];
    long long  minv=pow(10,10);
    long long maxv=-pow(10,10);
    for(int i=1;i<n;i++){
        minv=min(minv,R[i-1]);
        maxv=max(maxv,R[i]-minv);
    }
    cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 4656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  int p = 2019;
  string s;cin >> s;
  int n = s.size();
    ll x = 1;
    map<ll,ll> mp;
    ll sum = 0;
    mp[0]++;
    for(int i=n-1;i>=0;i--){
      ll c = s[i] - '0';
      sum = (sum+(c*x)%p)%p;
      mp[sum]++;
      x = (x*10)%p;
    }
    ll res = 0;
    for(auto m:mp){
      res += (m.second-1)*m.second/2;
    }
    cout << res << "\n";

  return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i < N;i++){
        cin >> a[i];
    }
    std::sort(a.begin(),a.end());
    cout << (a[N-1]-a[0]);
    return 0;
}

Measured memory_bytes: 256
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
const int N = 1e5+5;
int mod = 1e9+7;
int mul(int a,int b)
{
    return ((a%mod)*(b%mod))%mod;
}
int add(int a,int b)
{
    return ((a%mod)+(b%mod))%mod;
}
int sub(int a,int b)
{
    return ((a%mod)-(b%mod)+mod)%mod;
}
int power(int a,int b)
{
    int res = 1;
    while(b>0)
    {
        if(b&1)
            res = mul(res,a);
        b = b/2;
        a = mul(a,a);
    }
    return res;
}
signed  main()
{
    fast;
    int n;
    cin>>n;
    int ans = power(n,3);
    cout<<ans;
}   

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n, m, tsum = 0, hsum = 0;
		cin >> n >> m;
		if (!n) break;
		vector<int> t(n), h(m);
		REP(i, n) {
			cin >> t[i];
			tsum += t[i];
		}
		REP(i, m) {
			cin >> h[i];
			hsum += h[i];
		}
		int diff = tsum - hsum;
		if (diff % 2 != 0) {
			cout << -1 << endl;
			continue;
		}
		sort(ALL(h));
		sort(ALL(t));
		REP(i, n) {
			REP(j, m) {
				if (t[i] == h[j]+diff/2) {
					cout << t[i] << " " << h[j] << endl;
					goto nyan;
				}
			}
		}
		cout << -1 << endl;
	nyan:;
	}
	return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  string s;
  cin>>s;
  vector<int> vec(4);
  for (int i = 0; i < 4; ++i)
  {
    vec[i]=s[i]-'0';
  }
  for (int i = 0; i < (1<<3); ++i)
  {
    int tmp=vec[0];
    for (int j = 0; j < 3; ++j)
    {
      if((i>>j)&1) tmp+=vec[j+1];
      else tmp-=vec[j+1];
    }
    if(tmp==7)
    {
      string ans="";
      for (int j = 0; j < 3; ++j)
      {
        ans+=to_string(vec[j]);
        if((i>>j)&1) ans+="+";
        else ans+="-";
      }
      ans+=to_string(vec[3]);
      ans+="=7";
      cout<<ans<<endl;
      return 0;
    }
  }
}

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

using namespace std;

int main(){
int n;

cin>>n;
int arr[n];

for(int i=0;i<n;i++){
   cin>>arr[i];
}
sort(arr,arr+n);

for(int i=1;i<n;i++){
 if(arr[i]==arr[i-1]){
       cout<<"NO"<<endl;
       return 0;
  }
}
cout<<"YES"<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> L(2*N);
    for (int i = 0; i< 2*N; i++)
        cin >> L[i];

    sort(L.begin(),L.end());

    int result = 0;
    for (int i = 0; i < N;i++)
        result += L[2*i];

    cout << result;
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	if (N == 1) {
		cout << 1 << endl;
	}
	else if (2 <= N && N < 4) {
		cout << 2 << endl;
	}
	else if (4 <= N && N < 8) {
		cout << 4 << endl;
	}
	else if (8 <= N && N < 16) {
		cout << 8 << endl;
	}
	else if (16 <= N && N < 32) {
		cout << 16 << endl;
	}
	else if (32 <= N && N < 64) {
		cout << 32 << endl;
	}
	else {
		cout << 64 << endl;
	}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define INF 1000000000
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void){
	int d[200][200], r[8];
	int N, M, R; cin >> N >> M >> R;
	for(int i = 0; i < R; i++){
		int rr;
		cin >> rr;
		r[i] = --rr;
	}
	fill(d[0], d[N], INF);
	for(int i = 0; i < N; i++) d[i][i] = 0;
	for(int i = 0; i < M; i++){
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		d[a][b] = d[b][a] = c;
	}

	for(int k = 0; k < N; k++){
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	int res = INF;
	sort(r, r+R);
	do{
		int dist = 0;
		for(int i = 0; i < R - 1; i++) dist += d[r[i]][r[i+1]];
		res = min(res, dist);
	}while(next_permutation(r, r+R));

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 384
from collections import Counter


def choose(n: int) -> int:
    if n < 2:
        return 0
    else:
        return (n * (n - 1)) // 2


N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
d = {key: choose(value) for key, value in c.items()}
if len(d) > 1:
    sum_d = sum(d.values())
    for a in A:
        print(sum_d - d[a] + choose(c[a] - 1))
else:
    ans = choose(N - 1)
    for _ in range(N):
        print(ans)


Measured memory_bytes: 32284
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
typedef long long ll;
#define int long long
#define ff first
#define ss second
#define md 1000000007
#define md1 998244353
#define pb push_back
#define in insert
#define mkp make_pair
#define f(i,yha,wha) for(ll i=yha;i<wha;i++)
#define rf(i,wha,yha) for(ll i=wha;i>=yha;i--)
#define f0(n) for(ll i=0;i<n;i++)
#define f1(n) for(ll i=1;i<=n;i++)
#define fg(i,yha,wha,gap) for(ll i=yha;i<wha;i+=gap)
#define mpll map<ll,ll>
#define len(p) (ll)p.size()
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mem(a,t) memset(a,t,sizeof(a))
#define endl "\n"
#define ar array
#define vl vector<ll>
#define vpll vector<pair<ll,ll>>


void flash()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const ll N=2e5+10;

void solve()
{
 	ll n;
   cin>>n;
   ll a[n+10];
   ll ans[n+10]={0};
    f(i,2,n+1)
     cin>>a[i];
 	
 	f(i,2,n+1)
 	{
 		ans[a[i]]++;
	}
//	dfs(1,0);
	
	f(i,1,n+1)
	  cout<<ans[i]<<endl;
	 
	 
	   
}


int32_t main()
{
  flash();
  int t;
  t = 1;
//  cin >> t;
  while (t--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 6768
#include <cstdio>

using namespace std;

int main()
{
	int N, Ans = 0, A, K;
	scanf("%d", &N);
	while (N--)
	{
		scanf("%d%d", &A, &K);
		while (A % K)
		{
			int t = A / K, lim = K * t, x;
			//A - x * (t + 1) >= lim
			x = (A - lim) / (t + 1), A -= x * (t + 1);
			if (A % K)
				A -= (t + 1);
		}
		Ans ^= A / K;
	}
	if (Ans)
		puts("Takahashi");
	else
		puts("Aoki");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int N, R;
    cin >> N >> R;

    int internal = R + 100*(10-N);

    if (10 < N) {
        cout << R;
    } else {
        cout << internal;
    }

    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    auto AS = readln.split.to!(long[]);

    long r = 1;
    foreach (i, a; AS) {
        if (i < K) continue;
        writeln(a > AS[i-K] ? "Yes" : "No");
    }
}

Measured memory_bytes: 11736
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//------------------------------------------
//------------------------------------------

template<class T>
struct Edge {
    int from, to;
    T cost;

    Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const { return to; }
};

template<class T>
using Edges = vector<Edge<T>>;
template<class T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<class T>
using DistMatrix = vector<vector<T>>;

template<class G>
class CycleFind {
private:
    int V;
    int key_v;
    vector<bool> going;
    vector<bool> backing;
    vector<int> cycle_path;
    stack<int> history;
    const G &graph;

public:

    CycleFind(const G &_graph) : graph(_graph), key_v(-1) {
        V = graph.size();
        going = vector<bool>(V, false);
        backing = vector<bool>(V, false);
        build();
    }

    void dfs(int v, int p) {
        going[v] = true;
        history.push(v);
        for (auto e: graph[v]) {
            int to = (int) e;
            if (backing[to])continue;
            if (going[to] && !backing[to]) {
                key_v = to;
                return;
            }
            dfs(to, v);
            if (key_v != -1) return;
        }
        history.pop();
        backing[v] = true;
    }

    bool has_cycle() {
        return key_v != -1;
    }

    vector<int> get_cycle_path() const {
        return cycle_path;
    }

    void build() {
        for (int i = 0; i < V; i++) if (!going[i]) dfs(i, -1);
        if (has_cycle()) {
            cycle_path = vector<int>();
            while (!history.empty()) {
                auto v = history.top();
                history.pop();
                cycle_path.push_back(v);
                if (v == key_v) break;
            }
        }
    }

};

int main() {

    int V, E;
    cin >> V >> E;

    UnWeightedGraph G(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
    }

    CycleFind<UnWeightedGraph> cycleFind(G);
    if (cycleFind.has_cycle()) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

































Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 10;
const int mod = (int)1e9 + 7;
vector<int> g[N];
vector<int> arr;
bool used[N];
int c = 0;
void dfs(int v,int ps = -1){
    c++;
    used[v] = 1;
    for(int to: g[v]){
        if(!used[to])dfs(to, v);
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >> m;
    for(int i = 1;i <= m;++i){
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i = 1;i <= n;i++)if(!used[i]){c = 0; dfs(i); arr.push_back(c);}
    sort(arr.begin(), arr.end());
    int ans = 0,k = 0;
    for(int i = 0;i < (int)arr.size();++i){
        arr[i]-=k;
        ans += arr[i];
        k+=arr[i];
    }
    cout << ans;
    return 0;
}

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

using namespace std;

int n;
char s[105];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> s[i];
        if (s[i]=='Y')
        {
            cout << "Four";
            return 0;
        }
    }
    cout << "Three";
}

Measured memory_bytes: 256
n, m = map(int, input().split())

A = [0] * n
B = [0] * n

for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        A[b-1] = 1
    elif b == 1:
        A[a-1] = 1
    elif a == n:
        B[b-1] = 1
    elif b == n:
        B[a-1] = 1

for i in range(n):
    if A[i] == B[i] == 1:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


Measured memory_bytes: 6132
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func binarySearch(b []int, max, v int) int {
	min := 0
	i := max / 2
	//count :=0
	for {
		/*count ++
		if count > 5 {
			debugf("returnx i: %d\n", i)

			return i
		}*/
		debugf("b: %v\n", b)
		debugf("v: %d, i: %d, min: %d, max: %d\n", v, i, min, max)
		//if b[i] == v {
		//	debugf("return1 i: %d\n", i)
		//	return i
		//} else
		if v <= b[i] {
			if i == (max + min) / 2 + 1 {
				debugf("return2 i: %d\n", i)
				return i
			}
			i = (max + min) / 2 + 1
			min = i
		} else if b[i] < v {
			max = i
			if i == (max + min) / 2 {
				debugf("return3 i: %d\n", i)
				return i
			}
			i = (max + min) / 2
			max = i
		}
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	b := make([]int, n)
	for i := range b {
		b[i] = -1
	}

	ans := 0
	for i := range a {
		a[i] = nextInt()
	}
	debugf("a: %v\n", a)
	for i := range a {
		j := sort.Search(ans, func(k int) bool { return b[k] < a[i] })
		//j := binarySearch(b, ans, a[i])
		if b[j] == -1 {
			b[j] = a[i]
			ans++
		} else if b[j] < a[i] {
			b[j] = a[i]
		}// else if b[j] > a[i] && j < n-1 && b[j+1] == -1 {
		//	b[j+1] = a[i]
		//	ans++
		//}
		debugf("b: %v\n", b)
		/*
		for j := range b {
			if b[j] == -1 {
				b[j] = a[i]
				ans++
				break
			} else if b[j] < a[i] {
				b[j] = a[i]
				break
			}
		}
		*/
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


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

int main(){
  double a,b,x,y;
  cin>>a>>b>>x>>y;
  printf("%.12f",a*b/2);
  if(2*x==a&&2*y==b){
  cout<<" "<<1<<endl;
  }
  else{
  cout<<" "<<0<<endl;
  }
}


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

using namespace std;

typedef long long int ll;
const ll N=100;
ll h,w,c,x,f,ans=0;
vector <string> d[N];
string st,s[N],r;
multiset <string> e;

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin >> h >> w;
    for(int i=1; i<=h; i++)
        cin >> s[i];
    st=0+'0';
    d[0].push_back(st);
    st+=1+'0';
    d[1].push_back(st);
    st=1+'0';
    st+=0+'0';
    d[1].push_back(st);
    for(int i=2; i<12; i++)
    {
        for(auto y:d[i-1])
        {
            st=y;
            st+=i+'0';
            d[i].push_back(st);
        }
        for(int j=0; j<i; j++)
        {
            for(auto y:d[i-2])
            {
                st="";
                for(int k=0; k<j; k++)
                {
                    c=y[k]-'0';
                    if(c>=j)
                        st+=1+y[k];
                    else
                        st+=y[k];
                }
                st+=i+'0';
                for(int k=j; k<i-1; k++)
                {
                    c=y[k]-'0';
                    if(c>=j)
                        st+=1+y[k];
                    else
                        st+=y[k];
                }
                st+=j+'0';
                d[i].push_back(st);
            }
        }
    }
    /*for(int i=0; i<5; i++)
    {
        cout << "Start : " << i << ' ' << (ll)d[i].size() << endl;
        for(auto y:d[i])
        {
            for(auto c:y)
            {
                x=c-'0';
                cout << x << ' ';
            }
            cout << endl;
        }
        cout << endl;
    }*/
    //ans=13860+53460+62436+10396;
    //cout << ans << endl;
    //cout << endl;
    //st="4 3 2 1 0";
    //cout << st << endl;
    for(auto y:d[w-1])
    {

        f=1;
        x=0;
        for(int i=0; i<w; i++)
            if(i==y[i]-'0')
                x++;
        if(x>1) continue;
        //for(int i=0; i<w; i++)
        //    cout << y[i]-'0' << ' ';
        //cout << endl;
        x=1;
        e.clear();
        for(int i=1; i<=h; i++)
            e.insert(s[i]);
        while(f==1 && !e.empty())
        {
            st=*e.begin(),e.erase(e.begin());
            r=st;
            for(int i=0; i<w; i++)
            {
                c=y[i]-'0';
                if(r[i]==st[i])
                    swap(r[i],r[c]);
            }
            //cout << st << " VS " << r << endl;
            if(e.find(r)!=e.end())
                e.erase(e.find(r));
            else
            {
                if(x==1 && r==st)
                    x=0;
                else
                {
                    f=0;
                }
            }
        }
        if(f==1)
        {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
    //cerr << "Time elapsed : " << 1.0*clock()/CLOCKS_PER_SEC << "s.\n";
    return 0;
}
// test 1:
/*5 5
akdar
koara
bbmbb
araok
radka*/


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

template<typename T, int MAX_N>
struct segment_tree_sum {
    T arr1[MAX_N << 1], arr2[MAX_N << 1]; int N;

    segment_tree_sum(int n) {
        N = 1;
        while (N < n) N *= 2;

        for (int i = 0; i < 2*N-1; ++i) {
            arr1[i] = (T)0;
            arr2[i] = (T)0;
        }
    }

    void add(int a, int b, T v) {
        return add(a, b, v, 0, 0, N);
    }

    void add(int a, int b, T v, int k, int l, int r) {
        if (a <= l && r <= b) {
            arr1[k] += v;
        } else if (!(b <= l || r <= a)) {
            arr2[k] += (min(r, b) - max(l, a)) * v;
            const int m = (l+r) / 2;
            add(a, b, v, 2*k+1, l, m);
            add(a, b, v, 2*k+2, m, r);
        }
    }

    T query(int a, int b) {
        return query(a, b, 0, 0, N);
    }

    T query(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a) {
            return (T)0;
        }
        if (a <= l && r <= b) {
            return (r-l) * arr1[k] + arr2[k];
        }
        const int m = (l+r)/2;
        return (min(r, b) - max(l, a)) * arr1[k] + query(a, b, 2*k+1, l, m) + query(a, b, 2*k+2, m, r);
    }
};

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, Q; cin >> N >> Q;
    segment_tree_sum<long long, 201010> segt(N+1);
    for (int j = 0; j < Q; ++j) {
        int c, s, t, x; cin >> c;
        if (c == 0) {
            cin >> s >> t >> x;
            segt.add(s, t+1, x);
        } else {
            cin >> t;
            cout << segt.query(t, t+1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7300
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	int dis, pri;
	while (1) {
		cin >> dis >> pri;
		if (dis == 0 && pri == 0) break;
		double mindis = INF;
		for (int i = 0; i <= dis / 2; i++) {
			if (mindis > abs(sqrt(i*i + (dis - i)*(dis - i))-pri)) {
				mindis = abs(sqrt(i*i + (dis - i)*(dis - i))-pri);
			}
		}
		cout.precision(10);
		cout <<fixed<< mindis << endl;
	}
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int a,b;cin >>a>>b;
    if((a<0&&b>0)||(a==0)||(b==0)){
        cout << "Zero";
        return 0;
    }
    else if(a>0){
        cout << "Positive";
        return 0;
    }
    else{
        if((b-a)%2==0){
            cout << "Negative";
            return 0;
        }
        else{
            cout << "Positive";
            return 0;
        }
    }
}




Measured memory_bytes: 3516
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

template <class T> class SegmentTreeRMQ {
private:
    vector<T> segtree_min;
    vector<T> segtree_max;
    const int N = 1<<19;
    const T limit_max = (1<<31)-1;
    const T limit_min = (1<<31);
public:
    SegmentTreeRMQ(){
        segtree_max = *new vector<T>(N*2,limit_min);
        segtree_min = *new vector<T>(N*2,limit_max);
    }
    void update(int idx, T val){
        idx += N-1;
        segtree_max[idx] = segtree_min[idx] = val;
        while(idx){
            idx = (idx-1)/2;
            segtree_max[idx] = max(segtree_max[idx*2+1],segtree_max[idx*2+2]);
            segtree_min[idx] = min(segtree_min[idx*2+1],segtree_min[idx*2+2]);
        }
    }
    T getmax(int a, int b) { return query_max(a,b,0,0,N); }
    T getmin(int a, int b) { return query_min(a,b,0,0,N); }
    T query_max(int a,int b,int k,int l,int r){
        if(r <= a || b <= l) return limit_min;
        if(a <= l && r <= b) return segtree_max[k];
        T vl = query_max(a,b,k*2+1,l,(l+r)/2);
        T vr = query_max(a,b,k*2+2,(l+r)/2,r);
        return max(vl,vr);
    }
    T query_min(int a,int b,int k,int l,int r){
        if(r <= a || b <= l) return limit_max;
        if(a <= l && r <= b) return segtree_min[k];
        T vl = query_min(a,b,k*2+1,l,(l+r)/2);
        T vr = query_min(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
};


int main(){
    
    int n,q;
    cin>>n>>q;
    
    SegmentTreeRMQ<int> inst;
    REP(i,q){
        int com,x,y;
        cin>>com>>x>>y;
        if(com==0){
            inst.update(x,y);
        }else{
            cout<<inst.getmin(x,y+1)<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 19252
using System;
class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
		if (s.Substring(0, 1) == s.Substring(1, 1)) {
			if (s.Substring(2, 1) == s.Substring(3, 1)) {
				Console.WriteLine(s.Substring(0, 1) != s.Substring(2, 1) ? "Yes" : "No");
			} else {
				Console.WriteLine("No");
			}
		} else if (s.Substring(0, 1) == s.Substring(2, 1)) {
			if (s.Substring(1, 1) == s.Substring(3, 1)) {
				Console.WriteLine(s.Substring(0, 1) != s.Substring(1, 1) ? "Yes" : "No");
			} else {
				Console.WriteLine("No");
			}
		} else if (s.Substring(0, 1) == s.Substring(3, 1)) {
			if (s.Substring(1, 1) == s.Substring(2, 1)) {
				Console.WriteLine(s.Substring(0, 1) != s.Substring(1, 1) ? "Yes" : "No");
			} else {
				Console.WriteLine("No");
			}
		} else {
			Console.WriteLine("No");
		}
	}
}


Measured memory_bytes: 11092
// https://atcoder.jp/contests/abc175/tasks/abc175_d

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

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

const int N_MAX = 5000;
const int K_MAX = 1e9;
const int C_I_MAX = 1e9;
const ll INF = 2e18;

int N, K;
vector<int> P;
vector<int> C;

vector<int> dist;
vector<ll> acc;

int main() {
  cin >> N >> K;
  P = vector<int>(N);
  REP(i, N) {
    cin >> P[i];
    P[i]--;
  }
  C = vector<int>(N);
  REP(i, N) cin >> C[i];

  ll ans = -INF;
  REP(i, N) {
    int v = i;
    dist = vector<int>(N, -1);
    acc = vector<ll>(N, 0);
    dist[v] = 0;
    FOR(j, 1, K) {
      int u = P[v];
      if (dist[u] < 0) {
        dist[u] = j;
        acc[u] = acc[v] + C[u];
      } else {
        ll ds = acc[v] + C[u] - acc[u];
        if (ds < 0) break;
        int dd = j - dist[u];
        int r = (K - j) / dd;
        if (r > 0) r--;
        j += r * dd;
        dist[u] = j;
        acc[u] = acc[v] + C[u] + r * ds;
      }
      // cout << "i:" << i << " j:" << j << " u:" << u << " score:" << acc[u] << endl;
      chmax(ans, acc[u]);
      v = u;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3788
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/3 22:02:32
File Name     :main.cpp
************************************************ */
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include<random>
#include<ctime>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 1e9
#define bug puts("--------------")
const ll N = 2e5 + 10;
const ll mod = 1e9 + 7;
const ll Max_n = 1e6 + 10;
using namespace std;
int main(){
    string s1,s2;
    cin >> s1 >> s2;
    int a,b;
    cin >> a >> b;
    string s3;
    cin >> s3;
    if(s3 == s1) a --;
    else if(s3 == s2) b--;
    a = max(0,a);b = max(0,b);
    cout << a<<' '<<b;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s:String = read();
    let t:String = read();
    let mut sc:Vec<char> = s.chars().collect();
    let mut tc:Vec<char> = t.chars().collect();
    let mut ans = 0;
    for i in 0..s.len() {
        if sc[i] != tc[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4052
using System;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int ans = int.MaxValue;
        for (int i = 1; i < n; i++)
        {
            string a = i.ToString();
            string b = (n - i).ToString();
            int x = 0;
            for (int j = 0; j < a.Length; j++) x += int.Parse(a[j].ToString());
            for (int j = 0; j < b.Length; j++) x += int.Parse(b[j].ToString());
            ans = Math.Min(ans, x);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 15304
# 3Nを降順に並べると上位1/3が最強で下位1/3が弱い、考えるのは間の1/3だけでいい
# -> なんでこれがWAなの....
# あそうか 4 1 100 14 4 66 31 10 6 4 4 89

n = int(input())
arr = list(sorted(list(map(int, input().split())), reverse=True))
arr = arr[1::2]
arr = arr[:n]
print(sum(arr))


Measured memory_bytes: 37084
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++) cin>>h[i];
  bool ans=true;
  int saidai=0;
  for(int i=0;i<n;i++){
    if(h[i]>=saidai){
      saidai=h[i];
      continue;
    }
    if(h[i]<=saidai-2){
      ans=false;
      break;
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] arr = new int[n];
    long sum = 0;

    for(int i=0;i<n;i++) {
      arr[i] = sc.nextInt();
    }
    Arrays.sort(arr);
    if(n<=k) {
      System.out.println(0);
    } else {
      for(int j=0;j<n-k;j++) {
        sum = sum + arr[j];
      }
    }
    if(sum>0) System.out.println(sum);
    }
  }


Measured memory_bytes: 64828
def pow_k(x,n,p=10**9+7):
    if n==0:
        return 1
    K=1
    while n>1:
        if n%2!=0:
            K=(K*x)%p
        x=(x*x)%p
        n//=2
    return (K*x)%p

N,X,M=map(int,input().split())

sumA=[0]
res=0
MOD=[0]*(10**5+10)
x=X
A,B=[],[]
for i in range(1,N+1):
    if MOD[x]==1:
        point=x
        B=[]
        res=0
        while 1:
            res+=x
            B.append(res)
            x=(x*x)%M
            if x==point:
                break
    else:
        MOD[x]=1
        res+=x
        A.append(res)
        x=(x*x)%M        
    if B:
        break
if not B:
    print(A[-1])
else:
    C=[0]+B
    N-=len(A)
    print(A[-1]+B[-1]*(N//len(B))+(C[N%len(B)]))

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

const Int INF = 1e15;

int main(){
    int N; cin >> N;
    vector<Int> A(N+1);
    rep1(i,N) cin >> A[i];

    // dp[i][0]: A[1]~A[i]からi/2個とるときの最大値
    // dp[i][1]: A[1]~A[i]からi/2+1個とるときの最大値(i:奇数)
    vector<vector<Int>> dp(200010, vector<Int>(2, -INF));

    dp[1][0] = 0;
    dp[1][1] = A[1];
    dp[2][0] = max(A[1], A[2]);

    for(int i=3; i<=N; i++){
        Int last = A[i];
        if(i % 2 == 0){
            dp[i][0] = max(dp[i-1][1], last + dp[i-2][0]);
        } else {
            dp[i][0] = max(dp[i-1][0], last + dp[i-2][0]);
            dp[i][1] = last + dp[i-2][1];
        }
    }

    cout << dp[N][0] << endl;
}


Measured memory_bytes: 15676
# 2018/12/22
# CADDi2018 for Beginners B

# Input
n, h, w = map(int,input().split())

# Init
cnt = 0

# Calc
for idx in range(n):
    wa, wb = map(int, input().split())
    if h <= wa and w <= wb:
        cnt += 1

# Output
print(cnt)

Measured memory_bytes: 3060
// う　し　た　ぷ　に　き　あ　く　ん　笑
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int M = 3;
constexpr int LOVE = 753;
constexpr int INF = 1000000000 + 8;

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

    string s;
    cin >> s;
    const int n = s.size();

    int ans = INF;

    for (int i = 0; i < n - M + 1; i++) {
        const string ss = s.substr(i, M);
        const int x = stoi(ss);
        const int xx = abs(x - LOVE);
        ans = min(xx, ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

int main(void){
  set<string> s;
  rep(z,2){
    int n;
    cin>>n;
    rep(i,n){
      string h,m;
      cin>>h>>m;
      if(m.size()==1)m='0'+m;
      string str = h + ":" + m;
      s.insert(str);
    }
  }
  set<string>::iterator it;
  vector<string> ss;
  for(it=s.begin();it!=s.end();it++)
    ss.push_back(*it);
  rep(i,ss.size()){
    for(int j = 0 ; j < i ; j ++){
      if(ss[i].size() < ss[j].size())swap(ss[i],ss[j]);
      else if(ss[i] < ss[j])swap(ss[i],ss[j]);
    }
  }
  cout<<ss[0];
  loop(i,1,ss.size()){
    cout<<" "<<ss[i];
  }
  cout<<endl;
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int main(){
    int a,b;
        string op;
    while(1){
         cin >> a >> op >> b;
        if (op == "+") {
            cout << a+b << endl;
        }
        else if (op == "-"){
            cout << a-b <<endl;
        }
        else if(op == "*"){
            cout << a*b << endl;
        }
        else if (op == "/"){
            cout << a/b << endl;
        }
        else break;
    }
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, op[100010];

signed main(){
    cin >> N;
    REP(i, N + 1) op[i] = i;
    op[0] = 0;
    REP(i, N){
        ll j = 6;
        while(i + j <= N){
            op[i + j] = min(op[i + j], op[i] + 1);
            j *= 6;
        }
        j = 9;
        while(i + j <= N){
            op[i + j] = min(op[i + j], op[i] + 1);
            j *= 9;
        }
    }
    PRINT(op[N]);
    return 0;
}

Measured memory_bytes: 4376
n=int(input())
h_list=list(map(int,input().split()))
count=0
end=[]
for i in range(n):
    end.append(0)
while not h_list==end:
    count_0=1
    for i in range(n):
        if h_list[i]==0:
            count_0=1
        else:
            h_list[i]=h_list[i]-1
            if count_0==1:
                count=count+1
            else:
                pass
            count_0=0
print(count)


Measured memory_bytes: 38896
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define int long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'
ll n,x,m;
inline ll f(ll v){
	return (v*v)%m;
}
int arr[100010];
int val[100010];
signed main()
{
	cin>>n>>x>>m;
	ll k=0,st=0;
	ll ans=0;
	val[1]=x;
	arr[x]=1;
	ans+=val[1];
	for(int i=2;i<=m && i<=n;i++){
		val[i]=f(val[i-1]);
		ans+=val[i];
		if(arr[val[i]]!=0){
			k=i-arr[val[i]];
			st=arr[val[i]];
			break;
		}
		arr[val[i]]=i;
	}
	if(st==0){
		cout<<ans<<endl;
		return 0;
	}

	ll ex=(n-st+1)%k;
	ll g=(n-st+1)/k;
	// cout<<st<<' '<<k<<endl;
	// cout<<ex<<' '<<g<<endl;
	ans=0;
	ll an=0;
	for(int i=1;i<st;i++)ans+=val[i];
	for(int i=st,j=0;j<k;j++,i++)an+=val[i];
	ans+=an*g;
	for(int i=st,j=0;j<ex;j++,i++)ans+=val[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4756