akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }

void comb(vector<vector <long long int> > &v){
    for(int i = 0;i <v.size(); i++){
        v[i][0]=1;
        v[i][i]=1;
    }
    for(int k = 1;k <v.size();k++){
        for(int j = 1;j<k;j++){
            v[k][j]=(v[k-1][j-1]+v[k-1][j]);
        }
    }
}


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


Measured memory_bytes: 256
import java.util.*;
class Pair<V,K>{
	V first;
	K second;
	public Pair() {first = null;second = null;}
	public Pair(V f,K s){
		first = f;
		second = s;
	}
	public boolean equals(Object o) {
        if(!(o instanceof Pair))
        {
            return false;
        }
        Pair<V,K> pn = (Pair<V,K>)o;
        return pn.first.equals(first) && pn.second.equals(second);
	}
	public int hashCode() {
		return first.hashCode() + second.hashCode();
	}
}
public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long ans = 0;
		int n = in.nextInt();
		String s = in.next();
		String aa = null,bb = null;
		Map<Pair<String,String>,Integer> map = new HashMap();
		for(int i = 0;i < 1 << n;i ++) {
			StringBuilder a = new StringBuilder();
			StringBuilder b = new StringBuilder();
			for(int j = 0;j < n;j ++) {
				if((i >> j) % 2 == 1)a.append(s.charAt(j));
				else b.append(s.charAt(j));
			}
			aa = a.toString();
			bb = b.toString();
			if(map.containsKey(new Pair(aa,bb)))map.put(new Pair(aa,bb),map.get(new Pair(aa,bb)) + 1);
			else map.put(new Pair(aa,bb),1);
		}
		for(int i = 0;i < 1 << n;i ++) {
			StringBuilder a = new StringBuilder();
			StringBuilder b = new StringBuilder();
			for(int j = 0;j < n;j ++) {
				if((i >> j) % 2 == 1)a.append(s.charAt(n * 2 - 1 - j));
				else b.append(s.charAt(n * 2 - 1 - j));
			}
			aa = a.toString();
			bb = b.toString();
			if(map.containsKey(new Pair(aa,bb)))ans += map.get(new Pair(aa,bb));
		}
		System.out.println(ans);
	}
}


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

using ll = long long;
using pii = pair<int, int>;

#define     endl               "\n"
#define     fast_io            ios::sync_with_stdio(false); cin.tie(0);
#define     file_io            freopen("input.txt", "r", stdin);   \
                               freopen("output.txt", "w", stdout);
#define     all(x)             begin(x), end(x)
#define     debug(x)           cerr <<"Line "<< __LINE__ <<" : "<< #x " = "<< x <<endl;
 
template<typename T, typename TT>
ostream& operator<<(ostream &os, const pair<T, TT> &t) { return os<<"("<<t.first<<", "<<t.second<<")"; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &t) { for(auto& i: t) os<<i<<" "; return os; }



/**
 * This is an optimized (time & memory) version of Sieve of Eratosthenes 
 * 
 * input: n (range of primes to be generated), update MAXN as n
 * output: a vector of primes
 * 
 * -> discards even nonprimes during computation and memory
 * -> can be called multiple times
 * 		
 * There are appriximately (N / ln(N)) primes in range [1, N]	
 * Time complexity: O(Nlog(logN))
 * Space complexity: O(n/64 + n/ln(n))   
 * */

const unsigned int MAXN = 2e7 + 7;
bitset <MAXN> status;

///you can call it anywhere...TESTED
vector<int> sieve (const int& n) {
						    
    status.reset(); 	///clear bitset if necessary
    vector<int> primes;	/// stores generated primes
    
    if(n > 1) primes.emplace_back(2);
    
    int i = 3;
    for( ; i * i <= n; i += 2) {
		if(!status[i >> 1]) {	
            primes.emplace_back(i); 
            for(int j = i * i; j <= n; j += i + i) status[j >> 1] = 1;
        } 
	}
           
    for(; i <= n; i += 2) if(!status[i >> 1]) primes.emplace_back(i); 

    return primes;
}


/**
 * After a sieve call for a particular range
 * isPrime(x) returns true if x is a prime number in given range
 * 
 * -> First call sieve(n)
 * -> Then call it
 * 
 * Complexity: O(1)
 */


///you must call sieve() once before calling it...TESTED
bool isPrime (const int& n) {
	return n == 2 || (n > 2 && (n&1) && !status[n >> 1]); 
}


