akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <cassert>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	int n;
	cin >> n;
	if (!cin) return false;

	vvi lady(n);

	for (int i = 0; i < n - 1; ++i) {
		int ini, fin;
		cin >> ini >> fin;
		--ini; --fin;
		lady[ini].push_back(fin);
		lady[fin].push_back(ini);
	}

	//Root en  0
	vi color(n, 0);
	int cact = 1;
	queue<int> black, white;
	black.push(0);

	int nunos = 0, ndoses = 0;

	while (!black.empty() | !white.empty()) {
		if (!white.empty()) {
			swap(black, white);
		}

		while (!black.empty()) {
			int nAct = black.front(); black.pop();

			for (int i = 0; i < lady[nAct].size(); ++i) {
				int nsig = lady[nAct][i];
				if (color[nsig] == 0) {
					color[nsig] = cact;
					white.push(nsig);

					if (cact == 1) ++nunos;
					else ++ndoses;
				}
				else {
					if (color[nsig] != cact) assert(false);
				}
			}
		}

		if (cact == 1) cact = 2;
		else cact = 1;
	}

	//colorear
	vi unos, doses, ceros;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 == 0) ceros.push_back(i);
		if (i % 3 == 1) unos.push_back(i);
		if (i % 3 == 2) doses.push_back(i);
	}

	vi perm(n);
	int idx1 = 0, idx2 = 0, idx0 = 0;

	if (nunos > ceros.size() && ndoses > ceros.size()) {
		for (int i = 0; i < n; ++i) {
			if (color[i] == 1) {
				if (idx1 < unos.size()) {
					perm[i] = unos[idx1];
					++idx1;
				}
				else {
					perm[i] = ceros[idx0];
					++idx0;
				}
			}
			if (color[i] == 2) {
				if (idx2 < doses.size()) {
					perm[i] = doses[idx2];
					++idx2;
				}
				else {
					perm[i] = ceros[idx0];
					++idx0;
				}
			}
		}
	}
	else {
		if (nunos <= ceros.size()) {
			for (int i = 0; i < n; ++i) {
				if (color[i] == 1) {
					perm[i] = ceros[idx0];
					++idx0;
				}
				if (color[i] == 2) {
					if (idx1 < unos.size()) {
						perm[i] = unos[idx1];
						++idx1;
					}
					else if (idx2 < doses.size()) {
						perm[i] = doses[idx2];
						++idx2;
					}
					else {
						perm[i] = ceros[idx0];
						++idx0;
					}
				}
			}
		}
		else {
			for (int i = 0; i < n; ++i) {
				if (color[i] == 2) {
					perm[i] = ceros[idx0];
					++idx0;
				}
				if (color[i] == 1) {
					if (idx1 < unos.size()) {
						perm[i] = unos[idx1];
						++idx1;
					}
					else if (idx2 < doses.size()) {
						perm[i] = doses[idx2];
						++idx2;
					}
					else {
						perm[i] = ceros[idx0];
						++idx0;
					}
				}
			}
		}
	}

	for (int i = 0; i < perm.size(); ++i) {
		cout << perm[i];
		if (i == perm.size() - 1) cout << '\n';
		else cout << ' ';
	}

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

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

