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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void judge(bool b){b?Yes():No();}

template<typename T>
void ppp(T n){cout << n << endl;}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<string> vstr;



vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    cin >> s;

    vint west(n+1);
    vint east(n+1);

    west[0] = 0;
    east[0] = 0;
    rep(i, n){
        if(s[i] == 'W'){
            west[i+1] = west[i] + 1;
            east[i+1] = east[i] ;
        }
        else{
            west[i+1] = west[i];
            east[i+1] = east[i] + 1;
        }
    }

    int ans = INF;
    rep(i, n){
        int cnt = east[n]-east[i+1]+west[i];
        ans = min(ans, cnt);

    }

    ppp(ans);



    return 0;
}


Measured memory_bytes: 2964
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1ll;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
mint dp[100005][5];
int main(){
    string s;
    cin>>s;
    int n=s.size();
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<4;j++){
            dp[i+1][j]+=dp[i][j]*(s[i]=='?'?mint(3):mint(1));
            if(s[i]=='?'||s[i]-'A'==j)dp[i+1][j+1]+=dp[i][j];
        }
    }
    cout<<dp[n][3]<<"\n";
}

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

void CountingSort(int A[], int B[], int k, int n) {
  int C[10001] = {};
  
  for (int i = 1; i <= n; i++) C[A[i]]++;

  for (int i = 1; i <= k; i++) C[i] += C[i - 1];

  for (int i = n; i >= 1; i--) {
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}

int main() {
  int n; cin >> n;
  static int A[2000001]; for (int i = 1; i <= n; i++) cin >> A[i];

  static int B[2000001]; CountingSort(A, B, 10000, n);

  for (int i = 1; i <= n; i++) {
    if (i == n) cout << B[i] << endl;
    else cout << B[i] << " ";
  }

  return 0;
}


Measured memory_bytes: 18668
# import math
n = int(input())
x = 1
y = 1
for i in range(n):
    t, a = [int(_) for _ in input().split()]
    if x%t == 0:
        kt = x//t
    else:
        kt = x//t + 1
    if y % a == 0:
        ka = y // a
    else:
        ka = y // a + 1

    k = max(kt, ka)
    x = t*k
    y = a*k

print(x+y)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	scanf("%d", &k);
	set<int> s;
	int x = 7 % k; //余り(mod)を使えばtleしない
	int count = 1; //割った回数=項数
	while (s.count(x) == 0) //set sの中にxと同じ数字が出るまで繰り返す
	{
		if(x == 0) { //xが0になったらkの倍数がある
			printf("%d\n", count); //countが項数
			return 0;
		}
		s.insert(x); //setに入れる
		x = (x * 10 + 7) % k; //次のxを作る。7,77,777の配列aはa[x]=a[x - 1] * 10 + 7。余りの配列でも求め方は一緒。
		count++;
	}
	printf("-1\n");
	return 0;
}

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

using namespace std;

main(){
	int a;
	cin>>a;
	int A[a];
	int s=a-1;
	for(int c=0; c<a; c++){
		cin>>A[c];
	}
	while(s >= 0){
		printf("%d",A[s]);
		if (s != 0){
			printf(" ");
		}
		s=s-1;
	}
	printf("\n");
}



Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
#define ull unsigned long long
using namespace std;

string N;
int K;
char D[12];

bool isLike(int n) {
	string s = to_string(n);
	bool ret = true;

	//FOR(i, 0, s.size()) {
	//	cout << s[i] << " ";
	//}
	//cout << endl;

	//FOR(j, 0, K) {
	//	cout << D[j] << " ";
	//}
	//cout << endl;


	FOR(i, 0, s.size()) {
		FOR(j, 0, K) {
			if (s[i] == D[j]) {
				//cout << s[i] << " is bad number" << endl;
				ret = false;
				break;
			}
		}
		if (!ret)
			break;
	}

	return ret;
}



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

	cin >> N >> K;

	FOR(i, 0, K)
		cin >> D[i];


	int ans = 0;

	FOR(i, stoi(N), 100000) {
		if (isLike(i)) {
			ans = i;
			break;
		};
	}

	cout << ans << endl;

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

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

