akhauriyash/Code-Regression huggingface dataset:
n, d, a = [int(i) for i in input().split()]

xh = []
for i in range(n):
    xh.append([int(i) for i in input().split()])

# 座標でソート
xh.sort()
x = [xh[i][0] for i in range(n)]
h = [xh[i][1] for i in range(n)]

# i番目のモンスターに、i-k番目で使った爆弾が届いた場合の最小のi-k
# bisectより尺取り法のほうが圧倒的に速いだろjk
bomb_syakutori = [0 for i in range(n)]
l = 0
r = 0
flag = 0
while r <= n - 1:
    if x[r] <= x[l] + 2*d:
        bomb_syakutori[r] = l
        r += 1
    else:
        l += 1


bomb_ruisekiwa = [0 for i in range(n)]
# 左から貪欲に爆弾を使用
for i in range(n):
    bomb = 0
    if i == 0:
        bomb = (h[i]) // a + ((h[i]) % a != 0)
        bomb_ruisekiwa[i] = bomb
    else:
        if bomb_syakutori[i] == i:
            damage = 0
        elif bomb_syakutori[i]-1 < 0:
            damage = (bomb_ruisekiwa[i-1]) * a
        else:
            damage = (bomb_ruisekiwa[i-1] - bomb_ruisekiwa[bomb_syakutori[i]-1]) * a
        if h[i] - damage > 0:
            bomb = (h[i] - damage) // a + ((h[i] - damage) % a != 0)
        bomb_ruisekiwa[i] = bomb + bomb_ruisekiwa[i-1]

print(bomb_ruisekiwa[-1])

