akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]
            string[] s = GetString();
            var S = s[0];
            var T = s[1];

            var line = ReadLine();
            var A = line[0];
            var B = line[1];

            var U = Console.ReadLine();

            if (S == U)
            {
                Console.WriteLine("{0} {1}", A - 1, B);
            }
            else
            {
                Console.WriteLine("{0} {1}", A, B - 1);
            }
        }

        static string[] GetString()
        {
            var line = Console.ReadLine();
            return line.Split(' ');
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
const int N=3e3+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
}








































int n,m;
int dp[N][N][2];
void input()
{
	n=read<int>(),m=read<int>();
}
const int mo=1e9+7;
void add(int &x,int y)
{
	x+=y;x-=(x>=mo?mo:0);
}
void work()
{
	For(i,1,n)dp[0][i][0]=1;
	dp[0][0][1]=1;
	For(i,0,m-1)For(j,0,n)For(k,0,1)if(dp[i][j][k])
	{
		if(j)add(dp[i+1][j][k|(j==1)],dp[i][j][k]);
		if(j)add(dp[i+1][j-1][k|(j==1)],dp[i][j][k]);
		if(n-j)add(dp[i+1][j][k],dp[i][j][k]);
		if(n-j)add(dp[i+1][j+1][k],dp[i][j][k]);
	}
	int ans=0;
	For(i,0,n)add(ans,dp[m][i][1]);
	write(ans,'\n');
}
int main()
{
	//file();
	input();
	work();
	return 0;
}

Measured memory_bytes: 70656
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

x,n = i2()
p = intl()

m = 100
ls = [int(i) for i in range(-200,200)]
for i in range(n):
	ls.remove(p[i])
for j in range(len(ls)):
	if abs(x - ls[j]) < m :
		m = abs(x - ls[j])
		ans = ls[j]
print(ans) 

Measured memory_bytes: 9224
DN = list(map(int,input().split()))
D=DN[0]
N=DN[1]

if D==0 and N==100:
    print(101)
elif D==0:
    print(N)
elif D==1 and N==100:
    print(10100)
elif D==1:
    print(100*N)
elif D==2 and N==100:
    print(1010000)
else :
    print(10000*N)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
const int maxn = 2010;
const int M = 1000000007;

int n,m,gr;
ll ans,s;
ll dp[maxn][maxn]; // 分为 i 组 ， 和为 j 的方案数 
ll fac[maxn];

ll ksm(ll i, ll po){
	i %= M; 
	ll res = 1;
	while(po){
		if(po&1) res = res * i % M;
		po >>= 1;
		i = i * i % M;
	}
	return res;
}

ll inv(ll a){ return ksm(a,M-2); }

ll c(ll N, ll K){ 
	if(N<K)return 0;
    if(N<0||K<0)return 0;
	return 1ll*fac[N]*inv(fac[K])%M*inv(fac[N-K])%M; 
}

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	fac[0] = 1ll ;
	for(int i=1;i<=2001;i++) fac[i] = 1LL * fac[i-1] * i % M; 

	ans = 0;
	//printf("%lld\n",c(3,1));
	s = read();
	if(s<3) printf("0\n");
	else{
		gr = s / 3LL;
		
		for(int i=1;i<=gr;i++){
			m = s - 3ll * i;
//			printf("%lld\n",c(m+i-1ll,i-1ll));
			ans = (ans + c(m+i-1ll,i-1ll)) % M;
		} 
		printf("%d\n",(ans+M)%M);
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
  int h[10];
  REP(i, 10) cin >> h[i];
  sort(h, h+10, greater<int>());
  REP(i, 3) cout << h[i] << endl;
  return 0;
}

Measured memory_bytes: 3136
#include<vector>
#include<iostream>

using namespace std;


vector<int> GaussJordanMod2(vector<vector<unsigned int> > a){
	int n=a.size();
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			if(a[j][i/32]>>(i&31)&1){
				a[i].swap(a[j]);
				break;
			}
		}
		unsigned int rev=a[i][i/32]&~((1<<(i&31))-1);		
		for(int j=0;j<n;j++){
			if(i==j||!(a[j][i/32]>>(i&31)&1))continue;
			a[j][i/32] ^= rev;
			for(int k=i/32+1;k<(n+1+32-1)/32;k++){
				a[j][k] ^= a[i][k];
			}
		}
	}
	vector<int> res(n);
	for(int i=0;i<n;i++)res[i]=a[i][n/32]>>n%32&1;
	return res;
}


