akhauriyash/Code-Regression huggingface dataset:
N,M = map(int,input().split())
stores = []
for _ in range(N):
    price,stock = map(int,input().split())
    stores.append((price,stock))
stores = sorted(stores, key=lambda t: t[0])
total_cost = 0
for store in stores:
    price, stock = store[0], store[1]
    if M > stock:
        M -= stock
        total_cost += price * stock
    elif M <= stock:
        total_cost += price * M
        break
print(total_cost)

Measured memory_bytes: 18952
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	while(1)
	{
		int a,b;
		cin >> a >> b;
		if(a==0&&b==0)break;

		rep(i,a)
		{
			rep(j,b)
			{
				cout<<'#';
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}


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

const int MAX_N = 1e5+10;
int N, a[MAX_N], b[MAX_N];
vector<int> G[MAX_N];
bool vis[MAX_N];
int prevv[MAX_N];
int col[MAX_N];

void add_edge(int from, int to)
{
	G[from].push_back(to);
	G[to].push_back(from);
}

void dfs(int x)
{
	vis[x] = true;
	for(int i=0;i<G[x].size();++i){
		int y = G[x][i];
		if(!vis[y]){
			prevv[y]=x;
			dfs(y);
		}
	}
}

int dfs2(int x, int c)
{
	int res = 1;
	vis[x] = true;
	col[x] = c;
	for(int i=0;i<G[x].size();++i){
		int y = G[x][i];
		if(!vis[y] && (col[y] == -1 || col[y] == c)) res += dfs2(y, c);
	}
	return res;
}

void solve()
{
	memset(prevv, -1, sizeof(prevv));
	dfs(1);
	int t=N;
	int len=0;
	while(t!=-1){
		len++;
		t=prevv[t];
	}
	memset(col, -1, sizeof(col));
	t = N;
	int cnt = len/2;
	while(cnt--){
		col[t] = 0;
		t=prevv[t];
	}
	while(t!=-1){
		col[t]=1;
		t=prevv[t];
	}
	memset(vis,false,sizeof(vis));
	int bc = dfs2(1, 1);
	memset(vis,false,sizeof(vis));
	int wc = dfs2(N, 0);
	if(bc > wc) cout << "Fennec\n";
	else cout << "Snuke\n";
}

int main()
{
	cin >> N;
	for(int i=0;i<N-1;++i){
		cin >> a[i] >> b[i];
		add_edge(a[i], b[i]);
	}
	solve();
	return 0;
}

Measured memory_bytes: 15384
import math
A,B,H,M=map(int,input().split())
Ta=H*60+M
a=0.5*Ta
b=6*M
key=abs(b-a)
if key>180:
  key=360-key
c=math.cos(math.radians(key))
ans=A**2+B**2-2*A*B*c
print(math.sqrt(ans))

Measured memory_bytes: 9452
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
string s[N];
map<string,int> m;
long long ans = 0;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0;i < n; ++i){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
        ans += m[s[i]];
        m[s[i]]++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,k,ans=0,bpos;cin>>n>>m>>k;
  lvector A(n),B(m),SA(n+1,0),SB(m+1,0);
  rep(i,n) cin>>A[i];rep(i,m) cin>>B[i];
  rep(i,n) SA[i+1]=A[i]+SA[i];
  rep(i,m) SB[i+1]=B[i]+SB[i];
  for(ll apos=n;apos>-1;--apos) {
    if(SA[apos]>k) continue;
    bpos=upper_bound(ALL(SB),k-SA[apos])-SB.begin();
    ans=max(ans,apos+bpos-1ll);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 9476
//2008dC
I;int parse(char *p){switch(*p){
	case 'F':return 0;
	case 'T':return 1;
	case '-':return !parse(p+1);
	case '(':{
		int x=0;
		char *q=++p;
		for(;;p++){
			if(*p=='(')x++;
			if(*p==')')x--;
			if(x==0&&*p!='-')break;
		}
		p++;
		switch(*p){
			case '*':return parse(q)&parse(p+1);
			case '+':return parse(q)|parse(p+1);
			case '-':return !parse(q)|parse(p+2);
		}
	}
}return (I>>(*p-97))&1;}
char p[1001],*q;main(){for(;scanf("%s",p),*p-'#';puts(I==2048?"YES":"NO")){
for(q=strchr(p,'=')+1,I=0;I<2048;I++)if(parse(p)!=parse(q))break;
}exit(0);}

Measured memory_bytes: 552
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		string[] first = Console.ReadLine().Split();
		int n = int.Parse(first[0]);
		int k = int.Parse(first[1]);
		
		int[] w = new int[n];
		
		for (int i = 0; i < n; i++)
		{
			w[i] = int.Parse(Console.ReadLine().Split()[0]);
		}
		
		Solve(w, k);
	}

	static void Solve(int[] w, int k)
	{
		int first = 0;
		int last = 10000 * w.Length + 1;
		int lastAcceptP = last;
		while (first + 1 < last)
		{
			int p = (last + first) / 2;
			if (CheckAccept(w, k, p))
			{
				lastAcceptP = p;
				last = p;
			}
			else
			{
				first = p;
			}
		}
		System.Console.WriteLine(lastAcceptP);
	}

	static bool CheckAccept(int[] w, int k, int p)
	{
		int weight = 0;

		for (int i = 0; i < w.Length; i++)
		{
			if (w[i] > p)
			{
				return false;
			}
			if (weight + w[i] <= p)
			{
				weight += w[i];
			}
			else
			{
				weight = w[i];
				k--;
				if (k <= 0)
				{
					return false;
				}
			}
		}
		return true;
	}
}



Measured memory_bytes: 9916
N, M = map(int,input().split())
L = sorted(list(map(int,input().split())))
distance = []
for i in range(len(L)-1):
    distance.append(abs(L[i]-L[i+1]))
distance = sorted(distance)
for _ in range(N-1):
    try:
        del distance[-1]
    except:
        print(0)
        quit()
print(sum(distance))


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

using namespace std;

typedef long long int ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	
	int a, b;
	
	cin >> a >> b;
	
	cout << max(a + b, max(a * b, a - b)) << endl;
	
    return 0;
}