Measured memory_bytes: 101436
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){

	vector<int> a(7);
	for(int i=0; i<7; i++) cin >> a[i];

	vector<int> b = a;
	vector<int> c = a;

	long long int ans = a[1];

	
	long long int tmp = 0;
	if( a[0]%2 == 0 ) tmp += a[0];
	else tmp += (a[0]-1);

	if( a[3]%2 == 0 ) tmp += a[3];
	else tmp += (a[3]-1);
	
	if( a[4]%2 == 0 ) tmp += a[4];
	else tmp += (a[4]-1);
	
	if( a[0]%2 == 1 && a[3]%2 == 1 && a[4]%2 == 1 ) tmp += 3;

	long long int tmp2 = 0;
	long long int q = min(b[0], min(b[3], b[4]));
	tmp2 += q * 3;
	b[0] -= q;
	b[3] -= q;
	b[4] -= q;
	if( b[0]%2 == 0 ) tmp2 += b[0];
	else tmp2 += (b[0]-1);

	if( b[3]%2 == 0 ) tmp2 += b[3];
	else tmp2 += (b[3]-1);
	
	if( b[4]%2 == 0 ) tmp2 += b[4];
	else tmp2 += (b[4]-1);
	
	if( b[0]%2 == 1 && b[3]%2 == 1 && b[4]%2 == 1 ) tmp2 += 3;


	if( c[0] > 0 && c[3] > 0 && c[4] > 0 ){
		long long int tmp3 = 0;
		tmp3 += 1 * 3;
		c[0] -= 1;
		c[3] -= 1;
		c[4] -= 1;
		if( c[0]%2 == 0 ) tmp3 += c[0];
		else tmp3 += (c[0]-1);

		if( c[3]%2 == 0 ) tmp3 += c[3];
		else tmp3 += (c[3]-1);
	
		if( c[4]%2 == 0 ) tmp3 += c[4];
		else tmp3 += (c[4]-1);
	
		if( c[0]%2 == 1 && c[3]%2 == 1 && c[4]%2 == 1 ) tmp3 += 3;
		tmp2 = max(tmp2, tmp3);
	}

	ans += max(tmp, tmp2);

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MAX_N 210000

template<typename T>
class SegTree{
public:
    int n;
    T dat[2 * MAX_N - 1];

    void init(int n_, T init_num){
        n = 1;
        while(n < n_) n *= 2;
        for(int i = 0; i < 2*n-1; i++){
            dat[i] = init_num;
        }
    }

    // k番目の値(0-indexed)をaに変更
    void update(int k, T a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }

    // [a, b)の最小値を求める。
    // kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。
    // query(a, b, 0, 0, n)で外からは呼び出す。
    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return MAX_N+1;
        }

        if (a <= l && r <= b) {
            return dat[k];
        } else {
            ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};

int main(){
    int n, m;
    cin >> n >> m;

    SegTree<int> st;
    st.init(n+1, MAX_N+1);

    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        int q = st.query(a, a+1, 0, 0, st.n);
        if(b < q){
            st.update(a, b);
        }
    }

    int res = 0;
    int x = 0;
    while(x < n){
        int q = st.query(x, n+1, 0, 0, st.n);
        if(q == MAX_N+1){
            break;
        }
        res++;
        x = q;
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 1280
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, a: "List[int]", b: "List[int]"):
    A_sum = sum(a)
    B_sum = sum(b)
    if A_sum > B_sum:
        print(NO)
        return
    
    dif = [a[i]-b[i] for i in range(N)]
    one = 0
    two = 0
    for i in range(N):
        if dif[i] > 0:
            one += dif[i]
        if dif[i] < 0:
            two += -(dif[i]//2)
    
    if max(one,two) > B_sum-A_sum:
        print(NO)
    else:
        print(YES)
    # minimum_operations = []

    # for i in range(N):
    #     if dif[i] >= 0:
    #         minimum_operations.append(dif[i])
    #     else:
    #         minimum_operations.append(-(dif[i]//2))

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4980
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n, m = LI()
    if n == m:
        print("Yes")
    else:
        print("No")

main()



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

int index(char c){
	return c - '0';
}

int get_num(string num){
	int c = 0;
	int n = 1;
	for(string::reverse_iterator riter = num.rbegin();
		riter != num.rend(); riter++)
	{
		c += n * index(*riter);
		n = n * 10;
	}
	return c;
}

int main(){
	string s;
	int nums[50];
	vector<string> vs;
	vector<vector<int> > area;
	while(getline(cin, s)) vs.push_back(s);
	int n = vs.size();
	for(vector<string>::iterator iter = vs.begin();
		iter != vs.end(); iter++)
	{
		vector<int> vi;
		for(string::iterator siter = (*iter).begin();
			siter != (*iter).end(); siter++)
		{
			string num;
			while(siter != (*iter).end() && isdigit(*siter)) num.push_back(*(siter++));
			vi.push_back(get_num(num));
			if(siter == (*iter).end()) break;
		}
		area.push_back(vi);
	}

	for(int k = 0; k < 50; k++){
		nums[k] = 0;
	}
	nums[0] = area[0][0];
	int i = 1;
	while(i <= (n / 2)){
		nums[i] = nums[i - 1] + area[i][i];
		for(int j = i - 1; j > 0; j--){
			nums[j] = max(nums[j], nums[j-1]) + area[i][j];
		}
		nums[0] = nums[0] + area[i][0];
		i++;
	}
	while(i < n){
		for(int j = 0; j < n - i;j++){
			nums[j] = max(nums[j], nums[j+1]) + area[i][j];
		}
		i++;
	}
	cout << nums[0] << endl;
	return 0;
}

Measured memory_bytes: 0
import math as mt
x = int(input())
if x == 2:
    ans = 2
else:
    over = int(mt.sqrt(x))+1
    
    for i in range(x,x+100):
        rpf = True
        for j in range(2,over):
            if i % j == 0:
                rpf = False
                break
        if rpf == True:
            ans = i
            break
        over += 1
print(ans)

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

#define A first
#define B second

const ll MAXN = 1e5+5;

ll n, k;
ll a[MAXN], p[MAXN], u[MAXN], d[MAXN];
ll b[MAXN];

set<pii> s;

//set all of [l, r] -> v
void upd(ll l, ll r, ll v) {
    if (l < 0 || r < 0 || l >= k || r >= k) {
        upd((l%k+k)%k, (r%k+k)%k, v);
        return;
    }
    if (l > r) {
        upd(l, k-1, v);
        upd(0, r, v);
        return;
    }
    auto it = s.upper_bound(pii(r+1, 1<<30));
    it--;
    ll x = (*it).B;
    while (true) {
        it = s.lower_bound(pii(l, -1));
        if ((*it).A <= r) {
            s.erase(it);
        } else
            break;
    }
    s.insert(pii(l, v));
    s.insert(pii(r+1, x));
}

ll query(ll v) {
    v = (v%k+k)%k;
    auto it = s.upper_bound(pii(v, 1<<30));
    it--;
    return (*it).B;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n >> k;
    for (ll i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        if (2*a[i] > k && b[i] == 1) {
            cout << "-1\n";
            return 0;
        }
    }

    //do the up dp
    p[0] = 0;
    for (ll i = 0; i < n; ++i)
        p[i+1] = p[i] + 2*a[i];
    u[0] = 0;
    s.insert(pii(0, 0));
    s.insert(pii(k, 0));

    for (ll i = 1; i <= n; ++i) {
        ll x = query(-p[i]);
        if (x == 0) {
            u[i] = p[i];
        } else {
            u[i] = (p[i]-p[x])/k*k + k + u[x];
        }

        if (b[i-1] == 1) {
            upd(-p[i] + 1, -p[i]+2*a[i-1]-1, i);
        }
    }

    s.clear();
    s.insert(pii(0, n));
    s.insert(pii(k, n));
    p[n] = 0;
    for (ll i = n-1; i >= 0; --i)
        p[i] = p[i+1] + 2*a[i];
    d[n] = 0;

    for (ll i = n-1; i >= 0; --i) {
        ll x = query(-p[i]);
        if (x == n) {
            d[i] = p[i];
        } else {
            d[i] = (p[i]-p[x])/k*k + k + d[x];
        }

        if (b[i] == 1) {
            upd(-p[i]+1, -p[i] + 2*a[i] - 1, i);
        }
    }

    ll ans = (1LL << 60);
    for (ll i = 0; i <= n; ++i)
        ans = min(ans, u[i] + d[i]);
    cout << ans << endl;
}

Measured memory_bytes: 16512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 5005
int d[N],k,a[N];
void work()
{
	int n=read(),x=read(),m=read();
	x%=m; int sum=0;
	int ze=0;
	for(int i=1;i<=k;i++) a[i]=d[i]%m,sum+=a[i];
	for(int i=1;i<=k;i++) if(a[i]==0) ze++;
	int r=(n-1)/k;
	int ans=r*sum+x;
	ze*=r;
	for(int i=r*k+1;i<n;i++) ans+=a[i%k];
	for(int i=r*k+1;i<n;i++) if(a[i%k]==0) ze++;
//	cout<<ans<<endl;
	printf("%lld\n",n-ans/m-1-ze);
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int Q;
	cin>>k>>Q;
	for(int i=1;i<=k;i++) d[i]=read();
	while(Q--) work();
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



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


void solve_case()
{
    int n,i,j,t,k,m;
    map<string, int> cnt;
    cin >> n;
    while(n--)
    {
        string s;
        cin >> s;
        cnt[s]++;
    }
    cout << "AC x " << cnt["AC"] << "\n";
    cout << "WA x " << cnt["WA"] << "\n";
    cout << "TLE x " << cnt["TLE"] << "\n";
    cout << "RE x " << cnt["RE"] << "\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int Testcases = 1;
    //cin >> Testcases;
    while(Testcases--)
    {
        solve_case();
    }
    return 0;
}


Measured memory_bytes: 3672
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int):
    from itertools import chain
    from collections import Counter
    from functools import reduce
    pu = PrimeUtil(N+1)
    c = Counter(chain.from_iterable(pu.factor_iter(i) for i in range(2, N+1)))
    return reduce(lambda a,b: a*(b+1)%MOD, c.values(), 1)

class PrimeUtil:

    def __init__(self, size):
        self.size = size
        self._init_table()
  
    def _init_table(self):
        from itertools import takewhile
        self._is_prime = [True] * self.size
        self._is_prime[0] = False
        self._is_prime[1] = False
        for i in takewhile(lambda x: x*x<=self.size, range(self.size)):
            if not self._is_prime[i]:
                continue
            for j in range(i+i, self.size, i):
                self._is_prime[j] = False

    def prime_iter(self):
        return filter(lambda x: self._is_prime[x], range(self.size))

    def primes(self):
        return tuple(self.prime_iter())

    def factor_iter(self, n):
        from itertools import takewhile
        m = n
        for p in self.prime_iter():
            while m % p == 0:
                yield p
                m //= p
            if m == 1:
                return
    
    def factors(self, n):
        return tuple(self.factor_iter(n))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

using namespace std;

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

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define INF 10000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;
ll a[200001],b,n,z,x,c,s,t;
int main()
{
    fast;
    ll k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i],s+=a[i];
    sort(a+1,a+1+n);
    reverse(a+1,a+1+n);
    for(int i=1;i<=k;i++)s-=a[i];
    cout<<s<<endl;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	score := make(map[string]int)
	max := 0
	for i := 0; i < n; i++ {
		s := eGetLine(scanner)
		score[s]++
		if score[s] > max {
			max = score[s]
		}
	}
	words := make([]string, 0)
	for k, v := range score {
		if v == max {
			words = append(words, k)
		}
	}
	sort.Strings(words)
	for _, v := range words {
		fmt.Println(v)
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	return int(math.Pow(float64(a), float64(n)))
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}


Measured memory_bytes: 30848
#include <stdio.h>

int main()
{
	char A, B, C;
	scanf("%c%c%c", &A, &B, &C);
	
	if(A==B && B==C && C==A)
	{
		printf("No");
	}
	else if(A==B || B==C || C==A)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 1656
n,y = map(int,input().split())

for i in range(min(y//10000+1,n+1)):
    for j in range(n-i+1):
        k = n-i-j
        if 10000*i+5000*j+1000*k==y and k>=0:
            print(i,j,k)
            exit()

print(-1,-1,-1)

Measured memory_bytes: 3060
#include<iostream>
#include <cstdio>

using namespace std;

int main(){
	//Cramer's Rule
	double a, b, c, d, e, f;

	while(cin >> a >> b >> c >> d >> e>> f) {
		printf("%.3f %.3f\n", (e * c - b * f) / (a * e - b * d) + 0, (a * f - c * d) / (a * e - b * d) + 0);
	}
	return 0;
}

Measured memory_bytes: 1236
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(05)V9(15).
        01 B PIC 9(05)V9(15).
      	01 C PIC 9(05)V9(15).
      	01 E PIC 9(05)V9(15).
      	01 D PIC ZZZZZZZZZ.
      	01 X PIC 9(15).
      	01 Y PIC 9(15).
      	01 W PIC 9(15).
      	01 F PIC 9(10).
      	01 t PIC 9(15).
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
      	01 temp3 PIC 9(15).
        01 N PIC 9(15).
        PROCEDURE DIVISION.
      	MAIN.
      		ACCEPT INP.
			PERFORM VARYING temp1 FROM 1 BY 1
            UNTIL INP(temp1:1) = SPACE
        	END-PERFORM.
        	SUBTRACT 1 FROM temp1.
        	MOVE INP(1:temp1) TO A.
        	ADD 2 TO temp1.
        	PERFORM VARYING temp2 FROM temp1 BY 1
            UNTIL INP(temp2:1) = SPACE
        	END-PERFORM.
        	COMPUTE N = temp2 - temp1.
        	MOVE INP(temp1:N) TO B.
      		ADD 1 TO temp2.
      		PERFORM VARYING temp3 FROM temp2 BY 1
            UNTIL INP(temp3:1) = SPACE
        	END-PERFORM.
        	COMPUTE N = temp3 - temp2.
        	MOVE INP(temp2:N) TO C.
      		COMPUTE B = B * A.
      		IF B > C THEN
      			MOVE C to D
      			DISPLAY D
      		ELSE
      			MOVE B to D
      			DISPLAY D
      		END-IF.
		STOP RUN.

Measured memory_bytes: 384
#include "iostream"
using namespace std;

int main(void)
{
	int vac, jpn, math, jpn_d, math_d;
	cin >> vac >> jpn >> math >> jpn_d >> math_d;

	int jpnDay, mathDay;
	if ((jpn%jpn_d) == 0) {
		jpnDay = jpn / jpn_d;
	}else {
		jpnDay = jpn / jpn_d + 1;
	}
	if ((math%math_d) == 0) {
		mathDay = math / math_d;
	}else {
		mathDay = math / math_d + 1;
	}

	if (jpnDay > mathDay) {
		cout << vac - jpnDay << endl;
	}else {
		cout << vac - mathDay << endl;
	}
	return 0;
}

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

int cul(int A,int B);

int main(void){
	int A,B;
	double K,F;
	scanf("%d %d",&A,&B);
	K = cul(A,B);
	if(-1 != K){
		printf("%d\n",int(K));
	} else {
		printf("IMPOSSIBLE\n");
	}
	return 0;
}

int cul(int A,int B){
	double K,F;
	K = (double(A + B)) / 2.;
	if (0 == ceil(modf(K,&F))){
		K = F;
	} else {
		K = -1.;
	}
	return K;
}

Measured memory_bytes: 256
require "prime"

n = gets.to_i

c = Hash.new(0)
(1..n).each do |x|
  x.prime_division.each do |(factor, e)|
    c[factor] += e
  end
end

ans = 1
c.each_value do |e|
  ans *= e + 1
  ans %= 10 ** 9 + 7
end

p ans

Measured memory_bytes: 2300
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  n = int(input())
  S = [0] * n
  for i in range(n):
    S[i] = int(input())
    
  ans = sum(S)
  S = sorted(S)
  
  if ans % 10 == 0:
    for i in S:
      if (ans - i) % 10 != 0: # 最大値なので、sorted、昇順の最初から引いていくう！
        print(ans - i)
        exit()
    print(0)
  else:
    print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	ll tmp, sum = 0, min = 1e18, cnt = 0;
	bool zero = false;
	while(n--){
		scanf("%ld", &tmp);
		if(tmp<0) cnt++;
		if(tmp==0) zero = true;
		sum += labs(tmp);
		min = std::min(min, labs(tmp));
	}
	
	if(!zero and cnt%2) sum -= min*2;
	printf("%ld\n", sum);
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class Main {
	
	static boolean isPalindrome(String s) {
		StringBuilder res = new StringBuilder(s);
		String test = res.reverse().toString();
		if(test.compareTo(s) == 0)
			return true;
		else
			return false;
	}
	
	public static void main(String[] args) throws java.lang.Exception {
		MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      String s = sc.nextLine();
      
      if(isPalindrome(s) == true) {
    	  int n = s.length();
    	  String left = s.substring(0,(n - 1) / 2);
    	  String right = s.substring((n + 1) / 2, n);
    	  if(isPalindrome(left) == true && isPalindrome(right) == true)
    		  System.out.println("Yes");
    	  else
    		  System.out.println("No");
      }
      else
    	  System.out.println("No");
      
      
      
      out.close();
	}
	public static PrintWriter out;

	   public static class MyScanner {
	      BufferedReader br;
	      StringTokenizer st;
	 
	      public MyScanner() {
	         br = new BufferedReader(new InputStreamReader(System.in));
	      }
	 
	      String next() {
	          while (st == null || !st.hasMoreElements()) {
	              try {
	                  st = new StringTokenizer(br.readLine());
	              } catch (IOException e) {
	                  e.printStackTrace();
	              }
	          }
	          return st.nextToken();
	      }
	 
	      int nextInt() {
	          return Integer.parseInt(next());
	      }
	 
	      long nextLong() {
	          return Long.parseLong(next());
	      }
	 
	      double nextDouble() {
	          return Double.parseDouble(next());
	      }
	 
	      String nextLine(){
	          String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
	      }

	   }

      

}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e5+1000;
ll t,q,n;
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    string a;
    cin>>a;
    ll num1=0,num2=0;
    for(int i=0;i<n;i++){
        if(a[i]=='R') num1++;
    }
    for(int i=num1;i<n;i++){
        if(a[i]=='R') num2++;
    }cout<<num2<<endl;
    return 0;
}


Measured memory_bytes: 3668
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N = NI()
    A = NLI()
    
    L = [0 for _ in range(N)]
    L_gcd = 0
    for n in range(0,N-1):
        L_gcd = math.gcd(A[n],L_gcd)
        L[n+1] = L_gcd

    

    R = [0 for _ in range(N)]
    R_gcd = 0
    for n in range(N-1,-1,-1):
        R_gcd = math.gcd(A[n],R_gcd)
        R[n-1] = R_gcd
    R[-1] = 0

    
    ans = 0
    for n in range(N):
        ans = max(ans,math.gcd(L[n],R[n]))
    print(ans)
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 21416
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

int64_t n, m, a, stair[100001], i;
int64_t ndiv = 1000000007;

int main(void) {
    cin >> n >> m;
    for (i = 1; i <= m; i++) {
        cin >> a;
        stair[a] = -1;
    }
    stair[0] = 1;
    if (stair[1] == -1) {
        stair[1] = 0;
    } else {
        stair[1] = 1;
    }
    for (i = 2; i <= n; i++) {
        if (stair[i] == -1) {
            stair[i] = 0;
            continue;
        }
        stair[i] = stair[i-2]+stair[i-1];
        stair[i] %= ndiv;
    }
    cout << stair[n] << endl;
                  
    return 0;
}


Measured memory_bytes: 1152
<?php
fscanf(STDIN, "%d%d%d", $N, $M, $Q);
for($i = 0; $i <= $N; $i++){
  for($j = 0; $j <= $N; $j++){
    $map[$i][$j] = 0;
  }
}
for($i = 0; $i < $M; $i++){
  fscanf(STDIN, "%d%d", $L, $R);
  $map[$L][$R] += 1;
}
for($i = 1; $i <= $N; $i++){
  for($j = 1; $j <= $N; $j++){
    $map[$i][$j] = $map[$i][$j] + $map[$i][$j-1];
  }
}
for($i = 1; $i <= $Q; $i++){
  fscanf(STDIN, "%d%d", $L, $R);
  if(!isset($q[$L][$R])){
    $sum = 0;
    for($j = $L; $j <= $R; $j++){
      $sum += $map[$j][$R] - $map[$j][$L-1];
    }
    $q[$L][$R] = $sum;
  }
  echo $q[$L][$R],"\n";
}

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

#define int long long int
const int mxN = 100;                 
const int mxW = 1000000005;
const int mxV = 1000;          
int n, capc;
int dp[mxN+5][mxN*mxV + 5];                      //[max objects][max value sum]

void solve() {
    cin >> n >> capc;
    int val[n];
    int wt[n];

    int total_val = 0, ans = 0;

    for(int i=0; i<n; i++) {
        cin >> wt[i] >> val[i];
        total_val += val[i];                // this is when all the objects are included in the knapsack
    }

    dp[0][0] = 0;
    for (int i = 1; i <= total_val; i++) 
		dp[0][i] = 1e18;

    for(int i=0; i<n; i++) {
        for(int j=0; j<= total_val; j++) {
            
            if(j >= val[i]) {
                dp[i+1][j] = min(dp[i][j], dp[i][j-val[i]] + wt[i]);
            
            } else {
                dp[i+1][j] = dp[i][j];
            }

            if(dp[i+1][j] <= capc)
                ans = max(ans, j);
        }
    }

    cout << ans << endl;
}

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

    solve();
}

Measured memory_bytes: 80128
A = ['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']
B = ['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']
S = input()
if S in A:
    print('a')
elif S in B:
    print('A')


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

struct info{
    ll b, l, u, g;
    bool operator<(const info& another)const{
        return g > another.g;
    }
};

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

    ll N, X;
    cin >> N >> X;
    vector<info> infos(N);
    REP(i, N){
        ll b, l, u;
        cin >> b >> l >> u;
        info tmp = {b, l, u, u*(X-b)+b*l};
        infos.emplace_back(tmp);
    }
    sort(infos.begin(), infos.end());
    vector<ll> gs(N+1, 0);
    REP(i, N) gs[i+1] = gs[i] + infos[i].g;

    ll soko = 0;
    REP(i, N){
        soko += -infos[i].b * infos[i].l;
    }

    ll lb = -1, ub = 101010101010;
    while(ub-lb > 1){
        ll k = (ub+lb)/2;
        bool ok = false;
        ll q = k/X;
        ll r = k - X*q;
        if(q >= N){
            ok = true;
        }else{
            ll ma = -1;
            REP(i, N){
                ll sum = soko;

                if(r < infos[i].b) sum += infos[i].l * r;
                else sum += infos[i].l * infos[i].b + infos[i].u * (r - infos[i].b);

                if(i < q){
                    sum += gs[i] - gs[0];
                    sum += gs[q+1] - gs[i+1];
                }else{
                    sum += gs[q] - gs[0];
                }

                if(sum >= 0) ok = true;
            }
        }
        if(ok){
            ub = k;
        }else{
            lb = k;
        }
    }

    cout << ub << endl;

    return 0;
}

Measured memory_bytes: 8320
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int K = ni();
        int[] L = new int[K];
        int[] R = new int[K];
        for (int i = 0; i < K; i++) {
            L[i] = ni();
            R[i] = ni();
        }
        int[] dp = new int[N+1];
        dp[1] = 1;
        int countToi = 0;
        for (int i = 1; i < N; i++) {
            // System.out.println(Arrays.toString(dp));
            countToi = (countToi + dp[i]) % mod;
            for (int j = 0; j < K; j++) {
                if((i + L[j])<=N) dp[i+L[j]] = add(dp[i+L[j]], countToi);
                if((i + R[j]+1)<=N) dp[i+R[j]+1] = sub(dp[i+R[j]+1], countToi);
            }
        }
        // System.out.println(Arrays.toString(dp));
        long ans = dp[N];
        out.println(ans);
    }

    final int mod = 998244353;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

int main() {
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long res;
    if(a > 0 && b > 0 && c < 0 && d < 0) {
        res = min(a,b) * max(c,d);
    } else if(a < 0 && b < 0 && c > 0 && d > 0) {
        res = max(a,b) * min(c,d);
    } else {
        long long res1 = max(a,b) * max(c,d);
        long long res2 = min(a,b) * min(c,d);
        res =  max(res1, res2);
    }
    cout << res << endl;
}

Measured memory_bytes: 3628
N = int(input())
candies = [list(map(int, input().split())) for _ in range(2)]
dp = [[0] * (N) for _ in range(2)]
dp[0][0] = candies[0][0]
dp[1][0] = dp[0][0] + candies[1][0]
for i in range(1, N):
  dp[0][i] = dp[0][i-1] + candies[0][i]
  dp[1][i] = max(dp[0][i], dp[1][i-1]) + candies[1][i]
print(dp[1][N-1])


Measured memory_bytes: 3064
/// {{{ Author: Wang, Yen-Jen
// include
#include <bits/stdc++.h>

// using
using namespace std;

// types
typedef long long ll;
typedef pair<int,int> pii;

// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))

// input
inline bool SR(int &x) {
  return scanf("%d",&x) == 1;
}

inline bool SR(ll &x) {
  return scanf("%lld",&x) == 1;
}

inline bool SR(double &x) {
  return scanf("%lf",&x) == 1;
}

inline bool SR(char *s) {
  return scanf("%s",s) == 1;
}

inline bool RI() {
  return true;
}

template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
  return SR(x) && RI(tail...);
}