int main(){
    int N,C;
    cin >> N >> C;
    int p[C];
    int total=0;
    
    for(int i=0;i<C;i++){
        cin >> p[i];
    }

    for(int i=0;i<C;i++){
        total+=p[i];
    }

    if(total%(N+1)==0){
    cout << total/(N+1) << endl;
    }

    else if(total%(N+1)!=0){
    cout << total/(N+1)+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  rep(i, N) {
    rep(j, 10) { cin >> F[i][j]; }
  }
  vector<vector<int>> P(N, vector<int>(11));
  rep(i, N) {
    rep(j, 11) { cin >> P[i][j]; }
  }

  int ans = -INF;
  repp(i, 1, (1 << 10) - 1) {
    vector<int> f(10);
    rep(j, 10) { f[j] = i >> j & 1; }

    int bene = 0;
    rep(j, N) {
      int accord = 0;
      rep(k, 10) { accord += f[k] * F[j][k]; }
      bene += P[j][accord];
    }
    chmax(ans, bene);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<bitset>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int main(){
    int M,F,B;
    cin>>M>>F>>B;
    if(M >= B) cout<<0<<endl;
    else if(M<B && M+F >= B) cout<<B-M<<endl;
    else cout<<"NA"<<endl;
}


Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
using namespace  std;bool dp[2001];int a[21],m[201];int main(){    dp[0]=true;    int n;    cin>>n;    for(int i=0;i<n;i++)        cin>>a[i];    int q;    cin>>q;    for(int k=0;k<q;k++){            memset(dp,0,sizeof(dp));    dp[0]=true;            int ma;    cin>>ma;        for(int i=0;i<n;i++)            for(int j=ma;j>=0;j--)            {            if(j<a[i])continue;            dp[j]=dp[j] || dp[j-a[i]];            }    if(dp[ma])cout<<"yes"<<endl;    else cout<<"no"<<endl;    }    return 0;}


Measured memory_bytes: 3092
# -*- coding: utf-8 -*-

n = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    data = str(input())
    if (data == 'AC'):
        ac += 1
    elif (data == 'WA'):
        wa += 1
    elif (data == 'TLE'):
        tle += 1
    elif (data == 'RE'):
        re += 1    

print("AC x " + str(ac) + "\n" + "WA x " + str(wa) + "\n" + "TLE x " + str(tle) + "\n" + "RE x " + str(re) + "\n")

Measured memory_bytes: 69824
#include <iostream>
#include <string.h>

using namespace std;
int dx[4] = {-1, 0, 1,  0};
int dy[4] = { 0, 1, 0, -1};
char field[14][14];


void DFS(int y, int x)
{
	field[y][x] = '0';
	for(int i = 0; i < 4; ++i)
	{
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(field[ny][nx] == '1')
		{
			DFS(ny, nx);
		}
	}
}

void solve()
{
	memset(field, 0, sizeof(field));
	while(cin >> field[1][1])
	{
		for(int i = 2; i < 13; ++i)
		{
			cin >> field[1][i];
		}
		for(int i = 2; i < 13; ++i)
		{
			for(int j = 1; j < 13; ++j)
			{
				cin >> field[i][j];
			}
		}
		int count = 0;
		for(int i = 1; i < 13; ++i)
		{
			for(int j = 1; j < 13; ++j)
			{
				if(field[i][j] == '1')
				{
					++count;
					DFS(i, j);
				}
			}
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1140
#include<iostream>
#include<string>
using namespace std;
int main(){
  string S;
  cin>>S;
  string ans="";
  for(int i = 0; i < 3; i++ ){
    if(S[i]=='1'){
      ans+="9";
    }else{
      ans+="1";
    }
  }
  cout<<ans<<endl;
  return 0;

}


Measured memory_bytes: 256
s = input()
num = len(s)

kb = []

for i in range(num):
    kb.append(s[i])

mae = 0
usi = num-1
ans = 0

while mae < usi:
    #print(i)
    if s[mae] != s[usi]:
        if s[mae] == 'x':
            #kb.append('x')
            ans += 1
            mae += 1
        elif s[usi] == 'x':
            #kb.insert(mae,'x')
            ans += 1
            usi -= 1
        else:
            print(-1)
            exit()
    else:
        mae += 1
        usi -= 1

print(ans)

Measured memory_bytes: 48624
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import Counter
def resolve():
    n = int(input())
    odd = Counter()
    even = Counter()
    for i, a in enumerate(map(int, input().split())):
        if i & 1:
            odd[a] += 1
        else:
            even[a] += 1
    odd[-1] = even[-1] = 0

    res = n
    for key0, val0 in odd.most_common()[:2]:
        for key1, val1 in even.most_common()[:2]:
            if key0 != key1:
                res = min(res, n - val0 - val1)
    print(res)
resolve()

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

using namespace std;
using ll = int;
using vs = vector<string>;
using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;

#define R(a,i) for(ll a=0; a < (i); (a)++)
#define FOR(a,i,j) for(ll a=(i); a < (j); (a)++)
#define RD(a,i) for(ll a=(i)-1; (a) >= 0; (a)--)
#define FORD(a,i,j) for(ll a=(j)-1; (a) >= (i); (a)--)

#define xx first
#define yy second
#define pb push_back

#define all(X) begin(X),end(X)
#define sz(X) size(X)

#define DBG 1
#define TR(X) {if(DBG) cerr << (#X) << " = " << (X) << "\n";}
#define hline {if(DBG) cerr << "----------------------------------------------------------------------" << "\n";}
#define PK(X) {if(DBG) cerr << (X) << "\n";}

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

	string s;
	cin >> s;
	if(s == "Sunny")
		cout << "Cloudy" << endl;
	else if(s == "Cloudy")
		cout << "Rainy" << endl;
	else
		cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
        string s;
        cin>>s;
        int n=s.size();
        for(int i=0; i<n; i++)
        {
            if(i%2==0) cout<<s[i];
        }
cout<<endl;

}

Measured memory_bytes: 512
# 20-08-06再トライ
import sys
input = sys.stdin.readline
from itertools import accumulate

N, M, Q = [int(x) for x in input().split()]
train = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
for i in range(M):
    L, R = [int(x) for x in input().split()]
    train[L][R] += 1

cum = [list(accumulate(train[i])) for i in range(N + 1)]
del train
cum = list(zip(*cum))
cum = [list(accumulate(cum[j])) for j in range(N + 1)]

for _ in range(Q):
    p, q = [int(x) for x in input().split()]
    print(cum[q][N] - cum[q][p - 1])

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

#define int long long

#define inf 1000000007LL
#define mod 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)


int d[114];

int dp[55][114][114];

signed main() {
  int n;
  cin >> n;
  rep(i, 2 * n - 1) {
    cin >> d[i];
  }
  sort(d, d + 2 * n - 1);
  rep(i, n) {
    rep(j, 2 * n) {
      rep(k, 2 * n) {
        dp[i][j][k] = 0;
      }
    }
  }
  dp[0][1][0] = 1;
  rep(i, n - 1) {
    int p, a;
    if(d[n - 1 - i] == d[n - 1 - i - 1]) {
      p = 0;
    }
    else {
      p = 1;
    }
    if(d[n - 1 + i] == d[n - 1 + i + 1]) {
      a = 0;
    }
    else {
      a = 1;
    }
    rep1(j, i * 2 + 1) {
      rep(k, j) {
        rep(_, j + p + a) {
          if(_ < k + p) {
            dp[i + 1][j + p + a - ((k + p) - _ - 1)][_] = (dp[i + 1][j + p + a - ((k + p) - _ - 1)][_] + dp[i][j][k]) % inf;
          }
          else if(_ == k + p) {
            dp[i + 1][j + p + a][_] = (dp[i + 1][j + p + a][_] + dp[i][j][k]) % inf;
          }
          else {
            dp[i + 1][j + p + a - (_ - (k + p) - 1)][k + p + 1] = (dp[i + 1][j + p + a - (_ - (k + p) - 1)][k + p + 1] + dp[i][j][k]) % inf;
          }
        }
      }
    }
  }
  int all = 0;
  rep(j, 2 * n) {
    rep(k, 2 * n) {
      all = (all + dp[n - 1][j][k]) % inf;
    }
  }
  cout << all << endl;
}


Measured memory_bytes: 5120
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int main(void)
{
    sync;
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    int res=0;
    res+=min(a,k);
    k-=a;
    if(k>0)
        k-=b;
    if(k>0)
        res-=min(c,k);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			System.out.printf("3C%02d\n", (n-1)%39+1);
		}
	}	
}

Measured memory_bytes: 17180
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

  int x = c - a;
  int y = d - b;

  cout << c-y << " " << d+x << " " << a-y << " " << b+x << ln;
}


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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint>PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};

int N;
bool use[1000050];

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>N;
    int sum=0;
    rep(i,0,N){
        sum+=i+1;
        use[i+1]=true; 
        if(sum>N){
            use[sum-N]=false;
            break;
        }
    }
    int cnt=1;
    rep(i,0,N){
        if(use[i+1])cout<<i+1<<endl;
        else{
            if(cnt)cnt--;
            else break;
        }
    }
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
using System;using System.Linq;class P{static void Main(){var s="";while(s.All(c=>c!=48))s+=Console.ReadLine();for(int i=0;i<=s.Length-5;i+=5){var d="1231";var a=s.Substring(i,5);var x=d.Except(a).ToList();foreach(var c in a)Console.WriteLine((x.Count==1)?(c==d[x[0]-48])?"1":"2":"3");}}}


Measured memory_bytes: 6076
#include <stdio.h>

#define INF 100000000
#define MAX_N 1000000

typedef struct {
	int num;
	int max;
	int last;
} FIELD;

typedef struct {
	int x;
	int y;
} COORD;

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 }, corner[ 1998 ] = { 2 }, m;
COORD coord[ 1000001 ];
FIELD field[ 1002 ][ 1001 ];
const int dx[ 7 ] = { 1, 0, -1 , 0, -1, 0, 1 }, dy[ 7 ] = { 0, -1, 0, 1, 1, 1, 1 };

