akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const ll mod = 1000000007;
ll inv[20000100];
ll FactorialInv[20000100];
ll Factorial[20000100];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    const int MAX = 20000002;
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

ll f(ll H, ll W, ll K) {
    if(H < 0 or W < 0 or K < 0) return 0;
    ll ret = 0;
    for(ll k = 0; k <= K; k++) {
        ll tmp = 1;
        tmp *= combination(H, k);
        tmp *= combination(W, K - k);
        tmp %= mod;
        tmp *= combination(K, k);
        tmp %= mod;
        tmp *= Factorial[k];
        tmp %= mod;
        tmp *= Factorial[K-k];
        tmp %= mod;
        ret += tmp;
        ret %= mod;
    }
    return ret;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W, K;
    cin >> H >> W >> K;
    init_combination();
    ll ans = 0;
    ll Total = f(H, W, K);
    ll One = f(H - 1, W, K - 1);
    One *= H;
    One %= mod;
    ll Two = f(H - 2, W, K - 2);
    Two *= H;
    Two %= mod;
    Two *= (H - 1);
    Two %= mod;
    ll tmp = K * (K + 3) % mod;
    cerr << Total << " " << One << " " << Two << endl;
    tmp *= beki(2, mod - 2);
    tmp %= mod;
    tmp *= Total;
    tmp %= mod;
    cerr << tmp << endl;
    ans += tmp;
    tmp = beki(K, 3) * beki(3, mod - 2) % mod;
    tmp -= K * beki(3, mod - 2);
    tmp %= mod;
    tmp += mod;
    tmp %= mod;
    cerr << tmp << endl;
    tmp *= (One - Two);
    tmp %= mod;
    tmp += mod;
    tmp %= mod;
    ans += tmp;
    cout << ans % mod << endl;
    return 0;
}

Measured memory_bytes: 468992
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n]; for(int i=0;i<n;i++)a[i]=0;
	for(int i=0;i<n;i++)cin>>a[i];
	
	sort(a, a+n);
	int ans = a[n-1] - a[0];

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int h,w,a,b;
ll f[1000010];

ll powmod(ll x, ll n){
	ll s=1; int i=0;
	while(n>>i){
		if((n>>i)&1) s=(s*x)%MOD;
		x=(x*x)%MOD; i++;
	}
	
	return s;
}

ll comb(ll n, ll m){
	return (f[n]*powmod((f[m]*f[n-m])%MOD,MOD-2))%MOD;
}

int main(){
	cin >> h >> w >> a >> b;
	
	ll pos=0; f[0]=1;
	REP(i,1,1000010) (f[i]=f[i-1]*i)%=MOD;
	REP(i,b,w) (pos+=comb(i+h-a-1, h-a-1)*comb(w-i+a-2,w-i-1))%=MOD;
	
	
	cout << pos << endl;
	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
long long n, x, a[1000000];
int main() {
	cin >> n >> x; long long sum = 0, cnt;
	for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; }
	if (a[0] >= x)a[0] = x;
	for (int i = 1; i < n; i++) {
		a[i] = min(a[i], x - a[i - 1]);
	}
	for (int i = 0; i < n; i++)cnt += a[i];
	cout << sum - cnt << endl;
	return 0;
}

Measured memory_bytes: 1024
package main


import (
    "fmt"
)

func main() {
  var A,B,C int
  var count int = 0
  var R int
  var k int

  fmt.Scan(&A,&B)

  for  i := A; i <= B ; i++ {
    C = i
    R = 0
    k = 1
    for j := 10000; j >= 1; j /=10 {
      R  += (C/j)*k
      C  = C%j
      k *= 10

    }
    if i == R {
      count++
    }

    //fmt.Println("i:",i)
    //fmt.Println("R:",R)
    //fmt.Println("")

  }

  fmt.Println(count)
}


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

typedef long long ll;
typedef unsigned long long ull;
const int maxn=2e5+5;
int f[maxn];
int n,m;
int res[maxn];
int find_(int x)
{
    return x==f[x]? x:f[x]=find_(f[x]);
}