Measured memory_bytes: 256
"""Boot-camp-for-Beginners_Easy004_B_Tax-Rate_25-August-2020.py"""
import numpy as np
import sys

N=int(input())
X=N/1.08
if int(int(np.ceil(X))*1.08)==N:
    print(int(np.ceil(X)))
else:
    print(":(")

Measured memory_bytes: 27080
s = input()

dp = [[0 for _ in range(4)] for _ in range(len(s) + 1)]
dp[len(s)][3] = 1
n = 10 ** 9 + 7

for i in reversed(range((len(s)))):
    m = 1
    m1 = 1
    m2 = 0
    m3 = 0
    m4 = 0
    if s[i] == '?':
        m = 3
        m1 = 3
        m2 = 1
        m3 = 1
        m4 = 1

    if s[i] == 'C':
        m2 = 1

    if s[i] == 'B':
        m3 = 1

    if s[i] == 'A':
        m4 = 1

    dp[i][3] = (m * dp[i+1][3]) % n
    dp[i][2] = (m1 * dp[i+1][2] + m2 * dp[i+1][3]) % n
    dp[i][1] = (m1 * dp[i+1][1] + m3 * dp[i+1][2]) % n
    dp[i][0] = (m1 * dp[i+1][0] + m4 * dp[i+1][1]) % n

ans = dp[0][0]
print(ans)

Measured memory_bytes: 27608
#include <iostream>
#define DEBUG 0

