akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

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

int main(){
    int n, ans=0;
    cin >> n;
    if(10 <= n){
        ans += 9;
        if(1000 <= n){
            ans += 900;
            if(100000 == n)ans += 90000;
            else if(10000<=n)ans += n-10000+1;
        }
        else if(100<=n)ans += n-100+1;
    }
    else ans = n;

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

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;

int main(){
     
    int n,m,a[50],b[50],c[50],d[50],check,min;
    
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<m;i++){
        cin>>c[i]>>d[i];
    }
    for(int i=0;i<n;i++){
        min=1000000000;check=0;
        for(int j=0;j<m;j++){
            if(abs(a[i]-c[j])+abs(b[i]-d[j])<min){
                min=abs(a[i]-c[j])+abs(b[i]-d[j]);
                check=j;
            }
        }
        cout<<check+1<<endl;
    }
    
    return 0;
}
 

Measured memory_bytes: 256
/* it was worth becoming a chemist */
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "cardgame"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e5 + 5;

ll a, b;

int main() {	
    // #ifndef ONLINE_JUDGE
	//~ freopen(NAME".in", "r", stdin);
    //~ freopen(NAME".out", "w", stdout);
    // #endif

	cin >> a >> b;
	if (a == b) {
		cout << 0;
		return 0;
	}
	if (a == 0 || b == 0) {
		if (a == 0) {
			if (b < 0) cout << -b + 1;
			else cout << b;
		}
		else {
			if (a < 0) cout << -a;
			else cout << a + 1;
		}
		return 0;
	}
	if (a < b) {
		if (b < 0) cout << abs(abs(b) - abs(a));
		else {
			if (a > 0) cout << abs(abs(b) - abs(a));
			else cout << abs(abs(b) - abs(a)) + 1;
		}
	}
	else {
		if (a < 0) cout << 2 + abs(abs(b) - abs(a));
		else {
			if (b < 0) cout << 1 + abs(abs(b) - abs(a));
			else cout << 2 + abs(abs(a) - abs(b)); 
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a=0;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    //cout.setf(ios_base::fixed,ios_base::floatfield);
    int n,m,z=0;
    cin>>n;
    bool a[101]={false};
    for(int i=0;i<n;i++){
        cin>>m;
        a[m]=true;
    }
    for(int i=0;i<101;i++){
        if(a[i]==true) z++;
    }
    cout<<z<<'\n';
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <list>

void deleteDuplication(std::list<int> &L) {
    for (auto i=L.begin(); i!=L.end(); i++) {
        for (auto j=L.begin(); j!=L.end(); j++) {
            if (i!=j && *i==*j) j = L.erase(j);
        }
    }
}

int main() {
    std::list<int> S, T;
    int n, q;
    int ans = 0;
    
    std::cin >> n;
    for (int i=0; i<n; i++) {
        int temp;
        std::cin >> temp;
        S.push_back(temp);
    }
    std::cin >> q;
    for (int i=0; i<q; i++) {
        int temp;
        std::cin >> temp;
        T.push_back(temp);
    }

    deleteDuplication(S);
    deleteDuplication(T);
    
    for (auto i=S.begin(); i!=S.end(); i++) {
        for (auto j=T.begin(); j!=T.end(); j++) {
            if (*i == *j) ans++;
        }
    }
    std::cout << ans << "\n";
}


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

#define N 100000
bool prime[N + 5] = {0};
vector<long long> plst;

void sprime() {
    prime[0] = 1;
    prime[1] = 1;
    for(int i = 2; i * i <= N; ++i)
        if(!prime[i]) {
            for (int j = 2; i * j <= N; ++j) prime[i * j] = 1;
        }
    for(int i = 2;i <= N;++i)
        if(!prime[i])plst.push_back(i);
}

long long m,a,b;

void solve();

int main() {
    sprime();
    while(1){
        cin >> m >> a >> b;
        if(m+a+b==0)break;
        solve();
    }
    return 0;
}


void solve(){
    long long p = 0,q = 0,plstsize = plst.size();
    for(int i = 0;i < plstsize;++i){
        long long nowq = plst[i],lef,righ = 0;
        auto it = upper_bound(plst.begin(),plst.end(),nowq);
        lef = *lower_bound(plst.begin(),plst.end(),(a * nowq + b - 1) / b);
        if(it != plst.begin())righ = *(--it);
        it = upper_bound(plst.begin(),plst.end(),m/nowq);
        if(it != plst.begin())
            righ = min(righ,*(--it));
        else righ = 0;
        if(righ >= lef && p * q < nowq * righ)p = righ, q = nowq;
    }
    cout << p << " " << q << endl;
}



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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll a, b, c;
    cin >> a >> b >> c;
    
    if (a == b && b == c && ~a&1) {
        cout << -1 << endl;
        return 0;
    }

    int cnt = 0;
    rep(i, 1e5) {
        if (!(~a&1&&~b&1&&~c&1)) break;
        int ta = a;
        int tb = b;
        int tc = c;
        a = (tb+tc)/2;
        b = (tc+ta)/2;
        c = (ta+tb)/2;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int n,ans=0;
  string a,b,c;
  cin>>n>>a>>b>>c;
  
  rep(i,0,n){
    if(a[i]!=b[i] && b[i]!=c[i] && c[i]!=a[i]) ans+=2;
    else if(a[i]==b[i] && b[i]!=c[i]) ans++;
    else if(a[i]!=b[i] && b[i]==c[i]) ans++;
    else if(a[i]==c[i] && b[i]!=c[i]) ans++;
  }
  co(ans);
  
  return 0;
}

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

int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  
  vector<pair<int,int>> pn;
  pn.push_back(make_pair(a%10==0?0:10-a%10,a));
  pn.push_back(make_pair(b%10==0?0:10-b%10,b));
  pn.push_back(make_pair(c%10==0?0:10-c%10,c));
  pn.push_back(make_pair(d%10==0?0:10-d%10,d));
  pn.push_back(make_pair(e%10==0?0:10-e%10,e));
  
  sort(pn.begin(),pn.end());
  
  int time = 0;
  for(int i=0;i<pn.size()-1;i++){
    time += pn[i].first+pn[i].second;
  }
  time += pn[pn.size()-1].second;
  
  cout << time << endl;
  
}


Measured memory_bytes: 256
# 素因数分解
def prime_factorization(N):
    tmp = N
    ans = []
    for i in range(2, int(N ** 0.5) + 1):
        count = 0
        while tmp % i == 0:
            tmp //= i
            count += 1
        if count != 0:
            ans.append([i, count])
    if tmp != 1:
        ans.append([tmp, 1])
    if ans == []:
        ans.append([N, 1])
    return ans


mod = 10 ** 9 + 7
N = int(input())
prime_list = [0] * N
if N == 1:
    print(1)
    exit()

for i in range(1, N+1):
    tmp_list = prime_factorization(i)
    ##print(i, tmp_list)
    for k in range(len(tmp_list)):
        prime_list[tmp_list[k][0]-1] += tmp_list[k][1]

ans = 1
for i in range(1, N):
    ans *= prime_list[i] + 1
    ans %= mod
##print(prime_list)
print(ans)

Measured memory_bytes: 3064
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

    for a in A:
        if a == 0:
            ans = 0
            break
        elif ans < 10**18:
            ans *= a
        
    if ans > 10**18:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 21608
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op=="?":
        break

    
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b) 
    elif op=="/":
        print(a//b)
    


Measured memory_bytes: 5596
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N, an=0,m=9;
	cin >> N;
	N++;
	
	
		while (N >9) {
			an += 9;
			N /= 10;
			m = min(m, N%10);
		}
		an += N-1;
	


	cout << an << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
#define MAX_V 1000
struct edge{int to,cap,rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to]&&e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	G[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  for(;;){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0)return flow;
    flow+=f;
  }
}

int main(){
  int V,E;
  cin>>V>>E;
  for(int i=0;i<E;i++){
    int u,v,c;
    cin>>u>>v>>c;
    add_edge(u,v,c);
  }
  cout<<max_flow(0,V-1)<<endl;
  return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin>>s;
    ll m=0;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]=='+')
        {
            m++;
        }
        else
        {
            m--;
        }
    }
    cout<<m<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits>

