akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    N = int(input())
    X = []
    for i in range(N):
        S,P = map(str, input().split())
        P = int(P)
        X.append((S,P,i))
    X.sort(key=lambda x: x[1], reverse=True)
    X.sort(key=lambda x: x[0])

    for x in X:
        print(x[2]+1)

    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

# vim: set foldmethod=marker:}}}


Measured memory_bytes: 105196
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
  ll n,k;cin>>n>>k;
  ll ans=100000000000;
  vector<ll>t(n);
  for(int i=0;i<n;i++)
    cin>>t.at(i);
  sort(t.begin(),t.end());
  for(int i=0;i<=n-k;i++)
  {
    ll a=t.at(i+k-1)-t.at(i);
    ans=min(ans,a);
  }
  cout<<ans;
}
      
      

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long M = sc.nextInt();

		long a = N-2;
		long b = M-2;

		System.out.println(Math.abs(a*b));
	}

}


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

string bucket_sort(string str){
    vector<int>a(256,0);
    for(int i=0;i<str.length();i++){
        a[str[i]-'a']++;
    }
    string temp;
    for(auto i:a){
        temp.append(1,char('0'+i));
    }
    
    return temp;   
}

int main(){
  
    long int n,i;
    cin>>n;
    string s;
    unordered_map<string,long int>hash;
    
    for(i=0;i<n;i++){
        cin>>s;
        hash[bucket_sort(s)]++;
    }
    
    long long int res=0;
    
    for(auto &p:hash){
        res = res+(p.second*(p.second-1))/2;
    }
    cout<<res;
   
  return 0;
}

Measured memory_bytes: 36644
import java.io.StreamCorruptedException;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {
    static long pow10(int n){
        long a = 1;
        for(int i=0;i<n;i++) a*=10;
        return a;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(in);
        int n, k, A, r, K;
        while(true){
            n = sc.nextInt();
            k = sc.nextInt();
            if(n == 0 && k == 0) break;

            A = 0; K = 1;
            for(int i=1;;i++){
                long p = 9 * pow10(i-1) * i;
                if((long)n - (A+p) < 0) break;
                A += (int)p;
                K = i+1;
            }
            r = n - A;

//            out.println("n="+n+" ,A="+A+" ,r="+r +" ,K="+K);
            int v = (int)pow10(K-1) + r / K;
            int vi = r % K;

//            out.println(v+","+vi);
            StringBuilder sb = new StringBuilder();
            int ii = v;
            while(sb.length() <= 2*k){
                sb.append(ii++);
            }
            if(vi > 0){
//                out.println(sb);
                out.println(sb.substring(vi-1, vi-1+k));
            }
            else{
                String vv = (v-1)+"";
                sb.insert(0, vv.charAt(vv.length()-1));
                out.println(sb.substring(0, k));
            }
        }
    }

}

Measured memory_bytes: 12000
n = int(input())
h = list(map(int, input().split()))

i = 0

while True:
    if i == n-1:
        print('Yes')
        break
    if h[i] <= h[i+1]:
        if i == 0 or h[i-1] < h[i]:
            h[i] -= 1
        i += 1
    elif h[i] == h[i+1]+1 and (i==0 or h[i-1] < h[i]):
        h[i] -= 1
        i += 1
    else:
        print('No')
        break

Measured memory_bytes: 14252
MOD = 10**9 + 7

N, M = map(int, input().split())
As = list(map(int, input().split())) + [0]
Bs = list(map(int, input().split())) + [0]

NM = N*M
As.sort(reverse=True)
Bs.sort(reverse=True)

ans = 1
iA, iB = 0, 0
for x in reversed(range(1, NM+1)):
    isOnly = False
    if As[iA] == x:
        r = 1
        isOnly = True
        iA += 1
    else:
        r = iA
    if Bs[iB] == x:
        c = 1
        isOnly = True
        iB += 1
    else:
        c = iB

    if isOnly:
        ans *= r*c
    else:
        ans *= r*c - (NM - x)
    ans %= MOD

print(ans)


Measured memory_bytes: 41324
# coding: utf-8
N = int(input())

lst = [i+1 for i in range(N)]
i = 0

