akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int INF=1e15;

struct UnionFind {
    public:
    vector<int> par;
    UnionFind(int n){
        par=vector<int>(n,-1);
    }
    int root(int x){
        if(par[x]<0)return x;
        return par[x]=root(par[x]);
    }
    bool issame(int x,int y){
        return root(x)==root(y);
    }
    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y)return false;
        if(par[x]>par[y])swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }
    int size(int x){
        return -par[root(x)];
    }
};

using P=pair<int,int>;
signed main(){
    int N,M,K;cin>>N>>M>>K;
    vector<set<int>>NG(N);
    UnionFind uf(N);
    REP(i,M){
        int a,b;cin>>a>>b;a--;b--;
        NG[a].insert(b);
        NG[b].insert(a);
        uf.merge(a,b);
    }
    REP(i,K){
        int c,d;cin>>c>>d;c--;d--;
        if(!uf.issame(c,d))continue;
        NG[c].insert(d);
        NG[d].insert(c); 
    }
    REP(i,N){
        int ans=uf.size(i)-1-NG[i].size();
        cout<<ans<<endl;
    }
}

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

long long N,X,eaten=0;

int rec(){
  if(X==pow(2,N+2)-3){
    eaten+=(pow(2,N+1)-1);
    return 0;
  }else if(X>pow(2,N+1)-1){
    eaten+=(pow(2,N));
    X-=(pow(2,N+1)-1);
    N--;
    rec();
  }else if(X==pow(2,N+1)-1){
    eaten+=(pow(2,N));
    return 0;
  }else if(X>1){
    X--; N--;
    rec();
  }else{
    return 0;
  }
}

int main(){
  cin >> N >> X;
  rec();
  cout << eaten << endl;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let ns = n.to_string();
    let nc: Vec<u32> = ns.chars().map(|x| x.to_digit(10).unwrap()).collect();
    let sum: u32 = nc.iter().sum();

    if n % sum == 0 {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		ans+=a[i];
	}
	
	if(ans%10!=0)
		cout << ans << endl;
	else
	{
		sort(a.begin(),a.end());
		bool flag=false;
		for(int i=0;i<n;i++)
		{
			if(a[i]%10!=0)
			{
				ans-=a[i];
				flag=true;
				break;
			}
		}
		if(flag)cout << ans << endl;
		else cout << 0 << endl;
	}


	


	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;


int B = 710;
// バケット i は [i*B, (i+1)*B) の記録を持つ
// lazy[i] :=  バケットi の遅延を記録する
// 遅延が-1 ... 制約よりそんなことは発生しないことを利用して, これを遅延の単位元とできる
// i.e. lazy[i] == -1 def 消化時に何も伝播させないという遅延を与えるとみなす
// cnt[i] := パケットi に含まれる文字種類数
string s = "";
vvll mem(B, vll(26, 0));

// s_j を x に変更する
void update(int j, char x)
{
    // s の属するバケット, t の属するバケット
    int jp = j / B;
    mem[jp][int(s[j] - 'a')]--;
    s[j] = x;
    mem[jp][int(s[j] - 'a')]++;
}
 
// a_l,...,a_r の cnt を返す
int find(int l, int r)
{
    int st = l / B, gt = r / B;
    ll ret = 0;

    //... || ... s ... t ... || ...
    //直接計算
    if (st == gt){
        vll vc(26);
        for (int i = l; i <= r; i++) {
            vc[int(s[i] - 'a')]++;
        }
        REP(xxx, 26) {
            if (vc[xxx]) ret++;
        }
    }
    //... s ... || (被覆されるパケット)  || ... t ...
    else{
        //端が属するパケット内は直接更新
        vll vc(26);
        for (int i = l; i < (st + 1) * B; i++) {
            vc[int(s[i] - 'a')]++;
        }
        for (int i = gt * B; i <= r; i++) {
            vc[int(s[i] - 'a')]++;
        }
        //被覆されるパケットはパケット単位で調査する
        for (int i = st + 1; i < gt; i++){
            REP(xxx, 26) {
                if (mem[i][xxx]) vc[xxx]++;
            }
        }
        REP(xxx, 26) {
            if (vc[xxx]) ret++;
        }
    }
    return ret;
}

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

    ll n;
    cin >> n;
    cin >> s;
    REP(i, n) {
        int ip = i / B;
        mem[ip][int(s[i] - 'a')]++;
    }
    ll q;
    cin >> q;
    while (q) {
        ll type;
        cin >> type;
        if (type == 1) {
            ll i;
            char c;
            cin >> i >> c;
            i--;
            update(i, c);
        }
        else {
            ll l, r;
            cin >> l >> r;
            l--, r--;
            cout << find(l, r) << endl;
        }
        q--;
    }
    return 0;
}

Measured memory_bytes: 1300
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