namespace AtCoder
{
    public class ABC_063_B
    {
        public static void Main()
        {
            var s = Console.ReadLine();
            var len = s.Length;
            var result = "yes";

            for (int i = 1; result=="yes"&&i < len; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    if (s[i].ToString() == s[j].ToString())
                    {
                        result = "no";
                        break;
                    }
                }
            }
            Console.WriteLine(result);
            Console.Read();
        }


    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
int main(){
    ll N; cin >> N;
    ll Sum=0;
    vector<int> S(N);
    for(int i = 0; i < N; i++){
        cin >> S[i]; Sum += S[i];
    }
    sort(S.begin(), S.end());
    for(int i = 0; i < N; i++){
        if(Sum % 10 != 0){
            cout << Sum << endl;
            return 0;
        }
        else {
            if((Sum - S[i]) % 10 != 0){
                cout << Sum - S[i] << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}

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


#define NUM 1001

ll POW[NUM];
ll nCm[NUM][NUM];
ll memo[NUM];

int main(){

	ll N,K;
	scanf("%lld %lld",&N,&K);

	if(N < K){
		printf("0\n");
		return 0;
	}

	//コンビネーションを求める
	nCm[0][0] = 1;
	for(int n = 1; n <= K; n++) {
		for (int k = 0; k <= N; k++) {
			if(k > 0){
				nCm[n][k] = nCm[n-1][k]+nCm[n-1][k-1];
			}else{ //k == 0
				nCm[n][k] = 1;
			}
			nCm[n][k] %= MOD;
		}
	}

	ll tmp;

	//num^Nを作っておく
	for(ll num = 1; num <= K; num++){
		tmp = 1;

		for(int i = 1; i <= N; i++){
			tmp *= num;
			tmp %= MOD;
		}
		POW[num] = tmp;
	}

	memo[1] = 1;

	for(ll num = 2; num <= K; num++){

		memo[num] = POW[num];

		for(int i = 1; i <= num-1; i++){
			memo[num] -= nCm[num][i]*memo[i];
			memo[num] %= MOD;
			if(memo[num] < 0)memo[num] += MOD;
		}
	}

	printf("%lld\n",memo[K]);

	return 0;
}



Measured memory_bytes: 11000
#include <stdio.h>
#include <math.h>
#include <string.h>
#define rad M_PI/3
#define N 500001
 
int A[N]={0};
int L[N/2]={0};
int R[N/2]={0};
long count =0;
 
void Merge(int A[],int left,int mid,int right){
    int n1,n2;
    int i,j,k;
    n1=mid-left;
    n2=right-mid;
    for(i=0;i<n1;++i){
        L[i]=A[left+i];
    }
    for(i=0;i<n2;++i){
        R[i]=A[mid+i];
    }
    L[n1]=1000000010;
    R[n2]=1000000010;
    i=j=0;
    for(k=left;k<right;++k){
        if(L[i]<=R[j]){
            A[k]=L[i];
            ++i;
    }else{
        A[k]=R[j];
        ++j;
        count+=(n1-i);
    }
    }
    return;
}
void MergeSort(int A[], int left, int right) {
    int mid;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        MergeSort(A, left, mid);
        MergeSort(A, mid, right);
        Merge(A, left, mid, right);
    }
    return;
}
 
int main()
{
  int n, i;
  
    scanf("%d", &n);
  
    for (i = 0; i < n; ++i) {
        scanf("%d", &A[i]);
    }
    MergeSort(A, 0, n);
    printf("%ld\n", count);
      
    return 0;
  return 0;
}


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
const ll mod = 998244353;
ll dp[3009][3009];
ll dp2[3009][3009];
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int a,b,c,d;cin>>a>>b>>c>>d;
	dp[a][b]=1;
	repA(j,b+1,d) dp[a][j] = dp[a][j-1]*a%mod,dp2[a][j] = (dp2[a][j-1]*(a-1)+dp[a][j-1])%mod;
	repA(i,a+1,c) dp[i][b] = dp[i-1][b]*b%mod;
	repA(i,a+1,c) repA(j,b+1,d){
			dp[i][j] = (dp[i-1][j]*j+dp2[i][j-1]*(i-1)+dp[i][j-1])%mod;
			dp2[i][j] = (dp2[i][j-1]*(i-1)+dp[i][j-1])%mod;
	}
	cout<<dp[c][d];
	return 0;
}



Measured memory_bytes: 144704
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    auto B = A;
    sort(begin(B), end(B));
    if (B[N-1] == B[N-2]) {
        for (int i = 0; i < N; i++) cout << B[N-1] << '\n';
    } else {
        for (int i = 0; i < N; i++) {
            if (A[i] == B[N-1]) cout << B[N-2] << '\n';
            else cout << B[N-1] << '\n';
        }
    }
    return 0;
}

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

int main() {
	string S, T;
	cin >> S >> T;
	int a = 0;

	for (int i = 0; i < S.size() - T.size() + 1; i++) {
		int count = 0;
		for (int j = 0; j < T.size(); j++) {

			if (T.at(j) == S.at(j + i)) {
				count++;
			}
			if (j == T.size() - 1) {
				if (a <= count) {
					a = count;
				}
			}
		}
	}cout << T.size() - a;
	
}

Measured memory_bytes: 3612
/* ITP1_5_B:Print a Frame */
/* 20181120 AOJ */

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void){
	int H, W, i, j;

	while(1){
		scanf("%d %d", &H, &W);
		if(!H && !W) {
			break;
		} else {
			i = H;
			while(i--) {
				printf("#");
				for(j = 1; j < W - 1; j++) {
					if(i == 0 || i == H - 1){
						printf("#");
					} else {
						printf(".");
					}
				}
				printf("#\n");
			}
			printf("\n");
		}
	
	}
	return 0;
}


