akhauriyash/Code-Regression huggingface dataset:
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_VAL_MAX		100005									// 最大値

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Cnt[D_VAL_MAX];									// 個数
static long long slSum;											// 合計

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si1Cnt, 0, sizeof(si1Cnt));
	slSum = 0;

	// 配列数 - 取得
	int liACnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liACnt);

	// 配列 - 取得
	for (i = 0; i < liACnt; i++) {
		int liVal;
		fscanf(szpFpI, "%d", &liVal);

		// 個数 - 加算
		si1Cnt[liVal]++;

		// 合計 - 加算
		slSum += liVal;
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// クエリ数 - 取得
	int liQCnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liQCnt);

	// クエリ - 取得
	for (i = 0; i < liQCnt; i++) {
		int liBefore, liAfter;
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%d%d", &liBefore, &liAfter);

		// 合計 - 加算
		slSum += (long long)(liAfter - liBefore) * (long long)si1Cnt[liBefore];

		// 個数 - 加算
		si1Cnt[liAfter] += si1Cnt[liBefore];
		si1Cnt[liBefore] = 0;

		// 出力
		sprintf(lc1Buf, "%lld\n", slSum);
		fOutLine(lc1Buf);
	}

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 2112
n=int(input())
d=dict()
for m in range(1,n+1):
    while m>1:
        for i in range(2,int(m**0.5)+1):
            if m%i==0:break
        else:i=m
        d[i]=d.get(i,0)+1
        m/=i
def num(n):
    return len(list(filter(lambda x:x>=n,d.values())))