inline int add(int a, int b, int mod = MOD) {
  a += b; return a >= mod ? a - mod : a;
}
inline int sub(int a, int b, int mod = MOD) {
  a -= b; return a < 0 ? a + mod : a;
}
inline int mul(int a, int b, int mod = MOD) {
  return int((long long) a * b % mod);
}
inline int mpow(int base, long long ex, int mod = MOD) {
  int res = 1;
  for (; ex > 0; ex >>= 1) {
    if (ex & 1) res = mul(res, base, mod);
    base = mul(base, base, mod);
  }
  return res;
}
inline int inv(int a, int mod = MOD) {
  return mpow(a, mod - 2, mod);
}
inline int mdiv(int a, int b, int mod = MOD) {
  return mul(a, mpow(b, mod - 2,  mod));
}
inline void adds(int &a, int b, int mod = MOD) {
  a += b; if (a >= mod) a -= mod;
}
inline void subs(int &a, int b, int mod = MOD) {
  a -= b; if (a < 0) a += mod;
}
inline void muls(int &a, int b, int mod = MOD) {
  a = int((long long) a * b % mod);
}
inline void mdivs(int &a, int b, int mod = MOD) {
  a = mdiv(a, b, mod);
}
vector<int> fac, ifac; 
void prep_fact(int nax = 2e6 + 40) {
  fac.resize(nax);
  ifac.resize(nax);
  fac[0] = 1;
  for (int i = 1; i < nax; ++i) fac[i] = mul(i, fac[i - 1]);
  ifac[nax - 1] = inv(fac[nax - 1]);
  for (int i = nax - 1; i > 0; --i) ifac[i - 1] = mul(i, ifac[i]);
}
inline int ncr(int n, int r) {
  if (n < r || r < 0 || n < 0) return 0;
  return mul(fac[n], mul(ifac[n - r], ifac[r]));
}

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  prep_fact();
  int k; cin >> k;
  string s; cin >> s;
  int n = SZ(s);
  int ans = 0;
  for (int i = 0; i <= k; ++i) {
    adds(ans, mul(ncr(n - 1 + k - i, n - 1), mul(mpow(25, k - i), mpow(26, i))));
  }
  kek(ans);
}


Measured memory_bytes: 19868
#include <iostream>
#include <string.h>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>

using namespace std;

int main( void ) {

    int K, S, count, z;
    cin >> K >> S;

    count = 0;
    for ( int i = 0; i <= K; i++ ) {
        for ( int j = 0; j <= K; j++ ) {
           z = S - i - j;

           if ( z >= 0 && z <= K ) {
               count++;
           }

        }
    }

    cout << count << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<char>S(N);
  int ans=0;
  int ANS=0;
  for(int i=0;i<N;i++){
    cin>>S[i];
    if(ans==0){
    if(S[i]=='A'){
      ans++;
    }
    else{
      ans*=0;
    }
    }
    else if(ans==1){
    if(S[i]=='B'){
      ans++;
    }
    else if(S[i]=='A'){
      ans=1;
    }
    else{
      ans*=0;
    }
    }
    else if(ans==2){
    if(S[i]=='C'){
      ans*=0;
      ANS++;
    }
    else{
      ans*=0;
    }
    }
  }
  cout<<ANS<<endl;
}


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

int main()
{
    int h, w, d;
    cin >> h >> w >> d;
    int a[303][303];
    int x[90007], y[90007];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
            x[a[i][j]] = i;
            y[a[i][j]] = j;
        }
    }
    int dist[90007];
    for(int i = 1; i <= h * w; i++){
        if(i <= d) dist[i] = 0;
        else dist[i] = dist[i - d] + abs(x[i] - x[i - d]) + abs(y[i] - y[i - d]);
    }
    int q;
    cin >> q;
    int l[100007], r[100007];
    for(int i = 0; i < q; i++){
        cin >> l[i] >> r[i];
        cout << dist[r[i]] - dist[l[i]] << endl;
    }
}

