akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
 
int N;
long long mod = (long long)1e9+7;
long long res = 0;
const int MAX = 230000;
long long fac[MAX];
long long finv[MAX];

long long modpow(long long x, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 0) {
    long long res = modpow(x,n/2);
    res *= res;
    res %= mod;
    return res;
  } else {
    res = x * modpow(x,n-1) % mod;
    return res;
  }
}
 
/*
long long modpow(long long x, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n % 2 == 1) { 
            res *= x;
            res %= mod;
        }
        x *= x;
        x %= mod;
        n /= 2;
    }
    return res;
}
*/
 
// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
  res = 0;
  return modpow(a, mod - 2);
}
 
 
void calc(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  for (int i=2; i<MAX; i++){
    fac[i] = fac[i-1] * i % mod;
    finv[i] = finv[i-1] * modinv(i,mod) % mod;
  }
  return;
}

long long com(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}
 
int main(){
  scanf("%d",&N);
  long long K;
  scanf("%lld", &K);
  //printf("N=%d, K=%lld\n", N, K);
  calc();
  K = std::min(K, (long long)N-1);
  long long ans = 0;
  for (int i=0; i<=K; i++){
    //printf("ans += %lld*%lld\n",nCk[i], n1Ck[i]);
    ans += (com(N,i) * com(N-1,i))%mod;
    ans %= mod;
  }
  printf("%lld\n", ans);
  return 0;
}


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

int main() {
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int h = ty - sy;
    int w = tx - sx;
    
    for(int i=0; i<h; i++)
        cout << 'U';
    for(int i=0; i<w; i++)
        cout << 'R';
    for(int i=0; i<h; i++)
        cout << 'D';
    for(int i=0; i<w; i++)
        cout << 'L';
    
    cout << 'L';
    for (int i=0; i<h+1; i++)
        cout << 'U';
    for(int i=0; i<w+1; i++)
        cout << 'R';
    cout << 'D';
    cout << 'R';
    for(int i=0; i<h+1; i++)
        cout << 'D';
    for(int i=0; i<w+1; i++)
        cout << 'L';
    cout << 'U';
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,N,W[101];
	int sum=0;
	int S1=0;
	int S2=0;
	double ave=0.0;
	int cnt=1;
	scanf("%d",&N);
	for(i=1;i<=N;i++)
	{
		scanf("%d",&W[i]);
	}
	for(i=1;i<=N;i++)
	{
		sum=W[i]+sum;
	}
	ave=sum/2;
	i=1;
	do
	{
		S1= W[i] +S1;
		i++;
		cnt++;
	}while(S1<ave);
	if(ave-(S1-W[i-1])<=S1-ave){
		cnt=cnt-1;
		S1=S1-W[i-1];
		do
		{
			S2=W[cnt]+S2;
			cnt++;
			}
			while(cnt<=N);
			if(S1>S2)
				printf("%d",S1-S2);
			else
				printf("%d",S2-S1);
	}
	else{
		do
		{
			S2=W[cnt]+S2;
			cnt++;
			}
			while(cnt<=N);
			if(S1>S2)
				printf("%d",S1-S2);
			else
				printf("%d",S2-S1);
	}
	
	return 0;
}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();

        if (N % 2 != 0) {
            System.out.println("No");
            return;
        }

        if (S.substring(0, N / 2).equals(S.substring(N / 2))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break 
    row_a = "#" * W
    print(row_a)
    for i in range(H-2):
        row_b = "#" + "." * (W-2) + "#"
        print(row_b)
    print(row_a)
    print()


Measured memory_bytes: 5612
#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 rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    string S;cin >> S;
    int left = 0;
    int right = 0;
    int ct = 0;
    rep(i,N){
        if(S[i] == '('){
            if(ct < 0){
                left += (-1*ct);
                ct = 1;
            }
            else{
                ct++;
            }
        }
        if(S[i] == ')'){
            ct--;
        }
    }
    if(ct < 0)left += (-1*ct);
    else{
        right += ct;
    }

    rep(i,left)cout  << '(';
    cout << S ;
    rep(i,right)cout << ')' ;
    cout << endl;
}

