akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pii pair<ll,ll>
#define pb push_back
#define in(x) scanf("%d",&x)
#define inn(x,y) scanf("%d%d",&x,&y)
#define innn(x,y,z) scanf("%d%d%d",&x,&y,&z)

using namespace std;
const int N=2e5+5;
const int mod=1e9+7;

ll n,d,a;
ll by[N];
pii ar[N];

int main(){
    cin>>n>>d>>a;
    for(int i=1;i<=n;i++){
        cin>>ar[i].first>>ar[i].second;
    }
    
    sort(ar+1,ar+n+1);

    ll ans=0;
    for(int i=1;i<=n;i++){
        by[i]+=by[i-1];
        ll tmp=  ar[i].second+by[i];
        if(tmp<=0) continue;

        ll req = tmp/a + (ll)(tmp%a!=0);
        ans+=req;

        by[i]-=req*a;
        int j= upper_bound(
            ar+1,
            ar+1+n,
            make_pair(ar[i].first+2*d+1,0LL)
        )-ar;

        by[j]+=req*a;
    }

    cout<<ans;
    return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  int ans = 1;
  for(int i = 0; i < n; i++) {
    if(ans * 2 >= ans + k)
      ans += k;
    else
      ans *= 2;
  }
  cout << ans << endl;
}


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

int knsa[1010],knsb[1010],knsc[1010];
int knsk[1010];
int ans[310];
int main(){
	int A,B,C,N,cnt;
	while(1){
		cin>>A>>B>>C;
		if(A==0&&B==0&&C==0) break;
		cin>>N;
		for(int ii=1;ii<=A+B+C;ii++) {ans[ii]=2;}
		for(int i=0;i<N;i++){
			cin>>knsa[i]>>knsb[i]>>knsc[i]>>knsk[i];
			if(knsk[i]){
				ans[knsa[i]]=ans[knsb[i]]=ans[knsc[i]]=1;
			}
		}

		for(int i=0;i<N;i++){
			if(!knsk[i]){
				cnt=0;
				if(ans[knsa[i]]==1)cnt+=1;
				if(ans[knsb[i]]==1)cnt+=2;
				if(ans[knsc[i]]==1)cnt+=4;
				if(cnt==3)ans[knsc[i]]=0;
				if(cnt==5)ans[knsb[i]]=0;
				if(cnt==6)ans[knsa[i]]=0;
			}
		}

		for(int i=1;i<=A+B+C;i++){
			cout<<ans[i]<<endl;
		}

	}
}

Measured memory_bytes: 1176
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        for(int i=0; i<5; i++){
            int a=sc.nextInt();
            if(a==0){
                System.out.println(i+1);
                break;
            }
        }
    }
}

Measured memory_bytes: 35652
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int H=in(),W=in();
	vector<vector<int>> M(H,vector<int>(W,1<<30));
	queue<int> Q;
	REP(i,H){
		string S=in<string>();
		REP(j,W){
			if(S[j]=='#'){
				M[i][j]=0;
				Q.push(j+i*W);
			}
		}
	}
	while(!Q.empty()){
		int V=Q.front();
		Q.pop();
		int u=V%W,v=V/W;
		if(u>0 && M[v][u]+1<M[v][u-1]){
			M[v][u-1] = M[v][u]+1;
			Q.push(u-1+v*W);
		}
		if(u<W-1 && M[v][u]+1<M[v][u+1]){
			M[v][u+1] = M[v][u]+1;
			Q.push(u+1+v*W);
		}
		if(v>0 && M[v][u]+1<M[v-1][u]){
			M[v-1][u] = M[v][u]+1;
			Q.push(u+(v-1)*W);
		}
		if(v<H-1 && M[v][u]+1<M[v+1][u]){
			M[v+1][u] = M[v][u]+1;
			Q.push(u+(v+1)*W);
		}
	}
	int maxV=0;
	REP(i,H){
		REP(j,W){
			maxV=max(maxV,M[i][j]);
		}
	}
	out(maxV);
	return 0;
}