// output
inline void SP(const int x) {
  printf("%d",x);
}

inline void SP(const ll x) {
  printf("%lld",x);
}

inline void SP(const double x) {
  printf("%.16lf",x);
}

inline void SP(const char *s) {
  printf("%s",s);
}

inline void PL() {
  puts("");
}

template<typename I , typename... T> inline void PL(const I x , const T... tail) {
  SP(x);
  if(sizeof...(tail)) putchar(' ');
  PL(tail...);
}

// debug
#define WangYenJen

#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
  cerr << s << " = " << x << endl;
}

template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
  int c = 0;
  while(*s != ',' || c != 0) {
    if(*s == '(' || *s == '[' || *s == '{') c++;
    if(*s == ')' || *s == ']' || *s == '}') c--;
    cerr << *s++;
  }
  cerr << " = " << x << " , ";
  _DOING(s + 1 , tail...);
}

#define DEBUG(...) \
do {\
  fprintf(stderr , "%s: Line %d - ",__PRETTY_FUNCTION__,__LINE__);\
  _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);

#else
#define DEBUG(...)

#endif

// constant number
const int INF = 0x3f3f3f3f;
const ll INF64 = 0x3f3f3f3f3f3f3f3fll;

// random function
inline int RAND() {
  static int x = 880301;
  return (x = x * 0xdefaced + 1) % 0x7fffffff;
}
/// }}}

