akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    ll N, W;
    cin >> N >> W;
    struct Item {
        ll w;
        ll v;
    };
    vector<Item> items(N);
    rep(i,0,N) {
        cin >> items[i].w >> items[i].v;
    }
    ll w_base = items[0].w;
    auto dp = make_vec_nd(numeric_limits<ll>::min(), 2, N+1, 3*N+1);
    dp[0][0][0] = 0;
    rep(n,1,N+1) {
        rep(m,0,n+1) {
            rep(w,0,3*N+1) {
                if (!(m * w_base + w <= W)) {
                    continue;
                }
                dp[n%2][m][w] = dp[(n-1)%2][m][w];
                ll w_off = items[n-1].w - items[0].w;
                if (m >= 1 && w >= w_off) {
                    dp[n%2][m][w] = max(dp[n%2][m][w], dp[(n-1)%2][m-1][w-w_off] + items[n-1].v);
                }
            }
        }
    }
    ll ans = numeric_limits<ll>::min();
    rep(m,0,N+1) {
        rep(w,0,3*N+1) {
            ans = max(ans, dp[N%2][m][w]);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	char ss;
	int ans = 0;

	for (int i = 0; i < (int)s.size(); ++i) {
		char ch = s[i];
		if (i == 0) ss = ch;
		else {
			if (ch == ss);
			else ans = 1;
		}
	}
	if (ans == 0) {
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	ll i,o,t,j,l,s,z,k=0;
	cin >> i >> o >> t >> j >> l >> s >> z;
	k = ((i/2)+(j/2)+(l/2))*2;
	if(i&&j&&l){
		--i; --j; --l;
		k = max(k,((i/2)+(j/2)+(l/2))*2+3);
	}
	k += o;
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List

solve :: String -> Bool
solve s = x * x + y * y == z * z
    where ns = sort $ map read (words s)
          x  = ns !! 0
          y  = ns !! 1
          z  = ns !! 2

main :: IO ()
main = do
    n     <- readLn
    lines <- replicateM n getLine
    mapM_ (putStrLn . (\l -> if solve l then "YES" else "NO")) lines

Measured memory_bytes: 4460
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	ull mod = pow(10, 9) + 7;
	
	uint N;
	cin >> N;

	vector<uint> bcnt(60);
	
	for(uint i=0; i<N; i++) {
		ull A;
		cin >> A;
	
		uint l = 0;
		while(A > 0) {
			bcnt[l++] += A & 1;
			A /= 2;
		}
	}
	
	ull ans = 0;
	ull uni = 1;
	for(uint i=0; i<60; i++) {
		ans = (((((uni % mod) * bcnt[i]) % mod) * (N - bcnt[i])) + ans) % mod;
		uni *= 2;
	}
	
	cout << ans % mod;
	return 0;
}


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

using namespace std;

vector<int>li[1001];
bool vis[1001];
bool rec[1001];

int par[1001];

int n,m;

vector<pair<int,vector<int> > >possible;

void dfs(int v){

    vis[v]=true;
    rec[v]=true;

    for(auto e:li[v]){
        if(rec[e]){
            
            
            vector<int>ans;

            ans.push_back(e);

            int curr=v;
            
            while(curr!=e){
                
                ans.push_back(curr);
                curr=par[curr];
            }

            

            possible.push_back({(int)ans.size(),ans});

        }

        if(!vis[e]){
            par[e]=v;
            dfs(e);
        }
    }

    rec[v]=false;
}

int main() {
   
   cin>>n>>m;
   
   for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;

        li[a].push_back(b);
   
   }
   
   for(int i=1;i<=n;i++)
    sort(li[i].begin(),li[i].end());

   for(int i=1;i<=n;i++){

        if(!vis[i]){
            
            par[i]=-1;
            
            dfs(i);

        }

   }
    
    
  
   if(possible.empty())
   cout<<-1;
   else{
       sort(possible.begin(),possible.end());
       
       cout<<possible[0].first<<"\n";
       
       for(auto e:possible[0].second){
           cout<<e<<"\n";
       }
   }

   
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);

        var nums = Console.ReadLine().Split(' ')
            .Select(x => int.Parse(x))
            .ToList();
        var avel = nums.Select(x => (x + 1) / 2.0).ToList();
        double ans = 0.0;
        double res = 0.0;

        for (var i = 0; n > i; i++)
        {
            if (i < k)
            {
                res += avel[i];
                ans = res;
            }
            else
            {
                res -= avel[i - k];
                res += avel[i];
                if (ans < res) ans = res;
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 34012
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long int64;
const int M = 998244353;
const int N = (int) 4e5 + 10;

int fact[N], ifact[N];

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

int mult(int a, int b) {
	return (a * (int64) b) % M;
}

int bpow(int x, int y) {
	if (y == 0) {
		return 1;
	}
	int res = bpow(mult(x, x), y / 2);
	if (y % 2 == 1) {
		res = mult(res, x);
	}
	return res;
}

int inv(int x) {
	return bpow(x, M - 2);
}

int cnk(int n, int k) {
	return mult(fact[n], mult(ifact[k], ifact[n - k]));
}

int main() {
	int n, a, b;
	int64 k;
	scanf("%d%d%d%lld", &n, &a, &b, &k);
	fact[0] = ifact[0] = 1;
	for (int i = 0; i < n; ++i) {
		fact[i + 1] = mult(fact[i], i + 1);
		ifact[i + 1] = inv(fact[i + 1]);
	}
	int64 g = gcd(a, b);
	if (k % g != 0) {
		printf("%d\n", 0);
		return 0;
	}
	k /= g, a /= g, b /= g;
	int64 base_x = 0;
	for (int x = 0; x < b; ++x) {
		if ((k - x * (int64) a) % b == 0) {
			base_x = x;
			break;
		}
	}
	int ans = 0;
	while (base_x <= n) {
		int64 base_y = (k - base_x * (int64) a) / b;
		if ((base_y >= 0) && (base_y <= n)) {
			ans = (ans + cnk(n, base_x) * (int64) cnk(n, base_y)) % M;
		}
		base_x += b;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2560
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi

putsend 0 if n%2==1

l=n.to_s.length
cnt=0

# 1.upto(l) do |i|
#   d = n/(10**i)
#   cnt+=d
# end

#50の倍数
num=10
c5=0
while num<n do
  c5+=1
  num*=5
end

1.upto(c5) do |i|
  d = n/((5**i)*10)
  #puts d
  cnt+=d
end

puts cnt + n/10

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  str flag = "FESTIVAL", s; cin >> s;
  rep(i, s.size() - flag.size())
  {
    cout<<s[i];
  }
  cout<<endl;
  return;
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N_MAX 2010

int main()
{
    int n, x, y;
    int k[N_MAX] = {};
    scanf("%d%d%d", &n,&x,&y);
    
    for ( int i=0; i<n-1; i++ ){
        for ( int j=i+1; j<n; j++ ){
            
            if ( i <= x-1 && y-1 <= j )   k[((x-1)-i) + (j-(y-1)) + 1]++;
            else {
                if ( abs(x-1-i) + abs(y-1-j) + 1 < j-i ){
                    k[abs(x-1-i) + abs(y-1-j) + 1]++;
                }
                else {
                    k[j-i]++;
                }
            }
        }
    }
    for ( int i=1; i<n; i++ ) printf("%d\n",k[i]);
}


Measured memory_bytes: 128
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[][] s = new int[m][n];
        for(int i = 0; i < m; i++){
            int k = scanner.nextInt();
            for(int j = 0; j < k; j++){
                int tmp = scanner.nextInt();
                s[i][tmp-1]++;
            }
        }
        int[] p = new int[m];
        for(int i = 0; i < m; i++){
            p[i] = scanner.nextInt();
        }
        int total = 0;
        for(int i = 0; i < Math.pow(2,n); i++){
            int[] ans = new int[m];
            for(int j = 0; j < n; j++){
                if ((1&i>>j) == 1) {
                    int index = 0;
                    for(int l = 0; l < m; l++){
                        ans[l] += s[l][j];
                    }
                }
            }
            int count = 0;
            for(int l = 0; l < m; l++){
                //System.out.print(ans[l]);
                if(ans[l]%2 == p[l]){count++;}
            }
            if(count == m){total++;}
        }
        System.out.println(total);
    }
}

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


UL K, N, Q;

struct RMQ {
	UL N;
	vector<pair<UL, UL>> V;
	static pair<UL, UL> F(pair<UL, UL> l, pair<UL, UL> r) {
		if (l.second) r.first = K - r.first;
		return { (l.first + r.first) % K, l.second ^ r.second };
	}
	void init() {
		N = 1; while (N < ::N) N <<= 1;
		V.resize(N * 2 - 1);
		rep(i, ::N) {
			int a; scanf("%d", &a);
			if (a > 0) V[N - 1 + i] = { (K - a % K) % K, 0 };
			else if (a < 0) V[N - 1 + i] = { (-a) % K, 0 };
			else V[N - 1 + i] = { 0, 1 };
		}
		for (UL i = N - 2; i != ~0u; i--) {
			V[i] = F(V[(i << 1) + 1], V[(i << 1) + 2]);
		}
	}
	void upd(UL p, pair<UL, UL> v) {
		UL i = p + N - 1;
		V[i] = v;
		while (i) {
			i = (i - 1) >> 1;
			V[i] = F(V[(i << 1) + 1], V[(i << 1) + 2]);
		}
	}
	void swap(UL a, UL b) {
		pair<UL, UL> buf = V[N - 1 + b];
		upd(b, V[N - 1 + a]);
		upd(a, buf);
	}
	int query() {
		return (int)(V[0].first + 1) * (V[0].second ? -1 : 1);
	}

} G;

int main() {
	scanf("%u%u%u", &K, &N, &Q);
	G.init();
	rep(i, Q) {
		UL a, b; scanf("%u%u", &a, &b); a--; b--;
		G.swap(a, b);
		printf("%d\n", G.query());
	}
	return 0;
}



Measured memory_bytes: 4956
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n";
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=1e6+10;
int ans[N];
int a[200003];
int mp[N];
int32_t main()
{
	IOS;
	int n;
	cin>>n;

	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		mp[a[i]]++;

	}
	for(int i=1;i<=1000000;i++)
	{
		for(int j=1;j*i<=1000000;j++)
		{
			ans[i*j]+=mp[i];
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		//cout<<ans[a[i]]<<" ";
		if(ans[a[i]]==1)
			cnt++;
	}
	//cout<<endl;
	cout<<cnt<<endl;
	
}

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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N, tmp;
    cin >> N;
    vector<int> list(N);
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        list[tmp - 1] = i + 1;
    }
    for (int i : list)
        cout << i << " ";
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a < c && b > c) {
        cout << "Yes" << endl;
    } else if (a > c && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define LL long long
using namespace std;

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

  int t[n];

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

  int m;
  cin >> m;

  int drink[m][2];

  for (int i=0; i<m; i++) {
    cin >> drink[i][0];
    cin >> drink[i][1];
  }

  int output = 0;
  for (int i=0; i<m; i++) {
    for (int j=0; j<n; j++) {
      if (j+1 == drink[i][0]) {
        output += drink[i][1];
      } else {
        output += t[j];
      }
    }
    cout << output << endl;
    output = 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;
void solve(long long N, std::vector<long long> X){
    vector<pll> px(N);
    rep(i, N){
        px[i].first = X[i];
        px[i].second = i;
    }
    sort(px.begin(), px.end());
    reverse(px.begin(), px.end());
    vll rec(N, 0);
    rep(i, N){
        ll j = px[i].second;
        rec[j] = i;
    }
    if(N%2) { //* N is odd
        rep(i, N){
            if(rec[i] < N/2){
                cout << px[N/2].first << endl;
            }
            else if( rec[i]== N/2){
                cout << px[N/2-1].first << endl;
            }
            else{
                cout << px[N/2-1].first << endl;
            }
        }
    }
    else {
        if(N == 2){
            cout << X[1] << endl << X[0] << endl;
        }
        else{
            rep(i, N){ //* N is even
                if(rec[i] <= N/2-1){
                    cout << px[N/2].first << endl;
                }
                else{
                    cout << px[N/2-1].first << endl;
                }
            }
        }
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
// chctxdy
ll mod = 998244353;
ll n;
pll p[200000];
bool hit(ll i, ll j){
	return p[i].fi + p[i].se > p[j].fi;
}
ll ret(ll start, ll &end){
	ll prd = 1;
	ll cur = start + 1;
	while (cur < n && hit(start, cur)){
		ll next;
		ll res = ret(cur, next);
		(prd *= res) %= mod;
		cur = next;
	}
	end = cur; 
	return (prd + 1) % mod;
}
int main(){
	cin >> n;
	for (ll i = 0; i<n; i++) cin >> p[i].fi >> p[i].se;
	sort(p, p + n);
	ll prd = 1;
	ll cur = 0;
	while (cur < n){
		ll next;
		ll res = ret(cur, next);
		(prd *= res) %= mod;
		cur = next;
	}
	cout << prd << endl;
} 


Measured memory_bytes: 12800
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<random>
#include<ctime>
#include<cstdlib>
#include<unordered_map>
#include<string.h>
#include<iostream>
#define int long long
#define P pair<int,int>//xまでの距離がy
using namespace std;

int sum;
int t[100000];//種類
bool used[100000];
int k[100000];
int l[200000], r[200000], d[200000];
vector<P>V[100000];
void saiki(int s) {
	t[s] = sum;
	for (P i : V[s]) {
		if (k[i.first] <= 10000000000ll) {
			if (k[s] + i.second == k[i.first]) {
				continue;
			}
			else {
				puts("No");
				exit(0);
			}
		}
		else {
			k[i.first] = k[s] + i.second;
			saiki(i.first);
		}
	}
}
signed main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> l[i] >> r[i] >> d[i];
		l[i]--; r[i]--;
		V[l[i]].push_back({ r[i], d[i] });
		V[r[i]].push_back({ l[i], -d[i] });
	}
	memset(k, 0x3f, sizeof(k));
	memset(t, -1, sizeof(t));
	for (int i = 0; i < n; i++) {
		if (k[i] >= 10000000000ll) {
			k[i] = 0;
			saiki(i);
			sum++;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 22016
#include <stdio.h>

void branch(int w, int h, int x, int y, int r) {
    if (x - r < 0 || w < x + r) {
	printf("No\n");
    } else {
        if (y - r < 0 || h < y + r) {
	    printf("No\n");
	} else {
	    printf("Yes\n");
	}
    }
}

int main(void) {
    int w, h, x, y, r;

    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    branch(w, h, x, y, r);
    
    return 0;
}


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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

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

	int n,k;
	cin>>n>>k;

	if(n >=10){
		writeln(k);
	}else {
		cout<<k+100*(10-n)<<endl;
	}

}


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

int main(){
  int E,Y;
  cin >> E >> Y;
  if(E==0){
    if(Y>=1868&&Y<=1911)
      cout << "M" << Y-1867 << endl;
    else if(Y>=1912&&Y<=1925)
      cout << "T" << Y-1911 << endl;
    else if(Y>=1926&&Y<=1988)
      cout << "S" << Y-1925 << endl;
    else if(Y>=1989&&Y<=2016)
      cout << "H" << Y-1988 << endl;
  }
  else if(E==1)
    cout << Y+1867 << endl;
  else if(E==2)
    cout << Y+1911 << endl;
  else if(E==3)
    cout << Y+1925 << endl;
  else if(E==4)
    cout << Y+1988 << endl;

  return 0;
}



Measured memory_bytes: 3100
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let s = readLine()!.toArray()
var ans = [String]()
for c in s {
    if c == "B" {
        if ans.count > 0 {
            ans.removeLast()
        }
    } else {
        ans += [c]
    }
}
print(ans.joinWithSeparator(""))


Measured memory_bytes: 6884
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 2000

int n, ans = 0;
int a[MAX_N];

void dfs(int i, bool bo) {
  if (i == n) {
    if (bo) ans += 1;
  }
  else if (i < n) {
    for (int j = -1; j <= 1; ++j) {
      int t = a[i] + j;
      bool in = bo;
      in |= ((t % 2) == 0);
      dfs(i + 1, in);
    }
  }
  return;
}

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  dfs(0, false);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	char c;
	for(int i = 0; i < n; i++){
		cin >> c;
		if(c == 'Y'){
			cout << "Four" << endl;
			return 0;
		}
	}

	cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int right = sc.nextInt();
        int harf_right = right /2;
        //int[] place;
        //place = new int[num];
        int place;
        int i;
        int count = 0;
        for(i = 0; i < num; i++){
            place = sc.nextInt();
            if(place > harf_right){
                count += (right - place)*2;
            }else{
                count += place*2;
            }
        }
        System.out.print(count);
	}
}

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

#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ll long long int
 
using namespace std;

 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	char ch;
	cin>>ch;
	if(isupper(ch))
	cout<<"A";
	else
	cout<<"a";
	return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <unordered_map>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main() {
  int n;
  cin >> n;
  n++;
  unordered_map<int, int> mp;
  rep(i, n) {
    int k = i;
    for(int j = 2; j <= k; j++) {
      while(k % j == 0) {
        mp[j]++;
        k = k / j;
      }
    }
  }

  int cnt = 0;
  rep(i, n) rep(j, i) rep(k, j) {
    if(mp[i] >= 2 && mp[j] >= 4 && mp[k] >= 4) cnt++;
    if(mp[i] >= 4 && mp[j] >= 2 && mp[k] >= 4) cnt++;
    if(mp[i] >= 4 && mp[j] >= 4 && mp[k] >= 2) cnt++;
  }
  rep(i, n) rep(j, i) {
    if(mp[i] >= 14 && mp[j] >= 4) cnt++;
    if(mp[i] >= 4 && mp[j] >= 14) cnt++;
    if(mp[i] >= 2 && mp[j] >= 24) cnt++;
    if(mp[i] >= 24 && mp[j] >= 2) cnt++;
  }
  rep(i, n) if(mp[i] >= 74) cnt++;

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  int n, w;
  cin >> n >> w;
  vector<pair<int, int>> goods;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    goods.push_back(make_pair(a, b));
  }

  long **dp = new long *[n + 1];
  for (int i = 0; i <= n; i++) {
    dp[i] = new long[w + 1];
  }

  for (int i = 0; i <= w; i++) {
    dp[0][i] = 0;
  }

  for (int i = 1; i <= n; i++) {
    dp[i][0] = 0;
    for (int j = 1; j <= w; j++) {
      long temp = dp[i][j - 1] > dp[i - 1][j] ? dp[i][j - 1] : dp[i - 1][j];

      if (j - goods[i - 1].first >= 0)
        if (dp[i - 1][j - goods[i - 1].first] + goods[i - 1].second > temp)
          temp = dp[i - 1][j - goods[i - 1].first] + goods[i - 1].second;

      dp[i][j] = temp;
    }
  }

  cout << dp[n][w] << endl;

  for (int i = 0; i <= n; i++) {
    delete[] dp[i];
  }
  delete[] dp;

  return 0;
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> m >> n;
    int k=sqrt(n);
    vector<bool> ju(k,false);
    vector<long long> da(0);
    long long ki=2,co=-1;
    while(ki<k+1){
        if(n%ki==0){
            n/=ki;
            if(ju[ki]){
                da[co]++;
            }
            else{
                co++;
                da.push_back(1);
                ju[ki]=true;
            }
        }
        else{
            ki++;
        }
        //cout << n << endl;
    }
    co++;
    long long ans=1;
    for(int i=0;i<co;i++){
        long long si=da[i];
        vector<vector<long long>> dp(m+1,vector<long long>(si+1,0));
        dp[0][0]=1;
        for(int j=1;j<m+1;j++){
            for(int k=0;k<si+1;k++){
                for(int l=0;l<k+1;l++){
                    dp[j][k]=(dp[j-1][l]+dp[j][k])%1000000007;
                }
            }
        }
        //cout << dp[m][si] << endl;
        ans=(ans*dp[m][si])%1000000007;
    }
    if (n>1){
        ans=ans*m%1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 27520
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

ll dp[100][2][2][2];

int main() {
  ll N;
  cin >> N;
  ++N;
  vector<int> bit;
  while (N > 0) {
    bit.push_back(N & 1);
    N >>= 1;
  }
  dp[0][0][0][0] = 1;
  for (int i = 0; i < bit.size(); i++) {
    for (int carry = 0; carry < 2; carry++) {
      for (int lessU = 0; lessU < 2; lessU++) {
        for (int lessV = 0; lessV < 2; lessV++) {
          for (int add = 0; add <= 2; add++) {
            ll cur = dp[i][carry][lessU][lessV];
            int u = add & 1;
            int sum = carry + add;
            int v = sum & 1;
            int c = sum >> 1;
            if (lessU && bit[i] != u) {
              continue;
            }
            if (lessV && bit[i] != v) {
              continue;
            }
            (dp[i+1][c][lessU][lessV] += cur) %= MOD;
            if (!lessU && u < bit[i]) {
              (dp[i+1][c][1][lessV] += cur) %= MOD;
            }
            if (!lessV && v < bit[i]) {
              (dp[i+1][c][lessU][1] += cur) %= MOD;
            }
            if (!lessU && u < bit[i] && !lessV && v < bit[i]) {
              (dp[i+1][c][1][1] += cur) %= MOD;
            }
          }
        }
      }
    }
  }
  cout << dp[bit.size()][0][1][1] << endl;
  return 0;
}


Measured memory_bytes: 256
use std::cmp::{max,min, Ordering};
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let a : String = read();
    let b : String = read();
    let ans = if a.len() < b.len() {
        "LESS"
    } else if a.len() > b.len() {
        "GREATER"
    } else {
        match a.cmp(&b) {
            Ordering::Equal => "EQUAL" ,
            Ordering::Less => "LESS",
            Ordering::Greater => "GREATER",
        }
    };
    println!("{}",ans );
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)


ll A_ij[30][30] = {0};


int main(){
	
	ll N,M,X;

	cin>>N>>M>>X;
	vector<ll> rikaido(M);
	vector<ll> c_arr(N);
	

	REP(i,N){
		cin>>c_arr[i];
		REP(j,M){
			cin>>A_ij[i][j];
		}
	}
	

//	REP(i,N){
//		REP(j,M){
//			cout<<A_ij[i][j]<<endl;
//		}
//	}

	ll cost = 0;
	ll min_cost = INF;
	for(int i = 0; i < 1<<N; i++){
		fill(rikaido.begin(),rikaido.end(),0);
		cost = 0;
		//cout<<i<<endl;
		for(int j = 0; j < N; j++){
			//cout<<"ij : "<<((i>>j) & 1)<<endl;
			if( (i>>j & 1) != 0){
				//cout<<"a"<<endl;
				REP(k,M){
					rikaido[k] += A_ij[j][k];
				}
				cost += c_arr[j];
			}
		}
		
		bool flag = true;

		REP(k,M){
			//cout<<"rika : "<<rikaido[k]<<endl;
			flag = (rikaido[k] >= X) && flag;
		}
		if(flag){
			//cout<<"cots"<<cost<<endl;
			min_cost = min(cost,min_cost);
		}
	}
	if(min_cost == INF){
		cout<<-1<<endl;
	}else{
		cout<<min_cost<<endl;
	}
	return 0;
}



Measured memory_bytes: 3632
#include<cstdio>
using namespace std;
#define N 5050
#define mod 1000000007
int n,sz[N],dp[N][N],f[N],head[N],cnt,a,b;
struct edge{int t,next;}ed[N*2];
void adde(int f,int t){ed[++cnt]=(edge){t,head[f]};head[f]=cnt;ed[++cnt]=(edge){f,head[t]};head[t]=cnt;}
void dfs(int u,int fa)
{
	sz[u]=1;dp[u][1]=1;
	for(int i=head[u];i;i=ed[i].next)if(ed[i].t!=fa)
	{
		dfs(ed[i].t,u);
		for(int j=sz[u];j>=1;j--)
		{
			for(int k=1;k<=sz[ed[i].t];k++)
			dp[u][j+k]=(dp[u][j+k]+1ll*dp[u][j]*dp[ed[i].t][k])%mod;
			dp[u][j]=1ll*dp[u][j]*dp[ed[i].t][0]%mod;
		}
		sz[u]+=sz[ed[i].t];
	}
	for(int i=1;i<=sz[u];i++)dp[u][0]=(dp[u][0]-1ll*dp[u][i]*f[i])%mod;
}
int main()
{
	scanf("%d",&n);
	f[0]=1;for(int i=2;i<=n;i+=2)f[i]=1ll*f[i-2]*(i-1)%mod;
	for(int i=1;i<n;i++)scanf("%d%d",&a,&b),adde(a,b);
	dfs(1,0);printf("%d\n",(mod-dp[1][0])%mod);
}//

Measured memory_bytes: 98432
#include <iostream>

using namespace std;

int main(void) {
	string S;
	cin >> S;
	int nob = 0;
	int len = S.length();
	long long res = 0;
	for (int i = 0; i < len; ++i) {
		if (S[i] == 'B') {
			++nob;
		}
		else {
			res += nob;
		}
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;

int main(){
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    int ans = X;
    
    for(int i = 0; i < N; i++){
        int cnt = 0;
        while(A[i] * cnt + 1 <= D){
            ans++;
            cnt++;
        }
    }
    
    cout << ans << endl;
}

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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n;
	map<string, int> cnt;
	cin >> n;
	int ans = 0;
	set<string> st;
	for (int i = 0; i < n; ++i){
		string s;
		cin >> s;
		cnt[s]++;
		ans = max(ans, cnt[s]);
		st.insert(s);
	}
	for (auto it = st.begin(); it != st.end(); ++it){
		if (cnt[*it] == ans){
			cout << *it << "\n";
		}
	}
	return 0;
}



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

int main() 
{
        int a;
        int b;
        int count;

        cin >> a >> b;
        count = 0;
        while (a <= b)
        {
                if (a % 10 == a / 10000 && a / 10 % 10 == a / 1000 % 10)
                        count++;
                a++;
        }
        cout << count << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
P = list(map(int, input().split()))

class UnionFind():
    def __init__(self, N):
        self.nodes = [i for i in range(N)]

    def root(self, x):
        if self.nodes[x] != x:
            self.nodes[x] = self.root(self.nodes[x])
        return self.nodes[x]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        self.nodes[self.root(x)] = self.root(y)

tree = UnionFind(N)
for _ in range(M):
    x, y = map(int, input().split())
    tree.union(x-1, y-1)

ans = 0
for idx, p in enumerate(P):
    if tree.is_same(idx, p-1):
        ans += 1
print(ans)


Measured memory_bytes: 14008
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int sum1 = 0;
  int sum2 = 0;
  for(int i = 0; i < s.length(); ++i){
    if(i%2 == 0){
      if(s[i] == '0') ++sum1;
      else ++sum2;
    }
    else{
      if(s[i] == '1') ++ sum1;
      else ++sum2;
    }
  }
  if(sum1 <= sum2) cout << sum1 << endl;
  else cout << sum2 << endl;
}

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

const int MOD = (int)1e9+7;

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

	vector<bool> prime(1e6,true);
	prime.at(0)=false;
	prime.at(1)=false;
	for(int i=2;i<1e6;i++){
		if(prime.at(i)==false)	continue;
		for(int j=2*i;j<1e6;j+=i){
			prime.at(j)=false;
		}
	}
	for(int i=X;i<1e6;i++){
		if(prime.at(i)){
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
#define X first
#define Y second
signed main(){
  int n;
  while(cin>>n,n){
    vector<P> v(n+1),s(4);
    for(int i=0;i<n;i++) cin>>v[i].X>>v[i].Y;
    for(int i=0;i<4;i++) cin>>s[i].X>>s[i].Y;
    vector<int> cx,cy;
    for(int i=0;i<n;i++) cx.push_back(v[i].X);
    for(int i=0;i<n;i++) cy.push_back(v[i].Y);
    for(int i=0;i<4;i++) cx.push_back(s[i].X);
    for(int i=0;i<4;i++) cy.push_back(s[i].Y);
    
    int INF=30000;
    cx.push_back(INF);cx.push_back(-INF);
    cy.push_back(INF);cy.push_back(-INF);
    sort(cx.begin(),cx.end());
    cx.erase(unique(cx.begin(),cx.end()),cx.end());
    sort(cy.begin(),cy.end());
    cy.erase(unique(cy.begin(),cy.end()),cy.end());
    int w=cx.size(),h=cy.size();
    map<int,int> mx,my;
    for(int i=0;i<w;i++) mx[cx[i]]=i;
    for(int i=0;i<h;i++) my[cy[i]]=i;
    int imos[h][w];
    memset(imos,0,sizeof(imos));

    
    int ax=s[0].X,ay=s[0].Y,ix=s[0].X,iy=s[0].Y;
    for(int i=0;i<4;i++) ax=max(ax,s[i].X);
    for(int i=0;i<4;i++) ay=max(ay,s[i].Y);
    for(int i=0;i<4;i++) ix=min(ix,s[i].X);
    for(int i=0;i<4;i++) iy=min(iy,s[i].Y);

    
    v[n]=v[0];
    for(int i=0;i<n;i++){
      if(v[i].Y<v[i+1].Y){
	for(int j=my[v[i].Y];j<my[v[i+1].Y];j++){
	  imos[j][mx[v[i].X]]--;
	}
      }
      if(v[i].Y>v[i+1].Y){
	for(int j=my[v[i+1].Y];j<my[v[i].Y];j++){
	  imos[j][mx[v[i].X]]++;
	}
      }
    }
    //cout<<w<<" "<<h<<endl;
    int ans=0;
    for(int i=0;i<h-1;i++){
      for(int j=0;j<w-1;j++){
	imos[i][j+1]+=imos[i][j];
	//cout<<imos[i][j];
	if(imos[i][j]){
	  if(iy<=cy[i]&&cy[i+1]<=ay&&ix<=cx[j]&&cx[j+1]<=ax) continue;
	  ans+=(cy[i+1]-cy[i])*(cx[j+1]-cx[j]);
	}
      }
      //cout<<endl;
    }
    cout<<ans<<endl;

  }
  
  return 0;
}

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

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
void Y(){
  fin("YES");
}
void N(){
  fin("NO");
}
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

signed main(){
  int n;cin>>n;
  vector<int> v(n),edge[n];
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=0;i<n-1;i++){
    int a,b;cin>>a>>b;a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  if(n==2){
    if(v[0]==v[1])Y();
    else N();
  }
  int root;
  for(int i=0;i<n;i++)if(edge[i].size()>1)root=i;
  vector<int> parent(n,-1),son[n];
  queue<int> que;que.push(root);
  while(que.size()){
    int p=que.front();que.pop();
    for(int q:edge[p]){
      if(parent[p]==q)continue;
      parent[q]=p;
      son[p].push_back(q);
      que.push(q);
    }
  }
  vector<int> cou(n);
  for(int i=0;i<n;i++)if((cou[i]=son[i].size())==0)que.push(i);
  while(que.size()){
    int p=que.front();que.pop();
    if(son[p].size()==1){
      if(v[p]!=v[son[p][0]])N();
    }
    if(son[p].size()>1){
      int sum=0,mx=0;
      for(int q:son[p]){
        sum+=v[q];
        chmax(mx,v[q]);
      }
      if(sum<v[p])N();
      if(sum>v[p]*2)N();
      int de=(sum-v[p]);
      if(sum-mx<de)N();
      v[p]-=de;
    }
    if(p==root){
      if(v[p])N();
      Y();
    }
    if(--cou[parent[p]]==0)que.push(parent[p]);
  }
}


Measured memory_bytes: 12416
#B問題
import math
R, G, B, N = map(int, input().split())

ans = 0
if R == G == B == 1:
    print (int((N+2)*(N+1)/2))
else:
    for r in range(0, N // R + 1):
        for g in range(0, N // G + 1):
            if (N - R*r - G*g) % B == 0 and (N - R*r - G*g)/B >=0:
                ans += 1
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    int x[n];
    rep(i, n) scanf("%d", &x[i]);
    int ans = mod;
    For(p, 1, 110){
        int tmp = 0;
        rep(i, n) tmp += (x[i]-p) * (x[i]-p);
        chmin(ans, tmp);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
while 1:
    n=int(input())
    if not n:break
    l=[]
    for _ in range(n):
        m=set(map(int,input().split()[1:]))
        l.extend([m])
    o=set(map(int,input().split()[1:]))
    cd=[i+1 for (i,j) in enumerate(l) if j&o==o]
    if len(cd)!=1:
        print("-1")
    else:
        print(cd[0])





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

int calc(int x){
    int ret = 0;
    while(x){
        ret += x % 10;
        x /= 10;
    }
    return ret;
}

int main(){
    cin >> N;
    int ans = 1e9;
    for(int i = 1; i < N; i++){
        int A = i, B = N - i;
        int s = calc(A) + calc(B);
        ans = min(ans, s);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main() {
    double a;
    double d,l;
    cin >> a;
    d = a * a * M_PI;
    l = 2 * a * M_PI;
    printf("%f %f\n", d, l);
	return 0;
}



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

int main(){

  int x,y;
  cin >> x >> y;
  
  int n[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  
  if(n[x]==n[y]){
  	cout << "Yes";
  }else{
  	cout << "No";
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int time, h, m, s;
    cin >> time;//入力されたタイムを受けとる

    h = time/3600;
    m = (time%3600)/60;
    s = time%60;

    cout << h << ':' << m << ':' << s << '\n';
}


Measured memory_bytes: 3136
import scala.annotation.tailrec
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {
  val vowel = Array("a", "i", "u", "e", "o")
  val consonant = Array("", "k", "s", "t" ,"n", "h", "m", "y", "r")
  println(solve(readLine.trim.toList))
  @tailrec def solve(keys: List[Char], history: List[String] = Nil): String = {
    keys match {
      case Nil ⇒ history.reverse.mkString
      case '0'::f::r ⇒
        f match {
          case 'U' ⇒ solve(r, "nn"::history)
          case _ ⇒ solve(r, vowel(flickToInt(f))::"w"::history)
        }
      case d::f::r ⇒ solve(r, vowel(flickToInt(f))::consonant(d.asDigit - 1)::history)
      case _ ⇒ ???
    }
  }
  def flickToInt(flick: Char): Int = {
    flick match {
      case 'T' ⇒ 0
      case 'L' ⇒ 1
      case 'U' ⇒ 2
      case 'R' ⇒ 3
      case 'D' ⇒ 4
      case _ ⇒ ???
    }
  }
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

string s;
map<char,int> mp;

int main()
{
    cin >> s;
    _for(i,0,4){
        mp[s[i]]++;
    }
    if(mp.size() == 2 && mp.begin()->second == 2){
        printf("Yes\n");
    }else{
        printf("No\n");
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int n , k = 0;
		long a, b;
		n = stdin.nextInt();
		a = stdin.nextLong();
		b = stdin.nextLong();
		long[] A = new long[n];
		for (int i = 0; i < n; i++) {
			A[i] = stdin.nextInt();
		}
		long Tmax=1000000000;
		long Tmin=0;
		long T=0;
		//二分探索
		while(Tmax-Tmin>1){
			T=Tmin+(Tmax-Tmin)/2;
			 k=0;
			for(int i=0;i<n;i++){
				//何回爆発すれば全員殺せるかカウントする
				if(A[i]>b*T){
					k+=Math.ceil((double)(A[i]-b*T)/(double)(a-b));
				}
			}
			
			if(k>T){
				Tmin=T;
			}
			else if(k<=T){
				Tmax=T;
			}
		}
		System.out.println(Tmax);
	}

}

Measured memory_bytes: 50932
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

    ll A, B, C;
    cin >> A >> B >> C;

    if (A == B && B == C && A % 2 == 0) {
        cout << -1 << "\n";
        return 0;
    }
    for (ll i = 0;; ++i) {
        if (A % 2 || B % 2 || C % 2) {
            cout << i << "\n";
            return 0;
        }

        ll tmpA = A;
        ll tmpB = B;
        ll tmpC = C;
        A = (tmpB + tmpC) / 2;
        B = (tmpC + tmpA) / 2;
        C = (tmpA + tmpB) / 2;
    }
}

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

int main(){
  int n,k;
  cin >> n >>k;
  int ans=1;
  int q=k;
  if(n<k){cout << 1 << endl;
         return 0;}
  if(n==k){cout << 2 << endl;
          return 0;}
  for(int i=1;i<10000;i++){
    q=q*k;
    ans++;
    if(n<q){cout << ans << endl;
           return 0;}
  }
}

Measured memory_bytes: 256
<?php
$N = trim(trim(fgets(STDIN)));
$a_array = explode(' ', trim(fgets(STDIN)));
rsort($a_array);
//var_dump($a_array);
$Alice; $Bob;

for($i = 0; $i < $N; $i++) {
    if($i >= 1 && empty($a_array)) {
        break;
    }
    $Alice[] = $a_array[0];
    $a_array = array_slice($a_array, 1);
    //var_dump($a_array);
    if(!empty($a_array)) {
        $Bob[] = $a_array[0];
        $a_array = array_slice($a_array, 1);
    }
}
//var_dump($Alice); var_dump($Bob);
$Alice_sum = array_sum($Alice);
$Bob_sum = array_sum($Bob);

echo $Alice_sum - $Bob_sum;


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

string s;
int x, y;
const int OFFSET = 10000;
bitset<2*OFFSET+10> xx,yy;

void solve()
{
    const int n = s.length();
	int step = 0;
	bool f = true; // x axis
	bool fi = true;
	xx.set(OFFSET);
	yy.set(OFFSET);
	for(int i=0;i<=n;++i){
		if(s[i] == 'F') step++;
		else{
			auto& t = f ? xx : yy;
			if(fi) t<<=step;
			else t=(t<<step)|(t>>step);
			fi = false;
			step = 0;
			f ^= 1;
		}
	}
	if(xx.test(x+OFFSET)&&yy.test(y+OFFSET)) cout<<"Yes\n";
	else cout<<"No\n";
}

int main()
{
	cin >> s;
	cin >> x >> y;
	solve();
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"YES\n":"NO\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

int main()
{
    map<ll,bool> x;
    ll n,a;
    cin>>n;
    rep(i,n){
        cin>>a;
        if(x[a])yn(0),exit(0);
        x[a]=1;
    }
    yn(1);
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define inf (int)(3e18)

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int N;
string s;
int a[1000005];
signed main() {
	cin>>N>>s;
	int sum1=0,sum2=0;
	bool flag=true;
	rep(i,N){
		a[i]=s[i]-'1';
		int now=N-1,sum=0;
		while(now)sum+=now/2,now/=2;
		now=N-i-1;
		while(now)sum-=now/2,now/=2;
		now=i;
		while(now)sum-=now/2,now/=2;
		if(!sum){
			sum1+=a[i]%2;
			sum2+=a[i]/2;
		}
		if(a[i]==1)flag=false;
	}
	if(sum1%2)cout<<1<<endl;
	else if(!flag)cout<<0<<endl;
	else if(sum2%2)cout<<2<<endl;
	else cout<<0<<endl;
}



Measured memory_bytes: 9220
#include<cstdio>
#include<map>
using namespace std;

#define fs first
#define sc second
typedef pair<int,int> P;

P par[100001],x,y,tmp;
int rank[100001];

P find(int a){
  if(par[a].fs == a)return par[a];
  tmp = find(par[a].fs);
  return par[a] = P(tmp.fs,tmp.sc + par[a].sc);
}

int main(){
  char c;
  int a,b,w,n,m;
  while(scanf("%d%d",&n,&m),(n||m)){
    for(int i=1;i<=n;i++){
      par[i] = P(i,0); rank[i] = 0;
    }

    for(int i=0;i<m;i++){
      scanf(" %c ",&c);
      if(c=='?'){
	scanf("%d%d",&a,&b);
	if(find(a).fs==find(b).fs)printf("%d\n",par[b].sc - par[a].sc);
	else printf("UNKNOWN\n");
      }else{
	scanf("%d%d%d",&a,&b,&w);

	x = find(a); y = find(b);
	
	if(x.fs!=y.fs){
	  if(rank[x.fs]<rank[y.fs]){
	    par[x.fs] = P(y.fs,y.sc-x.sc-w);
	  }else{
	    par[y.fs] = P(x.fs,x.sc-y.sc+w);
	    if(rank[x.fs] == rank[y.fs])rank[x.fs]++;
	  }
	}
      }
    }
  }
}

Measured memory_bytes: 2216