Measured memory_bytes: 3328
import sys
input = sys.stdin.readline


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def main():
    N = int(input())
    answer = 0
    ans_list = factorization(N)
    sum_list = [1, 3, 6, 10, 15, 21, 28, 36, 45]
    if N == 1:
        print(0)
        exit()
    for i in ans_list:
        for j in range(len(sum_list)):
            if i[1] < sum_list[j]:
                answer += j
                break
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9496
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static int[] ls, bs;

	static int next(int x, int n) {
		if (n < x) x = n - (x - n);
		for (int i=0; i<bs.length; i++) {
			if (x == bs[i]) {
				return 0;
			}
		}

		return x;
	}

	static boolean isStop(int x, int n) {
		if (n < x) x = n - (x - n);
		for (int i=0; i<ls.length; i++) {
			if (x == ls[i]) {
				return true;
			}
		}
		return false;
	}

	static boolean solve() {
		int n = in.nextInt();
		int t = in.nextInt();
		int l = in.nextInt();
		int b = in.nextInt();
		if (n + t + l + b == 0) return false;

		ls = new int[l];
		for (int i=0; i<l; i++) {
			ls[i] = in.nextInt();
		}
		bs = new int[b];
		for (int i=0; i<b; i++) {
			bs[i] = in.nextInt();
		}

		double[][] dp = new double[t+3][n+10];
		dp[0][0] = 1.0;

		for (int k=0; k<t; k++) {
			for (int i=0; i<n; i++) {
				if (dp[k][i] == 0) continue;
				for (int j=1; j<=6; j++) {
					if (isStop(i+j,n)) {
						dp[k+2][next(i+j, n)] += dp[k][i] / 6;
					}
					else {
						dp[k+1][next(i+j, n)] += dp[k][i] / 6;
					}
				}
			}
		}

		// dump(dp);

		double ans = 0;
		for (int i=0; i<=t; i++) {
			ans += dp[i][n];
		}

		out.printf("%.10f\n", ans);

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 30608
h, w = map(int, input().split())
s = [[""]*(w+2)]
for _ in range(h):
    _s = list(input())
    _s.insert(0, "")
    _s.append("")
    s.append(_s)
s.append([""]*(w+2))

dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]

c = [["."]*(w+2) for _ in range(h+2)]

for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] != "#":
            continue

        for _dx, _dy in zip(dx, dy):
            x = i + _dx
            y = j + _dy
            if s[x][y] == "#":
                c[i][j] = "#"
                c[x][y] = "#"

ans = "Yes"
for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] != c[i][j]:
            ans = "No"
            break

print(ans)


Measured memory_bytes: 3064
N = int(input())
if N==2:
    print(-1)
    exit()
if N==3:
    print('.aa')
    print('b..')
    print('b..')
    exit()

ans = [['.']*N for i in range(N)]
a4 = [
    'aacd',
    'bbcd',
    'cdaa',
    'cdbb'
]
a5 = [
    'aabbc',
    'h.iic',
    'hj..d',
    'gj..d',
    'gffee'
]
a6 = [
    'aacd..',
    'bbcd..',
    'cd..aa',
    'cd..bb',
    '..aacd',
    '..bbcd'
]
a7 = [
    'aa.bb.c',
    '.ii..jc',
    'h..mmj.',
    'h.n...d',
    '.ln...d',
    'gl..kk.',
    'g.ff.ee'
]
k = 0
if N%4==1:
    for i,row in enumerate(a5):
        for j,c in enumerate(row):
            ans[i][j] = c
    k += 5
elif N%4==2:
    for i,row in enumerate(a6):
        for j,c in enumerate(row):
            ans[i][j] = c
    k += 6
elif N%4==3:
    for i,row in enumerate(a7):
        for j,c in enumerate(row):
            ans[i][j] = c
    k += 7
while k < N:
    for i,row in enumerate(a4):
        for j,c in enumerate(row):
            ans[k+i][k+j] = c
    k += 4
assert k==N

for row in ans:
    print(''.join(row))

Measured memory_bytes: 11892
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

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

  int S, W;
  cin >> S >> W;

  if(S > W){
    cout << "safe" << endl;
  }else{
    cout << "unsafe" << endl;
  }


  return 0;
}


Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created by sotetsuk on 2016/07/11.
 */
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n, pos;
    static ArrayList<Integer> preorder = new ArrayList<Integer>();
    static ArrayList<Integer> inorder = new ArrayList<Integer>();

    public static BinaryTree reconstruction(int l, int r) {
        if (l >= r) {
            return new BinaryTree();
        }

        int node = preorder.get(pos++);
        int i = inorder.indexOf(node);

        BinaryTree left = reconstruction(l, i);
        BinaryTree right = reconstruction(i + 1, r);

        return new BinaryTree(node, left, right);
    }

    public static void read() {
        n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            preorder.add(sc.nextInt());
        }
        for (int i = 0; i < n; i++) {
            inorder.add(sc.nextInt());
        }
    }

    public static void main(String[] args) {
        read();
        pos = 0;
        BinaryTree bt = reconstruction(0, preorder.size());
        System.out.println(bt);
    }

    public static class BinaryTree {
        boolean isEmpty;
        int node;
        BinaryTree left;
        BinaryTree right;

        public BinaryTree(int node, BinaryTree left, BinaryTree right) {
            this.isEmpty = false;
            this.node = node;
            this.left = left;
            this.right = right;
        }

        public BinaryTree() {
            this.isEmpty = true;
        }

        public String toString() {
            if (this.isEmpty) return "";
            String l = this.left.toString() + " ";
            String r = this.right.toString() + " ";

            if (l.trim().equals("")) {
                l = "";
            }
            if (r.trim().equals("")) {
                r = "";
            }

            return l + r + this.node;
        }
    }
}