const int MAX_N = 100000 + 7;

int A[MAX_N];

int main() {
  int N;
  RI(N);
  REP(i, N) RI(A[i]);
  ll ans = 0;
  REP(i, N) {
    ans += A[i] / 2;
    A[i] %= 2;
    if (A[i] && i + 1 < N && A[i + 1]) {
      ans++;
      A[i]--;
      A[i + 1]--;
    }
  }
  PL(ans);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define re(i,n) for(i=0;i<n;i++)
#define bre(i,n) for(i=n;i>0;i--)
#define rep(i,l,r) for(i=l;i<r;i++)
#define brep(i,l,r) for(i=r;i>l;i--)
const int inf=1145141919810893;
const int mod=998244353;
using namespace std;
template<class T>bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<class T>bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
template<int H,int W>int wa(int x1,int y1,int x2,int y2,int(&p)[H][W]){
	return p[y2][x2]-p[y2][x1]-p[y1][x2]+p[y1][x1];
}
struct Unif{
	vector<int> e;
	vector<int> rank;
	Unif(int n):e(n,-1),rank(n,1){}
	void uni(int a,int b){
		if(e[a]!=-1)
			uni(e[a],b);
		else if(e[b]!=-1)
			uni(a,e[b]);
		else{
			if(a==b)
				return;
			int ra=rank[a],rb=rank[b];
			if(ra>=rb){
				e[b]=a;
				if(ra==rb)
					rank[a]++;
			}
			else
				e[a]=b;
		}
	}
	bool find(int a,int b){
		if(e[a]!=-1)
			return find(e[a],b);
		else if(e[b]!=-1)
			return find(a,e[b]);
		else
			return a==b;
	}
	int num(int a){
		if(e[a]!=-1)
			return num(e[a]);
		else
			return a;
	}
};
int A,B,C,D,N,M,K,S,T,H,W,Q,X,Y;
signed main(){
	cin>>A>>B>>C>>X>>Y;
	int ans=0;
	if(X>Y){
		if(A+B>C*2)
			ans+=Y*C*2;
		else
			ans+=Y*(A+B);
		if(A>C*2)
			ans+=(X-Y)*C*2;
		else
			ans+=(X-Y)*A;
	}
	else{
		if(A+B>C*2)
			ans+=X*C*2;
		else
			ans+=X*(A+B);
		if(B>C*2)
			ans+=(Y-X)*C*2;
		else
			ans+=(Y-X)*B;
	}
	cout<<ans<<endl;
}

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

int main(){
  int w, a, b; cin >> w >> a >> b;

  int l = b-(w+a), r = a-(w+b);
  int ans;
  if(l>0 || r>0) ans =min(abs(l), abs(r));
  else ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
ll get_cnt(vector<ll>&v,ll n,ll cut){
	ll cnt=0;
	for(ll i=0;i<n;i++){
		cnt+=v[i]/cut;
		if(v[i]%cut==0)cnt--;
	}
	return cnt;
}
 
ll get_cnt_d(vector<long double>&v,ll n,long double cut){
	ll cnt=0;
	for(ll i=0;i<n;i++){
		cnt+=floor(v[i]/cut);
		if(ceil(v[i]/cut)==floor(v[i]/cut))cnt--;
	}
//	cout<<cut<<" "<<cnt<<endl;
	return cnt;
}
 
int main(){
	io;
	ll n,k;
	cin>>n>>k;
	vector<long double>v(n);
	vector<ll>v1(n);
	for(ll i=0;i<n;i++){
		cin>>v[i];
		v1[i]=v[i];
	}//cin>>v[i];
	ll low=1,high=1e9,ans=1e9;
	while(low<=high){
		ll mid=(low+high)/2;
		ll cnt=get_cnt(v1,n,mid);
		if(cnt<=k){
			ans=mid;
			high=mid-1;
		}else{
			low=mid+1;
		}
	}
	
	//long double val=ans;
//	val-=0.5001;
	//ll cnt=get_cnt_d(v,n,val);
	//if(cnt<=k)cout<<(ans-1)<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7900
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
      int r , d , x;
      cin >> r >> d >> x;
      long lx ;
      lx = x;
      for(int i = 0 ; i < 10 ; i++){
          lx = r * lx - d;
          cout << lx  << endl;
      }
      
      return 0;
    }

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, read().split())

    ans = 1
    for _ in range(N):
        if K < ans:
            ans += K
        else:
            ans *= 2

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

std::string solve(long a, long b, long c)
{
  auto x = a * a + b * b + c * c - 2 * a * b - 2 * a * c - 2 * b * c;
  return x > 0 && c > a + b ? "Yes" : "No";
}

int main()
{
  long a, b, c;
  std::cin >> a >> b >> c;

  std::cout << std::setprecision(20);
  std::cout << solve(a, b, c) << std::endl;
}


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

int main() {
    char a[105], b[105], c[105];
    int len_a, len_b, len_c;
    scanf("%s %s %s", a, b, c);
    len_a = strlen(a);
    len_b = strlen(b);
    //len_c = strlen(c);

    if ((a[len_a - 1] == b[0]) && b[len_b - 1] == c[0])
        puts("YES");
    else
        puts("NO");
    return 0;
}


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

const int MAXN = 1e3 + 10, INF = 1e9;

int n, m;
int id[MAXN][MAXN], fa[MAXN];

struct NetWork {
	static const int MAXM = MAXN * MAXN + MAXN * 10;
	int B, E, sum, N,  MaxFlow, MinCost;
	int last[MAXN << 1], vis[MAXN << 1], cur[MAXN << 1], dis[MAXN << 1];
	struct Edge { int link, to, flow, cost; } edge[MAXM << 1];
	inline void Init(int _, int __, int ___) {
		B = _, E = __, N = ___, sum = -1;
		std::fill(last, last + N + 1, -1);
	}
	inline void Add(int u, int v, int f, int c) { edge[++sum] = (Edge) { v, last[u], f, c }, last[u] = sum; }
	inline void AddEdge(int u, int v, int f, int c) { Add(u, v, f, c), Add(v, u, 0, -c); }
	inline int SPFA() {
		std::queue <int> Q;
		std::fill(dis, dis + N + 1, INF), dis[B] = 0, Q.push(B);
		while (!Q.empty()) {
			int x = Q.front(); Q.pop(); vis[x] = 0;
			for (int i = last[x]; ~i; i = edge[i].to) {
				int y = edge[i].link, c = edge[i].cost;
				if (dis[y] > dis[x] + c && edge[i].flow) {
					dis[y] = dis[x] + c;
					if (!vis[y]) vis[y] = 1, Q.push(y);
				}
			}
		}
		return dis[E] != INF;
	}
	int Dfs(int x, int dist) {
		int flown = 0, f;
		if (x == E || !dist) return dist; vis[x] = 1;
		for (int &i = cur[x]; ~i; i = edge[i].to) {
			int y = edge[i].link;
			if (!vis[y] && dis[y] - dis[x] == edge[i].cost && ((f = Dfs(y, std::min(dist, edge[i].flow))) > 0)) {
				edge[i].flow -= f, edge[i ^ 1].flow += f;
				flown += f, dist -= f;
				if (!dist) break;
			}
		}
		vis[x] = 0;
		return flown;
	}
	inline void ZKW() {
		MaxFlow = MinCost = 0;
		while (SPFA()) {
			for (int i = 0; i <= N; ++i) cur[i] = last[i], vis[i] = 0;
			int d = Dfs(B, INF);
			MaxFlow += d, MinCost += d * dis[E];
		}
	}
} G;
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1, x, y; i <= m; ++i) scanf("%d%d", &x, &y), id[x][y] = i;
	for (int i = 1; i <= m; ++i) fa[i] = i;
	int cnt = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = 1, lst = 0; j <= n; ++j) if (id[i][j]) {
			if (lst) {
				int x = find(lst), y = find(id[i][j]);
				if (x != y) fa[y] = x, ++cnt;
			}
			lst = id[i][j];
		}
	for (int j = 1; j <= n; ++j)
		for (int i = 1, lst = 0; i <= n; ++i) if (id[i][j]) {
			if (lst) {
				int x = find(lst), y = find(id[i][j]);
				if (x != y) fa[y] = x, ++cnt;
			}
			lst = id[i][j];
		}
	int S = n * 2 + 1, T = S + 1, N = T;
	G.Init(S, T, N);
	for (int i = 1; i <= n; ++i) G.AddEdge(S, i, 1, 0);
	for (int i = 1; i <= n; ++i) G.AddEdge(i + n, T, 1, 0);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j) G.AddEdge(i, j + n, 1, id[i][j] ? 1 : 2);
	G.ZKW();
	printf("%d %d\n", m - (2 * n - G.MinCost), cnt);
	return 0;
}


