akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long ll;


int N, K, Q;

int minimize(vector<int> const &A, int Y){
    vector<int> a(A);
    a.push_back(-1);//番兵
    vector<int> cnd;

    int stt = 0;
    for (int i = 0; i < N+1; i++){
        if (a[i] < Y){
            int end = i;
            vector<int> sub(a.begin()+stt, a.begin()+end);
            sort(sub.begin(), sub.end());
            for (int j = 0; j < (int)sub.size()-K+1; j++){
                cnd.push_back(sub[j]);
            }
            stt = i + 1;
        }
    }
    assert (stt == N+1);

    sort(cnd.begin(), cnd.end());
    if (cnd.size() < Q) {
        return -1;
    } else {
        return cnd[Q-1];
    }
}

int solve(vector<int> const &A){
    int ret = 1<<30;
    for (int i = 0; i < N; i++){
        int Y = A[i];
        int X = minimize(A, Y);
        if (X != -1){
            ret = min(ret, X-Y);
        }
    }
    return ret;
}

int main(){
    cin >> N >> K >> Q;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    cout << solve(A) << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    ans = []
    ps = []
    n = 1
    while True:
        n += 2
        for p in ps:
            if n % p == 0:
                break
        else:
            ps.append(n)
            if n % 5 == 1:
                ans.append(n)
                if len(ans) >= N:
                    return ' '.join(map(str, ans))


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6596
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  long long n,a[1000000],min,x=0,y=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i==0)x+=a[i];
    else y+=a[i];
  }
  min=abs(x-y);
  for(int i=1;i<n-1;i++){
    x+=a[i];
    y-=a[i];
    if(min>abs(x-y))min=abs(x-y);
  }
  cout<<min;
  return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h> 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;

#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)


const int MAXN = 1e6;
const int mod = 1e9 + 7;
const int inf = 1e9;



int main(){

	
	fastio;
	int n;
	cin >> n;

	vector<pii> arr(n);
	fo(n) cin >> arr[i].ss >> arr[i].ff;

	sort(all(arr));

	int gone = 0;

	fo(n){
		if((gone + arr[i].ss) > arr[i].ff){
			cout << "No" << endl;
			return 0;
		}

		gone += arr[i].ss; 
	}

	cout << "Yes" << endl;

	return 0;
 }	

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
const int N = 1e5 + 10 , M = 5e5+10 ,  MOD = 1e9+7;
const int OO = 0x3f3f3f3f;
const double EPS = 1e-3;
 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 


int n, m, x;
int seen[N];
int dp[N];

int solve(int idx){
  
    if(seen[idx]) return 0;
    if(idx == n) return 1;
  //  if(idx > n) return 0;
    int &ret = dp[idx];
    if(~ret) return ret;

   // ret = 0;
    ret = (solve(idx+1) + solve(idx+2))%MOD;

    return ret;


}



 
int main()
{
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    

    cin >> n >> m;
    for(int i = 0 ; i < m ; ++i){
        cin >> x;
        seen[x] = 1;
    }


    memset(dp , -1 , sizeof dp);

    ll ans = solve(0);
    cout << ans << "\n";
    

 
    
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>

using namespace std;

int main(){

    int x1, x2, x3, x4, x5;

    cin >> x1 >> x2 >> x3 >> x4 >> x5;

    if(x1 == 0){
        cout << "1\n";
    }

    if(x2 == 0){
        cout << "2\n";
    }

    if(x3 == 0){
        cout << "3\n";
    }

    if(x4 == 0){
        cout << "4\n";
    }
    
    if(x5 == 0){
        cout << "5\n";
    }

    return 0;
}

Measured memory_bytes: 3484
#include <stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	for (int a = 1; a <= 9; a++)
		for (int b = 1;b <= 9;b++)
		{
			if (a * b == n) {
				puts("Yes");
				return 0;
		}
		}
	puts("No");
}

Measured memory_bytes: 128
def resolve():
  N = int(input())
  base = 10**9+7

  if N == 1:
    print(0)
    return True

  ten = pow(10, N, base)
  nine = pow(9, N, base) * 2
  eight = pow(8, N, base)

  print((ten - nine + eight)%base)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 61804
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

int main() {
	string s, t;
	cin >> s;
	t.clear();
	for (int i = 0; i < s.length(); ++i) {
		t.push_back('x');
	}
	cout << t << endl;
	return 0;
}

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

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

	cout << (1900 * M + 100 * (N - M)) * pow(2, M) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;

