akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    bool ok = true;
    rep(i, (n-1)/2) {
        if (s[i] != s[(n-1)/2-i-1]) ok = false;
    }
    for (int i = (n+3)/2-1; i < n; i++) {
        if (s[i] != s[n-i-1]) ok = false;
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll A, B;
int K;

void solve() {
    REP(i, K) {
        if (i % 2 == 0) {

            if (A % 2 == 0) {
                B += A / 2;
                A /= 2;
            } else {
                A -= 1;
                B += A / 2;
                A /= 2;
            }
        } else {

            if (B % 2 == 0) {
                A += B / 2;
                B /= 2;
            } else {
                B -= 1;
                A += B / 2;
                B /= 2;
            }
        }
    }
    printf("%lli %lli", A, B);
}

int main() {
    cin >> A >> B >> K;
    solve();
    return 0;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
n = int(input())
a = sorted(list(map(int, input().split())))
if n % 2 == 1:
    b = [0]
    for i in range(1, n // 2 + 1):
        b.append(i * 2)
        b.append(i * 2)
else:
    b = []
    for i in range(n // 2):
        b.append(i * 2 + 1)
        b.append(i * 2 + 1)
if a != b:
    print(0)
else:
    print(pow(2, n//2, MOD))


Measured memory_bytes: 13880
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define debug1(a) cout<<#a<<" "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" "<<(a)<<" "<<#b<<" "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" "<<(a)<<" "<<#b<<" "<<(b)<<" "#c<<" "<<(c)<<endl;
typedef long double ld;
void solve()
{
	ll r;
	cin >> r;
	ll val = (22 / 7) * 1;
	ll val2 = (22 / 7) * (r * r);
	cout << val2 / val << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t = 1;
	while (t--)
	{
		solve();
	}
}

Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int A=0,B=0;
  rep(i,n){
    if(i%2==0)A+=a[i];
    else B+=a[i];
  }
  cout<<A-B<<endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define CM cerr<<(&MOP1-&MOP2)/1024.0/1024.0<<endl
using namespace std;
template <class T> inline T Min(T x, T y){
    return x<y?x:y;
}
template <class T> inline T Max(T x, T y){
    return x>y?x:y;
}
bool MOP1;
int n;
int A[N];
bool mark[N];
bool MOP2;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=n;i>1;i--){
		if(A[i]<A[i-1])A[i-1]--;
		if(A[i]<A[i-1]){
			puts("No");return 0;
		}
	}
	puts("Yes");
	return 0;
}






Measured memory_bytes: 640
#include <stdio.h>
#define MAX 100005
#define NIL -1

struct Node {
	int p , r , l;
};

struct Node T[MAX];
int n , D[MAX];

void print(int u)
{
	int i , c;
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].p);
	printf("depth = %d, ",D[u]);
	
	if( T[u].p == NIL) printf("root, ");
	else if(T[u].l == NIL) printf("leaf, ");
	else printf("internal node, ");
	
	printf("[");
	
	for( i = 0, c = T[u].l; c != NIL; i++ , c = T[c].r)
	{
		if(i)printf(", ");
		printf("%d",c);
	}
	printf("]\n");
}

int rec( int u , int p)
{
	D[u] = p;
	if(T[u].r != NIL) rec(T[u].r,p);
	if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void)
{
	int i , j , d , v , c , l , r;
	scanf("%d",&n);
	for( i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;
	
	for( i = 0; i < n; i++)
	{
		scanf("%d %d",&v,&d);
		for( j = 0; j < d; j++)
		{
			scanf("%d",&c);
			if( j == 0)T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for( i = 0; i < n; i++)
	{
			if(T[i].p == NIL) r = i;
	}
	
	rec(r,0);
	for( i = 0; i < n; i++) print(i);
	return 0;
}




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


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

template <typename T>
vector<T> readList(int len){
    vector<T> res(len);
    for(int i=0; i < len; i++){
        T temp;
        cin >> temp;
        res[i] = temp;
    }
    return res;
}


int main(){
    COMinit();

    int n, k;
    cin >> n >> k;
    auto a = readList<int>(n);

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

    long long up = 0;
    for(int i=k-1; i < n; i++){
        up += a[i]*COM(i, k-1);
        up = up % MOD;
    }

    long long down = 0;
    for(int i=0; i <= n-k; i++){
        down += a[i]*COM(n-(i+1), k-1);
        down = down % MOD;
    }

    long long res = (up + MOD - down) % MOD;

    cout << res << endl;


    // 計算例
    // cout << COM(100000, 50000) << endl;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h> 
#include <complex>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

ll mpow(ll a, ll b, ll p){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}

ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}

ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}

v64 dp,a;
ll tval;
string s,t;
bool bo = 0;
ll g = 3;

ll f(ll val){
	if(bo) return 0;
	if(dp[val]==-2){
		bo = 1;
		return 0;
	}
	if(dp[val]!=-1){
		return dp[val];
	}
	ll nval = (a[val+sz(t)]-a[val]+MOD)%MOD;
	nval *= mpow(g,(val*(MOD-2))%(MOD-1));
	nval %= MOD;
	if(nval==tval){
		ll nin = (val+sz(t))%sz(s);
		// cout << val << " " << sz(t) << " " << sz(s) << " " << nin << ln;
		if(nin!=val){
			dp[val] = -2;
			ll temp = f(nin);
			dp[val] = 1+temp;
		}
		else{
			// cout << val << ln;
			dp[val]=1;
			bo = 1;
		}
		if((val+dp[val]*sz(t))%sz(s) == val){
			bo = 1;
		}
	}
	else{
		dp[val]=0;
	}
	return dp[val];
}

void solve(){
	cin >> s;
	cin >> t;
	a.resize(sz(t)+sz(s)+5,0);
	ll fact = g;
	forn(i,sz(t)+sz(s)){
		a[i+1]=(a[i]+(s[i%sz(s)]-'a'+1)*fact)%MOD;
		fact *= g;
		fact %= MOD;
	}
	fact = g;
	forn(i,sz(t)){
		tval = (tval+(t[i]-'a'+1)*fact)%MOD;
		fact *= g;
		fact %= MOD;
	}
	dp.resize(sz(s)+5,-1);
	ll ans = 0;
	forn(i,sz(s)) ans = max(ans, f(i));
	// forn(i,sz(s)) cout << dp[i] << " ";
	// cout << ln;
	if(bo) cout << -1 << ln;
	else cout << ans << ln;
}

int main()
{
	fast_cin();
    ll t=1;
    // cin >> t;
    forn(i,t) {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 36892
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N, M = read_int_list()
    p = [0] * M
    S = [''] * M
    for i in range(M):
      l = read_str_list()
      p[i] = int(l[0])
      S[i] = l[1]
      
    r = set()
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in r:
          r.add(p[i])

    correct, penalties = 0, 0
    f = set()  
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in f:
          f.add(p[i])
          correct += 1
      # print(p[i], S[i], f, r)
      
      if S[i] == 'WA':
        if p[i] not in f and p[i] in r:
          penalties += 1

    print(correct, penalties)


def main0():
    N, M = read_int_list()
    p = [0] * M
    S = [''] * M
    for i in range(M):
      l = read_str_list()
      p[i] = int(l[0])
      S[i] = l[1]
      
    r = set()
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in r:
          r.add(p[i])

    correct = len(r)
    penalties = 0
    f = set()  
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in f:
          f.add(p[i])
      
      if S[i] == 'WA':
        if p[i] not in f and p[i] in r:
          penalties += 1

    print(correct, penalties)

main0()


Measured memory_bytes: 24792
#include<cstdio>
#include<iostream>
#include<numeric>

using namespace std;

int main(){
    int lim;
    scanf("%d", &lim);

    int sum=0;
    for(int i=1; i<=lim; i++){
        for(int j=1; j<=lim; j++){
            for(int k=1; k<=lim; k++){
                sum += gcd(gcd(i,j), k);
            }
        }
    }

    printf("%d", sum);
}

Measured memory_bytes: 3828
K, N = map(int,input().split())
A = list(map(int,input().split()))
list = []
x = K-A[len(A)-1] + A[0]
list.append(x)
for i in range(1,len(A)):
    list.append(A[i] - A[i-1])
print(K - max(list))

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

int n, A[50];

bool solve(int i, int m){
	if(m==0) return true;
	if(i >= n) return false;
	return (solve(i+1, m) || solve(i+1, m-A[i]));
}


int main() {
	ios::sync_with_stdio(false);
	
	int m;
	cin >> n;

	for(int i=0; i<n; i++){
		cin >> A[i];
	}
	
	cin >> m;
	int B[m];
	
	for(int i=0; i<m; i++){
		cin >> B[i];
		if(solve(0, B[i])) cout << "yes\n";
		else cout << "no\n";
	}
	
	
	return 0;
}

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

typedef long long ll;

char s[20][1010];
int sum[20][1010];
int main()
{
    int n,m,kk;
    scanf("%d%d%d",&n,&m,&kk);
    for(int i=1; i<=n; i++)
    {
        scanf("%s",s[i]+1);
        for(int j=1; j<=m; j++)
        {
            if(s[i][j]=='1')
                sum[i][j]=1;
            sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
        }
    }
    int ans=0x3f3f3f3f;
    for(int i=0; i<(1<<(n-1)); i++)
    {
        int now=0,len=0;
        int b[10]= {0};
        for(int j=0; j<n-1; j++)
        {
            if(i&(1<<j))
                now++,b[++len]=j+1;
        }
        b[++len]=n;
        int l=0;
//        cout<<i<<"====="<<now<<endl;
        for(int j=1; j<=m; j++)
        {
            int op=0;
            for(int k=1; k<=len; k++)
            {
                int x=sum[b[k]][j]+sum[b[k-1]][l]-sum[b[k-1]][j]-sum[b[k]][l];
//                if(i==0){
////                    cout<<j<<"+++"<<x<<endl;
//                }
                if(x>kk)
                    op=1;
            }
//            if(i==0){
////                cout<<l<<"??"<<op<<endl;
//            }
            if(op)
            {
                if(j-1==l)
                {
                    now=0x3f3f3f3f;
                    break;
                }
                else
                {
                    now++;
                    l=j-1;
                }
            }
        }
//        cout<<now<<endl;
        ans=min(ans,now);

    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  int k,s;
  cin >> k >> s;

  int c = 0;
  rep(i,k+1){
    rep(j,k+1){
      if ((s-i-j)<=k and (s-i-j)>=0){
        c += 1;
      }
    }
  }
  cout << c << endl;


  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

def get_point(s):
  if s == "r":
    return P
  elif s == "s":
    return R
  elif s == "p":
    return S

ans = 0
restricted = [False] * N
for i in range(N):
  if (i+1) <= K:
    ans += get_point(T[i])
  else:
    if T[i-K] == T[i]:
      if restricted[i-K]:
        ans += get_point(T[i])
      else:
        restricted[i] = True
    else:
      ans += get_point(T[i])

print(ans)


Measured memory_bytes: 4084
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = Integer.parseInt(sc.next());
		List<Integer> empList = new ArrayList<>();
		empList.add(0);
		for (int i = 1; i < num; i++) {
			empList.add(0);
			int bossNum = Integer.parseInt(sc.next());
			empList.set(bossNum - 1, empList.get(bossNum - 1) + 1);

		}
		for (int i = 0; i < empList.size(); i++) {
			System.out.println(empList.get(i));
		}
	}

}


Measured memory_bytes: 61260
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
const int maxn = 1e5+1;
pair<int,int> s[maxn];
int n;
inline char readchar(){
    static const size_t bufsize = 1 << 16;
    static size_t p = 0, end = 0;
    static char buf[bufsize];
    if (p == end) end = fread_unlocked(buf, sizeof(char), bufsize, stdin), p = 0;
    return buf[p++];
}
template <typename T> inline void read(T& a){
    static char p;
    static bool b;
    while (!isdigit(p = readchar()))b = p == '-';
    a = p ^ '0';
    while (isdigit(p = readchar())) a *= 10, a += p ^ '0';
    if(b)a *= -1;
}
inline void read(char &a){
	static char p;
	while(isspace(p = readchar()));
	a = p;
}
inline void read(string &a){
	static char p;
	while(isspace(p = readchar()));
	a = p;
	while(!isspace(p = readchar()))a.push_back(p);
}

int main(){
    read(n);
    for(int i = 0;i < n;++i)read(s[i].first), read(s[i].second), ++s[i].second;
    sort(s, s+n);
    int l = 0, r = 1000000001, w = 0;
    for(int i = 0;i < n;++i){
        l = max(l, s[i].first);
        r = min(r, s[i].second);
        w = max(w, s[i].second-s[i].first);
    }
    int res = w+max(0, r-l);
    int su = s[n-1].second;
    for(int i = n-2;i > -1;--i)res = max(res, max(0, r-s[i].first) + max(0, su-l)), su = min(su, s[i].second);
    printf("%d\n", res);
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    ll ans = 0;
    int n;cin>>n;
    vector<ll>a(n);rep(i, n)cin>>a[i];
    sort(a.begin(), a.end(), greater<int>());
    rep(i, n-1){
        ans += a[(i+1)/2];
    }
    co(ans);
}

Measured memory_bytes: 4848
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num__grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

a, b = wi()
for x in range(10000):
    if int(0.08 * x) == a and int(0.1 * x) == b:
        print(x)
        exit()
print(-1)

Measured memory_bytes: 64876
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define MP make_pair
#define PB push_back
#define ff first
#define ss second
#define TR(it,c) for( typeof(c.begin()) it = c.begin(); it != c.end(); ++it )
#define TRR(it,c) for( typeof(c.rbegin()) it = c.rbegin(); it != c.rend(); ++it
#define REP(i,a) for (int i = 0; i < (a); i++)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)

#define DRI(a) int a; scanf("%d", &a);
#define DRII(a, b) int a, b; scanf("%d %d", &a, &b);
#define DRIII(a, b, c) int a, b, c; scanf("%d %d %d", &a, &b, &c);
#define RI(a) scanf("%d", &a);
#define RII(a, b) scanf("%d %d", &a, &b);
#define RIII(a, b, c) scanf("%d %d %d", &a, &b, &c);
#define MM(arr, num) memset((arr), (num), sizeof((arr)))
#define DEB(x) cerr << ">>> " << (#x) << " -> " << (x) << endl;
#define DEBA(x,n) cerr << (#x) << " "; deba((x),(n));
void deba(int * a, int n){ cerr << "| "; REP(i,n) cerr << a[i] << " "; cerr << "|" << endl;}


inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<30;
typedef long long ll;
typedef unsigned long long ull;
/*******************************************************/
int a[123456];

int main() {

  DRI(n);
  REP(i,n){
    RI(a[i]);

  }
  ll sum = 0;
  sum += a[0]/2;
  a[0] -= sum*2;

  FOR(i,1,n-1){
    ll mn = min(a[i], a[i-1]);
    sum += mn;
    a[i]-=mn;
    a[i-1]-=mn;

    sum += a[i]/2;
    a[i] -= (a[i]/2)*2;


  }
  cout << sum << endl;


  return 0;
}


Measured memory_bytes: 640
n = input()

def dfs(i, l):
    if i == 3:
        return l+'=7' if sum(list(map(int, l.split("+")))) == 7 else ''
    return dfs(i+1, l+"+"+n[i+1]) or dfs(i+1, l+"+"+"-"+n[i+1])

print(dfs(0, n[0]).replace('+-', '-'))

Measured memory_bytes: 3060
import java.math.BigDecimal;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        
        boolean isSame = false;
        for (int i=0; i<a.length-1; i++){
            if (!(a[i] == a[i+1])){
                break;
            }
            if (i == a.length-2){
                isSame = true;
            }
        }
        
        int c = 0;
        if (!(isSame)){
            Arrays.sort(a);
            int minC = 999999999;
            for (int i=a[0]; i<=a[n-1]; i++){
                int temp = 0;
               for (int j=0; j<n; j++){
                   if (!(i==a[j])){
                       temp += Math.pow(a[j]-i,2);
                   }
               }
               if (temp < minC){
                   minC = temp;
               }
            }
            c = minC;
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    cin>>n;
    ll sum=0;
    ll a[n],freq[1000003]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        freq[a[i]]++;
    }
    ll q;
    cin>>q;
    while(q--)
    {
        ll x,y;
        cin>>x>>y;
        sum=sum+freq[x]*(y-x);
        freq[y]+=freq[x];
        freq[x]=0;
        cout<<sum<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 12240
/*......................*/
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double   ld;

//#include <ext/pb_ds/assoc_container.hpp>   
//#include <ext/pb_ds/tree_policy.hpp>  
//#include <functional> 
//using namespace __gnu_pbds;  
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> OST;           //unique elements  

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                       cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int t; cin >> t; while(t--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ook(x)                   order_of_key(x)
#define    fbo(x)                   find_by_order(x)

int main(){                                       //constraints , long long
     speed upp
     int n; cin >> n;
     int arr[n+5];
     multiset <int> s;
     f(i,1,n){
         cin >> arr[i];
         s.insert(arr[i]);
     }
     f(i,1,n){
         auto it = s.end(); it--;
         if(arr[i] == *it){
             it--;
         }
         cout << *it << '\n';
     }
}

Measured memory_bytes: 11776
def check(ccc, ddd, e, ans):
    m = 2147483647
    g = 1000000007
    for l in range(e):
        cl = ccc[l]
        if any(c != cl for c in ccc[l::e]):
            return
        dl = ddd[l]
        if any(d != dl for d in ddd[l::e]):
            return
    s = 0
    for c in ccc[:e]:
        s = (s * g + c) % m
    t = 0
    for d in ddd[:e]:
        t = (t * g + d) % m
    u = pow(g, e, m)
    for h in range(e):
        if s == t:
            bh = bbb[h]
            ans.update(((i - h) % n, aaa[i] ^ bh) for i in range(0, n, e))
            return
        t = (t * g + ddd[(e + h) % n] - ddd[h] * u) % m


def solve(n, aaa, bbb):
    ccc = [a1 ^ a2 for a1, a2 in zip(aaa, aaa[1:])] + [aaa[-1] ^ aaa[0]]
    ddd = [b1 ^ b2 for b1, b2 in zip(bbb, bbb[1:])] + [bbb[-1] ^ bbb[0]]

    ans = set()

    e = 1
    while e * e <= n:
        if n % e != 0:
            e += 1
            continue
        check(ccc, ddd, e, ans)
        check(ccc, ddd, n // e, ans)
        e += 1

    return ans


n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
ans = solve(n, aaa, bbb)
print(''.join('{} {}\n'.format(*answer) for answer in sorted(ans)))


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

import re

S = input()

a = S[:2]
b = S[2:]

isMonth = r'^(0[1-9]|1[0-2])$'
isYear = r'[0-9][0-9]'

if re.match(isYear, a) and re.match(isMonth, b) and re.match(isMonth, a) and re.match(isYear, b):
	print('AMBIGUOUS')
elif re.match(isYear, a) and re.match(isMonth, b):
	print('YYMM')
elif re.match(isMonth, a) and re.match(isYear, b):
	print('MMYY')
else:
	print('NA')

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,M;
  cin>>N>>M;
  priority_queue<ll> que;
  for(ll i=0;i<N;i++){
    ll tmp;
    cin>>tmp;
    que.push(tmp);
  }
  for(ll i=0;i<M;i++){
    ll tmp=que.top();
    que.pop();
    tmp=tmp/2;
    que.push(tmp);
  }

  ll ans=0;
  for(ll i=0;i<N;i++){
    ans+=que.top();
    que.pop();
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1400
public class Main { 
  public static void main(String[] args){
     int a = 60;
     int b = 3600;
     int S = new java.util.Scanner(System.in).nextInt(); //??????????§??????\???
     System.out.println( S/b +":" +  S%b/a+ ":"  +  S%b%a );
  }
}

Measured memory_bytes: 26204
x = int(input())
is_prime = False

while True:
    if x == 2:
        is_prime = True
        break
    for i in range(2, x):
        if x % i == 0:
            is_prime = False
            break
        else:
            is_prime = True
    if is_prime == False:
        x += 1
    else:
        break
print(x)

Measured memory_bytes: 2940
#define max(a,b)(a>b?a:b)
a[5][5];main(n,i,j,k,l,m,M){
	for(scanf("%d",&n);n--;printf("%d\n",M)){
		for(i=0;i<5;i++)for(j=0;j<5;j++)scanf("%d",a[i]+j);
		for(M=i=0;i<5;i++)for(j=0;j<5;j++){
			for(k=i;k<5;k++){
				for(l=j;l<5;l++){
					for(m=i;m<=k;m++){
						if(!a[m][l])goto end;
					}
				}
				end:
				l-=1;
				M=max(M,(k-i+1)*(l-j+1));
			}
		}
	}
exit(0);}

Measured memory_bytes: 600
n=int(input())
d=list(map(int,input().split()))
r=1 if d[0]==0 else 0
d=d[1:]
d.sort()
c=1
nc=0
j=1
mod=998244353
for i in d:
  if i<j:
    r=0
  elif i==j:
    nc+=1
    r=(r*c)%mod
  elif i==j+1:
    j=i
    c=nc
    nc=1
    r=(r*c)%mod
  else:
    r=0
print(r)

Measured memory_bytes: 85144
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int a,b;
	cin>>a>>b;
	int ans=0;
	if((a%4+44)%4!=0) {
		while((a%4+44)%4!=0) {
			ans^=a;
			a++;
			//cout<<a<<" "<<ans<<endl;
		}
	}
	if((b%4+44)%4!=3) {
		while((b%4+44)%4!=3) {
			ans^=b;
			b--;
			//cout<<b<<" "<<ans<<endl;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] S = new int[n+1];
		String[] ins = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			S[i] = Integer.parseInt(ins[i]);
		}
		int q = Integer.parseInt(br.readLine());
		int[] T = new int[q];
		ins = br.readLine().split(" ");
		for(int i = 0; i < q; i++){
			T[i] = Integer.parseInt(ins[i]);
		}

		int C = 0;
		for(int i = 0; i < T.length; i++){
			boolean flag = binarySearch(T[i], S, n);
			if(flag == true)
				C++;
		}
		System.out.printf("%d\n", C);
	}

	private static boolean binarySearch(int key, int[] A, int n){
		int left = 0;
		int right = n;
		while(left < right){
			int mid = (left + right) / 2;
			if(A[mid] == key)
				return true;
			else if(key < A[mid])
				right = mid;
			else
				left = mid + 1;
		}
		return false;
	}
}

Measured memory_bytes: 47528
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[200000];
int dp[200000];
int b[200000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i]==0){
			b[i] = 3 - dp[a[i]];
		}
		else {
			b[i] = dp[a[i] - 1] - dp[a[i]];
		}
		dp[a[i]]++;
	}
	int ans = 1;
	for (int i = 0; i < n; i++) {
		(ans *= b[i]) %= Mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3584
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
 
ans = 0
# count for 0 ~ K
for i in range(N-K):
    if(T[i] == 'r'):
        point = P
    elif(T[i] == 's'):
        point = R
    elif(T[i] == 'p'):
        point = S
    else: # already used
        point = 0
    ans += point
 
    if(T[i+K] == T[i]):
        T[i+K] = 'n'
 
# count for K ~ N
for i in range(N-K, N):
    if(T[i] == 'r'):
        point = P
    elif(T[i] == 's'):
        point = R
    elif(T[i] == 'p'):
        point = S
    else: # already used
        point = 0
    ans += point
 
print(ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define scanf(...) scanf(__VA_ARGS__)?:0
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <PII, int> PPI;
typedef pair <ll, ll> PLL;
typedef pair <PLL, PLL> PP;
typedef unsigned int ui;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const ll INF = 1e18;
#define maxn 1000003
int n, m, k, a, b, c;
 
int main()
{
	string s;
	boost;
	cin >> s;
	n = s.size();
	int poz = -1;
	FOR(i, 0, n-1)
	 if (s[i] == 'C') {
		 poz = i;
		 break;
	 }
	if (poz == -1) OUT("No");
	FOR(i, poz+1, n-1)
	 if (s[i] == 'F') OUT("Yes");
	OUT("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> as(N);
    for (auto && i: irange(0LL, N)){
        cin >> as.at(i);
    }
    vector<ll> acc(N+1, 0);
    for (auto && i: irange(0LL, N)){
        acc.at(i + 1) = (acc.at(i) + as.at(i)) % M;
    }
    map<ll, ll> acc_map{};
    for (auto && i: irange(0LL, N+1)){
        ll key = acc.at(i);
        auto itr = acc_map.find(key);
        if (itr == acc_map.end()){
            acc_map.insert(make_pair(key, 1ll));
        } else {
            itr->second++;
        }
    }
    ll ret = 0;
    for (auto && p: acc_map){
        ll v = p.second;
        ret += v * (v - 1) / 2;
    }
    cout << ret;
    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<cmath>
int N,D;
std::vector<std::vector<int> > v(10,std::vector<int>(10,0));
std::vector<std::vector<int> > memo(10,std::vector<int>(10,0)); 

int main(){
	
	std::cin >> N >> D;
	for(int i = 0; i<N;i++){
		for(int j = 0; j<D;j++){
			std::cin >> v[i][j];
		}	
	}
	
	int count = 0;
	for(int s = 0; s<N;s++){
		for(int t = 0; t<N;t++){
			if(memo[s][t]==1)
				continue;	
			double sum_pow2 = 0;
			memo[s][t] = 1;
			memo[t][s] = 1;
			for (size_t j = 0; j < D; j++)
			{
				sum_pow2 += std::pow(v[s][j] - v[t][j],2);
			}
			sum_pow2 = std::sqrt(sum_pow2);
			if(sum_pow2 - std::ceil<int>(sum_pow2) <= 0 && s !=t){
				count++;
			}
		}
	}	
	std::cout << count << std::endl;
	
}

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

int main(){
	int a,b,n,sum,ans=0;

	cin >>n >>a >>b;
	for(int i=0;i<=n;i++){
		sum=0;
		for(int j=i;j>0;j/=10)sum+=j%10;	
		if(sum>=a&&sum<=b)ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)

ll N, ans;

int main()
{
	fast();
	cin >> N;
	for (ll i = 2, M = N, z = 2; i * i <= M && N != 1; z = ++i)
	{
		while (N % z == 0)
			ans++, N /= z, z *= i;
		while (N % i == 0)
			N /= i;
	}

	cout << ans + (N != 1) << "\n";
}


Measured memory_bytes: 3612
s = list(input())
flg = 'WA'
if s[0] == 'A':
    if 'C'in s[2:len(s)-1]:
        s.remove('A')
        s.remove('C')
        s = ''.join(s)
        if s.islower() == True:
            flg = 'AC'
print(flg)

Measured memory_bytes: 9036
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<int>l(n),r(n);
    for(int i=0;i<n;i++)
        cin>>l[i]>>r[i];
    int ans=0;
    for(int i=0;i<n;i++)
        ans+=r[i]-l[i]+1;
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






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

int main(){
	long long a[100000], b[100000], n;
	scanf("%lld", &n);
	for(long long i=0;i<n;i++)
	scanf("%lld", &a[i]);
	b[1]=abs(a[0]-a[1]);
	b[2]=abs(a[0]-a[2]);
	for(long long i=3;i<n;i++){
		b[i] = min(b[i-1] + abs(a[i] - a[i-1]), b[i-2] + abs(a[i] - a[i-2]));
	}
	printf("%lld", b[n-1]);
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

vi encode(string s) {
  vi res(SZ(s));
  REP(i, SZ(s)) {
    if('a' <= s[i] && s[i] <= 'z') {
      res[i] = s[i] - 'a';
    } else {
      res[i] = s[i] - 'A' + 26;
    }
  }
  return res;
}

string decode(const vi &a) {
  string s = "";
  REP(i, SZ(a)) {
    if(0 <= a[i] && a[i] <= 25) {
      s += a[i] + 'a';
    } else {
      s += a[i] - 26 + 'A';
    }
  }
  return s;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    vi k(n);
    REP(i, n) cin >> k[i];
    string s; cin >> s;
    vi a = encode(s);
    REP(i, SZ(a)) {
      a[i] = ((a[i] - k[i%SZ(k)]) + 52) % 52;
    }
    cout << decode(a) << endl;
  }
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k, n;
	cin>>k>>n;
	
	vector<long> dist(n);
	for(int i=0; i<n; i++){
		cin>>dist[i];
	}
	
	long max_dist = INT_MIN;
	for(int i=0; i<n-1; i++)
		max_dist = max(dist[i+1]-dist[i], max_dist);
	
	max_dist = max(max_dist, k - (dist[n-1] - dist[0]));
	
	cout<<k - max_dist;
	return 0;
}


Measured memory_bytes: 1792
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    int n = Integer.parseInt(br.readLine());
    int[] order = new int[n];
    int[] val = new int[n];
    int[] bonus = new int[n-1];
    String[] s = br.readLine().split(" ");
    for (int i=0; i<n; i++) {
      order[i] = Integer.parseInt(s[i]);
    }
    s = br.readLine().split(" ");
    for (int i=0; i<n; i++) {
      val[i] = Integer.parseInt(s[i]);
    }
    s = br.readLine().split(" ");
    for (int i=0; i<n-1; i++) {
      bonus[i] = Integer.parseInt(s[i]);
    }
    int prevDish = -1;
    long sum = 0;
    for (int i=0; i<n; i++) {
      int dish = order[i];
      sum += val[dish-1];
      if (prevDish+1==dish) {
        sum += bonus[prevDish-1];
      }
      prevDish = dish;
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 23252
#include <iostream>
using namespace std;
int main(void){
    int a;
    cin>>a;
    int b=a;
    int sum=0;
    while(1){
        sum+=a%10;
        a/=10;
        if(a==0)break;
    }
    if(b%sum==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  cout << a+b+c-max({a, b, c}) << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect

n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    ans += (bisect.bisect_left(A, b)) * (n - bisect.bisect_right(C, b))
    
print(ans)

Measured memory_bytes: 23092
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int tarx[400300], tary[400300];
vector<pair<int,int> > vi[400300];
int seg[1200900];
void update(int idx, int l, int r, int index, int val)
{
    if(l>index||r<index) return;
    if(l==r&&l==index) {
        seg[idx]+=val;
        return;
    }
    int mid = (l+r)/2;
    update(idx*2,l,mid,index,val);
    update(idx*2+1,mid+1,r,index,val);
    seg[idx]=max(seg[idx*2],seg[idx*2+1]);
}
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    int r,c;
    n=3e5;
    cin>>r>>c>>m;
    for(i=1;i<=m;i++) {
        scanf("%d %d",&x,&y);
        tarx[x]++;
        tary[y]++;
        update(1,1,n,y,1);
        vi[x].push_back({x, y});
    }
    int chaeng = 0;
    for(i=1;i<=300000;i++) {
        for(auto x : vi[i]) {
            update(1,1,n,x.second,-1);
        }
        chaeng=max(chaeng, tarx[i]+seg[1]);
        for(auto x : vi[i]) {
            update(1,1,n,x.second,1);
        }
    }
    cout<<chaeng<<endl;
    return 0;
}


Measured memory_bytes: 28968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll n; cin>>n;
  vector<string> s(n);
  rep(i, n) cin >> s.at(i);
  sort(s.begin(), s.end());
  vector<string> ans(n);
  ans.at(0)=s.at(0);
  ll m=0;
  ll cnt=1;
  for(ll i=1; i<n; i++) {
    if(s.at(i-1)==s.at(i)) cnt++;
    else {
      if(cnt>m) {
        ans.clear();
        ans.push_back(s.at(i-1));
        m=cnt;cnt=1;
      }
      else if(cnt==m) {
        ans.push_back(s.at(i-1));
        cnt=1;
      }
      else if(cnt<m) {
        cnt=1;
      }
    }
  }
  
    if(s.at(n-1)==s.at(n-2)) {
    
    if(cnt>m) {
        ans.clear();
        ans.push_back(s.at(n-1));
    }
    else if(cnt==m) {
        ans.push_back(s.at(n-1));
    }
    else if(cnt<m) {
    }
  }
  else {
    if(cnt==m) {
        ans.push_back(s.at(n-1));
    }
    else if(cnt<m) {
    }
  }

  rep(i, ans.size()) cout << ans.at(i)<< endl;
}

  

Measured memory_bytes: 15872
#include <stdio.h>
#include <math.h>

int main(void)
{
    int x, tot = 0, cnt = 0;
    scanf("%d", &x);

    while(tot != 360)
    {
        tot += x;
        if(tot > 360)
            tot %= 360;
        cnt++;
    }
    printf("%d", cnt);

    return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
string S,T,U;
int a,b; 
int main(){
	cin>>S>>T>>a>>b>>U;
	if (S==U) --a; else --b;
	cout<<a<<' '<<b<<endl;
    return 0;
}


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

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];

	while (scanf("%s", s,0) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
	}

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

	return 0;
}



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

int main() {
	int n, m, d, num, maximo, l, r, q;
	cin >> n >> m >> d;
	map<int, pair<int,int> > mp;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			cin >> num;
			mp[num] = {i,j};
			if(!i and !j) maximo = num;
			else maximo = max(maximo, num);
		}
	}
	// 0 1    3               5
	//   0 (1,3) + dif[1]   (3,5) + dif[3]
	vector<long long> sum(maximo + 10, -1);
	for(int i = 0; i <= maximo; ++i){
		if(sum[i] != -1 or mp.count(i) == 0) continue;
		sum[i] = 0;
		for(int j = i + d; j <= maximo; j+= d){
			if(mp.count(j) == 0) break;
			long long dis = abs(mp[j].second - mp[j - d].second ) + abs(mp[j].first - mp[j - d].first);
			sum[j] = sum[j - d] + dis;
		}
	}
	cin >> q;
	while(q--){
		cin >> l >> r;
		if(l > r) swap(l, r);
		cout << sum[r] - sum[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=2e6+5;
int x,y,a,b,c;
int p[N],q[N],r[N];
bool cmp(int a,int b){
	return a > b;
}
vi g;
int main()
{
	cin>>x>>y>>a>>b>>c;
	rep(i , 1 , a + 1)
		cin>>p[i];
	rep(i , 1 ,b + 1)
		cin>>q[i];
	rep(i , 1 , c + 1)
		cin>>r[i];
	sort(p + 1,p + a + 1,cmp);
	sort(q + 1,q + b + 1,cmp);
	sort(r + 1,r + c + 1,cmp);
	rep(i , 1 , x + 1)
		g.pb(p[i]);
	rep(i , 1 ,y + 1)
		g.pb(q[i]);
	rep(i , 1 , min(c,x + y) + 1)
		g.pb(r[i]);
	sort(all(g),cmp);
	ll ans = 0;
	rep(i , 0 , x + y )
		ans += g[i];
	cout<<ans<<"\n";
	return 0;
}



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

using namespace std;

int main(){
    string s;
    cin>>s;
    int ans=0;
    int t=0;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')++t;
        else {
            ans=max(ans,t);
            t=0;
        }
    }
    cout<<max(ans,t)<<endl;
    return 0;
}

Measured memory_bytes: 256