void slove(){
    cin>>n>>m;
    for(int i=0;i<=n;i++)
    {
        f[i]=i;
        res[i]=1;
    }
    int max_=-1;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        int max_=-1;
        int fx=find_(x);
        int fy=find_(y);
        if(fx!=fy)
        {
            f[fx]=fy;
            res[fy]+=res[fx];
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(res[i]>max_)
            max_=res[i];
    }
    cout<<max_;


}

int main() {
    int _=1;
//    cin>>_;
    while (_--){
        slove();
    }
    return 0;
}

Measured memory_bytes: 5144
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if(n%10==9||n/10==9) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int A[100000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key) return 1;
    if (key > A[mid])
      left = mid + 1;
    else if (key < A[mid])
      right = mid;
  }
  return 0;
}

int main() {
  int i, q, k, sum = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &k);
    if (binarySearch(k)) sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 3616
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;


template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
	// printElems(&a[0], &a[n]);　みたいな感じで使う。
	void printElems(const int* begin, const int* end)
	{
		for (const int* p = begin; p != end; ++p) {
			cout << *p << ' ';
		}
		cout << endl;
	}
}

#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<n+1; i++)
#define repr(i,n) for(ll i=n-1; i>=0; i--)
#define repr1(i,n) for(ll i=n; i>0; i--)
#define FOR(i,j,n) for(ll i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(ll i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<ll,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll BIG = 1LL<<60;
const string yes = "Yes";
const string no = "No";

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


ll a[1000005];
ll er[1000005];

int main(){
	ll n;
	cin >> n;
	rep(i,n) cin >> a[i];

	ll tmp = a[0];
	rep1(i,n-1){
		tmp = gcd(tmp,a[i]);
		if(tmp == 1) break;
	}
	if (tmp!=1){
		prints("not coprime");
		return 0;
	}

	rep(i,n){
		er[a[i]]++;
	}
	for(int i = 2; i < 1000005; i++){
		ll cnt = 0;
		ll tt = i;
		while(tt < 1000005){
			cnt+=er[tt];
			tt+=i;
		}
		if(cnt>1){
			prints("setwise coprime");
			return 0;
		}
	}
	prints("pairwise coprime");






	return 0;
}




Measured memory_bytes: 19120
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

// 最大公約数
int gcd(int a, int b) {
  while (b) {
    int c = a % b;
    a = b; b = c;
  }
  return a;
}

// 最小公倍数
int lcm(int a, int b) {
  return a / gcd(a,b) * b;
}

int A,B,C,D;

int calc(int x, int k) {
  return x/k;
}

int calc2(int x) {
  return x - calc(x,C) - calc(x,D) + calc(x,lcm(C,D));
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> A >> B >> C >> D;
  cout << (calc2(B) - calc2(A-1)) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        // 入力(A B)
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sum = a + b;

        System.out.println((sum <= 9) ? sum : "error");
        sc.close();
    }    
}

Measured memory_bytes: 35716
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

bool judge(const ull K, const ull T, const vector<uint>& A, const vector<uint>& F) {
	
	ull sum = 0;
	for(ull i = 0; i<A.size(); i++) {
		ull d = T / F[i];
		if (A[i] > d) {
			sum += A[i] - d;
			if (sum > K) {
				return false;
			}
		}
	}
	return true;
}

