akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstring>
#include <regex>
#include <sstream>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

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

struct edge
{
public:
    int to;
    int cost;
};

// O(|E|(log|V|))
void dijkstra(std::vector<int> &dist, const std::vector<std::vector<edge>> &graph, int s)
{
    typedef std::pair<int, int> P;
    std::priority_queue<P, std::vector<P>, std::greater<P>> pq;
    for (auto &e : dist)
    {
        e = INF;
    }

    dist[s] = 0;
    // P(distance from start, vertex index)
    pq.push(P(0, s));
    while (!pq.empty())
    {
        P cur = pq.top();
        pq.pop();
        int v = cur.second;
        int cost = cur.first;
        if (dist[v] < cost)
        {
            continue;
        }
        for (const auto &next : graph[v])
        {
            if (dist[next.to] > next.cost + dist[v])
            {
                dist[next.to] = next.cost + dist[v];
                pq.push(P(dist[next.to], next.to));
            }
        }
    }
}

void restorePath(
    std::vector<int> &path,
    const std::vector<int> &dist,
    const std::vector<std::vector<edge>> &graph,
    int e)
{
    int cur = e;
    path.push_back(e);
    while (dist[cur] != 0)
    {
        for (const auto &n : graph[cur])
        {
            if (dist[n.to] + n.cost == dist[cur])
            {
                path.push_back(n.to);
                cur = n.to;
                break;
            }
        }
    }
    std::reverse(path.begin(), path.end());
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

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

    int n, a, b;
    cin >> n >> a >> b;

    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        int c = 0;
        int thisi = i;
        while(thisi){
            c += thisi % 10;
            thisi /= 10;
        }
        if (a <= c && c <= b){
            sum += i;
        }
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
          Scanner scanner = new Scanner(System.in);
          int input = scanner.nextInt();
          int A,B,C,D;
        D = input % 10;
        input /= 10;
        C = input % 10;
        input /= 10;
        B = input % 10;
        input /= 10;
        A = input;
        if(A + B + C + D == 7){
            System.out.println(A+"+"+B+"+"+C+"+"+D+"=7");
        }
        else if(A - B + C + D == 7){
            System.out.println(A+"-"+B+"+"+C+"+"+D+"=7");
        }
        else if(A + B - C + D == 7){
            System.out.println(A+"+"+B+"-"+C+"+"+D+"=7");
        }
        else if(A + B + C - D == 7){
            System.out.println(A+"+"+B+"+"+C+"-"+D+"=7");
        }
        else if(A - B - C + D == 7){
            System.out.println(A+"-"+B+"-"+C+"+"+D+"=7");
        }
        else if(A - B + C - D == 7){
            System.out.println(A+"-"+B+"+"+C+"-"+D+"=7");
        }
        else if(A + B - C - D == 7){
            System.out.println(A+"+"+B+"-"+C+"-"+D+"=7");
        }
        else if(A - B - C - D == 7) {
            System.out.println(A + "-" + B + "-" + C + "-" + D + "=7");
        }
    }
}



Measured memory_bytes: 22996
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

ll arr[6];
void solve() {
    ll N,A,B,C,D; cin >> N >> A >> B >> C >> D;

    map<ll, ll> dist;
    dist[1] = 1e18;
    dist[N] = 0;
    arr[2] = A;
    arr[3] = B;
    arr[5] = C;
    priority_queue<pll, vector<pll>, greater<pll>> pq;
    pq.emplace(0,N);
    auto func=[&](ll x, ll d, int num) {
        int k = x%num;
        ll cost1 = d+D*k;
        if (!dist.count(x/num)) dist[x/num] = 1e18;
        if (chmin(dist[x/num],cost1+arr[num])) {
            pq.emplace(dist[x/num],x/num);
        }
        if (k) {
            ll cost2 = d+D*(num-k);
            if (!dist.count(x/num+1)) dist[x/num+1] = 1e18;
            if (chmin(dist[x/num+1],cost2+arr[num])) {
                pq.emplace(dist[x/num+1],x/num+1);
            }
        }
    };
    while (!pq.empty()) {
        auto[d,v] = pq.top(); pq.pop();
        if (d > dist[v]) continue;
        if (v <= 2e18/D) chmin(dist[1],dist[v]+D*(v-1));
        func(v,d,2);
        func(v,d,3);
        func(v,d,5);
    }

    cout << dist[1]+D << ln;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //ifstream in("test.txt");
    //cin.rdbuf(in.rdbuf());
    //clock_t start = clock();
    int Q; cin >> Q;
    while (Q--) {
        solve();
    }

    //ここから切り離して末尾へ
    //clock_t end = clock();
    //const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    //cout << "time: " << time << "[ms]" << ln;
    //ここまで切り離して末尾へ
}