Measured memory_bytes: 8320
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
bool judge(vector<int> vec,int goal){
  bool dp[16005][2];
  for(int i=0;i<16005;i++){
    for(int j=0;j<2;j++) dp[i][j]=false;
  }
  dp[8002][0]=true;
  for(int i=0;i<vec.size();i++){
    for(int j=0;j<16005;j++){
      if(dp[j][0]){
        dp[j+vec[i]][1]=true;
        dp[j-vec[i]][1]=true;
      }
    }
    for(int j=0;j<16005;j++){
      dp[j][0]=dp[j][1];
      dp[j][1]=0;
    }
  }
  return dp[goal+8002][0];
}
int main(){
  string s;
  cin>>s;
  int n=s.length();
  int gx,gy;
  cin>>gx>>gy;
  int i1=0;
  while(s[i1]!='T'&&i1<n) i1++;
  gx-=i1;
  vector<int> xvec,yvec;
  int cnt=0;
  bool f=false;
  for(int i=i1+1;i<n;i++){
    if(s[i]=='F') cnt++;
    else{
      if(f){
        xvec.push_back(cnt);
        f=false;
      }
      else{
        yvec.push_back(cnt);
        f=true;
      }
      cnt=0;
    }
  }
  if(cnt>0){
    if(f) xvec.push_back(cnt);
    else yvec.push_back(cnt);
  }
  if(judge(xvec,gx)&&judge(yvec,gy)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

#define int long long
#define pb push_back


int dp[200005];

signed main() {
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++) {
        cin>>h[i];
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++) {
        for(int j=i-1;j>=max(0LL,i-k);j--) {
            dp[i]=min(dp[i],abs(h[i]-h[j])+dp[j]);
        }
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int>a(n+1,0);
  rep(i,k){
    int d;
    cin >> d;
    rep(j,d){
      int aa;
      cin >> aa;
      a[aa]=1;
    }
  }
  int cnt=n;
  rep(i,n+1){
    cnt-=a[i];
  }
  cout << cnt;
}






Measured memory_bytes: 3624
#include <iostream>

using namespace std;

#define SENTINEL 2000000000
int compareCount = 0;

void merge(int A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1];
    int R[n2];
    for (int i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }
    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    int i = 0;
    int j = 0;
    for (int k = left; k < right; k++) {
        compareCount++;
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
    }
}

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

int main() {
    int n;
    scanf("%d", &n);
    int A[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    mergeSort(A, 0, n);
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            printf("%d", A[i]);
        } else {
            printf(" %d", A[i]);
        }
    }
    printf("\n");
    printf("%d\n", compareCount);

    return 0;
}

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

int main(){
    string price;
    cin >> price;

    price = '0' + price;
    reverse(price.begin(),price.end());
    int n= price.length();

    vector<vector<int>> dp(n+1,vector<int>(2, 1e9));// dp[i][j] = i-th digit, j=0/1 : carry NO/YES
    dp[0][0] = 0;
    for(int i=0; i<n; i++){
        int x = price[i] - '0';
        
        dp[i+1][0] = min(dp[i][0] + x,      dp[i][1] + (x+1));
        dp[i+1][1] = min(dp[i][0] + (10-x), dp[i][1] + (10-(x+1)));
    }
    cout << dp[n][0] << endl;
    return 0;
}

Measured memory_bytes: 55856
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
        return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
        return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}
 
template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
    for (const T &x : s)
        out << x << ' ';
    return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl "\n"
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    ll n,x,t;
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t<<nl;
}


Measured memory_bytes: 3640
#[allow(unused_macros)]
macro_rules! i {
    ( $( $t:ty ),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let mut i = s.split_whitespace();
        ( $( i.next().unwrap().parse::<$t>().unwrap() ),* )
    }};
    ( $( $t:ty ),* ; $e:expr ) => {
        (0..$e).map(|_| i!( $( $t ),* )).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b) = i!(u32, u32);
    println!("{}", (a + b + 1) / 2);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
using namespace std;
vector<int> v,w[200010];
long long dp[200010],sum[200010] = {},mod = 1000000007;
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		int c; cin >> c;
		if(v.size()==0 || v.back()!=c) v.push_back(c);
	}
	n = v.size();
	dp[0] = 1;
	for(i=1;i<=n;i++){
		int x = v[i-1];
		dp[i] = (dp[i-1] + sum[x])%mod;
		sum[v[i-1]] = dp[i];
	}
	cout << dp[n] << endl;
}

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

int main(void){

	int N,A,B;
	cin >> N >> A >> B;
	if((B-A)%2==0){
		cout << "Alice" << endl;
	}else{
		cout << "Borys" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  int n;cin>>n;
  string s;cin>>s;
  int x=0;
  int maxv=0;
  rep(i,s.size()){
   if(s[i]=='I')x++;
    else x--;
    maxv=max(maxv,x);
  }
  cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
n_list = []
for i in range(N):
  n = input()
  n_list.append(n)
  
print('AC x ', n_list.count('AC'))
print('WA x ' , n_list.count('WA'))
print('TLE x ', n_list.count('TLE'))
print('RE x ' , n_list.count('RE'))


Measured memory_bytes: 16296
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)

	counts := [51]int{}
	patties := [51]int{}

	counts[0] = 1
	patties[0] = 1
	for i := 1; i <= 50; i++ {
		counts[i] = counts[i-1]*2 + 3
		patties[i] = patties[i-1]*2 + 1
	}

	var eats func(n, x int) int
	eats = func(n, x int) int {
		if n == 0 {
			if x <= 0 {
				return 0
			}
			return 1
		}

		count := counts[n]
		if count/2+1 == x {
			return patties[n-1] + 1
		}

		if count/2+1 < x {
			return eats(n-1, x-(count/2+1)) + patties[n-1] + 1
		}

		return eats(n-1, x-1)
	}

	ans := eats(n, x)
	fmt.Println(ans)
}