void dfs( int, int );

int main( void ) {
	int i, j, add, x, y, d, cnt, n;

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	add = 1;
	for ( i = 1; i < 1998; i++ ) {
		corner[ i ] = corner[ i - 1 ] + add;
		add += i & 1;
	}

	x = y = 500;
	d = cnt = 0;
	for ( i = 1; i <= 1000000; i++ ) {
		coord[ i ].x = x;
		coord[ i ].y = y;
		field[ x ][ y ].num = i;

		if ( i == corner[ cnt ] ) {
			d = d + 1 & 3;
			cnt++;
		}

		x += dx[ d ];
		y += dy[ d ];
	}

	for ( x = 1002; x--; field[ x ][ 1000 ].num = INF ) ;
	for ( y = 1001; y--; field[ 0 ][ y ].num = field[ 1001 ][ y ].num = INF ) ;

	for ( ; scanf( "%d %d", &m, &n ), m; printf( "%d %d\n", field[ coord[ n ].x ][ coord[ n ].y ].max, field[ coord[ n ].x ][ coord[ n ].y ].last ) ) {
		for ( i = m + 1; --i; field[ x = coord[ i ].x ][ y = coord[ i ].y ].max = INF, field[ x ][ y ].last = 0 ) ;
		for ( i = m + 1; --i;  ) {
			field[ coord[ i ].x ][ coord[ i ].y ].max = INF;
			field[ coord[ i ].x ][ coord[ i ].y ].last = 0;
		}

		dfs( coord[ n ].x, coord[ n ].y );
	}

	return 0;
}