Measured memory_bytes: 4520
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}
//dp[i][j]:i桁目まで見た時にあまりがjの個数
long long dp[100005][13];

int main() {
    string S;cin >> S;
    int N = S.size();
    //reverse(S.begin(),S.end());
    for(int i = 0;i<100005;i++)for(int j = 0;j<13;j++) dp[i][j] = 0;
    dp[0][0] = 1;
    for(int i = 0;i<S.size();i++){
        if(S.at(i) != '?'){
            int A = S.at(i)-'0';
            //i桁目が特定できているが、余りは13通りで考える
            for(int amari = 0;amari<13;amari++){
                dp[i+1][(amari*10+A) % 13] += dp[i][amari];
            }
        }
        else{
            //?としてあり得る0~9とそれぞれだった時のあまりを求める
            for(int j = 0;j<10;j++){
                for(int amari = 0;amari<13;amari++){
                    dp[i+1][(amari*10+j) % 13] += dp[i][amari];
                }
            }
        }
        for(int j = 0;j<13;j++) dp[i+1][j] %= MOD;
    }
    cout << dp[N][5]%MOD << endl;
}


Measured memory_bytes: 10624
#include<iostream>
#include<algorithm>
using namespace std;
int main(void) {
	int N, M, X; cin >> N >> M >> X;
	int A[M];
	int i, j; int a = 0, b = 0;
	for (i = 0; i < M; i++) {
		cin >> A[i];
	}
	for (i = X; i < N; i++) {
		for (j = 0; j < M; j++) {
			if (i == A[j]) {
				a += 1;
			}
		}
	}
	for (i = X; i >= 1; i--) {
		for (j = 0; j < M; j++) {
			if (i == A[j]) {
				b += 1;
			}
		}
	}
	cout << min(a, b) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll n;
    cin>>n;
    vector<ll>a(n);
    rep(0,i,n)cin>>a[i];
    sort(a.rbegin(),a.rend());
    ll A=0,B=0;
    rep(0,i,n){
        if(i%2==0)A+=a[i];
        else B+=a[i];
    }
    cout<<A-B;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 600010
using namespace std;
ll bit[N*2];
ll sum(int i){
    ll s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}
ll n;
void add(int i,ll x){
    while(i<=N){
        bit[i]+=x;
        i+=i&-i;
    }
}
ll BIT[N*2];
ll sum2(int i){
    if(i==0) return 0;
    return BIT[i]+sum2(i-(i&-i));
}
void add2(int i,ll x){
    while(i<=N){BIT[i]+=x;i+=i&-i;}
}
main(){
    ll k;cin>>n>>k;
    ll a[N];rep(i,n){cin>>a[i];add(i+1,a[i]-k);}
    pair<ll,int> p[N];
    rep2(i,1,n){
        p[i-1].first=sum(i);
        p[i-1].second=i+1;
    }
    p[n].first=0;p[n].second=1;
    sort(p,p+n+1);
    ll ans=0;
    rep(i,n+1){
        ans+=sum2(p[i].second);
        add2(p[i].second,1);
    }
    cout<<ans;

}

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

const int M = 1000005;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(M);
    for(int x : a){
        if(cnt[x] != 0){
            cnt[x] = 2;
            continue;
        }
        for(int i = x; i < M; i+= x) cnt[i]++;
    }
    int ans = 0;
    for(int x: a){
        if(cnt[x] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8000
#include <stdio.h>
#define N 10000

typedef struct {
  int id;
  int parent;
  int left;
  int right;
  int depth;
  int sibling;
  int height;
} Node;

Node T[N];
void Depth(int, int);
int Height(int);
void Sibling(int);

int main() {
  int root,n,i,id;
  scanf("%d",&n);

  for(i = 0; i < n; i++) {
    T[i].parent = -1;
  }


  for(i = 0; i < n; i++) {
    scanf("%d",&id);
    scanf(" %d %d",&T[id].left,&T[id].right);
    if(T[id].left != -1) T[T[id].left].parent = id;
    if(T[id].right != -1) T[T[id].right].parent = id;
  }

  for(i = 0; i < n; i++) {
    if(T[i].parent == -1) root = i;
  }

  Depth(root,0);
  Height(root);
  Sibling(n);

  for(i = 0; i < n; i++) {
    printf("node %d: parent = %d, sibling = %d, ",i,T[i].parent,T[i].sibling);
    printf("degree = ");
    if(T[i].left != -1 && T[i].right != -1) printf("2");
    else if(T[i].left != -1 || T[i].right != -1) printf("1");
    else printf("0");
  printf(", depth = %d, height = %d, ",T[i].depth,T[i].height);
    if(T[i].parent == -1) printf("root");
    else if(T[i].left == -1 && T[i].right == -1) printf("leaf");
    else printf("internal node");
    printf("\n");
  }
  return 0;
}

void Sibling(int n) {
  int i;
  for(i = 0; i < n; i++) {
    T[i].id = i;
  }
  for(i = 0; i < n; i++)
    if(T[i].parent == -1) T[i].sibling = -1;
    else if(T[T[i].parent].right != T[i].id) T[i].sibling = T[T[i].parent].right;
    else if(T[T[i].parent].left != T[i].id) T[i].sibling = T[T[i].parent].left;
  return;
}


void Depth(int child, int d) {
  if(child == -1) return ;
  T[child].depth = d;
  Depth(T[child].left,++d);
  Depth(T[child].right,d);
}

int Height(int u) {
  int a,b;
  a = b = 0;
  if(T[u].left != -1) a = 1 + Height(T[u].left);
  if(T[u].right != -1) b = 1 + Height(T[u].right);
  if(a < b) {
    T[u].height = b;
    return b;
  }
  T[u].height = a;
  return a;
}

Measured memory_bytes: 604
def resolve():
  N, M, C = map(int, input().split(" "))
  B = [int(x) for x in input().split(" ")]

  counter = 0
  for _ in range(N):
    A = [int(x) for x in input().split(" ")]
    sum_of_a_x_b = 0
    for a, b in zip(A,B):
      sum_of_a_x_b += a * b
    if sum_of_a_x_b + C > 0:
      counter += 1
  print(counter)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 62412
#include<bits/stdc++.h>
using namespace std;
vector<int> values, costs;
int n, aux, mx, value, cost;
void bt(int m) {
	if(m == n) {
		mx = max(mx, value - cost);
		return;
	}
	else {
		value += values[m];
		cost += costs[m];
		bt(m + 1);
		value -= values[m];
		cost -= costs[m];
		bt(m + 1);
	}
	return;
}
int main() {
	cin>>n;
	for(int i = 0; i < n; i++) {
		cin>>aux;
		values.push_back(aux);
	}
	for(int i = 0; i < n; i++) {
		cin>>aux;
		costs.push_back(aux);
	}
	bt(0);
	cout<<mx<<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;
typedef long long ll;
 
int main() {
  ll h,n;
  cin >> h >> n;
  ll total = 0;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    total += tmp;
    if(total >= h) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

struct Edge {
  int to;
  int idx;
};

int N;
int M;
int A[114514];
int B[114514];
int D[114514];
bool ans[214514];
bool used[114514];
vector<Edge> es[214514];
bool imp;

bool Dfs(int v, int r) {
  bool ret = 0;
  used[v] = 1;
  for (auto &e : es[v]) {
    int u = e.to;
    if (used[u]) continue;
    ans[e.idx] = Dfs(u, r);
    ret ^= ans[e.idx];
  }
  if (D[v]) ret ^= 1;
  if (v == r && v != N) {
    if (ret) imp = 1;
  }
  return ret;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  cin >> N >> M;
  vector<int> vs;
  vector<pii> ps;
  rep(i, N) {
    cin >> A[i] >> B[i];
    vs.eb(i);
  }
  ps.eb(pii(1000000001, N));
  sort(all(vs), [](int i, int j){return A[i] < A[j];});

  rep(i, N) {
    int idx = vs[i];
    ps.eb(pii(A[idx], i));
    if (i > 0) D[i] = B[vs[i-1]];
    D[i] ^= B[idx];
  
  }
  sort(all(ps));

  rep(i, M) {
    int l, r;
    cin >> l >> r;
    int u = lower_bound(all(ps), pii(l, 0))->YY;
    int v = lower_bound(all(ps), pii(r+1, 0))->YY;
    es[u].eb(Edge{v, i});
    es[v].eb(Edge{u, i});
  }

  Dfs(N, N);
  assert(!imp);
  rep(v, N) {
    if (used[v]) continue;
    Dfs(v, v);
    if (imp) {
      cout << "-1\n";
      return 0;
    }
  }

  vector<int> O;
  rep(v, M) {
    if (ans[v]) O.eb(v+1);
  }
  cout << O.size() << endl;
  rep(v, O.size()) {
    if (v) cout << " ";
    cout << O[v];
  }
  cout << endl;
}


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

void solve()
{
  int A, B;
  cin >> A >> B;
  cout << (6 - A - B);
}
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(11);
  solve();
  return 0; 
}


Measured memory_bytes: 256
#include<stdio.h>
int prim();
int g[101][101],n;

int main(){
    int i,j,cur=1;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&g[i][j]);
            if(g[i][j]==-1) g[i][j]=2001;
        }
    }
    printf("%d\n",prim());
    return 0;
}
int prim(){
    int i,v,u,minv,d[101],p[101],flag[101];
    for(i=0;i<n;i++){
        d[i]=2001;
        p[i]=-1;
        flag[i]=0;
    }
    d[0]=0;
    while(1){
        minv=2001;
        u=-1;
        for(i=0;i<n;i++){
            if(minv>d[i] && flag[i]!=1){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1) break;
        flag[u]=1;
        for(v=0;v<n;v++){
            if(flag[v]!=1 && g[u][v]!=2001){
                if(d[v]>g[u][v]){
                    d[v]=g[u][v];
                    p[v]=u;
                    flag[v]=2;
                }
            }
        }
    }
    int sum=0;
    for(i=0;i<n;i++){
        if(p[i]!=-1) sum+=g[i][p[i]];
    }
    return sum;
}


Measured memory_bytes: 2004
/*input
314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

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


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	ll n,m;
	cin>>n>>m;
	ll a;
	ll k=0;
	rep(i,0,m)cin>>a,k+=a;
	n-=k;
	if(n<0)n=-1;
	cout<<n<<endl;
	return 0;
}




Measured memory_bytes: 3644
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    con=2500
    n,a=map(int,readline().split())
    x=list(map(int,readline().split()))

    dp=[[[0]*(n+1) for _ in range(con+1)] for _ in range(n+1)]
    dp[0][0][0]=1
    for i in range(n):
        for k in range(n):
            for j in range(con+1-50):
                #i枚目を選ぶ
                dp[i+1][j+x[i]][k+1]+=dp[i][j][k]

                #i枚目を選ばない
                dp[i+1][j][k]+=dp[i][j][k]

    ans=0
    for k in range(1,n+1):
        ans+=dp[n][k*a][k]
    print(ans)

if __name__=="__main__":
    main()

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

typedef long long ll;
const int N = 1e5+10;
struct node{
	ll a;
	ll b;
}p[N];

bool cmp(node a,node b)
{
	return a.a<b.a;
}
int main()
{
	ll n,k;
	cin>>n>>k;
	for(ll i=0;i<n;i++)
		cin>>p[i].a>>p[i].b;
	sort(p,p+n,cmp);
	ll i;
	for(i=0;i<n;i++)
		if(k<=0)
			break;
		else
			k-=p[i].b;
	cout<<p[i-1].a<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define lli long long int 
#define ll long long 
#define f(i, n) for(int i=0; i<n; i++)

using namespace std;


void test(){
	
	int n;
	cin>>n;
	
	if(n%1000 == 0) {
		cout<<"0"<<endl;
		return ;
	}
	cout<<1000 - (n%1000)<<endl;
}
int main(){
	
	test();
	return 0;

}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
/**
*   author: j o s e m a g o
*   date:
**/
using namespace std;
#pragma GCC optimize ("Ofast")
#define f first
#define s second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"

typedef double db;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;
const int JJJ = 100009;




int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

    ios_base::sync_with_stdio(0); cin.tie(0);

    int N,k;
    cin >> N >> k;
    vector<int>h(N+k+1);
    for(int i = 0;i < N;i++){
        cin >> h[i];
    }
    vector<int>dp(N+k+1,INT_MAX);
    dp[0] = 0;
    for(int i = 1;i < k;i++) dp[i] = abs(h[i]-h[0]);
    for(int i = k;i < N;i++){
        for(int j = 1;j <= k;j++){
            dp[i] = min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
        }
    }

//    for(int i = 0;i < N;i++) cerr<<dp[i]<<" ";
    cout<<dp[N-1];




    return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	T := make(map[string]bool)
	ANS := 0
	for i := 0; i < N; i++ {
		var S string
		fmt.Scan(&S)
		if _, ok := T[S]; !ok {
			ANS += 1
			T[S] = true
		}
	}
	fmt.Println(ANS)
}


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

signed main()
{
	double N, M, D;
	cin >> N >> M >> D;
	cout << setprecision(7);
	if (D == 0)
		cout << (M-1) * 1/N << endl;
	else
		cout << (M-1) * ((N-2*D)*2/N + 2*D/N) / N << endl;
}


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

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {

            // ARC061A


            var S = Console.ReadLine();
            var k = S.Count() - 1;
            long a = 0;

            for (int i = 0; i < (1 << k); i++)
            {
                var s = long.Parse(S[0].ToString());

                for (int j = 0; j < k; j++)
                {
                    // 前からjからjけた目の右側にプラスにが存在するかどうかを論理積とって判断する。
                    if ((i & (1 << j)) != 0)
                    {
                        a += s;
                        s = 0;
                    }

                    // + が存在しない場合は数字を積み上げるので１０倍し、合計に足さないで保持して次のけたの数字と連結
                    // ↑で＋されている場合は０なので単純に次けたの数値を取得しているだけ。
                    s = ((s * 10) +( long.Parse(S[j + 1].ToString())));

                }

                a += s;
            }
            Console.WriteLine(a);

            Console.ReadKey();
        }



        #region MyRegion

        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        /// <summary>
        /// 空白区切の数値を取得する
        /// </summary>
        /// <returns>The read split int.</returns>
        public static int[] ReadSplitInt()
        {
            return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }

        /// <summary>
        /// 空白区切の数値を取得
        /// </summary>
        /// <returns>The read split long.</returns>
        public static long[] ReadSplitLong()
        {
            return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        }


        public static int[][] ReadSplitIntLines(int n)
        {
            return Enumerable.Range(0, n).Select(x => ReadSplitInt()).ToArray();
        }

        public static long[][] ReadSplitLongLines(int n)
        {
            return Enumerable.Range(0, n).Select(x => ReadSplitLong()).ToArray();
        }

        public static long[][] ReadSplitLongLines(long n)
        {
            var ret = new List<long[]>();
            for (long i = 0; i < n; i++)
            {
                ret.Add(ReadSplitLong().ToArray());
            }

            return ret.ToArray();
        }

        #endregion

    }
}


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