while (i < N):
    if lst[i] % 3 == 0 and lst[i] % 5 == 0:
        lst[i] = 0
    elif lst[i] % 3 == 0:
        lst[i] = 0
    elif lst[i] % 5 == 0:
        lst[i] = 0
    i = i + 1;

print(sum(lst))

Measured memory_bytes: 48552
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > pq;
// cout << fixed << setprecision(5) << sum << endl;

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}

long long nCr(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


// a^n mod を計算する
long long modpow(long long a, long long n, long long MOD) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long Mod) {
    return modpow(a, Mod - 2, Mod);
}


bool IsPrime(int x){
    for (int i = 2; i*i <= x; i++){
        if (x % i == 0){
            return false;
        }
    }
    return true;
}

vector<pair<ll, ll> > PrimeFactor(ll N){
    vector<pair<ll, ll> > prime;
    for (int i = 2; i*i <= N; i++){
        if (N % i != 0) continue;
        int cnt = 0;
        while (N % i == 0){
            cnt++;
            N /= i;
        }
        prime.push_back({i, cnt});
    }
    if (N > 1){
        prime.push_back({N, 1});
    }
    return prime;
}

vector<pair<ll, ll> > CountPrime(ll N){
    vector<pair<ll, ll> > prime;
    for (ll i = 2; i * i <= N; i++){
        if (N % i != 0) continue;
        ll cnt = 0, n = N;
        while (n % i == 0){
            cnt++;
            n /= i;
        }
        prime.push_back({i, cnt});
    }
    prime.push_back({N, 1});
    return prime;
}