Measured memory_bytes: 256
class UnionFindNode(object):
    """
    Union-Find構造
    ノードのグループ併合や、所属グループ判定を高速に処理する
    """

    def __init__(self, group_id, parent=None, value=None):
        self.group_id_ = group_id
        self.parent_ = parent
        self.value = value
        self.size_ = 1

    def __str__(self):
        template = "UnionFindNode(group_id: {}, \n\tparent: {}, value: {}, size: {})"
        return template.format(self.group_id_, self.parent_, self.value, self.size_)

    def is_root(self):
        return not self.parent_

    def root(self):
        parent = self
        while not parent.is_root():
            parent = parent.parent_
            self.parent_ = parent
        return parent

    def find(self):
        parent = self.root()
        return parent.group_id_

    def size(self):
        parent = self.root()
        return parent.size_

    def unite(self, unite_node):
        parent = self.root()
        unite_parent = unite_node.root()

        if parent.group_id_ != unite_parent.group_id_:
            if parent.size() > unite_parent.size():
                unite_parent.parent_ = parent
                parent.size_ = parent.size_ + unite_parent.size_
            else:
                parent.parent_ = unite_parent
                unite_parent.size_ = parent.size_ + unite_parent.size_
    def is_group(self,other):#selfとotherが同じグループに属するか
        return self.root()==other.root()

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

X = sorted([[i, xy[0]] for i, xy in P], key=lambda x: x[1])
Y = sorted([[i, xy[1]] for i, xy in P], key=lambda y: y[1])

Xe = [[X[i][0], X[i+1][0], abs(X[i][1]-X[i+1][1])] for i in range(N-1)]
Ye = [[Y[i][0], Y[i+1][0], abs(Y[i][1]-Y[i+1][1])] for i in range(N-1)]
E = sorted(Xe + Ye, key=lambda e: e[2])

U=[UnionFindNode(i) for i in range(N)]
i=0
ans=0
count=1
while(count<N):
    v1,v2,cost=E[i]
    if not U[v1].is_group(U[v2]):
        U[v1].unite(U[v2])
        ans+=cost
        count+=1
    i+=1
print(ans)


Measured memory_bytes: 128420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
#define IINF (1<<21)
typedef long long ll;