int main(){
	int dy[]={0,1,0,-1,0};
	int dx[]={0,0,1,0,-1};
	int n;
	cin>>n;
	while(n--){
		vector<vector<unsigned int> > a(100,vector<unsigned int>((101+31)/32,0));
		for(int i=0;i<100;i++){
			int y=i/10,x=i%10;
			for(int j=0;j<5;j++){
				int ny=y+dy[j],nx=x+dx[j];
				if(0<=ny&&ny<10&&0<=nx&&nx<10){
					a[ny*10+nx][i/32] |= 1<<(i&31);
				}
			}
		}
		for(int i=0;i<100;i++){
			int c;
			cin>>c;
			a[i][100/32] |= c<<(100&31);
		}
		vector<int> ans(GaussJordanMod2(a));
		for(int i=0;i<10;i++){
			cout<<ans[i*10];
			for(int j=1;j<10;j++){
				cout<<' '<<ans[i*10+j];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	char name[21];
	int win;
	int lose;
	int draw;
	int id;
} team_t;

int hikaku(const void* x,const void* y) {
	team_t* xx=(team_t*)x;
	team_t* yy=(team_t*)y;
	int katix,katiy;
	katix=xx->win*3+xx->draw;
	katiy=yy->win*3+yy->draw;
	if(katix>katiy)return -1;
	if(katix<katiy)return 1;
	if(xx->id>yy->id)return 1;
	if(xx->id<yy->id)return -1;
	return 0;
}

int main(void) {
	team_t team[10];
	int teamnum;
	int i;
	int onemore=0;
	while(1) {
		scanf("%d",&teamnum);
		if(teamnum==0)break;
		for(i=0;i<teamnum;i++) {
			scanf("%s %d %d %d",team[i].name,&team[i].win,&team[i].lose,&team[i].draw);
			team[i].id=i;
		}
		qsort(team,teamnum,sizeof(team_t),hikaku);
		if(onemore)puts("");
		for(i=0;i<teamnum;i++) {
			printf("%s,%d\n",team[i].name,team[i].win*3+team[i].draw);
		}
		onemore=1;
	}
	return 0;
} 

Measured memory_bytes: 0
import sys
def input():
	return sys.stdin.readline()[:-1]

INF = (1<<31)-1

class Rmin():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [INF] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Update(self, x, val):
		x += self.n-1
		self.node[x] = val
		while x > 0:
			x = (x-1)//2
			self.node[x] = min(self.node[2*x+1], self.node[2*x+2])
		return

	#[a, b)
	def Get(self, a, b, k=0, l=0, r=-1):
		if r < 0:
			r = self.n

		if a >= r or b <= l:
			return INF
		elif a <= l and b >= r:
			return self.node[k]
		else:
			vl = self.Get(a, b, 2*k+1, l, (l+r)//2)
			vr = self.Get(a, b, 2*k+2, (l+r)//2, r)
			return min(vl, vr)

n, q = map(int, input().split())
SegT = Rmin(n)
for _ in range(q):
	c, x, y = map(int, input().split())
	if c == 0:
		SegT.Update(x, y)
	else:
		print(SegT.Get(x, y+1))


Measured memory_bytes: 9444
#include<bits/stdc++.h>
#define Abs(a) ((a)>0?(a):(-1*(a)))
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
long long a[500010],cha[500010],ans;
int n;
int main()
{	
	scanf("%d",&n);
	f(i,1,n)scanf("%lld",&a[i]),cha[i]=Abs(a[i]-a[i-1]);
	cha[n+1]=Abs(a[n+1]-a[n]);
	f(i,1,n+1)ans+=cha[i];
	f(i,1,n)printf("%lld\n",ans+Abs(a[i+1]-a[i-1])-(cha[i]+cha[i+1]));
	return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> *i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int f=0,t=0;
    int n;
    cin>>n;
    REP(i,n) {
        int a;
        cin>>a;
        if(a%4==0) f++;
        else if(a%2==0) t++;
    }
    n-=(t/2)*2;
    if(n/2<=f) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> vec(n);
  
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  int count = 0;
  int prev = 0;
  for(int i = 0; i < n; i++) {
    if (prev < vec.at(i)) {
      prev = vec.at(i);
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ

using namespace std;
int main()
{
    ll a;
    ll b;
    ll c;
    ll d;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    while (a > 0 || c > 0) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }

    }

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 3000;
int n, v[N+1];

int main(){
    scanf("%d",&n);
    int sm = 0;
    for(int i = 0; i<n; ++i){scanf("%d", v+i);sm += v[i];}
    printf("%d\n",sm-n);
}

Measured memory_bytes: 256
import copy

H, W = map(int, input().split())
c=[]
for _ in range(10):
    c.append(list(map(int, input().split())))
A=[]
for _ in range(H):
    A.append(tuple(map(int, input().split())))

#print(c)
#print(H)

#１からの最短経路を求めよ

dp=copy.deepcopy(c)

for k in range(10):
    for i in range(10):
        for j in range(10):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
#print(dp)

ans=0
for y in range(H):
    for x in range(W):
        if A[y][x] != -1:
            ans += dp[A[y][x]][1]
print(ans)

Measured memory_bytes: 41052
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	unordered_map<string, ll> mp;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
		mp[s[i]]++;
	}
	ll ans = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ll tmp = it->second;
		ans += tmp * (tmp - 1) / 2;
	}
	dump(ans);
	return 0;
}


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

typedef   long long  int ll;
typedef  long double ld;
typedef std::vector<ll> vi;
typedef std::vector<std::vector<ll> > vv;

#define MOD 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,b) for(i=a;i<b;i++)
#define mp make_pair
#define pb(x) push_back(x)
#define fi first
#define se second
#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;
#define all(a) a.begin(),a.end()
#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];
#define ms(a,val) memset(a,val,sizeof(a))
using namespace std;

const int N = 1e5 + 5;


void solve(){
            ll i,j,n,W;
            cin>>n>>W;
            ll w[n+1],v[n+1];
            fo(i,1,n+1)
            {
				cin>>w[i]>>v[i];
			}
			ll dp[n+1][W+1];
			ms(dp,0);
			fo(i,1,n+1)
			{
				fo(j,1,W+1)
				{
					if(j>=w[i])
					dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]] + v[i]);
					else
					dp[i][j] = dp[i-1][j];
				}
			}
			/*fo(i,1,n+1)
			 {
				 fo(j,1,W+1)
				  cout<<dp[i][j]<< " ";
				  cout<<endl;
			  }*/
			 //cout<<dp[i][W]<<endl;
			cout<<dp[n][W]<<endl;
			
            
						            









}

int main()
{
    IO;
      ll t=1,i;
      //cin>>t;


      while(t--)
      {

          solve();
      }
    return 0;
}


Measured memory_bytes: 82492
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	ll n, z, w, a[2001];
	cin >> n >> z >> w;
	for (int i = 0;i < n;i++) cin >> a[i];
	cout << max(abs(a[n - 2] - a[n - 1]), abs(a[n - 1] - w)) << 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);
			String S = sc.next();
			sc.close();
			
			int count = 0;
			int length = S.length();
			int k = 15-length;
			for (int i=0; i<length; i++){
				 if (S.charAt(i)=='o'){
					 count++;
				 }
					 
			 }
			 if (k+count>7)
				 System.out.println("YES");
			 else
				 System.out.println("NO");
				 
	}

}


