akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind tree(N+1);

  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    tree.unite(A, B);
  }

  map<int, int> cnt;
  for (int i = 1; i <= N; i++) {
    cnt[tree.root(i)]++;
  }

  for (int i = 1; i <= N; i++) {
    cerr << tree.root(i) << endl;
  }

  cout << cnt.size() - 1<< endl;
  return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

vll adj[100111];
ll vis[100111];

void visit(ll ind){
	ll val = 0;
	for(auto x:adj[ind]){
		if(!vis[x])visit(x);
		val = max(val,vis[x]+1);
	}
	vis[ind] = val;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,m;
	cin >> n >> m;
	memset(vis,0,sizeof(vis));
	for(int i=0; i<m; i++){
		int x,y; cin >> x >> y;
		adj[x].pb(y);
	}
	ll ans = 0;
	for(int i=1; i<=n; i++)if(!vis[i])visit(i);
	for(int i=1; i<=n; i++)ans = max(ans,vis[i]);
	cout << ans << endl;
}	
/* Benq's
	stuff you should look for
	* ll, int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 8576
#include <iostream>
using namespace std;
#define rep(i,c,n) for(int i=c;i<n;i++)

int main() {
  int n;
  cin>>n;
  long long int ans=0;
  
  rep(i,1,n+1){
    if(i%3==0||i%5==0){continue;}
    ans+=i;
  }

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

Measured memory_bytes: 3648
using System;

using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        //整数の入力
        int N = int.Parse(Console.ReadLine());
        //スペース区切りの整数の入力
        string[] L = Console.ReadLine().Split(' ');
        //var L2 = L.Distinct().OrderBy(o => o);
        var L2 = L.OrderBy(o => o).ToArray();

        //string input = Console.ReadLine();
        //int b = int.Parse(input[0]);
        //int c = int.Parse(input[1]);
        //文字列の入力
        //string s = Console.ReadLine();
        //出力

        //onsole.WriteLine(N);
        //Console.WriteLine(string.Join(" ", L));

        int count = 0;

        if (L2.Count() <= 2)
        {
            Console.WriteLine(0);
            Environment.Exit(0);
        }


        for (int i = 0; i < L2.Count(); i++)
        {
            for (int j = i+1; j < L2.Count(); j++)
            {

                int li = int.Parse(L2[i]);
                int lj = int.Parse(L2[j]);
                if (li == lj)
                {
                    continue;
                }

                for (int k = j+1; k < L2.Count(); k++)
                {
                    int lk = int.Parse(L2[k]);
                    if (lj == lk)
                    {
                        continue;
                    }

                    if (li < lj + lk && lj < li + lk && lk < li + lj) {
                        count++;
                    }
                }
            }
        }


        Console.WriteLine(count);
        //Console.WriteLine(string.Join(" ", L2));
    }
}



Measured memory_bytes: 28912
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

LL n;
vector<LL> edges[110000];
LL num[110000];
vector<LL> deg(110000, 0);
LL ok = 1;
void dfs(LL v, LL p){

	if(deg[v] != 1) num[v] *= 2;
	vector<LL> r;
	for (LL x : edges[v]) {
		if (x != p){
			dfs(x, v);
			num[v] -= num[x];
			r.push_back(num[x]);
		}
	}
	if(num[v] < 0) ok = 0;
	if(v > 0) r.push_back(num[v]);
	sort(r.begin(), r.end());
	reverse(r.begin(), r.end());
	LL sum = 0;
	for(LL x : r){
		sum += x;
	}
	if(deg[v] > 1 && (sum % 2) != 0) ok = 0;
	if(deg[v] > 1 && r[0] * 2 > sum) ok = 0;
}
int main(){
	cin >> n;
	for(LL i = 0; i < n; i++){
		cin >> num[i];
	}
	for(LL i = 0; i < n-1; i++){
		LL a, b;
		cin >> a >> b;
		a--; b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
		deg[a]++; deg[b]++;
	}
	dfs(0, -1);
	if(num[0] != 0 || ok == 0){
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 15616
SA = input()
SB = input()
SC = input()

cur, SA = SA[0], SA[1:]

while True :
    if cur == 'a' :
        if len(SA) == 0 :
            print('A')
            break
        cur, SA = SA[0], SA[1:]
    elif cur == 'b' :
        if len(SB) == 0 :
            print('B')
            break
        cur, SB = SB[0], SB[1:]
    elif cur == 'c' :
        if len(SC) == 0 :
            print('C')
            break
        cur, SC = SC[0], SC[1:]

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

int main(void)
{   
    string s;
    cin >> s;
    int l = s.size(); 
    v_int abc(3);

    irep(i, l) {
        abc[s[i] - 'a']++;    
    }
    
    sort(abc.rbegin(), abc.rend());

    int x = abc[0];
    int y = abc[1];
    int z = abc[2];
    
    v_int v;
    irep(i, l) {
        if(x--) { v.push_back(0); }
        if(y--) { v.push_back(1); }
        if(z--) { v.push_back(2); }
    }

    bool ok = true;
    irep(i, l) {
        if(v[i] != (i%3)) {
            ok = false;    
        }
    }
    if(ok) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}
/** tcoder **/


