akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
s = ins()
l = s[:n]
r = s[n:]
r = r[::-1]
h = defaultdict(int)
for i in range(2**n):
    x = ""
    y = ""
    for j in range(n):
        if (i>>j)%2==0:
            x += l[j]
        else:
            y += l[j]
    h[(x,y)] += 1
ans = 0
for i in range(2**n):
    x = ""
    y = ""
    for j in range(n):
        if (i>>j)%2==0:
            x += r[j]
        else:
            y += r[j]
    if (x,y) in h:
        #ddprint(f"{x=} {y=} h {h[(x,y)]}")
        ans += h[(x,y)]
print(ans)


Measured memory_bytes: 166048
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi 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
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int I[300],R[300],O[300];
int main(){
	int N;
	const int MOD = 256;
	while(1){
		cin >> N;
		if(N==0) break;
		FOR(i,1,N+1) cin >> I[i];
		int ansS,ansA,ansC;
		double ansH = 100000000.0;
		REP(A,16){REP(S,16){REP(C,16){
					double H = 0;
					REP(i,300) O[i] = 0;
					R[0] = S;
					for(int i = 1; i <= N; i++){
		            	R[i] = (A * R[i - 1] + C) % MOD;
		           		O[ (I[i] + R[i]) % MOD ]++;
		          	}

		          	for(int i = 0; i < 256; i++){
		            	if(O[i] != 0) H -= (O[i] / (double)(N) * log(O[i] / (double)(N)));
		          	}
		          
		          	if(H + 1e-11 < ansH){
		            	ansH = H;
		            	ansS = S;
		            	ansA = A;
		            	ansC = C;
		          	}
				}
			}
		}
		cout << ansS << " " << ansA << " " << ansC << endl;
	}
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  int a, b;
  cin >> a >> b;

  cout << a * b << endl;

  return 0;
}


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

using namespace std;
typedef unsigned long long ll;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<n[k-1];

    return 0;
}





Measured memory_bytes: 256
#include <cstdio>
using namespace std;
#define N 2005
#define rep(i,l,r) for (int i=l;i<=r;++i)
int x1,x2,y1,y2,n,m,Q,g[N][N],x[N][N],y[N][N],k;
char ch[N][N];
int main()
{
	scanf("%d%d%d",&n,&m,&Q);
	rep(i,1,n)
	{
		scanf("%s",ch[i]+1);
		rep(j,1,m) g[i][j]=g[i-1][j]+g[i][j-1]-g[i-1][j-1]+ch[i][j]-'0',
		           x[i][j]=x[i-1][j]+x[i][j-1]-x[i-1][j-1]+(ch[i][j]=='1'&&ch[i][j-1]=='1'),
				   y[i][j]=y[i-1][j]+y[i][j-1]-y[i-1][j-1]+(ch[i][j]=='1'&&ch[i-1][j]=='1');
	}
	while(Q--)
	{
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		printf("%d\n",g[x2][y2]+g[x1-1][y1-1]-g[x2][y1-1]-g[x1-1][y2]
		            -(x[x2][y2]+x[x1-1][y1]-x[x2][y1]-x[x1-1][y2]
					 +y[x2][y2]+y[x1][y1-1]-y[x1][y2]-y[x2][y1-1]));
	}
	return 0;
}

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

// @@ !! LIM(f:gcd)
// --> f:gcd
// ---- inserted function gcd from util.cc
// g = eGCD(a, b, s, t)  --->  sa + tb = g
ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

// gcd(0, x) = x, gcd(-x, y) = gcd(x, y)
ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(abs(a), abs(b), dummy1, dummy2);
}
// ---- end gcd
// @@ !! LIM  -- end mark --

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

  ll K; cin >> K;
  ll sum = 0;
  for (ll a = 1; a <= K; a++) {
    for (ll b = 1; b <= K; b++) {
      ll x = gcd(a, b);
      if (x == 1) {
	sum += K;
      }else {
	for (ll c = 1; c <= K; c++) {
	  sum += gcd(x, c);
	}
      }
    }
  }
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 3624
import java.util.Scanner;

class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < s.length(); i++){
			
			
			switch(s.charAt(i)){
			case '0':sb.append('0');
			break;
			case '1':sb.append('1');
			break;
			case 'B':if(sb.length() != 0)sb.deleteCharAt(sb.length()-1);
			}
		}
		System.out.print(sb.toString());
		
	}

}


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

using namespace std;

