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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

typedef struct node{
    int c;
    int id;
}node;

int cmpAsc(const void* a, const void* b){
    int x = ((node*)a)->c, y = ((node*)b)->c;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    int p = ((node*)a)->id, q = ((node*)b)->id;
    if(p > q){
        return 1;
    }
    if(q < p){
        return -1;
    }
    return 0;
}

int binarySearch_l(node* p, int n, int target){
    int l = 0, r = n-1;
    int m = (l+r+1)/2;
    while(l < r){
        if((p + m)->c <= target){
            l = m;
        }else{
            r = m-1;
        }
        m = (l+r+1)/2;
    }
    if((p+m)->c != target){
        return -1;
    }
    return m;
}
int binarySearch_r(node* p, int n, int target){
    int l = 0, r = n-1;
    int m = (l+r)/2;
    while(l < r){
        if(target <= (p + m)->c){
            r = m;
        }else{
            l = m+1;
        }
        m = (l+r)/2;
    }
    if((p+m)->c != target){
        return -1;
    }
    return m;
}
int binarySearch_id(node* p, int l, int r, int target){
    int m = (l+r)/2;
    while(l < r){
        if(target < (p + m)->id){
            r = m;
        }else{
            l = m+1;
        }
        m = (l+r)/2;
    }
    return m;
}

int main(){
    char s[100001], t[100001];
    scanf("%s", s);
    scanf("%s", t);
    int s_len = strlen(s), t_len = strlen(t);
    node a[s_len];
    rep(i, 0, s_len){
        a[i].c = s[i] - 'a';
        a[i].id = i;
    }
    qsort(a, s_len, sizeof(node), cmpAsc);
    lld ans;
    int f = 0;
    int id = -1, target = t[0] - 'a';
    rep(i, 0, s_len){
        if(target == a[i].c){
            id = a[i].id;
            f = 1;
            break;
        }
    }
    ans = id+1;
    rep(i, 1, t_len){
        target = t[i] - 'a';
        int l, r;
        l = binarySearch_r(a, s_len, target);
        r = binarySearch_l(a, s_len, target);
        if(l == -1 || r == -1){
            f = 0;
            break;
        }
        int buf = binarySearch_id(a, l, r, id);
        if(a[buf].id <= id){
            buf = l;
        }
        if(id < a[buf].id){
            ans += a[buf].id - id;
        }else{
            ans += s_len + a[buf].id - id;
        }
        id = a[buf].id;
    }
    if(f){
        printf("%lld", ans);
    }else{
        printf("-1");
    }

    return 0;
}

Measured memory_bytes: 1916
#include <iostream>
#include <string>

#define N 1000

using namespace std;

