akhauriyash/Code-Regression huggingface dataset:
def read_input():
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(d)]
    return d, c, s


def simulate(d, c, s, t):
    """
    t : コンテスト番号列
    """
    last = {i: 0 for i in range(26)}

    def day_loss(curr):
        loss = 0
        for i, e in enumerate(c):
            loss += e * (curr - last[i])
        return loss
    
    sufficient = 0
    hist = []
    for day in range(1, d + 1):
        contest = t[day - 1] - 1
        last[contest] = day

        sufficient += s[day - 1][contest]
        sufficient -= day_loss(day)    

        hist.append(sufficient)

    return sufficient, hist


def submit():
    d, c, s = read_input()
    t = [int(input()) for _ in range(d)]
    _, hist = simulate(d, c, s, t)
    for h in hist:
        print(h)


if __name__ == "__main__":
    submit()

Measured memory_bytes: 9400
import java.util.*;
import java.io.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static long mod = 998244353;
	static int inf = (int) 1e15;
	static ArrayList<Integer>[] ad;
	static int n, k;
	static long[][] memo;
	static char[][] g;
	static boolean[] vis;
	static long ans, tem;
	static long[] a;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(x*(x-1)/2+y*(y-1)/2);
		out.close();
	}

	static long cal(int i, int u, int p) {
		if (memo[i][u] != -1)
			return memo[i][u];
		long ans = 1;
		for (int v : ad[i]) {
			if (v == p)
				continue;
			if (u == 0) {
				long tem = 0;
				tem = (2 * cal(v, 0, i)) % mod;
				tem = (tem + 2 * cal(v, 1, i)) % mod;
				tem = (tem - cal(v, 2, i) + mod) % mod;
				ans = ans * tem % mod;
			} else if (u == 1) {
				long tem = 0;
				tem = (2 * cal(v, 0, i)) % mod;
				tem = (tem + cal(v, 1, i)) % mod;
				tem = (tem - cal(v, 2, i) + mod) % mod;
				ans = ans * tem % mod;
			} else {
				long tem = 0;
				tem = cal(v, 0, i) % mod;
				tem = (tem + cal(v, 1, i)) % mod;
				tem = (tem - cal(v, 2, i) + mod) % mod;
				ans = ans * tem % mod;
			}
		}
		return memo[i][u] = ans;
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  double y = 0;
  double b = 0;
  double num = 0;
  string std;
  for (int i=0;i < n;i++){
    cin >> num;
    cin >> std;
    if (std == "JPY") y+=num;
    else b+=num;
  }
  cout << y + b*380000 << endl;
  return 0;
}

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

#define ff first
#define ss second
#define maxn 2000006
#define pb push_back
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)

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

using namespace std;

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

	ll n; cin>>n;

	double a[n];
	f(i,0,n-1) cin>>a[i];

	double s=0;

	f(i,0,n-1) s+=(1/a[i]);

	s=(1/s);;

	cout << std::fixed << std::setprecision(15) << s;


	return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
if (A+B)/2 <= C:
    ans = A*X+B*Y
else:
    if X <= Y:
        ans = 2*X*C
        if (Y-X)*B <= (Y-X)*2*C:
            ans += (Y-X)*B
        else:
            ans += (Y-X)*2*C
    else:
        ans = 2*Y*C
        if (X-Y)*A <= (X-Y)*2*C:
            ans += (X-Y)*A
        else:
            ans += (X-Y)*2*C