Measured memory_bytes: 1852
import sys
sys.setrecursionlimit(1000000)

S = list(input())
L = len(S)
b = S.count("B")
w = S.count("W")

def f(i, result):
  if S[i] == S[i-1]:
    if i == 1:
      print(result)
      exit()
    else:
      f(i-1, result)
  else:
    if i == 1:
      result += 1
      print(result)
      exit()
    else:
      result += 1
      f(i-1, result)
      
if L == 1:
  result = 0
  print(result)
  exit()
elif b == L or w == L:
  result = 0
  print(result)
  exit()
else:
  f(L-1, 0)

Measured memory_bytes: 99268
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# from numpy import array, sum

N, A, B = map(int, input().split())

h_li = []

for i in range(N):
	h_li.append(int(input()))

def all_beatable_check(k):
	# All enemy get B damage every time
	h_damaged = [h - B*k for h in h_li]
	# print(h_damaged)
	# A-B damage will be additionally given to enemies s.t. HP > 0
	ex_dmg = A - B
	h_ex_needed = [(h+ex_dmg-1) // ex_dmg if h > 0 else 0 for h in h_damaged]
	# print(h_ex_needed)
	# how many A-B damage is needed to beat all enemies
	hits_needed = sum(h_ex_needed)
	if hits_needed > k:
		return False
	else:
		return True

MIN_K = 0         # impossible
MAX_K = max(h_li) # possible

while MAX_K - MIN_K > 1:
	# print(f"{MIN_K}-{MAX_K} {MIN_K + (MAX_K - MIN_K) // 2}")
	k = (MIN_K + MAX_K) // 2
	res = all_beatable_check(k)
	if res is True:
		MAX_K = k
	elif res is False:
		MIN_K = k

print(MAX_K)

Measured memory_bytes: 14956
import java.util.Scanner;
public class Main {
	Scanner sc = new Scanner(System.in);
	int N;	//要素数
	int v=0;	//保存用変数
	int j=0;	//添字のための変数
	int[] A;
	
	public void input() {
		N = sc.nextInt();
		A = new int[N];
		for(int i=0; i<N; i++) { A[i] = sc.nextInt(); }
	}
	
	//ソート部分
	public void conpute() {
		output();
		for(int i=1; i<=N-1; i++) {
			v = A[i];
			j = i-1;
			while(j>=0 && A[j] > v) {
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = v;
			output();
		}
	}
	
	public void output() {
		System.out.print(A[0]);
		for(int i=1; i<N; i++) {
			System.out.print(" "+A[i]);
		}
		System.out.println();
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.conpute();
	}
}



Measured memory_bytes: 31180
#include <iostream>                                                      
using namespace std;                                                     
                                                                         
int main() {                                                             
  while (true) {                                                         
    int n, x;                                                            
    cin >> n >> x;                                                       
    if (n==0 && x==0) {                                                  
      break;                                                             
    }                                                                    
    int ans = 0;                                                         
    for (int i=1; i<=n; i++) {                                           
      for (int j=i+1; j<=n; j++) {                                       
        for (int k=j+1; k<=n; k++) {                                     
          if (i+j+k==x) {                                                
            ans++;                                                       
          }                                                              
        }                                                                
      }                                                                  
    }                                                                    
    cout << ans << endl;                                                 
  }                                                                      
  return 0;                                                              
}                                                                        
                

Measured memory_bytes: 3016
# -*- coding: utf-8 -*-

import itertools

while True:
 n, x = map(int, raw_input().split())
 if n==0 and x==0: break
 count = 0
 for a, b, c in itertools.combinations(range(1, n+1), 3):
  if a+b+c==x:
   count += 1
 print count

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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}
template<typename T>
vector<T> make_v(size_t a, T b){ return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts){
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations

// solve
int main(){
    
    string s;
    cin >> s;

    int n = (int)s.size() + 1;
    vector<int> ans(n, 0);

    s = '>' + s + '<';

    rep(i, n){
        if(s[i] == '>' && s[i + 1] == '<'){
            for(int j = i - 1, c = 1; j >= 0; j--, c++){
                chmax(ans[j], c);
                if(s[j] == '<')break;
            }
            for(int j = i + 1, c = 1; j < n; j++, c++){
                chmax(ans[j], c);
                if(s[j + 1] == '>')break;
            }
        }
    }

    long long sum = 0;
    rep(i, n)sum += ans[i];
    cout << sum << '\n';
    return 0;

}

Measured memory_bytes: 3356
/*! if g++ -g alds_1_8_b.cpp -o alds_1_8_b.out; then ./alds_1_8_b.out < alds_1_8_b.test; fi
 */

#include <memory>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



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

class node;
typedef shared_ptr<node> nodep;

class node{
public:
  int id;
  nodep left, right, parent;
  node(int _id, nodep l, nodep r, nodep p): id(_id), left(l), right(r), parent(p) {}
  node(int i): id(i), left(NULL), right(NULL), parent(NULL) {}
};

nodep root(NULL);

void insert(int i){
  nodep z(new node(i));
  nodep y(NULL);
  nodep x = root;
  while(x.get() != NULL){
    y = x;
    if(z->id < x->id){
      x = x->left;
    } else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y.get() == NULL){
    root = z;
  } else if(z->id < y->id){
    y->left = z;
  } else{
    y->right = z;
  }
}

void find(int i){
  nodep x = root;
  while(x.get() != NULL){
    if(x->id == i){
      cout << "yes" << endl;
      return;
    }
    if(i < x->id){
      x = x->left;
    } else{
      x = x->right;
    }
  }
  cout << "no" << endl;
}

void mid(nodep nd){
  if(nd.get() == NULL){
    return;
  }
  mid(nd->left);
  cout << " " << nd->id;
  mid(nd->right);
}

void pre(nodep nd){
  if(nd.get() == NULL){
    return;
  }
  cout << " " << nd->id;
  pre(nd->left);
  pre(nd->right);
}

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if(s[0] == 'i'){
      int id;
      cin >> id;
      insert(id);
    } else if(s[0] == 'f'){
      int id;
      cin >> id;
      find(id);
    }else{
      mid(root); cout << endl;
      pre(root); cout << endl;
    }
  }  
  return 0;
}