Measured memory_bytes: 22228
using System;
public class Hello{
    public static void Main(){
        var line = Console.ReadLine().Split();
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        Console.Write(Math.Min(a, Math.Min(b, c)));
        Console.Write(" ");
        Console.WriteLine(Math.Max(a, Math.Max(b, c)));
    }
}



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

int main() {
	int N, D, X;
	int a[101];
	cin >> N;
	cin >> D >> X;
	int i,j;
	for (i = 0; i < N; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (i = 0; i < N; i++) {
		j = 0;
		while (1 + a[i] * j <= D) {
			ans++;
			j++;
		}
	}
	cout << ans+X << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	final int maxn=(int)(1e6);
	private void solve()throws Exception
	{
		int n=nextInt();
		int hash[]=new int[maxn+1];
		int a[]=new int[n+1];
		for(int i=1;i<=n;i++)
			a[i]=nextInt();
		Arrays.sort(a,1,n+1);
		for(int i=1;i<=n;i++)
		{
			if(a[i]==a[i-1])
			{
				hash[a[i]]++;
				continue;
			}
			for(int j=a[i];j<=maxn;j+=a[i])
				hash[j]++;
		}
		int ans=0;
		for(int i=1;i<=n;i++)
			if(hash[a[i]]==1)
				ans++;
		out.println(ans);
	}

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

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 58812
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    ret = ""
    while N != 0:
        ret = str(N%2) + ret
        N = -(N//2)
    print(0 if ret == "" else ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
#include<stdio.h>
#define ll long long

int main()
{
	ll n, j = 0;
	char str[255];
	
	scanf("%lld", &n);
	
	while(n != 0){
		--n;
		str[j++] = n % 26 + 'a';
		n /= 26;
	}
	for(int i = j - 1; i >= 0; i--){
		printf("%c", str[i]);
	}
}

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

// #define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back

int w,h,fx,fy;
char ban[30][30];
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

bool inrange(int px,int py){
  if(px<0||py<0||px>=h||py>=w) return false;
  else return true;
}
int bsearch(int px,int py){
  int cnt = 0;
  REP(i,4){
    int nx = px+ dx[i]; int ny = py+dy[i];
    if(!inrange(nx,ny)) continue;
    if(ban[nx][ny]=='#') continue;
    //cnt++;
    //cout << nx << " " <<ny<<endl;
    if(ban[nx][ny]=='.'){
      ban[nx][ny]='!';
      cnt++;
      cnt += bsearch(nx,ny);
    }
  }
  return cnt;
}

int main(){
  while(1){
    cin >> w >> h;
    if((w==0)&&(h==0)) break;
    REP(i,h){
      char buf[21];
      cin >> buf;
      REP(j,w) {
        ban[i][j] = buf[j];
        if(ban[i][j] == '@'){
          fx = i; fy = j;
        }
      }
    } 
    cout << bsearch(fx,fy)+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i,N){
    cin >> h[i];
  }
  int count=0;
  rep(i,N){
    if(h[i]>=K){
      count++;
    }
  }
  printf("%d\n", count);
}


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

namespace Contest_01_Valeo_P6
{
    class Program
    {

        static void Main(string[] args)
        {
            //while (true)
            //{
            //    Console.WriteLine("start problem");
                string input = Console.ReadLine();
                long n = long.Parse(input.Split(' ')[0]);
                long result = getNumberOfPairs(n);
                Console.WriteLine(result);
            //    Console.Write("press y to exit : ");
            //    if (Console.ReadLine() == "y")
            //        return;
            //}
        }

        /// <summary>
        /// in session
        /// construct map of occurances
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        private static long getNumberOfPairs(long n)
        {
            long count = 0;
            List<List<long>> l = new List<List<long>>();
            for (int i = 1; i <= 10; i++)
            {
                List<long> intern = new List<long>();
                for (int j = 1; j <= 10; j++)
                {
                    intern.Add(0);
                }
                l.Add(intern);
            }
            for (long x = 1; x <= n; x++)
            {
                int startDigit = x.ToString().Select(c => int.Parse(c.ToString())).First();
                int endDigit = x.ToString().Select(c => int.Parse(c.ToString())).Last();
                
                l[startDigit][endDigit]++;
            }

            for (int i = 0; i < 10; i++)
            {
                count += l[i][i] *l[i][i];
                for (int j = i+1; j < 10; j++)
                {
                    count += 2 * l[i][j] * l[j][i];
                }
            }
            return count;
        }
    }
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}
ll dp[110][100010];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, W;
  cin >> n >> W;
  ll w[n], v[n];
  rep(i, n) cin >> w[i] >> v[i];

  rep(i,n){
    rep(j, W + 1) {
      chmax(dp[i + 1][j], dp[i][j]);
      if(j - w[i] >= 0) {
        chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
      }
    }
  }
  ll ans = 0;
  rep(i, W + 1) { chmax(ans, dp[n][i]); }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll INF = 1LL << 62;
#define atcoder(int)1e9+7
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int main() {
	
	int r, g, b;
	cin >> r >> g >> b;

	int sum = r * 100 + g * 10 + b;
	if (sum % 4 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;
}

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

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

	int n; cin >> n;
	vector<int> a(n), b(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b.begin(), b.end());
	int left = b[n / 2 - 1], right= b[n / 2];
	for(int i = 0; i < n; i++) {
		if(a[i] <= left) {
			cout  << right << '\n';
		}
		else {
			cout << left << '\n';
		}
	}
	
	return 0;
}	


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#include<unordered_map>
#include<algorithm>
#include<stdio.h>
/*
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*    ▀▀       ▀▀▀▀▀▀    ▀     ▀▀▀▀▀▀      ▀    ▀
*   ▀  ▀      ▀         ▀     ▀            ▀  ▀
*  ▀    ▀     ▀ ▀ ▀     ▀     ▀ ▀ ▀         ▀
* ▀ ▀▀▀▀ ▀    ▀         ▀     ▀             ▀
*▀        ▀   ▀         ▀     ▀             ▀
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*/
using namespace std;
void afify()
{
	ios::sync_with_stdio(0);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
//===============================================
#define ll long long
#define ld long double
#define mk make_pair
#define loop(i,intial,n)  for(int i=(intial);i<n;i++)
#define loopn(j,n,ends) for(int j=int(n-1);j>=ends;j--)
#define loopm(name)  for(auto it : name)
#define loopm2(name)  for(auto it2 : name)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(),v.end()
#define PI (ld)(3.14159265358979323846)
//===============================================
#define SF(a) scanf("%d",&a)
#define SF2(a,b) scanf("%d %d",&a,&b)
#define SFLL(a) scanf("%lld",&a)
#define SFLL2(a,b) scanf("%lld %lld",&a,&b)
#define PF(a) printf("%d\n",a)
#define PFLL(a) printf("%lld\n",a)
//===============================================
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;
typedef stringstream ss;
const double EPS = 1e-4;
const ll oo = (ll) 10e4 + 7;
const ll N = 10000018;
const ll mod = 1000000007;
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
//int dx[]={1,1,0,-1,-1,-1,0,1};
//int dy[]={0,1,1,1,0,-1,-1,-1}; 8 direction
//freopen("largest.in", "r", stdin);
//freopen("output.txt", "w", stdout);
//ifstream ifs("input.txt");
//ofstream ofs("output.txt");



int main()
{
	afify();
	string a, b;
	cin >> a >> b;
	int res = 0;
	loop(i, 0, a.length())
	{
		if (a[i] != b[i])
			res++;
	}
	cout << res << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3796
using System;

namespace To_Infinity
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var k = long.Parse(Console.ReadLine());

            var count = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (1 == int.Parse(s[i].ToString()))
                {
                    count++;
                }
                else
                {
                    break;
                }
            }
            if (count >= k)
            {
                Console.WriteLine(1);
                return;
            }
            if (1 == k)
            {
                Console.WriteLine(s[0]);
                return;
            }
            for (int i = 0; i < s.Length; i++)
            {
                if (1 != int.Parse(s[i].ToString()))
                {
                    Console.WriteLine(s[i]);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	
	string c = "";
	
	bool checker;
	
	for(int j = 0; j < 3000; j++){
		c = " " + c;
	}
	
	while(true){
		
		getline(cin, c);
		
		if(cin.eof()){
			break;
		}
		
		checker = false;
		
		for(int j = 0; j < 2000; j++){
			if(c[j] == '\0'){
				break;
			}
			if(c[j] == 'p' && c[j + 1] == 'e' && c[j + 2] == 'a' && c[j + 3] == 'c' && c[j + 4] == 'h'){
				c[j] = 'a';
				c[j + 1] = 'p';
				c[j + 2] = 'p';
				c[j + 3] = 'l';
				c[j + 4] = 'e';
			}else if(c[j] == 'a' && c[j + 1] == 'p' && c[j + 2] == 'p' && c[j + 3] == 'l' && c[j + 4] == 'e'){
				c[j] = 'p';
				c[j + 1] = 'e';
				c[j + 2] = 'a';
				c[j + 3] = 'c';
				c[j + 4] = 'h';
			}
			
		}
		
		for(int i = 0; i < 2000; i++){
			if(c[i] == '\0'){
				break;
			}
			cout << c[i];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1192
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n>>m;

    v = 0; For(i,1,m){cin>>u; v+=u; }

    if(v>=n) cout<<"Yes\n";
    else     cout<<"No\n";

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

int main(){
  	int n,m;
  	cin>>n>>m;
  	int a1,a2,a3;
  	a1=n+m;a2=n-m;a3=n*m;
  	cout<<max(a1,max(a2,a3))<<endl;
	  
	return 0;
}

Measured memory_bytes: 256
n=list(input())
n.reverse()
n.append('0')
n=list(map(int,n))
ans=0

dp1=n[0]
dp2=10-n[0]
for i in n[1:]:
    dp1,dp2=min(i+dp1,i+1+dp2),min(10-i+dp1,9-i+dp2)
print(min(dp1,dp2))

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

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define abs(a,b) (a)< 0 ?(a):-(a)
#define llong long long

int main(){
	char s[10]; scanf("%s",s);
	if( strcmp(s,"ABC")==0 ) printf("ARC");
	else printf("ABC");
	return 0;
}


Measured memory_bytes: 1732
// agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long int ll;
ll arr[200005];
ll pre[200005];
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
     
       
   ll n;
   cin>>n;
   for(int i=1;i<=n;i++) cin>>arr[i];
   for(int i=n-1;i>=1;i--){
       if(arr[i]>=arr[i+1]) pre[i]=pre[i+1]+1;
   }
   ll ans=INT_MIN;
   for(int i=1;i<=n;i++){
       ans=max(ans,pre[i]);
   }
   cout<<ans<<endl;
   
}

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

int main() {
	long long n,x;cin>>n>>x;
	vector<long long> a(n);
	long long ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]>x){
			ans+=a[i]-x;
			a[i]=x;
		}
	}
	for(int i=0;i<n-1;i++){
		if(a[i]+a[i+1]>x){
			ans+=a[i]+a[i+1]-x;
			a[i+1]=x-a[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;

string resolve(string org,int ch){
	string ret = "";
	for(int x=0;x<org.size();++x){
		if(org[x]==' ' || org[x]=='.'){
			ret += org[x];
		}else if(org[x]+ch<'a'){
			ret += 'z' - ('a'-(org[x]+ch)-1);
		}else if(org[x]+ch>'z'){
			ret += 'a' +(org[x]+ch-'z'-1);
		}else{
			ret += org[x]+ch;
		}	
	}
	return ret;
}

vector<string> tokens(string line){
	vector<string> ret;
	int b=0;
	string tmp= "";
	while(line[b]!=0){
		if(line[b]==' '){	
			if(tmp.size()>0){
				ret.push_back(tmp);
			}
			tmp = "";
		}else{
			tmp += line[b];
		}
		++b;
	}
	if(tmp.size()>0){
		ret.push_back(tmp);
	}
	return ret;
}

string solve(string line){
	vector<string> tok = tokens(line);
	int ch = 0;
	for(int x=0;x<tok.size();++x){
		if(tok[x].size()==3 || tok[x].size()==4){
			int tmp = 't'-tok[x][0];
			if(tmp>0){
				tmp = -7-tok[x][0]+'a';
			}
			string sol = resolve(tok[x],tmp);
			if(sol=="the" || sol =="that" || sol=="this"){ch = tmp;break;}
		}
	}
	return resolve(line,ch);
}

int main(){
	string line;
	while(getline(cin,line)){
		if(line=="")break;
		cout<<solve(line)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define M (long long)2e5+10

long long a[M], f[M], m[M];

using namespace std;

bool cmp(const long long a, const long long b)
{
	return a > b;
}

int main()
{
	long long n, k;
	long long maxl = -1;
	cin >> n >> k;

	for (long long i = 1; i <= n; i++)
		cin >> a[i];

	for (long long i = 1; i <= n; i++)
		cin >> f[i];

	sort(a + 1, a + n + 1);
	sort(f + 1, f + n + 1, cmp);

	for (long long i = 1; i <= n; i++)
	{
		m[i] = a[i] * f[i];
		maxl = max(maxl, m[i]);
	}

	long long l = 0, r = maxl, mid;
	while (l <= r)
	{
		mid = (l + r) >> 1;
		long long tot = 0;
		for (long long i = 1; i <= n; i++)
			if (m[i] > mid)
				tot += a[i] - mid / f[i];

		if (tot > k)
			l = mid + 1;
		else
			r = mid - 1;
	}

	cout << l << endl;

	return 0;
}

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

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

  cout << (n - 1) * (m - 1) << endl;
}

Measured memory_bytes: 3548
n, c = map(int, input().split())
xv = []
for _ in range(n):
  xv.append(tuple(map(int, input().split())))

af = [0]
prevx = 0
for x, v in xv:
  af.append(af[-1] + v - x + prevx)
  prevx = x

bf = [0]
prevx = 0
for x, v in xv[::-1]:
  x = c - x
  bf.append(bf[-1] + v - x + prevx)
  prevx = x

maxa = [0]
for _af in af[1:]:
  maxa.append(max(maxa[-1], _af))
maxb = [0]
for _bf in bf[1:]:
  maxb.append(max(maxb[-1], _bf))

ans = 0
for i, _af in enumerate(af):
  if _af + maxb[n - i] - (xv[i - 1][0] if i != 0 else 0) > ans:
    ans = _af + maxb[n - i] - (xv[i - 1][0] if i != 0 else 0)
for i, _bf in enumerate(bf):
  if _bf + maxa[n - i] - (c - xv[n - i][0] if i != 0 else 0) > ans:
    ans = _bf + maxa[n - i] - (c - xv[n - i][0] if i != 0 else 0)
print(ans)


Measured memory_bytes: 28260
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>
#include <map>
#include <algorithm>

using ll = long long;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

std::map<std::pair<std::string, std::string>, int> freq;

ll result = 0;

void backtracking(std::string s, int pos, std::string red, std::string blue, int _push) {
  if(s.size() == pos) {
    if(_push == 0) {
      std::reverse(red.begin(), red.end());
      std::reverse(blue.begin(), blue.end());
      result += freq[{red, blue}];
    } else
      freq[{red, blue}]++;
  } else {
    backtracking(s, pos + 1, red + s[pos], blue, _push);
    backtracking(s, pos + 1, red, blue + s[pos], _push);
  }
}

int main() {
  int n;
  std::cin >> n;
  std::string s, s2;
  std::cin >> s;
  s2 = s.substr(n, n);
  s = s.substr(0, n);
  std::string nup;
  backtracking(s, 0, nup, nup, 1);
  backtracking(s2, 0, nup, nup, 0);
  std::cout << result;
}


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

using namespace std;
int main(){
    int K, A, B;

    cin>>K;
    cin>>A;
    cin>>B;

    bool Q = false;

    for(int i=A; i<=B; i++){
        if(i%K == 0){
            Q = true;
            break;
        }
    }
    if(Q){
        cout<<"OK\n";
    }
    else{
        cout<<"NG\n";
    }

    return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,l;
    cin>>n>>l;
    if(n*2>l){
        cout<<"No\n";
        return 0;
    }
    int temp=l-2*n;
    if(temp%2!=0)
    {
        cout<<"No\n";
        return 0;
    }
    temp/=2;
    if(temp>n){
        cout<<"No\n";
        return 0;
    }
    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
typedef long long ll;
const ll MOD = 1e9 + 7;
using namespace std;

int main(void) {
	int num;
	cin >> num;
	vector<int> strengths(3 * num);
	for (int numOfParticipant = 0; numOfParticipant < 3 * num; numOfParticipant++)
		cin >> strengths[numOfParticipant];
	sort(strengths.begin(), strengths.end());
	ll ans = 0;
	int left = 0;
	int med = 3 * num - 2;
	while (med > left) {
		ans += strengths[med];
		left += 1;
		med -= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
N = int(raw_input())
inp = [int(i) for i in raw_input().split()]

sorted_inp = sorted(inp)

diff = 0

for i in range(len(inp)):
  if inp[i] != sorted_inp[i]:
    diff += 1

if diff == 0 or diff==2:
  print "YES"
else:
  print "NO"

Measured memory_bytes: 2568
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 3000;

int n;
ld p[N];
ld dp[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j >= 0; j--) {
      dp[j] = p[i] * dp[j-1] + (1 - p[i]) * dp[j];
    }
  }
  cout << fixed << setprecision(10) << accumulate(dp + (n+1)/2, dp + n + 1, 0.L) << nl;
  return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
# 整数の入力
a = list(input())
#print(a)
Flag=True
if a.count('h')+a.count('i')!=len(a):
    Flag = False
if a[0::2].count('h')!=len(a)/2:
    Flag = False
if a[1::2].count('i')!=len(a)/2:
    Flag = False

if Flag:print('Yes')
else:print('No')


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph emplace
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, co;
string A,B,C;
int main()
{
	cin>>A>>B>>C;
	reverse(all(A));
	reverse(all(B));
	reverse(all(C));
	while(1) {
		string *s;
		if(co==0)s=&A;
		else if(co==1)s=&B;
		else s=&C;
		if(s->empty()) break;
		co = s->back()-'a';
		s->pop_back();
	}
	if(co==0) cout<<'A';
	if(co==1)cout<<'B';
	if(co==2)cout<<'C';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

string S;
ll K;

int main(){
	cin >> S >> K;
	for (int i = 0; i < K; ++i) {
		if (S[i] != '1') {
			cout << S[i] << endl;
			return 0;
		}
	}
	cout << '1' << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,t;
int main(){
    cin>>n>>m;
    t=2*n;
    if(t>m)
		cout<<m/2<<endl;
    else if(t==m)
		cout<<n<<endl;
    else{
        m-=t;
        m/=4;
        cout<<n+m<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	ll k,a,b;
	cin>>k>>a>>b;
	if(b-a<=2)
	cout<<k+1;
	else{
		if(k<=a-1)
		cout<<k+1;
		else
		cout<<a+((k-a+1)/2)*(b-a)+(k-a+1)%2;
	}
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
	solve();
}


Measured memory_bytes: 3640
// ~zaletaet~

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define bpc __builtin_popcountl
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
struct chash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + RANDOM);
  }
};

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int32_t main() {
  fre("");
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
  #define int ll
  int n;
  cin >> n;
  vector<int> a(n);
  ll sum = 0;
  gp_hash_table<int, int, chash> cnt;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    cnt[a[i]]++;
  }
  int q;
  cin >> q;
  while (q--) {
    int x, y;
    cin >> x >> y;
    int v = cnt[x];
    sum -= (v * x);
    cnt[x] -= v;
    cnt[y] += v;
    sum += (v * y);
    cout << sum << '\n';
  }
  
  return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation
// gp_hash_table<T, U, chash> -> fast unordered_map
// m.count(x) <-> (m.find(x) != m.end())


Measured memory_bytes: 13536
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n, m;
  cin >> n >> m;
  priority_queue<int, vector<int>, greater<int>> pq;

  rep(i, 0, n) {
    int a;
    cin >> a;
    pq.push(a);
  }

  vector<P> v(m);
  rep(i, 0, m) cin >> v[i].second >> v[i].first;

  sort(v.rbegin(), v.rend());

  rep(i, 0, m) {
    rep(j, 0, v[i].second) {
      if (pq.top() < v[i].first) {
        pq.push(v[i].first);
        pq.pop();
      } else
        break;
    }
  }

  ll ans = 0;
  while (!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }

  cout << ans << endl;
}


Measured memory_bytes: 4492
while str = STDIN.gets
  n = str.split(" ")
  a = n[0].to_i
  b = n[1].to_i
  c = n[2].to_i

  if a > b
     n = b
     b = a
     a = n
  end

  if b > c
       n = b
       b = c
       c = n
  end

   if a > c
      n = a
      a = c
      c = n
   end

  if a > b
     n = b
     b = a
     a = n
  end

  puts "#{a} #{b} #{c}"

end

Measured memory_bytes: 8652