akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> v(n, 0), h(n);
    rep(i, n) cin >> h[i];
    v[n - 2] = 1;
    v[n - 1] = 1;
    do {
        int i = 0;
        int tmp = 1;
        for(auto x : v) {
            // cout << x << " ";
            if(x == 1) {
                tmp *= h[i];
            }
            i++;
        }
        
        ans += tmp;
        // cout << "\n";                              // v の要素を表示
    } while(next_permutation(v.begin(), v.end())); // 次の順列を生成
    cout << ans << endl;
    return 0;
}

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


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

#define INF bit(60)

#define DBGP 1


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

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

typedef pair<li, li> PI;

#define UF_NUM 505050

li cnt[2];

int main() {
    li a, b;
    cin >> a >> b;
    if (a == b) {
        cout << a << endl;
        return 0;
    }
    if (a + 1 == b) {
        cout << (a ^ b) << endl;
        return 0;
    }
    li num_btw = (b - b % 2 - a + a % 2) / 2 - 1;
    if (a % 2 > 0) {
        if (b % 2 > 0) {
            cout << ((num_btw % 2)^a ^ 1) << endl;
        } else {
            cout << ((num_btw % 2)^a ^ b) << endl;
        }
    } else {
        if (b % 2 > 0) {
            cout << ((num_btw % 2) ^ 1 ^ 1) << endl;
        } else {
            cout << ((num_btw % 2) ^ 1 ^ b) << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  double r;
  cin >> r;
  double pi = 3.141592;
  printf("%lf\n", 2*r*pi);
  return 0;
}


Measured memory_bytes: 3776
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b&&b == c) cout << 1 << endl;
    else if (a == b || b == c || c == a)cout << 2 << endl;
    else cout << 3 << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vs(N);
  for(int i = 0; i < N; ++i) {
    cin >> vs[i];
  }
  for(auto v : vs) {
    if(v % 2 == 0) {
      if(v % 3 != 0 && v % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
	int A, B, C;
	cin >> A >> B >> C;
	int result = B / A > C ? C : B / A;
	cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//union-find
#define UFLIMIT (1<<17)
ll unicnt[UFLIMIT+10];//正ならcnt、非正なら根のindex
int cnt[100010];
void ufinit(int n){rep(i,0,n)unicnt[i]=1;}
int root(int x){return unicnt[x]<=0?-(unicnt[x]=-root(-unicnt[x])):x;}
int same(int x,int y){return root(x)==root(y);}
void uni(int x,int y){
	if((x=root(x))==(y=root(y)))return;
	if(unicnt[x]<unicnt[y]){int t=x;x=y;y=t;}
	unicnt[x]+=unicnt[y];unicnt[y]=-x;
	cnt[x]+=cnt[y];
}
#undef UFLIMIT

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	ll vcnt,ecnt;
	E  e[100010];//適宜変える
}G;

int csort(const void*a,const void*b){
	ll p=(*(E*)a).c,q=(*(E*)b).c;
	return p<q?-1:p>q?1:0;
}

G g;
ll x[100010];
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,n)scanf("%lld",x+i);
	rep(i,0,m){
		ll x,y,c;
		scanf("%lld%lld%lld",&x,&y,&c);
		x--,y--;
		g.e[i].s=x;
		g.e[i].g=y;
		g.e[i].c=c;
	}
	g.vcnt=n;
	g.ecnt=m;
	qsort(g.e,g.ecnt,sizeof(E),csort);
}

ll ans;
int main(){
	readgraph();
	rep(i,0,g.vcnt)unicnt[i]=x[i];
	rep(i,0,g.ecnt){
		uni(g.e[i].s,g.e[i].g);
		cnt[root(g.e[i].s)]++;
		if(unicnt[root(g.e[i].s)]>=g.e[i].c){
			ans+=cnt[root(g.e[i].s)];
			cnt[root(g.e[i].s)]=0;
		}
	}
	printf("%lld\n",g.ecnt-ans);
}

Measured memory_bytes: 5628
let () =
  let f x = x*x in
  let rec read () =
    try let d = read_int () in
        let rec integral s = function
            i when i*d >= 600-d  -> s + d * (f (600-d))
          | i -> integral (s + d * (f (i*d))) (i+1)
        in Printf.printf "%d\n" (integral 0 1);read ()
    with End_of_file -> ()
  in read ();;

Measured memory_bytes: 2172
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
#define INF 10000000000

int main() {
    ll H, N;    cin >> H >> N;
    ll *A = new ll[N], *B = new ll[N];
    for (ll i = 0; i < N; i++)
        cin >> A[i] >> B[i];
    vector<ll> dp(H+1, INF);
    dp[0] = 0;

    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j <= H; j++) {
            dp[j] = min(dp[j], dp[max(j-A[i], (ll)0)] + B[i]);
        }
    }

    cout << dp[H] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

