akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A, B, C;
	int ans, temp, maximum;
	
	cin>>A>>B>>C;
	
	maximum = max(A,max(B,C));
	
	temp = maximum*3 - (A+B+C);
	
	if(temp%2 == 0){
		cout<<temp/2<<endl;
	} else {
		cout<<(temp+3)/2<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append([c for c in input()])

cnts = [[0 for _ in range(W)] for _ in range(H)]
if S[0][0] == "#":
    cnts[0][0]  = 1
for h in range(H):
    for w in range(W):
        if h == 0 and w == 0:
            continue

        c1, c2 = float('inf'), float('inf')
        if 0 <= h - 1:
            c1 = cnts[h - 1][w]
            if S[h][w] == "#" and S[h - 1][w] == ".":
                c1 += 1

        if 0 <= w - 1:
            c2 = cnts[h][w - 1]
            if S[h][w] == "#" and S[h][w - 1] == ".":
                c2 += 1

        cnts[h][w] = min(c1, c2)
print(cnts[H-1][W-1])


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

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

    int n, cnt = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        string str = to_string(i);
        int len = str.size();
        if(len % 2 == 1)
            cnt++;
    }
    cout << cnt;
    return 0;
}


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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N; cin>>N;
    ll power = 1;
    for(int i=1;i<=N;i++){
        power*=i;
        power%=MOD;
    }
    cout<<power<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin>>n>>k;
	//ll sum=1;
	vector<ll> A(n);
	rep(i,n){
	    ll a;cin>>a;
	    A[i]=a;
	    if(i<k){
	        //sum*=a;
	    }else{
	        //ll hoge=sum*a/A[i-k];
	        if(a>A[i-k]){
	            cout<<"Yes"<<endl;
	        }else{
	            cout<<"No"<<endl;
	        }
	        //sum=hoge;
	    }
	}
	return 0;
}