int main() {
  int H, W;
  cin >> H >> W;
  int dp[H][W];

  REP(h, H) {
    REP(w, W) {
      int in;
      cin >> in;
      dp[h][w] = !in;
    }
  }

  for (int h = 1; h < H; h++) {
    for (int w = 1; w < W; w++) {
      if (dp[h][w] == 0) continue;
      dp[h][w] = min(min(dp[h - 1][w - 1], dp[h - 1][w]), dp[h][w - 1]) + 1;
    }
  }

  int mx = -1;
  REP(h, H) {
    REP(w, W) {
      mx = max(mx, dp[h][w]);
    }
  }

  cout << mx * mx << endl;

  return 0;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

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

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

    int N, K;
    std::cin >> N >> K;

    vector<pair<int, int>> sushi;
    sushi.reserve(N);
    REP(i, N) {
        int t, d;
        std::cin >> t >> d;
        sushi.emplace_back(d, t - 1);
    }

    RSORT(sushi);

    using desc_sushi_pq = priority_queue<pair<int, int>,
                                         vector<pair<int, int>>,
                                         greater<pair<int, int>>>;

    desc_sushi_pq selected_sushi;
    map<int, int> sushi_type_cnt_map;

    ll sushi_total_value = 0;
    REP(i, K) {
        selected_sushi.emplace(sushi[i].first, sushi[i].second);
        sushi_total_value += sushi[i].first;
        auto itr = sushi_type_cnt_map.find(sushi[i].second);
        if(itr != sushi_type_cnt_map.end()) {
            itr->second++;
        }
        else {
            sushi_type_cnt_map.emplace(sushi[i].second, 1);
        }
    }


    size_t sushi_index       = K;
    ll     sushi_num_of_type = sushi_type_cnt_map.size();
    ll     ans               = sushi_total_value + sushi_num_of_type * sushi_num_of_type;
    while(true) {
        auto min_sushi_value = INF;
        while(true) {
            if(2 <= sushi_type_cnt_map[selected_sushi.top().second]) {
                min_sushi_value = selected_sushi.top().first;
                sushi_type_cnt_map[selected_sushi.top().second]--;
                selected_sushi.pop();
                break;
            }
            selected_sushi.pop();
            if(selected_sushi.size() == 0) {
                break;
            }
        }

        if(min_sushi_value == INF) {
            break;
        }
        else {
            sushi_total_value -= min_sushi_value;
            while(sushi_index != sushi.size()) {
                auto itr = sushi_type_cnt_map.find(sushi[sushi_index].second);
                if(itr == sushi_type_cnt_map.end()) {
                    sushi_type_cnt_map.emplace(sushi[sushi_index].second, 1);
                    selected_sushi.emplace(sushi[sushi_index].first, sushi[sushi_index].second);
                    break;
                }
                sushi_index++;
            }

            if(sushi_index == sushi.size()) {
                break;
            }
            else {
                sushi_total_value += sushi[sushi_index].first;
                sushi_num_of_type++;
                ans = max(ans, sushi_total_value + sushi_num_of_type * sushi_num_of_type);
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4724
import java.util.Scanner;

public class Main {

	static int UP=1,DOWN=3,RIGHT=2,LEFT=4;
	static int[] v1 = {0,-1, 0, 1, 0};
	static int[] v2 = {0,0, 1, 0, -1};
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int h=cin.nextInt();
			int w=cin.nextInt();
			if(h+w==0){
				break;
			}
			int[][] a = new int[h][w];
			String[] s = new String[h];
			for(int i =0;i < h;i++){
				s[i]=cin.next();
				char[] c = s[i].toCharArray();
				for(int j = 0;j <w;j++){
					if(c[j]=='^'){
						a[i][j]=UP;
					}
					else if(c[j]=='>'){
						a[i][j]=RIGHT;
					}
					else if(c[j]=='v'){
						a[i][j]=DOWN;
					}
					else if(c[j]=='<'){
						a[i][j]=LEFT;
					}
					else{
						a[i][j]=0;
					}
				}
			}
			int x=0,y=0;
			while(true){
				if(a[x][y]==0){
					System.out.println(y+" " +x);
					break;
				}
				else if(a[x][y]==-1){
					System.out.println("LOOP");
					break;
					// LOOP
				}
				int c = a[x][y];
				a[x][y]=-1;
				x+=v1[c];
				y+=v2[c];
				
			}
		}
	}

}

Measured memory_bytes: 12000
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

ll n;
ll t[101];
ll m;

int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    ll ans=0;
    rep(i,0,n){
        cin >> t[i+1];
        ans+=t[i+1];
    }
    cin >> m;
    rep(i,0,m){
        ll p,x;
        cin >> p >> x;
        ll z=x-t[p];
        cout << ans+z << "\n";
    }
    return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        StringBuilder A = new StringBuilder();
        for(int i = 0;i < S.length();i++){
            switch (S.charAt(i)) {
                case '0':
                A.append(S.charAt(i));
                break;
                case 'B':
                if(A.length() != 0){
                    A.setLength(A.length()-1);
                }
                break;
                case '1':
                A.append(S.charAt(i));
                break;
            }
        }
        System.out.println(A);
        
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define MAX 128

typedef long long ll;
//dp[i][j][k]:=i枚目までのj枚で和がk
ll dp[MAX][MAX][MAX*MAX];

void solve(void){
    ll n, a, sum = 0;
    cin >> n >> a;
    ll xs[n];
    rep(n, i) scanf("%lld", &xs[i]);
    sort(xs, xs+n);

    dp[0][0][0] = 1LL;
    Rep(0, n-1, i){
        sum += xs[i];
        Rep(0, i, j) {
            Rep(0, sum, k){
                if(dp[i][j][k]) {
                    dp[i+1][j][k] += dp[i][j][k];
                    dp[i+1][j+1][k+xs[i]] += dp[i][j][k];
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 1; i*a <= sum; i++){
        ans += dp[n][i][i*a];
    }
    cout << ans << '\n';
}

int main(void){
  solve();
  return 0;
}


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

#define pout(n)  printf ("%d\n", n)

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

typedef long long ll;
using namespace std;
 
int main (){
  string s;
  int st,f;
  cin >> s;

  rep(i,0,s.length()){
    if(s[i] == 'A'){
      st = i;
      break;
    }
  }
  per(i,s.length(),0){
    if(s[i] == 'Z'){
      f = i;
      break;
    }
  }
  pout(f-st+1);
  return 0;
}

Measured memory_bytes: 640
package main

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

func main() {
	N := nextInt()
	A := nextInt()
	B := nextInt()

	vs := make([]int, N)
	for i := 0; i < N; i++ {
		vs[i] = nextInt()
	}

	sort.Sort(sort.Reverse(sort.IntSlice(vs)))

	var avg float64
	for i := 0; i < A; i++ {
		avg += float64(vs[i])
	}

	avg /= float64(A)

	// Make dp.
	dp := make([][]int, 51)
	for i := 0; i <= N; i++ {
		dp[i] = make([]int, 51)
		for j := 0; j <= i; j++ {
			if j == 0 || j == i {
				dp[i][j] = 1
			} else {
				dp[i][j] = dp[i-1][j-1] + dp[i-1][j]
			}
		}
	}

	// Calc N and k.
	An, Ak := 0, 0
	for i := 0; i < N; i++ {
		if vs[i] == vs[A-1] {
			An++
			if i < A {
				Ak++
			}
		}
	}

	cnt := 0
	if Ak == A {
		for ; Ak <= B; Ak++ {
			cnt += dp[An][Ak]
		}
	} else {
		cnt = dp[An][Ak]
	}

	fmt.Printf("%f\n%d\n", avg, cnt)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	if x < y {
		return x
	}

	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}

	return y
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

// ---------- Util.


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define MOD (long long int)1e9+7
using namespace std;
long long int a[1001];

#define MAXN 300000
int prime[MAXN];
bool is_prime[MAXN];
int sieve(int n){
  int p=0;
  for(int i=0;i<=n;i++) is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      prime[p++]=i;
      for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
    }
  }
  return p;
}

int main(void){
  int n,i,j,m;
  long long int res;
  cin>>n;
  sieve(n+1);
  res=1;

  for(i=2;i<=n;i++){
    m=i;
    j=0;
    while(m>1){
      if(m%prime[j]==0){
        a[prime[j]]++;
        m/=prime[j];
      }
      else{
        j++;
      }
    }
  }
  for(i=1;i<=n;i++){
    if(a[i]!=0){
      res=(a[i]+1)*res;
      res%=MOD;
    }
  }
  cout<<res<<endl;

  return 0;
}

Measured memory_bytes: 256
S = input()

acgt_set = {'A', 'C', 'G', 'T'}
length = []

count = 0
for i, s in enumerate(S):
    if s in acgt_set:
        count += 1
        if i == len(S) - 1:
            length.append(count)
    else:
        length.append(count)
        count = 0

print(max(length))

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

int N;

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i <= N; i += 4) if(N == i || (N - i) % 7 == 0){ printf("Yes\n"); return 0; }
    printf("No\n");
    
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, k;
  cin >> n >> k;
  vi32 h(n);
  cin >> h;
  sort(h.begin(), h.end());
  int ans = 1e9;
  for (int l = 0; l + k <= n; l++) {
    int r = l + k;
    amin(ans, h[r - 1] - h[l]);
  }
  cout << ans << endl;
}


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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a) * (a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

struct line{
    ll m, c;
    ll val(ll x){
        return m * x + c;
    }
    ll intersectX(line b){
        return (b.c - c) / (m - b.m);
    }
};

const int N = 1e6 + 5;

line t[4 * N];

void add_line(line nl, int tv = 1, int tl = 0, int tr = N){
    int tm = (tl + tr)/2;
    bool lef = nl.val(tl) < t[tv].val(tl);
    bool mid = nl.val(tm) < t[tv].val(tm);

    if(mid){
        /// new line is min. for half without intersection
        swap(nl, t[tv]);
    }

    if(tr - tl == 1) return;
    if(mid != lef){
        /// [tl, tm) contains the intersection
        add_line(nl, 2 * tv, tl, tm);
    } else {
        /// [tm, tr) contains the intersection
        add_line(nl, 2 * tv + 1, tm, tr);
    }
}

ll get_min(ll x, int tv = 1, int tl = 0, int tr = N){
    int tm = (tl + tr)/2;
    ll mn = t[tv].val(x);
    if(tr - tl == 1) return mn;
    if(x < tm){
        return mn = min(mn, get_min(x, 2 * tv, tl, tm));
    } else {
        return mn = min(mn, get_min(x, 2 * tv + 1, tm, tr));
    }
}

vector<ll> h;

void solve(){
    ll n, c, x;
    cin>>n>>c;
    h.resize(n);
    fr(i, n) {
        cin>>h[i];
    }

    // fr(i, 4 * N) t[i] = {0ll, 0ll};

    /// dp[i] = c + min(dp[j] + sq(h[i] - h[j])); where j < i
    /// dp[i] = c + sq(h[i]) + min(-2h[j] * h[i] + sq(h[j]) + dp[j]);
    /// m = - 2h[j], c = sq(h[j]) + dp[j]
    /// segment tree is built on the query points, i.e. h[i]

    ll best = 0ll;
    line l = {-2ll * h[0], 0ll + sq(h[0])};
    add_line(l);
    rep(i, 1, n - 1){
        ll z = get_min(h[i]);
        best = c + sq(h[i]) + z;
        l = {-2ll * h[i], best + sq(h[i])};
        add_line(l);
    }

    cout<<best;
}

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

    ll tc = 1;
    //  cin>>t;
    while(tc--){
        solve();
    }

    return 0;
}