Measured memory_bytes: 2548
/*Lucky_Glass*/
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=700;
int n,mod,Nf,Ng;
vector< pair<int,int> > Epr;
int Ef[N+3][N+3];

int main(){
	scanf("%d%d",&n,&mod);
	Nf=2*n-1;Ng=2*n-1;
	for(int i=0;i<2*n;i++){
		while(i*i+Nf*Nf>4*n*n && Nf>=0) Nf--;
		while(i*i+Ng*Ng>=n*n && Ng>=0) Ng--;
		if(i>=n) Epr.push_back(make_pair(Nf+1,0));
		else  Epr.push_back(make_pair(Ng+1,Nf+1));
//		printf("%d %d\n",Epr.back().first,Epr.back().second);
	}
	sort(Epr.begin(),Epr.end());
	int Vans=0;long long typ=1;
	for(int k=0;k<=n;k++){
		memset(Ef,0,sizeof Ef);
		Ef[0][0]=1;
		for(int i=0,Ctf=0,Ctg=0;i<(int)Epr.size();Ctg+=Epr[i].second==0,Ctf+=Epr[i].second!=0,i++){
			for(int j=0;j<=k;j++){
				int tmp=Ef[i][j];
				if(Epr[i].second){
					if(j!=k) Ef[i+1][j+1]=(Ef[i+1][j+1]+1ll*tmp*(Epr[i].first-j-Ctg)%mod)%mod;
					Ef[i+1][j]=(Ef[i+1][j]+1ll*tmp*(Epr[i].second-k-n-(Ctf-j))%mod)%mod;
				}
				else
					Ef[i+1][j]=(Ef[i+1][j]+1ll*tmp*(Epr[i].first-j-Ctg)%mod)%mod;
			}
//			printf("%d %d\n",Ctf,Ctg);
		}
//		printf("%d\n",Ef[Epr.size()][k]);
		Vans=(Vans+typ*Ef[Epr.size()][k]+mod)%mod;
		typ*=-1;
	}
	printf("%d\n",Vans);
	return 0;
}


Measured memory_bytes: 2176
<?php
$num = trim(fgets(STDIN));

for($i = 0; $i < $num; $i++){
    fscanf(STDIN, "%d %d  %d", $date[0], $date[1], $date[2]);
    sort($date);
    $slop = sqrt(($date[0]**2 + $date[1]**2));
    if($slop == $date[2])
        echo "YES"."\n";
    else 
        echo "NO"."\n";
    
}


Measured memory_bytes: 9248
# coding: utf-8

import sys
input = sys.stdin.readline

# N = int(input())
# L = [int(x) for x in input().split()]
N, K = map(int, input().split())
S = input()

for i, s in enumerate(S) :
    print(s.lower() if i == K - 1 else s, end="")

print()


Measured memory_bytes: 2940
#include <iostream>
#define ll long long
using namespace std;

int main(){
    string a;
    cin >> a;
    ll n = a.size(), c = 0;
    if(a[0] == 'A' && a[1] != 'C' && a[n - 1] != 'C') {
        for(int i = 1; i < n; i++) {
            if(a[i] == 'C') {
                c++;
            } else if (isupper(a[i])) {
                c = 10;
                break;
            }
        }
        if(c == 1 && islower(a[1])) cout << "AC" << endl;
        else cout << "WA" << endl;
    } else cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
n = input()
a = int(n[:2])
b = int(n[2:])

if 0 < a <= 12 and  (b == 0 or b > 12):
    print('MMYY')
elif (a == 0 or a > 12) and 0 < b <= 12:
    print('YYMM')
elif 0 < a <= 12 and 0 < b <= 12:
    print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

long long x;

long long f(long long n){
    if(n==-1){
        return 0; 
    }
    else{
        return n/x+1;
    }
}

int main(){
    long long a, b;
    cin >> a >> b >> x;
    cout << f(b)-f(a-1) << endl;
}

Measured memory_bytes: 256
def main
    n,m = gets.chomp.split(" ").map(&:to_i)
    as = gets.chomp.split(" ").map(&:to_i)
    sum = as.sum
    cnt = 0
    as.each do |a|
        cnt += 1 if a >= sum * 1.0 / (4 * m)
    end
    if cnt >= m
        puts 'Yes'
    else
        puts 'No'
    end
end

main


Measured memory_bytes: 14280
#include<stdio.h>

int main()
{
	int high[11];
	int i,j;
	int box;
	for(i=0;i<10;i++){
		scanf("%d",&high[i]);
	}
	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(high[i]<high[j]){
				box=high[i];
				high[i]=high[j];
				high[j]=box;
			}
		}
	}
	for(i=0;i<3;i++) printf("%d\n",high[i]);
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N,K; cin >>N>>K;
    vector<int> x(N); cin >> x;
    
    int ans = 0;

    rep(i,N)
        ans += min(x[i]*2,abs(K-x[i])*2);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N,K,A;
    cin >> N >> K;
    rep(i,N) cin >> A;
    
    int c = (N-K)/(K-1);
    if(c*(K-1)+K == N) cout << c+1 << endl;
    else cout << c+2 << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