Measured memory_bytes: 2044
from sys import stdin
readline = stdin.readline


while True:
    old_room_num = int(readline())
    if old_room_num == 0:
        break
    octal = oct(old_room_num)[2:]
    new_room_num = octal.translate(str.maketrans('4567', '5789'))
    print(new_room_num)

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

using ll = long long;

constexpr ll mod = 1e9+7;

ll C[200001];
ll C2[200001];

ll pow(ll x, ll y, ll m) {
    ll s = 1;
    while(y != 0) {
        if(y & 1) {
            s = s*x % m;
        }
        x = x*x % m;
        y >>= 1;
    }
    return s;
}

void init(int h, int w) {
    C[0] = 1;
    C2[0] = 1;
    for(int i=1; i<=h+w; ++i) {
        C[i] = C[i-1] * i % mod;
        C2[i] = pow(C[i], mod-2, mod);
    }
}

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    init(h, w);
    ll res = 0;
    for(int i=b; i<w; ++i) {
        ll tmp = ((C[h-a-1+i] * C2[h-a-1] % mod) * C2[i]) % mod;
        ll tmp2 = ((C[w+a-i-2] * C2[a-1]) % mod) * C2[w-1-i] % mod;
        res = (res + (tmp * tmp2 % mod)) % mod;
    }
    cout << res << endl;
}


Measured memory_bytes: 3456
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

ll ans=0;
string S;
int num;

void dfs(int i,ll temp,ll sum){
  if(i==0){
    dfs(i+1,S[i]-'0',0);
  }else if(i!=num){
    dfs(i+1,S[i]-'0',sum+temp);
    dfs(i+1,temp*10+S[i]-'0',sum);
  }else{
    //cout<<temp+sum<<endl;
    ans+=temp+sum;
  }
}

int main(){
  cin>>S;
  num=S.size();

  dfs(0,0,0);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define mod 1000000007 //998244353
#define pb push_back
#define endd '\n'
#define ll long long 
#define mk make_pair 
#define fi first
#define all(a) a.begin(),a.end()
#define test ll int t,o;cin>>o;for(t=1;t<=o;t++)
#define goog(q,aao) cout<<"Case #"<<q<<": "<<aao<<'\n'
#define co(a) cout<<a<<'\n'
#define coo(a,b) cout<<a<<" "<<b<<'\n'
#define cooo(a,b,c) cout<<a<<" "<<b<<" "<<c<<'\n'
#define take_arr ll i,j,k,n;mul_itr;set_itr;cin>>n;ll arr[n];loop(i,n)cin>>arr[i]
#define take ll i,j,k,n;mul_itr;set_itr;cin>>n
#define print(arr,n) for(ll w=0;w<n;w++)cout<<arr[w]<<" ";cout<<'\n'
#define print_dou(arr,n,m) for(ll w=0;w<n;w++){ for(ll o=0;o<m;o++){cout<<arr[w][o]<<" "; }cout<<endd;}
#define dis(w) loop(i,w.size())cout<<w[i]<<" ";cout<<'\n'
#define mem(b,q)  memset(b,q , sizeof(b))
#define set_itr set<ll>:: iterator sitr ,sit
#define mul_itr multiset<ll>:: iterator itr,it
#define map_itr map<ll,ll>:: iterator mitr,mit
#define se second
#define pii pair<int,int>
#define iterate(s,d) for(d=s.begin();d!=s.end();++d)
#define pll pair<long long,long long>
#define vll vector<ll>
#define vpll vector< pair<ll,ll> >
#define vppll vector < pair<ll, pair<ll,ll> > >
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define loop1(i,a,n) for(i=a;i<n; i++) 
#define loop(i,n) for( i=0;i<n;i++)
#define loop2(n,m) for(int p=0;p<n;p++)for(int q=0;q<m;q++)
#define loop3(n,m,l) for(int i=0;i<n;i++)for(int j=0;j<m;j++)for(int k=0;k<l;k++)
#define checkbit(n, b) ((n >> b) & 1)
#define setbits(x) __builtin_popcount(x)  // returns no of set bits in x 
#define maxx 10e18
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define prefix_sum(arr,n); for(ll oo=1;oo<n;oo++)arr[oo]+=arr[oo-1];
using namespace std;
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
/*

   NOTE :
  maxx=*max_element(a,a+n); 
  m=(m-1+n)%n;     move anti-clockwise  beaware : if u use some x instead of one use m=(m-x+ (n/x+1)*n)%n 
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  template <typename T>
  using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
*/
//int32_t main(){
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    PRECISION;
    ll s,w;
    cin>>s>>w;
    if(w>=s)
    {
    	cout<<"unsafe"<<endd;
	}
	else
	{
		cout<<"safe "<<endd;
	}
    
    
  
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define size(n) ( int( n.size() ) )
#define sqr(n) ( (n) * (n) )
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 110;

int ans[N][N];

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int h, w, n;
    scanf("%d %d %d",&h,&w,&n);
    int x, cx = 1, cy = 1, fl = 0;
    for ( int i = 1; i <= n; i++ ){
        scanf("%d",&x);
        for ( int j = 1; j <= x; j++ ){
            ans[cx][cy] = i;
            if ( !fl ){
                cx++;
                if ( cx > h ){
                    cx = h;
                    cy++;
                    fl = 1;
                }
            }
            else{
                cx--;
                if ( !cx ){
                    cx = 1;
                    cy++;
                    fl = 0;
                }
            }
        }
    }
    for ( int i = 1; i <= h; i++ ){
        for ( int j = 1; j <= w; j++ ){
            printf("%d ",ans[i][j]);
        }
        printf("\n");
    }
    return 0;
}


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