Measured memory_bytes: 36608
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する


int main() {
    string s;
    cin >> s;
    if(s[0] == s[s.size()-1] ^ (s.size() % 2 != 0)){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }

    return 0;
}


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

using namespace std;
#define  ll long long 
#define db long double
#define f(i,l,u) for(ll i=l;i<u;i++)
#define all(a) a.begin(),a.end()
#define pb push_back

int main() {
    string s1;
    string s2;
    cin>>s1;
    cin>>s2;
    ll y=s1.length();
    ll y2=s2.length();
    
    if(y==y2-1)
    {
        ll c=0;
        f(i,0,y)
        {
            if(s1[i]==s2[i])
            c++;
        }
        if(c!=y)
        cout<<"No";
        else
        cout<<"Yes";
        
        
        
    }
    else
    {
        cout<<"No";
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

bool even(string s){
    int n = s.size();
    rep(i,n/2){
        if(s[i] != s[n/2 + i]) return false;
    }
    return true;
}

int main()
{
    string s;
    cin >> s;
    while(s.size()>1){
        s.erase(s.end()-2,s.end());
        if(even(s)){
            cout << s.size() << endl;
            return 0;
        }
    }
}


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

/// --- MinCostFlow Library {{{ ///
struct MinCostFlow {
  struct Edge {
    int to; ll cap, cost; size_t rev;
  };
  int n;
  vector< vector<Edge> > graph;
  vector<ll> dist;
  vector<int> prevv, previ;
  ll inf;
  MinCostFlow(int n, ll inf): n(n), graph(n), dist(n), prevv(n), previ(n), inf(inf) {}
  void addEdge(int a, int b, ll cap, ll cost, int undirected = 0) {
    graph[a].emplace_back((Edge) {b, cap, cost, graph[b].size()});
    graph[b].emplace_back((Edge) {a, undirected ? cap : 0, -cost, graph[a].size() - 1});
  }
  ll solve(int s, int t, ll f) {
    ll res = 0;
    while(f > 0) {
      fill(begin(dist), end(dist), inf);
      dist[s] = 0;
      bool update = 1;
      // Bellman-Ford
      while(update) {
        update = 0;
        for(int v = 0; v < n; v++) {
          if(dist[v] == inf) continue;
          for(size_t i = 0; i < graph[v].size(); i++) {
            Edge &edge = graph[v][i];
            if(edge.cap > 0 && dist[edge.to] > dist[v] + edge.cost) {
              dist[edge.to] = dist[v] + edge.cost;
              prevv[edge.to] = v;
              previ[edge.to] = i;
              update = 1;
            }
          }
        }
      }
      //
      if(dist[t] == inf) return -1;
      ll d = f;
      for(int v = t; v != s; v = prevv[v]) {
        d = min(d, graph[prevv[v]][previ[v]].cap);
      }
      f -= d;
      res += d * dist[t];
      for(int v = t; v != s; v = prevv[v]) {
        Edge &edge = graph[prevv[v]][previ[v]];
        edge.cap -= d;
        graph[v][edge.rev].cap += d;
      }
    }
    return res;
  }
};

/// }}}--- ///

const int N = 200 * 200;
ll inf = 1e18;
MinCostFlow ecas(N * 2, inf);

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int a[200][200];
  int h, w; cin >> h >> w;
  int s = 0 + N, t = w * h - 1;
  // ある最適解を, 二人が交わらないようにすることが可能.
  for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) {
    cin >> a[i][j];
    a[i][j] = - a[i][j];
    ecas.addEdge(i * w + j, i * w + j + N, 1, a[i][j]);
  }
  for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) {
    if(i != h - 1) ecas.addEdge(i * w + j + N, (i + 1) * w + j, 1, 0);
    if(j != w - 1) ecas.addEdge(i * w + j + N, i * w + (j + 1), 1, 0);
  }
  ll ans = a[0][0] + a[h - 1][w - 1];
  ans += ecas.solve(s, t, 2);
  cout << -ans << endl;
}



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