using namespace std;

int main(){
    int n, x;
    cin >> n >> x;
    int ans = 1, cur = 0;
    for(int i = 0; i < n; ++i){
        int tmp; cin >> tmp;
        cur += tmp;
        if(cur <= x)ans++;
    }
    cout << ans;
    return 0;

}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
#define vi vector<int>
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  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;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

struct s{
  int p,i,r;
};

//比較関数（降順）
bool cmpP(const s &a, const s &b){
  return a.p > b.p;
}

//比較関数（昇順）
bool cmpI(const s &a, const s &b){
  return a.i < b.i;
}

int main()
{

  //cout << fixed << setprecision(10);

  int n;
  string s; cin >> n >> s;
  char alphabets[26]={
    'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
  };

  rep(i,s.length()){
    int j;
    for (j=0; j<26; j++){
      if (s[i]==alphabets[j]){break;}
    }
    cout << alphabets[(j+n)%26];
  }


  return 0;
}


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

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  vector<pair<string,int>> frag = {
    {"maerd", 4}, {"remaerd", 6}, {"esare", 4}, {"resare", 5}
  };
  
  int N = s.size();
  bool b = true;
  for (int i = 0; i < N; i++) {
    if (s.substr(i,5) == "maerd" || s.substr(i,5) == "esare") i += 4;
    else if (s.substr(i,6) == "resare") i += 5;
    else if (s.substr(i,7) == "remaerd") i += 6;
    else {
      b = false;
      break;
    }
  }
  cout << (b ? "YES" : "NO") << endl;
}

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ld long double
#define int long long
const int N = 10500;

