akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;
    vs32 a(n);
    rep (i, n) cin >> a[i];

    s64 ans = 0;
    if (a[0] != 0)
    {
        ans = -1;
    }
    else
    {
        rep (i, n - 1)
        {
            if (a[i + 1] <= a[i])
            {
                ans += a[i + 1];
            }
            else if (a[i + 1] == a[i] + 1)
            {
                ++ans;
            }
            else
            {
                ans = -1;
                break;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

int main(void){
  int A,B;cin >> A >> B;
  if(A<=8&&B<=8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
n,k = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i)

def greed(query)
  min = query[0]
  max = query[-1]
  mina = min.abs

  if min >=0
    return max
  end

  if max <= 0
    return mina
  end

  return [max,mina].min * 2 + [max,mina].max
end


now = n
x.each_with_index do |x,idx|
  if x >= 0
    now = idx
    break
  end
end

count = []
start = [now - k, 0].max
loop do
  if start > now || start + k > n
    break
  end
  query = x[start...start+k]
  count << greed(query)
  start += 1
end

puts count.min



Measured memory_bytes: 12428
n=int(input())
edge=[[] for i in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
pre=[None]*(n+1)
pre[1]=1
q=[1]
while len(q)>0:
    t=q.pop()
    for i in edge[t]:
        if(pre[i]==None):
            pre[i]=t
            q.append(i)
route=[n]
t=n
while t!=1:
    t=pre[t]
    route.append(t)
route=route[::-1]
a=route[(len(route)+1)//2-1]
b=route[(len(route)+1)//2]
edge[a].remove(b)
edge[b].remove(a)
def v(s):
    a=1
    q=[s]
    c=[0]*(n+1)
    c[s]=1
    while len(q)>0:
        t=q.pop()
        for i in edge[t]:
            if(c[i]==0):
                c[i]=1
                a+=1
                q.append(i)
    return a
a=v(a)
b=v(b)
if(a>b):
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 66464
#pragma GCC optimize ("O3")
#include <iostream>
#include <sstream>
#include <fstream>
#include <iterator>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdio>

using namespace std;
using namespace std::placeholders;

// namespace { struct NoSync { NoSync() { cin.tie(0); ios::sync_with_stdio(false); } } nosync; }

using ll = long long;
#define float double

constexpr ll INF = 999999999LL;
constexpr ll MOD = 1e9 + 7;

#define y0 Y0
#define y1 Y1
#define j0 J0
#define j1 J1
#define prev PREV
#define next NEXT

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i##_len = (n), i = (i##_len) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define permutations(v) sort(all(v));for(bool v##p = true; v##p; v##p=next_permutation(all(v)))
#define UNIQUE(v) (v).erase(unique(all(v)), (v).end())
#define REMOVE(v) (v).erase(remove(all(v)), (v).end())
#define ROTATE(v, n) rotate((v).begin(), (v).begin() + (n), (v).end())
#define TO_SUMS(v) partial_sum(all(v), (v).begin())
#define SUMS(srcv, dstv) partial_sum(all(srcv), (dstv).begin())
#define nth_bit(n) (1LL<<(n))

template <typename T> T high()  { return numeric_limits<T>::max(); }
template <typename T> T high(T) { return numeric_limits<T>::max(); }
template <typename T> T low()   { return numeric_limits<T>::lowest(); }
template <typename T> T low(T)  { return numeric_limits<T>::lowest(); }

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

// f には functional のオブジェクトが便利 (lambda 式も   [](int a){ return a / 2 }   みたいな)
template<class C, class F> inline C mapped(const C& c, F f){// mapっていうSTLがあるから...
    // ex: mapped(v, bind(plus<ll>(), _1, 2))   [v の各要素について x + 2]
    C r; r.reserve(c.size()); transform(all(c), back_inserter(r), f); return r;
}
template<class C, class F> inline C filtered(const C& c, F f){
    // ex: filtered(v, bind(equal_to<ll>(), bind(modulus<ll>(), _1, 2), 0)   [x mod 2 == 0 な x を取ってくる]
    C r; copy_if(all(c), back_inserter(r), f); return r;
}
template<class C, class I, class F> inline typename C::value_type foldl(const C& c, I i, F f){
    // ex: foldl(v, 1, multiplies<int>())   [v の総乗]
    return accumulate(all(c), static_cast<typename C::value_type>(i), f);
}

// 出力
template<class T> ostream& operator << (ostream &s, vector<T> v){
    rep(i, v.size()) { if (i != 0) { s << " "; } s << v[i]; } return s;
}
template<class T, class U> ostream& operator << (ostream &s, pair<T, U> p){
    return s << p.first << " " << p.second;
}


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

    ll ans = 0;
    for(ll i = a; i <= b; i++){
        ans += (c % i == 0);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

ll M;
vector<ll> d, c;
int main() {
    cin >> M;
    d.resize(M);
    c.resize(M);

    rep(i, M) {
        cin >> d[i] >> c[i];
    }
    ll ans = accumulate(c.begin(), c.end(), 0LL) - 1;

    ll tmp = 0;
    rep(i, M) {
        tmp += d[i] * c[i];
    }

    if (tmp >= 10) {
        ans += tmp / 9;
        if (tmp % 9 == 0) ans--;
    }

    cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
bool initialized = false;

/**
 * @fn
 * This function must be called at first.
 */
void combination_init() {
    initialized = true;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

/**
 * @fn
 * Calculates the combination  ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ n ≤ 10^7
 * @return nCK % MOD
 */
long long combination(int n, int k) {
    assert(initialized);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/**
 * @fn
 * Calculates the factorial of the number.
 *
 * @return N! % MOD
 */
long long factorial(int n) {
    assert(initialized);
    if (n < 0) return 0;
    return fac[n] % MOD;
}

/**
 * @fn
 * Calculates the combination ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ 10^7 and 1 ≤ n ≤ 10^9
 * @return nCK % MOD
 */
long long combination2(int n, int k) {
    assert(initialized);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll res = 1;
    k = min(k, n - k);
    for (long long x = 1; x <= k; x++) {
        res *= (n - x + 1);
        res %= MOD;
        res *= inv[x];
        res %= MOD;
    }
    return res;
}

ll pow(ll x, ll y, ll mod) {
    if (y == 0) {
        return 1;
    }
    if (y % 2 == 0) {
        return pow(x * x % mod, y / 2, mod) % mod;
    } else {
        return x * pow(x, y - 1, mod) % mod;
    }
}

void Main() {
    ll N, A, B;
    cin >> N >> A >> B;
    combination_init();
    ll ans = pow(2, N, MOD);
    ans--;
    ans %= MOD;
    if (ans < 0) ans += MOD;
    ans -= combination2(N, A);
    ans %= MOD;
    if (ans < 0) ans += MOD;
    ans -= combination2(N, B);
    ans %= MOD;
    if (ans < 0) ans += MOD;
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 12160
#include<iostream>
#include<stdio.h>
#include<cctype>
using namespace std;

int main(){
	char s;
	for (int i = 0; i < 1200; i++){
		scanf("%c",&s);
		if (s == '\n') break;
		if (isalpha(s)){
			if(islower(s)) cout << char(toupper(s));
			else cout << char(tolower(s));
		}
		else cout << s;
	}
	cout << endl;
}


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

using namespace std;

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

	int n;
	cin >> n;

	long long ans = 0;

	map<int, long long> cnt;

	for(int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		cnt[x] += 1;
		ans += x;
	}

	int q;
	cin >> q;

	while(q--) {
		int b, c;
		cin >> b >> c;
		ans -= cnt[b] * b;
		ans += cnt[b] * c;
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << ans << '\n';
	}

	return 0;
}

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

class RangeAddTree{
private:
  // data[i] := orig[i] - orig[i - 1], data[0] := orig[0].
  // orig[i] = data[0] + ... + data[i].
  vector<long long> data;
  int size;
  int height; // the number of edges between the root and leaves
  long long sum_util(int bidx, int eidx, int data_idx, int dbi, int dei){
    if((bidx <= dbi) && (dei <= eidx)){
      return data[data_idx];
    }

    if((eidx <= dbi) || (dei <= bidx)){
      return 0;
    }

    int dmi = (dbi + dei) / 2;
    return sum_util(bidx, eidx, 2 * data_idx + 1, dbi, dmi) +
      sum_util(bidx, eidx, 2 * data_idx + 2, dmi, dei);
  }
  void add_util(int idx, long long val){
    int data_idx = (1 << height) - 1 + idx;
    while(data_idx > 0){
      data[data_idx] += val;
      data_idx = (data_idx - 1) / 2;
    }
    data[0] += val;
  }
public:
  RangeAddTree(int size){
    this->size = size;
    for(height = 0; (1 << height) < size; height++){
    }
    data = vector<long long>((1 << (height + 1)) - 1);
  }
  long long at(int idx){
    return sum_util(0, idx + 1, 0, 0, 1 << height);
  }
  void add_range(int begin, int end, long long val){
    add_util(begin, val);
    add_util(end, -val);
  }
};

int idx(long long position, vector<pair<long long, long long>>& enemies){
  return lower_bound(enemies.begin(), enemies.end(), make_pair(position, 0LL)) - enemies.begin();
}

int main(){
  long long N, D, A;
  cin >> N >> D >> A;

  vector<pair<long long, long long>> enemies(N);
  for(int i = 0; i < N; i++){
    long long x, h;
    cin >> x >> h;
    enemies[i] = make_pair(x, h);
  }
  sort(enemies.begin(), enemies.end());

  auto tree = RangeAddTree(N);
  long long ans = 0;
  for(int i = 0; i < N; i++){
    long long x, h;
    tie(x, h) = enemies[i];

    long long bomb_power = tree.at(i) * A;
    if(bomb_power < h){
      int bomb_area_end_idx =
        lower_bound(enemies.begin(),
                    enemies.end(),
                    make_pair(x + 2 * D + 1, 0LL)
                    ) -
        enemies.begin();
      long long added = (h - bomb_power + A - 1) / A;
      tree.add_range(i, bomb_area_end_idx, added);
      ans += added;
    }
  }
  cout << ans << endl;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int x = 0;
    bool ans = false;
    
    while(true) {
        x++;
        
        if (((x * a) % b) == c) {
            ans = true;
        }
        
        if (x > b) {
            break;
        }
    }
    
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#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>;
const int INF = numeric_limits<int>::max();

int main()
{
    int n;
    cin >> n;
    set<int> st;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        st.insert(d);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>

using namespace std;
int main() {
	vector<int>a;
	int N;
	vector<int>b;
	vector<int>c;
	cin >> N;
	int g;
	for (int i = 0; i < N; i++) {
		cin >> g;

		a.push_back(g);


	}
	int count = 1;
	


	for (int i = 0; i < N; i++) {

		if (a[i] % 2 == 0&&a[i]!=1) {
			a[i] = 2;
			
		}
		else {

			a[i] = 1;

		}

		


	}
	long long big = 1;
	for (int i = 0; i < N; i++) {

		big *= 3;

	}
	for (int i = 0; i < N; i++) {

		count*=a[i];

	}


	cout << big-count;


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


char isused[100010];


bool isPrime(int N){
  for(int i=2; i*i<=N; i++){
    if(N%i == 0) return false; 
  }
  return true;
}

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

  ll ans = 1;
  for(int i = 2; i<=N; i++){
    ll cnt = 0;
    ll div = i;
    if(isPrime(div)){
      while(N/div){
      cnt += N/div;
      div *= i;
      }
      // cout << i << ":" << cnt << endl;
      ans *= cnt+1;
      ans %= mod;
    }
  }
   
  cout << ans%mod << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define lb(a, b) lower_bound(a.begin(), a.end(), b)
#define ub(a, b) lower_bound(a.begin(), a.end(), b)
#define st(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef long double ld;
using namespace std;

struct WS{
  vvl d = vv(0, 0, 0, ll);
  ll N;
  WS(ll n){
    N = n;
    d.resize(n+1, vll (n+1, 10000000000));
    init();
  }
  void init(){
    re(i, N+1) d[i][i] = 0;
  }
  void insert(ll a, ll b, ll c){
    d[a][b] = min(d[a][b], c);
  }
  void warshall(){
    init();
    re(i, N+1) re(s, N+1) re(t, N+1) d[s][t]=min(d[s][t],d[s][i]+d[i][t]);
  }
};

int main(int argc, char const *argv[]) {
  ll x, y, z, n, m, r;std::cin >> n >> m >> r;
  vll s(r);re(i, r) std::cin >> s[i];
  WS w(n);
  re(i, m){
    std::cin >> x >> y >> z;
    w.insert(x, y, z);
    w.insert(y, x, z);
  }
  w.warshall();
  vector<int> v(r);
  re(i, r) v[i] = i;
  ll ans = 10000000000000000;
  do {
    ll tmp = 0;
    vector<int> t(r);
    re(i, r) t[v[i]] = s[i];
    rep(i, 1, r){
      tmp += w.d[t[i]][t[i-1]];
    }
    ans = min(ans, tmp);
  }while (std::next_permutation(v.begin(), v.end()));
  std::cout << ans << '\n';
  return 0;
}


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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

S = input()

for i in range(len(S)):
    for j in range(i,len(S)):
        t = S[0:i]+S[j:]
        if t == "keyence":
            print("YES")
            sys.exit()

print("NO")

Measured memory_bytes: 77516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

bool pal(const string &s){
    int L = s.size();
    rep(i,L)if(s[i]!=s[L-1-i]) return false;
    return true;
}

int main(){
    int n,L;
    cin >>n >>L;
    vector<string> s(n);
    rep(i,n) cin >>s[i];

    set<string> S;
    map<string,int> ct;
    rep(i,n){
        S.insert(s[i]);
        ++ct[s[i]];
    }

    string a = "";
    for(string x:S){
        string rev = x;
        reverse(all(rev));
        while(1){
            if(x==rev){
                if(ct[x]>=2){
                    ct[x]-=2;
                    a += x;
                }
                else break;
            }
            else{
                if(ct[x]>=1 && ct[rev]>=1){
                    --ct[x];
                    --ct[rev];
                    a += x;
                }
                else break;
            }
        }
    }

    string c = "";
    for(const auto &p:ct){
        if(p.se>0){
            if(pal(p.fi)){
                c = p.fi;
                break;
            }
        }
    }

    string b = a;
    reverse(all(b));
    cout << a+c+b << endl;
    return 0;
}



Measured memory_bytes: 3520
#include <stdio.h>
int main(void){
    int A,B;
    scanf("%d %d",&A,&B);
    char s;
    for(int i=0;i<A+B+1;i++){
        scanf(" %c",&s);
        if((i==A&&s!='-')||(i!=A&&s=='-')){printf("No");return 0;}
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int x,y,a =0;
    scanf("%d %d",&x,&y);
    
    switch(x){
        case 1 : a+= 300000; break;
        case 2 : a+= 200000; break;
        case 3 : a+= 100000; break;
        default : break;
    }
    switch(y){
        case 1 : a+= 300000; break;
        case 2 : a+= 200000; break;
        case 3 : a+= 100000; break;
        default : break;
    }
    if(x==1&&y==1){
        printf("%d",a+400000);
        }
    else    printf("%d",a);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

bool comp(const string& i, const string& j){
	return (i > j);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int x, a, b;
	cin >> x >> a >> b;
	int ans = (x-a)%b;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
int h1,m1,h2,m2,k;
cin>>h1>>m1>>h2>>m2>>k;

int h=h2-h1-1;
int m=(60-m1)+m2;
int sum = h*60+m;
sum-=k;


cout<<sum<<endl;

    
return 0;
}


Measured memory_bytes: 3636
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;} // ver. 2020-02-17
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;
const ll m = 1000000007;

ll pw(ll a, ll n) {
    if (n == 0) return 1;
    if (n % 2) {
        return (a * pw(a, n-1)) % m;
    }
    ll a2 = pw(a, n/2);
    return (a2 * a2) % m;
}

ll ch(ll n, ll k) {
    ll r = 1;
    for (ll i = 1; i <= k; ++i) {
        r *= (n+i-k);
        r %= m;
        r *= pw(i, m-2);
        r %= m;
    }
    return r;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = pw(2, n) - ch(n, a) - ch(n, b) - 1;
    ans %= m;
    ans = (ans + m) % m;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <sstream>
#include <cstring>
#include <bitset>
#include <stack>
using namespace std;
#define MP make_pair
#define PB push_back
const int INF=1e9;
const int mod=1e9+7LL;

int n,m;
vector <int> v[200005];
bool can[200005];

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].PB(y);
		v[y].PB(x);
		if (x==n) can[y]=true;
		if (y==n) can[x]=true;
	}
	for (int i=0;i<v[1].size();i++)
	{
		int tx=v[1][i];
		if (can[tx])
		{
			cout<<"POSSIBLE";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 12144
n = int(input())
if n == 0:
    print(0)
    exit()
ans = ""
while n != 0:
    if n % (2) == 0:
        n = n // (-2)
        ans = "0" + ans
    else:
        n = (n - 1) // (-2)
        ans = "1" + ans
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    int l = 0;
    if (s == "RRR") {
        cout << 3 << endl;
    } else if (s == "SSS") {
        cout << 0 << endl;
    } else if (s == "RRS" || s == "SRR") {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	char S[11];
	char T[12];
	
	scanf("%s",S);
	scanf("%s",T);
	
	for(int i=0; i<strlen(S);i++){
		if( S[i] != T[i] ){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
	
}


Measured memory_bytes: 1732
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let d: Vec<usize> = vec(n, |_| scan(tokens));
    let mut sum = 0;
    let mut sum2 = 0;
    for di in d {
        sum += di;
        sum2 += di * di;
    }
    println!("{}", (sum * sum - sum2) / 2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#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)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m+1);
  vector<int> dp(n+1);
  rep(i, m) cin >> a[i];
  int j = 0;
  dp[0] = 1;
  if (a[0] == 1) j++;
  else dp[1] = 1;
  FOR(i, 2, n+1) {
    if (i == a[j]) {
      j++;
      continue;
    }
    dp[i] = (dp[i-1]+dp[i-2])%mod;
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod    998244353
#define PI 2*acos(0.0)


int32_t main()
{
    io;
    int n;
    cin>>n;
    vi inp(n);
    for(auto& x: inp)
        cin>>x;
    sort(inp.rbegin(), inp.rend());
    ll ans = inp[0];
    int cnt = n-2, j = 1;
    while(cnt-2 >= 0)
    {
        ans += 2LL*inp[j];
        j++;
        cnt-= 2;
    }
    if(cnt)
        ans += inp[j];
    cout <<ans;
    return 0;
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef pair<long , long> pll;

const ll mx = 105;
const ll maxn = 1000001;
const ll mod = 1000000007;

vector<vector<int>> adj;
vector<int> res;
vector<int> ord;

int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(0);
   
   ll n, m, i, j, k, t, q, su = 0;

   cin>>n>>m;
   
   ll a[n];
   for(i =0 ;i < n;i++)
   {

     cin>>a[i];
     su+= a[i];

   }

   sort(a, a+n);
   ll count = 0;

   for(i = n-1;i >= 0;i--){
       if(count < m && 4*m*a[i] >= su){
           count++;
       }
       else{
           break;
       }
   }  
   if(count == m){
       cout<<"Yes\n";
   }
   else{
       cout<<"No\n";
   }

}




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

int dp[15][10], k;
std::vector<int> ans;
void print(){
	bool stat = false;
	for(int i=0;i<ans.size();i++){
		if(ans[i]) stat = true;
		if(stat) printf("%d",ans[i]);
	}
}
int main(){
	for(int i=0;i<=9;i++) dp[14][i] = 1;
	for(int i=13;i>=1;i--){
		for(int j=0;j<=9;j++){
			dp[i][j] = dp[i+1][j];
			if(j > 0) dp[i][j] += dp[i+1][j-1];
			if(j < 9) dp[i][j] += dp[i+1][j+1];
		}
	}
	scanf("%d",&k);
	int i;
	for(i=14;i;i--){
		int cnt = 0;
		for(int j=1;j<=9;j++) cnt += dp[i][j];
		if(k > cnt) k -= cnt;
		else break;
	}
	k += dp[i][0];
	for(int j=0;i<=14;i++){
		for(;j<=9;j++){
			if(k > dp[i][j]) k -= dp[i][j];
			else{
				ans.push_back(j);
				if(j) j--;
				break;
			}
		}
	}
	print();
	return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

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

signed main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  rep (i, n) {
    int k;
    cin >> k;
    rep (i, k) {
      int a; cin >> a;
      mp[a]++;
    }
  }

  int ans = 0;
  for (auto x: mp) {
    if (x.second == n) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;


namespace abc88_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = ReadLine().Split().Select(int.Parse).ToArray();
            int[] b = ReadLine().Split().Select(int.Parse).ToArray();
            int[] c = ReadLine().Split().Select(int.Parse).ToArray();

            int sum = 0;
            sum += a[0]+a[1]+a[2];
            sum += b[0]+b[1]+b[2];
            sum += c[0]+c[1]+c[2];

            if(sum == 3*(a[0]+b[1]+c[2])){
                WriteLine("Yes");
            }else{
                WriteLine("No");
            }
        }
    }
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int K;
    cin >> K;
    int count = 1;
    int mod = 7;
    for (int i = 0; i < K; ++i) {
        if (mod % K == 0) break;
        count++;
        mod = (mod * 10 + 7) % K;
    }
    if (mod % K == 0) cout << count << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`);
  
  while (input.hasNext()) {
    val A = input.nextInt()
    val B = input.nextInt()
    var num = (B - 1) / (A - 1) + if ((B - 1) % (A - 1) > 0) 1 else 0
    
    println(num)
  }
}

Measured memory_bytes: 36504
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin >> t;
    while (t--) {
        int a,b;
        cin>>a>>b;
        cout<<(2*b>a?0:a-2*b)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
long double a,b; 
ll sum=0;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>a>>b;
    cout<<(ll)(a*b)<<endl;
    return 0;
}


Measured memory_bytes: 3744
s = input()
k = int(input())
l = len(s)
dp = [[[0 for i in range(k+1)] for j in range(2)] for m in range(l+1)]
dp[0][0][0] = 1
for i in range(l):
    for x in range(k+1):
        if s[i] == "0":
            dp[i+1][0][x] += dp[i][0][x]
        else:
            if x < k:
                dp[i+1][0][x+1] += dp[i][0][x]
            dp[i+1][1][x] += dp[i][0][x]
        for j in range(1, int(s[i])):
            if x < k:
                dp[i+1][1][x+1] += dp[i][0][x]
        dp[i+1][1][x] += dp[i][1][x]
        for j in range(1, 10):
            if x < k:
                dp[i+1][1][x+1] += dp[i][1][x]
print(dp[-1][0][-1] + dp[-1][1][-1])

Measured memory_bytes: 70008
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import qualified Data.IntMap as M
import qualified Data.List as L
import Control.Monad
import Text.Printf (printf)

padding :: Int -> String
padding = printf "%06d"

main :: IO ()
main = do
    _ <- getLine
    py <- map ((\[a,b] -> (a,[b])) . map (fst . fromJust . BS.readInt) . BS.words) . BS.lines <$> BS.getContents
    let m = M.map (\v -> M.fromList (zip (L.sort v) [1..]))
          $ M.fromListWith (\[a] b -> a:b) py
    forM_ py (\(p,[y]) -> do
        let v = fromJust $ M.lookup p m
            i = fromJust $ M.lookup y v
        putStr $ padding p
        putStrLn $ padding i)


Measured memory_bytes: 59900
#include <bits/stdc++.h>
using namespace std;
const int N=200010;
int a[N],n;
long long s[N],ans;
map<long long,int> mp;
int main(){
	scanf("%d",&n);
	for (int i=1; i<=n; ++i) scanf("%d",&a[i]),s[i]=s[i-1]+a[i];
	for (int i=1; i<=n; ++i){
		++mp[s[i-1]];
		ans+=mp[s[i]];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 15104
//AUTHOR:- Avinash//
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long int
#define lll long long
#define fo(i,n) for(int i=0;i<n;i++)
#define take(a,i,n) for(int i=0;i<n;i++) cin>>a[i]
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ld long long double
#define d1(x) cout<<(x)<<endl
#define T int t;cin>>t;while(t--)
#define hell 1000000007
#define ex endl;
#define F first
#define maxn 200001
#define pi 3.14159265
#define S second
#define P pair<int,int>
#define PP pair<int,pair<int,int>>
#define pb push_back
#define in insert
#define vec vector<ll>
#define vec2 vector<vector<int>>
#define s(a,n) sort(a,a+n);
#define sv(a) sort(a.begin(),a.end());
#define MAX 1000
//Author:-Avinash//
ll power(ll x, ll y, ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(ll a, ll m)
{
    return power(a, m-2, m);
}
int main(){
 FAST
 string str;
 string s = "es";
 string ss = "s";
 cin>>str;
 int len = str.length();
 if(str[len-1] == 's'){
  cout<<str.append(s);
 }
 else{
  cout<<str.append(ss);
 }
 
}


Measured memory_bytes: 3652
def main():
    from math import gcd
    k=int(input())
    ans=0
    for a in range(1,k+1):
        for b in range(1,k+1):
            g=gcd(a,b)
            for c in range(1,k+1):
                ans+=gcd(g,c)
    print(ans)
if __name__ == '__main__':
    main()

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,ww;
  cin >> n >> ww;
  vector<int> w(n),v(n);
  vector<LL> dp(ww+1,0);
  for(int i=0;i<n;i++){
    cin >> w[i] >> v[i];
    for(int j=ww;j>=w[i];j--){
      dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
    }
  }
  LL ans=0;
  for(int i=0;i<=ww;i++){
    ans=max(ans,dp[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    int h,w; cin >> h >> w;
    vector<int> a(h), b(h);
    rep(i,h) {
        cin >> a[i] >> b[i];
        a[i]--;
    }

    map<int, int> mp;
    multiset<int> cand;
    rep(i,w) mp[i] = i;
    rep(i,w) cand.insert(0);

    rep(i,h){
        int l = a[i], r = b[i];
        auto it = mp.lower_bound(l);
        int rb = -1;
        while(it != mp.end() && it -> first <= r){
            chmax(rb, it -> second);
            cand.erase(cand.find(it -> first - it -> second));
            mp.erase(it++);
        }

        if(rb != -1 && r < w){
            cand.insert(r - rb);
            mp[r] = rb;
        }

        int ans = -1;
        if(cand.size()) ans = *cand.begin() + i+1;
        cout << ans << endl;
    }
}


Measured memory_bytes: 23564
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 200002
typedef long long ll;
ll max(ll a,ll b){
    if(a>b) return a;
    else return b;
}
ll b_search(ll left, ll right,ll *num,ll ans){
    while(right - left > 1){
        ll mid = left + (right-left)/2;
        if(num[mid] > ans) right = mid;
        else left = mid;
    }
    return left;
}

int main(){
    ll N,M,K;
    scanf("%lld %lld %lld",&N,&M,&K);
    ll A[MAX],B[MAX];
    ll Asum[MAX]={0},Bsum[MAX]={0};
    for(ll i=1;i<=N;i++){
        scanf("%lld",A+i);
        Asum[i] = Asum[i-1] + A[i];
    }
    for(ll i=1;i<=M;i++){
        scanf("%lld",B+i);
        Bsum[i] = Bsum[i-1] + B[i];
    }
    ll keep,ans = 0;
    keep = b_search(0,N+1,Asum,K);
    for(ll i=keep;i>=0;i--){
        ans = max(ans,i+b_search(0,M+1,Bsum,K-Asum[i]));
    }
    printf("%lld",ans);
}


Measured memory_bytes: 7976
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<int> b(n);
    for(int i=0;i<n;i++){
        b[i]=(a[i]-(i+1));
    }
    sort(b.begin(),b.end());
    long long sum1=0,sum2=0;
    for(int i=0;i<n;i++){
        sum1+=abs(a[i]-(b[n/2]+i+1));
        //sum2+=abs(a[i]-(b[n/2+1]+i+1));
    }
    cout<<sum1<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

using i64=long long;

i64 f(i64 b, i64 n) {
    return n<b? n:f(b, n/b)+(n%b);
}

int main() {
    i64 n, s;
    scanf("%lld %lld", &n, &s);

    if (n == s)
        return !printf("%lld\n", n+1);

    i64 ub=sqrt(n);
    for (i64 b=2; b<=ub; ++b)
        if (f(b, n) == s)
            return !printf("%lld\n", b);

    for (i64 p=ub+1; --p;) {
        i64 b=(n-s)/p+1;
        if (b < 2) continue;
        if (f(b, n) == s)
            return !printf("%lld\n", b);
    }

    return !printf("-1\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int main() {
  vector<int> a(3);
  for (int i = 0; i < (int)3; ++i) cin >> a[i];
  sort((a).begin(), (a).end());
  if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define boost ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define ll long long
#define rep(i,a,b) for(int i=a;i<b;++i)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define rpe(i,a,b) for(i=a-1;i>=b;i--)
#define rp(i,n) rep(i,0,n)
#define fr(i,n) fre(i,1,n)
#define trav(a, x) for (auto& a : x)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define endl "\n"
#define F first
#define S second
#define vi vector<int>
#define vii vector< vector<int> >
#define vpi vector< pair<int,int> >
#define viii vector< vector<vector<int> > >
#define cd complex<double>
#define PI acos(-1)
#define pie 3.14159265358979323846
#define all(c) (c).begin(),(c).end()
#define prec(n) fixed << setprecision(n)
#define print_time {cout << flush; cerr << endl << "Time taken: " << fixed << setprecision(3) << 1.0 * clock() / CLOCKS_PER_SEC << " secs\n";}
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b)) / gcd((a),(b))
#define bc(n) __builtin_popcountll(n)
#define leadzero(a) __builtin_clz(a)        // count leading zeroes
#define trailzero(a) __builtin_ctz(a)       // count trailing zeroes
#define bitcount(a) __builtin_popcount(a)   // count set bits
#define lps(v,x) (lower_bound(all(v),x)-v.begin())
#define ups(v,x) (upper_bound(all(v),x)-v.begin())
typedef long double ld;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
    X ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inft = (1LL<<61) ;
const int inf = 5e18;
const int mod = 1e9+7;
int modpow(int x, int n, int mod){
    x %= mod ;
    int res = 1;
    while(n>0){
        if(n & 1)res = res * x % mod;
        x = x*x%mod;
        n>>=1 ;}
    return res;}
const int N = 1e6+1e4+1e2+1 ;
const int M = 3*(1e5+1e3+1e1) ;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

signed main()
{
    boost ;
    cin.exceptions(cin.failbit);

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

    int a,b ;
    cin >> a >> b ;
    int ans = max(2*a-1, 2*b-1) ;

    ans=max(ans,a+b) ;

    cout << ans << endl ;

return 0 ;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int
map<int, lli> dp[100];
// 100 -> 200 -> 100 -> 200
// (0, 10) -> (2000, 0) -> (0, 20) -> (4000, 0)
// 100 -> 199 -> 150  -> 200
void solve(long long N, std::vector<long long> A) {
  dp[0][0] = 1000;
  rep(i, N){
    for(auto [s, t]: dp[i]){
      chmax(dp[i+1][s], t);
      chmax(dp[i+1][0], t + s * A[i]);
      chmax(dp[i+1][s + t/A[i]], t % A[i]);
    }
  }
  lli ma = 0;
  for(auto [s,t]:dp[N]){
    chmax(ma, t);
  }
  cout << ma <<endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3852
S = list(input())
t = input()
T = list(t)
NS = len(S)
NT = len(T)
j = -1
if NS < NT:
    pass
else:
    for i in range(NS - NT,-1,-1):
        j = i
        for k in range(NT):
            if S[i+k] == T[k] or S[i+k] == '?':
                pass
            else:
                j = -1
                break
        if j != -1:
            break
            
if j == -1:
    print('UNRESTORABLE')
else:
    k = 0
    ans = ''
    while k != NS:
        if k == j:
            ans += t
            k += NT
        else:
            if S[k] == '?':
                ans += 'a'
            else:
                ans += S[k]
            k += 1
    print(ans)

Measured memory_bytes: 3064
N = int(input())
c = list(input())
w = 0
r = N-1
ans = 0
while w < r:
    for i in range(w,r):
        if c[i] == "W":
            c[i] = "R"
            w = i
            break
    else:
        break
    for j in range(r,w,-1):
        if c[j] == "R":
            c[j] = "W"
            r = j
            break
    else:
        break
    ans += 1
print(ans)

Measured memory_bytes: 10704