akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int L;
vector<i64> A;

i64 eel[202020];
i64 eer[202020];
i64 ool[202020];
i64 oor[202020];
i64 rl[202020];
i64 ll[202020];

int main() {
  cin >> L;
  A.resize(L + 1);
  rep(i,1,L) cin >> A[i];
  int l = 1;
  int r = L;
  while(l <= L && A[l] == 0) l++;
  while(r >= 1 && A[r] == 0) r--;
  if(l > r) {
    cout << 0 << endl;
    return 0;
  }
  {
    i64 sum = 0;
    rep(i,l,r) {
      i64 x = A[i] & 1;
      if(A[i] == 0) x = 2;
      sum += A[i];
      eel[i] = min(eel[i - 1] + x, sum);
    }
  }
  {
    i64 sum = 0;
    rep(i,l,r) {
      i64 x = A[i] & 1;
      x = x ^ 1;
      sum += A[i];
      ool[i] = min({ool[i - 1] + x, sum, eel[i]});
    }
  }
  {
    i64 sum = 0;
    for(int i = r;i >= l;i--) {
      i64 x = A[i] & 1;
      if(A[i] == 0) x = 2;
      sum += A[i];
      eer[i] = min(eer[i + 1] + x, sum);
    }
  }
  {
    i64 sum = 0;
    for(int i = r;i >= l;i--){
      i64 x = A[i] & 1;
      x = x ^ 1;
      sum += A[i];
      oor[i] = min({oor[i + 1] + x, sum, eer[i]});
    }
  }
  i64 ans = min({eel[r], ool[r], eer[l] , oor[l]});
  rep(i,l,r) {
    ans = min(eel[i] + oor[i + 1], ans);
    ans = min(ool[i] + eer[i + 1], ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 9216
#include <cstdio>
#include <cmath>
#include <deque>
using namespace std;

struct D {double x; double y;};
typedef deque<D> v;

void koch(int n, v &d)
{
	if (n-- == 0)
		return;

	D e = d.back(); d.pop_back();
	D b = d.back();
	D p = {e.x - b.x, e.y - b.y};
	double l = sqrt(p.x * p.x + p.y * p.y);
	double r = atan2(p.y, p.x);
	auto f = [&](D x) {d.push_back(x); koch(n, d);};

	f({p.x / 3 + b.x, p.y / 3 + b.y});
	f({l / 3 * cos(M_PI / 3 + r) + p.x / 3 + b.x, l / 3 * sin(M_PI / 3 + r) + p.y / 3 + b.y});
	f({p.x * 2 / 3 + b.x, p.y * 2 / 3 + b.y});
	f(e);
}

int main()
{
	int n;
	v d = {{0, 0}, {100, 0}};
	scanf("%d", &n);

	koch(n, d);
	
	for (D x : d)
		printf("%.8f %.8f\n", x.x, x.y);
}


Measured memory_bytes: 3268
l,r=map(int, input().split())

k=0

can=[]
while l+k<=r and k<2020:
    can.append((l+k)%2019)
    k+=1
ans=2020
import itertools

for seq in itertools.combinations(range(len(can)),2):
    ans=min(ans,(can[seq[0]]*can[seq[1]])%2019)
print(ans)

Measured memory_bytes: 73560
interface Unit {
  /** 料理の添え字 */
  i: number;
  /** 高橋生値 */
  tv: number;
  /** 青木生値 */
  av: number;
  /** 合計 */
  wa: number;
}
function main(input) {
  const args: string[] = input.split("\n");
  const N = parseInt(args[0]);
  const arr: Unit[] = [];
  for (let i = 0; i < N; i++) {
    const points: number[] = args[i + 1].split(" ").map(v => parseInt(v));
    arr.push({
      i: i,
      tv: points[0],
      av: points[1],
      wa: points[0] + points[1]
    });
  }
  arr.sort(mysort);
  let result = 0;
  for (let i = 0; i < N; i++) {
    if (i % 2 === 0) {
      // 偶数は高橋の独壇場
      result += arr[i].tv;
    } else {
      // 奇数は青木の独壇場
      result -= arr[i].av;
    }
  }
  console.log(`${result}`);
}

function mysort(a: Unit, b: Unit): number {
  const wa = b.wa - a.wa;
  if (wa !== 0) {
    return wa;
  } else {
    // 同じなのならば高い方からにすればよい
    return (a.tv - a.av) - (b.tv - b.av);
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 53612
N, M = map(int, input().split())
from collections import defaultdict
d = defaultdict(list)
for i in range(M):
    P,Y = map(int, input().split())
    d[P].append([Y,i])
l = [0 for i in range(M)] 
cnt = 0   
for key in d:
    data = sorted(d[key])
    tmp = 0
    for i in range(len(data)):
        l[cnt] = [str(key).zfill(6) + str(tmp+1).zfill(6), data[i][1]]
        cnt += 1
        tmp += 1
l.sort(key = lambda x: x[1])
for i in range(M):
    print(l[i][0])

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

int main() {
	string s;cin >>s;
	int ia,iz;
	for (int i=0;i<s.size();++i){
		if(s[i] == 'A') {
			ia = i;
			break;
		}
	}
	for (int i=s.size()-1;i>0;--i){
		if(s[i] == 'Z') {
			iz = i;
			break;
		}
	}
	cout << iz - ia + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String SA = sc.next();
	String SB = sc.next();
	String SC = sc.next();
	int i = 0,j = 0,k = 0;
	String ans = "";
	char tmp = SA.charAt(i);
	i++;
	boolean f = true;
	while(f){
	    // System.out.println(tmp);
	    if ( tmp == 'a' ) {
		if ( i == SA.length() ) {
		    ans = "A";
		    break;
		}				
		tmp = SA.charAt(i);
		i++;

		//	System.out.println("111111");
	    } else if (tmp == 'b') {
		if ( j == SB.length() ) {
		    ans = "B";
		    break;
		}						
		tmp = SB.charAt(j);
		j++;
		//		System.out.println("222222");		
	    } else if (tmp == 'c') {
		if ( k == SC.length() ) {
		    ans = "C";
		    break;
		}						
		tmp = SC.charAt(k);
		k++;
		//		System.out.println("333333");		
	    }
	    
	}
	System.out.println(ans);
    }
}


Measured memory_bytes: 21844
def BubbleSort(A):
    nswap = 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]
                nswap += 1
    return nswap, A

input()
a = list(map(int, input().split()))

ns, sa = BubbleSort(a)
print(' '.join(map(str, sa)))
print(ns)


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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for(ll i = 0;i < n;i++){
        cin >> h[i];
    }

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

    for(ll i = n - 1;i >= n - k && i >= 0;i--){
        h[i] = 0;
    }

    ll ans = 0;
    for(ll i = 0;i < n;i++){
        ans += h[i];
    }

    cout << ans;

    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  ll x;
  cin >> x;
  ll ans = x / 11 * 2;
  x %= 11;
  if (x > 0) {
    x -= 6;
    ans++;
  }
  if (x > 0) {
    x -= 5;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_a
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	vector<ll> h;
	for(ll i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		h.push_back(x);
	}
	vector<ll>cost(n,INT_MAX);
	cost[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=i+2;j++)
		{
			if(j<n)
			{
				cost[j]=min(cost[j],cost[i]+abs(h[i]-h[j]));
			}
		}
	}
	cout<<cost[cost.size()-1]<<"\n";	
	return 0;
}

Measured memory_bytes: 1908
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto b = RD!string;

	if (b == "A")
		writeln("T");
	else if (b == "T")
		writeln("A");
	else if (b == "C")
		writeln("G");
	else
		writeln("C");

	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char g[105][105];
int n, m, step[105][105][4], now;
bool visit[105][105][4];
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
char ans[] = {"NESW"};

bool ok(int x, int y)
{
    if(x < 1 || x > n || y < 1 || y > m || g[x][y] == '#') return false;
    return true;
}

bool go(int &x, int &y, int &dir)
{
    int nx, ny;
    while(true)
    {
        nx = x + dx[dir], ny = y + dy[dir];
        if(ok(nx, ny))
        {
            x = nx, y = ny;
            break;
        }
        else
            dir = (dir+1)%4;
    }
    ++ now;
    if(visit[x][y][dir])  return 1;
    visit[x][y][dir] = 1;
    step[x][y][dir] = now;
    return 0;
}


int main()
{
    long long k;
    while(scanf("%d%d%lld", &n, &m, &k) != EOF && n+m+k)
    {
        int x, y, dir;
        for(int i = 1; i <= n; ++ i)
        {
            scanf("%s", g[i]+1);
            for(int j = 1; j <= m; ++ j)
                if(g[i][j] != '.' && g[i][j] != '#')
                {
                    x = i, y = j;
                    if(g[i][j] == 'N')  dir = 0;
                    else if(g[i][j] == 'E')  dir = 1;
                    else if(g[i][j] == 'S')  dir = 2;
                    else  dir = 3;
                }
        }
        memset(visit, 0, sizeof(visit));
        visit[x][y][dir] = 1;
        step[x][y][dir] = 1;
        now = 1;
        while(k)
        {
            if(go(x, y, dir))
            {
                k = k%(now-step[x][y][dir]);
                if(k > 0) -- k;
                else k += now-step[x][y][dir]-1;
                break;
            }
            -- k;
        }
        while(k)
        {
            go(x, y, dir);
            -- k;
        }
        printf("%d %d %c\n", x, y, ans[dir]);
    }
}

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

using namespace std;
typedef long long LL;
int arr[55], N, K;
LL kiri[55][121], kanan[55][121];

int main() {
	for (int i = 0; i <= 54; i++) {
		for (int j = 0; j <= 120; j++) {
			kiri[i][j] = 1e9;
			kanan[i][j] = 1e9;
		}
	}
	int N, K;
	cin >> N >> K;
	kiri[0][0] = 0, kanan[N + 1][0] = 0;
	LL sum = 0;
	int negatif = 0;
	for (int i = 1; i <= N; i++) {
		cin >> arr[i];
		sum += arr[i];
		if (arr[i] < 0) {
			negatif++;
			sum -= arr[i];
		}
	}
	if (K >= N + negatif) cout << sum << "\n";
	else {
		//kiri
		sum = 0;
		priority_queue<int> neg, pos;
		for (int i = 1; i <= N; i++) {
			sum += arr[i];
			if (arr[i] <= 0) neg.push(-arr[i]);
			else pos.push(arr[i]);
			stack<int> tmp;
			int sum2 = sum;
			for (int j = 0; j <= K - i; j++) {
				kiri[i][i + j] = sum2;	
				if (!neg.empty()) {
					sum2 += neg.top();
					tmp.push(neg.top());
					neg.pop();
				} else break;
			}
			while (!tmp.empty()) {
				neg.push(tmp.top());
				tmp.pop();
			}
		}
		while (!neg.empty()) neg.pop();
		while (!pos.empty()) pos.pop();
		//kanan
		sum = 0;
		for (int i = N; i >= 1; i--) {
			sum += arr[i];
			if (arr[i] < 0) neg.push(-arr[i]);
			else pos.push(arr[i]);
			stack<int> tmp;
			int sum2 = sum;
			for (int j = 0; j <= K - (N - i + 1); j++) {
				kanan[i][(N - i + 1) + j] = sum2;	
				if (!neg.empty()) {
					sum2 += neg.top();
					tmp.push(neg.top());
					neg.pop();
				} else break;
			}
			while (!tmp.empty()) {
				neg.push(tmp.top());
				tmp.pop();
			}
		}
		LL ans = 0;
		for (int i = 0; i <= N; i++) {
			for (int j = N + 1; j >= 0; j--) {
				if (i >= j) break;
				for (int k = i; k <= K; k++) {
					for (int l = N - j + 1; l <= K - k; l++) {
						if (kiri[i][k] == 1e9) {
							k = K;
							break;
						}
						if (kanan[j][l] == 1e9) break;
						ans = max(ans, kiri[i][k] + kanan[j][l]);
					}
				}
			}
		}
		cout << ans << "\n"; 
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  string w;cin>>w;
  map<char,int> mp;
  each(c,w){
    mp[c]++;
  }
  each(m,mp){
    if(m.second%2!=0){
      print("No");
      re 0;
    }
  }
  print("Yes");

}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int r,g,b; cin>>r>>g>>b;
    if((g*10+b)%4) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}


Measured memory_bytes: 3568
#include <iostream>
#include <math.h>

using namespace std;

int main(void){
	int n, i;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	double dega, degb;

	cin >> n;

	for(i=0;i<n;i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

		dega = (y2 - y1) / (x2 - x1);
		degb = (y4 - y3) / (x4 - x3);
	
		if(dega == degb){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			long N = scan.nextLong();
			long K = scan.nextLong();
			
			int answer = 0;
			if(N==K) {
				answer = 0;
				System.out.println(0);
			}else if(N<K){
				long sa = Math.abs(N-K);
				long min  = sa;
				long sb = Math.abs(sa-K);
				if(sb<min)min = sb;
				System.out.println(min);
			}else if(N>K) {
				long amari = N%K;
				long sa = Math.abs(amari-K);
				long min  = sa;
				long sb = Math.abs(sa-K);
				if(sb<min)min = sb;
				System.out.println(min);
			}
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 23764
function Main(input) {

	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n")[0];
    
    if(isUpperCase(input)) console.log("A");
    else console.log("a");
  
}
const isUpperCase = c => {
  return /^[A-Z]+$/g.test(c)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29524
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define mod 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

#ifdef ONLINE_JUDGE
	//	freopen("palindrome.in", "r", stdin);

	//freopen("palindrome.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	//freopen("input.in", "r", stdin);
	//  freopen("output.out", "w", stdout);
#endif
}
int main()
{
	Mohammed_Atef_Hassan
		int n,p;
	cin >> n;
	int a, b;
	cin >> a >> b; int cnt1 = 0, cnt2 = 0, cnt3 = 0;
	while (n--)
	{
		cin >> p;
		if (p <= a)cnt1++;
		else if (p >= a + 1 && p <= b)cnt2++;
		else cnt3++;
	}
	cout << min(cnt1, min(cnt2, cnt3)) << finl;
}

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

void Main()
{
  ll X; cin >> X;
  ll A, B;
  
  for (A = (ll)-6208; A <= 6208; A++) {
    for (B = (ll)-6208; B <= 6208; B++) {
      if (A*A*A*A*A - B*B*B*B*B == X) {
        cout << A << " " << B << endl; return;
      }
    }
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 3652
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

	cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;

}

Measured memory_bytes: 256
import numpy as np

def main():
    k, n = map(int,input().split())
    a = list(map(int, input().split()))
    a.append(k+a[0])
    #print(k,n)
    #print(a)
    a2 = []
    for i in range(len(a)-1):
        a2.append(a[i+1]-a[i])
    a2 = np.array(a2)
    print(k-np.max(a2))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 34148
#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define add(a,b) a=((a)+(b))%1000000007
#define mod 1000000007
#define ll long long
//#define file
using namespace std;

int b[100001],c[100001],n,i,j,k,l,ls;
char a[100002];
ll f[100001],g[100001],F[100001][3];

int main()
{
	#ifdef file
	freopen("agc027e.in","r",stdin);
	#endif
	
	scanf("%s",a+1),n=strlen(a+1);
	fo(i,1,n) b[i]=(b[i-1]+((a[i]=='a')?1:-1)+3)%3,c[i]=c[i-1]+(a[i]!=a[i+1]);
	
	ls=0;
	fo(i,1,n)
	{
		fo(j,0,2) F[i][j]=F[i-1][j];
		if (a[i-1]==a[i]) ls=i-1;
		
		if (i>1 && (b[i-1]+1)%3==b[i]) add(f[i],g[i-1]);
		else
		add(f[i],F[ls][(b[i]+2)%3]);
		if (b[i]==1 && (c[i-1]!=i-1 || i==1)) add(f[i],1);
		
		if (i>1 && (b[i-1]+2)%3==b[i]) add(f[i],g[i-1]);
		else
		add(f[i],F[ls][(b[i]+1)%3]);
		if (b[i]==2 && (c[i-1]!=i-1 || i==1)) add(f[i],1);
		
		if (c[i-1]==i-1) g[i]=(i+1)/2,f[i]=1; else g[i]=f[i];
		F[i][b[i]]=g[i];
	}
	printf("%lld\n",f[n]);
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}

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

template <typename T>
int read(T &x) {
    x = 0;
    int ch = getchar(), f = 1;
    while (ch > '9' || ch < '0') {
        if (ch == EOF) return 0;
        if (ch == '-') f = -f;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x *= f;
    return x;
}

int main(void) {
    int a, b, c;
    set<int> st{read(a), read(b), read(c)};
    if (st.size() == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int x,a,b; cin>>x>>a>>b;
    x-=a;
    int ans=x%b;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        bool a = false;
        if(i % 3 == 0){
            a = true;
        }
        else if(i % 10 == 3){
            a = true;
        }
        else if((i / 10) % 10 == 3){
            a = true;
        }
        else if((i / 100) % 10 == 3){
            a = true;
        }
        else if((i /1000) % 10 == 3){
            a = true;
        }
        if(a){
            printf(" %d",i);
        }
    }
    printf("\n");
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n;
    cin>>n;
    ll ans=0;
    for (int i=1; i<=n; i++) {
	if (i%3==0 || i%5==0) continue;
	ans += i;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var matrix = new List<List<int>>();
            var a = new int[3];
            var b = new int[3];
            for (int i = 0; i < 3; i++) {
                matrix.Add(IntList());
            }

            a[0] = 0;
            b[0] = matrix[0][0];
            b[1] = matrix[0][1];
            b[2] = matrix[0][2];
            a[1] = matrix[1][0] - b[0];
            a[2] = matrix[2][0] - b[0];

            if (matrix[1][1] == a[1] + b[1]
               && matrix[1][2] == a[1] + b[2]
               && matrix[2][1] == a[2] + b[1]
                && matrix[2][2] == a[2] + b[2]) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13396
l = input().split(" ")
n = int(l[0])
x = int(l[1])
l = input().split(" ")
for i in range(n):
    l[i] = int(l[i])
for i in range(n):
    l[i] = l[i]- x
l.append(0)
l = sorted(l, reverse=True)
ll = []
for i in range(n):
    ll.append(l[i]-l[i+1])
ll = sorted(list(set(ll)),reverse = True)
def gcd( x, y ):
    while y != 0:
        x, y = y, x%y
    return x
for i in range(len(ll)-1):
   ll[i+1] = gcd(ll[i],ll[i+1])
print(ll[-1])

Measured memory_bytes: 11660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[1000010];

int main() {
	ll n,l,r;
	cin>>n>>l>>r;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	for(int i=1;i<n;i++){
		ll now=a[i]-a[i-1];
		if(now*l>r){
			ans+=r;
		}
		else{
			ans+=now*l;
		}
	}
	cout <<ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

string S[100010];

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

  ll ans=0;
  int a=0,b=0,ab=0;
  for(int i=0;i<N;i++){
    for(int j=1;j<S[i].size();j++){
      if(S[i][j-1]=='A'&&S[i][j]=='B') ans++;
    }
    if(S[i][0]=='B'&&S[i].back()=='A') ab++;
    else if(S[i][S[i].size()-1]=='A') a++;
    else if(S[i][0]=='B') b++;
  }
  
  if(ab>0){
    ans+=ab-1;
    if(a>0){
      ans++;
      a--;
    }
    if(b>0){
      ans++;
      b--;
    }
  }
  

  cout<<ans+min(a,b)<<endl;

  return 0;
}


Measured memory_bytes: 1536
module IntPairSet = Set.Make (struct
  type t = int * int
  let compare = compare
end)

let () = Scanf.scanf "%d %d %d\n" @@ fun h w m ->
  let hs = Array.make h 0 in
  let ws = Array.make w 0 in
  let ms = IntPairSet.of_list @@ List.init m @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun h w -> h - 1, w - 1 in
  IntPairSet.iter (fun (h, w) ->
    hs.(h) <- 1 + hs.(h);
    ws.(w) <- 1 + ws.(w)) ms;
  let his = Array.init h Fun.id in
  let wis = Array.init w Fun.id in
  Array.sort (fun i j -> compare hs.(j) hs.(i)) his;
  Array.sort (fun i j -> compare ws.(j) ws.(i)) wis;
  Printf.printf "%d\n" @@
  max (IntPairSet.fold (fun (h, w) -> max @@ hs.(h) + ws.(w) - 1) ms min_int) @@
  List.fold_left max min_int @@
  List.init h @@ fun i ->
    let rec solve j =
      if w <= j then min_int
      else if not (IntPairSet.mem (his.(i), wis.(j)) ms)
      then hs.(his.(i)) + ws.(wis.(j))
      else solve (j + 1) in
    solve 0


Measured memory_bytes: 60724
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (a, b) = readListOfInt()
    println(Math.max(a-b, Math.max(a+b, a*b)))
    
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37808
#include <bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   stack < char > a;
   a.push(s[0]);
   int ans=0;
   for(int i=1;i<s.size();++i)
   {
      if(a.size() && a.top()!=s[i])
      {
         ans++;
        ans++;
         a.pop();
      }
      else
      {
        a.push(s[i]);
      }
   }
   cout<<ans;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	bool ans=false,ok=true;
	vl v(n),s(n);
	rep(i,n)cin>>v[i],s[i]=v[i];
	sort(all(s));
	rep(k,n)if(v[k]!=s[k])ok=false;
	ans|=ok;
	rep(i,n){
		vl t(n);
		range(j,i+1,n){
			ok=true;
			rep(k,n)t[k]=v[k];
			swap(t[i],t[j]);
			rep(k,n)if(t[k]!=s[k])ok=false;
			ans|=ok;
		}
	}
	YN(ans);
}


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


int main(){
    priority_queue<int> pr;
    while(1){
        string op;
        cin >> op;
        if(op=="insert"){
            int v;
            cin >> v;
            pr.push(v);
        }else if(op=="extract"){
            printf("%d\n",pr.top());pr.pop();
        }else break;
    }
    return 0;
}


Measured memory_bytes: 6980
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

std::map<long long, long long> factorint(long long n)
{
    std::map<long long, long long> res;
    do {
    top:
        for (long long i = 2; i < std::sqrt(n)+10; ++i) {
            if (n % i == 0) {
                if (res.find(i) == res.end()) res[i] = 0;
                res[i]++;
                n /= i;
                goto top;
            } 
        }
        if (n != 1) res[n] = 1;
        break;
    } while (true);
    
    return res;
}


int main()
{
    ll N;
    cin >> N;
    auto f = factorint(N);
    ll ans = 0;
    for(auto p : f) {
        rep(i, 1, p.second+1) {
            ll z = round(pow(p.first, i));
            if (g(N, z) == z) {
                N /= z;
                ans++;
            }
        }
    }
    cout << ans << endl;
}





Measured memory_bytes: 4064
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

ll num = 0;
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;
	num++;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}


const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

using graph = vector<vector<ll>>;

void solve()
{
	ll n, m;
	cin >> n >> m;
	graph gra(n);
	for (ll i = 0; i < m;i++){
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		gra[a].push_back(b);
		gra[b].push_back(a);
	}
	ll ans = 0;
	ll max = 0;
	vector<bool> seen(n, false);
	for (ll i = 0; i < n;i++){
		if(seen[i]){
			continue;
		}
		dfs(gra, seen, i);
		if (num > max)
		{
			max = num;
		}
		num = 0;
	}

	cout << max << endl;
}

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



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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e9;
const int MB = 30;
const int MOD = 1e9 + 7;

bool check(int n, int k, int m, vector<int>& a) {
	if (a[n - 1] <= m) return true;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cnt += (a[i] - 1) / m;
	}
	return cnt <= k;
}

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(all(a));
	int l = 0;
	int r = INF;
	while (r - l > 1) {
		int m = (l + r) >> 1;
		if (check(n, k, m, a)) r = m;
		else l = m;
	}
	cout << r;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 4756
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N;
	cin>>N;
	std::vector<int>co(100005);
	REP(i,100005)co[i]=0;
	REP(i,N){
		int A;
		cin>>A;
		co[A]++;
		co[A+1]++;
		co[A+2]++;
	}
	std::sort(co.begin(),co.end());
	
	cout<<co[100004]<<endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back


int main() {
  int s;
  cin >> s;
  vector<int> x;
  int n = s;
  bool flag = false;
  int onecnt = 0;
  while(onecnt!=2){
    x.push_back(n);
    if(n==1) onecnt++;
    if(n%2==0){
        n /=2;
    } else {
        n= 3*n+1;
    }
    
  }

  for(int i=0; i<x.size();i++){
      for(int j=i+1;j<x.size();j++){
          if(x[i] == x[j]){
              cout << j + 1<< endl;
              flag = true;
              break;
          }
      }
      if(flag) break;
  }
  

}


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

int w,h;
typedef pair<int, int> P;
vector<vector<int>> maze;
vector<vector<int>> thismap;
vector<int> dx = {1, 0, -1, 0};
vector <int> dy = {0, 1, 0, -1};

bool check(int x, int y, int x2, int y2){
    if (x2<0 || x2>=w || y2<0 || y2>=h) return false;
    if (x==x2){
        if (thismap[y+y2][x]!=0) return false;
    } else if (y==y2){
        if (thismap[y*2][(x+x2)/2]!=0) return false;
    }
    return true;
}

int bfs(){
    queue<P> que;
    que.push(P(0,0));
    maze[0][0]=1;
    
    while (que.size()){
        P p = que.front(); que.pop();
        if (p.first==w-1 and p.second==h-1) break;
        for (int i=0; i<4; i++){
            int nx = p.first + dx[i], ny = p.second + dy[i];
            
            if (check(p.first, p.second, nx, ny) && maze[nx][ny]==0){
                que.push(P(nx,ny));
                maze[nx][ny] = maze[p.first][p.second] + 1;
            }
        }
    }
    return maze[w-1][h-1];
}

int main(){
    cin >> w >> h;
    while (w!=0 || h!=0){
        vector<vector<int>> map2(h*2-1, vector<int>(w));
        for (int i=0; i<h*2-1; i++){
            if (i%2==0){
                for (int j=0; j<w-1; j++){
                    cin >> map2[i][j];
                }
            }else{
                for (int j=0; j<w; j++){
                    cin >> map2[i][j];
                }
            }
        }
        vector<vector<int>> maze2(w, vector<int>(h));
      
        thismap = map2;
        maze = maze2;
        int ans = bfs();
        cout << ans << endl;
        
        cin >> w >> h;
    }
}


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

int main() {
  // 入力部(N)
  int N;
  cin >> N;

  // 入力部(p1, p2, ... pN)
  vector<int> p(N);
  for(int i = 0; i < N; i++) {
    cin >> p.at(i);
  }

  // 配列pをソート。
  sort(p.begin(), p.end());

  // 配列pの最後尾(最も定価が高い品物の価格)の半額 を最初から引いておく。
  // 意味的には商品の合計を求める前に割引をしているもの。
  int sum = -p.at(N-1) / 2;

  // 全ての品物の価格を sum に加算。
  for(int i = 0; i < N; i++) {
    sum += p.at(i);
  }

  cout << sum << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <queue>


using namespace std;


using ll = long long;


class process {
    public:
        string name;
        ll time;
};


int main()
{
    queue<process*> ps;
    ll n, q;
    cin >> n >> q;

    for (int i = 0; i < n; i++) {
        process* tmp = new process;
        cin >> tmp->name >> tmp->time;
        ps.push(tmp);
    }

    ll now = 0;
    while (!ps.empty()) {
        process* tmp = ps.front();
        ps.pop();

        if (tmp->time > q) {
            tmp->time -= q;
            ps.push(tmp);
            now += q;
        } else {
            now += tmp->time;
            tmp->time = 0;
            cout << tmp->name << " " << now << endl;
            delete tmp;
        }
    }
}



Measured memory_bytes: 7496
from collections import deque

N, *AB = map(int, open(0).read().split())

E = [set() for _ in range(N + 1)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a].add((b, i))
    E[b].add((a, i))

K = max(len(e) for e in E)
A = [0] * (N - 1)
Q = deque([(-1, 1)])
while Q:
    p, v = Q.popleft()
    c = 0
    for u, i in E[v]:
        E[u].remove((v, i))
        c += 1 + (c + 1 == p)
        Q.append((c, u))
        A[i] = c

print(K)
for a in A:
    print(a)


Measured memory_bytes: 53548
A,B,C,D,E,F=map(int,input().split())
# 作れる水の量をDPで求める (MAXはF)
# 作れる砂糖の量をDPで求める　（MAXは、F*(E/(E+100)）
# 作れる水の量に対して二分探索で、最も多く入れられる砂糖の量を求める。

dpW=[False]*(F+1)
dpW[0]=True
for w in (A*100,B*100):
  for j in range(len(dpW)):
    if dpW[j] and j+w<len(dpW):
      dpW[j+w]=True
      
water=[]
for i in range(len(dpW)):
  if dpW[i] and i!=0:
    water.append(i)

maxsugar=int(F*(E/(E+100)))+1
dpS=[False]*(maxsugar+1)
dpS[0]=True
for s in (C,D):
  for j in range(len(dpS)):
    if dpS[j] and j+s<len(dpS):
      dpS[j+s]=True
sugar=[]
for i in range(len(dpS)):
  if dpS[i]:
    sugar.append(i)
    
ans=[0,0]
maxrate=0
for w in water:
  maxS=int(w*(E/100))
  if w+maxS>F:
    maxS=F-w
  # maxSを越えない最大の砂糖をsugarから探す
  ok=0
  ng=len(sugar)
  while abs(ok-ng)>1:
    mid=abs(ok+ng)//2
    if sugar[mid]<=maxS:
      ok=mid
    else:
      ng=mid
  if sugar[ok]/w>=maxrate:
    maxrate=sugar[ok]/w
    ans=[w+sugar[ok],sugar[ok]]
print(*ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long

using namespace std;

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

    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << '\n';

    return 0;
}


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

typedef long long int LLI;
LLI Q, H, S, D;
LLI N;

int main() {
  scanf("%lld%lld%lld%lld", &Q, &H, &S, &D);
  scanf("%lld", &N);

  S = min(S, min(4*Q, 2*H));
  D = min(2*S, D);
  LLI ans = N/2*D;
  if (N%2 == 1) ans += S;
  printf("%lld\n", ans);
}


Measured memory_bytes: 256
from math import log2

def main():
    a, b = map(int, input().split())
    if a == b:
        print(a)
        return
    if b == 0:
        print(0)
        return
    d = b - a + 1
    x = (d // 2 + (d % 2) * (a % 2)) % 2
    for i in range(1, int(log2(b)) + 1):
        k = 0
        p = 2**i
        q = 2 * p
        pa, qa = a % p, a % q
        pb, qb = b % p, b % q
        if a % q >= p:
            k += q - qa
        if b % q >= p:
            k += qb - p + 1
        x += (k % 2) * p
    print(x)

if __name__ == '__main__':
    main()

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

int main() {
	int c[3][3];
	int a[3], b[3];
	for (int i = 0;i < 3;i++) {
		cin >> c[i][0] >> c[i][1] >> c[i][2];
	}
	a[0] = 0;
	b[0] = c[0][0];a[1] = c[1][0] - b[0];
	b[1] = c[0][1] - a[0];
	b[2] = c[1][2] - a[1];
	a[2] = c[2][1] - b[1];
	bool A = c[2][0] == a[2] + b[0];
	bool B = c[1][1] == a[1] + b[1];
	bool C = c[0][2] == a[0] + b[2];
	bool D = c[2][2] == a[2] + b[2];
	if (A&&B&&C&&D)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi a(n+1);
    REP(i,1,n)cin>>a[i];
    vi b(n+1);
    for(int i=n;i>=1;i--){
        int c=0;
        for(int j=i;j<=n;j+=i){
            c+=b[j];
        }
        if(c%2!=a[i])b[i]=1;
    }
    int m=0;
    REP(i,1,n)m+=b[i];
    cout<<m<<endl;
    REP(i,1,n)if(b[i])cout<<i<<sp;
}

Measured memory_bytes: 2560