akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct Union_Find_Tree{
    vector<int> par, rank, num;
    const int n;
    
    Union_Find_Tree(int n) : n(n){
        par.assign(n, -1), rank.assign(n, 0), num.assign(n, 1);
    }
    
    int root(int x){
        if(par[x] < 0 || par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    bool unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y);
        if(rank[x] == rank[y]) rank[x]++;
        par[y] = x, num[x] += num[y];
        return true;
    }
    
    int size(int x) {return num[root(x)];}
    
    bool same(int x, int y) {return root(x) == root(y);}
    
    void clear(){
        fill(all(par), -1), fill(all(rank), 0), fill(all(num), 1);
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    Union_Find_Tree uf(N);
    int ans = N-1;
    rep(i, M){
        int u, v; cin >> u >> v; u--, v--;
        if(uf.unite(u, v)) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4580
#include<stdio.h>
#include<string.h>
int N,M[101][101][2],i,j,F[101][101],c,R;

int dfs(int x,int y,int f)
{
	if(F[y][x]==f)return 1;
	if(F[y][x]==0)
	{
		F[y][x]=f;
		return dfs(M[y][x][0],M[y][x][1],f);
	}
	return 0;
}

int main()
{
	for(;scanf("%d",&N),N;)
	{
		memset(F,0,sizeof(F));
		for(i=0;i<N;i++)
			for(j=0;j<N;j++)
				scanf("%d%d",&M[i][j][0],&M[i][j][1]);
		for(i=R=0,c=1;i<N;i++)
			for(j=0;j<N;j++)
				if(F[i][j]==0)
				{
					R+=dfs(j,i,c++);
				}
		printf("%d\n",R);
	}
	return 0;
}

Measured memory_bytes: 728
#include <stdio.h>

int main() {
    char s[200000];
    
    scanf("%s",s);
    
    for(int i=0;i<sizeof(s);i++){
        if(s[i]=='?'){
            s[i]='D';
        }
    }
    printf("%s", s);
    return 0;
}


Measured memory_bytes: 1928
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000
#define ll long long int
using namespace std;

#define min max

int main(){
 int a,b,c;cin>>a>>b>>c;
 int ans = a+b+c;
 int d = min(a,b);
 d =min(d,c);
 cout<<ans - d<<endl;


  return 0;
}

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

int check(vector< int > A, int Q, int r[11][4]) {
    int score = 0;
    for (int i = 0; i < Q; i++) {
        if (A[r[i][1]] - A[r[i][0]] == r[i][2]) {
            score += r[i][3];
        }
    }
    return score;
}
int main(void) {
    int N, M, Q;
    std::cin >> N >> M >> Q;
    int r[55][4];
    for (int i = 0; i < Q; i++) {
        cin >> r[i][0] >> r[i][1] >> r[i][2] >> r[i][3];
    }
    vector< int > A(N + 10);
    for (int i = 0; i <= N; i++) {
        A[i] = 1;
    }
    A[N + 1] = M;
    int digit = N, score = 0;
    while (true) {
        score = max(score, check(A, Q, r));
        if (digit < 1) {
            digit = 1;
        }
        while (A[digit] == A[digit + 1]) {
            A[digit] = 1;
            ++digit;
            if (digit > N) {
                break;
            }
        }
        if (digit > N) {
            break;
        }
        ++A[digit];
        --digit;
    }
    printf("%d\n", score);

    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if(n<m)
  {
    for(int i=0;i<m;i++)
      cout<<n;
    cout<<endl;
  }
  else
  {
    for(int i=0;i<n;i++)
      cout<<m;
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 10010010010
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

 

 
int main(){
    ll n; cin >> n;
    
    ll ans = 1000000000005;
    
    for(ll i=1; i*i<=n; i++){
        if(n%i == 0){
            ll a = i;
            ll b = n/i;
            ans = min(ans, a+b-2);
        }
    }
    cout << ans << endl;
    
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int64_t n, m;
  cin >> n >> m;
  for (int64_t i = m / n + 1; 1 <= i; --i) {
    if (m < i * n)
      continue;
    int64_t rem = m - i * n;
    if ((rem % i) == 0) {
      cout << i << "\n";
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,cnt=0,y;
    cin>>n>>m;
    while(n--)
    {
        cin>>y;
        if(y>=m)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  
    int n;
    cin>>n;
 
    char a = 'a';//char('a'-1);
    // cout<<char(a+1)<<endl;
    // int pos = 0;
    string s  = "";
    while(n>0){
        n-=1;
        s+=char(a + n%26);
        n/=26;
    }
    for(int i =s.size()-1;i>=0;i--)
    cout<<s[i];
    
 
    return 0;
}


Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
S=sys.stdin.readline().strip()

def isok(d):    #長さdの文字列で重ならない2つの文字列が存在するかを判定
    D={}    #出てきた文字列:スタート位置
    for i in range(N-d+1):
        x=S[i:i+d]
        if x not in D:  #前に文字列が出てきていない場合
            D[x]=i
        else:  #既に文字列が出てきている場合
            if d<=i-D[x]:    #文字列が重なっていない場合は
                return True
            else:           #文字列が重なっていた場合は
                pass        #更に右側の文字列を探すために処理を継続する
    else:
        return False

h=N
l=0
while h-l!=1:
    m=(h+l)/2
    if isok(m):
        l=m
    else:
        h=m
print l


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

    int min_i = INF;
    int min_i_abs = INF;
    int ans = 0;

    for(int i=1; i<=N; i++){
        ans += L+i-1;
        if(abs(L+i-1) < min_i_abs){
            min_i = L+i-1;
            min_i_abs = abs(L+i-1);
        }
    }
    cout << ans - min_i << endl;
    return 0;
}

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

int main(){
  int N,M;
  cin >>N >>M;
  int L, R, Lmax=1, Rmin=N;

  for(int i=0; i<M; i++){
    cin >>L >>R;
    if(L>Lmax) Lmax = L;
    if(R<Rmin) Rmin = R;
  }

  int ans;
  if(Rmin < Lmax) {
    ans=0;
  } else {
    ans = Rmin - Lmax + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
int n, no, a, i, j;
char m;
int x[4][13] ={{0}};

scanf("%d",&n);

while(n > 0){
scanf(" %c",&m);
scanf("%d",&no);

if(m == 'S')
a = 0;
if(m == 'H')
a = 1;
if(m == 'C')
a = 2;
if(m == 'D')
a = 3;

x[a][no - 1] = 1;
n--;
}

for(i = 0; i < 4; i++){
for(j = 0; j < 13; j++){
if(x[i][j] == 0){

if(i == 0)
m = 'S';
if(i == 1)
m = 'H';
if(i == 2)
m = 'C';
if(i == 3)
m = 'D';

printf("%c %d\n", m, j + 1);
}
}
}

return 0;
}

Measured memory_bytes: 596
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
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

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(std::string S, std::string T, long long A, long long B, std::string U){
  if(S==U){
    --A;
  }
  if(T==U){
    --B;
  }
  cout<<A<<" "<<B<<endl;
}

int main(){
  cout<<setprecision(1000);
  cin.tie(0);
  ios::sync_with_stdio(false);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long A;
    cin>>A;
    long long B;
    cin>>B;
    std::string U;
    std::cin >> U;
    solve(S, T, A, B, U);
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Vector;

public class Main {

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

		String s1=ob.next();
		char s[]=s1.toCharArray();
		Vector v=new Vector();
		for (int i=0; i<s1.length();) {
			if (s1.charAt(i)=='R') {
				int count=0;
				while (i<s1.length()&&s1.charAt(i)=='R') {
					i++;
					count++;
				}
				v.add(count);
			}
			else {
				while (i<s1.length()&&s1.charAt(i)=='S') {
					i++;
				}
			}
		}
		if (v.isEmpty()) {
			System.out.println(0);
		}
		else {
			System.out.println(Collections.max(v));
		}
	}

}


Measured memory_bytes: 26948
#include <iostream>
using namespace std;
int n,m,dp[50],cnt;
int main(void){
    while(1){
    cin>>n>>m;
    if(n==0&&m==0)return 0;
    for(int j=0;j<50;j++)dp[j]=0;
    int i=0;
    cnt=m;
    while(1){
        if(m>0){
            dp[i]++;
            m--;
        }
        else if(m==0&&dp[i]>0){
            m+=dp[i];
            dp[i]=0;
        }
        if(dp[i]==cnt)break;
        i=(i+1)%n;
    }
    cout<<i<<endl;
    }
}



Measured memory_bytes: 3052
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <ctime>
#include <cstdlib>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1010 , P = 1e9 + 7;
int Pow(int x,ll t){int r=1;for(;t;t>>=1,x=1ll*x*x%P)if(t&1)r=1ll*r*x%P;return r;}
int n,m,black,lr,ud;
ll K;
char s[N][N];

int main(){
    scanf("%d%d%lld",&n,&m,&K);
    rep(i,0,n) scanf("%s",s[i]);
    rep(i,0,n) rep(j,0,m) black += s[i][j] == '#';
    rep(i,0,n) lr += s[i][0] == '#' && s[i][m-1] == '#';
    rep(i,0,m) ud += s[0][i] == '#' && s[n-1][i] == '#';
    K--;
    if(K<=0||(lr*ud>0)) printf("%d\n",1);
    else {
        int out = lr+ud , in = 0;
        if(lr) rep(i,0,n) rep(j,1,m) in += s[i][j] == '#' && s[i][j-1] == '#';
        else if(ud) rep(i,1,n) rep(j,0,m) in += s[i-1][j] == '#' && s[i][j] == '#';
        int ans = Pow(black,K) , del = ((Pow(black,K) - Pow(out,K))%P+P)%P;
        del = 1ll*del*Pow(black-out,P-2)%P*in%P;
        if(black == out) del = K%P*Pow(black,K-1)%P*in%P;
        ans -= del;if(ans < 0) ans += P;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>

int main() {
	int A = 0;
	int B = 0;
	float T = 0;
	int count = 0;
	
	std::cin >> A;
	std::cin >> B;
	std::cin >> T;
	int i = A;
	T = T + 0.5f;

	while (i < T) {
		count += B;
		i += A;
	}

	std::cout << count << std::endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,A,B;

int main(){
	cin>>N>>A>>B;
	int a=0;
	int b=0;
	int c=0;
	REP(i,N){
		int d;
		cin>>d;
		if(d<=A){
			a++;
		}else if(B<d){
			c++;
		}else{
			b++;
		}
	}
	cout<<min(a,min(b,c))<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,w,ch,cw,dh,dw;
#define pf push_front
#define pb push_back
#define mp make_pair
typedef pair<int,int>pi;
int d[1001][1001],vis[1001][1001];
char s[1001][1001];
int main(){
	cin>>h>>w>>ch>>cw>>dh>>dw;
	int i,j;
	deque<pi>dq;
	for(i=1;i<=h;++i)fill(d[i]+1,d[i]+w+1,0x3f3f3f3f);
	for(i=1;i<=h;++i)for(j=1;j<=w;++j)cin>>s[i][j];
	d[ch][cw]=0;
	vis[ch][cw]=1;
	dq.pf(mp(ch,cw));
	
	while(!dq.empty()){
		int x=dq.front().first,y=dq.front().second;
		//cout<<x<<" "<<y<<endl;
		vis[x][y]=1;
		if(x==dh&&y==dw){
			cout<<d[x][y];
			return 0;
		}
		dq.pop_front();
		for(i=-2;i<3;++i){
			for(j=-2;j<3;++j){
				int nx=x+i,ny=y+j;
				if(nx<1||nx>h||ny<1||ny>w||vis[nx][ny]||s[nx][ny]=='#')continue;
				if(abs(i)+abs(j)<2){
					d[nx][ny]=d[x][y];
					dq.pf(mp(nx,ny));
				}else{
					if(d[x][y]+1<d[nx][ny]){
						d[nx][ny]=d[x][y]+1;
						dq.pb(mp(nx,ny));
					}
				}
				//cout<<":"<<nx<<" "<<ny<<endl;
			}
		}
	}
	cout<<-1;
}

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

int main(){
	int n,m; cin>>n>>m;
	vector<int> a(m,0), b(m-1,0);
	for (int i=0; i<m; i++)
		cin>>a[i];
	sort(a.begin(),a.end());
	for (int i=1; i<m; i++)
		b[i-1]=a[i]-a[i-1];
	sort(b.begin(),b.end());
	int ret=0;
	for (int i=0; i<m-n; i++)
		ret+=b[i];
	cout<<ret<<"\n";
	return 0;
}

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

int main(){
  int city, street, input1, input2;
  cin >> city >> street;
  vector<int> num(city);
  for(int i = 0; i < street; i++){
	cin >> input1 >> input2;
    num.at(input1 -1)++;
    num.at(input2 -1)++; 
  }
  for(int i = 0; i < city; i++)
    cout << num.at(i) << endl;
}

Measured memory_bytes: 256
from itertools import *
def f(s):
 if sum(s)==10:return"((({} + {}) + {}) + {})".format(*s)
 for a,b,c,d in permutations(s):
  for x,y,z in permutations('+-*'*2,3):
   for t in[f"({a} {x} {b}) {y} ({c} {z} {d})",f"(({a} {x} {b}) {y} {c}) {z} {d}",f"({a} {x} ({b} {y} {c})) {z} {d}"]:
    if eval(t)==10:return'('+t+')'
 else:return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


Measured memory_bytes: 5660
import heapq

k, t = map(int, input().split())
a = list(map(int, input().split()))

q = []
for i in range(t):
    heapq.heappush(q, (a[i] * -1, i))

cakes = [-1]
for _ in range(k):
    count1, cake1 = heapq.heappop(q)
    if cakes[-1] == cake1 and len(q) > 0:
        count2, cake2 = heapq.heappop(q)
        cakes.append(cake2)

        heapq.heappush(q, (count1, cake1))
        if count2 + 1 < 0:
            heapq.heappush(q, (count2 + 1, cake2))
    else:
        cakes.append(cake1)
        if count1 + 1 < 0:
            heapq.heappush(q, (count1 + 1, cake1))

ans = sum(1 for i in range(len(cakes) - 1) if cakes[i] == cakes[i + 1])
print(ans)

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
int main(){
    int n;
    scanf("%d",&n);
    int h[100005];
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    int dp[100005];
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    printf("%d\n",dp[n-1]);
}


Measured memory_bytes: 1024
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0)->ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
int fact[int(2e5+1)];
int inv[int(2e5+1)];
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA  
   string s;cin>>s;
    for(int i=0;i+2<sz(s);++i)
    {
      if(s[i]==s[i+2])
      {
        cout<<i+1<<" "<<i+3<<endl;return 0;
      }
    }
    for(int i=0;i+1<sz(s);++i)
    {
      if(s[i]==s[i+1])
      {
        cout<<i+1<<" "<<i+2<<endl;return 0;
      }
    }
    cout<<-1<<" "<<-1<<endl;


}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int A,B,C;
    cin >> A >> C >> B;
    if((A<=B && B<=C)||C<=B&&B<=A){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)

int main(){
	//input
	ll N,K; cin>>N>>K;
	
    if(K>(N-1)*(N-2)/2) cout<<-1;
    else{
        ll H=(N-1)*(N-2)/2-K;
        if(H==0){
            cout<<N-1<<endl;
            rep1(i,N-1){
                cout<<1<<" "<<i+1<<endl;
            }
        }
        else{
            cout<<N-1+H<<endl;
            rep1(i,N-1){
                cout<<1<<" "<<i+1<<endl;
            }

            ll cnt=0;
            FOR(i,2,N){
                FOR(j,i+1,N+1){
                    cout<<i<<" "<<j<<endl;

                    if(++cnt==H) return 0;
                }
            }
        }
    }
}

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

using namespace std;
using namespace std::chrono;

/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
    char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
    vector<char*> v({token});
    while(token = strtok(NULL,", ")) v.push_back(token);
    return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
    debug() << " [" << args.back() << ": " << H << "] ";
    args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------


typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
int mod=1000000007;
const int MX=0x3f3f3f3f;

int main(){
    IOS;
    int n,m,i;
    cin>>n>>m;
    vi adj[n+1];
    int h[n+1],a,b;
    REP(i,1,n) cin>>h[i];
    REP(i,1,m){
        cin>>a>>b;
        adj[a].EB(b);
        adj[b].EB(a);
    }   
    int ans=0,flag;
    REP(i,1,n){
        flag=0;
        if(!adj[i].size()){
            ans++;
            continue;
        } 
        else{
            for(auto u:adj[i])
                if(h[u]>=h[i]) {
                    flag=1;
                    break;
                }
        }
        if(!flag) ans++; 
    }
    cout<<ans;
    return 0;
} 


Measured memory_bytes: 9184
def dfs(a,b,c):
  todo=[[]]
  ret=[]
  while len(todo)>0:
    t=todo.pop()
    l=len(t)
    if l==a:
      ret.append(t)
    else:
      s=0
      for i in range(1,l+1):
        s+=6**i*t[i-1]
      for i in range(b+1):
        if s+6**(l+1)*i<=c:
          tc=t.copy()
          tc.append(i)
          todo.append(tc)
  return ret
a=6
b=5
c=int(input())
l=dfs(a,b,c)
ans=c
for li in l:
  ansi=sum(li)
  now=c-sum([6**(i+1)*li[i]for i in range(len(li))])
  for i in range(1,7):
    ansi+=now%9
    now//=9
  ans=min(ans,ansi)
print(ans)


Measured memory_bytes: 5492
#include<bits/stdc++.h>
using namespace std;
const int N=200005,mod=998244353;
int n,k,l[N],r[N],dp[N]={1},s[N]={1};
int main()
{
	scanf("%d%d",&n,&k);
	n--;
	for(int i=1;i<=k;i++)
		scanf("%d%d",&l[i],&r[i]);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(l[j]>i)
				continue;
			int x=max(0,i-r[j]),y=i-l[j];
			int v=(s[y]+mod-s[x-1])%mod;
			dp[i]=(dp[i]+v)%mod;
		}
		s[i]=(s[i-1]+dp[i])%mod;
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 5344
"""D - 2017-like Number
"""

import math


class Sieve:
    """Sieve of Eratosthenes.

    List primes up to n.
    """

    def __init__(self, n):
        self.__prime = []
        self.__is_prime = [i >= 2 for i in range(n + 1)]

        for i in range(2, int(math.sqrt(n)) + 1):
            if self.__is_prime[i]:
                for j in range(i * i, n + 1, i):
                    self.__is_prime[j] = False

        for i in range(2, n + 1):
            if self.__is_prime[i]:
                self.__prime.append(i)

    def prime(self):
        return self.__prime

    def is_prime(self, n):
        return self.__is_prime[n]


class Fenwick:
    """Fenwick Tree implementation with 1-based index.

    Valid index: [1, N]
    """

    def __init__(self, N):
        self.fen = [0 for _ in range(N + 1)]

    def add(self, idx, val):
        while idx < len(self.fen):
            self.fen[idx] += val
            idx += idx & (-idx)

    def accum(self, idx):
        ret = 0
        while idx > 0:
            ret += self.fen[idx]
            idx -= idx & (-idx)
        return ret

    def sum(self, begin, end):
        return self.accum(end) - self.accum(begin - 1)


if __name__ == '__main__':
    Q = int(input())  # number of query
    A = [0 for _ in range(Q)]  # answer

    SIEVE = Sieve(10 ** 5)

    ACCUM = Fenwick(10 ** 5 + 1)
    for i in range(1, 10 ** 5 + 1):
        if SIEVE.is_prime(i) and SIEVE.is_prime((i + 1) // 2):
            ACCUM.add(i, 1)

    # print(ACCUM.fen)

    for i in range(Q):
        l, r = map(int, input().split())
        A[i] = ACCUM.sum(l, r)

    print('\n'.join(map(str, A)))


Measured memory_bytes: 15820
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

int main() {
	string s;
	cin >> s;
	
	int cnt = count(cbegin(s), cend(s), 'o');
	cout << 700 + cnt * 100 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#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,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

D dp[3005][3005];

int main(){
    int n; cin >> n;
    vector<D> p(n);
    rep(i,n) cin >> p[i];
    dp[0][0] = 1.0;
    rep(i,n){
        rep(j,i+1){
            dp[i+1][j] += dp[i][j] * (1-p[i]);
            dp[i+1][j+1] += dp[i][j] * p[i];
        }
    }
    D ans = 0.0;
    FOR(i, (n+1)/2, n+1) ans += dp[n][i];
    printf("%.10f", ans);
}


Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vvchar vector<vector<char>>
#define vchar vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int n;string s;cin>>n>>s;
    
    int r=0,l=0;

    //)
    rep(i,n){
        if(s[i]=='('){
            r++;
        }else{
            if(r<=0) cout<<'(';
            else r--;
        }
    }
    cout<<s;

    reverse(all(s));
    rep(i,n){
        if(s[i]==')'){
            l++;
        }else{
            if(l<=0) cout<<')';
            else l--;
        }
    }
    cout<<endl;

}

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


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<ctime>
#include<cassert>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int f[1000000];
int main()
{	int n,x,ans=0; cin>>n;
	for(rint i=1;i<=n;i++) scanf("%d",&x),f[x]=f[x-1]+1;
	for(rint i=1;i<=n;i++) ans=max(ans,f[i]);
	cout<<n-ans;
	return 0;
}


Measured memory_bytes: 1024
nums1=[int(e) for e in input().split()]
nums2=[int(t) for t in input().split()]
all_vote = 0
sums = nums1[0]
for num in nums2:
  all_vote += num
for k in nums2:
  if (k/(all_vote) < 1/(4*nums1[1])):
    sums-=1
if(nums1[1]<=sums):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
// cut  count atcoder

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

/*
int main() {
  int n;
  string s;
  cin>>n>>s;
  int ans=0;

  for(int i=0;i<n;i++){
    map<char,int> x,y;
    int cnt=0;

    for(int j=0;j<=i;j++)
    x[s[j]]++;

    for(int j=i+1;j<n;j++)
      y[s[j]]++;


    cout<<"trying to display the map elements "<<endl;

    for(map<char,int>::iterator it= x.begin();it!=x.end();it++)
        cout<<it->first<<" ";

    cout<<"second half"<<endl;

    for(map<char,int>::iterator it = y.begin();it!= y.end();it++)
        cout<<it->first<<" ";

   cout<<endl;

    for(map<char,int>::iterator v= x.begin();v!=x.end();v++){
     if(y.count(v->first)) cnt++;
    }

    //cout<<cnt<<endl;
    ans=max(ans,cnt);

  }
  cout<<ans<<endl;
}

*/



int main(){

 long long n,a,b,pas=0; string s;

 cin>>n>>a>>b;
 cin>>s;

 int foreign = 0;

 for(long long  i=0;i<s.length();i++)
 {

  if(s[i] == 'a'){
      if(pas < a+b){
      cout<<"Yes"<<endl;
       pas++; }
      else cout<<"No"<<endl;
 }
  else if(s[i] == 'b'){

    if(pas < a+b && foreign<b){
        cout<<"Yes"<<endl;
       pas++; }
    else cout<<"No"<<endl;

    foreign++;
 }
  else
    cout<<"No"<<endl;
 }


 return 0;
}




















Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fr(i,a,b) for (int i=(a); i<(b);++i)
#define frr(i,a,b) for(int i=(a-1);i>=(b);--i)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<int,int> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define sz(a) (ll)a.size()
#define endl '\n'
#define po(a,b) (ll)(pow(a,b)+0.5)
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
const ll M=1e8+7;
const int MaxM=2e5+5;

int main()
{ Fast
int n,mx;
cin>>n>>mx;
   int a,b;
   ll dp[mx+1]={};
   fr(i,0,n)
   {   cin>>a>>b;
       frr(i,mx+1,1)
       {
           if(i-a>=0)dp[i]=max(dp[i],dp[i-a]+b);
       }
   }
   cout<<dp[mx]<<endl;
}


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

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

  vector<unsigned int> a(9);
  int x,d,n,di;

  if(K<=9){
    cout<<K<<endl;
    return 0;
  }
  for(int i=0;i<9;++i){
    a[i] = i+1;
  //  cout<<a[i]<<endl;
  }
  n=0;
  while(1){
    x = a[n];
    d = x%10;
    for(int i=-1;i<=1;++i){
      di = d+i;
      if(di>=0 && di<=9){
        a.push_back(x*10+di);
      //  cout<<x*10+di<<endl;
      }
    }
    if(a.size()>=K){
      cout<<a[K-1]<<endl;
      return 0;
      break;
    }
    n = n+1;
  }
  
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, n;
  in(n);
  a = 100000000000;
  b = 0;
  rep(i, n){
    in(c);
    b = b + c;
    if(c % 10 != 0)
      a = min(a, c);
  }
  if(b % 10 == 0)
    out(max(0ll, b - a));
  else
    out(b);
  memi;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for(int i=0;i<n;i++) cin>>h[i];
    sort(h.begin(),h.end());
    ll res=1e15;
    for(int i=0;i<=n-k;i++){
        res = min(res, h[i+k-1]-h[i]);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
     
    int main(){
       long n,i,j,d2,d5,d10;
     
       scanf("%ld",&n);
       if (n%2==0) {
          d5=0;
          for (i=10;i<=n;i*=5) d5+=n/i;
          printf("%ld\n",d5);
       } else {
          printf("%ld\n",0);
       }
       return 0;
    }

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
	int x,y;
	scanf("%d %d",&x,&y);
	int a=x,b=y;
	x*=100;
	y*=10;
	if(x%8==0){
		x=x/8;
	}else{
		x=x/8+1;
	}
	int t=max(x,y);
	int aa=t*0.08;
	int bb=t*0.1;
	if(aa==a&&bb==b){
		printf("%d",t);
	}else{
		printf("-1");
	}
	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007 
typedef long long ll;
 
int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin>>n;
	
	vector<int> a(n-1);
	vector<int> count(n+1);
	for(int i=0;i<n-1;i++)
	{
		cin>>a[i];
		count[a[i]]++;
	}
	
	for(int i=1;i<=n;i++)
		cout<<count[i]<<"\n";
	
	return 0;
}

Measured memory_bytes: 4784
import java.util.Scanner;

public class Main {
	static String cipher;
	static int pos;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			cipher = sc.nextLine();
			String tc = cipher;
			if (cipher.equals("."))
				break;
			pos = 0;
			System.out.println(cipher());
		}
		sc.close();
	}
	
	static String cipher(){
		StringBuilder sb = new StringBuilder(string());
		while(pos < cipher.length()){
			sb.append(string());
		}
		return sb.toString().replace('?', 'A');
	}
	
	static String string(){
		char c = cipher.charAt(pos);
		if(c == '['){
			pos++;
			StringBuilder sb = new StringBuilder(string());
			while(cipher.charAt(pos) != ']'){
				sb.append(string());
			}
			pos++;
			return sb.reverse().toString();
		}
		return Character.toString(letter());
	}
	
	static char letter(){
		char c = cipher.charAt(pos++);
		if(c == '+'){
			char let = letter();
			if(let == '?'){
				return let;
			}
			let++;
			if(let > 'Z'){
				let -= 26;
			}
			return let;
		} else if (c == '-'){
			char let = letter();
			if(let == '?'){
				return let;
			}
			let--;
			if(let < 'A'){
				let += 26;
			}
			return let;
		}
		return c;
	}

}

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

using namespace std;

int main() {
    int r,d,x;
    cin>>r>>d>>x;
int a[10];
for(int i=0;i<10;i++)
    {
        if(i==0)
        a[i]=r*x-d;
        else
        a[i]=r*a[i-1]-d;
        cout<<a[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <limits>
#include <vector>
#include <algorithm>
using namespace std;
// ------ RMQ Class ------ //
template<typename Type> class RMQ {
private:
	int size_; vector<Type> dat;
	Type query_(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return numeric_limits<Type>::max();
		if (a <= l && r <= b) return dat[k];
		int lc = query_(a, b, 2 * k, l, (l + r) / 2);
		int rc = query_(a, b, 2 * k + 1, (l + r) / 2, r);
		return min(lc, rc);
	}
public:
	RMQ(int size__) {
		for (size_ = 1; size_ < size__; size_ <<= 1); dat.resize(size_ * 2, numeric_limits<Type>::max());
	}
	RMQ(vector<Type> v) {
		for (size_ = 1; size_ < dat.size(); size_ <<= 1); dat.resize(size_ * 2, numeric_limits<Type>::max());
		for (int i = 0; i < v.size(); i++) dat[i + size_] = v[i];
		for (int i = size_ - 1; i >= 1; i--) dat[i] = min(dat[2 * i], dat[2 * i + 1]);
	}
	int size() { return size_; }
	int ndat() { return numeric_limits<Type>::max(); }
	void update(int i, int x) {
		i += size_; dat[i] = x;
		while (i > 1) i >>= 1, dat[i] = min(dat[2 * i], dat[2 * i + 1]);
	}
	Type query(int l, int r) {
		return query_(l, r, 1, 0, size_);
	}
};
int n, ptr, ret, a[200000], b[200000], previ[200001];
int main() {
	scanf("%d", &n); ret = n;
	for (int i = 0; i < n; i++) scanf("%d", &a[i]), b[i] = a[i];
	sort(b, b + n);
	for (int i = 0; i < n; i++) ptr = lower_bound(b, b + n, a[i]) - b, a[i] = ptr + 1;
	for (int i = 1; i <= n; i++) previ[i] = -1;
	RMQ<int> r(n);
	for (int i = 0; i < n; i++) r.update(i, a[i]);
	for (int i = 0; i < n; i++) {
		if (previ[a[i]] != -1) {
			if (r.query(previ[a[i]], i) >= a[i]) ret--;
		}
		previ[a[i]] = i;
	}
	printf("%d\n", ret);
}

Measured memory_bytes: 6964
def main():
    n=int(input())
    ab=[list(map(int,input().split())) for _ in [0]*(n-1)]
    g=[[] for _ in [0]*n]
    [g[a-1].append(b-1) for a,b in ab]
    [g[b-1].append(a-1) for a,b in ab]
    color=[-1]*n
    color[0]=0
    q=[[0,0]]
    while q:
        qq=[]
        while q:
            i,root=q.pop()
            cnt=1
            for j in g[i]:
                if j==root:
                    continue
                if cnt==color[i]:
                    cnt+=1
                color[j]=cnt
                cnt+=1
                qq.append([j,i])
        q=qq
    d=[-1]*n
    d[0]=0
    q=[0]
    cnt=0
    while q:
        qq=[]
        cnt+=1
        while q:
            i=q.pop()
            for j in g[i]:
                if d[j]==-1:
                    d[j]=cnt
                    qq.append(j)
        q=qq
    print(max(color[1:]))
    for i,j in ab:
        if d[i-1]>d[j-1]:
            k=i
        else:
            k=j
        print(color[k-1])
main()

Measured memory_bytes: 47284
n = int(input())
ans = [0] * (n + 1)
for x in range(1, int(n**0.5) + 1):
    for y in range(1, int(n**0.5) + 1):
        for z in range(1, int(n**0.5) + 1):
            if x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:
                ans[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1
print(*ans[1:], sep='\n')

Measured memory_bytes: 9364
#include<stdio.h>

int n , A[50];

int solve (int i, int m) {
  if (m == 0 ) return 1;
  if (i >= n) return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main() {
  int q, M, i;

  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &M);
    if (solve(0, M)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


Measured memory_bytes: 2140
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        n: usize, m: usize,
        a: [u64; n],
        bc: [(usize, u64); m]
    }

    let mut heap = std::collections::BinaryHeap::new();
    let a_count = count(&a);
    for (&k, &v) in a_count.iter() {
        heap.push((Rev(k), v));
    }
    for i in 0..m {
        let (mut cnt, num) = bc[i];
        let mut icnt = 0;
        while let Some((Rev(k), v)) = heap.pop() {
            if k < num {
                if cnt < v {
                    icnt += cnt;
                    heap.push((Rev(k), v - cnt));
                    break;
                } else {
                    icnt += v;
                    cnt -= v;
                }
            } else {
                heap.push((Rev(k), v));
                break;
            }
        }
        heap.push((Rev(num), icnt));
    }
    let mut ret = 0u64;
    while let Some((Rev(k), v)) = heap.pop() {
        ret += k * v as u64;
    }
    println!("{}", ret);
}

#[allow(dead_code)]
fn count<T: Eq + std::hash::Hash + Clone>(slice: &[T]) -> std::collections::HashMap<T, usize> {
    let mut hmap = std::collections::HashMap::new();
    for item in slice {
        *hmap.entry(item.clone()).or_insert(0) += 1;
    }
    hmap
}

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<std::cmp::Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> std::cmp::Ordering {
        other.0.cmp(&self.0)
    }
}

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

using namespace std;

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

    for(int i = K; i < N; ++i)
    {
        cout << ( A[i - K] < A[i] ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 4396
N, K = gets.chomp.split(' ').map{|x| x.to_i}
S = gets.chomp
A = []
idx = 0
while idx < N do
  ch = S[idx]
  cnt = 0
  
  while idx < N and ch == S[idx] do
    idx += 1
    cnt += 1
  end

  A.push([ch, cnt])
end

M = A.size
sum = Array.new(M+1, 0)
for i in 1..M do
  sum[i] = sum[i-1] + A[i-1][1]
end


def getSum(sum, l, r)
  r = [r, M].min
  return sum[r] - sum[l]
end

ans = 0
for i in 0...M do
  score = 0
  if A[i][0] == '0'
    score = getSum(sum, i, i + 2 + (K - 1) * 2)
  else
    score = getSum(sum, i, i + 1 + K * 2)
  end
  ans = [ans, score].max
end

p ans
        


Measured memory_bytes: 15996
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  string S; cin>>S;
  sort(S.begin(),S.end());
  int K=0;
 if(S.at(0)==S.at(1)&&S.at(1)!=S.at(2)&&S.at(2)==S.at(3))
   cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256