Measured memory_bytes: 38720
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a[5], n, mini = 1e16;
	cin >> n;
	for(int i = 0; i < 5; i++){
		long long x;
		cin >> x;
		mini = min(mini, x);
	}
	long long ans = ceil((double)n / mini) + 4;
	cout << max(ans, (long long)5);
	
	
}

Measured memory_bytes: 256
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define cps CLOCKS_PER_SEC
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
#define MOD 1000000007
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
int power(int x,int y){ int res = 1; while(y>0){   if(y&1) res = (res*x)%MOD;
        y >>= 1; x = (x*x)%MOD; } return res; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

bool check(int mid,int x,int y){
    int ret = 0;
    for(int i=max(mid/2-3,1LL);i<=min(mid/2+3,mid);i++){
        int a = i,b = mid-i+1;
        if(a >= x) a++;
        if(b >= y) b++;
        ret = max(ret,a*b);
    }
    return ret < x*y;
}

void solve(){
    int q; cin>>q;

    while(q--){
        int x,y; cin>>x>>y;

        int s = 1,e = 3e9;
        int ans = 0;

        while(s <= e){
            int mid = (s+e)>>1;
            if(check(mid,x,y)) ans = mid,s = mid+1;
            else e = mid-1;
        }

        cout<<ans<<endl;
    }
}
 
signed main(){

    FastRead; 


    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}



Measured memory_bytes: 256
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools



sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

A, B =  map(int,input().split())
if(A<=8 and B<=8):
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 38868
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES(n)          cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n)          cout << ((n) ? "Yes" : "No"  ) << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

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

  int cnts[5] = {0};
  rep(i, 6) cnts[a[i]]++;

  for (int i = 1; i < 5; i++) {
    if (cnts[i] == 0 || cnts[i] == 3) {
      outl("NO");
      return;
    }
  }
  outl("YES");
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b; cin >> a >> b;
    if(1 <= a && a <= 9 && 1 <= b && b <= 9){
        cout << a*b << endstr;
    }
    else{
        cout << -1 << endstr;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define CloseIO std::ios::sync_with_stdio(false)
const ll N = 8e6+1000;
const ll Mod = 100;
const ll INF = 0x3f3f3f3f3f;
vector<pair<ll,ll> > mp(N);
int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll sum = c+d;
  c = max(c,d);
  d = sum - c;
  ll tmp = (c*d)/__gcd(c,d);
  ll t1 = a/c, t2 = a/d, t3 = a/tmp;
  ll k1 = b/c, k2 = b/d, k3 = b/tmp;
  if(a % c == 0) t1--;
  if(a % d == 0) t2--;
  if(a % tmp == 0) t3--;
  cout<<b-a+1-(k1-t1) - (k2 - t2) + (k3 - t3)<<endl;

    return 0;
}


Measured memory_bytes: 125312
s = list(input())

A = int("".join(s[:2]))
B = int("".join(s[2:]))

if A <= 12 and B <= 12 and A >= 1 and B >= 1:
    print('AMBIGUOUS')
elif (A > 12 or A == 0) and B <= 12 and B != 0:
    print('YYMM')
