akhauriyash/Code-Regression huggingface dataset:
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

N = INT()
ans = False
cnt = 0
for i in range(N):
    a, b = MAP()
    if a == b:
        cnt += 1
        if cnt >= 3:
            ans = True
    else:
        cnt = 0
if ans:
    Yes()
else:
    No()


Measured memory_bytes: 9532
MOD = 1000000007

n = int(input())
a = list(map(int,input().split()))

ans = 0
for k in range(60):
    mask = 1<<k
    cnt1 = sum(1 for x in a if x&mask != 0)
    ans += cnt1*(n-cnt1)*(1<<k)
print(ans%MOD)

Measured memory_bytes: 43692
//
// Created by yamunaku on 2020/05/10.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

ll modpow(ll x, ll a){
    ll ans = 1;
    while(a){
        if(a & 1) ans = ans * x % MOD;
        a >>= 1;
        x = x * x % MOD;
    }
    return ans;
}

ll inv(ll x){
    return modpow(x, MOD - 2);
}

vector<ll> fact, invfact;

void buildFact(int n){
    fact = vector<ll>(n + 1, 1);
    invfact = vector<ll>(n + 1, 1);
    for(int i = 1; i <= n; i++){
        fact[i] = fact[i - 1] * i % MOD;
    }
    invfact[n] = inv(fact[n]);
    for(int i = n - 1; i >= 1; i--){
        invfact[i] = invfact[i + 1] * (i + 1) % MOD;
    }
}

ll bcomb(int n, int k){
    return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}

int main(){
    //CFS;
    ll n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    buildFact(n);
    rep(i, k + 1){
        ans = (ans + bcomb(n - 1, i) * m % MOD * modpow(m - 1, n - 1 - i) % MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6360
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int l = sc.nextInt();
    int[] data = new int[n+1];
    int total_apple = 0;
    int except_apple = 0;
    int apple = 0;
    int apple_i = 0;
    int answer = 0;
    int j = 1;

    for(int i = 1;i <= n;i++) {
      data[i] = l + i - 1;
      total_apple += data[i];
    }

    except_apple = total_apple - data[1];
    apple = Math.abs(total_apple - except_apple);

    for(int i = 1;i <= n;i++) {

      except_apple = total_apple - data[i];
      apple_i = Math.abs(total_apple - except_apple);

      if(apple > apple_i) {
        apple = apple_i;
        j = i;
      }

    }

    answer = total_apple - data[j];

    System.out.println(answer);

  }

}


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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i=0; i<n; i++) {
    cin >> a.at(i);
    if (a.at(i) == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  long long ans = 1;

  for (int i=0; i<n; i++) {
    double log_ans = log(ans);
    double log_a = log(a.at(i));
    if ( log_ans + log_a > 18*log(10.0)*1.001){
      cout << -1 << endl;
      return 0;
    }
    ans *= a.at(i);
    if (ans > 1000000000000000000) {
      cout << -1 << endl;
      return 0;
    }
  }  
  cout << ans << endl;
}

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

vector<int> binaryExp(int n) {
    vector<int> v = {0};
    while (n > 0) {
        v.push_back(n%2);
        n /= 2;
    }
    return v;
}

int main()
{

#ifdef _d
    freopen("input.txt", "r", stdin);
#endif

    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char> > a(h+1, vector<char> (w+1));
    int white = 0;
    int black = 0;
    vector<int> rb(h+1, 0);
    vector<int> cb(w+1, 0);
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cin >> a[i][j];
            if (a[i][j] == '.') {
                ++white;
            } else if (a[i][j] == '#') {
                ++black;
                ++rb[i];
                ++cb[j];
            }
        }
    }
    int rmx = (int)pow(2, h)-1;
    int cmx = (int)pow(2, w)-1;
    int ans = 0;
    for (int i = 0; i <= rmx; ++i) {
        for (int j = 0; j <= cmx; ++j) {
            vector<int> p = binaryExp(i);
            vector<int> q = binaryExp(j);
            int m = p.size()-1;
            int n = q.size()-1;
            int candy = 0;
            for (int x = 1; x <= m; ++x) {
                if (p[x] == 1) {
                    candy += rb[x];
                }
            }
            for (int y = 1; y <= n; ++y) {
                if (q[y] == 1) {
                    candy += cb[y];
                }
            }
            for (int x = 1; x <= m; ++x) {
                for (int y = 1; y <= n; ++y) {
                    if (p[x] == 1 && q[y] == 1) {
                        if (a[x][y] == '#') {
                            --candy;
                        }
                    }
                }
            }
            if (black-candy == k) {
                // cerr << i << " " << j << "\n";
                ++ans;
            }
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i<n;i++)
int main(){
int n,tem;
cin >> n;
vector<int> a(n);
rep(i,n){
    cin>>tem;
    a[tem-1]=i+1;
}
rep(i,n)printf("%d ", a[i]);
printf("\n");

}

Measured memory_bytes: 1152
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	double d;
	scanf("%lf", &d);

	double ans = d*sqrt(2);

	for (int x = 1; x <= 10; x++) {
		if (d*d - x*x >= 0) {
			double y = sqrt(d*d - x*x);
			ans = max(ans, x + (y < 1.0 ? 1.0 : y));
		}
	}

	printf("%.12lf\n", ans);

	return 0;
}

