akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const double PI = 3.14159265358979323846;
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}

int main(void) {
  string s;
  cin >> s;
  string ans;
  if (s[s.size() - 1] == 's') {
    ans = s + "es";
  } else {
    ans = s + "s";
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    ll n,i,l=1e4,m=0,c=1e9,j,s; cin>>n; 
    vector<ll>a; 
    for(i=0;i<n;i++) 
    {cin>>l; a.pb(l); }
    sort(a.begin(),a.end());
    for(i=a[0];i<=a[n-1];i++)
    { s=0;
        for(j=0;j<n;j++)
        {
            s+=(i-a[j])*(i-a[j]);
        }
        c=min(c,s);
    }
    cout<<c;
	return 0;
}

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

int findsum(int a){
  int sum = 0;
  while(a>0){
    sum += a%10;
    a /= 10;
  }
  return sum;
}


int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int n,a,b;
  int ans=0;

  cin>>n>>a>>b;
  
  for(int i=n;0<i;i--){
    //cout<<i<<endl;
    int sum = findsum(i);
    //cout<<sum<<endl;
    if(a<=sum&&sum<=b){
      ans += i;
    }
  }    
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    cout << fixed << setprecision(10);
    long idx=0;
    long W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << (W * H / 2.0) << " " << (2 * x == W && 2 * y == H) << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    
    sum += r - l +1;
  }
  cout << sum << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
int main()
{
    int q,x;
    char op[20];
    list<int> v;
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>op;
        if(op[0]=='i')
        {
            cin>>x;
            v.push_front(x);
        }
        else if(op[6]=='L')
            v.pop_back();
        else if(op[6]=='F')
            v.pop_front();
        else if(op[0]=='d')
        {
            cin>>x;
            for(list<int>::iterator it=v.begin();it!=v.end();it++)
                if(*it==x)
                {
                    v.erase(it);
                    break;
                }
        }
    }
    int i=0;
    for(list<int>::iterator it=v.begin();it!=v.end();it++)
    {
        if(i++)
            cout<<" ";
        cout<<*it;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 34344
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e15)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	int cnt[5]={0};
	string s;
	For(i,0,n-1){
		cin>>s;
		switch(s[0]){
			case 'M':
				cnt[0]++;
				break;
			case 'A':
				cnt[1]++;
				break;
			case 'R':
				cnt[2]++;
				break;
			case 'C':
				cnt[3]++;
				break;
			case 'H':
				cnt[4]++;
				break;
		}
	}
	int ans=0;
	int o[5]={0,1,2,3,4};
	do{
		ans+=cnt[o[0]]*cnt[o[1]]*cnt[o[2]];
		//cout<<ans<<"\n";
	}while(next_permutation(o,o+5));
	cout<<ans/12<<'\n';
	//For(i,0,4) cout<<cnt[i]<<" \n"[i==4];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N, L, ans = 100000000;
	int a_0 = 0, a_1 = 0;
	cin >> N >> L;
	for (int i = 0; i < N; i++) {
		a_0 += L + i;
	}
	for (int i = 0; i < N; i++) {
		if (L + i == 0) {
			cout << a_0;
			return 0;
		}
		else if (a_0 < 0) {
			if (ans > a_0 - (L + i)) {
			ans = a_0 - (L + i);
			}

		}
		else if (a_0 > 0) {
			if (ans > a_0 - L + i) {
				ans = a_0 - L + i;
			}
		}
		
	}
	cout << ans << endl;


	

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
string s;
std::cin >> s;
long long ans=0;
long long now=s[0]-'0';

for (int bits = 0; bits < (1<<(s.length()-1)); bits++) {
  now=s[0]-'0';
  // std::cout << "bots=" <<bits<< '\n';
  for (int i = 0; i < s.length()-1 ;i++) {
    if(bits&(1<<i)){
      // std::cout << "ans+=" <<now<< '\n';
      ans+=now;
      now=s[i+1]-'0';
    }
    else {
      now=now*10+(s[i+1]-'0');
      // std::cout << s[i+1]-'0' << '\n';
    }
  }
  // std::cout << "ans+=" <<now<< '\n'<<'\n';
  ans+=now;
}
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
        int H,W; cin>>H>>W;
        REP(i,H){
                string s; cin>>s;
                cout<<s<<endl<<s<<endl;
        }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
D = [a-b for a,b in zip(A,B)]
D.sort()