Measured memory_bytes: 4776
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		s: [char; n],
	}

	for i in 0..n {
		if s[i] == 'Y' {
			println!("Four");
			return;
		}
	}
	println!("Three");
}



Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<ll, ll> mp;
vector<vector<ll>> tree;
vector<bool> visited;
vector<ll> counter;
void dfs(ll now, ll parent)
{
    if (visited[now])
        return;
    visited[now] = true;
    counter[now] += counter[parent] + mp[now];
    for(ll i = 0; i < tree[now].size(); i++){
        dfs(tree[now][i],now);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n, q;
    cin >> n >> q;
    tree.resize(n);
    visited.resize(n, false);
    counter.resize(n, 0);
    for (ll i = 0; i < n - 1; i++)
    {
        ll a, b;
        cin >> a >> b;
        --a;
        b--;
        tree[a].emplace_back(b);
        tree[b].emplace_back(a);
    }
    for (ll i = 0; i < q; i++)
    {
        ll p, x;
        cin >> p >> x;
        mp[p - 1] += x;
    }
    counter[0] = mp[0];
    visited[0] = true;
    for (ll i = 0; i < tree[0].size(); i++)
    {
        dfs(tree[0][i], 0);
    }
    for (ll i = 0; i < n; i++)
    {
        cout << counter[i] << endl;
    }
}

Measured memory_bytes: 39936
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

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


	
int main() {
	ll A[3], K;
	cin >> A[0] >> A[1] >> A[2] >> K;
	sort(A, A + 3);

	repn(i, K) A[2] *= 2;

	cout << A[0] + A[1] + A[2];
	system("PAUSE");
}

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

#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, n) for(int i = 0; i < n; ++i)
typedef long long llint;

const int maxN = 100;

int n, x, a[maxN];

void run() {
    cin >> n >> x;
    REP(i, n) {
        cin >> a[i];
    }
    sort(a, a + n);
    int tot = 0;
    REP(i, n) {
        tot += a[i];
        if (tot >= x) {
            cout << i + (tot == x) << "\n";
            return;
        }
    }
    cout << n - 1 + (tot == x) << "\n";
}

int main() {
#ifdef LOCAL
    freopen("input", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    run();
#ifdef LOCAL
    fclose(stdin);
#endif
    return 0;
}

Measured memory_bytes: 256
class Paper:
    def __init__(self, n, m):
        self.n = n
        self.m = m
        self.table = [[1] * n for _ in range(m)]

    def __str__(self):
        return str(self.table)

    def thickness(self, x, y):
        return self.table[y][x]

    def fold(self, d, c):
        if d == 1:
            return self.foldl(c)
        else:
            return self.foldb(c)

    def foldl(self, c):
        nn = max(c, self.n - c)
        tbl = [[0] * nn for _ in range(self.m)]
        for y in range(self.m):
            for x in range(c):
                tbl[y][x] += self.table[y][c - x - 1]
            for x in range(self.n - c):
                tbl[y][x] += self.table[y][c + x]
        self.n = nn
        self.table = tbl

    def foldb(self, c):
        mm = max(c, self.m - c)
        tbl = [[0] * self.n for _ in range(mm)]
        for x in range(self.n):
            for y in range(c):
                tbl[y][x] += self.table[c - y - 1][x]
            for y in range(self.m - c):
                tbl[y][x] += self.table[c + y][x]
        self.m = mm
        self.table = tbl

while True:
    n, m, t, p = map(int, input().split())
    if n == m == t == p == 0:
        break

    paper = Paper(n, m)
    for i in range(t):
        d, c = map(int, input().split())
        paper.fold(d, c)
    for i in range(p):
        x, y = map(int, input().split())
        print(paper.thickness(x, y))


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

def main():
    d=int(input())
    C=tuple(map(int,input().split()))
    S=[list(map(int,input().split())) for _ in range(d)]
    Last=[0]*26
    score=0
    for day in range(d):
        t=int(input())-1
        Last[t]=day+1
        score+=S[day][t]
        for i,c in enumerate(C):
            score-=c*(day+1-Last[i])
        print(score)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 68704
#include<stdio.h>

int main(void)
{
  int x,y,r,gcd,tmp;

  scanf("%d", &x);
  scanf("%d", &y);
  if (x<y) {
    tmp = x;
    x = y;
    y = tmp;
  }
  while (y>0) {
    r = x%y;
    x = y;
    y = r;
  }
  gcd = x;
  printf("%d\n", gcd);
}



Measured memory_bytes: 2112
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    if(c == 0){
        cout << "No" << endl;
        return 0;
    }
    ll ab = a*b*4;
    ll cmp = c-a-b;
    if(cmp < 0){
        cout << "No" << endl;
        return 0;
    }
    cmp = cmp*cmp;
    if(ab < cmp) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#define rep(N) for (int i = 0; i < N; i++)
#define For(i, N) for (i = 0; i < N; i++)
#define rev(N) 	for (int i = N - 1; i >= 0; --i)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << endl;
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << endl;
}

void f(int sn, int en, string ss, string es) {
	int center = (sn + en) / 2;
	bool b;
	string s;
	say(center);
	cin >> s;
	if (s == "Vacant")return;
	if ((center - sn + 1) % 2 == 0) {
		if (s == ss)b=true;
	}else {
		if (s != ss)b=true;
	}
	if ((en - center + 1) % 2 == 0) {
		if (s == es)b=false;
	}
	else {
		if (s != es)b=false;
	}
	if (b)f(sn, center, ss, s);
	else f(center, en, s, es);
}

int main() {
	int N;
	string s;
	cin >> N;
	say(0);
	cin >> s;
	if (s == "Vacant")re;
	f(0, N, s, s);
}

Measured memory_bytes: 852
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    string s, t;
    cin >> s >> t;
    vector<int> accs(s.size()), acct(t.size());
    for(int i=0;i<s.size();i++){
        accs[i] = (i - 1 >= 0 ? accs[i - 1] : 0) + (s[i] == 'A' ? 1 : -1);
    }
    for(int i=0;i<t.size();i++){
        acct[i] = (i - 1 >= 0 ? acct[i - 1] : 0) + (t[i] == 'A' ? 1 : -1);
    }
    int q; cin >> q;
    for(int i=0;i<q;i++){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--; c--; d--;
        int n1 = 0, n2 = 0;
        // for(int j=a;j<=b;j++){
        //     n1 += s[j] == 'A' ? 1 : -1;
        // }
        // for(int j=c;j<=d;j++){
        //     n2 += t[j] == 'A' ? 1 : -1;
        // }
        n1 = accs[b] - (a - 1 >= 0 ? accs[a - 1] : 0);
        n2 = acct[d] - (c - 1 >= 0 ? acct[c - 1] : 0);
        n1 = (n1 + 3 * 100000) % 3;
        n2 = (n2 + 3 * 100000) % 3;
        cout << (n1 == n2 ? "YES" : "NO") << '\n';
    }
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<tuple<string, int, int>> pa(N);
    for (int i=0; i<N; i++){
        string S;
        int P;
        cin >> S >> P;
        pa.at(i) = make_tuple(S, P*(-1), i+1);
    }
    sort(pa.begin(), pa.end());
    
    for (int i=0; i<N; i++){
        cout << get<2>(pa.at(i)) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, M, tmp, ans=0;
    cin >> N;
    vector<string> s(N);
    string a;
    for(int i=0; i<N; i++){
	cin >> s[i];
    }
    cin >> M;
    vector<string> t(M);
    for(int i=0; i<M; i++){
	cin >> t[i];
    }


    for(int i=0; i<N; i++){
    	tmp = 0;
    	for(int j=0; j<N; j++){
    	    if(s[i]==s[j])
    		tmp++;
    	}
    	for(int j=0; j<M; j++){
    	    if(s[i]==t[j])
    		tmp--;
    	}
    	ans = max(ans, tmp);
    }
    cout << ans << endl;
    
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;

int main(){
   int a,b;
   cin >> a >> b;
   if(a+b==15) cout <<"+";
   else if(a*b==15) cout <<"*";
   else cout << "x";
   return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize (2)
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ii =  pair<int,int>;
const int  dir[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
const int mod = 1000000007;
const int INF = 0x3f3f3f;
#define all(v) v.begin(),v.end()
ll quick_pow(ll base, ll n) {
    ll ans = 1;
    while (n ) {
        if (n & 1 )
            ans *= base;
        base *= base;
        n >>= 1;
    }
    return ans;
}
void solve();
int main() {
    int T=1;
//    cin>>T;
    while (T--){
        solve();
    }
    return 0;
}
void solve() {
    int n;
    double d;
    int x,y;
    cin>>n>>d;
    int ans=0;
    for (int i = 0; i < n; ++i) {
        cin>>x>>y;
//        cout<<x<<" "<<y<<" "<<hypotf(x,y)<< " "<<d<<endl;
        ans+=hypot(x,y) <= d;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3768
a,b,c,d = list(int(input()) for i in range(4))
ans = 0
for i in range(a + 1):
    for o in range(b + 1):
        for p in range(c + 1):
            if 500 * i + 100 * o + 50 * p == d:
                ans += 1
print(ans)
    


Measured memory_bytes: 2940
#include<iostream>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// mint
int64_t const MOD = 1e9+7;

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};
typedef mod_int<MOD> mint;

//optional
template<typename T>
struct optional {
  bool valid;
  T v_;
  optional(): valid(false) {}
  optional& operator=(T const& v)
    { v_ = v; valid = true; return *this; }
  T& operator*() { return v_; }
  T const& operator*() const { return v_; }
};

int const MAXN=50;
int const MAXK=MAXN*MAXN;

optional<mint> dp[MAXN+1][MAXN+1][MAXK+1];

mint calc(int i, int j, int k) {
  if(dp[i][j][k].valid) return *dp[i][j][k];
  mint res;
  int new_k = k-j-j;
  if(new_k >= 0 && i >= 1) {
    if(i-1 >= j) res += mint(j+j+1)*calc(i-1, j, new_k);
    if(i-2 >= j) res += mint(j+1)*(j+1)*calc(i-1, j+1, new_k);
    if(i >= j && j >= 1) res += calc(i-1, j-1, new_k);
  }
  return *(dp[i][j][k] = res);
}

int main() {
  int n, k; std::cin >> n >> k;
  dp[0][0][0] = 1;
  fin(calc(n, 0, k).v_);
  return 0;
}


Measured memory_bytes: 101888
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

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

    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d[] = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		int m = 1;
		for (int i = 0; i < n - 1; i++) {
			if (d[i + 1] - d[i] != 0)
				m++;
		}
		System.out.println(m);
	}
}

Measured memory_bytes: 21716
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d1[200010];
ll d3[200010];

int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> v1,v2,v3;
  ll mx = -1000000007;
  rep(i,0,n){
    ll a;
    cin>>a;
    if(a<0)v1.pb(a);
    if(a==0)v2.pb(a);
    if(a>0)v3.pb(a);
    mx = max(mx,a);
  }
  sort(all(v1));
  sort(all(v3));
  reverse(all(v1));
  if(mx<0){
    ll ans = 1;
    if(k%2==1){
      rep(i,0,k){
        ans *= (MOD+v1[i]);
        ans %= MOD;
      }
    }
    else{
      reverse(all(v1));
      rep(i,0,k){
        ans *= (MOD+v1[i]);
        ans %= MOD;
      }      
    }
    cout << ans << endl;
  }
  else{
    if(v1.sz+v3.sz<k){
      cout << 0 << endl;
      return 0;
    }
    ll ans = 1;
    while(k>1){
      if(v1.sz>1&&v3.sz>1){
        ll a1 = v1[v1.sz-1];
        ll a2 = v1[v1.sz-2];
        ll b1 = v3[v3.sz-1];
        ll b2 = v3[v3.sz-2];
        if(a1*a2>=b1*b2){
          ans *= (MOD+a1);
          ans %= MOD;
          ans *= (MOD+a2);
          ans %= MOD;
          v1.pop_back();
          v1.pop_back();
        }
        else{
          ans *= (MOD+b1);
          ans %= MOD;
          ans *= (MOD+b2);
          ans %= MOD;
          v3.pop_back();
          v3.pop_back();
        }
        k -=2;
      }
      else if(v1.sz>1){
          ll a1 = v1[v1.sz-1];
          ll a2 = v1[v1.sz-2];
          ans *= (MOD+a1);
          ans %= MOD;
          ans *= (MOD+a2);
          ans %= MOD;
          v1.pop_back();
          v1.pop_back();
          k-=2;     
      }
      else if(v3.sz>1){
          ll b1 = v3[v3.sz-1];
          ll b2 = v3[v3.sz-2];
          ans *= (MOD+b1);
          ans %= MOD;
          ans *= (MOD+b2);
          ans %= MOD;
          v3.pop_back();
          v3.pop_back();
          k-=2;        
      }
      else{
        break;
      }
    }
    if(k==1){
      if(v3.sz>0){
        ans *= v3[v3.sz-1];
        ans %= MOD;
      }
      else if(v2.sz>0){
        ans *= 0;
      }
      else{
        ans *= MOD+v1[v1.sz-1];
        ans %= MOD;
      }
    }
    if(k==2){
      if(v2.sz>0){
        ans *= 0;
      }
      else{
        ans *= MOD+v1[v1.sz-1];
        ans %= MOD;
        ans *= MOD+v3[v3.sz-1];
        ans %= MOD;
      }      
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5732
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n;
cin >> n;
ll t[n];
for (ll i = 0; i < n; i++) cin >> t[i];
ll m;
cin >> m;
ll p[m];
ll x[m];
for (ll i = 0; i < m; i++) cin >> p[i] >> x[i];
ll ans[m];
for (ll i = 0; i < m; i++) ans[i] = 0;
ll sum = 0;
for (ll i = 0; i < n; i++) sum += t[i];
for (ll i = 0; i < m; i++) {
    ans[i] = sum - t[p[i]-1] + x[i];
}
for (ll i = 0; i < m;i++){
    cout << ans[i] << endl;
}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<list>

typedef long long ll;

using namespace std;

bool isPrime(int x){
	if(x==2)
		return true;
	if(x<2 || x%2 ==0)
		return false;
		
	for(int i = 3 ; i*i<=x ; i+=2){
		if(x%i==0)
			return false;
	}
	return true;
}

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int ans = 0;
	while (n--){
		int t;
		cin>>t;

		if(isPrime(t)){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3116
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>

int main(){
	int N,po;
	std::string t_name;
	std::cin >> N;
	std::vector<std::pair<std::pair<std::string,int>,int> > SP(N);
	for(int i = 0 ; i < N ; i ++){
		std::cin >> t_name >> po;
		SP[i] = make_pair(make_pair(t_name,-po),i);
	}
	sort(SP.begin(),SP.end());
	for(int i = 0 ; i < N ; i ++){
		std::cout << SP[i].second + 1 << std::endl;
	}
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n,d,a;
pii enemy[252521];

ll x[252521];
ll h[252521];

ll imos[252521];

int main(){
    scanf("%d%d%d",&n,&d,&a);
    REP(i,n){
        scanf("%d%d",&enemy[i].first,&enemy[i].second);
    }
    sort(enemy,enemy+n);
    REP(i,n)x[i] = enemy[i].first;
    REP(i,n)h[i] = enemy[i].second;
    ll ans = 0;
    REP(i,n){
        // shori
        h[i] = max(0ll, h[i] - imos[i]);
        int cnt = (h[i] + a - 1) / a;
        int to = upper_bound(x,x+n,x[i]+d+d) - x;
        ans += cnt;
        imos[i] += 1ll * cnt * a;
        imos[to] -= 1ll * cnt * a;
        // update
        imos[i+1] += imos[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 7424
n,t = gets.strip.split.map(&:to_i)
ary = []
n.times do
  a,b = gets.strip.split.map(&:to_i)
  if b <= t
    ary.unshift(a)
  end
end
if ary.size == 0
  puts "TLE"
else
  puts ary.min
end

Measured memory_bytes: 14220
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <math.h>
#define ll long long;

using namespace std;


bool PrimeNumber(int p) {
	if (p == 2) return true;
	else if (p < 2 || p % 2 == 0) return false;

	int i = 3;
	while (i <= sqrt((double)p)) {
		if (p%i == 0) {
			return false;
		}
		i = i + 2;
	}
	return true;
}

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

	for (int i = 0; i < n; i++) {
		if (PrimeNumber(a[i])) count++;
	}
	cout << count << endl;
	
}

Measured memory_bytes: 3096
local w = string.byte("W")

local s = io.read()
local s_len = s:len()
local b_count = 0
local count = 0
local last_w_pos = 0
for i = 1, s_len do
	local is_w = s:byte(i) == w
	if b_count ~= 0 and is_w then
		count = count + b_count
		last_w_pos = last_w_pos + 1
	elseif is_w then
		last_w_pos = last_w_pos + 1
	else
		b_count = b_count + 1
	end
end

print(count)


Measured memory_bytes: 2712
#include <iostream>

using namespace std;

int main()
{
	// 入力
	int A, B, K;
	cin >> A >> B >> K;
	
	int answer = 0;
	int divisionRank = 0;
	
	for (int i = 100; i >= 1; i--)
	{
		if (A % i == 0 && B % i == 0)
		{
			// 順位
			divisionRank++;
			
			if (divisionRank == K)
			{
				answer = i;
			}
		}
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

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

int main(){
	while(true){
		int a, b;
		char op;
		cin >> a >> op >> b;
		int ans = 0;
		if(op == '?') break;
		if(op == '+') ans = a + b;
		if(op == '-') ans = a - b;
		if(op == '*') ans = a * b;
		if(op == '/') ans = a / b;
		cout << ans << endl;
	}
}



Measured memory_bytes: 3076
import java.util.Scanner;

class Main{
    public static void main(String args[])
    {
        Scanner s= new Scanner(System.in);
       
        int n = s.nextInt();
        int a[][] = new int [n][2];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<2;j++)
            {
                a[i][j]=s.nextInt();


            }
        }
        if(Triplate(a,n))
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
        

    }
    public static boolean Triplate(int [][] arr,int n)
    {
        for(int i=0;i<n-2;i++)
        {

            if(arr[i][0]==arr[i][1] && arr[i+1][0]==arr[i+1][1] && arr[i+2][0]==arr[i+2][1] )
            {
                return true;
            }
        }
        return false;
    }
}

Measured memory_bytes: 35828
import java.io.*
import java.lang.*
import java.lang.Math.*

fun solve() {
    val X = rd.readInt()

    var k = 0
    while (true) {
        k++
        if ((k*X)%360 == 0) {
            break
        }
    }

    val ans = k
    println(ans)
}


//val rd = debug.Reader("agc", "046", "a", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


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

struct card {
    char mark;
    int number;
    int InputIndex;
};

int partition(card A[], int p, int r) {
    int x = A[r].number;
    int i = p - 1;
    
    for(int j = p; j < r; ++j) {
        if(A[j].number <= x) {
            ++i;
            card cpy = A[i];
            A[i] = A[j];
            A[j] = cpy;
        }
    }
    card cpy = A[r];
    A[r] = A[i + 1];
    A[i + 1] = cpy;
    
    return i + 1;
}

void QuickSort(card A[], int p, int r) {
    if(p < r) {
        int q = partition(A, p, r);
        QuickSort(A, p, q - 1);
        QuickSort(A, q + 1, r);
    }
}

int main(void) {
    card A[100000];
    int n;
    
    cin >> n;
    
    for(int i = 0; i < n; ++i) {
        cin >> A[i].mark >> A[i].number;
        A[i].InputIndex = i;
    }
    
    QuickSort(A, 0, n - 1);
    
    bool flag = true;
    int k = 1;
    while(k < n) {
        if(A[k].number == A[k - 1].number && A[k].InputIndex < A[k - 1].InputIndex) {
            flag = false;
            break;
        }
        ++k;
    }
    
    if(flag) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    
    for(int i = 0; i < n; ++i) {
        cout << A[i].mark << ' ' << A[i].number << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4192
#include <iostream>
#include <vector>

int main(){
  int N = 0;
  std::cin >> N;
  
  std::vector<int> member(N+1);
  
  member.at(0) = -1;
  
  for(int cnt = 0; cnt < N-1; cnt++){
    int number = 0;
    std::cin >> number;
    member.at(number)++;
  }
  
  for(int cnt = 1; cnt <= N; cnt++){
    std::cout << member.at(cnt) << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 4052
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

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

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

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input! {
        n: usize,
        arr: [i32; n],
    }
    let (q, o) = (arr.iter().filter(|a| a.trailing_zeros() > 1).count(), arr.iter().filter(|&a| a % 2 == 1).count());
    if q + o == n && o - 1 <= q { println!("Yes"); }
    else if o <= q { println!("Yes") }
    else { println!("No") }
}


Measured memory_bytes: 4352
n=int(input())
hoge=list(map(int,input().split()))
hoge.append(0)
hoge=hoge[::-1]
hoge.append(0)
hoge=hoge[::-1]
kei=0
for i in range(n+1):
  kei+=abs(hoge[i]-hoge[i+1])

for i in range(n):
  tag=i+1
  #通過
  if(hoge[tag-1]<=hoge[tag] and hoge[tag]<=hoge[tag+1]):
    print(kei)
  elif(hoge[tag-1]>=hoge[tag] and hoge[tag]>=hoge[tag+1]):
    print(kei)
  #Uターン
  elif(hoge[tag+1]<=hoge[tag-1] and hoge[tag-1]<=hoge[tag]):
    print(kei-2*abs(hoge[tag-1]-hoge[tag]))
  elif(hoge[tag]<=hoge[tag-1] and hoge[tag-1]<=hoge[tag+1]):
    print(kei-2*abs(hoge[tag-1]-hoge[tag]))
  #近道
  elif(hoge[tag-1]<=hoge[tag+1] and hoge[tag+1]<=hoge[tag]):
    print(kei-2*abs(hoge[tag+1]-hoge[tag]))
  elif(hoge[tag]<=hoge[tag+1] and hoge[tag+1]<=hoge[tag-1]):
    print(kei-2*abs(hoge[tag+1]-hoge[tag]))

Measured memory_bytes: 13928
#include <iostream>
int x,a,b,c,na,nb,nc,ans;

int main(){
	std::cin>>a>>b>>c>>x;
	x/=50;
	na=x/10;
	nb=x/2;
	for(int i=0;i<=na;i++){
		if(i>a){
			break;
		}
		for(int j=0;j<=nb;j++){
			if(j>b){
				break;
			}
			if(c>=x-i*10-j*2&&0<=x-i*10-j*2){
				ans++;
			}
		}
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll ncr(ll x, ll y) {
	ll ans = 1;
	for (ll i = 1; i <= y; ++i) {
		ans *= (x - y + i);
		ans /= i;
	}

	return ans;
}
int main()
{
    fio;
    int a,b,c;
    cin>>a>>b>>c;
    if(b*c >= a)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


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



int main(){
    
    double a,S,L;
    cin>>a;

    double PI=3.14159265359;

    S=a*a*PI;
    L=2*a*PI;
    cout<< fixed << setprecision(6);


    cout<<S<<" "<<L<<endl;


}



Measured memory_bytes: 3204
// https://atcoder.jp/contests/abc173/tasks/abc173_e

use proconio::fastout;
use proconio::input;
use std::collections::VecDeque;

const MOD: i64 = 1000000007;

#[fastout]
fn main() {
    input! {
        n: usize, k: usize,
        mut a_s: [i64; n],
    }
    let ans = if n == k || (a_s.iter().max().unwrap() < &0 && k % 2 != 0) {
        a_s.sort_unstable_by(|&a, &b| b.cmp(&a));
        let ans = a_s[..k].iter().fold(1, |acc, &cur| (acc * cur) % MOD);
        if ans < 0 {
            MOD + ans
        } else {
            ans
        }
    } else {
        let mut ps: Vec<_> = a_s.iter().filter(|&&x| x >= 0).collect();
        let mut ns: Vec<_> = a_s.iter().filter(|&&x| x < 0).collect();
        ps.sort_unstable_by(|&a, &b| b.abs().cmp(&a.abs()));
        ns.sort_unstable_by(|&a, &b| b.abs().cmp(&a.abs()));
        let mut ps: VecDeque<_> = ps.iter().map(|&&x| x).collect();
        let mut ns: VecDeque<_> = ns.iter().map(|&&x| x).collect();
        let mut acc = 1;
        let mut size = 0;
        while size < k {
            if size == k - 1 {
                acc = (acc * ps.pop_front().unwrap()) % MOD;
                size += 1;
            } else {
                let mut pi = ps.iter();
                let mut ni = ns.iter();
                let x = (pi.next(), pi.next(), ni.next(), ni.next());
                match x {
                    (Some(p0), Some(p1), Some(n0), Some(n1)) => {
                        if p0 * p1 < n0 * n1 {
                            acc = (acc * ns.pop_front().unwrap()) % MOD;
                            acc = (acc * ns.pop_front().unwrap()) % MOD;
                            size += 2;
                        } else {
                            acc = (acc * ps.pop_front().unwrap()) % MOD;
                            size += 1;
                        }
                    }
                    (_, _, Some(_), Some(_)) => {
                        acc = (acc * ns.pop_front().unwrap()) % MOD;
                        acc = (acc * ns.pop_front().unwrap()) % MOD;
                        size += 2;
                    }
                    _ => {
                        acc = (acc * ps.pop_front().unwrap()) % MOD;
                        size += 1;
                    }
                }
            }
        }
        acc
    };
    println!("{}", ans);
}


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

int main() {
  int N;
  cin >> N;
  
  for (int i = 1; i < 10; i++) {
    if (N % i == 0 && N/i <= 9){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

 

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int a, b;
  cin >> a >> b;
  REP(i,10000){
    if(i == 0) continue;
    if(i*8/100 == a &&i*10/100 == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int H,A;
    int cont=1;
    cin>>H>>A;
    while (H !=0)
    {
        H=H-A;
        if(H==0||H<0){
            cout<<cont;
            return 0;
        }
        cont++;
    }
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val inf = 1e9.toInt()
    val (h, n) = readLine()!!.split(' ').map { it.toInt() }
    val ms = (0 until n).map {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        a to b
    }

    val dp = IntArray(2e4.toInt() + 1) { inf }
    dp[0] = 0

    for (i in 0..h) {
        for (m in ms) {
            val j = i + m.first
            dp[j] = Math.min(dp[i] + m.second, dp[j])
        }
    }

    println(dp.slice(h..dp.lastIndex).min())
}


Measured memory_bytes: 40768
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
#include<set>
#include<fstream>
#include<list>
#include<sstream>

#define loopi(x,y) for(int i = x;i<(y);i++)
#define loopj(x,y) for(int j = x;j<(y);j++)
#define rloopi(x,y) for(int i = x;i>=(y);i--)
#define rloopj(x,y) for(int j = x;j>=(y);j--)


#define nl cout<<"\n";
#define ll long long int
#define mod  1000000007

using namespace std;



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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int x;
	cin >> x;

	cout << !x;

}


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

void solve(long long N, long long K, std::vector<long long> A, std::vector<long long> F){
    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<long long>());
    ll l = 0;
    ll r = 1e12;
    auto isValid = [&](ll time) {
		       ll setsLeft = K;
		       for (ll i = 0; i < N; i++) {
			   ll coeff = A[i];
			   ll diff = F[i];
			   ll prod = coeff*diff;
                           if (prod > time) {
                               ll setsNeeded = coeff - time/diff;
                               if (setsLeft >= setsNeeded) {
				   setsLeft-=setsNeeded;
                               } else {
				   return false;
                               }
                           }
                       }
		       return true;
		   };
    while (l < r) {
      ll mid = (l + r) / 2;
      if (isValid(mid)) {
	  r = mid;
      } else {
	  l = mid+1;
      }
    }
    cout << l << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> F(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&F[i]);
    }
    solve(N, K, std::move(A), std::move(F));
    return 0;
}


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

int main() {
	int a[3];
	for(int i=0;i<3;i++) scanf("%d", &a[i]);
	sort(a, a+3);
	if(a[0]!=a[2] && (a[0]==a[1] || a[1]==a[2]))
		puts("Yes");
	else
		puts("No");
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define FALSE 0
#define TRUE 1
/*
問題文

JOI 君はマルスタンプ，バツスタンプ，マルバツスタンプの3種類のスタンプをそれぞれ 0 個以上持っている．これらはマルやバツのマークを紙に印字することができるスタンプである．

マルスタンプを使うとマルが 1 つ印字され，バツスタンプを使うとバツが 1 つ印字される．マルバツスタンプを使うとマルとバツが横一列に 1 つずつ印字され，スタンプの向きを変えることで，マルの右にバツが来るようにも，バツの右にマルが来るようにも印字できる．

JOI 君は，持っているスタンプをそれぞれちょうど 1 回ずつ適当な順番で使い，紙に横一列にマルとバツを印字した．印字されたマルとバツの列は文字列 S で表される．S は O と X から構成された長さ N の文字列であり，Si= O ならば JOI 君が印字したマークのうち左から i 番目のものがマルであることを表し，Si= X ならばそれがバツであることを表す (1≦i≦N)．

あなたは，JOI 君が持っているスタンプの個数は分からないが，JOI 君が印字したマルとバツの列は知っている．印字されたマルとバツの列から，JOI 君が持っているマルバツスタンプの個数としてあり得るもののうち最大値を求めよ．
制約

    1≦N≦100000(=105)
    S は長さ N の文字列である．
    S の各文字は O か X である．

入力・出力

入力
入力は以下の形式で標準入力から与えられる．
N
S

出力
JOI 君が持っているマルバツスタンプの個数としてあり得るもののうち最大値を出力せよ．
入出力例
入力例 1

5
OXXOX

出力例 1

2

JOI 君が印字したマークは，左から順に，マル，バツ，バツ，マル，バツである．JOI 君がマルスタンプ，バツスタンプ，マルバツスタンプをそれぞれ 0,1,2 個持っているとすると，以下の順番でスタンプを使えば，そのようにマークを印字することができる．

    1 つ目のマルバツスタンプを使ってマルとバツをこの順に印字する．
    この右に，2 つ目のマルバツスタンプを使ってバツとマルをこの順に印字する．
    最後に，この右に，バツスタンプを使ってバツを印字する．

マルバツスタンプを 3 個以上持っているケースは考えられないので，2 を出力する．
入力例 2

14
OXOXOXOXXOXOXO

出力例 2

7

入力例 3

10
OOOOOOOOOO

出力例 3

0
*/

void clear_std_out() {
    while (getchar()!='\n')
    {
        //から
    }
}
int main()
{
    /*
    xoxと交互に来る場合にご認識する可能性がある
    前回がxoスタンプだった場合は判定をしないことで回避できる
    パターンは下記(上記誤判定が起きるケースは<付きのもの)
    ooo
    oox
    oxo<
    oxx
    xoo
    xox<
    xxo
    xxx
    */
    int str_len = 0;
    
    //printf("文字数を入れる>");
    scanf("%d", &str_len);
    clear_std_out();
    str_len += 1;
    

    char *inp_str = (char *)calloc(str_len, sizeof(char));
    //char inp_str[10000];
    //scanf_s("%s", inp_str);
    //printf("文字列を入れる>");
    scanf("%s", inp_str);
    clear_std_out();
    int is_last_xo = FALSE;
    char head = '\0', tail = '\0';
    int xo_count = 0;
    for (int i = 0; inp_str[i+1] != '\0'; i++) {
        head = inp_str[i];
        tail = inp_str[i + 1];

        if (is_last_xo == FALSE && head != tail) {
            xo_count++;
            is_last_xo = TRUE;
        }
        else {
            is_last_xo = FALSE;
        }

    }
    printf("%d\n", xo_count);

    //for(int i=0; inp_str[i] !='\n'; i++)
    
    return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します



Measured memory_bytes: 2132
#include <iostream>
#include <valarray>
using namespace std;
int main(){
    int n;
    cin>>n;
    valarray<long long>a(n);
    for(auto& i:a){
        cin>>i;
    }
    cout<<a.min()<<" "<<a.max()<<" "<<a.sum()<<endl;
}


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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll a, b, c;
    ll k;
    cin >> a >> b >> c >> k;
    ll odp;
    if (k % 2 == 0)
        odp = a - b;
    else
        odp = b - a;
    if (abs(odp) > 1000000000000000000)
        cout << "Unfair";
    else
        cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<iomanip>
#include<queue>
#include<string>

typedef long long ll;
const int inf = 0x3f3f3f3f,maxn = 100 + 5;

using namespace std;

int main(){

	int n,y;

	while(cin >> n >> y)
	{
		int a,b,c;

		y = y / 1000;

		bool flag = false;

		for(a = n;a >= 0;a--)
		{
			for(b = n - a;b >= 0;b--)
			{
				for(c = n - a - b;c >= 0;c--)
				{
					if(a + b + c == n && a * 10 + b * 5 + c == y)
					{
						flag = true;
						printf("%d %d %d\n",a,b,c);
						break;
					}
				}

				if(flag) break;

			}

			if(flag) break;
		}

		if(!flag) printf("-1 -1 -1\n");
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var HW = ReadSplitInt();
            var H = HW[0];
            var W = HW[1];
            var list = new List<string>();
            for (var i = 0; i < H; i++)
            {
                var C = Read().ToArray();
                list.Add(string.Join("", C));
                list.Add(string.Join("", C));
            }

            list.ForEach(Println);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();

        static void Print(object value = null) => Console.Write(value.ToString());
        static void Println(object value = null) => Console.WriteLine(value.ToString());
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13396
function Main(input) {
  input = input.split("\n");
  var ans = parseInt(input[0].split(" ")[0])*parseInt(input[0].split(" ")[1]);

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30000