using namespace std;

int main(void) {
	int N, tmp, min = 2000, max = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		if (min > tmp) min = tmp;
		if (max < tmp) max = tmp;
	}
	cout << (max - min + 1) / 2 << endl; //小数点以下切り上げ
	
	return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>

int main(void){
  int i,j,prime[10001],n;

  for(i=0;i<10001;i++)prime[i]=0;

  prime[0]=prime[1]=1;
  
  for(i=2;i*i<10001;i++){
    if(prime[i]==0){
      for(j=2*i;j<10001;j+=i){
	prime[j]=1;
      }
    }
  }
  
  while(scanf("%d",&n),n){
    for(i=n;i>1;i--){
      if(prime[i]==0 && prime[i-2]==0){
	printf("%d %d\n",i-2,i);
	break;
      }
    }
  }
  return 0;
}

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

int main() {
    ll N,A,B,C,D,E; 
    cin>>N>>A>>B>>C>>D>>E;
    ll mn =min({A,B,C,D,E});
    cout<<(N+mn-1)/mn+4<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	a := N % 10
	res := "hon"
	if a == 0 || a == 1 || a == 6 || a == 8{
		res = "pon"
	} else if a == 3 {
		res = "bon"
	}

	

	fmt.Println(res)
}


Measured memory_bytes: 1752
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int ans=0;
  rep(i,n){
    cin>>a[i];
    if(i!=0 && a[i]>a[i-1]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3960
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  string S;
  cin >> S;
  const regex re = regex("^(?:dream(?:er)?|eraser?)+$");
  cout << (regex_match(S, re) ? "YES" : "NO") << endl;
  return 0;
}


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

  if (count(s.begin(), s.end(), 'o') + 15 - s.length() >= 8)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

long long int N, A[100001] = {}, ans = 0;

int main() {
	cin >> N;
	ans = N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	stable_sort(A, A + N + 1);
	for (int i = 1; i < N; i++) {
		if (A[i] == A[i + 1]) {
			ans-=2;
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

class Dice {
	private int[] d = new int[6];
	
	public void setDice(int index, int dnum) {
		this.d[index] = dnum;
	}
	
	public int getDice(int index) {
		return this.d[index];
	}
	
	void diceroll(String direction) {
		char[] dire = direction.toCharArray();
		for (char c : dire) {
			this.rool(c);
		}
	}
	
	void printDiceTop() {
		System.out.println(this.d[0]);
	}
	
	void printDiceRight() {
		System.out.println(this.d[2]);
	}
	
	private void rool(char di) {
		int temp = this.d[0];
		if (di == 'E') {
			this.d[0] = this.d[3];
			this.d[3] = this.d[5];
			this.d[5] = this.d[2];
			this.d[2] = temp;
		} else if (di == 'W') {
			this.d[0] = this.d[2];
			this.d[2] = this.d[5];
			this.d[5] = this.d[3];
			this.d[3] = temp;
		} else if (di == 'S') {
			this.d[0] = this.d[4];
			this.d[4] = this.d[5];
			this.d[5] = this.d[1];
			this.d[1] = temp;
		} else if (di == 'N') {
			this.d[0] = this.d[1];
			this.d[1] = this.d[5];
			this.d[5] = this.d[4];
			this.d[4] = temp;
		} else;
	}
	
	public boolean setTop(int dnum) {
		for (int i = 0; i < this.d.length; i++) {
			if (dnum == this.d[i]) {
				if (i == 1) this.rool('N');
				if (i == 2) this.rool('W');
				if (i == 3) this.rool('E');
				if (i == 4) this.rool('S');
				if (i == 5) {
					this.rool('N');
					this.rool('N');
				}
				return true;
			}
		}
		return false;
	}
	
	public boolean setCenter(int dnum) {
		int temp;
		int n = 0;
		for (int i = 1; i < 5; i++) {
			if (dnum == d[i]) {
				if (i == 1) n = 0;
				if (i == 2) n = 1;
				if (i == 4) n = 2;
				if (i == 3) n = 3;
				for (int j = 0; j < n; j++) {
					temp = this.d[1];
					this.d[1] = this.d[2];
					this.d[2] = this.d[4];
					this.d[4] = this.d[3];
					this.d[3] = temp;
				}
				return true;
			}
		}
		return false;
	}
	
	boolean diceCheck(Dice dice) {
		for (int i = 0; i < 6; i++) {
			for (int j = 0; j < 6; j++) {
				if (this.d[i] == dice.getDice(j)) {
					this.setTop(this.d[i]);
					dice.setTop(dice.getDice(j));
					if (dice.setCenter(this.d[1])) {
						for (int k = 2; k < 6; k++) {
							if (this.d[k] != dice.getDice(k))
								break;
							if (this.d[k] == dice.getDice(k) && k == 5) {									return true;
							}
						}
					} //else break;
				}
			}
		}
		return false;
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Dice dice[] = new Dice[2];
		for (int i = 0; i < 2; i++) {
			dice[i] = new Dice();
			for (int j = 0; j < 6; j++)
				dice[i].setDice(j, scan.nextInt());
		}
		if (dice[0].diceCheck(dice[1])) {
			System.out.println("Yes");
		} else System.out.println("No");
	}
}

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

//0102
int main(){
	int n;
	while(cin >> n, n){
		int tbl[11][11]={0};

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

		for(int i=0; i<n+1; ++i){
			for(int j=0; j<n+1; ++j){
				cout.width(5);
				cout << tbl[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import math

def main():
    D, G = map(int, input().split())

    pc = [list(map(int, input().split())) for _ in range(D)]

    ans = 100**10
    for i in range(1<<D):
        score = 0
        prob = 0
        last = -1
        for j in range(D):
            p, c = pc[j]
            if i & (1<<j):
                score += (j+1)*100*p + c
                prob += p
            else:
                last = j
        if score >= G:
            ans = min(ans, prob)
            continue
        elif last == -1:
            continue
        else:
            need = math.ceil((G-score)/((last+1)*100))
            if need > pc[last][0]-1:
                continue
            else:
                ans = min(ans, prob+need)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<ll,ll> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

int main(){
    ll  a;
    double b;
    cin >> a >> b;
    ll ib =b*100+0.5;
    ll ans = a*ib/100;
    printf("%ld\n",ans);
    return 0;
}

Measured memory_bytes: 3788
S = input()
K = int(input())
len_s = len(S)

substring_set = set()
for i in range(len_s):
    for j in range(min([K, len_s-i])):
        substring_set.add(S[i:i+j+1])

sorted_list = sorted(list(substring_set))
print(sorted_list[K-1])


Measured memory_bytes: 4592
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define all(v) (v).begin(),(v).end()
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<ll,ll>;

int main(void){
  int N,M; cin>>N>>M;
  vector<pi> AB(N);
  rep(i,N){
    cin>>AB[i].first>>AB[i].second;
  }
  sort(all(AB));
  ll ans=0;
  int pnt=0,rem=M;
  while(rem>0){
    if(rem>=AB[pnt].second){
      ans+=AB[pnt].first*AB[pnt].second;
      rem-=AB[pnt].second;
    }
    else{
      ans+=AB[pnt].first*rem;
      rem=0;
    }
    ++pnt;
  }
  cout<<ans<<endl;
}

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

int main() {
  string s, ans;
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '0') {
      ans += '0';
    } else if (s[i] == '1') {
      ans += '1';
    } else if (ans.size() != 0) {
      ans.pop_back();
    } else {
      continue;
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    K = int(input())
    a = K // 2
    b = K - a
    print(a * b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#include<stdio.h>

int main(){
	int i;
	int n;
	long long int pow = 1;

	scanf("%d",&n);

	for(i=1; i<=n; i++){
		pow = ( pow * (long long int)i ) % 1000000007;
	}

	printf("%d\n",pow);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

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

#define fs first
#define sc second

int n;
vector<int> edge[100100];

// Pのfirstが最短距離、secondが頂点番号
int prev_node[100100];
int d[100100];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+n, INT_MAX);

    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.sc;
        if(d[v] < p.fs) continue;
        for(int i = 0; i < edge[v].size(); i++){
            int e = edge[v][i];  //vからeへの道
            if(d[e] > d[v] + 1){
                d[e] = d[v] + 1;
                que.push(P(d[e], e));
                prev_node[e] = v;
            }
        }
    }
}

ll child[100100];

ll tree_child_dfs(int s, int pre){
    ll res = 0;
    for(int i = 0; i < edge[s].size(); i++){
        if(edge[s][i] == pre)   continue;

        res += tree_child_dfs(edge[s][i], s);
    }
    res++;
    child[s] = res;
    return res;
}


int main(){
    cin >> n;
    for(int i = 0; i < n-1; i++){
        int a, b;   cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    dijkstra(0);
    tree_child_dfs(0, -1);

    int dis = (d[n-1] - 1) / 2;
    int node = n-1;
    for(int i = 0; i < dis; i++){
        node = prev_node[node];
    }

    ll sunuke = child[node];
    ll fenec = n - child[node];
    if(sunuke >= fenec){
        cout << "Snuke" << endl;
    }
    else{
        cout << "Fennec" << endl;
    }


    return 0;
}



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

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

const LL MOD = 1000000007;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int ans = 1000000;
    int n, t;
    cin >> n >> t;
    for (int i = 0; i < n; ++i)
    {
        int ci, ti;
        cin >> ci >> ti;
        if (ti <= t) ans = min(ci, ans);
    }
    if(ans == 1000000) cout << "TLE" << endl;
    else cout << ans << endl;

    return 0;
}


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

int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> a(2*m);
    vector<int> x(n+1);
    for(int i=0;i<2*m;i++){
        cin>>a.at(i);
        x.at(a.at(i))++;
    }
    for(int i=1;i<n+1;i++){
        cout<<x.at(i)<<endl;
    }

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)

	d := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&d[i])
	}

	sort.Ints(d)
	center := N / 2
	ans := d[center] - d[center-1]
	fmt.Println(ans)
}


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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


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

	cout << "ABC" << to_string(n) << endl;
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long a,b,c,d;
  a=1; b=1; c=1;
  for(int i=0;i<N;i++){
    a*=10; b*=9; c*=8;
    a%=1000000007; b%=1000000007; c%=1000000007;
  }
  cout<<(a-2*b+c+2000000014)%1000000007<<endl;
  
  
  return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
#define N 100
#define INF 10000000
#define WHITE 0
#define BLACK 1
typedef struct {
  int v[N];
  int c[N];
  int k,d,pi,color;
} Graph;
int n;
Graph g[N];

void dijkstra()
{
  int i,j,u,mincost;
  for(i=0; i<n; i++){
    g[i].d = INF;
    g[i].pi = -1;
    g[i].color = WHITE;
  }
  g[0].d = 0;
  
  while(1) {
    mincost = INF;
    for(i=0; i<n; i++) {
      if(g[i].color != BLACK && g[i].d < mincost) {
        mincost = g[i].d;
        u = i;
      }
    }
    
    if(mincost == INF) break;
    
    g[u].color = BLACK;
    for(i=0; i<g[u].k; i++) {
      j = g[u].v[i];
      if(g[j].color != BLACK && g[u].c[i] + g[u].d < g[j].d) {
        g[j].pi = u;
        g[j].d = g[u].c[i] + g[u].d;
      }
    }
  }
}

int main()
{
  int i,j,u,ver,cost;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d%d",&u,&g[i].k);
    for(j=0; j<g[i].k; j++) {
      scanf("%d%d",&ver,&cost);
      g[u].v[j]=ver; g[u].c[j] = cost;
    }
  }
  
  dijkstra();
  for(i=0; i<n; i++) printf("%d %d\n",i,g[i].d);
  return 0;
}

Measured memory_bytes: 680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
ll N, K;

signed main()
{
    ll ans = 0ll;
    cin >> N >> K;
    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }
    // N = p*b + r
    for (ll b = 1; b <= N; ++b) {
        ll r = N % b;
        ll p = N / b;
        ans += p * max(0ll, b - K); // b未満の数
        ans += max(0ll, r - (K - 1)); // b以上のあまり
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{

    public static void main(String args[]) throws Exception{
        Main main = new Main();
    }

    public Main(){
        Scanner scanner = new Scanner(System.in);
        int H,A;
        H = Integer.parseInt(scanner.next());
        A = Integer.parseInt(scanner.next());

        int total = 0, result=0;

        while(total < H){
            total += A;
            result++;
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>S;
    N = S.size();
    T = "";
    rep(i,N) T.push_back('x');
    cout<<T<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)

using namespace std;

typedef long long LL;
const int N = 100010;
int a[N], b[N], c[N], d[N]; LL sum[N];
int n; LL ans;

int main() {
	int i, j;
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d", &a[i]); sort(a + 1, a + n + 1);
	rep(i, 1, n) scanf("%d", &b[i]); sort(b + 1, b + n + 1);
	rep(i, 1, n) scanf("%d", &c[i]); sort(c + 1, c + n + 1);
	j = 0;
	rep(i, 1, n) {
		while(j < n && a[j+1] < b[i]) ++j;
		d[i] = j;
	}
	rep(i, 1, n) sum[i] = sum[i-1] + d[i];
	j = 0;
	rep(i, 1, n) {
		while(j < n && b[j+1] < c[i]) ++j;
		ans += sum[j];
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;
#define LL long long

const int MAXN = 212345;


int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	LL L, R;
	cin >> L >> R;

	LL x = (L - 1) / 2019LL;
	LL y = R / 2019LL;


	if (x != y) cout << 0 << '\n';
	else {
		LL mn = 2019;

		for (LL i = L; i <= R; ++i)
			for (LL j = i + 1; j <= R; ++j)
				mn = min (mn, (i * j) % 2019LL);

		cout << mn << '\n';
	}


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<double> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  double ans=a[0];
  for(int i=1;i<n;i++){
    ans=(ans+a[i])/2;
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
int main(void){
    ll N,K;cin>>N>>K;
    ll l[N];REP(i,N)cin>>l[i];
    sort(ALL(l,N),greater<ll>());
    ll ans=0;
    REP(i,K)ans+=l[i];
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int f(int i,int x){
	return i*(100+x)/100;
}

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		vvi a(21,vi(21));
		vp b(n);
		for(int i=0;i<n;i++) cin>>b[i].first>>b[i].second;
		int m,x=10,y=10;
		cin>>m;
		a[x][y]++;
		for(int i=0;i<m;i++){
			char c;
			int d,id;
			cin>>c>>d;
			if(c=='W') id=0;
			if(c=='S') id=1;
			if(c=='E') id=2;
			if(c=='N') id=3;
			for(int j=0;j<d;j++){
				x+=dx[id],y+=dy[id];
				a[x][y]++;
			}
		}
		bool res=1;
		for(int i=0;i<n;i++) if(!a[b[i].first][b[i].second]) res=0;
		cout<<(res?"Yes":"No")<<endl;
	}
}


Measured memory_bytes: 3120
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const double EPS = 1e-5;
const int MAX_J = 5001;

int X,Y,Z;
double dp[51][MAX_J];
int V[4];
int event[51], event_A[51];

int main(){
    while(1){
        scanf("%d%d%d",&X,&Y,&Z);
        if(!X)break;

        for(int i = 0; i < X; i++){
            scanf("%d",&V[i]);
        }
        fill(event, event+Y+1, 0);
        for(int i=0;i<Z;i++){
            int N,E,A;
            scanf("%d%d%d",&N,&E,&A);
            event[N] = E;
            event_A[N] = A;
        }
        for(int i=0;i<Y+1;i++){
            for(int j=0;j<MAX_J;j++){
                dp[i][j] = 0;
            }
        }

        dp[0][0] = 1;
        for(int i=0;i<Y;i++){
            for(int j=0;j<MAX_J;j++){
                for(int k=0;k<X;k++){
                    int nx = min(Y, i + V[k]), mn = j;
                    if(event[nx] == 2) mn += event_A[nx];
                    else if(event[nx] == 3) mn = max(0, j-event_A[nx]);
                    else if(event[nx] == 1) nx = min(Y, nx + event_A[nx]);
                    dp[nx][mn] += dp[i][j] / X;
                }
            }
        }
        double ans = 0;
        for(int i = 0; i < 5000; i++) ans += i * dp[Y][i];
        printf("%d\n", (int)(ans+EPS));
    }
    return 0;
}

Measured memory_bytes: 3180
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

long long M = 1000000007;

long long mod_mul(long long a, long long b)
{
    return ((a % M) * (b % M)) % M;
}
long long mod_factorial(long n)
{
    long long res = 1;
    for (int i = n; i >= 1; i--)
    {
        res = mod_mul(res, i);
    }
    // cout << "fact:" << n << " " << res << endl;
    return res;
}
long mod_pow(long n, long m)
{
    if (m == 0)
        return 1;
    else if (m == 1)
        return n % M;
    else if (m % 2 == 0)
    {
        long long p = mod_pow(n, m / 2);
        return mod_mul(p, p);
    }
    return mod_mul((mod_pow(n, m - 1)), n);
}

int main()
{
    long X, Y;
    cin >> X >> Y;
    long a = (2 * X - Y) / 3;
    long b = (-X + 2 * Y) / 3;
    if ((2 * X - Y) % 3 != 0 || a < 0 || b < 0)
    {
        cout << "0" << endl;
        return 0;
    }
    // cout << a << " " << b << endl;
    long mod_ab = mod_factorial(a + b);
    long mod_a = mod_factorial(a);
    long mod_b = mod_factorial(b);
    cout << mod_mul(mod_ab, mod_pow(mod_mul(mod_a, mod_b), M - 2)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int64_t N, W;
    cin >> N >> W;
    vector< vector<int64_t> > V(4);
    --N;
    int64_t w0, v0;
    cin >> w0 >> v0;
    V[0].push_back(v0);
    while(N--) {
        int64_t w, v;
        cin >> w >> v;
        V[w-w0].push_back(v);
    }

    for(auto &e: V) {
        sort(e.begin(), e.end());
        e.push_back(0);
        reverse(e.begin(), e.end());
        partial_sum(e.begin(), e.end(), e.begin());
    }

    int64_t ans = 0;
    for(int64_t i=0; i<V[0].size(); i++) {
        for(int64_t j=0; j<V[1].size(); j++) {
            for(int64_t k=0; k<V[2].size(); k++) {
                for(int64_t l=0; l<V[3].size(); l++) {
                    if(w0*(i+j+k+l) + j + 2*k + 3*l <= W) {
                        ans = max(ans, V[0][i] + V[1][j] + V[2][k] + V[3][l]);
                    }
                }
            }
        }
    }

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


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

int main() {
  int A, B, N;
  cin >> N >> A >> B;
  if (N * A > B) {
    cout << B << endl;
  }
  else if (N * A == B) {
    cout <<  B << endl;
  }
  else {
    cout << N * A << endl;
  }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=500006;

void solve(){
	int n;
	cin>>n;
	vector<pair<pair<int,int>,int>>z(n);
	for(int i=0;i<n;i++){
		cin>>z[i].F.S>>z[i].F.F;
		z[i].S=i;
	}
	sort(all(z));
	int cur=0,flag=0;
	for(int i=0;i<n;i++){
		if(z[i].F.S+cur<=z[i].F.F)cur+=z[i].F.S;
		else flag++;
	}
	if(flag)cout<<"No";
	else cout<<"Yes";
	
	
	
	
}
	
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	if(a<0)a+=mod;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;	
}


Measured memory_bytes: 2560
import sys
from bisect import bisect
from itertools import accumulate

n, m, k, *ab = map(int, sys.stdin.buffer.read().split())
aaa = [0] + ab[:n]
bbb = [0] + ab[n:]
acc = list(accumulate(aaa))
bcc = list(accumulate(bbb))

ans = 0
for i in range(n + 1):
    r = k - acc[i]
    if r < 0:
        break
    j = bisect(bcc, r) - 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 51576
from collections import defaultdict

if __name__ == '__main__':
    nums = [int(x) for x in input().split()]
    N,T = nums[0],nums[1]
    cities = [int(x) for x in input().split()]

    d = defaultdict(int)

    minPrice = 90000000000
    maxProf = -1
    for city in cities:
        minPrice = min(city, minPrice)
        prof = city - minPrice
        d[prof] += 1
        
        maxProf = max(prof,maxProf)
    print(d[maxProf])


Measured memory_bytes: 20960
<?php
list($n,$m)=explode(' ',trim(fgets(STDIN)));
for($i=0;$i<$n;$i++) $a[$i]=explode(' ',trim(fgets(STDIN)));
for($i=0;$i<$m;$i++) $b[$i]=trim(fgets(STDIN));
 
for($i=0;$i<$n;$i++){
  $c=0;
  for($j=0;$j<$m;$j++) $c+=$a[$i][$j]*$b[$j];
  echo $c,PHP_EOL;
}

Measured memory_bytes: 17000
import java.io.*;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pw =new PrintWriter(new OutputStreamWriter(System.out));
static StringTokenizer st;
static BitSet bs;
static int TC,N,M,a,b,n;
static int [] values;
    public static void main(String[] args) throws IOException {
        // write your code here
        st= new StringTokenizer(br.readLine());
        a = Integer.parseInt(st.nextToken());
        b = Integer.parseInt(st.nextToken());
        String sum = "";
        String sumA = "";
        for (int i=0;i<a;i++)
            sum+=b;
        for (int j=0;j<b;j++)
            sumA+=a;
        pw.println(sum.compareTo(sumA)<0?sum:sumA);pw.flush();


    }

    private static boolean condition(int A, int B) {
        int firstDigit = firstDigit(B);
        int firstDigitA = firstDigit(A);
        return (A%10)==firstDigit&&firstDigitA==B%10;
    }
    static int firstDigit(int n)
    {

        int digits = (int)(Math.log10(n));
        n = (int)(n / (int)(Math.pow(10, digits)));
        return n;
    }
}


Measured memory_bytes: 25044
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <map>
#include <sstream>
using namespace std;
int main(){	
	ios_base::sync_with_stdio(0);
	string arr[]={"Sunny","Cloudy","Rainy"};
	
	string s;
	cin >> s;

	for(int i=0;i<3;i++){
		if(s==arr[i]){
			if(i==2){
				cout << arr[0] << '\n';
			}
			else{
				cout << arr[i+1] << '\n';
			}
		}
	}
}


Measured memory_bytes: 256
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　| 　_　 _ l
　 　　　／` ミ＿xノ
　　 　 /　　　 　 |　見ちゃダメ〜
　　　 /　 ヽ　　 ﾉ　　
　 　 │　　|　|　|　　
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)__)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 1; i <= n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int h, w;
  cin >> h >> w;
  string s[55];
  rep(i, h) cin >> s[i];
  int count = 0;
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#' && s[i][j - 1] != '#' && s[i - 1][j] != '#' &&
          s[i + 1][j] != '#' && s[i][j + 1] != '#')
        count++;
    }
  }
  if (count == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

#include <atcoder/mincostflow>

using namespace std;
using namespace atcoder;
#define rep(i,l,r) for(int i = l; i < r; ++i)

int main() {
    int n, k, s, t;
    long long a, MAX = 1'000'000'000;
    cin >> n >> k;
    s = 2 * n;
    t = s + 1;

    mcf_graph<int, long long> mcf(t + 1);
    mcf.add_edge(s, t, k * n, MAX);
    rep(i, 0, n) {
        mcf.add_edge(s, i, k, 0);
        mcf.add_edge(n + i, t, k, 0);
    }

    rep(i, 0, n) {
        rep(j, 0, n) {
            cin >> a;
            mcf.add_edge(i, n + j, 1, MAX - a);
        }
    }

    auto ans = mcf.slope(s, t, k * n).back(); 
    cout << MAX * k * n - ans.second << endl;

    auto edge = mcf.edges();
    vector<string> g(n, string(n, '.'));
    for(auto e : edge) {
        if (e.from == s || e.to == t || e.flow == 0) continue;
        g[e.from][e.to - n] = 'X';
    }

    for(auto gg : g) cout << gg << endl;
}


Measured memory_bytes: 3460
#include<iostream>
using namespace std;using L=long long;L n,m,p,q,s[100002],S,t,i;int main(){for(cin>>n>>m>>p;--m;s[p<q?p:q]++,s[p>q?p:q]--,p=q)cin>>q;for(;cin>>p>>q>>m;S+=min(t*p,t*q+m))t+=s[++i];cout<<S<<'\n';return 0;}

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

int main() {
  int N;
  long long ans = 0;
  char s[5] = { 'M', 'A', 'R', 'C', 'H' };
  string name;
  map<char, long long> mp;

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> name;
    for (int i = 0; i < 5; ++i) {
      if (name[0] == s[i]) {
        mp[s[i]]++;
        break;
      }
    }
  }

  for (int i = 0; i < 5; ++i) {
    for (int j = i + 1; j < 5; ++j) {
      for (int k = j + 1; k < 5; ++k) {
        ans += (mp[s[i]] * mp[s[j]] * mp[s[k]]);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main()
{

  int dp[4001][4];
  for(int i=1;i<5;i++)
    for(int j=0;j<4001;j++)
      dp[j][i-1] = i==1&&j<=1000?1:0;

  for(int i=2;i<=4;i++)
    for(int j=0;j<=4000;j++)
      for(int k=0;k<=j && k<=1000;k++)
	dp[j][i-1] += dp[j-k][i-2];

  int n;
  while(cin >> n)
    cout << dp[n][3] << endl;
    
  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std; 
using lint =                            long long int;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD 1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/
vector<int> gen_primes(int N){
   vector<int> ans;
   vector<int> alive(N + 1,1); //for 1 based indexing;   
   lint now = 2;
   for(;now*now <= N; ++now){
      if(alive[now]) ans.push_back(now);
      for(int t = now;t <= N;t += now) alive[t] = 0;
   }
   for(;now <= N;++now)  if(alive[now])  ans.push_back(now);     //for the primes greater than factor sqrt(N);
   return ans;
}

void solve(){  
  vector<int> primes = gen_primes(200000);
  int X;
  cin>>X;
  cout<<*lower_bound(ALL(primes),X) << endl;
}

int main(){   
  
 solve();

 return 0;
}


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

int main() {
  int N;
  cin >> N;

  vector<int64_t> data(N+1,0);
  data.at(0) = 2;
  data.at(1) = 1;


  for (int i=2; i<N+1; i++) {
    //cout << i << endl;
    data.at(i) = data.at(i-2) + data.at(i-1);
    
  }
  cout << data.at(N) << endl;
}



Measured memory_bytes: 256
def main():

    S = input()
    out = 0
    for i in range(len(S)):
        if i % 2 == 0 and S[i] == "L":
            out += 1
        if i % 2 != 0 and S[i] == "R":
            out += 1
    if out == 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060