const int N = 100 + 5;

ll eq[N][N], dp[N][N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	string s;
	int K;
	cin >> s >> K;
	eq[0][0] = 1;
	rep(i,1,s.length()+1){
		int cur = s[i-1] - '0';
		rep(j,0,s.length()){
			eq[i][j + (cur != 0)] += eq[i-1][j];
		}
		rep(j,0,cur){
			rep(k,0,s.length()){
				dp[i][k + (j != 0)] += eq[i-1][k];
			}
		}
		rep(j,0,10){
			rep(k,0,s.length()){
				dp[i][k + (j != 0)] += dp[i-1][k];
			}
		}
	}
	cout << eq[s.length()][K] + dp[s.length()][K] << '\n';
}


Measured memory_bytes: 384
total, tar = list(map(int, input().split()))
dice_array = list(map(int, input().split()))

hope_array = [0.0] * total
for i in range(total):
   hope_array[i] = (dice_array[i] * (dice_array[i] + 1)) / 2 / dice_array[i]

dice_total = [0]
 
for i in range(total):
  dice_total.append(hope_array[i] + dice_total[i])
 
ans = dice_total[tar]
tar_num = tar
for i in range(total - tar):
  tmp = dice_total[i + 1 + tar] - dice_total[i + 1]
  if ans < tmp:
    ans = tmp

print(ans)


Measured memory_bytes: 25060
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#define INTMAX 2000000000
using namespace std;

// calc num of passengers
int calc(vector<int> passengers, string s){
	int remain = 0;
	int n;
	for (int i = 0; i < 8; i++) {
		n = passengers[i] - (s[i] - '0');
		n = (n < 0) ? 0 :  n;
		remain += n;
	}
	return remain;
}

// convert string to int if there are same best answers
int getNum(string s, int location){
	return atoi(s.substr(location, 8).c_str());
}

int main(){
	vector<int> passengers;
	int p[8];
	int ans_remain;
	int ans_location;
	int tmp;
	string s = "4121214141212141";
	while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]) {
		ans_remain = INTMAX;
		ans_location = -1;
		passengers.clear();
		for (int i = 0; i < 8; i++) {
			passengers.push_back(p[i]);
		}
		for (int i = 0; i < 8; i++) {
			tmp = calc(passengers, s.substr(i, 8)); 
			if(ans_remain > tmp){ // find new best answer
				ans_remain = tmp;
				ans_location = i;
			}else if (ans_remain == tmp) { // same answer
				if (getNum(s, ans_location) > getNum(s, i)) {
					ans_remain = tmp;
					ans_location = i;
				}
			}
		}
		// print ans
		for (int i = 0; i < 7; i++) {
			cout << s[ans_location+i] << " ";
		}
		cout << s[ans_location+7] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
# include <iostream>
# include <stdio.h>
# include <cmath>
# include <iomanip>
// # include <cstring>
// # include <string>
// # include <cctype>
// # include <algorithm> //transformの関数はaslgorithmライブラリに入っているみたい。
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  double PI = acos(-1);
  double rad;
  double S,L,h;
  rad = c * PI/180;
  S = a * b * sin(rad) /2;
  L = sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(rad)) + a + b;
  h = b*sin(rad);
  cout << fixed;
  cout << setprecision(5) << S << endl;
  cout << setprecision(5) << L << endl;
  cout << setprecision(5) << h << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main(void){
  int N, D, X;
  cin >> N >> D >> X ;
  int A[N];
  for(int i = 0 ; i < N ; i++){
    cin >> A[i];
  }


  int ans = X;
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j * A[i] + 1 <= D ; j++){
      ans++;
    }
  }

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