def main():
    N = int(input())
    S = input()
    lst = [0] * N
    ans = N

    if S[0] == "E":
        lst[0] = 1
    for i in range(1, N):
        if S[i] == "E":
            lst[i] = lst[i - 1] + 1
        else:
            lst[i] = lst[i - 1]

    for i in range(N):
        if i == 0:
            left = 0
        else:
            left = i - lst[i - 1]
        right = lst[N - 1] - lst[i]

        if left + right < ans:
            ans = left + right

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21072
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int n,k;
cin>>n>>k;
vector<int> a(n),d1(n),d2(n);
for(int i=0;i<n;i++)cin>>a.at(i);
for(int i=0;i<n;i++){
    d1.at(i)=2*a.at(i);
    d2.at(i)=2*abs(k-a.at(i));
}
int ans=0;
for(int i=0;i<n;i++){
    ans+=min(d1.at(i),d2.at(i));
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (int)(count); i++)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
const int MODULO = 100000 ;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;

using namespace std;

bool CMP(const pair<int,string>&x, const pair<int,string>&y){
	return x.first > y.first;
}

int main()
{
	int n;
	bool b = false;
	while(cin>>n,n){
		vector<pair<int,string> > v;
		while(n--){
			string s; int a,b,c;
			cin>>s>>a>>b>>c;
			v.push_back(make_pair(a*3+c,s));
		}

		stable_sort(v.begin(),v.end(),CMP);
		if(b) cout << endl;
		b = true;
		FOR(i,sz(v)){
			cout << v[i].second << "," << v[i].first << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1228
import numpy as np
N = int(input())
S = input()

l_r = []
l_g = []
l_b = []
for i in range(N):
  if S[i]=='R':
    l_r.append(i)
  if S[i]=='G':
    l_g.append(i)
  if S[i]=='B':
    l_b.append(i)
    
l_r = set(l_r)
l_g = set(l_g)
l_b = set(l_b)

ans = len(l_r)*len(l_g)*len(l_b)

for r in l_r:
  for g in l_g:
    mi = min(r, g)
    ma = max(r, g)
    l = ma - mi
    if ma+l in l_b:
      ans -= 1
    if mi-l in l_b:
      ans -= 1
    if l%2==0 and l//2 + mi in l_b:
      ans -= 1

print(ans)


Measured memory_bytes: 27304
#include<stdio.h>
int main(){
  int n,m,i;
  int r[4],a[4],h,b;
  while(1){
    scanf("%d %d",&n,&m);
    if(n==0&&m==0)break;
    h=0;
    b=0;
    for(i=0;i<4;i++){
      r[i]=n%10;
      a[i]=m%10;
      n/=10;
      m/=10;
      if(r[i]==a[i])h++;
    }
    for(i=0;i<16;i++){
      if(r[i/4]==a[i%4])b++;
    }
    printf("%d %d\n",h,b-h);
  }
  return 0;
}

Measured memory_bytes: 600
A = list(map(int, input().split()))
A += list(map(int, input().split()))
A += list(map(int, input().split()))
flag=0
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1=A[6]-a1
            b2=A[7]-a1
            b3=A[8]-a1
            if b1<0 or b2<0 or b3<0:
                break
            if a3+b1==A[0] and a3+b2==A[1] and a3+b3==A[2] and a2+b1==A[3] and a2+b2==A[4] and a2+b3==A[5]:
                flag=1
print("Yes" if flag==1 else "No")


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

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

  N %= 100;
  N %= 10;
  
  switch(N){
    case 0:
    case 1:
    case 6:
    case 8:
      result = "pon";
      break;
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      result = "hon";
      break;
    case 3:
      result = "bon";
      break;
    default :
      result = "";
  }
  cout << result << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

#define N 100

int bubbleSort(int *A, int n) {
	int i, tmp;
	int flag = 1;
	int count = 0;

	while (flag) {
		flag = 0;
		for (i = n-1; i > 0; i--) {
			if (A[i] < A[i-1]) {
				tmp = A[i];
				A[i] = A[i-1];
				A[i-1] = tmp;

				count++;
				flag = 1;
			}
		}
	}

	return count;
}

int main (){
	int i,n;
	int A[N];
	int count;

	scanf("%d", &n);

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

	count = bubbleSort(A, n);

	for (i = 0; i < n-1; i++)
		printf("%d ", A[i]);

	printf("%d\n", A[i]);
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 600
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = new long[](N);
    auto B = new long[](N);
    foreach (i; 0 .. N)
    {
        scan(A[i], B[i]);
    }
    A.sort();
    B.sort();
    long a = (N & 1) ? A[N / 2] : (A[N / 2] + A[N / 2 - 1]);
    long b = (N & 1) ? B[N / 2] : (B[N / 2] + B[N / 2 - 1]);
    writeln(b - a + 1);
}


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

bool equals( const string& a, int start, const string& b ) {
	for( int i = 0; i < b.size(); ++i ) {
		if( start+i >= a.size() || a[start+i] != b[i] ) {
			return false;
		}
	}

	return true;
}

bool can_goal( const string& s, int beg, int end ) {
	for( int i = beg; i < end; ++i ) {
		if( equals( s, i, "##" ) ) {
			return false;
		}
	}

	return true;
}

bool can_over( const string& s, int beg, int end ) {
	for( int i = beg; i < end; ++i ) {
		if( equals( s, i, "..." ) ) {
			return true;
		}
	}

	return false;
}

int main() {
	int N, A, B, C, D;
	string S;
	cin >> N >> A >> B >> C >> D >> S;

	bool goal = can_goal( S, A-1, C-1 ) && can_goal( S, B-1, D-1 );
	bool result = goal && (C < D || can_over( S, B-2, D-1 ));

	cout << (result ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int m[10];
  for(int i = 0;i < 10;i++){
    cin >> m[i];
  }
  sort(m,m+10);
  cout << m[9] << endl << m[8] << endl << m[7] << endl;
}

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

int main()
{
    ll a;
    cin >> a;

    cout << a + pow(a, 2) + pow(a, 3) << endl;

    return 0;
}

Measured memory_bytes: 4148
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

pub fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let n: u32 = read(&mut stdin).unwrap();
    let mut cards: Vec<u32> = (0..n).map(|_x| read(&mut stdin).unwrap()).collect();

    cards.sort();
    cards.reverse();

    let player = cards
        .iter()
        .enumerate()
        .fold((0, 0), |acc, x|
            if x.0 % 2 == 0 {
                (acc.0 + x.1, acc.1)
            } else {
                (acc.0, acc.1 + x.1)
            });
    println!("{:?}", player.0 - player.1);
}


Measured memory_bytes: 4476
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define ll long long

#define DEBUG (0)

int main()
{
  int n = 0;
  int result = 0; /* 0:approved, 1: denied */

  cin >> n;

  vector<int>a(n,0);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  for(int i = 0; i < n; i++){
    if((a[i] % 6 == 0) || (a[i] %10 == 0) || (a[i] %2 == 1)){
      /* do nothing */
    }else{
      result = 1;
      break;
    }
  }

  if(result == 0){
    cout << "APPROVED" << "\n";
  }else{
    cout << "DENIED" << "\n";
  }

#if DEBUG
  for(int i = 0; i < n; i++){
    cout << a[i] << " ";
  }
  cout << "\n";
#endif
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b != c)
        cout << c << endl;
    else if (a != b && b == c)
        cout << a << endl;
    else if (a == c && a != b)
        cout << b << endl;

    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N = 0;
	int K = 0;
	cin >> N >> K;

	int i = 0;
	vector<int> have;
	while(i < N){
		have.emplace_back(0);
		i++;
	}
	i = 0;
	while(i < K){
		int p = 0;
		cin >> p;
		int j = 0;
		while(j < p){
			int sunuke = 0;
			cin >> sunuke;
			have[sunuke - 1] = 1;
			j++;
		}
		i++;
	}

	int itazura = 0;
	i = 0;
	while(i < N){
		if(have[i] == 0){
			itazura++;
		}
		i++;
	}
	cout << itazura << endl;
}

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

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

    vector <pair <int, int>> als (n);
    
    for (int i=0; i<n; i++){
        
        cin >> als[i].first;
        
        als[i].second=i+1;
    }
    
    sort (als.begin(), als.end());
    
    for (int i=0; i<n; i++){
        
        cout << als[i].second << " ";
    }
    
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 1664
S = input()
N = len(S)
l = (N-1)//2
r = (N+3)//2
if S[:l]==S[:l][::-1] and S[r-1:]==S[r-1:][::-1]:
    if S==S[::-1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int d;
	cin >> d;
	if (d == 25) cout << "Christmas" << endl;
	else if (d == 24) cout << "Christmas Eve" << endl;
	else if (d == 23) cout << "Christmas Eve Eve" << endl;
	else cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define MOD 1000000007

using namespace std;

ll store[2005][2005];
ll form[2005][2005];

ll get(ll i, ll j, ll a[], ll b[])
{
    if(i<0 || j<0)
        return 0;
    if(form[i][j]!=-1)
        return form[i][j];
    ll ans = 0;
    if(a[i]!=b[j])
        store[i][j] = 0;
    else store[i][j] = 1 + get(i-1,j-1,a,b), store[i][j]%=MOD;
    form[i][j] = (store[i][j] + get(i,j-1,a,b) + get(i-1,j,a,b) - get(i-1,j-1,a,b)), form[i][j]%=MOD;
    if(form[i][j]<0)    
        form[i][j]+=MOD;
    return form[i][j];
    //return store[i][j] = (1 + 2*get(i-1,j-1,a,b));
}

int main()
{
   FAST/**/
   
   ll n,m;
   cin>>n>>m;
   
   ll arr[n], arr1[m];
   for(ll i=0;i<n;i++)
        cin>>arr[i];
   for(ll j=0;j<m;j++)
        cin>>arr1[j];
   
   memset(store,-1,sizeof(store));
   memset(form,-1,sizeof(form));
   
   ll ans = 0;
   
   for(ll i=0;i<n;i++)
        for(ll j=0;j<m;j++)
        {
            get(i,j,arr,arr1);
            ans+=store[i][j];
            //cout<<"at "<<i+1<<" and "<<j+1<<" val = "<<store[i][j]<<"\n";
            ans%=MOD;
        }
            
   cout<<(ans+1)%MOD;
   
   return 0;
}

Measured memory_bytes: 63104
#include<iostream>
using namespace std;
int N,M;
int W[100][100],p[50][50];
int get(int i,int j,int r)
{
	return r==0?p[i][j]:r==1?p[j][M-i-1]:r==2?p[M-i-1][M-j-1]:p[M-j-1][i];
}
main()
{
	while(cin>>N>>M,N)
	{
		for(int i=0;i<N;i++)for(int j=0;j<N;j++)cin>>W[i][j];
		for(int i=0;i<M;i++)for(int j=0;j<M;j++)cin>>p[i][j];
		int ansx=N,ansy=N;
		for(int i=0;i<=N-M;i++)for(int j=0;j<=N-M;j++)
		{
			for(int r=0;r<4;r++)
			{
				bool now=true;
				int x=-1,y=-1;
				for(int I=0;now&&I<M;I++)for(int J=0;J<M;J++)
				{
					int a=W[i+I][j+J],b=get(I,J,r);
					if(b>=0&&b!=a)
					{
						now=false;
						break;
					}
					if(b>=0&&x<0)x=i+I,y=j+J;
				}
				if(now)
				{
					if(ansx>x||ansx==x&&ansy>y)ansx=x,ansy=y;
				}
			}
		}
		if(ansx==N)cout<<"NA"<<endl;
		else cout<<ansy+1<<" "<<ansx+1<<endl;
	}
}



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

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    if (A + K - 1 < B - K + 1)
    {
        for (int i = A; i <= A + K - 1; i++)
        {
            cout << i << endl;
        }
        for (int i = B - K + 1; i <= B; i++)
        {

            cout << i << endl;
        }
    }
    else
    {
        for (int i = A; i <= B; i++)
        {
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

//Convenient Location
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[][] c = new int[10][10];
			for(int[]a:c)Arrays.fill(a, 1<<25);
			for(int i=0;i<10;i++)c[i][i]=0;
			int max = 0;
			while(n--!=0){
				int s = sc.nextInt();
				int t = sc.nextInt();
				int d = sc.nextInt();
				c[s][t]=c[t][s]=Math.min(c[s][t], d);
				max = Math.max(max, Math.max(s, t));
			}
			for(int k=0;k<10;k++)for(int i=0;i<10;i++)for(int j=0;j<10;j++)c[i][j]=Math.min(c[i][j], c[i][k]+c[k][j]);
			int k = 0;
			int w = 1<<25;
			for(int i=0;i<10;i++){
				int s = 0;
				for(int j=0;j<=max;j++)s+=c[i][j];
				if(s<w){
					k = i;
					w = s;
				}
			}
			System.out.println(k+" "+w);
		}
	}
}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.Scanner;


class ABC implements Comparable<ABC>{
	int a;
	int b;

	public ABC(int a, int b){
		this.a = a;
		this.b = b;
	}

	public int compareTo(ABC abc) {
		//降順なら上１，下−１
        //昇順なら上−１，下１
        if (this.b < abc.b) return -1;
        if (this.b > abc.b) return 1;
        return 0;
	}


}


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

		int n = stdIn.nextInt();
		ABC [] abc = new ABC[n];

		for(int i = 0; i < n; i++) {
			abc[i] = new ABC(stdIn.nextInt(),stdIn.nextInt());
		}

		Arrays.sort(abc);

		
		long cnt = 0;
		
		for(int i = 0; i < n; i++) {
			if(cnt + abc[i].a <= abc[i].b) {
				cnt += abc[i].a;
				continue;
			}else {
				System.out.println("No");
				return;
			}
		}
		
		System.out.println("Yes");



	}

}