int main(){
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double x = pow(x1 - x2, 2);
    double y = pow(y1 - y2, 2);

    cout << fixed << setprecision(12) << sqrt(x + y) << endl;
    return 0;
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

ll x;

void f(ll c) {
    for (ll b = -1e4; b <= 1e4; ++b) {
        ll a = b + c;
        if (pow(a, 5LL) - pow(b, 5LL) == x) {
            cout << a << " " << b << endl;
            exit(0);
        }
    }
}

int main() {
    cin >> x;
    for (ll i = 1; i * i <= x; ++i) {
        if (x % i == 0) {
            f(i);
            if (x / i != i)
                f(x / i);
        }
    }

    return 0;
}

Measured memory_bytes: 4260
#include<stdio.h>
 
int main(void){
  int i,j,k,n,b,f,r,v;
  static int pe[4][3][10];
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    scanf("%d%d%d%d",&b,&f,&r,&v);
    pe[b-1][f-1][r-1]+=v;
  }
 
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++)
        printf(" %d",pe[i][j][k]);
      printf("\n");
    }
    if(i<3) printf("####################\n");
  }
return 0;
}


Measured memory_bytes: 2084
def main():
    N = int(input())
    A_l = [int(i) for i in input().split()]
    order = [-1 for _ in range(N)]

    for index, A in enumerate(A_l):
        order[A-1] = index+1
    print(" ".join([str(i) for i in order]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 61932
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
A = na()
mod = 10**9+7

def bSort(a):
    c = 0
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j] < a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]
                c += 1

    return c

