akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;
const int INF = 1e6;
const long long int LINF= 1e16;
int main() {
    LL n;
    cin >> n;
    vector<LL> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vector<vector<LL >> dp(n + 1, vector<LL>(2, 0));
    dp[0][0] = 0;
    dp[0][1] = - LINF;
    for (LL i = 1; i < n + 1; i++) {
        dp[i][0] = max(dp[i - 1][0] + a[i - 1], dp[i - 1][1] - a[i - 1]);
        dp[i][1] = max(dp[i - 1][0] - a[i - 1], dp[i - 1][1] + a[i - 1]);
    }

    cout << dp[n][0] << endl;
    return 0;
}


Measured memory_bytes: 6528
n = int(input())
x = list(map(int, input().split()))
x.sort(reverse=True)

ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        a, b = x[i], x[j]
        left, right = j + 1, n
        while right - left > 1:
            k = (left + right) // 2
            if a < b + x[k]:
                left = k
            else:
                right = k
        if a < b + x[left]:
            ans += (left - j)

print(ans)

Measured memory_bytes: 43884
def main():
    N, M = map(int, input().split())
    H = [int(h) for h in input().split()]
    is_Good = [True for i in range(N)]

    for i in range(M):
        A, B = map(int, input().split())
        if H[A-1] <= H[B-1]:
            is_Good[A-1] = False
        if H[B-1] <= H[A-1]:
            is_Good[B-1] = False

    cnt = 0
    for i in range(N):
        if is_Good[i] == True:
            cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()

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

int N, s[MAXN + 3];
bool visited[MAXN + 3];

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
        scanf("%d", &s[i]);

    LL answer = 0;
    for (int C = 1; C < N - 1; C++) {
        LL currentProfit = 0;
        memset(visited, false, sizeof(visited));

        for (int k = 0; k * C < N - 1; k++) {
            if (N - 1 - k * C <= 1) break; //A must be > 1
            if (N - 1 - k * C - C < 1) break; //B must be > 0

            if (visited[N - 1 - k * C]) break;
            visited[N - 1 - k * C] = true;

            if (visited[k * C]) break;
            visited[k * C] = true;

            currentProfit += s[k * C];
            currentProfit += s[N - 1 - k * C];

            answer = max(answer, currentProfit);
        }
    }

    printf("%lld\n", answer);
}


Measured memory_bytes: 768
#include <stdio.h>
#define S_len 10000
#define T_len 500
#define TRUE 1
#define FALSE 0

int isMatched(int S[],int n, int Ti){
  int i=0;
  while(i != n){
    if(S[i] == Ti){
      return TRUE;
    }
    i++;
  }
  return FALSE;
}

int main(){
  int n,q,i, match=0;
  int S[S_len];
  int T[T_len];

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&T[i]);
  }

  for(i=0; i<q; i++){
    match += isMatched(S,n,T[i]);
  }
  
  printf("%d\n",match);
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>

using ll = long long;

bool check(std::string S) {
    if (S[0] != 'A')return false;
    int index = 2;
    int cnt = 0;
    for (int i = 2; i < S.length() - 1; i++) {
        if (S[i] == 'C') {
            cnt++;
            index = i;
        }
    }
    if (cnt != 1)return false;
    std::string s2(S);
    std::transform(s2.begin(), s2.end(), s2.begin(), tolower);
    S[0] = 'a';
    S[index] = 'c';
    if (S != s2)return false;
    return true;
}

