akhauriyash/Code-Regression huggingface dataset:
s = str(input())
n = len(s)
num = (n-1)//2
a = 1

if num % 2 == 0:
    num_e = num // 2 
    for i in range(num_e):
        if (s[i] != s[num-i-1]) or (s[i] != s[num + i + 1]) or (s[i] != s[n-i-1]):
            a = 0
            break

else:
    num_o = num // 2
    if s[num_o] != s[num+num_o+1]:
        a = 0
    else:
        for i in range(num_o):
            if s[i] != s[num-i-1] or s[i] != s[num + i + 1] or s[i] != s[n-i-1]:
                a = 0
                break
if a:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int op(int a,int b){return max(a,b);}
int e(){return 0;}

const int N=330000;

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	segtree<int,op,e> seg(N);
	for(i=0;i<n;i++){
		cin>>a;
		b=max(0,a-m);
		c=min(N,a+m+1);
		seg.set(a,seg.prod(b,c)+1);
	}
	cout<<seg.all_prod()<<endl;
}

Measured memory_bytes: 8576
'use strict'
function main(inp) {
  inp = inp.trim()
  const N = inp - 0
  const L = inp.length - 1
  
  let ans = 0
  for (let i = 0; i < L; i++) {
    if (i%2 === 0) ans += Math.pow(10, i) * 9
  }
  if (L%2 === 0) ans+= N - (Math.pow(10,L) - 1)
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define ryuque(t) priority_queue<t,vec<t>,greater<t>>
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define MOD 1000000007ll
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}

//nCk(mod p)
const ll NUM=2;
ll fac[NUM],finv[NUM],inv[NUM];
void cmodf(ll p=MOD){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	rep(i,2,NUM){
		fac[i]=fac[i-1]*i%p;
		inv[i]=p-inv[p%i]*(p/i)%p;
		finv[i]=finv[i-1]*inv[i]%p;
	}
}
ll cmod(ll n,ll k,ll p=MOD){
	return fac[n]*(finv[k]*finv[n-k]%p)%p;
}

//最大公約数
ll gcd(ll n,ll m){
	ll k=n%m;
	while(k!=0){n=m;m=k;k=n%m;}
	return m;
}
ll gcd(vector<ll> a){
	rep(i,1,a.size()){
		ll k=a[i-1]%a[i];
		while(k!=0){
			a[i-1]=a[i];
			a[i]=k;
			k=a[i-1]%a[i];
		}
	}
	return a.back();
}

//最小公倍数
ll lcm(ll n,ll m){
	ll t=n*m,k=n%m;
	while(k!=0){n=m;m=k;k=n%m;}
	return t/m;
}
ll lcm(vector<ll> a){
	ll n;
	rep(i,1,a.size()){
		n=a[i-1]*a[i];
		ll k=a[i-1]%a[i];
		while(k!=0){
			a[i-1]=a[i];
			a[i]=k;
			k=a[i-1]%a[i];
		}
		n/=a[i];
		a[i]=n;
	}
	return n;
}

//keyの小さい方から探していった時に初めてvalueがjoken以上になる時のkey（keyが増えたらvalueも増えるか同じになるとき）
ll value(ll key) {
	/*変更*/
	return 0;
}
ll mink(ll lkey,ll rkey/*ここも調べる*/,ll joken){
	ll mkey;
	while(lkey!=rkey){
		mkey=(lkey+rkey)/2;
		if(value(mkey)>=joken)rkey=mkey;
		else lkey=mkey+1;
	}
	return rkey;
}

//ペア配列の整理
struct pea{
	ll f,s;
	bool operator<(const pea &c)const{
		return f!=c.f?f<c.f:s<c.s;
	};
};

//変数定義

//再帰関数

//アルゴリズム
void solve(){
	ll n,m;
	cin>>n>>m;
	vec<vll> a(n);
	rep(i,0,m){
		ll s,t;cin>>s>>t;
		a[s].pub(t);
		a[t].pub(s);
	}
	vll c(n,-1);
	ll k=0;
	rep(i,0,n){
		if(c[i]==-1){
			deque<ll> b;
			b.pub(i);
			c[i]=k;
			while(b.size()!=0){
				rep(j,0,a[b.front()].size()){
					if(c[a[b.front()][j]]==-1){
						b.pub(a[b.front()][j]);
						c[a[b.front()][j]]=k;
					}
				}
				b.pof();
			}
			k++;
		}
	}
	ll q;cin>>q;
	rep(i,0,q){
		ll s,t;cin>>s>>t;
		if(c[s]==c[t])cout<<"yes"<<kai;
		else cout<<"no"<<kai;
	}
}


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