void dfs( int x, int y ) {
	int i;

	field[ x ][ y ].max = 0;
	for ( i = 4; i < 7; i++ ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( field[ nx ][ ny ].num <= m ) {
			if ( field[ nx ][ ny ].max == INF )
				dfs( nx, ny );

			if ( field[ x ][ y ].max < field[ nx ][ ny ].max ) {
				field[ x ][ y ].max = field[ nx ][ ny ].max;
				field[ x ][ y ].last = field[ nx ][ ny ].last;
			} else if ( field[ x ][ y ].max == field[ nx ][ ny ].max )
				if ( field[ x ][ y ].last < field[ nx ][ ny ].last )
					field[ x ][ y ].last = field[ nx ][ ny ].last;
		}
	}

	if ( isPrime[ field[ x ][ y ].num ] ) {
		if ( !field[ x ][ y ].max )
			field[ x ][ y ].last = field[ x ][ y ].num;

		field[ x ][ y ].max++;
	}
}

Measured memory_bytes: 24172
#include <stdio.h>


 int main()
 {
   int a,b;
   int d,r;
   double f;

   scanf("%d %d",&a,&b);

   d = a/b;
   r = a%b;

   f = a*1.0/b*1.0;

   printf("%d %d %lf\n",d,r,f);
return(0);
}

Measured memory_bytes: 636
import math


def is_prime(num):
    if (num < 2):
        return False
    elif(num == 2):
        return True
    elif (num % 2 == 0):
        return False
    sqrt_num = int(math.sqrt(num))
    for i in range(3, sqrt_num+1):
        if i % 2 == 0:
            continue
        if (num % i == 0):
            return False
    return True


N = int(input())
if is_prime(N):
    print(len(list(str(N))))
    exit()

min_num = 11
sqrt_num = int(math.sqrt(N))
for i in range(1, sqrt_num+1):
    if (N % i == 0):
        a = N//i
        b = i
        _min_num = max(len(list(str(a))), len(list(str(b))))
        min_num = min(min_num, _min_num)