/*
class Pair implements Comparable<Pair>{
    //firstが検索対象
    public int first;
    public int second;
    Pair(int a, int b) {
        this.first = a;
        this.second = b;
    }

    public int compareTo(Pair pair) {
        //降順なら上１，下−１
        //昇順なら上−１，下１
        if (this.first < pair.first) return 1;
        if (this.first > pair.first) return -1;
        return 0;
    }
}


*/

Measured memory_bytes: 103528
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int ans[100010];
struct UnionFind {
	vector<int> par;
	UnionFind(int x) : par(x, -1) {}
	void init(int x) { par.assign(x, -1); }
	int root(int x) {
		if (par[x] <= -1) return x;
		else return 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)];
	}
};
vector<int> P[100010];

int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	UnionFind G(N);
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		A--;B--;
		P[A].push_back(B);
		P[B].push_back(A);
		G.merge(A, B);
	}
	for (int i = 0; i < N; i++) {
		ans[i] = G.size(i) - P[i].size() - 1;
	}
	for (int i = 0; i < K; i++) {
		int C, D;
		cin >> C >> D;
		C--; D--;
		if (G.issame(C, D)) {
			ans[C]--;
			ans[D]--;
		}
	}
	for (int i = 0; i < N; i++) {
		cout << ans[i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 7416
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




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


  ll N ;cin >> N ;
  vector<ll> L ;
  
  rep(i,N*2){
    ll inp; cin >> inp;
    L.pb(inp);
  }

  sort(rall(L));

  ll ans = 0;
  rep(i,2*N){
    if(i%2 == 1) ans += L[i] ;
  }
  cout << ans << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
// AOJ 1175: And Then. How Many Are There?
// 2017.12.21 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

typedef struct { int s, del, m; } Q;
Q q[10000]; int top;
typedef struct { int x, y, r; } T;
T d[25];
int col[4][6], clen[4]; char f[5];
int up[25][25], ulen[25];		// ?????????????????????????????°??¨??????
char visited[16777216];

int main()
{
	int n, i, j, k, a, c, cmax, l, p, r, s, del, m, ans;

	while (scanf("%d", &n) && n > 0) {
		memset(clen, 0, sizeof(clen)), memset(f, -1, sizeof(f)), cmax = 0;
		for (i = 0; i < n; i++) {
			scanf("%d%d%d%d", &d[i].x, &d[i].y, &d[i].r, &c);
			if  (f[c] >= 0)          c = f[c];
			else f[c] = cmax++, c = cmax-1;

			col[c][clen[c]++] = i;
		}

		memset(ulen, 0, sizeof(ulen));
		for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
			if (hypot(d[i].x-d[j].x, d[i].y-d[j].y) < d[i].r+d[j].r) up[j][ulen[j]++] = i;
		}

		ans = 0;
		memset(visited, 0, 1 << n);
		q[0].s = 0, q[0].del = 0, q[0].m = n, top = 1;
		while (top) {
			s = q[--top].s, del = q[top].del, m = q[top].m;

			if (m == 1 || visited[s]) continue;
			visited[s] = 1;
			for (c = 0; c < cmax; c++)if ((l = clen[c]) >= 2) for (p = 0; p < l; p++) {
				i = col[c][p];
				if (s & (1<<i)) continue;
				for (k = 0; k < ulen[i]; k++) {
					a = up[i][k];
					if (!(s & (1<<a))) goto next;
				}

				for (r = p+1; r < l; r++) {
					j = col[c][r];
					if (s & (1<<j)) continue;
					for (k = 0; ; k++) {
						if (k == ulen[j]) {
							if (del+2 > ans) ans = del+2;
							q[top].s = s|(1<<i) | (1<<j), q[top].del = del+2, q[top++].m = m-2;
							break;
						}
						a = up[j][k];
						if (!(s & (1<<a))) break;
					}
				}
				next:;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 18240
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s1,s2;
  cin >> s1;
  cin >> s2;

  auto f
    = [&]{
        auto i = s1.begin();
        auto j = s2.rbegin();
        for(; i != s1.end(); ++i,++j){
          if (*i != *j){
            return false;
          }
        }
        return true;
      };
  cout << (f() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
    int n,m;
    cin >> n >> m;
    LL ans;
    if (max(n,m)-min(n,m) > 1) {
        cout << 0 << endl;
        return 0;
    }
    if (n == m) {
        ans = 2;
    } else {
        ans = 1;
    }
    REP(i,1,n+1) ans = (ans * i) % 1000000007;
    REP(i,1,m+1) ans = (ans * i) % 1000000007;
    cout << ans << endl;

    return 0;
}

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

int main () {
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> x(N), y(N), a(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  int b = 0; int c = W; int d = 0; int e = H;
  for (int i = 0; i < N; i++) {
    if (a.at(i) == 1) {
      if (x.at(i) > b) {
        b = x.at(i);
      }
    }
    else if (a.at(i) == 2) {
      if (x.at(i) < c) {
        c = x.at(i);
      }
    }
    else if (a.at(i) == 3) {
      if (y.at(i) > d) {
        d = y.at(i);
      }
    }
    else {
      if (y.at(i) < e) {
        e = y.at(i);
      }
    }
  }
  if (c-b < 0 || e-d < 0) cout << 0 << endl;
  else cout << (c-b)*(e-d) << endl;
}


Measured memory_bytes: 256
#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 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<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int A,B,C,N; cin >> A >> B >> C >> N;
	int ans = 0;
	rep(a,N+1) rep(b,N+1){
		int c = N-a*A-b*B;
		if(0<=c && c%C == 0) ans++;
	}
	cout << ans << endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        var age = int.Parse(Console.ReadLine());

        if ((age == 3) || (age == 5) || (age == 7))
        {
            Console.WriteLine("YES");
        }else
        {
            Console.WriteLine("NO");
        }
        
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int A, B, C;
    cin >> A >> B >> C;
    int K; cin >> K;

    int i = 0;
    while(i <= K) {
        if (A >= B) {
            B *= 2;
        } else if (B >= C) {
            C *= 2;
        } else {
            OUT("Yes")
            return 0;
        }
        i++;
    }

    OUT("No")

    return 0;
}

Measured memory_bytes: 3636
N = gets.strip.to_i
mochis = []
(0..(N-1)).each do |i|
  mochi = gets.strip.to_i
  mochis.push(mochi)
end
(0..(N-1)).each do |i|
  (i..(N-1)).each do |j|
    mochis[i], mochis[j] = mochis[j], mochis[i] if mochis[i] < mochis[j]
  end
end
mochis.uniq!
puts mochis.size

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define ld long double
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main() {
  ll X;
  cin >> X;

  ll current = 100;

  ll y = 0;
  while (current < X) {
    y++;
    current *= 1.01;
  }

  cout << y << endl;
  return 0;
}

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

void trace(int A[], int N){
    int i;
    for(i=0; i<N; i++){
        if(i>0) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[], int N){
    int j,i,v;
    for(i=1; i<N; i++){
        v = A[i];
        j = i-1;
        while(j>=0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

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

Measured memory_bytes: 3076
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//221
	string a,b;
	cin>>a>>b;
	unordered_map<char,char> m,n;
	REP(i,0,(int)a.length()-1) {
		if(m.count(a[i])==1||n.count(b[i])==1) {
			if(m[a[i]]!=b[i]||n[b[i]]!=a[i]) {
				cout<<"No";
				return;
			}
		} else {
			m[a[i]]=b[i];
			n[b[i]]=a[i];
		}
	}
	cout<<"Yes";
	
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define fr(i,a,n) for( i=a;i<=n;i++)
#define rf(i,n,a) for( i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pp(a,b) pb(mp(a,b))
#define fi first
#define se second
#define ll long long
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a))
#define cl(a) mem(a,0)
#define all(x) x.begin(),x.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std; 



int main() {
	fastio
	string s;
	cin >> s;
	int n = s.length(), i;
	int f[n] = {0}, cur = 0;
	i = n-1;
	while(i > 0){
	    f[i] = cur;
	    if(s[i] == 'C' and s[i-1] == 'B')cur++, i-=2;
	    else if(s[i] == 'A')i--;
	    else cur = 0, i--;
	}
	f[0] = cur;
	ll tot = 0;
	fr(i, 0, n-1)if(s[i] == 'A')tot += f[i];
	
	cout << tot;
	
	return 0;
}


Measured memory_bytes: 1300
#include<stdio.h>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
const int N=10000516;
struct thh{
	int a,b,ma[2],id[2];
}tree[N];
struct lh{
	int l,r,t,it;
};
bool operator<(lh x,lh y)
{
	return x.t<y.t;
}
priority_queue<lh>q;
int v[N],n,w[N];
void update(int p)
{
	int ls=p<<1,rs=p<<1|1;
	if(tree[ls].ma[1]>tree[rs].ma[1])
	{
		tree[p].ma[1]=tree[ls].ma[1];
		tree[p].id[1]=tree[ls].id[1];
	}
	else 
	{
		tree[p].ma[1]=tree[rs].ma[1];
		tree[p].id[1]=tree[rs].id[1];
	}
	if(tree[ls].ma[0]>tree[rs].ma[0])
	{
		tree[p].ma[0]=tree[ls].ma[0];
		tree[p].id[0]=tree[ls].id[0];
	}
	else 
	{
		tree[p].ma[0]=tree[rs].ma[0];
		tree[p].id[0]=tree[rs].id[0];
	}
}
void bt(int p,int x,int y)
{
	tree[p].a=x;tree[p].b=y;
	if(x==y)
	{
		if(x&1)tree[p].ma[1]=v[x],tree[p].id[1]=x;
		else tree[p].ma[0]=v[x],tree[p].id[0]=x;
		return;
	}
	int mid=x+y>>1;
	bt(p<<1,x,mid);bt(p<<1|1,mid+1,y);
	update(p);
}
int getmax(int p,int x,int y,int k)
{
	if(tree[p].a>=x&&tree[p].b<=y)return tree[p].id[k];
	int ls=p<<1,rs=p<<1|1;
	int t1=0,t2=0;
	if(tree[ls].b>=x&&tree[ls].a<=y)t1=getmax(ls,x,y,k);
	if(tree[rs].b>=x&&tree[rs].a<=y)t2=getmax(rs,x,y,k);
	if(v[t1]>v[t2])return t1;
	else return t2;
}
main()
{
	int i,j,k,x,y,z;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&w[i]);
	for(i=1;i<=n;i++)v[i]=n+1-w[i];
	bt(1,1,n);
	lh tmp;tmp.l=1;tmp.r=n;tmp.it=getmax(1,1,n,1);tmp.t=v[tmp.it];
	q.push(tmp);
	while(q.size())
	{
		lh node=q.top();
		q.pop();x=node.it;
		int a=node.l,b=node.r;
		if(a&1)k=0;else k=1;
		y=getmax(1,x+1,b,k);
		printf("%d %d ",w[x],w[y]);
		k^=1;
		if(a==b-1)continue;
		//
		int l1,r1;
		//
		l1=a,r1=x-1;
		if(l1<r1)
		{
			tmp.l=l1,tmp.r=r1,tmp.it=getmax(1,l1,r1,k);
			tmp.t=v[tmp.it];q.push(tmp);
		}
		l1=x+1;r1=y-1;
		if(l1<r1)
		{
			tmp.l=l1,tmp.r=r1,tmp.it=getmax(1,l1,r1,k^1);
			tmp.t=v[tmp.it];q.push(tmp);
		}
		l1=y+1,r1=b;
		if(l1<r1)
		{
			tmp.l=l1,tmp.r=r1,tmp.it=getmax(1,l1,r1,k);
			tmp.t=v[tmp.it];q.push(tmp);
		}
	}	
}

Measured memory_bytes: 19444
#include <stdio.h>

int main()
{
  int a , N, i, flag = 1, n = 0;
  int A[100] = {0};
  
  scanf("%d", &N);
  
  for (i = 0; i < N; i++){
    scanf("%d", &A[i]);
  }
  
  while (flag) {
    flag = 0;
    for (i = N - 1; i > 0; i--) {
      if (A[i] < A[i-1]) {
        a = A[i];
        A[i] = A[i-1];
        A[i-1] = a;
        flag = 1;
        n++;
      }
    }
  }
  
  for (i = 0; i < N - 1; i++) {
    printf("%d ", A[i]);
  }
  printf("%d\n", A[i]);

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

Measured memory_bytes: 600
n, p = map(int, input().split())
s = list(reversed(list(map(int, input()))))
if p == 2:
    ans = 0
    s = list(reversed(s))
    for i in range(n):
        if s[i] % 2 == 0:
            ans += i + 1
    print(ans)
    exit()
if p == 5:
    ans = 0
    s = list(reversed(s))
    for i in range(n):
        if s[i] % 5 == 0:
            ans += i + 1
    print(ans)
    exit()
cur = 1
c = [0] * (n + 1)
ans = 0
t = [0] * p
t[c[0]] += 1
for i in range(n):
    c[i + 1] = (c[i] + cur * s[i]) % p
    ans += t[c[i + 1]]
    t[c[i + 1]] += 1
    cur = cur * 10 % p
print(ans)


Measured memory_bytes: 49612
require 'matrix'

p0x, p0y, p1x, p1y = gets.split.map &:to_i
p0 = Vector[p0x, p0y]
p1 = Vector[p1x, p1y]

q = gets.to_i

def cross(p1, p2)
  return p1[0] * p2[1] - p1[1] * p2[0]
end

q.times do
  p2x, p2y = gets.split.map &:to_i
  p2 = Vector[p2x, p2y]
  if cross(p2-p1, p0-p1) > 0
    puts "COUNTER_CLOCKWISE"
  elsif cross(p2-p1, p0-p1) < 0
    puts "CLOCKWISE"
  elsif (p0-p1).inner_product(p2-p1) < 0
    puts "ONLINE_FRONT"
  elsif (p0-p1).norm >= (p2-p1).norm
    puts "ON_SEGMENT"
  else
    puts "ONLINE_BACK"
  end
end

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if(max(x-a, a-x) < max(x-b, b-x)){
        cout << "A" << endl;
    }else{
        cout << "B" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;
 
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 7;

ll n, k, r, s, p, ans;
string t;
 
int main()
{
	speed;
	cin >> n >> k >> r >> s >> p >> t;
	string a(n, '.');
	forn( i, n ) {
		if ( i < k ) {
			if ( t[i] == 'r' ) {
				ans += p;
				a[i] = 'p';
			}
			else if ( t[i] == 'p' ) {
				ans += s;
				a[i] = 's';
			}
			else {
				ans += r;
				a[i] = 'r';
			}
		}
		else {
			char need;
			ll b = 0;
			if ( t[i] == 'r' ) {
				need = 'p';
				b = p;
			}
			else if ( t[i] == 'p' ) {
				need = 's';
				b = s;
			}
			else {
				need = 'r';
				b = r;
			}
			if ( a[i - k] == need ) continue;
			a[i] = need;
			ans += b;
		}
	}
	cout << ans << endl;
	time;
}

Measured memory_bytes: 640