int dp[N];
void SOLVE(){
    fill(dp, dp + N, 1e18);
    int h, n;
    cin >> h >> n;
    vector <pii> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i].first >> a[i].second;
    }
    dp[0] = 0;
    for (int i = 0; i < n; i++){
        for (int sum = a[i].first; sum < N; sum++){
            dp[sum] = min(dp[sum], dp[sum - a[i].first] + a[i].second);
        }
    }
//    for (int sum = N; sum > 0; sum--){
//        for (int i = 0; i < n; i++){
//            if (sum < a[i].first) continue;
//            dp[sum] = min(dp[sum], dp[sum - a[i].first] + a[i].second);
//        }
//    }
    int ans = 1e18;
    for (int i = h; i < N; i++){
        ans = min(ans, dp[i]);
    }
    cout << ans << '\n';
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int Q = 1;
    //cin >> Q;
    while (Q--){
        SOLVE();
    }

    return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
  int k, a, b;

  cin >> k;
  cin >> a >> b ;
  
  for (int i = a; i <= b; i++)
  {
    if(i % k == 0){
        cout << "OK" << endl;
        return 0;
    }
  }
  
  cout << "NG" << endl;
 
  return 0;

}

Measured memory_bytes: 3636
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        int[] d = new int[n];
        Map<Integer, Integer> red = new TreeMap<>();
        Map<Integer, Integer> blue = new TreeMap<>();
        int[] used = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            red.put(a[i], b[i]);
        }
        for (int i = 0 ; i < n ; i++) {
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
            blue.put(c[i], d[i]);
        }
        int count = 0;
        for (Entry<Integer,Integer> entry : blue.entrySet()) {
            int bx = entry.getKey();
            int by = entry.getValue();
            int maxY = -1;
            int index = -1;
            for (int i = 0 ; i < n ; i++) {
                int rx = a[i];
                int ry = b[i];
                if (bx > rx && by > ry && used[i] == 0 && maxY < ry) {
                    maxY = ry;
                    index =i;
                }
            }
            if (index >= 0) {
                count++;
                used[index] = 1;
            }
        }
        System.out.println(count);


    }

}

