akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///

void _case()
{
    long double n,m;
    cin>>n>>m;
    ll ans=0;
    for(int i=0;i< (int) n;i++){
        long double a,b;
        cin>>a>>b;
        if(a*a+b*b<=m*m) ans++;
    }
    cout<<ans el;
}

main()
{
//    fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3780
#include<cstdio>
#include<algorithm>
#include<cmath>
#define mp make_pair
#define P pair<int, int>
#define y1 yy1 
#define LL long long
using namespace std;
const double pi = acos(-1);
const int M = 200010;
int val[M], px[M], x1, x2, y1, y2, n, x, y, f[M], st, en; 
P p[M];
 
int find(int x) {
	int ans = 0;
	for(int i = x; i >= 1; i -= i & -i) {
		ans = max(ans, val[i]); 
	} 
	return ans;
}
 
void insert(int x, int now) {
	for(int i = x; i <= n; i += i & -i) {
		val[i] = max(val[i], now);
	}
}
 
bool cmp(P a, P b) {
	return a.second == b.second ? a.first < b.first : a.second < b.second;
}
 
int main() {
	int m;
	scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &m);
	for(int i = 1; i <= m; i++) {
		scanf("%d%d", &x, &y);
		if(min(x1, x2) <= x && x <= max(x1, x2) && min(y1, y2) <= y && y <= max(y1, y2)) p[++n] = mp(x, y);
	} 
	if(x1 > x2) {
		x1 *= -1;
		x2 *= -1;
		for(int i = 1; i <= n; i++) p[i].first *= -1;
	} 
	if(y1 > y2) {
		y1 *= -1;
		y2 *= -1;
		for(int i = 1; i <= n; i++) p[i].second *= -1;
	} 
	p[++n] = mp(x1, y1);
	p[++n] = mp(x2, y2); 
	sort(p + 1, p + n + 1, cmp);
	for(int i = 1; i <= n; i++) px[i] = p[i].first;
	sort(px + 1, px + n + 1);
	for(int i = 1; i <= n; i++) {
		int pos = lower_bound(px + 1, px + n + 1, p[i].first) - px;
		f[i] = find(pos) + 1;
		if(p[i] == mp(x1, y1)) st = i;
		if(p[i] == mp(x2, y2)) en = i; 
		insert(pos, f[i]);
	}
	double ans = 1.0 * (x2 - x1 + y2 - y1) * 100 - (20.0 - 5 * pi) * (f[en] - f[st] - 1);
	///printf("%.15lf\n", ans); 
//	printf("%d %d\n", f[en], f[st]);
	if(f[en] - f[st] - 1 == min(x2 - x1 + 1, y2 - y1 + 1)) ans += 1.0 * 10 * pi - 5.0 * pi;
	printf("%.15lf", ans);
} 

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#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(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll r,x,d;

int main(){
	cin >> r >> d >> x;
	rep(i,10){
		cout << r * x - d << endl;
		x = r*x - d;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String s2 = sc.next();
		sc.close();
		System.out.println(s.charAt(0) == s2.charAt(2) && s.charAt(1) == s2.charAt(1) && s.charAt(2) == s2.charAt(0) ? "YES" : "NO");

	}
}



Measured memory_bytes: 35768
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
V ans;
ll koko;
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n)cin>>a[i];
    ll now[n+10]={},now_cou=n;
    rep(j,n){
        now[j]=a[j];
    }
    rep(i,n){
        int ok=0;
        rrrep(j,now_cou-1,0){
            if(now[j]==j+1){
                ok=1;
                ans.p_b(now[j]);
                rrep(k,j,now_cou-1){
                    now[k]=now[k+1];
                }
                //now[j]=LINF;
                break;
            }
        }
        now_cou--;
        if(!ok){
            Cout(-1);
            return 0;
        }
    }
    reverse(all(ans));
    rep(i,n){
        Cout(ans[i]);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, n;
    cin >> x >> n;
    set<int> st;
    for (int i = 0; i <= 101; i++)
        st.insert(i);
    while (n--) {
        int p;
        cin >> p;
        st.erase(p);
    }
    auto it = st.lower_bound(x);
    int abs1 = abs(*it - x), abs2 = INT_MAX;
    if (it != st.begin())
        abs2 = abs(*(--it) - x);
    cout << (abs1 < abs2 ? x + abs1 : x - abs2) << endl;
    return 0;
}