cc = bSort(A)
B = sorted(A)
g = 0
p = 0
for i in range(1,n):
    if B[i-1] != B[i]:
        p = i
    g += p

j = k*(k-1)//2

ans = cc*k%mod+g*j%mod

print(ans%mod)

Measured memory_bytes: 40304
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int N=350*2,P=1e9+7;
typedef long long LL;

int n,K;
LL f[N][N];//f[i,j]表示连通块(i,j)的出现次数
LL g[N],ans;
int A[N],B[N];
int use[N];

int main(){
    scanf("%d%d",&n,&K);
    g[0]=1;
    FOR(i,1,n)g[i*2]=g[(i-1)*2]*(i*2ll-1)%P;
    FOR(i,1,K){
        scanf("%d%d",&A[i],&B[i]);
        use[A[i]]=use[B[i]]=1;
    }
    FOR(len,1,n*2-1){
        FOR(i,1,n*2-len){
            int j=i+len;
            int x=0,y=0;
            FOR(k,1,i-1)if(!use[k])++y;
            FOR(k,i,j)if(!use[k])++x;
            FOR(k,j+1,n*2)if(!use[k])++y;
            FOR(k,1,K)if((i<=A[k]&&A[k]<=j)^(i<=B[k]&&B[k]<=j))x=1;
            if((x&1)||(y&1))continue;
            //printf("x=%d,y=%d\n",x,y);
            f[i][j]=g[x];
            //printf("f[%d,%d]=%lld\n",i,j,f[i][j]);
            FOR(k,i,j-1){
                if(!use[k])--x;
                if(x&1)continue;
                f[i][j]=(f[i][j]-f[i][k]*g[x])%P;
                //printf("f[%d,%d]=%d\n",i,k,f[i][k]);
                //printf("(%d,%d) -= (%d,%d) * g[%d] * g[%d]\n",i,j,i,k,x,y);
            //printf("f[%d,%d]=%lld\n",i,j,f[i][j]);
            }
            //printf("f[%d,%d]=%lld\n",i,j,f[i][j]);
            if(f[i][j])ans=(ans+f[i][j]*g[y])%P;
        }
    }
    ans=(ans+P)%P;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x) for(int i = 0;i < x;++i)
#define FOR(i,x,y) for(int i = x;i < y;++i)
#define ALL(a) a.begin(),a.end()
using ll = long long;

int n,m,q;

vector<int>graph[123456];
int dist[123456];
typedef pair<int,int> P;
void dijkstra()
{
    REP(i,n)dist[i] = 123456789;
    dist[0] = 0;
    priority_queue<P,vector<P>,greater<P>>que;
    que.push({0,0});
    while(!que.empty())
    {
        P p = que.top();que.pop();
        int leng = p.first;
        int vect = p.second;
        if(leng > dist[vect])continue;
        for(int next : graph[vect])
        {
            if(dist[next] > leng + 1)
            {
                dist[next] = leng + 1;
                que.push({dist[next],next});
            }
        }
    }
}
struct edge
{
    int lf,rt;
    bool before;
};
vector<edge>input;
vector<int>tree[123456];
vector<int>query;
bool black[123456];
int blacknum = 1;
void color(int x)
{
    if(black[x])return;
    black[x] = true; blacknum++;
    for(int ch : tree[x]) color(ch);
}
void process(int ed)
{
    int ldis = dist[input[ed].lf];
    int rdis = dist[input[ed].rt];
    if(ldis > rdis)swap(input[ed].lf,input[ed].rt);
    if(ldis == rdis)return;
    tree[input[ed].lf].push_back(input[ed].rt);
    if(black[input[ed].lf])color(input[ed].rt);
}