/**
 * Required functions: vector<int> sieve(const int& n)
 * Sample call: int phi = eulerPhi(n, seive(sqrt(n)));
 * 
 * Input: n (a number which totient value has to be calculated), a vector of primes <= sqrt(n)
 * Output: ϕ(n)
 * 
 * Complexity: O(sieve_call + inner) = O(sqrt(n)lg(lg(sqrt(n))) + sqrt(n)/ln(sqrt(n))) +  lg(n)) = O(sqrt(n)lg(lg(sqrt(n)))) 
 * */
int eulerPhi (int n, vector<int> const& rooted_primes) {
    int res = n;
        
    for(const int& prime : rooted_primes) {
		if(prime * 1LL * prime <= n && !(n % prime)) {
			while(!(n % prime)) n /= prime; 
			res /= prime;
			res *= (prime - 1); 
		}
	}
	if(n > 1) {
		res /= n;
		res *= (n - 1);
	}
    return res;
}


int main(int argc, char** argv) {
    fast_io
	
	int n;
	cin >> n;
	cout << eulerPhi(n, sieve(sqrt(n+1))) << endl;

    return 0;
}















Measured memory_bytes: 5652
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#define R register
#define EN std::puts("")
#define LL long long
inline LL read(){
    LL x=0,y=1;
    char c=std::getchar();
    while(c<'0'||c>'9'){if(c=='-') y=0;c=std::getchar();}
    while(c>='0'&&c<='9'){x=x*10+(c^48);c=std::getchar();}
    return y?x:-x;
}
//a:abs大的负数->abs小的负数->小正数->大正数
//b:大正数->小正数->abs小的负数->abs大的负数 
int n,fir;//a[fir]是a数组中第一个非负数
LL k;
LL a[200006],b[200006];
inline int finda(int i,LL ans){
    R int l=1,r=n,mid,ret=0;
    while(l<=r){
        mid=(l+r)>>1;
        if(a[mid]*a[i]<ans) ret=mid,l=mid+1;
        else r=mid-1;
    }
    return ret>=i?(ret-1):ret;//如果ret>=i，说明其中有一对是两个a[i]相乘得到，此时要减1
}
inline int findb(int i,LL ans){
    R int l=1,r=n,mid,ret=0;
    while(l<=r){
        mid=(l+r)>>1;
        if(b[mid]*a[i]<ans) ret=mid,l=mid+1;
        else r=mid-1;
    }
    return (ret+i>n)?(ret-1):ret;//同理，但b是倒序
}
inline int check(LL ans){
    LL nowk=0;
    for(R int i=1;i<fir;i++)//负数 
        nowk+=findb(i,ans);
    for(R int i=fir;i<=n;i++)//正数
        nowk+=finda(i,ans);
    nowk/=2;//去重
    return nowk>=k;
}
inline int cmp(int x,int y){
    return x<y;
}
int main(){
    n=read();k=read();
    for(R int i=1;i<=n;i++) a[i]=read(); 
    std::sort(a+1,a+1+n);
    fir=n+1;
    for(R int i=1;i<=n;i++)
        if(a[i]>=0){fir=i;break;}
    for(R int i=1;i<=n;i++) b[n-i+1]=a[i];//存入b数组，对负数二分时使用
    R LL l=-1e18,r=1e18,mid,ans;
    while(l<=r){
        mid=(l+r)/2;
        if(check(mid)) ans=mid,r=mid-1;
        else l=mid+1;
    }
    std::printf("%lld",ans-1);
    return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=2e5+10;
int n,a[N];
map<int,int>mp;
int main()
{
    cin>>n;

    rep(i,1,n) cin>>a[i];
    //rep(i,1,n) printf("%d ",i+a[i]);
    rep(i,1,n) mp[i+a[i]]++;
    ll ans=0;
    rep(i,1,n) ans+=mp[i-a[i]];
    cout<<ans<<endl;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> edges[100000];
    vector<pair<int,int>> ed;
    map<pair<int,int>,int> col;
    for(int i=0;i<n-1;++i){
        int a, b;
        cin >> a >> b;
        edges[a-1].emplace_back(b-1);
        edges[b-1].emplace_back(a-1);
        ed.emplace_back(a-1, b-1);
    }

    int k = 0;
    for(int i=0;i<n-1;++i){
        k = max(k, (int)edges[i].size());
    }
    queue<pair<int,int>> q;
    q.emplace(0, -1);
    while(!q.empty()){
        int v, prev;
        tie(v, prev) = q.front();
        q.pop();
        int ng = prev==-1?-1:col[{prev, v}];
        int c = 1;
        if(ng == c) ++c;
        for(auto to : edges[v]){
            if(to==prev) continue;
            col[{to, v}] = c;
            col[{v, to}] = c;
            ++c;
            if(c == ng) ++c;
            q.emplace(to, v);
        }
    }

    cout << k << endl;
    for(int i=0;i<n-1;++i){
        cout << col[ed[i]] << endl;
    }

    return 0;
}

//stop @ 14:55

Measured memory_bytes: 19316
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll n;cin>>n;
  
  vvll f(n,vll(10)),p(n,vll(11));

  
  rep(i,0,n){
    rep(j,0,10){
      cin>>f[i][j];
    }
  }
  rep(i,0,n){
    rep(j,0,11){
      cin>>p[i][j];
    }
  }
  ll ans=-MOD;
  rep(i,1,1<<10){
    vll mise(n,0);
    rep(j,0,10){
      if(i>>j&1){
        rep(k,0,n){
          if(f[k][j])mise[k]++;
        }
      }
    }
    ll tmp=0;
    rep(j,0,n){
      tmp+=p[j][mise[j]];
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;

}


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

int main(){
    int x;
    vector<int> unti;
    while(1){
        
        cin>>x;
        if(x==0) break;
        unti.push_back(x);        
        
    }
    
    REP(i,unti.size()){
        cout<<"Case "<<i+1<<": "<<unti[i]<<endl;
    }
}


Measured memory_bytes: 3176
import math

def cut(l,A,K):
    counter = 0
    i = N - 1
    if l == 0:
        return False
    while i >= 0:
        c = math.ceil(A[i] / l) - 1
        if c == 0:
            break
        else:
            counter += c
            i -= 1
    if counter <= K:
        return True
    else:
        return False
    
if __name__ == '__main__':
    N,K = map(int,input().split())
    A = [float(a) for a in input().split()]
    A.sort()
    left = 0
    right = math.ceil(A[-1])
    while left <= right:
        middle = (left + right) // 2
        if cut(middle,A,K):
            if not cut(middle-1,A,K):
                break
            else:
                right = middle - 1
        else:
            left = middle + 1
    print(middle)

Measured memory_bytes: 97860
H, W = gets.split.map(&:to_i)

s = Array.new(H)

for i in 0..H-1 do
  s[i] = gets.chomp
end

D = [-1, 1, 0]

for x in 0..H-1 do
  for y in 0..W-1 do
     next if s[x][y] == "#"
     tmp = 0

     D.each {|dx|
       D.each {|dy|
          next if dx == 0 && dy == 0 || x + dx < 0 || x + dx > H-1 || y + dy < 0 || y + dy > W-1
          tmp += 1 if s[x+dx][y+dy] == "#"
       }
     }

     s[x][y] = tmp.to_s
  end
end

for i in 0..H-1 do
  puts s[i]
end


Measured memory_bytes: 1916
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		for(long n = 1; n <= 3500; n++) {
			for(long w = 1; w <= 3500; w++) {
				long k1 = N * n * w;
				long k2 = 4 * n * w - N * (n + w);
				if(k2 >= 1 && k1 % k2 == 0) {
					System.out.printf("%d %d %d", k1 / k2, n, w);
					System.exit(0);
				}
			}
		}
		sc.close();
	}
}

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