print(min_num)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n; string a, b; cin >> a >> b;
	if (a.size() > b.size()) {
		cout << "GREATER" << endl;
	}
	else if (a.size() < b.size()) {
		cout << "LESS" << endl;
	}
	else if (a == b) {
		cout << "EQUAL" << endl;
	}
	else if (a > b) {
		cout << "GREATER" << endl;
	}
	else if (a < b) {
		cout << "LESS" << endl;
	}
	cin >> n;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> ans(n + 1);
    for(int x = 1; x <= 100; x++){
        for(int y = 1; y <= 100; y++){
            for(int z = 1; z <= 100; z++){
                int value = x*x + y*y + z*z + x*y + y*z + z*x;
                if(value > n) continue;
                ans[value]++;
            }
        }
    }

    for(int i = 1; i <= n; i++){
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3556
#include <cstdio>
#include <algorithm>
using namespace std;

bool bag[3005];
long long answ, anss;
long double deg = -1;

int main() {
    long long A, B, C, D, E, F;
    scanf("%lld%lld%lld%lld%lld%lld", &A, &B, &C, &D, &E, &F);
    bag[0] = true;
    for (long long i = C; i <= 3000; ++i) bag[i] |= bag[i - C];
    for (long long i = D; i <= 3000; ++i) bag[i] |= bag[i - D];
    for (long long a = 0; a <= 3000; a += A * 100)
        for (long long b = 0; b <= 3000; b += B * 100) {
            long long water = a + b;
            if (water == 0 || water > F) continue;
            long long maxsugar = min(E * (a + b) / 100, F - water);
            for (long long i = maxsugar; ~i; --i) if (bag[i]) {
                if (100.l * i / (water + i) > deg)
                    answ = water + i, anss = i, deg = 100.l * i / (water + i);
                break;
            }
        }
    if (deg == -1) printf("%lld 0\n", 100 * A);
    else printf("%lld %lld\n", answ, anss);
    return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int n; cin>>n;
  int s=0;
  int x=n;
  while (x) {
    s+=x%10; x/=10;
  }
	
  if (n%s==0) out("Yes");
  cout<<"No"<<endl;
  return 0;
}


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

using namespace std;

inline int read()
{
    int x=0;char ch=getchar();
    while(ch<'0'|| ch>'9')ch=getchar();
    while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
    return x;
}

typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vec;
#define x first
#define y second
const int N=131100;

int n,fa[N];
vec g[N],f[N];
ll mid,mv[N];

inline bool cmpx(pr a,pr b){return a.x<b.x;}
inline bool cmpy(pr a,pr b){return a.y<b.y;}

inline void work(vec &ls,vec &rs,vec &f)
{
    if(ls.size()>rs.size())swap(ls,rs);
    int el=ls.size(),er=rs.size();

    sort(ls.begin(),ls.end(),cmpy);
    sort(rs.begin(),rs.end(),cmpx);

    mv[0]=rs[0].y;
    for(int i=1;i<er;i++)
        mv[i]=min(mv[i-1],rs[i].y);

    for(int i=0,j=er-1;i<el;i++)
    {
        while(j>=0 && ls[i].y+rs[j].x>mid)j--;
        if(j>=0)f.push_back(pr(ls[i].x,mv[j]));
    }

    sort(ls.begin(),ls.end(),cmpx);
    sort(rs.begin(),rs.end(),cmpy);
    mv[0]=rs[0].x;
    for(int i=1;i<er;i++)
        mv[i]=min(mv[i-1],rs[i].x);

    for(int i=0,j=er-1;i<el;i++)
    {
        while(j>=0 && ls[i].x+rs[j].y>mid)j--;
        if(j>=0)f.push_back(pr(mv[j],ls[i].y));
    }
}

inline void dfs(int u)
{
    if(!f[u].empty())f[u].clear();
    if(g[u].empty())
    {
        f[u].push_back(pr(0,0));
        return;
    }

    for(int i=0,e=g[u].size();i<e;i++)
        dfs(g[u][i].x);

    vec &ls=f[g[u][0].x];
    for(int i=0,e=ls.size(),c=g[u][0].y;i<e;i++)
        ls[i].x+=c,ls[i].y+=c;
    vec &rs=f[g[u][1].x];
    for(int i=0,e=rs.size(),c=g[u][1].y;i<e;i++)
        rs[i].x+=c,rs[i].y+=c;

    work(ls,rs,f[u]);
    ls.clear();
    rs.clear();
}

int main()
{
    n=read();
    for(int i=2,a;i<=n;i++)
    {
        fa[i]=read();
        g[fa[i]].push_back(pr(i,read()));
    }

    ll l=0,r=1e10,ans=1e10;
    while(l<=r)
    {
        mid=l+r>>1;
        dfs(1);
        if(f[1].empty())
            l=mid+1;
        else
            r=mid-1,ans=mid;
    }

    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 30452
S = input().strip()
a, b = int(S[:2]), int(S[2:])
if 1 <= a <= 12:
    if 1 <= b <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= b <= 12:
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 2940
// Created by Nandu Vinodan
#include "bits/stdc++.h"

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;


bool isPalin(string s, int i, int j) {

	while (i < j) {
		if (s[i]!=s[j]) return false;
		i++;
		j--;
	}
	return true;
}
void testcase() {
    string s;
    cin >> s;

    int n = s.length();
    int i=0, j=s.length()/2 - 1;

    if (!isPalin(s, 0, n-1)) {
    	cout << "No\n";
    	return;
    }

    if (isPalin(s, 0, (n-1)/2-1) && isPalin(s, (n+3)/2 - 1, n-1))
    	cout << "Yes";
    else
    	cout << "No";
    cout << "\n";

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,j,n) for (int i = j; i < (n); ++i)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


string back_path(string s){
    int n = s.length();
    string str="";
    rep(i,n){
        if(s[i] == 'U') str+='D';
        if(s[i] == 'D') str+='U';
        if(s[i] == 'R') str+='L';
        if(s[i] == 'L') str+='R';
    }
    return str;
}

int main() {
    pi s,t;
    cin >> s.first >> s.second >> t.first >> t.second;
    pi d;
    d.first = t.first-s.first;
    d.second = t.second-s.second;
    string go="";
    rep(i,d.second){
        go+='U';
    }
    rep(i,d.first){
        go+='R';
    }
    string go_second = "LU"+go+"RD";
    string ans = go+back_path(go)+go_second+back_path(go_second);
    cout<<ans<<endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	vector<int> v;
	int n,p;
    int x[101];
	cin>>n;
	for(int i=1;i<=n;++i) cin>>x[i];
	for(int i=1;i<=100;++i)
	{
		p=0;
		for(int j=1;j<=n;++j)	p+=(x[j]-i)*(x[j]-i);
        v.push_back(p);
	}
	sort(v.begin(),v.end());
	cout<<v[0];
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b, K;
    cin >> a >> b >> K;
    if (a >= K) {
        a -= K;
    } else {
        K -= a;
        a = 0;
        b = max(b - K, 0LL);
    }
    cout << a << " " << b << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
typedef long long ll;
typedef pair<int, int> pii;
int n;
string s[10100];
pair<bool,bool> a[10010];
ll ans;
int tp1,tp2,tp3;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		for(int j=1;j<s[i].size();j++){
			if(s[i][j]=='B' && s[i][j-1]=='A')ans++;
		}
		
		if(s[i][0]=='B')a[i].first=1;
		if(s[i][s[i].size()-1]=='A')a[i].second=1;
		
		if(a[i].first && a[i].second)tp2++;
		else{
			if(a[i].first)tp3++;
			if(a[i].second)tp1++;
		}
	}
	if(tp2){
		ans+=tp2+1;
		tp1--;
		tp3--;
		if(tp1<0)ans--,tp1++;
		if(tp3<0)ans--,tp3++;
	}
	ans+=min(tp1,tp3);
	cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(void) {
  long long int n;
  cin >> n;
  string str = to_string(n);
  int len = str.size()-1;
  long long int sum = 0;

  for (int bit = 0; bit < (1<<len); ++bit)
  {
    vector<int> s;
    for (int i = 0; i < len; ++i)
      if (bit & (1<<i)) 
        s.push_back(i+1);
    s.insert(s.begin(),0);
    s.push_back(len+1);
    
    for (int i = 0; i < s.size()-1; ++i)
    {
      sum += stoll(str.substr(s[i],s[i+1]-s[i]));
      //cout << str.substr(s[i],s[i+1]-s[i]) << "\n";
    }
    //cout << "sum : " << sum << "\n";
  }
  cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin>>n>>x;
  vector<int>l(n+1);
  l.at(0)=0;
  for(int i=0;i<n;i++){
    int y=0;
    cin>>y;
    l.at(i+1)=l.at(i)+y;
  }
  int ans=0;
	for(int i=0;i<=n;i++){
      if(l.at(i)<=x){
        ans++;
      }
    }
  cout<<ans<<endl;
}
  


Measured memory_bytes: 3612
using static System.Console;
using static System.Convert;
class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var num1 = ToInt32(input[0]);
        var num2 = ToInt32(input[1]);

        var PicA = new string[num1];
        var PicB = new string[num2];
        for (var i = 0; i < num1 + num2; i++)
        {
            var str = ReadLine();
            if (i < num1) PicA[i] = str;
            else PicB[i % num1] = str;
        }

        for (var i = 0; i < num1; i++)
        {
            var counter = 0;
            var isSame = true;
            while (true)
            {
                if (!PicA[i].Contains(PicB[0])) { isSame = false; break; }
                var index = PicA[i].IndexOf(PicB[0],counter*PicB.Length);
                if (index == -1||PicA.Length-i-PicB.Length<0) { isSame = false; break; }
               isSame = true;
                for (var j = 1; j < num2; j++)
                {
                    for(var h = 0; h < PicB[j].Length; h++)
                    {
                        if (!(PicA[j+i].Substring(index + h, 1) == PicB[j].Substring(h, 1))) { isSame = false; break; }
                    }
                    if (!isSame) break;
                }
                if (isSame) { WriteLine("Yes");break; }
                counter++;
            }
            if (isSame) break;
            if (i == num1 - 1) WriteLine("No");
        }
    }
}