int main(){
    ll N, M; cin >> N >> M;
    string S, T; cin >> S >> T;
    ll g = GCD(M, N);
    ll Length = M / g * N;
    ll n = N/g, m = M/g;
    ll res = Length;
    for (int i = 0; i < g; i++){
        ll a = i*n;
        ll b = i*m;
        
        if (a*Length/N == b*Length/M){
            if (S[a] != T[b]) res = -1;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
	char a[100];
	int w[26];
	int s = 0;
	int q;
	gets(a);
	for(q = 0; a[q] != '\0'; q++);
	for(int j = 97; j <= 123; j++){
		int b = 0;
	for(int i = 0; i <= q; i++){
		if(a[i] == (char)j)
		{
			b++;
			}
		}
		w[j - 97] = b;
	}
	for(int m = 0; m <= 26; m++){
			if(w[m] % 2 == 1)
		{
		s++;	
			}
			}
		if(s > 0)
		{
			printf("No\n");
			}
			else
			{
				printf("Yes\n");
				}
		return 0;
	}

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

using namespace std;

int main (void) {
    int N, tmp;
    vector<int> d;

    cin >> N;
    for ( int i=0; i<N; i++ ) {
        cin >> tmp;
        d.push_back(tmp);
    }

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

    int ans=1;
    for ( int i=1; i<N; i++ ) {
        if ( d.at(i) == d.at(i-1) )
            continue;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


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

int main(int argc, char *argv[]) {
	int num_operation = 0;
	std::string input_s;
	std::cin >> num_operation;
	std::cin >> input_s;

	int max = 0;
	int x = 0;
	for (int i = 0; i < input_s.size(); i++) {
		if (input_s[i] == 'I') {
			x++;
		} else {
			x--;
		}
		if (x >= max) {
			max = x;
		}
	}
	std::cout << max << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int asc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}

int main(){
  int i,j,k=0,N;
  long x;
  
  scanf("%d %ld",&N,&x);
  long A[N];
  for(i=0;i<N;i++)
    scanf("%ld ",&A[i]);
  qsort(A,N,sizeof(long),asc);
  
  for(i=0;i<N-1;i++){
    if(x<A[i]){
      break;
    }
    x-=A[i];
    k++;
  }
  if(A[N-1]==x)
    k++;
  printf("%d\n",k);
  return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int l[10];
    int v1,v2;
    int l_total;
    double sec_tmp;
    int sec;
    int i;
    
    while(true){
        l_total=0;
        for(i=0;i<10;i++){
            if(scanf("%d,",&l[i])==EOF)return 0;
            l_total+=l[i];
        }
        scanf("%d,%d",&v1,&v2);
        sec_tmp=(double)(v1*l_total)/(v1+v2);
        i=0;
        while(sec_tmp>0){
            sec_tmp-=(double)l[i];
            i++;
        }
        cout<<i<<endl;
    }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int n,a,b,c; cin>>n>>a>>b>>c;
    string s[n]; for(int i=0; i<n; i++) cin>>s[i];
    string ans="";
    for(int i=0; i<n; i++){
        if(i<n-1&&a==1&&b==1&&c==0&&s[i]=="AB"){
            if(s[i+1]=="AC"){
                b--; a++;
                ans+='A';
            }
            else{
                a--; b++;
                ans+='B';
            }
        }
        else if(i<n-1&&a==1&&b==0&&c==1&&s[i]=="AC"){
            if(s[i+1]=="AB"){
                c--; a++;
                ans+='A';
            }
            else{
                a--; c++;
                ans+='C';
            }
        }
        else if(i<n-1&&a==0&&b==1&&c==1&&s[i]=="BC"){
            if(s[i+1]=="AB"){
                c--; b++;
                ans+='B';
            }
            else{
                b--; c++;
                ans+='C';
            }
        }
        else if(s[i]=="AB"){
            if(a>b){
                a--; b++;
                ans+='B';
            }
            else{
                b--; a++;
                ans+='A';
            }
        }
        else if(s[i]=="BC"){
            if(b>c){
                b--; c++;
                ans+='C';
            }
            else{
                c--; b++;
                ans+='B';
            }
        }
        else if(s[i]=="AC"){
            if(a>c){
                a--; c++;
                ans+='C';
            }
            else{
                c--; a++;
                ans+='A';
            }
        }
        if(a<0||b<0||c<0){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes\n";
    for(char i:ans) cout<<i<<"\n";
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

int check(vector<int>& vec,int k)
{
  int res = 0,cal = 1;
  for(int i=0;i<vec.size();i++)
    {
      if(i < k)
	{
	  cal *= vec[i],res = max(cal,res);
	  continue;
	}
      cal /= vec[i-k];
      cal *= vec[i];
      res = max(cal,res);
    }
  return res;
}

int main()
{
  int n,k;
  while(cin >> n >> k,n|k)
    {
      vector<int> vec;
      vec.resize(n);
      for(int i=0;i<n;i++)
	cin >> vec[i];
      int ans = 0,C;
      C = check(vec,k);
      for(int i=0;i<n;i++)
	for(int j=i+1;j<n;j++)
	  swap(vec[i],vec[j]),ans = max(ans,check(vec,k)),swap(vec[i],vec[j]);
      ans-C>=0?cout << ans-C << endl:cout << "NO GAME" << endl;
    }
  return 0;
}

Measured memory_bytes: 1200
#include <cstdio>

typedef long long ll;
const int maxn=200000+10,maxa=2000+10,mod=1000000007;
int x[maxn],y[maxn];
ll fac[maxa*4],ifac[maxa*4],f[maxa*2][maxa*2];

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

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

int main(){
	// freopen("in.txt","r",stdin);
	int n;ll ans=0;scanf("%d",&n);
	fac[0]=ifac[0]=1;
	for(int i=1;i<maxa*4;++i)fac[i]=fac[i-1]*i%mod;
	ifac[maxa*4-1]=power(fac[maxa*4-1],mod-2);
	for(int i=maxa*4-2;i>=1;--i)ifac[i]=ifac[i+1]*(i+1)%mod;
	for(int i=1;i<=n;++i){
		scanf("%d%d",x+i,y+i);
		++f[maxa-x[i]][maxa-y[i]];
	}
	for(int i=1;i<maxa*2;++i)
		for(int j=1;j<maxa*2;++j)
			f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	for(int i=1;i<=n;++i){
		ans=(ans+f[maxa+x[i]][maxa+y[i]]-C((x[i]+y[i])*2,x[i]*2)+mod)%mod;
	}
	// for(int i=1;i<=n;++i)
	// 	for(int j=1;j<=n;++j)
	printf("%lld\n",ans*power(2,mod-2)%mod);
	return 0;
}

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

def gcd(x, y):
    if x == 0 or y == 0:
        return max(x, y)
    g = x % y
    if g == 0:
        return y
    return gcd(y, g)

R = [0] * N
R[N-1] = w = 0
for i in range(N-2, -1, -1):
    R[i] = w = gcd(w, A[i+1])

L = [0] * N
L[0] = w = 0
for i in range(1, N):
    L[i] = w = gcd(w, A[i-1])

w = 1
for i in range(N):
    w = max(w, gcd(L[i], R[i]))

print(w)


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

int main(void)
{
	int n;
	while(cin >> n && n)
	{
		vector<int> dp(n + 5);
		dp[0] = 1;
		for (int i = 0; i < n; i++)
		{
			dp[i + 1] += dp[i];
			dp[i + 2] += dp[i];
			dp[i + 3] += dp[i];
		}
		int days = max(dp[n] / 10, 1);
		cout << (days / 365 + !!(days % 365)) << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline int ubnd(T&v,ET(T) x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T) x){return lower_bound(begin(v),end(v),x)-begin(v);}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline void inpt(T&v,int n,function<ET(T)()>f=In<ET(T)>){for(v.reserve(n);n--;v.emplace_back(f()));}
TT inline void show(T&v,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),cout<<x;cout<<e;}
#undef TT
#undef ET

inline void fast_io(){ios::sync_with_stdio(0); cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline string instr(){string x;cin>>x;return x;}
inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a, ll p){return pow_mod(a,p-2,p);}

const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000;
const int MAX_N = (1 << 15) + 1;

bool sieve[MAX_N] = {true, true};
int main()
{
  for (int i = 2; i * i < MAX_N; i++){
    if (sieve[i]) continue;
    for (int j = i * i; j < MAX_N; j += i) sieve[j] = true;
  }
  int n;
  while (n = in()){
    int cnt = 0;
    for (int i = 2; i <= n / 2; i++){
      if (!sieve[i] && !sieve[n - i]) cnt++;
    }
    cout << cnt << endl;
  }

  return (0);
}

// priority_queue queue deque front top push pop map set stringstream max_element min_element insert count find get tie make_tuple

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

using namespace std;

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

    vector<int> h(N);
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    
    int min = 1000000000;

    for(int i = 0; i + K - 1 < N ; i++){
        int dig = h[i + K - 1] - h[i];
        if (dig <= min) {
            min = dig;
        }
    }

    cout << min << endl;
    
    


}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()

ll N;
vector<vector<vector<double>>> note;
double dp(ll a,ll b,ll c) {
  if(a==0&&b==0&&c==0) {
return 0;
  }
  if(note[a][b][c]>=0) {
return note[a][b][c];
  }
  
 
  double s=0;
  double z=(N-a-b-c)/(double)N;
  z=1-z;
  s+=1/z;
  if(a>0) {
  s+=dp(a-1,b,c)*a/N/z;
  }
  if(b>0) {
  s+=dp(a+1,b-1,c)*b/N/z;
  }
  if(c>0) {
  s+=dp(a,b+1,c-1)*c/N/z;
  }
  
note[a][b][c]=s;
  
  return s;
}
  
  
  
  


 
int main() {
 
  cin>>N;
  note=vector<vector<vector<double>>> (N+1,vector<vector<double>>(N+1,vector<double>(N+1,-1)));
 vector<ll> vec(3,0);
  for(ll i=0;i<N;i++) {
ll A;
    cin>>A;
    if(A==1) {
vec[0]++;
    }
    else if(A==2) {
vec[1]++;
    }
    else {
vec[2]++;
    }
  }
 cout<<fixed<<setprecision(10);
 cout<<dp(vec[0],vec[1],vec[2])<<endl;

}
  
  
  
  
  
  
  
  
  
  


Measured memory_bytes: 219940
#include <stdio.h>
#include <stdlib.h>
int H[100009],num[100009];
int main()
{
    int n,m,sum=0;;
    scanf("%d%d",&n,&m);
    int i;
    for(i=1;i<=n;i++){
        num[i]=1;
        int h;
        scanf("%d",&h);
        H[i]=h;
    }
    for(i=1;i<=m;i++){
        int p,q;
        scanf("%d%d",&p,&q);
        if(H[p]<H[q])
            num[p]=0;
        else if(H[q]<H[p])
            num[q]=0;
        else
            num[q]=num[p]=0;
    }
    for(i=1;i<=n;i++)
        if(num[i])
        sum++;
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 2516
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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


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

using namespace std;

int main()
{
    int n;
    long long a[100000], b[100000], c[100000], l, r, m, d[100000];
    vector <pair <int, long long> > v;
    long long ans = 0;
    cin >> n;

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

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

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

    sort(c, c+n);

    for (int i = 0; i < n; i++)
    {
        l = -1;
        r = n-1;

        while (l < r-1)
        {
            m = (l+r)/2;

            if (c[m] > b[i])
                r = m;
            else
                l = m;
        }

        if (c[r] <= b[i])
            v.push_back(make_pair(b[i], 0));
        else
            v.push_back(make_pair(b[i], n-r));
    }

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

    d[0] = v[0].second;

    for (int i = 1; i < n; i++)
        d[i] = d[i-1]+v[i].second;

    for (int i = 0; i < n; i++)
    {
        l = -1;
        r = n-1;

        while (l < r-1)
        {
            m = (l+r)/2;

            if (v[m].first > a[i])
                r = m;
            else
                l = m;
        }

        if (v[r].first > a[i])
        {
            if (r == 0)
                ans += d[n-1];
            else
                ans += d[n-1]-d[r-1];
        }
    }

    cout << ans;
}


Measured memory_bytes: 5492
#if loc||local
#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll x,k,d;
  cin>>x>>k>>d;

  ll ax = abs(x);
  constexpr auto ceil = [](auto a,auto b){return (a-1)/b+1;};
  if(ceil(ax,d)>k){
    ax -= k*d;
    cout<< ax <<endl;
    return 0;
  }

  ll xd = ax/d;
  k -= xd;
  ax -= xd*d;

  if(k&1)ax-=d;
  
  cout<<abs(ax)<<endl;

}
  


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

int main() {
  //input
  int A, B, C;
  cin >> A >> B >> C;
  //calc & output
  if ( A == B && B == C ) {
    cout << "No" << endl;
    return 0;
  }
  if ( A != B && B != C && C != A ) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(abc.Sum() == abc.Max() * 2 ? "Yes" : "No");
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    int ans = 0;
    ans = n/500;
    ans *= 1000;
    n %= 500;
    ans += (n/5)*5;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
int main(){
    int a,b,c;
    std::scanf("%d %d %d",&a,&b,&c);
    if(a<=b&&b<=c)std::printf("%d\n",a+b);
    else if(a<=b&&c<=b)std::printf("%d\n",a+c);
    else if(b<=a&&a<=c)std::printf("%d\n",a+b);
    else if(b<=a&&c<=a)std::printf("%d\n",b+c);
    else if(c<=a&&a<=b)std::printf("%d\n",a+c);
    else std::printf("%d\n",b+c);
}

Measured memory_bytes: 128
# https://atcoder.jp/contests/abc098/tasks/abc098_b

if ARGV[0]=="LOCAL_DEV"
  define_method("debug") do |var|
    p var
  end
else
  define_method("debug") do |var|
  end
end

N=STDIN.gets.strip.to_i
S=STDIN.gets.strip
ans=0
(1..S.size-1).each do |i|
  s=S[0,i]
  t=S[i,N]
  shash = Hash.new(0)
  thash = Hash.new(0)
  s.chars do |a|
    shash[a]+=1
  end
  t.chars do |a|
    thash[a]+=1
  end
  c=0
  ('a'..'z').each do |a|
    if shash[a]>0 && thash[a]>0
      c+=1
    end
  end
  ans=[ans,c].max
end

puts ans


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


def get_input() -> tuple:
    """
    標準入力の取得

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    A = list(map(int, input().split()))

    return N, A


def main(N: int, A: list) -> None:
    """
    求解処理.\n
    数列内の負の数が奇数か偶数かで場合分けを行う.

    Args:\n
        N (int): 整数列内の要素数
        A (list): 整数列
    """
    minus_sign_count = len([a for a in A if a < 0])
    B = [abs(a) for a in A]
    if minus_sign_count % 2 == 1:
        # 絶対値が最小の要素の正負を反転する
        B[B.index(min(B))] *= -1
    result = sum(B)

    # 結果出力
    print(result)


if __name__ == "__main__":
    N, A = get_input()
    main(N, A)


Measured memory_bytes: 14224
import sys
a,b,c,k = map(int,input().split())
 
an = 0
if k<=a:
    an = k
    print(an)
    sys.exit()
else:
    an = a
    k -= a
if k<=b:
    print(an)
    sys.exit()
else:
    k -= b
an -= k
print(an)

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define OUT(a) cout << (a) << "\n"

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const ll MOD = 10e9 + 7;
int dp[100001];

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i, n) cin >> h[i];
    REP(i, n+1) dp[i] = INT_MAX;
    dp[0] = 0;
    for(int i=0; i<n-1; i++) {
        if (i+2 < n) {
            dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
        }
        if (i+1 < n) {
            dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int n;cin >> n;
  vint a(n);vin(a);
  vint ans(n);
  rep(i,n){
    ans[0]+=a[i];
    if(i%2)ans[0]-=a[i]*2;
  }
  repi(i,1,n)
    ans[i]=2*a[i-1]-ans[i-1];

  rep(i,n)
    cout << ans[i] << " ";
  cout << endl;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define LL long long
#define SZ(x) (int)x.size()-1
#define F(i,a,b) for (int i=a;i<=b;++i)
#define DF(i,a,b) for (int i=a;i>=b;--i)
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
int read(){
    char ch=getchar(); int w=1,c=0;
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
    for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
    return w*c;
}
int main(){
	int x=read(),y=read(),a=0;
	if (x<=3){
		a+=3-x+1;
	}
	if (y<=3) a+=3-y+1;
	if (a==6) a+=4;
	cout<<a*100000<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include <bitset>
#include <type_traits>
#include <string>
#include <climits>
#include <cmath>
#include <vector>


using namespace std;

// long long func(long long a, long long b, long long c){ 
//     long long ret = 0;
//     a %= c; 
//     while (b) { 
//         if (b & 1){
//         	ret = (ret + a) % c; 
//         }  
//         a = (2 * a)%c; 
//         b >>= 1;
//     } 
//     return ret; 
// } 

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

	int N, a, b, c, boy=0;
	cin >> N;
	for(a=1;a<N;a++){
		// cout << "doing" << a << endl;
		for(b=(N/a)+1;b>0;b--){
			if((a*b)<N){
				// cout << a << " times " << b << "=" << a*b << endl;
				boy += b;
				// cout << boy << endl;
				break;
			}
		}
	}

	cout << boy << endl;
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int A, B, C, X, Y;

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

    std::cin >> A >> B >> C >> X >> Y;

    int minCost = std::numeric_limits<int>::max();

    for(int i=0;i<=std::max(X, Y);++i){
        int cost = C * 2 * i + A * std::max(X - i, 0) + B * std::max(Y - i, 0);
        minCost = std::min(minCost, cost);
    }

    std::cout << minCost << std::endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
	private long count;
	private int[] a;
	 
	public static void main(String[] args) {
		new Main();
	}
	 
	public Main() {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		 
		try {
			int nico = Integer.parseInt(in.readLine());
			String[] se = in.readLine().split(" ");
			 
			a = new int[nico];
			for (int i = 0; i < nico; i++) {
				a[i] = Integer.parseInt(se[i]);
			}
			 
			mergeSort(0, nico);
			
			System.out.println(count);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	 
	public void merge(int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		 
		int[] l = new int[n1];
		int[] r = new int[n2];
 
		for (int i = 0; i < n1; i++) {
			l[i] = a[left + i];
		}
		 
		for (int i = 0; i < n2; i++) {
			r[i] = a[mid + i];
		}
		 
		int i = 0;
		int j = 0;
		for (int k = left; k < right; k++) {
			if (i == n1) {
				a[k] = r[j];
				j++;
				continue;
			}
			if (j == n2) {
				a[k] = l[i];
				i++;
				continue;
			}
			 
			if (l[i] <= r[j]) {
				a[k] = l[i];
				i++;
			} else {
				count = count + n1 - i;
				a[k] = r[j];
				j++;
			}
		}
	}
	 
	public void mergeSort(int left, int right) {
		if ((left + 1) < right) {
			int mid = (left + right) / 2;
			mergeSort(left, mid);
			mergeSort(mid, right);
			merge(left, mid, right);
		}
	}
}

Measured memory_bytes: 61748
N = int(input())
S = input()
#A,B= map(int,input().split())
#S =list(map(int,input().split()))
# [list(map(int,input().split())) for i in range(N)]
color = "ab"
ans = 0
for i in range(N):
    if S[i]!=color:
        color = S[i]
        ans += 1
print(ans)



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

string s;

int main(){
	cin>>s;
	int now=0;
	int sum=1;
	for(int i=0;i<(int)s.length();i++){
		if(i==0){
			if(s[i]=='B')now=0;
			else now=1;
			continue;
		}
		if(now==0 && s[i]=='W'){
			now=1;
			sum++;
		}else if(now==1 && s[i]=='B'){
			now=0;
			sum++;
		}
	}
	cout<<sum-1<<endl;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

    ll H, N;
    cin >> H >> N;
    vector<ll> A(N);

    rep(i, N) cin >> A[i];

    ll sum = 0;
    rep(i, N){
      sum += A[i];
    }

    if(H > sum){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }

  return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;

  vector< int64 > dp(2, -infll);
  dp[0] = 0;
  for(int i = 0; i < N; i++) {
    vector< int64 > dp2(2, -infll);
    for(int j = 0; j < 2; j++) {
      for(int k = 0; k < 1+(i+1!=N); k++) {
        chmax(dp2[k],dp[j]+((j+k)%2==1?-A[i]:A[i]));
      }
    }
    dp.swap(dp2);
  }
  cout << max(dp[0],dp[1]) << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 1;
    bool isup = false;
    bool isdown = false;
    for(int i = 1; i < n; i++){
        if(!isup && !isdown && a[i-1] < a[i]){
            isup = true;
        }else if(!isup && !isdown && a[i-1] > a[i]){
            isdown = true;
        }else if(!isup && isdown && a[i-1] < a[i]){
            ans++;
            isdown = false;
        }else if(isup && !isdown && a[i-1] > a[i]){
            ans++;
            isup = false;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3704
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n = inp[0]
d = []
n.times do
  d << inp
end
lt = -1e20
lb = -1e20
rt = -1e20
rb = -1e20
d.each do |a|
  lt = big(-a[0]-a[1], lt)
  lb = big(-a[0]+a[1], lb) 
  rt = big(a[0]-a[1], rt) 
  rb = big(a[0]+a[1], rb)  
end
p big(lt+rb,lb+rt)


Measured memory_bytes: 27556
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> A;
    cin >> B;

    if(A<=B){
        rep(bi,B) cout << A;
    }else{
        rep(ai,A) cout << B;
    }


    

}

Measured memory_bytes: 3616
package main

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

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

func solve(s string, t string) string {
    return strings.Trim(t, " ") + strings.Trim(s, " ")
}

func main() {
    sc.Split(bufio.ScanWords)
    defer out.Flush()

    s := next()
    t := next()
    res := solve(s, t)
    fmt.Fprintln(out, res)
}

func next() string {
    sc.Scan()
    return sc.Text()
}

func nextStringAsBytes(n int64) []byte {
    sc.Scan()
    return []byte(sc.Text())
}

func nextInt() int64 {
    a, _ := strconv.ParseInt(next(), 10, 64)
    return a
}

func nextFloat() float64 {
    a, _ := strconv.ParseFloat(next(), 64)
    return a
}

func nextInts(n int64) []int64 {
    ret := make([]int64, n)
    for i := int64(0); i < n; i++ {
        ret[i] = nextInt()
    }
    return ret
}

func nextFloats(n int64) []float64 {
    ret := make([]float64, n)
    for i := int64(0); i < n; i++ {
        ret[i] = nextFloat()
    }
    return ret
}
func nextStrings(n int64) []string {
    ret := make([]string, n)
    for i := int64(0); i < n; i++ {
        ret[i] = next()
    }
    return ret
}

func containStr(arr []string, target string) bool {
    for _, v := range arr {
        if v == target {
            return true
        }
    }
    return false
}

func PrintOut(src interface{}, joinner string) {
    switch reflect.TypeOf(src).Kind() {
    case reflect.Slice:
        s := reflect.ValueOf(src)
        for idx := 0; idx < s.Len(); idx++ {
            fmt.Fprintf(out, "%v", s.Index(idx))
            if idx < s.Len()-1 {
                fmt.Fprintf(out, "%s", joinner)
            } else {
                fmt.Fprintln(out)
            }
        }
    default:
        fmt.Fprintln(out, "orz")
    }
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
    switch reflect.TypeOf(m).Kind() {
    case reflect.Map:
        s := reflect.ValueOf(m)
        for _, v := range s.MapKeys() {
            keys = append(keys, v)
            values = append(values, s.MapIndex(v))
        }
    default:
        fmt.Fprintln(out, "orz")
    }
    return
}


Measured memory_bytes: 640
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1; 
    // cin >> t; 
    while (t--) {
        int x, n;
        cin >> x >> n;
        map<int, int> mp;
        for(int i = 0; i < n; i++) {
            int x;
            cin >> x;
            mp[x] = 1;
        }

        int mn = 205, ans;
        for(int i = -101; i <= 101; i++) {
            if(abs(x - i) < mn && mp[i] == 0) {
                mn = abs(x - i);
                ans = i;
            }
        }

        cout << ans << '\n';
    }
    
    return 0;
}



Measured memory_bytes: 3648
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

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


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll sheep;
	cin>>sheep;
	ll wolf;
	cin>>wolf;
	if(wolf>=sheep)
	{
		cout<<"unsafe"<<"\n";
	}
	else
	{
		cout<<"safe"<<"\n";
	}
	return 0;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    string s;
    cin >> s;
    i64 n = s.size();

    if (s.size() < 26) {
        for (char c = 'a'; c <= 'z'; c++) {
            if (s.find(c) == string::npos) {
                cout << s + c << endl;
                return;
            }
        }
    } else {
        for (i64 i = n - 2; i >= 0; i--) {
            if (s[i] < s[i + 1]) {
                cout << s.substr(0, i) + *lower_bound(rbegin(s), rbegin(s) + n - i, s[i]) << endl;
                return;
            }
        }
    }

    cout << -1 << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
<?php

	$n = trim(fgets(STDIN));
	$ans = 0;
	$a[0] = trim(fgets(STDIN));
	if($a[0] != 0) $ans = -1;
	for($i=1; $i<$n; $i++){
	    $a[$i] = trim(fgets(STDIN));
	    if($a[$i-1] + 1 < $a[$i]) $ans = -1;
	}
	if($ans<0) echo -1;
	else{
	    $x = 0;
	    for($i=1; $i<$n; $i++){
	        if($a[$i-1] + 1 == $a[$i]){
	            $x = $a[$i];
	        } else {
	            $ans += $x;
	            $x = $a[$i];
	        }
	    }
	    $ans += $x;
	    echo $ans;
	}
?>

Measured memory_bytes: 20976
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL A[200001];
LL S[200001];
int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
		if(i==0){
			S[i]=A[i];
		}else{
			S[i]=S[i-1]+A[i];
		}
	}
	int a=0;
	int c=2;
	LL ans=1e15;
	for(int i=0;i<=N-2;i++){
		while(1){
			if(abs(S[a]-(S[i]-S[a]))>abs(S[a+1]-(S[i]-S[a+1]))){
				a++;
			}else{
				break;
			}
		}
		if(i==c)c++;
		while(1){
			if(abs((S[c]-S[i])-(S[N-1]-S[c]))>abs((S[N-1]-S[c+1])-(S[c+1]-S[i]))){
				c++;
			}else{
				break;
			}
		}
		LL v[4];
		v[0]=S[a];
		v[1]=S[i]-S[a];
		v[2]=S[c]-S[i];
		v[3]=S[N-1]-S[c];
		LL mi=1e15;
		LL ma=0;
		REP(i,4){
			mi=min(mi,v[i]);
			ma=max(ma,v[i]);
		}
		ans=min(ans,ma-mi);
	}
	cout<<ans<<endl;
	
	return(0);
}

Measured memory_bytes: 3328