set<int> st;
map<int, bool> repeat, vis;

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		if (st.count(x)) repeat[x] = true;
		st.insert(x);
	}
	int ans = 0;
	for (auto i : st) {
		if (vis[i]) continue;
		for (int j = i + i; j <= MAXN; j += i)
			vis[j] = true;
		ans += !repeat[i] and !vis[i];
	}
	cout << ans << "\n";
}

Measured memory_bytes: 59848
#include<stdio.h>
int a[100001];
int com[100001],x[100001],y[100001],b[100001];
int B=400;
int n,q;
void put(int a[100001]);
int min(int a,int b);
void update(int i,int x);
void find(int s,int t);
int main(void){
  put(a);
  int i;
  scanf("%d %d",&n,&q);
  for(i=0;i<q;i++){
    scanf("%d %d %d",&com[i],&x[i],&y[i]);
    if(com[i]==0)
      update(x[i],y[i]);
    else if(com[i]==1)
      find(x[i],y[i]);
  }
  return 0;
}
int min(int a,int b){
  if(a<=b)
    return a;
  else
    return b;
}
void update(int i,int x){
  int j;
  a[i]=x;
  b[i/B]=2147483647;
  for(j=i-i%B;j<min(i-i%B+B,n);j++){
    b[i/B]=min(b[i/B],a[j]);
  }
}
void find(int s,int t){
  int ans=2147483647;
  int j;
  for(j=s;j<=t;){
    if(j%B==0 && j+B<=t-1){
      ans=min(ans,b[j/B]);
      j+=B;
    }else{
      ans=min(ans,a[j]);
      j++;
    }
  }
  printf("%d\n",ans);
}
void put(int a[100001]){
  int i;
  for(i=0;i<100001;i++)
    a[i]=2147483647,b[i]=2147483647;
}

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

bool check (string s){
  int n = s.length();
  if (n%2==1){
    return false;
  }
  else {
    return (s.substr(0,n/2-1)==s.substr(n/2));
  }
}

int choise_sort (int n, int a[]){
  int index;
  for (int i=0; i<n-1; i++){
    int min = a[i], num;
    for (int j=i; j<n-1; j++){
      if (a[j+1]<min){
        min = a[j+1];
        num = j+1;
      }
    }
    index = a[i];
    a[i] = min;
    a[num] = index;
  }
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++){
    cin >> a.at(i);
  }
  sort (a.begin(),a.end());

  int sum = 0, index = 1;
  for (int i=0; i<n-1; i++){
    if (a.at(i+1)==a.at(i)){
      index++;
    }
    else {
      if (index%2==1){
        sum++;
      }
      index = 1;
    }
  }
  
  if (index%2==1){
    sum++;
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s=="SUN"){
        cout <<7 <<endl;
    }
     if(s=="MON"){
        cout <<6 <<endl;
    }
     if(s=="TUE"){
        cout <<5 <<endl;
    }
     if(s=="WED"){
        cout << 4<<endl;
    }
     if(s=="THU"){
        cout <<3 <<endl;
    }
     if(s=="FRI"){
        cout << 2<<endl;
    }
     if(s=="SAT"){
        cout << 1<<endl;
    }
     

}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,X[4];

map<vector<int>,int> MP;
vector<vector<int>> V;

vector<int> E[22];

int state[50050][12];
ll dp[50][20202];
ll mo=1000000007;

int isok(vector<int> v) {
	int cur=0, st=0, ng=0;
	FORR(r,v) {
		cur+=r;
		if(cur==X[st]) st++,cur=0;
		else if(cur>X[st]) return 0;
	}
	return 1+(st==3);
}