int main()
{
    cin >> n >> m >> q;
    REP(i,m)
    {
        int u,v;
        cin >> u >> v;
        --u;--v;
        input.push_back({u,v,true});
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    REP(i,q)
    {
        int r;
        cin >> r;
        --r;
        input[r].before = false;
        query.push_back(r);
    }
    black[0] = true;
    dijkstra();
    REP(i,m)
    {
        if(input[i].before)
        {
            process(i);
        }
    }
    stack<int>ans;
    for(auto que = query.rbegin();que != query.rend();++que)
    {
        ans.push(n - blacknum);
        process(*que);
    }
    while(!ans.empty())
    {
        cout << ans.top() << endl;
        ans.pop();
    }
    return 0;
}

Measured memory_bytes: 20408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC125_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] strs_a = Console.ReadLine().Split(' ');

            int[] a = new int[n];
            int[] gcds_plus = new int[n];
            int[] gcds_minus = new int[n];
            //int[] gcds = new int[n];

            for (int i = 0; i < n; ++i)
            {
                a[i] = int.Parse(strs_a[i]);
            }

            int gcd_ = 1;
            int gcd_max = 1;

            if (n == 2)
            {
                gcd_max = Math.Max(a[0], a[1]);
            }
            else
            {
                gcd_ = gcd_arr(a, n, gcds_plus);
                gcd_ = gcd_arr_minus(a, n, gcds_minus);


                if (gcd_max < gcds_minus[1])
                {
                    gcd_max = gcds_minus[1];
                }
                if (gcd_max < gcds_plus[n - 2])
                {
                    gcd_max = gcds_plus[n - 2];
                }

                for (int i = 1; i < n - 1; ++i)
                {
                    int gcds = gcd(gcds_plus[i - 1], gcds_minus[i + 1]);

                    if (gcd_max < gcds)
                    {
                        gcd_max = gcds;
                    }

                }
            }

            Console.WriteLine("{0}", gcd_max);
        }

        static int gcd(int a, int b)
        {
            int c;
            while (a != 0)
            {
                c = a;
                a = b % a;
                b = c;
            }
            return b;
        }

        static int gcd_arr(int[] n, int size, int[] gcds)
        {
            int last_gcd, i;
            if (size < 2) return 0;

            last_gcd = gcd(n[0], n[1]);

            gcds[0] = n[0];
            gcds[1] = last_gcd;

            for (i = 2; i < size; i++)
            {
                last_gcd = gcd(last_gcd, n[i]);
                gcds[i] = last_gcd;
            }

            return last_gcd;
        }

        static int gcd_arr_minus(int[] n, int size, int[] gcds)
        {
            int last_gcd, i;
            if (size < 2) return 0;

            last_gcd = gcd(n[size - 2], n[size - 1]);

            gcds[size - 1] = n[size - 1];
            gcds[size - 2] = last_gcd;

            for (i = size - 3; i >= 0; i--)
            {
                last_gcd = gcd(last_gcd, n[i]);
                gcds[i] = last_gcd;
            }

            return last_gcd;
        }
    }
}


Measured memory_bytes: 23772
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifdef on_linux
	#include <sys/resource.h>
#endif

#ifdef dobby_is_a_free_elf
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
	#define trace(...) 0;
#endif

using namespace std;
using namespace __gnu_pbds;

#define int                     long long
#define ll                      long long

#define fi                      first
#define sc                      second
#define mp                      make_pair
#define pb                      push_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define sqr(a)                  ((a) * (a))
#define lbd                     lower_bound
#define ubd                     upper_bound
#define sz(x)                   (int)((x).size())
#define all(x)                  (x).begin(), (x).end()
#define mem0(x)                 memset(x, 0, sizeof (x))
#define mem1(x)                 memset(x, -1, sizeof (x))
#define pii                     pair<int32_t, int32_t>
#define pll                     pair<long long, long long>