Measured memory_bytes: 21844
N,M = list(map(int,input().split()))
x = []
y = []
red = [0 for i in range(N)]
mas = [1 for i in range(N)]
red[0] = 1

for i in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    mas[x] -= 1
    mas[y] += 1
    if red[x] == 1:
        if red[y] == 0:
            red[y] = 1
        if mas[x] == 0:
            red[x] = 0

print(sum(red))

        
    

Measured memory_bytes: 4656
#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>;

vector<int> x(10), y(10);

double dist (int i, int j) {
    double dx = x.at(i) - x.at(j);
    double dy = y.at(i) - y.at(j);
    return pow(dx*dx + dy*dy, 0.5);
}

int main() {
    int n;
    cin >> n;
    
    for (int i = 1; i <= n; ++i) cin >> x.at(i) >> y.at(i);
    double sum = 0.0;
    vector<int> v(n);
    rep(i,n) v.at(i) = i + 1;
    
    do {
        for (int i = 0; i < n - 1; ++i) sum += dist(v.at(i), v.at(i+1));
    } while (next_permutation(v.begin(), v.end()));

    int factorial = 1;
    for (int i = 1; i <= n; ++i) factorial *= i;
    cout << std::fixed << std::setprecision(15);
    cout << sum / factorial << endl;

    return 0;
}