namespace atcorder_BeginnerContest_121
{
    class Program
    {

        static void Main(string[] args)
        {
            int[] dataArr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int rowCnt = dataArr[0];
            int colCnt = dataArr[1];
            int plusVal = dataArr[2];

            int[] bArr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int retCnt = 0;
            for (int i = 0; i < rowCnt; i++)
            {
                int[] aArr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                int sum = 0;
                for (int j = 0; j < colCnt; j++)
                {
                    sum += aArr[j] * bArr[j];
                }
                if (0 < sum + plusVal) retCnt++;
            }

            Console.WriteLine(retCnt);

        }
    }
}



Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

int key(int a, int b, int c) {
	return a * 500 * 500 + b * 500 + c;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int n, h; cin >> n >> h&&n;) {
		unordered_set<int> st;
		rep(i, 0, h) {
			string c;
			int a, b;
			cin >> c >> a >> b; a--, b--;
			if (c == "xy") {
				rep(j, 0, n)st.insert(key(a, b, j));
			}
			else if (c == "xz") {
				rep(j, 0, n)st.insert(key(a, j, b));
			}
			else {
				rep(j, 0, n)st.insert(key(j, a, b));
			}
		}
		cout << n*n*n - st.size() << endl;
	}
	return 0;
}

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

void sortBubble(int *a,char *b,size_t n){
  int i,j;
  for (i=0;i<n;i++){
    for (j=n-1;j>i;j--){
      if (a[j]<a[j-1]){
        swap(a[j],a[j-1]);
        swap(b[j],b[j-1]);
      }
    }
  }
}
void sortSelection(int *a,char *b,size_t n){
  int i,j,min;
  for (i=0;i<n;i++){
    min=i;
    for (j=i;j<n;j++){
      if (a[j]<a[min])min=j;
    }
    swap(a[i],a[min]);
    swap(b[i],b[min]);
  }
}

int main(){
  int n,i;
  bool ans=1;
  cin>>n;
  int a[n],x[n];
  char b[n],y[n];
  for (i=0;i<n;i++)cin>>b[i]>>a[i];
  copy(a,a+n,x);copy(b,b+n,y);
  sortBubble(a,b,n);
  sortSelection(x,y,n);
  for (i=0;i<n;i++)ans&=(y[i]==b[i]);
  for (i=0;i<n;i++){
    if (i)cout<<' ';
    cout<<b[i]<<a[i];
  }
  cout<<endl<<"Stable"<<endl;
  for (i=0;i<n;i++){
    if (i)cout<<' ';
    cout<<y[i]<<x[i];
  }
  cout<<endl<<(ans?"Stable":"Not stable")<<endl;
}