Measured memory_bytes: 3632
import java.io.*;
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
      Scanner sc=new Scanner(System.in);
       while(true){
        int m=sc.nextInt();
        int f=sc.nextInt();
        int r=sc.nextInt();
           if((m==-1)&&(f==-1)&&(r==-1))break;           
           else{
            if((m==-1)||(f==-1))System.out.println("F");
            else{
                if(m+f>=80)System.out.println("A");
                else{
                    if((m+f>=65)&&(m+f<80))System.out.println("B");
                    else{
                        if((m+f>=50)&&(m+f<65))System.out.println("C");
                        else{
                            if((m+f>=30)&&(m+f<50)){
                                if(r>=50)System.out.println("C");
                                else System.out.println("D");
                            }
                            else System.out.println("F");
                        }
                    }
                }
            }

           }
       }
       
      }
    }


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

vector<int>v;
double EPS=1e-9;
//ll pre[500010],a[500010],res[1000001];
const ll mod=1e9+7;
ll fastpow(ll a, ll n)
{
    if(n == 0) return 1;
    ll x = fastpow(a, n/2);
    ll ans = x * x % mod;
    if(n % 2 == 1) ans = ans *a % mod;
    return ans%mod;
}

ll C(ll n,ll m) {
    if(n < m) return 0;
    ll res = 1;
    for(ll i=1; i<=m; i++) {
        ll a = (n+i-m)%mod;
        ll b = i%mod;
        res = res*(a*fastpow(b,mod-2)%mod)%mod;
    }
    return res;
}

ll Lucas(ll n,ll m) {
    if(m == 0) return 1;
    return C(n%mod, m%mod) * Lucas(n/mod,m/mod)%mod;
}


int a[200010],vis[200010],suf[200010];
ll gcd(ll n,ll k)
{
    if(k==0)return n;
    else return gcd(k,n%k);
}
vector<int>v1,v2,v3,sub1,sub2;
int main()
{
    ll n;
cin>>n;/*
bool p=0;
while(n>0)
{
    ll temp=n%10;
    if(temp==7){p=1;}
    n/=10;
}
if(p==1)cout<<"Yes";
else cout<<"No";*/
  /*  ll sum=0;
    for(int i=1;i<=n;i++)
{
    if(i%3!=0&&i%5!=0)sum+=i;
}
cout<<sum;*/
ll sum=0;
for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    for(int k=1;k<=n;k++)
{
    sum+=gcd(__gcd(i,j),k);
}
cout<<sum;
/*string s;

for(int i=1;i<=n;i++)
{
    cin>>s[i];
    if(s[i]=='R')v1.push_back(i);
    if(s[i]=='B')v1.push_back(i);
    if(s[i]=='G')v1.push_back(i);
}
for(int i=0;i<v2.size();i++)
{
    for(int j=0;j<v1.size();j++)
    {
        sub1.push_back(v2[i]-v1[j]);
    }
}
for(int i=0;i<v3.size();i++)
{
    for(int j=0;j<v2.size();j++)
    {
        sub1.push_back(v3[i]-v2[j]);
    }
}ll c=0;
for(int i=0;i<sub1.size();i++)
{
    for(int j=0;j<sub2.size();j++)
    {
        if(sub2[j]!=sub1[i])c++;
    }
}
for(int i=0;i<sub1.size();i++)
{
    cout<<sub1[i]<<' ';
}*/
return 0;
}


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

int main(void){
	int a,b,c;
	cin>>a>>b>>c;
	double C = 3.1415926535*c/180;
	double cl = sqrt(a*a+b*b-2*b*a*cos(C));
	double S = a*b*sin(C)/2;
	cout <<setprecision(10)<<S<<endl;
	cout <<setprecision(10)<<a+b+cl<<endl;
	cout << setprecision(10)<<2*S/a<<endl;
}