vector<int> dx = {-1, 0, 0, 1};
vector<int> dy = {0, -1, 1, 0};

int main(){
    int H, W;
    cin >> H >> W;

    vector<string> board(H);
    for(int i = 0;i < H;i++){
        cin >> board[i];
    }

    vector<vector<int>> dis(H, vector<int>(W, 0));
    queue<pair<int, int>> que;

    dis[0][0] = 1;//スタートの距離を１とする
    que.push(make_pair(0, 0));//スタートの位置をqueに追加

    //幅優先探索を行う

    while(!que.empty()){
        pair<int, int> current = que.front();
        que.pop();

        int y, x;
        y = current.first;
        x = current.second;

        for(int i = 0;i < 4;i++){

            int next_y, next_x;
            next_y = y + dy[i];
            next_x = x + dx[i];

            if(next_y < 0 || next_y >= H || next_x < 0 || next_x >= W || board[next_y][next_x] == '#') continue;//範囲外もしくは壁の時はスルーする
            if(!(dis[next_y][next_x] == 0)) continue;//既に探索済みならスルーする

            dis[next_y][next_x] = dis[y][x] + 1;

            que.push(make_pair(next_y, next_x));
        }
    }

    int wall = 0;//壁の数を調べる
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(board[i][j] == '#') wall++;
        }
    }

    if(dis[H-1][W-1] == 0){//たどり着けない時
        cout << -1 << endl;
        return 0;
    }

    int ans;
    ans = H * W - wall - dis[H-1][W-1];

    cout << ans << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#ifdef BOI
