akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;
ll N;

//多次元vector
template<typename T>
vector<T> make_table(int n, T v) {
    return vector<T>(n, v);
}

template<typename... Args>
auto make_table(int n, Args... args) {
    auto val = make_table(forward<Args>(args)...);
    return vector<decltype(val)>(n,move(val));
}

int main() {
    cin >> N;
    auto dp = make_table(110, 5, 5, 5, 0ll);
    dp[0][0][0][0] = 1;
    for (int n = 0; n < N; n++) {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                for (int k = 0; k < 5; k++) {
                    for (int l = 1; l < 5; l++) {
                        if (i == 1 && j == 2 && l == 3) continue;
                        if (i == 1 && k == 2 && l == 3) continue;
                        if (j == 1 && k == 2 && l == 3) continue;
                        if (j == 2 && k == 1 && l == 3) continue;
                        if (j == 1 && k == 3 && l == 2) continue;
                        dp[n+1][j][k][l] += dp[n][i][j][k];
                        dp[n+1][j][k][l] %= MOD;
                    }
                }
            }
        }
    }
    ll res = 0;
    for (int i = 1; i < 5; i++) {
        for (int j = 1; j < 5; j++) {
            for (int k = 1; k < 5; k++) {
                res += dp[N][i][j][k];
                res %= MOD;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

//LIFE IS NOT A PROBLEM TO BE SOLVED

#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) cout << mat[i][j] << " "; cout << endl; }

using namespace std;

typedef long long int ll;
typedef pair <int, char> ii;
typedef pair <int, ii> iiii;


int main(){
	
	int n; cin >> n;
	priority_queue <int> pq;
	int aux;
	
	rep(i, 0, n){
		cin >> aux;
		pq.push(aux);
	}
	
	int sum[2], op = 0;
	sum[0] = sum[1] = 0;
	
	while(!pq.empty()){
		sum[op] += pq.top();
		pq.pop();
		op^=1;
	}
	
	cout << sum[0] - sum[1] << "\n";

	
}

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    int count = 0;
    int ans = 0;
    rep(i,n) cin >> h[i];

    for (int i = 1; i < n; i++) {
        if (h[i] > h[i-1]) {
            ans = max(ans, count);
            count = 0;
        }
        else {
            count++;
        }
        
    }

    ans = max(ans, count);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

ll inf=1e10;

int main() {
  ll n,d,a;
  cin >> n >> d >> a;
  ll zero=0;
  vector<pll> e(n);
  for(ll i=0;i<n;i++) {
    ll h,x;
    cin >> x >> h;
    e[i]=pll(x,(h+a-1)/a);
  }
  sort(e.begin(), e.end());
  ll ans =0;
  d=2*d;
  ll tot=0;
  queue<pll> q;
  for(ll i=0;i<n;i++) {
    ll x=e[i].first;
    ll h=e[i].second;
    while(q.size() &&q.front().first<x) {
      tot-=q.front().second;
      q.pop();
    }
    
    h-=tot;
    if(h>0) {
      ans+=h;
      ll damage=h;
      tot+=damage;
      q.emplace(x+d,damage);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

int n, ma, mb;
int a[41], b[41], c[41];
int dp[50][410][410];
const int INF = 1e7;

signed main(){
    cin >> n >> ma >> mb;
    rep(i, 0, n){
        cin >> a[i] >> b[i] >> c[i];
    }
    rep(i, 0, 41){
        rep(j, 0, 410){
            rep(k, 0, 410){
                dp[i][j][k] = INF;
            }
        }
    }
    dp[0][0][0] = 0;
    // rep(i, 0, n){
    //     rep(j, 0, 410){
    //         rep(k, 0, 410){
    //             if(dp[i][j][k] == INF) continue;
    //             dp[i + 1][j][k] = dp[i][j][k];
    //             if(j + a[i] >= 410 || k + b[i] >= 410) continue;
    //             dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
    //         }
    //     }
    // }
    rep(i, 0, n){
        rep(j, 0, 410){
            rep(k, 0, 410){
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
                if(j - a[i] < 0 || k - b[i] < 0) continue;
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j - a[i]][k - b[i]] + c[i]);
            }
        }
    }
    int ans = INF;
    rep(i, 0, 410){
        rep(j, 0, 410){
            if(i == 0 && j == 0) continue;
            if(ma * j == mb * i){
                ans = min(ans, dp[n][i][j]);
            }
        }
    }
    // rep(i, 0, 20){
    //     rep(j, 0, 20){
    //         if(dp[n][i][j] == INF) cout << -1 << " ";
    //         else cout << dp[n][i][j] << " ";
    //     }
    //     cout << endl;
    // }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 55552
#include <stdio.h>
#include <stdlib.h>

#ifdef TEST
struct test {
    int ans;
} td[] = {
    {},
};
#endif

void
solver(int n, int *x)
{
    int i;
    int ave;
    int cost;

    ave = 0;
    for(i = 0; i < n; i++)
        ave += x[i];
    ave = (int)((double)(ave) / n + 0.5);

    cost = 0;
    for(i = 0; i < n; i++) {
        cost += (ave - x[i]) * (ave - x[i]);
    }
    printf("%d\n", cost);
}

int
main(int argc, char *argv[])
{
#ifdef TEST
    int tt;
    for(tt = 0; tt < sizeof(td) / sizeof(struct test); tt++) {
        solver();
        printf("%d\n", td[tt].ans);
    }
#endif
    int i;
    int N;
    int X[100];

    scanf("%d", &N);
    for(i = 0; i < N; i++) {
        scanf("%d", X + i);
    }
    solver(N, X);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set =
tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll a,b;
    cin>>a>>b;
    ll s=a/b;
    a-=s*b;
    cout<<min(a,abs(a-b));
}

Measured memory_bytes: 3608
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int x; cin >> x;
	if (x >= 30)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3628
main :: IO()
main = do
    a <- readLn
    b <- readLn
    c <- readLn
    d <- readLn
    e <- readLn
    print $ solve [a,b,c,d,e]



solve :: [Int] -> Int
solve ls = sum summing + last changeLs
    where changeLs = firstSmall ls []
          summing = map floorUp (init changeLs)

--1の位が最も小さい数字を一番後ろにに持っていく。ただし０は１０と扱う。
firstSmall :: [Int] -> [Int] -> [Int]
firstSmall ls resultLs
    | ls == []							= resultLs
    | resultLs == []					= firstSmall (tail ls) [head ls]
    | otherwise 						= if (getOne $ head ls) > (getOne $ last resultLs)
												then firstSmall (tail ls) ((head ls):resultLs)
												else firstSmall (tail ls) (resultLs ++ [(head ls)])

--１の位を出力。ただし0だったら10を返す。
getOne :: Int -> Int
getOne num = if (mod num 10) == 0 then 10 else mod num 10 

--１０の位までで切り上げ。
floorUp :: Int -> Int
floorUp num = if mod num 10 == 0 then num else num + 10 - (mod num 10)

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <cstdio>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

ll dp[50010];



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

    ll n,m;
    cin>>n;
    map<string,ll> mp;
    rep(i,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    cin>>m;
    rep(i,m){
        string t;
        cin>>t;
        mp[t]--;
    }
    ll maxi=0;
    for(auto p:mp){
        maxi=max(maxi,p.second);
    }
    cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(){
  int a,b;
  if(scanf("%d",&a)==1){}
  if(scanf("%d",&b)==1){}
  
  int sum = a + b;
  int sub = a - b;
  int pro = a * b;
  
  if(sum >= sub && sum >= pro){
    printf("%d",sum);
  }else if(sub >= sum && sub >= pro){
    printf("%d",sub);
  }else{
    printf("%d",pro);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path; vl A, B; ll pre = 0;
//***********//
ll binarySearch() {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = 200010; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は V.size()
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;
		pre = 0;
		for (i = 0; i < N; i++) {
			pre += B[max(z, min(mid - A[i], (ll)100010))];
		}
		//debug(mid, pre);
		if (pre >= M) left = mid;
		else right = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return left;
}
int main() {
	cin >> N >> M;
	A.resize(N);
	B.resize(100011);
	for (i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end());
	ll prev = -1;
	for (i = 0; i < N; i++) {
		for (j = prev+1; j <= A[i]; j++) {
			B[j] = N - i;
		}
		prev = A[i];
	}
	ll base = binarySearch();
	pre = 0;
	for (i = 0; i < N; i++) {
		pre += B[max(z, min(base - A[i], (ll)100010))];
	}
	vl sum(N + 1);
	sum[0] = 0;
	for (i = 0; i < N; i++) sum[i + 1] = sum[i] + A[i];
	for (i = 0; i < N; i++) {
		ans+=A[i]* B[max(z, min(base - A[i], (ll)100010))] + sum[N] - sum[N-B[max(z, min(base - A[i], (ll)100010))]];
	}
	debug(base,ans,M,pre);
	cout << ans - (pre - M) * base;
}

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

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

    map<string,int> s;
    string str;
    int max_cnt = 0, s_size = 0;
    for (int i = 0; i < n; i++) {
        cin >> str;
        if (s.find(str) == s.end()) {
            s[str] = 0;
            s_size++;
        } else {
            s[str]++;
        }
        if (s[str] > max_cnt) max_cnt = s[str];
    }

    for (auto it = s.begin(); it != s.end(); it++) {
        if (it->second == max_cnt) cout << it->first << endl;
    }

    return 0;
}


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

int main()
{
	int i, n, x;
	cin >> n;
	int ans[n+1];
	ans[0]=0;
	for(i=1; i<=n; i+=1)
	{
		cin >> x;
		ans[x]=i;
	}
	for(i=1; i<=n; i+=1)
		cout << ans[i] << " ";
	cout << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >> A>>B;
	
	if (A>B){
	std::cout << "safe" << std::endl;}
	else
	std::cout << "unsafe" << std::endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll N=1000000007;
//ll power(ll a,ll b,ll mod)
//{
//    ll result=1;
//    while(b>0)
//    {
//        if(b%2==1)
//            result=(result*a)%mod;
//        a=(a*a)%mod;
//        b=b/2;
//    }
//    return result;
//}
//ll d,x,y;
//void extendedEuclid(ll a,ll b)
//{
//    if(b==0)
//    {
//        d=a; x=1; y=0;
//    }
//    else
//    {
//        extendedEuclid(b,a%b);
//        ll temp=x; x=y; y=temp-(a/b)*y;
//    }
//}
//ll modInverse(ll a,ll m)
//{
//    extendedEuclid(a,m);
//    return (x%m+m)%m;
//}
//ll lcm(ll a,ll b)
//{
//    if(a==0||b==0)
//        return 0;
//    return (a*b)/(__gcd(a,b));
//}
//void sieve(ll n)
//{
//    bool isPrime[n+1];
//    isPrime[0]=false; isPrime[1]=false;
//    for(ll i=2;i<=n;i++)
//        isPrime[i]=true;
//    for(ll i=2;i<=n;i++)
//    {
//        if(isPrime[i]==true)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//                isPrime[j]=false;
//        }
//    }
//}
//bool isPowerOfTwo(ll n)
//{
//    return (n&&!(n&(n-1)));
//}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k,i,sum=0; cin>>n>>k; ll A[n];
    for(i=0;i<n;i++)  cin>>A[i];
    sort(A,A+n);
    for(i=0;i<k;i++)  sum+=A[i];
    cout<<sum;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,k,i,j,srx[200001],sry,t,p;
int main()
{
   scanf("%d%d",&n,&k);
   for(i=1;i<=n;++i)
   {scanf("%d",&t);
   srx[t]++;}
   sort(srx+1,srx+n+1);
   for(i=n;i>n-k;--i)
   sry+=srx[i];
   printf("%d",n-sry);
   return 0;
}

Measured memory_bytes: 1024
//  main.cpp
//  ABC
//
//  Created by Amarsanaa Davaasuren on 2019/08/31.
//  Copyright © 2019 Amarsanaa Davaasuren. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#define rep(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int main(){
    int N; cin >> N;
    vector <int> A(N),B(N),C(N-1);
    rep(i,0,N){
        cin >> A[i];A[i]--;
    }
    rep(i,0,N){
        cin >> B[i];
    }
    rep(i,0,N-1){
        cin >> C[i];
    }
    int ans = 0;
    rep(i,0,N){
        ans += B[A[i]];
        if (i!= N-1 && A[i] == A[i+1]-1){
            ans += C[A[i]];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
//ここまで共通
int N;
int A[200010] = { 0 };
int main() {
	cin >> N;
	for (int i = 1; i < N; i++) {
		int a;
		cin >> a;
		a--;
		A[a]++;
	}
	for (int i = 0; i < N; i++) {
		cout << A[i] << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
const int MOD = 1e9 + 7;
map<int, int> mp;

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i=2; i<=n; i++){
		//find the prime factors in N N-1 N-2....
		int x = i;
		for(int j=2; j*j<=i; j++){
			while(x%j == 0){
				mp[j]++;
				x /= j;
			}
		}
		if(x > 1)
			mp[x]++;
	}

	ll ans = 1;
	for(auto x : mp)
		ans = ans*(x.second + 1)%MOD;

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


Measured memory_bytes: 256
from collections import deque

N = int(input())
S = input()
rgb = {"R":0, "G":0, "B":0}
RGBs = 0
for s in S:
    rgb[s] += 1

for i in range(N):
    tail = (N - 1 - i) // 2
    for d in range(1, tail + 1):
        Si = S[i]
        Sj = S[i + d]
        Sk = S[i + d * 2]
        if Si == Sj or Sj == Sk or Sk == Si:
            continue
        RGBs += 1

ans = rgb["R"] * rgb["G"] * rgb["B"] - RGBs
print(ans)

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

int main(){
  int L, R, d, x, c=0, i;
  cin >> L >> R >> d;
  for(int i = L; i <= R; i++){
    x = i % d;
    if(x == 0){
      c = c + 1;
    }
    else{
      c = c + 0;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

const int N = 112345;
vii G(N);

int dfs(int now, int par) {
    int res = 0;
    for (int v: G[now]) {
        if (v == par) continue;
        res += dfs(v, now);
    }
    if (res == 0) return 1;
    else if (res == 1) return 0;
    else {
        cout << "First" << endl;
        exit(0);
    }
}

signed main() {
    fio();
    
    int n;
    cin >> n;
    rep (i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    dfs(0, -1);
    if (n % 2 == 1) {
        cout << "First" << endl;
    }
    else {
        cout << "Second" << endl;
    }
}

Measured memory_bytes: 9016
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
	if a[i] > K: break
	while b[j] > K - a[i]: j -= 1
	ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 47364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;


main(){
    int n;cin>>n;
    int a[n];
    unordered_map<ll,int> ht;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ht[i+a[i]]++;
    }
    ll count=0;
    for(int i=0;i<n;i++){
        if(ht.find(i-a[i])!= ht.end()){
            count+= ht[i-a[i]];
        } 
    }
    cout<<count;
}

Measured memory_bytes: 12060
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 0
#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(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	for (int r, c; cin >> r >> c&&r;) {
		if ((r*c) % 2)cout << "no" << endl;
		else cout << "yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int64_t N;
  cin>>N;
  for(int64_t h=1;h<=3500;h++){
    for(int64_t n=1;n<=3500;n++){
      int64_t a=(4*h*n-N*n-N*h);
      if(a>0&&N*h*n%a==0&&N*h*n/a>0){
        cout<<h<<" "<<n<<" "<<N*h*n/a<<endl;return 0;
      }
    }
  }
  return 0;  
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()



int main() {
    int n;
    cin>>n;
    int a[n];
    rep(i,n) cin>>a[i];

    map<int,int> cnt;
    ll ans=0;
    rep(i,n){
        ans+=cnt[i-a[i]];
        cnt[a[i]+i]++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 21424
n,y= map(int,input().split())

ans=(-1,-1,-1)
m=range(n+1)
for a in m:
	for b in m:
		c=n-a-b
		total = 10000*a + 5000*b + 1000*c
		if (c>=0) & (total==y):
			ans=(a,b,c)
			break
		else:
			continue
		break

print("%d %d %d"%ans)


Measured memory_bytes: 3060
#include <stdio.h>

void fibonacci(int);

int main()
{
  int n;

  scanf("%d",&n);

  fibonacci(n);

  return 0;
}

void fibonacci(int n)
{
  int i,F[44];
  
  F[0] = 1;
  F[1] = 1;

  for(i=2;i<=n;i++) F[i] = F[i - 2] + F[i - 1];

  printf("%d\n",F[n]);

}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

typedef int Data;
typedef int SubData;

const int MN=100000;

vector<int> G[MN];
Data dp[MN];			//0-rooted dp[v]=term(merge(dp[u1],dp[u2],...))
SubData dp_nottermed[MN];	//0-rooted merge(dp[u1],...)
Data up[MN];			//up[v]= 0-rooted??§???v?????????p??¨??????, v->p?????????dp?????? term(merge(up[p],dp[v's bro1],dp[v's bro1],...))
Data DP[MN];			//DP[v]: ans for v-rooted tree
vector<SubData> ls,rs;		//ls/rs[i] = 0-rooted??§??????v???children??????/?????????i???merge????????????(???v??§????????????)
SubData init=0;
SubData merge(SubData val,Data v){
	return max(val,v);
}
SubData merge2(SubData x,SubData y){
	return max(x,y);
}
Data term(SubData val){
	return val+1;
}
void dfs(int v,int p=-1){
	SubData val=init;
	for(int u:G[v]) if(u!=p){
		dfs(u,v);
		val=merge(val,dp[u]);
	}
	dp_nottermed[v]=val;
	dp[v]=term(val);
//	cout<<"dp["<<v<<"]="<<dp[v]<<endl;
}
void ufs(int v,int p=-1){		//0-rooted??§upward?????¨???????¨????
	vector<int> ch;	//children
	for(int u:G[v]) if(u!=p) ch.pb(u);
	int K=ch.size();
	ls.resize(K+1);
	rs.resize(K+1);
	ls[0]=init;
	rs[0]=init;
	rep(i,K){
		ls[i+1]=merge(ls[i],dp[ch[i]]);
		rs[i+1]=merge(rs[i],dp[ch[K-1-i]]);
	}
//	if(p==-1) rep1(i,K) show(ls[i]),show(rs[i]);
	rep(i,K){
		int u=ch[i];
		SubData val=merge2(ls[i],rs[K-1-i]);
		if(p>=0) val=merge(val,up[v]);
		up[u]=term(val);
//		cout<<"up["<<u<<"]="<<up[u]<<endl;
	}
	rep(i,K) ufs(ch[i],v);
}
void calcDP(int N,int r=0){
	dfs(r);
//	up[r]=e			//Data????????????(???init)???????????§??¢???????????§??????
	ufs(r);
	rep(v,N){
		SubData val=dp_nottermed[v];
		if(v!=r) val=merge(val,up[v]);
		DP[v]=term(val);
	}
}
int main(){
	int N;
	cin>>N;
	rep(i,N-1){
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	calcDP(N);
	rep(i,N) printf("%d\n",(N-1)*2+1-DP[i]);
}

Measured memory_bytes: 22660
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
 
 
int dp[101][4][4][4];
 
int main() {
	int N;
	cin >> N;
	
	//長さ0の文字列は1である。
	//0,1,2に関する制約しかないので、
	//Sは、333Sと考えても問題がない。
	dp[0][3][3][3] = 1;
 
	int mod = 1'000'000'007;
 
	//文字列の文字数
	for (int len = 0; len < N; len++)
	{
		//最後から1文字目の文字
		for (int c1 = 0; c1 < 4; c1++)
		{
			//最後から2文字目の文字
			for (int c2 = 0; c2 < 4; c2++)
			{
				//最後から3文字目の文字
				for (int c3 = 0; c3 < 4; c3++)
				{
					//条件に当てはまるものがない場合はcontinue;
					if (dp[len][c1][c2][c3] == 0) continue;
 
					//新しく追加する文字
					for (int a = 0; a < 4; a++)
					{
						//ダメな5つの条件をカットする
						if (a == 2 && c1 == 1 && c2 == 0) continue;
						if (a == 2 && c1 == 0 && c2 == 1) continue;
						if (a == 1 && c1 == 2 && c2 == 0) continue;
						if (a == 2 && c1 == 1 && c3 == 0) continue;
						if (a == 2 && c2 == 1 && c3 == 0) continue;
 
						//ダメな条件を抜けたら、aを足した文字列が作れる
 
						// S = ...... c3 c2 c1
						// nextS = ...... c2 c1 a
 
						dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
						dp[len + 1][a][c1][c2] %= mod;
					}
				}
			}
		}
	}
 
	int ans = 0;
 
	//長さNの全部の答えを纏める
	//最後から1文字目の文字
	for (int c1 = 0; c1 < 4; c1++)
	{
		//最後から2文字目の文字
		for (int c2 = 0; c2 < 4; c2++)
		{
			//最後から3文字目の文字
			for (int c3 = 0; c3 < 4; c3++)
			{
				ans += dp[N][c1][c2][c3];
				ans %= mod;
			}
		}
	}
 
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
/* -- template -- */
P vec[] = {mp(0, 1), mp(1, 0), mp(-1, 0), mp(0, -1)};
int main() {
    int H, W; cin >> H >> W;
    string S[H]; rep(i, H) cin >> S[i];
    queue<P>Q;
    Q.push(mp(0, 0));
    int dist[H][W];
    int add = 0;
    rep(i, H){
        rep(j, W){
            dist[i][j] = INF;
            if(S[i][j] == '#')++add;
        }
    }
    dist[0][0] = 0;

    while(!Q.empty()) {
        P q = Q.front();Q.pop();
        for(int i = 0; i < 4; ++i) {
            int h = q.first + vec[i].first, w = q.second + vec[i].second;
            if(h < 0 || w < 0 || h >= H || w >= W)continue;
            if(S[h][w] == '#')continue;
            if(dist[h][w] == INF) Q.push(mp(h, w));
            dist[h][w] = min(dist[h][w], dist[q.first][q.second] + 1);
        }
    }
    if(dist[H - 1][W - 1] != INF)cout << H * W - dist[H - 1][W - 1] - add - 1 << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    int ans=0,max_div = 0;
    for(int i=1;i<=n;i++){
        int m=i;
        int tmp=0;
        //cout<<i<<endl;
        while(m%2==0){
            tmp++;
            m/=2;
        }
        if(max_div<tmp){
            ans=i;
            max_div=tmp;
        }
    }
    if(n==1) cout<<1<<endl;
    else cout<<ans<<endl;
}

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

struct UnionFind{
    vector<int> par;
    UnionFind(int n) : par(n){
       REP(i, n) par[i] = i;
    }
    int root(int x){
        if(x == par[x]) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(x < y) swap(x, y);
        par[x] = y;
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
};

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

    int n, m;
    cin >> n >> m;

    vector<int> P(n);
    REP(i, n){
        int p;
        cin >> p;
        p--;
        P[i] = p;
    }

    UnionFind uf(n);
    REP(i, m){
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.unite(x, y);
    }

    int ans = 0;
    REP(i, n) if(uf.same(i, P[i])) ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h> 


int n, M[1000][1000], color[1000], d[1000], f[1000], tt=0;

void dfs_visit(int u) {
  
  int v;
  
  color[u] = 1;
  
  tt++;
  
  d[u] = tt;
  
  for ( v = 0; v < n; v++ ) {
    if ( M[u][v] == 0 ) {
      continue;
    }
    if ( color [v] == 0 ) {
      dfs_visit(v);
    }
  }
  
  f[u] = ++tt;

  return;
  
}

void print(int a,int *b,int *c){

  printf("%d",a);
  printf(" %d", b[a-1]);
  printf(" %d", c[a-1]);
  printf("\n");

  return;

}

void dfs() {
  int i;
  
  for ( i = 0; i < n; i++ ) color[i] = 0;

  dfs_visit(0);
  
  for ( i = 1; i < n; i++ ) {  
    if ( color[i] == 0 ) dfs_visit(i);
    else continue;
  }
	
  for ( i = 1; i<=n; i++ ) {
    print(i,d,f);
  }

  return;
}

int main() {
  int u, v, k, i, j;
      
  scanf("%d", &n);
  
  for (i = 0; i<n; i++ ) {
    for (j = 0; j<n; j++ ) M[i][j] = 0;
  }
  
  for (i = 0; i < n; i++ ) {
    scanf("%d %d", &u, &k);

    
    for (j = 0; j < k; j++ ) {
      scanf("%d", &v);
      v--;
      M[u-1][v] = 1;
    }
  }
  
  dfs();
  
  return 0;
}



Measured memory_bytes: 2132
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
const int MOD=1000000007;

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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }



int main(int argc, char**argv){
    string s;
    cin >> s;

    vector<int> a(4);
    for (int i = 0; i < 4; i++){
        a[i] = (int)(s[i] - '0');
    }

    for (int bit = 0; bit < (1<<3); bit++){
        int result = a[0];
        string out = "";
        for (int i = 0; i < 3; i++){
            out += s[i];
            if (bit & (1 << i)){
                result += a[i+1];
                out += "+";
            }else{
                result -= a[i+1];
                out += "-";
            }
        }
        out += s[3];
        if (result == 7){
            out += "=7";
            cout << out << endl;
            return 0;
        }
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const int MOD=1000000007;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, a, b;
	cin>>x>>a>>b;
	abs(x-a)<abs(x-b) ? cout<<'A'<<'\n' : cout<<'B'<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    set<string> s;
    while(n--)
    {
        string a;
        cin >> a;
        s.insert(a);
    }
    cout << s.size();
    return 0;
}

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

using namespace std;
#define int long long
#define all(a) (a).begin(), (a).end()
#define ms(a,v) memset(a, v, sizeof(a))
#define sz(v) ((int)(v).size())
#define mp make_pair
#define pb push_back
#define prev biiiiirl_sai_de_casa_comi_pra_caralho
#define next trapezio_descendente
#define index eh_ele_que_nos_vai_buscar
#define left aqui_eh_37_anos_porra
#define R32 ({int32_t x; scanf("%d", &x); x;})
#define RL ({long long x; scanf("%lld", &x); x;})
#define RC ({char x; scanf(" %c", &x); x;})
#define RI RL
#define ff first
#define ss second
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;

int32_t main(){
  int ptr = 1;
  int n = RI+1;

  bool has = false;
  deque<int> st, nd;
  for(int i = 48; i >= 0; i--){
    if(has){
      st.push_back(ptr);
      nd.push_back(ptr);
      ptr++;
    }

    if((n>>i)&1){
      if(has){
        st.push_front(ptr);
        nd.push_back(ptr);
        ptr++;
      }
      has=1;
    }
  }

  cout << st.size()+nd.size() << endl;
  for(int x : st) cout << x << " ";
  for(int x : nd) cout << x << " ";
  cout << endl;
}


Measured memory_bytes: 256
N=int(input())
S=list(input())
def caeser(S,n):
  r = []
  for s in S:
    if ('A' <= s and s <= 'Z'):
      r.append(chr((ord(s) - ord('A') + n) % 26 + ord('A')))
    # a - z
    elif ('a' <= s and s <= 'z'):
      r.append(chr((ord(s) - ord('a') + n) % 26 + ord('a')))
  return "".join(r)
  
print(caeser(S,N))

Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
set<string> st;
void f(int rest, string s,char mx)
{
    if (rest == 0)
    {
        cout << s << endl;
    }
    else
    {
        for (char c = 'a'; c <= mx;c++){
            f(rest - 1, s + c, (c == mx ?(char)(mx+1):mx));
        }
    }
}
int main()
{
    int n;
    cin >> n;
    string s = "";
    f(n,s,'a');
    for (auto e : st)
    {
        cout << e << endl;
    }
}

Measured memory_bytes: 1536
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int cnt = 0;
  string a, b;
  cin >> a >> b;
  REP(i,3) if(a[i] == b[i]) cnt++;
  cout << cnt << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;
typedef pair<int,int> P;

int main()
{

    int N,M,C;
    cin>>N>>M>>C;

    int B[30],A[30][30];
    REP(i,M) cin >> B[i];
    REP(i,N){
    	REP(j,M){
    		cin >> A[i][j];
    	}
    }

    int ans = 0;
    REP(i,N){
    	int sum=C;
    	REP(j,M){
    		sum += A[i][j]*B[j];
    	}
    	if(sum>0) ans ++;
    }

    cout << ans << endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=700,m,a,b,c,d,e;
	long double z,w;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>str;
	if(str[0]=='o'){n+=100;}
	if(str[1]=='o'){n+=100;}
	if(str[2]=='o'){n+=100;}
	cout<<n;
	



	cout<<endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)))
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
int n,m;
vi E[100005];
int ans=INT_MIN;
int dis[100005];
/*---main code---*/

int calc(int x)
{
	if(dis[x]!=-1)
	{
		return dis[x];
	}
	dis[x]=0;
	EACH(E[x],it)
	{
		int to=*it;
		dis[x]=max(dis[x],calc(to)+1);
	}
	return dis[x];
}

int main()
{
	FIO;
	cin>>n>>m;
	FILL(dis,-1);
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		E[x].push_back(y);
	}
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,calc(i));
	}
	cout<<ans<<'\n';
	return 0;
}



Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=5e5+10;
const int maxm=20e5+10;
char s[maxn],t[maxn],all[maxm];
int ns,nt,n;
int bl,br;
int z[maxm];
void Z_function()
{
	z[0]=n;
	bl=br=0;
	for(int i=1;i<n;i++)
	{
		z[i]=0;
		if(i<=br)
		{
			int p=i-bl;
			if(i+z[p]-1<br)
			{
				z[i]=z[p];
			}
			else
			{
				z[i]=min(z[p],br-i+1);
				while(i+z[i]<n&&all[i+z[i]]==all[z[i]])z[i]++;
				bl=i;
				br=i+z[i]-1;
			}
		}
		else
		{
			while(i+z[i]<n&&all[i+z[i]]==all[z[i]])z[i]++;
			bl=i;
			br=i+z[i]-1;
		}
	}
}
int nxt[61][maxn];
int main()
{
	scanf("%s",s);ns=strlen(s);
	scanf("%s",t);nt=strlen(t);
	while(n<ns+nt-1)
	{
		for(int i=0;i<ns;i++,n++)
			all[n]=s[i];
	}
//	cout<<all<<endl;
	for(int i=nt+n-1;i>=nt;i--)
		all[i]=all[i-nt];
	n+=nt;
	for(int i=0;i<nt;i++)
		all[i]=t[i];
	Z_function();
	memset(nxt,-1,sizeof(nxt));
	for(int i=0;i<ns;i++)
	{
		if(z[nt+i]>=nt)nxt[0][i]=(i+nt)%ns;
	}
	for(int t=0;t<60;t++)for(int i=0;i<ns;i++)if(nxt[t][i]>=0)
	{
		nxt[t+1][i]=nxt[t][nxt[t][i]];
	}
	for(int i=0;i<ns;i++)
		if(nxt[60][i]>=0)
		{
			printf("-1");
			return 0;
		}
	ll ans=0;
	for(int i=0;i<ns;i++)
	{
		ll tmp=0;
		int pos=i;
		for(int t=60;t>=0;t--)
		{
			if(nxt[t][pos]>=0)
			{
				pos=nxt[t][pos];
				tmp+=1ll<<t;
				
			}
		}
		ans=max(ans,tmp);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 130304
s = list(input())
l = len(s)
ans = "No"
if s == s[::-1] and s[:(l-1)//2] == s[:(l-1)//2][::-1] and s[(l-1)//2+1:] == s[(l-1)//2+1:][::-1]:
    ans = "Yes"
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
long long int min(long long int a,long long int b){return a>b?b:a;}
int main(){
    long long int na,nb,nc,a,b,c,d,e,l,r;
    while(true){
        scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e);
        if(a==0&&b==0&&c==0&&d==0&&e==0)return 0;
        scanf("%lld%lld%lld",&na,&nb,&nc);
        if(nc>=d)printf("%lld\n",nc*e+nb*b+na*a);
        else if(nc+nb>=d){
               l=d*e+na*a+(nb+nc-d)*b;
               r=na*a+nb*b+nc*c;
               printf("%lld\n",min(l,r));
        }
        else if(na+nb+nc>=d){
            l=d*e+(na+nb+nc-d)*a;
            r=na*a+nb*b+nc*c;
            printf("%lld\n",min(l,r));
        }
        else printf("%lld\n",min(na*a+nb*b+nc*c,d*e));
    }
    
}


Measured memory_bytes: 2708
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    if (s.at(i) == '1') {
      s.at(i) = '9';
    } else if (s.at(i) == '9') {
      s.at(i) = '1';
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256