Measured memory_bytes: 38444
'use strict';
function main(input) {
  let sum = 0;
  const arr = input.trim().split('\n');
  const a = arr[1].split(' ').map(x => Number(x));
  const b = arr[2].split(' ').map(x => Number(x)).map(x => sum += x);
  const c = arr[3].split(' ').map(x => Number(x));

  for (let i = 0; i < a.length; i ++) {
    if (a[i] + 1 === a[i + 1]) {
      sum += c[a[i] - 1];
    }
  }
  
  console.log(sum);
}

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

Measured memory_bytes: 21444
#include<cstdio>

using namespace std;

bool prime[100001];

void prime_checker(){
	for(int i = 3; i < 100000; i+=2){
		if(prime[i]){
			for(int j = i*2; j < 100000; j+=i){
				prime[j] = false;
			}
		}
	}
}

int main(void){
	
	int n;
	
	for(int i = 3; i < 100001; i+=2){
		prime[i] = true;
	}
	prime[0] = false;
	prime[1] = false;
	prime[2] = true;
	
	prime_checker();
	
	while(scanf("%d", &n) != EOF){
		
		for(int i = n-1; i >= 0; i--){
			if(prime[i]){
				printf("%d ",i);
				break;
			}
		}
		for(int i = n+1 ;; i++){
			if(prime[i]){
				printf("%d\n",i);
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const double EPS = 1e-6;

int main(void) {
	int N;
	while (cin >> N, N) {;
		vector<string> F(N);
		VI W(N), S(N);
		for (int i = 0; i < N; i++) {
			cin >> F[i] >> W[i] >> S[i];
		}

		VI p(N);
		iota(p.begin(), p.end(), 0);

		double ans = 1e+8;
		VI best_p(p.begin(), p.end());

		do {
			double g = 0, gt = 0;
			for (int i = 0; i < N; i++) {
				g += (i + 1) * W[p[i]];
				gt += W[p[i]];
			}
			g /= gt;

			int total = 0;
			bool flg = true;
			for (int i = N - 1; i >= 0; i--) {
				flg &= total <= S[p[i]];
				total += W[p[i]];
			}

			if (flg && g < ans + EPS) {
				ans = g;
				swap(best_p, p);
			}
		} while (next_permutation(p.begin(), p.end()));

		for (auto i : best_p) {
			cout << F[i] << endl;
		}
	}

	return 0;
}

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

typedef pair<int,int>P;

queue<P> que;
int dy[4]={-1,0,1,0};
int dx[4]={0,-1,0,1};


int main(){
  int n;
  cin>>n;
  for(int k=1;k<=n;k++){
    int x,y;
    char maps[9][9];
    for(int i=0;i<8;i++){
      cin>>maps[i];
    }
    cin>>x>>y;
    x--;y--;
    maps[y][x]='0';
    que.push(P(y,x));
    while(!que.empty()){
      P p=que.front();que.pop();
      for(int i=1;i<=3;i++){
	for(int j=0;j<4;j++){
	  int ny=p.first+dy[j]*i;
	  int nx=p.second+dx[j]*i;
	  if(maps[ny][nx]=='1' && ny>=0 && ny<8 && nx>=0 && nx<8){
	    maps[ny][nx]='0';
	    que.push(P(ny,nx));
	  }
	}
      }
    }
    cout<<"Data "<<k<<':'<<endl;
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){
	cout<<maps[i][j];
      }
      cout<<endl;
    }
  }
  return 0;
}
    

Measured memory_bytes: 1204