print(num(74)+ num(24)*(num(2)-1)+ num(14)*(num(4)-1)+ num(4)*(num(4)-1)*(num(2)-2)//2)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define bitcnt(a) (ll) __builtin_popcount((a))

/*575専用スペース A place only for 575*/
/*人人人人人人人人人人*/
using namespace std;
/*Y^Y^Y^Y^Y^Y^Y^Y^Y*/

int main() {
  ll n;
  cin >> n;
  ll A = 0, B = 0;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    if (A < a) {
      A = a;
      B = b;
    }
  }
  cout << A + B << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int num,cnt=0;
    cin>>num;
    while(1){
      int max=0;
      if(num/10==0)break;
      for(int j=10;num/j>0;j*=10){
        int a=num/j,b=num%j;
        if(a*b>max)max=a*b;
      }
      num=max;
      cnt++;
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>

int main()
{
 long n,m,i,j,k,l;
 
 while(scanf("%ld %ld",&n,&m)!=EOF)
 {
   if(n>m) l=m;
   else l=n;
   if(n%l==0&&m%l==0)  printf("%ld\n",l);
   else
   {
   for(i=1;i<=l/2;i++)
   {
    if(n%i==0&&m%i==0) k=i;
   }
   printf("%ld\n",k);
  }
 }
 return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int M = 20;
		
		int[][] right = new int[M][];
		for(int i=0;i<M;i++) right[i] = new int[N];
		int t = 0;
		for(int i=0;i<N;i++){
			while(true){
				if(t + 1 < N && X[t + 1] - X[i] <= L){
					t++;
					continue;
				}
				break;
			}
			right[0][i] = t;
		}
		
		for(int i=1;i<M;i++){
			for(int j=0;j<N;j++){
				right[i][j] = right[i-1][right[i-1][j]];
			}
		}
		
		int[][] left = new int[M][];
		for(int i=0;i<M;i++) left[i] = new int[N];
		
		t = N - 1;
		for(int i=N-1;i>=0;i--){
			while(true){
				if(t - 1 >= 0 && X[i] - X[t - 1] <= L){
					t--;
					continue;
				}
				break;
			}
			left[0][i] = t;
		}
		
		for(int i=1;i<M;i++){
			for(int j=0;j<N;j++){
				left[i][j] = left[i-1][left[i-1][j]];
			}
		}
		
		List<int> ans = new List<int>(Q);
		for(int q = 0; q < Q; q++){
			int a = A[q], b = B[q];
			
			if(a < b){
				int cnt = 0;
				int now = a;
				
				for(int i=M-1;i>=0;i--){
					if(right[i][now] < b){
						cnt += 1 << i;
						now = right[i][now];
					}
				}
				
				ans.Add(cnt + 1);
			}
			
			if(a > b){
				int cnt = 0;
				int now = a;
				
				for(int i=M-1;i>=0;i--){
					if(left[i][now] > b){
						cnt += 1 << i;
						now = left[i][now];
					}
				}
				ans.Add(cnt + 1);
			}
			
		}
		Console.WriteLine(String.Join("\n",ans));
	}
	int N;
	long[] X;
	long L;
	int Q;
	int[] A,B;
	public Sol(){
		N = ri();
		X = rla();
		L = rl();
		Q = ri();
		A = new int[Q];
		B = new int[Q];
		for(int i=0;i<Q;i++){
			var d = ria();
			A[i] = d[0] - 1;
			B[i] = d[1] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int ans=0;
  for(int i=0; i<N; i++){
    int h;
    cin >> h;
    if(h >= K){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<int> num(n);
  map<int,long long> kazu;
  
  for(int i=0; i<n;i++){
    cin >> num.at(i); 
    kazu[num.at(i)]++;
  }
  
  long long sum;
  
  for(int i=0; i<n;i++){
    sum += kazu[i+1]*(kazu[i+1]-1)/2;
  }
  
  for(int i=0;i<n;i++){
    cout << sum-kazu[num.at(i)]+1 << endl;
  }
  
}


Measured memory_bytes: 15900
N,K=(int(x) for x in input().split())
# N=4
# K=3
n=0

# print("N=",list(range(N+1)))
for i in range(K,N+2):
    # K個を選択する
    M=N*(N+1)/2-(N-i)*(N-i+1)/2
    # print("M=%d-%d"%(N*(N+1)/2,(N-i)*(N-i-1)/2))
    m=i*(i-1)/2
    n+=M-m+1
    # print("")
    # print("i=",i)
    # print("M,m=",M,m)
    # print("場合=",M-m+1)
print(int(n%(1e9+7)))

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define maxx ((ll)1e6+5)
#define pb push_back
#define ins insert
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expo(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*int sv[1000000]={0};
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
void sve() {sv[0]=1;sv[1]=1;for(int i=2;i*i<=maxx;i++){if(!sv[i]){for(int j=2*i;j<=maxx;j+=i)sv[j]=1;}}}//0 hai to prime
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[r],mod-2)))%mod; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod-2)))%mod; return res;}*/
int d[100005][3];
using namespace std;
signed main()
{
    int n,k,i,j;
    cin >> n;
    int a[n][3];
    for(i=0 ; i<n ; i++)
    	for(j=0 ; j<3 ; j++)
    		cin >> a[i][j];
    d[0][0] = a[0][0];
    d[0][1] = a[0][1];
    d[0][2] = a[0][2];
    for(i=1 ; i<n; i++)
    {
    	for(j=0 ; j<3 ; j++)
    	{
    		int p=0;
    		for(k=0 ; k<3 ; k++)
    		{
    			if(k!=j)
    				p = max(p , a[i][j] + d[i-1][k]);
    		}
    		d[i][j] = p;
        }
   	}
   	cout << max({d[n-1][0] , d[n-1][1] , d[n-1][2]}) << "\n";
    return 0;
}

Measured memory_bytes: 4864
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a, b,c, d, e, x;
    int  f,h;
    x = 0;
    char c1;
    string s;
//    cin>> a;
//    cin>> s;
//    cin >> b;
//    c1 = s[b-1];
//    for (int i = 0; i< s.length(); i++){
//        if(s[i] ==c1 ){
//            cout << s[i];
//        }
//        else {
//            cout << "*";
//        }
//    }
//    return 0;
    int a1[5];
    f = 0;
    h = 10;
    for (int i = 0; i<5; i++){
        cin>> a1[i];
    }
    for (int i = 0; i< 5; i++){
        if (a1[i] % 10!= 0 && a1[i] % 10 <=h){
            h = a1[i] % 10;
            
            f = i;
            
        }
    }