Measured memory_bytes: 26428
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
x = [];y=[];h=[]
sh = -1
for i in range(n):
    xa,ya,ha = readInts()
    x.append(xa);y.append(ya);h.append(ha);
    if ha > 0:
        sh = i
# CxとCyを特定しておく すべてにおいて合致するかを考える
resx = -1;resy =-1;resh=-1;
for Cx in range(101):
    for Cy in range(101):
        ok = True
        H = h[sh] + abs(x[sh] - Cx) + abs(y[sh] - Cy)
        # 全操作して合致するようにする
        for i in range(n):
            if h[i] == 0:
                if H > abs(x[i] - Cx) + abs(y[i] - Cy):
                    ok = False
                    break
            elif h[i] > 0:
                if H -h[i] !=  abs(x[i] - Cx) + abs(y[i] - Cy):
                    ok = False
                    break
        if ok:
            resx = Cx;resy = Cy;resh = H;

print(resx,resy,resh)


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

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

    long long sum = 0;
    map<int, int> m;
    for(int i =0; i < N; i++){
        sum += m[a[i]];
        m[a[i]] ++;
    }
    for(int i =0; i < N; i++){
        cout << sum - (m[a[i]] - 1) << endl;
    }
}

Measured memory_bytes: 8320
#include<iostream>
#include<math.h>
#include<iomanip>
#include<string.h>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<algorithm>

using namespace std;

long long int sum = 0;

void merge(int a[], int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int l[n1 + 1], r[n2 + 1];
  for(int i = 0; i < n1; i++){
    l[i] = a[left + i];
  }
  l[n1] = 1000000000;
  for(int i = 0; i < n2; i++){
    r[i] = a[mid + i];
  }
  r[n2] = 1000000000;

  int j = 0, k = 0;
  for(int i = 0; i < n1 + n2; i++){
    if(l[j] <= r[k]){
      a[left + i] = l[j];
      j++;
    }
    else{
      a[left + i] = r[k];
      sum += n1 - j;
      k++;
    }
  }
}

void mergesort(int a[], int left, int right){
  if(left + 1 < right){
    int mid = (left + right)/ 2;
    mergesort(a, left, mid);
    mergesort(a, mid, right);
    merge(a, left, mid, right);
  }
}
int main(){

  int n;
  cin >> n;

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

  mergesort(a, 0, n);

  cout << sum << endl;



}


Measured memory_bytes: 4652
a = list(input())
b = list(input())
c = list(input())

def calc(list):
  if list=='a':
    if len(a)==0:
      print('A')
    else:
      i = a.pop(0)
      calc(i)
  elif list=='b':
    if len(b)==0:
      print('B')
    else:
      i = b.pop(0)
      calc(i)
  elif list=='c':
    if len(c)==0:
      print('C')
    else:
      i = c.pop(0)
      calc(i)

calc('a')

Measured memory_bytes: 3188
N,M=map(int,input().split())
ka=[[int(x) for x in input().split()] for _ in range(N)]
K=list()
A=list()
for i in range(N):
  K.append(ka[i][0])
  A.append(ka[i][1:])
ans=[0]*(M+1)
for i in range(N):
  for j in range(K[i]):
    ans[A[i][j]]+=1
cnt=0
for i in range(M+1):
  if ans[i]==N:
    cnt+=1
print(cnt)


Measured memory_bytes: 9124
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int c1, c5, c10, c50, c100, c500;
    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
    int x=c1+c5*5+c10*10+c50*50+c100*100+c500*500;
    if(x>=1000)
        cout << "1" << endl;
    else
        cout << "0" << endl;
}


Measured memory_bytes: 3104
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long


