akhauriyash/Code-Regression huggingface dataset:
a,b,c,x,y = map(int,input().split())

ans = a * x + b * y

for i in range(1,max(x,y)+1):
    tmp = max(0, x-i) * a + max(0, y-i) * b + 2 * c * i
    ans = min(ans,tmp)
    
print(ans)

Measured memory_bytes: 3060
import sys
from itertools import product

N,M = list(map(int, input().split()))

K = []

for i in range(M):
    k = list(map(int, input().split()))
    K.append(k)

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



S = []

for s in product([0,1], repeat=N):
    S.append([0] + list(s))

count = 0

for s in S:
    verify = True
    for p,k in zip(P,K):
        _sum = 0
        for i in k[1:]:
            _sum += s[i]
        parity = _sum % 2
        if parity != p:
            verify = False
            break
    if verify:
        count += 1

print(count)


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

int main() {
    int N, K, h[100000], ans = 1e9;
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];
    sort(h, h + N);

    for (int i = 0; i + K - 1 < N; ++i) ans = min(ans, h[i + K - 1] - h[i]);
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
double t, a;
vector<double> h;

int main(){
  cin >> n;
  cin >> t >> a;
  h = vector<double>(n);
  for(lli i = 0;i < n;i++) cin >> h[i];
  for(lli i = 0;i < n;i++) h[i] = abs(t-0.006*h[i]-a);
  cout << min_element(h.begin(), h.end())-h.begin()+1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;

int main() {
	ll h, w;
	cin >> h >> w;
	if (h == 1||w==1) {
		cout << 1 << endl;
		return 0;
	}
	if (h % 2 == 0 && w % 2 == 0) {
		ll a = w / 2;
		cout << a * h << endl;
		return 0;
	}
	ll sum;
	if (w % 2 == 0) {
		sum = w / 2;
	}
	else {
		sum = w / 2 + 1;
	}
	ll ans = 0;
	ll kai = sum - 1;
	if (w % 2 == 1) {
		for (int i = 0; i < h; i++) {
			if (i % 2 == 0) {
				ans += sum;
			}
			else {
				ans += kai;
			}
		}
		cout << ans << endl;
		return 0;
	}
	else {
		for (int i = 0; i < h; i++) {
			ans += sum;
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
int v[N];
int dp[N];
int n, k;
int calc(int idx) {
	if (idx >= n - 1)
		return 0;
	int &ret = dp[idx];
	if (ret != -1)
		return ret;
	ret = 1e9;
	for (int i = 1; i <= k; ++i)
		if (idx + i < n)
			ret = min(ret, calc(idx + i) + abs(v[idx] - v[idx + i]));
	return ret;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	k = 2;
	memset(dp, -1, sizeof(dp));
	cout << calc(0) << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 100000000001
#define INFS 1000000
#define PI 3.141592653589793238

int main() {
    int x;
    cin >> x;
    if(x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {

	int N;
	cin >> N;
	vector <int> V(N);
	vector <int> C(N);

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

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

	int sum_V = 0;
	int sum_C = 0;

	for (int i = 0; i < N; ++i) {
		
		if (V[i] > C[i]) {
			sum_V += V[i];
			sum_C += C[i];
		}

	}
	cout << sum_V - sum_C << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}
int n, W;
int w[101];
ll  v[101];
ll dp[101][100001];

ll rec(int i, int j) {
    if (dp[i][j] >= 0)
        return dp[i][j];
    ll res;
    if (i == n) {
        res = 0;
    } else if (j < w[i]) {
        res = rec(i + 1, j);
    } else {
        res = max(rec(i+1, j), rec(i+1, j - w[i]) + v[i]);
    }
    return dp[i][j] = res;
}

int main()
{
    cin >> n >> W;
    rep(i,n) {
        cin >> w[i] >> v[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << rec(0, W) << endl;

    return 0;
}


Measured memory_bytes: 79104
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

D = i()
c = l()
s = [l() for _ in range(D)]
last = [0]*26
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    print(idx+1)

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

int main(){
  int n,k;
  cin >> n >> k;
  set<int> st;
  for (int i = 0; i < k; i++)
  {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++)
    {
      int a;
      cin >> a;
      st.insert(a);      
    }
  }
  cout << n-st.size() << endl;  
}

Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=270005,inf=1047483647;
struct node { int z[2],s[2]; bool b; } a[N<<2];
int Y[N],t[N],i,j,k,n,m,l,r,x,Z,d,J,X;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

void mt(int w){ for (;w<X;w+=w&-w) ++t[w]; }
int qt(int w){ int z=0; for (;w;w-=w&-w) z+=t[w]; return z; }

void push(int w)
{
	a[w].b^=1,swap(a[w].z[0],a[w].z[1]),swap(a[w].s[0],a[w].s[1]);
}

void pushdown(int w)
{
	if (a[w].b)
		push(w<<1),push(w<<1|1),a[w].b=0;
}

void update(int w)
{
	node &W=a[w],L=a[w<<1],R=a[w<<1|1];
	if (L.z[0]<R.z[0])
		W.z[0]=L.z[0],W.s[0]=L.s[0];
	else
		W.z[0]=R.z[0],W.s[0]=R.s[0];
	if (L.z[1]<R.z[1])
		W.z[1]=L.z[1],W.s[1]=L.s[1];
	else
		W.z[1]=R.z[1],W.s[1]=R.s[1];
}

void build(int w,int L,int R)
{
	if (L==R)
	{
		Y[L]=a[w].z[L&1]=read(),a[w].z[L+1&1]=inf,a[w].s[L&1]=L;
		return;
	}
	int mid=L+R>>1;
	build(w<<1,L,mid),build(w<<1|1,mid+1,R),
	update(w);
}

void MT(int w,int L,int R)
{
	if (L==R)
	{
		Y[L]=a[w].z[0]=a[w].z[1]=inf;
		return;
	}
	pushdown(w);
	int mid=L+R>>1;
	x>mid?MT(w<<1|1,mid+1,R):MT(w<<1,L,mid),
	update(w);
}

int QT(int w,int L,int R)
{
	if (l<=L&&r>=R) return a[w].s[0];
	pushdown(w);
	int mid=L+R>>1;
	int x=l<=mid?QT(w<<1,L,mid):0,y=r>mid?QT(w<<1|1,mid+1,R):0;
	return Y[x]<Y[y]?x:y;
}

void motree(int w,int L,int R)
{
	if (l<=L&&r>=R)
	{
		push(w);
		return;
	}
	pushdown(w);
	int mid=L+R>>1;
	if (l<=mid)
		motree(w<<1,L,mid);
	if (r>mid)
		motree(w<<1|1,mid+1,R);
	update(w);
}

int main()
{
	n=read(),Y[0]=inf;
	build(1,1,n);
	J=ceil(log(n+1)/log(2)),X=1<<J;
	for (int u=n>>1;u;--u)
	{
		Z=qt(x=l=a[1].s[1]),
		d=0;
		for (j=J-1;~j;--j)
			if (t[d|1<<j]<=Z)
				d|=1<<j,Z-=t[d];
		r=min(d,n),
		
		printf("%d ",Y[l]);
		MT(1,1,n);
		x=QT(1,1,n),
		r=x,
		printf("%d ",Y[r]);
		MT(1,1,n);
		
		mt(l),mt(r),
		motree(1,1,n);
		
	}
	return 0;
}

Measured memory_bytes: 17280
#template
def inputlist(): return [int(j) for j in input().split()]
#template
import copy
def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)
def check(s,n):
    if len(s) < n:
        d = n-len(s)
        for _ in range(d):
            s = '0'+s
    return s
ans = 0
H,W,K = inputlist()
maze = [[0] for _ in range(H)]
for i in range(H):
    maze[i] = list(input())
maza = copy.deepcopy(maze)
for i in range(2**H):
    xi = base10to(i,2)
    xi = check(xi,H)
    x_ = []
    for ind in range(H):
        if xi[ind] == "1":
            x_.append(ind)
    for j in range(2**W):
        yj = base10to(j,2)
        yj = check(yj,W)
        y_ = []
        for stu in range(W):
            if yj[stu] == "1":
                y_.append(stu)
        for x in x_:
            maze[x] = ["x" for _ in range(W)]
        for y in y_:
            for xa in range(H):
                maze[xa][y] = "x"
        count = 0
        for a in range(H):
            for b in range(W):
                if maze[a][b] == "#":
                    count+=1
        if count == K:
            ans +=1
        maze = copy.deepcopy(maza)

print(ans)

Measured memory_bytes: 9352
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;

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

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

int main(){

    long long n, v; cin >> n >> v;
    
    vector<long long> a(n);
    vector<long long> b(n);
    vector<long long> c(n);
    vector<long long> d(n);

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

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

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

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

    /*for(int i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;
    for(int i = 0; i < n; i++) cout << b[i] << " ";
    cout << endl;*/

    map<long long, long long> ma;
    map<long long, long long> mb;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            long long C = a[i] + b[j];
            ma[C]++;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            long long C = c[i] + d[j];
            mb[C]++;
        }
    }
    
    long long ans = 0;
    for(auto itr = ma.begin(); itr != ma.end(); ++itr) {
        long long C = itr->first;
        long long num1 = itr->second;

        //cout << C << " " << num1 << endl;
        C = v - C;

        long long num2 = mb[C];
        ans += num1 * num2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 190588
n = raw_input()
A = map(int, raw_input().split())
for i in range(0, len(A)):
        if i == len(A)-1:
            print A[i]
        else:
            print A[i],
            
for i in range(1, len(A)):
    j = i - 1
    tmp = A[i]
    while A[j] > tmp and j >= 0:
        tmp2 = A[j]
        A[j] = tmp
        A[j+1] = tmp2
        j -= 1
        
    for i in range(0, len(A)):
        if i == len(A)-1:
            print A[i]
        else:
            print A[i],

Measured memory_bytes: 6456
#include <iostream>
#include <string.h>
using namespace std;

int main() {
  char str[222];
  cin >> str;
  int n = strlen(str);
  for (int i=n-2; i; i-=2) {
    if (strncmp(str, str+i/2, i/2)==0) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
def main():
    n,k,q,*a=map(int,open(0).read().split())
    s=sorted
    m=1e18
    for b in a:
        i=[i for i,t in enumerate(a)if t<b]
        l=s(u for t in[s(a[i+1:j])[::-1][k-1:]for i,j in zip([-1]+i,i+[n])]for u in t)
        if len(l)>=q:m=min(m,l[q-1]-b)
    print(m)
main()

Measured memory_bytes: 3392
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long x = scanner.nextLong();
		if(x % 11 == 0){
			System.out.println( x/11 * 2);
		}else if(x % 11 > 6){
			System.out.println(x/11 * 2 +2);
		}else{
			System.out.println(x/11 * 2 +1);
		}
	}
}

Measured memory_bytes: 9804
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
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;
  return 0;
}


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

int main(void){
    int n; cin >> n;
    vector<char> vec(n);
    for(int i=0;i<n;i++) cin >> vec.at(i);

    //下処理
    vector<int> w(n);
    for(int i=1;i<n;i++){
        w.at(i) = w.at(i-1);
        if(vec.at(i-1)=='W') w.at(i)++;
    }
    vector<int> e(n);
    for(int i=n-2;i>=0;i--){
        e.at(i) = e.at(i+1);
        if(vec.at(i+1)=='E') e.at(i)++;
    }
    vector<int> person(n);
    for(int i=0;i<n;i++){
        person.at(i) = w.at(i) + e.at(i);
        //cout << w.at(i) << e.at(i) << person.at(i) << endl;
    }

    int minnum = n;
    for(int reader=0;reader<n;reader++){
        minnum = min(minnum,person.at(reader));
    }
    cout << minnum << endl;
    return 0;
}

Measured memory_bytes: 4096
s = input()
for i in range(len(s)):
    if (i + 1) % 2 == 0 and s[i] == "R":
        print("No")
        exit()
    elif (i + 1) % 2 != 0 and s[i] == "L":
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int n;
int k;
list<long long> L;
int main()
{
    long long v;
    
    cin >> n >> k;
    int t = min(n,k);
    long long ans = 0;
    
    for (int i = 0;i < n;i++){
        cin >> v;
        L.push_back(v);
    }
    for (int i = 0;i <= t;i++){
        for (int j = 0;j <= t-i;j++){
            vector<long long> w;
            w.resize(i+j);
            long long res = 0;
            if (i == 0 && j == 0){
                continue;
            }
            int ii = 0;
            for (auto it1 = L.begin();ii < i;it1++){
                w.push_back(*it1);
                res += *it1;
                ii++;
            }
            int jj = 0;
            for (auto it2 = L.end();jj < j;it2--){
                if (it2 == L.end()){
                    ;
                }
                else {
                    w.push_back(*it2);
                    res += *it2;
                    jj++;
                }
            }
            sort(w.begin(),w.end());
            int u = min(k-i-j,(int)w.size());
            int ori = 0;
            while (u > 0){
                if (w[ori] < 0){
                    res += abs(w[ori]);
                }
                else {
                    goto EXIT;
                }
                ori++;
                u--;
            }
            EXIT:
            ans = max(res,ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char ramen[3];
  int ryokin=700;
  for(int i=0; i < 3; i++){
    scanf("%c", &ramen[i]);
  }
  for(int i=0; i < 3; i++){
    if(ramen[i] == 'o'){
      ryokin+=100;
    }
  }
  printf("%d\n", ryokin);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cassert>

namespace Xel_UFF {
    class UFF {
        using Int = int;
        std::vector<Int> parent;
        std::vector<Int> rank;

        Int find(Int x) {
            auto &px = parent[x];
            if (px < 0) {
                return x;
            } else {
                return px = find(px);
            }
        }

    public:
        explicit UFF(Int n) : parent(n, -1), rank(n, 0) {}

        bool unite(Int a, Int b) {
            const auto pa = find(a);
            const auto pb = find(b);
            if(pa == pb) return false;

            if (rank[pa] > rank[pb]) {
                parent[pa] += parent[pb];
                parent[pb] = pa;
            } else {
                parent[pb] += parent[pa];
                parent[pa] = pb;

                if (rank[pa] == rank[pb]) {
                    rank[pb]++;
                }
            }
            return true;
        };

        Int size(Int x) {
            const auto px = find(x);
            return -parent[px];
        }

        bool is_same(Int a, Int b) {
            const auto pa = find(a);
            const auto pb = find(b);
            return pa == pb;
        }

    };
}
using namespace Xel_UFF;



using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N, M;
    cin >> N >> M;
    if(!cin) return;
    vector<int> A, B;
    for (int i = 0; i < M; ++i) {
        int tmp, tmp2;
        cin >> tmp >> tmp2;
        tmp--; tmp2--;
        A.push_back(tmp);
        B.push_back(tmp2);
    } // end i
    vector<ll> huben;
    huben.push_back(0);
    UFF uft(N);
    ll sum = 0;
    for (int i = M - 1; i >= 0; --i) {
        ll a_size = uft.size(A[i]);
        ll b_size = uft.size(B[i]);

        if(uft.unite(A[i], B[i])){
            sum += a_size * b_size;
        }
        huben.push_back(sum);
    } // end i
    ll kaiteki = huben.back();
    for (int i = M - 1; i >= 0; --i) {
        cout << kaiteki - huben[i] << endl;
    } // end i





}

int main(int argc, char *argv[]) {
    string FileName("A"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    // /home/USER/.../MEPH_X -> MEPH_X
    if (sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size() - ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
         solve(cin);
}


Measured memory_bytes: 3824
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

class Printable a where
  format :: a -> String

instance Printable Int where
  format = show

instance Printable Integer where
  format = show

instance Printable Double where
  format = show

instance Printable Float where
  format = show

instance Printable Char where
  format = show

instance Printable String where
  format x = x

instance Printable Bool where
  format = show

put :: Printable a => a -> IO ()
put = putStr . format

putLn :: Printable a => a -> IO ()
putLn = putStrLn . format

putList :: Printable a => [a] -> IO ()
putList [a] = put a
putList (a:as) = do
  put a
  putStr " "
  putList as

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [n, i] <- readInt
  put $ n - i + 1


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

int main() {
	int N, K;
	cin >> N >> K;
	int a = 1;
	for (int i = 0;i < N;i++) {
		int b, c;
		b = 2 * a;
		c = a + K;
		if (b >= c) {
			a = c;
		}
		else {
			a = b;
				
		}
	}
	cout << a << endl;
}

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

int main(void){
    int N,A,B,C;
    cin>>N>>A>>B>>C;
    vector<int> l(N);

    int ans = 1000000000;
    for (int i=0;i<N;i++) cin>>l[i];

    //bit全探索みたいなのを4進数でやりたい
    for (ll i=0;i<pow(4,N);i++){
        ll qq=i;
        vector<int> useA,useB,useC;

        //4進数の桁が0=>その竹を使わない
        //1=>Aの材料,2=>Bの材料,3=>Cの材料にする
        for (int j=0;j<N;j++){
            int use=qq%4;
            qq/=4;
            switch(use){
                case 1:useA.push_back(l[j]);break;
                case 2:useB.push_back(l[j]);break;
                case 3:useC.push_back(l[j]);break;
                default: break;
            }
        }

        //A,B,Cどれかに材料がなかったらcontinue
        if (useA.size()==0) continue;
        if (useB.size()==0) continue;
        if (useC.size()==0) continue;

        int aa=0,bb=0,cc=0; //材料の竹の長さの合計
        int mpA=0,mpB=0,mpC=0; //それぞれの竹を作るのに使うmp

        //まず材料の竹をすべて合成する
        for (int j=0;j<useA.size();j++) aa+=useA[j];
        mpA+=(useA.size()-1)*10;
        for (int j=0;j<useB.size();j++) bb+=useB[j];
        mpB+=(useB.size()-1)*10;
        for (int j=0;j<useC.size();j++) cc+=useC[j];
        mpC+=(useC.size()-1)*10;

        //延長or短縮の魔法を使う
        mpA+=abs(aa-A);
        mpB+=abs(bb-B);
        mpC+=abs(cc-C);

        int cost=mpA+mpB+mpC;
        //cout<<cost<<" "<<aa<<" "<<bb<<" "<<cc<<" ";
        //cout<<mpA<<" "<<mpB<<" "<<mpC<<endl;
        if (i==0) ans=cost;
        else ans=(ans<cost)?ans:cost;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;


public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		m.input();
		m.solve();
		m.output();
	}
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	/*/
	InputUtil in = new InputUtil();
	PrintWriter out = new PrintWriter(System.out);
	//*/
	int N = 0;
	int M = 0;
	int ans = 0;
	
	public void input() throws IOException {
		/*
		S = br.readLine();
		/*/
		N = in.nextInt();
		M = in.nextInt();
		//*/
	}

	public void solve() throws IOException {
		ans = (1900*M + 100*(N-M))*pow2(M);
	}
	
	private int pow2(int m){
		int ret = 1;
		for(int i=0; i<m; i++){
			ret *= 2;
		}
		return ret;
	}

	public void output() {
		out.println(ans);
		out.flush();
		
	}
}


//*
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}
}
//*/


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

using namespace std;

#define ll long long
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef set<int> si;
typedef set<vi> svi;
typedef set<ll> sll;
typedef set<vll> svll;
typedef set<pii> spii;
typedef set<vpii> svpii;
typedef set<pll> spll;
typedef set<vpll> svpll;
typedef vector<si> vsi;
typedef vector<sll> vsll;
typedef vector<spii> vspii;
typedef vector<spll> vspll;
#define ft first
#define sc second
#define pb push_back
#define ins insert
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define sortarr(a,n) sort(a,a+n)
#define tt ll tc; cin >> tc; while(tc--)
#define rep(var,start,end,interval) for(ll var=start;(interval>0 and var<end) or (interval<0 and var>end);var+=interval)
#define each(x,v) for(auto x : v)
#define takearr0(a,n) rep(z,0,n,1) cin >> a[z];
#define takearr1(a,n) rep(z,1,n+1,1) cin >> a[z];

const ll max_n = 3e5 + 5;

ll h,w,m;
spll s,s1,s2;

int main()
{
	io;
	cin >> h >> w >> m;
	while(m--)
	{
		ll x,y;
		cin >> x >> y;
		s.ins({x,y});
		s1.ins({x,y});
		s2.ins({x,y});
	}
	vll fr(h+1,0),fc(w+1,0);
	vpll to_del;
	each(p,s) ++fr[p.ft];
	ll r = 0,mx = 0;
	rep(i,0,h+1,1)
	{
		if(fr[i] > fr[r])
			r = i;
	}
	ll ans1 = 0;
	each(p,s) if(p.ft == r) to_del.pb(p);
	each(p,to_del) s1.erase(p);
	ans1 += to_del.size();
	each(p,s1) ++fc[p.sc];
	each(x,fc) mx = max(mx,x);
	ans1 += mx;
	fr.assign(h+1,0);
	fc.assign(w+1,0);
	to_del.clear();
	each(p,s) ++fc[p.sc];
	ll c = 0;
	mx = 0;
	rep(i,0,w+1,1)
	{
		if(fc[i] > fc[c])
			c = i;
	}
	ll ans2 = 0;
	each(p,s) if(p.sc == c) to_del.pb(p);
	each(p,to_del) s2.erase(p);
	ans2 += to_del.size();
	each(p,s2) ++fr[p.ft];
	each(x,fr) mx = max(mx,x);
	ans2 += mx;
	cout << max(ans1,ans2) << endl;
	return 0;
}

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

#define dk23      ios_base :: sync_with_stdio(false);
#define inp       freopen("input.txt","r",stdin);

int main()
{
    dk23

    string s,t;
    cin>>s>>t;
    string ans=t+s;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
*	created: 16.08.2020 15:02:05
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#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++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = LLONG_MAX;
const int MOD = 1000000007;
// const int MOD = 998244353;

int dp[MAX];

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    vector<int> h(n);
    rep(i,n) {
        cin >> h[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    rep(i,n) {
        chmin(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
        chmin(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4788
#include <iostream>
#include <vector>
#include <algorithm>

int main(void) {
	// in
	int n, m;
	std::cin >> n >> m;
	std::vector<int> x(m);
	for(int i = 0; i < m; ++i) std::cin >> x[i];

	// sort
	std::sort(x.begin(), x.end());
	
	int ans = 0;
	// if n >= m then ans = 0
	if(n >= m) ans = 0;
	else {
		// if n < m
		std::vector<int> dx(m-1);
		for(int i = 0; i < m-1; ++i) dx[i] = x[i+1] - x[i];
		std::sort(dx.begin(), dx.end());
	
		for(int i = 0; i < m - n; ++i) {
			ans += dx[i];
		}
	}
	
	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int a, b;
	int MAX, MIN;
	int kari;
	cin >> a >> b;
	MAX = max(a, b);
	MIN = min(a, b);
	while (1) {
		if (MAX % MIN == 0) {
			break;
		} else {
			kari = MAX % MIN;
			MAX = max(MIN, kari);
			MIN = min(MIN, kari);
		}
	}
	cout << MIN << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
int main()
{
    ll n,p;
    cin >> n >> p;
    ll ans=1,t=p;
    ll cnt=0,mod=2;
    while(mod*mod<=t&&p)
    {
        if (p%mod==0)
        {
            cnt++;
            p/=mod;
        }else
        {
            ans*=pow(mod,cnt/n);
            cnt=0,mod++;
        }
    }
    if (p!=0&&n==1) ans*=p;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>

class UnionFind{
public:
    UnionFind(int N):parent(N), rank(N,0), size(N,1){
        for(int i=0;i<N;++i) parent[i]=i;
    }
    int find(int x){
        return x==parent[x]?x:parent[x]=find(parent[x]);
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    void unite(int x,int y){
        x=find(x), y=find(y);
        if(x==y) return;
        if(rank[x]==rank[y]) parent[y]=x, rank[x]++;
        else{
            if(rank[x]<rank[y]) std::swap(x,y);
            parent[y]=x;
        }
        size[x]+=size[y];
        size[y]=0;
    }
    int getParentSize(int x){
        return size[find(x)];
    }
    int getSize(int x){
        return size[x];
    }
private:
    std::vector<int> parent, rank, size;
};

#include<iostream>
using namespace std;
int main(){
    int N,Q;
    cin>>N>>Q;
    UnionFind UF(N);
    for(int i=0;i<Q;++i){
        int c,x,y;
        cin>>c>>x>>y;
        if(c) cout<<UF.same(x,y)<<endl;
        else UF.unite(x,y);
    }
}

Measured memory_bytes: 3220
#include<stdio.h>

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(((r<=y)&&(y<=(H-r)))&&((r<=x)&&(x<=(W-r)))){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
return 0;

}

Measured memory_bytes: 584
N,Q=map(int, input().split())
node_lst=[list(map(int, input().split())) for i in range(N-1)]
ope_lst=[list(map(int, input().split())) for i in range(Q)]
cnt_lst=[0 for i in range(N)]
for ope in ope_lst:
    p, x = ope[0], ope[1]
    cnt_lst[p-1]+=x
node_lst=sorted(node_lst, key=lambda x:x[0])
for l in node_lst:
    src, dst = l[0]-1, l[1]-1
    cnt_lst[dst]+=cnt_lst[src]
print(" ".join([str(c) for c in cnt_lst]))

Measured memory_bytes: 125412
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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







int main() {
    double t, x;
    scanf("%lf %lf", &t, &x);
    printf("%.4lf\n", t / x);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 201  //check the limits, man
int ad[N][N];
int color[N];
int valid=1;
void dfs(int s,int n)
{
    int i;
    rep(i,n)
    {
        if(ad[s][i])
        {
            if(color[i]==color[s])
                valid=0;
            else if(color[i]==0)
                color[i]=3-color[s],dfs(i,n);
        }
    }
}
void floyd(int n)
{
    int i,j,k;
    rep(k,n)
    {
        rep(i,n)
        {
            rep(j,n)
                ad[i][j]=min(ad[i][j],ad[i][k]+ad[k][j]);
        }
    }
    return ;
}
int main()
{
    int n,i,j,k;
    in(n);
    string str;
    rep(i,n)
    {
        cin >> str;
        rep(j,n)
            if(str[j]=='1')ad[i][j]=1;
    }
    color[0]=1;
    dfs(0,n);
    if(!valid)
    {
        out(-1);
        return 0;
    }
    rep(i,n)
    {
        rep(j,n)
        {
            if(i!=j && ad[i][j]==0)
                ad[i][j]=N;
        }
    }
    floyd(n);
    k=0;
    rep(i,n)
    {
        rep(j,n)
            k=max(k,ad[i][j]);
    }
    out(k+1);
}




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

using namespace std;
typedef long long ll;

int main() {
  int r,d,x;
  cin >> r >> d >> x;

  for(int i=0; i<10; i++){
    int xx = r*x-d;
    cout << xx << "\n";
    x = xx;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n,n1,n2,n3,n4;
    scanf("%d",&n);
    n4=n%10;
    n=n/10;
    n3=n%10;
    n=n/10;
    n2=n%10;
    n1=n/10;
    if(n1==n2&&n2==n3||n2==n3&&n3==n4||n1==n2&&n2==n3&&n3==n4)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}




Measured memory_bytes: 128
#include <stdio.h>

int main(void){
  long long int L, R, a, b, min, c;
  scanf("%lld %lld", &L, &R);
  if(R - L > 2019) {
    printf("0");
    return 0;
  }
  else {
  a = L % 2019;
  b = R % 2019;
  min = 2019;
  int i, j;
  for(i=a; i<b; i++){
    for(j=i+1; j<=b; j++){
      c = (i*j) % 2019;
      if(c < min) min = c;
    }
  }
  
  printf("%lld\n", min);
  }
  return 0;
}

Measured memory_bytes: 128
H,W= list(map(int,input().split()))
M = []

for i in range(H):
    M.append(list(input()))

Hs = []
for i in range(H):
    flag = 0
    for j in range(W):
        if M[i][j]!=".":
            flag = 1
    if flag==1:
        Hs.append(i)

Ws = []
for j in range(W):
    flag = 0
    for i in range(H):
        if M[i][j]!=".":
            flag = 1
    if flag==1:
        Ws.append(j)

for i in Hs:
    out = []
    for j in Ws:
        out.append(M[i][j])
    print("".join(out))


Measured memory_bytes: 39280
#include <bits/stdc++.h>
#include <cstdlib>
#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() {
    int k;
    int n;
    int max_n = 0;
    int ans;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    vector<int> d(n);
    rep(i, n) {
        if (i == 0) {
            d[0] = a[0] + (k - a[n-1]);
        } else {
            d[i] = a[i] - a[i-1];
        }
    }
    rep(i, n) {
        max_n = max(max_n, d[i]);
    }
    ans = k - max_n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    string s;
    cin >> s;
    int ans[s.size()] = {};
    int ans_r[s.size()] = {};
    int ans_l[s.size()] = {};

    int n = s.size();
    int size = s.size();
    int r_count = 1;
    repd(i, 1, size) {
        if (s[i] == 'R') {
            r_count++;
        }
        if (s[i - 1] == 'R' && s[i] == 'L') {
            ans_r[i - 1] = r_count;
            r_count = 0;
        }
    }

    int l_count = 1;
    repd(i, 1, size) {
        int index = size - i - 1;
        if (s[index] == 'L') {
            l_count++;
        }
        if (s[index + 1] == 'L' && s[index] == 'R') {
            ans_l[index + 1] = l_count;
            l_count = 0;
        }
    }

    rep(i, n) {
        int temp = ans_r[i] / 2;
        ans[i] += ans_r[i] - temp;
        ans[i + 1] += temp;
    }
    rep(i, n) {
        int temp = ans_l[i] / 2;
        ans[i] += ans_l[i] - temp;
        ans[i - 1] +=temp;
    }

    //rep(i, s.size()) { cout << ans_r[i] << " "; }
    //cout << endl;
    //rep(i, s.size()) { cout << ans_l[i] << " "; }
    //cout << endl;
    rep(i, s.size()) { cout << ans[i] << " "; }
    cout << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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


def ok(l):
    cnt = 0
    for L in a:
        cnt += L // l
        if L % l != 0:
            cnt += 1
        cnt -= 1
    return cnt <= k

#bottom:ng, top:ok
bottom, top = 0, max(a)

while top - bottom > 1:
    mid = (top + bottom) // 2
    if ok(mid):top = mid
    else: bottom = mid

print(top)


Measured memory_bytes: 30768
/*
**   Contest : AtCoder Beginner Contest 165
**   Problem : D - Floor Function
**
**    Author : Dhiraj Govindvira
**      Date : 03-May-2020 ~ Sunday
**      Time : 10:30:45 AM
*/

#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
#endif

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Extra --------------------------------------------------------------------

#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double
#define endl                '\n'
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Template -----------------------------------------------------------------

template <typename T> 
inline bool inrange(T a, T l, T r) {
    if(l>r) swap(l,r);
    return (a>=l and a<=r);
}
template <typename T, typename U> 
inline bool exist(T val, U &any) {
    return (any.find(val) != any.end());
}
// multiple input
template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll a, b, n;
    inp(a,b,n);

    n = min(n,b-1);
    std::cout<<((a*n/b)-a*(n/b))<<endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int t = 1;
    loop(i,1,t+1)
    {
        cerr<<"Case #"<<i<<"\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 205;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, k, P, fac[MAXN], inv[MAXN];
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int binom(int x, int y) {
	if (y > x) return 0;
	else return 1ll * fac[x] * inv[y] % P * inv[x - y] % P;
}
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = 1ll * fac[i - 1] * i % P;
	inv[n] = power(fac[n], P - 2);
	for (int i = n - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1ll) % P;
}
int solve(int n, int k) {
	int ans = 0;
	for (int deg = 1; deg <= k && deg <= n - 2; deg++) {
		static int dp[MAXN][MAXN];
		if ((n - 1) - deg > k) continue;
		memset(dp, 0, sizeof(dp));
		dp[0][deg] = 1, dp[0][deg + 1] = P - 1;
		for (int i = 0; i <= deg - 1; i++)
		for (int j = deg; j <= n - 1; j++) {
			update(dp[i][j], dp[i][j - 1]);
			int tmp = dp[i][j], l = max(max(j, i + 2), n + i - k), r = min(n - 1, k + (i + 1));
			if (l <= r) update(dp[i + 1][l], tmp), update(dp[i + 1][r + 1], P - tmp);
		}
		for (int i = deg; i <= n - 1; i++) {
			update(dp[deg][i], dp[deg][i - 1]);
			update(ans, dp[deg][i]);
		}
	}
	return 1ll * ans * fac[n - 1] % P;
}
int main() {
	read(n), read(k), read(P);
	init(n); int ans = (k == n - 1) ? fac[n] : 0;
	for (int i = 3; i <= n; i++)
		update(ans, 1ll * fac[n] * inv[i] % P * solve(i, k - (n - i)) % P);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3792
"use strict";

const main = arg => {
    // 標準入力の不要な空白と改行を削除し、配列に格納する
    const input = arg.trim().split(" ");

    if (input[0] === 'AAA' || input[0] === 'BBB') {
        console.log('No');
    }else{
        console.log("Yes");
    }

}

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

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

vector<vector<int>> g(200010);
ll cnt[200010];

void dfs(int now, int from) {
    for (auto to : g[now]) {
        if (to == from) continue;
        cnt[to] += cnt[now];
        dfs(to, now);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    rep(i, 0, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    rep(i, 0, q) {
        int p, x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }

    dfs(0, -1);

    rep(i, 0, n) cout << cnt[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 24320
Z='RUBY_THREAD_VM_STACK_SIZE';ENV[Z]||(require'rubygems';exec({Z=>'50000000'},Gem.ruby,$0));def f(i)a=H[i].map{|e|f e}.sort_by(&:-@);r=0;a.size.times{|i|x=a[i]+i+1;r<x&&r=x};r end;N=gets.to_i;H=Hash.new{|h,k|h[k]=[]};(N-1).times{|i|H[gets.to_i-1]<<i+1};p f 0

Measured memory_bytes: 225284
#include <bits/stdc++.h>
#define ll long long
#define N 100005
#define f first
#define s second
using namespace std;
int main() {
    ll a,b;
    cin>>a>>b;
    if(a<10 && b<10)
        cout<<a*b;
    else cout<<-1;
    return 0;
}


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

int main(){
    int N,D;
    cin >> N >> D;
    int X[N][D];
    for(int n=0; n<N; n++){
        for(int d=0; d<D; d++){
            cin >> X[n][d];
        }
    }
    int count = 0;
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            double kyori=0;
            for(int d=0; d<D; d++){
                kyori += (X[i][d]-X[j][d])*(X[i][d]-X[j][d]);
            }
            kyori = sqrt(kyori);
            if(floor(kyori) == kyori){
                count ++;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256