int main(void) {
    int i;
    int hash[N];
    char c;
    string S, ans;
    cin >> S;
    for(i = 0; i < N; i++) {
        hash[i] = 0;
    }
    for(i = 0; i < S.size(); i++) {
        c = S[i];
        hash[(unsigned char)c]++;
    }
    ans = "yes";
    for(i = 0; i < N; i++) {
        if(hash[i] > 1) {
            ans = "no";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
'use strict'

const main = arg => {
 const input = arg.trim().split("\n")[0].split(" ").map(num => parseInt(num, 10));
 const W = input[0];
 const H = input[1];
 const x = input[2];
 const y = input[3];
 const r = input[4];
 let result = "No";
 if((x-r >= 0 && W >= x+r) && (y-r >= 0 && H >= y+r)){ result = "Yes"; }

 console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));




Measured memory_bytes: 15372
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end() 
#define MAXN 3005
using namespace std;

int n;
double p[MAXN];
double dp[MAXN][MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>p[i];
    dp[1][1] = p[1],dp[1][0] = 1-p[1];
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            dp[i+1][j] += (dp[i][j]*(1-p[i+1]));
            dp[i+1][j+1] += (dp[i][j]*p[i+1]);
        }
    }
    // for(int i=1;i<=n;i++)
    // {
    //     for(int j=0;j<=n;j++) cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    double ans=0;
    for(int i=(n+1)/2;i<=n;i++) ans+=dp[n][i];
    // cout<<ans<<endl;
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 69120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int n;
    cin>>n;
    vi p(n);
    rep(i,n){
        cin >> p[i];
    }
    int ans=0;
    rep(i,n-1){
        if(p[i]==i+1){
            ans++;
            swap(p[i], p[i + 1]);
        }
    }
    if(p[n-1]==n){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3784
//agc008_b.cpp
//Sun Jul 28 21:54:45 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll a[n];
	ll ruiseki[n+1];
	ll plusruiseki[n+1];
	ruiseki[0] = 0;
	plusruiseki[0] = 0;
	for (int i=0;i<n;i++){
		cin >> a[i];
		ruiseki[i+1] = ruiseki[i]+a[i];
		if (a[i]>0){
			plusruiseki[i+1] = plusruiseki[i]+a[i];
		}else {
			plusruiseki[i+1] = plusruiseki[i];
		}
	}

	ll ans = 0;
	for (int i=0;i<=n-k;i++){
		ll temp = 0;
		if (ruiseki[i+k]-ruiseki[i]>0){
			temp +=  ruiseki[i+k]- ruiseki[i];
		}
		temp += plusruiseki[i]-plusruiseki[0]+
				plusruiseki[n]-plusruiseki[i+k];
		if (ans<temp){
			ans = temp;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main(void){
  string s1, s2,temp = "";
  cin >> s1 >> s2;
  for(int i=0;i<s1.length();i++){
    temp += s2[s1.length()-1-i];
  }
  if(s1 == temp) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

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

    ll x = n/k;

    ll a = abs(n-(k*x));
    ll b = abs(n-(k*(x+1)));
    ll c = abs(n-(k*(x-1)));

    ll ans = min(a,b);
    ans = min(ans,c);

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=1005,inf=10005;
int dp[2][N],val[N],dp2[N][inf];
vi v[N];
bool pos;
int fun(int ind,int sz,int col,int curr,int done=0)
{
  if(done>val[curr]) return inf;
  if(ind==sz) { pos=true; return 0;}
  if(dp2[ind][done]!=-1) return dp2[ind][done];
  int ans=inf,v1=v[curr][ind];
  //take this of same col
  ans=dp[1-col][v1]+fun(ind+1,sz,col,curr,done+val[v1]);
  //take this of other col
  ans=min(ans,val[v1]+fun(ind+1,sz,col,curr,done+dp[col][v1]));
  return dp2[ind][done]=ans;
}
void dfs(int u)
{
  for(int v1:v[u])
    dfs(v1);
  pos=false;
  rep(k,0,2)//assign colour i to this node, and minimise other colour
    {
      rep(i,0,sz(v[u])) rep(j,0,inf) dp2[i][j]=-1;
      dp[1-k][u]=fun(0,sz(v[u]),k,u);
    }
  if(!pos)
    {
      cout<<"IMPOSSIBLE"<<endl;
      exit(0);
    }
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,x;
  cin>>n;
  rep(i,2,n+1)
    {
      cin>>x;
      v[x].pb(i);
    }
  rep(i,1,n+1) cin>>val[i];
  dfs(1);
  cout<<"POSSIBLE"<<endl;
  return 0 ;
}


Measured memory_bytes: 39424
W,H = map(int,input().split())
ans = 10**30
for i in range(1,W):
    a = H*i
    w = W - i
    b = max((w//2)*H,w*(H//2))
    c = w*H - b
    x = max(a,b,c) - min(a,b,c)
    ans = min(ans,x)
for i in range(1,H):
    a = W*i
    h = H - i
    b = max((W//2)*h,W*(h//2))
    c = h*W - b
    x = max(a,b,c) - min(a,b,c)
    ans = min(ans,x)
print(ans)

Measured memory_bytes: 3064
import java.io.*;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            int n = scan.nextInt();
            char[] s = scan.next().toCharArray();
            for(int i = 0; i < n/2; i++) {
                if(s[i] != s[i+n/2]) {
                    out.println("No");
                    return;
                }
            }
            out.print(n%2 == 0 ? "Yes" : "No");
        }
    }

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 22740
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        k: usize
    }
    if m == 1 {
        if k == n - 1 {
            println!("1");
        } else {
            println!("0");
        }
        return;
    }
    let d = 998244353;
    let mut a = m * pow_m(m - 1, n - 1, d) % d;
    let mut ans = a;
    for i in 0..k {
        a = a * (n - 1 - i) % d * inv_m((i + 1) * (m - 1) % d, d) % d;
        ans += a;
    }
    println!("{}", ans % d);
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}

fn inv_m(n: usize, d: usize) -> usize {
    pow_m(n, d - 2, d)
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p,ll b)
{
	if(p==0) return 1;
	ll z=powN(a,p/2,b);
	z=(z*z)%b;
	if(p%2) z=(z*a)%b;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2,MOD);
}


int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22) cout<<"bust"<<endl;
	else cout<<"win"<<endl;	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

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

int main(){
  LL A, B;
  cin >> A >> B;
  cout << A * B / gcd(A, B) << endl;
}

Measured memory_bytes: 256
from itertools import product

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

p = [i + k for i, k in product(a, b)]
p.sort(reverse=True)
q = [i + k for i, k in product(p[:k], c)]
q.sort(reverse=True)
print('\n'.join(map(str, q[:k])))


Measured memory_bytes: 219252
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;
const int mod=1e9+7;

int n,m,k,dfn[N],low[N],tim=0,ans=1,fac[N],ifac[N],st[N],tp=0;
vector<int> E[N];
bool vis[55];

int qpow(int a,int b) {
	int ret=1;
	while(b) {
		if(b&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return ret;
}

int C(int n,int m) {
	if(m<0||n<m) return 0;
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

void dfs(int u,int fa) {
	dfn[u]=low[u]=++tim;
	st[++tp]=u;
	for(auto v:E[u])
		if(v!=fa) {
			if(!dfn[v]) {
				dfs(v,u),low[u]=min(low[u],low[v]);
				if(low[v]>=dfn[u]) {
					memset(vis,0,sizeof(vis));
					int x;
					do {
						x=st[tp--];vis[x]=1;
					} while(x!=v);
					vis[u]=1;
					int _n=0,_m=0;
					for(int i=1;i<=n;i++)
						if(vis[i]) {
							++_n;
							for(auto j:E[i]) if(vis[j]) ++_m;
						}
					_m>>=1;
					if(_m<_n) ans=1ll*ans*k%mod;
					else if(_m==_n) {
						int sum=0;
						for(int i=1;i<=_n;i++) sum=(sum+qpow(k,__gcd(i,_n)))%mod;
						ans=1ll*ans*sum%mod*qpow(_n,mod-2)%mod;
					}
					else ans=1ll*ans*C(_m+k-1,k-1)%mod;
				}
			}
			else low[u]=min(low[u],dfn[v]);
		}
}

int main() {
	cin>>n>>m>>k;
	for(int i=1,u,v;i<=m;i++) cin>>u>>v,E[u].push_back(v),E[v].push_back(u);
	fac[0]=1;for(int i=1;i<N;i++) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[N-1]=qpow(fac[N-1],mod-2);
	for(int i=N-1;i;i--) ifac[i-1]=1ll*ifac[i]*i%mod;
	for(int i=1;i<=n;i++) if(!dfn[i]) dfs(i,0);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;



int main() {
	int i, j, k;
	int n;
	string s;
	cin >> n;
	cin >> s;
	ll int dp[5003][5003] = {};
	dp[0][0] = 1;
	rep(i, 1, n+1) {
		rep(j, 0, i+1) {
			if (j == 0) {
				dp[i][j] = (dp[i - 1][j + 1] * 2 + dp[i - 1][j]) % MOD;
			}
			else {
				dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j + 1] * 2) % MOD;
			}
		}
	}
	cout << dp[n][s.length()] << endl;
	return 0;
}

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

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

	if (abs(c-a)<=d)
	{
		cout << "Yes" << "\n";
	}
	else if (abs(b-a)<=d && abs(c-b)<=d)
	{
		cout << "Yes" << "\n";
	}

	else
	{
		cout << "No" << "\n";
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,q,ans=0;
  scanf("%d",&n);
  int i,S[n];
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
scanf("%d",&q);
int T[q];
for(i=0;i<q;i++){
  scanf("%d",&T[i]);
}
for(i=0;i<q;i++){
int left=0,right=n,mid;
while(left<right){
  mid=(left+right)/2;
  if(S[mid]==T[i]){ans++;
break;
  }
  else if(T[i]<S[mid])right=mid;
  else {left=mid+1;}
}
}
printf("%d\n",ans);
return 0;
}



Measured memory_bytes: 2312
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double n,s=0,d,a[100];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=1/a[i];
    }
    d=1/s;
    cout<<d<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int GCD(int a, int b) {
	if (!b) return a;
	else {
		return GCD(b, a % b);
	}
}

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

	K--;
	for (int i = 0; i < N; i++) {
		char c;
		cin >> c;
		if (i == K) {
			int n = (int)c + 32;
			cout << (char)n;
		}
		else {
			cout << c;
		}
	}
	cout << endl;
}

Measured memory_bytes: 3644
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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


struct edge{
    int to, cost;
    edge(int To, int Cost): to(To), cost(Cost){};
};


long long prim(std::vector<std::vector<edge>>& G){
    int V(G.size());
    long long res(0);
    //std::pair<int, int> first: 距離　second: 頂点
    std::priority_queue<std::pair<int, int>,
                        std::vector<std::pair<int, int>>,
                        std::greater<std::pair<int, int>>> que;
    std::vector<int> d(V, INF);
    d[0] = 0;
    que.push({0, 0});

    while(!que.empty()){
        std::pair<int, int> p = que.top(); que.pop();
        int v(p.second);
        if(d[v] < p.first) continue;
        d[v] = 0;
        res += p.first;
        for(edge &e : G[v]){
            if(d[e.to] > e.cost){
                d[e.to] = e.cost;
                que.push({d[e.to], e.to});
            }
        }
    }
    return res;
}

int main(){
    int V, E; std::cin >> V >> E;
    std::vector<std::vector<edge>> G(V);
    {
        int s, t, w; 
        for(int i(0); i < E; ++i){
            std::cin >> s >> t >> w;
            G[s].emplace_back(t, w);
            G[t].emplace_back(s, w);
        }
    }
    std::cout << prim(G) << std::endl;
    return 0;
}



Measured memory_bytes: 6180
/* Author : tushar3105 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<long long int,long long int> ii;					// Pair of integers
typedef vector<long long int> vi;                   				// Vector of integers
typedef vector<vector<long long int>> vvi;                 			// Vector of vi
typedef vector<pair<long long int, long long int>> vii;				// Vector of ii

#define pb push_back								// Push back to vectors
#define mp make_pair								// For pairs
#define ff first								// For pairs
#define ss second								// For pairs
#define all(c) (c).begin(),(c).end()						// Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i,x,y) for(long long int i=(x);i<=(y);++i)				// Loop to go forward
#define reb(i,x,y) for(long long int i=(x);i>=(y);--i)				// Loop to go backward
#define trf(c,it) for(auto it = (c).begin(); it != (c).end(); it++)		// Remember it is an iterator
#define trb(c,it) for(auto it = (c).end()-1; it != (c).begin()-1; it--)		// Remember it is an iterator
#define tc(t) long long int t; cin>>t;while(t--)				// Test cases
//fill (dist,dist+110000,pinf);							// For setting default

const long long int mod = 1e9+7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

lli n, k, mx=ninf, arr[210000];

lli check (lli x)
{
    lli cnt=0;
    
    ref(i,0,n-1)
        if (arr[i]>x)
            cnt=cnt+(arr[i]+x-1)/x-1;
    
    if (cnt<=k)
        return 1;
        
    else
        return 0;
}

lli binarySearch (lli l, lli r)
{ 
    lli mid, ans;
    
    while (l<=r)
    {
        mid = (l+r)/2;
        if (l==mid && r==mid)
			break;
			
        ans = check(mid);
        
        if (ans==1) 
            r=mid;
  
        else
            l=mid+1;
    }
    
    return mid;
} 

int main (void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin>>n>>k;
	
	ref(i,0,n-1)
	    cin>>arr[i];
	
    cout<<binarySearch(1,1e15)<<endl;

	return 0;
}


Measured memory_bytes: 5124
# 2019/06/04
# AtCoder Beginner Contest 047 - C

# Input
s = input()

# Init
ws = s[0]
scnt = 0

for i in range(1, len(s)):
    # Change color: Count up
    if ws != s[i]:
        ws = s[i]
        scnt += 1

# Output
print(scnt)


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.nextLine();
			int origLength = s.length();
			int oneCount = (int) s.chars().filter(x -> x == '1').count();
			int zeroCount = origLength - oneCount;
			System.out.println(2 * Math.min(oneCount, zeroCount));
		}
	}
}

Measured memory_bytes: 28876
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;

long long n,a,x[50],dp[51][51][2501],ret,sm;

int main(){
    LL(n); LL(a);
    REP(i,n) LL(x[i]);

    dp[0][0][0] = 1;
    REP(i,n){
        REP(j,i+2){
            REP(k,2501){
                if (j < 1 || k < x[i]) {
                    dp[i+1][j][k] = dp[i][j][k];
                } else {
                    dp[i+1][j][k] = dp[i][j][k] + dp[i][j-1][k-x[i]];
                }
            }
        }
    }
    REP(i,n+1) ret += dp[n][i][i*a];
    cout << ret-1 << endl;
}


Measured memory_bytes: 49152
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n, q;
  cin >> n >> q;
  vector<tuple<int, int, int>> v;
  vector<int> s(n);
  vector<int> t(n);
  vector<int> x(n);
  rep(i, n){
    cin >> s[i] >> t[i] >> x[i];
    v.push_back(make_tuple(s[i]-x[i], -1, i));
    v.push_back(make_tuple(t[i]-x[i], 0, i));
  }
  rep(i, q){
    int d;
    cin >> d;
    v.push_back(make_tuple(d, 1, i));
  }
  ssort(v);
  int vsz=v.size();
  multiset<int> minx;
  vector<int> ans(q);
  rep(i, vsz){
    if(get<1>(v[i])==-1){
      minx.insert(x[get<2>(v[i])]);
    } else if(get<1>(v[i])==1){
      if(minx.empty()){
        ans[get<2>(v[i])]=-1;
      } else {
        ans[get<2>(v[i])]=*minx.begin();
      //minx.erase(minx.begin());
      }
    } else if(get<1>(v[i])==0){
      minx.erase(minx.find(x[get<2>(v[i])]));
    }
  }
  rep(i,q){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 22688
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,h;
    cin>>n>>h;
    VII arr(n);
    ll ans=0;
    for(auto &x:arr)
    {
        cin>>x;
        if(x>=h)ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ANextAlphabet {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        char c;
        in>>c;
        out<<char(c+1)<<'\n';
    }
};


int main() {
	ANextAlphabet solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
int s[100050];
int st[100050];
int t,n;
int ans=0;
char c;

int main()
{
    while (scanf("%c",&c)!=EOF)
    {
        if (c=='\n') break;
        if (c!='0' && c!='1') scanf("%c",&c);
        s[n++]=(c=='1');
    }
    for (int i=0; i<n; ++i)
    {
        st[t++]=s[i];
        while (t>1 && st[t-2]!=st[t-1])
        {
            t-=2;
            ans+=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	string s ;
	cin>>s ;
	int n = s.size() ;
	if(s[0] == s[n-1])
	{
		if(n % 2 == 0)
			cout<<"First\n";
		else
			cout<<"Second\n";
	}
	else
	{
		if(n % 2 == 0)
			cout<<"Second\n" ;
		else
			cout<<"First\n";
	}
	return 0 ;
}

Measured memory_bytes: 512
import sys
N=int(input())
S=str(input())
tmp=[]
s=list(S)
tmpl=N


if N==1 or N%2!=0:
    print('No')
    sys.exit()
else:
    for i in range(int(N/2)):
        tmp.append(s[i])
tmp2=''
tmp2=''.join(tmp)
if tmp2+tmp2==S:
    print('Yes')
elif N!=0 or N&2==0:
    print('No')


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;

namespace abc161
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var lun = new List<int>();
            lun.Add(0);
            for (var i = 0; i < n; ++i)
            {
                Inc(lun, 0);
            }
            Write(lun);
        }
        static void Inc(List<int> lun, int level)
        {
            if (level < lun.Count - 1 && lun[level] > lun[level + 1])
            {
                // 判定を上位に
                Inc(lun, level + 1);
                return;
            }
            if (level == lun.Count - 1 && lun[level] == 9)
            {
                // くりあげ
                lun[level] = 0;
                lun.Add(1);
            }
            else if (lun[level] == 9)
            {
                // 判定を上位に
                lun[level] = 0;
                Inc(lun, level + 1);
            }
            else
            {
                ++lun[level];
            }
            for (var l = level - 1; l >= 0; --l)
            {
                lun[l] = 0 > (lun[l + 1] - 1) ? 0 : lun[l + 1] - 1;
            }
        }
        static void Write(List<int> lun)
        {
            for (var l = lun.Count - 1; l >= 0; --l)
            {
                Console.Write(lun[l]);
            }
            Console.WriteLine("");
        }
    }
}


Measured memory_bytes: 13268
# atcoder : python3 (3.4.3)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7

# main
N = int(input())
A = list(map(int,input().split()))

ans = 1
cnt = [3]+[0]*(N)

for i in range(N):
    ans *= cnt[A[i]]
    ans %= mod
    cnt[A[i]] -= 1
    cnt[A[i]+1] += 1

print(ans)

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

int main() {
	int r, w, c, o;
	while (cin >> r >> w >> c >> o, r, w, c, o) {
		int ans = 0;

		while ((r + (ans*o)) / w < c)ans++;
		cout << ans << endl;
	}
	return 0;
}

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

int main(){

  int h, w;
  cin >> h >> w;

  string s[111];
  for(int i=0;i<h;i++) cin >> s[i];

  string ans[55][55];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){

      if(s[i][j] == '.'){
	int cnt = 0;
	for(int a=-1;a<2;a++){
	  for(int b=-1;b<2;b++){
	    if(i+a < 0 || i+a == h || j+b < 0 || j+b == w) continue;
	    if(s[i+a][j+b]=='#') cnt++;
	  }
	}
	
	cout << cnt;
      }
      else cout << "#";
    }
    cout << endl;
  }

  //for(int i=0;i<h;i++) cout << ans[i] << endl;

}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"
 
using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, d;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> d;
    int m = d + 1 + d;
    int ans = (n + m - 1)/m;
    cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
  
int main(void)
{
    char str[400];
    int count[100];
    int n,i,j=0;
     
    while(1){
        scanf("%s",str);
        if(str[0]=='-'){
            break;
        }
        scanf("%d",&n);
        for(i=0;i<n;i++){
            scanf("%d",&count[i]);
        }
        for(i=0;i<n;i++){
            strncat(str,str,count[i]);
            int j=0;
            while(str[j] != '\0'){
                str[j] = str[j + count[i]];
                j++;
            }
        }
        printf("%s\n",str);
    }
    return 0;
}

Measured memory_bytes: 1020
#include<stdio.h>
#include<cctype>

int main(void) {
	char ch;

	while (1) {
		scanf("%c", &ch);

		if (islower(ch))printf("%c",toupper(ch));

		else if (isupper(ch))printf("%c", tolower(ch));

		else printf("%c",ch);

		if (ch == '\n')break;
	}

	return 0;
}


Measured memory_bytes: 2576
h,w = [int(i) for i in input().split()]
s = []
for i in range(h):
  array = list(input())
  s.append(array)

from collections import deque
e = [i for row in s for i in row]
chk =[]
def f():
  d = [[float('inf')]*w for i in range(h)]
  d[0][0]=1
  n = [0,0,1,-1]
  m = [1,-1,0,0]
  que = deque([])
  que.append((0,0))
  while que:
    p = que.popleft()
    if p[0]==h-1 and p[1]==w-1:
      break
    for i in range(4):
      nh = p[0]+n[i]
      nw = p[1]+m[i]
      if 0<=nh<h and 0<=nw<w and d[nh][nw]==float('inf') and s[nh][nw]!='#':
        d[nh][nw] = d[p[0]][p[1]]+1
        #print('chk')
        que.append((nh,nw))
  return  d[h-1][w-1]

res = f()
#print(res)
if res != float("inf"):
  print(h*w-res-e.count('#'))
else:
  print('-1')

Measured memory_bytes: 3316
#include <cstdio>
#include <cstring>

using namespace std;

char s[109];

int main() {
  int m;
  scanf("%d%s", &m, s);
  int n = (int)strlen(s);
  for (int i = 0; i < n && i < m; ++i) {
    putchar(s[i]);
  }
  if (n > m) {
    puts("...");
  } else {
    putchar('\n');
  }
}


Measured memory_bytes: 1632
x = int(input())

l = [i**5 for i in range(1000)]

for i in range(len(l)-1):
    for j in range(i+1,len(l)):
        if l[j]-l[i]==x:
            print(int(l[j]**(1/5)),int(l[i]**(1/5)))
            exit()
        if l[j]+l[i]==x:
            print(int(l[j]**(1/5)),-int(l[i]**(1/5)))
            exit()
print('Not found')

Measured memory_bytes: 64120
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
aLst = [[int(x) for x in input().split()] for _ in range(N-1)]
pLst = [[int(x) for x in input().split()] for _ in range(Q)]

tmpLst = [[] for _ in range(N+1)]
for i, j in aLst:
    tmpLst[i].append(j)
    tmpLst[j].append(i)

ansLst = [0] * (N + 1)
for i,j in pLst:
    ansLst[i] += j

def dfs(v, p):
    for i in tmpLst[v]:
        if i == p:
            continue
        ansLst[i] += ansLst[v]
        dfs(i, v)


dfs(1, 0)

ans = ' '.join(map(str, ansLst[1:]))
print(ans)


Measured memory_bytes: 285892
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cassert>
#include <string>
#include <cstring>
#include <bitset>
#include <stack>
#include <iomanip>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};

const int N = 4e2 + 5;

int a [N];
i64 dp [N][N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  F0R (i, n) cin >> a[i];
  auto sum = [&] (int L, int R) {
    i64 s = 0;
    FOR (i, L, R + 1) {
      s += a[i];
    }
    return s;
  };
  for (int T = 1; T < n; T++) {
    for (int L = 0; L + T < n; L++) {
      int R = L + T;
      if (L == R) {
        dp[L][R] = 0;
      } else {
        dp[L][R] = 1e18;
        i64 s = sum (L, R);
        for (int i = L; i < R; i++) {
          dp[L][R] = min (dp[L][R], dp[L][i] + dp[i + 1][R] + s);
        }
      }
    }
  }
  cout << dp[0][n - 1] << '\n';
  return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll LINF = ll(1e18);

int main(){
  int a, b, q;cin>>a>>b>>q;
  vector<ll> shrine(a+2), temple(b+2);
  shrine[0]=temple[0]=-LINF;
  shrine[a+1]=temple[b+1]=LINF;
  rep(i, a)cin>>shrine[i+1];
  rep(i, b)cin>>temple[i+1];
  sort(shrine.begin(), shrine.end());
  sort(temple.begin(), temple.end());
  while(q--){
    ll x;cin>>x;
    int sh_id = lower_bound(shrine.begin(), shrine.end(), x)-shrine.begin();
    int te_id = lower_bound(temple.begin(), temple.end(), x)-temple.begin();
    if(shrine[sh_id]==x){
      cout<<min(temple[te_id], temple[te_id-1])<<endl;
    }else if(temple[te_id]==x){
      cout<<min(shrine[sh_id], shrine[sh_id-1])<<endl;
    }else{
      ll s1, s2, t1, t2;
      s1=x-shrine[sh_id-1];
      s2=shrine[sh_id]-x;
      t1=x-temple[te_id-1];
      t2=temple[te_id]-x;
      cout<<min(
        min(
          max(s1, t1), max(s2, t2)
        ),
        min(
          min(s1, t2)+s1+t2,
          min(s2, t1)+s2+t1
        )
      )<<endl;
    }
  }
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

typedef long long ll;
using namespace std;

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

	int n; cin >> n;
	ll x[1005],y[1005];

	int mod = -1;

	for (int i = 0;i < n;i++){
		cin >> x[i] >> y[i];
		if(i == 0) mod = abs(x[i]+y[i])%2;
		else if(mod != abs(x[i]+y[i])%2){
			cout << -1 << endl;
			return 0;
		}
	}

	vector<string> w(n,""),p(n,"");

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

	for (int i = 0;i < n;i++){
		for (int j = 30;j >= 0;j--){
			ll d  = 1 << j;
			ll nx = d-1;
			//cout << nx << endl;
			if(abs(x[i]-d)+abs(y[i]) <= nx){
				w[i] = "R" + w[i];
				x[i] -= d;
			}else if(abs(x[i]+d)+abs(y[i]) <= nx){
				w[i] = "L" + w[i];
				x[i] += d;
			}else if(abs(x[i])+abs(y[i]+d) <= nx){
				w[i] = "D" + w[i];
				y[i] += d;
			}else if(abs(x[i])+abs(y[i]-d) <= nx){
				w[i] = "U" + w[i];
				y[i] -= d;
			}
		}
		//reverse(w[i].begin(),w[i].end());
		cout << p[i] + w[i] << endl;
	}
	
	return 0;

}


Measured memory_bytes: 384
//
//  main.cpp
//

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

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

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

int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    auto first_appear = make_vec_nd(N, 10, N+1);
    rrep(i,N,0) {
        rep(d,0,10) {
            if (d == S[i] - '0') {
                first_appear[d][i] = i;
            } else {
                first_appear[d][i] = first_appear[d][i+1];
            }
        }
    }
    ll ans = 0;
    rep(a,0,10) {
        rep(b,0,10) {
            rep(c,0,10) {
                ll fa = first_appear[a][0];
                if (fa >= N) {
                    continue;
                }
                ll fb = first_appear[b][fa+1];
                if (fb >= N) {
                    continue;
                }
                ll fc = first_appear[c][fb+1];
                if (fc >= N) {
                    continue;
                }
                ans++;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 2944
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if (e - a <= k) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

bool check(int k){
    for(int i = 2; i * i <= k; i++){
        int checker = i * i;
        while(checker <= k){
            if(checker == k){
                return true;
            }
            checker = checker * i;
        }
    }
    return false;
}

int main() {
    int x;
    cin >> x;
    for(int i = x; i > 1; i--){
        if(check(i)){
            cout << i << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
	int n,m=0;
	cin >> n;
	int ans = 0;
	vector<int> h(n+1, 0);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	h[n] = 2000000000;
	for (int i = 0; i < n; i++) {
		while (h[i] >= h[i + 1]) {
			m++;
			i++;
		}
		ans = max(ans, m);
		m = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;
	
int gcd(int a, int b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 100000;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int32_t main() {
	FAST;

	int a;
	cin >> a;
	cout << a + a * a + a * a * a;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a; i<=b; ++i)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using vl=vector<ll>;
using vp=vector<pll>;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    ll cnt[105]={};
    ll ans=0;
    FOR(i,1,n){
        ll a,b;
        cin>>a>>b;
        if(a==b) cnt[i]=cnt[i-1]+1;
        else cnt[i]=0;
        if(cnt[i]>=3) ++ans;
    }
    cout<<(ans?"Yes":"No");
    return 0;
}

Measured memory_bytes: 3644