akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int n, in[25];
    while (~scanf("%d",&n)) {
        REP(i,1,n) scanf("%d", &in[i]);

        int mx = -1, ans = 0;
        REP(i,1,n) {
            mx = max(mx, in[i]);
            if (in[i]==mx) ans++;
        }
        printf("%d\n", ans);
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int comp(const void *a,const void *b);
int searchSup4(int P[],int imax,int trgt,int times);

int main(){

	int N,M,N0;	//1<=N<=1000;1<=N<=2E8
	int P[1001];
	int PP[1001*1002/2];
	int i,j;
	int k;
	int bak;
	int score_all;
	
	while(1){
		scanf("%d %d\n",&N,&M);
		if(!N&&!M)break;
		//for(i=0;i<1001;i++)P[i]=0;
		//for(i=0;i<(1001*1002/2);i++)PP[i]=0;
		
		for(i=0;i<N;i++)scanf("%d\n",&P[i]);
		P[N]=0;
		
		k=0;
		for(i=0;i<=N;i++){
			for(j=i;j<=N;j++){
				PP[k]=P[i]+P[j];
				k++;
			}
		}
		
		qsort(PP,k,sizeof(int),comp);
		
		score_all=searchSup4(PP,k,M,2);
		printf("%d\n",score_all);
		
	}
	return 0;
}

int comp(const void *a,const void *b){
	int x= *(int *)a;
	int y= *(int *)b;
	return x>y?1:(x<y?-1:0);
}

int searchSup4(int P[],int imax,int trgt,int times){
//printf("imax=%d,trgt=%d,times=%d\n",imax,trgt,times);
	int score;
	int score_max;
	int i;
	int i0;
	
//	i0=imax;
//	while(i0>=0){
//		if(P[i0]<=trgt)break;
//		i0--;
//	}

	i0=0;
	int convR=imax;
	while(convR){
//printf("\tconvR=%d,i0=%d,P[i0]=%d,trgt=%d\n",convR,i0,P[i0],trgt);
		convR/=2;
		if(P[i0+convR]>trgt){
			i0=i0;
		}else{
			i0+=convR;
		}
		
	}
	while(i0<=imax && P[i0]<=trgt)i0++;
	i0=i0-1;
	
//printf("i0=%d,P[i0]=%d,imax=%d,",i0,P[i0],imax);if(i0<imax)printf("P[i0+1]=%d,",P[i0+1]);puts("");

//printf("\ti0=%d,trgt=%d\n",i0,trgt);
	if(times==1){
		return P[i0];
	}
	
	score_max=0;
	for(i=i0;i>=0;i--){
//printf("\t\ti0=%d,i=%d\n",i0,i);
		score=P[i]+searchSup4(P,i,trgt-P[i],times-1);
		if(score>=score_max)score_max=score;
	}
	return score_max;
}

Measured memory_bytes: 4564
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <bits/stdc++.h>
#include <unistd.h>

using i64 = std::uint_fast32_t;

namespace io {
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline i64 scan() {
    i64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
    *op++ = c;
    if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  /* x shoud be greater than or equal to zero */
  inline void print(i64 x) {
    char d[20];
    int i = 0;
    while (true) {
      d[i] = x % 10 + 48;
      x /= 10;
      ++i;
      if (x <= 0) break;
    }
    while (i--) {
      putc(d[i]);
    }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}

signed main() {
  using namespace io;
  i64 h = scan();
  i64 n = scan();
  i64 s = 0;
  for (int i = 0; i < n; i++) {
    s += scan();
  }
  if (s >= h) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 384
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll n;
    cin >> n;
    map<string, int> result;
    rep(i, n) {
        string s;
        cin >> s;
        ++result[s];
    }
    printf("AC x %d\n", result["AC"]);
    printf("WA x %d\n", result["WA"]);
    printf("TLE x %d\n", result["TLE"]);
    printf("RE x %d\n", result["RE"]);
    return 0;
}


Measured memory_bytes: 3260
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, const char * argv[]) {
    char s[101] = {0};
    char t[101] = {0};
    
    cin >> s >> t;
    
    sort(s, s + strlen(s));
    sort(t, t + strlen(t), greater<char>());
    
    if (strcmp(s, t) < 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

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

const int MAXN = 100000;
const int MAXM = 100000;

int N, M, K, L, parent[MAXN+MAXM+5];

int root(int x) {
    if (parent[x] == -1) return x;
    return parent[x] = root(parent[x]); // path compression + return
}

bool isConnected(int A, int B) {
	int rootA = root(A);
	int rootB = root(B);
	return (rootA == rootB);
}

void connect(int x, int y) {
	int rootX = root(x);
	int rootY = root(y);
	if (rootX != rootY) parent[rootX] = rootY;
}
// person is i
// language is MAXN + L

int main() {
	memset(parent, -1, sizeof parent);
	cin >> N >> M;
    for (int i=1;i<=N;i++) {
        cin >> K;
        for (int j=1;j<=K;j++) {
            cin >> L;
            connect(i, MAXN + L); // connecting person to language.
        }
    }
    int cnt=1;
    for (int i=2;i<=N;i++) {
        if (!isConnected(i,1)) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    int n; cin >> n;
    switch(n % 10){
        case 2: case 4: case 5 : case 7: case 9:
        cout << "hon" << endl;break;
        case 0:case 1: case 6: case 8:
        cout << "pon" << endl;break;
        case 3 : cout << "bon" << endl;
    }
    system("pause");
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;	// 998244353
using ll = long long;
using namespace std;

ll power( ll a, int b ){
	ll res = 1;
	while( b > 0 ){
		if( b & 1 ) res = res*a % mod;
		a = a*a % mod;
		b >>= 1;
	}
	return res;
}

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

	vector<int> a(n);
	for( auto &k : a ) cin >> k;

	const int a_bound = 1000010;
	vector<int> l(a_bound, 0);

	for( auto k : a ){
		if( k == 1 ) continue;
		int t = k;
		for( int p = 2; p*p <= k; ++p ){
			int cnt = 0;
			while( t % p == 0 ){
				t /= p;
				++cnt;
			}
			if( cnt > 0 ){
				l[p] = max(l[p], cnt);
			}
		}
		if( t != 1 ){
			l[t] = max(l[t], 1);
		}
	}
	
	vector<int> pset;
	for( int p = 2; p <= a_bound; ++p ){
		if( l[p] > 0 ) pset.emplace_back(p);
	}

	ll ans = 0;
	
	for( auto &t : a ){
		ll pro = 1;
		for( auto p : pset ){
			int cnt = 0;
			while( t % p == 0 ){
				t /= p;
				++cnt;
			}
			pro *= pow((ll)p, l[p]-cnt);
			pro %= mod;
		}
		ans += pro;
		ans %= mod;
	}

	cout << ans << endl;
}

Measured memory_bytes: 4352
N,M = (int(x) for x in input().split())
R = N
L = 1
for i in range(M):
  l,r = (int(x) for x in input().split())
  if l > L:
    L = l
  if r < R:
    R = r
if R-L < 0:
  print(0)
else:
  print(R-L+1)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextLong());
        }
        long max = Collections.max(list);
        long min = Collections.min(list);
        System.out.println(max - min);
    }
}

Measured memory_bytes: 35848
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

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

  vector<int> M;
  rep(i, N) {
    int m;
    cin >> m;
    M.push_back(m);
  }

  int result = 0;
  int highest = 0;
  rep(i, N) {
    if (M[i] >= highest) {
      result++;
      highest = M[i];
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    N = int(input())
    A = list(map(int, input().split()))

    ds_list = []
    for k in range(20):
        ds = [-1] * N
        ds_list.append(ds)
        half = 2 ** k
        divider = half * 2
        last = -1
        for i in range(N):
            if half <= A[i] % divider:
                ds[i] = last = i
            else:
                ds[i] = last


    cn = 0
    for r in range(N - 1, -1, -1):
        if r == 0:
            cn += 1
            break

        lp = -1
        for k in range(20):
            p = ds_list[k][r]
            if p <= 0:
                continue
            else:
                lp = max(lp, ds_list[k][p - 1])
        cn += r - lp


    print(cn)


if __name__ == '__main__':
    main()



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

int main(){
    int N,i;
    long long sum;
    sum = 0;

    cin >> N;

    for(i = 1; i <= N; i++){
        if(i % 3 != 0 && i % 5 != 0) sum += i;
        //cout << i << ":" << sum << endl;
    }

    cout << sum << endl;

}

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

using namespace std;
typedef long long int ll;

int main() {
  int n;
  int a;
  deque<int> deq;
  cin>>n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (i & 1)
      deq.push_front(a);
    else
      deq.push_back(a);
  }
  if (n & 1) reverse(deq.begin(), deq.end());
  for (auto&& b : deq) {
    cout << b << " ";
  }
  cout << endl;

  return 0;
}


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;

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

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> vn,vp;
  rep(i,N) {
    ll x;
    cin>>x;
    if(x<0LL) vn.push_back(x);
    if(x>=0LL) vp.push_back(x);
  }
  reverse(vn.begin(),vn.end());
  ll d = INF;
  for(ll i =0LL ; i <= K; i ++) {
    if(K-i>(ll)vp.size()) continue;
    if(i>(ll)vn.size())continue;
    ll dd;
    if(i==0LL){
      dd=vp[K-1LL];
    }
    else if(i == K){
      dd=-vn[K-1LL];
    }
    else{
      dd=2LL*(-vn[i-1LL])+vp[K-i-1LL];
    }
    chmin(d,dd);
  }
  for(ll i =0LL ; i <= K; i ++) {
    if(K-i>(ll)vn.size()) continue;
    if(i>(ll)vp.size())continue;
    ll dd;
    if(i==0LL){
      dd=-vn[K-1LL];
    }
    else if(i == K){
      dd=vp[K-1LL];
    }
    else{
      dd=2LL*(vp[i-1LL])-vn[K-i-1LL];
    }
    chmin(d,dd);
  }
  cout<<d<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i,n) {
    int x, y;
    cin >> x >> y;
    a[i] = x-y;
    b[i] = x+y;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int ans = max(a.back()-a.front(), b.back()-b.front());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4776
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

int query(int q) {
	printf("%d\n", q);
	fflush(stdout);
	string s; cin >> s;
	if (s == "Vacant") exit(0);
	if (s == "Male") return 0;
	else return 1;
}
void solve(int l, int r, int lq, int rq) {
	int mi = (l + r) / 2;
	int q = query(mi);
	if (q == (lq ^ (mi - l) & 1)) solve(mi, r, q, rq);
	else solve(l, mi, lq, q);
}

int main(){
	int n; cin >> n;
	solve(0, n - 1, query(0), query(n - 1));
	return 0;
}


Measured memory_bytes: 852
#include <stdio.h>

int main(void)
{
	long a, b, t;
	
	while (scanf("%ld %ld", &a, &b) != EOF){
		while (b != 0){
			if (a < b){
				t = a;
				a = b;
				b = t;
			}
			t = a % b;
			a = b;
			b = t;
		}
		printf("%ld\n", a);
		
	}
	return (0);
}

Measured memory_bytes: 596
using System;
class Program
{
	static void Main(string[] args)
	{
        string input1 = Console.ReadLine();
        string[] input2 = Console.ReadLine().Split(' ');
        int n = int.Parse(input1);
        int[] Ps = new int[n];

        for (int i = 0; i < n; i++)
        {
            Ps[i] = int.Parse(input2[i]);
        }

        int count = 0;
        int min = Ps[0];
        for (int i = 0; i < n; i++)
        {
            if(Ps[i] <= min)
            {
                count++;
                min = Ps[i];
            }
        }
		//出力
		Console.WriteLine(count);
	}
}


Measured memory_bytes: 33116
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  int r, g;
  cin >> r >> g;
  cout << g * 2 - r << endl;

}


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

static const int maxn = 10001;

int isp[maxn];
vector<int> p;

void eratosthenes() {
	//init
	fill(isp, isp + maxn, 1);


	int i, j;
	int maxi = sqrt(maxn);
	for (i = 2; i <= maxi; i++) {
		j = i + i;
		while (j < maxn) {
			isp[j] = 0;
			j += i;
		}
	}

	for (i = 2; i < maxn; i++) {
		if (isp[i])p.push_back(i);
	}

}

int main() {
	int i, j, k;

	eratosthenes();
	/*
	for (i = p.size() - 1; i >= 0; i--) {
		cout << p[i] << endl;
	}
	*/

	while (1) {
		int n;

		cin >> n;
		if (n == 0)break;

		int a = 0, b = 0; // [a, b]
		int sum = 2;
		int ans = 0;
		while (b <= n) {
			if (sum == n) {
				ans++;
				b++;
				sum += p[b];
			} else if (sum < n) {
				b++;
				sum += p[b];
			} else if (sum > n) {
				sum -= p[a];
				a++;
			}
		}

		cout << ans << endl;
		
	}

	

	return 0;
}

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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ll n,i,j,ans=0,cnt; cin >>n; ll m=sqrt(n);
	for (i=2;i<=m;i++) {
		cnt=0;
		while (n%i==0) {
			n/=i;
			cnt++;
		}
		for (j=1;;j++) {
			if (cnt-j<0) break;
			cnt-=j;
			ans++;
		}
//		cout <<ans<<" ";
	}
	if (n!=1) ans++;
	cout <<ans;
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 3680
#include<stdio.h>
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int a[n+1];
    double sum=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    int cm=0;
    double std=sum/(4*m);
    for(int i=1;i<=n;i++){
        if(std<=a[i]){
            cm++;
        }
    }
    if(cm>=m){
        printf("Yes\n");
        return 0;
    }else{
        printf("No\n");
        return 0;
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
using namespace std;
/*
struct ar{
    int a,b,c,d;
};
bool comp(ar x,ar y)
{
    return(x.d>y.d);
}*/
int main(){
    fast
long long  a,b,n,x;
cin>>a>>b>>n>>x;
x=min(n,b-1);
cout<<(a*x/b)-a*(x/b)<<endl;

return 0;
}


Measured memory_bytes: 3612
def resolve():
    MOD = 10**9+7
    K = input()
    D = int(input())
    N = len(K)

    # dp[keta][D][smaler]
    dp = [[[0]*2 for _ in range(D)] for _ in range(N+1)]
    dp[0][0][0] = 1

    for i in range(N):
        for d in range(D):
            # smaller=1 どの数字も使用できる
            for k in range(10):
                dp[i + 1][(d + k) % D][1] += dp[i][d][1]
                dp[i + 1][(d + k) % D][1] %= MOD

            # smaller=0 K[i]未満の数字のみ使用できる
            # 次の遷移は繰り上げが無いのでどの数字も使用できる。smaller = 1
            num = int(K[i])
            for k in range(num):
                dp[i + 1][(d + k) % D][1] += dp[i][d][0]
                dp[i + 1][(d + k) % D][1] %= MOD

            dp[i + 1][(d + num) % D][0] += dp[i][d][0]
            dp[i + 1][(d + num) % D][0] %= MOD


    print((dp[N][0][0] + dp[N][0][1] - 1) % MOD)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 157332
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int64_t X;
    cin >> X;
    for (int64_t i = -2000; i < 2001; i++){
        for (int64_t j = -2000; j < 2001; j++){
            if (i * i * i * i * i - j * j * j * j * j == X){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int h, w, n, idx = 1;
    cin >> h >> w >> n;
    int arr[n + 5], ans[h + 5][w + 5];
    for(int i = 1; i <= n; i++)
        cin >> arr[i];
    for(int i = 0; i < h; i++)
    {
        if(i % 2 == 0)
        {
            for(int j = 0; j < w; j++)
            {
                if(arr[idx])
                    ans[i][j] = idx;
                else
                {
                    while(!arr[idx])
                        idx++;
                    ans[i][j] = idx;
                }
                arr[idx]--;
            }
        }
        else
        {
            for(int j = w - 1; j >= 0; j--)
            {
                if(arr[idx])
                    ans[i][j] = idx;
                else
                {
                    while(!arr[idx])
                        idx++;
                    ans[i][j] = idx;
                }
                arr[idx]--;
            }
        }
    }
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
            cout << ans[i][j] << " ";
        cout << endl;
    }
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  map<int,int> A;
  for(int i=0;i<N;i++){
    A[i]=0;
  }

  int a;
  for(int i=1;i<N;i++){
    cin>>a;
    a--;
    A[a]++;
  }

  for(int i=0;i<N;i++){
    cout<<A.at(i)<<endl;
  }
}

Measured memory_bytes: 13012
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc131_a.cpp
 * time   : Sat May  2 00:50:57 2020
 * quest  : A - Security
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  cout << ((s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) ? "Bad\n" : "Good\n");
  return 0;
}


Measured memory_bytes: 256
package main

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

type TupleInt struct {
	first  int
	second int
}

func main() {
	sc := NewScanner()
	N, M := sc.NextInt(), sc.NextInt()
	A := make(SortInterFace, N)
	for i := 0; i < N; i++ {
		A[i] = TupleInt{sc.NextInt(), sc.NextInt()}
	}
	k := 0
	sum := 0
	sort.Sort(A)
	for i := 0; i < N; i++ {
		l := max(0, min(M-k, A[i].second))
		sum += A[i].first * l
		k += l
	}
	fmt.Println(sum)

}
func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type SortInterFace []TupleInt

func (s SortInterFace) Len() int {
	return len(s)
}
func (s SortInterFace) Less(i, j int) bool {
	return s[i].first < s[j].first
}
func (s SortInterFace) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 5120
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
ll n , a[N] , ans , cmax;
int main(){
fcin;
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    for(int i= 0 ;i  < n ; i ++){
        cmax = max(a[i],cmax);
        if(a[i] < cmax) ans+=abs    (a[i]-cmax);
    }
    cout << ans<<'\n';


}

Measured memory_bytes: 4732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	
	public static void Main(string[] args)
	{
		int n = Console.ReadLine().ToInt();
		int[] bh = Input().ToInt();
		int[] h = new int[n+2];
		Array.Copy(bh, 0, h, 0, n);
		int[] c = new int[n+2];
		for(int i = 1; i < n; i++)
			c[i]=999999999;
		for(int i = 0; i < n; i++)
		{
			c[i+1] = Math.Min(c[i+1], Math.Abs(h[i]-h[i+1]) + c[i]);
			c[i+2] = Math.Min(c[i+2], Math.Abs(h[i]-h[i+2]) + c[i]);
		}
		Console.WriteLine(c[n-1]);
	}
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		int[] r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
	
}

Measured memory_bytes: 19296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n, k; cin >> n >> k;
	vector<vector<ll>> g(n);
	REP(i, n - 1) {
		ll a, b; cin >> a >> b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	ll ma = 0;
	REP(i, n) {
		vb visited(n, false);
		ll cnt = 0;
		{
			queue<pair<ll, ll>> que;
			que.push({ i, 0 });
			while (!que.empty()) {
				ll cur, depth;
				tie(cur, depth) = que.front(); que.pop();
				visited[cur] = true;
				cnt++;
				if (depth == k / 2) continue;
				for (auto e : g[cur]) if (!visited[e]) que.push({ e, depth + 1 });
			}
		}

		if (k % 2 != 0) {
			function<ll(ll, ll)> dfs = [&] (ll cur, ll prev) -> ll{
				if (cur == i) {
					ll ans = 0;
					for (auto e : g[cur]) if(e != prev) {
						if (visited[e]) {
							ans = max(ans, dfs(e, cur));
						} else {
							return 1;
						}
					}
					return ans;
				} else {
					ll cnt = 0;
					for (auto e : g[cur]) if (e != prev) {
						if (visited[e]) {
							cnt += dfs(e, cur);
						} else {
							cnt++;
						}
					}
					return cnt;
				}
			};
			cnt += dfs(i, -1);
		}

		ma = max(ma, cnt);
	}
	cout << n - ma << endl;

	return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <iomanip>
#include <cassert>
#include <string.h>
#include <cstdio>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-8;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9 + 7;
const LL MAX = 1 << 20;

int n;
int a[MAX];

void bad()
{
	cout << -1 << endl;
	exit(0);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	cin >> n;
	FOR(i, 0, n)
		cin >> a[i];

	if (a[0])
		bad();

	FOR(i, 1, n)
		if (a[i] > a[i - 1] + 1)
			bad();

	LL ans = 0;
	set<int> treba;
	int level = 0;
	RFOR(i, n, 1)
	{
		if (a[i] < 2)
		{
			if (a[i])
				++ans;
			treba.clear();
			level = 0;
			continue;
		}

		treba.insert(a[i] + level);
		ans += SZ(treba);
		level++;
		if (*treba.begin() <= level)
			treba.erase(treba.begin());					
	}

	cout << ans << endl;
	cin >> n;
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n]={0};
	for (int i = 0; i < n-1; ++i)
	{
		cin>>a[i];
	}
	int ans=0;
	ans+=a[0];
	ans+=a[n-2];
	for (int i = 0; i < n-1; ++i)
	{
		ans+=min(a[i],a[i+1]);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main() {
	while (true) {
		int h;
		cin >> h;
		if (h == 0) return 0;
		int gogo[10][5] = {};
		int ans = 0;
		REP(i, h) {
			REP(q, 5) {
				cin >> gogo[(10 - h)+i][q];
			}
		}
		int diff = 1;
		while (diff != 0) {
			diff = 0;
			int deleted[10][5] = {};
			REP(i, 10) {
				for (int q = 0; q + 2 < 5; ++q) {
					if(gogo[i][q] == gogo[i][q+1] && gogo[i][q] == gogo[i][q+2]){
						deleted[i][q] = 1;
						deleted[i][q + 1] = 1;
						deleted[i][q + 2] = 1;
					}
				}
			}
			REP(i, 10) {
				REP(q, 5) {
					if (deleted[i][q] == 1) {
						diff += gogo[i][q];
						gogo[i][q] = 0;
					}
				}
			}
			REP(t,10)
			for (int i = 8; i >= 0; --i) {
				//simulate droppings
				for (int q = 0; q < 5; ++q) {
					if (gogo[i + 1][q] == 0) {
						gogo[i + 1][q] = gogo[i][q];
						gogo[i][q] = 0;
					}
				}
			}
			ans += diff;
		}
		cout << ans << endl;
	}
}


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

const int MAXN = 2e5;
int arr[MAXN];
int l[MAXN], r[MAXN];
int l2[MAXN], r2[MAXN];

main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> arr[i];
    }
    for (int i = 0; i < n + 2; ++i) {
        r[i] = n + 1;
        r2[i] = n + 1;
    }
    for (int i = 0; i < n + 2; ++i) {
        l[i] = 0;
        l2[i] = 0;
    }
    vector<pair<int, int>> st;
    vector<pair<int, int>> st2;
    for (int i = 1; i <= n; ++i) {
        while (!st2.empty() && st2.back().second < arr[i]) {
            r2[st2.back().first] = i;
            st2.pop_back();
        }
        int x = 0;
        while (!st.empty() && st.back().second < arr[i]) {
            r[st.back().first] = i;
            st2.push_back(st.back());
            st.pop_back();
            ++x;
        }
        reverse(st2.end() - x, st2.end());
        st.push_back({i, arr[i]});
    }
    st.clear();
    st2.clear();
    for (int i = n; i >= 1; --i) {
        while (!st2.empty() && st2.back().second < arr[i]) {
            l2[st2.back().first] = i;
            st2.pop_back();
        }
        int x = 0;
        while (!st.empty() && st.back().second < arr[i]) {
            l[st.back().first] = i;
            st2.push_back(st.back());
            st.pop_back();
            ++x;
        }
        reverse(st2.end() - x, st2.end());
        st.push_back({i, arr[i]});
    }
    int ans = 0;
    for (int i = 1; i < n + 1; ++i) {
        // cout << l[i] << " " << r[i] << endl;
        // cout << l2[i] << " " << r2[i] << endl;
        ans += (l[i] - l2[i]) * (r[i] - i) * arr[i];
        ans += (r2[i] - r[i]) * (i - l[i]) * arr[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 8564
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main(){
    ll x, y;
    cin >> x >> y;

    int ans = 0;
    while(x <= y){
        ans++;
        x *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
vector<bool> seen;
void dfs(const Graph& G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}
signed main() {
    long long INF = 1000000000000;
    int N;cin>>N; vector<int>H(100005);
    vector<int>DP(100005, INF);
    DP[0] = 0;
    for(int X=0;X<N;X++){
      cin>>H[X];
    }
    for (int X = 0; X < N; X++) {
        for (int Y = 1; Y <= 2; Y++) {
            chmin(DP[X + Y], DP[X] + std::abs(H[X] - H[X + Y]));
        }
    }
    cout<<DP[N-1]<<endl;
}


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

int main() {
    long long int n,sum;cin>>n>>sum;
    long long int val[n];long long  int w[n];
    long long int i,j,k;
    for(i=0;i<n;i++)
    {
        cin>>w[i]>>val[i];
    }
    long long int dp[n+1][sum+1];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=sum;j++)
        {
            dp[i][j] = 0;
        }
    }
    
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=sum;j++)
        {
            if(j>=w[i-1])
            {
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]]+val[i-1]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    
    cout<<dp[n][sum]<<endl;
    
	// your code goes here
	return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int fib[50];
int Solve(int n)
{
    if(n == 0 || n == 1) return fib[n] = 1;
    if(fib[n] != 0) return fib[n];
    return fib[n] = Solve(n - 1) + Solve(n - 2);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for(int i = 0; i < 50; i++) fib[i] = 0;
    cout << Solve(n) << endl;
    return 0;
}




Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long

const int N = 1e6 + 1;
int32_t main(){
   boost;
   int n;
   cin>>n;
   int a[n];
   int mark[N]={0};
   for(int i=0;i<n;i++){
      cin>>a[i];
      mark[a[i]]++;
   }
   for(int i=1;i<N;i++){
      if(mark[i] > 0){
         for(int j=2*i;j<N;j+=i)
            mark[j] = -1;
      }
      if(mark[i]>1)
         mark[i] = -1;
   }
   int ans = 0;
   for(int i=1;i<N;i++)
      if(mark[i]>0)
         ans++;
   cout<<ans<<endl;
}

Measured memory_bytes: 13024
/*
....................
....................
*/
#include<bits/stdc++.h>
#define ll long long int
#define here cout<<"here\n"
#define pb push_back
#define mp make_pair
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pf printf
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
using namespace std;

const ll mod = 1e9+7;

const int MAX = 100005;


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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll A[n],B[n],C[n],i,j;
    for(i=0;i<n;i++)
    {
    	cin>>A[i]>>B[i]>>C[i];
    }
    ll an1=A[0],an2=B[0],an3=C[0];
    // cout<<an1<<" "<<an2<<" "<<an3<<endl;
    for(i=1;i<n;i++)
    {
    	ll an11=A[i]+max(an2,an3);
    	ll an22=B[i]+max(an1,an3);
    	ll an33=C[i]+max(an1,an2);
    	an1=an11;
    	an2=an22;
    	an3=an33;
    	// cout<<an1<<" "<<an2<<" "<<an3<<endl;
    }
    
    cout<<max({an1,an2,an3})<<endl;
	
	return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  int ma=max(A,B);
  int mi=min(A,B);
  
  if((ma-mi)%2 == 0){
    int C=-(ma-mi)/2+ma;
       cout << C << endl;
    }else{
    cout << "IMPOSSIBLE" << endl;
    }
}

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"
#include "profile.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define profile(X) LOG_DURATION(X)
#else
#define debug(...) 42
#define profile(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-9;
const int MOD = 1e9 + 7;
const ld PI = 3.141592653589793;
const int maxn = 600001;
using cd = complex<double>;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

int l[maxn];
int r[maxn];
int d[maxn];
int up[maxn];
int par[maxn];

pair<int, int> _find(int v) {
    if (v == par[v]) {
        return {v, 0};
    }
    auto x = _find(par[v]);
    par[v] = x.first;
    up[v] += x.second;
    return {par[v], up[v]};
}

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    profile("all");
    auto solve = [](int _) {
        int n, m;
        cin >> n >> m;
        for (int i = 1; i <= n; ++i) {
            par[i] = i;
        }
        for (int i = 1; i <= m; ++i) {
            cin >> l[i] >> r[i] >> d[i];
            auto root1 = _find(l[i]);
            auto root2 = _find(r[i]);
            if (root1.first == root2.first) {
                int dist_r = up[r[i]];
                int dist_l = up[l[i]];
                int exp = dist_r - dist_l;
                if (exp != d[i]) {
                    cout << "No";
                    return;
                }
            }
            par[root2.first] = root1.first;
            up[root2.first] = d[i] - up[r[i]] + up[l[i]];
        }
        cout << "Yes";
    };


    fast_io();

    cout.precision(9);
    cout <<
         fixed;
    for (int i = 1; i <= 1; ++i)
        solve(1);


}


Measured memory_bytes: 6672
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>
// #include <multiset>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
	for (T x : s)
		cout << x << " ";
	cout << endl;
}

ll gcd(ll a, ll b){
	return b > 0 ? gcd(b, a % b) : a;
}

const int maxn = 1e5 + 7;

int get(int n, int l, int x){
	ll summa = 0;
	for (int i = 0; i < n; i++){
		if (i + l != x)
			summa += i + l;
	}
	return summa;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	int n, k;
	cin >> n >> k;
	if (k + n - 1 > n * (n - 1) / 2){
		cout << -1 << endl;
		return 0;
	}
	if (k + n - 1 <= n * (n - 1) / 2){
		int now = n * (n - 1) / 2 - k;
		cout << now << endl;
		// int now = 0;
		for (int i = 1; i <= n; i++){
			for (int j = i + 1; j <= n; j++){
				cout << i << " " << j << "\n";
				now--;
				if (now == 0)
					return 0;
			}
		}
	}
	return 0;	
}	


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,j,c,n,r=0;
  scanf("%d",&n);
  for(i=1;i<=n;i+=2){
    c=0;
    for(j=1;j<=n;j++)if(i%j==0)c++;
    if(c==8)r++;
  }
  printf("%d",r);
  return 0;
}

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