elif A <= 12 and (B > 12 or B == 0) and A != 0:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3060
n,k = gets.chomp.split(" ").map(&:to_i)
a_arr = gets.chomp.split(" ").map(&:to_i)

0.upto(n-k-1) do |i|
  if a_arr[i] < a_arr[k + i]
    puts "Yes"
  else
    puts "No"
  end
end


Measured memory_bytes: 36016
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

using LL = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 100001;
int n, m, a, b, d[N];
VI e[N], q;

int main() {
    scanf("%d%d", &n, &m);
    REP(i, n + m - 1) {
        scanf("%d%d", &a, &b);
        e[b].push_back(a);
        d[a]++;
    }
    FOR(i, 1, n) if (!d[i])
        q.push_back(i);
    REP(i, q.size()) {
        for (int j : e[q[i]]) {
            d[j]--;
            if (!d[j])
                q.push_back(j);
        }
    }
    REP(i, n)
        d[q[i]] = i;
    FOR(i, 1, n) {
        int f = 0;
        for (int j : e[i])
            if (f == 0 || d[f] > d[j])
                f = j;
        printf("%d\n", f);
    }


    return 0;
}

Measured memory_bytes: 7156
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())

ll n,p;
int main(){
    cin>>n>>p;
    ll ans=1;
    for(ll i=2;i*i<=p;i++){
        if(p%i) continue;
        ll count=0;
        //割れる回数を調べる
        while(p%i==0) count++,p/=i;
        //n回以上割れるものをかける
        while(count>=n) count-=n,ans*=i;
    }
    if(p!=1 && n==1) ans*=p;
    cout<<ans<<endl;
    return 0;
}








Measured memory_bytes: 256
import heapq
N = int(input())
V = list(map(int, input().split()))
heapq.heapify(V)
while len(V) > 2:
    min_ = heapq.heappop(V)
    second_min = heapq.heappop(V)
    heapq.heappush(V, (min_+second_min)/2)
else: print((V[0] + V[1]) / 2)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#define MN 40002
#define MM 5000001
#define ll long long
#define ld long double
#define inf 0x7fffffff
#define clz 1000000007
#define ers(arr,val) memset(arr,val,sizeof(arr));
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repd(i,b,a) for(int i=(b);i>=(a);i--)
#define repe(i,u) for(int i=h[u];i;i=e[i].nx)
using namespace std;
struct xx{
	int x,y,id;
}a[100001];
int n,m,p=1;
int ans[100001][2];
bool cmp(xx p,xx q){
	return p.x==q.x?p.y<q.y:p.x<q.x;
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,m){
		scanf("%d%d",&a[i].x,&a[i].y);a[i].id=i;
	}
	sort(a+1,a+m+1,cmp);
	int num=1;
	rep(i,1,m){
		ans[a[i].id][0]=a[i].x; ans[a[i].id][1]=num;
		if(a[i].x!=a[i+1].x) num=1;
		else num++;
	}
	rep(i,1,m){
		printf("%06d%06d\n",ans[i][0],ans[i][1]);
	}
	return 0;
}

Measured memory_bytes: 3456
import Control.Applicative
import Data.List.Split
main = do
  s <- lines <$> getContents
  mapM_ (putStrLn . decode) s

decode::String -> String
decode s = concat $ head v:(map aux $ tail v)
  where
    v = splitOn "@" s
    aux t = concat (replicate (read [t!!0]) [t!!1]) ++ (tail.tail $ t)

Measured memory_bytes: 3668
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while a[i] + b[j] > K:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47508
#include "bits/stdc++.h"
#include <cmath>

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

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

    int min_s = 100;
    for(char s = 'a'; s <= 'z'; s++){
        string Si = S;
        int N = S.size();
        int sum = 0;
        while(true){
            map<char,int> cnt;
            for(int i = 0; i < N; i++){
                cnt[Si[i]]++;
            }
            if(cnt.size() == 1){
                break;
            }
            for(int i = 1; i < N; i++){
                if(Si[i] == s) Si[i - 1] = s;
            }
            sum++;
            N--;

        }
        min_s = min(min_s, sum);
    }
    cout << min_s << endl;
}

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

using namespace std;
typedef long long int ll;


ll substrp(string S,ll P)
{
	//cout<<"hello"<<endl;
	ll count=0;
	if(10%P==0)
	{
		for(int i=0;i<S.length();i++)
		{
			if((S[i]-'0')%P==0)
			{
				count+=i+1;
			}
		}
	}
	else
	{
		map<ll,ll>M;
		ll a=0;
		vector<int>A(S.length());
		ll total=1;
		A[0]=1;
		for(ll i=1;i<S.length();i++)
		{
			total=((10%P)*(total))%P;
			A[i]=total;
			//cout<<A[i]<<endl;
		}	
		
		for(int i=S.length()-1;i>=0;i--)
		{	
			a=((S[i]-'0')%P*A[S.length()-1-i]+a)%P;
			if(a==0)
			{
				
				if(M.count(a)==0)
				{
					count+=1;
					M[a]=1;
				}
				else
				{
					count+=M[a]+1;
					M[a]+=1;
				}
			}
			else
			{
				if(M.count(a)==0)
					M[a]=1;
				else
				{
					count+=M[a];
					M[a]+=1;
				}

			}
		}
	}
	return count;
}