Measured memory_bytes: 11360
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N;
int A[200005];
int R[200005];
signed main(){
    scanf("%lld",&N);
    rep(i,N){
        scanf("%lld",&A[i]);
        if(i==0)R[i]=A[i];
        else R[i]=R[i-1]+A[i];
        R[i]%=mod;
    }
    int ans=0;
    for(int i=N;i>=1;i--){
        ans+=R[i-1]*A[i];
        ans%=mod;        
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 4856
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
using namespace std;

ll n, a, b;

bool is_ok(vector<ll> &h, ll num){
	ll coun = 0;
	for (int i = 0; i < n; i++){
		if ((h[i] - b*num + a - 1)/a > 0) coun += (h[i] - b*num + a - 1)/a;
	}
	if (coun <= num) return true;
	return false;
}

int nibutan(vector<ll> &h, ll ok, ll ng){
	if (ok - ng == 1) return ok;
	ll mid = (ok+ng)/2;
	if (is_ok(h, mid)) return nibutan(h, mid, ng);
	return nibutan(h, ok, mid);
}


int main(){
	cin >> n >> a >> b;
	vector<ll> h(n);
	ll hmax = 0;
	for (int i = 0; i < n; i++){
		cin >> h[i];
		hmax = max(hmax, h[i]);
	}

	a -= b;

	cout << nibutan(h, hmax/b+1, 0) << endl;

	return 0;
}


Measured memory_bytes: 4064
#include<stdio.h>
int main(){
  int n,s=0,i,j,k,l;
  int p[7]={0};
  int d[7][7]={
    {1,0,0,1,1,0,1},
    {0,1,0,1,0,1,1},
    {0,0,1,0,1,1,1},
    {1,1,0,1,1,1,1},
    {1,0,1,1,1,1,1},
    {0,1,1,1,1,1,1},
    {1,1,1,1,1,1,1}
  };
  char w;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    int c[7]={0};
    scanf("%c",&w);
    if(w=='J')k=0;
    if(w=='O')k=1;
    if(w=='I')k=2;
    if(!i){
      for(j=0;j<7;j++){
	if(d[0][j]*d[k][j])p[j]=1;
      }
      continue;
    }
    for(j=0;j<7;j++){
      for(l=0;l<7;l++){
	if(d[k][l]*d[j][l])c[l]+=p[j];
      }
    }
    for(j=0;j<7;j++){//printf("%d ",c[j]);
      p[j]=c[j]%10007;
    }//printf("\n");
  }
  for(i=0;i<7;i++)s+=p[i];
  printf("%d\n",s%10007);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int A,B,C;cin>>A>>B>>C;
  if(C>=A&&C<=B)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}





Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
  int n,k,i=0,j=0,count=0;
  char baseNum[101];
  scanf ("%d %d",&n ,&k);
  while (n!=0)
  {
    baseNum[i] = n % k;
    n = n/k;
    i++;
    count++;
  }

  printf ("%d",count);
  return 0;
}