int main() {
	ull N, K;
	cin >> N >> K;
	
	vector<uint> A(N);
	ull sum = 0;
	for (uint n=0; n<N; n++) {
		cin >> A[n];
		sum += A[n];
	}
	
	if (K >= sum) {
		cout << 0;
		return 0;
	}
	
	vector<uint> F(N);
	for (uint n=0; n<N; n++) {
		cin >> F[n];
	}
	
	sort(A.begin(), A.end());
	sort(F.begin(), F.end(), greater<uint>());
	
	ull low = 0;
	ull high = (ull)A[N-1] * (ull)F[0];
	
	while (low < high) {
		ull mid = (low + high) / 2;
 
		if (judge(K, mid, A, F)) {
			high = mid;
		} else {
			low = mid + 1;
		}
	}
	
	cout << low;
	
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<int> dp(k+1);
	for(int i=0;i<=a[0];i++){
		dp[i]=1;
	}
	for(int i=1;i<n;i++){
		vector<int> newdp(k+1);
		for(int j=0;j<=k;j++){
			newdp[j]=add(dp[j],mod-(j-a[i]-1>=0?dp[j-a[i]-1]:0));
			if(j-1>=0){
				newdp[j]=add(newdp[j],newdp[j-1]);
			}
		}
		dp=newdp;
	}
	cout<<dp[k]<<endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

bool f(int a, int b){
	return a > b;
}

int main() {
	int n_cake, n_day, eat_num;
	
	std::cin >> n_cake >> n_day;
	
	std::vector<int> cakes(n_day);
	for(int i = 0; i < n_day; ++i){
		std::cin >> cakes[i];
	}
	
	std::sort(cakes.begin(), cakes.end(), f);
	cakes[0]--;
	cakes[0] = -cakes[0];
	
	while(cakes.size() != 1){
		std::sort(cakes.begin(), cakes.end(), f);
	    cakes[0]--;
	    cakes[0] = -cakes[0];
	    if(cakes[0] == 0) cakes.erase(cakes.begin());
	    if(cakes[cakes.size() - 1] < 0) cakes[cakes.size() - 1] = -cakes[cakes.size() - 1];
	}
	if(cakes[0] < 0) cakes[0] = -cakes[0];
	else cakes[0]--;
	
	std::cout << cakes[0] << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;

namespace tst
{
    class Program
    {
        public static bool Bingo(bool[] B)
        {
            /* B[]
             |0|1|2|
             |3|4|5|
             |6|7|8|
             */
            if (Tate(B)) return true;
            else if (Yoko(B)) return true;
            else if (Naname(B)) return true;
            else return false;
        }
        public static bool Tate(bool[] B)
        {
            for(int i=0; i<3; i++)
            {
                if (B[i] == true && B[i + 3] ==true && B[i + 6]==true)
                {
                    return true;
                }
            }
            return false;
        }
        public static bool Yoko(bool[] B)
        {
            for (int i = 0; i < 9; i+=3)
            {
                if (B[i] ==true && B[i + 1] ==true && B[i + 2]==true)
                {
                    return true;
                }
            }
            return false;
        }
        public static bool Naname(bool[] B)
        {
            if (B[0] == true && B[4] ==true && B[8]==true) return true;
            if (B[2] == true && B[4] == true && B[6] == true) return true;
            return false;
        }
        public static void Main()
        {
            //３＊３の配列だと正直だが、比較が大変そうなので一次で
            int[] A = new int[9];
            bool[] B = new bool[9];
            for(int i=0; i<3; i++)
            {
                string[] In = Console.ReadLine().Split(' ');
                for(int j=0; j<3; j++)
                {
                    A[(3*i)+j] = int.Parse(In[j]);
                }
            }
            int n = int.Parse(Console.ReadLine());
            for(int i=0; i<n; i++)
            {
                int k = int.Parse(Console.ReadLine());
                for(int j=0; j<9; j++)
                {
                    if (k == A[j])
                    {
                        B[j] = true;
                        break;
                    }
                }
            }
            if (Bingo(B))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, a, b, ans, curcomp, ss;
vi adj[200005];

int main() {
	fastio; cin >> n;
	FOR(i, 1, n-1) {
		cin >> a >> b;
		if (b < a) adj[a].pb(b);
		if (a < b) adj[b].pb(a);
	}
	ans = 1; curcomp = 1; ss = 1;
	FOR(i, 2, n) {
		ll cur = i-1;
		for (auto it:adj[i]) cur -= it;
		ss += cur + 1;
		ans += ss;
	}
	cout << ans;
}


Measured memory_bytes: 14472
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)


const int MAX_N = (int) 1e5;
int N, X, x[MAX_N];

void solve() {
    if (N == 1) {
        cout << max(x[0] - X, X - x[0]) << endl;
        return;
    }
    sort(x, x + N);
    int diff = INF;
    int diffs[N - 1];
    FOR(i, 0, N - 1) {
        diff = min({x[i + 1] - x[i], diff, abs(X - x[i]), abs(X - x[i + 1])});
        diffs[i] = x[i + 1] - x[i];
    }
    REPR(d, diff) {
        REP(i, N - 1) {
            if (diffs[i] % (d + 1) != 0) break;
            if (i == N - 2) {
                cout << d + 1 << endl;
                return;
            }
        }
    }
}

int main() {
    cin >> N >> X;
    REP(i, N) cin >> x[i];
    solve();
    return 0;
}

Measured memory_bytes: 1024
import bisect
from collections import deque

N = int(input())
a = []
for _ in range(N):
  a.append(int(input()))

d = deque()
d.append(a[-1])
for i in reversed(range(N-1)):
	if a[i] >= d[-1]:
		d.append(a[i])
	else:
		index = bisect.bisect_right(d,a[i])
		d[index] = a[i]

print(len(d))


Measured memory_bytes: 8060
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<(n); i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  string S;
  cin >> S;
  ULL K;
  cin >> K;

  REP(S.size()) {
    if(S[i] == '1' && K > (i+1)) {
      continue;
    }
    cout << S[i] << endl;
    break;
  }
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353LL
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
ll gcd(ll a, ll b); 
  
// To compute x raised to power y under modulo m 
ll power(ll x,ll y, ll m); 
  
// Function to find modular inverse of a under modulo m 
// Assumption: m is prime 
ll modInverse(ll a, ll m) 
{ 
    return power(a, m-2, m);  
} 
  
// To compute x^y under modulo m 
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; 
} 
  
// Function to return gcd of a and b 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b%a, a); 
} 
int main()
{
	ll ans,h,t;
	cin>>h;
	ans=0;
	t=1;
	//c=1;
	while(h!=0)
	{
		h=h/2;
		ans=ans+t;
		t=t*2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N, K;
int a[100000+10];
int S[100000+10];
int positiveS[100000+10];

signed main(void) {
    cin>>N>>K;
    int positive_sum=0;
    rep(i, N) {
        cin>>a[i];
        if (i==0) {
            S[i]=a[i];
            if (a[i]>0) positiveS[i]=a[i];
            else positiveS[i]=0;
        } else {
            S[i]=S[i-1]+a[i];
            if (a[i]>0) positiveS[i]=positiveS[i-1]+a[i];
            else positiveS[i]=positiveS[i-1];
        }
    }

    int ans=0;
    REP(i, 0, N-K) {
//        cout<<"i:"<<i<<endl;
        //白で最後潰す場合
        int positive_sum_in_window = positiveS[K+i-1]-positiveS[i-1];
        int white = positiveS[N-1]-positive_sum_in_window;
//        cout << "positive_sum_in_window:" << positive_sum_in_window << endl;
//        cout << "white:" << white << endl;
        //黒で最後潰す場合
        int window_sum=S[K+i-1]-S[i-1];
        int black= white+window_sum;
//        cout << "window_sum:" << window_sum << endl;
//        cout << "black:" << black << endl;
        ans=max(ans, max(white, black));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
#define Maxn 1000010
char ch[Maxn]; 
int a[Maxn];
inline int c(int i,int j){
	if(i>=j)return 1; 
    else return 0;
}
inline int C(int i,int j){
	if(i==0)return 1;
	return c(i%2,j%2)*C(i/2,j/2);
} 
int main(){
	scanf("%d",&n);
	scanf("%s",ch+1);
	for(int i=1;i<=n;++i)a[i]=ch[i]-'0';
	n--;
	for(int i=1;i<=n;++i)a[i]=max(a[i+1],a[i])-min(a[i+1],a[i]);
	int ans=0;
	for(int i=1;i<=n;++i)ans+=C(n-1,i-1)*a[i];
	if(ans&1){
		puts("1");
		return 0;
	}
	for(int i=1;i<=n;++i)
	    if(a[i]==1){
			puts("0");
			return 0;
	    }else a[i]/=2;
	ans=0;
	for(int i=1;i<=n;++i)ans+=C(n-1,i-1)*a[i];
	if(ans&1){
		puts("2");
	}else puts("0");
	return 0;
}

Measured memory_bytes: 5248
#include <stdio.h>
#include <math.h>


int main(void)
{
    int n;
    scanf("%d", &n);
    int h[n];
    for(int i=0; i < n; i++){
        scanf("%d", &h[i]);
    }

    int max = h[0];
    int cnt = 1;
    for(int i=1; i < n; i++){
        if(max <= h[i]){
            cnt++;
            max = h[i];
        }
    }


    printf("%d\n", cnt);
    
    return 0;
} 



Measured memory_bytes: 128
#include<stdio.h>

int main(){

	char hitachi[11];
	scanf("%s",&hitachi);
	//printf("%s\n",hitachi);

	int i,judge=1;

	for(i=0;hitachi[i]!='\0';i=i+1){
		if(hitachi[i]=='h'){
			if(hitachi[i+1]=='i'){
				i++;
			}else{
				judge = 0;
				break;
			}
		}else{
			judge = 0;
			break;
		}
	}

	if(judge==1){
		printf("Yes");
	}else{
		printf("No");
	}

	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
	int i=0,num[10000]={},n;
	do{
		scanf("%d",&n);
		if(n!=0){
			num[i] = n;
			i++;
		}
	}while(n!=0);
	
	for(n=0;n<i;n++){
		printf("Case %d: %d\n",n+1,num[n]);
	}
	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include<map>
using namespace std;
typedef long long ll;
ll n,s[26],d[365][26],t[365],ans;
map<ll,ll> mp;
int main(void){
    cin>>n;
    for(int i=0;i<26;i++)mp[i]=0;
    for(int i=0;i<26;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<26;j++){
            cin>>d[i][j];
        }
    }
    for(int i=0;i<n;i++){cin>>t[i];}
    for(int i=0;i<n;i++){
        ans+=d[i][t[i]-1];
        mp[t[i]-1]=i+1;
        for(int j=0;j<26;j++){
            ans-=s[j]*(i+1-mp[j]);
        }
        cout<<ans<<endl;
    }
}


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

template <typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n = 0) : n(n), d(n + 1) {}
  void add(int i, T x = 1) {
    for (i++; i <= n; i += i & -i) d[i] += x;
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i & -i) x += d[i];  // 最下位bitの加算
    return x;
  }
  T sum(int l, int r) { return sum(r - 1) - sum(l - 1); }
};

int main() {
  ll n, d, a, ans = 0;
  cin >> n >> d >> a;
  vector<pair<ll, ll>> p(n);

  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());

  BIT<ll> bit(n + 1);

  rep(i, n) {
    ll x = p[i].first;
    ll h = p[i].second;
    h -= bit.sum(i);
    if (h <= 0) continue;
    ll num = (h + a - 1) / a;
    ans += num;
    ll damage = num * a;
    bit.add(i, damage);
    // ll rx = min(x + d * 2, (ll)1e10);
    ll rx = x + d * 2;
    bit.add(
        upper_bound(p.begin(), p.end(), pair<ll, ll>(rx + 1, -1)) - p.begin(),
        -damage);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8012
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> S;
  unordered_map<char, ll> mp;
  rep(i, S.length()) mp[S[i]]++;
  for (auto itr = mp.begin(); itr != mp.end(); itr++){
    if (itr->second != 2){
      cout <<"No" << endl;
      return 0;
    }
  }
  cout <<"Yes" << endl;
  return 0;
  
}


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

typedef long long int ll;

int main()
{

	ll a, b, k;
	cin >> a >> b >> k;
	a-=k;
	ll diff = 0;
	if(a < 0){
		diff = a*(-1);
		a = 0;
	}
	b-=(diff);
	if(b < 0){
		b = 0;
	}
	cout << a << " " << b << endl;

	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)

ans = ""
i = 0
for _ in range(n):
    if i > n or ans == s: break
    if s[i:i+5] == "erase":
        i += 5
        ans += "erase"
        if s[i:i+1] == "r":
            i += 1
            ans += "r"
    elif s[i:i+5] == "dream":
        i += 5
        ans += "dream"
        if s[i:i+3] == "era": continue
        elif s[i:i+2] == "er":
            i += 2
            ans += "er"
print("YES" if ans == s else "NO")

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

using namespace std;

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

int N;
ll a[100];
vector<P> h;

int ret_index(int x, int index_option){
    int y;
    if (index_option == 1){
        y = x;
    }
    else{
        y = N - x - 1;
    }
    return y + 1;
}

int main(){
    cin >> N;

    ll mi = 10000000, mi_index = -1;
    ll ma = -10000000, ma_index = -1;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        if(mi > a[i]) {
            mi = a[i];
            mi_index = i;
        }
        if(ma < a[i]) {
            ma = a[i];
            ma_index = i;
        }
    }

    int index_option = 1;
    if(-mi > ma){
        for(int i = 0; i < N; i++){
            a[i] = -a[i];
        }
        for(int i = 0; i < N / 2; i++){
            swap(a[i], a[N-i-1]);
        }
        ma = -mi;
        ma_index = N - mi_index - 1;
        index_option = -1;
    }

    int s = 0;
    for(int i = 1; i < N; i++){
        if(a[i] >= a[i-1])  continue;

        a[i] += ma;
        h.emplace_back(P(ret_index(i, index_option), ret_index(ma_index, index_option)));
        s++;
        if(a[i] > ma){
            ma = a[i];
            ma_index = i;
        }

        if(a[i] >= a[i-1])  continue;
        a[i] += ma;
        h.emplace_back(P(ret_index(i, index_option), ret_index(ma_index, index_option)));
        if(a[i] > ma){
            ma = a[i];
            ma_index = i;
        }
        s++;
    }

    if(s > 2*N){
        exit(1);
    }
    cout << s << endl;
    for(int i = 0; i < s; i++){
        cout << h[i].second << " " << h[i].first << endl;
    }

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.next();

		int l = line.length();					// 数字の長さ
		StringBuffer src;
		int n = (int)Math.pow(2, l-1);	// 部分集合の数
		long sum = 0L;							// 答えとなる合計値
		int count;									// srcに挿入したときの文字のズレ。
		String[] temp;							// split用の配列。

//		sum = Long.parseLong(line);

		for (int i = 0; i < n; i++) {
			src = new StringBuffer(line);
			count = 0;
			for (int j = 0; j < l-1; j++) {
				if ( (i & (1 <<j)) == (1<< j) ) {
					src.insert(j+1+count, "+");
					count++;
				}
			}
			temp = src.toString().split("\\+");
			for (int k = 0; k < temp.length; k++) {
				sum += Long.parseLong(temp[k]);
			}
		}

		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#define PI 3.14159265359
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	string s;
	cin >> s;
	bool can = true;
	bool c = false;
	if (s[0] == 'A'){
		rep(i,1,s.size()-1) {
			if (s[i] >= 'a' && s[i] <= 'z') continue;
			else if ((i>1 && i<s.size()-1) && s[i] == 'C') {
				if (c) { can = false; break; }
				c = true;
			}
			else {can = false;break;}
		}
	}
	else {
		can = false;
	}
	if (can && c) cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k, c, d[200005] = {}, e[200005] = {};
    string s;
    vector<pii> a, b;
    cin >> n >> k >> c >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'o' && i < c + 1) d[i] = 1;
        else if (s[i] == 'o' && i >= c + 1) d[i] = d[i - c - 1] + 1;
        else d[i] = d[i - 1];
    }
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'o' && i + c + 1 >= n) e[i] = 1;
        else if (s[i] == 'o' && i + c + 1 < n) e[i] = e[i + c + 1] + 1;
        else e[i] = e[i + 1];
    }
    //for (int i = 0; i < n; i++) cout << d[i] << ' ' << e[i] << '\n';
    for (int i = 0; i < n; i++) if (s[i] == 'o' && d[i] + e[i] - 1 >= k) {
        int z = 0;
        if (i) z += d[i - 1];
        if (i + 1 < n) z += e[i + 1];
        if (z < k) cout << i + 1 << '\n';
    }
}