int main() {
    std::string S;
    std::cin >> S;
    if (check(S)) {
        std::cout << "AC" << std::endl;
    }
    else {
        std::cout << "WA" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 1010;
int n;
LL x[maxn],y[maxn],u[maxn],v[maxn],bs[35];
void work(){
    cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    int sum = (x[0] ^ y[0]) & 1;
    for (int i = 0; i < n; i++) if ( ((x[i] ^ y[i]) & 1 ) ^ sum) {cout<<"-1"<<endl;return;}

    if (sum == 0) {
      cout << 32 << endl;
      for (int i = 30; i > -1; i--) cout<<bs[i]<<" ";
      cout << 1 << endl;
      for (int i = 0; i < n; i++) x[i]++;
    }else {
      cout << 31 << endl;
      for (int i = 30; i > -1; i--) cout<<bs[i]<<" ";
      cout << endl;
    }

    for (int i = 0; i < n; i++) u[i] = x[i] + y[i], v[i] = x[i] - y[i];

    for (int i = 0; i < n; i++) {
        for (int j = 30; j > -1; j--) {
            if (u[i] > 0 && v[i] > 0) {cout << 'R'; u[i] -= bs[j];  v[i] -= bs[j];}//x[i] > y[i] & x[i] > 0
            else if (u[i] > 0 && v[i] < 0) {cout << 'U'; u[i] -= bs[j];  v[i] += bs[j];}//y[i] > x[i] & y[i] > 0
            else if (u[i] < 0 && v[i] > 0) {cout << 'D'; u[i] += bs[j];  v[i] -= bs[j];}//x[i] > y[i] && y[i] < 0
            else {cout << 'L'; u[i] += bs[j];  v[i] += bs[j];}//x[i] < y[i] & x[i] < 0;
      }
      if (sum == 0) cout << 'L';
      cout << endl;
    }
}
int main(){
    bs[0] = 1;
    for (int i=1;i<32;i++) bs[i] = bs[i-1] << 1;
    work();
    return 0;
}


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


int main() {
  string S;
  bool flag = false;
  cin >> S;
  if(S.at(0) == 'A'){
    for(int i=1;i<S.size();++i){
      if(isupper(S.at(i))){
        if(i > 1 && i != S.size() - 1 ){
          if(S.at(i) == 'C' && !flag){
            flag = true;
          }else{
            cout << "WA" << endl;
            return 0;
          }
        }else{
          cout << "WA" << endl;
          return 0;
        }
      }
    }
  }else{
    cout << "WA" << endl;
    return 0;
  }

    if(flag){
      cout << "AC" << endl;
      return 0;
    }else{
      cout << "WA" << endl;
      return 0;
    }
}


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

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var s = Console.ReadLine().Split();
		string ans = "NO";
		if (s[0][s[0].Length - 1] == s[1][0] && s[1][s[1].Length - 1] == s[2][0])
		{
			ans = "YES";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
s1=gets.strip.split('')
s2=gets.strip.split('')

dp = Array.new(s1.length+1) { [0]*(s2.length+1) }

(s1.length+1).times {|i| dp[i][0]=i }
(s2.length+1).times {|i| dp[0][i]=i }

s1.each_with_index do |c1, i|
  s2.each_with_index do |c2, j|
    c = c1==c2 ? 0 : 1
    dp[i+1][j+1] = [
      dp[i+1][j]+1,
      dp[i][j+1]+1,
      dp[i][j]+c
    ].min
  end
end

# dp.each{|l|p l}

p dp.last.last



Measured memory_bytes: 14724
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod 1000000007
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	string s;
	cin>>s;
	int ans=0,cnt=0;
	f(i,s.size()){
		if(s[i]=='A'||s[i]=='G'||s[i]=='T'||s[i]=='C') cnt++;
		else{
			ans=max(ans,cnt);
			cnt=0;
		}
	}
	ans=max(ans,cnt);
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/***************************************************************
	File name: F.cpp
	Author: huhao
	Create time: Sat 05 Oct 2019 10:00:23 PM CST
***************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=r*10+c-48;
		c=getchar();
	}
	return r*t;
}
const int N=1010,M=(1<<15)|10;
#define i64 long long
const i64 mod=1000000007;
i64 n,f[M],a[N][N],m,p2[N];
i64 calc(i64 k)
{
	if(f[k])
		return f[k];
	for(i64 i=k;i;i=(i-1)&k)
		if((i&3)==0||(i&3)==3)
		{
			if(i&1)
			{
				i64 s=1;
				fr(I,1,n)
					if((1<<(I-1))&(k^i))
					{
						i64 t=1;
						fr(J,1,n)
							if((1<<(J-1))&i)
								if(a[I][J])
									t=t*2%mod;
						t=(t-1+mod)%mod;
						fr(J,1,n)
							if((1<<(J-1))&(k^i))
								if(a[I][J])
									t=t*2%mod;
						s=s*t%mod;
					}
				fr(I,1,n)
					if((1<<(I-1))&i)
						fr(J,1,n)
							if(((1<<(J-1))&(k^i))&&a[I][J])
								s=s*2%mod;
				f[k]=(f[k]+s)%mod;
			}
			else
			{
				i64 s=1;
				fr(I,1,n)
					if((1<<(I-1))&(k^i))
					{
						i64 p=1;
						fr(J,1,n)
							if(((1<<(J-1))&i)&&a[I][J])
								p=p*2%mod;
						p=(p+mod-1)%mod;
						s=s*p%mod;
					}
				fr(I,1,n)
					if((1<<(I-1))&i)
						fr(J,1,n)
							if(((1<<(J-1))&(k^i))&&a[I][J])
								s=s*2%mod;
				i64 C=calc(k^i);
				f[k]=(f[k]+s*C)%mod;
			}
		}
	return f[k];
}
int main()
{
	n=read();
	m=read();
	fr(i,1,m)
	{
		int u=read(),v=read();
		a[u][v]=1;
	}
	p2[0]=1;
	fr(i,1,m)
		p2[i]=p2[i-1]*2%mod;
	printf("%lld\n",(p2[m]-calc((1<<n)-1)+mod)%mod);
	return 0;
}

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

int n, q, N;
int dat[4*100000];

void init(){
	N = 1;
	while(N < n) N *= 2;
	rep(i,N*2) dat[i] = INT_MAX;
}

void update(int x, int y){
	x += N-1;
	dat[x] = y;
	while(x > 0){
		x = (x-1)/2;
		dat[x] = min(dat[x*2+1],dat[x*2+2]);
	}
}

int query(int a, int b, int t, int r, int l){
	if(a >= l || b <= r) return INT_MAX;
	if(a <= r && l <= b) return dat[t];
	return min(query(a,b,t*2+1,r,(r+l)/2),query(a,b,t*2+2,(r+l)/2,l));
}

int main(){
	scanf("%d%d",&n,&q);
	init();
	rep(i,q){
		int com, x, y;
		scanf("%d%d%d",&com,&x,&y);
		if(com == 0){
			update(x,y);
		} else{
			printf("%d\n",query(x,y+1,0,0,N));
		}
	}
}

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

#define ll long long
#define rep(i, n) for(i = 0; i < n; i++)

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

    set<int> sugar_possible;
    set<int> water_possible;
    
    rep(i, F/A/100 + 1){
        rep(j, F/B/100 + 1){
            water_possible.insert(i*A+j*B);
        }
    }
    
    rep(i, F/C + 1){
        rep(j, F/D + 1){
            sugar_possible.insert(i*C+j*D);
        }
    }

    int best_s = 0;
  	int best_w = A;
    for(int w : water_possible){
        if(w == 0) continue;
        for(int s : sugar_possible){
            // cout << w << ' ' << s << '\n';
            if(w * 100 + s <= F && s <= E * w && best_s * w < s * best_w){
                best_w = w;
                best_s = s;
            }
        }
    }

    cout << best_w * 100 + best_s << ' ' << best_s << endl;
    
    return 0;
}


Measured memory_bytes: 3864
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	d := make([]int, n)
	for i := range d {
		fmt.Scan(&d[i])
	}

	ans := 0
	for i := range d {
		for j := i + 1; j < len(d); j++ {
			ans += d[i] * d[j]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10,mxsiz=10;
inline int read(){
	int x=0,f=1;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
	return x*f;
}
int ans=0x3f3f3f3f;
int n,f[maxn],g[maxn];
inline void dfs(int x){
	if(x>mxsiz||x>ans)return;
	int yh=0;
	for(register int i=1;i<=n;++i){
		if(f[i]^g[i])break;
		if(i==n){
			ans=x;
			return;
		}
	}
	for(register int i=1;i<=n;++i)yh^=f[i];
	for(register int i=1;i<=n;++i){
		int tmp=f[i];
		f[i]=yh;
		dfs(x+1);
		f[i]=tmp;
	}
}
int a[maxn],b[maxn],cnt,tot;
map<int,int>mp;
int fst[maxn],lst[maxn<<1],to[maxn<<1],e;
int cl[maxn],num[maxn],d[maxn];
inline void add(int x,int y){
	to[++e]=y,lst[e]=fst[x],fst[x]=e;
}
inline void dfs(int x,int c){
	cl[x]=c;
	for(register int i=fst[x];i;i=lst[i])if(!cl[to[i]])dfs(to[i],c);
}
inline void solve(){
	for(register int i=1;i<=n;++i)a[i]=f[i],a[0]^=f[i],b[i]=g[i],b[0]^=g[i];
	f[0]=a[0],g[0]=b[0],sort(a,a+n+1),sort(b,b+n+1);
	for(register int i=0;i<=n;++i)if(a[i]^b[i])return;
	ans=0,f[n+1]=f[0],g[n+1]=g[0],++n;
	for(register int i=1;i<=n;++i){
		if(!mp[f[i]])mp[f[i]]=++cnt;
		a[i]=mp[f[i]];
		if(!mp[g[i]])mp[g[i]]=++cnt;
		b[i]=mp[g[i]];
	};
	for(register int i=1;i<=n;++i){
		if(a[i]^b[i])add(a[i],b[i]),add(b[i],a[i]),++d[a[i]],++d[b[i]];		
	}
	for(register int i=1;i<=n;++i)d[i]/=2;
	for(register int i=1;i<=n;++i)if(!cl[a[i]]&&a[i]!=b[i])++tot,dfs(a[i],tot);
	for(register int i=1;i<=n;++i)num[cl[i]]+=d[i];
	for(register int i=1;i<=tot;++i){
		if(num[i]<=1)continue;
		ans+=num[i];
		if(i^cl[a[n]])++ans;
		else if(a[n]!=b[n])--ans;
	}
}
int main(){
	n=read();
	for(register int i=1;i<=n;++i)f[i]=read();
	for(register int i=1;i<=n;++i)g[i]=read();
	if(n<=5)dfs(0);
	else solve();
	if(ans==0x3f3f3f3f)printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10240
z[9999],a,b,c;f(x,y){fflush(!printf("? %d %d\n",x,y));scanf("%s",&b);b=b=='Y';}main(i){if(scanf("%d%d",&a,&b),a<=b){puts("Impossible");return 0;}for(i=a+=b;~--i;)!c||f(i,z[c-1])?(z[c++]=i):c--;for(c=*z,i=a;~--i;)z[i]=f(c,i);for(printf("! "),i=0;i<a;)printf("%d",z[i++]);}

Measured memory_bytes: 720
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      int a,b,c;
      cin >> a >> b >> c;
      
      int t =c-(a-b);
      if(t>=0)
        cout << t << endl;
     	else
          cout << 0 << endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int main(){

 long long n,m;
 cin>>n>>m;

  if(n == 1) n = 1;
  else n = n-2;

  if(m == 1) m =1;
  else m = m-2;

  cout<<n*m<<endl;


 return 0;
 }


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define endl       "\n"
#define ll         long long
#define pb         push_back
#define FIO        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define NUM        1000000007
#define MOD        998244353
#define F          first
#define S          second
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a-1;i>=b;i--)
#define vi         vector<ll>
#define pii        pair<ll,ll>
#define vpi        vector<pii>
#define mi         map<ll,ll>
#define mpi        map<pii,ll>
#define all(v)     (v).begin(),(v).end()
#define rall(v)    (v).rbegin(),(v).rend()
#define fac(a)     tgamma(a+1)

bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{ 
    return (a.second < b.second);      // compare function for sorting modification
}

vector<ll> primes;
vector<bool> PRIME(1000005,true);       // prime no.s less than 10^6
void sieve(ll n)                        // PRIME[i]=true => i=prime no.
{  PRIME[0]=false;PRIME[1]=false;
    for (ll p=2; p*p<=n; p++) { 
        if (PRIME[p] == true) { 
            for (ll i=p*p; i<=n; i += p){PRIME[i]=false;} 
        } 
    } rep(i,2,n+1){if(PRIME[i]){primes.pb(i);}}
}  

ll nCr[1001][1001];
void combination(ll n)                  // nCr values
{
    rep(i,0,n+1){
        rep(j,0,i+1){
            if(j==0 or j==i)nCr[i][j]=1;
            else nCr[i][j]=(nCr[i-1][j-1]+nCr[i-1][j])%NUM;
        }
    }
}

#define N  1000005

ll a,b,c,d,e,i,j,k,l,m,n,q,p,r,u,v,w,x,y,z,mn,mx;
ll arr[N];
//ll dp[2005][2005];

int main() 
{
    FIO;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        mn=LONG_LONG_MAX;
        mx=LONG_LONG_MIN;
        cin>>n;
        a=0,b=0,c=0,d=0;
        while(n--)
        {
            string s;
            cin>>s;
            if(s=="AC")a++;
            else if(s=="WA")b++;
            else if(s=="TLE")c++;
            else if(s=="RE")d++;
        }
        cout<<"AC x "<<a<<endl;
        cout<<"WA x "<<b<<endl;
        cout<<"TLE x "<<c<<endl;
        cout<<"RE x "<<d<<endl;
        
        
        
        
        
        
        
        
        
        
        h:;
        cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <cstdlib>

using namespace std;

int a[200];
int top = 0;
void push(int num)
{
	a[++top] = num;
}

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

int main(int argc, char const *argv[])
{
	int x, y;
	char c[80];
	while(cin >> c)
	{
		switch(c[0])
		{
			case '+':
				y = pop();
				x = pop();
				push(x + y);
				break;
			case '-':
				y = pop();
				x = pop();
				push(x - y);
				break;
			case '*':
				y = pop();
				x = pop();
				push(x * y);
				break;
			default:
				push(atoi(c));
		}
	}
	cout << pop() << endl;
	return 0;
}

Measured memory_bytes: 1152
N, K = map(int,input().split())
mod = pow(10, 9) + 7

total = 0
for i in range(K, N + 2):
  maximum = (N - i + 1 + N) * i / 2
  minimum = (i - 1) * i / 2
  count = maximum - minimum + 1
  total += (count % mod)
  
print(int(total % mod))

Measured memory_bytes: 9184
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String x=gs();
	   
	    //System.out.print(P[1]+P[0]);

        if (x.charAt(0)==x.charAt(1) || x.charAt(1)==x.charAt(2) || x.charAt(2)==x.charAt(3)) {
        	System.out.print("Bad");
        }else {
        	System.out.print("Good");
        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35408
// https://beta.atcoder.jp/contests/abc051/tasks/abc051_b

// template start
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buf = make([]byte, 1000)

func inputLine() string{
	sc.Scan()
	return sc.Text()
}

func scanInt() int {
	out, e := strconv.Atoi(inputLine())
	if e != nil {
        panic(e)
    }
	return out
}

func scanIntArray(n int) []int {
	out := make([]int, n)
	for i, v := range(strings.Split(inputLine(), " ")) {
		num, e := strconv.Atoi(v)
		if e != nil {
			panic(e)
		}
		out[i] = num
	}
	return out
}
//  template end

func main() {
	sc.Buffer(buf, 10000)
	arr := scanIntArray(2)
	k, s := arr[0], arr[1]
	cnt := 0
	var x, y, z = 0, 0, 0
	for x=0; x<=k; x++ {
		for y=x; y<=k; y++ {
			z = s - (x+y)
			if z >= 0 && z <= k && x<=y && y<=z{
				if x==y && y==z {
					cnt += 1
				} else if (x!=y && y==z) || (y!=z && z==x) || (z!=x && x==y) {
					cnt += 3
				} else {
					cnt += 6
				}
			} else {
				continue
			}
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int A,B;
    cin>>A>>B;
    if(A==B){
        cout<<"Draw"<<endl;
    }
    else if(A==1){
        cout<<"Alice"<<endl;
    }
    else if(B==1){
        cout<<"Bob"<<endl;
    }
    else if(A>B){
        cout<<"Alice"<<endl;
    }
    else{
        cout<<"Bob"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/


string str;
int n, cnt1, cnt2, cnt3, cnt4;

int main() {
   cin>>n;
   while(n--) {
      cin>>str;
      if(str == "AC") cnt1++;
      else if(str == "WA") cnt2++;
      else if(str == "TLE") cnt3++;
      else cnt4++;
   }
   printf("AC x %d\n", cnt1);
   printf("WA x %d\n", cnt2);
   printf("TLE x %d\n", cnt3);
   printf("RE x %d\n", cnt4);
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

ll n;
ll a[100010];

ll solve(ll total)
{
	ll ret = 0;
	for(ll i=1; i<n; i++){
		if( total < 0 ){
			total += a[i];
			if( total > 0 ){
				continue;
			} else {
				ret += 1 - total;
				total = 1;
				continue;
			}
		} else {
			total += a[i];
			if( total < 0 ){
				continue;
			} else {
				ret += 1 + total;
				total = -1;
				continue;
			}
		}
	}
	return ret;
}

int main()
{
	ll ret, ret2, ret3;
	cin >> n;
	for(ll i=0; i<n; i++) cin >> a[i];

	if( a[0] == 0 ){
		ret2 = solve(1) + abs(1-a[0]);
		ret3 = solve(-1) + abs(1+a[0]);
		ret = min(ret2, ret3);
	} else {
		ret = solve(a[0]);
		ret2 = solve(1) + abs(1-a[0]);
		ret3 = solve(-1) + abs(1+a[0]);
		ret = min(ret, min(ret2, ret3));
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>


#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void C_task();

int main()
{
	C_task();
	
	fflush(stdout);
	return 0;
}

static void C_task()
{
	int N;
	get1int(N);

	auto seqA = new int[N + 1];
	int maxIdx = 0, maxNum = 0, secondNum = 0;
	for (int i = 0; i < N; i++) {
		get1int(seqA[i]);
		if (maxNum < seqA[i]) {
			maxNum = seqA[i];
			maxIdx = i;
		}
	}
	std::sort(seqA, seqA + N);
	secondNum = seqA[N - 2];
	
	for (int i = 0; i < N; i++) {
		printf("%d\n", (i == maxIdx ? secondNum : maxNum));
	}

	delete[] seqA;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    vector<tuple<string,int,int>> mp(n);

    rep(i,n){
        string s; int a; cin >> s >> a;
        mp[i] = make_tuple(s,a*-1,i+1);
    }

    sort(all(mp));

    rep(i,n) cout << get<2>(mp[i]) << endl;

}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



s = S()
d = len(s)
dp = [[0] * 13 for _ in range(d + 1)]
dp[0][0] = 1
for i in range(d):
    for j in range(13):
        if s[i] != '?':
            dp[i + 1][(j * 10 + int(s[i])) % 13] = (dp[i + 1][(j * 10 + int(s[i])) % 13] + dp[i][j]) % mod
        else:
            for k in range(10):
                dp[i + 1][(j * 10 + k) % 13] = (dp[i + 1][(j * 10 + k) % 13] + dp[i][j]) % mod


print(dp[d][5])

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

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

    string S;
    cin >> S;

    vector<pair<pair<int,int>,int>> DP(N+1); // R,G,B;
    // DP.at(i) := S.at(i)より先にあるR,G,Bの数
    DP.at(N).first.first = 0;
    DP.at(N).first.second = 0;
    DP.at(N).second = 0;

    for(int i=N-1;i>=0;i--)
    {
        if(S.at(i)=='R') DP.at(i).first.first = DP.at(i+1).first.first + 1;
        else             DP.at(i).first.first = DP.at(i+1).first.first;
        if(S.at(i)=='G') DP.at(i).first.second = DP.at(i+1).first.second + 1;
        else             DP.at(i).first.second = DP.at(i+1).first.second;
        if(S.at(i)=='B') DP.at(i).second = DP.at(i+1).second + 1;
        else             DP.at(i).second = DP.at(i+1).second;
    }
/*
    for(int i=0;i<N;i++)
    {
        cout << DP.at(i).first.first << ' ' << DP.at(i).first.second << ' ' << DP.at(i).second << endl;
    }
*/
    ll total = 0;

    for(int i=0;i<N;i++)
    {
        if(S.at(i)=='R') total += DP.at(i).first.second * DP.at(i).second;
        if(S.at(i)=='G') total += DP.at(i).first.first * DP.at(i).second;
        if(S.at(i)=='B') total += DP.at(i).first.first * DP.at(i).first.second;
    }

    for(int i=0;i<N;i++)
    {
        for(int j=1;j<=(N-i-1)/2;j++)
        {
            if(S.at(i)!=S.at(i+j) && S.at(i+j)!=S.at(i+j*2) && S.at(i)!=S.at(i+j*2))
            {
                total--;
                //cout << i << ' ' << i+j << ' ' << i+j*2 << endl;
            }
        }
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>

long long int  dp[2][10];
int  n, m, nums[10];
char id[100005];

int main(){
  dp[1][0] = 1;
  scanf("%d", &n);
  scanf("%s", id);
  scanf("%d", &m);
  for(int i = 0;i < m;i++){
    scanf("%d", nums + i);
  }
  for(int i = 0;i < n;i++){
    int twotime = 1;
    if((n - i) % 2 == 0){
      twotime = 2;
    }
    if(id[i] == '*'){
      for(int j = 0;j < 10;j++){
	dp[i % 2][j] = 0;
	for(int k = 0;k < m;k++){
	  int add = (nums[k] * twotime) % 10 + (nums[k] * twotime) / 10;
	  dp[i % 2][j] += dp[1 - (i % 2)][(j + 10 - add) % 10];
	}
      }
    }
    else{
      int k = id[i] - '0';
      for(int j = 0;j < 10;j++){
	dp[i % 2][j] = 0;
	int add = (k * twotime) % 10 + (k * twotime) / 10;
	dp[i % 2][j] += dp[1 - i % 2][(j + 10 - add) % 10];
      }
    }
  }
  printf("%lld\n", dp[(n - 1) % 2][0]);
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[425];
ll sum[425];
ll dp[425][425];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,n)sum[i+1] = sum[i] + a[i];
  REP(i,n+1)dp[i][i] = 0;
  REP(i,n)dp[i][i+1] = 0;
  FOR(len,2,n+1)REP(i,n+1-len){
    int j = i+len;
    dp[i][j] = 1ll<<60;
    FOR(x,i+1,j){
      CHMIN(dp[i][j], dp[i][x] + dp[x][j]);
    }
    dp[i][j] += sum[j] - sum[i];
  }
  printf("%lld\n",dp[0][n]);
  return 0;
}


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

int main(void) {
  string S;
  cin >> S;
  vector<string> dict = {"Sunny", "Cloudy", "Rainy"};
  cout << dict[(find(dict.begin(), dict.end(), S) - dict.begin() + 1) % 3]
       << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int n, m, v, ct, pe[nax];
char s[3];
bool ac[nax];

int main(){
    scanf("%d %d", &n, &m);
    for(int i = 1 ;i <= m ; i++){
        scanf("%d %s", &v, s);
        if(s[0] == 'A'){
            if(!ac[v]){
                ac[v] = true;
                ++ ct;
            }
        }
        else{
            if(!ac[v]){
                pe[v] ++ ;
            }
        }
    }
    int p = 0;
    for(int i = 1 ;i <= n ;i++){
        if(ac[i]){
            p += pe[i];
        }
    }
    printf("%d %d\n", ct, p);
}
/*
    Good Luck
        -Lucina
*/



Measured memory_bytes: 768
import numpy as np
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

n,p  = list(map(int, input().split()))
a = 1
f = factorize(p)
for x, y in f:
    if y >= n:
        a *= x**(y // n)
if n == 1:
    print(p)
else:
    print(a)

Measured memory_bytes: 20860
N = int(input())
C = [int(input()) for i in range(N)]
MOD = 10**9 + 7

# 左からi番目までの石を見ていくときに何通りの列ができるか
dp = [0] * N
# 一通りはあるので１
dp[0] = 1

# ある色が最後にどこで出てきたか覚えておく
last = dict()




for i,c in enumerate(C):
    if i == 0:
        last[c] = i
    else:
        dp[i] = dp[i-1]
        """

        たとえば
        112212121222
        のi=8（一番右にある1）を見ているとき、i=8の石を選んで間をひっくり返すか返さないかの選択肢がうまれる。
        その時増える起こりうる列の数は、最後の1が出てきたところから左について、何通りの列を作るれかに依存する。
        11111112 1222
        11222212 1222
        11221212 1222
        みたいなパターンがあり、i=8の1を選んでひっくり返すか、そのままにしておくかの選択の余地が生まれる。
        
        なので、
        ・最後に同じ数字が出てきた場所を覚えておく。
        ・そこまでのdpを今のdpに加える（i番目の石を選んでひっくり返す場合、最後にiと同じ色が出てきたところの手前のとりうる列の数だけ新たに列を作ることができるため）
        を繰り返せば、最終的な数が求まる

        """
        # cが既に出てきていて、さらに今見ている石と隣り合っていない場合
        if c in last and last[c] < i-1:
            dp[i] += dp[last[c]]
            dp[i] %= MOD
        last[c] = i

print(dp[-1])

Measured memory_bytes: 36556
#include<stdio.h>
int main()
{
    long a,b;
    scanf("%lld %lld",&a,&b);
    if(a<=0)
    {
        if(b>=0)printf("Zero");
        else if(b<0)
        {
            if((b-a)%2==0)printf("Negative");
            else printf("Positive");
        }
    }
    else printf("Positive");
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> a;
  rep(i, n) {
    a.push_back(s[i] - '0');  // cast(char->int)
  }
  ll ans = 0;
  rep(bit, 1 << (n - 1)) {
    ll now = a[0];
    rep(i, n - 1) {
      if (bit & 1 << i) {
        ans += now;
        now = 0;
      }
      now = now * 10 + a[i + 1];
    }
    ans += now;
  }
  cout << ans << endl;
}

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

using namespace std;

void doc() {
    freopen("OB.inp", "r", stdin);
    freopen("OB.out", "w", stdout);
}

const   int MaxN = 1e5 + 5;

void solve(){
    int n;
    cin >> n;
    double a[n + 1], f[n + 1][n + 1][2];
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    memset(f, 0, sizeof(f));
        f[1][0][0] = 1.0 - a[1];
        f[1][1][1] = a[1];
    for(int i = 2; i <= n ; i++)
        f[i][0][0] = f[i - 1][0][0] * (1.0 - a[i]);
    for(int i = 2; i <= n; i++)
    for(int j = 1; j <= i; j++){
            f[i][j][0] = (f[i - 1][j][0] + f[i - 1][j][1]) * (1.0 - a[i]);
            f[i][j][1] = (f[i - 1][j - 1][0] + f[i - 1][j - 1][1]) * a[i];
    }
//    cout << f[2][0][0] << " " << f[3][1][1] << '\n';
//    cout << f[1][0][0] << '\n';
//    double sum[n + 1], summ = 0;
//    double temp = 0;
//    memset(sum, 0, sizeof(sum));
//    for(int i = 0; i <= (1 << n) - 1; i++){
//        bool check = false;
//        int cnt = 0;
//        for(int j = 0; j < n; j++)
//            if ((i >> j) & 1) cnt++;
//        if (cnt >= n / 2 + 1) check = true;
//        if (!check) continue;
//        double t = (double)1;
//        for(int j = 1; j <= n; j++)
//            t *= ((i >> (j-1))&1) ? (a[j]) : (1.0 - a[j]);
////            if ((i >> j)&1)
////                t *= a[i];
////            else t *= (1 - a[i]);
//    //    cout << i << " " << t << '\n';
////        if (cnt == 1 && (i >> 2)&1) {
////            temp += t;
////            //cout << i << endl;
////        }
//        sum[cnt] += t;
//        summ += t;
//    }
//////    cout << "*" << temp << '\n';
////    for(int i = n / 2 + 1; i <= n; i++)
////        cout << sum[i] << '\n';
//    cout << summ << '\n';
    double res = 0;
    for(int i = n / 2 + 1; i <= n; i++)
    {
        res += f[n][i][0] + f[n][i][1];
       // cout << i << " " << f[n][i][0] + f[n][i][1] << '\n';
      //  cout << i << endl;
    }
    cout << fixed << setprecision(10) << res;
}

int main()
{
//    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}



Measured memory_bytes: 140928
N=input()

if N.endswith('2'):
    print('hon')
if N.endswith('4'):
    print('hon')
if N.endswith('5'):
    print('hon')
if N.endswith('7'):
    print('hon')
if N.endswith('9'):
    print('hon')
    
if N.endswith('0'):
    print('pon')
if N.endswith('1'):
    print('pon')
if N.endswith('6'):
    print('pon')
if N.endswith('8'):
    print('pon')

if N.endswith('3'):
    print('bon')

Measured memory_bytes: 9080
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0]*(N+1), [0]*(M+1)
for i in range(N):
	a[i+1] = a[i] + A[i] 
for i in range(M):
	b[i+1] = b[i] + B[i]
 
ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 46888
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int R[8], G[8], B[8];
string color[8] = {"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"};

int calc_d(int r, int g, int b, int i){
  return (r - R[i]) * (r - R[i]) + (g - G[i]) * (g - G[i]) + (b - B[i]) * (b - B[i]);
}

int main(){

  REP(i,8){
    if(i % 2 == 1){
      B[i] = 255;
    }
    if(i % 4 >= 2){
      G[i] = 255;
    }
    if(i >= 4){
      R[i] = 255;
    }
  }

  while(true){
    string s;
    cin >> s;

    if(s == "0") break;

    int r, g, b;
    r = stoi(s.substr(1,2), nullptr, 16);
    g = stoi(s.substr(3,2), nullptr, 16);
    b = stoi(s.substr(5,2), nullptr, 16);

    int ans = 0;
    int d = INF;
    REP(i,8){
      int tmp = calc_d(r, g, b, i);
      if(tmp < d){
        d = tmp;
        ans = i;
      }
    }
    cout << color[ans] << endl;
  }
  return 0;
}




Measured memory_bytes: 3160
s = input()
k = int(input())
count = 0
for i in range(len(s)):
    if s[i]=="1":
        count = i+1
    else:
        break
        
if len(s)==1:
    print(int(s[0]))
elif k<=count:
    print("1")
else:
    print(int(s[count]))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int sigma(int n){
    int sum=0;
    for (int i=1; i<=(n); i++){
        sum+=i;
    }
    return sum;
}
int distance(int yo,int xo,int yi,int xi){
    return (yo-yi)*(yo-yi)+(xo-xi)*(xo-xi);
}
signed main(){
    int N,a,b;
    string S;
    cin >>  N>>S;
    int M = S.length();
    b=(int)('Z');
    rep(i,M){
        a=(int)(N+S[i]);
        if(a>b){
            a = a-26;
        }
        S[i]=(char)a;
    }
    rep(i,M){
        cout << S[i];
    }
    cout << endl;
}


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


void solve(long long N, std::vector<long long> A){
    for(auto a : A){
        if(a == 0){
            cout << 0 << endl;
            return;
        }
    }
    long long ans = 1;
    for (int i = 0; i < N; i++)
    {
        if(A[i] <= 1000000000000000000/ans) ans *= A[i];
        else{
            cout << -1 << endl;
            return;
        }
    }
    cout << ans << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4036
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n, l;
	while(cin >> n >> l) {
		int sum = 0;
		REP(i, n) {
			sum += l + i;
		}
		int v = INF;
		int ans = INF;
		REP(i, n) {
			int a = sum - (l+i);
			if(chmin(v, abs(sum - a))) {
				ans = a;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


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

int arr[100005];


int main() {
	int n, k, q;
	cin >> n >> k >>q;
	for(int i = 0; i < q; i++) {
		int x; cin >> x; arr[x]++;
	}
	for(int i = 0; i < n; i++) {
		int res = k - q + arr[i+1];
		if(res > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


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

int main() {
    int A, B, M;
    cin >> A >> B >> M;

    int a[A], b[B];

    for(int i = 0; i < A; i++) cin >> a[i];
    for(int i = 0; i < B; i++) cin >> b[i];

    int ans = 1e7;

    for(int i = 0; i < M; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        int price;
        price = a[x - 1] + b[y - 1] - c;
        if(ans > price) ans = price;
    }

    sort(a, a + A);
    sort(b, b + B);

    int price = a[0] + b[0];

    if(ans > price) ans = price;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import itertools

a, b, c = list(map(int, input().split()))
k = int(input())

ABC = ['A', 'B', 'C']


def solve():
    for kk in range(1, k + 1):
        for x in list(itertools.product([0, 1, 2], repeat=kk)):
            abc = [a, b, c]
            for xx in x:
                abc[xx] = abc[xx] * 2

            if abc[0] < abc[1] < abc[2]:
                return 'Yes'

    return 'No'


print(solve())


Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
int s[100010];
int n,nu,ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&nu);
		s[nu]++;s[nu+1]++;s[nu+2]++;	
	}
	for(int i=1;i<=100009;i++)ans=max(ans,s[i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

//Calling Extraterrestrial Intelligence Again
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int N = 100000;
		boolean[] f = new boolean[N+1];
		Arrays.fill(f, true);
		List<Integer> sieve = new ArrayList<Integer>();
		f[0]=f[1]=false;
		for(int i=2;i<=N;i++)if(f[i]){
			sieve.add(i);
			for(int j=i+i;j<=N;j+=i)f[j]=false;
		}
		int n = sieve.size();
		for(;;){
			int m = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
			if((m|a|b)==0)break;
			boolean con = true;
			for(int x=m;x>0;x--){
				if(!con)break;
				for(int ip=0;ip<n;ip++){
					int p = sieve.get(ip);
					if(p*p>x)break;
					int q = x/p;
					if(x%p!=0||p*b<q*a)continue;
					if(f[q]){
						con = false;
						System.out.println(p+" "+q);
						break;
					}
				}
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
a = [input().split() for l in range(4)]
N=int(a[0][0])
A=a[1]
B=a[2]
C=a[3]
manzoku=0
for i in range(N):
    manzoku=manzoku+int(B[int(A[i])-1])
    if i>0 and int(A[i])==int(A[i-1])+1:
        manzoku=manzoku+int(C[int(A[i-1])-1])

print(manzoku)


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

bool prime[1000003];
bool sieve() {
    memset(prime, true, sizeof(prime));
    for(int i = 2; i * i < 1000003; ++i){
        if(prime[i]){
            for(int j = 2 * i; j < 1000003; j += i){
                prime[j] = false;
            }
        }
    }
}
long long fact(int n) {
    long long ans = 1;
    for(int i = 2; i <= n; ++i) ans *= i;
    return ans;
}
int dig(long long x) {
    int ans = 0;
    long long n = x;
    while(n > 0) {
        ans += 1;
        n/=10;
    }
    return ans;
}
int main() { 
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // double time = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
    

    
        
    // cout << "Execution-Time : " << (clock() - time) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <queue>
#include <bitset>

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

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

    ll N;
    cin>>N;
    vector<array<ll, 11>> F(N), P(N);
    for (ll n = 0; n < N; n++)
        for (ll i = 0; i < 10; i++) cin>>F[n][i];
    for (ll n = 0; n < N; n++)
        for (ll i = 0; i <= 10; i++) cin>>P[n][i];

    ll ans = -inf;
    for (ll i = 1; i < 1<<10; i++) {
        ll a = 0;
        for (ll n = 0; n < N; n++) {
            ll cnt = 0;
            for (ll j = 0; j < 10; j++)
                if ((i & (1 << j)) && F[n][j]) cnt++;
            a += P[n][cnt];
        }
        ans = max(a, ans);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

var (
	finv, inv, fac [MAX]int
)

func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func init() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for 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
	}
}

const (
	MOD = 998244353
	MAX = 510000
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

func main() {
	var N, M, K int
	fmt.Scanf("%d %d %d\n", &N, &M, &K)

	sum := int64(0)
	for i := 0; i <= K; i++ {
		p := ModPow(int64(M-1), int64(N-1-i))
		m := ModMul(int64(M), p)
		sum = ModAdd(sum, ModMul(m, int64(COM(N-1, i))))
	}
	fmt.Println(sum)
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 13804