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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll h,w,n;

int main(){
  cin >> n >> h >> w;
  cout << (n-h+1)*(n-w+1) << endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    vector<vector<int>> graph;
    int N;
    cin >> N;
    graph.resize(N);
    for (int i = 0; i < N-1; i++) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        graph[A].push_back(B);
        graph[B].push_back(A);
    }
    vector<int> cis;
    for (int i = 0; i < N; i++) {
        int ci;
        cin >> ci;
        cis.push_back(ci);
    }
    sort(cis.begin(), cis.end());
    reverse(cis.begin(), cis.end());
    struct VtxInfo {
        int idx;
        int con_vertices;
    };
    auto comp = [](VtxInfo lhs, VtxInfo rhs){ return lhs.con_vertices > rhs.con_vertices; };
    priority_queue<VtxInfo, vector<VtxInfo>, decltype(comp)> queue(comp);
    vector<int> connected_count(N, 0);
    for (int i = 0; i < N; i++) {
        connected_count[i] = (int)graph[i].size();
        queue.push(VtxInfo{i, connected_count[i]});
    }
    vector<int> written(N, -1);
    ll score = 0;
    while (!queue.empty()) {
        VtxInfo vtx_info = queue.top();
        queue.pop();
        if (written[vtx_info.idx] != -1) {
            continue;
        }
        score += vtx_info.con_vertices * cis.back();
        written[vtx_info.idx] = cis.back();
        cis.pop_back();
        for (int to : graph[vtx_info.idx]) {
            connected_count[to]--;
            if (connected_count[to] >= 0) {
                queue.push(VtxInfo{to, connected_count[to]});
            }
        }
    }
    cout << score << endl;
    for (int i = 0; i < N; i++) {
        cout << written[i];
        if (i < N - 1) {
            cout << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int N,A,B,C,D;
string S;
int main() {
    cin >> N >> A >> B >> C >> D >> S;
    A--,B--,C--,D--;
    S[A]='A',S[B]='B';

    for (int i=0; i<(N*10); i++) {

        if (A<C && S[A+1]=='.') {
            S[A+1] = 'A';
            S[A] = '.';
            A += 1;
        } else if (A<C && S[A+2]=='.') {
            S[A+2] = 'A';
            S[A] = '.';
            A += 2;
        }

        if ((C>D && A<B && S[B+1]=='.' && S[B-1]=='.')||
            (C>D && A<B && S[B+1]=='.' && S[B-1]=='A')) {
            ;
        } else {
            if (B<D && S[B+1]=='.') {
                S[B+1] = 'B';
                S[B] = '.';
                B += 1;
            } else if (B<D && S[B+2]=='.') {
                S[B+2] = 'B';
                S[B] = '.';
                B += 2;
            }
        }

        if (A==C && B==D) {
            cout << "Yes" << endl;
            return 0;
        }

    }

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


Measured memory_bytes: 640
#include<stdio.h>
double p[2][3][3];
int dx[4]={-1,0,0,1};
int dy[4]={0,1,-1,0};
int main(){
	int n;
	char a,b,c;
	int s,g,x;
	int i,j;
	while(1){
	scanf("%d",&n);
	if(n==0)return 0;
	scanf(" %c %c %c",&a,&b,&c);
	s=(int)a-'A';
	g=(int)b-'A';
	x=(int)c-'A';
	for(i=0;i<9;i++){
		if(i!=s)p[0][i/3][i%3]=0.0f;
		else p[0][i/3][i%3]=1.0f;
		p[1][i/3][i%3]=0.0f;
	}
	while(n>0){
		n--;
		for(i=0;i<9;i++){
			for(j=0;j<4;j++){
				if(i/3+dy[j]<0||i/3+dy[j]>=3||i%3+dx[j]<0||i%3+dx[j]>=3||(i/3+dy[j]==x/3&&i%3+dx[j]==x%3)){
					p[1][i/3][i%3]+=p[0][i/3][i%3]/4;
				}
				else p[1][i/3+dy[j]][i%3+dx[j]]+=p[0][i/3][i%3]/4;
			}
		}
		for(i=0;i<9;i++){
			p[0][i/3][i%3]=p[1][i/3][i%3];
			p[1][i/3][i%3]=0.0f;
		}
	}
	printf("%lf\n",p[0][g/3][g%3]);
	}	
}
	

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
long long int a[200005],sum[200005];
int main()
{
	map<long long int ,long long int >mp;
	int n,k;
	long long int ans=0;
	cin>>n>>k;
	sum[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=0;i<=n;i++)
	{
		if(i>=k) {
			mp[(sum[i-k]-(i-k))%k]--;
		} 
		if(mp.count((sum[i]-i)%k))
		{
		ans+=mp[(sum[i]-i)%k];
	    }
		mp[(sum[i]-i)%k]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    deque<ll>b;
    if(n%2==0){
        for(ll i=0;i<n;i++){
            if(i%2==0){
                b.push_back(a[i]);
            }
            else {
                b.push_front(a[i]);
            }
        }
    }
    else {
        for(ll i=0;i<n;i++){
            if(i%2==1){
                b.push_back(a[i]);
            }
            else {
                b.push_front(a[i]);
            }
        }
    }
    for(ll i=0;i<n;i++){
        cout << b[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 6380
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<list>
#include<math.h>
using namespace std;

#define ll long long
#define vecint vector<int>
#define listint list<int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl

#define INF 1000000007

bool is_prime(int x){
  for(int i=2;i*i<=x;i++){
    if(x%i==0) return false;
  }
  return true;
}

int main(){
  ll div=0;
  ll sum_div=1;
  ll N;

  cin >> N;
  REP(i,2,N+1){
    if(is_prime(i)){
      div=0;
      int x=i;
      while(N/x!=0){
        div+=N/x;
        x*=i;
      }
      sum_div*=div+1;
      if(sum_div>INF){
        sum_div%=INF;
      }
    }
  }

  print(sum_div);
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double PI=3.14159265358979323846;

int gcd(int a,int b){
  if(a % b == 0) return b;
  return gcd(b, a%b);
}

int lcm(int a,int b){
  return a * b / gcd(a,b);
}

int main(){
  int n; cin >> n;
  int h[n];
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  bool flg = true;
  for(int i = 1; i < n; i++){
    int a = h[i] - h[i-1];
    if(a >= 1){
      h[i]--;
    }else if(a < 0){
      flg = false;
    }
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

solve :: Int -> Int -> Int -> [Int]
solve !r !d !x = snd $ foldl'
  (\(!y, !acc) !i -> let y' = y * r - d in (y', y' : acc))
  (x, [])
  [1 .. 10]

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (r, d, x) <-
    (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2))
    .   VU.unfoldrN 3 readInt
    <$> B.getLine
  mapM_ print $ reverse  $ solve r d x


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a=0,b=0;
    string s;
    cin>>s;
    a=s.find("A");
    if(a>0)
    s=s.substr(a);
    for(int i=s.size()-1;i>=0;i--){
            if(s[i]=='Z'){
                b=i;
            break;
            }

    }
    cout<<b+1;

       return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define el "\n" 
#define insert it
#define lb lowerbound
#define up upperbound
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7,siz = 5e5 + 10;
const double PI = acos(-1);
const int LINF = LLONG_MAX;
int maxProfit(vector<int>& prices) {
    int i = 0;
    int ans = 0;
    int peak = prices[0];
    int mini = 0;
    int cur = 1000;
    while(i < prices.size()-1){
        while(i < prices.size()-1 and prices[i] >= prices[i+1]){
            i++;
        }
        mini = prices[i];
        // cout << "lol " << cur << el;
        int hold = cur/mini;
        cur = 1000;
        while(i < prices.size()-1 and prices[i] <= prices[i+1]){
            i++;
        }
        peak = prices[i];
        // cout << hold << " " << peak << " " << mini << " ";
        ans += (peak - mini)*hold;
        // cout << ans << el;
        cur += ans;
        // cout << cur << el;
    }
    return cur;
}
void test(){
	int a;
	cin >> a;
	vector<int>v(a);
	f(i,0,a){
		cin >> v[i];
	}	
	cout << maxProfit(v);
}  
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tt = 1;
    // cin >> tt;
    f(i,0,tt) test();   
    return 0;
}



Measured memory_bytes: 3652
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
string s;
bool b[1000];
ll ans=0;
bool check(char c){
	return ((c=='A')||(c=='C')||(c=='G')||(c=='T'));
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>s;int n=s.size();
	for(int i=0;i<n;i++)b[i]=check(s[i]);//cout<<b[i];cout<<'\n';
	for(int i=0;i<n;i++)if(b[i]){
		ll cnt=1;
		for(int j=i+1;j<n;j++){
			if(b[j]==1)cnt++;
			else break;
		}
//		cout<<cnt;
		ans=max(ans,cnt);
	}
	cout<<ans;
	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 P = pair<int,int>;


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

    int ans = n*(n-1)/2 + m*(m-1)/2;

    cout << ans << endl;

    return 0;
}



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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll a,b,x;cin>>a>>b>>x;

  ll bottom=a*a;

  if((lb)bottom*b/2>=x){
    // out(setprecision(10)<<atan(b/((lb)2*x/a/b)));
    out(setprecision(10)<<180*atan2((a*b*b),(2*x))/M_PI);
    // out(setprecision(10)<<M_PI*atan2((a*b*b),(2*x)));
  }else{
    // out(setprecision(10)<<atan(a/(b-((lb)2*x/a/a-b))));
    out(setprecision(10)<<90-180*atan2(a*a*a,2*(a*a*b-x))/M_PI);
    // out(setprecision(10)<<90-M_PI*atan2(a*a*a,2*(a*a*b-x)));
  }


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

typedef long long ll;
const int N=303,MOD=1000000007;
inline void inc(int a,int &b){b=(a+b)%MOD;}

int f[N*2][N][N];
int A[N*2],ty[N*2];
int n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n*2;i++)scanf("%d",A+i);
	for(int i=1;i<=n*2;i+=2)
		if(~A[i] && ~A[i+1])ty[A[i]]=-1,ty[A[i+1]]=-1;
		else if(~A[i])ty[A[i]]=1;
		else if(~A[i+1])ty[A[i+1]]=1;

	f[n*2+1][0][0]=1;
	for(int i=n*2+1;i>1;i--)
		for(int j=0;j<=n;j++)
			for(int k=0;k<=n;k++)
			{
				int v=f[i][j][k];
				if(!v)continue;

				if(ty[i-1]==-1)inc(v,f[i-1][j][k]);
				else if(ty[i-1]==1)
				{
					inc(v,f[i-1][j][k+1]);
					if(j)inc(v,f[i-1][j-1][k]);
				}
				else
				{
					inc(v,f[i-1][j+1][k]);
					if(j)inc(v,f[i-1][j-1][k]);
					if(k)inc((ll)v*k%MOD,f[i-1][j][k-1]);
				}
			}

	int ans=f[1][0][0],tmp=0;
	for(int i=1;i<=n*2;i+=2)
		if(A[i]==-1 && A[i+1]==-1)ans=(ll)ans*(++tmp)%MOD;
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 216960
// abca29c.cpp : Typical Stairs
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int calc(vector<int> &v, int i, int n){
	if(i>n) return 0;
	if(i==n) return 1;
	if(v[i]==-2) return 0;
	if(v[i]==-1) v[i] = (calc(v,i+1,n) + calc(v,i+2,n)) % MOD;
	return v[i];
}

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

	vector<int> v(n+1,-1);
	for(int i=0;i<m;i++){
		int a; cin>>a;
		v[a] = -2;
	}

	int ans = calc(v,0,n);

	cout<< ans <<endl;
}

Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

int main(){
    int N;
    cin >> N;
    double S;
    for (size_t i = 0; i < N; i++)
    {
        double a;
        cin >> a;
        S+= 1.0/a;
    }
    cout << setprecision(7) ;
    cout << (1.0/S) << endl; 
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int k,s;
	scanf("%d%d",&k,&s);
	int x,y,z,count=0;
	for(x=0;x<=k;x++)
		{for(y=0;y<=k;y++)
			{z=s-x-y;
			if(z>=0 && z<=k)
				{count++;}
			}
		}
	


	printf("%d\n",count);
	return 0;
}


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

int main(){
  long long N,A,B;
  cin >>N>>A>>B;  
  
  if(B<A){
    cout<<0<<endl;
    return 0;
  }
  if((N==1)&&(A<B)){
    cout<<0<<endl;
    return 0;
  }
  long long ans=0;
  ans=(B*(N-1)+A)-(A*(N-1)+B)+1;
  
  cout<<ans<<endl;
  return 0;
}

    
  
 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <utility>
using namespace std;
//#define local
const int maxn=55;
long long dp[maxn][maxn*maxn];
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int n,a,x,maxx=0;
    long long ans=0;
    cin>>n>>a;
    dp[0][0]=1;
    for(int i=1; i<=n; i++)
    {
        cin>>x;
        maxx=max(maxx,x);
        for(int j=i-1; j>=0; j--)
            for(int k=0; k<=j*maxx; k++)
                dp[j+1][k+x]+=dp[j][k];
    }
    for(int i=1; i<=n ;i++)
        ans+=dp[i][i*a];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include<numeric>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    size_t n;
    cin >> n;
    
    vector<int> index(n);
    iota(index.begin(), index.end(), 0);
  
    int tmp_a, tmp_b;
    vector<int> a, b;
    for (int i : index) {
      cin >> tmp_a >> tmp_b;
      a.push_back(tmp_a);
      b.push_back(tmp_b);
    }
    sort(index.begin(), index.end(), [&](int i1, int i2){ return b[i1] < b[i2]; });
    int sum = 0;
    for (int i : index) {
      sum += a[i];
      if (sum > b[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 2804
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
# stdin = open("sample.txt")


MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr


    
def main():
    a = int(stdin.readline().rstrip())
    amari = a % 1000
    if amari == 0:
        print(0)
    else:
        print(1000-amari)
    
main()

Measured memory_bytes: 27224
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int A, B;
	
	scanf("%d %d %d", &a, &b, &c);
	
	A = b-a;
	B = c-b;
	
	if (A == B){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	
	return (0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int dp[10][10];

int main(){
	int n;
	cin>>n;
	for(int i=1; i<=n; i++){
		vector<int>arr;
		int num = i;
		while(num){
			arr.push_back(num%10);
			num/=10;
		}
		dp[*arr.begin()][*arr.rbegin()]++;
	}
	long long ret = 0;
	for(int i=1; i<=n; i++){
		vector<int>arr;
		int num = i;
		while(num){
			arr.push_back(num%10);
			num/=10;
		}
		ret+=dp[*arr.rbegin()][*arr.begin()];
	}
	cout<<ret;
}

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

void dfs(int water, int sugar, int &a, int &b, int &c, int &d, int &e, int &f, vector<vector<bool>> &memo)
{
    if (100 * water + sugar <= f)
    {
        if (!memo[water + a][sugar])
        {
            dfs(water + a, sugar, a, b, c, d, e, f, memo);
        }

        if (!memo[water + b][sugar])
        {
            dfs(water + b, sugar, a, b, c, d, e, f, memo);
        }

        if (water * e >= sugar)
        {
            memo[water][sugar] = true;

            if (!memo[water][sugar + c])
            {
                dfs(water, sugar + c, a, b, c, d, e, f, memo);
            }

            if (!memo[water][sugar + d])
            {
                dfs(water, sugar + d, a, b, c, d, e, f, memo);
            }
        }
    }
}

int main()
{
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    vector<vector<bool>> memo(F + 1, vector<bool>(F + 1, false));
    dfs(0, 0, A, B, C, D, E, F, memo);

    double best = 0;
    int ans_whole = 0;
    int ans_sugar = 0;
    for (int i = 0; i * 100 <= F; i++)
    {
        for (int j = 0; i * 100 + j <= F; j++)
        {
            if (memo[i][j])
            {
                if (best <= (double)j / ((double)i * 100 + j))
                {
                    best = (double)j / ((double)i * 100 + j);
                    ans_whole = i * 100 + j;
                    ans_sugar = j;
                }
            }
        }
    }
    cout << ans_whole << " " << ans_sugar << endl;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int x=(A-1)/D;
  int y=(C-1)/B;
  if(x>=y){
    cout << "Yes" <<  endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3584
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second
 
//#include <boost/unordered_map.hpp>
//using namespace boost;
 
/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/
 
using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
//using i128 = i64;
//using u128 = u64;
 
ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}
 
template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}
 
template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

template<class T>
void print(const T &a)
{
	for (auto x : a) printf("%d ", x); puts("");
}

const int MAXN = 555;
const int MAXM = 26;
//const i64 INF = 1000000000000000000LL;
const int INF = 1000000000;
//const int MOD = 998244353;
const int MOD = 998244853;
const int INV2 = (MOD+1)/2;
const ld pi = 3.1415926535897932384626433;

int tot;
int a[MAXN][MAXN];

void solve(int L, int R, int tot)
{
	if (L == R) return;
	int m = (L+R)>>1;
	for (int i = L; i <= m; ++ i)
		for (int j = m+1; j <= R; ++ j)
			a[i][j] = a[j][i] = tot;
	solve(L, m, tot+1);
	solve(m+1, R, tot+1);
}

int main()
{
	
	int N;
	cin >> N;
	solve(1, N, 1);
	for (int i = 1; i <= N-1; ++ i) 
	{
		for (int j = i+1; j <= N; ++ j)
			printf("%d ", a[i][j]);
		puts("");
	}
	
	return 0;
}


Measured memory_bytes: 1536
<?php

fscanf(STDIN, "%d", $in_n);
$in_h = fgets(STDIN);

$arr_h = explode(" ", $in_h, $in_n);
//print_r(explode(" ", $in_h, $in_n));

$ans = 0;
$high = $arr_h[0];

for($i = 0; $i < $in_n; $i++){
    if($arr_h[$i] >= $high){
        $ans++;
        $high = $arr_h[$i];
    }
//    echo "test : $i : $ans \n";
}

echo "$ans\n";

?>

Measured memory_bytes: 4604
N=int(input())

ans=None
tmp=0
z=1
if(N%2==0):
    tmp=int(N/2)
    ans=[2 for i in range(tmp)]
    A=map(int,input().split())
    for i in A:
        if(int(i/2)<=int(N/2)):
            ans[int(i/2)-1]-=1
        else:
            print(0)
            exit() 
else:
    tmp=int(N/2)
    ans=[2 for i in range(tmp)]
    z=0
    A=map(int,input().split())
    for i in A:
        if(i==0):
            z=1
            continue
        if(int(i/2)<=int(N/2)):
            ans[int(i/2)-1]-=1
        else:
            print(0)
            exit()
output=2**(tmp)%(10**9+7)
for i in ans:
    if(i!=0):
        output=0

print(output*z)

Measured memory_bytes: 10864
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int INF=INT_MAX;
const ld PI=3.1415926535897932384626433;
const ld E=2.71828183;
const int MOD=1e9+7;
vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
int powMod(int base,int exp,int mod){
    //base^exp %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}

void solve();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    //cin >> t;
    //while(t--)
        solve();
}
void solve(){
    int n;
    cin >> n;
    vi occ(n);

    for(int i=1; i<n; i++) {
        int x;
        cin >> x;
        occ[x-1]++;
    }
    for(int i:occ)
        cout << i << "\n";


}

Measured memory_bytes: 4012
N = int(input())
if N < 10:
    print(N)
elif 10 <= N <100:
    print(9)
elif 100 <= N <1000:
    print(N - 90)
elif 1000 <= N < 10000:
    print(909)
elif 10000 <= N < 100000:
    print(N - 9090)
else:
    print(90909)

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a < c && c < b)
  {
    cout << "Yes" << endl;
  }
  else if (b < c && c < a)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef vector<pair<int , int>> vpii;
    typedef pair<int , int> pii;
    typedef pair<long long  , long long> pll;
    typedef pair<double , double> pdd;
    #define eb emplace_back;
    #define mp make_pair;
     
    int main(){
        ll sum = 0;
        int n;
        cin>>n;
        for(int i = 1 ; i<=n ; i++){
            if(i%3 != 0 && i%5!=0){
                sum+=i;
            }
        }
        cout<<sum;
        return 0;
    }

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;
 
int main() {
  string s, st;
  cin >> s;

  for (int i = 0; i < (1 << 3); ++i) {
    int t = s[0] - '0';
    st = s[0];
    for (int j = 0; j < 3; ++j) {
      if (i & (1 << j))
        st = st + "+" + s[j + 1], t += s[j + 1] - '0';
      else
        st = st + "-" + s[j + 1], t -= s[j + 1] - '0';
    }
    if (t == 7) {
      st = st + "=7";
      break;
    }
  }

  cout << st << endl;
  return 0;
}


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


int main(){
    ll l, r;
    cin >> l >> r;

    ll l_remainder = l % 2019;
    ll r_remainder = r % 2019;

    if(r - l >= 2018){
        cout << 0 << endl;
        return 0;
    }else if(l_remainder > r_remainder){
        cout << 0 << endl;
        return 0;
    }
    
    ll x = 0;
    ll i = l;
    ll multi = 100000;
    while(1){
        if(i == r) break;
        ll j = i+1;
        while(j <= r){
            x = (i * j) % 2019;
            if(x == 0){
                cout << x << endl;
                return 0;
            }
            if(x < multi){
                multi = x;
            } 
            j++;
        }
        i++;
    }

    cout << multi << endl;

    return 0;
}

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

#define rep(i,a,b) for(long long i = a; i < b; i++)
#define dump(a) for(auto x : a) cout << x << " "; cout << "\n"
#define print(a) cout << a << "\n"
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr << #x << ": " << x << ", " << #y << ": " << y << "\n"
#define debug3(x,y,z) std::cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << "\n"

typedef long long ll;
using vi   = vector<int>;
using vll  = vector<long long>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvs  = vector<vector<string>>;

int main() {
  string s;cin >> s;
  int count = 0;
  if (s.find('R') != string::npos) {
    count = 1;
  } 
  
  if (s[0] == 'R') {
    if (s[1] =='R') {
      count++;
      if (s[2] == 'R') {
        count++;
      }
    }
  } else {
    if (s[1] == 'R') {
      if (s[2] == 'R') {
        count++;
      }
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3636
def cnt(n,p):
    tmp=0
    m=n
    while(m>0):
        tmp+=m%p
        m//=p
    return tmp
ans=10**15
N=int(input())
for i in range(N+1):
    ans=min(ans,cnt(i,6)+cnt(N-i,9))
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  LL n, k; cin >> n >> k;
  vector<LL> a(n);
  rep(i, n) cin >> a[i];

  LL ans = 0, x = 0;
  for (int i = 40; i >= 0; i --) {
    LL t = (1LL << i);
    LL num = 0;
    for (int j = 0; j < n; j ++) {
      num += 1 & (a[j] >> i);
    }
    if (2 * num >= n) ans += t * num;
    else if (x + t <= k) {
      ans += t * (n - num);
      x += t;
    }
    else ans += t * num;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(B<=C||D<=A){
    cout<<0<<endl;
    return 0;
  }
  else if(A<=C&&D<=B)
    cout<<D-C<<endl;
  else if(C<=A&&B<=D)
    cout<<B-A<<endl;
  else if(C<=B&&B<=D&&A<=C)
    cout<<B-C<<endl;
  else
    cout<<D-A<<endl;
 
}
  







Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
int main() {
	string S, T;
	cin >> n;
	cin >> S >> T;
	rep(i, n) {
		cout << S[i] << T[i];
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,K;
    cin>>N>>K;
    ll ans=0;
    if(K==0){
        cout <<N*N<<"\n";
    }
    else{
    rep(i,K+1,N+1){
        ans+=max(N%i-K+1,0LL)+N/i*(i-K);
    }
    cout <<ans<<"\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

typedef  long long ll;

#define rep(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(ll (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

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

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

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}

void solve(void){
   int x,y;
   cin >> x >> y;
   cout << x+y/2 <<endl;

}

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

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

using namespace std;

typedef long long ll;

const int MAXN = 2e5 + 7;
const ll INF = 2e9;

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(0);
	char c;
	cin >> c;
	cout << char(c + 1) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using Vec = vector<T>;
template<class T> using VVec = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}

struct IoSetup {
	IoSetup() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

int N, M, Q;
int L[200005], R[200005], q[100005], p[100005];

void solve() {
	multiset<int> st[505];
	rep (i, M) st[L[i]].insert(R[i]);

	int memo[505][505];
	rep2 (i, 1, N + 1) rep2 (j, 1, N + 1) {
		memo[i][j] = distance(st[i].begin(), st[i].upper_bound(j));
	}


	rep (i, Q) {
		int ans = 0;
		rep2 (j, p[i], q[i] + 1) ans += memo[j][q[i]];
		cout << ans << '\n';
	}
}

int main() {
	cin >> N >> M >> Q;
	rep (i, M) cin >> L[i] >> R[i];
	rep (i, Q) cin >> p[i] >> q[i];
	solve();
	
	return 0;
}


Measured memory_bytes: 16368
s=input()
cnt=0
tmp=0
for i in s:
    if i=="A" or i=="T" or i=="C" or i=="G":
        tmp+=1
    if tmp>0 and (i!="A" and i!="T" and i!="C" and i!="G"):
        cnt=max(cnt,tmp)
        tmp=0
cnt=max(cnt,tmp)
print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<algorithm>
#define f first
#define s second
#define pb push_back
using namespace std;
int const inf=0x3f3f3f3f;
int const maxn=1e5+5;
typedef long long ll;
int a[maxn],b[maxn];
int main(){
	int n,m,k,ma=inf,mb=inf;
	int u,v,w;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		ma=min(ma,a[i]);
	}
	for(int i=1;i<=m;i++) {
		scanf("%d",&b[i]);
		mb=min(mb,b[i]);
	}
	int res = ma+mb;
	for(int i=0;i<k;i++){
		scanf("%d%d%d",&u,&v,&w);
		res=min(a[u]+b[v]-w,res);
	}
	printf("%d\n",res);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second

int main()
{
	
	int r, g, b;
	scanf("%d%d%d", &r, &g, &b);
	puts((100*r+10*g+b)%4==0?"YES":"NO");
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 3) {
    cout << "2 5 63" << '\n';
    return 0;
  }
  vector<int> a;
  int s = 0;
  for (int i = 1; i <= 30000; i++) {
    if (i % 2 == 0 || i % 3 == 0) {
      a.push_back(i);
      s += i;
      if ((int) a.size() == n) {
        break;
      }
    }
  }
  int need = (6 - s % 6) % 6;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] + need <= 30000 && ((a[i] + need) % 2 == 0 || (a[i] + need) % 3 == 0)) {
      a[i] += need;
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      cout << ' ';
    }
    cout << a[i];
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(void){
  int i,x;
  int a=0;
  char s[200001];
  char t[200001];
  
  scanf("%s",s);
  scanf("%s",t);
  
  x = strlen(s);
  
  for(i=0;i<x;i++){
   if(s[i]==t[i]){
    a++; 
   }
  }
  
  printf("%d",x-a);
 return 0; 
}

Measured memory_bytes: 2540
using System;

public class Hello{
    public static void Main(){
        string InputSum;
        int Sum, TmpSum, PatternCount;
        while((InputSum = Console.ReadLine()) != null){
            Sum = int.Parse(InputSum);
            PatternCount = 0;
            TmpSum = 0;
            for(int n1 = 0; n1 <= 9; n1++){
                if(n1 > Sum) continue;
                else if(n1 + 27 < Sum) continue;
                for(int n2 = 0; n2 <= 9; n2++){
                    TmpSum = n1 + n2;
                    if(TmpSum > Sum) continue;
                    else if(TmpSum + 18 < Sum) continue;
                    for(int n3 = 0; n3 <= 9; n3++){
                        TmpSum = n1 + n2 + n3;
                        if(TmpSum > Sum) continue;
                        if(Sum - TmpSum < 10) PatternCount++;
                    }
                }
            }
            Console.WriteLine(PatternCount);
        }
    }
}

Measured memory_bytes: 8996
import string

letters = [chr(i) for i in range(ord('A'), ord('Z')+1)]
mod = ord('Z')+1-ord('A')

n = int(input())
s = input()

ans = ""
for ids in s:
    idx = (ord(ids) - ord('A') + n) % mod
    ans += letters[idx]

print(ans)

Measured memory_bytes: 40940
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int height = sc.nextInt();
		int width = sc.nextInt();
		
		char[][] board = new char[height][width];
		
		for (int i = 0; i < height; i++) {
			String sCurr = sc.next();
			for (int j = 0; j < width; j++) {
				board[i][j] = sCurr.charAt(j);
			}
		}
		
		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if (!(board[i][j] == '#')) {
					boolean iLess = false;
					boolean iMore = false;
					boolean jLess = false;
					boolean jMore = false;
					int tempVal = 0;
					if (i - 1 >= 0) {
						iLess = true;
					} 
					if (i + 1 < board.length) {
						iMore = true;
					}
					if (j - 1 >= 0) {
						jLess = true;
					}
					if (j + 1 < board[0].length) {
						jMore = true;
					}
					if (iLess) {
						if (board[i - 1][j] == '#') {
							tempVal++;
						}
					}
					if (iMore) {
						if (board[i + 1][j] == '#') {
							tempVal++;
						}
					}
					if (jLess) {
						if (board[i][j - 1] == '#') {
							tempVal++;
						}
					}
					if (jMore) {
						if (board[i][j + 1] == '#') {
							tempVal++;
						}
					}
					if (iLess && jLess) {
						if (board[i - 1][j - 1] == '#') {
							tempVal++;
						}
					}
					if (iLess && jMore) {
						if (board[i - 1][j + 1] == '#') {
							tempVal++;
						}
					}
					if (iMore && jLess) {
						if (board[i + 1][j - 1] == '#') {
							tempVal++;
						}
					}
					if (iMore && jMore) {
						if (board[i + 1][j + 1] == '#') {
							tempVal++;
						}
					}
					board[i][j] = Integer.toString(tempVal).charAt(0);
				}
			}
		}
		for (int i = 0; i < height; i++) {
			String printString = "";
			for (int j = 0; j < width; j++) {
				printString += board[i][j];
			}
			System.out.println(printString);
		}
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const int TopIndex = 1;
const int DummySize = 1;

void Exchange(vector<int>& Heap, int InsertIndex)
{
	int ParentIndex = InsertIndex / 2;
	while(InsertIndex > TopIndex && Heap[InsertIndex] > Heap[ParentIndex]){
		swap(Heap[InsertIndex], Heap[ParentIndex]);
		InsertIndex = ParentIndex;
		ParentIndex = InsertIndex / 2;
	}
}

void Insert(vector<int>& Heap, int k)
{
	Heap.push_back(k);
	int InsertIndex = Heap.size() - 1;
	Exchange(Heap, InsertIndex);
}

void maxHeapify(vector<int>& A, int i)
{
	int H = A.size() - 1;
	int l = 2 * i;
	int r = 2 * i + 1;
	//????????????????????????????????§???????????§????????????????????¶
	int largest;
	if(l <= H && A[l] > A[i]){
		largest = l;
	}else{
		largest = i;
	}
	if(r <= H && A[r] > A[largest]){
		largest = r;
	}
	//i???????????????????????§????????´???
	if(largest != i){
		swap(A[i], A[largest]);
		//?????°??????????????????
		maxHeapify(A, largest);
	}
}

void ExtractMax(vector<int>& Heap)
{
	int TailIndex = Heap.size() - 1;
	cout << Heap[TopIndex] << endl;
	swap(Heap[TailIndex], Heap[TopIndex]);
	Heap.pop_back();
	maxHeapify(Heap, TopIndex);
}

int main()
{
	vector<int> Heap(DummySize);
	while(true){
		string Command;
		cin >> Command;
		if(Command == "insert"){
			int k;
			cin >> k;
			Insert(Heap, k);
		}else if(Command == "extract"){
			ExtractMax(Heap);
		}else{
			break;
		}
	}
	return 0;
}

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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD   = 1e9 + 7;
const double PI = acos(-1.0);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
const int INF   = 1e18;

#define fastio            ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define rsz resize
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define f first
#define s second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define spc " "
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){

    int n;
    cin >> n;
    vi a(n);
    rep(i, n){
        cin >> a[i];
    }
    
    unordered_map<int, int> mp;
    int sum = 0;
    rep(i, n){
        sum += a[i];
        mp[a[i]]++;
    }
    int q;
    cin >> q;
    rep(i, q){
        int b, c;
        cin >> b >> c;
        if(present(mp, b)){
            sum += (c - b) * mp[b];
            mp[c] += mp[b];
            mp.erase(b);
        }
        cout << sum << endl;
    }


}

signed main(){
    fastio;

    solve();

    return 0;
}


Measured memory_bytes: 7424
#include <stdio.h>

int main(){
  int a[31],i,s;
  for(i=1;i<31;i++) a[i]=1;
  for(i=0;i<28;i++){
    scanf("%d",&s);
    a[s]=0;
  }
  for(i=1;i<31;i++) if(a[i]) printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 596
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    A.sort()
    q = []
    a = A.pop()
    ans = a
    a = A.pop()
    heapq.heappush(q, -a)
    heapq.heappush(q, -a)
    while A:
        a = A.pop()
        ans += -heapq.heappop(q)
        heapq.heappush(q, -a)
        heapq.heappush(q, -a)
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 109032
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=200005;
int n;
int a[N];
int main(){
	n=read();
	For(i,1,n)
		a[i]=read();
	if (a[1]==1)
		return puts("-1"),0;
	For(i,1,n)
		if (a[i]-a[i-1]>1)
			return puts("-1"),0;
	LL ans=0;
	For(i,1,n)
		if (a[i+1]!=a[i]+1)
			ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;
 
int main() {

    int N, Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int a = 0; a <= N; ++a) {
        for (int b = 0; b + a <= N; ++b) {
            int c = N - a - b;
            int total = 10000*a + 5000*b + 1000*c;
            if (total == Y) {
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }

    cout << res10000 << " " << res5000 << " " << res1000 << endl;

	return 0;
}

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

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split().ToArray();
        int n = int.Parse(s[0]);
        int k = int.Parse(s[1]);

        int[] x = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

        int ans = int.MaxValue;

        if (n == 1)
        {
            Console.WriteLine(x[0]);
            return;
        }
        for (int i = 0; i < x.Length - k + 1; i++)
        {
            ans = Math.Min(ans, Math.Abs(x[i + k - 1]) + Math.Abs(x[i + k - 1] - x[i]));
            ans = Math.Min(ans, Math.Abs(x[i]) + Math.Abs(x[i + k - 1] - x[i]));
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 21088