#include "debug.h"
#else
#define debug(args...)
#endif
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define eps 1e-7
#define inf 0x3f3f3f3f
typedef long long ll;
typedef long double ld;
#define endl '\n'

int main() {
    cin.tie(0)->sync_with_stdio(0), cin.exceptions(cin.failbit);
#ifdef BOI
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ll n, m; cin >> n >> m;
    cout << (n == 1 || m == 1 ? 1 : (n * m + 1) / 2);
}


Measured memory_bytes: 3568
import sys
  
f = [0, 1] * 500000
f.append(0)
f[1] = 0
f[2] = 1
i = 3
while i < 1000:
    if f[i] == 1:
        j = i * i
        while j <= 1000000:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    print(sum(f[:i + 1]))

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

int main(){
  int l;
  cin >> l;
  ll a[l];
  rep(i,l) cin >> a[i];
  vector<vector<ll>> dp(l+1,vector<ll>(5,INF));
  dp[0][0] = 0;
  rep(i,l) {
    dp[i+1][0] = dp[i][0] + a[i];
    for(int j = 1; j <= 3; j++) {
      for(int k = 0; k <= j; k++) {
        if(j % 2) {
          if(a[i] == 0) dp[i+1][j] = min(dp[i+1][j],dp[i][k]+2);
          else dp[i+1][j] = min(dp[i+1][j],dp[i][k]+a[i]%2);
        }
        else dp[i+1][j] = min(dp[i+1][j],dp[i][k]+(1-a[i]%2));
      }
    }
    rep(j,4) dp[i+1][4] = min(dp[i+1][4],dp[i+1][j]); 
    dp[i+1][4] = min(dp[i+1][4],dp[i][4]+a[i]);
  }
  cout << dp[l][4] << endl;
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int st = 0,ans = 0;
    for(int i = 0; i < 3; i++){
        if(st == 0 && s[i] == 'R'){
            st = 1;
            ans++;
        }else if(st == 1 && s[i] == 'R'){
            ans++;
        }else if(st == 1 && s[i] == 'S'){
            st = 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
N = int(input())
Ai = input().split()
if N != 1:
  if N%2==0:
    b = Ai[::-2] + Ai[::2]
  else:
    b = Ai[-2::-2] + Ai[::2]
    b = b[::-1]
else:
  b = Ai
print(*[bb for bb in b], sep=" ")


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
	s64 n,m; cin >> n >> m;
	s64 res = 0;
	res += min(n,m/2);
	n -= res;
	m -= res*2;
	res += m/4;
	cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A, B = map(int, stdin.readline().rstrip().split())

Aprime = prime_factorize(A)
Bprime = prime_factorize(B)

Aset = set(Aprime)
Bset = set(Bprime)

cup = Aset & Bset

#print(Aset)
#print(Bset)

#print(cup)

print(1 + len(cup))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int n, x, y;

int main () {

ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

cin >> n >> x >> y;

if ((y - x) % 2 == 0) cout << "Alice";
else cout << "Borys";

return 0;

}


Measured memory_bytes: 256
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val a = input.split(" ").head.toLong
    val b = input.split(" ").tail.head.toLong
    val c = input.split(" ").tail.tail.head.toLong
    val k = input.split(" ").tail.tail.tail.head.toLong

    (max(min(k, a), 0) * 1 + max(min(k - a, b), 0) * 0 + max(min(k - a - b, c), 0) * (-1)).toString
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """2 1 1 3""".stripMargin -> """2
                                   |
                                |""".stripMargin,
    """1 2 3 4""".stripMargin -> """0
                               |""".stripMargin,
    """2000000000 0 0 2000000000""".stripMargin -> """2000000000"""
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

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

int main(){
  
  string str;
  string str1;

  cin>>str>>str1;

  str+=str;

  if(str.find(str1)!=-1){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;

}
		  


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

int main() {
	int n;
	int m;
	int a0,a1,a2,b0,b1,b2;
	int ans;

	cin >> n ;
	n/=2;
	rep(i, n){
		cin >> a0 >> b0 ;
		a[a0]++;
		b[b0]++;
	}
	a1=0;
	b1=0;
	m=100005;
	rep(i, m){
		if (a[i]>a1){
			a0=i;
			a1=a[i];
		}
		if (b[i]>b1){
			b0=i;
			b1=b[i];
		}
	}
	if (a0!=b0) {
		cout << 2*n-a1-b1 << endl;
		return 0;
	}
	a[a0]=0;
	b[b0]=0;
	a2=0;
	b2=0;
	rep(i, m){
		a2=max(a2,a[i]);
		b2=max(b2,b[i]);
	}
	if (a1+b2>a2+b1) cout << 2*n-a1-b2 << endl;
	else cout << 2*n-a2-b1 << endl;
	return 0;
}

Measured memory_bytes: 4400
//In the name of ALLAH
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long long maxn = 2e5 + 1;
const long long INF = 4e18 ;
const long long M = 1e9 + 7;
const int lg = 21;

ll n, x, maxx, ind, y, a[maxn];
vector<pll> v;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x;
		a[i] = x;
		if(abs(x) > maxx)
			maxx = abs(x), y = x, ind = i;
	}
	for(int i = 0; i < n; i++)
		if(y * a[i] < 0)
			v.pb({ind + 1, i + 1}), a[i] += y;
	if(y > 0){
		for(int i = 0; i < n - 1; i++)
			if(a[i] > a[i + 1])
				v.pb({i + 1, i + 2}), a[i + 1] += a[i];
	}
	else{
		for(int i = n - 1; i >= 1; i--)
			if(a[i - 1] > a[i])
				v.pb({i + 1, i}), a[i - 1] += a[i];
	}
	cout << v.size() << endl;
	for(int i = 0; i < v.size(); i++)
		cout << v[i].X << " " << v[i].Y << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	a := scanInts(m)

	b := []int{-1, 2, 5, 5, 4, 5, 6, 3, 7, 6}
	dp := make([][10]int, n+1)
	dp[0][0] = 1

	for k := 0; k < m; k++ {
		num := a[k]
		c := b[num]
		for i := 0; i < n; i++ {
			if i+c > n || dp[i][0] == 0 {
				continue
			}

			f := false
			if dp[i+c][0] < dp[i][0]+1 {
				f = true
			}
			if dp[i+c][0] == dp[i][0]+1 {
				for j := 9; j > 0; j-- {
					cnt := dp[i][j]
					if num == j {
						cnt++
					}
					if dp[i+c][j] > cnt {
						break
					}
					if dp[i+c][j] < cnt {
						f = true
					}
				}
			}
			if f {
				for j := 0; j < 10; j++ {
					dp[i+c][j] = dp[i][j]
				}
				dp[i+c][0]++
				dp[i+c][num]++
			}
		}
		// debug(num, c, dp[n])
	}

	for i := 9; i > 0; i-- {
		for j := 0; j < dp[n][i]; j++ {
			fmt.Fprint(wr, i)
		}
	}
	fmt.Fprintln(wr)
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int d, n;
  cin >> d >> n;
  int a = 0;
  for(int i = 1; i <= 1010000; i++){
    int cnt = 0, j = i;
    while(j % 100 == 0){
      cnt++;
      j /= 100;
    }
    if(d == cnt){
      a++;
    }
    if(a == n){
      cout << i << endl;
      system("pause");
      return 0;
    }
  }
  system("pause");
  return 0;
}


Measured memory_bytes: 504
// atcoder/abc071/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int x, a, b;
  while (cin >> x >> a >> b) {
    cout << (abs(x - a) < abs(x - b) ? "A" : "B") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 110;
int a[N];
int n,m;

int main()
{
  cin >> n >> m;
  int total = 0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    total += a[i];
  }
  sort(a,a+n);
  double lim = 1.0*total/(4*m);
  int num = 0;
  for(int i=0;i<n;i++){
    if(a[i]>=lim) num++;
  }
  if(num>=m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<cctype>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
int n , s[1000];
double a0 , a , m0 , m , siguma;
m0 = m = siguma = 0;
while(1){
cin >> n;
if( n == 0 )break;
for(int i = 0; i < n; i++){
  cin >> s[i];
  m0 += s[i];
}
m = m0 / n;
for(int i = 0; i < n; i++){
  siguma += pow( s[i] - m , 2) ;
}
a0  = sqrt ( siguma / n );
a = fabs(a0);
printf("%.8f\n", a);
a0 = a = m0 = m = siguma = n = 0;
for(int i = 0; i < 1000; i++){
  s[i] = 0;
}
}
return 0;
}


Measured memory_bytes: 3208
#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 <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <limits>
#include <iomanip>

using namespace std;

template <typename T> class SegTree{
 /* Segment木                                                                              */
 /* [0,n)の計n個の要素を格納し、ある区間[l,r)の値を取得するための構造。                    */
 /* 更新処理、値の取得共にlog(n)                                                           */
 /* これが使えるための条件は、区間A,Bの値を用いて区間A+Bの値がcombineにより計算できること。*/
 /* 便宜的にoperator+を実装したくらすならば格納可能としている。例はBoxを参照のこと。       */
 private:
  vector<T> data;
  long long size; // 入力として与えられる要素数でなくそれ以上の最大の2の累乗を実際のサイズ歳て保持する
 public:
  T combine(T a, T b){
   //cout << "combine: "; a.print();
   //cout << "combine: "; b.print();
   return a+b;
  }
  SegTree(long long n, T def){
     size = 1;
     while(size < n) size*=2;
     data=vector<T>(size*2-1, def);
     for(int i=0; i<n; i++) setValue(i, def);
  }

  T getValue(int l){
    return getValue(l, l+1);
  }
  T getValue(int l, int r){
    // return sum in [l,r-1] or [l,r)
    return getValue_(0, l, r, 0, size);
  }
  T getValue_(int ind, int l, int r, int lb, int rb){
    //cout << ind << ", "<< l << ", " << r <<", "<<lb <<", "<< rb<<endl;
    if(l<=lb && rb<=r) return data[ind];
    int mid = (lb+rb)/2;
    if(r <= mid) return getValue_(ind*2+1, l, r, lb, mid);
    if(mid <= l) return getValue_(ind*2+2, l, r, mid, rb);
    return combine(getValue_(ind*2+1, l, r, lb, mid),
                   getValue_(ind*2+2, l, r, mid, rb));
  }
  void setValue(int i, T value){
    // add x to i
    int internal_index = size-1+i;
    data[internal_index]=value;
    while( internal_index != 0 ){
      internal_index=(internal_index-1)/2;
      data[internal_index]=combine(data[internal_index*2+1], data[internal_index*2+2]);
      //cout << "set: "<< internal_index << endl;
      //data[internal_index].print();
    }
    return;
  }
};
class Box{
  public:
  long long a;
  Box(long long a_):a(a_){};
  const Box operator+(const Box& B) const{
   return Box(max(a, B.a));
  }
  void print(){
   cout << a<<endl;
  }
};

int main(){
  int N; 
  cin >> N;
  int h[N];
  int a[N];
  for(int i=0; i<N; i++) cin >> h[i];
  for(int i=0; i<N; i++) cin >> a[i];
  SegTree<Box> ST(N+1, Box(0));
  for(int i =0; i <N; i++){
     Box b = ST.getValue(0, h[i]);
     //cout << h[i] <<", "<< b.a+a[i] << endl;
     ST.setValue(h[i], Box(b.a+a[i])); 
  }
  cout << ST.getValue(0, N+1).a <<endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    ll ans = (ll)(N - 1) * N / 2;

    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
ans = 0
if n < 3:
    print(0)
    exit()
for i in range(n-2):
    for j in range(i+1,n-1):
        if l[i] == l[j]:
            continue
        for k in range(j+1,n):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            if l[i] < l[j]+l[k] and l[j] < l[i]+l[k] and l[k] < l[i] + l[j]:
                ans += 1

print(ans) 

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(ALL(h));
  if(k >= n) cout << 0 << endl;
  else {
    ll ans = 0;
    rep(i, n-k) ans += h[i];
    cout << ans << endl;
  }
}


Measured memory_bytes: 4840
H,W = map(int,input().split())
ahw = [strlist for strlist in [[s for s in input()] for i in range(H)] if "#" in strlist]
tenti = []
for h in range(W):
   m =  [ah[h] for ah in ahw]
   if "#" in m:
       tenti.append(m)
for ahwnum in range(len(ahw)):
    print("".join([num[ahwnum] for num in tenti]))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;++i)
string s[1010]; //map
int chy[10], chx[10]; //cheese
int d[1010][1010]; //min time
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int h, w, n, ans;

void bfs(){
  REP(i,n){
    int sy = chy[i], sx = chx[i]; //i.start
    int gy = chy[i+1], gx = chx[i+1]; //i.goal
    queue<int> qy, qx;
    
    qy.push(sy); qx.push(sx);
    REP(j,h) REP(k,w) d[j][k] = 1e9; //init for visit check
    d[sy][sx] = 0; //start time

    while(1){
      int posy = qy.front(); qy.pop();
      int posx = qx.front(); qx.pop();
      if(posy == gy && posx == gx){
        ans += d[gy][gx];
        break;
      }
      REP(j,4){
        int y = posy + dy[j], x = posx + dx[j];
        if(y < 0 || h <= y || x < 0 || w <= x){ //not allowed range
          continue;
        }
        if(d[y][x] == 1e9 && s[y][x] != 'X'){ //first visit && not X
          d[y][x] = d[posy][posx] + 1; //previous time + 1
          qy.push(y); qx.push(x);
        }
      }
    }
  }
}
int main(){
  cin>>h>>w>>n;
  REP(i, h){
    cin>>s[i];
    
    REP(j, w){
      if(s[i][j] == 'S'){
        chy[0] = i;
        chx[0] = j;
      }else if('1' <= s[i][j] && s[i][j] <= '9'){
        chy[s[i][j]-'0'] = i;
        chx[s[i][j]-'0'] = j;
      }
    }
  }    
  bfs();
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++)
        cin >> A[i];

    ll res = 0;
    for(int i=1;i<N;i++){
        int diff = A[i - 1] - A[i];
        if(diff > 0){
            A[i] += diff;
            res += (ll)diff;
        }
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 4044
#include <stdio.h>
 
int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int i;
  int ta,tb;
  i = 0;
  while (i < 1000000000)
  {
    if (a%2 != 0 || b%2 != 0 || c%2 != 0)
    {
      break;
    }
    else if (a == b && b == c)
    {
      printf("-1");
      return (0);
    }
    ta = a;
    tb = b;
    a = b/2 + c/2;
    b = ta/2 + c/2;
    c = ta/2 + tb/2;
    i++;
  }
  printf("%d",i);
}

Measured memory_bytes: 128
def abc():
    n = int(input())
    blue = {}
    for i in range(n):
        s = input().rstrip()
        blue[s] = blue.get(s, 0) + 1

    m = int(input())
    red = {}
    for i in range(m):
        s = input().rstrip()
        red[s] = red.get(s, 0) + 1

    ans = 0
    for k in blue.keys():
       ans = max(ans, blue.get(k) - red.get(k, 0))
    print(ans)


abc()


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

namespace AtCoder
{
    class Program
    {
        static int[] march;

        static void Main(string[] args)
        {
            //[summary]C - March
            int N = int.Parse(Console.ReadLine());
            var dic = GetMarch();

            //"M,A,R,C,H"それぞれの文字から始まる名前が何種類あるか数える
            for(int i = 0; i < N; i++)
            {
                var S = Console.ReadLine();

                if (dic.ContainsKey(S[0]))
                {
                    dic[S[0]]++;
                }
            }

            //頭文字の個数だけを取り出す
            march = dic.Values.ToArray();

            long count = 0;

            for(int i = 0; i < Math.Pow(2, 5); i++)
            {
                count += CountCombis(i); 
            }

            Console.WriteLine(count);
        }

        static long CountCombis(int n)
        {
            var binary = Convert.ToString(n, 2).PadLeft(5, '0');
            long count = 1;

            if (binary.Count(x => x == '1') == 3)
            {
                for(int i = 0; i < 5; i++)
                {
                    if (binary[i] == '1')
                    {
                        count *= march[i];
                    }
                }

                return count;
            }
            else
            {
                return 0;
            }
        }

        static Dictionary<char, int> GetMarch()
        {
            var march = "MARCH";
            var dic = new Dictionary<char, int>();

            foreach(var c in march)
            {
                dic.Add(c, 0);
            }

            return dic;
        }
    }
}

Measured memory_bytes: 13652
MOD = 10 ** 9 + 7
t = [0] * 60
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(60):
    cnt = 0
    for j in range(n):
        if (a[j] >> i) & 1:
            cnt += 1
    ans += cnt * (n - cnt) * pow(2, i, MOD)
print(ans % MOD)


Measured memory_bytes: 122936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7ll;

int a,b;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>a>>b;

int mid=a+b;

if(mid%2==0) cout<<mid/2<<endl;
else cout<<(mid+1)/2<<endl;


}



Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<algorithm>
#define st first
#define nd second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 2e5 + 10;

int a[N], b[N];

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
    a[0] = a[n];
    priority_queue<pii> pq;
    for(int i = 1; i <= n; i++){
        scanf("%d", &b[i]);
        if(b[i] != a[i])
            pq.push({b[i], i % n});
    }
    b[0] = b[n];
    ll ans = 0;
    while(!pq.empty()){
        pii p = pq.top();
        pq.pop();
        int x = (p.nd + 1) % n, y = (p.nd - 1 + n) % n;
        if(b[x] + b[y] >= b[p.nd]) return !printf("-1");
        int sum = b[x] + b[y] ;
        int ma = max(a[p.nd], sum);
        int k = (b[p.nd] - ma + sum - 1) / sum;
        b[p.nd] -= sum * k;
        if(b[p.nd] < a[p.nd]) return !printf("-1");
        ans += k;
        if(b[p.nd] != a[p.nd]) pq.push({b[p.nd], p.nd});
    }
    printf("%lld", ans);


}


