akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int base_map[10][10],house_index[10][10];
int H,W,finish_state;
int church_row,church_col;
int POW[24],diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1)return true;
	else{
		return false;
	}
}


int ans;

void recursive(int state,int row,int col){

	if(state == finish_state){
		if(row == church_row || col == church_col){
			ans++;
		}
		return;
	}

	int next_row,next_col,next_state;

	for(int i = 0; i < 4; i++){
		next_row = row+diff_row[i];
		next_col = col+diff_col[i];

		while(rangeCheck(next_row,next_col) == true &&
			((base_map[next_row][next_col] != 1) || ((state & (1 << house_index[next_row][next_col])) != 0))){
			next_row += diff_row[i];
			next_col += diff_col[i];
		}

		if(!rangeCheck(next_row,next_col))continue;

		next_state = state+POW[house_index[next_row][next_col]];
		recursive(next_state,next_row,next_col);
	}
}


void func(){

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			house_index[row][col] = -1;
		}
	}

	int index = 0;
	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			scanf("%d",&base_map[row][col]);
			if(base_map[row][col] == 1){
				house_index[row][col] = index++;
			}else if(base_map[row][col] == 2){
				church_row = row;
				church_col = col;
			}
		}
	}

	ans = 0,finish_state = POW[index]-1;

	recursive(0,church_row,church_col);

	printf("%d\n",ans);
}

int main(){

	for(int i = 0; i < 24; i++)POW[i] = pow(2,i);

	while(true){
		scanf("%d %d",&W,&H);
		if(H == 0 && W == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int n,a[1 << 18],ma1[1 << 18],ma2[1 << 18];

signed main(){
	cin >> n;
	for(int i = 0;i < (1 << n);i++){
		cin >> a[i];
		ma1[i] = a[i];
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < (1 << n);j++){
			if(((j >> i) & 1)){
				int b[4] = {ma1[j],ma2[j],ma1[j ^ (1 << i)],ma2[j ^ (1 << i)]};
				sort(b,b + 4,greater<int>());
				ma1[j] = b[0];
				ma2[j] = b[1];
			}
		}
	}
	int ma = 0;
	for(int i = 1;i < (1 << n);i++){
		chmax(ma,ma1[i] + ma2[i]);
		cout << ma << endl;
	}
	return 0;
}

Measured memory_bytes: 9216
mod = 10**9+7
L = input()
l = len(L)
DP = [[0,0] for _ in range(l)] #上から決めていく、0は一致、1は小さいことが確定
DP[0][0] = 2
DP[0][1] = 1
for i in range(1,l):
    if L[i] == '0':
        DP[i][0] = DP[i-1][0]
        DP[i][1] = DP[i-1][1]*3 % mod
    else:
        DP[i][0] = DP[i-1][0]*2 % mod
        DP[i][1] = (DP[i-1][0]+DP[i-1][1]*3) % mod
print((DP[l-1][0]+DP[l-1][1]) % mod)

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

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;

    auto get = [](int a,int b)->int{
        return max(to_string(a).size(), to_string(b).size());
    };

    int mn = LLONG_MAX;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            mn = min(mn, get(i, n/i));
        }
    }
    cout << mn << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<climits>
#include <cmath>
#include <cstring>
using namespace std;
//#define unsignedlonglongint int
int main(){
 long long int i,j,k,l,n;
cin>>n>>k;
long long int a[n+1],b[n+1];
b[1]=0;
for(i=1;i<=n;i++)
	cin>>a[i];
//cout<<b[5];
b[2]=abs(a[1]-a[2]);
for(i=3;i<n+1;i++){
	b[i]=690000000000;

      for(j=1;j<i&&j<=k;j++){
      	//if(i>j)
     // cout<<b[i-j]+abs(a[i]-a[i-j])<<" " ;
	b[i]=min(b[i],b[i-j]+abs(a[i]-a[i-j]));
}
//cout<<b[i]<<" ";
}
//cout<<b[1]<<" "<<b[2];
cout<<b[n];
}

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

const long long SIZE = 100030, MOD = 1000000007;

int main() {
  long long n, m, factorial[SIZE], ifactorial[SIZE], inv[SIZE], result = 1;
  cin >> n >> m;
  inv[1] = 1;
  factorial[0] = 1;
  factorial[1] = 1;
  ifactorial[0] = 1;
  ifactorial[1] = 1;
  for (long long i = 2; i < SIZE; i++) {
      inv[i] = (-MOD / i + MOD) * inv[MOD % i] % MOD;
      factorial[i] = factorial[i - 1] * i % MOD;
      ifactorial[i] = ifactorial[i - 1] * inv[i] % MOD;
  }
  auto C = [&](long long n, long long k) {
    return factorial[n] * ifactorial[k] % MOD * ifactorial[n - k] % MOD;
  };
  vector<long long> count;
  for (long long i = 2; i * i <= m; i++) {
    if (m % i == 0) {
      long long current = 0;
      do {
        current++;
        m /= i;
      } while (m % i == 0);
      count.emplace_back(current);
    }
  }
  if (m > 1) {
    count.emplace_back(1);
  }
  for (auto i : count) {
    result = result * C(i + n - 1, i) % MOD;
  }
  cout << result;
  return 0;
}

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