int main()
{
	string S;
	ll N,P;
	cin>>N>>P;
	cin>>S;
	cout<<substrp(S,P)<<endl;
	//out<<ceil(pow(10,2))<<endl;
	return 0;
}

Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    for( int i=0; i<k; i++){
        if(c <= b){
            c = 2*c;
        }else if( a >= b){
            b = 2*b;
        }
    }
    if(c > b && b > a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}




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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    string s;
    cin >> s;

    if(s.size() == 2) {
        if(s[0] == s[1]) cout << 1 << " " << 2 << endl;
        else cout << -1 << " " << -1 << endl;
        return 0;
    }
    rep(i, 0, s.size() - 2) {
        int cnt1 = 1, cnt2 = 0;
        char cur = s[i];
        rep(j, 1, 3) {
            if(cur == s[i + j]) cnt1++;
            else cnt2++;
        }
        if(cnt1 > cnt2) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

    char cur = s[s.size() - 2];
    if(cur == s[s.size() - 1]) {
        cout << s.size() - 2 << " " << s.size() << endl;
        return 0;
    }

    cout << -1 << " " << -1 << endl;

}


Measured memory_bytes: 512
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 1e9 + 7;
struct Edge {
	int f, t, cap, flow = 0;
	Edge(int f, int t, int cap) : f(f), t(t), cap(cap) {}
};
const int inf = 1e9;
struct Dinic {
	int n, m, s, t;
	vector<Edge> edges;
	queue<int> q;
	vi ptr, lvl;
	vvi g;
	void init(int n, int s, int t) {
		this->n = n;
		this->m = 0;
		this->s = s;
		this->t = t;
		ptr.resize(n+1);
		lvl.resize(n+1);
		g.resize(n+1);
	}
	void add_edge(int f, int t, int cap) {
		edges.emplace_back(f, t, cap);
		edges.emplace_back(t, f, 0);
		g[f].pb(m);
		g[t].pb(m+1);
		m+=2;
	}
	bool bfs() {
		fill(all(lvl), -1);
		lvl[s] = 0;
		q.push(s);
		while(!q.empty()) {
			int u = q.front();
			q.pop();
			for(auto id : g[u]) {
				if(edges[id].cap-edges[id].flow<1||lvl[edges[id].t]!=-1) continue;
				lvl[edges[id].t]=lvl[u]+1;
				q.push(edges[id].t);
			}
		}
		return lvl[t]==-1;
	}
	ll dfs(int v, int cap) {
		if(cap==0)
			return 0;
		if(v==t)
			return cap;
		for(;ptr[v]<g[v].size();ptr[v]++) {
			int id = g[v][ptr[v]];
			int u = edges[id].t;
			if(lvl[v]+1!=lvl[u]||edges[id].cap-edges[id].flow<1) continue;
			int t = dfs(u, min(cap, edges[id].cap-edges[id].flow));
			if(t==0) continue;
			edges[id].flow+=t;
			edges[id^1].flow-=t;
			return t;
		}
		return 0;
	}
	ll flow() {
		ll ans = 0;
		while(true) {
			if(bfs()) break;
			fill(all(ptr), 0);
			while(ll inc = dfs(s, inf)) ans += inc;
		}
		return ans;
	}
};
int main() {//DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m, u, v, c;
	cin >> n >> m;
	Dinic x;
	vi deg;
	vector<pair<int, int>> edges;
	deg.resize(n+1);
	for(int i = 0; i < m; i++) {
		cin >> u >> v;
		edges.pb({u, v});
		deg[u]++;
		deg[v]++;
	}
	int si, f1, f2, c4 = 0;
	si=f1=f2=-1;
	for(int i = 1; i <= n; i++) {
		if(deg[i]&1) return cout << "No", 0;
		if(deg[i]>4) si = i;
		else if(deg[i]>2) {
			c4++;
			if(f1==-1)f1=i;
			else f2 = i;
		}
	}
	if(si!=-1||c4>2) return cout << "Yes", 0;
	if(c4<2) return cout << "No", 0;
	x.init(n, f1, f2);
	for(auto i : edges) {//FLOW = MIN CUT, VERY ORZ
		x.add_edge(i.first, i.second, 1);
		x.add_edge(i.second, i.first, 1);
	}
	if(x.flow()>2) return cout << "No", 0;//SO SAD
	cout << "Yes";
}