using namespace std;
int Hdead[2][2]; // Lo/Hi, parity
int Wdead[2][2];
int main() {
    int H,W,N;
    int sr, sc;
    char S[200001];
    char T[200001];
    cin >> H >> W >> N;
    cin >> sr >> sc;
    cin >> S;
    cin >>T;

    Hdead[0][0] = 0;
    Wdead[0][0] = 0;
    Hdead[1][0] = H+1;
    Wdead[1][0] = W+1;
    Hdead[0][1] = 0;
    Wdead[0][1] = 0;
    Hdead[1][1] = H+1;
    Wdead[1][1] = W+1;
    int parity = 0;
    if (DEBUG) cout << Wdead[0][parity] << "," << Wdead[1][parity] << "," << Hdead[0][parity] << "," << Hdead[1][parity] << endl;

    for (int i=N-1; i>=0; i--) {
        char tak = S[i];
        char aok = T[i];
        Wdead[0][parity^1] = Wdead[0][parity];
        Wdead[1][parity^1] = Wdead[1][parity];
        Hdead[0][parity^1] = Hdead[0][parity];
        Hdead[1][parity^1] = Hdead[1][parity];
        switch (aok) {
            case 'L':
                Wdead[1][parity^1] = min(Wdead[1][parity^1]+1, W+1);
                break;
            case 'R':
                Wdead[0][parity^1] = max(Wdead[0][parity^1]-1, 0);
                break;
            case 'U':
                Hdead[1][parity^1] = min(Hdead[1][parity^1]+1, H+1);
                break;
            case 'D':
                Hdead[0][parity^1] = max(Hdead[0][parity^1]-1, 0);
        }
                
        parity ^= 1;
        if (DEBUG) cout << Wdead[0][parity] << "," << Wdead[1][parity] << "," << Hdead[0][parity] << "," << Hdead[1][parity] << endl;
        Wdead[0][parity^1] = Wdead[0][parity];
        Wdead[1][parity^1] = Wdead[1][parity];
        Hdead[0][parity^1] = Hdead[0][parity];
        Hdead[1][parity^1] = Hdead[1][parity];
        switch (tak) {
            case 'L':
                Wdead[0][parity^1]++;
                break;
            case 'R':
                Wdead[1][parity^1]--;
                break;
            case 'U':
                Hdead[0][parity^1]++;
                break;
            case 'D':
                Hdead[1][parity^1]--;
        }
        parity ^= 1;
        if (DEBUG) cout << Wdead[0][parity] << "," << Wdead[1][parity] << "," << Hdead[0][parity] << "," << Hdead[1][parity] << endl;

        if (Wdead[1][parity] - Wdead[0][parity] <= 1 ||
            Hdead[1][parity] - Hdead[0][parity] <= 1) {
            cout << "NO" << endl; 
            return 0;
        }
    }

    if (DEBUG) cout << Wdead[0][parity] << "," << Wdead[1][parity] << "," << Hdead[0][parity] << "," << Hdead[1][parity] << endl;
    if (Wdead[0][parity] < sc && Wdead[1][parity] > sc && Hdead[0][parity] < sr && Hdead[1][parity] > sr) cout << "YES" << endl;
    else cout << "NO" << endl;
        
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <cassert>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main (void){ 
    string s;
    string result = "";
    vector <string> v(10);
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        v[i] += s[i];
        if (v[i] == "0") {
            result += "0";
        } else if (v[i] == "1") {
            result += "1";
        } else {
            if (result.empty()) {

            } else {
                result.pop_back();
            }
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
using namespace std;
using ll = long long;

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


    vector<int> nums(10, 1);
    rep(i, 0, k)
    {
        int d;
        cin >> d;
        nums[d] = 0;
    }


    rep(i, n, n * 100)
    {
        int num = i;
        bool ok = true;
        while (num > 0)
        {
            if (not nums[num % 10])
            {
                ok = false;
                break;
            }
            else 
                num /= 10;
        }
        if (ok)
        {
            cout << i << endl;
            return 0;
        } 
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> C(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> C[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << C[i][j];
		}
		cout << endl;
		for (int j = 0; j < W; j++) {
			cout << C[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
import bisect
N = int(input())
A = list(map(int, input().split()))
L = sorted(A[:2*N])
sumL = sum(L[N:])
R = sorted(A[N:])
sumR = sum(R[:N])
AL = [sumL]
p = N
BL = [False] * (2*N)
for a in reversed(A[N:2*N]):  # sumLはだんだん減る
    ind = bisect.bisect_left(L, a)
    if BL[ind] != False:
        BL[ind] += 1
        ind += BL[ind] - 1
    if ind >= p:
        sumL -= L[ind]
        p -= 1
        while BL[p] != False:
            p -= 1
        sumL += L[p]
    AL.append(sumL)
    BL[ind] = 1
AR = [sumR]
p = N-1
BR = [False] * (2*N)
for a in A[N:2*N]:  # sumRはだんだん増える
    ind = bisect.bisect_left(R, a)
    if BR[ind] != False:
        BR[ind] += 1
        ind += BR[ind] - 1
    if ind <= p:
        sumR -= R[ind]
        p += 1
        while BR[p] != False:
            p += 1
        sumR += R[p]
    AR.append(sumR)
    BR[ind] = 1
AL.reverse()
C = [AL[i] - AR[i] for i in range(N+1)]
print(max(C))


Measured memory_bytes: 37212
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,n,m,ans,sum;

int main()
{
	cin>>a>>b;
	
	c=b-a;
	
	c--;
	
	ans=c*(c+1)/2-a;
	
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t; cin >> s >> t;
	int ans = 0;
	rep(i, 3) {
		if (s[i] == t[i])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()

if S == 'SSS':
  print(0)
if S == 'RRR':
  print(3)
if S == 'SRR' or S == 'RRS':
  print(2)
if S == 'SSR' or S == 'SRS' or S == 'RSS' or S == 'RSR':
  print(1)



Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
    string S;
    cin >> S;
    string R;
    for (auto x : S)
    {
        switch (x)
        {
        case '0':
            R.push_back(x);
            break;
        case '1':
            R.push_back(x);
            break;
        case 'B':
            if (!R.empty())
                R.pop_back();
            break;
        }
    }
    cout << R << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	int a, b, t;
	cin >> a >> b >> t;
	cout << b*(t / a) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)


int main() {
    int N;
    int d[110];
    cin >> N;
    rep(i, N) {
        cin >> d[i];
    }

    bool b[110] = {};
    rep(i, N) {
        b[d[i]] = true;
    }
    cout << count(b, b + 110, true) << endl;
}

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

int main() {
    int N; cin >> N;
    unordered_map<string, int> m;
    for (int i = 0; i < N; ++i) {
        string s; cin >> s;
        m[s]++;
    }
    cout << "AC" << " x " <<  m["AC"] << endl;
    cout << "WA" << " x " <<  m["WA"] << endl;
    cout << "TLE" << " x " <<  m["TLE"] << endl;
    cout << "RE" << " x " <<  m["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC149A
{
    class Program
    {
        static void Main(string[] args)
        {
            string a, b, c;
            var word = Console.ReadLine().Split(' ');
            a = (word[0]);
            b = (word[1]);
            Console.WriteLine(b + a);
            Console.ReadKey();
        }
    }
}


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

using namespace std;

int main(void)
{
  int n; cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  
  int mx=*max_element(a.begin(),a.end());
  int mi=*min_element(a.begin(),a.end());
  
  cout<<mx-mi<<endl;
  return 0;
}

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

int main() {
    int n, m;
    string s;

    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> s;
            if (s == "snuke") {
                printf("%c%d\n", j+'A'-1, i);
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = [A[i]-i-1 for i in range(N)]
B.sort()
if N % 2:
    b = B[N//2]
else:
    b = (B[N//2-1] + B[N//2]) // 2

ans = sum([abs(BB-b) for BB in B])
print(ans)

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

using namespace std;

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 10000000
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}
#define dbg(x) cout <<#x<<":"<<x<<endl;
ll max1(ll a, ll b, ll c=-inf, ll d=-inf) {ll mx1=(a>b)?a:b, mx2=(c>d)?c:d; return ((mx1>mx2)?mx1:mx2);}
#define int ll

struct node {
	vector<int> v,w;
};

#define PI 3.14159265

signed main() {
	fast;

	int a,b,x;
	cin>>a>>b>>x;

	cout<<std::fixed<<std::setprecision(20);

	if(2*x>=(a*a*b)) {
		lld val = (b*a*a - x);
		val /= 1.0*a*a*a;
		val *= 2.0;

		lld ans = atan(val)*180.0/PI;
		cout<<ans;
	}
	else {
		lld val = x;
		val /= 1.0*a*b*b;
		val *= 2.0;

		lld ans = atan(val)*180.0/PI;
		cout<<90-ans;
	}
}

Measured memory_bytes: 256
import fractions

def lcm(x,y):
	return (x*y)//fractions.gcd(x,y)
count = 0
A,B,C,D= map(int,input().split())
lcm = lcm(C,D)
E = (A-1)//C
F = (A-1)//D
G = (A-1)//lcm
H = B//C
I = B//D
J = B//lcm

count = (B-A+1)-((H-E)+(I-F)-(J-G))

print(count)


Measured memory_bytes: 5048
n,h = map(int,input().split())

al = []
bl = []

for _ in range(n):
    a,b = map(int,input().split())
    al.append(a)
    bl.append(b)

amax = max(al)
bl = [i for i in bl if i > amax]

bl = sorted(bl, reverse=True)

ans = 0
for b in bl:
    h -= b
    ans += 1
    if h <= 0:
        print(ans)
        import sys
        sys.exit()

import math
print(ans + math.ceil(h/amax))

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


int main()
{


        long long n,m,a,b,c,e,f,g,p,q,r,fr,sc,tr,sz,tz,sz1,zr=0,sz2,i,j,k,mx=-9,mn=999999999999; string str,ttr,ntr;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct,tct; vector<string>vst;
        set<long long>st,nt,tt; map<string,long long>mp,nq,qr,mp1; map<long long,long long>mmm,mp2;

        scanf("%lld %lld",&n,&m);

        for(i=1;i<=m;i++)
        {
            scanf("%lld",&a);  cin>>str;
            if(str=="AC" && mmm[a]==0)
            {
                mmm[a]=1; ans++;   sum=sum+mp2[a];
            }

            if(mmm[a]==0)
            {
                mp2[a]++;
            }

        }

        cout<<ans<<" "<<sum<<endl;












    return 0;
}



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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

int N, W;
int weight[110], value[110];
int dp[110][10010];

int main() {
   cin >> N >> W;
   rep (i, 0, N) {
      cin >> value[i] >> weight[i];
   }

   rep (i, 0, W+1) {
      dp[0][i] = 0;
   }

   rep (i, 0, N) {
      rep (w, 0, W+1) {
         if (w >= weight[i]) {
            dp[i+1][w] = 
               max(dp[i][w-weight[i]]+value[i], dp[i][w]);
         } else {
            dp[i+1][w] = dp[i][w];
         }
      }
   }
   cout << dp[N][W] << endl;

   return 0;
}


Measured memory_bytes: 7008
#include <iostream>
#include <fstream>
#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <cstring>
#include <numeric>
#include <stack>
#include <iomanip>
#include <chrono>
using namespace std;

#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385

#define sd(mark) scanf("%d",&mark)
#define ss(mark) scanf("%s",mark)
#define sl(mark) scanf("%lld",&mark)
#define clr(mark) memset(mark,0,sizeof(mark))
#define setinf(mark) memset(mark,0x3f,sizeof(mark))

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#ifndef KaalaNamak
#define endl '\n'
#define trace(...)
#define start_routine() 
#define end_routine()
#endif


signed main() {
    start_routine();
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);
    cout<<fixed<<setprecision(10);
    int t=1;
    // cin>>t;
    #ifdef KaalaNamak
        t=4;
    #endif
    while(t--){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max(max(a*c,a*d),max(b*c,b*d))<<"\n";
    }
    end_routine();

}

Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 1LL << 60;
const int inf = 1 << 30;

int main() {
    int N; cin >> N;
    string ans = "";
    while (N != 0) {
        int d  = abs(N) % 2;
        ans += to_string(d);
        if (N > 0) N /= -2;
        else N = (-N + d * 2) / 2;
    }
    if (ans.size()) reverse(ans.begin(), ans.end());
    cout << (ans.size() ? ans : "0") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
 string c;
 while(true){
 cin>>c;
 if(c=="0")
 break;
 int a=0,b=0;
 for(int i=1;i<c.size();i++){
  if(c[i]=='A')
  a++;
  if(c[i]=='B')
  b++;
 }
 if(a>b)
 a++;
 if(a<b)
 b++;
 cout<<a<<" "<<b<<endl;
 }
 return 0;   
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  float a, b;
  cin >> n;
  priority_queue <float> q;
  for (int i = 0; i < n; ++i){
	cin >> a;
	q.push(-a);
  } 
  for (int i = 0; i < n-1; ++i){
	a = q.top();
	q.pop();
	b = q.top();
	q.pop();
	q.push((a+b)/2);
  }
  cout << -q.top() << "\n";
return 0;
}


Measured memory_bytes: 256
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$N = $key->A[0];
$W = $key->A[1];

$dp = array();

$ret = solve(0,$W);
printf("%d\n",$ret);

function solve($i,$w) {
  global $N,$W,$key,$dp;
  if (isset($dp[$i][$w])) {
    return $dp[$i][$w];
  }
  $res = 0;
  if ($i == $N) {
    $res = 0;
  }
  else if ($w < $key->X[$i][0]) {
    $res = solve($i+1,$w);
  }
  else {
    $r1 = solve($i+1,$w);
    $r2 = solve($i+1,$w - $key->X[$i][0]) + $key->X[$i][1];
    //printf("%d 重さ %d 入れない　%d 入れた　%d\n",$i,$w,$r1,$r2);
    $res =  max($r1,$r2);
  }
  $dp[$i][$w]=$res;
  return $res;
}


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

n = int(input())
c = [0 for i in range(n)]
s = [0 for i in range(n)]
f = [0 for i in range(n)]
for i in range(1,n):
    c[i], s[i], f[i] = list(map(int,input().split()))

for i in range(1,n):
    t = 0
    for j in range(i,n):
        if(t<s[j]):t=s[j]
        elif(t%f[j]==0):pass
        else:t=t+f[j]-t%f[j]
        t += c[j]
    print(t)
print(0)

Measured memory_bytes: 3188
#include<stdio.h>
int main(void){
int m,n,ai,min,max;
long sum;
scanf("%d",&n);
for(m=0;m<n;m++){
scanf("%d",&ai);
if(m==0){
min=ai;
max=ai;
sum=ai;
}
else{
if(ai<min){
min=ai;
}
if(max<ai){
max=ai;
}
sum+=(long)ai;
}
} 
printf("%d %d %ld\n",min,max,sum);
return 0;
}

Measured memory_bytes: 600
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int sum1 = 0;
    int sum2 = 0;
    int sum3 = 0;
    sum1 = A * X + B * Y;
    sum2 = C * ((int) Math.max(X, Y) * 2);
    if (X > Y) {
      sum3 = C * (Y * 2) + (X - Y) * A;
    } else {
      sum3 = C * (X * 2) + (Y - X) * B;
    }
    int ans = Math.min(sum3, Math.min(sum1, sum2));
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var end = array.Max() * 2;

            double min = double.MaxValue;
            for (int i = 0; i < end; i++)
            {
                double sum = 0;
                for (int j = 0; j < array.Length; j++)
                {
                    sum += Math.Pow((array[j] - i), 2);
                }

                if (sum < min)
                    min = sum;
            }

            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define befv(V) ((V)[(sz(V)-2)])
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

int H, W, T;

int main() {
	cin >> H >> W >> T;

	for(int i = 1; i <= H; i++) {
		for(int j = 1; j <= W; j++) {
			int c = (!!((i-j+INF)%(T<<1) < T)) << 1 | (!!((i+j)%(T<<1) < T));
			putchar("RGBY"[c]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 512
import java.util.*

fun main(args: Array<String>) {
    var inp = Scanner(System.`in`)
    var n = inp.nextInt()
    var k = inp.nextInt()
    var sum: Int = 0
    for (i in 1..n) {
        var x = inp.nextInt()
        sum += Math.min(x, Math.abs(x - k)) * 2
    }
    println(sum)
}

Measured memory_bytes: 31144
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b)for(int i = (a);i <= (b); i++)
#define ROF(i, a, b)for(int i = (a);i >= (b); i--)
const int N = 22;
int f[N][1<<N], lg[1<<N];
int n, K;
int main(){
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    cin>>n>>K;
    int x;
    FOR(i, 0, n){
        FOR(j, 0, (1 << i) - 1){
            scanf("%1d", &x);
            f[i][(1<<i)|j] = x;
            //printf("i=%d j=%d f=%d\n", i, j, f[i][(1<<i)|j]);
        }
    }
    FOR(i, 2, (1 << n) - 1)lg[i] = lg[i>>1] + 1;
    ROF(i, n, 0){
        FOR(s, 1 << i, (1 << i + 1) - 1){
            ROF(j, i, 0){
                if(!f[j][s])continue;
                int F = f[j][s];
                int s1 = s >> j;
                int s2 = s & ((1 << j) - 1);
                //printf("i=%d s=%d j=%d s1=%d s2=%d f=%d\n", i, s, j,  s1, s2, F);
                if(j)f[0][s1] += F;
                if(s2){
                    int k = lg[s2];
                    int S = ((s1 << 1 | 1) << k) | (s2 ^ (1 << k));
                    //printf("k=%d S=%d s1=%d\n", k, S, (s1 << 1 | 1) << k);
                    f[k][S] += F;
                }
                int s3 = (~s2) & ((1 << j) - 1);
                //printf("i=%d s=%d j=%d s1=%d s2=%d s3=%d F=%d\n", i, s, j, s1, s2, s3, F);
                if(s3){
                    int k = lg[s3];
                    int S = (s1 << k + 1) | (s2 & ((1 << k) - 1));
                    f[k][S] += F;
                }
            }
        }
    }
    ROF(i, n, 0){
        FOR(s, 0, (1 << i) - 1){
            if(f[0][s|(1<<i)] >= K){
                //printf("i=%d\n", i);
                for(int k = i - 1;k >= 0; k--){
                    printf("%d", s >> k & 1);
                }
                puts("");
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 215424
#include <stdio.h>

// I/O
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
//


// Solve
void dfs(int G[100][100], int n, int *d, int *f, int u) {
    static int t = 0;
    d[u] = ++t;
    for(int i = 0; i < n; ++i) {
        if(!G[u][i] || d[i]) continue;
        dfs(G, n, d, f, i);
    }
    f[u] = ++t;
}

int main(int argc, char **argv) {
    int n = get_uint();
    int G[100][100] = {};
    for(int i = 0; i < n; ++i) {
        int u = get_uint() - 1;
        int k = get_uint();
        for(int j = 0; j < k; ++j) G[u][get_uint() - 1] = 1;
    }
    int d[100], f[100] = {};
    for(int i = 0; i < n; ++i)
        if(!f[i]) dfs(G, n, d, f, i);
    for(int i = 0; i < n; ++i) {
        put_uint(i + 1), putchar_unlocked(' ');
        put_uint(d[i]), putchar_unlocked(' ');
        put_uint(f[i]), putchar_unlocked('\n');
    }
    return 0;
}



Measured memory_bytes: 2052
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let A = scan.word::<usize>();
    let B = scan.word::<usize>();
    let C = scan.word::<usize>();
    let mut K = scan.word::<usize>();

    let mut m = 0_i64;
    let a = A.min(K);
    m += a as i64;
    K -= a;

    let b = B.min(K);
    K -= b;

    let c = C.min(K);
    m -= c as i64;

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


Measured memory_bytes: 2108
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    long long res = 1LL << 60;
    for (int i = 0; i + k <= n; ++i) {
        int l = X[i];
        int r = X[i + k - 1];

        long long ans = r - l + min(abs(r), abs(l));
        res = min(res, ans);
    }

    cout << res << '\n';

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s=="Sunny")cout << "Cloudy";
    if(s=="Cloudy")cout << "Rainy";
    if(s=="Rainy") cout << "Sunny";
    cout << endl;

}

Measured memory_bytes: 256
def calc(a,b,x)
  return (a * x) / b - a * (x / b)
end
a,b,n = gets.split.map(&:to_i)
ans = []
ans << calc(a,b,n)
ans << calc(a,b,n-1)
ans << calc(a,b,[0,n/b*b-1].max)
p ans.max

Measured memory_bytes: 14328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort(ALL((c)))
#define debug(x)                 \
    do {                         \
        std::cout << #x << ": "; \
        view(x);                 \
    } while (0)

template <typename T>
void view(T e) {
    std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << ", ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

int main() {
    ll X;
    cin >> X;
    if (X >= 30) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 3632
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	string s = ReadLine(); // N

	int x = 0;
	for (int i = 0; i < s.Length; i++)
	{
	    x += s[i] - '0';
	}

	WriteLine(x == 1 ? 10 : x);
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+7;
typedef long long ll;
ll A[maxn],B[maxn];int T[maxn];
template <typename T>
struct BIT{
	int n;
	vector<T> v;
	
	BIT(int n=0)
	{
		init(n);
	}
	void init(int nin)
	{
		n=nin;
		v.resize(n+2);
		for(int i=1;i<=n;i++) v[i]=0;
	}
	void add(int i,T a)
	{
		while(i<=n)
		{
			v[i]+=a;
			i+=(i&(-i));
		}
	}
	T sum(int i)
	{
		T s=0;
		if(i<=0) return 0;
		while(i>0)
		{
			s+=v[i];i-=(i&(-i));
		}
		return s;
	}
	T sum(int i,int j)
	{
		return sum(j)-sum(i-1);
	}
	//a[1]+a[2]+...a[ret]>=x
	int low_bound(T x)
	{
		T tmp=0;int ret=0,k=1;
		while(2*k<=n) k<<=1;
		for(;k>=1;k>>=1)
		{
			if(ret+k <= n && v[ret+k]<x)
			{
				x-=v[ret+k];ret+=k;
			}
		}
		return ret+1;
	}
};
int main()
{
	int q;scanf("%d",&q);vector<ll> as;//as的作用的给数下标 
	for(int i=1;i<=q;i++)
	{
		scanf("%d",&T[i]);
		if(T[i]==1)
		{
			scanf("%lld%lld",&A[i],&B[i]);
			as.push_back(A[i]);
		}
	}
	sort(as.begin(),as.end());
	as.erase(unique(as.begin(),as.end()),as.end());
	int sz=as.size();map<ll,int> mp;
	for(int i=1;i<=sz;i++)
	{
		mp[as[i-1]]=i;
		//cout<<i<<" "<<as[i-1]<<endl;
	}
	BIT<ll> bitsum(sz);
	BIT<ll> bitnum(sz);
	int allv=0;ll tmp=0;
	for(int i=1;i<=q;i++)
	{
		if(T[i]==1)
		{
			int id=mp[A[i]];
			bitsum.add(id,A[i]);
			bitnum.add(id,1);
			tmp+=B[i];//cout<<i<<" "<<B[i]<<endl;
			allv++;
		}
		else
		{
			int id=bitnum.low_bound((allv+1)/2);//cout<<" "<<as[id-1]<<endl;
			ll ans=0;
			ans-=bitsum.sum(1,id-1);
			//cout<<ans<<endl;
			ans+=as[id-1]*bitnum.sum(1,id-1);
			//cout<<ans<<endl;
			ans+=bitsum.sum(id+1,sz);
			//cout<<ans<<endl;
			ans-=as[id-1]*bitnum.sum(id+1,sz);
			//cout<<ans<<endl;
			cout<<as[id-1]<<" "<<ans+tmp<<endl;
		}
	}
 } 

Measured memory_bytes: 15476
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
#include <numeric>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int N;
    cin >> N;
    vector<int> T(N);
    for(int i = 0; i < N; i++) cin >> T[i];
    int M;
    cin >> M;
    vector<int> P(M), X(M);
    for(int i = 0; i < M; i++) cin >> P[i] >> X[i];

    int64_t sum = accumulate(T.begin(), T.end(), 0);
    for(int i = 0; i < M; i++){
        cout << sum - T[P[i] - 1] + X[i] << endl;
    }

    return 0;
}

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

int main()
{
	int a, b;
	
	while (scanf("%d %d", &a, &b), a + b){
		if ((a * b) % 2 == 1){
			printf("no\n");
		}
		else {
			printf("yes\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1012
use std;

pub fn main() {
  fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse::<T>().ok().unwrap()
  }
  fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
      .split_whitespace()
      .map(|e| e.parse().ok().unwrap())
      .collect()
  }
  let k = read::<i32>();
  let ab = read_vec::<i32>();
  let a = ab[0];
  let b = ab[1];

  if (k - (a % k)) % k <= b - a {
    println!("OK");
  } else {
    println!("NG");
  }
}

Measured memory_bytes: 2108
/*
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
*/
#include <bits/stdc++.h>

#define rep(i,n)  for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main()
{
    ll n,k,a,b;
    cin >> n >> k;
        a = n%k;
        b = abs(a-k);
        if(a > b){
            cout << b;
        }else{
            cout << a;
        }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Int long long
#define pb push_back
using namespace std;


Int N,M,K;
Int X,Y,Z,D;
const int MAXN=105;
Int B,C;


struct DisJointSet{
    vector<int> SZ;
    vector<int> ID;
    int n;

    DisJointSet(int n){
        SZ.resize(n);
        ID.resize(n);
        this->n=n;
        
        for(int i=0;i<n;++i){
            ID[i]=i;
            SZ[i]=1;
        }
    }
    
    int find(int x){
        return (ID[x]==x ? x:find(ID[x]));
    }
    
    void Union_find(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(SZ[x]>SZ[y]){
            ID[y]=x;
            SZ[x]+=SZ[y];
        }
        else{
            ID[x]=y;
            SZ[y]+=SZ[x];
        }
        return;
    }
};


int main()
{
    
  cin>>N>>M;
  vector<Int> A(N);
  Int sum=0;
  for(auto &x:A) cin>>x,sum+=x;
  sort(A.rbegin(),A.rend());
  Int ans=0;
  
  for(int i=0;i<min(N,M);++i){
      ans+=A[i];
  }
  
  ans=sum-ans;
  ans=max(ans,0LL);
  cout<<ans<<"\n";
  
}

Measured memory_bytes: 4812
#include <cstdio>
#include <algorithm>

using namespace std;

int a[1001];

int main() {
  int n;
  while (true) {
    scanf("%d", &n);
    if (n == 0) break;
    for (int i=0;i<n;i++) scanf("%d", &a[i]);
    sort(a, a+n);
    int mind = a[n-1];
    for (int i=0;i<n-1;i++) mind = min(mind, a[i+1]-a[i]);
    printf("%d\n", mind);
  }
  return 0;
}

Measured memory_bytes: 2780
n,m=[int(x) for x in input().split()]

h=[int(x) for x in input().split()]

t=[1 for i in range(n)]

for i in range(m):
  a,b=[int(x) for x in input().split()]
  a-=1
  b-=1
  if h[a]>h[b]:
    t[b]=0
  elif h[a]<h[b]:
    t[a]=0
  else:
    t[a]=0
    t[b]=0
print(sum(t))

Measured memory_bytes: 20120
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;



//メモリ置き場


//inputします
void input() {
	
}

//ライブラリ置き場
i64 cup(i64 xxx38, i64 yyy38) {//切り上げ
	return (xxx38 + yyy38 - 1) / yyy38;
}
//main
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	input();
	string s;
	cin >> s;
	int ans = 0;
	int pre = 0;
	ff(i, 0, s.size()) {
		char d = s[i];
		if (d == 'A' || d == 'T' || d == 'C' || d == 'G')pre++;
		else {
			if (pre > ans)ans = pre;
			pre = 0;
		}
	}
	if (pre > ans)ans = pre;
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int>s(13);
  vector<int>h(13);
  vector<int>c(13);
  vector<int>d(13);
  rep(i,n){
    char gara;
    int a;   
    cin >> gara >> a;
    a--;
    if(gara=='S') s[a]++;
    if(gara=='H') h[a]++;
    if(gara=='C') c[a]++;
    if(gara=='D') d[a]++;
  }
  rep(i,13){
    if(!s[i]) cout << 'S' << " " << i+1 << endl;
  }
  rep(i,13){
    if(!h[i]) cout << 'H' << " " << i+1 << endl;
  }
  rep(i,13){
    if(!c[i]) cout << 'C' << " " << i+1 << endl;
  }
  rep(i,13){
    if(!d[i]) cout << 'D' << " " << i+1 << endl;
  }
  return 0;

      
}



Measured memory_bytes: 3096
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	cout << t + s << endl;
	
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  st s;
  ll n;
  cin >> s >> n;
  ll k=s.size();
  rep(i,k){
    ll z=s[i]-'a';
    if(i!=k-1&&z==0){
      continue;
    }
    else if(i==k-1){
      n%=26;
      z+=n;
      z%=26;
      s[i]=abc[z];
    }
    else{
      if(26-z<=n){
        s[i]='a';
        n-=26-z;
      }
      else{
        continue;
      }
    }
  }
  cout << s << endl;
}

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

int main() {
  int n, h, w;
  cin >> n >> h >> w;
  int a, b, count = 0;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a >= h && b >= w) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n, c, k = ns()
    t = [ni() for _ in range(n)]
    t.sort()

    ans = 0
    idx = 0
    while idx < n:
        ans += 1

        k_idx = bisect.bisect_right(t, t[idx] + k)
        c_idx = idx + c

        idx = min(k_idx, c_idx)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9556
#include<stdio.h>
#include<stdlib.h>

int main(){
  
  int *A,key,i,j,tmp,mini,count=0;
  scanf("%d",&key);
  A = (int *)malloc(sizeof(int) * key);
  if(A == NULL){
    exit(0);
  }
  for(i=0;i<key;i++){
    A[i] = 0;
  }
  for(i=0;i<key;i++){
    scanf("%d",&A[i]);
  }
  
  for(i = 0;i<key;i++){
    mini = i;
    for(j = i;j < key;j++){
      if(A[j] < A[mini]){
	mini = j;      
}
    }
      tmp = A[i];
      A[i] = A[mini];
      A[mini] = tmp;
      if(i!=mini)count++;
  }
  for(i=0;i<key;i++){ 
    if(i != key-1){
    printf("%d ",A[i]);
    }else{
      printf("%d\n%d\n",A[key-1],count);  
    }
  }
  free(A);
  
  return 0;
}

Measured memory_bytes: 600
def main():
    A, B, C, D = list(map(int, input().strip().split()))
    print(calc(A, B, C, D))


def calc(A, B, C, D):
    # bがa包含
    # aがb包含
    # a start をbが包含
    # a end をbが包含
    if C <= A <= B <= D:
        return B - A
    elif A <= C <= D <= B:
        return D - C
    elif C <= A <= D:
        return D - A
    elif C <= B <= D:
        return B - C
    else:
        return 0

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
typedef long long Long;
void FastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
}

const int N = 1e6;

int main()
{
  FastIO();
  //int tc, ca = 0;
  int n;
  cin >> n;
  vector <Long> v(n);
  int zero = 0;
  for (int i = 0;i < n;i++){
    cin >> v[i];
    if (v[i]==0)zero++;
  }
  Long lim = 1e18;
  if (zero)cout << "0" << '\n';
  else {
    Long prod = 1;
    for (int i = 0;i < n;i++){
      if (v[i] <= lim/prod)prod *= v[i];
      else {
        prod = -1;
        break;
      }
    }
    cout << prod << '\n';
  }
  return 0;
}


Measured memory_bytes: 3948