int main() {
  string S;
  cin>>S;
  string a=S.substr(0,4);
  string b=S.substr(5,2);
  if(b=="04")
    cout<<"Heisei"<<endl;
  else if(b=="03")
    cout<<"Heisei"<<endl;
  else if(b=="01")
    cout<<"Heisei"<<endl;
  else if(b=="02")
    cout<<"Heisei"<<endl;
  else{
    cout<<"TBD"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String n[] = sc.next().split("");
    if (n[0].equals(n[1]) && n[1].equals(n[2])){
      System.out.println("Yes");
    }else if (n[1].equals(n[2]) && n[2].equals(n[3])){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35884
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    vector<int> a={0,2,0,1,0,1,0,0,1,0,1,0};
    int x,y; cin>>x>>y;
    x--; y--;
    if(a[x]==a[y]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3576
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long INF = 1L<<59;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    auto G = new int[][](N);
    foreach (i; 0..N-1) {
        auto s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1]-1;
        G[s[1]-1] ~= s[0]-1;
    }

    auto children = new int[](N);
    auto sub = new int[](N);

    int dfs1(int n, int p) {
        sub[n] = 1;
        foreach (m; G[n]) if (m != p) sub[n] += dfs1(m, n), children[n] += 1;
        return sub[n];
    }

    dfs1(0, -1);

    /*
      dp1[i][j]: 頂点iを根とする部分木で、辺をj本切っており、iを含む連結成分にコンピュータがないときの最小コスト
      dp2[i][j]: 頂点iを根とする部分木で、辺をj本切っており、iを含む連結成分にコンピュータがあるときの最小コスト
     */
    auto dp1 = new long[][][](N);
    auto dp2 = new long[][][](N);
    foreach (i; 0..N) {
        dp1[i] = new long[][](children[i]+1, sub[i]+1);
        dp2[i] = new long[][](children[i]+1, sub[i]+1);
        foreach (j; 0..children[i]+1) dp1[i][j][] = dp2[i][j][] = INF;
    }

    int dfs(int n, int p) {
        if (A[n] > 0) {
            dp1[n][0][0] = A[n];
            dp2[n][0][0] = A[n];
        } else {
            dp2[n][0][0] = A[n];
        }

        int s = 1;
        int c = 0;

        foreach (m; G[n]) {
            if (m == p) continue;
            int mc = children[m];
            int x = dfs(m, n);
            foreach (i; 0..s) {
                foreach (j; 0..sub[m]) {
                    // 切る
                    if (dp1[m][mc][j] != INF || dp2[m][mc][j] < 0) {
                        dp1[n][c+1][i+j+1] = min(dp1[n][c+1][i+j+1], dp1[n][c][i]);
                        dp2[n][c+1][i+j+1] = min(dp2[n][c+1][i+j+1], dp2[n][c][i]);
                    }
                    // 切らない
                    dp1[n][c+1][i+j] = min(dp1[n][c+1][i+j], dp1[n][c][i] + dp1[m][mc][j]);
                    dp2[n][c+1][i+j] = min(dp2[n][c+1][i+j], dp2[n][c][i] + dp1[m][mc][j], dp2[n][c][i] + dp2[m][mc][j], dp1[n][c][i] + dp2[m][mc][j]);
                }
            }
            s += x;
            c += 1;
        }

        return s;
    }

    dfs(0, -1);

    int ans = 1 << 29;
    foreach (i; 0..N) if (dp1[0][children[0]][i] != INF) ans = min(ans, i);
    foreach (i; 0..N) if (dp2[0][children[0]][i] < 0) ans = min(ans, i);
    ans.writeln;
}


Measured memory_bytes: 404348
#include <stdio.h>

int main(void){
   int rngN,i,L,min,minP,PieTaste=0;
   scanf("%d%d",&rngN,&L);
   int rngTaste[rngN],rngTaste_[rngN];

   for(i=0;i<rngN;i++){
      rngTaste[i] = L +i;
      rngTaste_[i]=rngTaste[i];
      if(rngTaste_[i]<0) rngTaste_[i]*=-1;
   }

   min=rngTaste_[0];
   for(i=1;i<rngN;i++)
      if(min>rngTaste_[i]){ min=rngTaste_[i]; minP=i;}

   for(i=0;i<rngN;i++)
      if(i!=minP) PieTaste+=rngTaste[i];

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

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

namespace AtCoder.Abc
{
    class A_155_Poor
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            string result = "";

            for (int i = 0; i < inputLongArray.Length - 1; i++)
            {
                for (int j = i + 1; j < inputLongArray.Length; j++)
                {
                    if (inputLongArray[i] == inputLongArray[j])
                    {
                        if (inputLongArray[0] == inputLongArray[1] && inputLongArray[1] == inputLongArray[2])
                        {
                            result = "No";
                            goto EXITLOOP; 
                        }
                        else
                        {
                            result = "Yes";
                            goto EXITLOOP;
                        }
                    }
                    else
                    {
                        result = "No";
                    }
                }
                
            }
            EXITLOOP:;
            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string S;
	cin >>S;
	Rev(S);
	vector<int> NN(S.size()+1, 0);
	Rep0(i, S.size())
		NN.at(i)=S.at(i)-'0';
	int N=NN.size();
	vector<vector<int>> DP(N, vector<int> (2, 0));
	DP.at(0).at(0)=NN.at(0);
	DP.at(0).at(1)=10-NN.at(0);
	for (int i=1; i<N; i++) {
		DP.at(i).at(0)=min(DP.at(i-1).at(0)+NN.at(i), DP.at(i-1).at(1)+1+NN.at(i));
		DP.at(i).at(1)=min(DP.at(i-1).at(0)+10-NN.at(i), DP.at(i-1).at(1)+9-NN.at(i));
	}
	int SS=min(DP.at(N-1).at(0), DP.at(N-1).at(1));
	cout <<SS <<endl;
	return 0;
}



Measured memory_bytes: 59780
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		
		StringBuilder sb = new StringBuilder();
		int i = A;
		for(;i < A+K && i <= B;++i) {
			sb.append(i);
			sb.append('\n');
		}
		i = A+K-1 >= B-K+1 ? A+K : B-K+1;
		for(;i <= B;++i) {
			sb.append(i);
			sb.append('\n');
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <vector>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	int big = max(a, b);
	int small = min(a, b);
	ll ans = big;
	while (1)
	{
		if (ans % small)
			ans += big;
		else
			break;
	}
	cout << ans;
	system("pause>0");
	return 0;
}


Measured memory_bytes: 504
#include <stdio.h>

#define MAX 100

int size[MAX], hval[MAX], roll[MAX][MAX];
void GVE(int c, int v);

int main(){
  int i, j, n, c;

  scanf("%d", &n);
  for(i = 1; i <= n; i++){
    hval[i] = 10000;
    for(j = 1; j <= n; j++){
      roll[i][j] = 0;
    }
  }
  for (i = 1; i <= n; i++){
    scanf("%d", &c);
    scanf("%d", &size[c]);
    for(j = 1; j <= size[c]; j++){
      scanf("%d", &roll[c][j]);
    }
  }

  GVE(1, 0);

  for(i = 1; i <= n; i++){
    if(hval[i] == 10000){
      hval[i] = -1;
    }
    printf("%d %d\n", i, hval[i]);
  }
  return 0;
}

void GVE(int c, int v){
  int i;
  hval[c] = v;
  for (i = 1; i <= size[c]; i++){
    if (hval[roll[c][i]] > v){
      GVE(roll[c][i], v + 1);
    }
  }
}

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

int main() {
	int a,b;
	char op;
	for(int i=0;;i++){
		cin>>a>>op>>b;
		if(op=='?'){break;}
		if(op=='+'){cout<<a+b<<endl;}
		if(op=='-'){cout<<a-b<<endl;}
		if(op=='*'){cout<<a*b<<endl;}
		if(op=='/'){cout<<a/b<<endl;}
	}
	return 0;
}

Measured memory_bytes: 3088
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long N, M;
  scanln(N, M);
  long[] as = readln.split.to!(long[]);

  long x = 1;

  foreach(a; as) {
    long b = a/2;
    x = x/gcd(x, b)*b;
    if (x > M) {
      0.writeln;
      return;
    }
  }
  foreach(a; as) {
    long b = a/2;
    if (x/b%2 == 0) {
      0.writeln;
      return;
    }
  }

  writeln(M.floor(x).ceil(2));
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005;
int a[N],b[N],num[N];
int n,m,k;
struct Node
{
    int voice,text;
} c[N];
int main()
{


    scanf("%d%d%d",&n,&m,&k);

    
    cout<<min(n*m,k)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long N,i,H,M,ans;
    cin>>N;
    M=-1;ans=0;
    for(i=0;i<N;i++){
        cin>>H;
        if(H>M-1){
            ans++;
        }
        M=max(M,H);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def merge(a, left, mid, right):
    INF = int(1e+11)
    l = a[left:mid]
    r = a[mid:right]
    l.append(INF)
    r.append(INF)
    i = 0
    j = 0

    ans = 0

    for k in range(left, right):
        ans += 1
        if l[i] <= r[j]:
            a[k] = l[i]
            i += 1
        else:
            a[k] = r[j]
            j += 1
    
    return ans


def merge_sort(a, left, right):
    ans = 0
    if left + 1 < right:
        mid = (left + right) // 2
        ans += merge_sort(a, left, mid)
        ans += merge_sort(a, mid, right)
        ans += merge(a, left, mid, right)
    return ans


def print_list_split_whitespace(s):
    for x in s[:-1]:
        print(x, end=" ")
    print(s[-1])

n = int(input())
s = [int(x) for x in input().split()]

ans = merge_sort(s, 0, len(s))

print_list_split_whitespace(s)
print(ans)


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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
#define MN 200005
lg ans=0;
lg a[MN],b[MN];
int l,n;
void g1(){
	lg res=0;
	int l=1,r=n;
	for(int i=1;i<=n&&l<=r;++i){
		if(i&1)res+=a[l]*2,++l;
		else res+=b[r]*2,--r;
	}
	if(n&1)res-=a[r];else res-=b[l];
	ans=max(ans,res);
	//cerr<<res<<"@"<<ans<<endl;
	//cerr<<l<<' '<<endl;
	int be=1;
	if(!(n&1)){
		cerr<<"???"<<endl;
		++be;
		res-=a[1]*2;
		res-=b[l];res+=a[l];++l;
	} 
	ans=max(ans,res);
	//cerr<<res<<"@"<<ans<<endl;
	//cerr<<l<<' '<<be<<endl;
	for(int i=be;i<=n;i+=2){
		assert(i<l);
		res-=a[i]*2;res+=a[l-1];res-=b[l];
		ans=max(res,ans);
		//cerr<<"@@@"<<i<<' '<<res<<endl;
		if(i+1>n)break;
		res-=a[i+1]*2;
		res-=b[l];res+=a[l];++l;
		ans=max(res,ans);
		//cerr<<"@@@"<<i+1<<' '<<res<<endl;
	}
}
int main(){
	read(l);read(n);
	for(int i=1;i<=n;++i){
		read(a[i]);
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i){
		b[i]=l-a[i];
	}
	g1();
	for(int i=1;i<=n;++i)swap(a[i],b[n-i+1]);
	g1();
	cout<<ans;
	return 0;
}


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

int main(){

    int n;
    cin >> n;

    vector<int> a(n);
    int ans=0;
    rep(i,n){
        cin >> a[i];
        ans+=a[i];
    }

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

    for(int i=0;i<n;i++){
        if(ans%10!=0){
            cout << ans <<endl;
            return 0;
        }else{
            if(a[i]%10!=0){
                ans-=a[i];
            }
        }
    }

    cout << 0 << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;

int main(int, char**) {
	ll n, k;
	cin >> n >> k;
	vector<int> A;
	vector<int> visit(n, -1);
	for (int i=0; i<n; i++) {
		int a; cin >> a;
		a--;
		A.push_back(a);
	}
	ll tour = 0;
	ll roop = 0;
	int now = 0;
	int rstart;
	visit[now] = 0;
	while (true) {
		int next = A[now];
		if (visit[next]==-1) {
			visit[next] = visit[now] + 1;
			now = next;
		} else {
			tour = visit[next];
			roop = visit[now] + 1 - visit[next];
			rstart = next;
			break;
		}
	}
	// check last position
	if (k < tour) {
		int start = 0;
		for (int i=1; i<k+1; i++) {
			start = A[start];
		}
		cout << start + 1 << endl;
		return 0;
	}
	k -= tour;
	k %= roop;
	for (int i=1; i<k+1; i++) {
		rstart = A[rstart];
	}
	cout << rstart + 1 << endl;	
	return 0;
}

Measured memory_bytes: 5112
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll z(ll a){
  if(a<0)return -a;
  return a;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;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;
  }
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(void){
  char s[101];
  scanf("%s",s);
  int l=strlen(s),ans=0;
  FOR(l/2)if(s[i]!=s[l-i-1])ans++;
  PRN(ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int main(){
  int M, N;
  cin >> M >> N;
  vector<vector<char>> C(M + 2, vector<char>(N + 2, '#'));
  for (int i = 1; i <= M; i++){
    for (int j = 1; j <= N; j++){
      cin >> C[i][j];
    }
  }
  vector<vector<pair<int, int>>> P(26);
  for (int i = 1; i <= M; i++){
    for (int j = 1; j <= N; j++){
      if (C[i][j] != '.'){
        P[C[i][j] - 'A'].push_back(make_pair(i, j));
      }
    }
  }
  vector<pair<int, int>> S;
  for (int i = 0; i < 26; i++){
    if (!P[i].empty()){
      int y1 = P[i][0].first;
      int x1 = P[i][0].second;
      int y2 = P[i][1].first;
      int x2 = P[i][1].second;
      if (y1 == y2){
        if (abs(x2 - x1) >= 2){
          S.push_back(make_pair(y1, (x1 + x2) / 2));
        }
      } else if (x1 == x2){
        if (abs(y2 - y1) >= 2){
          S.push_back(make_pair((y1 + y2) / 2, x1));
        }
      } else {
        S.push_back(make_pair(y1, x2));
        S.push_back(make_pair(y2, x1));
      }
    }
  }
  vector<bool> c(26, true);
  for (int i = 0; i < 26; i++){
    if (P[i].empty()){
      c[i] = false;
    }
  }
  int ans = 0;
  for (int i = 0; i < 26; i++){
    int cnt = S.size();
    for (int j = 0; j < cnt; j++){
      if (C[S[j].first][S[j].second] == '.'){
        vector<int> cnt2(26, 0);
        for (int k = 0; k < 4; k++){
          int y = S[j].first;
          int x = S[j].second;
          while (C[y][x] == '.'){
            y += dy[k];
            x += dx[k];
          }
          if (C[y][x] != '#'){
            cnt2[C[y][x] - 'A']++;
          }
        }
        for (int k = 0; k < 26; k++){
          if (cnt2[k] == 2){
            c[k] = false;
            ans += 2;
            for (int l = 0; l < 2; l++){
              C[P[k][l].first][P[k][l].second] = '.';
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3296
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100005],dp[100005];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(abs(a[i-2]-a[i])+dp[i-2],abs(a[i-1]-a[i])+dp[i-1]);
		//cout<<dp[i]<<"\n";
	}
	/*for(int i=0;i<n;i++){
		cout<<dp[i]<<" ";
	}
	cout<<"\n";*/
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<float.h>
#include<cstdio>
#include<vector>
using namespace std;
#define EPS (1e-10)
#define equals(a,b) fabs((a)-(b))<DBL_EPSILON*fmax(1,fmax(fabs(a),fabs(b)))
//点のクラス
class Point{
    public:
        double x,y;
        Point(double x=0,double y=0):x(x),y(y){}

        Point operator + (Point p){return Point(x+p.x,y+p.y);}
        Point operator - (Point p){return Point(x-p.x,y-p.y);}
        Point operator * (double a){return Point(a*x,a*y);}
        Point operator / (double a){return Point(x/a,y/a);}

        double norm(Point p){return p.x*p.x+p.y*p.y;}
        double abs(Point p){return sqrt(norm(p));}    
        bool operator < (const Point &p)const{
            return x!=p.x?x<p.x:y<p.y;
        }
        bool operator == (const Point &p)const{
            return equals(x,p.x)&&equals(y,p.y);
        }
};
typedef Point Vector;
struct Segment{ Point p1,p2; };
typedef Segment Line;
double norm(Vector v){return v.x*v.x+v.y*v.y;} 
double abs(Vector v){return sqrt(norm(v));}    
//円
class Circle{
	public:
		Point c;
		double r;
		Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};
//多角形
typedef vector<Point> Polygon;
//内積
double dot(Vector a,Vector b){ return a.x*b.x+a.y*b.y; }
//外戚
double cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; }
//点の内包
int contains(Polygon g,Point p){
	int n=g.size();
	bool x=false;
	for(int i=0;i<n;i++){
		Point a=g[i]-p;
		Point b=g[(i+1)%n]-p;
	if( abs(cross(a,b))<EPS&&dot(a,b)<EPS)return 1;
    if(a.y>b.y)swap(a,b);
    if(a.y<EPS&&EPS<b.y&&cross(a,b)>EPS)x=!x;
    }
    return (x?2:0);
}   
int main(){
    Polygon g;
    Point p;
    int n;
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>p.x>>p.y;
        g.push_back(p);
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p.x>>p.y;
        cout<<contains(g,p)<<"\n";
    }
    return 0;
}
    



Measured memory_bytes: 3220
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int dp[1010][1010];
int main(){
  int H,W;
  cin >> H >> W;
  vector<string> field(H);
  for(int i=0; i<H; i++){
    cin >> field[i];
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(i+1<H && field[i+1][j]=='.'){
        dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
      }
      if(j+1<W && field[i][j+1]=='.'){
        dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod;
      }
    }
  }
  cout << dp[H-1][W-1] << endl;
  return 0;
}


Measured memory_bytes: 5248
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e17;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)




int main() {
    int n, x, m, mn = 1e9;
    
    cin >> n >> x;
    REP(i, n){
        cin >> m;
        x -= m;
        mn = min(mn, m);
    }
    
    cout << n + x / mn << endl;
}


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

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
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;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

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

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

signed main()
{
    ll a, b, c, d; cin >> a >> b >> c >> d;

    ll l = lcm(c, d);

    ll ans = b - a + 1;
    ans -= b / c - (a-1) / c;
    ans -= b / d - (a-1) / d;
    ans += b / l - (a-1) / l;

    cout << ans << endl;
}


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

using namespace std;

int main()
{
  int N;
  long D;
  cin >> N >> D;
  long X[N],Y[N];
  int ans = 0;
  for(int i = 0;i < N;i++){
    cin >> X[i] >> Y[i];
    if((X[i] * X[i]) + (Y[i] * Y[i]) <= D * D) ans++;
  }

  cout<<ans<<endl;
}

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

#define FOR(i, a, b) for(int i = a; i<b; ++i)
#define FR(a, b) for(int i = a; i>=b;--i)
#define _upgrade cin.tie(0); ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define INF 1e9+2137
#define all(x) (x).begin(), (x).end()

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int, int> iPair;

const int MAX = 1e5+1;
const int M = 1e9+7;


vector<int> tree[MAX];
ll dp[MAX][2];
int n;
void DFS(int node, int pr)
{
    dp[node][1] = dp[node][0] = 1;
    for(auto i : tree[node])
        if(i != pr)
        {
            DFS(i, node);
            dp[node][0] *= (dp[i][0]+dp[i][1])%M;
            dp[node][1] *= dp[i][0];

            dp[node][1] %= M;
            dp[node][0] %= M;
        }
}
int main()
{
    _upgrade;
    cin>>n;
    FOR(i, 0, n-1)
    {
        int a, b;
        cin>>a>>b;
        tree[a].pb(b);
        tree[b].pb(a);
    }

    DFS(1, -1);
    cout<<(dp[1][0]+dp[1][1])%M;
}


Measured memory_bytes: 14208
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <iterator>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
int main(){
  int N,M,X;
  cin >> N >> M >> X;
  map<int,bool> A;
  FOR(i,0,N){
    A[i] = false;
  }
  FOR(i,0,M){
    int n;
    cin >> n;
    A[n] = true;
  }
  int pre = 0,aft = 0;
  FOR(i,0,X){
    if(A[i]) pre++;
  }
  FOR(i,X,N){
    if(A[i]) aft++;
  }
  cout << min(pre,aft) << endl;
  return 0;
}

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

int main() {
 string s;
  cin >> s;
 int result=999;
  int a;
  for(int i=0;i<s.size()-2;i++){
   string sub;
    sub=s.substr(i,3);
   int num = atoi(sub.c_str()); 
   
    a=753-num;
    if(a<0){
    a=-a;
    }  
    if(a<result){
      result=a;
    }
  }
  cout << result <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
using namespace std;
 
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	
	if(b-a==c-b) printf("YES\n");
	else printf("NO\n");
	
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
	const S = input[0]
    var count = 0
	while(S[0] == S[count+1]){
		count++
	}
	const l = [count]
	for(i=1; i < S.length; i++){
		if(S[i] == "R"){
			if(S[i] == S[i-1]){
				l.push(l[i-1]-1)
			}else{
				var count = 0
				while(S[i] == S[i+count+1]){
					count++
				}
				l.push(count)
			}
		}else{
			if(S[i] == S[i-1]){
				l.push(l[l.length-1]-1)
			}else{
				l.push(0)
			}
		}
	}
	var res = new Array(l.length)
    res.fill(0)
	for(i=0; i < l.length; i++){
		pos = l[i] % 2 == 0 ? i+l[i] : S[i] == "R" ? i+l[i]+1 : i+l[i]-1
		res[pos]++
	}
	res = res.join(" ")
	console.log(res)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){

  string s;
  cin >> s;
  int ct[26] = {};

  for(auto x:s)
    ct[x-'a']++;

  string res = "Yes";
  for(auto x:ct){
    if (x % 2 == 1){
      res = "No";
      break;
    }
  }
  cout << res << endl;
  
  return 0;
}

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

const int MOD=1e9+7;
const int MAX=201010;

ll fact[MAX], rfact[MAX];

ll mod_pow(ll x, ll n, ll mod) {
    ll a = 1LL;
    while (n) {
        if (n%2) a = ((a%mod)*(x%mod))%mod;
        x = ((x%mod)*(x%mod))%mod;
        n /= 2LL;
    }
    return a;
}

ll mod_inverse(ll a, ll m) {
    return mod_pow(a, m-2, m);
}

ll ncr(int n, int r) {
    return fact[n] * rfact[r] % MOD * rfact[n-r] % MOD;
}

int main() {
    fact[0] = rfact[0] = 1;
    for (int i=1; i<MAX; ++i) {
        fact[i] = (fact[i-1] * i) % MOD;
        rfact[i] = mod_inverse(fact[i], MOD);
    }

    int H, W, A, B;
    cin >> H >> W >> A >> B;

    ll ans=0;
    for (int i=B+1; i<=W; ++i) {
        int h = H-A-1, w = i-1;
        ll t = ncr(h+w, h);
        h = A-1, w = W-i;
        t *= ncr(h+w, w);
        ans += t%MOD;
    }

    cout << ans%MOD << endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cstring>
#define nt(x) (x+h)
namespace Hao_Nan_A___Wo_Bu_Hui_A___Wo_Hao_Ruo_A
{
	const int N=101000,M=510;
	int ind[M],outd[M],q[N];
	int n,h,e;
	int ask(int p){return p==q[p]?p:q[p]=ask(q[p]);}
	void link(int u,int v){q[ask(u)]=ask(v);}
	void add(int x,int y)
	{
//		printf("%d -> %d\n",x,y);
		ind[y]++;outd[x]++;
		link(x,y);
	}
	void initialize()
	{
		scanf("%d%d",&n,&h);e=0;
		for(int i=1;i<=h*2;i++)
			ind[i]=outd[i]=0,q[i]=i;
		for(int i=1,A,B,C,D,u,v;i<=n;i++)
		{
			scanf("%d%d%d%d",&A,&B,&C,&D);
			if(C)u=nt(C);else u=A;
			if(D)v=D;else v=nt(B);
			add(u,v);
		}
	}
	bool check()
	{
		static bool vis[M];
		memset(vis,0,sizeof(vis));
		for(int i=1;i<=h;i++)if(ind[i]>outd[i])return 0;
		for(int i=1;i<=h;i++)if(ind[nt(i)]<outd[nt(i)])return 0;

		for(int i=1;i<=h<<1;i++)
			if(ind[i]!=outd[i])vis[ask(i)]=1;
		for(int i=1;i<=h<<1;i++)
			if(!vis[ask(i)] && (ind[i]||outd[i]))return 0;
		return 1;
	}
	void solve()
	{
		initialize();
		if(check())printf("YES\n");
		else printf("NO\n");
	}
}
int main()
{
//	freopen("in","r",stdin);
	Hao_Nan_A___Wo_Bu_Hui_A___Wo_Hao_Ruo_A::solve();
	return 0;
}


Measured memory_bytes: 384
alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
d1 = {}
d2 = {}
for i in range(26):
    d1[i] = alp[i]
    d2[alp[i]] = i
N = int(input())
S = input()
ans = []
for i in range(len(S)):
    s = S[i]
    n = d2[s]
    n += N
    n %= 26
    ans.append(d1[n])
print(''.join(ans))

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

int main() {
  int H,W;
  vector<string> v(H);
  cin >> H>>W;
  for(int i =0;i<H;i++){
    cin >> v.at(i);
  }
  
  for(int i=0; i<W+2;i++){
    cout <<'#';
  }
  cout << endl; 
    
  for(int i =0;i<H;i++){
    cout <<'#' << v.at(i) <<'#' <<endl;
  }  
  for(int i=0; i<W+2;i++){
    cout <<'#';
  }
  cout << endl;
}


Measured memory_bytes: 33024
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let ans = [];
   for(let i = 1; i < xs[0]; i++){
   ans.push(xs[1] - i);
   }
   ans.push(xs[1]);  
   for(let i = 1; i < xs[0]; i++){
   ans.push(xs[1] + i);
   }
   const sort = (a,b) =>{
   return a - b;
   }
   ans.sort(sort);
   let ans1 = ans.join(' ');
   console.log(ans1);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
 #include <math.h>
 #include <iostream>
 #include <iomanip>
 using namespace std;
 
 int main(){
    int N, M;
    int p[120000];
    string S[120000];
    int i;
    int WA = 0;
    int WA_tmp[120000];
    int AC = 0;
    int AC_chk[120000];
 
    for (i=0; i<120000; i++){
        AC_chk[i]=0;
        WA_tmp[i]=0;
        }

  
    cin >> N >> M;

    for (i=1; i<M+1; i++)
        cin >> p[i] >> S[i];

    for (i=1; i<M+1; i++){
        if(AC_chk[p[i]]==1);

        else if(S[i]=="AC"){
            AC_chk[p[i]]=1;
            AC++;
            WA=WA+WA_tmp[p[i]];
        }

        else
            WA_tmp[p[i]]++;
        }

    cout << AC << ' ' << WA << endl;
    return 0;
 }
 


Measured memory_bytes: 7168
#include<iostream>
#include <string>
using namespace std;
int main()
{
  string S[3],A;
  int s[3];
  bool ans=false;
  cin>> A;
  S[0]=A.substr(0, 4);
  S[1]=A.substr(5, 2);
  S[2]=A.substr(9, 2); 
  s[0]=atoi(S[0].c_str());
  s[1]=atoi(S[1].c_str());
  s[2]=atoi(S[2].c_str());
  if(s[0]<2020){
  	if(s[1]<5){
        ans=true;
    }
  }
  if(ans){
    cout << "Heisei";
  }else{
    cout << "TBD";
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int N; cin >> N;
    vector<int>v(N);
    for(auto& e : v)
        cin >> e;
    sort(all(v));
    int ans = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            if(i == j)continue;
            int a = min(v[i],v[j]);
            int b = max(v[i],v[j]);
            auto it =  upper_bound(all(v),b - a);
            auto itr = lower_bound(all(v),a + b);
            int cnd = (itr - v.begin()) + (v.end() - it) - N;
            if(cnd <= 0) continue;
            auto ai = v.begin() + i; auto bi = v.begin() + j;
            cnd -= (it <= ai and ai < itr) + (it <= bi and bi < itr);
           // if(cnd)cout << cnd << " -> " << v[i] << " : "  << v[j] << endl;
            ans += max(cnd,0LL);
        }
    }
    cout << ans / 6 << endl;
}



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

int main() {
  	int n;
  	string s;
  	cin >> n >> s;
  
  	int ans=1;
  	rep(i, n-1){
      if(s.at(i) != s.at(i+1)) ans++;
    }
  
  	cout << ans << endl;
  	return 0;  
}


Measured memory_bytes: 3756
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int n; cin >> n;
	vector<vector<int>> f(n, vector<int>(11));
	vector<vector<int>> p(n, vector<int>(11));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> f[i][j];
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 11; ++j) {
			cin >> p[i][j];
		}
	}
	int res = -(1 << 30);
	for (int b = 1; b < (1 << 10); ++b) {
		int cost = 0;
		for (int i = 0; i < n; ++i) {
			int open_cnt = 0;
			for (int j = 0; j < 10; ++j) {
				if ((b >> j & 1) && f[i][j]) open_cnt++;
			}
			cost += p[i][open_cnt];	
		}
		if (res < cost) res = cost;
	}
	cout << res << endl;
	return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int N;
  cin >> N;
  if (N % 2 != 0) {
    cout << N / 2 + 1 << endl;
  } else {
    cout << N / 2 << endl;
  }
  return 0;
}


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

const int MAXN = 400010;
int n;
int head[MAXN], nxt[MAXN], to[MAXN], tot, fa[MAXN];
void addedge(int b, int e) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e;
}
int A[MAXN], B[MAXN], *T;
int xs[MAXN], ys[MAXN], bak;
int dfs(int u) {
	int pt = T[u] ? 0 : u;
	for (int i = head[u]; i; i = nxt[i]) {
		int t = dfs(to[i]);
		if (t) {
			if (pt) xs[++bak] = pt, ys[bak] = t, pt = 0;
			else pt = t;
		}
	}
	return pt;
}
void solve() {
	int rt = 0;
	memset(head, 0, n + 1 << 2); tot = 0;
	for (int i = 1; i <= n; ++i) {
		std::cin >> fa[i]; T[fa[i]] ^= 1;
		if (fa[i] == -1) rt = i; else addedge(fa[i], i);
	}
	dfs(rt);
}
bool vis[MAXN];
int col[MAXN];
void mkcol(int u) {
	vis[u] = true;
	for (int i = head[u]; i; i = nxt[i])
		if (vis[to[i]]) assert(col[to[i]] != col[u]);
		else col[to[i]] = col[u] ^ 1, mkcol(to[i]);
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	T = A, solve(), T = B, solve();
	for (int i = 1; i <= n; ++i) if (A[i] != B[i])
		return std::cout << "IMPOSSIBLE" << std::endl, 0;
	memset(head, 0, n + 1 << 2); tot = 0;
	for (int i = 1; i <= bak; ++i)
		addedge(xs[i], ys[i]), addedge(ys[i], xs[i]);
	for (int i = 1; i <= n * 2; ++i) if (!vis[i]) mkcol(i);
	std::cout << "POSSIBLE" << std::endl;
	for (int i = 1; i <= n; ++i)
		std::cout << (A[i] & 1 ? 0 : (col[i] ? 1 : -1)) << (" \n" [i == n]);
	return 0;
}


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

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}

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

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

    int n, k;
    cin >> n >> k;

    if(n / 2 + (int)(n % 2 == 1) >= k) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main(){

  int n,k;

  while(cin >> n >> k, n, k){

    int a[100000] = {0},z = 0,x = 0;

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

    for(int i=0;i<k;i++) z += a[i];
    x = z;
    for(int i=k;i<n;i++){
      x += (a[i] - a[i-k]);
      z = max(z , x);
    }

    cout << z << endl; 
  }
}

Measured memory_bytes: 1556
#include<bits/stdc++.h>
#define fr(i,j,n) for(int i=j;i<n;i++)
#define pb        push_back
#define rf(i,j,n) for(i=n;i>=j;i--)
#define vi        vector<int>
#define hmm        "\n"
#define sp        " "
using namespace std;
int main()
{
    string p ;
    cin >> p;
    long long  ac = 0,ans=0;
    for(int i = 0 ; i<p.size();  )
    {
        if(p[i]=='A'){ac++; i++; }
        else if(i+1<p.size() && p[i]=='B' && p[i+1]=='C'){
            ans+=ac; i+=2;
        }
        else {ac=0; i++; }
        
    }
    cout<<ans<<hmm;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


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

    vector<char> ans;

    while(true) {
        if (n <= 0) break;
        char c = n % 26  - 1 + 'a';
        if (n%26 == 0) c = 'z', n--;
        n /= 26;

        ans.push_back(c);
    }

    rrep(i, ans.size()) cout << ans[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 3608