Measured memory_bytes: 4224
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
template<class T> struct RollingHash{
    using ull=unsigned long long int;
    const ull M=(1ull<<61)-1;
    const ull mask30 = (1ull << 30) - 1;
    const ull mask31 = (1ull << 31) - 1;
    const ull mask61 =M;
    vector<ull> hash,pows;
    ull base;

        // mod 2^61-1
    ull cal_mod(ull x){
        ull xu=(x>>61);
        ull xd=(x&mask61);
        ull res=xu+xd;
        if(res>=M)res-=M;
        return res;
    }

    //a*b mod 2^61-1
    ull mul(ull a,ull b){
        ull au=(a>>31),bu=(b>>31);
        ull ad=(a&mask31),bd=(b&mask31);
        ull mid=ad*bu+au*bd;
        ull midu=(mid>>30);
        ull midd=(mid&mask30);
        return cal_mod(au*bu*2+midu+(midd<<31)+ad*bd);
    }


    RollingHash(const T &a,ull base):hash(a.size()+1,0),pows(a.size()+1,1){
		for(int i = 0; i <int (a.size()); i++) {
            pows[i + 1] =mul(pows[i], base);
            hash[i + 1] =cal_mod(mul(hash[i], base) + ull(a[i]));
            if(hash[i+1]>=M)hash[i+1]-=M;
		}
    }
    //[b1,b1+len]と[b2,b2+len]が一致するかどうか
    bool match(int b1, int b2,int len){
        ull h1 = cal_mod(hash[b1+len]+M-mul(hash[b1], pows[len]));
        ull h2 = cal_mod(hash[b2 + len]+M-mul(hash[b2],pows[len]));
        return (h1 == h2);
    }
    //[l,l+len]のハッシュ値
    ull get(int l, int len){
        return cal_mod(hash[l+len] + M - mul(hash[l], pows[len]));
    }
};
constexpr int Hash_Num=2;
struct base_t{
    int use[Hash_Num];
    int &operator[](int i){return use[i];}
    base_t(){
        mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
        for(int i=0;i<Hash_Num;i++)use[i]=rnd()%10000;
    }
}bases;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    RollingHash<string> rh(s,bases[0]);
    int l=0,r=n/2+1,mid;
    while(r-l>1){
        int mid=(l+r)/2;
        map<unsigned long long,int> mp;
        bool ok=false;
        for(int i=0;i<n-mid+1;i++){
            unsigned long long val=rh.get(i,mid);
            if(mp.count(val)){
                if(i-mp[val]>=mid)ok=true;
            }else{
              mp[rh.get(i,mid)]=i;
            }
        }
        if(ok)l=mid;
        else r=mid;
    }
    cout<<l<<"\n";
}

Measured memory_bytes: 4028
#include<stdio.h>
 int  main(){
 	int a, b, c;
 	scanf("%d",&a);
 	scanf("%d",&b);
 	scanf("%d",&c);
 	if (b-a==c-b) {
 		printf("YES");
 	}
 	else {
 		printf("NO");
	 }	
	 return 0;
 }

Measured memory_bytes: 128
import java.util.Scanner;