Measured memory_bytes: 19944
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define ff first
#define ss second
#define pb emplace_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
#define INFi LLONG_MAX;
int main()
{
    ll n,W;
    cin >> n >> W;
    ll dp[n+1][100005];
    for(ll i=0;i<n+1;i++)
    {
        for(ll j=0;j<100005;j++)
        {
            if(j==0)     dp[i][j] = 0;
            else                 dp[i][j] = 10000000000000;
        }
    }
    for(ll i=1;i<n+1;i++)
    {
        ll w,v;
        cin >> w >> v;
        for(ll j=1;j<100005;j++)
        {
            if(j-v>=0)  dp[i][j] = min(dp[i][j],dp[i-1][j-v] + w);
            dp[i][j] = min(dp[i][j],dp[i-1][j]);
        }
    }
    ll ans = 0;
    for(ll i=1;i<100005;i++)
    {
        if(dp[n][i]<=W)   ans = max(ans,i);
    }
    cout<<ans;
}

Measured memory_bytes: 79104
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())
b = [0] * n
for i in range(n):
	b[i] = int(input())

for i in range(n):
	for j in range(3):
		if a1[j] == b[i]:
			a1[j] = -1
	for j in range(3):
		if a2[j] == b[i]:
			a2[j] = -1
	for j in range(3):
		if a3[j] == b[i]:
			a3[j] = -1
if set(a1) == {-1}:
	print("Yes")
elif set(a2) == {-1}:
	print("Yes")
elif set(a3) == {-1}:
	print("Yes")
elif a1[0] == a2[0] and a3[0] == -1:
	print("Yes")
elif a1[1] == a2[1] and a3[1] == -1:
	print("Yes")
elif a1[2] == a2[2] and a3[2] == -1:
	print("Yes")
elif a1[0] == a2[1] and a3[2] == -1:
	print("Yes")
elif a1[2] == a2[1] and a3[0] == -1:
	print("Yes")