Measured memory_bytes: 5260
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
#define BIG 2000000007
 
#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;
 
typedef struct {
	int a;
	int b;
} hw;
 
#define N_MAX 100000
#define M_MAX 100000
 
ull n, m, k;
ull h, w;
// ull a[N_MAX];
// ull b[N_MAX];
// ull dp[N_MAX][M_MAX + 1];
// char s[N_MAX + 1];
// char t[N_MAX + 1];
hw arr[N_MAX];
 
void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

ull divide(ull a, ull b){
	ull x = MOD - 2;
	ull ans = 1;
	while (x) {
		if (x & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		x /= 2;
	}
	return (a * ans) % MOD;
}
 
int digits(ull x){
	int i = 1;
	while (x >= 10) {
		x /= 10;
		i++;
	}
	return i;
}
 
int min(ull x, ull y){
	return (x < y) ? x : y;
}
 
ull gcd(ull x, ull y){
	if (x < y) {
		return gcd(y, x);
	} else if (y == 0) {
		return x;
	} else {
		return gcd(y, x % y);
	}
}
 
ull bitpow(ull a, ull x){
	ull result = 1;
	while (x) {
		if (x & 1) {
			result *= a;
			result %= MOD;
		}
		x /= 2;
		a = (a * a) % MOD;
	}
	return result;
}

int comp(const void *left, const void *right){
	if (((hw*)left)->a < ((hw*)right)->a) {
		return -1;
	} else if (((hw*)left)->a > ((hw*)right)->a) {
		return +1;
	} else {
		return 0;
	}
}
  
ull solve(){
	int i, j;
	ull rank = 0;

	qsort(arr, n, sizeof(hw), comp);
	for (i = 0; i < n; i++) {
		rank += (ull)arr[i].b;
		if (rank >= k) break;
	}
	printf("%d\n", arr[i].a);
 
	return 0;
}
 
int main(void){
	int i, j;
	int x = 0;
 
	scanf("%llu%llu", &n, &k);

	for (i = 0; i < n; i++) {
		scanf("%d%d", &arr[i].a, &arr[i].b);
	}

	solve();
 
	return 0;
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int get(int n) {
    if (n == 2) {
        return 0;
    } else if (n == 4 || n == 6 || n == 9 || n == 11) {
        return 1;
    } else {
        return 2;
    }
}

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b >= 10) {
        cout << "error\n";
    } else {
        cout << a + b << endl;
    }
}