Measured memory_bytes: 128
//#define _USE_MATH_DEFINES	//M_PI
#include <iostream>			//std::cout, std::cin
//#include <string>			//std::string
#include <vector>			//std::vector
//#include <valarray>			//std::valarray	??°????????????????¬???????
//#include <algorithm>		//std::sort
//#include <time.h>			//localtime_s
//#include <cstdlib>			//abs
//#include <cmath>			//abs, pow, sqrt, sin, cos,
//#include <fstream>			//std::ifstream
//#include <iomanip>			//std::setprecision
//#include <random>			//std::random(C++11)

int main(void) {

	
	//test??¨
	//std::ifstream in("test.txt");
	//std::cin.rdbuf(in.rdbuf());

	//??\???
	int n;
	std::cin >> n;
	std::vector<std::vector<int>> dice(n, std::vector<int>(6));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 6; j++) {
			std::cin >> dice[i][j];
		}
	}

	//??????
	bool flg = true;
	std::vector<int> dice1(6), dice2(6), temp1(6);
	for (int i = 0; i < n - 1; i++) {
		dice1 = dice[i];
		for (int j = i + 1; j < n; j++) {
			dice2 = dice[j];

			for (int x = 0; x < 4; x++) {
				for (int y = 0; y < 4; y++) {
					for (int z = 0; z < 4; z++) {
						if (std::equal(dice1.begin(), dice1.end(), dice2.begin())) {
							flg = 0;
							x = y = z = 4;
							i = j = n;
						}
						temp1[0] = dice1[3];
						temp1[1] = dice1[1];
						temp1[2] = dice1[0];
						temp1[3] = dice1[5];
						temp1[4] = dice1[4];
						temp1[5] = dice1[2];
						dice1 = temp1;
					}
					temp1[0] = dice1[1];
					temp1[1] = dice1[5];
					temp1[2] = dice1[2];
					temp1[3] = dice1[3];
					temp1[4] = dice1[0];
					temp1[5] = dice1[4];
					dice1 = temp1;
				}
				temp1[0] = dice1[0];
				temp1[1] = dice1[3];
				temp1[2] = dice1[1];
				temp1[3] = dice1[4];
				temp1[4] = dice1[2];
				temp1[5] = dice1[5];
				dice1 = temp1;
			}

		}
	}

	if (flg) {
		std::cout << "Yes" << std::endl;	
	}
	else {
		std::cout << "No" << std::endl;
	}

}

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

void dfs(string s, char max_char, int max_length) {
    if (s.length() == max_length) {
        cout << s << endl;
    } else {
        for (char c = 'a'; c <= max_char; ++c) {
            dfs(s + c, (c == max_char) ? max_char + 1: max_char, max_length);
        }
    }
}

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

    dfs("a", 'b', n);

    return 0;
}



Measured memory_bytes: 1536
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // 入力値を受け取る
        Scanner sc = new Scanner(System.in);
        // 入力された２つの整数をaとbへ代入する
        int a = sc.nextInt();
        int b = sc.nextInt();

        // 大小関係を判定する
        String sign = "";
        if( a < b ) {
            sign = "<";
        } else if( a > b ) {
            sign = ">";
        } else if( a == b ) {
            sign = "==";
        }

        // 大小関係を出力する
        System.out.printf("a %s b\n", sign);
        sc.close();
    }
}


Measured memory_bytes: 26092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	string s, t; cin >> s >> t;
	int cnt = 0;
	for (int i = 0; i < 3; i++) cnt += s[i] == t[i];
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

class UnionFind {
    public :
        vecllong parent;  // 親のインデックス
        vecllong height;  // 木の高さ
        vecllong size;  // 木の頂点数
        llong component;  // 木の数