lack = sum(d for d in D if d<0)

ans = 0
for d in D[::-1]:
    if lack < 0 and d > 0:
        ans += 1
        lack += d
    if d < 0:
        ans += 1
print(-1 if lack < 0 else ans)

Measured memory_bytes: 24172
N = int(input())
A = [int(x) for x in input().split()]

def Partition(A,p,r):
    x = A[r]
    i = p-1
    for j in range(p,r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

p = Partition(A,0,N-1)

for i in range(N):
    if i != 0:
        print(" ",end="")
    if i == p:
        print("[",end="")
    print(A[i],end="")
    if i == p:
        print("]",end="")
print()



Measured memory_bytes: 16368
#include <cstdio>

int main(int argc, char const *argv[]) {
  int a, b;
  scanf("%d", &a);
  scanf("%d", &b);
  if (a <= b) {
    printf("%d\n", a);
  } else {
    printf("%d\n", a - 1);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

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

int main()
{
  string s;
  cin >> s;
  int apos = 0, zpos = 0;
  REP(i, s.length()) {
    if(s[i] == 'A') {
      apos = i + 1;
      break;
    }
  }
  for(int i = apos + 1; i < s.length(); i++) {
    if(s[i] == 'Z') zpos = i + 1;
  }
  cout << zpos - apos + 1 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n;
    cin >> n;
    vector<ll> dp(55);
    dp[0] = 1;
    dp[1] = 1;
    REP(i, 2, n + 1){
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    print(dp[n]);
}



Measured memory_bytes: 3224
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		int y1=sc.nextInt();
		int y2=sc.nextInt();
		for(;;){
			boolean f=false;
			for(int y=y1; y<=y2; y++){
				if(y%4==0&&(y%100!=0||y%400==0)){
					println(y+"");
					f=true;
				}
			}
			if(!f)
				println("NA");
			y1=sc.nextInt();
			y2=sc.nextInt();
			if(y1==0&&y2==0)
				break;
			println("");
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<stdio.h>

typedef struct {
  int node;
  int p,l,r,s;
  int d,h;
  int depth;
  int type;
} Node;

Node T[25];

int depth(int count,int p){
  count++;
  if(T[p].p == -1) return count;
  depth(count,T[p].p);
}

int height(int i){
  int h = 0,t = 0;
    if(T[i].l == -1 && T[i].r == -1) return 0;

    if(T[i].l != -1) h = height(T[i].l) + 1;
    if(T[i].r != -1) t = height(T[i].r) + 1;

    if(h > t) return h;
    else return t;
}

int main(){
  int n,i,m,l,r;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    T[i].p = T[i].l = T[i].r = T[i].s = -1;
    T[i].d = 0;
    T[i].type = 2;

  }

  for(i = 0;i < n;i++){
    scanf("%d%d%d",&m,&l,&r);
    T[m].node = m;
    T[m].l = l;
    T[m].r = r;
    if(l > -1){
      T[m].d++;
      T[l].p = m;
    }
    if(r > -1){
      T[m].d++;
      T[r].p = m;
    }
    if(l > -1 && r > -1){
      T[l].s = r;
      T[r].s = l;
    }
  }

  for(i = 0;i < n;i++){
    if(T[i].p == -1) T[i].type = 0;
    else if(T[i].l != -1 || T[i].r != -1) T[i].type = 1;
    T[i].depth = depth(-1,T[i].node);
  }

  for(i = 0;i < n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", T[i].node,T[i].p,T[i].s,T[i].d,T[i].depth,height(i));
    if(T[i].type == 0) printf("root\n");
    else if(T[i].type == 1) printf("internal node\n");
    else printf("leaf\n");
  }

  return 0;
}



Measured memory_bytes: 2088
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001 
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl> 
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define set(x,k) memset(x,k,sizeof(x))
#define cy cout << "YES" << endl
#define  cn cout << "NO" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (auto i=2; i<MAXN; i++) 
  		spf[i] = i; 
  	for (auto i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (auto i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (auto j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
	return;
} 

vl getFactorization(ll x) 
{ 
    vl ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 


void check()
{
	ll n = 0;
	string s;
	cin >> s;
	for(ll i=0;i<s.size();i++) n+=(s[i]-'0');
	if(n%9==0) cout << "Yes" << endl;
	else cout << "No" << endl;
    return ;
}

int32_t main()
{
    fastio;
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}

Measured memory_bytes: 3772
#!/usr/bin/env python3

#import
#import math
#import numpy as np
N = int(input())

i = 0
isum = 0

while isum < N:
    i += 1
    isum += i

t = isum - N

for j in range(1, i + 1):
    if j != t:
        print(j)

Measured memory_bytes: 9248
n = int(input())

e = [0] * (n+1)


for i in range(2, n+1):
  num = i
  m = 2
  while m * m <= num:
    while num % m == 0:
      e[m] += 1
      num //= m
    m += 1
  if num > 1:
    e[num] += 1
    

num2 = num4 = num14 = num24 = num74 = 0    
for i in range(len(e)):
  if e[i] >= 2:
    num2 += 1
  if e[i] >= 4:
    num4 += 1
  
  if e[i] >= 14:
    num14 += 1
    
  if e[i] >= 24:
    num24 += 1
    
  if e[i] >= 74:
    num74 += 1
    
    
ans = num74 + (num24 * (num2-1)) + (num14 * (num4-1)) + (num4 * (num4-1) * (num2-2)//2)
print(ans)

Measured memory_bytes: 3316
from itertools import combinations
import math
S = input()
T = input()
#N = int(input())
#C = input()
#D, T, S=map(int,input().split())
#C = []
#for i in range(N):
#    C.append(list(map(int,input().split())))
c = 0
for i in range(len(S)-(len(T)-1)):
    cc = 0
    for t in range(i, i+len(T)):
        if S[t] == T[t-i]:
            cc += 1
    if c<cc:
        c=cc
print(len(T)-c)

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

struct edge{int to, cap, rev; };

vector<edge> G[MAX_V], H[MAX_V];
int level[MAX_V];
int iter[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, cap, G[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty()){
		int v = que.front(); que.pop();
		for(int i = 0; i < G[v].size(); i++){
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0){
				level[e.to] = level[v]+1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int t, int f){
	if(v == t) return f;
	for(int &i = iter[v]; i < G[v].size(); i++){
		edge &e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]){
			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(;;){
		bfs(s);
		if(level[t] < 0) return flow;
		memset(iter,0, sizeof(iter));
		int f;
		while((f = dfs(s, t, INF)) > 0){
			flow += f;
		}
	}
}

int n, e, q;
int x[1000], s[1000], t[1000];
set<P> saw;
int pre = 0;

int main(){
    cin >> n >> e >> q;
    rep(i,e){
        int s, t;
        cin >> s >> t;
        if(s > t) swap(s,t);
        s--; t--;
        saw.insert(P(s,t));
        add_edge(s,t,1);
    }
    rep(i,q){
        cin >> x[i] >> s[i] >> t[i];
        s[i]--; t[i]--;
        if(s[i] > t[i]) swap(s[i],t[i]);
        if(saw.count(P(s[i],t[i])) == 0){
            add_edge(s[i],t[i],0);
            saw.insert(P(s[i],t[i]));
        }
    }
    rep(i,q){
        if(x[i] == 1){
            rep(j,G[s[i]].size()){
                int rev = G[s[i]][j].rev;
                if(G[s[i]][j].to == t[i]){
                    G[s[i]][j].cap = 1;
                    G[t[i]][rev].cap = 1;
                }
            }
            pre = max_flow(0,n-1)+pre;
        } else{
            rep(j,G[s[i]].size()){
                int rev = G[s[i]][j].rev;
                if(G[s[i]][j].to == t[i]){
                    G[s[i]][j].cap = 0;
                    G[t[i]][rev].cap = 0;
                }
            }
            rep(j,n) rep(k,G[j].size()){
                int rev = G[j][k].rev;
                int to = G[j][k].to;
                if(G[j][k].cap == 2){
                    G[j][k].cap = 1;
                    G[to][rev].cap = 1;
                }
            }
            pre = max_flow(0,n-1);
        }
        cout << pre << endl;
    }
}

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


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

    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    int ans=m;
    for(int i=0;i+m-1<n;i++){
        int cost=0;
        for(int j=i;j<i+m;j++){
            if(s[j]!=t[j-i])    cost++;
        }
        ans=min(ans,cost);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;

public:
    vector<ll> sums;

    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void build() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};


int main() {
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> as(n), bs(m);
    rep(i, n) cin >> as[i];
    rep(i, m) cin >> bs[i];

    int ans = 0;

    CumulativeSum as_sum(n), bs_sum(m);
    rep(i, n) as_sum.set(i, as[i]);
    rep(i, m) bs_sum.set(i, bs[i]);
    as_sum.build();
    bs_sum.build();

    rep(i, n + 1) {
        ll asum = i == 0 ? 0 : as_sum.getSum(i - 1);
        if (asum > k) continue;
        ll bmax = k - asum;


        auto it = upper_bound(bs_sum.sums.begin(), bs_sum.sums.end(), bmax);
        int bi = 0;
        if (it == bs_sum.sums.begin()) {

        } else {
            bi = distance(bs_sum.sums.begin(), it);
        }

        int now = i + bi;
        cmax(ans, now);
    }

    cout << ans << endl;
}


Measured memory_bytes: 12764
def ym
  s=gets.chomp
  s_former=s[0..1].to_i
  s_latter=s[2..3].to_i

  if s_former>=1 && s_former<=12
    if s_latter>=1 && s_latter<=12
      return "AMBIGUOUS"
    else
      return  "MMYY"
    end
  else
    if s_latter>=1 && s_latter<=12
      return "YYMM"
    else
      return "NA"
    end
  end
end

#p defined?(ym)
print ym


Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

int main()
{
	char str[25];
	scanf("%s",str);
	int n = strlen(str);
	for(int i = 0;i < n;i++)
	{
		if(str[i] == ',') str[i] = ' ';
		printf("%c",str[i]);
	 } 
	 printf("\n");
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int W,H;
char m[9][9];
int main(){
  int c=0;
  scanf("%d %d",&H,&W);
  for(int i=0;i<H;i++)scanf("%s",&m[i]);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(m[i][j]=='#')c++;
    }
  }
  if(c==W+H-1)printf("Possible\n");
  else printf("Impossible\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
#include <random>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;
using pis = std::pair<int, std::string>;

const long long INF = 1000000000000000001;
const long long _MOD_ = 1000000000000000009;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

template<typename T>
constexpr T binaryPow_mod(T radix, T index, T mod) noexcept {
	radix %= mod;
	T rtv = 1;
	while (index > 0) {
		if (index & 1) {
			rtv *= radix;
			rtv %= mod;
		}

		radix *= radix;
		radix %= mod;

		index = index >> 1;
	}

	return rtv;
}

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

	ll n;
	cin >> n;
	ll ans = binaryPow_mod((ll)10, n, _MOD);
	ans -= binaryPow_mod((ll)9, n, _MOD) * 2;
	ans %= _MOD;
	if (ans < 0) ans += _MOD;
	ans += binaryPow_mod((ll)8, n, _MOD);
	ans %= _MOD;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define inf 0x3f3f3f3f
#define MAX(x,y) x=max(x,y)
using namespace std;
 
const int N=18;
const int M=32775;
 
int n,m,bin[N],num[M],ma[N][M],sum[M],f[N][M],g[M];
 
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
 
int lowbit(int x)
{
	return x&(-x);
}
 
int main()
{
	n=read();m=read();
	bin[0]=1;
	for (int i=1;i<=n;i++) bin[i]=bin[i-1]*2,num[bin[i]]=i;
	int tot=0;
	for (int i=1;i<=m;i++)
	{
		int x=read()-1,y=read()-1,z=read();tot+=z;
		ma[x][bin[y]]=ma[y][bin[x]]=z;
	}
	for (int i=0;i<n;i++)
		for (int j=1;j<bin[n];j++)
			ma[i][j]=ma[i][j-lowbit(j)]+ma[i][lowbit(j)];
	for (int i=1;i<bin[n];i++) sum[i]=sum[i-lowbit(i)]+ma[num[lowbit(i)]][i-lowbit(i)];
	for (int i=0;i<n;i++)
		for (int j=0;j<bin[n];j++)
			f[i][j]=-inf;
	f[0][1]=0;
	for (int j=0;j<bin[n];j++)
		for (int i=0;i<n-1;i++)
		{
			if (f[i][j]<0) continue;
			for (int k=0;k<n;k++)
				if (!(j&bin[k])&&ma[i][bin[k]]) MAX(f[k][j+bin[k]],f[i][j]+ma[i][bin[k]]);
		}
	for (int i=0;i<bin[n];i++) g[i]=f[n-1][i];
	for (int i=1;i<bin[n];i++)
	{
		if (g[i]<0) continue;
		int r=i^(bin[n]-1);
		for (int s=r;s;s=(s-1)&r)
		{
			int mxv=0;
			for (int j=i;j;j-=lowbit(j)) mxv=max(mxv,sum[s+lowbit(j)]);
			MAX(g[i+s],g[i]+mxv);
		}
	}
	printf("%d",tot-g[bin[n]-1]);
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define nav(...) "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
#define oo INT_MAX/2
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
	~debug() {cerr<<endl;}
	template<class T> debug& operator<<(T x) {cerr<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<< (pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x) {
		*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(all(x));}
#else
	template<class T> debug& operator <<(const T&) {return *this;}
#endif
};

class mint {
public:
	static int mod;
	mint() : x(1) {}
	mint(int x_) : x(x_) {}

	mint operator +(mint rhs) {
		ll ans = ll(x) + ll(rhs.x);
		while(ans >= mod) ans -= mod;
		while(ans < 0) ans += mod;
		return ans; }

	mint operator -(mint rhs) {
		ll ans = ll(x) - ll(rhs.x);
		while(ans >= mod) ans -= mod;
		while(ans < 0) ans += mod;
		return ans; }

	mint operator *(mint rhs) {
		int ans = ll(x)*ll(rhs.x) % mod;
		while(ans < 0) ans += mod;
		return ans; }

	mint operator /(mint rhs) { return *this * inv(rhs); }

	mint& operator +=(mint rhs) { return *this = *this + rhs; }
	mint& operator -=(mint rhs) { return *this = *this - rhs; }
	mint& operator *=(mint rhs) { return *this = *this * rhs; }
	mint& operator /=(mint rhs) { return *this = *this / rhs; }

	friend ostream& operator <<(ostream& out, mint x) { return out<<x.x; }
	friend istream& operator >>(istream& in, mint& x) { return in>>x.x; }
	friend mint mpow(mint a, int n);
	friend mint inv(mint a);

private:
	int x;
};

mint mpow(mint a, int n) {
	if(n == 0) return 1;
	mint x = mpow(a, n/2);
	x *= x;
	if(n % 2 == 1) x *= a;
	return x;
}

mint inv(mint a) {
	return mpow(a, mint::mod - 2);
}

int mint::mod = 1000*1000*1000 + 7;

#define MAXN (2*1000*1000+5)

mint fact[MAXN], inverse[MAXN];

mint binomial(int n, int k) {
	return fact[n]*inverse[n-k]*inverse[k];
}

mint get(int r, int c) {
	mint ans = 0;
	
	for(int i = 0; i <= r; i++)
		ans += binomial(i+1+c, c);
	
	return ans;
}

bool solve(void) {

	int r1, c1, r2, c2;
	cin>>r1>>c1>>r2>>c2;
	
	mint ans = get(r2, c2);
	ans -= get(r1-1, c2);
	ans -= get(r2, c1-1);
	ans += get(r1-1, c1-1);
	
	cout << ans << endl;

	return true;
}

int main(int argc, char* argv[]) {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	fact[0] = 1;
	for(int i = 1; i < MAXN; i++)
		fact[i] = fact[i-1]*i;
	
	for(int i = 1; i < MAXN; i++) {
		inverse[i] = inv(fact[i]);
	}
	
	solve();
	return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
const int mx = 5e5+7;
ll n,k;
const ll mod=1e9+7;
vector<ll>g[mx];
ll dp[mx];
void dfs(ll u,ll fa){
	ll tmp=(u==1)?k-1:k-2;
	for(auto v:g[u]){
        if(v==fa) continue;
        dp[v]=tmp;
        dfs(v,u);
        tmp--;
	}
}
int main(){
	scanf("%lld %lld",&n,&k);
	ll u,v,now;
	for(ll i=1;i<n;i++){
		scanf("%lld %lld",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,0);
	ll ans=1;
	dp[1]=k;
	for(ll i=1;i<=n;i++){
        ans=(ans*dp[i])%mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 21248
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int A, B;
  cin >> A >> B;

  if (A + B < 10) {
    cout << A + B << endl;
  } else {
    cout << "error" << endl;
  }
  return 0;
}

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

int main(void)
{
	int n;
	int num[100];
	int i;
	
	cin >> n;
	
	for (i = 0; i < n; i++){
		cin >> num[i];
	}
	
	cout << num[i - 1];
	for (i -= 2;i >= 0; i--){
		cout << " " <<  num[i];
	}
	
	cout << endl;
	
	return (0);
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#ifdef FIO
const int S = 1 << 21;
char p0[S],*p1,*p2;
#ifndef ZXY
#define getchar() (p2 == p1 && (p2 = (p1 = p0) + fread(p0,1,S,stdin)) == p1 ? EOF : *p1++)
#endif
inline int read() {
	static int x,c;x = 0;
	do{c = getchar();}while(!isdigit(c));
	do{x = (x << 3) + (x << 1) + (c & 15);c = getchar();}while(isdigit(c));
	return x;
}
#endif
int a[10];
int main() {
	cin >> a[1] >> a[2] >> a[3] >> a[4] >> a[5];
	for(int i = 1;i <= 5;++i)
		if(a[i] == 0) {cout << i << endl;break;}
	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){
  map<string, int> id;

  string A,B;
  cin >> A >> B;
  int a = 0, b = 1;
  id[A] = a, id[B] = b;

  int n,v = 2;
  cin >> n;

  vector< vector<pii> > docs(n);
  rep(i,n){
    int m; cin >> m;
    rep(j,m){
      cin >> A >> B;
      if(id.count(A) == 0) id[A] = v, v++;
      if(id.count(B) == 0) id[B] = v, v++;
      docs[i].push_back( make_pair(id[A], id[B]) );
    }
  }
  
  vector< vector<vi> > inv(v, vector<vi>(v));
  rep(i,n){
    for(auto x : docs[i]){
      inv[x.first][x.second].push_back(i);
    }
  }

  vector<vi> d(v, vi(v,0));
  rep(i,v) d[i][i] = 1;
  d[a][b] = 1;

  vi used_docs(n,0);
  queue<int> q;
  for(int idx : inv[a][b]){
    if(!used_docs[idx]){
      used_docs[idx] = 1;
      q.push(idx);
    }
  }

  while(q.size()){
    int idx = q.front(); q.pop();
    for(auto x : docs[idx]){
      a = x.first, b = x.second;
      if(d[a][b]) continue;
      if(d[b][a] == 1){
	cout << "No" << endl;
	return 0;
      }

      rep(i,v){
	if(d[i][a]==0) continue;
	rep(j,v){
	  if(d[b][j]==0) continue;
	  if(d[i][j]) continue;
	  d[i][j] = 1;
	  for(int nidx : inv[i][j]){
	    if(used_docs[nidx]) continue;
	    used_docs[nidx] = 1;
	    q.push(nidx);
	  }
	}
      }
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int a, b;
  cin >> a >> b;
  if(a + b == 4){
    say(2);
  }else if(a + b == 3){
    say(3);
  }else if(a + b == 5){
    say(1);
  }
}

Measured memory_bytes: 256
def check(s)
    str = s.dup
    dp = []
    dp[0] = 0
    tmp = str[0]
    str.length.times do |i|
        next if i == 0
        if str[i] == tmp
            dp[i] = dp[i-1] + 1
            tmp = (str[i] == "0") ? "1" : "0"
        else
            dp[i] = dp[i-1]
            tmp = str[i]
        end
    end
    dp.last
end

def test
    s = gets.chomp
    ans = check(s)
    s[0] = (s[0] == "0") ? "1" : "0"
    ans2 = check(s) + 1
    [ans, ans2].min
end

p test

Measured memory_bytes: 3708
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; cin >> N;
  vector<vector<LL>> dp(N, vector<LL>(N));
  for (int i = 0; i < N; ++i) {
    cin >> dp[i][i];
  }
  for (int j = 1; j < N; ++j) {
    for (int i = 0; i + j < N; ++i) {
      dp[i][i + j] = max(
          dp[i][i] - dp[i + 1][i + j],
          dp[i + j][i + j] - dp[i][i + j - 1]
      );
    }
  }
  cout << dp[0][N-1] << endl;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
vector<int> Eratosthenes(int n);
int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int array[3][3];
    rep(i, 3) rep(j, 3)
    {
        cin >> array[i][j];
    }
    int a[3] = {101, 101, 101};
    int b[3] = {101, 101, 101};
    rep(j, 3)
    {
        rep(i, 3)
        {
            if (a[j] > array[i][j])
                a[j] = array[i][j];
        }
    }
    bool flg = true;
    rep(i, 3)
    {
        rep(j, 3)
        {
            b[j] = array[i][j] - a[j];
        }
        if (b[0] != b[1] || b[1] != b[2] || b[2] != b[0])
            flg = false;
    }
    if (flg)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String s = sc.next();
			if (s.equals("-")) {
				break;
			} else {
				int n = s.length();
				char[] alp = new char[n];
				for (int i = 0; i < n; i++) {
					alp[i] = s.charAt(i);
				}
				int m = sc.nextInt();
				for (int i = 0; i < m; i++) {
					int h = sc.nextInt();
					char[] tmp = new char[h];
					for (int j = 0; j < h; j++) {
						tmp[j] = alp[j];
					}
					for (int j = 0; j < n - h; j++) {
						alp[j] = alp[j + h];
					}
					for (int j = 0; j < h; j++) {
						alp[n - h + j] = tmp[j];
					}
				}
				for (int i = 0; i < n; i++) {
					System.out.print(alp[i]);
				}
				System.out.println();
			}
		}
		sc.close();
	}

}


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

int abs(int);
int manh(int,int,int,int);

int main(){
	int n,m;
	cin>>n>>m;
	int a[n];
	int b[n];
	int c[m],d[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];
	}
	
	int current_dist;
	
	for (int i = 0; i < n; ++i)
	{
		int min_dist=manh(a[i],c[0],b[i],d[0]);
		int checkpoint=1;
		for (int j = 0; j < m; ++j)
		{
			current_dist=manh(a[i],c[j],b[i],d[j]);
			if (current_dist<min_dist)
			{
				min_dist=current_dist;
				checkpoint=j+1;
			}

		}
		cout<<checkpoint<<endl;
	}



return 0;
}



int manh(int x1,int x2,int y1,int y2){
	return abs(x1-x2)+abs(y1-y2);
}

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

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  if(a*b*c%2==0){
    cout << 0 << endl;
    return 0;
  }
  vector<ll> vec(3);
  vec[0]=a;vec[1]=b;vec[2]=c;
  sort(vec.begin(),vec.end());
  cout << vec[0]*vec[1] << endl;
}

Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

int zero = 0;

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	if (abs(b - a) % 2 == 0) {
		cout << abs(b - a) / 2 << endl;
	}
	else {
		int ans1 = a + (b - a - 1) / 2;
		int ans2 = (n - b + 1) + (n - (a + n - b + 1)) / 2;
		cout << min(ans1, ans2) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n;
    lint k;
    cin >> n >> k;
    vector<lint> v(100010, 0);
    rep(i, n){
        int a;
        lint b;
        cin >> a >> b;
        v[a] += b;
    }
    lint cnt = 0;
    int j = 0;
    while(cnt < k && j < 100005){
        j++;
        cnt += v[j];
    }
    cout << j << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);
		long X =Long.parseLong(Ws[1]);

		W = in.readLine();
		Ws = W.split(" ");
		long[] A = new long[Ws.length];
		for (int i = 0; i < Ws.length; i++) {
			A[i] = Long.parseLong(Ws[i]);
		}

		long ans = Math.abs(X-A[0]);

		for(int i=1;i<A.length;i++){
			ans=gcd(ans,Math.abs(X-A[i]));
		}

		System.out.println(ans);

	}

	public static long gcd(long a , long b){
		long x,y;
		if(a<b){
			x=b;
			y=a;
		}else{
			x=a;
			y=b;
		}
		long r;
		while((r=a%b)!=0){
			a=b;
			b=r;
		}
		return b;
	}
}


Measured memory_bytes: 49364
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
ll GCD(ll a, ll b) {
	if (b == 0)return a;
	return GCD(b, a%b);
}
ll LCM(ll a, ll b) {
	return a / GCD(a, b)*b;
}
ll mypow(ll a, ll b,ll c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	else return mypow(a, b / 2, c)*mypow(a, b / 2, c) % c;
}
/*
//Conbination!
ll c[51][51];
void comb(int n) {
	rep(i, 51) {
		rep(j, i + 1) {
			if (j == 0 || j == i)c[i][j] = 1;
			else c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
		}
	}
}
*/
int main() {
	int n;
	cin >> n;
	cout << (n + 1) / 2 * (n / 2) << endl;
	return 0;
}


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


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n, 0);
    vector<int> b(m, 0);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < m; i++)
        cin >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    for(int i = 1; i < n; i++) {
        if (a[i] == a[i-1]) {
            cout << 0 << endl;
            return 0;
        }
    }
    for(int j = 1; j < m; j++) {
        if (b[j] == b[j-1]) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll mod = 1e9 + 7;
    ll ans = 1;
    int pre_idx1 = 0, pre_idx2 = 0;
    int empty_space = 0;
    for(int i = n*m; i >= 1; i--) {
        auto it1 = lower_bound(a.begin(), a.end(), i);
        int idx1 = n - distance(a.begin(), it1);
        auto it2 = lower_bound(b.begin(), b.end(), i);
        int idx2 = m - distance(b.begin(), it2);
        // printf("push %d, idx1 = %d, idx2 = %d\n", i, idx1, idx2);
        empty_space += (idx1*idx2) - (pre_idx1*pre_idx2);
        if (empty_space <= 0) {
            cout << 0 << endl;
            return 0;
        }
        if (idx1 != pre_idx1 && idx2 != pre_idx2) {
            ans *= 1;
        } else if (idx1 != pre_idx1) {
            ans *= idx2;
        } else if (idx2 != pre_idx2) {
            ans *= idx1;
        } else {
            ans *= empty_space;
        }
        ans %= mod;
        empty_space -= 1;
        pre_idx1 = idx1;
        pre_idx2 = idx2;
    }
    cout << ans << endl;
    return 0;
}




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

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    int count = 0;
    int max = 0;
    for (int i=0; i<n; i++){
        if(h[i]>=max){
            count++;
            max = h[i];
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <climits>

using namespace std;

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

    vector<long long> dp(n, 100000000000);
    dp[0] = 0;
    for (int i = 0; i < n-1; i++) {
        dp[i+1] = min(dp[i]+abs(h[i]-h[i+1]), dp[i+1]);
        if (i+2 < n)
            dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
    }

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

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

int n, k;
vector<int> enemy;
long ans = 0;

long sumVector(vector<int> v);

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

  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    enemy.push_back(x);
  }

  if (n > k) {
    // 敵が多いときのみ
    vector<int> enemy_2;
    enemy_2.resize(n - k);
    sort(enemy.begin(), enemy.end(), greater<int>());
    copy(enemy.begin() + k, enemy.end(), enemy_2.begin());
    ans = sumVector(enemy_2);
  }

  printf("%lu", ans);

  return 0;
}

long sumVector(vector<int> v){
  long sum = 0;
  for(size_t i=0; i<v.size(); i++){
    sum += v[i];
  }
  return sum;
}

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

using namespace std;

int split_odd(int x, int y) {
  int pos_x = int((x + 1)/3);
  int size1 = pos_x * y;
  int rest_x = x - pos_x;
  int pos_y = y / 2;
  int size2 = rest_x * pos_y;
  int size3 = rest_x * (y - pos_y);
  return max({size1, size2, size3}) - min({size1, size2, size3});
}

int main() {
  int x, y;
  cin >> x >> y;
  // xの方が必ず小さい
  if(x > y) swap(x, y);

  // 割り切れる場合は0
  if(x%3 == 0 || y%3==0) {
    cout << "0\n";
    return 0;
  }

  // 同じ方向に割った場合
  int even = x;
  // 違う方向に割った場合
  int odd1 = split_odd(x, y);
  int odd2 = split_odd(y, x);
  cout << min({even, odd1, odd2}) << endl;
  return 0;
}


Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *                      # ll = deepcopy(l)
from heapq import *                     # heappush(hp,x)
from string import *                    # alpha = ascii_lowercase
from random import *                    # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *                    # bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin                   # bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize                 # minn = -maxsize
from operator import *                  # d = sorted(d.items(), key=itemgetter(1))
from itertools import *                 # pre = [0] + list(accumulate(l))
from decimal import Decimal             # a = Decimal(a)    # use this for math questions
from collections import Counter         # d = dict(Counter(l))
from collections import defaultdict     # d = defaultdict(list)

'''
2 3
7 9
'''

def f(l,k,x):
    cuts = 0
    for i in l:
        cuts += (ceil(i/x)-1)
    return cuts <= k

def solve(l,k):
    n = len(l)
    if(k == 0):
        return max(l)
    lo,hi = 1,max(l)
    l.sort(reverse=True)
    ans = max(l)
    while(lo <= hi):
        mid = (lo + hi) >> 1
        if(f(l,k,mid)):
            hi = mid - 1
            ans = min(ans,mid)
        else:
            lo = mid + 1
    return ans

N,K = list(map(int, stdin.readline().rstrip().split()))
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,K)
print(ans)



Measured memory_bytes: 100628