Measured memory_bytes: 3148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();

		for (char c : s.toCharArray()) {
			char converted = (char) (((c + n) - 'A') % 26 + 'A');
			System.out.print(converted);
		}
		sc.close();
	}
}


Measured memory_bytes: 28244
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let _ = read::<usize>();
    let a = read_vec::<i64>();
    let x = a.iter().cloned().max().unwrap();
    let mut y = -1;
    let mut s = (y*2-x).abs();
    for b in a {
        if b == x {
            continue;
        }
        let st = (b*2-x).abs();
        if st < s {
            s = st;
            y = b;
        }
    }
    println!("{} {}",x,y);
}


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

int main()
{
    int i;
    char s[4];
    cin>>s;
    for(i=0;i<3;i++)
    {
        if(s[i]==s[i+1])
        {
            cout<<"Bad";
            return 0;
        }
    }
    cout<<"Good";
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        char[] s = scan.nextLine().toCharArray();
        List<Character> non_n = new ArrayList<>();
        for( char tmp : s) {
            if (tmp != 'x') {
                non_n.add(tmp);
            }
        }
        for (int i = 0; i < non_n.size(); i++) {
            if (!non_n.get(i).equals(non_n.get(non_n.size() - i - 1))) {
                System.out.println("-1");
                return;
            }
        }

        int count = 0;
        int tail = s.length - 1;
        for (int i = 0; i < tail;) {
            if(s[i] == s[tail]) {
                i++;
                tail--;
                continue;
            }
            count++;
            if(s[i] == 'x') {
                i++;
            } else  {
                tail--;
            }
        }
        System.out.println(count);
    }
}

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