int gcd(int a, int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

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

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

signed main(){
  int a,b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>

//エイリアス
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};



int main(){
    Stream io;

    int N;
    io.read(N);
    auto A = io.read_vec<int>(N);

    vector<int> v;
    v.push_back(A[0]);
    for(int i = 1; i < N; i++){
        if(A[i] != A[i - 1]) v.push_back(A[i]);
    }

    vector<int> u;
    if(v.size() >= 2 && v[0] < v[1]) u.push_back(v[0]);
    for(int i = 1; i < v.size() - 1; i++){
        if(v[i] > v[i - 1] && v[i] > v[i + 1]) u.push_back(v[i]);
        else if(v[i] < v[i - 1] && v[i] < v[i + 1]) u.push_back(v[i]);
    }
    if(v.size() >= 2 && v[v.size() - 1] > v[v.size() - 2]) u.push_back(v[v.size() - 1]);

    ll ans = 1000;
    ll stock = 0;
    for(int i = 0; i < u.size(); i++){
        if(i % 2 == 0){
            stock = ans / u[i];
            ans = ans % u[i];
        }
        else{
            ans += stock * u[i];
            stock = 0;
        }
    }
    if(u.size() > 0) ans += stock * u.back();
    cout << ans;

    return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
vector<P> connect[100005];
long long cost[100005];

int dp[40][500][500];

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

int main() {

	int N;
	cin >> N;

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

	sort(A.begin(),A.end());
	int same = 0;
	int before = A[0];
	for (int i = 1; i < N; ++i) {
		if (before == A[i]) same++;
		before = A[i];
	}
	int ans = same % 2 != 0 ? N - 1 : N;
	ans -= same;
	cout << ans << endl;
}

Measured memory_bytes: 6272
package main

import (
	"fmt"
	"strconv"
)

func calcPelimeter(x, y int) int {
	return 2 * (x + y)
}

func calcArea(x, y int) int {
	return x * y
}

func main() {
	var in1, in2 string
	fmt.Scan(&in1, &in2)
	x1, _ := strconv.Atoi(in1)
	x2, _ := strconv.Atoi(in2)
	fmt.Println(calcArea(x1, x2), calcPelimeter(x1, x2))
}



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

using namespace std;

#define int long long

signed main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &x: a) cin >> x;
  int ans = 0;
  map<int,int> mp;
  for (int i = 0; i < n; ++i) {
    ans += mp[i-a[i]];
    ++mp[i+a[i]];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 27452
N = int(input())
A = [int(input()) for i in range(N)]
first = sorted(A)[-1]
second = sorted(A)[-2]
if first == second:
    for i in range(N):
        print(first)
else:
    idx = A.index(first)
    for i in range(N):
        if i == idx:
            print(second)
        else:
            print(first)


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


int main() {
    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7)cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int main()
{
  string s;
  cin >> s;
  int n;
  cin >> n;
  string forth = "";
  string back = "";
  int t,f;
  bool state = true;
  string c;
  for(int i=0; i<n;++i){
    cin >> t;
    if(t==1){
      if(state) state = false;
      else state = true;
    }else{
      cin >> f >> c;
      if(f==1){
        if(state) forth = forth + c;
        else back = back + c;
      }else{
		if(state) back = back + c;
        else forth = forth + c;
      }
    }
  }
  
  if(state){
    reverse(forth.begin(), forth.end());
    s = forth + s + back;
  }else{
    reverse(back.begin(), back.end());
    reverse(s.begin(), s.end());
    s = back + s + forth;
  }
  cout << s << endl;

}

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

using namespace std;

#define ull unsigned long long int
#define ll long long int 

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

int main(){

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

    int product[100006];
    int m,n;
    cin >> n >> m;
    ll count = 0;
    for(int i=0; i<n; i++){
        cin >> product[i];
        count += product[i];  
    }
    int num=0;
    for(int i=0; i<n; i++){
        if(product[i]>= ((1.0*count/(4*m)))) num++;
    }

    if(num>=m) cout << "Yes" << endl;
    else cout << "No" << endl;
   
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int A, B;
  cin >> A >> B;
  cout << (A-1) * (B-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }

int main(){
    ll t1,t2; cin>>t1>>t2;
    ll a1,a2; cin>>a1>>a2;
    ll b1,b2; cin>>b1>>b2;
    if(t1*a1+t2*a2==t1*b1+t2*b2) cout<<"infinity"<<endl;
    else{
        ll x=t1*a1+t2*a2,y=t1*b1+t2*b2;
        if(a1>b1 && a2>b2) cout<<0<<endl;
        else if(a1<b1 && a2<b2) cout<<0<<endl;
        //else if(a1==b1 || a2==b2) cout<<0<<endl;
        else{
            ll d1=(a1-b1)*t1;
            ll d2=(a2-b2)*t2;
            ll d3=d1+d2;
            if(d1>0 && d3>0){cout<<0<<endl; return 0;}
            if(d1<0 && d3<0){cout<<0<<endl; return 0;}
            ll z=labs(d1)/labs(d3);
            z=2*z+1;
            if(labs(d1)%labs(d3)==0)z--;
            cout<<z<<endl;
            
        }
    }
}

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

//  2進数ならば baseNumber を  2 とする
// 10進数ならば baseNumber を 10 とする
ll GetDigitsCount(ll targetNumber, ll baseNumber) {
	ll digitsCount = 0;
	while (targetNumber != 0) {
		digitsCount++;
		targetNumber /= baseNumber;
	}
	return digitsCount;
}

int main()
{
    ll n, k; cin >> n >> k;
	
	cout << GetDigitsCount(n, k) << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by RHelper
 * More info: https://github.com/mkc1370/RHelper
 * @author 
 */

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

public class ARemainingBalls
{
    private readonly StringReader cin;
    private readonly StringWriter cout;
    private readonly Scanner scanner;

    public ARemainingBalls(StringReader cin, StringWriter cout)
    {
        this.cin = cin;
        this.cout = cout;
        scanner = new Scanner(cin);
    }

    public void Solve()
    {
        var s = CINS;
        var t = CINS;
        var a = CINL;
        var b = CINL;
        var u = CINS;

        if (s == u)
        {
            COUT($"{a - 1} {b}");
        }
        else
        {
            COUT($"{a} {b - 1}");
        }
    }

    private long CINL => scanner.Long();
    private double CIND => scanner.Double();
    private string CINS => scanner.String();
    private static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat(v, (int)n);
    private List<long> CINVL(long n) => Repeat(0, n).Select(_ => CINL).ToList();
    private List<double> CINVD(long n) => Repeat(0, n).Select(_ => CIND).ToList();
    private List<string> CINVS(long n) => Repeat(0, n).Select(_ => CINS).ToList();

    private void COUT(object o) => cout.WriteLine(o);
}

public class Scanner
{
    public Scanner(StringReader stringReader)
    {
        this.stringReader = stringReader;
    }

    private readonly StringReader stringReader;
    private readonly char[] buffer = new char[1024];
    private int len, ptr;
    private bool isEof;

    private char Read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = stringReader.Read(buffer, 0, 1024)) <= 0)
            {
                isEof = true;
                return '\0';
            }
        }

        return buffer[ptr++];
    }

    public char Char()
    {
        char b;
        do b = Read();
        while (b < 33 || 126 < b);
        return b;
    }

    public string String()
    {
        var sb = new StringBuilder();
        for (char b = Char(); b >= 33 && b <= 126; b = Read())
            sb.Append(b);
        return sb.ToString();
    }

    public long Long()
    {
        long ret = 0;
        char b;
        var ng = false;
        do b = Read();
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-')
        {
            ng = true;
            b = Read();
        }

        for (;; b = Read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            else ret = ret * 10 + b - '0';
        }
    }

    public double Double()
    {
        return double.Parse(String(), CultureInfo.InvariantCulture);
    }
}