Measured memory_bytes: 2764
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
vector <pair<pair<int,int>,llint> > v;
vector <llint> v1[200005];
vector <pair<llint,int> > v2[200005];
llint t[600005],p[600005],dp[200005],maxi,off=1,x1;
void send(int x) {
	if(p[x]==0) return;
	if(t[x]==-1e17) t[x]=p[x];
	else t[x]+=p[x];
	if(x<off) {
		p[x*2]+=p[x];
		p[x*2+1]+=p[x];
	}
	p[x]=0;
}
void update(int x,int lo,int hi,int l,int r,llint v) {
	send(x);
	if(lo>r or hi<l) return;
	if(lo>=l && hi<=r) {
		p[x]+=v;
		send(x);
		return;
	}
	update(x*2,lo,(lo+hi)/2,l,r,v);
	update(x*2+1,(lo+hi)/2+1,hi,l,r,v);
	if(x<off) t[x]=max(t[x*2],t[x*2+1]);
}
llint query(int x,int lo,int hi,int l,int r) {
	send(x);
	if(lo>r or hi<l) return -1e17;
	if(lo>=l && hi<=r) return t[x];
	return max(query(x*2,lo,(lo+hi)/2,l,r),query(x*2+1,(lo+hi)/2+1,hi,l,r));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin >> n >> m;
	while(off<n) off*=2;
	for(int i=1;i<off+n;i++) {
		t[i]=-1e17;
		//p[i]=-1e17;
	}
	for(int i=0;i<m;i++) {
		llint a,b,c;
		cin >> a >> b >> c;
		v.push_back(make_pair(make_pair(a-1,b-1),c));
		v1[a-1].push_back(c);
		v2[b].push_back(make_pair(-c,a-1));
	}
	for(int i=0;i<n;i++) {
		for(int j=0;j<v1[i].size();j++) {
			x1+=v1[i][j];
			if(i) update(1,0,off-1,0,i-1,v1[i][j]);
		}
		for(int j=0;j<v2[i].size();j++) {
			x1+=v2[i][j].first;
			if(v2[i][j].second) update(1,0,off-1,0,v2[i][j].second-1,v2[i][j].first);
		}
		dp[i]=x1;
		if(i) dp[i]=max(dp[i],query(1,0,off-1,0,i-1));
		maxi=max(maxi,dp[i]);
		/*cout << dp[i] << "\n";
		for(int j=0;j<i;j++) {
			cout << query(1,0,off-1,j,j) << " ";
		}
		cout << "\n";
		cout << query(1,0,off-1,0,0) << "\n";*/
		update(1,0,off-1,i,i,dp[i]);
		//cout << dp[i] << " " << query(1,0,off-1,0,0) << "\n";
	}
	cout << maxi;
	return 0;
}


Measured memory_bytes: 36576
using System;

class Program
{
  static bool _trigger;
  static void Main()
  {
    var line = Console.ReadLine();
    var _line = line.Split(" ");
    int x = int.Parse(_line[0]);
    int y = int.Parse(_line[1]);
    
    for (int i = 0; i < x + 1; i++)
    {
      if (i * 2 + (x - i) * 4 == y)
      {
        _trigger = true;
      }
    }
    string message = _trigger ? "Yes" : "No";
    Console.WriteLine(message);
    
  }
}

Measured memory_bytes: 27148
import collections
s1=input()
s2=input()
s1 = list(s1)
s2 = list(s2)

s11 = collections.Counter(s1)
s22 = collections.Counter(s2)

if len(s11) != len(s22):
    print('No')
    exit()