int main(){
  string O,E; cin >> O >> E;
  int o=O.size();
  int e=E.size();
  string ans="";
  for(int i=0;i<e;i++){
    ans+=O.at(i);
    ans+=E.at(i);
  }
  if(o>e){
    ans+=O.at(o-1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();

    let mut total = N * (N + 1) / 2;

    for i in 2..=N {
        let mut t = i;
        while t <= N {
            total += t;
            t += i;
        }
    }

    println!("{}", total);
}


Measured memory_bytes: 2156
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	_ = nextInt()
	m := nextInt()
	swa := map[int]int{}
	sac := map[int]int{}
	for i := 0; i < m; i++ {
		p := nextInt()
		str := nextStr()
		if str == "AC" {
			sac[p]++
		} else {
			_, ok := sac[p]
			if ok == false {
				swa[p]++
			}
		}
	}

	ansac := len(sac)
	answa := 0

	for k, v := range swa {
		_, ok := sac[k]
		if ok == true {
			answa += v
		}
	}

	fmt.Println(ansac, answa)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 8140
import numpy as np
N,K,Q=np.array(list(map(int, input().split())))

N_i=np.zeros(N)+K-Q
A=np.zeros(Q)
for i in range(Q):
    A[i]=int(input())

for i in range(Q):
    N_i[int(A[i]-1)]+=1

for i in N_i:
    if i<=0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 15540
#include <bits/stdc++.h>
    using namespace std;
     int n,a[100006],b[100006],c[100006],dp[100006][4];
    int main()
    {
      cin>>n;
      for(int i=1;i<=n;i++){ 
          cin>>a[i]>>b[i]>>c[i];
      } 
      
      for(int i=1;i<=n;i++){ 
          dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
          dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
          dp[i][3]=max(dp[i-1][1],dp[i-1][2])+c[i];
      } 
      cout<<max({dp[n][1],dp[n][2],dp[n][3]})<<"\n";
      
        
     
        return 0;
    }

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N, M; cin >> N >> M;
  unordered_set<int> se1, se2;
  rep(i, M) {
    int a, b; cin >> a >> b;
    if (a == 1) se1.insert(b);
    if (b == N) se2.insert(a);
    if (a == 1 && se2.find(b) != se2.end() ||
        b == N && se1.find(a) != se1.end()) {
      cout << "POSSIBLE" << '\n';
      return;    
    }
  }
  cout << "IMPOSSIBLE" << '\n';
}


Measured memory_bytes: 8520
# ABC162C

from fractions import gcd
from math import gcd

k = int(input())
total = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            # print(a, b, c, gcd(a, gcd(b, c)))
            total += gcd(a, gcd(b, c))
print(total)


Measured memory_bytes: 10380