public class Output
{
	public static void Main()
	{
		var reader = new System.IO.StringReader(Console.In.ReadToEnd());
		var writer = new System.IO.StringWriter();
		var solver = new ARemainingBalls(reader, writer);
		solver.Solve();
		System.Console.Write(writer.GetStringBuilder().ToString());
	}
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  COMinit();

  long long N,K;cin>>N>>K;
  for(long i=1;i<=K;i++){
    cout<<COM(K-1,i-1)*COM(N-K+1,i)%MOD<<endl;
  } 
}

Measured memory_bytes: 12160
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        Calc();
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        for(int i=0;i<4;i++){
            StringBuilder sb = new StringBuilder();
            bool b1 = i%2 == 0;
            bool b2 = i/2 == 0;
            sb.Append(b1 ? "S" : "W");
            sb.Append(b2 ? "S" : "W");
            for(int j=1;j<N-1;j++){
                if(b1^b2^(s[j] == 'o')){
                    sb.Append("S");
                    b1 = b2;
                    b2 = true;
                }
                else{
                    sb.Append("W");
                    b1 = b2;
                    b2 = false;
                }
            }
            if((i/2 == 0 ^ b2 ^ i%2 == 0 ^ s[0] != 'o') && (i%2 == 0 ^ b1 ^ b2 ^ s[N-1] != 'o')){
                Console.WriteLine(sb.ToString());
                return;
            }
        }
        Console.WriteLine(-1);
    }
}

Measured memory_bytes: 13096
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

//        C   Station              C   Station
map<pair<long, long>, vector<pair<long, long> > > way;

//        C,  station
set<pair<long, long> > done;