for i in range(len(s11)):
    if s11.most_common()[i][1] != s22.most_common()[i][1] :
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 72540
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k,ans;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	if (k==0){
		cout<<n*n;
		return 0;
	}
	for (int b=k+1;b<=n;b++){
		ans+=(b-k)*(n/b);
		for (int m=k;m<=n%b;m++) ans++;
	}
	cout<<ans;
	return 0;
}

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) {return b < a ? a = b, 1 : 0;}
template<typename T> inline bool chkmax(T &a, T b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("C.in", "r", stdin);
	freopen ("C.out", "w", stdout);
#endif
}

const int Mod = 1e9 + 7;

int n, ans = 1, tot[1001000];

inline int Plus(int a, int b) {
	return (a += b) >= Mod ? a - Mod : a;
}

int main() {

	File();

	n = read();
	int mid = n >> 1;

	For (i, 1, n) {
		int sum = read();
		if ((n - 1 - sum) & 1) return puts("0"), 0;
		if ((++ tot[sum]) > 2 || (sum == 0 && tot[sum] >= 2)) return puts("0"), 0;
		if (i <= mid) ans = Plus(ans, ans);
	}
	printf ("%d\n", ans);

    return 0;

}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#define INFTY 10000000
using namespace std;

int a[2000000] = {};

int h = 0,i = 0;

int parent(int k){return (k / 2);}
int left(int k) {return (2 * k);}
int right(int k){return (2 * k + 1);}

void maxh(int i){

  int l,r,largest;
  l = left(i);
  r = right(i);

  if(l <= h && a[l] > a[i]) largest = l;
  else largest = i;
  if(r <= h && a[r] > a[largest]) largest = r;

  if(largest != i){
    swap(a[i],a[largest]);
    maxh(largest);
  }
}

void heapincrese(int *a,int i,int k){
  if(k < a[i]) return;

  a[i] = k;

  while(i > 1 && a[parent(i)] < a[i]){
    swap(a[i],a[parent(i)]);
    i = parent(i);
  }
}

void insert(int k){
  h++;
  a[h] = -INFTY;
  heapincrese(a,h,k);
}

void extract(){
  if(h < 1) return ;
  int max;
  max = a[1];
  //for(int j = 1;j <= h;j++) cout << j << "= " <<  a[j] << endl;
  cout << max << endl;
  a[1] = a[h];
  h--;
  maxh(1);
}

int main(){

  string com;

  int k;

  while(1){
    cin >> com;

    if(com == "insert"){
      cin >> k;
      insert (k);
    }
    else if(com == "extract"){
      extract();
    }
    else if(com == "end") break;
  }
}

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

int main() {
  long N = 0L; // problem, 1 <= N <= 10^9
  int K = 0; // base, 2 <= K <= 10
  int c = 0; // keta

  cin >> N >> K;
  while(N%K!=0 || N>=K) { // N!=0 is always true
    N = N / K;
    c++;
  }

  cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 1; i <= (int)n; i++)

int main() {
    int N;
    cin >> N;
    vector<int> xyz (1000000, 0);
    REP(x, 100){
        REP(y, 100){
            REP(z, 100){
                xyz.at((int)pow(x+y+z, 2)-(x*y+y*z+z*x))++;
            }
        }
    }
    REP(i, N){
        cout << xyz.at(i) << "\n";
    }
    return 0;
}

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

static int dp[1<<16][105];