print(ans)

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << C << endl;
    }
    if (A == C) {
        cout << B << endl;
    }
    if (B == C) {
        cout << A << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int lmax(long long int a, long long int b){
    if(a<b)return b;
    else return a;
}
int main()
{
    long long int n,W;
    cin >> n >> W;
    vector<long long int>w(n);
    vector<long long int>v(n);
    for (long long int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }

    vector<vector<long long int>> dp(n+1,vector<long long int>(W+1,0));

    for (long long int i = 0; i < n; i++)
    {
        for(long long int j=0;j<=W;j++){
            if(j>=w[i])
            {
                dp[i+1][j]=lmax(dp[i][j], dp[i][j-w[i]]+v[i]);
            }else
            {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    cout << dp[n][W] << endl;    
    return 0;
}

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

#define ll long long
#define ar array
#define endl "\n"

int main(){
    //
    //freopen("input.txt", "r", stdin);
    //
    ios::sync_with_stdio(0);
    cin.tie(0);

    set <string> S;
    int n;
    cin>>n;
    for (int i=0; i<n; ++i){
        string temp;
        cin>>temp;
        S.insert(temp);
    }
    cout<<S.size();

}

Measured memory_bytes: 19220
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> L(n);
	rep(i, n) cin >> L.at(i);
	int sum = 0;
	sort(L.begin(), L.end());
	for (int i = 0; i < n - 2; i += 1) {
		int a = L.at(i);
		for (int j = i + 1; j < n - 1; ++j) {
			int b = L.at(j);
			for (int k = j + 1; k < n; ++k) {
				int c = L.at(k);
				if (abs(b - c) < a) sum++;
				else break;
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <random>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
	int n;
	cin >> n;
	multiset<int> st;
	REP(i,n){
		int a;
		scanf("%d", &a);
		st.insert(a);
	}
	int m;
	cin >> m;
	REP(i,m){
		int a;
		scanf("%d", &a);
		if (st.count(a) == 0){
			cout << "NO" << endl;
			return 0;
		}
		st.erase(st.find(a));
	}
	cout << "YES" << endl;
    
    return 0;
}

Measured memory_bytes: 9600
#include <stdio.h>

int main(void)
{
	int sum, a, i;
	
	while (scanf("%d", &sum), sum != 0){
		for (i = 0; i < 9; i++){
			scanf("%d", &a);
			sum -= a;
		}
		
		printf("%d\n", sum);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    string s, t;
    cin >> s >> t;
    ll ans = t.size();
    for(int i = 0;i < s.size();i++){
        if(i + (t.size()-1) < s.size()){
            ll a = 0;
            int o = i;
            int b = 0;
            while(o < i+t.size()){
                if(s[o] == t[b]){
                    b++;
                    o++;
                    continue;
                }
                else{
                    a++;
                    o++;
                    b++;
                }
            }
            ans = min(ans,a);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int a,b;
int n;//工事中の箇所
int main()
{
  while(cin>>a>>b,a||b){
    cin >>n;
    int dp[20][20] ={0};
    dp[1][1] =1;
    for(int i = 0;i < n;i++){
      int x,y;
      cin >>x>>y;
      dp[y][x] =-1;
    }
    for(int y = 1;y <=b;y++){
      for(int x = 1;x <=a;x++){
	if(dp[y][x] !=-1){
	  if(y !=1 &&dp[y-1][x] !=-1){
	    dp[y][x] +=dp[y-1][x];
	  }
	  if(x !=1&&dp[y][x-1] !=-1){
	    dp[y][x] +=dp[y][x-1];
	  }
	}
      }
    }
    cout <<dp[b][a] <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

#define MAX 250

int main(){
  int n,i,a[MAX];

  scanf("%d" ,&n);

   for(i = 0 ; i < n ; i++){
     if(i < n)break;
  }
   
  for(i = 0 ; i < n ; i++){
    scanf("%d" , &a[i]);
  }

  for(i = 0 ; i < n ; i++){
    printf("node %d: key = %d, " ,i+1 ,a[i]);

    if(i){
      printf("parent key = %d, " ,a[(i+1)/2-1]);
    }

    if(2*i+1 < n){
      printf("left key = %d, " ,a[2*i+1]);
    }
    if(2*i+2 < n){
      printf("right key = %d, " ,a[2*i+2]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2052
macro_rules! input {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    let stdin = std::io::stdin();
    let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
    let mut next = move || -> String{
        bytes
            .by_ref()
            .map(|r|r.unwrap() as char)
            .skip_while(|c|c.is_whitespace())
            .take_while(|c|!c.is_whitespace())
            .collect()
    };
    input! {next,
        r: f64,
    }
    println!("{}", 2.0*std::f64::consts::PI*r);
}


Measured memory_bytes: 2196
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll K;
  cin >> K;
  string S;
  cin >> S;

  if(S.size() <= K){
    cout << S << endl;
  } else{
    rep(i, K) cout << S[i];
    cout << "..." << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
  int n,r=0;
  cin>>n;
  int c[10][10]={0};
  for(int i=1;i<=n;++i){
    int h=i,t=i%10;
    while(h>9)h/=10;
    ++c[h][t];
  }
  for(int i=1;i<=9;++i)for(int j=1;j<=9;++j)r+=c[i][j]*c[j][i];
  cout<<r;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;


int main()
{
    int n;
    scanf("%d",&n);
    
    if(n%2==0)
    {
        n=n/2;
    }
    else
    {
        n=n+1;
        n=n/2;
    }

    printf("%d\n",n);
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
using namespace std;
signed main(){
	int x[5];
	for (int i = 0; i < 4; i++) {
		cin >> x[i];
	}
	cout << x[2] + (x[1] - x[3]) << " " << x[3] + (x[2] - x[0]) << " " << x[0] - (x[3] - x[1]) << " " << x[1] + (x[2] - x[0]) << endl;

	system("PAUSE");
	return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 094d
int main(){
    int n;
    cin >> n;
    ll a[n+1];
    rep(i, n) cin >> a[i];
    sort(a, a+n);
    ll ans = 1LL << 60;
    ll maxA = a[0];
    ll mid = (a[n-1]+1)/2;
    rep(i, n){
        ll tmp = a[i];
        if (abs(tmp - mid) < ans){
            ans = abs(tmp-mid);
            maxA = tmp;
        }
    }
    cout << a[n-1] << ' ' << maxA << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef long long ll;
const int MOD = 1e9+7;
const int BASE = 27;
const int N = 200001;
const ll oo = 1e18;
const double EPS = 1e-9;

int n , a[N],b[N];

priority_queue<pii> q;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i){
		scanf("%d",a+i);
	}
	for (int i = 0; i < n; ++i){
		scanf("%d",b+i);
		q.push(mp(b[i],i));
	}
	ll ans = 0;
	while(q.size()){
		pii f = q.top();
		q.pop();
		if(b[f.y] == a[f.y])continue;
		if(a[f.y] > b[f.y]){
			puts("-1");
			return 0;
		}
		int nxt_idx = (f.y+1)%n;
		int prv_idx = (f.y-1+n)%n;
		int rem = b[nxt_idx]+b[prv_idx];
		int g = (b[f.y]-a[f.y])/rem;
		int newVal = f.x-g*rem;
		b[f.y] =  newVal;
		ans += g;
		if(!g && newVal != a[f.y]){
			puts("-1");
			return 0;
		}
		q.push(make_pair(newVal,f.y));
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
    string s;
    int num[26] = {};
    cin >> s;
    for(int i = 0;i < s.size();i++)++num[s[i]-'a'];
    for(int i = 0;i < 26;i++){
        if(num[i] % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10001)

n, m = list(map(int, input().split()))
v = []
w = []

for i in range(n):
    a,b = list(map(int, input().split()))
    v.append(a)
    w.append(b)

x = [[-1]* (m+1) for i in range(n+1) ]

def knapsack(i, c):
    if x[i][c] == -1:
        if c == 0 or i == n:
            x[i][c] = 0

        else:
            a = knapsack(i+1, c)
            b = 0

            if c >= w[i]:
                b = v[i] + knapsack(i+1, c - w[i])
            x[i][c] = max(a, b)

    return x[i][c]

print(knapsack(0, m))


Measured memory_bytes: 23640
# 2019-11-16 14:51:41(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    a, b = [int(x) for x in sys.stdin.readline().split()]
    ans = max(a+b, a-b, a*b)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	int l,r,d;
	cin>>l>>r>>d;

	int t=0;
	for(int i=l; i<r+1; i++){
		if(i%d==0)t++;
	}
	cout<<t<<endl;

	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
using namespace std;
int a[13]={0,1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
int v[100005];
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        v[i]=200000;
    }
    int s=0;
    v[0]=0;
    for(int i=1;i<=12;i++){
        for(int j=a[i];j<=n;j++){
            v[j]=min(v[j-a[i]]+1,v[j]);
        }
    }
    cout<<v[n]<<endl;
    return 0;
}

Measured memory_bytes: 640
X = list()
Y = list()
D = list()
score = 0

n,d = map(int, input().split())
for i in range(n):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

for i in range(n):
    dis = (X[i]**2 + Y[i]**2)**0.5
    D.append(dis)

for i in range(n):
    if d >= D[i]:
        score += 1

print(score)

Measured memory_bytes: 33104
#include <stdio.h>

int main() {

	int N, K;
	scanf("%d", &N);
	scanf("%d", &K);
	
	int num=1;
	for(int i=1; i<=N; i++){
		if (num<K){
		num*=2;
	}
		else{
			num+=K;
		}
	}
	
	printf("%d\n", num);

    return 0;
}


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

int main() {
  long long x;
  cin >> x;

  long long k = x / 11;
  long long l = x % 11;

  if (l==0) {
    cout << k*2 << endl;
  }

  else if (l<=6) {
    cout << k*2 + 1 << endl;
  }
  else {
    cout << k*2 + 2 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

 	int x, y;
 	while( 1 ){
	cin >> x >> y;
 		
 	if(x == 0 && y == 0) break;
	
	if(x < y) cout << x << " " << y <<endl;
	else cout << y << " " << x <<endl;

	}
}

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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] answer = new int[N];
        Arrays.fill(answer,-1);
        for(int i = 0 ; i<M ; i++){
            int s = sc.nextInt()-1;
            int c = sc.nextInt();
            if(s == 0 && c == 0 && N != 1){
                System.out.println(-1);
                return;
            }
            if(answer[s] == c || answer[s] == -1){
                answer[s]=c;
            }else{
                System.out.println("-1");
                return;
            }
        }
        for(int i = 0 ; i < N ; i++){
            if(answer[i] != -1){
                System.out.print(answer[i]);
            }else{
                if(N > 1 && i == 0){
                    System.out.print(1);
                  } else {
                    System.out.print(0);
                  }
            }
        }
        System.out.print("\n");
    }
}

Measured memory_bytes: 23636
n, k = map(int, input().split())
a = list(map(int, input().split()))

l, r = 0, 10 ** 9
while r - l > 1:
    x = (l + r) // 2

    cnt = 0
    for i in range(n):
        if a[i] % x == 0:
            cnt += a[i] // x - 1
        else:
            cnt += a[i] // x

    if cnt <= k:
        r = x
    else:
        l = x

print(r)


Measured memory_bytes: 93900
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 2010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll F[MAXN*MAXN], I[MAXN*MAXN];
ll dp[MAXN][MAXN]; // dp[i][j]   i ta color    j ta 0    i>=j 

ll powmod(ll a, ll b){
	if (!b) return 1;
	if (b&1) return a*powmod(a*a%mod, b>>1)%mod;
	return powmod(a*a%mod, b>>1);
}

ll C(ll n, ll r){
	if (r<0 || r>n) return 0;
	return (F[n]*I[r]%mod)*I[n-r]%mod;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	F[0]=1;
	for (int i=1; i<MAXN*MAXN; i++) F[i]=F[i-1]*i%mod;
	I[MAXN*MAXN-1]=powmod(F[MAXN*MAXN-1], mod-2);
	for (int i=MAXN*MAXN-1; i; i--) I[i-1]=I[i]*i%mod;
	
	cin>>n>>k;
	if (k==1) kill(1)
	dp[0][0]=1;
	for (int i=1; i<=n; i++){
		for (int j=0; j<=i; j++){
			dp[i][j]=dp[i-1][j]*C(i*(k-1)+j-1, k-2)%mod;
			if (j) dp[i][j]=(dp[i][j] + dp[i][j-1])%mod;
		}
	}
	
	ans=dp[n][n]*F[n]%mod;
	cout<<ans<<'\n';
	
	return 0;
}


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

using namespace std;

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

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n;
    //cout<<n<<endl;
    cin>>n;
    //cout<<n<<endl;
    vi c={0,0,0};
    ll ans=1;
    //cout<<n<<endl;
    rep(i,n){
        //cout<<111<<endl;
        int a;
        cin>>a;
        if (c[0]==a){
            if (c[1]==a){
                if (c[2]==a){
                    ans*=3;
                    ans%=MOD;
                }
                else{
                    ans*=2;
                    ans%=MOD;
                }
            }
            c[0]+=1;
        }
        else if (c[1]==a){
            if (c[2]==a){
                ans*=2;
                ans%=MOD;
            }
            c[1]+=1;
        }
        else if (c[2]==a)c[2]+=1;
        else ans=0;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef  int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
//#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// khodaya komak kon
/// ya navid navid
const int N=2e5;
ll t0[N];
ll t1[N];
ll t10[N];
ll t11[N];
int32_t main(){
    string s;
    cin >> s;
    for (int i=1;i<=s.size();i++){
        t0[i]=t0[i-1];
        t1[i]=t1[i-1];
        if (s[i-1]=='A'){
            t0[i]++;
        }
        else{
            t1[i]++;
        }
    }
    string u;
    cin >> u;
    for (int i=1;i<=u.size();i++){
        t10[i]=t10[i-1];
        t11[i]=t11[i-1];
        if (u[i-1]=='A'){
            t10[i]++;
        }
        else{
            t11[i]++;
        }
    }
    ll q;
    cin >> q;
    for (int i=0;i<q;i++){
        ll x,y;
        cin >> x >> y;
        ll w,h;
        cin >> w >> h;
        ll z=t0[y]-t0[x-1];
        z-=t1[y]-t1[x-1];
        z+=3e8;
        z%=3;
        ll z1=t10[h]-t10[w-1];
        z1-=t11[h]-t11[w-1];
        z1+=3e8;
        z1%=3;
        //cout << z << " " << z1 << endl;
        if (z1!=z){
            cout << "NO";
        }
        else{
            cout << "YES";
        }
        cout << '\n';
    }
}














Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> a(H, vector<char>(W));
  
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      cin >> a.at(i).at(j);
    }
  }
  
  for (int j=0; j<W+2; j++){
    cout << "#";
  }
  cout << endl;
  
  for (int i=0; i<H; i++){
    cout << "#";
    for (int j=0; j<W; j++){
      cout << a.at(i).at(j) ;
    }
    cout << "#" << endl;
  }
  
    for (int j=0; j<W+2; j++){
    cout << "#";
  }
  cout << endl;
	
}


Measured memory_bytes: 256
import scala.math._

// longでrangeの作り方

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val a, b = sc.nextInt
//  val list = List.fill(3)(sc.next)

  val ans = (a + b) % 24

  println(ans)


  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 25912
def main():
    N = int(input())
    H = list(map(int, input().split(" ")))
    flag = True
    for i in range(N - 1):
        if H[i] - H[i + 1] < 0:
            H[i + 1] -= 1
    for j in range(N - 1):
        if H[j + 1] - H[j] < 0:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

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

int main(){
    vector<int> vec;
    int k,n;
    cin>>n>>k;
    rep(i,n){
        int p;
        cin>>p;
        vec.push_back(p);
    }
    sort(vec.begin(),vec.end());
    ll ans = 0;
    rep(i,k){
        ans+=vec[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



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


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int i, j, k;
	int r, g, b;
	cin >> r >> g >> b;

	if (((r * 100 + g * 10 + b) % 4) == 0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	system("pause");
	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> food(M + 1, false);
  
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      food.at(A)++;
    }
  }
  
  int cnt = 0;
  for (int i = 0; i < M+1; i++) {
    if (food.at(i) == N) cnt++;
  }
  cout << cnt << endl;
}

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

namespace ABC105
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var n = input[0];
            var k = input[1];

            if (n % k == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1);
            }
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int x,y;
	cin>>x>>y;
	if((4*x)<y)
	cout<<"No"<<endl;
	else{
		if(y%2==0)
		{
			if((y/2)>=x)
			cout<<"Yes"<<endl;
			else
			cout<<"No"<<endl;
		}
		else
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;


ll lcm(ll a ,ll b)
{
    ll l = __gcd(a,b);
    //cout<<"l"<<" "<<l<<endl;
    return a/l*b;
}

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

ll ans =1;
for(ll index = 0 ;index < n;index++)
{
    ll c;
    cin>>c;

    ans = lcm(ans,c);
    // cout<<ans<<endl;
}

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


Measured memory_bytes: 3636
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    ll M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if (M1 != M2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
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; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};


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

	sort(all(a));
	sort(all(f)); reverse(all(f));

	ll l = 0, r = 1e12,m;
	while(l <= r){
		m = (l+r)/2;
		bool flag = true;
		ll tmp = k;
		for(int i = 0; i < n; i++){
			if(a[i]*f[i] > m){
				//ll num = (a[i]*f[i]-m-1)/a[i]+1;
				ll num = a[i]-m/f[i];
				tmp -= num;
				if(tmp < 0) flag = false;
			}
		}
		if(flag){
			r = m-1;
			//cout << "r" << endl;
		}else{
			l = m+1;
			//cout << "l" << endl;
		}
	}

	cout << l << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b > c+d){
    cout << "Left" << endl;
  }else if(a+b == c+d){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define itn int
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,k,n) for(ll i=k;i<n;i++)
#define REPEACH(itr,k) for(auto itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;

int main(){
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(),v.end());
  int ans=0;
  ans+=v[2]-v[1];
  v[0]+=ans;
  if((v[2]-v[0])%2==0){
    ans+=(v[2]-v[0])/2;
  }
  else{
    ans+=(v[2]-v[0])/2;
    v[0]=v[2]-1;
    ans+=2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int[][] a = new int[3][3];
    int[] x = new int[3];
    int[] y = new int[3];
    int max = Integer.MIN_VALUE;
    for(int i=0; i<3; i++){
      for(int j=0; j<3; j++){
        a[i][j] = sc.nextInt();
        if(a[i][j] > max){
          max = a[i][j];
        }
      }
    }
    String f = "Yes";
    
    x[0] = 0;
    for(int j=0; j<3; j++){
      y[j] = a[0][j] - x[0];
    }
    for(int j=0; j<3; j++){
      x[j] = a[j][0] - y[0];
    }
    for(int i=0; i<3; i++){
      for(int j=0; j<3; j++){
        if(a[i][j] != x[i]+y[j]){
          f = "No";
        }
      }
    }
    System.out.println(f);

    sc.close();
  }
}


Measured memory_bytes: 22612
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    static int N;
    static int t;
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            Scanner sc = new Scanner(System.in);
            String s = sc.nextLine();
            String[] p = s.split(" ");
            for(int i=0; i<p.length; i++){
                out.print(Character.toUpperCase(p[i].charAt(0)));
            }
            out.println();
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}

Measured memory_bytes: 21972
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
# https://atcoder.jp/contests/arc098/tasks/arc098_b

# xorは桁の繰り上がりがない足し算！→範囲で1が1回以下出てくるような範囲は大丈夫
# 1が2回以上出てこない最長の範囲ならどのようにl,rを選んでも題意が成り立つ
# 尺取法か,累積和で、足し算とxorが成り立つ最長の範囲を取ってくれば良い
# Alに対して範囲が成り立つ最長のArを探せば良い
# だけど一つずらしても最長の区間が存在する場合は？
#

N = read_a_int()
A = read_ints()
# a_sum = 0
# a_xor = 0
# ans = 0
# r = 0
# for l in range(N):
#     while r < N and a_sum + A[r] == a_xor ^ A[r]:  # 条件にすべきなのは次の状態
#         a_sum += A[r]
#         a_xor ^= A[r]
#         r += 1
#         # print(l, r, a_sum, a_xor)
#     ans += r - l
#     # print(l, r)
#     a_sum -= A[l]
#     a_xor ^= A[l]
# print(ans)

# 一般化尺取法


def two_pointers(ls: list):
    '''すべてのlに対して、条件is_okをみたすls[l:r]の中で
    r - lが最大になるような(l,r)の集合を返す'''
    n_ls = len(ls)
    ret = []

    def append(r, pre_states):
        '''状態にls[r]を考慮して更新する'''
        # 問題によって自分で定義
        sum_state, xor_state = pre_states
        sum_state += ls[r]
        xor_state ^= ls[r]
        return (sum_state, xor_state)

    def pop(l, pre_states):
        '''状態からls[l]を抜く更新をする'''
        # 問題によって自分で定義
        sum_state, xor_state = pre_states
        sum_state -= ls[l]
        xor_state ^= ls[l]
        return (sum_state, xor_state)

    def is_ok(r, pre_states):
        '''満たしていてほしい条件'''
        # 問題によって自分で定義
        states = append(r, pre_states)
        sum_state, xor_state = states
        return sum_state == xor_state

    r = 0
    states = (0, 0)
    for l in range(n_ls):
        while r < n_ls and is_ok(r, states):
            # 更新式
            states = append(r, states)
            r += 1
        ret.append((l, r))
        # 抜けるときの更新
        states = pop(l, states)
    return ret


idxs = two_pointers(A)
ans = 0
for l, r in idxs:
    ans += r - l
print(ans)


Measured memory_bytes: 81144
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define num_max(p,q)((p)>(q)?(p):(q))
#define num_min(p,q)((p)<(q)?(p):(q))
int cmp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;//昇順
	 //降順ならreturn *(int*)b - *(int*)a;
}
int main()
{
	long long N;
	scanf("%lld", &N);
	long long x, y;
	long long root=sqrt(N);
	long long p = N + 1;
	for (long long i = 2;i <= root;i++)
	{
		if (N%i == 0) {
			x = N / i;
			y = i;
			if (x + y < p)p = x+y;
		}
	}
	printf("%lld\n", p - 2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> c(n);
  REP(i,n){
    cin >> p[i];
    c[i] = p[i];
  }
  sort(ALL(p));
  int rep = 0;
  REP(i,n){
    if(p[i] != c[i]) rep++;
  }
  if(rep == 2 || rep == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int t[10010],p[10010],x[10010];
int main()
{
	int n,m,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t[i];
		sum+=t[i];
	}
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>p[i]>>x[i];
		cout<<sum-t[p[i]]+x[i]<<"\n";
	}
	return 0;
}

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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64

int judge(int a,int b, int goal){
    int ma=0;
    int a_kosuu=goal / a;
    int b_kosuu=0;
    while(1){
        if(ma < a * a_kosuu + b * b_kosuu) ma=a * a_kosuu + b * b_kosuu;
        a_kosuu-=1;
        if(a_kosuu<0) break;
        b_kosuu = (goal - a*a_kosuu)/b;
    }
    return ma;
}


int main(){
    int wa1,wa2,su1,su2,houwa,omosa;
    cin >> wa1 >> wa2 >> su1 >> su2 >> houwa >> omosa;
    pair<int, int > ans;
    ans.first=wa1*100;
    ans.second=0;
    int tmp_water=wa1*100;
    int tmp_sugar;
    while(tmp_water <=omosa){
        if(judge(wa1*100,wa2*100,tmp_water)!=tmp_water){
            tmp_water +=100;
            continue;
        }
        tmp_sugar=judge(su1,su2,min(houwa*tmp_water/100,omosa-tmp_water));
        if(float(ans.second)/(ans.second + ans.first) < float(tmp_sugar)/(tmp_water + tmp_sugar)){
            ans.first=tmp_water;
            ans.second=tmp_sugar;
        }
        tmp_water += 100;
    }
    cout << ans.first + ans.second << "\n" << ans.second << endl;
}


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

int main() {
  ll N, K;
  cin >> N >> K;
  ll count = 0;
  while (true) {
    if (N < pow(K, count)) {
      break;
    } else if (N == pow(K, count)) {
      count++;
      break;
    }
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = INT()
B = INT()
if A>B:
	print("GREATER")
elif A<B:
	print("LESS")
else:
	print("EQUAL")


Measured memory_bytes: 5208
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  char c;
  cin >> c;
  if (65 <= c && c <= 90) cout << 'A' << endl;
  else cout << 'a' << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define pb push_back
#define mp make_pair
#define NMAX 100001
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;

int n,m;
int a[NMAX];
int id[NMAX];
int res,cnt;
vector <int> adj[NMAX];
bool visit[NMAX];
inline void DFS(int u){
    //cout<<"GO: "<<u<<'\n';
    for(int v:adj[u]){
        if(!id[v]){
            id[v]=cnt;
            DFS(v);
        }
    }
}
int main(){
    //freopen("D.inp","r",stdin);
    //memset(-1,p,sizeof(p));
    read(n);read(m);
    for(int i=1;i<=n;i++){
        read(a[i]);
    }
    for(int i=1;i<=m;i++){
        int u,v;
        read(u);read(v);
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i=1;i<=n;i++){
        if(!id[i]){
            cnt++;
            id[i]=cnt;
  //          visit[i]=true;
            DFS(i);
 //           load(i);
 //           cout<<'\n';
        }
    }
    for(int i=1;i<=n;i++){
     //   cout<<id[i]<<" "<<id[a[i]]<<'\n';
        if(id[i]==id[a[i]]) res++;
    }
    writeln(res);
}


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

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for (int i = 0; i <= n; i += 4)
	{
		if ((n - i) % 7 == 0) puts("Yes"), exit(0);
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int N, A;
  scanf("%d", &N);
  scanf("%d", &A);
  
  const int denomi = N % 500;
  
  if (denomi <= A)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  
  return 0;
}

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

using namespace std;

int main() {
    int A, B, C;
    cin >> A;
    cin >> B;
    cin >> C;
    long long ans = min(A, C);
    C -= min(A, C);
    ans += min(C, B) * 2 ;
    int tmp = min(C, B);
    B -= tmp;
    C -= tmp;
    ans += B;
    if (C > 0)
        ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256