akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl




signed main(){

	string S;
	cin >> S;

	rep(n, 16){
		string t;
		if (n&(1 << 0)) t += "A";
		t += "KIH";
		if (n&(1 << 1)) t += "A";
		t += "B";
		if (n&(1 << 2)) t += "A";
		t += "R";
		if (n&(1 << 3)) t += "A";

		cerr << t << endl;

		if (S == t){ YES; return 0; }
	}
	NO;


	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

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

using namespace std;

const ll p = (1e+9) + 7;

ll add(ll a, ll b) {
	return (a + b) % p;
}

ll sub(ll a, ll b) {
	return (a + p - b) % p;
}

ll mul(ll a, ll b) {
	return ((a%p)*(b%p)) % p;
}

ll power(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	else if (b == 1) {
		return a % p;
	}
	else if (b % 2 == 0) {
		ll c = power(a, b / 2);
		return (c*c) % p;
	}
	else {
		ll c = power(a, b / 2);
		return (((c*c) % p)*a) % p;
	}
}

ll divi(ll a, ll b) {
	return mul(a, power(b, p - 2));
}




int main() {
	int N;
	string S1, S2;
	cin >> N >> S1 >> S2;

	int state = -1;
	ll ans = 1;
	int i = 0;
	while(i< N) {
		if (state == -1) {
			if (S1[i] == S2[i]) {
				ans = mul(ans, 3);
				state = 0;
				i++;
			}
			else {
				ans = mul(ans, 6);
				i += 2;
				state = 1;
			}
		}
		else if (state == 0) {
			if (S1[i] == S2[i]) {
				ans = mul(ans, 2);
				state = 0;
				i++;
			}
			else {
				ans = mul(ans, 2);
				i += 2;
				state = 1;
			}
		}
		else {
			if (S1[i] == S2[i]) {
				state = 0;
				i++;
			}
			else {
				ans = mul(ans, 3);
				i += 2;
				state = 1;
			}
		}
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
// I/O
#include <iostream>
#include <iomanip>

// data structures
#include <set>
#include <queue>
#include <vector>

// manipulations
#include <algorithm>

#define rep(i,n) for(int i=0;i< (n);++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define for_lowercase(c) for(int c='a';c<='z';++c)
#define for_uppercase(c) for(int c='A';c<='Z';++c)
#define ALL(a) (a).begin(),(a).end()
using LLI = long long int;
LLI GCD(LLI a,LLI b){ if(a<b) return GCD(b,a); else if(a%b==0) return b; else return GCD(b,a%b); }
LLI LCM(LLI a,LLI b){ return (a/GCD(a,b))*b; }
using VI  = std::vector<LLI>;
using PI  = std::pair<LLI,LLI>;
using VVI = std::vector<VI>;
using VPI = std::vector<PI>;
template<class T> bool is_odd (T x){ return   x%2 ; }
template<class T> bool is_even(T x){ return !(x%2); }
LLI combination(LLI n,LLI k,bool reset=false){
    static VVI C; static LLI n_hashed = -1;
    if(n<0){ std::cerr << "[ERROR] n must be non-negative in combination()" << std::endl; exit(1); }
    if(!(0<=k&&k<=n)){ std::cerr << "[WARNING] k should be in range [0,n] in combination()" << std::endl; return 0; }
    if(n_hashed<n || reset){
        C.resize(n+1);
        for(int i=0;i<=n;++i) C[i].resize(i+1,1); // filled with 1
        for(int i=1;i<=n;++i)for(int j=1;j<i;++j) C[i][j] = C[i-1][j-1] + C[i-1][j];
        n_hashed = n;
    }
    return C[n][k];
}

int main() {
    std::ios::sync_with_stdio(false);
    std::string S;
    std::cin >> S;
    std::cout << S.substr(0,S.length()-8) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,T,c,t,ans=10000;
int main()
{
    scanf("%d%d",&n,&T);
    for(int i=1;i<=n;i++)
    {
    	scanf("%d%d",&c,&t);
    	if(t<=T)ans=c<ans?c:ans;
	}
	if(ans==10000)printf("TLE");
	else printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <iterator>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <random>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

#define MOD 1000000007
#define inf 2000000000

set<int> edg[101000];

int main() {

#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long n, k;
	cin >> n >> k;

	long long tmp = n / k;
	long long ans = tmp * tmp * tmp;
	if (k % 2 == 0 && n >= (k / 2))
	{
		tmp = n / k;
		if ((n % k) >= (k / 2))
			tmp++;
		ans += tmp * tmp * tmp;
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 4992
#encoding:utf-8
d_ary = []
while gets
 d_ary.push $_.to_i
end

i = 0
while i < d_ary.length
 s = 0
 x = d_ary[i]
 width = d_ary[i]
 while x < 600
  length = x**2
  s += length * width
  x += d_ary[i]
 end
 puts s
 i += 1
end

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

int main() {
	// your code goes here
    string s;
    cin>>s;
    int n = s.size();
    long long ans=0;
    for(int i=0;i<n;i++){
        ans = ans + (s[i] - '0');
    }
    if(ans%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
	return 0;
}

Measured memory_bytes: 3732
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
    int i = 0,h,n,sum = 0,a;

    scanf("%d%d",&h,&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        sum += a;
    }

    if(sum >= h) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 256
import kotlin.math.ceil

fun main(args: Array<String>) {
    //val (h, w)= Pair(1L, 4L)
    val (h, w)= readLine()!!.split(" ").map { it.toLong() }

    if (h == 1L || w == 1L) {
        println("1")
        return
    }

    val answer = ceil((h * w).toDouble() / 2).toLong()

    println("$answer")
}


Measured memory_bytes: 36288
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    string s;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            std::deque<string> deq;
            int max_size=0;
            string tmp;
            for (int i=0;i<n;i++) {
                cin>>s;
                tmp="";
                for (int j=0;j<s.size();j++) {
                    if (j==0) {
                        tmp+=s.at(j);
                    }
                    if ( (s.at(j)=='a'||s.at(j)=='i'||s.at(j)=='u'||s.at(j)=='e'||s.at(j)=='o')&&j!=s.size()-1) {
                        tmp+=s.at(j+1);
                    }
                }
                deq.emplace_back(tmp);
                if (max_size<tmp.size()) {
                    max_size=tmp.size();
                }
            }
            int bad_count=0;
            for (int k=1;k<=max_size;k++) {
                std::deque<string> code;
                int count=0;
                for (int l=0;l<deq.size();l++) {
                    if (deq[l].size()<k) {
                        if (find(code.begin(),code.end(),deq[l])==code.end()) {
                            code.emplace_back(deq[l]);
                            count++;
                        } else {
                            break;
                        }
                    } else {
                        if (find(code.begin(),code.end(),deq[l].substr(0,k))==code.end()) {
                            code.emplace_back(deq[l].substr(0,k));
                            count++;
                        } else {
                            break;
                        }
                    }
                }
                if (count==deq.size()) {
                    cout<<k<<endl;
                    break;
                } else {
                    bad_count++;
                }
            }
            if (bad_count==max_size) {
                cout<<-1<<endl;
            }
        }
    }
}


Measured memory_bytes: 3172
#include<stdio.h>
#include<string.h>
int F(char c){return !strchr("yuiophjklnm",c);}
int main()
{
	char s[64];
	int i,r,f,g;
	while(scanf("%s",s),*s-'#')
	{
		f=F(*s);
		for(i=r=0;s[++i];)
		{
			g=F(s[i]);
			r+=f!=g;
			f=g;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{
    public class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            Console.WriteLine((x / 500) * 1000 + ((x % 500) / 5) * 5);
        }
    }
}


Measured memory_bytes: 13140
def solve(n, u, v, w):
    res = [-1] * (n+1)
    res[1] = 0
    E = {_: [] for _ in (set(u) | set(v))}
    W = {}
    for u_i, v_i, w_i in zip(u, v, w):
        E[u_i].append(v_i)
        E[v_i].append(u_i)
        W[(u_i, v_i)] = w_i
        W[(v_i, u_i)] = w_i
    que = [1]
    while que:
        s = que.pop(0)
        for t in E[s]:
            if res[t] != -1:
                continue
            d = W[s,t]
            que.append(t)
            if d % 2 == 0:
                res[t] = res[s]
            else:
                res[t] = 1 - res[s]
    return "\n".join(map(str, res[1:]))

n = int(input())
u = [0] * n
v = [0] * n
w = [0] * n
for i in range(n-1):
    u[i], v[i], w[i] = map(int, input().split())
print(solve(n, u, v, w))

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

using lint = long long;
using ldouble = long double;

void solve() {
    int h, n;
    std::cin >> h >> n;

    while (n--) {
        int a;
        std::cin >> a;
        h -= a;
    }

    std::cout << (h <= 0 ? "Yes" : "No") << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer cout<<endl<<"answer : ";
#define maxn 100005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0;string s;bool flag=false;
        cin>>n; lld a[n]; for(i=0;i<n;i++) {cin>>a[i];cnt+=a[i];}
        map<lld,lld> mps;
        for(i=0;i<n;i++)
            if(mps.find(a[i])==mps.end())
                mps[a[i]]=1;
            else
                mps[a[i]]++;
        cin>>q;
        while(q--)
        {
            cin>>x>>y;
            if(mps.find(x)!=mps.end())
            {
                cnt-=mps[x]*x;
                cnt+=mps[x]*y;
                if(mps.find(y)==mps.end())
                    mps[y]=mps[x];
                else
                    mps[y]+=mps[x];
                mps[x]=0;
            }
            cout<<cnt<<endl;
        }
 
 
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|
 
*/

Measured memory_bytes: 9536
#include<bits/stdc++.h>
#define LL long long int 
#define LD long double
#define PI 3.14159265358979323846
#define MOD ((LL)1e9+7)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const LL N=1e5+10;
vector<LL>A(N),dp(N);
vector<bool>f(N);
LL n,k;

/*
LL DP(LL I)
{
	if(f[I])return dp[I];
	if(I==1)dp[I]=0;
	else if(I==2)dp[I]=abs(A[1]-A[2]);
	else
	{
		dp[I]=min(DP(I-1)+abs(A[I-1]-A[I]),DP(I-2)+abs(A[I]-A[I-2]));
	}
	f[I]=true;
	return dp[I];
	
}*/

int main()
{
	IOS
	cin>>n>>k;
	for(LL i=1;i<=n;i++)cin>>A[i];
	dp[1]=0;
	for(LL i=2;i<=n;i++)
	{
		LL d=1e18;
		for(LL j=1;j<=k && i-j>=1 ;j++)
		d=min(d,abs(A[i]-A[i-j])+dp[i-j]);
		dp[i]=d;
	}
	cout<<dp[n]<<endl;
		
	
	
}
			
				
			
	
	
	
			
		



Measured memory_bytes: 1792
import sys
def divisors(n,TF):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if TF == 1:
                if i != n // i:
                    divisors.append(n//i)
    return divisors
N = int(input())
if N == 2:
    print(1)
    sys.exit()

ans = len(divisors(N - 1, 1)) + 2
A = divisors(N, 0)
for i in A:
    x = N
    while x % i == 0:
        x //= i
    if x % i == 1:
        ans += 1
print(ans)


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

int main(){
	int n;
  	cin >> n;
  	bool key = 0;	
  	while(n>0){
    	if(n%10 == 7)
          key=1;
      	n/=10;
    }
  	if(key)
      	cout<<"Yes"<<endl;
 	else
      	cout<<"No"<<endl;
}

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

int main (){
  int N,M;
  cin >> N >> M;
  vector<int> vec(M*2);
  for (int i=0; i<M*2;i++){
    cin >> vec.at(i);
  }
  for (int i=0; i<N;i++){
    int count =0;
    for (int j=0;j<M;j++){
      for (int k=0;k<2;k++){
        if (i+1 ==vec.at(j*2+k)){
          count++;
        }
      }
    }
    cout << count <<endl;
  }
}
      
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vii vector<int>
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll s;
    cin>>s;
    ll num=1000000000;
    ll rem=s%num;
    rem=(num-rem)%num;
    s=(s+rem)/num;
    cout<<"0 0 ";
    cout<<num<<" 1 ";
    cout<<rem<<" "<<s;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a_list = [ int(v) for v in input().split() ]

def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a

gcd_l = [ a_list[0] for i in range(n) ]
gcd_r = [ a_list[-1] for i in range(n) ]
for i in range(n-1):
    gcd_l[i+1] = gcd(gcd_l[i],a_list[i+1])
a_list.reverse()
for i in range(n-1):
    gcd_r[i+1] = gcd(gcd_r[i],a_list[i+1])
gcd_r.reverse()

ans_list = [ gcd_r[1] ] + [ gcd(gcd_l[i], gcd_r[i+2])  for i in range(n-2) ] + [ gcd_l[-2] ]
print(max(ans_list))

Measured memory_bytes: 68972
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;

#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }

#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
//#define endl "\n"
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        int k;
        cin>>k;
        int ans = 0;
        foo(i,1,k+1)
        foo(j,1,k+1)
        foo(k1,1,k+1){
            // cout << i << " " << j << " " << k1 << endl;
            // deb(__gcd(__gcd(i, j), k1));
            ans += __gcd(__gcd(i, j), k1);
        }
        cout << ans;
    }
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


ll ab(ll x){
  if(x >= 0)  return x;
  else return -x;
}

int main(){
  ll N;
  ll a[1000000];
  cin >> N;
  a[0] = 0;
  a[N+1] = 0;
  for(int i = 1; i <= N; i++){
    cin >> a[i];
  }
  ll s = 0;
  for(int i = 1; i <= N+1; i++){
    s += ab(a[i] - a[i-1]);
  }

  for(int i = 1; i <= N; i++){
    ll x = ab(a[i+1]-a[i-1]) - (ab(a[i+1]-a[i])+ab(a[i]-a[i-1]));
    cout << s + x << endl;
  }

  return 0;
}


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

x = []
y = []

sm = 0

for _ in range(n):

    tmp_x, tmp_y = map(int, input().split())
    
    if len(x)>0:
        for i in range(_):
            diff = ((tmp_x - x[i])**2 + (tmp_y - y[i])**2)**0.5
            sm += diff       
    x.append(tmp_x)
    y.append(tmp_y)

print (2*sm/n)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
char a[200005];
int b[200005]={0};
int c[200005]={0};
int main()
{
    int n;
    cin >> n;
    cin >> a+1;
    for(int i=1;i<=n;i++){
        b[i]=b[i-1];
        if(a[i]=='W')
            b[i]++;
    }
    for(int i=n;i>0;i--){
        c[i]=c[i+1];
        if(a[i]=='R')
            c[i]++;
    }
    int ans = n+1 ;
    for(int i=1;i<=n+1;i++){
        ans = min(ans,max(b[i-1],c[i]));
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  string s;
  cin>>s;
  if ((s[0] == s[1] && s[1] == s[2]) || (s[2] == s[3] && s[1] == s[2])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
from sys import stdin
#, setrecursionlimit, stdout
#setrecursionlimit(1000000)
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
#from heapq import heapify, heappop, heappush, heappushpop, heapreplace
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())
#mod=1000000007
res=['NET', 'DA']
############# CODE STARTS HERE #############

def bin_search(a, val):
    pos, l, r=0, 0, len(a)-1
    while l<=r:
        m=(l+r)//2
        if a[m]<=val:
            pos=m+1
            l=m+1
        else:
            r=m-1
    return pos


test_case=1
while test_case:
    test_case-=1


    n, m, k=mi()
    a=li()
    b=li()
    for i in range(1, n):
        a[i]+=a[i-1]
    for i in range(1, m):
        b[i]+=b[i-1]
    ans=0
    a=[0]+a
    for i in range(n+1):
        if a[i]<=k:
            c=bin_search(b, k-a[i])
            ans=max(ans, c+i)
    print(ans)

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

using namespace std;

int main() {
  int x, n;
  cin >> x >> n;
  set<int> st;
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    st.insert(p);
  }

  int diff = 1e9;
  int m = -1;
  for (int i = -150; i <= 150; ++i) {
    if (st.find(i) == st.end()) {
      int d = abs(i - x);
      if (d < diff) {
	m = i;
	diff = d;
      }
    }
  }
  cout << m << '\n';
  return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
#define fi fisrt
#define se second
#define l(s) s.size()
int n;
string s;
ll ans;
int main()
{
	cin>>s;
	n=l(s)-1;
	for(int i=0;i<(1<<n);i++)
	{
		ll sum,now;
		sum=now=0;
		for(int j=0;j<=n;j++)
		{
			now*=10;
			now+=s[j]-'0';
			if(i&(1<<j))
			{
				sum+=now;
				now=0;
			}
		}
		sum+=now;
		ans+=sum;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
// finish date: 2019/06/30

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


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

    map<int, int> check_is2;
    rep(i, N) check_is2[a[i]]++;
    if (check_is2.size() == 1) {
        if (a[0] == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }

    if (check_is2.size() == 2) {
        if (N % 3 == 0 && check_is2[0] == N / 3) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }

    if (check_is2.size() == 3) {
        vi val(3);
        vi cnt(3);
        int i = 0;
        for (auto e:check_is2) {
            val[i] = e.first;
            cnt[i] = e.second;
            i++;
        }
        if (((val[0] ^ val[1]) == val[2]) && (cnt[0] == cnt[1]) && (cnt[1] == cnt[2])) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }


    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

int main(){
    ll N,S;
    cin >> N >> S;
    vector<ll> X(N),P(N),L,R,res;
    for(int i=0;i<N;i++){
        cin >> X[i] >> P[i];
        if(X[i]<S) L.emplace_back(i);
        else R.emplace_back(i);
    }
    if(L.empty()){
        cout << X[R.back()]-S << endl;
        return 0;
    }
    if(R.empty()){
        cout << S-X[L.front()] << endl;
        return 0;
    }
    int ls = L.size(),rs = R.size(),l = 0,r = 0;
    reverse(R.begin(),R.end());
    ll sum = P[R[0]]+P[L[0]];
    bool left = true;
    if(P[L[0]]>=P[R[0]]){
        res.emplace_back(X[R[0]]);
        r = 1;
    }else{
        res.emplace_back(X[L[0]]);
        l = 1;
        left = false;
    }
    while(l<ls && r<rs){
        if(left){
            if(sum>=P[R[r]]){
                res.push_back(X[R[r]]);
                sum += P[R[r]];
                r++;
            }else{
                res.push_back(X[L[l]]);
                sum += P[R[r]];
                l++;
                left = false;
            }
        }
        else{
            if(sum>P[L[l]]){
                res.push_back(X[L[l]]);
                sum += P[L[l]];
                l++;
            }else{
                res.push_back(X[R[r]]);
                sum += P[L[l]];
                r++;
                left = true;
            }
        }
    }
    if(left && l!=ls) res.push_back(X[L[l]]);
    else if(!left && r!=rs) res.push_back(X[R[r]]);
    res.push_back(S);
    ll ans = 0;
    reverse(res.begin(),res.end());
    for(int i=0;i<res.size();i++){
        if(i!=res.size()-1) ans += abs(res[i+1]-res[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,m;
    scanf("%d%d%d",&a,&b,&m);
    int A[a], B[b];
    int mina = 1000000, minb = 1000000, ans = 1000000;
    for (int i = 0; i < a; i ++){
        scanf("%d",&A[i]);
        mina = min(mina,A[i]);
    }
    for (int i = 0; i < b; i ++){
        scanf("%d",&B[i]);
        minb = min(minb,B[i]);
    }
    for (int i = 0; i < m; i++){
        int x,y,c;
        scanf("%d%d%d",&x,&y,&c);
        ans = min(ans,A[x-1]+B[y-1]-c);
    }
    printf("%d",min(ans,mina+minb));
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;


void swap(int &a ,int &b)
{
	int temp;
	if( a > b)
	{
		temp = a;
		a = b;
		b = temp;
	}
}

int main(void)
{
	int a[3000][2];
	
	int i = 0;
	for( ;  i < 3000 ; i++)
	{
		cin >> a[i][0] >> a[i][1];
		swap( a[i][0] ,a[i][1] );
		
		if( !(a[i][0] | a[i][1]) ) break;
	}
	
	for(int j = 0 ; j < i ; j++)
	{
		cout << a[j][0] << " " << a[j][1] << endl;
	}
		
	return 0;
} 



Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int a[10000000];
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
int cmp(int x,int y){
	return x>y;
}

int main(){
    int N=read();
    int M=read();
//    int F=
    long long all=0;
    
    for(int i=1;i<=N;i++){
    	a[i]=read();
    	all+=a[i];
	}
	double F=(all)*(1.0/(4*M));
	sort(a+1,a+1+N,cmp);
	if(a[M]>=F){
		cout<<"Yes\n";
	}
	else
	cout<<"No"<<endl;
	
 	return 0;
} 

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

int main(){
    int N,M,X,*A,i,cost=0;
    cin >> N >> M >> X;
    A = new int[M];
    for(i=0;i<M;i++){
        cin >> A[i];
        if(A[i]>X){
            cost++;
        }
    }
    cout << min(cost , M-cost) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b;
  cin >> a >> b;
  int YABAI;
  YABAI = b - a;
  YABAI ++;
  int WAYO;
  WAYO = 0;
  int OOTJNY, KYR;
  KYR = 0;
  OOTJNY = a;
  int TOMIO;
  int c, d, e, f, g;
  
  while(YABAI > WAYO){
      c = OOTJNY % 10;
      TOMIO = OOTJNY / 10;
      d = TOMIO % 10;
      TOMIO /= 10;
      e = TOMIO % 10;
      TOMIO /= 10;
      f = TOMIO % 10;
      TOMIO /= 10;
      g = TOMIO % 10;
    if(c == g && d == f){
      KYR ++;
    }
    OOTJNY ++;
    WAYO ++;
  }
  cout << KYR << endl;
//  cout << c << d << e << f << g << endl;
//  cout << TOMIO << endl;
}
  

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int r, g;
  cin >> r >> g;
  cout << 2 * g - r << endl;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String k=sc.next();
		int d=sc.nextInt();
		long mod=1000000007;
		long[][][] dp=new long[k.length()+1][d][2];
		//1がｋ未満
		dp[0][0][0]=1;
		for(int i=1; i<=k.length(); i++){
			int num=k.charAt(i-1)-'0';
			for(int j=0; j<d; j++){
				dp[i][(j+num)%d][0]=dp[i-1][j][0];
				for(int t=9; t>=0; t--){
					dp[i][(j+t)%d][1]=(dp[i][(j+t)%d][1]+dp[i-1][j][1])%mod;
					if(t<num){
						dp[i][(j+t)%d][1]=(dp[i][(j+t)%d][1]+dp[i-1][j][0])%mod;
					}
				}
			}
		}
		System.out.println((dp[k.length()][0][0]+dp[k.length()][0][1]-1+mod)%mod);
	}
}


Measured memory_bytes: 87120
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	In := readLineInt()
	SureCat, Unknown, TCats := In[0], In[1], In[2]
	if SureCat+Unknown >= TCats && SureCat <= TCats {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

/////////////////////////////////////////

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}


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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> L(N);
  for (int i=0; i<N ;i++){
    cin >> L.at(i);
  }
  
  sort(L.begin(),L.end());
  int count = 0;
  
  for(int i=0; i<N-2 ;i++){
    for(int j=i+1; j<N-1 ;j++){
      for(int h=j+1; h<N;h++){
        if(L.at(h)>=L.at(i)+L.at(j)){
          break;
        }
        else if(L.at(i)!=L.at(j) && L.at(j)!=L.at(h)){
          count = count + 1;
        }
      }
    }
  }
  
  cout << count << endl;
  
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

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

    int S=s.size();

    ll ans=0;

    rep(mask,1<<(S-1))
    {
        int st=0;
        rep(i,S-1)
        {
            if(mask>>i&1)
            {
                ans+=atoll(s.substr(st,(i+1)-st).c_str());
                st=i+1;
            }
        }
        ans+=atoll(s.substr(st).c_str());
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;

  for (int j = 3; j <= n; j+=2) {
    ll cnt = 0;
    reps1(i, j+1) {
      if (j % i == 0) cnt++;
    }
    if (cnt == 8) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
int a[3][3],b[3][3];
string line()
{
	int kg=0;
	for (int i=0;i<3;i++)  if (b[i][0]==1 && b[i][1]==1 && b[i][2]==1)  kg=1;
	for (int i=0;i<3;i++)  if (b[0][i]==1 && b[1][i]==1 && b[2][i]==1)  kg=1;
	if (b[0][0]==1 && b[1][1]==1 && b[2][2]==1)  kg=1;
	if (b[2][0]==1 && b[1][1]==1 && b[0][2]==1)  kg=1;
	if (kg)  re "Yes";
	else  re "No";
}
int main()
{
	for (int i=0;i<3;i++)  for (int j=0;j<3;j++)  cin>>a[i][j];
	int n;
	cin>>n;
	int kkg=0;
	for (int i=0;i<n;i++)
	{
		int h;
		cin>>h;
		int kg=0;
		for (int i=0;i<3;i++)  for (int j=0;j<3;j++)  if (a[i][j]==h)  b[i][j]=1;
	}
	cout<<line();
	re 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>
#include <queue>
#include <list>
#include <cstring>
#include <unordered_set>
#include <cmath>
#include <iomanip>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::getline(stream, buf);
		std::stringstream sstr(buf);

		std::vector<int> retval;
		retval.reserve(num);

		std::string input;;
		for (int i = 0; i < num && std::getline(sstr, input, delim); ++i)
		{
			retval.push_back(std::stoi(input));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num && std::getline(sstr, buf, delim); ++i)
		{
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename Itr>
	void PrintLine(Itr begin, Itr end)
	{
		bool first = true;

		for (int i = 0; begin != end; ++begin, ++i)
		{
			if (!first)
			{
				std::cout << ' ';
			}

			std::cout << (*begin);

			first = false;
		}
		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}

	int Adj[100][100] = {};
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;
	if (argc == 1)
	{
		std::cin.tie(0);
		std::ios::sync_with_stdio(false);
	}

	int num;
	stream >> num;

	int node, degree;
	int t;

	for (int i = 0; i < num; ++i)
	{
		stream >> node >> degree;
		for (int j = 0; j < degree; ++j)
		{
			stream >> t;
			Adj[node - 1][t - 1] = 1;
		}
	}

	for (int i = 0; i < num; ++i)
	{
		bool first = true;

		for (int j = 0; j < num; ++j)
		{
			if (!first)
			{
				std::cout << ' ';
			}
			std::cout << Adj[i][j];
			first = false;
		}
		std::cout << '\n';
	}
}



Measured memory_bytes: 3244
#include<stdio.h>
int main()
{
    int i,j,temp,k;
    int  ara[10];
    scanf("%d%d",&i,&j);
    if(i>j){
        temp=i;
        i=j;
        j=temp;
    }
    for( k=0;k<j;k++)
    {
        ara[k]=i;
    }
    ara[k]='\0';
    for( k=0;k<j;k++)
    {
        printf("%d",ara[k]);
    }
    printf("\n");


}


Measured memory_bytes: 128
n,m=map(int,input().split())
sc=[tuple(map(int,input().split())) for _ in range(m)]
for i in range(1000):
  if not len(str(i))==n:
    continue
  for s,c in sc:
    if not str(i)[s-1]==str(c):
      break
  else:
    print(i)
    exit()
print(-1)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main()
{
	int c;
	double a, b, S, L, h;
	const double PI = 3.14159265359;

	cin >> a >> b >> c;

	double radian = c * PI / 180.0;

	S = 1.0 / 2.0 * a * b * sin(radian);
	L = a + b + sqrt(a*a + b*b - 2.0*a*b*cos(radian));
	h = b * sin(radian);

	cout << fixed << setprecision(14) << S << "\n"
		<< L << "\n"
		<< h << "\n";
}

Measured memory_bytes: 1296
#include<iostream>
#include<string>
#define rep(i, n) for (int i = 0; i < (n); i ++)

using namespace std;

int main()
{
  const int cake = 4;
  const int donut = 7;
  
  int x;
  cin >> x;
  
  if (x < cake)
  {
    cout << "No";
    return 0;
  }

  int max_cake = x / cake;
  int max_donut = x / donut;
  
  rep(i, max_cake + 1)
  {
    rep(j, max_donut + 1)
    {
      if (i * cake + j * donut == x)
      {
        cout << "Yes";
        return 0;
      }
    }
  }
  
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

ll modpow(ll a, ll p) {
    if(p == 0)
        return 1;
    if(p % 2 == 0) {
        ll halfp = p / 2;
        ll half = modpow(a, halfp);
        return half * half % MOD;
    } else {
        return a * modpow(a, p - 1) % MOD;
    }
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while(b) {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if(u < 0)
        u += m;
    return u;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> cnt;
    REP(i, N) {
        cin >> A[i];
        REP(j, 61) {
            if(!(A[i] & (1LL << j))) {
                cnt[j]++;
            }
        }
    };

    ll ans = 0LL;
    REP(j, 61) {
      ll tmp = cnt[j] * (N - cnt[j]) % MOD;
        ans += tmp * modpow(2LL, j);
        ans %= MOD;
    }

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


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

using namespace std;
typedef long long ll;

void solve(vector<int> &A) {
    sort(A.begin(), A.end());
    int N = A.size();
    ll sum = 0;
    for(int i = 1; i < N - 1; i++) {
        sum += A[i];
    }
    cout << sum / (N - 2) << endl;
}

int main() {
    int N;
    while(cin >> N, N) {
        vector<int> A(N);
        for(int i = 0; i < N; i++) cin >> A[i];
        solve(A);
    }
    return 0;
}



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

const int maxn=1e5+10;

int n,m,u[maxn],v[maxn],Ans;
bool need[410][410];
bitset<233> abc;

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i,j,k;
	bool flag;
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++)
		scanf("%d%d",&u[i],&v[i]);

	for (i=1;i<=n;i++)
	{
		need[i][i]=1;
		flag=1;
		for (j=m;j>=1;j--)
		{
			if (need[i][u[j]]&&need[i][v[j]])
			{
				flag=0;
				break;
			}
			if (need[i][u[j]]||need[i][v[j]])
				need[i][u[j]]=need[i][v[j]]=1;
		}
		need[i][0]=!flag;
	}

	for (i=1;i<=n;i++) if (!need[i][0])
	for (j=i+1;j<=n;j++) if (!need[j][0])
	{
		flag=0;
		for (k=1;k<=n;k++)
			flag|=need[i][k]&&need[j][k];
		Ans+=!flag;
	}
	printf("%d\n",Ans);
}


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

using namespace std;

#define ll long long

const ll mod = 1000000007LL;

struct Matrix {
	int n;
	vector<vector<ll>> element;

	Matrix(int n) : n(n) {
		element.resize(n);
		for (int i = 0; i < n; ++i)
			element[i].resize(n, 0);
	}

	Matrix operator *(Matrix a) {
		assert(n == a.n);
		Matrix res(n);
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				ll tmp = 0;
				for (int k = 0; k < n; ++k) {
					tmp += element[i][k] * a.element[k][j] % mod;
					tmp %= mod;
				}
				res.element[i][j] = tmp;
			}
		}
		return res;
	}

	Matrix pow(ll k) {
		if (k == 0) {
			Matrix res(n);
			for (int i = 0; i < n; ++i)
				res.element[i][i] = 1;
			return res;
		}
		Matrix tmp = pow(k / 2);
		if (k % 2 == 1)
			return tmp * tmp * (*this);
		return tmp * tmp;
	}
};

signed main() {
	int n; ll k;
	cin >> n >> k;
	Matrix m(n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			int a; cin >> a;
			m.element[j][i] = a;
		}
	}
	m = m.pow(k);
	ll ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			ans = (ans + m.element[i][j]) % mod;
	cout << ans << endl;
	return 0;
}

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

void solve(){
    string s, ss;
    cin >> s >> ss;
    int sz = s.size();
    int ans=0;
    for(int i=0; i<sz; i++){
        if(s[i]!=ss[i])
            ans++;
    }
    cout << ans <<endl;
}

int main(){
   // int t;  cin >> t;   while(t--)
    solve();

    return 0;
}


Measured memory_bytes: 3924
#include<bits/stdc++.h>
#include<deque>
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; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;
const int MOD = 1000000007;




int main(){
    deque <char> s;   
    string u;   cin >> u;
    for(char v:u)   s.push_back(v);
    int q;  cin >> q;
    int t[q];
    bool flag = true;
    

        rep(i,q){
            cin >> t[i];
            if(t[i]==1) {
                flag = !flag;//反転
                }
        
        if(t[i]==2){
            int f;
            char c;
            cin >> f;
            cin >> c;

            if( (f==2 && flag==0) || (f==1 && flag==1) ){//top
                s.push_front(c);
            }

            if( (f==1 && flag==0) || (f==2 && flag==1) ){//back
                s.push_back(c);
            }

        }
        
        }

        if(flag==0){
        for(int i=0 ; i<(s.size()+1)/2 ; i++){
                swap(s.at(i),s.at(s.size()-1-i));
            }
            }

        for(auto it=s.begin(); it!=s.end();it++)  cout << *it;

cout<< endl;
        

}

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


int N, A, B;


void input() {
    cin >> N;
}


int main() {
    input();
    if (N == 1) cout << "Hello World" << endl;
    else {
        cin >> A >> B;
        cout << A + B << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[2][101];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, 2) REP(j, n) cin >> a[i][j];

  int memo1[101];
  int memo2[101];

  memo1[0] = 0;
  memo2[0] = 0;
  FOR(i, 1, n + 1) {
    memo1[i] = memo1[i - 1] + a[0][i - 1];
    memo2[i] = memo2[i - 1] + a[1][i - 1];
  }

  int ans = 0;
  FOR(i, 1, n + 1) {
    ans = max(ans, memo1[i] + (memo2[n] - memo2[i - 1]));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
l = []
ans = 'Yes'
ps = 'a'
for i in range(n):
  s = input()
  if s in l:
    ans = 'No'
  l.append(s)
  if i != 0 and ps[-1] != s[0]:
    ans = 'No'
  ps = s

print(ans)


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  int result = 0;
  for (int i = 1; i < n-1; i++) {
    if (a.at(i-1) < a.at(i) && a.at(i) < a.at(i+1)) {
      result++;
    } else if (a.at(i-1) > a.at(i) && a.at(i) > a.at(i+1)) {
      result++;
    }
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main(){
   int N;
   std::cin >> N;
   double X;
   int cX = std::ceil(N / 1.08);
   int Nx = cX * 1.08;
   if (Nx == N){
      std::cout << cX << std::endl;
   } else{
      std::cout << ":(" << std::endl;
   }
}




Measured memory_bytes: 256
def forbidden_list():
    condition = input()
    num_str = input()
    
    condition_list = condition.split()
    X = int(condition_list[0])
    N = int(condition_list[1])
    
    if N == 0:
        print(X)
        return
    
    num_list_str = num_str.split()
    num_list = []
    for i in num_list_str:
        num_list.append(int(i))
    
    num_list.sort()
    flag = True
    sub = 0
    tmp = X
    
    while flag:
        tmp = X + sub
        for i in num_list:
            count = 0
            if tmp == i:
                count = 1
                break
        if count == 0:
            print(tmp)
            return
        
        sub += 1
        tmp = X - sub
        for i in num_list:
            count = 0
            if tmp == i:
                count = 1
                break
        if count == 0:
            print(tmp)
            return
    
forbidden_list()

Measured memory_bytes: 9228
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cmath>

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

int GCD(int n,int m){
	if(m==0) return n;
	return GCD(m,n%m);
}

int LCM(int n,int m){
	return n*m/GCD(n,m);
}

int main(){
	int n,m,k;
	cin >> n >> m;
	REP(i,n-1){
		cin >> k;
		m = LCM(m,k);
	}
	cout << m << endl;
}

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

#define eb emplace_back
#define pb push_back
#define INF LLONG_MAX
#define FLT_INF pow(10.0, 16)


using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<ll, ll>;
using int3 = tuple<ll, ll, ll>;

template <typename A> string to_string(const A& v);
string to_string(const string& s) { return '"'+ s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(const pair<A, B>& p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C> string to_string(const tuple<A, B, C>& p) {
  return "(" + to_string(std::get<0>(p)) + ", " + to_string(std::get<1>(p)) +  ", " + to_string(std::get<2>(p)) + ")";
}

template <typename A> string to_string(const A& v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T>& val) {
  sort(val.begin(), val.end());
}

template <typename T>
void reverse(vector<T>& val) {
  reverse(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T>& val) {
  sort(val.begin(), val.end(), greater<T>());
}

template <typename T>
T pair_sum(pair<T, T>& val) {
  return val.first + val.second;
}


template <typename T>
T min(T a, T b, T c) {
  return min(min(a, b), c);
}

template <typename T>
T max(T a, T b, T c) {
  return max(max(a, b), c);
}


template <typename T>
T mul_mod(T a, T b, T mod) {
  T res = 0;
  a %= mod;
  while (b) {
    if (b & 1) {
      res = (res + a) % mod;
    }
    a = (2 * a) % mod;
    b >>= 1;
  }
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...);
#endif

#define COMMON_MOD pow(10, 9) + 7
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;
/* printf("%lld %lld \n", cur_n, m / 2 + 1);
*/

class mytask {
public:

  mytask() { }



  int solve() {


    ll a, b;

    cin >> a >> b;

    ll min_n, max_n;

    min_n = min(a, b);
    max_n = max(a, b);
    for (ll i = 0; i < max_n; i++) {
      cout << min_n;
    }
    return 0;
  }

};


int main() {

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

  auto task = mytask();
  task.solve();

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,k,count=0, a[100005];

  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  n=n-k;
  count++;
  if(n>0){
    while(1){
    n=n-k+1;
    count++;
    if(n<=0) break;
  }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 2080