int main()
{   
    int N, M, L;
    
    while(cin >> N, N) {

	int res = 0;
	memset(dp, 0, sizeof(dp));
	
	for(int i=0; i<N; i++) {
	    cin >> M >> L;

	    int sb = 0;
	    for(int j=0; j<M; j++) {
		int s,e;
		cin >> s >> e;
		s -= 6; e -= 6;
		;
		for(int k=s; k<e; k++)
		    sb |= (1<<k);
	    }

	    for(int k=0; k<(1<<16); k++) {
		dp[k][i+1] = max(dp[k][i+1], dp[k][i]);

		if(sb&k) continue;
		dp[sb|k][i+1] = max(dp[sb|k][i+1], dp[k][i] + L);
		res = max(res, dp[sb|k][i+1]);
	    }
	}

	cout << res << endl;
	
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>

using namespace std;
const long long P = 1000000007;

int main() {
  string o,e;
  cin >> o >> e;
  string pass = "";
  for(int i = 0; i < min(o.size(),e.size()); i++) {
    pass += o[i];
    pass += e[i];
  }
  if(o.size() > e.size()) {
    pass += o[o.size()-1];
  }else if(o.size() > e.size()) {
    pass += e[e.size()-1];
  }
  cout << pass << endl;
  return 0;
}


Measured memory_bytes: 256
// 2011/03/29 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		double a;
		cin >> a;
		if(cin.eof())
			break;

		double sum = a;
		for(int i=2; i<=10; i++){
			if(i%2==0)
				a *= 2.0;
			else
				a /= 3.0;
			sum += a;
		}

		cout.precision(8);
		cout << fixed << sum << endl;
	}

	return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li a[111];

int main() {
    li n, x;
    cin >> n >> x;
    rin{cin >> a[i];}

    sort(a, a + n);
    li res = 0;
    li now = 0;
    while (now < n && x >= a[now]) {
        x -= a[now];
        res++;
        now++;
    }
    if (res == n) {
        cout << (x == 0 ? res : res - 1) << endl;
    } else {
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(int a,int b){
	return a>b;
}
int main(){
	int n,k,a[101]={},sum;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=k;i++)sum+=a[i];
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[111111],b[111111],cnt,mx,nw;
pair<int,int> arr[111111];
long long sum,fuck,x,y,d,pp;
long long gcd(long long a,long long b)
{
	if (!b) return a;
	return gcd(b,a%b);
}
struct frac
{
	long long x,y;
	bool operator > (const frac &u) const
	{
		return ((double)x/(double)y>(double)u.x/(double)u.y);
	}
}cur,ass;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		sum+=a[i];
	}
	for (int i=1;i<=n;i++)
	{
		arr[i]=make_pair(max(a[i],b[i]),i);
	}
	sort(arr+1,arr+n+1);
	reverse(arr+1,arr+n+1);
	for (int i=1;i<=n;i++)
	{
		fuck+=arr[i].first;
		if (fuck>=sum)
		{
			cnt=i;
			break;
		}
	}
	/*x=n-cnt;y=n;
	d=gcd(x,y);x/=d;y/=d;
	cur.x=x;cur.y=y;
	for (int i=1;i<=n;i++)
	{
		nw=b[arr[i].second];
		if (i<cnt) pp=max(0ll,sum-fuck+arr[i].first);
		else pp=max(0ll,sum-fuck+arr[cnt].first);
		if (pp>=nw) continue;
		x=1ll*nw*(n-cnt)+nw-pp;y=1ll*nw*n;
		d=gcd(x,y);x/=d;y/=d;
		ass.x=x;ass.y=y;
		if (ass>cur) cur=ass;
	}*/
	x=n-cnt;y=n;
	d=gcd(x,y);x/=d;y/=d;
	cur.x=x;cur.y=y;
	mx=-1e9;
	for (int i=cnt+1;i<=n;i++) mx=max(mx,b[arr[i].second]);
	for (int i=1;i<=cnt;i++)
	{
		nw=max(mx,b[arr[i].second]);
		pp=max(0ll,sum-fuck+arr[i].first);
		if (pp>=nw) continue;
		x=1ll*nw*(n-cnt)+nw-pp;y=1ll*nw*n;
		d=gcd(x,y);x/=d;y/=d;
		ass.x=x;ass.y=y;
		if (ass>cur) cur=ass;
	}
	printf("%lld %lld\n",cur.x,cur.y);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n[1100];
int main()
{
  long long a,b,ans=0;
  cin>>a>>b;
  for(int i=0;i<a;i++)
  {
  	cin>>n[i];
  }
  sort(n,n+a);
  for(int i=0;i<b;i++)
  {
  	ans+=n[i];
  }
  cout<<ans;
   return 0;
}


Measured memory_bytes: 3628
s = input()
t = input()
S = len(s)
T = len(t)
dp = [[0 for j in range(T+1)] for i in range(S+1)]
for i in range(S):
    for j in range(T):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
a = ""
i += 1
j += 1
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        i -= 1
        j -= 1
        a = s[i] + a

print(a)

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

const int N = 1e2+2;
int n, k;
int ar[N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        int m;
        cin >> m;
        for (int j = 1; j <= m; j++)
        {
            int x;
            cin >> x;
            ar[x]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (ar[i] == 0)
            ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3632
a,b,c,d = map(int,input().split())

if b <= c:
    print(0)
elif a <= c <= b <= d:
    print(b-c)
elif a <= c <= d <= b:
    print(d-c)
elif c <= a <= d <= b:
    print(d-a)
elif c <= d <= a <= b:
    print(0)
elif c <= a <= b <= d:
    print(b-a)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        vector<int> a(n);
        for(int i=0;i<n;i++)cin>>a[i];
        int ans=-1000000;
        for(int i=0;i<n;i++){
            int sum=0;
            for(int j=i;j<n;j++){
                sum+=a[j];
                if(ans<sum)ans=sum;
            }
        }
        cout<<ans<<endl;
    }
}

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

int main() {
	double n,k;
	cin>>n>>k;
	double ans=0;
	for(int i=1;i<=n;i++)
		ans+=pow(0.5,ceil(log2(ceil(k/i))))/n;
	printf("%.12f\n",ans);
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<pair<ll, ll> > v(n);
  rep(i, n){
    ll a, b;
    cin >> a >> b;
    v[i] = make_pair(a, b);
  }
  sort(v.begin(), v.end());
  ll ans = 0, cnt = 0;
  for(int i = 0; i < m; i++){
    if(v[cnt].second == 0)cnt++;
    ans += v[cnt].first;
    v[cnt].second -= 1;
  }
  cout << ans << endl;
  system("pause");
}


Measured memory_bytes: 2040
#include <stdio.h>
int main(void){
    // Your code here!
    char S[4],T[4];
    int count = 0;
    scanf("%s",S);
    scanf("%s",T);
    for(int i = 0; i < 3; i++)
    {
        if(S[i] == T[i])
        {
            count++;
        }
    }
    printf("%d\n",count);
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;
const int MOD = 1e9 + 7;

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  REP(i,H) cin >> a[i];

  vector<vector<int>> dp(H, vector<int> (W, 0));
  dp[0][0] = 1;
  REP(i,H)REP(j,W) {
    if(a[i][j] == '#') continue;
    if((i + 1 < H) && (a[i + 1][j] == '.')) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
    if((j + 1 < W) && (a[i][j + 1] == '.')) dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD;
  }

  cout << dp[H - 1][W - 1] << endl;
  return 0;
}



Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
const ll mod = (ll)1e9 + 7;
	
int main(){
	speed;
	int n; cin >> n;
	if(n % 1000 == 0) {
		cout << 0;
	}
	else {
		cout << 1000 - (n % 1000);	
	}
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif


signed main(){

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

  if(n%2 == 1){
    cout << 0 << endl;
    return 0;
  }
  else {
    sort(d.begin(),d.end());
    int l = d[n/2-1];
    int r = d[n/2];
    cout << r - l << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll n;
    cin >> n;
    auto cnt_digit = [] (ll x) -> ll {
        ll res = 0;
        while(x != 0) {
            res += x % 10;
            x /= 10;
        }
        return res;
    };
    ll ans = cnt_digit(n);
    ll fac = 10;
    while(fac <= n) {
        ll tmp = cnt_digit(n - (n % fac)-1);
        // cout << tmp << endl;
        ans = max(ans, tmp);
        fac *= 10;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define pii   pair<int,int>
#define hell  1000000007
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb  push_back
#define all(a)      (a).begin(),(a).end()

typedef long long  ll;
using namespace std;

const ll INF=(1LL<<60)-1;
const int N=1e5+20;

int main(){
   
    boost;
    
    ll n; cin >> n;
    ll m; cin >> m;
    
    ll s = 0;
    ll ans = 0;
    
    map<ll,ll> mp;
    mp[0] = 1;
    
    rep(i,0,n){
    	ll x; cin >> x;
    	s += x;
		ans += mp[s%m];
		mp[s%m]++;	
	}
	
	cout << ans;
	
   	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

class UnionFind {
    int n;
    vector<int> uni;
    int forest_size;
public:
    explicit UnionFind(int n) : n(n), uni(static_cast<u32>(n), -1), forest_size(n) {};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        forest_size--;
        return true;
    }
    int size(){ return forest_size; }
    int size(int i){ return -uni[root(i)]; }
    bool same(int a, int b) { return root(a) == root(b); }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<int> deg(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        deg[a]++; deg[b]++;
        uf.unite(a, b);
    }
    for (int i = 0; i < k; ++i) {
        int c, d;
        cin >> c >> d;
        c--; d--;
        if(uf.same(c, d)){
            deg[c]++; deg[d]++;
        }
    }
    for (int i = 0; i < n; ++i) {
        if(i) printf(" ");
        printf("%d", uf.size(i)-deg[i]-1);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{

  //ll t;
  //cin>>t;
  //while(t--)
  {
   ll n,a[200001],i,k=0;
   cin>>n;
   for(i=0;i<n;i++)
    {cin>>a[i];}
    sort(a,a+n);
   for(i=1;i<n;i++)
   {
     if(a[i]==a[i-1])
    {
            k=1;
           cout<<"NO"<<endl;
       break;
       }
   }
   if(k==0)
    cout<<"YES"<<endl;
  }
return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
long long n,m,t,i,j,px[100005],dp[100005],qx[100005],ql,qr,s=0x1212121212121212ll;
int main()
{
	scanf("%lld%lld%lld",&n,&m,&t);
	fz1(i,n)scanf("%lld",&px[i]);
	dp[0]=m;qx[ql=qr=1]=0;
	fz1(i,n){
		while(ql<=qr&&2*(px[i]-px[qx[ql]+1])>=t){
			s=min(s,dp[qx[ql]]-px[qx[ql]+1]*2);
			ql++;
		}
		dp[i]=s+2*px[i];
		if(ql<=qr) dp[i]=min(dp[i],dp[qx[ql]]+t);
		qx[++qr]=i;
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 2560
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int ans,F[maxn],n,m;

inline int f(int x)
{
	if(F[x]==x) return x;
	return F[x]=f(F[x]);
}

int main()
{
	n=read(); m=read();
	for(int i=1;i<=n;i++) F[i]=i;
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read(),z=read(),fx=f(x),fy=f(y);
		if(fx==fy) continue; F[fx]=fy;
	}
	for(int i=1;i<=n;i++) if(F[i]==i) ans++; cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

i64 n, m, l, h[16][16], g[16][16], deg[16], dp[1 << 15];

i64 f(int s) {
    if (dp[s] != 0) return dp[s];
    if (s == (1 << l) - 1) return 0;
    i64 res = 1ll << 60;
    for (int u = 0; u < l; ++u) {
        if (s & (1 << u)) continue;
        for (int v = 0; v < l; ++v) {
            if (u == v || s & (1 << v)) continue;
            int t = s | (1 << u) | (1 << v);
            res = min(res, g[u][v] + f(t));
        }
    }
    return dp[s] = res;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            h[i][j] = 1ll << 60;
        }
    }
    i64 sum = 0;
    for (int i = 0; i < m; ++i) {
        i64 s, t, d;
        cin >> s >> t >> d;
        deg[s]++;
        deg[t]++;
        sum += d;
        h[s][t] = h[t][s] = min(h[s][t], d);
    }
    vector<int> to(n, -1);
    for (int i = 0; i < n; ++i) {
        if (deg[i] % 2 == 1) {
            to[i] = l;
            l++;
        }
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                h[i][j] = min(h[i][j], h[i][k] + h[k][j]);
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (to[i] != -1 && to[j] != -1) {
                g[to[i]][to[j]] = h[i][j];
            }
        }
    }


    cout << sum + f(0) << endl;
    return 0;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N;
    cin >> N;
    if(N%2!=0){
        cout << 0 << endl;
    }else{
        ll cnt = 0;
        ll tmp = 10;
        for(;tmp<=N;tmp*=5){
            cnt += N/tmp;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        mut a: [u64;n],
    }

    a.sort();
    a.reverse();

    let mut ans = a[0];

    for i in 1..n - 1 {
        ans += a[(i + 1) / 2];
    }

    println!("{}", ans);
}


Measured memory_bytes: 6216
#https://atcoder.jp/contests/keyence2020/tasks/keyence2020_a
# -*- coding: utf-8 -*-
H = int(input())
W = int(input())
N = int(input())
ans = 0
white = H*W
if H>=W :
  for i in range(H):
    ans += 1
    black = (i+1)*H
    if black >= N:
      break
elif W>H :
  for i in range(W):
    ans += 1
    black = (i+1)*W
    if black >= N:
      break
print(ans)

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <iomanip>

const int MOD = 1000000007;


ll POWER(ll x,ll y)
{
	ll ret=1;
	ll p=x;
	for (ll i=y;i>0;i/=2)
	{
		if (i%2) ret=(ret*p)%MOD;
		p=(p*p)%MOD;
	}
	return ret;
}
ll gcm(ll a, ll b)
{
	if (b>a) {ll c=a; a=b; b=c;}
	while (b>0)
	{
		ll r=a%b;
		a=b;
		b=r;
	}
	return a;
}

ll p5(ll x) {return x*x*x*x*x;}


ll r5(ll x)
{
	ll s,m,l;
	l=6208;
	s=0;
	while (l>s+1)
	{
		m=(s+l)/2;
		//cerr<<s<< " "<<m<<" "<<l<<endl;
		ll m5=p5(m);
		if (m5>x) l=m; else s=m;
	}
	return s;
}

int main(int argc, char *argv[])
{
	ll x;
	cin>>x;
	ll a,b,a5,b5;
	a=0;b=r5(x);a5=0;b5=p5(b);
	do {
		if (a5+b5==x)
		{
			cout<<b<<" "<<-a<<endl;
			return 0;
		}
		else if (a5+b5<x)
		{
			a++;
			a5=p5(a);
		}
		else
		{
			b--;
			b5=p5(b);
		}
	} while(a<=b);

	a=0;b=r5(x);a5=0;b5=p5(b);
	do
	{
		if (a5+x==b5)
		{
			cout<<b<<" "<<a<<endl;
			return 0;
		}
		else if (a5+x<b5)
		{
			a++;
			a5=p5(a);
		}
		else
		{
			b++;
			b5=p5(b);
		}

	} while(p5(b)-p5(b-1)<=x);
	return 0;
}



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

#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

int main() {
	sp;

	////////////////To Remove//////////////
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	///////////////////////////////////////

	int n, k;
	cin>>n>>k;

	vector<int> A(n), dp(n, INT_MAX);
	for(int i = 0; i < n; ++i) cin>>A[i];
	
	dp[0] = 0;
	for(int i = 1; i < n; ++i){
		for(int j = max(0, i-k); j < i; ++j){
			dp[i] = min(dp[i], abs(A[i] - A[j]) + dp[j]);
		}
	} 

	cout<<dp[n-1];

  return 0;
}

Measured memory_bytes: 1024
N=int(input())
A=list(map(int,input().split()))
B=[0]*(10**5+1)
for i in range(N):
  B[A[i]]+=1
  B[A[i]+1]+=1
  if A[i]-1==0:
    B[0]+=1
  elif A[i]-1>0:
    B[A[i]-1]+=1
print(max(B))

Measured memory_bytes: 13964
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k; ll num;
    cin >> n >> k;
    vector<ll> ap, an, a;
    for(int i=0;i<n;++i) {
        cin >> num;
        a.push_back(abs(num));
        if(num > 0) ap.push_back(num);
        else if(num < 0) an.push_back(-num);
    }

    // 答えが 0 にしかならない
    if(ap.size() == 0 && an.size() == 0) {
        cout << 0 << endl;
        return 0;
    }

    // 答えを正の数にできる？
    ll ans = 1LL;
    sort(ap.rbegin(), ap.rend());
    sort(an.rbegin(), an.rend());
    int pi = 0, ni = 0, kk = 0;
    while(kk < k-1 && (pi < int(ap.size())-1 || ni < int(an.size())-1)) {
        if(ni >= int(an.size())-1 || (pi < int(ap.size())-1 && ap[pi+1] * ap[pi] > an[ni+1] * an[ni])) {
            ans *= (ap[pi+1] * ap[pi]) % MOD;
            pi += 2;
        } else {
            ans *= (an[ni+1] * an[ni]) % MOD;
            ni += 2;
        }
        ans %= MOD;
        kk += 2;
    }
    while(kk < k && pi < int(ap.size())) {
        ans *= ap[pi++];
        ans %= MOD;
        ++kk;
    }
    if(kk == k) {
        cout << ans << endl;
        return 0;
    }

    // 答えを正にできないため，できるだけ絶対値を抑える
    sort(a.begin(), a.end());
    ans = 1LL;
    for(int i=0;i<k;++i) {
        ans *= a[i];
        ans %= MOD;
    }
    cout << (MOD-ans) % MOD << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int solve(int n, int h, vector<int> a, vector<int> b) {
	int ma = 0;
	for (int i = 0; i < n; i++) {
		ma = max(ma, a[i]);
	}

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (ma < b[i]) {
			h -= b[i];
			cnt++;
		}

		if (h <= 0) {
			return cnt;
		}
	}

	cnt += h / ma;
	cnt += (bool)(h % ma);
	return cnt;
}

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

	int n, h;
	cin >> n >> h;

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

	sort(b.begin(), b.end(), greater<int>());

	cout << solve(n, h, a, b) << endl;
	return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
     
#include <list>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>

using namespace std;

void solution() {
    int x, y;
    cin >> x >> y;
    if (y % 2 == 0 && x * 2 <= y && x * 4 >= y) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

/*-------------------*/

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);
           
    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

/*
　　     　 　          ∧_,,∧　　　
    　            ♪　  (・ω・)　♪
               ＿＿＿＿○＿＿つヾ＿＿＿＿＿
             /δ⊆・⊇ 。/†: :† /δ ⊆・⊇｡ /|
            |￣￣￣￣￣￣￣￣￣￣￣￣￣ | |
            |　　　*/solution();/* 　　| |
            |　　　　　　　　　　　　　 |
*/

#ifdef Time
double P2HxQ = clock();
printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

Measured memory_bytes: 3588
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i64 = read();
    let k: i64 = read();

    let ans = if k % 2 == 0 {
        let s = n / k;
        let t = n / (k / 2) - s;
        s.pow(3) + t.pow(3)
    } else {
        let t = n / k;
        t.pow(3)
    };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
// how many ways?
#include <iostream>


using namespace std;


int main()
{
	int n, x;
	int sum;

	while(1){
		cin >> n >> x;
		if(n == 0 && x == 0)
			break;

		int count = 0;
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				if(j == i)
					continue;

				for(int k = 1; k <= n; k++){
					if(k == i || k == j)
						continue;

					sum = i + j + k;
					if(sum == x)
						count++;
				}
			}
		}

		cout << count / 6 << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#define N 500005
using namespace std;
int nxt[N],num[N*8];char s[N*8],t[N];
void getnxt(char s[]){
    nxt[0]=nxt[1]=0;
    int l=strlen(s);
    for(int i=1;i<l;++i){
        int j=nxt[i];
        while(j && s[i]!=s[j]) j=nxt[j];
        nxt[i+1]= s[i]==s[j] ? j+1 : 0 ;
    }
}
int kmp(char s1[],char s2[]){
    getnxt(s1);
    int ans=0;
    int n=strlen(s1),m=strlen(s2);
    for(int i=0,j=0;i<m;++i){
    	num[i]=0;
        while(j && s1[j]!=s2[i]) j=nxt[j];
        if(s1[j]==s2[i]) ++j;
        if(j==n) num[i]=1+num[i-n],ans=max(ans,num[i]);
    }
    return ans;
}
int main(){
	scanf("%s%s",&s,&t);
	int n=strlen(s),m=strlen(t);
	if(n>=m){
		for(int i=n;i<4*n;++i) s[i]=s[i%n];
		int ans1=kmp(t,s);
		for(int i=4*n;i<8*n;++i) s[i]=s[i%n];
		int ans2=kmp(t,s);
		if(ans1<ans2) printf("-1\n");
		else printf("%d\n",ans1);
	}
	else{
		int len=(m/n+1)*n*2;
		for(int i=n;i<len;++i) s[i]=s[i%n];
		int ans1=kmp(t,s);
		for(int i=len;i<2*len;++i) s[i]=s[i%n];
		int ans2=kmp(t,s);
		if(ans1<ans2) printf("-1\n");
		else printf("%d\n",ans1);
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    int last = S[0] - '0';
    int cnt = 1;
    vector<pair<int, int> > RL;
    for(int i = 1; i < N; i++){
        int x = S[i] - '0';
        if(last != x){
            RL.emplace_back(last, cnt); 
            cnt = 0;
        }
        last = x;
        cnt++;
    }
    RL.emplace_back(last, cnt); 

    queue<int> que;
    queue<int> que2;
    if(S[0] == '0')
        que2.push(0);
    int tmp = 0;
    int ans = -1;
    for(auto&& p : RL){
        int num = p.first;
        int cnt = p.second;
        if(num == 0){
            tmp += cnt;
            que.push(cnt);
            if(que.size() > K){
                tmp -= que.front();
                que.pop();
                tmp -= que2.front();
                que2.pop();
            }
        }
        else{
            tmp += cnt;
            que2.push(cnt);
        }

        chmax(ans, tmp);
    }

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


Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin >> s;

    if ((s.at(0) == s.at(1)) && (s.at(1) == s.at(2)) && (s.at(2) == s.at(3))){
        cout << "No" << endl;
    }else if((s.at(0) == s.at(1) && s.at(2) == s.at(3)) || (s.at(0) == s.at(2) && s.at(1) == s.at(3)) || (s.at(0) == s.at(3) && s.at(2) == s.at(1))) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))

sp = set(p)
ans = -200
for i in range(-100, 102):
    if abs(x-i) <= abs(x-ans) and not i in sp:
        if abs(x-i)==abs(x-ans):
            ans = min(ans, i)
        else:
            ans = i
print(ans)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n; cin >> n;
    ll cnt = 0;
    ll cnt_temp = 0;

    rep(i,n){
        int a; cin >> a;
        cnt_temp += a;
        if(a == 0){
            cnt += cnt_temp/2;
            cnt_temp = 0;
        }
    }
    cnt += cnt_temp/2;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi TRA(5);
  VIN(TRA)
  SORT(TRA);
  int minE = TRA[0];
  OUT((n+minE-1)/minE+4);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int N;
int main(){
    cin >> N;
    vector<int> v;
    long long int ans = 0;
    for(int i=0; i<N*3; i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort( v.begin(), v.end());
    for(int i=0; i<N; i++){
        ans += v[ 3 * N - 2 - i * 2];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420