Measured memory_bytes: 6108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		int h=sc.nextInt();
		int w=sc.nextInt();

		int s=H*W-h*W-w*H+h*w;
		System.out.println(s);
	}
}

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

int main() {
	int k;
	string s;
	cin >> k >> s;
	
	for(int i = 0; i < s.length(); i++){
		cout << char ((s[i] - 'A' + k) % 26 + 'A') ; 
	}
	return 0;
}

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define pb push_back

#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)

#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;

Graph G;

vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

int main()
{
    ll n, k;
    cin >> n >> k;
    vll h(n);
    rep(i, 0, n) cin >> h[i];

    ll dp[110000];
    rep(i, 0, 110000)
    {
        dp[i] = INF;
    }

    dp[0] = 0;

    rep(i, 0, n)
    {
        rep_cs(j, 1, k)
        {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[n - 1] << endl;
}

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

using namespace std;

int main(){
  
  int N; cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) cin >> d.at(i);
  sort(d.begin(), d.end());
 
  cout << d.at(N/2) - d.at((N/2)-1) << endl;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        out.println(in.next().replace(",", " "));
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 23120
/*Mrc01*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#define ll long long 
#define ull unsigned long long 
#define f(i,x,n) for(ll int i=x;i<n;i++) 
#define re(j,x,n) for(ll int j=x;j>=n;j--)
#define f1(k,x,n) for(ll int k=x;k<=n;k++)
#define mp make_pair
#define pb push_back
#define bit(x, i) (x >>(i - 1) & 1ll)
#define MAX 1000001
const int mod=1000000007;
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<ll int,ll int>,null_type, less<pair<ll int,ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
      new_data_set; 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char s[2][3];
    f(i,0,2)
    {
      f(j,0,3)
       cin>>s[i][j];
    }
    string s1,s2,s3,s4;
    f(i,0,3)
     s1+=s[0][i];
    f(i,0,3)
     s2+=s[1][i];
    s3=s1;
    s4=s2;
    reverse(s3.begin(),s3.end());
    reverse(s4.begin(),s4.end());
    if(s4==s1&&s3==s2)
    {
      cout<<"YES";
    }
    else
      cout<<"NO";
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[int(2e5 + 5)], ans[int(2e5 + 5)];
vector <int> Graph[int(2e5 + 5)];

int Now[int(2e5 + 5)];
int DFS(int node){
  int Before, L = 0;
  if (A[node] <= Now[0]){
    Before = Now[0];
    Now[0] = A[node];
  }else{
    int R = N;
    while (R - L > 1){
      int mid = (L + R) / 2;
      if (A[node] > Now[mid]) L = mid;
      else R = mid;
    }
    L++;
    Before = Now[L];
    Now[L] = A[node];
  }

  int ansL = 0, ansR = N;
  while (ansR - ansL > 1){
    int mid = (ansL + ansR) / 2;
    if (Now[mid] < 1e9 + 1) ansL = mid;
    else ansR = mid;
  }
  ans[node] = ansL + 1;

  for (int i = 0; i < Graph[node].size(); i++){
    int next = Graph[node][i];
    if (ans[next] != 0) continue;
    DFS(next);
  }
  Now[L] = Before;
  return 0;
}

int main(){
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", A + i);
  for (int i = 0; i < N - 1; i++){
    int U, V; scanf("%d%d", &U, &V);
    Graph[U].push_back(V);
    Graph[V].push_back(U);
  }
  fill(Now, Now + N + 2, 2e9);
  DFS(1);

  for (int i = 1; i <= N; i++){
    printf("%d\n", ans[i]);
  }

  return 0;
}


Measured memory_bytes: 28556