akhauriyash/Code-Regression huggingface dataset:
import Data.List

splitRec _ [] = []
splitRec n xs = let (h, t) = splitAt n xs in h : splitRec n t

counting = sortBy (flip compare) . map (\es -> (length es, head es)) . group . sort 

calc n os es
  | ov /= ev || length (takeWhile ((==oc) . fst) os) > 1 || length (takeWhile ((==ec) . fst) es) > 1 = n - oc - ec
  | ol == 1 && el == 1 = div n 2
  | ol == 1 = div n 2 - secondc es
  | el == 1 = div n 2 - secondc os
  | otherwise = min (n - oc - secondc es) (n - ec - secondc os)
  where
    ol = length os
    el = length es
    (oc, ov) = head os
    (ec, ev) = head es
    secondc = fst . head . tail

main = do
    n <- readLn :: IO Int
    [os, es] <- map counting . transpose . splitRec 2 . map (read :: String -> Int) . words <$> getLine
    print $ calc n os es

Measured memory_bytes: 52604
#include<bits/stdc++.h> 
using namespace std; 
typedef long long ll;
vector<int> g[200005];
int a[200005],b[200005],f[200005],root[200006],tot,n;
int ls[4000005],rs[4000005],mx[4000005],ans[200005];
int Query(int p,int l,int r,int x){
	if(!p||!x)return 0;
	if(r<=x)return mx[p];
	int mid=(l+r)/2,m=0;
	m=max(m,Query(ls[p],l,mid,x));
	if(x>mid)m=max(m,Query(rs[p],mid+1,r,x));
	return m;
}
void Update(int &p,int q,int l,int r,int x,int y){
	p=++tot;
	ls[p]=ls[q],rs[p]=rs[q],mx[p]=max(mx[q],y);
	if(l==r)return ;
	int mid=(l+r)/2;
	if(x<=mid)Update(ls[p],ls[q],l,mid,x,y);
	else Update(rs[p],rs[q],mid+1,r,x,y);
}
void dfs(int x,int fa){
	f[x]=Query(root[fa],1,n,a[x]-1)+1;
	ans[x]=max(f[x],ans[fa]);
	Update(root[x],root[fa],1,n,a[x],f[x]);
	for(int y:g[x]){
		if(y^fa)dfs(y,x);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),b[i]=a[i];
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++)a[i]=lower_bound(b+1,b+n+1,a[i])-b;
	for(int i=1,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		g[x].push_back(y),g[y].push_back(x);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 70828
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string>
#include<math.h>
#include<string.h>
using namespace std;
int main()
{
   int n,m;
   int sum1,sum2,sum;
   scanf("%d %d",&n,&m);
   sum1=n*(n-1)/2;
   sum2=m*(m-1)/2;
   sum=sum1+sum2;
   printf("%d\n",sum);
        return 0;
}


Measured memory_bytes: 888
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
def lcm(a, b):
    return a // gcd(a, b) * b

N, M = map(int, input().split())
As = list(map(int, input().split()))

Bs = [A//2 for A in As]

lcmB = reduce(lcm, Bs)

for B in Bs:
    if lcmB // B % 2 == 0:
        print(0)
        break
else:
    num = M // lcmB
    print((num+1)//2)


Measured memory_bytes: 14748
#include<iostream>
using namespace std;
typedef long long ll;
const int N = 51;
ll bu[N], p[N];
ll recursive(int n, ll x) {
    if (n == 0) { //level 0 burger
        return 1; //is p
    }
    if (x == 1) { //bottom (not level 0 burger)
        return 0; //is b
    } else if (x <= bu[n] / 2) { //切り捨てで真ん中の1個左まで
        return recursive(n - 1, x - 1);
    } else if (x == bu[n] / 2 + 1) {
        return 1 + recursive(n - 1, x - 2);
    }
    return p[n - 1] + 1 + recursive(n - 1, x - bu[n - 1] - 2);
}
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0);
    int n;
    ll x;
    cin >> n >> x;
    p[0] = 1;
    bu[0] = 1;
    for (int i = 1; i < N; ++i) {
        bu[i] = 2 * bu[i - 1] + 3;
        p[i] = 2 * p[i - 1] + 1;
    }
    cout << recursive(n, x) << endl;
    return 0;
}

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

int main(){
  int a,b;

  cin >> a >> b;
  if ( a >=13 ) cout << b << endl;
  else if ( 6 <= a && a <=12 ) cout << b/2 << endl;
  else if ( a < 6) cout << '0' << endl;
  


  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from collections import defaultdict
import math
import re

def main():
    N, L = map(int, input().split())
    total = sum(range(L, L+N))

    if L * (L + N - 1) < 0:
        print(total)
        return

    max_val = max([L, L + N - 1])
    max_abs_val = max_val if max_val > 0 else -max_val
    min_val = min([L, L + N - 1])
    min_abs_val = min_val if min_val > 0 else -min_val

    if max_abs_val < min_abs_val:
        print(total - max_val)
    else:
        print(total - min_val)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
using namespace std;
int n,m;

vector<int>dp;

vector<vector<int>> edge1, edge2;
int dfs(int n)
{
  if(dp[n]>-1)return dp[n];
  int res=0;
  for(int ne:edge2[n])
  {
    res=max(dfs(ne)+1,res);
  }
  dp[n]=res;
  return res;
}

int main()
{
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  dp=vector<int>(n+1,-1);
  edge1=vector<vector<int>>(n+1) ;
  edge2=vector<vector<int>>(n+1) ;
  for(int i=0;i<m;i++)
  {
    int a,b;
    cin>>a>>b;
    edge1[a].push_back(b);
    edge2[b].push_back(a);
  }
  for(int i=1;i<n+1;i++)
  {
    sort(edge1[i].begin(),edge1[i].end());
    sort(edge2[i].begin(),edge2[i].end());
  }
  for(int i=1;i<=n;i++)
  {
    if(dp[i]==-1)dfs(i);
  }


  int res;
  res=*max_element(dp.begin(), dp.end());
  cout<<res<<endl;



  return 0;

}


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

int main() {
  int A,B,C=0;
  cin >> A >> B;
  for(int i=A; i<=B; i++)
    if(i/10000==i%10 && i%10000/1000==i%100/10)
      C++;
  cout << C << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

	ll n;
	cin >> n;
	vector<ll>b(n);
	rep(i, n) cin >> b[i];
	vector<pair<ll, ll>>a(n);
	rep(i, n)a[i] = make_pair(b[i],i);
	sort(all(a));
	rep(i, n) {
		cout << a[i].second + 1 << " ";
	}
}


Measured memory_bytes: 3200
from itertools import accumulate
import collections


N = int(input())
A = list(map(int, input().split()))

def main():
    # 累積和
    B = [0] + A
    B = list(accumulate(B))

    c = collections.Counter(B)
    cm = c.most_common()

    cnt = 0
    for v in cm:
        if v[1] > 1:
            cnt += (v[1]*(v[1]-1)//2)

    return cnt

print(main())


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

int n;
ll x,y;
int main(){
	cin >> n;
	cin >> x >> y;
	for(int i=1;i<n;i++){
		ll a,b; cin >> a >> b;
		ll c = (x+a-1)/a; ll d = (y+b-1)/b;
		x = max(c,d)*a; y = max(c,d)*b;
	}
	cout << x+y << endl;
}

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

int popcnt(int x){
  return __builtin_popcount(x);
}

int f(int x){
  if(x==0) return 0;
  else return f(x%popcnt(x))+1;
}

int main(){

  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> x(n);
  int pc=0;
  for(int i=0;i<n;i++){
    x[i]=s[i]-'0';
    pc+=x[i];
  }

  vector<int> ans(n);
  for(int b=0;b<2;b++){
    int npc=pc;
    if(b==0) npc++;
    else npc--;

    if(npc<=0) continue;

    int r0=0;
    for(int i=0;i<n;i++){
      r0=(r0*2)%npc;
      r0+=x[i];
    }

    int k=1;
    for(int i=n-1;i>=0;i--){
      if(x[i]==b){
        int r=r0;
        if(b==0) r=(r+k)%npc;
        else r=(r-k+npc)%npc;
        ans[i]=f(r)+1;
      }
      k=(k*2)%npc;
    }
  }

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

}

Measured memory_bytes: 5244
n = int(input())

a = list(map(int,input().strip().split()))

t_4 = 0
t_2 = 0
for i in a:
  if i%4==0:
    t_4+=1
  elif i%2==0:
    t_2+=1
other = len(a)-t_4-t_2
if other <= t_4:
  print("Yes")
elif other == t_4 +1:
  if t_2 > 0:
    print("No")
    exit()
  else:
    print("Yes")
    exit()
else:
  print("No")

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

typedef long long ll;
typedef pair<int, int> pi;		// (B, A)

int N;
vector<pi> P;

void input_init(void) {
	cin >> N;
	P.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> P[i].second >> P[i].first;
}

bool solve(void) {
	sort(P.begin(), P.end());
	bool ret = true;
	ll total_t = (ll)0;
	for (int i = 0; i < N; ++i) {
		total_t += (ll)P[i].second;
		ll end_t = (ll)P[i].first;
		if (total_t > end_t) {
			ret = false;
			break;
		}
	}
	return ret;
}

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

	input_init();
	bool ans = solve();

	cout << (ans ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <atcoder/fenwicktree>

using ll = long long;

using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    atcoder::fenwick_tree<ll> fwt(n);
    for (int i=0, ai; i<n; i++) {
        cin >> ai;
        fwt.add(i, ai);
    }
    for (int i=0, t, a, b; i<q; i++) {
        cin >> t >> a >> b;
        if (t == 0) {
            fwt.add(a, b);
        } else {
            cout << fwt.sum(a, b) << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 8216
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

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

	ll N=in();
	deque<ll> A(N);
	REP(i,N){
		A[i]=in();
	}
	sort(ALL(A));
	ll left = A.front();
	ll right = A.back();

	vector<pair<int,int>> H;
	for(int i=1;i<N-1;i++){
		if(A[i]<0){
			H.emplace_back(right,A[i]);
			right -= A[i];
		}
		else{
			H.emplace_back(left,A[i]);
			left -= A[i];
		}
	}
	
	out(right-left);
	for(auto& x:H) out(x.first,x.second);
	out(right,left);
	return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <iomanip>
#include <sstream>

using namespace std;

#define ll long long
#define eps 1e-7
#define inf 0x1fffffff
#define maxn 1000010



bool is[maxn];
vector<int>p;



int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	int n;
	memset(is,true,sizeof(is));
	for(int i=2;i<maxn;i+=2)
		is[i] = false;
	is[0] = is[1] = false;
	p.push_back(2);
	for(int i=3;i<maxn;i+=2)
	{
		if(is[i])
		{
			p.push_back(i);
			for(int j=i+i;j<maxn;j+=i)
			{
				is[j] = false;
			}
		}
	}
	while(cin>>n)
	{
		cout<<upper_bound(p.begin(),p.end(),n)-p.begin()<<endl;
	}
	return 0;
}

Measured memory_bytes: 2612
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define forn(i,n) for(int i=0;i<(int) n;i++)
#define Forn(i,n) for(int i=1;i<=(int) n;i++)

int main()
{
   char ch;
   cin>>ch;
   if(ch=='A') cout<<'T';
   else if(ch=='T') cout<<'A';
    else  if(ch=='G') cout<<'C';
     else  if(ch=='C') cout<<'G';


}






Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long power(long long x, long long y) 
{ 
    long long res = 1;    
    x=x%mod;
    while(y>0) 
    { 
        if(y & 1) 
        res=(res*x)%mod; 
        y=y/2; 
        x=(x*x)%mod;   
    } 
    return res; 
}
int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
   
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m,a,b,c,d;
      cin>>n;
      if(n==1)
      {
          cout<<0; return 0;
      }
      count=(n*(n-1))%mod;
      ans=(power(8,n)+(2*(power(9,n)-power(8,n)+mod)%mod)%mod)%mod;
      k=power(10,n);
      ans=(k-ans+mod)%mod;
      cout<<ans;
      
	return 0;
}

Measured memory_bytes: 3604
n,x,m=map(int,input().split())

A,color=[x],["white" for _ in range(m)]
color[x]="gray"
while 1:
    num=A[-1]**2%m
    if color[num]=="gray":
        A.append(num)
        break
    else:
        color[num]="gray"
        A.append(num)

fixed,loop=[],[]
point=A[-1]
flag=0
for i in A[:-1]:
    if i==point:flag=1

    if flag:loop.append(i)
    else:fixed.append(i)

ans=0
if n<=len(fixed):print(sum(fixed[:n]))
else:
    ans +=sum(fixed)
    div,mod=divmod(n-len(fixed),len(loop))
    ans +=div*sum(loop)
    ans +=sum(loop[:mod])
    print(ans)

Measured memory_bytes: 80844
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
int main()
{  
    ll a1 , a2 ;
   
    ll N ;
    cin >> N ;
    ll a[N] ;
    ll b[N] ;
    for(ll i = 0 ; i < N ; i++){
        cin >> a[i] ;
        b[i] = a[i] ;
    }
    sort(a , a+ N) ;
    a1 = a[N-1] ;
    a2 = a[N-2] ;

    for(ll i = 0 ; i < N ; i++){
        if(b[i] == a1){
            cout << a2 << endl;
        }else{
            cout << a1 << endl;
        }
    }

    
    return 0;
}

Measured memory_bytes: 6760
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}



int main() {
	ll N, K, Q;

	cin >> N >> K >> Q;

	vector<ll> seikai(N);



	rep(i, Q) {
		ll a;

		cin >> a;

		a--;
		seikai[a] += 1;
	}


	rep(i, N) {
		if (K - (Q - seikai[i]) > 0) {
			cout << "Yes" << endl;
		}

		else {

			cout << "No" << endl;
		}
	}


	
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int int64_t
#define ll long long
#define abs(a) llabs(a)
#define re(s) reverse((s).begin(),(s).end())
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int x,n;
    cin>>x;

    int cnt=0;

    if(x <= 6){
        cout<<1<<'\n';
        return 0;
    }

    cnt = (x/11);
    n = x%11;

    if(n == 0){
        cout<<cnt*2<<'\n';
    }else if(n <= 6){
        cout<<cnt*2+1<<'\n';
    }else{
        cout<<cnt*2+2<<'\n';
    }

    return 0;
}

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

int main(){
	int N, T; cin >> N >> T;
	
	vector<int> c(N), t(N);
	for(int i = 0; i < N; i++){
		cin >> c[i] >> t[i];
	}

	int cost = 9999;
	for(int i = 0; i < N; i++){
		if(t[i] <= T && c[i] < cost){
			cost = c[i];
		}
	}

	if(cost != 9999){
		cout << cost;
	}
	else{
		cout << "TLE";
	}
	return 0;
}

Measured memory_bytes: 256
/****************************
    > File Name: a.cpp
    > Author: caoyu01
  	> Mail: yalecyu@gmail.com 
    > Created Time: 2016年09月11日 星期日 20时07分45秒
*****************************/
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cle(x) memset(x,0,sizeof(x))
#define rep(i,x) for(int i=0;i<x;i++)
const int N = 1000+10;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
int main()
{
#ifndef ONLINE_JUDGE
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
#endif
	int a,b,h;
	while(cin>>a>>b>>h)cout<<(a+b)*h/2<<endl;
	return 0;
}


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

int main() {
  int a,b,x;
  cin>>a>>b>>x;
  if(x-a>=0 && x-a<=b) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    int res = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j * i < n; j++) {
            res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3648
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    #h0,w0h1,w1 = map(int, input().split())
    s=input()
    p=input()
    if len(p)>len(s):
        print("No")
        exit()
    if p in s*2:
        print("Yes")
    else:
        print("No")

main()



Measured memory_bytes: 5568
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a*b%2==0){
		printf("Even\n");
	}
	else{
		printf("Odd\n");
	}
	//printf("%d %d %d\n",a,b,a*b);
	return 0;
}
	

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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> d(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> d.at(i);
    }

    sort(d.begin(), d.end());
    int64_t ans = d.at(N / 2) - d.at(N / 2 - 1);
    cout << ans << endl;
}

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

int main() {
	map<char, int> roman;
	roman['I'] = 1;
	roman['V'] = 5;
	roman['X'] = 10;
	roman['L'] = 50;
	roman['C'] = 100;
	roman['D'] = 500;
	roman['M'] = 1000;
	string s;
	while(cin >> s){
		int ans = roman[s[0]];
		for(int i = 1; i < s.size(); ++i){
			if(roman[s[i - 1]] >= roman[s[i]])
				ans += roman[s[i]];
			else
			 	ans += roman[s[i]] - roman[s[i - 1]] - roman[s[i - 1]];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    bool bb=1;
    while (a>0&&c>0){
        if (bb){
            c-=b;
            bb=0;
        }
        else{
            bb=1;
            a-=d;
        }

    }
    if (a<=0)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

void solve(double T, double X) {
  double ans = 0;
  ans = T / X;
  printf("%.10f\n", ans);
}

int main() {
  double T, X;
  cin >> T >> X;
  solve(T, X);
  return 0;
}

Measured memory_bytes: 888
import collections
def main():
    s = input()
    K = int(input())
    d = collections.defaultdict(int)
    idx = collections.defaultdict(list)
    n = len(s)
    for i in range(n):
        idx[s[i]].append(i)

    cand = set()
    for c in sorted(idx.keys())[:K]:
        cand.add(c)
        for i in idx[c]:
            for l in range(1, K+1):
                cand.add(s[i:i+l])

    cand = sorted(list(cand))
    return cand[K-1]

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;

    if (s.compare("AAA") == 0 || s.compare("BBB") == 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

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

        if (S.contains("A") == S.contains("B")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t n;
	cin >> n;
	n++;
	vector<int> digit(0);
	while (n!=0) {
		digit.push_back(n % 10);
		n = (n - (n % 10)) / 10;

	}
	reverse(digit.begin(), digit.end());
	int ans = digit.at(0) - 1 + (digit.size() - 1) * 9;
	cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for i in range(N):
    for j in range(N):
        flg = True
        for k in range(M):
            for l in range(M):
                try:
                    if A[i+k][j+l] != B[k][l]:
                        flg = False
                except IndexError:
                    flg = False
        if flg:
            print("Yes")
            exit()

print("No")

Measured memory_bytes: 43244
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] a = new int[N];

    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }

    sc.close();

    int min = Integer.MAX_VALUE;

    for (int i = -100; i <= 100; i++) {
      int cost = 0;
      for (int j = 0; j < N; j++) {
        int dif = (int) Math.abs(a[j] - i); 
        cost += dif * dif;
      }
      min = Math.min(min, cost);
    }

    System.out.println(min);

  }

}

Measured memory_bytes: 21844
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (mat (make-array (list n n) :element-type 'uint32))
         (res (make-array (list n n) :element-type 'uint32)))
    (dotimes (i n)
      (dotimes (j n)
        (setf (aref res i j) (setf (aref mat i j) (read-fixnum)))))
    (dotimes (k n)
      (dotimes (i n)
        (dotimes (j n)
          (let ((new-dist (+ (aref mat i k) (aref mat k j))))
            (when (> (aref mat i j) new-dist)
              (println -1)
              (return-from main))
            (when (and (= (aref mat i j) new-dist)
                       (/= i k)
                       (/= k j))
              (setf (aref res i j) 0))))))
    (println (floor (reduce #'+ (array-storage-vector res)) 2))))

#-swank(main)



Measured memory_bytes: 37480
// CODE by Kazhybay Askar
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define iter   set<int>::iterator
#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define mp     make_pair
#define cont   continue
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 1e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll a[MAXN],b[MAXN],dp[MAXN];
vector<int>g[MAXN],v;
bool used[MAXN];
ll n,m,k,cnt,sum,ans,mx,mn=INF;
bool y;

void freopen(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}


void solve(){
	cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        dp[i]=INF;

    }
    dp[1]=0;
    for(int i=2;i<=n;i++){
        dp[i]=min(dp[i],dp[i-1]+abs(a[i-1]-a[i]));
        if(i>2)dp[i]=min(dp[i],dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n];
}

int main(){
	Speed;
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	r0;
}




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

namespace abc128_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var d = new SortedDictionary<string, SortedDictionary<int, int>>();

      for (var i = 1; i <= n; i++)
      {
        var s = CIn.Read();
        var p = CIn.ReadInt();

        if (d.ContainsKey(s)) d[s].Add(p, i);
        else d.Add(s, new SortedDictionary<int, int>() { [p] = i });
      }

      foreach (var e1 in d)
      {
        foreach (var e2 in e1.Value.Reverse())
        {
          Console.WriteLine(e2.Value);
        }
      }
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 11996
#include <bits/stdc++.h>
using namespace std;
int n, sum, a[105];
int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(a[i] % 2 == 1 && i % 2 == 1)
			sum++;
	}
	printf("%d\n", sum);
	return 0;
}

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

int main() {
    vector <int> s(3);
    int ans;
    
    for(int i = 0;i < 3;i++){
        cin >> s[i];
    }
   
   sort(s.begin(),s.end());
    
    ans = s[0] + s[1];
    
    cout << ans;
    
	return 0;
}


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

const int MAX_N = 100000000;
int digs[MAX_N];
int K;
int max_idx = 0;

void update_digs(int idx, int v) {
  digs[idx] += v;
  if (digs[idx] > 9) {
    digs[idx+1] += digs[idx] / 10;
    digs[idx] %= 10;
  }
  if (digs[idx]) max_idx = std::max(max_idx, idx);
  if (digs[idx+1]) max_idx = std::max(max_idx, idx+1);
}

int main() {
  scanf("%d", &K);
  int idx = 0;
  int kk = K;
  max_idx = -1;
  while (kk) {
    max_idx++;
    kk /= 10;
  }
  while (1) {
    int found = -1;
    for (int m = 0; m <= 9; ++m) {
      int v = (m * (K % 10) + digs[idx]) % 10;
      if (v == 7) {
        found = m;
        break;
      }
    }
    if (found != -1) {
      int kk = K;
      for (int i = 0; kk; ++i) {
        int v = kk % 10;
        update_digs(idx + i, found * v);
        kk /= 10;
      }
    }
    // printf("%d %d %d %d\n", found, idx, max_idx, digs[idx]);
    if (idx >= max_idx && digs[idx] == 7) break;
    if (found == -1 && digs[idx] != 7) {
      printf("-1\n");
      return 0;
    }

    idx++;
    if (idx > MAX_N - 10) {
      printf("-1\n");
      // printf("BROKEN\n");
      return 0;
    }
  }
  printf("%d\n", max_idx + 1);
}


Measured memory_bytes: 7560
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL)
#define cases ll t; cin>>t; while(t--)
#define rep(qq,pp) for(ll i=qq;i<pp;i++)
#define nl "\n"

int main() {
    faster;

    int n,m;

    cin>>n>>m;
    cout<<n*m<<nl;
}


Measured memory_bytes: 3652
using System;
using System.Linq;

namespace testing
{
    class Program
    {

        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if ((a[0] * a[1]) < a[2]) { Console.WriteLine(a[0] * a[1]); }
            if ((a[0] * a[1]) > a[2]) { Console.WriteLine(a[2]); }
            if ((a[0] * a[1]) == a[2]) { Console.WriteLine(a[0] * a[1]); }
        }
    }
}


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

#define ll long long

bool kmax(vector<ll> &v,ll log,ll k) {
	ll sum = 0;
	for(int i = 0;i < v.size()	;i++)
		sum += (v[i]-1)/log;
	return sum<=k;
}
ll bs(vector<ll> &v,ll low,ll high,ll k) {
	if(low < high) {
		ll mid = (high+low)/2;
		if(kmax(v,mid,k))
			return bs(v,low,mid,k);
		else
			return bs(v,mid+1,high,k);
	}
	return low;
}
int main() {
	ll n,k;
	cin >> n >> k;
	vector<ll> v(n);
	ll max_val = 0;
	for(int i = 0;i<n;i++)
	{
		cin >> v[i];
		if(max_val < v[i])
			max_val	= v[i];
	}
	cout << bs(v,1,max_val,k) << endl;
	return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<double> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = 0;
    for (int i = 0; i < n; i++) {
        ans += v[i];
        if (i) ans /= 2;
    }
    printf("%.12f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,m,l,r,min = 1000000,max = 0;
  scanf("%d %d",&n,&m);
  for(int i = 0;i < m;i++){
    scanf("%d %d",&l,&r);
    if(l > r){
      int t = l;
      l = r;
      r = t;
    }
    if(l > max)max = l;
    if(min > r)min = r;
  }
  if(max > min){
    printf("0\n");
  }else{
    printf("%d\n",min - max + 1);
  }
  return 0;
}

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

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

    int ans = 1;
    char tmp = S[0];
    for (int i = 1; i < N; ++i){
        if(tmp == S[i]) continue;
        else {
            tmp = S[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a, b;
  bool flag1 = false;
  bool flag2 = false;
  bool flag_a = false;
  for(int i=0;i<n;i++) {
    cin >> a >> b;
    if(a == b) {
      if(flag1 == false) flag1 = true;
      else if(flag1 == true && flag2 == false) flag2 = true;
      else if(flag2 == true) {
        flag_a = true;
        break;
      }
    } else {
      flag1 = false;
      flag2 = false;
    }
  }
  flag_a ? puts("Yes") : puts("No");
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int m,k;
  cin >> m >> k;
  if(1<<m <= k){
    cout << -1 << endl;
  }
  else if(m==0){
    printf("0 0\n");
  }
  else if(m==1){
    if(k==0) printf("0 0 1 1\n");
    else printf("-1\n");
  }
  else {
    int mm = 1<<m;
    rep(i,mm) if(i!=k) printf("%d ",i);
    printf("%d ",k);
    rep(i,mm) {
      int ii = mm - 1 - i;
      if(ii!=k) printf("%d ",ii);
    }
    printf("%d\n",k);
  }
}


Measured memory_bytes: 1792
x,y = gets.split.map(&:to_i)
ga = [1,3,5,7,8,10,12]
gb = [4,6,9,11]
gc = [2]

if ga.include?(x) && ga.include?(y) || gb.include?(x) && gb.include?(y) || gc.include?(x) && gc.include?(y)
    puts 'Yes'
else
    puts 'No'
end

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

int main () {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  if( K <= A) { 
    cout << K << endl;
  } else if( K <= A + B) {
    cout << A << endl;
  } else {
    int tmp = K - (A+B);
    cout << A - tmp << endl;
  }
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

#define MAX 2000000000
#define MOD 1000000007


int main(void)
{
  int x,a,b;
  scanf("%d%d%d",&x,&a,&b);
  if(abs(x-a)>abs(x-b)) printf("B\n");
  else printf("A\n");
	return 0;
}

Measured memory_bytes: 128
import Foundation

let input = readLine()!.componentsSeparatedByString(" ")
let array = readLine()!.componentsSeparatedByString(" ").map{ Int($0)! }
var N = 0
var maxDis = 0
for e in array{
  let dist = e - N
  if(dist > maxDis){
    maxDis = dist
  }
  N = e
}
let around = Int(input[0])!
if(around - N + array[0] > maxDis){
  maxDis = around - N + array[0]
}
print(around - maxDis)

Measured memory_bytes: 18720
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    int ans = 0;
    REP(i, N)
    {
        while (a[i] % 2 == 0)
        {
            a[i] /= 2;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main() {
    ll n;
    cin >> n;
    map<ll, ll> mp;
    rep(i, n) {
        ll tmp_num;
        cin >> tmp_num;
        ++mp[tmp_num];
    }
    ll m;
    cin >> m;
    rep(i, m) {
        ll tmp_num;
        cin >> tmp_num;
        --mp[tmp_num];
    }
    for ( auto tmp_mp: mp) {
        if ( tmp_mp.second < 0 ) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#define INF long long (int)1e18+1
#define MAX 200001
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;
	
int main() {
	string s;
	cin >> s;
	if (s[s.size() - 1] == 's')cout << s + "es" << endl;
	else cout << s + 's' << endl;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    cout << (set<int>({7, 5, 3}).count(n) ? "YES" : "NO") << endl;
  }
  
  return 0;
}


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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = [int(e) for e in lines[0].split(" ")][0]
    (s, t) = [e for e in lines[1].split(" ")]

    return (n, s, t)


def solve(n, s, t):


    result = []
    for i in range(n):
        result.append(s[i])
        result.append(t[i])
    

    return "".join(result)


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;

int main() {
  int q;
  cin >> q;
  string k;
  multimap<string, int> M;
  while (cin >> q >> k) {
    if (q == 0) {
      int x;
      cin >> x;
      M.insert({k, x});
    }
    if (q == 1) {
      auto p = M.equal_range(k);
      while (p.first != p.second)
        cout << (*(p.first++)).second << endl;
    }
    if (q == 2)
      M.erase(k);
    if (q == 3) {
      string r;
      cin >> r;
      auto lo = M.lower_bound(k);
      auto hi = M.upper_bound(r);
      while (lo != hi) {
        auto p = *(lo++);
        cout << p.first << " " << p.second << endl;
      }
    }
  }
}


Measured memory_bytes: 24872
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin >> s >> t;
    int alpha_s[26], alpha_t[26];
    for( int i = 0; i < 26; ++i ) alpha_s[i] = alpha_t[i] = -1;

    bool flg = true;
    for( int i = 0; i < s.size(); ++i ) {
        if( alpha_s[s[i] - 'a'] == -1 ) {
            alpha_s[s[i] - 'a'] = t[i];
        
        } else {
            if( alpha_s[s[i] - 'a'] != t[i] ) flg = false;
        }
        if( alpha_t[t[i] - 'a'] == -1 ) {
            alpha_t[t[i] - 'a'] = s[i];

        } else {
            if( alpha_t[t[i] - 'a'] != s[i] ) flg = false;

        }
    }

    if( flg ) cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;

//union-find tree
//要素数nで初期化
//必要に応じて操作ができるように各操作を関数にしておく
//MAX_Nを設定しておく
vector<ll> par(1000000);//親（一つ上のノード）を持つ
vector<ll> ran(1000000,0);

void ini(int x){
    for(int i=0;i < x;i++)
    {
        par.at(i)=i;
    }
}
//-----------↑初期化↑--------------

ll findroot(ll x){
    if(par.at(x)==x){
        return x;
    }else{
        return findroot(par.at(x));
    }
}//根を見つける

//-----------↑親を見つける↑---------------

bool same(ll x,ll y){
    return par.at(x)==par.at(y);
}

//-----------↑同じグループかどうか判定↑----------

void unite(ll x,ll y){
    x=findroot(x);
    y=findroot(y);
    if(x==y){
        return ;
    }//二要素の根が同じならおわり

    if(ran.at(x)<ran.at(y)){
        par.at(x)=y;
    }else if(ran.at(x)>ran.at(y)){
        par.at(y)=x;
    }else{
        par.at(x)=y;
        ran.at(y)++;//ランクの低い方の木の根を高い方の根につなげる
    }
}
//-----------↑二つの要素をつなげる↑------------


signed main(){
    ll n,m,ans=0;
    cin>>n>>m;
    ini(n);
    vector<bool> v(n,false);
    for(int i=0;i < m;i++)
    {
        ll x,y,z;
        cin>>x>>y>>z;
        unite(x-1,y-1);
    }

    for(int i=0;i < n;i++)
    {
        if(v.at(findroot(i))==false){
            ans++;
            v.at(findroot(i))=true;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
int n;

int main(){
	IOS
	cin >> n;
	int arr[n+5];
	ll alice=0;
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	sort(arr, arr+n);
	for(int i=n-1;i>=0;i-=2){
		alice+=arr[i]-arr[i-1];
	}
	cout << alice << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
using namespace std;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<< " "<< b<<  " "<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt(); //pops
		int an = 0;
		
		
		boolean div = false;
		if(n%4 == 0 && (n%4)%m == 0)
		{
			div = true;
		}
		
		int[] a = new int[n];
		int sum = 0;
		
		for(int i = 0; i < n; i++)
		{
			a[i] = sc.nextInt();
			sum += a[i];
		}
		
		
		for(int i = 0; i < n; i++)
		{
			if(a[i] * 4 * m >= sum)
				an++;
		}
		
		if(an >= m)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}


Measured memory_bytes: 22736
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Dice dice = new Dice(sc);
        char[] point = sc.next().toCharArray();
        for(char p:point){
            dice.roll(p);
        }
        System.out.println(dice.dice.get(0));
    }
}

class Dice{
    static ArrayList<String> dice = new ArrayList<>();
    static final int[] EAST = {2,5,3,0};
    static final int[] WEST = {3,5,2,0};
    static final int[] SOUTH = {1,5,4,0};
    static final int[] NORTH = {4,5,1,0};
    static String g;
    
    public Dice(Scanner sc){
        for(int i = 0; i < 6; i++){
            dice.add(sc.next());
        }
    }
    public static void roll(char point){
        g = dice.get(0);
        switch(point){
            case 'E':
                for(int i:EAST){
                    g = dice.set(i,g);
                } break;
            case 'W':
                for(int i:WEST){
                    g = dice.set(i,g);
                } break;
            case 'S':
                for(int i:SOUTH){
                    g = dice.set(i,g);
                } break;
            case 'N':
                for(int i:NORTH){
                    g = dice.set(i,g);
                } break;
            default:
        }
    }
}

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

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

  cout << A + B + C + (pow(2, K) - 1) * max({A, B, C}) << endl;
  return 0;
}

Measured memory_bytes: 4184
S = input()

c_count = 0
if S[0] == 'A' and S[1].islower() and S[-1].islower():
    for s in S[2:-1]:
        if s == 'C':
            c_count+=1
        elif s.islower():
            continue
        else:
            c_count = None
            break

if c_count == 1:
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3060
while True:
    l,m=map(int,input().split())
    if l==0 and m==0:
        break
    a=[int(input()) for i in range(l)]
    b=sum(a[0:m])
    c=[b]
    for i in range(l-m):
        b+=a[i+m]-a[i]
        c.append(b)
    print(max(c))
        


Measured memory_bytes: 11744