int main(){
    int N; cin >> N;
    int A[N], B[N], C[N-1];
    int ans=0;

    for(int i=0; i<N; i++) cin >> A[i];

    for(int i=0; i<N; i++){
        cin >> B[i];
        ans+=B[i];
    }

    for(int i=0; i<N-1; i++) cin >> C[i];

    for(int i=0; i<N-1; i++){
        if(A[i+1] == A[i]+1) ans+=C[A[i]-1];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    int r, d, n;
    cin >> r >> d >> n;
    int x = n;
    for(int i = 0; i < 10; i++){
        x = r*x - d;
        cout << x;
        if(i == 9){
            continue;
        }
        cout << "\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch GreenBin | diff GreenBin.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address GreenBin.cpp && ./a.out

/*
 
 8/15/2019
 
 14:14-
 
 */

const int MAX_N=1e6+1;
string S[MAX_N];
int N;

void solve() {
  map<string,LL> cnt;
  REP(i,N) {
    string s=S[i];
    sort(ALL(s));
    cnt[s]++;
  }
  LL res=0;
  FORR(kvp,cnt) {
    LL n=kvp.second;
    res+=n*(n-1)/2;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>S[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 23808
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  bool four = false;
  for (int i = 0; i < N; i++) {
    char S;
    cin >> S;
    if (S =='Y') four = true;
  }
  if (four) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
  return 0;
}


Measured memory_bytes: 3588
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	map<string, int> B;
	int n;	char c; string b;
	while (cin >> n >> c >> b)
		B[b]++;
	cout << B["A"]++ << endl;
	cout << B["B"]++ << endl;
	cout << B["AB"]++ << endl;
	cout << B["O"]++ << endl;
	return 0;
}

Measured memory_bytes: 1212
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
// set<int>st{ 3,1,4,1,5,9,2,6,5,3,5 };
//     for (auto itr = st.begin(); itr != st.end(); ++itr) {
//         cout << *itr;
//     }
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
    string s;
    int a=100000;
    int z=-1;
    cin>>s;
    char c;
    rep(i,s.size()){
        c=s.at(i);
        if(c=='A'&&i<a){
            a=i;
        }
        if(c=='Z'&&i>z){
            z=i;
        }
    }
    cout<<z-a+1<<endl;

}

Measured memory_bytes: 3700
#include <iostream>
#include <deque>

int main()
{
    std::string s;
    std::cin >> s;

    std::deque<char> dq;
    for (const char& ch : s)
        dq.push_back(ch);

    int Q;
    std::cin >> Q;

    bool rev = false;
    for (int i = 0; i < Q; i++) {
        int T;
        std::cin >> T;
        if (T == 1)
            rev = !rev;
        else {
            int F;
            char C;
            std::cin >> F >> C;
            if (F == 1)
                if (rev)
                    dq.push_back(C);
                else
                    dq.push_front(C);
            else
                if (rev)
                    dq.push_front(C);
                else
                    dq.push_back(C);
        }
    }

    std::string res;
    if (rev)
        while (!dq.empty()) {
            res += dq.back();
            dq.pop_back();
        }
    else
        while (!dq.empty()) {
            res += dq.front();
            dq.pop_front();
        }

    std::cout << res << std::endl;

    return 0;
}

Measured memory_bytes: 4324
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;

class Program
{
	static void Main(string[] args)
	{
		int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int N = intArray[0];
		int M = intArray[1];

		if(N == M)
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	}
}

//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();


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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
#define LOCAL
#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{
#ifdef LOCAL
~debug() {cerr<<endl; }
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 <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,a,b;
    vi x,y;
    cin>>n>>m>>a>>b;
    x.pb(a);
    y.pb(b);
    f(n){
        int tmp;cin>>tmp;
        x.pb(tmp);
    }
    f(m){
        int tmp;cin>>tmp;
        y.pb(tmp);
    }
    sort(all(x));
    reverse(all(x));
    sort(all(y));
    if(x[0]>=y[0]){
        cout<<"War";
    }else cout<<"No War";
    cout<<endl;
    return 0;
}


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

f=n
ans=0
while f==n:
    f=0
    for i in range(n):
        if a[i]%2==0:
            a[i]=a[i]//2
            f+=1
    if f==n:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
int a[100010];

int main(int argc, char const *argv[])
{
	int N;
	scanf("%d", &N);

	int pos = -1;
	int neg = -1;

	for(int i = 1; i <= N; i++) {
		scanf("%d", &a[i]);
		if(a[i] < 0) neg = i;
		if(a[i] > 0) pos = i;
	}
	int sum = 0;
	for(int i = 1; i <= N; i++) {
		sum += abs(a[i]);
	}

	if(pos != -1 && neg != -1) {
		printf("%d\n", sum);

		int cur = a[pos];
		for(int i = 1; i <= N; i++) {
			if(i == neg || i == pos) continue;
			if(a[i] <= 0) {
				printf("%d %d\n", cur, a[i]);
				cur -= a[i];
			}
		}
		int tmp = cur;
		cur = a[neg];
		for(int i = 1; i <= N; i++) {
			if(i == neg || i == pos) continue;
			if(a[i] > 0) {
				printf("%d %d\n", cur, a[i]);
				cur -= a[i];
			}
		}
		printf("%d %d\n", tmp, cur);
	} else if (pos != -1) {
		int opt = 1;
		for(int i = 1; i <= N; i++) {
			if(a[i] < a[opt]) {
				opt = i;
			}
		}
		printf("%d\n", sum - 2 * a[opt]);
		int cur = a[opt];
		int cnt = 1;
		for(int i = 1; i <= N; i++) {
			if(i == opt) continue;
			++cnt;
			if(cnt == N) {
				printf("%d %d\n", a[i], cur);
			} else {
				printf("%d %d\n", cur, a[i]);
				cur -= a[i];
			}
		}
	} else {
		int opt = 1;
		for(int i = 1; i <= N; i++) {
			if(a[i] > a[opt]) {
				opt = i;
			}
		}
		printf("%d\n", sum + 2 * a[opt]);
		int cur = a[opt];
		for(int i = 1; i <= N; i++) {
			if(i == opt) continue;
			printf("%d %d\n", cur, a[i]);
			cur -= a[i];
		}
	}
	return 0;
}

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

using namespace std;

//#define FILE_IO

const int mod = 1e9 + 7;

typedef long long LL;
typedef pair<LL, int> pii;

int N, M, S, T, ans;
int cnt[2][100005];
LL d[2][100005];
vector<pii> edg[100005];
priority_queue< pii, vector<pii>, greater<pii> > pq;

void dijkstra(int id, int source)
{
    for(int i = 1; i <= N; i++) d[id][i] = 1LL << 60;
    pq.push({0LL, source});
    cnt[id][source] = 1;
    d[id][source] = 0;

    while(!pq.empty())
    {
        LL y = pq.top().first;
        int x = pq.top().second;
        pq.pop();

        if(d[id][x] != y)   continue;
        for(auto e: edg[x])
        {
            int nxt = e.first;
            LL dst = e.second;
            if(d[id][nxt] > y + dst)
            {
                d[id][nxt] = y + dst;
                cnt[id][nxt] = cnt[id][x];
                pq.push({y + dst, nxt});
            }
            else if(d[id][nxt] == y + dst)
                (cnt[id][nxt] += cnt[id][x]) %= mod;
        }
    }
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &M);
    scanf("%d%d", &S, &T);
    for(int i = 1; i <= M; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        edg[x].push_back({y, z});
        edg[y].push_back({x, z});
    }

    dijkstra(0, S);
    dijkstra(1, T);
    LL D = d[0][T];
    LL d2 = (D / 2);
    LL d1 = ((D + 1) / 2);

    ans = (1LL * cnt[0][T] * cnt[1][S]) % mod;
    for(int i = 1; i <= N; i++)
    {
        if(d[0][i] == d[1][i])
        {
            int c = (1LL * cnt[0][i] * cnt[1][i]) % mod;
            c = (1LL * c * c) % mod;
            ans -= c;
            ans += mod;
            ans %= mod;
        }

        for(auto e: edg[i])
            if(d[0][i] + e.second == d[0][e.first] && d[0][e.first] + d[1][e.first] == d[0][T] && d[0][i] + d[1][i] == d[0][T])
            {
                int nxt = e.first;
                if(d[0][i] < d1 && d[0][nxt] > d2 && d[1][nxt] < d1 && d[1][i] > d2)
                {
                    int c = (1LL * cnt[0][i] * cnt[1][nxt]) % mod;
                    c = (1LL * c * c) % mod;
                    ans -= c;
                    ans += mod;
                    ans %= mod;
                }
            }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 18040
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
const ll MAX_N = 3000;
/**/
int main() {
	// 入力
	ll N;cin>>N;
	ll A[N-1];
    REP(i,N-1){
		cin>>A[i];
		A[i]--;
	}
    
	// 解法
	ll B[N];REP(i,N)B[i] = 0; // 配列を作って0で初期化
	REP(i,N-1){
		B[A[i]]++;
	}
	//出力

	REP(i,N) printf("%lld\n", B[i]);
}


Measured memory_bytes: 6872
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);


int main() {
    class SEGTREE {
        unsigned int n;
        ll dflt;
        vector<ll> dat;

        static ll op(const ll a, const ll b) {
            return max(a, b);
        }

        bool f(const unsigned int id, const ll a){
            return dat[id] >= a;
        }

    public:
        SEGTREE(unsigned long _n, ll _a) : n(1), dflt(_a) {
            while (n < _n) {n *= 2;}
            dat.resize(n * 2, dflt);
        }

        void update(unsigned int k, ll a) {
            k += n;
            dat[k] = a;
            while (k > 0) {
                k >>= 1;
                dat[k] = op(dat[k<<1], dat[(k<<1)|1]);
            }
        }

        void init(vector<ll> &v) {
            for (int i = 0; i < (int)v.size(); ++i) dat[i + n] = v[i];
            for (int i = n - 1; i >= 1; --i) {
                dat[i] = op(dat[i * 2], dat[i * 2 + 1]);
            }
        }

        ll query(unsigned int l, unsigned int r) {
            ll res_left = dflt, res_right = dflt;
            l += n; r += n;
            for ( ; l < r; l >>= 1, r >>= 1){
                if(l&1){
                    res_left = op(res_left, dat[l]);
                    if((++l) == r) break;
                }
                if(r&1){
                    res_right = op(dat[r ^ 1], res_right);
                }
            }
            return op(res_left, res_right);
        }

        unsigned int max_right_search(unsigned int id, ll a){
            while(id < n) id = (id<<1) | !f(id<<1, a);
            return id - n;
        }

        unsigned int max_right(unsigned int l, unsigned int r, ll a){
            //[l, r)内のindexであるjであって、query(l, j) < a <= query(l, j + 1)なるものを求める
            //つまり、j >= l かつ dat[j] >= a である最小の数jを求める(func = maxの場合)
            unsigned int see_after = r + n;
            l += n;
            for (unsigned int tr = r + n ; l < tr; l >>= 1, tr >>= 1){
                if(l&1){
                    if(f(l, a)) return max_right_search(l, a);
                    if((++l) == tr) break;
                }
                if((tr&1) && f(tr ^ 1, a)) see_after = tr ^ 1;
            }
            return see_after == r + n ? r : max_right_search(see_after, a);
        }

        //単項にアクセスする[]だが、書き換え厳禁
        //一応後でinitすれば書き換えてもよさそうだが…
        ll &operator[](int k) { return dat[k + n]; }
    };
    cin>>N>>Q;
    N -= 2;
    SEGTREE yoko(N + 5, -1), tate(N + 5, -1);
    ll res(N * N);
    rep(_, Q){
        int t, x;
        cin>>t>>x;
        x -= 2;
        if(t == 2) swap(yoko, tate);
        int id = tate.max_right(0, N, x);
        res -= id;
        yoko.update(x, id);
        if(t == 2) swap(yoko, tate);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 11436
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    int sum = 0; int mem = n;
    while (n > 0) {
        sum += n%10;
        n /= 10;
    }
    if (mem % sum == 0)
    {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
N, x = map(int,input().split())
a = list(map(int,input().split()))
a = [0]+a

before_a=a[0]
ans = 0
counter = 0
for i in range(1,N+1):
    if a[i]+before_a>x:
        ans = a[i]+before_a - x
        a[i] -= ans
        counter +=ans
    before_a = a[i]
print(counter)


Measured memory_bytes: 14540
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <bitset>
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long
using namespace std;
	
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1e9 + 7;
//__int128


signed main()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int a, b;
  cin >> a >> b;
  cout << max(a - 2 * b, 0) << endl;
	return 0;
}

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

int main() {
  long long n, m;
  cin >> n >> m;
  vector<P> drink_stock_pairs;

  rep(i, n) {
    long long a, b;
    cin >> a >> b;
    drink_stock_pairs.push_back(P(a, b));
  }
  sort(drink_stock_pairs.begin(), drink_stock_pairs.end());
  long long ans = 0;
  rep(i, n) {
    long long a = drink_stock_pairs[i].first;
    long long b = drink_stock_pairs[i].second;
    ans += a * min(b, m);
    m -= b;
    if (m <= 0) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5+10;

vector<int> g[N];
vector<ll> d(N);

void dfs(int x,int p,ll cnt){
	d[x]+=cnt;
	for(int v:g[x]){
		if(v!=p) dfs(v,x,d[x]);
	}
}

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

	for(int i = 0; i < n-1; i++){
		int a,b;
		cin>>a>>b;
		--a,--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	for(int i = 0; i < q; i++){
		int p,x;
		cin>>p>>x;
		d[--p] += x;
	}

	dfs(0,-1,0);

	for(int i = 0; i < n; i++){
		cout<<d[i]<<" ";
	}
}

Measured memory_bytes: 24320
if __name__ == '__main__':
    a = int(input())
    li_1 = list(map(int, input().split()))
    res = []
    for x in range(0, a - 1):
        if x == 0:
            res.append(li_1[x])
        else:
            res.append(min(li_1[x], li_1[x - 1]))
res.append(li_1[-1])
result = 0
for x in res:
    result += x

print(result)

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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

#define FOR(i,n) for(ll i=0;i<n;i++)

ull log_10(ull N){
   ull count = 1;
   double N_ = N;
   while(N_>=10){
      N_/=10;
      count++;
   }
   return count;
}

vector<ull> prime;

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0); 

   ull N;
   cin >> N;

   for(ull i=1;i*i<=N+1;i++){
      if(N%i==0)prime.push_back(i);
   }

   ull MIN = log_10(N);
   for(ull i=0;i<prime.size();i++){
      MIN = min(max(log_10(prime[i]),log_10(N/prime[i])),MIN);
   }

   cout << MIN << endl;
   return 0;
}


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

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define llrep(i,m,n) for(ll i=m;i<n;++i)
#define inf 1000000000
#define llinf 1000000000000000000
#define mod 1000000007
#define mmod 998244353
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<int>v;

int main() {
	int n;
	cin >> n;
	rep(i, 0, n) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	int ans = 0;
	rep(a, 0, n) {
		rep(b, a + 1, n) {
			rep(c, b + 1, n) {
				if (v[a] + v[b] > v[c] && v[b] + v[c] > v[a] && v[c] + v[a] > v[b]) {
					if (v[a] != v[b] && v[b] != v[c] && v[c] != v[a]) {
						ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
int arr1[200001];
int arr2[200001];

int foo(int n, int m, ll x) {
    ll sum = 0;
    int i = 0, j = 0;
    int count = 0;

    while (i < n) {
        sum += (ll) arr1[i];
        i++;
        if (sum > x) {
            i--;
            sum -= (ll) arr1[i];
            break;
        }
    }
    count = i;

    while (j < m) {
        sum += (ll) arr2[j];
        j++;
        while (sum > x && i > 0) {
            i--;
            sum -= (ll) arr1[i];
        }
        count = (sum <= x) ? max( (count), (i + j) ) : count;
    }

    return count;
}

int main(int argc, char *argv[]) {
    int t = 1;
    while( t-- ) {
        ll x;
        int n, m;
        scanf("%d%d%lld", &n, &m, &x);

        for (int i = 0 ; i < n; i++) {
            scanf("%d", &arr1[i]);
        }

        for (int j = 0 ; j < m; j++) {
            scanf("%d", &arr2[j]);
        }

        printf("%d\n", foo(n, m, x));
    }
    return 0;
}


Measured memory_bytes: 5384