Measured memory_bytes: 256
n,k = map(int,input().split())
A = sorted(list(map(int,input().split())))
F = sorted(list(map(int,input().split())))[::-1]
o = []
for a,f in zip(A,F):
    o.append(a*f)
ok = max(o)    
ng = -1

while ok - ng > 1:
    mid = (ok+ng)//2
    k1 = 0
    for i in range(n):
        k1 += max( 0 , A[i]- mid//F[i])
    if k1<= k:
        ok = mid
    else:
        ng = mid
print(ok)


Measured memory_bytes: 126204
#include <iostream>
using namespace std;
string s, k="ACGT";
int c, mx;
int main() {
	cin>>s;
	for(int i=0; s[i]; i++) {
		if(k.find(s[i])<4) c++, mx = max(mx, c);
		else c = 0;
	}
	cout<<mx;
 	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

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

    vector<int> hs(n);

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

    int idx = -1;
    double diff = std::numeric_limits<double>::infinity();
    for(int i = 0; i < n; i++) {
        double temp = t - hs[i]*0.006;
        double new_diff = abs(a-temp);
        if (new_diff < diff) {
            idx = i;
            diff = new_diff;
        }
    }

    cout << idx+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m; cin >> n >> m;
	if (n == m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    bool ok=true;
    for(int i=0; i<n; i++){
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0) ok=false;
        }
    }
    if(ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

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

using namespace std;

#define MOD 1000000007
#define N 100005
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
    ll a, inti, ans; 
	ld b;
    cin>>a>>b;
    inti = (b * 100) + 0.5;
    ans = a * inti;
    ans = ans / 100;
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3748
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <iostream>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

const int BIT_MAX = 100010;
const LL mod = 1e9 + 7;

template <class T> class BIT {
    T x[BIT_MAX + 1];

public:

    BIT() {
        fill(x, x + BIT_MAX + 1, 0);
    }

    void add(int a , T b) {
        ++a;
        for(; a <= BIT_MAX ; a += a & -a) (x[a] += b) %= mod;
    }

    T get(int a) {
        ++a;
        T b = 0;
        for(; a > 0 ; a -= a & -a) (b += x[a]) %= mod;
        return b;
    }
};

int N;
LL A, B;
LL S[100010];
int ta[100010];
int tb[100010];
BIT<LL> va , vb;
int qa , qb;

int main() {
    scanf("%d%lld%lld" , &N , &A , &B);
    if(A < B) swap(A, B);
    S[0] = -A - 3;
    qa = qb = 0;
    repp(i, 1, N + 1) {
        scanf("%lld" , S + i);
        while(S[i] - S[qa + 1] >= A) ++qa;
        while(S[i] - S[qb + 1] >= B) ++qb;
        ta[i] = qa;
        tb[i] = qb;
    }
    qa = qb = 0;
    va.add(1, 1);
    vb.add(1, 1);
    repp(i, 2, N + 1) {
        int x = (vb.get(ta[i] + 1) - vb.get(qb) + mod) % mod;
        int y = (va.get(tb[i] + 1) - va.get(qa) + mod) % mod;
        if(ta[i] + 1 > qb) va.add(i , x);
        if(tb[i] + 1 > qa) vb.add(i , y);
        if(S[i] - S[i - 1] < A) qa = i - 1;
        if(S[i] - S[i - 1] < B) qb = i - 1;
    }
    printf("%lld\n" , (va.get(N) - va.get(qa) + vb.get(N) - vb.get(qb) + mod + mod) % mod);
    return 0;
}


Measured memory_bytes: 3456
import math
N = int(input())
if N == 1:
    print(0)
    exit()
div = {}
for i in range(2, int(math.sqrt(N))+1):
    while N % i == 0:
        N = N // i
        if i in div:
            div[i] += 1
        else:
            div[i] = 1
    if N == 1:
        break
if N != 1:
    div[N] = 1
ans = 0
for v in div.values():
    i = 1
    while v >= i:
        v -= i
        i += 1
        ans += 1
print(ans)


Measured memory_bytes: 9204
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    int ans = 0;
    cin >> s;

    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            ans++;
        }
    }

    cout << ans << endl;
}


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

int main() {
  int N;
  vector<string> outputs={"AC", "WA", "TLE", "RE"};
  cin >> N;
  vector<int> results(4,0);
  for (int i = 0; i < N; ++i) {
    string input;
    cin >> input;
    if (input == outputs[0]) results[0]++;
    if (input == outputs[1]) results[1]++;
    if (input == outputs[2]) results[2]++;
    if (input == outputs[3]) results[3]++;
  }
  for (int i = 0; i < 4; ++i) {
    cout << outputs[i] << " x " << results[i] << endl;
  }
  return 0; 
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;

int main(){
  int n;
  cin >> n;
  
  if(n%2==0){
    cout << n/2<<endl;
  }
  else
    cout << n/2 + 1<<endl;
  
}

Measured memory_bytes: 256