Measured memory_bytes: 256
N = int(input())
A_list = [int(i) for i in input().split()]
B_list = [int(i) for i in input().split()]
C_list = [int(i) for i in input().split()]
total = 0
prev_a = -2
for a in A_list:
    total += B_list[a-1]
    if a == prev_a + 1:
        total += C_list[prev_a-1]
    prev_a = a
print(total)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
  	int length = s.size();
  	if (s.substr(length-1) == "s") {
      cout << s << "es" << endl;
    } else {
      cout << s << "s" << endl;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL a,b,c,d;cin >> a >> b >> c >> d;

    LL tmp = a*c;
    tmp = max(tmp,a*d);
    tmp = max(tmp,b*c);
    tmp = max(tmp,b*d);
    cout << tmp << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

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

    int c0=0, c1=0;
    for(int i=0; i<S.size(); i++) {
        if(S[i] != '0' + i % 2)
            c0++;
        if(S[i] != '0' + (i+1) % 2)
            c1++;
    }

    cout << min(c0, c1) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvl = vector<vector<long>>;
using vvp = vector<vector<pair<int,long>>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007
#define INF 1e17

int main(){
  long n,m,L;
  cin >> n >> m >> L;
  vector<vector<long>> d(n,vector<long>(n,INF));
  rep(i,n) d.at(i).at(i) = 0;
  
  rep(i,m){
    int a,b;
    long c;
    cin >> a >> b >> c;
    if(c > L) continue;
    a--;
    b--;
    d.at(a).at(b) = c;
    d.at(b).at(a) = c;
  }
  rep(k,n){
    rep(i,n){
      rep(j,n){
        d.at(i).at(j) = min(d.at(i).at(j), d.at(i).at(k) + d.at(k).at(j));
      }
    }
  }
  vector<vector<long>> nd(n,vector<long>(n,INF));
  rep(i,n) nd.at(i).at(i) = 0;
  rep(i,n){
    rep(j,n){
      if(i == j) continue;
      long tmp = d.at(i).at(j);
      if(tmp <= L) nd.at(i).at(j) = 1;
    }
  }
  rep(k,n){
    rep(i,n){
      rep(j,n){
        nd.at(i).at(j) = min(nd.at(i).at(j), nd.at(i).at(k) + nd.at(k).at(j));
      }
    }
  }
  int q;
  cin >> q;
  rep(i,q){
    int s,t;
    cin >> s >> t;
    s--;
    t--;
    if(nd.at(s).at(t) == INF) cout << -1 << endl;
    else cout << nd.at(s).at(t) - 1 << endl;
  }
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int n, ans, deep[220], uu;
char g[210][210];
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%s", g[i] + 1);
	}
	for(int u = 1; u <= n; u++){
		memset(deep, -1, sizeof(deep));
		deep[u] = 1;
		bool flag = 0;
		int res = 0;
		queue<int> q;
		q.push(u);
		while(!q.empty()){
			int x = q.front();
			q.pop();
			for(int j = 1; j <= n; j++){
				if(g[x][j] == '1'){
					if(deep[j] == deep[x] - 1 || deep[j] == deep[x] + 1) continue;
					if(deep[j] == -1){
						deep[j] = deep[x] + 1;
						res = max(res, deep[j]);
						q.push(j);
					}
					else{
						flag = 1;
						break;
					}
				}	
			}
		}
		if(flag == 0){
			if(ans < res) {
				ans = res, uu = u;
			}
		}
	}
	if(ans){
		cout<<ans;
	}
	else printf("-1");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;


int main(void) {

  int n, m;
  bool f = true;
  while(cin >> n >> m){
    if( n == 0||m==0 ) break;
    if(!f ) cout << endl;
    f = false;
    vector<int> ans;
    for(int i=n; i<=m; i++){
      if( i % 400 == 0) ans.push_back(i);
      else if( i % 100 == 0 ) continue;
      else if( i % 4 == 0 ) ans.push_back(i);
    }
    if( ans.size() == 0 ) cout << "NA" << endl;
    else for(int i=0; i<ans.size(); i++) cout << ans[i] << endl;

  }


  return 0;
}


// EOF

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int s[110];

int main(){
    int n;
    cin >> n;
    bool flag = true;
    int tot = 0;
    rep(i, n){
        cin >> s[i];
        tot += s[i];
        flag &= (s[i]%10==0);
    }

    if (flag) {
        cout << 0 << endl;
    }

    else if (tot%10 != 0) cout << tot << endl;

    else{
        sort(s, s+n);
        rep(i, n){
            if (s[i]%10!=0){
                tot -= s[i];
                break;
            }
        }
        cout << tot << endl;
    }



    return 0;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  bool same = true;
  ll sum = 0, keep = 1e9;
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    if (a != b) same = false;
    sum += a;
    if (a > b) keep = min(keep, b);
  }
  
  if (same) cout << "0\n";
  else cout << sum - keep << '\n';
}

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