        UnionFind (llong size_) : parent(size_), height(size_, 1), size(size_, 1) {
            for (llong i = 0; i < size_; i++) {
                parent[i] = i;
            }
            component = size_;
        }
        void init (llong size_) {
            parent.resize(size_);
            size.assign(size_, 1);
            component = size_;
            for (llong i = 0; i < size_; i++) {
                parent[i] = i;
            }
        }

        // メソッド
        // Find
        llong root(llong index) {
            if (index == parent[index]) {
                return index;
            }
            parent[index] = root(parent[index]);
            return parent[index];
        }

        // Union
        bool merge(llong index1, llong index2) {
            llong root1 = root(index1);
            llong root2 = root(index2);

            if (root1 == root2) {
                return false;
            }

            component--;

            if (height[root1] < height[root2]) {
                parent[root1] = root2;
                size[root2] += size[root1];
            } else {
                parent[root2] = parent[root1];
                size[root2] += size[root1];
                if (height[root1] == height[root2]) {
                    height[root1]++;
                }
            }
            return true;
        }

        bool isSameRoot(llong index1, llong index2) {
            return root(index1) == root(index2);
        }

        llong sizeOfSameRoot(llong index) {
            return size[root(index)];
        }
};

int main(void) {
    llong N, M;

    cin >> N >> M;

    llong p[N];
    FOR(i, N) cin >> p[i];

    UnionFind tree(N);
    vvecllong xy(M, vecllong(2, 0));
    FOR(i, M) {
        llong x, y;
        cin >> x >> y;
        tree.merge(x-1, y-1);
    }

    llong ans = 0;
    FOR(i, N) {
        if (tree.isSameRoot(i, p[i] - 1)) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8832
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

int main() {
  uint32_t N;
  double num;
  cin >> N;
  num = ((N / 2) + (N & 0x01));
  cout << num / ((double)N) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

    cout << (a + b)%24 << endl;
    return 0;
}




Measured memory_bytes: 256
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/
 
#include <bits/stdc++.h>
//#include <windows.h>
 
#define ll long long
#define X first
#define Y second
#define MP make_pair
 
using namespace std;
 
    /*
const int MAX_MEM = 1e8;
int mpos=0;
char mem[MAX_MEM];
inline void * operator new(size_t n){
	char *res = mem + mpos;
	mpos += n;
	assert(mpos <= MAX_MEM);
	return (void *)res;
}
 
inline void operator delete(void *){}
    */

const int N = 2e3 + 13;
const ll mod = 1e9 + 7;
    
int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll a, b;
	cin >> a >> b;
	if(a <= 0 && b >= 0){
		cout << "Zero";
	}
	else if(a < 0){
		if(a % 2 == -1 && b > 0){
			cout << "Negative";	
		}
		else if(b < 0 && (abs(a - b) + 1) % 2 == 1){
			cout << "Negative";
		}
		else{
			cout << "Positive";
		}
	}
	else{
		cout << "Positive";
	}
	
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
cs = gets.chomp

ridx = []
widx = []
cs.length.times do |idx|
  if cs[idx] == 'R'
    ridx.push(idx)
  else
    widx.push(idx)
  end
end

cnt = 0
while ridx.length > 0 and widx.length > 0
  r = ridx.pop
  w = widx.shift
  if r > w
    cnt += 1
  else
    break
  end
end

p cnt

Measured memory_bytes: 16988
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    // 累積和
    vector<vector<int>> csum(2, vector<int>(N));
    csum[0][0] = A[0][0]; csum[1][N - 1] = A[1][N - 1];
    for (int i = 1; i < N; i++) {
        csum[0][i] = csum[0][i - 1] + A[0][i];
        csum[1][N - 1 - i] = csum[1][N - i] + A[1][N - 1 - i];
    }

    // 最大値を探す
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int num = csum[0][i] + csum[1][i];
        ans = max(ans, num);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void Comuse() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;
  solve();
}

///////////////////////////////////////////////////////////

string S;
void solve() {
  cin >> S;
  if(S == "AAA" || S == "BBB"){
    cout << "No" <<endl;
  } else{
    cout << "Yes" <<endl;
  }
}


Measured memory_bytes: 256
import static java.lang.Math.*;

import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		double r = scan.nextDouble();
		scan.close();

		System.out.printf("%f %f",PI*pow(r,2),2*PI*r);
	}

}

Measured memory_bytes: 19056
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

start1 = a
end1 = a+v*t
start2 = b
end2 = b+w*t
if(a==b):
    print("YES")
    exit()
if(w>=v):
    print("NO")
    exit()

dist = abs(a-b)
rv = abs(v-w)

if(dist <= t*rv): print("YES")
else: print("NO")

Measured memory_bytes: 9204
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
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)*}
    };
}
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)*}
    };
}
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!{
        P: usize,
        Q: usize,
        R: usize,
    }
    let max = std::cmp::max(std::cmp::max(P, Q), R);
    println!("{}", P + Q + R - max);
}



Measured memory_bytes: 4476