//    cout << a1[f];
    
    
    
    
    for(int i = 0; i<5; i++){
        if (i == f){
            continue;
        }
        x+=a1[i];
//        cout << x << endl;
        
        if (a1[i] % 10 != 0){
            
            while (x % 10 != 0){
                x++;
            }
        }
    }
//    cout << a1[f]<< endl;
//    cout << x;
    x = x+a1[f];
    cout << x;
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using p = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止

int main(void){
    int a;
    cin >> a;
    cout << a+ a*a+a*a*a << endl;

}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>

/*#### modular_arithmetic */
class modular_arithmetic{
public:
	int mod, range;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	void set_mod(int _mod){mod = _mod;}
	int add(int x,int y){return (x+y)%mod;}
	int sub(int x,int y){return (x-y+mod)%mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int x,int y){
		int r = 1;
		while(1){
			if(y&1)r=mul(r,x);
			if(y>>=1)x=mul(x,x);else
				break;
		}
		return r;
	}
};
/*####*/

modular_arithmetic md;
void upd(int&x,int y){
	x = md.add(x,y);
}

int c[22][22];
int N,M;
int dp[1<<20],dp2[1<<20];
int to[1<<20][20];

int main(){
	scanf("%d%d",&N,&M);
	memset(c,-1,sizeof(c));
	int q;
	for(scanf("%d",&q); q--;){
		int A,B,C;
		scanf("%d%d%d",&A,&B,&C);
		c[A-1][B-1] = C;
	}
	for(int mask=0; mask<(1<<(N-1)); mask++)
		for(int i=0; i<N-1; i++)
			if((mask&(1<<i))==0){
				int t = i;
				for(int j=i+1; j<N-1; j++)
					if(mask&(1<<j)){
						t = j;
						break;
					}
				if(t == i)
					to[mask][i] = mask|(1<<i);
				else
					to[mask][i] = (mask - (1<<t)) | (1<<i);
			}
	int res = 0;
	dp[0] = 1;
	for(int i=0; i<M; i++){
		for(int j=0; j<N-1; j++){
			memset(dp2,0,sizeof(dp2));
			for(int mask = 0, now; mask < (1<<(N-1)); mask++)
				if(now = dp[mask]){
					for(int k=0; k<2; k++)if(k == c[i][j] || c[i][j] == -1){
						if((bool)k == (bool)(mask&(1<<j))){
							upd(dp2[mask], now);
						}else
						if(k == 1 && (mask&(1<<j)) == 0){
							upd(dp2[to[mask][j]], now);
						}
					}
				}
			memcpy(dp,dp2,sizeof(dp));
		}
	}
	for(int mask = 0; mask < (1<<(N-1)); mask++)
		upd(res, dp2[mask]);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 51456
/*
 * Ring.c
 *
 *  Created on: 2015/02/13
 */
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

int main(void){
	char R[256],S[256];
	scanf("%s\n",R);scanf("%s\n",S);

	strncat(R,R,strlen(S));

	if(strstr(R,S)) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>


using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

int main()
{
	int n; cin >> n;
	int x = n;
	int fx = 0;
	while (x > 0)
	{
		fx += x % 10;
		x /= 10;
	}
	if (n%fx == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let n = get_string().parse::<u64>().unwrap();
    let a = get_string().parse::<u64>().unwrap();
    println!("{}", n * n - a);
}

fn get_string() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    line.trim().to_string()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a;
    cin >> a;
    
    cout << 48-a << endl;
    

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		HashSet<Integer> aArraySet = new HashSet<Integer>();

		for(int i=0; i<N; i++){
			int a = Integer.parseInt(sc.next());
			if (aArraySet.contains(a)){
				aArraySet.remove(a);
			}else {
				aArraySet.add(a);
			}
		}
		System.out.println(aArraySet.size());
    }
}

Measured memory_bytes: 50828
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli mod = 1e9+7;
lli n; 
vector<lli> a;
lli fact_m[100002];

lli fact(lli x) {
  if (fact_m[x] > 0) return fact_m[x];
  return fact_m[x] = x * fact(x-1) % mod;
}

lli pow(lli x, lli p) {
  lli y = 1, a = x;
  for (; p>0; p>>=1) {
    if (p&1) y = y * a % mod;
    a = a * a % mod;
  }
  return y;
}

lli inv(lli x) {
  return pow(x, mod-2);
}

lli comb(lli n, lli r) {
  return fact(n) * inv(fact(r)) % mod * inv(fact(n-r)) % mod;
}

int main() {
  fill(begin(fact_m), end(fact_m), 0);
  fact_m[0] = 1;

  cin >> n; 
  lli m = n + 1;
  read_n(a, m);
  lli pl=0, pr=0;
  vector<lli> pos(m+1, -1);
  for (lli i=0; i<m; ++i) {
    if (pos[a[i]] >= 0) {
      pl = pos[a[i]];
      pr = i;
      break;
    } else {
      pos[a[i]] = i;
    }
  }
  lli nlr = pl + m - 1 - pr;
  for (lli s=1; s<=m; ++s) {
    lli diff = nlr >= s-1 ? comb(nlr, s-1) : 0;
    lli ans = (comb(m, s) + mod - diff) % mod;
     // cout << s << ' ' << diff << ' ' << comb(m, s) << endl;
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 5120
import java.io.*;
import java.util.*;
class Main {
	public static void main (String[] args) {
		//System.out.println("GfG!");
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k = sc.nextInt();
		int a[]=new int[n+1];
		a[0]=0;
		for(int i=1;i<=n;i++)
		a[i]=sc.nextInt();
	    int dp[]=new int[n+1];
	    dp[0]=0;
	    dp[1]=0;
	    if(k+1>=n)
	    System.out.println(Math.abs(a[n]-a[1]));
	    else{
	    for(int i=2;i<=(1+k);i++){
	        dp[i]=Math.abs(a[i]-a[1]);
	    }
	    dp[2]=Math.abs(a[2]-a[1]);
	    for(int i=k+2;i<=n;i++){
	        int c = k;
	        for(int j=1;j<=c;j++){
	            if(j==1){
	                dp[i]=dp[i-j]+Math.abs(a[i]-a[i-j]);
	                continue;
	            }
	            dp[i]=Math.min(dp[i-j]+Math.abs(a[i]-a[i-j]),dp[i]);
	            
	        }
	    }
	    	    System.out.println(dp[n]);}
	}
}

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

using namespace std;

using ll = long long;

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

    int a, b;

    cin >> a >> b;
    if (a <= b) cout << a << endl;
    else cout << a - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    int cost=0,minXY;
    minXY=min(X,Y);
    //min(A,B)枚について
    if(A+B>2*C)cost+=2*C*minXY;
    else cost+=(A+B)*minXY;
    if(X==Y){cout<<cost<<endl; return 0;}
    //残りについて
    if(X>Y){
        if(A>2*C) cost+=(X-minXY)*2*C;
        else cost+=(X-minXY)*A;
    }
    else{
        if(B>2*C) cost+=(Y-minXY)*2*C;
        else cost+=(Y-minXY)*B;
    }
    cout<<cost<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n;
  cin >> s;
  REP(i,s.size()){
    cout << char ( (s[i]-'A'+n)%26+'A' );
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL a,b;
    cin>>a>>b;
    if((a + b) % 2 == 0){
        PUTS((a + b) / 2);
    }
    else{
        PUTS("IMPOSSIBLE");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n, k;
	cin >> n >> k;
	int ans = n;
	vi cnt(n + 1);
	for(int i = 0; i < k; i++){
		int d;
		cin >> d;
		while(d--){
			int x;
			cin >> x;
			if(cnt[x] == 0)
				ans--;
			cnt[x]++;
		}
	}
	cout << ans << endl;
}

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

int main(){
    int a,b,flag=1,n=0;
    char op;
    std::vector<int> ans;

    while(flag){
        cin >> a >> op >> b;
        switch(op){
            case '+':
                ans.push_back(a+b);
                n++;
                break;
            case '-':
                ans.push_back(a-b);
                n++;
                break;
            case '*':
                ans.push_back(a*b);
                n++;
                break;
            case '/':
                ans.push_back(a/b);
                n++;
                break;
            case '?':
                flag = 0;
                break;
            default:
                break;
        }
    }
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
}


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

long long int gcd(long long int a, long long int b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    
    if (b == 0) return a;
    else return gcd(b, a % b);
}

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

    for(int i=0; i<t; i++){
        long long int a, b, c, d;
        cin >> a >> b >> c >> d;

        if(d < b){ cout << "No" << endl; continue; }
        if(a < b){ cout << "No" << endl; continue; }
        if(c >= b){ cout << "Yes" << endl; continue; }

        long long int x = gcd(b,d);
        long long int y = a % x + (b - x);
        if(y > c)  cout << "No"  << endl;
        if(y <= c) cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3576
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
char str[max_n];
void reads(string& s){scanf(" %s",str);s=str;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int a,b,h,m;
int main(){
    scanf("%d%d%d%d",&a,&b,&h,&m);
    double x=(h*60+m)*1.0/(12*60)*2*PI;
    double y=m*1.0/60*2*PI;
    x=fabs(x-y);
    double c=sqrt(a*a+b*b-2*a*b*cos(x));
    printf("%.9f\n",c);
    return 0;
}

Measured memory_bytes: 4204
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <iomanip>


int main()
{
	long long sx, sy, tx, ty;

	std::cin >> sx >> sy >> tx >> ty;

	std::string ans;

	bool mx, my;

	if (sx < tx) {
		mx = true;
	} else {
		tx *= -1;
		mx = false;
	}

	if (sy < ty) {
		my = true;
	} else {
		ty *= -1;
		my = false;
	}

	for (size_t i = 0; i < tx - sx; i++) {
		ans += "R";
	}

	for (size_t i = 0; i < ty - sy; i++) {
		ans += "U";
	}

	for (size_t i = 0; i < tx - sx; i++) {
		ans += "L";
	}

	for (size_t i = 0; i < ty - sy; i++) {
		ans += "D";
	}

	ans += "D";
	for (size_t i = 0; i <= tx - sx; i++) {
		ans += "R";
	}

	for (size_t i = 0; i <= ty - sy; i++) {
		ans += "U";
	}
	ans += "LU";
	for (size_t i = 0; i <= tx - sx; i++) {
		ans += "L";
	}

	for (size_t i = 0; i <= ty - sy; i++) {
		ans += "D";
	}

	ans += "R";

	for (size_t i = 0; i < ans.length(); i++) {
		if (ans[i] == 'D' || ans[i] == 'U') {
			if (my) {
				std::cout << ans[i];
			} else {
				if (ans[i] == 'D') {
					std::cout << 'U';
				} else {
					std::cout << 'D';
				}
			}
		} else {
			if (mx) {
				std::cout << ans[i];
			} else {
				if (ans[i] == 'R') {
					std::cout << 'L';
				} else {
					std::cout << 'R';
				}
			}
		}
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		long x = fs.nextLong();
		long rishi;
		long year = 0;
		long money = 100;
		while (money < x) {
			rishi = money / 100;
			int temp;
			if (x - money > 100) {
				if (money >= 10000) {
					money += rishi;
					year++;
				} else {
					temp = (int) (Math.max(Math.ceil((100 - money % 100) / rishi), 1));
					money += rishi * temp;
					year += temp;
				}
			} else {
				temp = (int) (Math.max(Math.ceil((x - money) / rishi), 1));
				money += rishi * temp;
				year += temp;
			}
		}
		System.out.println(year);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

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

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

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

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

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 32568
#line 1 "main.cpp"
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#line 1 "/home/ecasdqina/cpcpp/libs/library_cpp/data_structure/union_find.hpp"



#line 6 "/home/ecasdqina/cpcpp/libs/library_cpp/data_structure/union_find.hpp"

class union_find {
public:
	using size_type = std::int_fast32_t;
	using container = std::vector<size_type>;
	
	container data;
	size_type comp_cnt;

private:
	const size_type find(size_type k) {
		if(data[k] < 0) return k;
		return data[k] = find(data[k]);
	}

public:
	union_find() = default;
	union_find(const union_find &) = default;
	union_find(union_find&&) = default;

	union_find & operator=(const union_find &) = default;
	union_find & operator=(union_find &&) = default;

	union_find(size_type N): data(N, -1), comp_cnt(N) {}

	bool unite(size_type x, size_type y) {
		x = find(x); y = find(y);
		if(x == y) return false;
		if(data[x] > data[y]) std::swap(x, y);
		
		data[x] += data[y];
		data[y] = x;
		comp_cnt--;
		return true;
	}
	
	bool is_united(size_type x, size_type y) { return find(x) == find(y); }
	size_type size() const { return data.size(); }
	size_type size(size_type k) { return -data[find(k)]; }
	size_type comp(size_type k) { return find(k); };
	size_type count() const { return comp_cnt; }
	size_type operator[](size_type k) { return find(k); }
	
	void swap(union_find & r) {
		data.swap(r.data);
		std::swap(comp_cnt, r.comp_cnt);
	}
};


#line 18 "main.cpp"

int main() {
	int n; scanf("%d", &n); std::vector<int> x(n), y(n);
	for(int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]);

	std::vector<std::pair<int, int>> vec;
	for(int i = 0; i < n; i++) vec.push_back({x[i], i});
	sort(begin(vec), end(vec), std::greater<>());

	union_find uf(n);
	std::set<std::pair<int, int>> st;
	for(auto [v, i]: vec) {
		auto it = st.upper_bound({y[i], 1 << 30});

		int max = i;
		while(it != st.end()) {
			uf.unite(i, it->second);
			max = it->second;
			it = st.erase(it);
		}

		st.insert({y[max], max});
	}

	for(int i = 0; i < n; i++) printf("%d\n", uf.size(i));
	return 0;
}


Measured memory_bytes: 8148
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007  
long modPow(long a, long x, long p) {
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

long modInverse(long a, long p) {
    return modPow(a, p-2, p);
}
long modBinomial(long n, long k, long p) {
    long numerator = 1;
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }
    long denominator = 1;
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }
    return ( numerator* modInverse(denominator,p) ) % p;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a,b;
  cin >> a >> b;
  int countup = 0;
  int countdown = 0;
  if(a<b){
    swap(a,b);
  }
  assert(a>=b);
  int mini = max(a,b)-min(a,b);
  countdown += mini;
  a -= mini*2;
  b -= mini;
  if(b<0||b%3!=0){
    cout << 0;
    return 0;
  }
  countup += a/3;
  countdown += b/3;
  int res = 1;
  cout << modBinomial(countup+countdown,countup,mod);
}

Measured memory_bytes: 256
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse::<usize>().unwrap();
    let mut b: Vec<usize> = (&mut iter).take(n).map(|x| x.parse::<usize>().unwrap() - 1).collect();
    
    let mut ret = vec![];
    let mut no_ans = false;
    while !b.is_empty() {
        let mut t = None;
        for i in 0..b.len() {
            let j = b.len()-1-i;
            if b[j] == j {
                t = Some(j);
                break;
            }
        }
        if let Some(v) = t {
            ret.push(v);
            b.remove(v);
        } else {
            no_ans = true;
            break;
        }
    }
    if no_ans {
        println!("-1");
    } else {
        ret = ret.iter().map(|x| *x + 1).collect();
        ret.reverse();
        for r in ret {
            println!("{}", r);
        }
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define re register
int f[3010][3010];
const int mod=998244353;
int main()
{
	re int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	f[a][b]=1;
	for(re int i=a+1;i<=c;i++)
	{
		re int nw=0;
		for(re int j=b;j<=d;j++)
		{
			f[i][j]=(nw+1ll*f[i-1][j]*j)%mod;
			nw=(1ll*(nw+f[i-1][j])*(i-1))%mod;
		}
	}
	re int ans=0;
	for(re int j=b;j<=d;j++)
	{
		ans=(1ll*ans*c+f[c][j])%mod;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 38948
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] abx=cin.ArrayInt(3,0);
        int ab=abx[0]+abx[1];
        int a=abx[0];
        int x=abx[2];
      string ans="YES";
       if(ab<x||a>x)ans="NO";
      Console.WriteLine(ans);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int gcd(int a,int b){
    int t;
    while(b>0){
        t=b;
        b=a%b;
        a=t;
    }
    return a;
}

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

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,r,x,y,z,max1=0,ans=0;
    string s,t,u;
    cin>>k>>x;
    for(ll i=-1000000;i<1000000;i++){
        if(i>=x-k+1&&i<=x+k-1)cout<<i<<" "<<endl;
    }
    
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,m;
  cin>>n>>m;
  if(n>m){
    rep(i,n){
      cout<<m;
    }
  }
  else if(m>n){
    rep(i,m){
      cout<<n;
    }
  }
  else{
    rep(i,n){
      cout<<n;
    }
  }
}


Measured memory_bytes: 256
use proconio::{fastout, input};
use std::cmp;

fn accumurate(l: Vec<i64>) -> Vec<i64> {
    let n = l.len();
    let mut ret = vec![0; n];
    ret[0] = l[0];
    for i in 1..n {
        ret[i] = ret[i - 1] + l[i];
    }

    return ret;
}

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        p: [usize; n],
        c: [i64; n],
    }
    let inf = 1 << 32;
    let mut ans = -inf;
    let mut used = vec![false; n];

    for i in 0..n {
        if used[i] {
            continue;
        } else {
            used[i] = true;
        }

        let mut c_loop: Vec<i64> = Vec::new();
        let mut j = p[i] - 1;
        c_loop.push(c[j]);

        while j != i {
            used[j] = true;
            j = p[j] - 1;
            c_loop.push(c[j]);
        }

        let n_loop = c_loop.len();
        c_loop.append(&mut c_loop.to_vec());
        let cs_loop = accumurate(c_loop);
        let tot_loop = cs_loop[n_loop - 1];

        let _jmax = cmp::min(k, n_loop);

        for _i in 0..n_loop {
            for _j in 1..(_jmax + 1) {
                let mut _tmp = cs_loop[_i + _j] - cs_loop[_i];

                if tot_loop > 0 && k > _j {
                    _tmp += (((k - _j) / n_loop) as i64) * tot_loop;
                }

                if ans < _tmp {
                    ans = _tmp;
                }
            }
        }
    }

    print!("{}", ans);
}


Measured memory_bytes: 2528
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main() {
	int N;

	while(cin >> N, N) {
		int rx = 10, ry = 10;
		vvi field(21, vi(21, 0));

		int x, y;
		REP(i, N) {
			cin >> x >> y;
			field[x][y] = 1;
		}

		int M;
		cin >> M;
		
		char c;
		int t;
		REP(i, M) {
			cin >> c >> t;
			if(c == 'N') {
				REP(j, t) {
					ry++;
					field[rx][ry] = 0;
				}
			} else if(c == 'E') {
				REP(j, t) {
					rx++;
					field[rx][ry] = 0;
				}
			} else if(c == 'W') {
				REP(j, t) {
					rx--;
					field[rx][ry] = 0;
				}
			} else {
				REP(j, t) {
					ry--;
					field[rx][ry] = 0;
				}
			}
		}

		FOR(i, 0, 20) {
			FOR(j, 0, 20) {
				if(field[i][j] == 1) {
					cout << "No" << endl;
					goto ne;
				} else {

				}
			}
		}

		cout << "Yes" << endl;

		ne:;
	}

	return 0;
}

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

long long N, W, w[109], v[109], maxn = 0, minx = (1LL << 60);
vector<long long>V[4];

int main() {
	cin >> N >> W;
	for (int i = 1; i <= N; i++) {
		cin >> w[i] >> v[i]; minx = min(minx, w[i]);
	}
	for (int i = 1; i <= N; i++) V[w[i] - minx].push_back(v[i]);
	for (int i = 0; i < 4; i++) sort(V[i].begin(), V[i].end(), greater<long long>());
	long long S0 = 0;
	for (int i = 0; i <= V[0].size(); i++) {
		long long S1 = 0;
		for (int j = 0; j <= V[1].size(); j++) {
			long long S2 = 0;
			for (int k = 0; k <= V[2].size(); k++) {
				long long S3 = 0;
				for (int l = 0; l <= V[3].size(); l++) {
					long long WW = (minx + 0LL)*i + (minx + 1LL)*j + (minx + 2LL)*k + (minx + 3LL)*l;
					if (WW <= W) maxn = max(maxn, S0 + S1 + S2 + S3);
					if (l != V[3].size()) S3 += V[3][l];
				}
				if (k != V[2].size()) S2 += V[2][k];
			}
			if (j != V[1].size()) S1 += V[1][j];
		}
		if (i != V[0].size()) S0 += V[0][i];
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main(void)
{
  int N;
  std::cin >> N;
  char march[] = {'M', 'A', 'R', 'C', 'H'};
  long long marchNum[5] = {0};
  for(int i = 0; i < N; i++){
    std::string str;
    std::cin >> str;
    for(int j = 0; j < 5; j++){
      if(str[0] == march[j])  marchNum[j]++;
    }
  }
  long long comNum = 0;
  for(int i = 0; i < 3; i++){
    for(int j = i + 1; j < 4; j++){
      for(int k = j + 1; k < 5; k++){
        comNum += marchNum[i] * marchNum[j] * marchNum[k];
      }
    }
  }

  std::cout << comNum << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,ll>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 2*1e5;
const int mod = 1e9+7;

int main() {
    int n, t; cin >> n >> t;
    vint T(n);
    rep(i,n) cin >> T[i];
    ll sum = 0;
    rep(i,n-1) {
        sum += min(t,T[i+1]-T[i]);
    }
    sum += t;
    cout << sum << endl;
}

Measured memory_bytes: 1024
# A, Multiplication 1
# A * Bを求めてください。
# 1 < A < 100
# 1 < B < 100
# 入力はすべて整数である。

# スペース区切りの入力を整数として受け取れるおまじない。
a,b = map(int, (input().split()))

print(a * b)

Measured memory_bytes: 9152
#include <stdio.h>
int main(void){
    // Your code here!
    int a;
    int b;
    scanf("%d %d", &a, &b);
    
    if(a>b){
        printf("a > b\n");
    }
    else if(a<b){
        printf("a < b\n");
    }
    else{
        printf("a == b\n");
    }
}



Measured memory_bytes: 2124
#include<iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    long long sum(0);
    for(int i(1);i<=n;i++){
        if(i%3 != 0 && i%5 != 0)sum += i;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3160
const Main = (input) => {
  const N = parseInt(input.trim())

  const NumArray = [...Array(N).keys()].map(n => n += 1)

  let result = 0

  NumArray.forEach((elem, i) => {
    if ((elem % 3 === 0 || elem % 5 === 0) === false) {
      result += parseInt(elem)
    }
  })

  console.log(result)
  return result
}


Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 96708
#include<stdio.h>

int main(void){
   int i,min,cnt1 = 0, cnt2 = 0;
   char n[100000];
   
   scanf("%s", n);
    
   for(i = 0; n[i]!='\0'; i++){ 
        if((i % 2 == 0) && (n[i] == '1') || (i % 2 == 1) && (n[i] == '0')) cnt1++;       
   }
       
   for(i = 0; n[i]!='\0'; i++){ 
         if((i % 2 == 0) && (n[i] == '0') || (i % 2 == 1) && (n[i] == '1')) cnt2++;
         
   }
   
   if(cnt1 < cnt2) min = cnt1;
    else min = cnt2;
           
   printf("%d", min);
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int prime[1000000],N;
bool isprime[1000001];

int sieve(int n){
	int p=0;
	for(int i=0;i<=n;i++)isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(int i=0;i<=n;i++){
		if(isprime[i]){
			prime[p++]=i;
			for(int j=i*2;j<=n;j+=i)isprime[j]=false;
		}
	}
	return p;
}

int main(){
	sieve(10000);
	while(cin>>N){
		int ans=0;
		for(int i=1;i<=N;i++)if(isprime[i]&&isprime[N+1-i])ans++;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
s = sum(B)

for i in range (0,N-1):
  if A[i] + 1 == A[i+1]:
    s = s + C[A[i]-1]

print(s)

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll R, G;
    cin >> R >> G;

    cout << G + (G - R) << endl;
    
    return 0;
}

Measured memory_bytes: 3540