using namespace std;

int main() {
  int n;
  vector<pair<int, int> > a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(make_pair(tmp, i));
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (a[n - 1].second != i)
      cout << a[n - 1].first << endl;
    else {
      cout << a[n - 2].first << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3312
#include <algorithm>
#include <array>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <string>
#include <string_view>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int64_t read_int() {
    int64_t ret = 0, sgn = 1;
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    if (ch == '-') { sgn = -1; ch = getchar_unlocked(); }
    for (; isdigit(ch); ch = getchar_unlocked())
        ret = (ret * 10) + (ch - '0');
    ungetc(ch, stdin);
    return sgn * ret;
}

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()

template <typename T> inline void assign_min(T& x, const T& value) noexcept { x = min(x, value); }
template <typename T> inline void assign_max(T& x, const T& value) noexcept { x = max(x, value); }

constexpr char LF = '\n';

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

template <typename Int>
vector<int64_t> make_cumsum(const vector<Int>& v) {
    vector<int64_t> cumsum(v.size()+1);
    for (size_t i = 1; i < cumsum.size(); ++i) {
        cumsum[i] = cumsum[i-1] + v[i-1];
    }
    return cumsum;
}

// [first, last) の和を返す
inline int64_t sum_of(const vector<int64_t>& cumsum, int first, int last) noexcept {
    return cumsum[last] - cumsum[first];
}

// 区間[a, b)の中で最初に pred(x) = true となるような x を返す。
// そのような x が存在しないときは b を返す。
template <class Pred>
int64_t bin_search(int64_t a, int64_t b, Pred pred) {
    // 不変条件: i<a ⇒ pred(i)=false, i>=b ⇒ pred(i)=true
    if (a == b) return b;
    int64_t m = a + (b - a) / 2;
    if (pred(m))
        return bin_search(a, m, pred);
    else
        return bin_search(m+1, b, pred);
}

int main() {
    int N = read_int();
    int M = read_int();
    int64_t K = read_int();
    vector<int64_t> A(N), B(M);
    REP(i, N) A[i] = read_int();
    REP(i, M) B[i] = read_int();

    auto cumsum_a = make_cumsum(A);
    auto cumsum_b = make_cumsum(B);

    int64_t ans = 0;
    REP(a, N+1) {
        // 机Aの本を a 冊読むとする
        auto time_a = sum_of(cumsum_a, 0, a);
        if (time_a > K) break;
        auto max_b = bin_search(1, M+1, [&](int b) {
            auto time_b = sum_of(cumsum_b, 0, b);
            return (time_a + time_b) > K;
        });
        assign_max(ans, a + max_b - 1);
    }
    cout << ans << LF;
}


Measured memory_bytes: 9160
/////////////////////////   _LeMur_
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 300005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n;
string a , b , c;

int mas[30];

int main(){
    cin>>n;
    cin>>a>>b>>c;
    int answ = 0;
    for(int i=0;i<n;i++){
        mas[a[i] - 'a']++;
        mas[b[i] - 'a']++;
        mas[c[i] - 'a']++;
        int mx = 0;
        for(int j=0;j<26;j++){
            mx = max(mx , mas[j]);
        }
        answ += 3 - mx;
        mas[a[i] - 'a']--;
        mas[b[i] - 'a']--;
        mas[c[i] - 'a']--;
    }
    cout<<answ<<endl;
    return 0;
}


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

ll mod = 1e9+7;

int main() {
    int N, C;
    cin >> N >> C;
    vector<ll> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    vector<vector<ll>> pow(401, vector<ll>(401, 1));
    pow[0][0] = 0;
    for (int i = 0; i <= 400; i++) {
        for (int j = 1; j <= 400; j++) {
            pow[i][j] = pow[i][j-1]*i%mod;
        }
    }
    for (int i = 1; i <= 400; i++) {
        for (int j = 0; j <= 400; j++) {
            pow[i][j] = (pow[i][j]+pow[i-1][j])%mod;
        }
    }
    vector<ll> dp(C+1, 0);
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
        vector<ll> x, y(C+1);
        x = dp;
        fill(dp.begin(), dp.end(), 0);
        for (int j = 0; j <= C; j++) {
            y[j] = (pow[B[i]][j] - pow[A[i]-1][j] + mod) % mod;
        }
        for (int j = 0; j <= C; j++) {
            for (int k = 0; k <= j; k++) {
                dp[j] += (x[k]*y[j-k])%mod;
            }
            dp[j] %= mod;
        }
    }
    cout << dp[C] << endl;
    return 0;
}

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

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