else:
	print("No")



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;

    int ans=INT_MAX;

    for (int t = 0; t <= max(X, Y) * 2; t++) {
        int cur_cost = A * max(X - t / 2, 0) + B * max(Y - t / 2, 0) + t * C;
        if (ans >= cur_cost) {
            ans = cur_cost;
        } 
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";
 
int main(){
  char s[5];
  cin >> s;
  rep(i, 1, 4){
    if (s[i] == s[i-1]){
      print("Bad");
      exit(0);
    }
  }
  print("Good");
  
  return 0;
}

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


int main()
{
  string a,b;
  cin>>a>>b;
  
  
  int siz=a.size();
  int count=0;
  for(int i=0;i<siz;i++)
  {
    if(a[i]!=b[i])
      count++;
  }
  
  cout<<count<<endl;
  
  return 0;
}

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

long long n,prime_son[209],cnt[209],a[209],tot,endd,ANS;
long long prime_son2[209],cnt2[209],tot2,end2,ANS2 = 1;

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

void FenJie(long long x)
{
	for(long long i = 2;i*i<=x;i++)
	{
		if(isPrime(i)==false)continue;
		if(x%i==0)
		{
			prime_son[++tot] = i;
			while(x%i==0)x /= i,cnt[tot]++;
		}
	}
	if(x!=1)prime_son[++tot] = x,cnt[tot]++;
	endd = tot;
}
void FenJie2(long long x)
{
	for(long long i = 2;i*i<=x;i++)
	{
		if(isPrime(i)==false)continue;
		if(x%i==0)
		{
			prime_son2[++tot2] = i;
			while(x%i==0)x /= i,cnt2[tot2]++;
		}
	}
	if(x!=1)prime_son2[++tot2] = x,cnt2[tot2]++;
	end2 = tot2;
}

void Judge(long long x,long long m)
{
	long long remain = m/x;
	if(x==1)return;
	if(remain%x==1)ANS++;//cout << "FUCK\n";
	else if(remain%x==0)Judge(x,remain);
}

void dfs(long long id,long long t,long long now)
{
	a[id] = t;
	for(long long i = 1;i<=t;i++)now *= prime_son[id];
	if(id==endd)
	{
		Judge(now,n);
		//cout << now << "!\n";//
		return;
	}
	for(long long i = 0;i<=cnt[id+1];i++)dfs(id+1,i,now);
}

int main()
{
	cin >> n;
	FenJie(n);
	FenJie2(n-1);
	for(int i = 1;i<=end2;i++)ANS2 *= cnt2[i]+1;
	
	//for(long long i = 1;i<5;i++)cout << prime_son[i] << " " << cnt[i] << endl;//
	//cout << "XHZNB!\n" << ANS2 << endl;//
	//for(long long i = 1;i<10;i++)cout << prime_son2[i] << " " << cnt2[i] << endl;//
	
	for(long long t = 0;t<=cnt[1];t++)dfs(1,t,1);
	cout << ANS+ANS2-1;
	return 0;
}

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

#define N 100000

using namespace std;

int n, m, k;

int main() {
    // freopen ("a.in", "r", stdin);

    long long x, y;
    cin >> x >> y;

    long long nr = 0;
    for (long long i = x; i <= y; i *= 2)
        nr++;

    cout << nr;
    return 0;
}

Measured memory_bytes: 256
#define max(a,b)(a=a<b?b:a)
long c,x[1<<17],v[1<<17],ans,L,R,Rmax,Lmax;i;
main(n){
	for(scanf("%d%ld",&n,&c);~scanf("%ld%d",x+i,v+i);)L+=v[i++];
	for(;i--;){
		L-=v[i];
		R+=v[i];
		max(ans,L-!!i*x[i-1]*2+max(Rmax,R-(c-x[i])));
	}
	for(;i<n;i++){
		L+=v[i];
		R-=v[i];
		max(ans,R-(i!=n-1)*(c-x[i+1])*2+max(Lmax,L-x[i]));
	}
	printf("%ld",ans);
}

Measured memory_bytes: 1792
// main.cpp
// ITP1_8_A_xc
// 大文字と小文字の入れ替え
// fAIR, LATER, OCCASIONALLY CLOUDY.
// Fair, later, occasionally cloudy.

#include <iostream>
#include <cctype>
using namespace std;

int main() {
    string s;
    getline(cin, s);
    
    for(int i=0;i<s.length();i++){
        if(isalpha(s[i])){
            if(islower(s[i])){
                s[i] = toupper(s[i]);
            }else{
                s[i] = tolower(s[i]);
            }
        }
    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define repi(i, a, b) for(int i=a; i>b; i--)
#define db(x) (cerr << #x << ": " << x << '\n')
#define iceil(n, x) ((n + x - 1) / x)
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define fi first
#define se second
#define umap unordered_map
#define umapi umap<int, int>
#define mapi map<int, int>
#define uset unordered_set
#define useti uset<int>
#define seti set<int>
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 
#define int ll
using namespace std;

template<typename T>
using maxpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using minpq = priority_queue<T>;

int ans = 2 * 1ll * 1e5 * 1e9;

inline void updateans(int a, int b, int c, int d) {
//	db(ans), db(a), db(b), db(c), db(d);
	int mx = max(a, max(b, max(c, d)));
	int mn = min(a, min(b, min(c, d)));
	ans = min(ans, mx - mn);
//	db(ans);
}

main()
{	
	#ifndef ONLINE_JUDGE
		//freopen("C:\\Users\\HP\\Desktop\\input.txt", "r", stdin);
//		freopen("C:\\Users\\HP\\Desktop\\output.txt", "w", stdout);
	#endif
	clock_t clk = clock();
	cerr << "I will return...\n";
	
	int n; cin >> n;
	int a[n];
	
	for(int&i : a) cin >> i;
	
	int j = 0, k = 2;
	int l1, l2, r1, r2;
	
	l1 = a[0], l2 = a[1];
	r1 = a[2], r2 = 0;
	
	rep(i, 3, n) r2 += a[i];
	
	while(k < n - 1 && abs(r1 - r2 + 2 * a[k + 1]) < abs(r1 - r2))
		k++, r1 += a[k], r2 -= a[k];
		
	updateans(l1, l2, r1, r2);
	
	rep(i, 2, n - 2) {
		l2 += a[i], r1 -= a[i];
		if(i == k) {
			k++; r1 += a[k], r2 -= a[k];
		}
		while(j < i - 1 && abs(l1 - l2 + 2 * a[j + 1]) < abs(l1 - l2))
			j++, l1 += a[j], l2 -= a[j];
		while(k < n - 1 && abs(r1 - r2 + 2 * a[k + 1]) < abs(r1 - r2))
			k++, r1 += a[k], r2 -= a[k];
		updateans(l1, l2, r1, r2);
	}
	
	cout << ans << '\n';
	
	cerr << "...don't you ever hang your head.\n";
	cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << '\n';
}








Measured memory_bytes: 1792
def factor(n):
    """
    素因数分解
    """
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr

def main():
    n = int(input())
    if n == 1:
        print(0); return
    fs = factor(n)
    ans = 0
    for f in fs:
        for e in range(1, f[1]+1):
            z = f[0] ** e
            if n % z == 0:
                n //= z
                ans += 1
    print(ans)

main()


Measured memory_bytes: 9268
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
ans = 0
for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
    else:
        ans += a[i]
        if a[i+1] >  b[i]-a[i]:
            ans += b[i]-a[i]
            a[i+1] -= b[i]-a[i]
        else:
            ans += a[i+1]
            a[i+1] = 0
print(ans)

Measured memory_bytes: 24136