int getstate(vector<int> v) {
	
	int ret=isok(v);
	
	if(ret>0) {
		if(ret==2) return 0;
		MP[v]=MP.size();
		V.push_back(v);
		E[v.size()].push_back(MP[v]);
		return MP[v];
	}
	while(1) {
		v.erase(v.begin());
		if(isok(v)==2) return 0;
		if(MP.count(v)) return MP[v];
	}
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X[0]>>X[1]>>X[2];
	
	V.push_back(vector<int>());
	V.push_back(vector<int>());
	
	MP[vector<int>()]=1;
	E[0].push_back(1);
	FOR(i,18) {
		FORR(r,E[i]) {
			vector<int> v=V[r];
			for(x=1;x<=10;x++) {
				v.push_back(x);
				state[r][x]=getstate(v);
				v.pop_back();
			}
		}
	}
	
	dp[0][1]=1;
	FOR(i,N) FOR(j,V.size()) for(x=1;x<=10;x++) (dp[i+1][state[j][x]] += dp[i][j])%=mo;
	ll ret=0;
	FOR(j,V.size()) ret += dp[N][j];
	cout<<dp[N][0]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 10296
import sys
input = lambda: sys.stdin.readline().rstrip() 
s=input()
count=0
s1=str()
s2=str()
for _ in range(int(input())):
  l=list(map(str,input().split()))
  
  if l[0]=='1':
    count+=1
  elif count%2==0:
    if l[1]=='1':
      s1=l[2]+s1
    else:
      s2=s2+l[2]
  else:
    if l[1]=='2':
      s1=l[2]+s1
    else:
      s2=s2+l[2]
s=s1+s+s2
if count%2!=0:
  s=s[::-1]
print(s)

Measured memory_bytes: 4400
N = int(input())
A = [int(input()) for i in range(N)]
a1=max(A)
a2=0
j=0
for i in range(N):
    if A[i]==a1:
        j=j+1
    else:
        j=j
if j!=1:
    for i in range(N):
        print(a1)
else:
    for i in range(N):
        if A[i]>a2 and A[i]!=a1:
            a2=A[i]
    for i in range(N):
        if A[i]==a1:
            print(a2)
        else:
            print(a1)

Measured memory_bytes: 12532
#include <stdio.h>

int main()
{
    int arr[100],n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&arr[i]);
    for(j=n-1;j>=0;j--)
    {
        if(j==0)
            printf("%d\n",arr[j]);
        else
        printf("%d ",arr[j]);
    }
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define INF 2147483640
using namespace std;
int G[10][10],n,m,k,ans;
int cnt(int r,int c)
{
	int vis[10][10]={0},ret=0;
	//cout << r << ' ' << c << '\n';
	for(int i=0; i<n; i++)
		if(r&(1<<i))
			for(int j=0; j<m; j++) vis[i][j]=1;
	for(int i=0; i<m; i++)
		if(c&(1<<i))
			for(int j=0; j<n; j++) vis[j][i]=1;
	for(int i=0; i<n; i++)
		for(int j=0; j<m; j++)
			if(!vis[i][j]) ret+=G[i][j];
	return ret;
}
int main()
{
	//freopen("out.txt","w",stdout);
	cin >> n >> m >> k;getchar();
	for(int i=0; i<n; getchar(),i++)
		for(int j=0; j<m; j++)
			G[i][j]=(getchar()=='#');
	for(int i=0; i<(1<<n); i++)
		for(int j=0; j<(1<<m); j++)
			if(cnt(i,j) == k)
			{
				//cout << i << ' ' << j << '\n';
				ans++;
			}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, a[1000007];
int main() {
	while(scanf("%d", &n), n) {
		for(int i = 0; i < n; i++) scanf("%d", a + i);
		sort(a, a + n);
		int p = 0;
		for(int i = 0; i < n; i++) {
			if(i && a[i - 1] != a[i]) p = 0; p++;
			if(p * 2 > n) {
				printf("%d\n", a[i]); break;
			}
		}
		if(p * 2 <= n) puts("NO COLOR");
	}
}

Measured memory_bytes: 6488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> s(n);
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        s[i] = make_pair(a, b);
    }

    sort(s.begin(), s.end());
    ll cost = 0;
    ll cnt = 0;
    for(int i = 0; i < n; i++){
        if(cnt < m){
            cnt += s[i].second;
            cost += s[i].first * s[i].second;
        }
        while(cnt > m){
            cnt--;
            cost -= s[i].first;
        }
        if(cnt == m) break;
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define X first
#define Y second
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;

int n, a, b;
vector<pair<int, int> > v[100002];
int sol[100002];
int maxi = 0;

void dfs(int x, int p, int b) {
	int boja = 1;
	for (int i = 0; i < v[x].size(); i++) {
		int sus = v[x][i].X;
		if (sus != p) {
			if (boja == b) boja++;
			maxi = max(maxi, boja);
			sol[v[x][i].Y] = boja;
			dfs(sus, x, boja);
			boja++;
		}
	}
}

int main () {

	cin >> n;
	for (int i = 0; i < n-1; i++) {
		cin >> a >> b;
		v[a].push_back({b, i});
		v[b].push_back({a, i});
	}
	
	dfs(1, 0, 0);
	cout<< maxi << "\n";
	for (int i = 0; i < n-1; i++) cout << sol[i] << "\n";

	return 0;
}

Measured memory_bytes: 9344
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}



Measured memory_bytes: 2692
#include <iostream>

int main(int argc, char **argv){

    std::string s;
    
    std::cin >> s;

    int b = -1, e = -1;
    int N = s.size();
    for(int i = 0; i < N; i++){
        if(s.at(i) == 'A' && b == -1) b = i;
        if(s.at(N-1-i) == 'Z' && e == -1) e = N-1-i;
    }

    std::cout << (e-b+1) << std::endl;
    
}


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

int main(){
   
        int count[26] = {};
        char ch;
        
        while( cin >> ch){
            if( isalpha(ch)){
                ch = tolower(ch);
                count[ch - 'a'] += 1;
            }
        }
        
        for(int i=0; i<26; i++){
            printf("%c : %d\n", i+'a', count[i]);
        }
        
    return 0;
    
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    for(char c = 'a'; c <= 'z'; c++){
        if(count(s.begin(),s.end(),c)==0){
            cout << c << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>


using namespace std;
#define PI acos(-1)

int main()
{
	int S;
	cin >> S;
	int a =S%10;
	switch(a){
	    case 0:
	    case 1:
	    case 6:
	    case 8:
	    cout<<"pon"<<endl;
	    break;
	    
	    case 2:
	    case 4:
	    case 5:
	    case 7:
	    case 9:
	    cout<<"hon"<<endl;
	    break;
	    
	    case 3:
	    cout<<"bon"<<endl;
	    break;
	}

}



Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))

A.insert(0,0)
A.append(0)
cost = [0]*(N+1)
for i in range(N+1):
    cost[i] = abs(A[i+1]-A[i])

total = sum(cost)

for i in range(N):
    print(total - cost[i] - cost[i+1] + abs(A[i+2]-A[i]))

Measured memory_bytes: 14176
from heapq import heappush, heappop, heapify, heapreplace
from collections import defaultdict
from bisect import bisect_left


class Solution:
    def main(self):
        path = defaultdict(list)
        N, Q = map(int, input().split())
        freq = [0] * N
        for i in range(N-1):
            ai, bi = map(int, input().split())
            path[ai-1].append(bi-1)
            # path[bi-1].append(ai-1)

        for i in range(Q):
            p, x = map(int, input().split())
            freq[p-1] += x

        stack = [(0, 0)]
        seen = set()
        res = freq[:]
        for i in range(N):
            for other in path[i]:
                res[other] += res[i]

        print(' '.join(map(str, res)))


if __name__ == '__main__':
    Solution().main()

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

int n;
double v[60],ans;

int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>v[i];
    sort(v,v+n);
    ans=v[0];
    for(int i=1;i<n;i++)ans=(ans+v[i])/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#define MAXN 100
using namespace std;

void printA(int *A, int n) {
    for (int i=0; i<n; i++) {
        cout << A[i];
        if (i == n-1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
}

void insertionSort(int *A, int n) {
    for (int i=1; i<n; i++) {
        printA(A, n);
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
    }
}

int main() {
    // input
    int n;
    cin >> n;
    
    int A[MAXN];
    for (int i=0; i<n; i++) {
        cin >> A[i];
    }

    // solve and output
    insertionSort(A, n);
    printA(A, n);
}


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

int main() {
    ll n,k;
    cin>>n>>k;
    if(k==1){
        cout<<0<<endl;
    }else {
        cout<<n-k<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int gcd(int,int);

main()
{
  int a=0,b=0;
  int cd=0;

  while(scanf("%d %d",&a,&b) != EOF)
    {
      cd = gcd(a,b);
      printf("%d\n",cd);
    }
  return 0;
}

int gcd(int m,int n)
{
	// øÉOª éêÍOðÔ·
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// [NbhÌû@
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
    var n int
    fmt.Scan(&n)
    ans, max_h := 0, 0
    for i := 0; i < n; i++ {
        var h int
        fmt.Scan(&h)
        if h >= max_h {
            ans++
            max_h = h
        }
    }
    fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    vector<ll> s(N + 1, 0);
    map<ll, ll> nums;
    for (int i = 0; i < N; i++) s[i + 1] = s[i] + a[i];
    for (int i = 0; i < N + 1; i++) nums[s[i]]++;

    ll res = 0;
    for (auto it : nums)
    {
        ll num = it.second;
        res += num * (num - 1) / 2;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 18732
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,a,b;

int main(void){
	scanf("%d%d%d",&n,&a,&b);
	int di=b-a;
	printf("%s\n",di%2==0?"Alice":"Borys");
	return 0;
}

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

int main()
{

    int N;
    cin >> N;
    
    vector<int> A;
    for (int i = 0; i < N; i++) {
        A.push_back(i);
        cin >> A[i];
    }
    
    int result = 0;
    bool flag = false;
    while (!flag) {
        for (int i = 0; i < N; i++) {
            if (A[i] % 2 == 1) {
                flag = true;
                break;
            }
            A[i] /= 2;
        }
        if (!flag) {
            result++;
        }
    }
    cout << result << endl;

    return 0;   
}

Measured memory_bytes: 256
k, t = map(int, raw_input().split())
a = map(int, raw_input().split())

if t == 1:
    print  k - 1
    import sys
    sys.exit()

m = max(a)
p = a.index(m)

k -= 1
a[p] -= 1

while k:
    m = max(a[:p] + a[p + 1:])
    if m == 0:
        break
    p = a.index(m)
    k -= 1
    a[p] -= 1

print max(a)

Measured memory_bytes: 2696
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) { cin >> a[i]; }
	vector<int> aa(n + 1);

	int m = 0;
	vector<int> b;

	for (int i = n; i >= 1; i--) {
		int ans = 0;
		for (int j = i; j <= n; j = j + i) {
			ans += aa[j];
		}
		aa[i] = (ans + a[i]) % 2;
		if (aa[i]) {
			m++;
			b.push_back(i);
		}
	}

	cout << m << endl;
	for (int i = 0; i < b.size(); i++) {
		if (i > 0) {
			cout << " " << b[i];
		}
		else {
			cout << b[i];
		}
	}
}

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<double> v(N);
  double max = 0;
  int index1 = 0;
  rep(i,N){
    cin >> v[i];
    max < v[i] ? max = v[i],index1 = i:1;
  }
  int temp = int_INF;
  int index2;
  rep(i,N){
    if(i == index1){
      continue;
    }
    else{
      abs(v[i] - max / 2) < temp ? temp = abs(v[i] - max / 2),index2 = i:1;
    }
  }

  printf("%d",static_cast<int>(max));
  cout << " ";
  printf("%d",static_cast<int>(v[index2]));
}


Measured memory_bytes: 1024
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);




int main(){
   IOS

   int n, T;
   cin>>n>>T;

   vector<pii> a(n);

   for(int i = 0; i < n; i++){
      cin>>a[i].first>>a[i].second;
   }
   sort(all(a));


   int dp[n + 1][T + 1];

   memset(dp, 0, sizeof dp);

   //dp[i][j] = ans for 1 to ith dish and time to finish is j mins

   for(int i = 0; i < n; i++){
      for(int t = 0; t < T; t++){
         if(i > 0)dp[i][t] = dp[i - 1][t];
         if(t >= a[i].first){
            dp[i][t] = max(dp[i][t], (i > 0 ? dp[i - 1][t - a[i].first] : 0) + a[i].second);
         }
      }
   }

   int mx = 0;
   for(int i = 1; i < n; i++){
      for(int t = 0; t < T; t++)
         mx = max(mx, dp[i - 1][t] + a[i].second);
   }

   cout<<mx<<"\n";


   // for(int i = 0; i < n; i++){
   //    for(int t = 0; t < T; t++){
   //       cout<<dp[i][t]<<" ";
   //    }cout<<endl;
   // }

   

}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
   if(b&1) res = res * a % mod;
        a = a * a % mod;
   b >>= 1;
    }

    return res;
}



Measured memory_bytes: 38796
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using i64=long long int;

int main() {
    int N;
    cin >> N;
    string A, B, C;
    cin >> A;
    cin >> B;
    cin >> C;

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) {
            if (A[i] == B[i] && B[i] == C[i] && C[i] == A[i]) {
                ans += 0;
            } else {
                ans += 1;
            }
        } else {
            ans += 2;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
B - Two Colors Card Game
https://beta.atcoder.jp/contests/abc091/tasks/abc091_b

"""
import sys
from sys import stdin
from collections import defaultdict
input = stdin.readline


def main(args):
    words = defaultdict(int)

    N = int(input())
    for _ in range(N):
        w = input().strip()
        words[w] += 1
    M = int(input())
    for _ in range(M):
        w = input().strip()
        words[w] -= 1

    ans = 0
    for k, v in words.items():
        ans = max(ans, v)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  int n;
  cin>>n;
  int ans=n%1000==0?0:1000-(n%1000);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define N 100009
#define INF 1000000009
#define MOD 1000000007
typedef long long int ll;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<< endl;
#define tr2(x,y) cout<<x<<" "<<y<<" " << endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << " " << endl;
bool dp[N][109];
int a[N];
int main(){ 
    int i,j,n,m,t,k,x,y;
    sd2(n,k);
    for(i=1; i<=n; i++){
        sd(a[i]);
    }
    for(j=1; j<=k; j++){
        for(i=1; i<=n; i++){
            if(j<a[i])continue;
            if(j==a[i]){
                dp[j][i]=1;
            }
            else{
                bool f=1;
                for(x=1; x<=n; x++){
                    if(dp[j-a[i]][x]){
                        f=0;
                    }
                }
                dp[j][i]=f;
            }
            // tr3(j,a[i],dp[j][i]);
        }
    }
    int ans=0;
    for(i=1; i<=n; i++){
        if(dp[k][i])ans=1;
    }
    
    if(ans==1){
        tr("First");
    }
    else{
        tr("Second");
    }
}


Measured memory_bytes: 10880
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}

			int[][] map = new int[n][n];

			int MAX = 100000;
			int r[] = new int[n];
			int c[] = new int[n];
			Arrays.fill(r, MAX);

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					map[i][j] = sc.nextInt();
					c[j] = Math.max(map[i][j], c[j]);
					r[i] = Math.min(map[i][j], r[i]);
				}
			}
/*			
			System.out.println(Arrays.toString(c));
			System.out.println(Arrays.toString(r));
	*/		boolean m2[][] = new boolean[n][n];
			
			int ans = 0;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					m2[i][j] = (map[i][j]== c[j]&&map[i][j]== r[i]);
					if(m2[i][j]){
						ans = Math.max(ans, map[i][j]);
					}
				}
			}
			System.out.println(ans);
		}

	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

  /*#ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
   fast();


    ll n,m,f=0;
    cin>>n>>m;
    ll gd=gcd(1ll*n,1ll*m);
    ll lcm=1ll*n/gd * 1ll*m;
   
    //cerr<<lcm<<endl;
    string s,t;
    cin>>s>>t;
   // cout<<s<<" "<<t<<endl;
    if(s[0]!=t[0])
    {
      cout<<-1<<endl;
    }
    else
    {
      map<ll,char>mm;
      vi v,vv;

      
      for(int i=1;i<n;i++)
      {
           ll p=i*(lcm/n);
           v.pb(p);
      }
      for(int i=1;i<m;i++)
      {
        ll p=i*(lcm/m);
        vv.pb(p);
        
      }
      sort(v.begin(),v.end());sort(vv.begin(),vv.end());
      /*for(auto tt:v)cout<<tt<<" ";
        cout<<endl;
      for(auto tt:vv)cout<<tt<<" ";
        cout<<endl;*/
      ll size=max(v.size(),vv.size());
      vector<ll> combo(size); 
    vector<ll>::iterator it, st; 
      it = set_intersection(v.begin(), 
                          v.end(), 
                          vv.begin(), 
                          vv.end(), 
                          combo.begin()); 
      //for(auto tt:combo)cout<<tt<<" ";
        //cout<<endl;
      for(int i=0;i<combo.size();i++)
      {
        if(combo[i]==0)
        {
          break;
        }
        else
        {
          ll x=lcm/n;
          ll p=combo[i]/x;
          ll y=lcm/m;
          ll q=combo[i]/y;
          //cout<<"P = "<<p<<" Q = "<<q<<endl;
          if(s[p]!=t[q])
          {
            //cout<<"IFFFFFF "<<s[p]<<" "<<t[q]<<endl;
            f=1;
            break;
          }
        }
      }
  
    //cout<<"F "<<f<<endl;
      if(f)
      {
        cout<<-1<<endl;
      }
      else
      {
        cout<<lcm<<endl;
      }
    
    
  }


return 0;
}


Measured memory_bytes: 2804
// BROWNIE TK

#include <bits/stdc++.h>

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

using namespace std;

/*STD fucntions*/
lli power(lli x,lli y,lli p)
{
	lli res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%p;
		//y must be even now
		y=y>>1; //y=y/2
		x=(x*x)%p;
	}
	return res;
}
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli max(lli a, lli b) 
{
  if (a > b)
    return a;
  return b;
}
lli min(lli a, lli b) 
{
  if (a < b)
    return a;
  return b;
}
lli bins(lli arr[], lli l, lli r, lli x)
{
  if (r >= l) {
    lli mid = l + (r - l) / 2;
    if (arr[mid] == x)
      return mid;
    if (arr[mid] > x)
      return bins(arr, l, mid - 1, x);
    return bins(arr, mid + 1, r, x);
  }
  return -1;
}
lli modi(lli a,lli m)
{
// fermat little thm where m is prime
return power(a,m-2,m);
}
/*CODE BEGINS*/
int main()
{
  kira;
  lli n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  s[k-1]=tolower(s[k-1]);
  cout<<s;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
typedef complex<ld> point;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string t;
    cin >> t;
    for(int i=0;i<t.size();i++)
    {
        if(t[i]=='?')
            cout << 'D';
        else
            cout << t[i];
    }
    cout << '\n';

    return 0;
}


Measured memory_bytes: 3748
n = input()

ans = "No"
if n == "hi":
    ans = "Yes"
if n == "hihi":
    ans = "Yes"
if n == "hihihi":
    ans = "Yes"
if n == "hihihihi":
    ans = "Yes"
if n == "hihihihihi":
    ans = "Yes"

print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define ll long long
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

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

	ll N;

	cin >> N;

	ll A[N], B[N], C[N];

	for(ll l = 0; l < N; l++){
		cin >> A[l];
	}

	for(ll l = 0; l < N; l++){
		cin >> B[l];
	}

	for(ll l = 0; l < N; l++){
		cin >> C[l];
	}

	sort(A, A+N);
	sort(B, B+N);
	sort(C, C+N);

	ll ans = 0;
	for(ll b = 0; b < N; b++){

		ll ok = -1;
		ll ng = N;

		while(ng - ok > 1){
			ll mid = (ok + ng)/2;

			if(A[mid] < B[b]) {
				ok = mid;
			} else {
				ng = mid;
			}
		}

		ll a = ok + 1;

		ok = N;
		ng = -1;
		while(ok - ng > 1){

			ll mid = (ok + ng)/2;

			if(C[mid] <= B[b]) {
				ng = mid;
			} else {
				ok = mid;
			}
		}
		ll c = N - ok;

		ans += a * c;

	}

	cout << ans << endl;

	Never To return 0;
}


Measured memory_bytes: 2560
a, b, q = gets.split.map(&:to_i)
INF = 1e18
s = [-INF] + a.times.map{ gets.to_i } + [INF]
t = [-INF] + b.times.map{ gets.to_i } + [INF]

q.times do
    x = gets.to_i
    s_r = s.bsearch_index{ |ss| ss > x }
    t_r = t.bsearch_index{ |tt| tt > x }
    ans = INF 
    s[s_r-1,2].each do |ss|
        t[t_r-1,2].each do |tt|
            ans = [ans, (x - ss).abs + (ss - tt).abs, (x - tt).abs + (ss - tt).abs].min
        end
    end
    puts ans
end

Measured memory_bytes: 7988
import java.util.Scanner;

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

        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        for (int i = A; i <= B; i++) {
            if (i % K == 0) {
                System.out.println("OK");
                return;
            }
        }

        System.out.println("NG");
    }
}

Measured memory_bytes: 35840
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	string s; cin >> s;
	if (n % 2 == 1) cout << "No";
	else {
		if (s.substr(0, n / 2) == s.substr(n / 2)) cout << "Yes";
		else cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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;

int main(){
  int m,k;
  cin >> m >> k;
  if(m==0){
    if(k==0){
      cout << "0 0" << endl;
    }else{
      cout << -1 << endl;
    }
  }else if(m==1){
    if(k==0){
      cout << "0 0 1 1" << endl;
    }else{
      cout << -1 << endl;
    }
  }else{
    int mx = 1<<m;
    if(k<mx){
      rep(i,mx){
        if(i!=k)cout << i << " ";
      }
      cout << k << " ";
      rep(i,mx){
        if((mx-1-i)!=k)cout << mx-1-i << " ";
      }
      cout << k << endl;
    }else{
      cout << -1 << endl;
    }
  }
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long d = sc.nextLong();
		int ans = 0;
		for(int i = 0; i < n; i++) {
			long x = sc.nextLong();
			long y = sc.nextLong();
			if((x * x + y * y) <= d * d ) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 60540
n,m=map(int,input().split())
x=sorted([int(i) for i in input().split()])
xbet=sorted([abs(x[i+1]-x[i]) for i in range(m-1)],reverse=True)
y=sum(xbet)
if n>=m:
    print(0)
else:
    print(y-sum(xbet[:n-1]))


Measured memory_bytes: 13832
n = gets.chomp
if n[0] == "1"
  n[0] = "9"
else 
  n[0] = "1"
end
if n[1] == "1"
  n[1] = "9"
else 
  n[1] = "1"
end
if n[2] == "1"
  n[2] = "9"
else 
  n[2] = "1"
end

puts n


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

int main() {
  int n;
  cin>>n;
  vector<int>x(n);
  vector<int>y(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int i=0;i<n;i++){
    cin>>y[i];
  }
  double kotae1=0;
  for(int i=0;i<n;i++){
    kotae1+=abs(x[i]-y[i]);
  }
  cout<<fixed<<setprecision(12)<<kotae1<<endl;
  
  double kotae2=0;
  for(int i=0;i<n;i++){
    kotae2+=abs(x[i]-y[i])*abs(x[i]-y[i]);
  }
  kotae2=sqrt(kotae2);
  cout<<fixed<<setprecision(12)<<kotae2<<endl;
  
  double kotae3=0;
  for(int i=0;i<n;i++){
    kotae3+=abs(x[i]-y[i])*abs(x[i]-y[i])*abs(x[i]-y[i]);
  }
  double a=(double)1/(double)3;
  kotae3=pow(kotae3,a);
  cout<<fixed<<setprecision(12)<<kotae3<<endl;
  
  double kotae4=0;
  for(int i=0;i<n;i++){
    kotae4=max((double)abs(x[i]-y[i]),kotae4);
  }
  cout<<fixed<<setprecision(12)<<kotae4<<endl;
  
  return 0;
}


Measured memory_bytes: 3492
import java.io.{BufferedReader, InputStreamReader}

import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine.toInt
    val as = in.readLine.split("\\s+").map(_.toInt)

    val nums = Array.ofDim[ArrayBuffer[Int]](n + 1)
    for {
      i <- 0 to n
    } {
      nums(i) = new ArrayBuffer[Int]
    }
    for {
      i <- (n - 1) to 0 by -1
    } {
      nums(as(i)) += i
    }

//    System.err.println("----")
//    for {
//      i <- 1 to n
//    } {
//      System.err.println(i + "=" + nums(i))
//    }

    def blocks(k: Int): Option[Int] = {
      @tailrec
      def haveLessOne(currentIndex: Int): Boolean = {
        val num = as(currentIndex)
        if (num == 1) {
          true
        } else {
          nums(num - 1).find(_ < currentIndex) match {
            case Some(lessIndex) => haveLessOne(lessIndex)
            case None => false
          }
        }
      }

      nums(k).reverse.find(haveLessOne)
    }

    for {
      k <- n to 1 by -1
    } {
      blocks(k) match {
        case Some(index) =>
          System.out.println(n - k)
          return
        case None =>
      }
    }

    System.out.println(-1)
  }
}


Measured memory_bytes: 99332
# -*- coding: utf-8 -*-

N, M = [int(i) for i in input().split()]
X = list(map(int, input().split()))

sorted_X = sorted(X)

diff_list = []
for i, j in zip(sorted_X, sorted_X[1:]):
    diff_list.append(j - i)

ans = sorted(diff_list, reverse=True)[N-1:]
print(sum(ans))

Measured memory_bytes: 13968