const ll MOD = 10000;

int main() {
    int n;
    cin >> n;
    int t, a;
    cin >> t >> a;

    int tmp_h = 0;
    double ans = 1;
    double near_t = 0;
    rep(i, n) {
        cin >> tmp_h;
//        cout << (double)t - (double)tmp_h * 0.0006 << endl;
        if ( i == 0 ) {
            ans = 1;
            near_t = abs((double)t - (double)tmp_h * 0.006 - (double)a);
        }
        else if ( near_t > abs( (double)t - (double)tmp_h * 0.006 - (double)a) ) {
            ans = i+1;
            near_t = abs((double)t - (double)tmp_h * 0.006 - (double)a);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll a[100005];
ll b[100005];


int main(){
    int n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
        b[i]=a[i];
    }
    
    ll temp1=0;
    rep(i,n){
        b[i]=b[i-1]+b[i];
        if(i%2){
            if(b[i]<=0){
                temp1+=1-b[i];
                b[i]=1;
            }
        }else{
            if(b[i]>=0){
                temp1+=b[i]+1;
                b[i]=-1;
            }
        }
    }
    rep(i,n){
        cerr<<b[i];
    }
    cerr<<endl;
    ll temp2=0;
    rep(i,n){
        a[i]=a[i-1]+a[i];
        if(i%2==0){
            if(a[i]<=0){
                temp2+=1-a[i];
                a[i]=1;
            }
        }else{
            if(a[i]>=0){
                temp2+=a[i]+1;
                a[i]=-1;
            }
        }
    }
     rep(i,n){
        cerr<<a[i];
    }
    cerr<<endl;
    ll ans=min(temp1,temp2);
    
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

struct drink
{
  long long price;
  long long num;

  drink(long price, long long num)
  {
    this->price = price;
    this->num = num;
  }

  bool operator<(const drink& another) const
  {
    return price < another.price;
  };
};

void EnergyDringCollector()
{
  int n;
  int m;
  long long ans = 0;
  cin >> n >> m;
  vector<drink> d;
  for (int i = 0; i < n; i++)
  {
    int a;
    int b;
    cin >> a >> b;
    d.push_back(drink(a, b));
  }

  std::sort(d.begin(), d.end());
  int count = 0;
  for (auto itr : d)
  {
    if (count + itr.num <= m)
    {
      count = count + itr.num;
      ans = ans + itr.price * itr.num;
    }
    else
    {
      ans = ans + itr.price * (m - count);
      break;
    }
  }

  cout << ans << endl;
  return;
}

int main()
{
  EnergyDringCollector();
}


Measured memory_bytes: 2420
A,B,C,D=(int(x) for x in input().split(" "))
def gcd(x,y): 
  
   while(y): 
        x, y = y, x % y 
  
   return x 
def nb_divisers(n,m):
    return n//m
def nb_d_btw(f,g,n):
    if f%n==0:
        return nb_divisers(g,n)-nb_divisers(f,n)+1
    else:
        return nb_divisers(g,n)-nb_divisers(f,n)
def nb_notdivisers_f(a,b,c,d):
    e=int(c*d/gcd(c,d))
    return b-a+1-(nb_d_btw(a,b,c)+nb_d_btw(a,b,d)-nb_d_btw(a,b,e))
print(nb_notdivisers_f(A,B,C,D))

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

using LL = long long;
using LD = long double;
 
LL mod = 10e9+7;

int main()
{
	LL x, y, z;
	cin >> x >> y >> z;

	cout << z << " " << x << " " << y << "\n";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int a,b;
	cin >> a >> b;
	if( b % a )
		cout << b - a;
	else 
		cout << a + b;
	cout << endl;
	ret 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	for (int bit = 0;bit < (1 << 3);++bit) {
		int cnt = s[0] - '0';
		rep(i, 1, s.size()) {
			int x = s[i] - '0';
			if (bit & (1 << i - 1))cnt += x;
			else cnt -= x;
		}
		if (cnt == 7) {
			rep(i, 0, s.size()) {
				cout << s[i];
				if (i < s.size() - 1) {
					if (bit & (1 << i))cout << '+';
					else cout << '-';
				}
			}
			cout << "=7" << "\n";
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3652
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *
import queue

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

sys.setrecursionlimit(1500)
S = In.int()
MOD = 10**9+7

@functools.lru_cache(None)
def rec(ct):
    if ct==0:
        return 1
    
    ans = 0
    for i in range(3, ct+1):
        ans+=rec(ct-i)
        ans%=MOD
    
    return ans


Out.int(rec(S))

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c; cin>>a>>b>>c;
    int ans;
    if(b<c) swap(b,c);
    if(a<b) swap(a,b);
    int goal = a-b+(a-c);
    if(goal%2==1) ans = (goal+1)/2+1;
    else {
        ans = goal/2;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
use std::collections::HashMap;
use std::io::{stdin, Read};

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!($iter), parse!($iter))
    };
    ($iter: ident,3) => {
        (parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident,4) => {
        (parse!($iter), parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident, $n: ident) => {
        $iter.take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let n: usize = parse!(iter);
    let s: Vec<_> = iter.next().unwrap().chars().collect();
    let ls = s[..n].to_vec();
    let rs = s[n..].to_vec();
    let left = create_hashmap(ls, n, false);
    let right = create_hashmap(rs, n, true);
    let mut res = 0;
    for (k, v) in left {
        res += *right.get(&k).unwrap_or(&0) * v
    }
    println!("{}", res);
}

fn create_hashmap(s: Vec<char>, n: usize, rev: bool) -> HashMap<(String, String), usize> {
    let mut left: HashMap<(String, String), usize> = HashMap::new();
    for i in 0..(1 << n) {
        let mut a: Vec<char> = Vec::new();
        let mut b: Vec<char> = Vec::new();
        for j in 0..n {
            if i & (1 << j) != 0 {
                a.push(s[j]);
            } else {
                b.push(s[j])
            }
        }
        if rev {
            a.reverse();
            b.reverse();
        }
        let a: String = a.into_iter().collect();
        let b: String = b.into_iter().collect();
        let key = (a, b);
        let v = *left.get(&key).unwrap_or(&0);
        left.insert(key, v + 1);
    }
    left
}


Measured memory_bytes: 98536
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999;
#define atcoder 1000000007;

using namespace std;

int main(){

	int x;

	cin >> x;

	if (x >= 1200)
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
     
     
    void solve(){
        ll n,m,d,c=0,j=1,k=1,f=0;
        cin>>n;
        ll a[n];ll s=0,s1=0;
        for(int i=0;i<n;i++){ cin>>a[i];s+=a[i];}
        c=a[0],f=a[n-1];
        ll mi=(ll)(1e18);
        for(int i=0;i<n;i++)
        {
            s1+=a[i];
            s-=a[i];
            mi=min(abs(s-s1),mi);
        }
        cout<<mi<<endl;
    }
         
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int q;
        //cin>>q;
        //for(int i=0;i<q;i++)
    	    solve();
    	return 0;
    }

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

using namespace std;

typedef long long ll;
const int MAXN = 2e3 + 2;
ll n, x, cost[MAXN], rmq[MAXN][20];
ll ans, dp[MAXN][MAXN];

void prep()
{
    for(int i = 0;i < n;i++)
        rmq[i][0] = cost[i];

    for(int i = 1;(1 << i) <= n;i++)
        for(int j = 0;j + (1 << (i - 1)) < n;j++)
            rmq[j][i] = min( rmq[j][i - 1], rmq[j + (1 << (i - 1))][i - 1] );
}

int get_min(int l, int r)
{
    if(l > r)swap(l, r);

    int k = log2(r - l + 1);
    return min( rmq[l][k], rmq[r - (1 << k) + 1][k] );
}

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

    cin >> n >> x;
    for(int i = 0;i < n;i++)
        cin >> cost[i];

    prep();

    for(int r = 0;r < n;r++)
    {
        for(int i = 0;i < n;i++)
        {
            ll mn1, mn2; mn1 = mn2 = INT_MAX;

            if(i - r < 0)
            {
                mn1 = get_min(0, i);
                mn2 = get_min((i - r + n) % n, n - 1);
            }else{
                mn1 = get_min(i - r, i);
            }
            if(i == 0)
                dp[i][r] += 1LL * min(mn1, mn2);
            else
                dp[i][r] += dp[i - 1][r] + 1LL * min(mn1, mn2);
        }
    }

    ans = 99999999999999999;
    for(int i = 0;i < n;i++)
    {
        ll nval = dp[n - 1][i] + 1LL * i * x;
        ans = min(ans, nval);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> a(n);
    vector<int> num(pow(10,5),0);
    for(int i=0;i<n;i++){
        cin>>a[i];
        num[a[i]]++;
    }
    sort(a.begin(),a.end());
    long long kazu=0;
    long long ans=num[0]+num[1];
    for(long long i=0;i<a[n-1]-1;i++){
        kazu=num[i]+num[i+1]+num[i+2];
        ans=max(ans,kazu);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            int oddNum = K/2;
            int evenNum = K - oddNum;
            Console.WriteLine(oddNum*evenNum);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 11092
fn main() {
    let input: Vec<i32> = read_vec();
    let k = input[2];

    // それぞれの山から読むことのできるところまでを取る
    let a: Vec<i32> = take_by_time(k, &read_vec());
    let b: Vec<i32> = take_by_time(k, &read_vec());

    println!("{}", max_read(k, &a, &b));
}

fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn take_by_time(k: i32, books: &[i32]) -> Vec<i32> {
    let mut v = vec![0];
    books
        .iter()
        .scan(0, |state, cur| {
            if k - *state - cur < 0 {
                return None;
            }

            *state += cur;
            Some(*state)
        })
        .for_each(|n| v.push(n));
    v
}

fn max_read(k: i32, a: &[i32], b: &[i32]) -> i32 {
    let mut ans: i32 = 0;
    let mut j = b.len() - 1;

    a.iter().enumerate().for_each(|(i, &a)| {
        while b[j] > k - a {
            j -= 1;
        }

        ans = ans.max((i + j) as i32);
    });

    ans
}


Measured memory_bytes: 6284
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;

int N,C;
int s[100001],t[100001],c[100001];
int sm[200002];
int tt[200002];
int main()
{
    cin >> N >> C;
    for(int i = 0; i < N; i++)
    {
        cin >> s[i] >> t[i] >> c[i];
    }

    for(int i = 1; i <= C; i++)
    {
        //0で初期化
        for(int j = 0; j < 200002; j++) tt[j] = 0;
        //それぞれのテレビ番組の始まる時間を1にして終わったところを-1する。
        //2倍して1引いたのは録画の間の0.5の時間をないことにするため。
        //ないことにすることで始まる時間と終わる時間が同じものは同一とみなされる。
        for(int j = 0; j < N; j++) if(c[j] == i) tt[s[j]*2-1]++, tt[t[j]*2]--;
        //累積和を作る。
        //これで録画時間が重なっている数がわかる。
        //今回はそれぞれのチャンネルのどの時間帯に録画しているかがわかる。
        for(int j = 1; j < 200002; j++) tt[j] += tt[j-1];
        //それぞれのチャンネルで録画機を使っている時間帯を調べて足していくことで、ループが終わった時に重なっている部分がわかる。
        for(int j = 0; j < 200002; j++) if(tt[j] > 0) sm[j]++;
    }

    int ans = 0;
    //一番多く録画機を使っている時間帯を探してその数を出力したら答えになる。
    for(int j = 0; j < 200002; j++)
    {
        if(ans < sm[j]) ans = sm[j];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
	int N, K;
	cin >> N >> K;
	if(K == 1) K = N;
	cout << max(N - K, 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	ll n; cin >> n;
	ll ans = 0;
	for( ll i = 0; i < n; ++i ) ans += i;
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from bisect import bisect_left as bi_l, bisect_right as bi_r
from itertools import accumulate

n, H, *ab = map(int, sys.stdin.read().split())
a = ab[::2]
b = ab[1::2]

def main():
    a_max = max(a)
    b.sort()
    needless_cnt = bi_r(b, a_max)
    if needless_cnt == n:
        return (H + a_max - 1) // a_max

    cands = b[needless_cnt:]
    total = list(accumulate(cands[::-1]))

    needed_cnt = bi_l(total, H) + 1
    m = len(total)
    if needed_cnt <= m:
        return needed_cnt
    
    remain = H - total[-1]
    return m + (remain + a_max - 1) // a_max

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 25508
#include <stdio.h>
#include <string.h>

int main() {
  int i, string, I;
  char word[200];
  char ring[300];
  scanf( "%s", &ring );
  scanf( "%s", &word );
  string = strlen( ring );
  for( i = 0; i < string; i++ ) {
    I = i + string;
    ring[I] = ring[i];
  }
  if( strstr(ring, word) != 0 ) {
    printf( "Yes\n" );
  } else {
    printf( "No\n" );
  }
  return 0;
}

Measured memory_bytes: 956
#include<iostream>
#include<climits>
#include<numeric>
#include<algorithm>
#include <sstream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<utility>
#include<array>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<forward_list>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

bool isprime(ll int x){
 	for (int i = 2;i*i<x; ++i)
 	{
 		if(x%i==0)
 		{
 			return false;
 		}
 		/* code */
 	}
 	return true;
}
int main() {

    ll int a,b;
    cin>>a;

    while(!isprime(a))a++;

    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DEBUG_OUTPUT_ENABLED 1
	#define DBG(X) dout << #X << "=" << (X) << '\n';
	#define SAY(X) dout << (X) << '\n';
#else
	#define DEBUG_OUTPUT_ENABLED 0
	#define DBG(X) 42;
	#define SAY(X) 42;
#endif

#define dout   ___debug::instance

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const multiset<T>& v) { for(auto el: v) cout << el << " "; return os; }
namespace ___debug {
	struct DebugStream {
		private:
			bool is_first;
		public:
			DebugStream(bool _is_first): is_first(_is_first) {}
			template<typename T> DebugStream operator<<(const T& value) const {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				cout << value;
				return DebugStream(false);
			};

			template<typename T> DebugStream printArray(T* l, T* r) {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				while(l != r) {
					cout << (*l);
					++l;
					if(l == r) {
						cout << '\n';
					} else {
						cout << ' ';
					}
				}
				return DebugStream(false);
			}
	};
	DebugStream instance(true);
};

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	int k = fetch<int>();
	int a = fetch<int>();
	int b = fetch<int>();
	for(int i = a; i <= b; ++i) {
		if(i % k == 0) {
			cout << "OK\n";
			return;
		}
	}
	cout << "NG\n";
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

namespace AtCoder.Abc
{
    class A_169_Multiplication
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long a = inputLongArray[0] * inputLongArray[1];

            long result = a;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27848
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, x; cin >> n >> x;
  int res = 1;
  int d = 0;
  for (int i = 0; i < n; ++i) {
    int l; cin >> l;
    d += l;
    res += d <= x;
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
# k<=5ということは最長で5文字

s = gets.chomp.chars
k = gets.chomp.to_i
result = []

0.upto(s.size-1).each do |i|
  # 1~min(5,s.size)文字
  1.upto([k, s.size-i].min).each do |j|
    result << s[i, j].join("")
  end
end
puts result.uniq.sort[k-1]

Measured memory_bytes: 8700
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int ch = sc.nextInt();
        int cw = sc.nextInt();
        System.out.println(h*w + ch*cw - h*cw - w*ch);
    }
}

Measured memory_bytes: 23764
#include<stdio.h>
int main(){
  int a,b;
  float x;
  int y;
  int z;
  scanf("%d %d",&a,&b);
  x=(a+b)*0.5;
  y=10*x;
  z=y-(int)x*10;
  //printf("%f %d %d",x,y,z);
  if(z>4){
    printf("%d",(int)x+1);
  }
  else{
    printf("%d",(int)x);
  }
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

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

  long n,k;
  cin >> n >> k;
  long a,b;
  map<long,long> mp;
  for(int i = 0; i < n; i++){
    cin >> a >> b;
    mp[a] += b;
  }
  for(auto x : mp){
    k -= x.second;
    if(k <= 0){
      cout << x.first << endl;
      break;
    }
  }
}

Measured memory_bytes: 4224