Measured memory_bytes: 3428
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        #define endl "\n"
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "Yes" << endl;
        return 0;
    }

    while (1) {
        string t = "";
        map<char, int> cnt;
        bool f = false;
        REP(i, SZ(s)) {
            if (s.substr(i, 3) == "ABC") {
                t += "#";
                i+=2;
                f = true;
            } else {
                t += s[i];
                cnt[s[i]]++;
            }
        }
        if (!f) break;
        
        char x = '#';
        if (cnt['A'] == 0 && cnt['B'] > 0 && cnt['C'] > 0) {
            x = 'A';
        } else if (cnt['A'] > 0 && cnt['B'] == 0 && cnt['C'] > 0) {
            x = 'B';
        } else if (cnt['A'] > 0 && cnt['B'] > 0 && cnt['C'] == 0) {
            x = 'C';
        }

        if (x == '#') {
            cout << "No" << endl;
            return 0;
        }
        REP(i, SZ(t)) {
            if (t[i] == '#') t[i] = x;
        }
        s = t;
        if (s == "ABC") {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}




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

int main()
{
	std::vector<double> v;
	double f;
	
	while( std::cin >> f ){
		v.push_back( f );
	}
	
	std::sort( v.begin(), v.end() );

	std::cout << v[v.size()-1] - v[0] << std::endl;

 	return 0;
}

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

using namespace std;

int main(int argc,char* argv[]){
  int N,count=0;
   cin >> N;
   int A[N],B[N],C[N-1];
   for(int i=0;i<N;i++) cin >> A[i];
   for(int i=0;i<N;i++) {
     cin >> B[i];
     count += B[i];
   }
   for(int i=0;i<N-1;i++) cin >> C[i];
   for(int i=0;i<N-1;i++){
     if(A[i]+1==A[i+1]){
       count += C[A[i]-1];
     }
    }
    cout << count << endl;
    return 0;
}


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

int main()
{
    std::string s;
    std::cin >> s;
    for (int i = (s.size() - 1) / 2; i >= 0; i --)
    {
        if (s.substr(0, i) == s.substr(i, i))
        {
            printf("%d\n", i * 2);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
l = list(map(int, input().split()))

jump = [0] * (n + 1)
ans = 1
for i in range(n):
    jump[i+1] = jump[i] + l[i]
    if jump[i+1] <= x:
        ans += 1
    else:
        break

print(ans)


Measured memory_bytes: 38384
#include <stdio.h>

//main関数
int main(void){

	//1.Nの１桁目を算出する
	int N;
	//コードを読み取る
  scanf("%d", &N);

	N = N % 10;

	//コードを入力してください。
	if(N == 2 || N == 4 || N == 5 || N == 7 || N == 9)
	{
		printf("hon");
	}
	if(N == 0 || N == 1 || N == 6 || N == 8)
	{
		printf("pon");
	}
	if(N == 3)
	{
		printf("bon");
	}

	return 0;
}


Measured memory_bytes: 1732
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n,x;
    cin>>n>>x;
    int a[n];
    for(int i=0;i<n;i++)   cin>>a[i];
    
    sort(a,a+n);
    int cnt=0;
    for(int i=0;i<n;i++){
        if(i==n-1){
            if(a[i]==x) cnt++;
        }
        else{
            if(x-a[i]>=0){
                cnt++;
                x -= a[i];
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

int main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    s.push_back('E');
    int stand;
    if(s[0]=='0') stand=1;
    else stand=0;
    int L=0,R=0;
    //尺取り法
    int ans=0;
    while(R<n){
        if(stand<=k) {
            if(s[R]=='1' && s[R+1]=='0'){
                stand+=1;
            }
            ans=max(ans,R-L+1);
            R+=1;
        }
        else if(L==R){
            L+=1;
            R+=1;
        }
        else{
            if(s[L]=='0' && s[L+1]=='1'){
                stand-=1;
            }
            L+=1;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
n = int(input())
prices = list(map(int,input().split()))
stock_num = 0
cash = 1000

for i in range(n-1):
    if prices[i+1] >= prices[i]:
        temp = cash // prices[i]
        cash -= prices[i]*temp
        stock_num += temp
    else:
        cash += stock_num*prices[i]
        stock_num = 0

cash += stock_num*prices[n-1]
stock_num = 0

print(cash)


Measured memory_bytes: 9076
H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]
ans = 0
for ii in range(1 << H):
    for jj in range(1 << W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if ii >> i & 1:
                    continue
                if jj >> j & 1:
                    continue
                if c[i][j] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Measured memory_bytes: 9116
#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<ll,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));
 
ll h,w,n;
vector<P> vec;
 
bool ch(int x, int y){
	if(x == h) return true;
	if(x == 0) return true;
	if(y == w) return true;
	if(y == 0) return true;
	return false;
} 
 
ll f(int x, int y){
	if(x == 0){
		return (ll)y;
	}else if(x == h){
		return (ll)INF + (ll)INF + (ll)w - (ll)y;
	}else if(y == 0){
		return (ll)INF + (ll)INF + (ll)INF + (ll)h - (ll)x;
	}else if(y == w){
		return (ll)INF + (ll)x;
	}
}
 
int main(){
	cin >> h >> w >> n;
	int c = 0;
	REP(i,0,n){
		int x,y,xx,yy; cin >> x >> y >> xx >> yy;
		if(ch(x, y) and ch(xx, yy)){
			vec.push_back({f(x, y), c});
			vec.push_back({f(xx, yy), c++});
		}
	}
	sort(vec.begin(), vec.end());
	
	stack<int> st;
	REP(i,0,vec.size()){
		if(!st.empty() and st.top() == vec[i].second) st.pop();
		else st.push(vec[i].second);
	}
	
	if(st.empty()) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 6384
n,x=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
c=0
for i in range(n):
  x-=l[i]
  if i+1==n and x!=0:
    break
  if x>=0:
    c+=1
  else:
    break
print(c)

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

// {u}{int,long,llong}_{max,min}
#define inf         int_max/3
#define llinf       llong_max/3
#define mod         (1000000007ll)
#define moda(a, b)  a=((a)+(b))%mod
#define modp(a, b)  a=((a)*(b))%mod
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using ll  = long long;
using g   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int a, b;cin >> a >> b;
    if(a*b%2 == 0){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: Jalpaiguri Govt Enggineering College
*/
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
#define ll int
#define int long long
#define ld long double
#define ff first
#define ss string 
#define se second
#define endl "\n"
#define alt(v) v.begin(),v.end()
#define ralt(v) v.rbegin(),v.rend()
#define pb emplace_back
#define mp make_pair
#define fab(i,a,b) for(int i=(a);i<(b);i++)
#define fba(i,a,b) for(int i=(b);i>=(a);i--)
int mod=1000000007;
// int mod=998244353;
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};
int dx1[]={-2,-2,-2,-2,-2,2,2,2,2,2,-1,-1,-1,-1,1,1,1,1,0,0};
int dy1[]={0,-1,-2,1,2,0,-1,-2,1,2,-1,-2,1,2,-1,-2,1,2,-2,2};

bool test  = 0;
const int N = 1e3+5;
const int inf = 1e9;
int h,w,m;
void solve()
{
    
    cin>>h>>w>>m;
    map<int,int>row,col;
    vector<pair<int,int>>v;
    for(int i = 1,x,y;i<=m;++i)
    {
        cin >>x>>y;
        x--;
        y--;
        row[x]++;
        col[y]++;
        v.pb(mp(x,y));
    }
    int mxrow = 0;
    set<int>r,c;
    for(auto it : row)
        mxrow = max(mxrow,it.se);
    for(auto it : row)
    {
        if(it.se == mxrow)
            r.insert(it.ff);
    }
    int mxcol = 0;
    for(auto it :col)
        mxcol = max(mxcol,it.se);

    int ans = mxrow + mxcol;
    
    for(auto it : col)
    {
        if(it.se == mxcol)
            c.insert(it.ff);
    }

    int cnt = 0;
    for(auto it :v)
    {
        int x = it.ff;
        int y = it.se;
        if(r.find(x)!=r.end() and c.find(y)!=c.end())
            cnt++;
    }
    int tot = (int)r.size()*(int)c.size();

    bool ok = false;
    if(cnt < tot)
        ok = true;
    if(!ok)
        ans--;
    cout<<ans;

    
}




    

















signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 73412
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .split(config.newline, 2);

A = line[1].split(' ').map(Number);
B = [].concat(A);

k = A.reduce(function (p, c) { return (c > p) ? c : p; }, 0);

sort(A, B, k);

console.log(B.join(' '));

function sort(A, B, k) {
  var C, i;

  C = [];
  for (i = 0; i <= k; i++) C.push(0);

  for (i in A) C[A[i]]++;

  for (i = 1; i <= k; i++) C[i] += C[i - 1];

  for (i = A.length - 1; i >= 0; i--) {
    B[C[A[i]]-1] = A[i];
    C[A[i]]--;
  }
}

Measured memory_bytes: 187164
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a,b,c,d,e,i,j,k=0;
vector<long long>v;
cin>>a>>b;
while(1)
{
        if(a>b)break;
   // cout<<a<<endl;   
        
a=a*2;k++;
       
}
cout<<k<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int mt[10], h[3];

void renew_highest (int i){
	if (i > h[0]){
		h[2] = h[1];
		h[1] = h[0];
		h[0] = i;
		return;
	}
	if (i > h[1]){
		h[2] = h[1];
		h[1] = i;
		return;
	}
	if (i > h[2]){
		h[2] = i;
	}
	return;
}

int main(void) {
	int i;
	for (i=0; i<10; i++){
		scanf ("%d", &mt[i]);
		renew_highest (mt[i]);
	}
	for (i=0; i<3; i++) printf ("%d\n", h[i]);
	return 0;
}

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

typedef long long ll;
#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int A[100000] = {0};
int main(void)
{
	int N;
	cin >> N;
	Rep(i, N){
		int a;
		cin >> a;
		A[a-1]++;
	}
	int n = 0;
	Rep(i, 100000){
		if(A[i] > 1){
			n += A[i] - 1;
		}
	}
	PrintLn(N - (n + 1) / 2 * 2);
	return 0;
}


Measured memory_bytes: 640
a, b = map(int, input().split())
A = [list(input().split()) for i in range(a)]
cost = 1000
e='TLE'
for i in A:
    c = int(i[1])
    if b >= c:
        d = int(i[0])
        cost = min(cost, d)
        e=0
if e==0:
  print(cost)
else:
  print(e)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n, m;
vi p;
vp xy;

const int MAX_N = 101010;

int par[MAX_N];
int rnk[MAX_N];

void init(int n) {
    rep(i, n){
        par[i] = i;
        rnk[i] = 0;
    }
}
int find(int x){
    if(par[x] == x){
        return x;
    }
    else{
        return par[x] = find(par[x]);
    }
}
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rnk[x] < rnk[y]) {
        par[x] = y;
    }
    else{
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
}
bool same(int x, int y) {
    return find(x) == find(y);
}


int main()
{
    cin >> n >> m;
    p.resize(n); rep(i, n) cin >> p[i];
    rep(i, n) p[i]--;


    init(n);
    rep(i, m){
        int x, y; cin >> x >> y;
        unite(x - 1, y - 1);
    }
    int ans = 0;
    rep(i, n){
        if(p[i] == i || find(p[i]) == find(i)) ans++;
    }
    cout << ans << endl;


    return 0;

}

Measured memory_bytes: 1408
main = do
  n    <- getLine
  line <- getLine
  let 
    ls   = map read $ words line :: [Int]
    minv = foldr min   1000000 ls
    maxv = foldr max (-1000000) ls
    sumv = sum ls
    in
      putStrLn $ (show minv) ++ " " ++ (show maxv) ++ " " ++ (show sumv)



Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


string S;
int K;


char solve(){
	int N = SIZE(S);
	int cnt = 0;
	rep(i, 0, N)
		if(S[i] == '1') cnt++;
		else break;
	if(K <= cnt) return '1';
	return S[cnt];
}


signed main(){
	cin >> S;
	cin >> K;

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>

using namespace std;


int main(){
    int N, L;
    cin >> N >> L;
    priority_queue< string, vector<string>, greater<string> > S;
    string s;
    for (int i = 0; i < N; i++){cin >> s; S.push(s);}
    for (int i = 0; i < N; i++){cout << S.top(); S.pop();}


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
int n, maxWeight;
pair<int,int> arr[105];
ll dp[2][100005];
int main() {
    IO;
    cin >> n >> maxWeight;
    for(int i = 1; i <= n; ++i)
        cin >> arr[i].f >> arr[i].s;
    int itr = 0;
    dp[0][0] = 0;
    for(int i = 1; i <= 100000; ++i){
        dp[0][i]= 1e15;
    }
    for(int i = 1;  i <= n; ++i){
        itr = !itr;
        for(int j = 0; j <= 100000; ++j){
            if(j < arr[i].s)
                dp[itr][j] = dp[itr^1][j];
            else
                dp[itr][j] = min(arr[i].f+dp[itr^1][j-arr[i].s], dp[itr^1][j]);
        }
    }
    int ans;
    for(int i = 0; i <= 100000; ++i){
        if(dp[itr][i] <= maxWeight)
            ans = i;
    }
    cout << ans;
    return 0;
}


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

int main(void) {
  string a, b;
  cin >> a >> b;
  int ab = stoi(a + b);
  int root = sqrt(ab);

  if(root*root==ab){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> l(n);
    for(int i=0; i<n; i++){
        cin >> l[i];
    }
    sort(l.begin(),l.end(),greater<int>());
    int sum = 0;
    for(int i=0; i<k; i++){
        sum += l[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int MAXN=100005;

char str[MAXN];

int main()
{
	scanf("%s",str);
	int n=strlen(str),cnt=0;
	for(int i=0;i<n;i++)
		cnt+=str[i]=='p';
	int ans=(n/2)-cnt;
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

const int maxn = 1e2 + 5;
long long seq[maxn];
inline long long abs(long long x) {return x > 0 ? x : -x;}
inline long long min(long long x, long long y) {return x > y ? x : y;} 
int main(){
    long long x, k, d;
    std::cin >> x >> k >> d;
    long long tm = abs(x) / d;
    if (tm >= k ) {
        std::cout << (x > 0 ? abs(x - k * d): abs(x + k * d)) << std::endl;
    }else {
        if ((k - tm) & 1) {
            if (x > 0) {
                std::cout << abs(x - tm * d - d) << std::endl;
            }else {
                std::cout << abs(x + tm * d + d) << std::endl; 
            }
        }else {
            std::cout << (x > 0 ? abs(x - tm * d): abs(x + tm * d)) << std::endl;
        }
    }
}

Measured memory_bytes: 3624
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.....╬╬............
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬..╬.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.....╬..........
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬..╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬....╬╬╬╬╬╬╬...╬╬╬╬╬╬╬╬╬╬......╬......
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬..╬...╬╬╬╬╬╬╬..╬......╬╬╬╬..╬╬╬╬........
# ╬╬╬╬╬╬╬╬╬╬╬╬╬.╬╬.╬....╬╬╬╬╬╬╬╬╬........╬.╬........╬╬.╬╬╬....................
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬....╬.....╬╬╬...........╬.╬╬╬....╬..╬╬..╬╬╬╬╬╬╬╬..............
# ╬╬╬╬╬╬.╬╬╬╬╬╬╬╬........................╬╬╬╬╬╬╬╬╬..╬...╬╬╬╬╬╬╬╬...╬╬╬........
# ╬╬..╬╬╬..╬╬╬╬.....╬╬╬╬╬..................╬╬╬╬╬╬╬.......╬╬.╬╬╬╬..╬....╬......
# ╬╬......╬...╬╬╬╬╬╬╬╬╬╬╬.╬.................╬╬╬╬.........╬..╬╬╬...........╬...
# ╬╬.......╬╬╬╬╬....╬..................................╬....╬╬...............╬
# ╬╬.....╬╬╬╬╬╬╬╬....................................╬╬....╬..................
# ╬╬.....╬╬╬╬╬╬╬╬╬╬╬╬╬╬......................╬..........╬.....................
# ╬╬╬╬..╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬......................................╬................
# ╬╬╬╬╬.......╬╬╬╬╬..........................................╬................
# ╬╬╬╬╬╬╬....................................╬╬╬..............................
# ╬╬╬╬╬╬╬╬╬╬..........................╬..╬╬╬╬╬╬╬╬.............................
# ╬╬╬╬╬╬╬╬╬.╬..╬..................╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.........╬...................
# ╬╬╬╬╬╬╬╬╬╬╬╬..................╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬........╬....................
# ╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬................╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬.......╬......................
# ╬....╬╬╬╬╬╬╬╬╬╬╬.................╬╬╬╬╬╬╬╬╬╬.................................

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    if v[i] - c[i] > 0:
        ans += v[i] - c[i]

print(ans)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#define int long long int
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int j,arr[n];
	for(j=0;j<n;j++)
	  cin>>arr[j];
    sort(arr,arr+n);
    multimap<int,pair<int,int>> mp;
    if(n==1)
    {
		cout<<0<<endl;
	}
	else
	{
		mp.insert({arr[n-1],{arr[n-1],arr[n-1]}});
		int answer=0;
		for(j=n-2;j>=0;j--)
		{
			auto it=mp.end();
			it--;
			answer+=(it->first);
			int val1=it->second.first;
			int val2=it->second.second;
			mp.erase(it);
			int val=arr[j];
			int p1=min(val,val1);
			mp.insert({p1,{val,val1}});
			int p2=min(val,val2);
			mp.insert({p2,{val,val2}});
		}
		cout<<answer<<endl;
	}
}


Measured memory_bytes: 17680
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	fmt.Println(abc126c(n, k))
}

func abc126c(n int, k int) float64 {
	var result float64
	result = 0
	for i := 1; i <= n; i++ {
		if i >= k {
			result += 1.0 / float64(n)
		} else {
			result +=
				(1.0 / float64(n)) *
					math.Pow(0.5, math.Ceil(math.Log2(float64(k)/float64(i))))
		}
	}
	return result
}


Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    while (1)
    {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0)
            break;
        REP(i, h)
        {
            REP(j, w)
            {
                if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
                    cout << "#";
                else
                {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092
fun main(args: Array<String>) = ABC159A.main()

object ABC159A {
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }


    fun main() {
        val (n,m)= readInts()
        val s = n+m
        println(s.C(2) - n*m)
    }


    /*####################################################################################*/


    fun Int.factorial(): Int = when {
        this < 0 -> throw IllegalArgumentException()
        this == 0 -> 1
        else -> (1..this).binaryMerge { a, b -> a * b }
    }

    fun Int.P(k: Int): Int = (this - k + 1..this).binaryMerge { a, b -> a * b }

    fun Int.C(k: Int): Int = this.P(k) / k.factorial()


    fun <T> List<T>.binaryMerge(operation: (a: T, b: T) -> T): T? {
        when (this.size) {
            0 -> return null
            1 -> return this[0]
            2 -> return operation(this[0], this[1])
            3 -> return operation(this[0], operation(this[1], this[2]))
        }
        val half = this.size / 2
        val leftSide = this.subList(0, half - 1)
        val rightSide = this.subList(half, this.lastIndex)
        return operation(leftSide.binaryMerge(operation)!!, rightSide.binaryMerge(operation)!!)
    }

    fun IntRange.binaryMerge(operation: (a: Int, b: Int) -> Int): Int = this.toList().binaryMerge(operation)!!
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    if (x >= 30) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}

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

int main() {
  int N, K;
  int ans = 0;
  int l[60];
  cin >> N >> K;
  rep(i, N) cin >> l[i];

  sort(l, l+N, greater<int>());
  rep(i, K) ans += l[i];

  cout << ans << endl;

  return 0;
}

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

int main() {
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3620
import numpy as np
import sys
sys.setrecursionlimit(10**8)

def nibutan(r, target): # r:sorted list
    l = len(r)
    if l==2:
        if r[0]<target<=r[1]:
            return 1
        elif r[0]>=target:
            return 0
        else:
            return -2
    if r[0]==target:
        return 0
    elif r[-1]==target:
        return l-1
        
    tmp = l//2
    if r[tmp]<target<=r[tmp+1]:
        return tmp+1
    elif target <= r[tmp]:
        return nibutan(r[:tmp+1], target)
    elif target > r[tmp+1]:
        return tmp+nibutan(r[tmp:], target)


n = int(input())
a = np.array(list(map(float, input().split())))
b = np.array(list(map(float, input().split())))

x = a-b
negative = x[x<0]
positive = sorted(x[x>0], reverse=True)
negative_sum = -negative.sum()

if negative_sum<=0:
    print(0)
    exit()

if len(positive)==0:
    print(-1)
    exit()

sub_sum = []
tmp = 0
for i in range(len(positive)):
    tmp += positive[i]
    sub_sum.append(tmp)

#print(positive, negative, sub_sum)

if negative_sum > sub_sum[-1]:
    print(-1)
    exit()
if negative_sum <= sub_sum[0]:
    print(1+len(negative))
    exit()

print(nibutan(sub_sum, negative_sum)+len(negative)+1)

# l = len(positive)
# s = 0
# f = l

# for i in range(l):
#     #print(f,s)
#     tmp = (f+s)//2
#     if sub_sum[max(0,tmp-1)]<negative_sum<=sub_sum[tmp]:
#         print(tmp-1+len(negative))
#         exit()
#     # elif sub_sum[tmp] < negative_sum <= sub_sum[min(tmp+1, l-1)]:
#     #     print(tmp+1+len(negative),tmp)
#     #     exit()
#     elif sub_sum[tmp]>negative_sum:
#         f = min(tmp+1, l)
#     elif sub_sum[tmp]<negative_sum:
#         s = tmp
    


    


Measured memory_bytes: 23232
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		while(scan.hasNext()){
			String N = scan.next();
			int repeat;
			String result = "";
			String character;
			char text[] = N.toCharArray();
			for(int i = 0 ; i < text.length ; i++){
				if(text[i] == '@'){
					repeat = Integer.parseInt(String.valueOf(text[i+1]));
					character = String.valueOf(text[i+2]);
					i += 2;
					for(int j = 0 ; j < repeat ; j++){
						result += character;
					}
				}else{
					result += String.valueOf(text[i]);
				}
			}
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 26156
#include <stdio.h>

int main(){
 
 int n,i,r,t;

 scanf("%d",&n);

 for(i=3;i<=n;i++){
  t = i;
  r = t%3;
  if(r==0){
   printf(" %d",i);
  }else{
   while(t>0){
    r = t%10;
    if(r==3){
     printf(" %d",i);
     break;
    }else{
     t /= 10; 
    } 
   }
  }
  
 }
 printf("\n");

 return 0;
}

Measured memory_bytes: 596
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    d, g = LI()
    lst = [0 for _ in range(d)]
    for i in range(d):
        p, c = LI()
        lst[i] = (p, c)
    
    ans = float("inf")
    bits = itertools.product([0,1],repeat=d)

    for bit in bits:
        point = 0
        cnt = 0
        for i in range(d):
            if bit[i] == 1:
                cnt += lst[i][0]
                point += (i+1)*100*lst[i][0] + lst[i][1]
        for i in range(d-1,-1,-1):
            if point>=g:
                break
            if bit[i] == 0:
                for _ in range(lst[i][0]-1):
                    cnt += 1
                    point += (i+1)*100
                    if point>=g:
                        break
        if point>=g:
            ans = min(ans,cnt)
    print(ans)

main()            


Measured memory_bytes: 75244
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ax=[a[i] for i in range(n+1)]

ans=0

for i in range(n):
    ans+=min(ax[i]+ax[i+1],b[i])
    ax[i+1] = max(0,ax[i+1]-max(0,b[i]-ax[i]))

print(ans)

Measured memory_bytes: 19156
#include<stdio.h>
#include<stdlib.h>
int cy[111111];
void set(int q,int w){
    cy[q] = w;
}
int compare(const void *a, const void *b) {
    return cy[*(int*)a] - cy[*(int*)b];
}
int main() {
    int n, m, p[111111], y[111111], i,order[111111];
    scanf("%d%d", &n, &m);
    for (i = 0; i < m; i++)
        order[i] = i;
    for (i = 0; i < m; i++) {
        scanf("%d%d", &p[i], &y[i]);
        set(i, y[i]);
    }
    qsort(order, m, sizeof(int), compare);
    long num[111111], cp, t[111111];
    for (i = 0; i < 111111; i++)
        t[i] = 0;
    for (i = 0; i < m; i++) {
        t[p[order[i]]]++;
        cp = p[order[i]];
        cp = cp * 1000000;
        num[order[i]]= t[p[order[i]]]+cp;
    }
    for (i = 0; i < m; i++) {
        cp = num[i];
        while (cp < 100000000000) {
            printf("0");
            cp = cp * 10;
        }
        printf("%ld\n", num[i]);
    }
    return 0;
}

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

int main(){

  int n,i;
  double x1,x2,x3,y1,y2,y3,xp,yp,A,B,C,D,E,F,r;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
    A = 2*(x1-x2);
    B = 2*(y1-y2);
    C = x1+x1 - x2*x2 + y1*y1 - y2*y2;
    D = 2*(x2-x3);
    E = 2*(y2-y3);
    F = x2*x2 - x3*x3 + y2*y2 - y3*y3;

  
    xp = (B*F - E*C)/(B*D - A*E);
    yp = (C*D - A*F)/(B*D - A*E);
    r = sqrt((xp - x1)*(xp - x1) + (yp - y1)*(yp - y1));


    printf("%.3lf %.3lf %.3lf\n",round(xp*1000)/1000,round(yp*1000)/1000,round(r*1000)/1000);
  }


  return 0;
}

Measured memory_bytes: 668
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(reader.readLine());
		String[] strArray = reader.readLine().split(" ");
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = Integer.parseInt(strArray[i]);
		}
		
		int q = Integer.parseInt(reader.readLine());
		strArray = reader.readLine().split(" ");
		int ans = 0;
		for (int i = 0; i < q; i++) {
			ans += binarySearch(arr, Integer.parseInt(strArray[i]));
		}
		System.out.println(ans);		
	}
	
	public static int binarySearch(int[] arr, int target) {
		
		if (arr == null || arr.length == 0) {
			return 0;
		}
		int n = arr.length;
		
		int floor = 0;
		int ceiling = n - 1;
		
		while (floor <= ceiling) {
			int guessIdx = floor + (ceiling - floor) / 2;
			int guessValue = arr[guessIdx];
			if (guessValue == target) {
				return 1;
			}
			if (guessValue < target) {
				floor = guessIdx + 1;
			} else {
				ceiling = guessIdx - 1;
			}
		}
		return 0;
	}
}


Measured memory_bytes: 51612
#include <iostream>
#include <algorithm>
using namespace std;
int n,c[1005],w[1005],dp[1005];
bool d[1005][1005];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++)cin>>c[i]>>w[i+1];
    for(int i=0;i<=n;i++)w[i+1]+=w[i];
    for(int i=0;i<n;i++)d[i][i]=true;
    for(int k=1;k<n;k++){
        for(int i=0;i+k<n;i++){
            int l=i,r=i+k;
            if(d[l][r-1]&&w[r]-w[l]<=c[r])d[l][r]=true;
            if(d[l+1][r]&&w[r+1]-w[l+1]<=c[l])d[l][r]=true;
        }
    }
    for(int i=1;i<=n;i++)dp[i]=n;
    int ans=0;
    int i=0;
    while(i<n){
        int j=i;
        while(d[i][j+1])j++;
        i=j+1;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4100
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,w=MI()
WV=[LI() for i in range(n)]
dp=[[0]*(w+1) for i in range(n+1)]
for i in range(n):
    for j in range(w+1):
        if j-WV[i][0]>=0:
            dp[i+1][j]=max(dp[i+1][j],dp[i][j],dp[i][j-WV[i][0]]+WV[i][1])
        else:
            dp[i+1][j]=max(dp[i+1][j],dp[i][j])
    #print(dp)
print(max(dp[-1]))


            

    
    



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

int main(){
int N, K;
  cin >> N >> K;
long long mi = 1000000010;
long long d[N];
  
  for(int i = 0;i < N;i++) cin >> d[i];
  
  sort(d, d + N);
  
  for(int i = 0;i < N - K + 1;i++){
  mi = min(mi,abs(d[i + K - 1] - d[i]));
  }
  
  cout << mi << endl;
  return 0;
  
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    ll n;
    cin >> n;
    ll a[n];
    std::vector<ll> v;
    int ans = 1;
    rep(i, n) {
        cin >> a[i];
        v.push_back(a[i]);
    }
    Sort(v);
    rep(i, n-1) {
        if ( v.at(i) == v.at(i+1) ) {
            ans = 0;
        }
    }
  
  	cout << (ans ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 3444