akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (m,d) = get!(usize,usize);
    let mut count = 0usize;
    for i in 1..m+1 {
        for j in 1..d+1 {
            let d10 = j/10;
            let d1 = j%10;
            if d10 >=2 && d1>=2 && d1*d10 == i {
                count += 1;
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 8572
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, h;
	cin >> n >> h;
	vector<pair<int, int>> vp;
	while (n--)
	{
		int a, b;
		cin >> a >> b;
		vp.emplace_back(b, 1);
		vp.emplace_back(a, h);
	}
	sort(vp.rbegin(), vp.rend());
	int ans = 0;
	for (auto& p : vp)
	{
		int o = min(p.second, (h + p.first - 1) / p.first);
		ans += o;
		h -= o * p.first;
		if (h <= 0) break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = a*c;
  ans = max(ans, a*d);
  ans = max(ans, b*c);
  ans = max(ans, b*d);
  cout << ans << endl;

}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

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

int main(){
	long long n,p,q;
	cin>>n>>p>>q;
	vector<int> v(n);
	long long sum = 0;
	rep(i,n) cin>>v[i],sum+=v[i];
	vector<long long> w(n);
	rep(i,n){
		w[i]=v[i]-p*(q-i);
	}
	sort(w.begin(),w.end());
	long long ans = LLONG_MAX/2;
	ans*=-1;
	rep(i,n+1){
		// cout<<i<<" "<<sum<<" "<<i*(i-1)<<" "<<sum+i*(i-1)<<endl;
		ans=max(ans,sum+p*i*(i-1));
		if(i<n) sum-=w[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8636
#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e5 + 7;
int n;
int a[maxx], b[maxx];
int ans, res;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	for(int i = 1; i <= n; i++) {
		if(a[i] == i) {
			swap(a[i], a[i + 1]);
			ans++;
		}
	}
	if(a[n] == n) ans++;
	for(int i = n; i >= 1; i--) {
		if(b[i] == i) {
			swap(b[i], b[i - 1]);
			res++;
		}
	}
	if(b[1] == 1) res++;
	cout << min(ans, res) << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <vector>
#include <sstream>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
int main(){ 
    int n; 
    cin >> n;
    long long a[n+2], sum = 0;
    a[0] = 0;
    a[n+1] = 0;
    for (int i = 0; i<n; i++){
    	cin >> a[i+1];
	}
	for (int i = 0; i<n+1; i++){
    	sum += abs(a[i+1]-a[i]);
	}
	for (int i = 0; i<n; i++){
		cout << sum - abs(a[i]-a[i+1]) - abs(a[i+1]-a[i+2]) + abs(a[i]-a[i+2]) << endl;
	}
	return 0;
}

Measured memory_bytes: 2048
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, m;
	scanf("%d%d", &n, &m);
	int k, p;
	vector<int> a(m);
	rep(i, n) {
		scanf("%d", &k);
		rep(j, k) {
			scanf("%d", &p);
			++a[--p];
		}
	}
	int ans = 0;
	rep(i, m) {
		if (a[i] == n)++ans;
	}
	printf("%d\n", ans);

	Please AC;
}


Measured memory_bytes: 3848
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

const long long INF = 1LL << 60;
const long long P = 1000000007;

int main() {
  string s;
  cin >> s;
  string t = "keyence";
  bool flag = false;
  for(int i = 0; i < s.size(); i++) {
    for(int j = i; j < s.size(); j++) {
      string u = "";
      for(int k = 0; k < s.size(); k++) {
        if(i > k || k > j) {
          u.push_back(s[k]);
        }
      }
      if(u == t) {
        flag = true;
      }
    }
  }
  if(s == t) {
    flag = true;
  }
  if(flag) {
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)

using namespace std;
typedef long long ll;
ll INF = 1001001001;
ll gcd(int a, int b) {return b ? gcd(b, a%b):a;}
ll lcm(int a, int b) {return a*b/gcd(a, b);}
  int main() {
    int N, K; cin >> N >> K;
    int count=0;
    vector<int> a(N);
    rep(i, N) {
      cin >> a[i]; 
      if(a[i]>=K) count++;
    }
    cout << count << endl;
  }

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		int K = GetInt();
		var h = new int[N];
		for(int i = 0; i < N; i++)
			h[i] = GetInt();

		int[] dp = Enumerable.Repeat(int.MaxValue, N).ToArray();
		dp[0] = 0;
		for(int i = 0; i < N - 1; i++)
		{
			for(int j = 1; j <= K; j++)
			{
				if(i + j >= N)
					break;

				dp[i + j] = Math.Min(dp[i + j], dp[i] + Math.Abs(h[i + j] - h[i]));				
			}
		}

		Console.WriteLine(dp[N - 1]);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 23392
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
#include <numeric>
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <queue>

using namespace std;


int main()
{
	int N;
	cin >> N;
	vector<double> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	
	long double tmp = 0.0;
	for (int i = 0; i < N; i++)
	{
		tmp += 1.0 / A[i];
	}

	long double ans = 1.0 / tmp;

	cout << ans << endl;

	return 0;
 
}

Measured memory_bytes: 256
import numpy as np
N,M,C=map(int,input().split())
B=np.array(input().split(),dtype=np.int32)
count=0
for i in range(N):
    A=np.array(input().split(),dtype=np.int32)
    if sum(A*B)+C>0:
        count+=1
print(count)

Measured memory_bytes: 27136
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    X = int(readline())
    X *=2
    i = 1
    while True:
        if i**2 + i >= X:
            print(i)
            break
        else:
            i += 1
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;

int main(int argc, char *argv[])
{
    int A, B, C;
    std::cin >> A >> B >> C;

    int K;
    std::cin >> K;

    int max = 0;

    std::vector<bool> flag(3, false);
    if (A <= B) {
        if (B <= C) {
            max = C;
            flag[2] = true;
        } else {
            max = B;
            flag[1] = true;
        }
    } else {
        if (A <= C) {
            max = C;
            flag[2] = true;
        } else {
            max = A;
            flag[0] = true;
        }
    }

    for (int i = 0; i < K; i++) {
        max *= 2;
    }

    if (flag[0]) {
        std::cout << max + B + C << std::endl;
    } else if (flag[1]) {
        std::cout << A + max + C << std::endl;
    } else if (flag[2]) {
        std::cout << A + B + max << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    public void solve() {
    	char[] S = ns().toCharArray();
    	char[] T = ns().toCharArray();
    	int[][] dp = new int[3001][3001];
    	for (int i = 0; i < S.length; i++) {
			for (int j = 0; j < T.length; j++) {
				if(S[i] == T[j]) {
					dp[i+1][j+1] = Math.max(dp[i+1][j+1],dp[i][j] + 1);
				} else {
					dp[i+1][j+1] = Math.max(dp[i+1][j+1],
									Math.max(dp[i][j+1], dp[i+1][j]));
				}
			}
		}
//    	out.println(dp[S.length][T.length]);	// 最長の長さ
    	
    	StringBuffer sb = new StringBuffer();
    	int si = S.length;
    	int tj = T.length;
    	while(si > 0 && tj > 0) {
    		if(dp[si][tj] == dp[si-1][tj])	si--;
    		else if(dp[si][tj] == dp[si][tj-1])	tj--;
    		else  {
				sb.append(S[si-1]);		// dp は　+1　しているので　-1 する
				si--; tj--;
    		}
    	}
    	out.println(sb.reverse().toString());
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  vll a(3); rep(i, 3) cin >> a[i];
  sort(all(a));
  ll flag = a[2] * 2 - a[0] - a[1];
  if(flag % 2 == 0) fin(flag / 2)
  else fin((flag + 3) / 2)
  return;
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

Measured memory_bytes: 256
/*input
3 4
2 2 4
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 998244353;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 3005;
int dp[N][N][3];

int main()
{
  ifalse;
  int n, s;
  cin >> n >> s;
  vector < int > a(n);
  for(auto &x: a) {
    cin >> x;
  }

  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for(int i = 0; i < n; i ++) {
    for(int j = 0; j <= s; j ++) {
      dp[i + 1][j][0] = add(dp[i + 1][j][0], dp[i][j][0]);
      dp[i + 1][j][1] = add(dp[i + 1][j][1], add(dp[i][j][0], dp[i][j][1]));
      dp[i + 1][j][2] = add(dp[i + 1][j][2], add(dp[i][j][0], add(dp[i][j][1], dp[i][j][2])));
      if(j + a[i] <= s) {
        dp[i + 1][j + a[i]][1] = add(dp[i + 1][j + a[i]][1], add(dp[i][j][0], dp[i][j][1]));
        dp[i + 1][j + a[i]][2] = add(dp[i + 1][j + a[i]][2], add(dp[i][j][0], dp[i][j][1]));
      }
    }
  }

  cout << dp[n][s][2], nl;
  return 0;
}

Measured memory_bytes: 106112
n, d = gets.chomp.split.map(&:to_i)
d = d * d
hash = {}
cnt = 0
n.times do |i|
	x, y = gets.chomp.split.map(&:to_i)
	# # #if d <= x ** 2 + y **2 && !hash.has_key?(x.to_s+"_"+y.to_s)
	# # 	cnt += 1
	# # 	hash[x.to_s+"_"+y.to_s] = 1
	# # end
	if d >= x *x +y * y
		cnt += 1
		#puts "x:#{x} y:#{y}"
	end
end
puts cnt


Measured memory_bytes: 14340
N = int(input())
K = list(map(int,input().rstrip().split(" ")))
Ka = [0] * (10 ** 5 + 1)
Ke = [0] * (10 ** 5 + 1)
Ka2 = []
Ke2 = []

for i in range(N):
    if i % 2 == 0: Ka[K[i]] += 1
    else: Ke[K[i]] += 1
Ka2 = sorted(Ka,reverse = True)
Ke2 = sorted(Ke,reverse = True)

if Ka.index(Ka2[0]) == Ke.index(Ke2[0]):
    if Ka2[0] - Ka2[1] < Ke2[0] - Ke2[1]:
        print(N - Ka2[1] - Ke2[0])
    else:
        print(N - Ka2[0] - Ke2[1])
else:
    print(N -Ka2[0] - Ke2[0])

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

ll a[214514],num[214514];

int main(){
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i)num[i]=num[i-1]+a[i];
		else num[i]=a[i];
	}
	ll ans=1e18;
	for(int i=0;i<n;i++){
		ans=min(ans,abs(num[i]*2-num[n-1]));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define LL long long
#define db long double

using namespace std;
const int N=4000+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int st[N],tp,an[N];
char cc[2];
int qry(int x,int y)
{
    printf("? %d %d\n",x,y),fflush(stdout);
    scanf("%s",cc);
    return cc[0]=='Y';
}

int main()
{
///
    int a=rd(),b=rd(),n=a+b;
    if(a<=b){puts("Impossible");exit(0);}
    for(int i=0;i<n;++i)
    {
	if(!tp) st[++tp]=i;
	else if(qry(st[tp],i)) st[++tp]=i;
	else --tp;
    }
    int smy=st[tp];
    for(int i=0;i<n;++i) an[i]=qry(smy,i);
    printf("! ");
    for(int i=0;i<n;++i) printf("%d",an[i]);
    exit(0);
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,x;
	cin>>n>>m>>x;
	int a[m];
	int A=0,B=0;
	for(int i=0;i<m;i++){
		cin>>a[i];
		if(a[i]<x) A++;
		else B++;
	}
	cout<<min(A,B);
	return 0;
}


Measured memory_bytes: 380
sub gcd{my($a,$b)=@_;$b?gcd($b,$a%$b):$a}
$N=<>;
@A=glob<>;
@L=(0,map$l=gcd($l,$_),@A);
@R=reverse(0,map$r=gcd($r,$_),reverse@A);
printf sort{$b-$a}map gcd($L[$_],$R[$_+1]),0..$N-1


Measured memory_bytes: 42760
#include <iostream>

using namespace std;

int main()
{
   char chara;
   cin>>chara;

    if(chara=='a'||chara=='e'||chara=='o'||chara=='u'||chara=='i'){
            cout<<"vowel";

    }
   else{
        cout<<"consonant";

   }

    return 0;
}

Measured memory_bytes: 384
def main():
    N, P = list(map(int, input().split()))
    S = map(int, input())
    if P == 2 or P == 5:
        r = 0
        for i, s in enumerate(S):
            if s % P == 0:
                r += (i + 1)
        return r

    g1 = [1, 1]
    g2 = [1, 1]
    inverse = [0, 1]
    mod = P
    for i in range(2, P):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    H = [0] * N
    h = 0
    for i, s in enumerate(S):
        h = (h * 10 + s) % P
        H[i] = h
    K = [0] * P
    K[0] = 1
    shift = 1
    r = 0
    for i, h in enumerate(H):
        t = (h * inverse[shift]) % P
        r += K[t]
        K[(h * inverse[shift]) % P] += 1
        shift = (shift * 10) % P

    return r
   

print(main())


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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n,m;
    cin >> n >> m;
    int ans = ((n-m)*100+m*1900)*pow(2,m);
    COUT(ans);
    return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
char p[1005],h[]={'e','y','e','n','c','e','\0'},pp[]={'k','e','y','e','n','c','e','\0'};
main()
{
	scanf("%s",p);
	int ckk=0;
	for(int i = 0;p[i];i++)
	{
		if(i>0)
		ckk=1;
		if(p[i]=='k')
		{
			int ck=0,ck2=0;
			for(int j = 0,po=i+1;j <= 6 && p[po];)
			{
				ck2=0;
				for(int k = po;p[k];k++,po++)
				{
					if(p[k]!=h[j])
					{
						//printf("%c %c %d %d\n",p[k],h[j],k,j);
						ck2=1;
					}
					else
					{
						j++;
						po++;
						break;
					}
				}
				ck+=ck2;
				//if(ck2==1)
				//printf("%d ",j);
				if(p[po]=='\0')
				{
					if(j==6 && ck<=1-ckk)
					{
						printf("YES");
						return 0;
					}
				}
				else
				{
					if(j==6)
					{
						if(ck<=-ckk)
						{
							printf("YES");
							return 0;
						}
					}
				}
			}
		}
	}
	int co=0;
	for(int i = 0;p[i];i++)
	{
		if(p[i]==pp[i])
		co++;
		else
		break;
	}
	for(int i = strlen(p)-1,cc=6;i >= 0;i--)
	{
		if(p[i]==pp[cc])
		{
			cc--;
			co++;
		}
		else
		break;
	}
	//printf("%d  ",co);
	if(co>=7)
	printf("YES");
	else
	printf("NO");
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl H(N);
    for (ll i = 0; i < N; i++) {
        cin >> H[i];
    }
    bool ok = true;
    for (ll i = N - 2; i >= 0; i--) {
        if (H[i] > H[i + 1] + 1) {
            ok = false;
            break;
        }
        else if (H[i] > H[i + 1]) {
            --H[i];
        }
    }

    cout << (ok ? "Yes\n" : "No\n");
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    vector<vector <int > > v(K);
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int b;
            cin >> b;
          b--;
            v[i].push_back(b);
        }
    }
    int key = 0;
    vector<int> count(N);
    for (int h = 0; h < N; h++) {
        for (int i = 0; i < K; i++) {
            for (int j = 0; j < v[i].size(); j++) {
                if (v[i][j] == h) {
                    count[h]++;
                }
            }
        }
        if (count[h] > 0) {
            key++;
        }
    }
     cout << N - key << endl;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
          
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int tate = int.Parse(str[0]);
                int yoko = int.Parse(str[1]);

                if ((tate == 0) && (yoko == 0))
                {
                    break;
                }
                for (int i = 0; i < tate; ++i)
                {
                    for (int j = 0; j < yoko; ++j)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
                
            }
        }
    }
}

Measured memory_bytes: 5296
N, K = map(int, input().split())
mod = 10**9 + 7
ans = 0
for i in range(K, N+2):
  mi = N-i+1
  ma = N
  s_max = ((mi+ma)*i)//2
  mi = 0
  ma = i-1
  s_min = ((mi+ma)*i)//2
  #print(s_min, s_max)
  ans += (s_max-s_min+1)
  ans %= mod

print(ans)



Measured memory_bytes: 9188
import java.util.*;

 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		
		HashMap<Character, TreeSet<Integer>> map = new HashMap<>();
		for (int i=0;i<26;i++) {
			map.put((char)('a'+i), new TreeSet<Integer>());
		}
		
		for (int i=0;i<s.length();i++) {
			map.get(s.charAt(i)).add(i);
		}
		int pos = -1;
		long num = 0;
		for (int i=0;i<t.length();i++) {
			if (map.get(t.charAt(i)).isEmpty()) {
				System.out.println(-1);
				return;
			} else {
				if (map.get(t.charAt(i)).higher(pos) != null) {
					pos = map.get(t.charAt(i)).higher(pos);
				} else {
					num++;
					pos = map.get(t.charAt(i)).first();
				}
			}
		}
		
		
		System.out.println(num*s.length()+pos+1);
	}
}
 

Measured memory_bytes: 36020
#include<string>
#include<iostream>
#include<set>

using namespace std;


string rev(string& s) {
	string ns;
	for (auto itr = s.rbegin(); itr != s.rend(); ++itr) {
		ns.push_back(*itr);
	}
	return ns;
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		set<string> st;
		string s;
		cin >> s;
		for (int j = 0; j < s.size() - 1; j++) {
			string ls;
			for (int k = 0; k <= j; k++) {
				ls.push_back(s[k]);
			}
			string rs;
			for (int k = s.size()-1; k >j; k--) {
				rs.push_back(s[k]);
			}
			string ns1 = ls; ns1 += rs; st.insert(ns1);
			ns1 = ls; ns1 += rev(rs); st.insert(ns1);
			ns1 = rev(ls); ns1 += rs; st.insert(ns1);
			ns1 = rev(ls); ns1 += rev(rs); st.insert(ns1);
			ns1 = rs; ns1 += ls; st.insert(ns1);
			ns1 = rs; ns1 += rev(ls); st.insert(ns1);
			ns1 = rev(rs); ns1 += ls; st.insert(ns1);
			ns1 = rev(rs); ns1 += rev(ls); st.insert(ns1);
		}
		cout << st.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3244
import sys
from collections import deque
import copy
import math
import heapq
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, T] = [int(input_raw[0]), int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = [int(input_raw[i]) for i in range(N)]
    que = [-A[N - 1]]
    max_sub = 0
    count = 0
    for i in range(N-2, -1, -1):
        if (-que[0]) - A[i] == max_sub:
            count += 1
        elif (-que[0]) - A[i] > max_sub:
            count = 1
            max_sub = max((-que[0]) - A[i], max_sub)
        heapq.heappush(que, -A[i])
    print min(count, T/2)




if __name__ == '__main__':
    main()


Measured memory_bytes: 45212
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;

    set<string> keihin;

    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        keihin.insert(s);
    }

    cout << keihin.size() << endl;
    
    
    return 0;
}

Measured memory_bytes: 19252
N = int(input())
H = [int(h) for h in input().split()]

max = 0
count = 0
for i in range(len(H)-1):
    if H[i] >= H[i+1]:
        count += 1
    else:
        if count > max:
            max = count
        count = 0
if count > max:
    max = count
print(max)

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

ll bnf1();
ll bnf2();
ll bnf3();
ll get_digit();

string s;
int p,priority[300],len;

ll Cal(ll res,char c,ll x){
  p++;
  
  ll r;
  
  if(x==2)r=bnf2();
  if(x==3)r=bnf3();
  if(x==4)r=get_digit();
  
  if(c=='+') return res+r;
  if(c=='-') return res-r;
  return res*r;
}

ll bnf(){
  
  ll res;
  
  if(p<len&&s[p]=='('){
    
    p++;
    
    res=bnf1();
    
    p++;
    return res;
  }

  res=bnf1();

  return res;  
}

ll bnf1(){
  
  ll res=bnf2();
  
  while(p<len&&priority[s[p]]==1) res=Cal(res,s[p],2);
  
  return res;
}

ll bnf2(){
  
  ll res=bnf3();
  
  while(p<len&&priority[s[p]]==2) res=Cal(res,s[p],3);
  
  return res;
}

ll bnf3(){
  
  ll res=get_digit();
  
  while(p<len&&priority[s[p]]==3) res=Cal(res,s[p],4);
  
  return res;
}

ll get_digit(){
  
  ll res=0;
  
  if(s[p]=='('){
    
    res=bnf();
    
    return res;
  }
  
  while('0'<=s[p]&&s[p]<='9') res=res*10+s[p++]-'0';
  
  return res;
}


int main(){
  
  cin>>s;

  s='('+s+')';
  len=s.size();
  
  ll ans;
  int flag=0;
  
  for(int i=1;i<=3;i++)
    for(int j=1;j<=3;j++)
      for(int k=1;k<=3;k++){
	priority['+']=i;
	priority['-']=j;
	priority['*']=k;
	p=0;
	if(!flag)ans=bnf(),flag=1;
	else ans=max(ans,bnf());
      }

  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3212
#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>;

const int INF = 1001001001;

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  int ans = INF;
  for(int i=1; i <= 100; ++i){
    int sum = 0;
    rep(j,n){
      sum += (x[j] - i) * (x[j] - i);
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#!/usr/local/gnu/bin/bash
read n
w=(`tr a a`)
if((`echo ${w[@]} | tr ' ' '\n' | sort -u | wc -l`!=n))
then
    echo No
    exit
fi
for i in `seq $((n-1))`
do
    if [ ${w[i-1]: -1} != ${w[i]:0:1} ]
    then
        echo No
        exit
    fi
done
echo Yes

Measured memory_bytes: 1000
// (function main(){
//   const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
//   const n = Number(lines.shift());
//   lines.shift().split(' ').map(Number).forEach(function(key, i, a) {
//     console.log(`node ${i+1}: key = ${a[i++]}, `+((i-1)?`parent key = ${a[Math.floor(i/2)-1]}, `:'')+(2*i-1<a.length?`left key = ${a[2*i-1]}, `:'')+(2*i<a.length?`right key = ${a[2*i]}, `:''));
//   });
// })();

require('fs').readFileSync('/dev/stdin', 'utf8').trim().split(/[ |\n]/).slice(1).forEach((k,i,a)=>console.log(`node ${++i}: key = ${k}, `+((i-1)?`parent key = ${a[Math.floor(i/2)-1]}, `:'')+(2*i-1<a.length?`left key = ${a[2*i-1]}, `:'')+(2*i<a.length?`right key = ${a[2*i]}, `:'')))



Measured memory_bytes: 17280
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll x, y;
	cin >> x >> y;

	cout << (abs(x - y) <= 1 ? "Brown" : "Alice") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

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

int main() {
    ll x,y;
    cin>>x>>y;
    ll sum=0;
    while(x<=y){
        x*=2;
        sum+=1;
    }
    cout<<sum<<endl;


    return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        s : chars
    }
    let mut char0 : i32 = 0;
    let mut char1 : i32 = 0;
    for i in s.iter() {
        if i == &'1' {char0 += 1} else {char1 += 1};
    }
    println!("{:?}", if char0 * char1 == 0 {0} else {if char0 > char1 {char1 * 2} else {char0 * 2} });
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x0, x;
  cin >> N;
  int mx = 0;
  int ans = 0;
  cin >> x0;
  for (int i = 0; i < N-1; i++){
    cin >> x;
    
    if (x0 >= x) ans++;
    else ans = 0;
    
    mx = max(mx, ans);
    x0 = x;
  }
  cout << mx << endl;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b" << endl;
	}
	if (a > b) {
		cout << "a > b" << endl;
	}
	if (a == b) {
		cout << "a == b" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String[] v = br.readLine().split(" ");
			int[] n = {
					Integer.parseInt(v[0]),
					Integer.parseInt(v[1]),
					Integer.parseInt(v[2])
			};
			Arrays.sort(n);

			System.out.println(n[0] + " " + n[1] + " " + n[2]);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24484
n, q = [int(e) for e in input().split()]
A = []
res = []
for i in range(n):
    l = input().split()
    A.append((l[0], int(l[1])))

idx = 0
tot_t = 0
while A:
    dif = A[0][1] - q
    if dif <= 0:
        tot_t += A[0][1]
        res.append((A[0][0], tot_t))
        A.pop(0)
    else:
        tmp = (A[0][0], dif)
        A.pop(0)
        A.append(tmp)
        tot_t += q

for e in res:
    print(e[0], e[1])



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

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll>a(n);
  rep(i,0,n) cin >> a[i];
  sort(a.begin(),a.end());
  ll lb = 1; //lower bound(下限)
  ll ub = a[n-1]+1; //upper bound(上限)
  ll mid = (lb+ub)/2; //ここで二分
  while(lb < ub){
    ll cnt = 0;
    rep(i,0,n){
      cnt += (a[i]-1)/mid;
    }
    if(cnt <= k){
      ub = mid; 
      mid = (lb+ub)/2;
    }
    else{
      lb = mid+1;
      mid = (lb+ub)/2;
    }
  }
  cout << lb << endl;
}

Measured memory_bytes: 4768
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
int a, b, c;

void solve() {
	cin >> a >> b >> c;
	int sum = a + b + c;
	int M = max({a, b, c});
	int mod1 = (a + b + c) % 2;
	int mod2 = M % 2;
	if (mod1 != mod2) {
		M = M + 1;
	}
	cout << ((3 * M) - sum) / 2 << endl;
	return;
}

int main(int args, char* argv[]) {
	solve();
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<i64>();
    let mut a = 1;
    let mut ans = std::usize::MAX;
    while a * a <= n {
        if n % a == 0 {
            let b = n / a;
            ans = min(ans, format!("{}", b).len());
        }
        a += 1;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
package main

import (
	"fmt"
)

func permutation(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
		}
	} else if k > n {
		v = 0
	}
	return v
}

func factorial(n int) int {
	return permutation(n, n-1)
}

func combination(n int, k int) int {
	return permutation(n, k) / factorial(k)
}

func homogeneous(n int, k int) int {
	return combination(n+k-1, k)
}

func main() {

	var n, m int
	fmt.Scan(&n, &m)

	g := combination(n, 2)
	k := combination(m, 2)
	fmt.Println(g + k)

}


Measured memory_bytes: 512
n, m, k = map(int, input().split())
MOD = 998244353
ans = 0
c = 1

for i in range(k + 1):
    ans += (((m * pow(m - 1, n - i - 1, MOD)) % MOD) * c) % MOD
    ans %= MOD
    c = (c * (n - 1 - i) * pow(i + 1, MOD - 2, MOD)) % MOD
    
    
print(ans%MOD)

Measured memory_bytes: 68360
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		byte[] cc = sc.next().getBytes();
		int n = cc.length;
		println((n % 2 == 1) == (cc[0] == cc[n - 1]) ? "Second" : "First");
	}
}


Measured memory_bytes: 39352
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 日 12/10 19:59:05 2017
 * Ended  Time*  : 日 12/10 20:05:03 2017
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const int MaxN = 2e5;

int cnt[MaxN + 5];
int n, k;

bool cmp(int x, int y){ return x > y; }

int main()
{
	while(~scanf("%d %d", &n, &k)){
		for(int i = 1; i <= n; i++){
			int x;
			scanf("%d", &x);
			cnt[x]++;
		}
		sort(cnt + 1, cnt + 1 + n, cmp);
		int tot = 0;
		for(int i = k + 1; i <= n; i++) tot += cnt[i];
		printf("%d\n", tot);
		memset(cnt, 0, sizeof(cnt));
	}
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
int main(void)
{
	int s[50],i = 0, j;
	double w[50], h[50], b[50];
	
	while(scanf("%d, %lf, %lf",&s[i], &w[i], &h[i]) != EOF){
		b[i] = w[i] / (h[i] * h[i]);
		i++;
	}
	for(j = 0; j <= i; j++){
		if(b[j] >= 25){
			printf("%d\n", s[j]);
		}
	}
	
	return 0;
}


Measured memory_bytes: 1980
r,g,b,n = map(int,input().split())
count = 0
for i in range(n+1):
    for j in range(n+1):
        all_sum = n
        all_sum  -= i*r
        all_sum  -= j*g
        if all_sum < 0:
            continue
        if all_sum %b == 0 and i+j+(all_sum//b) != 0:
            count += 1
            #print(i,j,all_sum,b)
print(count) 

Measured memory_bytes: 40940
#include <iostream>

using namespace std;

int main() {
	const int max = 50;

	int N, M;
	char a[max][max],  b[max][max];
	bool ans = false;

	cin >> N >> M;
	for (int i = 0; i < N; i++)	cin >> a[i];
	for (int i = 0; i < M; i++)	cin >> b[i];

	for (int i = 0; i <= N - M; i++) {
		for (int j = 0; j <= N - M; j++) {
			for (int k = 0; k < M; k++) {
				for (int l = 0; l < M; l++) {
					if (a[i + k][j + l] != b[k][l])	goto OUT;
					if (k == M - 1 && l == M - 1) {
						ans = true;
						goto ANS;
					}
				}
			}
			OUT:;
		}
	}

	ANS:
	cout << ((ans) ? "Yes" : "No") << endl;

	return 0;
}

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

const string R = "yuiophjklnm";

int main() {
  for(string s; cin >> s && s != "#"; ) {
    int res = 0;
    for(int i = 1; i < s.size(); ++i) {
      res += (R.find(s[i-1]) == string::npos) ^ (R.find(s[i]) == string::npos );
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
import kotlin.math.ceil

fun main() = Thread(null, ::abc173a, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc173a() {
    val n = readLine()!!.toInt()

    val payment = ceil(n / 1000.0).toInt() * 1000

    val answer = payment - n

    println(answer)
}


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

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

  int N;
  cin >> N;

  vector<int> A(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }

  long long ans = 0;
  vector<int> AA = A;

  auto Eval = [&](const vector<int> &order) {
    long long cost = 0;
    A = AA;
    for (auto i : order) {
      if (i == 0) continue;
      long long cur = 0;
      for (int j = i; j <= N; j += i) {
        cur += A[j];
      }
      if (cur < 0) {
        for (int j = i; j <= N; j += i) {
          A[j] = 0;
        }
      }
    }
    for (int i = 1; i <= N; i++) {
      cost += A[i];
    }
    return cost;
  };

  vector<int> order(N + 1);
  iota(begin(order), end(order), 0);
  ans = max(ans, Eval(order));
  reverse(begin(order), end(order));
  ans = max(ans, Eval(order));
  
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
  for (int rep = 0; rep < 10000; rep++) {
    shuffle(begin(order), end(order), rnd);
    ans = max(ans, Eval(order));
  }

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


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a + n);
    cout << a[n / 2] - a[n / 2 - 1];
    return 0;
}

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

#define int long long

int32_t main() {
	int n ;
	cin >> n ;
	map<int,int> mp ;
	for(int i = 0 ; i < n ; i++) {
		int x ;
		cin >> x ;
		mp[x]++ ;
	}
	if(mp.size() > 3 || n%3){
		if(mp[0] == n) cout << "Yes" ;
		else
		cout << "No" ;
	}else{
		if(mp.size() == 1){
			if(mp[0] == n){
				cout << "Yes" ; return 0 ;
			}
		}else if(mp.size() == 2){
			if(mp[0] == n/3){
				cout << "Yes" ; return 0 ;
			}
		}else{
			int x = 0 ;
			for(auto i : mp){
				x ^= i.first ;
				if(i.second != n/3){
					cout << "No" ; return 0 ;
				}
			}
			if(x == 0){
				cout << "Yes" ; return 0 ;
			}
		}
		cout << "No" ;
	}
	return 0;
}

Measured memory_bytes: 5120