long long N, M;


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

	for(int i = 0; i < M; i++){
		long p, q, c;
		cin >> p >> q >> c;
		p--;q--;
		way[make_pair(c, p)].push_back(make_pair(c, q));
		way[make_pair(c, q)].push_back(make_pair(c, p));
		way[make_pair(-1, p)].push_back(make_pair(c, q));
		way[make_pair(-1, q)].push_back(make_pair(c, p));
		way[make_pair(c, p)].push_back(make_pair(-1, q));
		way[make_pair(c, q)].push_back(make_pair(-1, p));
		//cout << "way company" <<  c << " station " << p << " -> company " << c << " station " << q << endl;
		//cout << "way company" <<  c << " station " << q << " -> company " << c << " station " << p << endl;
		//cout << "way company" <<  -1 << " station " << p << " -> company " << c << " station " << q << endl;
		//cout << "way company" <<  -1 << " station " << q << " -> company " << c << " station " << p << endl;
		//cout << "way company" <<  c << " station " << p << " -> company " << -1 << " station " << q << endl;
		//cout << "way company" <<  c << " station " << q << " -> company " << -1 << " station " << p << endl;
	}
	
	//		   cost,           c,  p
	priority_queue<pair<long, pair<long, long > > , vector<pair<long, pair<long, long> > >, greater<pair<long, pair<long, long > > > > Q;

	Q.push(make_pair(0, make_pair(-1, 0)));

	while(!Q.empty()){
		long cost = Q.top().first;
		long company = Q.top().second.first;
		long station = Q.top().second.second;
		//cout << "cost = " << cost << "company = " << company << " station = " << station << endl;
		Q.pop();
		if(done.count(make_pair(company, station)) != 0){
			continue;
		}
		done.insert(make_pair(company, station));
		if(station == N-1){
			cout << cost << endl;
			return 0;
		}

		for(int i = 0; i < way[make_pair(company, station)].size(); i++){
			long ncost = cost;
			long ncompany = way[make_pair(company, station)][i].first;
			long nstation = way[make_pair(company, station)][i].second;
			if(company == -1){
				ncost++;
			}
			//cout << "ncost = " << ncost << "ncompany = " << ncompany << " nstation = " << nstation << endl;
			if(done.count(make_pair(ncompany, nstation)) != 0){
				continue;
			}
			Q.push(make_pair(ncost, make_pair(ncompany, nstation)));
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 89772
import com.sun.org.apache.xpath.internal.operations.Bool

fun main(args: Array<String>) {
    val N = nextInt()
    fun c753(s: String): Int {
        if (s.length > 0 && s.toLong() > N) return 0
        val f = BooleanArray(10)
        s.forEach { f[it - '0'] = true }
        var count = if (f[7] && f[5] && f[3]) 1 else 0
        for (c in "753") count += c753(s + c)
        return count
    }
    val ans = c753("")
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta


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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){   
    ll n, k;
    cin >> n >> k;

    vector<ll> h(n);
    rep(i, n)cin >> h[i];
    sort(ALL(h), greater<ll>());
    
    ll sum = 0;
    for(ll i = k; i < n; ++i)sum += h[i];
    cout << sum << endl;
}

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

int n;

struct st{
	int lef;
	int rig;
	st(){
		lef = INT_MAX;
		rig = INT_MAX;
	}
	st(int lef_, int rig_){
		lef = lef_;
		rig = rig_;
	}
	st add(){
		st r;
		r.lef = lef;
		r.rig = rig;
		if (r.lef != INT_MAX){
			r.lef--;
			r.rig++;
		}
		return r;
	}
};

int k;

#define MAX 100002
vector<int> v[MAX];

bool used[MAX];
int c[MAX];

st merge(st a, st b){
	if (a.lef == INT_MAX){
		return b;
	}
	if (b.lef == INT_MAX){
		return a;
	}
	if (a.lef % 2 != b.lef % 2){
		return st(INT_MIN, INT_MIN);
	}
	if (a.lef > b.lef){
		swap(a, b);
	}
	if (a.lef <= b.lef&&b.rig <= a.rig){
		return b;
	}
	if (a.rig < b.lef){
		return st(INT_MIN, INT_MIN);
	}
	return st(b.lef, a.rig);
}
st tmp[MAX];

inline st dfs(int b,int pr=-1){
	st r;
	for (int i = 0; i < v[b].size(); i++){
		if (v[b][i] == pr){
			continue;
		}
		r = merge(r, dfs(v[b][i], b).add());
	}
	if (used[b]){
		r = merge(r, st(c[b], c[b]));
	}
	if (r.lef == INT_MIN){
		puts("No");
		exit(0);
	}
	tmp[b] = r;
	return tmp[b];
}
inline void dfs2(int b, st up,int pr=-1){
	if (used[b]){

	}
	else{
		st r = merge(up, tmp[b]);
		if (r.lef == INT_MAX){
			c[b] = 0;
		}
		else{
			c[b] = r.lef;
		}
		used[b] = true;
	}
	st nw = st(c[b] - 1, c[b] + 1);
	for (int i = 0; i < v[b].size(); i++){
		if (v[b][i] != pr){
			dfs2(v[b][i], nw,b);
		}
	}
}

int main(){
	cin >> n;
	for (int i = 1; i < n; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	cin >> k;
	for (int i = 0; i < k; i++){
		int v, p;
		scanf("%d%d", &v, &p);
		v--;
		c[v] = p;
		used[v] = true;
	}
	st T = dfs(0);
	dfs2(0, T);
	puts("Yes");
	for (int i = 0; i < n; i++){
		printf("%d\n", c[i]);
	}
		return 0;
}

Measured memory_bytes: 13568
import math

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

def solve(x):    #Trueで切り切れる
    cnt = 0
    for a in A:
        cnt += math.ceil(a / x) - 1
    return cnt <= K

left = 0
right = 10 ** 9 + 1

for _ in range(100):
    mid = (left + right) / 2
    if solve(mid):
        right = mid
    else:
        left = mid

print(math.ceil(right))

Measured memory_bytes: 93684
#include "bits/stdc++.h"
using namespace std;
void __dump(int x){cerr << x;}
void __dump(long long x){cerr << x;}
void __dump(long double x){cerr << fixed << setprecision(3) << x;}
void __dump(char x){cerr << '\'' << x << '\'';}
void __dump(const string &x){cerr << '"' << x << '"';}
void __dump(const char *x){cerr << '"' << x << '"';}
void __dump(bool x){cerr << (x ? "true" : "false");}
void _dump(){cerr << "\n";}
template <typename T, typename U> void __dump(const pair<T, U> &x){cerr << '{'; __dump(x.first); cerr << ','; __dump(x.second); cerr << '}';}
template <typename T, typename U, typename V> void __dump(const tuple<T, U, V> &x){cerr << '{'; __dump(get<0>(x)); cerr << ',';  __dump(get<1>(x)); cerr << ',';  __dump(get<2>(x)); cerr << '}';}
template <typename T> void __dump(const T& x){int f=0; cerr << '{'; for(auto&i:x) cerr << (f++ ? "," : ""), __dump(i); cerr << "}";}
template <typename T, typename ... U> void _dump(T t, U ... u){__dump(t); if(sizeof...(u)) cerr << ", "; _dump(u...);}
#define dump(x ...) cerr  <<  "|| "  <<  # x  <<  "  =  ", _dump(x) 
//#define int long long
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define size(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define ln '\n'
#define __ ' '
#define LL long long
#define LD long double
#define pii pair<int,int>
const int INF = 2e9;
const int NN = -1;
int m,k;
vector<int> ans;

int main(){ FAST;
	cin >> m >> k;
	
	if(k >= (1<<m)){
		cout << -1 << ln;
		return 0;
	}

	if(m == 1 && k == 0) ans = {0, 0, 1, 1}; 
	else if(m == 1 && k == 1){
		cout << -1 << ln;
		return 0;
	}
	else{
		ans.emplace_back(k);
		for(int i=0; i<(1<<m); ++i) if(i != k) ans.emplace_back(i);
		ans.emplace_back(k);
		for(int i=(1<<m)-1; i>=0; --i) if(i != k) ans.emplace_back(i);
	}

	// for(int i=0; i<size(ans); ++i) for(int j=i+1; j<size(ans); ++j) if(ans[i] == ans[j]){
	// 	int x=0;
	// 	for(int ind=i; ind<=j; ++ind) x ^= ans[ind];
	// 	assert(x == k);
	// }

	for(int x: ans) cout << x << __;
	cout << ln;

}

Measured memory_bytes: 2932
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct UF{
    vector<int> par, sz;
    UF(){}
    UF(int n):par(n), sz(n, 1){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int n, m;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    vector<int> a(m), b(m);
    UF uf(n);
    vector<int> ans(m);
    rep(i, 0, m){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    ans[m - 1] = n * (n - 1) / 2;
    for(int i = m - 1; i >= 1; i--){
        if(uf.same(a[i], b[i])){
            ans[i - 1] = ans[i];
        }else{
            int p = uf.sz[uf.find(a[i])];
            int q = uf.sz[uf.find(b[i])];
            uf.unite(a[i], b[i]);
            ans[i - 1] = ans[i] - p * q;
        }
    }
    for(int ii = 0; ii < ans.size(); ii++){
        cout << ans[ii] << endl;
    }
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,0,n) cin >> a[i];
  rep(i,k,n) {
    if (a[i] > a[i-k]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll ans = 1;
	FOR(i, 2, sqrt(1000)){
		ll temp = 1;
		while (temp < x){
			temp *= i;
		}
		if (temp == i){continue;}
		if (temp != x){
			temp /= i;
		}
		ans = max(ans, temp);
	}
	cout << ans << endl;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> a(n); rep(i,n) cin >> a[i];

  int Alice = 0,Bob = 0;
  sort(a.begin(),a.end());
  for(int i = n-1;i>=0;i-=2){
    Alice += a[i];
    if(i-1>=0) Bob += a[i-1];
  }
  int ans = Alice-Bob;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<algorithm>
#define INFTY 1 << 21
using namespace std;

static const int N = 100;

int main(){
    int n;
    cin >> n;
    int p[N+1], m[N+1][N+1];
    for(int i = 1; i <= n; i++){
        scanf("%d %d", &p[i-1], &p[i]);
    }
    int i, j, l;
    for(i = 1; i <= n; i++){
        m[i][i] = 0;
    }   // 初期化
    for(l = 2; l <= n; l++){
        for(i = 1; i <= n - l + 1; i++){
            j = i + l - 1;
            m[i][j] = INFTY;
            for(int k = i; k < j; k++){
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}



Measured memory_bytes: 3260
n =int(input())
xi = list(map(int,input().split()))
min_kyo = 0
for house in xi:
  min_kyo += (1 - house)**2
  
for i in range(2,max(xi)+1):
  kyori = 0
  for house in xi:
    kyori += (i - house)**2
  if kyori < min_kyo:
    min_kyo = kyori
    
print(min_kyo)

Measured memory_bytes: 38640