int main(int argc, char* argv[]) {
  int K, T;
  cin >> K >> T;

  vector<int> a(T);
  int maximum = 0;
  for (int i = 0; i < T; ++i) {
    cin >> a[i];
    maximum = max(maximum, a[i]);
  }

  cout << max(maximum - (K - maximum) - 1, 0) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string a;
  	cin >> a;
  	if(a[2]!=a[3]) cout << "No\n";
  	else if(a[4]!=a[5]) cout << "No\n";
  	else cout << "Yes\n";
  	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long tint;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend() 
#define NACHO ios::sync_with_stdio(0); cin.tie(NULL);

const int INF = 1111122222;
const int MOD = 1e9+7;

int main(){
	int n, k; cin >> n >> k;
	int a [n];
	forn(i, n){
		cin >> a[i];
	}
	sort(a, a+n);
	tint cont = 0;
	forn(i, n-k){
		cont+=a[i];
	}
	cout << cont << "\n";
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  ll X,Y,ans=0;
  cin>>X>>Y;
  
  while(X<=Y){
    X*=2;
    ans++;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 764
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

X = int(input())
i = X

while 1:
    if not is_prime(i):
        i += 1
    else:
        ans = i
        print(i)
        break


Measured memory_bytes: 9156
#include<cstdio>
int cnt[100005];

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        int u;
        scanf("%d",&u);
        cnt[u]++;
    }
    int upper = 100000;
    int ans = 0;
    for(int i = 0; i <= upper; i++){
        int u = cnt[i];
        if(i!=0) u += cnt[i-1];
        if(i!=upper) u += cnt[i+1];
        if(u>ans) ans = u;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2084
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	String a=scan.next();
	for(int i=0;i!=a.length()+1;i++) {
		if(i==a.length()) {
			System.out.println("yes");
			return;
		}
		char ch=a.charAt(i);
		int count=0;
		for(int j=i;j!=a.length();j++) {
			char ch2=a.charAt(j);
			if(ch==ch2) {
				count++;
			}
		}
		if(count!=1) {
			System.out.println("no");
			return;
		}
	}
}
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;
using ll = long long;

int main()
{
    ll ans = 0;
    ll x;
    ll m = 100;
    
    cin >> x;
    while (1){
        m = m + m/100;
        ans++;
        if (x <= m){
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;
 
public class Main {
 
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      if (a < b)
         System.out.println("a < b");
      else if (a > b)
         System.out.println("a > b");
      else
         System.out.println("a == b");
   }
}

Measured memory_bytes: 26060
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str

def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    conns = [[] for _ in range(N)]
    for i in range(M):
        conns[A[i] - 1].append(B[i] - 1)
        conns[B[i] - 1].append(A[i] - 1)

    q = [0]
    ret = [-1] * N
    visited = [False] * N
    visited[0] = True
    while True:
        nex = []
        for i in q:
            for con in conns[i]:
                if not visited[con]:
                    nex.append(con)
                    ret[con] = i
                    visited[con] = True
        if len(nex) == 0:
            break
        q = nex
    for r in ret[1:]:
        if r < 0:
            print('No')
            return
    print('Yes')
    for r in ret[1:]:
        print(r + 1)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 98100
#include<bits/stdc++.h>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const int maxn = 3e5+10;
int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	ll t = a+b;
	ll time = n/t;
	ll y = n%t;
	ll sum = 0;
	sum+=time*a;
	if(y<=a) sum+=y;
	else sum+=a;
	cout<<sum<<endl;
		 
	return 0;
}


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

signed main(void){
  
  string S; cin >> S;
  int res = 0,ans = 0;
  for(int i = 0; i < (int)S.size(); i++){ 
    if( S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C' ){ res++;}
    else{ res = 0;}
    ans = max(res,ans);
  }

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

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define pr(x) prev(x.end())
# define mset multiset
# define umap unordered_map
# define gcd __gcd
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int mod = 1e9+7;//998244353
const int N = 1e5+5;



void solve(){
	string s;
	cin>>s;
	ll sum=0;
	rep(i,sz(s)){
		sum+=(int)(s[i]-'0');
	}
	if(sum%9==0)cout<<"Yes";
	else cout<<"No";
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

Measured memory_bytes: 3768
import sys
from fractions import gcd

a = []
for _ in range(5):
    a.append(int(input()))

k = int(input())

for i in range(5):
    for j in range(5):
        if abs(a[i] - a[j]) > k:
            print(":(")
            exit(0)

print("Yay!")


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, i=0, j=0;
    string s, t, ans="";
    cin >> n;
    cin >> s >> t;
    while(t[j]!='\0'){
        ans+=s[i];
        ans+=t[j];
        i++;j++;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int A[100];
int sw = 0;

void bubbleSort(int A[], int N)
{
    for (int i = 0; i < N; i++)
    {
        for (int j = N - 1; j > i; j--)
        {
            if (A[j] < A[j - 1])
            {
                swap(A[j], A[j - 1]);
                sw++;
            }
        }
    }
}

int main()
{
    // 入力の受け取り
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }

    // ソートの実行
    bubbleSort(A, n);

    // 結果出力
    for (int j = 0; j < n; j++)
    {
        if (j > 0)
        {
            cout << " ";
        }
        cout << A[j];
    }

    // 回数出力
    cout << endl;
    cout << sw << endl;

    return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
inline ll rd(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int mod = 1e9+7;
const int maxn = 2099;
int dp[maxn][maxn],fac[maxn*maxn],inv[maxn*maxn],n,k;
inline int C(int n,int m){
	return 1ll * fac[n] * inv[m] % mod * inv[n-m] % mod;
}
inline int qpow(int a,int b){
	int ans = 1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)ans=1ll*ans*a%mod;
	return ans; 
}
int main(){
	n = rd(),k = rd();
	if(k==1){puts("1");return 0;}
	fac[0] = 1;
	Rep(i,1,2002*2002) fac[i] = 1ll * fac[i-1] * i % mod;
	inv[2002*2002] = qpow(fac[2002*2002],mod-2);
	Dep(i,2002*2002-1,0) inv[i] = 1ll * inv[i+1] * (i+1) % mod;
	dp[0][1] = 1;
	Rep(i,2,n){
		dp[0][i] = 1ll * dp[0][i-1] * C((i-1)*(k-1) + k-2,k-2) % mod;
		//n插入m 
	}
	Rep(i,1,n){
		Rep(j,i,n){
			dp[i][j] = (dp[i-1][j] +
			1ll * dp[i][j-1] * C(i+(j-1)*(k-1)+k-2,k-2) % mod) % mod;
		}
	}
	writeln(1ll * dp[n][n] * fac[n] % mod);
	return 0;
}
//n+1个空 
//a1 + a2 + a3 …… an + a[n+1] = m
//(a1+1) + (a2+1) + (a3+1) + …… = m + n + 1

Measured memory_bytes: 51456
#include<bits/stdc++.h>
using namespace std;
#define P 1000000007
int n,i,j,x,l[26];
long long dp[2][26],ans,sum;
char s[100005];
int main() {
	scanf("%d%s",&n,s);
	for(j=0; j<26; j++)l[j]++;
	for(i=0; i<n; i++) {
		x=s[i]-'a',l[x]++;
		for(sum=1,j=0; j<26; j++)
			if(j!=x)sum=sum*l[j]%P;
		ans=(ans+sum)%P;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
	int a,sum;
	sum = 0;
	for(int i=0;i<3;i++){
		cin >>a;
		sum +=a;
	}
	if(sum > 21){
		cout << "bust";
	}else{
		cout << "win";
	}
	return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Tue Jan 28 20:52:55 2020
//
package main

import "fmt"

var a, b int

func main() {
	fmt.Scan(&a, &b)
	if a < b {
		for i := 0; i < b; i++ {
			fmt.Print(a)
		}
	} else {
		for i := 0; i < a; i++ {
			fmt.Print(b)
		}
	}
	fmt.Println()
}


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

using namespace std;

int main(){
  long long n,m,d;
  cin >> n >> m >> d;
  if(d==0){
    cout << setprecision(20) << fixed;
    cout << (double)(m-1)/n << endl;
    return 0;
  }
  cout << setprecision(20) << fixed;
  cout << (double)(m-1)*2*(n-d)/(n*n) << endl;
}

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

using namespace std;
class dsu{
	public:
	vector<int>p;
	int n;
	
	dsu(int _n):n(_n){
		p.resize(n);
		iota(p.begin(),p.end(),0);
	}
	inline int get(int x){
		return(x==p[x]?x:(p[x]=get(p[x])));
	}
	inline bool unite(int x,int y){
		x=get(x);
		y=get(y);
		if(x!=y){
			p[x]=y;
			return true;
		}
		return false;
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	dsu d(n);
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		d.unite(x,y);
	}
	vector<vector<int> >comp(n);
	for(int i=0;i<n;i++){
		comp[d.get(i)].push_back(a[i]);
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(!comp[i].empty()){
			cnt++;
		}
	}
	if(cnt==1){
		puts("0");
		return 0;
	}
	int choose=2*cnt-2;
	long long ans=0;
	vector<int>other;
	for(int i=0;i<n;i++){
		if(!comp[i].empty()){
			sort(comp[i].begin(),comp[i].end());
			ans+=comp[i][0];
			choose--;
			for(int j=1;j<(int)comp[i].size();j++){
				other.push_back(comp[i][j]);
			}
		}
	}
	if(choose>(int)other.size()){
		puts("Impossible");
		return 0;
	}
	sort(other.begin(),other.end());
	for(int i=0;i<choose;i++){
		ans+=other[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;

int main() {
  string n;
  cin >> n;
  int m = 0;
  REP(i, SZ(n)) {
    int k = (n[i] - '0');
    m = (m + k) % 9;
  }
  if (m == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
import scala.io.StdIn
 
object Main{
  def main(args:Array[String]){
    val sc=new java.util.Scanner(System.in)
    val n=sc.nextInt
    val a=Array.fill(4,13)(false)
    val map=Map("S"->0,"H"->1,"C"->2,"D"->3)
    for(i<-0 until n){
      val c=map(sc.next)
      val I=sc.nextInt-1
      a(c)(I)=true
    }
    for(i<-0 until 4;j<-0 until 13 if !a(i)(j)){
      if(i==0) println("S "+(j+1))
      if(i==1) println("H "+(j+1))
      if(i==2) println("C "+(j+1))
      if(i==3) println("D "+(j+1))
    }
  }
}

Measured memory_bytes: 45120
n=int(input())
s=list(input())
l=[chr(ord('A') + i) for i in range(26)]
x=[]
for i in range(int(len(s))):
  if l.index(s[i])+n>25:
    x.append(l[l.index(s[i])+n-26])
  else:
    x.append(l[l.index(s[i])+n])
print("".join(x))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

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

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N, tot, a[100002];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    FOR(i,1,N+1) cin >> a[i];
    FOR(i,1,N+2) tot += abs(a[i]-a[i-1]);
    
    FOR(i,1,N+1) {
        int tmp = tot;
        tmp -= abs(a[i-1]-a[i]);
        tmp -= abs(a[i+1]-a[i]);
        tmp += abs(a[i+1]-a[i-1]);
        cout << tmp << "\n";
    }
}

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

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  string S,T;
  cin >> S >> T;
  string ans = "Yes";
  if(S.size()+1 == T.size()){
    REP(i,S.size()){
      if(S[i] != T[i]){
        ans = "No";
      }
    }
  }else{
    ans = "No";
  }
  cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int l = a.size();
  int ans;
  if (l % 2 == 1) {
    int ma = a[l / 2];
    int mb = b[l / 2];
    ans = mb - ma + 1;
  } else {
    double ma = a[l / 2] + a[l / 2 - 1];
    double mb = b[l / 2] + b[l / 2 - 1];
    ans = mb - ma + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4800
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		long a=sc.nextLong();
		long b=sc.nextLong();
		long c=sc.nextLong();
		long d=sc.nextLong();
		ArrayList<Long> x=new ArrayList<>();
		ArrayList<Long> y=new ArrayList<>();
		x.add(a);
		x.add(b);
		y.add(c);
		y.add(d);
		if (a<=0&&0<=b) x.add(0L);
		if (c<=0&&0<=d) y.add(0L);
		long ans=Long.MIN_VALUE;
		for (long v:x) {
			for (long u:y) {
				ans=Math.max(ans, u*v);
			}
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

Measured memory_bytes: 32456
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
0 0 2
2 0 2

output:
1.00000000 -1.73205080 1.00000000 1.73205080
"""

import sys
from math import sin, cos, atan2, acos
from operator import attrgetter


class Circle(object):
    __slots__ = ('centre', 'radius')

    def __init__(self, centre=float('inf'), radius=-1):
        self.centre = complex(centre)
        self.radius = float(radius)


def arg(p_vector):
    return atan2(p_vector.imag, p_vector.real)


def polar(a, r):
    return a * cos(r) + a * sin(r) * 1j


def get_circles_cross_points(c1, c2):
    centre_distance = abs(c1.centre - c2.centre)
    a = acos((pow(c1.radius, 2) + pow(centre_distance, 2) - pow(c2.radius, 2)) /
             (2 * c1.radius * centre_distance))
    t = arg(c2.centre - c1.centre)
    ans = [c1.centre + polar(c1.radius, t + a), c1.centre + polar(c1.radius, t - a)]
    ans.sort(key=attrgetter('real', 'imag'))

    return ans


def solve(_circle_info):
    for i, circle in enumerate(_circle_info):
        cx, cy, r = map(int, circle)
        circles[i].centre = cx + cy * 1j
        circles[i].radius = r

    cp1, cp2 = get_circles_cross_points(*circles)
    print('{0:.8f} {1:.8f} {2:.8f} {3:.8f}'.format(cp1.real, cp1.imag, cp2.real, cp2.imag))
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    circle_info = map(lambda x: x.split(), _input)

    circles = [Circle() for _ in range(2)]
    solve(circle_info)

Measured memory_bytes: 8080
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,a,b,c;
int main(){
    cin>>n;
    ll ans=0; a=b=c=0;
    for(int i=0;i<n;i++){
	string s;cin>>s;
	if(s[0]=='B'&&s[s.size()-1]=='A')a++;
	else if(s[0]=='B')b++;
	else if(s[s.size()-1]=='A')c++;
	for(int j=0;j<s.size()-1;j++){
	    if(s[j]=='A'&&s[j+1]=='B')ans++;
	}
    }//cout<<a<<" "<<b<<" "<<c<<endl;
    if(a==0){
	ans+=min(b,c);
    }
    else{
	ans+=a-1;
	if(b>0)ans++,b--;
	if(c>0)ans++,c--;
	ans+=min(b,c);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, pwd, min = 100000;
  scanf("%d", &n);
  scanf("%d", &pwd);
  int m[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &m[i]);
    pwd -= m[i];
    if (m[i] < min) min = m[i];
  }

  printf("%d\n", n + pwd / min);
  return 0;
}


Measured memory_bytes: 128
n = int(input())
li = list(map(int,input().split()))
ans = li[0]
h = 10**18
for i in range(n-1):
  ans*=li[i+1]
  if ans>h:
    if 0 in li:
      print(0)
    else:
      print(-1)
    break;
  elif i==n-2:
    print(ans)

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

using namespace std;

int main()
{
 	int n,k;
  	cin>>n>>k;
	int pivot = n;
	int connections = n*(n-1);
	connections/=2;

	set< pair<int,int> > removed;
	int end = pivot - 1;
	for(int i=1;i<pivot;i++)
	{	
      	//cout<<i<<" "<<pivot<<" "<<end<<endl;
		for(int j=i+1;j<=end;j++)
		{
			if(k==0)
				break;
			removed.insert(make_pair(i,j));
			k--;
		}
      	//end--;
		if(k==0)
			break;
	}
	if(k!=0)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<connections-(removed.size())<<endl;
		for(int i=1;i<=n;i++)
		{
			for(int j=i+1;j<=n;j++)
			{
				if(j!=i)
				{
					pair<int,int> p = make_pair(i,j);
					pair<int,int> q = make_pair(j,i);
					if((removed.find(p)==removed.end())&&(removed.find(q)==removed.end()))
					{
						cout<<i<<" "<<j<<endl;
					}
				}
			}
		}
	}
	return 0;
}



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

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

	string cnt = r + g + b;
	if(stoi(cnt) % 4 == 0) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    
    for (int i = 0; i < k; i++) {
        if (i % 2 == 0) {
            if (a % 2 == 1) {
                a--;
            } else {
            }
            b += a / 2;
            a /= 2;
        } else {
            if (b % 2 == 1) {
                b--;
            } else {
            }
            a += b / 2;
            b /= 2;
        }
    }
    
    cout << a << " " << b << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll L,x[200005];
int n;
ll rui[200005][3];
ll sol(){
	int pre = 0;
	for(int i=1;i<=n;i++){
		rui[i][0] = rui[i-1][0]+(x[i]-pre);
		rui[i][1] = rui[i-1][1]+1LL*(x[i]-pre)*(-2*i);
		rui[i][2] = rui[i-1][2]+1LL*(x[i]-pre)*(2*i);
		pre = x[i];
	}
	ll ret = -1e18;
	for(int i=1;i<=n;i++){
		ll sum = x[i]*(n-i+1)+(L-x[n])*(n-i);
		//if(i==3)cout<<sum<<endl;
		if(i==n){
			ret = max(ret,sum); continue;
		}
		int zan = n-i-1;
		int x = (zan)/2+1;
		if(zan%2==0){
    		sum += rui[i+x][1]-rui[i][1] + 1LL*(n+i+1)*(rui[i+x][0]-rui[i][0]);
    		if(zan) sum += rui[n][2]-rui[i+x][2] + 1LL*(-n-i-2)*(rui[n][0]-rui[i+x][0]);
		}
		else{
			sum += rui[i+x][1]-rui[i][1] + 1LL*(n+i+1)*(rui[i+x][0]-rui[i][0]);
    		if(zan) sum += rui[n][2]-rui[i+x+1][2] + 1LL*(-n-i-2)*(rui[n][0]-rui[i+x+1][0]);
		}
		ret = max(ret,sum);
	}
	return ret;
}
int main(){
	cin>>L>>n;
	for(int i=1;i<=n;i++) scanf("%d",&x[i]);
	ll ans = -1e18;
	ans = max(ans,sol()); //cout<<ans<<endl;
	for(int i=1;i<=n;i++){
		x[i] = L-x[i];
	}
	reverse(x+1,x+n+1);
	ans = max(ans,sol());
	cout<<ans<<endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    string r,g,b;
    cin >> r >> g >> b;
    string rr = r+g+b;
    int rgb = stoi(rr);
    if (rgb%4 == 0) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
}


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

int main() {
	int N,K,x = 1,a,b;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		a = x * 2;
		b = x + K;
		if (a <= b) x = a;
		else x = b;
	}
	cout << x << endl;

}

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

int main()
{
        int input_num, out_i, in_i;
        int array[100], min, tmp;
        int sorted_seq = 0;

        scanf("%d", &input_num);

        for ( in_i = 0 ; in_i < input_num ; in_i++ )
        {
                scanf("%d", &array[in_i]);
        }

        /*Selection sort*/
        for ( out_i = 0 ; out_i < input_num ; out_i++ )
        {
                min = out_i;
                for ( in_i = out_i ; in_i < input_num ; in_i++ )
                {
                        if ( array[in_i] < array[min] )
                                min = in_i;
                }

                if ( out_i != min )
                {
                        tmp = array[out_i];
                        array[out_i] = array[min];
                        array[min] = tmp;
                        sorted_seq = sorted_seq + 1;
                }
        }

        for ( in_i = 0 ; in_i < input_num ; in_i++ )
        {
                if ( in_i == input_num - 1 )
                        fprintf( stdout, "%d\n", array[in_i] );
                else 
                        fprintf( stdout, "%d ", array[in_i] );
        }
        fprintf( stdout, "%d\n", sorted_seq );

        return 0;
}

Measured memory_bytes: 600
N = int(input())
#S = list(input())

#N,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=0
remind_i = N+100

for i in A:
    ans+=B[i-1]
    if i-remind_i==1:
        ans+=C[remind_i-1]
    remind_i = i





print(str(ans))

Measured memory_bytes: 38256
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int x = sc.nextInt();
        int y = sc.nextInt();
        int m = y - 2 * x;
        int n = 4 * x - y;

        if (m % 2 == 0 && m >= 0 && n % 2 == 0 && n >= 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");

        }


        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 35836
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		
		n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			System.out.println("Case " + (i + 1) + ":");
			for (int j = 0; j < 10; j++) {
				a = a * a;
				a %= 1000000;
				a /= 100;
				System.out.println(a);
			}
		}
	}
}

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

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

	std::vector<int> ls(n);
	for (auto&& e : ls)
		std::cin >> e;

	std::sort(ls.begin(), ls.end());

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			auto k = std::lower_bound(ls.begin(), ls.end(), ls[i] + ls[j]) - ls.begin();

			ans += k - j - 1;
		}
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,w;
   cin>>n>>w;

   int a[n][2];
   int wt[n],val[n];

   for(int i=0;i<n;i++)
   {
     cin>>wt[i]>>val[i];
   }
   long long int dp[n+1][w+1];

   memset(dp,0,sizeof(dp));

   for(int i=1;i<=n;i++)
   {
      for(int j=1;j<=w;j++)
      {
        if(wt[i-1]>j)
        {
           dp[i][j]=dp[i-1][j];
        }
        else
          dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]);
      }
   }
   // for(int i=0;i<=w;i++)
   // cout<<i<<"  ";
   // cout<<"\n";
   // for(int i=0;i<=n;i++)
   // {
   //    for(int j=0;j<=w;j++)
   //    {
   //       cout<<dp[i][j]<<"  ";      
   //    }
   //    cout<<"\n";
   // }
   cout<<dp[n][w];


}


Measured memory_bytes: 79104
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

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

    long long ans = 0;
    for(int i=0; i<63; ++i){
        int x = 0;
        for(int j=0; j<n; ++j){
            if(a[j] & (1LL << i))
                ++ x;
        }
        long long tmp = x * (long long)(n - x);
        tmp %= MOD;
        tmp *= (1LL << i) % MOD;
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


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

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

  map<int, int> p;
  int ans = 0;

  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    if (p.count(s)) {
      if (p[s] != c) {
        cout << "-1" << endl;
        return 0;
      }
    } else {
      p[s] = c;
    }
  }

  for (auto a : p) {
    auto s = a.first;
    auto c = a.second;

    if (N > 1 && s == 1 && c == 0) {
      cout << "-1" << endl;
      return 0;
    }

    ans += (int)pow(10, N - s) * c;
  }

  if (N > 1 && !p.count(1)) ans += (int)pow(10, N - 1);

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        
        int []l = new int [n+1];
		int []r = new int [n+1];
		l[0] = 0;
		r[n] = 0;

		for(int i = 0; i < n ; i++) {
			l[i+1] = gcd(l[i],a[i]);
		}
		for(int j = n-1; j>=0; j--) {
			r[j] = gcd(r[j+1],a[j]);
		}
		int max = 1;
		
		for(int i = 0 ; i < n ; i++) {
			int p = gcd(l[i],r[i+1]);
			if(max < p)
				max = Math.max(max, p);
        }
        System.out.println(max);
    }

    public static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

}

Measured memory_bytes: 51824
import math

H, W = [int(x) for x in input().split()]
A = [[0] * W for _ in range(H)]

for i in range(H):
    A[i] = [int(x) for x in input().split()]

retlist = []

for i in range(H):
    for j in range(W - 1):
        if A[i][j] % 2 == 1:
            A[i][j + 1] += 1
            A[i][j] -= 1
            retlist.append((i, j, i, j + 1))

for i in range(H - 1):
    if A[i][W - 1] % 2 == 1:
        A[i + 1][W - 1] += 1
        A[i][W - 1] -= 1
        retlist.append((i, W - 1, i + 1, W - 1))

print(len(retlist))
for i1, j1, i2, j2 in retlist:
    print("{} {} {} {}".format(i1 + 1, j1 + 1, i2 + 1, j2 + 1))


Measured memory_bytes: 22056
#include<bits/stdc++.h>
using namespace std;
char a[100];
int main()
{
   int n,s=0;
   cin>>n;
   for(int i=0;i<n;i++)
   cin>>a[i];
   for(int i=0;i<n;i++)
   {
   if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')
   s++;
   }
   cout<<s;
   return 0;
   } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  ll cnt=1;
  ll all_cnt=1;
  REP(i,n){
    int a;
    cin>>a;
    all_cnt*=3;
    if(a%2==0){
      cnt*=2;
    }
  }
  P(all_cnt-cnt);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		String X=stdIn.next();
		String Y=stdIn.next();
		String a[]={"A","B","C","D","E","F"};
		int z=0;
		if(X.equals(Y))
			System.out.println("=");
		else{
			while(z<6){
				if(X.equals(a[z])){
					System.out.println("<");
					break;
				}
				if(Y.equals(a[z])){
					System.out.println(">");
					break;
				}
				z++;
			}
		}
	}
}

Measured memory_bytes: 25172
#include <iostream>
using namespace std;
int main(){
    int n,v; cin >> n;
    int A[n+1];
    for (int i=0; i<n; i++){ cin >> A[i];}
    int c = 0,cnt = 0;
    for (int i=0; i<n; i++){ 
        if (A[c]!=-1){
            v = c;
            c = A[c]-1;
            A[v] = -1;
            cnt++;
            if (c+1==2) { cout << cnt << endl; return 0;}
        }
        else {cout << -1 << endl; return 0;}
    }
    cout << -1 << endl;
}

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

using namespace std;
const int N = 8e3 + 10;
bitset <N> dpx, dpy;
vector <int> vec[2];

int main()
{
    string s; cin >> s;
    int X, Y; cin >> X >> Y;
    int n = s.size(), d = 0, i = 0, dis = 0;
    while (i < n && s[i] == 'F') i++;
    int xx = i;
    for (; i < n; i ++) {
        if (s[i] == 'T') {
            if (dis > 0) vec[d].push_back(dis);
            d ^= 1, dis = 0;
        }
        else dis++;
    }
    if (dis > 0) vec[d].push_back(dis);
    int x = 0, y = 0;
    for (int i : vec[0]) x += i;
    for (int i : vec[1]) y += i;
    dpx[x] = 1;
    dpy[y] = 1;
    for (int i : vec[0]) dpx |= (dpx >> (i * 2));
    for (int i : vec[1]) dpy |= (dpy >> (i * 2));
    int ans = dpx[abs(X - xx)] & dpy[abs(Y)];
    cout << (ans ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	x := getNextInt(scanner)
	y := getNextInt(scanner)
	ans := 0
	switch x {
	case 1:
		ans += 300000
	case 2:
		ans += 200000
	case 3:
		ans += 100000
	}
	switch y {
	case 1:
		ans += 300000
	case 2:
		ans += 200000
	case 3:
		ans += 100000
	}
	if x == 1 && y == 1 {
		ans += 400000
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
///using ll=long long;
#define ll long long
const int amx=100000;
int main()
{
	int a[amx],b[amx];
	ll n,k;
	cin>>n>>k;
	vector<pair<int,int> >vec;
	for(int i=0;i<n;i++){
		int a2,b2;
		cin>>a2>>b2;
		vec.push_back(make_pair(a2,b2));
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<n;i++){
		a[i]=vec[i].first;
		b[i]=vec[i].second;
	}
	for(int i=0;i<n;i++){
		if(b[i]>=k){
			cout<<a[i]<<endl;
			break;
		}else{
			k-=b[i];
		}
	}
	return 0;
}

Measured memory_bytes: 1908
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int H,W,A,B;
	int MOD = (int)1e9 + 7;
	long[] nCk,modInv;

	public long modpow(long x,long y){
		if(y == 0)return 1;
		else if(y == 1)return x;
		else if(y % 2 == 0){
			long z = modpow(x,y / 2) % MOD;
			return z * z % MOD;
		}else{
			return modpow(x,y - 1) * x % MOD;
		}
	}

	public void solve() {
		H = nextInt();
		W = nextInt();
		A = nextInt();
		B = nextInt();


		nCk = new long[H + W];
		modInv = new long[H + W];
		nCk[0] = 1;
		modInv[0] = 1;

		for(int i = 1;i < H + W;i++){
			nCk[i] = nCk[i - 1] * i % MOD;
			modInv[i] = modpow(nCk[i],MOD - 2) % MOD;
		}


		long ans = 0;
		for(int i = 0;i < H - A;i++){

			int n1 = B - 1 + i;
			int k1 = i;

			long comb1 = nCk[n1] * modInv[k1] % MOD * modInv[n1 - k1] % MOD;

			int n2 = W - B - 1 + H - 1 - i;
			int k2 = W - B - 1;

			long comb2 = nCk[n2] * modInv[k2] % MOD * modInv[n2 - k2] % MOD;

			ans += comb1 * comb2 % MOD;
			ans %= MOD;

		}
		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 11604
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin>>n){
    if(n==0) break;
    char c[n][2],s;
    for(int i=0;i<n;i++) cin >> c[i][0] >> c[i][1];
    int m;
    cin >> m;
    for(int i=0;i<m;i++){
      cin >> s;
      bool ok = true;
      for(int j=0;j<n;j++){
	if(s==c[j][0]){
	  cout << c[j][1];
	  ok = false;
	  break;
	}
      }
      if(ok) cout << s;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
import sys
input = sys.stdin.readline
def main():
    K, X = map(int, input().split())
    LOWER = max(X - K + 1, -1000000)
    UPPER = min(X + K - 1, 1000000)
    ans = [str(i) for i in range(LOWER, UPPER+1)]
    print(" ".join(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    cerr << a << " " << b << endl;
    if (a > b)
        swap(a, b);
    if (a == 0)
        return b;
    return gcd(a, b % a);
}

int main()
{
    ll n, k;
    cin >> n >> k;
    if (n % k == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << min(n % k, k - n % k) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string.h>
using namespace std;

int main(void) {
	int A, B;
	cin >> A >> B;
	if (A >= 13) {
		cout << B << endl;
	}
	else if (6 <= A && A <= 12) {
		cout << B / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256