//0571
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray(), t = "JOI".toCharArray();
        int n = s.length, p = 0, max = 0;
        while (p < n) {
            if (s[p] == t[0]) {
                int[] c = new int[3];
                for (int i = 0; i < 3; i++) {
                    while (p < n && s[p] == t[i]) {
                        c[i]++;
                        p++;
                    }
                }
                max = Math.max(max, c[0] >= c[1] && c[2] >= c[1] ? c[1] : 0);
            } else {
                p++;
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 55404
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl '\n'
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    ll N;
    cin >> N;
    vector<ll> p(N,0);
    for(ll i=0;i<N;++i)cin>>p[i];
    vector<bool> check(101,0);
    for(ll i=0;i<N;++i)check[p[i]]=1;
    ll Min=INF;
    ll ans;
    for(ll i=-100;i<200;++i){
        if(0<=i&&i<101&&check[i])continue;
        if(chmin(Min,llabs(X-i))){
            ans=i;
        }
    }prt(ans)

    return 0;
}


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

int gcd(int a, int b){
    if(a < b){
        int tmp = a;
        a = b;
        b = tmp;
    }
    int r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main(){

    int K;
    cin >> K;
    int sum = 0;
    for (int i = 1; i <= K; i++){
        for (int j = 1; j <= K; j++){
            for (int k = 1; k <= K; k++){
                sum += gcd(gcd(i, j), k);
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3624
Sa=list(input())
Sb=list(input())
Sc=list(input())
S=Sa.pop(0)
Win="A"
while(S!=""):
  if(S=="a"):
    S=""
    if(len(Sa)!=0):
    	S=Sa.pop(0)
    Win="A"
  elif(S=="b"):
    S=""
    if(len(Sb)!=0):
	    S=Sb.pop(0)
    Win="B"
  elif(S=="c"):
    S=""
    if(len(Sc)!=0):
    	S=Sc.pop(0)
    Win="C"
print(Win)


Measured memory_bytes: 3188
#include<iostream>
#include<utility>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 3 * 1e5 + 3;

bool is_visited[MAX_N];
vector<int> graph[MAX_N];
int dist[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int u, v;
    for (int i = 0; i < M; i++) {
        cin >> u >> v;
        u--, v--;
        graph[u * 3].push_back(v * 3 + 1);
        graph[u * 3 + 1].push_back(v * 3 + 2);
        graph[u * 3 + 2].push_back(v * 3);
    }
    int S, T;
    cin >> S >> T;
    S--, T--;
    for (int i = 0; i < 3 * N; i++) {
        dist[i] = -1;
    }
    queue<P> Q;
    Q.push(P(S * 3, 0));
    while (!Q.empty()) {
        P now = Q.front();
        Q.pop();
        int node = now.first;
        int cost = now.second;
        if (is_visited[node]) continue;
        is_visited[node] = true;
        dist[node] = cost;
        for (int i = 0; i < graph[node].size(); i++) {
            Q.push(P(graph[node][i], cost + 1));
        }
    }
    if (dist[T * 3] < 0) cout << -1 << endl;
    else cout << dist[T * 3] / 3 << endl;
    return 0;
}

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

void solve(){
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++){
      cin>>h[i];
  }
  int dp[n];
  dp[0] = 0;
  dp[1] = abs(h[0]-h[1]);
  for(int i=2;i<n;i++){
      dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1];
}


int main(){
  solve();
}

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

typedef long long LL;
int main() {
    long long int n; cin >> n;
    int a = 1, b;
    int ans , f;

    int sqrtn = sqrt(n);
    b = n;
    
    /*
    for (long long int i = 1;i <= n; i++) {
        if(n % i == 0) {
            b = n / i;
        }
    }
    */
    for (LL i = 1; i <= sqrtn; i++) {
    if (n % i == 0) {
      b = n / i;
    }
  }
    int rea = 0;

    cout << int(log10(b)) + 1 << endl;
    //cout << log10(b) + 1 << endl;
    //cout << int(log10(10000)) << endl;
}

Measured memory_bytes: 256
l, r = map(int, input().split())

ans = 1e20
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        ans = min(ans, (i * j) % 2019)
        if ans == 0:
            break
    if ans == 0:
        break
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <string>
#include <set>
#include <vector>

using namespace std;

int n,q;
string str;
vector<pair<char, char> > req;

int judge(int x){
	for(auto &p: req){
		if(str[x] == p.first){
			if(p.second == 'L'){
				x--;
				if(x == -1)return 1;
			}else{
				x++;
				if(x == n)return -1;
			}
		}
	}
	return 0;
}

int main()
{
	cin >> n >> q;
	cin >> str;
	
	for(int i = 0 ; i < q; i++){
		char X;
		cin >> X;
		char lr;
		cin >> lr;
		req.push_back(make_pair(X, lr));
	}
	
	int l = 0, r = n;
	int m = (l + r) / 2;
	while(1){
		if(judge(m) > 0){
			l = m;
		}else{
			r = m;
		}
		m = (l + r) / 2;
		if(r - l == 1){
			break;
		}
	}
	//cout << r << endl;
	int start = r;
	
	l = 0, r = n;
	m = (l + r) / 2;
	while(1){
		if(judge(m) < 0){
			r = m;
		}else{
			l = m;
		}
		m = (l + r) / 2;
		if(r - l == 1){
			break;
		}
	}
	cout << r - start << endl;
}

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

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

use std::collections::*;

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

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

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

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

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

    let mut A = scan.word::<i64>();
    let B = scan.word::<i64>();
    let mut C = scan.word::<i64>();
    let D = scan.word::<i64>();

    let takahashi_win;

    loop {
        // takahashi
        C -= B;
        if C <= 0 {
            takahashi_win = true;
            break;
        }

        // aoki
        A -= D;
        if A <= 0 {
            takahashi_win = false;
            break;
        }
    }

    println!("{}", if takahashi_win { "Yes" } else { "No" });
}


Measured memory_bytes: 2132
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
import math
eps = 1e-12

def calc_intersection_points(circle0, circle1):
    x0, y0, r0 = circle0
    x1, y1, r1 = circle1
    d = math.hypot(x0 - x1, y0 - y1)
    if d > r0 + r1 or d < abs(r0 - r1):
        return []
    ret = []
    if r0 + r1 == d:
        a = r0
        h = 0.0
    else:
        a = (r0**2 - r1**2 + d**2) / (2.0 * d)
        h = math.sqrt(r0**2 - a**2)
    x2 = x0 + a * (x1 - x0) / d
    y2 = y0 + a * (y1 - y0) / d
    x3 = x2 + h * (y1 - y0) / d
    y3 = y2 - h * (x1 - x0) / d
    ret.append((x3, y3))
    if h == 0:
        return ret
    x4 = x2 - h * (y1 - y0) / d
    y4 = y2 + h * (x1 - x0) / d
    ret.append((x4, y4))
    return ret


n, k = map(int, input().split())
niku = []
for _ in range(n):
    x, y, c = map(int, input().split())
    niku.append((x, y, c))

l = 0.0; r = 10**8
for _ in range(64):
    mid = (l + r) / 2.0
    circles = []
    for x, y, c in niku:
        circles.append((x, y, mid / c))
    points = []
    for i in range(n):
        for j in range(i+1, n):
            points += calc_intersection_points(circles[i], circles[j])
    for x, y, _ in niku:
        points.append((x, y))
    cooked = 0
    for x, y in points:
        ret = 0
        for cx, cy, cr in circles:
            if math.hypot(x - cx, y - cy) <= cr + eps:
                ret += 1
        if ret > cooked:
            cooked = ret
    if cooked >= k:
        r = mid
    else:
        l = mid
print(l)

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

#define int long long
#define rep(i, n) for (int i = 0; (int) (i) < n; i++)
#define reps(i, n) for (int i = 1; (int) (i) <= n; i++)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << x << endl
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) { return b < a && (a = b, true); }
struct SetUp { SetUp() { cout << fixed << setprecision(20); }; } setUp;

int N, M;
int a[1100], b[1100], c[1100][22];
int dp[1100][4400];
signed main() {
    cin >> N >> M;
    rep(i, 1100)rep(j, 4400) { dp[i][j] = 1e11; }
    dp[0][0] = 0;
    rep(i, M) {
        cin >> a[i] >> b[i];
        int C = 0;
        rep(j, b[i]) {
            cin >> c[i][j];
            C |= bit(c[i][j] - 1);
        }
        rep(j, 4400) {
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i + 1][j | C], dp[i][j] + a[i]);
        }
    }
    int ans = dp[M][bit(N) - 1];
    cout << (ans == 1e11 ? -1 : ans) << endl;

}

Measured memory_bytes: 38272
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a=cin.ReadInt;
          	var b=a/100;
          	var c=(a-b*100)/10;
          	var d=a-b*100-c*10;
          	WriteLine(b+c+d);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
#コンビネーション
def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

N = 10 ** 6  # N は必要分だけ用意する
mod = pow(10, 9) + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

import math
x, y = map(int,input().split())

if (2 * y - x) % 3 != 0 and (2 * x - y) % 3 != 0:
    print(0)
else:
    a = (2 * y - x) // 3
    b = (2 * x - y) // 3
    ans = cmb(a+b, a)
    print(ans % (pow(10, 9) + 7))


Measured memory_bytes: 122172