int main() {
	int N, R;
	int m;
	int res = -2000000000;

	scanf("%d", &N);
	scanf("%d", &m);
	for (int i = 1;i < N;i++) {
		scanf("%d", &R);
		
		if (res < R - m) {
			res = R - m;
		}
		if (R < m) {
			m = R;
		}
	}

	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 1028
N, Y = map(int, input().split())

answer = '-1 -1 -1'
for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y and z >= 0:
            answer = str(x) + ' ' + str(y) + ' ' + str(z) 
            break
print(answer)


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

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

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

    bool able_flg = false;
    int ans = 0;
    int icount = 1;
    for (int i = 0; i < N; i++)
    {
        if (a[i] == icount)
        {
            icount++;
            able_flg = true;
        }
        else
        {
            ans++;
        }
    }

    if (able_flg == true)
    {
        cout << ans << endl;
    }
    else
    {
        cout << "-1" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
  int h1,h2,k1,k2;
  int a,b,c,d;
  int hp=0,kp=0;
  scanf("%d %d",&h1,&h2);
  scanf("%d %d",&k1,&k2);
  scanf("%d %d %d %d",&a,&b,&c,&d);

  hp=a*h1+b*h2+c*(h1/10)+d*(h2/20);
  kp=a*k1+b*k2+c*(k1/10)+d*(k2/20);

  if(hp>kp) printf("hiroshi\n");
  else if(hp<kp) printf("kenjiro\n");
  else printf("even\n");

  return 0;
}



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

int main() {
  char a;
  cin >> a;
  
  int sum = 1;

  if ((a == 'a') || (a == 'i') || (a == 'u') || (a == 'e') || (a == 'o')) {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();

        int N = nextInt();

        int[] weights = new int[N];

        for (int i = 0; i < weights.length; i++) {
            weights[i] = nextInt();
            if (i > 0) weights[i] += weights[i - 1];
        }

        int min = Integer.MAX_VALUE;

        for (int i = 0; i < weights.length - 1; i++) min = Math.min(min, Math.abs(weights[weights.length - 1] - 2*weights[i]));

        System.out.println(min);
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}

Measured memory_bytes: 22100
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

int main() {
  int n;
  cin >> n;
  set<string> s;
  for(int i = 0; i<n; i++) {
    string ss; cin >> ss;
    s.insert(ss);
  }
  cout << s.size() << endl;
  
  return 0;
}


Measured memory_bytes: 19192
# -*- coding:utf-8 -*-
N = int(input())
a = [tmp for tmp in reversed(range(1,N+1)) if tmp%2 == 0]
ans = 0
for tmp in range(7):
    if N == 1:
        ans = 1
        break
    b = [tmp2//2 for tmp2 in a if tmp2%2 == 0]
    if len(b) != 0:
        ans += 1
    else:
        ans = (2**ans)*a.pop()
        break
    a = [tmp2 for tmp2 in b]
print(ans)

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
int N;
char s[10101][30];
int bs, ae,aa;
int i, j, k, ans;
int main(){
    scanf("%d", &N);
    fornum(i,0,N){
        scanf("%s", s[i]);
        if(s[i][0]=='B'){
            bs++;
        }
        for (j = 1; s[i][j];j++){
            if(s[i][j-1]=='A'&&s[i][j]=='B'){
                ans++;
            }
        }
        if(s[i][j-1]=='A'){
            ae++;
            if(s[i][0]!='B'){
                aa=1;
            }
        }
    }
    if(ae!=bs){
        ans += ae > bs ? bs : ae;
    }else{
        ans += ae;
        if(ae!=0&&aa==0){
            ans--;
        }
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  int mn=100100100;
  rep(i,n){
    ll a;cin>>a;
    int cnt=0;
    while(a>0){
      if(a%2!=0){
        break;
      }
      cnt++;
      a>>=1;
    }
    mn=min(mn,cnt);
  }
  cout << mn<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,x[10],y[10];
int cal() {
	if(n==1) {
		for(int i=0;i<10;i++) {
			bool f=true;
			for(int j=0;j<m;j++) {
				if(i!=y[j]) f=false;
			}
			if(f) return i;
		}
		return -1;
	}
	if(n==2) {
		for(int i=10;i<100;i++) {
			bool f=true;
			for(int j=0;j<m;j++) {
				if(x[j]==1&&i/10!=y[j]) f=false;
				if(x[j]==2&&i%10!=y[j]) f=false;
			}
			if(f) return i;
		}
		return -1;
	}
	for(int i=100;i<1000;i++) {
		bool f=true;
		for(int j=0;j<m;j++) {
			if(x[j]==1&&i/100!=y[j]) f=false;
			if(x[j]==2&&(i/10)%10!=y[j]) f=false;
			if(x[j]==3&&i%10!=y[j]) f=false;
		}
		if(f) return i;
	}
	return -1;
}
int main() {
	//freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++) {
		scanf("%d%d",&x[i],&y[i]);
	}
	printf("%d\n",cal());
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int N;
int judge=0;
cin>>N;
for(int i=0;i<=100;i=i+4)
{
for(int j=0;j<=100;j=j+7)
{
if(N==i+j) judge++; 
}
}
if(judge>0) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main(void){
    ll n,k;cin >> n >> k;
    if(2*k > (n+1)){
        cout <<-1 << endl;
        return 0;
    }else{
        ll mid_small = k + n - 1;
        ll adding = mid_small + 1;
        //cout << mid_small << " " << adding << endl;
        int cnt = 0;
        vector<int> used(3*n,0);

        while(1){
            ll sum = 0;
            int cnt = 0;
            sum += mid_small + adding;
           // cout << mid_small << " " << adding << endl;
            if(adding <= k + 2*n - 1){

                cout << mid_small << " " << adding << " " << mid_small+adding << endl;
                used[mid_small+adding - k]++;
                used[mid_small - k]++;
                used[adding - k]++;
                mid_small--;
                adding += 2;
                cnt++;
            }else{
                break;
            }

        }
        vector<ll> ans;
        rep(i,3*n){
            if(!used[i])ans.pb(i + k);
        }
        int sz = ans.size() / 3;
        vector<pair<ll,pair<ll,ll>>> ans2;
        rep(i,sz){
            ans2.pb(mp(ans[i]+ans[i+2*sz-1-i],mp(ans[i],ans[2*sz-1-i])));
        }
        sort(all(ans2));reverse(all(ans2));
        rep(i,sz){
            cout << ans2[i].ss.ff << " " << ans2[i].ss.ss << " " << ans[i+2*sz] << endl;
        }
        return 0;
    }

}


Measured memory_bytes: 7280
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def rotate(nd, d):
    c = nd[d]
    if d:
        nd[1] = c[0]
        c[0] = nd
    else:
        nd[0] = c[1]
        c[1] = nd
    return c


root = None
def insert(val, pri):
    global root
    st = []
    dr = []
    x = root
    while x:
        st.append(x)
        if x[2] == val:
            return
        d = (x[2] < val)
        dr.append(d)
        x = x[d]
    nd = [None, None, val, pri]
    while st:
        x = st.pop(); d = dr.pop()
        c = x[d] = nd
        if x[3] >= c[3]:
            break
        rotate(x, d)
    else:
        root = nd

def __delete(nd):
    st = []; dr = []
    while nd[0] or nd[1]:
        l = nd[0]; r = nd[1]
        d = (l[3] <= r[3]) if l and r else (l is None)
        st.append(rotate(nd, d))
        dr.append(d ^ 1)
    nd = x = None
    while st:
        nd = x; x = st.pop(); d = dr.pop()
        x[d] = nd
    return x

def delete(val):
    global root
    x = root

    y = None
    while x:
        if val == x[2]:
            break
        y = x; d = (x[2] < val)
        x = x[d]
    else:
        return

    if y:
        y[d] = __delete(x)
    else:
        root = __delete(x)

def find(val):
    x = root
    while x:
        if val == x[2]:
            return 1
        x = x[x[2] < val]
    return 0

def debug():
    s0 = [""]
    s1 = [""]

    def dfs(nd):
        v = str(nd[2])
        s0.append(v)
        if nd[0]:
            dfs(nd[0])
        s1.append(v)
        if nd[1]:
            dfs(nd[1])
    dfs(root)
    return " ".join(s1), " ".join(s0)


M = int(readline())
ans = []
for m in range(M):
    cmd, *V, = readline().split()
    if cmd == "print":
        ans.extend(debug())
    elif cmd == "find":
        ans.append("yes" if find(int(V[0])) else "no")
    elif cmd == "delete":
        delete(int(V[0]))
    else:
        val, pri = map(int, V)
        insert(val, pri)
write("\n".join(ans))
write("\n")


Measured memory_bytes: 65680
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////


int main(){
  ini(N);
  vi v(N); in(v);
  int flg = 0;
  rep(i,N){
    if(v[i] % 2 == 1) flg = 1;
  }
  out(flg ? "first" : "second");





}

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

int calc_gcd(int a, int b) {
    if (b == 0) return a;
    return calc_gcd(b, a % b);
}

void solve(string s) {
    int n = s.size();
    int idx = 0;
    vector<char> dirs;
    while (idx < n) {
        if (s[idx] == 'n') {
            dirs.push_back('n');
            idx += 5;
        }
        else {
            dirs.push_back('w');
            idx += 4;
        }
    }
    reverse(dirs.begin(), dirs.end());
    int ans1 = 0, ans2 = 1;
    if (dirs[0] == 'w') ans1 = 90;
    int pow_num = 2;
    for (int i = 1; i < dirs.size(); i++) {
        if (ans2 < pow_num) {
            ans1 *= pow_num / ans2;
            ans2 = pow_num;
        }
        if (dirs[i] == 'n') ans1 -= 90;
        else ans1 += 90;
        int g = calc_gcd(ans1, ans2);
        ans1 /= g, ans2 /= g;
        pow_num *= 2;
    }
    cout << ans1;
    if (ans2 > 1) cout << '/' << ans2;
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    while (true) {
        cin >> S;
        if (S == "#") break;
        solve(S);
    }
    return 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int n, r;
    cin >> n >> r;
    if (n < 10)
    {
        c(r + (100 * (10 - n)));
    }
    else
    {
        c(r);
    }
    return 0;
}

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

int main() {
    std::multiset <std::string> M;
    int kase;
    for (scanf("%d", &kase); kase; --kase) M.insert("a");
    for (scanf("%d", &kase); kase; --kase) M.insert("b");
    for (scanf("%d", &kase); kase; --kase) M.insert("c");
    while (M.size()>1) {
        std::string s = *M.begin(), t = *M.rbegin();
        M.erase(M.lower_bound(s));
        M.erase(M.lower_bound(t));
        M.insert(s + t);
    }
    printf("%s\n", (*M.begin()).c_str());
    return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
#include <bits/stdc++.h>
#include <fstream>
#include<string.h>
#include <algorithm>
#include<math.h>
#include<vector>
#include <queue>
#include <deque> 
#define ll long long
#define M 1000000007 
#define MM 998244353
#define INF (1LL<<60)-1
using namespace std;
 
ll cnt;
void dfs(ll node,vector<ll> adj[],bool vis[])
{
    cnt++;
    vis[node]=true;
    for(ll child:adj[node])
    {
        if(!vis[child])
        {
            dfs(child,adj,vis);
        }
    }
}
 
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*ll t,tcitr;
    cin>>t;
    tcitr=0;
    while(tcitr<t)
    {*/
        //cout<<"Case #"<<tcitr+1<<": ";
        ll n,m,i,j,k;
        cin>>n>>m;
        vector<ll> adj[n];
        for(i=0;i<m;i++)
        {
            cin>>j>>k;
            j--;
            k--;
            adj[j].push_back(k);
            adj[k].push_back(j);
        }
        ll ans=0;
        bool vis[n]={};
        for(i=0;i<n;i++)
        {
            if(!vis[i])
            {
                cnt=0;
                dfs(i,adj,vis);
                ans=max(ans,cnt);
            }
        }
        cout<<ans<<"\n";
        /*tcitr++;
    }*/
    return 0;
}

Measured memory_bytes: 24080
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector< pair<int, int> > v;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        v.push_back(make_pair(a, i+1));
    }

    sort(v.begin(), v.end());
    for (int i = 0; i < n-1; i++) {
        cout << v[i].second << " ";
    }
    cout << v[n-1].second << endl;

    return 0;

}

Measured memory_bytes: 1780
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if((e-d<=k) and (e-c<=k) and (e-b<=k) and (e-a<=k) and (d-c<=k) and (d-b<=k) and (d-a<=k) and (c-b<=k) and (c-a<=k) and (b-a<=k)):
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3064
use std::io::*;
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let g: usize = itr.next().unwrap().parse().unwrap();
    let pc: Vec<(usize, usize)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    // g以上
    let mut ans = 1usize << 60;
    for bit in 0..1 << n {
        let mut tc = 0;
        let mut tp = 0;
        for i in 0..n {
            if bit >> i & 1 == 1 {
                tc += pc[i].0;
                tp += pc[i].1 + pc[i].0 * 100 * (i + 1);
            }
        }
        // 足りない分解く
        if tp >= g {
            ans = std::cmp::min(ans, tc);
        } else {
            // 大きいほうコアラ
            let mut ok = false;
            for i in (0..n).rev() {
                if bit >> i & 1 == 0 {
                    for _ in 0..pc[i].0 {
                        tc += 1;
                        tp += 100 * (i + 1);
                        if tp >= g {
                            ok = true;
                            break;
                        }
                    }
                }
                if ok {
                    break;
                }
            }
            if ok {
                ans = std::cmp::min(ans, tc);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//main definations
#define endl "\n"
#define UI unsigned int
#define LLI long long int
#define ULLI unsigned long long int
#define PI 3.14159258

//codechef only
#define TC for(UI defined_i=1;defined_i<=t;defined_i++)
//int b_s(int arr[], int n, int find);
using namespace std;
int main(){
	int n, k, temp, ans=0;
	cin>>n;
	cin>>k;
	for(int i=0;i<n;i++){
		cin>>temp;
		if((temp)<(k-temp)){
			ans=ans+temp;
		}
		else{
			ans=ans+(k-temp);
		}
	}
	cout<<2*ans<<endl;
	return 0;
}
/*
int b_s(int arr[], int n, int find){
	int start=0, end=n-1, mid=(start+end)/2;
	while(start<=end){
		if(arr[mid]==find){
			return mid;
		}
		else if(arr[mid]<find){
			start=mid+1;
			mid=(start+end)/2;
		}
		else{
			end=mid-1;
			mid=(start+end)/2;
		}
	}
	return -1;
}*/

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

int main() {
    
    map<string, int> res;
	int n;
	cin >> n;
	for (int i=0; i<n; i++) {
		string x;
		cin >> x;
		res[x]++;
	}
	int m;
	cin >> m;
	for (int i=0; i<m; i++) {
		string x;
		cin >> x;
		res[x]--;
	}
	int mx = 0;
	for (map<string, int>::iterator x=res.begin(); x!=res.end(); x++) {
		mx = max(mx, x->second);
	}
	cout << mx << endl;
	
}


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

using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)

int main(){

	vector<int> data(10);

	rep(i,10){
		cin >> data[i];
	}

	sort(data.begin(),data.end());

	rep(i,3){
		cout << data[9 - i] << endl;
	}


	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int match = 0;
    int i = -1;
    vector<bool> used(n);
    while(i < n){
        i++;
        if (s[i] == ')') continue;
        for(int j = i+1; j < n; j++){
            if (s[j] == ')' && !used[j]){
                match++;
                used[j] = true;
                break;
            }
        }
    }
    int numR = 0, numL = 0;
    rep(i,n){
        if (s[i] == '(') numR++;
        else numL++;
    }
    numR -= match;
    numL -= match;
    rep(i, numR) s = s + ')';
    rep(j, numL) s = '(' + s;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll X, Y; cin >> X >> Y;
  for (ll a = 0; a <= 100; a++) {
    for (ll b = 0; b <= 100; b++) {
      if (a + b == X && 2 * a + 4 * b == Y) {
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;
  

  return 0;
}



Measured memory_bytes: 3648
import java.util.*;

class Main{
	int a;
	int b;
	public Main(){
		Scanner scan = new Scanner(System.in);
		for(;;){
			a=scan.nextInt();
			b=scan.nextInt();
			if(a==0 || b==0)break;
			for(int j=0; j<a; j++){
				for(int i=0; i<b; i++){
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
	public static void main(String[]args){
		new Main();
	}
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

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

  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);

  sort(a.begin(), a.end());
  int ans=0;
  a.push_back(0);
  
  rep(i,n){
    int count=0;
    
    while(a.at(i)==a.at(i+1)){
      i++;
      count++;
    }

    if(count%2==0) ans++;
  }

  cout << ans;
}

Measured memory_bytes: 4824
#include <stdio.h>
#include <string.h>

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	if(b % a == 0){
		printf("%d", a + b);
	}else{
		printf("%d", b - a);
	}
	
	
	return 0;
}

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

using namespace std;

void do_country(int& n, int& k, vector<int>& x);

int main()
{
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        int n, k;
        cin >> n >> k;
        vector<int> x;
        for (int j = 0; j < n; j++) {
            int input_x;
            cin >> input_x;
            x.push_back(input_x);
        }
        do_country(n, k, x);
    }
}

void do_country(int& n, int& k, vector<int>& x)
{
    sort(x.begin(), x.end());
    //reverse(x.begin(), x.end());
    //cout << x.at(0) << x.at(n - 1) << endl;
    int ans = x[n - 1] - x[0];
    vector<int> distance;
    for (int i = 0; i < n - 1; i++) {
        distance.push_back(x[n - 1 - i] - x[n - 2 - i]);
    }
    sort(distance.begin(), distance.end());
    //reverse(distance.begin(), distance.end());
    //cout << ans << endl;
    for (int i = 1; i < (n > k ? k : n); i++) {
        ans -= distance[n - i - 1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

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

    for(int i=0;i<n;i++){
        int v=a[i];
        int j=i-1;
        while(j>=0&&a[j]>v){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        for(int k=0;k<n;k++){
            if(k>0) cout << " ";
            cout << a[k];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3084
#include <stdio.h>

int main(){
  int x[3], i, j, a;

  scanf("%d %d %d",&x[0], &x[1], &x[2]);

  for(i=0;i<3;i++) {
    for(j=2;j>i;j--) {
      if(x[j]<x[j-1]) {
        a = x[j];
        x[j] = x[j-1];
        x[j-1] = a;
      }
    }
  }



  for(i=0;i<3;i++) {
    printf("%d", x[i]);
    if(i!=2) printf(" ");
    else printf("\n");
}

  return 0;
}



Measured memory_bytes: 2068
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(int, N);
    vector<i64> a(N);
    read(a);

    sort(all(a));
    if (accumulate(all(a), 0LL) - a.back() > a.back()) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll a, b;cin >> a;
	cout << 2 * a * 3.14 << endl;


	return 0;
}


Measured memory_bytes: 3800
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    string s[3] = {"Sunny", "Cloudy", "Rainy"};
    string w;
    cin >> w;
    for (int i = 0; i < 3; i++) {
        if(s[i] == w) {
            cout << s[(i + 1)%3] << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,m = f()
    a = [""] * n
    b = [""] * m
    for i in range(n):
        a[i] = input()
    
    for i in range(m):
        b[i] = input()
    
    if m>n:
        print("No")
    else:
        for i in range(0, n - m+1):
            for j in range(0, n - m+1):
                ok = True
                for k in range(m):
                    if a[i+k][j:j+ m] != b[k]:
                        ok = False
                if ok:
                    print("Yes")
                    return
        
        print("No")


solve()


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

int main()
{
  int n,m,s=0;
  cin>>n>>m;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  for(int i=0;i<m;i++)
    s+=a[i];
  cout<<s;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <unordered_map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

int main(int argc, char** argv) {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) {
    cin >> v[i];
  }

  priority_queue<double, vector<double>, greater<double> > q;
  rep(i, n) {
    q.push(v[i]);
  }

  while (q.size() > 1) {
    // NOTE: fetch minimum two elements.
    double v1 = q.top(); q.pop();
    double v2 = q.top(); q.pop();

    double newV = (v1 + v2) / 2.0;  // calculate new.
    q.push(newV);
  }

  double res = q.top(); q.pop();

  cout << res << endl;

  // For Debug
  // cout << n << endl;
  // rep(i, n) {
  //   cout << v[i] << endl;
  // }
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc118/tasks/abc118_c

// http://ctylim.hatenablog.com/entry/2015/08/30/191553
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>

#define ALL(a) (a).begin(), (a).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define MAXINDEX(c) distance((c).begin(), max_element((c).begin(), (c).end()))
#define MININDEX(c) distance((c).begin(), min_element((c).begin(), (c).end()))
#define DEBUG(x) std::cerr << #x << " = " << (x) << " (" << __FILE__ << "::" << __LINE__ << ")" << std::endl;
#define ERROR(s) std::cerr << "Error::" << __FILE__ << "::" << __LINE__ << "::" << __FUNCTION__ << "::" << (s) << std::endl;
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

template <typename T>
T inputValue()
{
  T a;
  std::cin >> a;
  // scanf("%d", &a);
  return a;
}

void inputArray(int *p, int a)
{
  rep(i, a)
  {
    std::cin >> p[i];
    // scanf("%d",p+i);
  }
}

template <typename T>
void inputVector(std::vector<T> *p, int a)
{
  rep(i, a)
  {
    T input;
    std::cin >> input;
    // scanf("%d", &input);
    p->push_back(input);
  }
}

template <typename T>
void output(T a, int precision)
{
  if (precision > 0)
  {
    std::cout << std::setprecision(precision) << a << "\n";
  }
  else
  {
    std::cout << a << "\n";
  }
}

using namespace std;

int gcd(int a, int b)
{
  while (1)
  {
    if (a < b)
      swap(a, b);
    if (!b)
      break;
    a %= b;
  }
  return a;
}

typedef unsigned long long int ulli;
int main(int argc, char **argv)
{

  ulli N = inputValue<ulli>();
  ulli K = inputValue<ulli>();
  vector<ulli> v;
  inputVector<ulli>(&v, N);


  vector<ulli> bitSum(64,0);

  EACH(k, v)
  {
    ulli t = *k;
    for(int i=0; i<64&&t!=0; i++){
      bitSum[i] = bitSum[i] + (t&1) ;
      t = t >> 1;
    }
  }

  ulli d = 0;

  int flag = 0;

  ulli sum0 = 0;
  for (int i = 63; i >= 0; i--)
  {

    ulli K_bit = (K >> i) & 1ll;
    ulli A_bit = (bitSum[i] > N / 2 ? 0 : 1);
    ulli D_bit;
    if (!flag)
    {
      D_bit = K_bit && A_bit;
      flag = K_bit && (!A_bit);
    } else {
      D_bit = A_bit;
    }
    d = (d << 1) | (D_bit);
    // cout << K_bit << "," << A_bit << "," << D_bit << "," << bitSum[i] << endl;
    if (!D_bit)
    {
      sum0 = sum0 + (bitSum[i] << i);
      // cout << i<< ":" <<bitSum[i]<< ","<<(bitSum[i] << i) << endl;
    }else{
      sum0 = sum0 + ((N-bitSum[i]) << i);
      // cout << i << ":" << bitSum[i] << "," << ((N - bitSum[i]) << i) << endl;
    }
  }
  cout << sum0 << endl;

  // ulli sum = 0;
  // EACH(k, v)
  // {
  //   sum = sum + (*k^d);
  // }
  // cout << sum << endl;
  // return 0;
}

//

Measured memory_bytes: 1400
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext())
		{
			System.out.print("3C");
			int x = sc.nextInt() % 39;
			if (0 < x && x < 10) System.out.print(0);
			System.out.println(x == 0 ? 39 : x);
		}
	}
}

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

int main () {
    int n; 
    string s, ret = ""; 
    cin >> n >> s;
    for (char c : s) {
        ret += 'A' + (c-'A'+n)%26;
    }
    cout << ret << endl;
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int A, B, C;
  while(cin>>A>>B>>C,A){
	int N;
	cin >> N;
	VI ans(A+B+C+1, 2);
	set<tuple<int,int,int>> ws;
	REP(i,N){
	  int a, b, c, r;
	  cin >> a >> b >> c >> r;
	  if(r == 1){
		ans[a] = ans[b] = ans[c] = 1;
	  }
	  else{
		ws.insert(make_tuple(a,b,c));
	  }
	}
	for(auto&& t: ws){
	  int a, b, c;
	  tie(a,b,c) = t;
	  if(ans[b] == 1 && ans[c] == 1)
		ans[a] = 0;
	  else if(ans[a] == 1 && ans[c] == 1)
		ans[b] = 0;
	  else if(ans[a] == 1 && ans[b] == 1)
		ans[c] = 0;
	}

	FOR(i,1,A+B+C+1)
	  cout << ans[i] << endl;
  }

  return 0;
}

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

using namespace std;

vector <int> D[51];
int P[51], De[51], L[51][51];

void dfs(int d, int p)
{
    for (int i = 0; i < D[d].size(); i++)
    {
        int a = D[d][i];
        if (a != p)
        {
            P[a] = d;
            De[a] = De[d] + 1;
            dfs(a, d);
        }
    }
}

int LCA(int a, int b)
{
    if (De[a] < De[b])
    {
        swap(a, b);
    }
    while (De[a] > De[b])
    {
        a = P[a];
    }
    while (a != b)
    {
        a = P[a];
        b = P[b];
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(false);
    int n, m, a, b;
    long long S;
    cin >> n;
    for (int i = 0; i < n-1; i++)
    {
        cin >> a >> b;
        D[a].push_back(b);
        D[b].push_back(a);
    }
    cin >> m;
    int A[m], B[m], K[n+1];
    for (int i = 0; i < m; i++)
    {
        cin >> A[i] >> B[i];
    }
    P[1] = -1;
    De[1] = 0;
    dfs(1, -1);
    vector <pair<int,int>> V;
    for (int i = 1; i <= n; i++)
    {
        V.push_back({De[i],i});
    }
    sort(V.rbegin(),V.rend());
    for (int i = 1; i <= n; i++)
    {
        for (int y = 1; y <= n; y++)
        {
            L[i][y] = LCA(i, y);
        }
    }
    S = pow(2, n-1);
    for (int i = 1; i < (1 << m); i++)
    {
        for (int y = 1; y <= n; y++)
        {
            K[y] = 0;
        }
        int c = 0;
        long long k=0;
        for (int y = 0; y < m; y++)
        {
            if ((1 << y) & i)
            {
                c++;
                K[A[y]]++;
                K[B[y]]++;
                K[L[A[y]][B[y]]] -= 2;
            }
        }
        for (int y = 0; y < V.size(); y++)
        {
            a = V[y].second;
            if (K[a] > 0)
            {
                k++;
            }
            if (P[a] != -1)
            {
                K[P[a]] += K[a];
            }
        }
        if (c % 2 == 1)
        {
            S -= pow(2, n-1-k);
        }
        else
        {
            S += pow(2, n-1-k);
        }
    }
    cout << S;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,(input().split())))
B = [(0)*2 for _ in range(N)]
for i in range(N):
    B[i] = (A[i],i)
B.sort(reverse=True)

dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 0

ans = []
for l in range(N+1):
    for r in range(N+1):
        if l+r == N:
            ans.append(dp[l][r])
            break
        if r+1 < N+1:
            dp[l][r+1] = max(dp[l][r+1], dp[l][r] + B[l+r][0] * abs(B[l+r][1] - (N-(r+1)) ))
        if l+1 < N+1:
            dp[l+1][r] = max(dp[l+1][r], dp[l][r] + B[l+r][0] * abs(B[l+r][1] - l))

print(max(ans))

Measured memory_bytes: 100756
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

ll max(ll a, ll b){
    return (a>b)?a:b;
}

int main(){
    ll n, m, k;    cin >> n >> m >> k;
    vector<ll>a(n);
    rep(i, n)   cin >> a[i];
    vector<ll>b(m);
    rep(i, m)   cin >> b[i];
    vector<ll>sum_a(n+1);
    vector<ll>sum_b(m+1);
    sum_a[1] = a[0];
    for(int i = 2; i <= n; i++)  sum_a[i] += sum_a[i-1] + a[i-1];
    sum_b[1] = b[0];
    for(int i = 2; i <= m; i++)  sum_b[i] += sum_b[i-1] + b[i-1];
    ll ans = 0;
    rep(i, n+1){
        int ok = -1, ng = m+1;
        while(ok < ng-1){
            int ptr = (ok+ng)/2;
            if(sum_b[ptr] + sum_a[i] <= k){
                ok = ptr;
            }else{
                ng = ptr;
            }
        }
        if(ok < 0)  break;
        ans = max(ans, i+ok);
    }
    cout << ans << endl;
}


Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int mod=1e9+7;
int n,m,dp[1010][1010];
char s[1010][1010];
int main() {
	scanf("%d%d",&n,&m);
	int i,j;
	for(i=1;i<=n;i++) {
		scanf("%s",s[i]+1);
		for(j=1;j<=m;j++) {
			if(s[i][j]=='#') continue;
			if(i==1&&j==1)dp[i][j]=1;
			else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
	printf("%d",dp[n][m]);
	return 0;
}

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

int main() {
  int K,S;
  cin>>K>>S;
  int Z=0;
  for(int i=0;i<=K;i++){
    int N=S-i;
    
    if(N>2*K||N<0){
      continue;
    }
    else if(N<=K){
      Z+=N+1;
    }
    else{
      Z+=2*K-N+1;
    }
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
static const int N = 1000000;

int cnt;

void insertionSort(int A[], int n, int g){
  int i,j,v;

  for(i = g; i<n; i++){
    v = A[i];
    j = i-g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j = j-g;
      cnt++;
    }
      A[j+g] = v;
  }
}

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    printf("%d\n", A[i]);
  }
}
 
int main(){
  int n, i, j, k, key,m=6;
  int A[N+1],G[6]={2500, 150, 40, 13, 4, 1};

  scanf("%d", &n);
 
  cnt = 0;

  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
   
  for(i = 0;i<m;i++){
    if(G[i]<=n){
      k = i;
      break;
    }
  }
  for(i = k; i < m; i++){
    insertionSort(A, n, G[i]);

    /*   key = A[i];
	 j = i - 1;
	 while(j >= 0 && A[j] > key){
	 A[j+1] = A[j];
	 j--;
	 A[j+1] = key;
	 }*/
  }
  printf("%d\n",m - k);

  for(i = k; i<m; i++){
    if(i!=k)printf(" ");
    printf("%d",G[i]);
  }
  printf("\n");
  printf("%d\n",cnt);

  trace(A, n);

  return 0;
}

Measured memory_bytes: 4508