akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
	int W, H, x, y, r;
	
	cin >> W >> H >> x >> y >> r;
	
	if(0<=x-r && x+r<=W && 0<=y-r && y+r<=H)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
		
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef std::pair<int, int> int_pair;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {
	int a = 0;
	cin >> a;
	if (a == 7 || a == 5 || a == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
ct = []
N,T = parse.(split(readline()))
for _ in 1:N
    c,t = parseMap(split(readline()))
    push!(ct,(c,t))
end

ct = sort(collect(ct), by=x->x[2])
if ct[1][2] > T
    return "TLE"
end    
min_cost = 10000000
for i in 1:N
    if ct[i][2] <= T
        min_cost > ct[i][1] && (min_cost = ct[i][1])
    else    
        return min_cost
    end
    if i == N && min_cost != 10000000
        return min_cost
    end    
end
end

println(main())

Measured memory_bytes: 124004
#include<iostream>
#include<string>
#include<stdio.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<vector>

using namespace std;

int main(){
    int a,b,c;cin >> a >> b >> c;
    int m = 0;
    if(a >= b && a >= c)m += a*10+b+c;
    else if(b >= a && b >= c)m+= b*10+a+c;
    else if(c>=a && c >= b)  m+= c*10+a+b;
    cout << m << endl;
}

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

import itertools

N = int(input())
k = 1
while k * (k+1) // 2 <= N:
    k += 1

if k * (k-1) // 2 == N:
    S = [[] for _ in range(k)]
    for i,(a,b) in enumerate(itertools.combinations(range(k),2),1):
        S[a].append(i)
        S[b].append(i)
    print('Yes')
    print(k)
    for se in S:
        print(len(se), *se)
else:
    print('No')

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

signed main(){
	int a,b;cin>>a>>b;
	int ans=1;
	while(a*2<=b){
		a*=2;
		ans++;
		}
		cout<<ans<<endl;
	}


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

int main()
{
  ll x, k, d;
  cin >> x >> k >> d;  
  x = abs(x);
  ll ans = 0;
  
  //0に到達しない場合
  if(x / d > k) ans =  x - d*k;
  else
  {
    ll ans_r = x % d;
    ll ans_l = abs(ans_r - d);
    
    if((k-x/d) % 2 == 0) ans = ans_r;
    else ans = ans_l;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int sum = 0;
		for (int i = 0; i < n; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			sum += r -l + 1;
		}

		System.out.println(sum);

		sc.close();

	}

}

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

int main(void){
    int K;
    cin >> K;
    if (K == 1) {
        cout << 1 << endl << 1 << endl;
        return 0;
    }
    int n = 2*ceil(K/4.0);
    vector<vector<int>> c(n);
    rep(y,n){
        c[y].resize(n);
        rep(x,n){
            if (y%2 == 0) {
                c[y][x] = (y+x)%n;
            } else {
                c[y][x] = n + (y+x)%n;
                if (c[y][x] > K - 1) {
                    c[y][x] -= n;
                }
            }
        }
    }
    cout << n << endl;
    rep(y,n){
        rep(x,n){
            cout << c[y][x]+1 << (x < n-1 ? " " : "\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define usll                    unordered_set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
//	inp_out();
	ll n;
	cin>>n;
	unordered_map<string,ll> mp;
	while(n--)
	{
		string s;
		cin>>s;
		mp[s]++;
	}
	cout<<mp.size();

	return 0;
}


Measured memory_bytes: 17712
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = sum(b)
for i in range(1,n):
  if a[i-1]+1 == a[i]:
    ans += c[a[i-1]-1]
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
typedef long long LL;
int main() {
	int x = 0, y = 0, z = 0;
	std::cin >> x >> y >> z;
	for (int i = 0; i < x; i++) {
		if (y*i + z*(i + 1) == x) {
			std::cout << i << std::endl;
			return 0;
		}else
		if (y*i + z*(i + 1) > x) {
			std::cout << i-1 << std::endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int n,a,b;
int h[100000];

bool solve(ll k)
{
  ll cnt = 0;
  REP(i,n){
    if(h[i]>b*k)  cnt += (ll)(h[i]-b*k+(a-b-1))/(a-b);
  }
  return cnt<=k;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> a >> b;
  REP(i,n) cin >> h[i];
  ll ok = 1e9;
  ll ng = 0;
  
  while(abs(ok-ng) > 1){
    ll mid = (ok+ng)/2;
    if(solve(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << '\n';
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int H, W, A[80][80], B[80][80], sa[80][80];
bitset<30101> dp[80][80];
int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    // input
    cout << fixed << setprecision(10);
    cin >> H >> W;
    rep2(y, 0, H) rep2(x, 0, W) cin >> A[y][x];
    rep2(y, 0, H) rep2(x, 0, W) cin >> B[y][x];
    rep(i, H) rep(j, W) sa[i][j] = abs(A[i][j] - B[i][j]);

    int base = 15000;
    dp[0][0].set(base + sa[0][0]);
    dp[0][0].set(base - sa[0][0]);

    rep(i, H) rep(j, W){
        int d = sa[i][j];
        if(i){
            dp[i][j] |= dp[i-1][j] >> d;
            dp[i][j] |= dp[i-1][j] << d;
        }
        if(j){
            dp[i][j] |= dp[i][j-1] >> d;
            dp[i][j] |= dp[i][j-1] << d;
        }
    }  

    int ans = INTINF;
    rep(i, 30101){
        if(dp[H-1][W-1][i]){
            ans = min(ans, abs(i - base));
        }
    }

    print(ans);

    
    
    return 0;
}


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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define debug(x) cerr << (#x) << "is "<< x << "\n"

using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

void test();

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int tt;
	// cin >> tt;
	// f(i,0,tt)
		test();
	return 0;
}

void test(){
	int n,m;
	cin >> n >> m;
	vector<bool> a(n+1,1);
	ll dp[n+1];
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	f(i,0,m){
		int x;
		cin >> x;
		a[x] = 0;
	}
	f(i,1,n+1){
		if(i==1){
			if(a[i]) dp[i] = 1;
		}
		else{
			if(a[i]){
				dp[i] = (dp[i-1]+dp[i-2])%MOD;
			}
		}
	}
	cout << dp[n] << "\n";
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
  int N;
  cin >> N;
  
  long long H[N];
  for(int i=0; i<N; i++)
    cin >> H[i];
    
  long long count=0;
  long long max=0;
  for(int i=0; i<N-1; i++)
    {
      if(H[i]<H[i+1])
	{
	  if(count>max)
	    max = count;
	  count = 0;
	}
      else
	{
	  count++;
	}
      //cout << count << endl;
    }

  if(count>max)
    max=count;
  cout << max << endl;


  return 0;
}



Measured memory_bytes: 1024
using System;

namespace AtCoderSucks
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            int d = int.Parse(Console.ReadLine());

            if (d == 25)
                Console.WriteLine("Christmas ");
            else if (d == 24)
                Console.WriteLine("Christmas Eve");
            else if (d == 23)
                Console.WriteLine("Christmas Eve Eve");
            else if (d == 22)
                Console.WriteLine("Christmas Eve Eve Eve");
        }
    }
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

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

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main() {
    int N, R;
    cin >> N >> R;
    if (N < 10) {
        cout << R + 100 * (10 - N) << endl;
    } else {
        cout << R << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int gcd(int a , int b){
	if(b == 0)	return a;
	return gcd(b,a%b);
}
int main() {
	long long int k ,sum=0;
	cin>>k;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int p=1;p<=k;p++){
				sum += gcd(gcd(i,j),p);
			}
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
	char s[100][100];
	int i, n, j;
	int h, w;
	scanf("%d %d", &h, &w);
	for(i = 1 ; i <= h ; i++)
	{
		getchar();
		for(j = 1 ; j <= w ; j++)
		{
			scanf("%c", &s[i][j]);
		}
	}
	int vis = 1;
	for(i = 1 ; i <= h ; i++)
	{
		for(j = 1 ; j <= w ; j++)
		{
			if(s[i][j] == '#')
			{
				if(s[i + 1][j] != '#' && s[i - 1][j] != '#' && s[i][j + 1] != '#' && s[i][j - 1] != '#')
				{
					vis = 0;
				}
			}
		}
	}
	if(w == 1 && h == 1)
	{
		printf("Yes\n");
	}
	else
	{
		if(vis == 1)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;
const int MAX_N = (int)1e5 + 100;

using edge = pair<int,int>;
vector<edge> G[MAX_N];
int N;
vector<int> res;  // res[i]: iの色

// v: 現在の頂点, par: 前の頂点(親)
// c: vの色(0/1)
void dfs(int v, int par, int c)
{
  res[v] = c;
  for (auto e : G[v]) {
    int nv, w;
    tie(nv, w) = e;
    if (nv == par) continue;
    // 偶数なら同色
    if (w % 2 == 0) dfs(nv, v, c);
    // 奇数なら反対の色
    else dfs(nv, v, 1 - c);
  }
}

int main()
{
  cin >> N;

  REP(i,0,N-1) {
    int u,v,w;
    cin >> u >> v >> w;
    --u; --v;
    // undirected
    G[u].push_back(edge(v,w));
    G[v].push_back(edge(u,w));
  }

  res.resize(N);
  // 頂点0をrootと見なして，そこから塗る
  dfs(0, -1, 0);

  REP(i,0,N) cout << res[i] << endl;

  return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>

int main() {
    
	int a;
	int b;
	int c;
	
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	
	if(a+b+c >= 22)puts("bust");
	else
	puts("win");
	
	
    return 0;
}


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

constexpr auto MAXN = 400000+50;

int totNums,totLine,num[MAXN]; bool val[MAXN];

bool Check(const int& targ){
	for(int i=0;i<totNums;i++) val[i] = num[i]>=targ;

	for(int i=totLine;i<totNums;i++)
		if(val[i] == val[i-1]) return val[i];
		else if(val[totNums-i] == val[totNums-i-1]) return val[totNums-i];
	return *val;
}

signed main(void)
{
	int fr = INT_MAX, to = INT_MIN,mid;

	scanf("%d", &totLine); totNums = (totLine<<1)-1;
	for(int i=0;i<totNums;i++){ scanf("%d", num+i); fr = std::min(fr,num[i]); to = std::max(to,num[i]); }

	while(fr<to){
		mid = (1+fr+to)>>1;
		if(Check(mid)) fr = mid;
		else to = mid-1;
	}

	printf("%d\n", fr);

	return 0;
}

Measured memory_bytes: 1280
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
n = int(input())
a = list(map(int, input().split()))
sort = sorted(a)
ans = sort[0]

for i in range(1,n):
    if ans <= 1000000000000000000:
        ans = ans * sort[i]

if ans <= 1000000000000000000:
 print(ans)
else:
 print("-1")


Measured memory_bytes: 21776
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = sum(B)

for i in range(N-1):
  if A[i] + 1 == A[i+1]:
    ans += C[A[i]-1]
    
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
 
  int H, W, i, j;
 
  while(1){
      
  scanf("%d %d",&H ,&W);
  
if(H == 0 && W == 0)break;
 
  for(i = 0; i < H; i++){

    for(j = 0; j < W; j++){
        
    printf("#");
    
  }
  
  printf("\n");
 
  }
  
  printf("\n");
  
  }
  
 
  return 0;
  }



Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    int x, a, b;
    cin >> x >> a >> b;

    int elapsed = b - a;
    string ans;
    if(elapsed <= 0){
        ans = "delicious";
    }else if(elapsed <= x){
        ans = "safe";
    }else{
        ans = "dangerous";
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

struct range {
  struct itr {
    int64_t i;
    constexpr itr(int64_t i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int64_t operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int64_t l_, int64_t r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

struct revrange {
  struct itr {
    int64_t i;
    constexpr itr(int64_t i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int64_t operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int64_t l_, int64_t r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;
constexpr u64 border = 1000000000000000000;

int main() {
  size_t N;
  std::cin >> N;
  std::vector<u64> A(N);
  for (auto &x: A) {
    std::cin >> x;
  }
  std::sort(A.begin(), A.end());
  if (A.front() == 0) {
    std::cout << 0 << '\n';
    return 0;
  }
  __uint128_t cur = 1;
  for (auto x: A) {
    cur *= x;
    if (cur > border) {
      std::cout << -1 << '\n';
      return 0;
    }
  }
  std::cout << (u64) cur << '\n';
  return 0;
}


Measured memory_bytes: 4060
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;

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

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        long[] sum = new long[n + 1];
        long[] psum = new long[n + 1];
        for (int i = 0; i < n; i++) {
            sum[i + 1] = sum[i] + a[i];
            psum[i + 1] = psum[i] + Math.max(0, a[i]);
        }

        long max = Long.MIN_VALUE;
        for (int i = k; i <= n; i++) {
            // Math#max : first paint range (as all black or white)
            // adding psum : sum all plus excluding first paint range
            max = Math.max(max, Math.max(sum[i] - sum[i - k], 0) + psum[n] - (psum[i] - psum[i - k]));
        }
        out.println(max);
    }

    static class InputStreamScanner {

        private InputStream in;

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

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

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

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

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

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

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

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

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

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

Measured memory_bytes: 43972
#include <bits/stdc++.h>
#define int long long
using namespace std;
string S;
int num=0;
int ans=9999;
int pow1(int a,int b){
  int ans=1;
  if(b==0){
    return 1;
  }
  else{
    for(int i=0;i<b;i++){
      ans = a*ans;
    }
    return ans;
  }
}
signed main(){
  cin >> S;
  for(int i=0;i<=S.size()-3;i++){
    num=0;
    for(int j=0;j<3;j++){
      num+=(S[i+j]-'0')*pow1(10,2-j);
    }
    //cout << num << endl;
    ans=min(ans,abs(753-num));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int n,p[100000],count=0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> p[i];
	for (int i = 0; i < n; i++) {
		if (i+1 == p[i]) {
			swap(p[i], p[i + 1]);
			count++;
		}
	}
	cout << count << endl;
	int x;
	cin >> x;
	return 0;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}


int main(){

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

    string s;
    cin >> s;
    rep(i, 0, s.size())
        s[i] = 'x';
    cout << s << '\n';
    
    

    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
S=[list(map(int,input().split())) for _ in range(M)]

D=[-1]*N
ans=True

for s,c in S:
    if D[s-1] == -1:
        D[s-1]=c
    else:
        if D[s-1] != c:
            ans=False

if D[0]==0 and 1<N: ans=False
if D[0]==-1:
    if N==1:
        D[0]=0
    else:
        D[0]=1

for i in range(N):
    if D[i]==-1: D[i]=0 
     
print(''.join(map(str,D)) if ans else -1)

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

using namespace std;

int main()
{
    int fri[501] = {0};
    int n, m;
    int stua[10001];
    int stub[10001];
    int ans = 0;

    cin >> n >> m;
    while (n != 0 && m != 0) {

    for (int i = 0; i < m; i++) {
        cin >> stua[i] >> stub[i];
        if (stua[i] == 1) {
            fri[stub[i]] = 1;
        }
        if (stub[i] == 1) {
            fri[stua[i]] = 1;
        }
    }

    for (int i = 0; i < m; i++) {
        if (fri[stua[i]] == 1 && stub[i] != 1 && fri[stub[i]] != 1) {
            fri[stub[i]] = 2;
        }
        if (fri[stub[i]] == 1 && stua[i] != 1 && fri[stua[i]] != 1) {
            fri[stua[i]] = 2;
        }
    }

    for (int i = 0; i < 501; i++) {
        if (fri[i]) ans++;
    }

    cout << ans << endl;
    cin >> n >> m;
    ans = 0;

    for (int i = 0; i < 501; i++) {
        fri[i] = 0;
    }
    }
}



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

#define lli long long int
#define LLI(n) lli n; scanf("%lld", &n);
#define Sort(n) sort(n.begin(), n.end());
#define Reve(n) reverse(n.begin(), n.end());
#define yes puts("Yes");
#define no puts("No");

//素数
bool IsPrime(lli num)
{
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)return false;
  }
  return true;
}
//各桁の和
lli Sum(lli n)
{
  lli sum=0;
  if (n<0) return 0;
  while (n>0)
  {
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(void)
{
  LLI(a)
  LLI(b)
  if(a%500<=b) yes
  else no
  return 0;
 }


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main(){
  int i,a[10],b[10],n,p[10],q[10],k=0,ans1=0,ans2=0;
  scanf("%d\n",&n);
  for(i=1;i<=n;i++){
    scanf("%d ",&p[i-1]);
    a[i-1]=i;
    b[i-1]=i;
  }
  scanf("\n");
  for(i=1;i<=n;i++){
    scanf("%d ",&q[i-1]);
  }
  do{
    for(i=0;i<n;i++){
      if(a[i]!=p[i]){
        k=1;
        break;
      }
    }
    if(k==0){
      break;
    }
    ans1++,k=0;
  }while(next_permutation(a,a+n));
  do{
    for(i=0;i<n;i++){
      if(b[i]!=q[i]){
        k=1;
        break;
      }
    }
    if(k==0){
      break;
    }
    ans2++,k=0;
  }while(next_permutation(b,b+n));
  printf("%d\n",abs(ans1-ans2));
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Contexts;
class Simple {
    private int N;
    void Solve() {
        //input
        N = io.Int;
        //cal
        var sum = 0;
        for(int i = 1; ; ++i) {
            sum += i;
            if(sum >= N) {
                //ret
                Console.WriteLine(i);
                return;                
            }
        }
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //System.Console.SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if(_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = Console.ReadLine();
        while(st == "") st = Console.ReadLine();
        if(st != null) _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() { Console.Out.Flush(); }
}
static class NumericEx {
    public static string pad0 <T>(this T v, int n) { return v.ToString().PadLeft(n, '0'); }
    public static double RoundOff(this double v, int n) { return Math.Round(v, n - 1, MidpointRounding.AwayFromZero); }
    public static bool Odd(this int v) { return v % 2 != 0; }
    public static bool Odd(this long v) { return v % 2 != 0; }
    public static void REP(this int v, Action <int> act) {
        for(int i = 0; i < v; ++i) act(i);
    }
    public static void REPR(this int v, Action <int> act) {
        for(int i = v - 1; i >= 0; --i) act(i);
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
 
int main(){
    long long int n;
    scanf("%lld",&n);
 
    char name[100];
    int i=0;
    
    while(n!=0)
    {
        n--;
        int kt = n%26;
        name[i] ='a'+ kt;
        n/=26;
        i++;
    }
 
    for(int j=i-1;j>=0;j--)
    {
        printf("%c",name[j]);
    }
    
    return 0;
}

Measured memory_bytes: 1648
#include<cstdio>
#include<iostream>

using namespace std;

int main(void) {

	int n, time, c[100], t[100], min=0;

	bool jud = false;

	cin >> n >> time;

	for (int i = 0; i < n; i++) {
		cin >> c[i] >> t[i];
		if (t[i] <= time && c[i] <= c[min]) {
			min = i;
			jud = true;
		}
	}
	if (jud==false)cout << "TLE\n";
	else cout << c[min] << "\n";

	return 0;
}

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

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

using namespace std;

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

int main() {
  string s;
  cin >> s;

  bool res = s[2] == s[3] && s[4] == s[5];

  cout << (res ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int H=in.nextInt();
			int W=in.nextInt();
			if((H|W)==0)
				return;
			int base[][]=new int[H][W];
			for(int i=0;i<H;i++)
			{
				String s=in.next();
				for(int j=0;j<W;j++)
				{
					if(s.charAt(j)=='.')
						base[i][j]=0;
					else if(s.charAt(j)=='^')
						base[i][j]=1;
					else if(s.charAt(j)=='>')
						base[i][j]=2;
					else if(s.charAt(j)=='v')
						base[i][j]=3;
					else if(s.charAt(j)=='<')
						base[i][j]=4;
				}
			}
			int nowh=0;
			int noww=0;
			for(;;)
			{
				if(base[nowh][noww]==1)
				{
					base[nowh][noww]=5;
					nowh--;
				}
				else if(base[nowh][noww]==2)
				{
					base[nowh][noww]=5;
					noww++;
				}
				else if(base[nowh][noww]==3)
				{
					base[nowh][noww]=5;
					nowh++;
				}
				else if(base[nowh][noww]==4)
				{
					base[nowh][noww]=5;
					noww--;
				}
				else if(base[nowh][noww]==0)
				{
					System.out.println(noww+" "+nowh);
					break;
				}
				else if(base[nowh][noww]==5)
				{
					System.out.println("LOOP");
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

const ll md = 1e9+7;

ll inv(ll a, ll b){
	return a!=1 ? b - inv(b%a,a)*b/a : 1LL;
}

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	vector<ll> a(n);
	trav(x, a) cin >> x;

	vector<ll> dp(n);

	ll sum = 0;
	rep(i,1,n){
		dp[i] = (i + sum)*inv(i+1, md) % md;
		sum = (sum + dp[i])%md;
	}

	ll prod = 1;
	rep(i,1,n+1) prod = prod * i % md;

	ll ans = 0;
	rep(i,0,n){
		ll cur = dp[i] + dp[n-i-1] + 1;
		ans += cur * a[i] % md;
	}
	ans %= md;
	ans *= prod;
	ans %= md;
	if(ans < 0) ans += md;
	cout << ans << endl;
}

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

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

    map<int, int> mp;
    for (int i = 0; i < N; ++i) ++mp[A[i]];

    int counter = 0;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (itr->second % 2) ++counter;
    }

    cout << counter << endl;
}

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

int main(void) {
    int n, k, q;
    scanf("%d %d %d", &n, &k, &q);
    vector<int> v(n);
    for(int i=0;i<n;i++){
        v[i] = 0;
    }
    for(int i=0;i<q;i++){
        int k;
        scanf("%d", &k);
        v[k-1]++;
    }

    for(int i=0;i<n;i++){
        if(q-v[i]<k)
            printf("Yes\n");
        else
            printf("No\n");
    }
}

Measured memory_bytes: 1024
import Foundation

let values = readLine()!.components(separatedBy: " ").map{Int($0)!}
assert(values.count == 2)
let X = values[0]
let Y = values[1]

for turu in 0...X {
    let kame = X - turu
    let legs = turu * 2 + kame * 4
    if legs == Y {
        print("Yes")
        exit(0)
    }
}

print("No")



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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define pf push_front
#define sz(x) (int)(x).size()
#define lb lower_bound 
#define ub upper_bound 
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef vector<string> vs;
typedef unsigned long long ull;
typedef long double ld;
typedef map<int,int> mii;

const int MOD = 1e9+7;
const ll INF = 1e18; //
const ld PI = acos((ld)-1);

int main () {
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}



Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int x, a, b;

int main()
{
    scanf("%d %d %d", &x, &a, &b);
    if (abs(x-a) < abs(x-b)) printf("A\n");
    else printf("B\n");
    return 0;
}

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

char A[101][101];
int main() {
    int H,W;
    cin >> H >> W;
    string s;    
    for(int i=1;i<=H;i++) {
        cin >> s;
        for(int j=1;j<=W;j++) {
            A[i][j] = s[j-1];
        }
    }

    for(int i=0;i<=W+1;i++)
        cout << "#";
    cout << endl;
    for(int i=1;i<=H;i++) {
        cout << "#";
        for(int j=1;j<=W;j++) {
            cout << A[i][j];
        }
        cout << "#" << endl;
    }
    for(int i=0;i<=W+1;i++)
        cout << "#";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
"""
Given N, D, A, N means no. of monsters, D means distances of bombs, A attack of the bombs

Find the minimum of bombs required to win.

Each monster out of N pairs - pair[0] = position, pair[1] = health
"""
from collections import deque

mod = 1e9+7
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    N, D, A = [int(x) for x in raw_input().split()]
    D *= 2
    monsters = []
    
    for _ in range(N):
        pos, health = [int(x) for x in raw_input().split()]
        monsters.append([pos, health])    
    
    
    monsters.sort(key = lambda x : x[0])
    
    remain_attacks_queue = deque([])
    
    remain_attack = 0
    
    ans = 0
    
    for monster in monsters:
        # monster[0] - pos, monster[1] - health
        # queue[0] - position, queue[1] - attack points
        while len(remain_attacks_queue) and monster[0] - D > remain_attacks_queue[0][0]:
            remain_attack -= remain_attacks_queue.popleft()[1]
        if remain_attack < monster[1]:
            remained_health = monster[1] - remain_attack
            times = remained_health / A if remained_health % A == 0 else remained_health // A + 1
            #print(times)
            attack = times * A
            remain_attacks_queue.append([monster[0], attack])
            ans += times
            remain_attack += attack
        
    print(ans)
    

main()

Measured memory_bytes: 75676
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 105

using namespace std;

int main()
{
    ll n,m,arr[sz*sz],ans[sz][sz],x;

    scanf("%lld %lld %lld",&n,&m,&x);

    for(ll i=1; i<=x; i++)
    {
        scanf("%lld",&arr[i]);
    }

    ll k=1;

    for(ll i=1; i<=n; i++)
    {
        if(i%2!=0)
        {
            for(ll j=1; j<=m; j++)
            {
                ans[i][j]=k;

                arr[k]--;

                if(arr[k]==0)
                    k++;
            }
        }

        else
        {
            for(ll j=m; j>=1; j--)
            {
                ans[i][j]=k;

                arr[k]--;

                if(arr[k]==0)
                    k++;
            }
        }
    }

    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=m; j++)
        {
            printf("%lld ",ans[i][j]);
        }

        printf("\n");
    }

    return (0);
}




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

int main() {
    int N=0,M=0,X=0,s=0,s_=0;
    std::cin>>N>>M>>X;
    std::vector<int> V(128);
    std::vector<int> m(128);
    for(int i=0;i<=N;i++){
        V[i]=i;
    }
    for(int i=0;i<M;i++){
        std::cin>>m[i];
    }
    for(int i=0;i<X;i++){
        int t=V[i];
        for(int j=0;j<M;j++){
            if(t==m[j]){
                s=s+1;
            }
        }
    }
    for(int i=X+1;i<N;i++){
        int t=V[i];
        for(int j=0;j<M;j++){
            if(t==m[j]){
                s_=s_+1;
            }
        }
    }
    std::cout<<std::min(s,s_);
    return 0;
}

Measured memory_bytes: 256
_ = input()
h = list(map(int, input().split()))
ans = 0
while sum(h) > 0:
    left = 0
    while left < len(h) and h[left] == 0:
        left += 1
    h[left] -= 1
    right = left + 1
    while right < len(h) and h[right] != 0:
        h[right] -= 1
        right += 1
    ans += 1
print(ans)

# 問題文、rとlは固定かと思ったけど毎回指定するってのがサンプルから分かった
# 操作逆にしてぜんぶ0にするまでを数える
# NもHも小さいので「山になっている部分を減らす」を毎回やっても大丈夫だと思う
# しゃくとり的にやったけどちょっと雑
# むしろこれでも間に合うか（毎回sumするver）

Measured memory_bytes: 9096
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 3003
using namespace std;
typedef long long ll;

int n, a[N];
ll f[N][N], sum[N];

ll dp(int l, int r) {
    if (f[l][r] != -1) return f[l][r];
    ll &res = f[l][r];
    if (l == r) return res = a[l];
    else return res = sum[r] - sum[l - 1] - min(dp(l + 1, r), dp(l, r - 1));
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    memset(f, -1, sizeof f);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        sum[i] = sum[i - 1] + a[i];
    }
    cout << dp(1, n) * 2 - sum[n];
    return 0;
}


Measured memory_bytes: 70912
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll a[100002];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    ll s1 = 0, s2 = 0;
    for(int i = 0; i < n / 2; i++) s1 += a[i];
    for(int i = 0; i < n / 2; i++) s2 += a[n - 1 - i];
    if(n % 2 == 0){
        cout << s2 - s1 + (s2 - a[n / 2]) - (s1 - a[n / 2 - 1]) << endl;
    }
    else{
        cout << s2 - s1 + max(s2 - (s1 - a[n / 2 - 1] + a[n / 2]), (s2 - a[n / 2 + 1] + a[n / 2]) - s1) << endl;
    }
}

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

int main(void){
	string S, T;
    cin >> S >> T;

    for(int i=0 ;i<S.size(); i++){
        if(S[i] != T[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}	

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

//time,man
vector<vector<int>> cul(ll N){
  vector<vector<int>> A(N-1,vector<int>(N));
  if(N&1){
    for(int i=1;i<N;i++){
      for(int j=0;j<N;j++){
        A[i-1][j]=(i+j)%N;
      }
    }
    return A;
  }
  if(N==4){
    A[0]={1,3,1,0};
    A[1]={3,2,0,2};
    A[2]={2,0,3,1};
    return A;
  }
  auto B=cul(N/2);
  for(int i=0;i<N/2-1;i++){
    for(int j=0;j<N;j++){
      int idx=j%(N/2),dif=(j>=N/2?N/2:0);
      A[i][j]=B[i][idx]+dif;
    }
  }
  for(int i=N/2-1;i<N-1;i++){
    int t=i-N/2+1;
    int dif=N/2;
    for(int j=0;j<N/2;j++){
      A[i][j]=(t+j)%(N/2)+dif;
      A[i][(t+j)%(N/2)+dif]=(j+1)%(N/2);
    }
  }
  return A;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  if(N==2){cout<<-1<<endl; return 0;}
  auto A=cul(N);
  //for(auto &I:A){cout<<I<<endl;}
  
  for(int i=0;i<N;i++){
    for(int j=0;j+1<N;j++){cout<<A[j][i]+1<<(j+2==N?"\n":" ");}
  }
  

  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

const int inf = 1e7;

int main()
{
	int n, k;
	vector<vector<int>> g;

	scanf("%d%d", &n, &k);
	g.resize(n);
	for(int i = 0; i < n - 1; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		a -= 1; b -= 1;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	bool odd = (k & 1);
	int ans = n;
	vector<pair<int,int>> dist(n);
	queue<pair<int,pair<int,int>>> q;
	vector<int> count(n);

	for(int root = 0; root < n; ++root) {

		pair<int, int> init_value = {inf, 0};
		fill(dist.begin(), dist.end(), init_value);
		q.push({root, {0, -1}});

		while(!q.empty()) {

			int v = q.front().first;
			int d = q.front().second.first;
			int b = q.front().second.second;
			q.pop();

			if(dist[v].first < inf)
				continue;
			dist[v] = {d, b};

			for(auto w : g[v]) {
				int nb = (b == -1) ? w : b;
				q.push({w, {d + 1, nb}});
			}
		}

		int base = 0;

		for(int i = 0; i < n; ++i) {
			if(dist[i].first <= k / 2)
				base += 1;
		}

		fill(count.begin(), count.end(), 0);
		for(int i = 0; i < n; ++i) {
			if(odd && dist[i].first == k / 2 + 1)
				count[dist[i].second] += 1;
		}

		int top = 0;
		for(int i = 0; i < n; ++i)
			top = max(top, count[i]);

		ans = min(ans, n - base - top);
	}

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

	return 0;
}


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

int main()
{
	string a; int b;
	cin >> a >> b;
	for (int c = 0; c < a.length(); c++) {
		if (a[c] == 'a')continue;
		int d = 26 - (a[c] - 'a');
		if (d > b)continue;
		a[c] = 'a';
		b -= d;
	}
	b %= 26;
	a[a.length() - 1] += b;
	cout << a << endl;
}

Measured memory_bytes: 640
#include <cstdint>
#include <iostream>

typedef int64_t i64;

static const auto NMAX = 100000;

static int N;
static int L;
static int A[NMAX];

static void solve(int u) {
	std::cout << "Possible" << std::endl;
	for(auto i = 1; i < u; i++) std::cout << i << std::endl;
	for(auto i = N - 1; i >= u; i--) std::cout << i << std::endl;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin >> N >> L;
	for(auto i = 0; i < N; i++) std::cin >> A[i];
	for(auto i = 1; i < N; i++) {
		if(A[i - 1] + A[i] >= L) {
			solve(i);
			return 0;
		}
	}
	std::cout << "Impossible" << std::endl;
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<utility>
#include<algorithm>
using namespace std;

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

	vector<pair<int, int>> red(N, pair<int, int>());
	for(int i=0; i<N; i++)
		cin >> red[i].first >> red[i].second;
	sort(red.begin(), red.end());

	vector<pair<int, int>> blue(N,pair<int, int>());
	for(int i=0; i<N; i++)
		cin >> blue[i].first >> blue[i].second;
	sort(blue.begin(), blue.end());

	vector<bool> used(N, false);
	for(int i=0; i<N; i++){
		int bx = blue[i].first;
		int by = blue[i].second;

		int index = -1;
		int y = -1;
		for(int j=0; j<N&&red[j].first<bx; j++){
			if(used[j] == true)
				continue;

			if(red[j].second<by && red[j].second>y){
				index = j;
				y = red[j].second;
			}
		}
		if(index == -1)
			continue;

		used[index] = true;
	}

	cout << count(used.begin(), used.end(), true) << endl;

	return 0;
}


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

int main()
{
    int64_t n, k; cin >> n >> k;
    int64_t ans = 1,digit = k;

    while(n>=digit) {
        digit *= k;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np

n, k = map(int, sys.stdin.readline().split())
h = np.array(sys.stdin.read().split(), dtype=np.int64)
h.sort()

def main():
    res = np.amin(h[k-1:] - h[:-k+1])
    print(res)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 24608