akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc075/tasks/abc075_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, K;
  cin >> N >> K;

  struct Point {
    ll x;
    ll y;
  };

  V<Point> ps(N);

  rep(i, N) {
    ll x, y;
    cin >> x >> y;
    ps[i] = {x, y};
  }

  VL xs(N);
  VL ys(N);

  rep(i, N) {
    xs[i] = ps[i].x;
    ys[i] = ps[i].y;
  }

  sort(all(xs));
  sort(all(ys));

  ll res = numeric_limits<ll>::max();

  rep(right_i, N) rep(left_i, right_i) rep(top_i, N) rep(bottom_i, top_i) {
    ll left = xs[left_i];
    ll right = xs[right_i];
    ll top = ys[top_i];
    ll bottom = ys[bottom_i];

    ll ct = 0;

    for (auto p : ps) {
      unless(left <= p.x && p.x <= right) continue;
      unless(bottom <= p.y && p.y <= top) continue;
      ct++;
    }

    if (ct >= K) chmin(res, (right - left) * (top - bottom));
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N,C;
int X[555555],V[555555];
int S[555555];

int ans;

void solve()
{
    for(int i=0;i<N;i++) S[i+1]=S[i]+V[i];
    int ma=-INF;
    for(int i=N-1;i>=0;i--)
    {
        chmax(ans,S[i+1]-X[i]);
        chmax(ans,S[i+1]-2*X[i]+ma);
        chmax(ma,S[N]-S[i]+X[i]-C);
    }
}

signed main(){
    cin>>N>>C;
    vector<int> x(N),v(N);
    for(int i=0;i<N;i++) cin>>x[i]>>v[i];

    for(int t=0;t<2;t++)
    {
        for(int i=0;i<N;i++)
        {
            X[i]=x[i];
            V[i]=v[i];
        }
        solve();
        for(int i=0;i<N;i++) x[i]=C-x[i];
        reverse(all(x));
        reverse(all(v));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    ll h, w;
    cin >> h >> w;
    if(h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    if(h%2 == 0 && w%2 == 0) {
        cout << h*w/2 << endl;
    }
    else {
        if(h%2 != 0 && w%2 != 0) {
            if(h < w) {
                cout << h*w/2+1 << endl;
            }
            else if(h > w){
                cout << h*w/2+1 << endl;
            }
            else {
                cout << h*w/2+1 << endl;
            }
        }
        else {
            cout << h*w/2 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 55555;

int main() {
    int n;
    cin >> n;
    vector<bool> primes(maxn, true);
    for (int i = 2; i < maxn; ++i) {
        if (primes[i]) {
            for (int j = i + i; j < maxn; j += i) {
                primes[j] = false;
            }
        }
    }
    vector<int> res;
    for (int i = 2; i < maxn; ++i) {
        if (primes[i] && i % 5 == 1) {
            res.push_back(i);
            if (res.size() >= n) {
                break;
            }
        }
    }
    for (int& x : res) {
        cout << x << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    string s; cin >> s;
    int k; cin >> k;
    vector<string> S;
    int p = 0, q = 0;
    while(p < s.size()){
        rep(j, k+1){
            if(p + j < s.size()){
                S.push_back(s.substr(p, j+1));
            }
        }
        p++;
    }
    sort(all(S));
    S.erase(unique(S.begin(), S.end()), S.end());
    cout << S[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 1916
#include "bits/stdc++.h"
#define rep(i,N) for (int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;

int main() {

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

	std::array<int, 3> arr; std::cin >> arr[0] >> arr[1] >> arr[2];
	std::sort(arr.begin(), arr.end());

	std::cout << arr[0] + arr[1];

	return 0;
}

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

int main()
{
	long long x, i,m=100;
	cin >> x;
	for (i = 1;; i++)
	{
		m = m + m / 100;
		if (m >= x) break;
	}
	cout << i;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 1; i <= (n); i++)
#define asort(x) sort(x.begin(),x.end())
 
int main() {
    int n, k, d;
    int ans = 0, tmp;
    cin>>n>>k;
    vector<int> a(n+1);
    rep(i,k) {
        cin>>d;
        rep(i,d) {
            cin>>tmp;
            a[tmp]++;
        }
    }
    rep(i,n) {
        if(a[i] == 0) ans++;
    }

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

Measured memory_bytes: 3576
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
  ll n;
  cin>>n;
  ll a[n];
  ll i;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  ll dp[n]={0};
  dp[0]=0;
  dp[1]=abs(a[0]-a[1]);
  for(i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i-2]-a[i]));
  }
  cout<<dp[n-1];
  
  
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	int n, cnt = 0;
	vector<int>list;

	cin >> n;

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

	for (int i = 1; i < n ; i++) {
		if (list[i - 1] == list[i]) {
			cnt++;
			i++;
		}
	}

	cout << cnt << endl;
	

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        string[] input = Console.ReadLine().Split(' ');
        var n = long.Parse(input[0]);
        var m = long.Parse(input[1]);

        long[] WA = new long[n + 1];
        long[] AC = new long[n + 1];
        for (long i = 1; i < n + 1; i++)
        {
            WA[i] = 0;
            AC[i] = 0;
        }

        long countAC = 0;
        long countWA = 0;
        for (long i = 0; i < m; i++)
        {
            string[] tmp = Console.ReadLine().Split();
            long p = long.Parse(tmp[0]);
            string s = tmp[1];

            if (AC[p] == 0)
            {
                if (s == "AC")
                {
                    AC[p] = 1;
                    countAC++;
                    countWA += WA[p]; 
                }
                else if (s == "WA")
                {
                    WA[p] += 1;
                }
            }
        }

        Console.Write(countAC);
        Console.Write(" ");
        Console.Write(countWA);
    }
}


Measured memory_bytes: 17276
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<s32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

int main()
{
	FASTIO;
	ll X,u,v;
	cin >> X;
	u = X / 100;
	v = X % 100;
	for(int b = 0;b < 101;b++){
		for(int c = 0;c < 51;c++){
			for(int d = 0;d < 35;d++){
				for(int e = 0;e < 26;e++){
					for(int f = 0;f < 21;f++){
						ll temp1 = (b + 2 * c + 3 * d + 4 * e + 5 * f) % 100;
						ll temp2 = u - (b + c + d + e + f);
						if(temp1 == v && temp2 >= 0){
							cout << 1 << ln;
							return 0;
						}
					}
				}
			}
		}
	}
	cout << 0 << ln;
	return 0;
}


Measured memory_bytes: 256
/**  elias **/
#include <bits/stdc++.h>
#define F first
#define S second
#define ld long double
#define pb push_back
#define sz size
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%lld",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(int i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(int i=s;i<n+s;i++){scll(a[i]);}
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(int i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define F first
#define S second
#define ld long double
#define ll long long
#define pb push_back
#define sz size
using namespace std;
const ll mod=1e9+7;
const int N=2e6+10;
ll f[N],inv[N];
ll pow_(ll a,ll b,ll mod=1e9+7){
    ll ans=1ll;
    while(b){
        if(b&1)ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}

void init(){
    f[0]=inv[0]=1;
    for(int i=1; i<N; i++){
            f[i]=1ll*i*f[i-1]%mod,inv[i]=pow_(f[i],mod-2);
    }
}

ll C(int n,int m){
    return f[n]*inv[n-m]%mod*inv[m]%mod;
}
ll num_of_way(int xa,int ya,int xb,int yb){
	int xx=abs(xa-xb);
	int yy=abs(ya-yb);
	return C(xx+yy,xx);
}
int main(){
init();
ll n,m,a,b;
scll(n);scll(m);scll(a);scll(b);
ll ans=0;
loop(i,1,n-a){
	ans+=(num_of_way(1,1,i,b)*num_of_way(i,b+1,n,m))%mod;
	ans%=mod;	
}
printf("%lld\n",ans);
}


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

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

using namespace std;

bool compare_by_nested_pair_second(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.second < b.second;
}

int main(){
  int n;cin>>n;
  vector<pair<pair<ll,ll>, ll>> ab(n);
  rep(i,n){
    ll a,b;cin>>a>>b;
    auto p = make_pair(a, b);
    ab[i] = make_pair(p, a+b);
  }

  sort(ab.rbegin(), ab.rend(), compare_by_nested_pair_second);
//  sort(ab.begin(), ab.end(), compare_by_nested_pair_second);

//rep(i,n)cout<<ab[i].second<<' ';cout<<endl;

  ll result=0;
  rep(i,n){
    if(i%2==0) result += ab[i].first.first;
    else result -= ab[i].first.second;
  }

  cout<<result;

  return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<climits>
#include<algorithm>
#include<vector>
#include<valarray>
#include<string>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iostream>
#include<iomanip>
using namespace std;
   
   
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define DREP(i,n) for(int i=n;i>0;i--)
#define Rep(i,m,n) for(int i=m;i<n;i++)
#define ReP(i,m,n) for(int i=m;i<=n;i++)
#define scani(a) scanf("%d",&a)
#define scand(a) scanf("%lf",&a)
#define scans(s) scanf("%s",s)
#define readi(a) int a;scanf("%d",&a)
#define printi(a) printf("%d",a)
#define prints(s) printf("%s",s)
#define even(n) (((n)+1)%2)
#define odd(n) ((n)%2)
#define sg(x) ((x)?1:0)
#define LF printf("\n")
#define SPACE printf(" ")
#define pb push_back
#define mp make_pair
#define bs binary_search
#define all(a) (a).begin(),(a).end()
#define forall(itr,a) for(auto itr=(a).begin();itr!=(a).end();++itr)
   
typedef long long LL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<double,double> pdd;
typedef pair<int,int> pii;

const double pi = acos(-1.0);
double rad(double t){return t*pi/180.0;}
double deg(double d){return d*180.0/pi;}
template<typename T>T GCD(T x,T y){return y?GCD(y,x%y):x;}
template<typename T>T LCM(T x,T y){return x/GCD(x,y)*y;}
template<class T>ostream& operator<<(ostream& os,const set<T>& s){os<<"{";for(auto itr=s.begin();s.end() != itr;++itr){if(itr!=s.begin())os<<',';os<<*itr;}os<<"}";return os;}
template<class S,class T>ostream& operator<<(ostream& os,const pair<S,T>& p){os<<'('<<p.first<<','<<p.second<<')';return os;}
const int MOD = (int)pow(10,9) +7;
 
 
//begin global variable
//


//
//end   global variable

int main(){
  ios::sync_with_stdio(false);
  //begin main()
  //

  LL n,a[100000];
  cin >> n;
  rep(i,n) cin >> a[i];

  LL tani = 1,ans = 0;
  
  rep(i,n){
    //cout << "tani=" << tani << ",a[i]=" << a[i] ;
    if( a[i]-1 >= tani ){
      ans += (a[i]-1)/tani;
    }else if( a[i] == tani ){
      tani = a[i] + 1 ;
    }
    if( tani == 1 ) tani = 2;
    
    //cout << ",tani=" <<tani << ",ans=" << ans << endl;
  }
  cout << ans << endl;
  //
  //end   main()
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
if(a%c==0||b%c==0){
	cout<<(b-a)/c+1;
	return 0; 
} 
cout<<(b-a)/c;
return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	string s;
	
	cin >> n;
	cin >> s;

	if (n % 2 == 0) {
		int i;
		int j = n / 2;
		for (i = 0; i < n / 2; i++, j++) {
			if (s[i] != s[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = 0;
        int b = 0;
        if (s[0] == "A") a = 10;
        else if (s[0] == "B") a = 11;
        else if (s[0] == "C") a = 12;
        else if (s[0] == "D") a = 13;
        else if (s[0] == "E") a = 14;
        else if (s[0] == "F") a = 15;
        if (s[1] == "A") b = 10;
        else if (s[1] == "B") b = 11;
        else if (s[1] == "C") b = 12;
        else if (s[1] == "D") b = 13;
        else if (s[1] == "E") b = 14;
        else if (s[1] == "F") b = 15;
        if (a < b) Console.WriteLine("<");
        else if (a > b) Console.WriteLine(">");
        else Console.WriteLine("=");
    }
}


Measured memory_bytes: 11092
package main

import "fmt"

//繰り返し自乗法
func pow(num int, time int) int {
	res := 1
	for time > 0 {
		if time%2 != 0 {
			res = res * num
		}
		num = num * num
		time /= 2
	}
	return res
}

//最大値
func Max(nums ...int) int {
	if len(nums) == 0 {
		panic("min() requires at least one arguments.")
	}
	res := nums[0]
	for _, val := range nums {
		if res < val {
			res = val
		}
	}
	return res
}

func solve(n int) int {
	var cnt int
	for ; n%2 == 0; n /= 2 {
		cnt++
	}
	return cnt
}

func main() {
	var n, ans int
	fmt.Scan(&n)
	for i := 1; i <= n; i++ {
		ans = Max(ans, solve(i))
	}
	fmt.Println(pow(2,ans))
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main(){
    i64 n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<k) cout<<n*x<<endl;
    else cout<<k*x+(n-k)*y<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> T;
	if (T[0] != T[1] && T[0] != T[2] && T[1] != T[2]) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include <stdio.h>

typedef long long lld;

int gcd(lld a, lld b)
{
	return  ((b > 0) ? gcd(b, a % b) : a);
}
int lcm(lld a, lld b)
{
	return (a / gcd(a, b) * b);
}

int main(void)
{
	lld a, b;

	while (~scanf("%lld %lld", &a, &b)){
		printf("%d %d\n", gcd(a, b), lcm(a, b));
	}
	return (0);
}

Measured memory_bytes: 596
#include <stdio.h>

int cal(int z){
	int temp, fin;
	temp=z%1000;
	if(temp>0){
		fin=1000-temp;
	}
	else{
		fin=0;
	}
	return fin;
}

int main(){
	double x,y;
	scanf("%lf", &x);
	printf("%d",cal(x));
	return 0;
}

Measured memory_bytes: 1740
#include<set>
using namespace std;
#include<iostream>
int	main(){
	/*
	while(true){
	
	int A,B,C,D,E,F,G,H,I,J,answer;
		
	cin >> A;
	if(A == 0) return 0;
	cin >> B >> C >> D >> E >> F >> G >> H >> I >> J;
	answer = A - B - C - D-E-F-G-H-I-J;
	cout << answer << endl;

	}
	*/
	/*
	int A,B,C,D,E,F;

	cin >> A, B, C, D;
	if(A < B, C, D){ 
		cout << B + C + D << endl;
	}
	
	else if(B < A, C, D){
		cout << A + C + D << endl;
	}

	else if(C < A && C < B && C < D){
		cout << A + B + D << endl;
	}

	else if(D < A && D < B && D < C){
		cout << A + B + C << endl;
	}

	if(E < F){
		cout << F << endl;
	}

	else{
		cout << E << endl;
	}
	
	return 0;
}*/
	/*
	int N, M;
	cin >> N >> M;
	cout << N + M << endl << N - M << endl << N * M << endl << N / M << endl;
}*/

/*int N, M; 
	cin >> N >> M;
	cout << N % M << endl;
}*/

/*	int N;
	cin >> N;
	cout << -(N % 2)+1 ;
}*/

	/*int A, B, C, D, E ;
	cin >> A >> B >> C >> D >> E;
	cout << (A + B + C + D + E) / 5 ;
}*/

	/*int A, B, C, D ;
	cin >> A >> B >> C >> D;
	cout << (A + B + C + D) / 60 << endl << (A + B + C + D) % 60 << endl;
	*/

/*	int A,B;
	cin >> A >> B;
	cout << ( A + B ) / 2 << endl;*/

/*	int m, f, b;
	cin >> m >> f >> b;

	if ( m + f >= b && m <= b ){
		cout << b - m << endl;
	}
	
	if ( m + f > b && m > b ){
		cout << 0 << endl;
	}


	if ( m + f < b ){
		cout << "NA" << endl;
	}*/

	int X , x ;
	cin >> X ;

	x = X % 7 ;

	if ( x == 2 ){
		cout << "sat" << endl;
	}

	if ( x == 3 ){
		cout << "sun" << endl;
	}

	if ( x == 4 ){
		cout << "mon" << endl;
	}

	if ( x == 5 ){
		cout << "tue" << endl;
	}

	if ( x == 6 ){
		cout << "wed" << endl;
	}

	if ( x == 0 ){
		cout << "thu" << endl;
	}

	if ( x == 1 ){
		cout << "fri" << endl;
	}
}


Measured memory_bytes: 3108
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

a, b, c = MAP()
if b - a == c - b:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 5200
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

const int N_max = pow(10,5);
vector<int> tree[N_max];

int depth[2][N_max];

void dfs(int v, int p, int d, int player){
  depth[player][v] = d;
  for (auto &e: tree[v]) {
    if ( e == p ) continue;
    dfs(e, v, d+1, player);
  }
  return;
}

int main() {
  int N; cin >> N;
  rep(i, N-1) {
    int a, b; cin >> a >> b; a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  dfs(0, -1, 0, 0); // fennec
  dfs(N-1, -1, 0, 1); // snuke
  int fennec = 0, snuke = 0;
  rep(i, N) {
    if ( depth[0][i] <= depth[1][i] ) fennec++;
    else snuke++;
  }
  string result;
  if (fennec > snuke) result = "Fennec";
  else result = "Snuke";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 12800
n,a,b=gets.split.map &:to_i
if a==0 && b==0
  puts 0
elsif n <= a
  puts n
elsif n > a && n <= (a+b)
  puts a
elsif n > (a+b)
  d= n % (a+b)
  r= n / (a+b)
  if d<=a
    puts a*r+d
  elsif d>a && d<=(a+b)
    puts a*r+a
  else
    puts a*r
  end
end


Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include<utility>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<ll, ll> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int GCD(int x, int y) {
	return x ? GCD(y % x, x) : y;
}

int main()
{
	string s;
	cin>>s;
	int n=s.size();
	
	vector<pair<int,int>>al(26);//first 区間長 second previous position
	FOR(i,1,n+1){
		int ite=s[i-1]-97;
		al[ite].F=max(al[ite].F,i-al[ite].S-1);
		al[ite].S=i;
	}
	rep(i,26){
		if(al[i].S!=n-1)
		{
			al[i].F=max(al[i].F,n-al[i].S);
		}
	}
	int ans=1e9;
	char ansc;
	rep(i,26){
		ans=min(ans,al[i].F);
		if(ans==al[i].F){
			char a='a';
			a+=i;
			ansc=a;
		}
	}
	//cout<<al[0].F<<endl;
	//cout<<ansc<<endl;
	cout<<ans<<endl;



}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val pp = readLine()!!.split(" ").map { it.toInt() }
    val qq = readLine()!!.split(" ").map { it.toInt() }

    val array = mutableListOf<Int>()
    repeat(n) {
        array.add(it+1)
    }

    var pIndex = -1
    var qIndex = -1
    var pos = 0

    do {
        pos++
        var pFailed = false
        var qFailed = false

        array.forEachIndexed { index, i ->
            if (i != pp[index]) pFailed = true
            if (i != qq[index]) qFailed = true
            if (pFailed && qFailed) {
                return@forEachIndexed
            }
        }

        if (!pFailed) pIndex = pos
        if (!qFailed) qIndex = pos

        if (pIndex != -1 && qIndex != -1) {
            println(Math.abs(pIndex - qIndex))
            return
        }
    } while (nextPermutation(array))
}

fun nextPermutation(array: MutableList<Int>): Boolean {
    var tmp = 0
    for (i in array.size-2 downTo 0) {
        if (array[i] < array[i+1]) {
            for (j in array.size-1 downTo i+1) {
                if (array[j] > array[i]) {
                    tmp = array[i]
                    array[i] = array[j]
                    array[j] = tmp

                    val tmpArray = array.takeLast(array.size-(i+1)).sorted()
                    tmpArray.forEachIndexed { index, e ->
                        array[i+1+index] = e
                    }

                    return true
                }
            }
        }
    }

    return false
}

Measured memory_bytes: 41988
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

const int N=1e5+5;

ll t,n,w[N],v[N],mem[105][N],W,k;

ll dp(int pos,int sum)
{
    if (pos==n)return 0;
    if (mem[pos][sum]!=-1)return mem[pos][sum];
    ll ans=dp(pos+1,sum);
    if (w[pos]+sum<=W)ans=max(ans,v[pos]+dp(pos+1,sum+w[pos]));
    return mem[pos][sum]=ans;
}

int main()
{
    t=1;
    while(t--)
    {
        memset(mem,-1,sizeof mem);
        cin >> n >> W;
        for (int i=0;i<n;i++)
        {
            cin >> w[i] >> v[i];
        }
        cout << dp(0,0) << endl;
    }
}


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

int main(){
  char A,B,C,D; cin>>A >>B >>C >>D;
  int a=A-'0',b=B-'0',c=C-'0',d=D-'0';
  if(a+b+c+d==7){
    cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    return 0;
  }else if(a+b+c-d==7){
    cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    return 0;
  }else if(a+b-c+d==7){
    cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    return 0;
  }else if(a+b-c-d==7){
    cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    return 0;
  }else if(a-b+c+d==7){
    cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    return 0;
  }else if(a-b+c-d==7){
    cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    return 0;
  }else if(a-b-c+d==7){
    cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    return 0;
  }else if(a-b-c-d==7){
    cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
s = input()
n = len(s) - 1
sum = 0

for bit in range(1 << n):
    eval_str = ''
    eval_str += s[0]
    for i in range(n):
        if bit & (1 << i):
            eval_str += '+'
        eval_str += s[i + 1]
    sum += eval(eval_str)

print(sum)

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

int main() {
    int m, n; cin >> m >> n;
    vector<int> p(m), sum(m + 1);
    for(int i = 0; i < m; ++i) {
        cin >> p[i];
    }
    sort(rbegin(p), rend(p));
    for(int i = 0; i < m; ++i) {
        sum[i + 1] = sum[i] + p[i];
    }
    vector<int> c(n), e(n);
    for(int i  = 0;  i < n; ++i) {
        cin >> c[i] >> e[i];
    }

    vector<int> dp(m + 1);
    for(int i = 0; i < n; ++i) {
        auto nxt = dp;
        for(int j = 0; j < m; ++j) {
            const int k = min(j + c[i], m);
            nxt[k] = max(nxt[k], dp[j] + sum[k] - sum[j] - e[i]);
        }
        dp = move(nxt);
    }

    cout << *max_element(begin(dp), end(dp)) << endl;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  if(n == 1) cout << "Hello World" << endl;
  else{
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef unsigned long long LL;
typedef pair<int,int> pii;
int n,rr;
LL di[200005],sd[200005],ans=ULLONG_MAX,mul[200005],dr,m;
int main()
{
    scanf("%d %llu",&n,&m);
    for(int i=1;i<=n;i++)
    {
        mul[i]=(i*2)+1;
        scanf("%llu",&di[i]);
        sd[i]=sd[i-1]+di[i];
    }
    mul[1]=5;
    for(int i=1;i<=n;i++)
    {
        dr=(LL)(n+i)*m;
        rr=0;
        for(int j=n;j>0;j-=i)
        {
            rr++;
            int nx=max(j-i,0);
            dr+=(sd[j]-sd[nx])*mul[rr];
        }
        ans=min(ans,dr);
        //printf("%lld %d\n",dr,i);
    }
    printf("%llu",ans);
}


Measured memory_bytes: 8516
import sys
from math import sqrt
from itertools import combinations
def resolve():
    eps = 1e-7
    N, K, *xyc = map(int, sys.stdin.read().split())
    x = xyc[::3]
    y = xyc[1::3]
    ci = list(zip(x, y))
    _r = xyc[2::3]
    l = 0
    r = 10 ** 6
    while l + eps < r:
        T = (l + r) / 2
        rad = [(T/_r[i])**2 for i in range(N)]
        ans = 0
        xys = []
        for i, j in combinations(range(N), 2):
            cx1, cy1 = ci[i]
            cx2, cy2 = ci[j]
            xt = cx2-cx1
            yt = cy2-cy1
            XY = xt**2+yt**2
            a = (XY+rad[i]-rad[j])/2
            d = XY*rad[i]-a**2
            if d < eps:
                continue
            x1 = (a*xt+yt*sqrt(d))/XY+cx1
            y1 = (a*yt-xt*sqrt(d))/XY+cy1
            x2 = (a*xt-yt*sqrt(d))/XY+cx1
            y2 = (a*yt+xt*sqrt(d))/XY+cy1
            xys.append([x1, y1])
            xys.append([x2, y2])
        xys.extend(ci)
        for X, Y in xys:
            tmp = 0
            for (x, y), k in zip(ci, rad):
                if (x-X)**2+(y-Y)**2 < k+eps:
                    tmp += 1
            ans = max(ans, tmp)
            if ans >= K:
                break
        if ans >= K:
            r = T
        else:
            l = T
    print(r)
resolve()

Measured memory_bytes: 46300
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, k; cin >> a >> b >> c >> k;
    if (a > k) cout << k << '\n';
    else {
        ll ans = a;
        k -= a;
        if (b > k) cout << ans << '\n';
        else {
            k -= b;
            ans -= min(c, k);
            cout << ans << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100;
vector <int> g[N],mol[N];
map <pii,int> yal;
queue <pii> q;
ll par[N];
void add_edge(ll u,ll v){
    yal[{u,v}]++;
    yal[{v,u}]++;
    if (yal[{u,v}]>1 && u!=v){
        q.push({u,v});
    }
    return ;
}
void mrg(ll u,ll v){
    if (mol[u].size()>mol[v].size()) swap(u,v);
    for (auto t : g[u]){
        add_edge(v,par[t]);
        g[v].pb(par[t]);
    }
    g[u].clear();
    for (auto t : mol[u]){
        par[t]=v;
        mol[v].pb(t);
    }
    mol[u].clear();
    return ;
}
int32_t main(){
    sync;
    ll n;
    cin >> n;
    for (int i=1;i<N;i++) par[i]=i,mol[i].pb(i);
    for (int i=1;i<2*n-1;i++){
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
        add_edge(u,v);
    }
    while(q.size()){
        pii a=q.front();
        q.pop();
       // cout << a.F << " " << a.S << endl;
        mrg(a.F,a.S);
    }
    ll y=par[1];
    for (int i=2;i<=n;i++){
        if (par[i]!=y) kill("NO");
    }
    kill("YES");

}


Measured memory_bytes: 89716
#include <iostream>

int main()
{
    int n;
    std::cin >> n;
    for (auto i = 1; i < 10; i++) {
        if (n % i == 0 && n / i < 10) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
}

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()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    reverse(h.begin(), h.end());
    int ans = 0;
    int val = 0;
    for (int i = 1; i < n; i++)
    {
        if (h[i - 1] <= h[i])
            val++;
        else
            val = 0;
        ans = max(ans, val);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cerr<<#x<<" "<<x<<endl;
#define f(i,n) for(ll i=0; i<n; i++)
#define f1(i,n) for(ll i=1; i<=n; i++)
#define fr(i,n) for(ll i=n-1; i>=0; i--)
#define f1r(i,n) for(ll i=n; i>0; i--)
#define mst(arr,val) memset(arr,val,sizeof(arr))
#define all(x) x.begin(),x.end()

typedef long long int ll;
typedef pair<ll,ll> pii;
ll M=1e9+7;
ll M2=998244353;
void show(vector<ll> v)
{
    for(int i=0; i<v.size(); i++)
        cout<<v[i]<<" ";
    cout<<"\n";
}
void showrev(vector<ll> v)
{
    for(int i=0; i<v.size(); i++)
        cout<<v[v.size()-i-1]<<" ";
    cout<<"\n";
}
void showarr(ll arr[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
}
void showpv(vector<pair<ll,ll> > v)
{
    f(i,v.size())
        cout<<"("<<v[i].ff<<","<<v[i].ss<<")"<<" ";
    cout<<"\n";
}
void showmap(map<ll,ll> m)
{
    for(auto i:m)
        cout<<" ("<<i.ff<<","<<i.ss<<") ";
    cout<<"\n";
}
void lcs( string X, string Y, int m, int n )
{
   int L[m+1][n+1];
   for (int i=0; i<=m; i++)
   {
     for (int j=0; j<=n; j++)
     {
       if (i == 0 || j == 0)
         L[i][j] = 0;
       else if (X[i-1] == Y[j-1])
         L[i][j] = L[i-1][j-1] + 1;
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]);
     }
   }

   // Following code is used to print LCS
   int index = L[m][n];

   // Create a character array to store the lcs string
   char lcs[index+1];
   lcs[index] = '\0'; // Set the terminating character

   // Start from the right-most-bottom-most corner and
   // one by one store characters in lcs[]
   int i = m, j = n;
   while (i > 0 && j > 0)
   {
      // If current character in X[] and Y are same, then
      // current character is part of LCS
      if (X[i-1] == Y[j-1])
      {
          lcs[index-1] = X[i-1]; // Put current character in result
          i--; j--; index--;     // reduce values of i, j and index
      }

      // If not same, then find the larger of two and
      // go in the direction of larger value
      else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
   }

   // Print the lcs
   cout << lcs;
}
int main()
{
    IOS
    ll T = 1,Q=1;
    //cin>>T;

    while(T--)
    {
        string s,t; cin>>s>>t;
        int n = s.length(), m = t.length();
        lcs(s,t,n,m);
    }
    return 0;
}


Measured memory_bytes: 35456
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let d: usize = read();
    let e: usize = read();
    let f: usize = read();
    let mut water = vec![false; 40];
    let mut sugar = vec![false; 3000];
    water[0] = true;
    sugar[0] = true;
    for i in 0..40 {
        if !water[i] {
            continue;
        }
        if i + a < 40 {
            water[i + a] = true;
        }
        if i + b < 40 {
            water[i + b] = true;
        }
    }
    for i in 0..3000 {
        if !sugar[i] {
            continue;
        }
        if i + c < 3000 {
            sugar[i + c] = true;
        }
        if i + d < 3000 {
            sugar[i + d] = true;
        }
    }
    let mut ans = (-1.0, 0, 0);
    for i in 1..40 {
        if !water[i] {
            continue;
        }
        for j in 0..3000 {
            if !sugar[j] || i * e < j || 100 * i + j > f {
                continue;
            }
            let v = (100f64 * j as f64 / (100 * i + j) as f64, 100 * i + j, j);
            //println!("{:?} {:?}", ans, v);
            if ans.0 < v.0 {
                ans = v;
            }
        }
    }
    println!("{} {}", ans.1, ans.2);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


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

    vector<P> p;
    rep(i,n){
        int a, b;
        cin>>a>>b;

        p.push_back(make_pair(a, b));
    }
    sort(p.begin(), p.end());
    ll cnt=0;
    int ans;
    rep(i,n){
        cnt+=p[i].second;
        ans=p[i].first;
        if(cnt>=k) break;
    }

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

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

ll dp[7][2][10][10];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string N; cin>>N;
  int NL=N.length();
  
  dp[0][0][0][0]=1;
  
  rep(i,NL) rep(j,2) rep(k,10) rep(l,10){
    if(dp[i][j][k][l]==0) continue;
    if(j==0){
      int n=N[i]-'0';
      if(k==0){
        dp[i+1][(i+1)==NL][n][n]+=dp[i][j][k][l];
        rep(m,n){
          dp[i+1][1][m][m]+=dp[i][j][k][l];
        }
      }else{
        dp[i+1][(i+1)==NL][k][n]+=dp[i][j][k][l];
        rep(m,n){
          dp[i+1][1][k][m]+=dp[i][j][k][l];
        }
      }
    }else{
      if(k==0){
        rep(m,10) dp[i+1][1][m][m]+=dp[i][j][k][l];
      }else{
        rep(m,10) dp[i+1][1][k][m]+=dp[i][j][k][l];
      }
    }
  }
  ll ans=0;
  for(int i=1;i<=9;i++) for(int j=1;j<=9;j++){
    ans+=dp[NL][1][i][j]*dp[NL][1][j][i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0]*(K+1) for i in range(N)]
for j in range(a[0]+1):
  dp[0][j]=1
  
for i in range(1,N):
  for j in range(K+1):
    if j==0:
      dp[i][j]=1
    else:
      dp[i][j]=dp[i][j-1]+dp[i-1][j]
      if j>=a[i]+1:
        dp[i][j]-=dp[i-1][j-1-a[i]]
      dp[i][j]=dp[i][j]%(10**9+7)
      
print(dp[-1][-1])


Measured memory_bytes: 119916
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define ll long long
#define ul unsigned long

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  priority_queue<int> q;
  FOR(i,0,N)
  {
    int A;
    cin >> A;
    q.push(A);
  }
  do
  {
    int x = q.top();
    q.pop();
    q.push(x/2);
  }while(--M);
  long count = 0;
  while(!q.empty())
  {
    count += q.top();
    q.pop();
  }
  cout << count << '\n';
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){

  llong n,m;
  cin>>n>>m;
  vector<LP> v;
  REP(i,n){
    LP p;
    cin>>p.first>>p.second;
    v.pb(p);
  }
  VSORT(v);
  llong count = 0;
  llong ans = 0;
  while(1){

    if(v[count].second<m){
      ans += v[count].second * v[count].first;
      m -= v[count].second;
    }else{
      ans += v[count].first * m;
      break;
    }
    count++;
  }

  cout<<ans<<endl;


 

  return 0;
}

Measured memory_bytes: 2420
# Union-Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True


def same(x, y):
    return find(x) == find(y)


def size(x):
    return -par[find(x)]


N, M = map(int, input().split())
# 負のとき size, 非負のとき parent
par = [-1] * N
P = list(map(int, input().split()))
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

ans = 0
for i, p in enumerate(P):
    if same(i, p-1):
        ans += 1

print(ans)

Measured memory_bytes: 89836
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int d = sc.nextInt();
	if (Math.abs(c-a) <= d || (Math.abs(b-a) <= d && Math.abs(c-b) <= d)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		int K = in.nextInt();
		boolean ans = false;
		for (int i = 0; i <= N; i++) {
			for (int j = 0; j <= M; j++) {
				if(M*i+N*j-2*i*j == K) ans = true;
			}
		}
		System.out.println(ans? "Yes":"No");
		
	}

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

Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define betheflash ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vs vector<string>
#define vvi vector<vector<int>>
#define mii map<int,int>
#define msi map<string,int>
#define mis map<int,string>
#define pb push_back
#define mod 1000000007
using namespace std;
void solve()
{
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes";
	else
		cout<<"No";
}
int main()
{
    betheflash
	int t=1;
	//cin>>t;
	for(int ha=0;ha<t;ha++)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M, P = map(int, input().split())

edges = []
for _ in range(M):
    a, b, c = map(int, input().split())
    edges.append([a-1, b-1, -c+P])


def bellnabFord(edges, src, N):
    inf = float('inf')
    dist = [inf for i in range(N)]
    dist[src] = 0

    for i in range(2*N):
        for s, d, c in edges:
            if dist[d] > dist[s]+c:
                dist[d] = dist[s]+c
                if i >= N: #N回目以降の更新では-infに。(数字の大きさに影響されない)
                    dist[d] = -float('inf')

            if i == N-1:
                prev = dist[-1]
    return (prev, dist[-1])


prev, dist = bellnabFord(edges, 0, N)
if prev != dist:
    ans = -1
else:
    ans = max(0, -dist)
print(ans)

Measured memory_bytes: 74944
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String strArray[] = br.readLine().split(" ");
	int A = Integer.parseInt(strArray[0]);
	int B = Integer.parseInt(strArray[1]);
	if ((A + B) % 2 == 0)
	    System.out.println((A + B) / 2);
	else
	    System.out.println("IMPOSSIBLE");
    }
}


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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> data(M);
  for(int i=0;i<M;i++){
    
    cin>>data.at(i);
  }
 
  for(int i=0;i<M;i++){
    N -=data.at(i);
  }
  if(N>=0){
    cout<<N<<endl;
  }
  else{
    cout<<-1<<endl;
  }
  
    
}

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

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

using namespace std;
using ll = long long;

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 3780