#define DECIMAL(n)              cout << fixed << setprecision(n);
#define rep(i,a,b)              for(int32_t i = (a); i < (b); ++i)
#define between(i,x,y)          ((i) >= (x) && (i) <= (y))
// #define clamp(i,x,y)            (((i) < (x)) ? (x) : ((y) < (i)) ? (y) : (i));

template<typename T, typename U> static inline void remax(T &x, U y) {if (x < y) {x = y;}}
template<typename T, typename U> static inline void remin(T &x, U y) {if (y < x) {x = y;}}

static mt19937_64 gen(chrono::duration_cast<chrono::nanoseconds>
                      (chrono::high_resolution_clock::now().time_since_epoch()).count());

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase, insert same as normal set

const long double PI = 3.14159265358979323846264338;
const double eps = 1e-10;
const int32_t fftmod = 998244353;
const int32_t MOD = 1000000007;
const long long INF = 1e18;
const int32_t N = 1e5 + 10;
const int32_t NN = 1e6 + 10;



inline void elf_magic(int testcase)
{
	string s;
	cin >> s;
	string t = "YAKI";
	if (sz(s) < sz(t)) {
		cout << "No";
		return;
	}
	for (int i = 0; i < sz(t); ++i) {
		if (s[i] != t[i]) {
			cout << "No";
			return;
		}
	}
	cout << "Yes";
	return;
}

int32_t main()
{
	#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
	#endif

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

	int TESTS = 1;
	//cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		elf_magic(i);
		if (i != TESTS)	{ cout << '\n'; }
	}
	return 0;
}

Measured memory_bytes: 3576
#include<iostream>
using namespace std;
int main()
{
	int a, b;

	cin >> a >> b;

	if (a == b)
		cout << "Draw";
	else
		if (a == 1)
			cout << "Alice";
		else
			if (b == 1)
				cout << "Bob";
			else
				if (a > b)
					cout << "Alice";
				else
					cout << "Bob";

	cin >> a;


	return 0;
}

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

int main() {
  long long int q, h, s, d;
  long long int n;
  cin >> q >> h >> s >> d >> n;

  long long int half = min(2 * q, h);
  long long int one = min(half * 2, s);
  long long int two = min(one * 2, d);

  cout << two * (n / 2) + one * (n % 2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n;
int main(void) {
	ll ans = 0;
	cin >> n;
	rep(i, n) {
		ll l, r; cin >> l >> r;
		ans += (r - l) + 1;
	}
	printf("%lld\n", ans);
	return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int n;cin>>n;
	if(n%2==0){
		cout<<0.5<<endl;
	}
	else{
		printf("%.12lf\n",(n/2+1)/(double)n);
	}
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[3];
		for (int i=0;i<3;i++) {
			A[i]= sc.nextInt();
		}
		Arrays.sort(A);
		System.out.println(A[0]+A[1]);
	}
}


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

int main() {
  int n; cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  int ans = 0;
  rep(i, n) {
    for (int j=i+1; j<n; j++) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main(void)
{
  int len;
  char *s=(char *)malloc(128);
  scanf("%d",&len);
  scanf("%s",s);
  if(strlen(s)<=len){
    printf("%s\n",s);
  }else{
    for(int i=0;i<len;i++){
      printf("%c",*(s+i));
    }
    puts("...");
  }
  free(s);
}


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

int fun(int x){
    int ans = 0;
    for(int i = 1;;i++){
        ans += i;
        if(ans == x) return i;
        else if(x < ans) return i-1;
    }
}

int main() {
    ll n; cin >> n;
    ll half = sqrt(n);
    int ans = 0;
    if(n == 1){
        cout << 0 << endl; return 0;
    }
    for(int i = 2; i <= half; i++){
        int a = 0;
        while(n%i==0){
            a++;
            n /= i;
        }
        ans += fun(a);
    }
    if(n > 1) cout << ans+1 << endl;
    else cout << ans << endl;

    return 0;
}

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

int main() {
	int a[10],b[10];
	for(int i=0;i<10;i++)cin>>a[i];
	for(int i=0;i<10;i++)cin>>b[i];
	sort(a,a+10);
	sort(b,b+10);
	cout<<(a[9]+a[8]+a[7])<<" "<<(b[9]+b[8]+b[7])<<endl;
	return 0;
}

Measured memory_bytes: 3024
from bisect import bisect_left

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

aa = A[:]
aa.sort()

ans = 0
num = []

for i in range(N-1):
    ind = bisect_left(aa, A[i])
    del aa[ind]
    
    num.append(aa[-1]-A[i])

print(num.count(max(num)))

Measured memory_bytes: 14480