akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
vector<int> ans;
    
void show(){
    for(int i=0;i<ans.size();i++){
        cout << ans[i];
        if(i!=ans.size()-1){
            cout << " ";
        }
    }
    cout << endl;
    return ;
}

int main(){
    int n;
    cin >> n;
    if(n==3){
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }else{
        int cnt = 0;
        ans.PB(2);
        ans.PB(4);
        ans.PB(3);
        ans.PB(9);
        cnt = 4;
        if(n%2==0){
            for(int i=1;i<5000;i++){
                if(cnt==n)break;
                cnt+=2;
                ans.PB(6*i+2);
                ans.PB(6*i+4);
            }
            if(cnt==n){
                show();
            }else{
                for(int i=1;i<2500;i++){
                    if(cnt==n)break;
                    cnt+=2;
                    ans.PB(12*i+9);
                    ans.PB(12*i+3);
                }
                if(cnt==n){
                    show();
                }else{
                    for(int i=1;i<=5000;i++){
                        if(cnt==n)break;
                        cnt++;
                        ans.PB(6*i);
                    }
                    show();
                }
            }
        }else{
            ans.PB(6);
            cnt++;
            for(int i=1;i<5000;i++){
                if(cnt==n)break;
                cnt+=2;
                ans.PB(6*i+2);
                ans.PB(6*i+4);
            }
            if(cnt==n){
                show();
            }else{
                for(int i=1;i<2500;i++){
                    if(cnt==n)break;
                    cnt+=2;
                    ans.PB(12*i+9);
                    ans.PB(12*i+3);
                }
                if(cnt==n){
                    show();
                }else{
                    for(int i=1;i<=5000;i++){
                        if(cnt==n)break;
                        cnt++;
                        ans.PB(6*i+6);
                    }
                    show();
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] cnt = new int[26];
		
		while (sc.hasNext()) {
			String str = sc.nextLine();
			
			for (int i = 0; i < str.length(); i++) {
				char c = str.charAt(i);
				
				if (Character.isUpperCase(c))
					cnt[c - 'A']++;
				else if (Character.isLowerCase(c))
					cnt[c - 'a']++;
			}
		}
		for (int i = 0; i < 26; i++) {
			System.out.printf("%c : %d\n", 'a' + i, cnt[i]);
		}
	}
}


Measured memory_bytes: 26244
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    int D, T, S;
    cin >> D >> T >> S;
    if (D <= T*S) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3620
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int ar[N];
int32_t main()
{
    IOS;
    for(int i=0;i<N;i++)
    {
        int x=i;
        while(x)
        {
            x%=setbits(x);
            ar[i]++;
        }
    }
    int n;
    cin>>n;
    string s;
    cin>>s;
    int b=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
        b++;
    }
    /**if(b==0)
    {
        for(int i=0;i<n;i++)
        cout<<1<<"\n";
        return 0;
    }**/
    int p1[n],p2[n];
    int t1=1,t2=1;
    int c1=b+1,c2=b-1;
    for(int i=0;i<n;i++)
    {
        p1[i]=t1;
        t1=(t1*2)%c1;
        if(c2>0)
        {
            p2[i]=t2;
            t2=(t2*2)%c2;
        }
    }
    int n1=0,n2=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
        {
            n1=(n1+p1[n-i-1])%c1;
            if(c2)
            n2=(n2+p2[n-1-i])%c2;
        }
    }
    int ans[n];
    for(int i=0;i<n;i++)
    {
        if(c2==0&&s[i]=='1')
        ans[i]=0;
        else
        {
            if(s[i]=='1')
            {
                int cur=(n2-p2[n-i-1]+c2)%c2;
                //cout<<cur<<" "<<ar[cur]<<"\n";
                ans[i]=1+ar[cur];
            }
            else
            {
                int cur=(n1+p1[n-i-1])%c1;
                //cout<<cur<<' '<<ar[cur]<<'\n';
                ans[i]=1+ar[cur];
            }
        }
    }
    for(int i=0;i<n;i++)
    cout<<ans[i]<<"\n";
}

Measured memory_bytes: 9944
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int find(int x,int t[]){
   if(t[x]==x)
     return x;
   else
     return t[x]=find(t[x],t); 
}
int main() {
  int n,m,x,y,z;
  cin >> n>>m;
  int t[n];
  rep(i,n)
    t[i]=i;
  int sum=n;
  rep(i,m){
     cin>>x>>y>>z;
     x--;y--;
     x=find(x,t);
     y=find(y,t);
     if(x==y)
       continue;
     if(x<y)
       t[y]=x;
     else
       t[x]=y;
     sum--;
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;
const int MOD = (int)1e9 + 7;
template <class T>
inline T in()
{
    T x;
    cin >> x;
    return x;
}

signed main()
{
    string s = in<string>();
    int r = 15 - s.size();
    int count = 0;
    for (auto &&c : s)
    {
        if(c == 'o'){
            count++;
        }
    }
    cout << (count + r >= 8 ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 256
package main

import (
        "fmt"
        "os"
        "bufio"
        "strings"
        "strconv"
)

func main() {
        sc := bufio.NewScanner(os.Stdin)

        for sc.Scan() {
                digits := 0
                num := 0
                for _, s := range strings.Fields(sc.Text()) {
                        i, _ := strconv.Atoi(s)
                        num += i
                }
                for num > 0 {
                        digits += 1
                        num /= 10
                }
                fmt.Printf("%d\n", digits)
        }
}



Measured memory_bytes: 1064
n,m,l = gets.split.map {|s| s.to_i}
  a = Array.new
  b = Array.new
 

for i in 1..n
     c = gets.split.map{|s| s.to_i}
     a.push(c)
end

for j in 1..m
     c = gets.split.map{|s| s.to_i}
     b.push(c)
end


for i in 1..n
    for j in 1..l
      print " " unless j == 1
      s = 0
      for k in 1..m
      s += a[i-1][k-1]*b[k-1][j-1]
      end
      print s
    end
    print "\n"
end



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

int N, M;
vi A;
string s;

int main(){
    cin >> N >> M;
    int a;
    float vote_sum = 0;
    for(int i=0; i < N; ++i){
        cin >> a;
        A.push_back(a);
        vote_sum += a;
    }
    // 降順ソート
    sort(A.begin(), A.end(), std::greater<int>());
    if(A[M-1] < vote_sum / (4 * M)) cout << "No";
    else cout << "Yes";
	return 0;
}

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

int main()
{
    ll n,m,k;
    cin>>n>>m>>k;

 if (k<=n)
  cout<<n-k<<" "<<m<<endl;

  else if(k<=n+m)
    cout<<0<<" "<<n+m-k<<endl;

  else
    cout<<0<<" "<<0<<endl;

  exit(0);



}


Measured memory_bytes: 3588
fun main(args: Array<String>) {
    var N = readLine()!!.toLong()

    // 奇数の場合 0
    if (N % 2 == 1L) {
        println(0)
        return
    }

    var count = 0L
    N = N / 2
    while (N > 0) {
        count += N / 5
        N /= 5
    }

    println(count)
}




Measured memory_bytes: 31660
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i-- )
int main() {

ll k,n;
cin>>n>>k;
vector<ll>A(n);
ll ans=0;
REP(i,0,n)
{
    cin>>A[i];
    //ans+=A[i];
}
 sort(A.rbegin(),A.rend());
 REP(i,k,n)
 {
     ans+=A[i];
 }
 cout<<ans;
 
	return 0;
}

Measured memory_bytes: 1792
a, b, k = map(int, input().split())

x = b - a
if x < 2 * k:
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(a, a + k):
        print(i)

    for i in range(b - k + 1, b + 1):
        print(i)


Measured memory_bytes: 3060
n,y= map(int,input().split())
f = [False]

#binary_search
def binary_search(x,r):
    l = 0
    while(r-l>=1):

        i = int((l+r)/2)
        # print(i)
        if(4000*i==x):
            f[0] = True
            return i
        elif(4000*i<x):
            l=i+1
        else:
            r = i
    #見つからなかった
    return 0


for a in range(0,n+1):
    if f[0]==True:
        break
    b = int(binary_search(y-9000*a-1000*n,n-a+1))
    if f[0] == True:
        print(a,b,n-a-b)
        break
if f[0]==False:
    print(-1,-1,-1)


Measured memory_bytes: 3064
import bisect
import sys
input = sys.stdin.readline

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

INF = float('inf')
for _ in range(q):
    x = int(input())
    if x > s[a-1]:
        sl = x - s[a-1]
        sr = INF
    elif x < s[0]:
        sl = INF
        sr = s[0] - x
    else:
        si = bisect.bisect_right(s, x)
        sl = x - s[si-1]
        sr = s[si] - x

    if x > t[b-1]:
        tl = x - t[b-1]
        tr = INF
    elif x < t[0]:
        tl = INF
        tr = t[0] - x
    else:
        ti = bisect.bisect_right(t, x)
        tl = x - t[ti-1]
        tr = t[ti] - x

    ans = min(max(sl, tl), max(sr, tr))

    ans = min(ans, sr*2+tl)
    ans = min(ans, sr+tl*2)
    ans = min(ans, sl*2+tr)
    ans = min(ans, sl+tr*2)

    print(ans)


Measured memory_bytes: 115932
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    int N; cin >> N;
    int A[N]; rep(i, N) cin >> A[i];
    ll ans = 1;
    sort(A, A+N, greater<int>());
    int j = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == A[i+1]) {
            ans *= A[i];
            i++; j++;
        }
        if (j == 2){
            cout << ans << endl;
            return 0;
        }
    }

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

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

int main() {
  ll n;cin>>n;
  string s=" ";
    while(n){
      n--;
    s+=n%26+'a';
      n/=26;
    }
  reverse(all(s));
  cout<<s<<endl;
}

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

int main() {
  ll n,ans=1;
  string s;
  cin >> n;
  vector<string> sc;
  
  rep(i,n) {
    cin >> s;
    sc.push_back(s);
  }
  sort(sc.begin(),sc.end());
  rep(i,n-1) {
    if ((sc[i])!=(sc[i+1])) ans++;
  }

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

Measured memory_bytes: 11592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,k,x,y,dir[4][2]={1,0,-1,0,0,1,0,-1},u[850][850];
char a[850][850];
struct node {
    int x;
    int y;
    int step;
};
int judge(int x,int y){
    if(x<1 || x>n || y<1 || y>m)
        return 1;
    if(u[x][y] == 1 || a[x][y] == '#')
        return 1;
    return 0; 
}
void bfs(){
    node init;
    queue<node> q;
    node next;
    init.x = x;
    init.y = y;
    init.step = 0;
    u[x][y] = 1;
    q.push(init);
    while(!q.empty()){
        node tmp = q.front();
        q.pop();
        for(int i=0;i<4;i++){
            next.x = tmp.x+dir[i][0];
            next.y = tmp.y+dir[i][1];
            if(judge(next.x,next.y)) continue;
            a[next.x][next.y]='c';
            next.step = tmp.step+1;
            u[next.x][next.y] = 1;
            if(next.step<k)q.push(next);
        }
    }
}
int main(){
    while(cin>>n>>m>>k){
        memset(u,0,sizeof(u));
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                cin>>a[i][j];
                if(a[i][j]=='S')x=i,y=j;
            }
        }
        bfs();
        int ans=100000;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(a[i][j]=='S'||a[i][j]=='c'){
                    int num=1;
                    int tmp=min(min(i-1,j-1),min(n-i,m-j));
                    num+=(tmp+k-1)/k;
                    ans=min(ans,num);
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    stack<int> s;
    int a, b;
    string str;

    while (cin >> str) {
        if (str == "+") {
            b = s.top(); s.pop();
            a = s.top(); s.pop();
            s.push(a+b);
        } else if (str == "-") {
            b = s.top(); s.pop();
            a = s.top(); s.pop();
            s.push(a-b);
        } else if (str == "*") {
            b = s.top(); s.pop();
            a = s.top(); s.pop();
            s.push(a*b);
        } else s.push(atoi(str.c_str()));
    }

    cout << s.top() << endl;
}


Measured memory_bytes: 3176
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<ctime>
#include<algorithm>
#include<sstream>
#include<bitset>
#define scand(a) scanf("%d",&a)
#define scandd(a,b) scanf("%d%d",&a,&b)
#define scanddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define mst(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x&-x)
#define lson rt<<1
#define rson rt<<1|1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fLL;
const int maxn=1e4+5;
const ll mod=1e9+7;

int main()
{
	#ifdef local
	freopen("1.txt","r",stdin);
	#endif
	int N,d;
	scandd(N,d);
	ll k=d*1LL*d;
	int sum=0;
	while(N--)
	{
		ll x,y;
		scanf("%lld%lld",&x,&y);
		if(x*x+y*y<=k)sum++;
	}
	printf("%d",sum);
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll n;
    cin>>n;
    ll ans=0,x=0,y=0,z=0;
    rep(i,n){
        string s;
        cin>>s;
        rep(i,s.size()){
            if(s[i]=='A' && s[i+1]=='B') ans++;
        }

        if(s[0]=='B' && s.back()=='A') x++;
        else if(s[0]=='B') y++;
        else if(s.back()=='A') z++;
    }

    if(y==0 && z==0){
        ans+=max(x-1,0LL);
    }
    else if(y==z){
        ans+=x+y;
    }
    else if(y>z){
        ans+=x+min(y,z);
    }
    else if(y<z) ans+=x+min(y,z);

    cout<<ans<<endl;
}


Measured memory_bytes: 3600
/* bimillahir rahmanir rahim...
 * AUTHOR
 * mubin_akib */
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b) - 1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a) - 1; i >= 0; i--)
#define REP(i, a, b) for(int i = a; i <= (b); ++i)
#define trav(a,x) for (auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const char nl = '\n';

int a[1234567];

void solve() {
    int n;
    cin >> n;
    while(n > 0){
        n -= 1000;
    }
    if(n < 0) cout << -n << nl;
    else cout << n << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3672
/*		author:: ajeet  */
/*			*/

	#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	int32_t main(){
		IOS;
		int w,s;
		cin>>s>>w;
		if(w>=s) cout<<"unsafe"<<endl;
		else cout<<"safe"<<endl;
		return 0;
	}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll a,b;
  cin >> a >> b;
  if(a<6)cout << 0 << endl;
  else if(a<13)cout << b/2 << endl;
  else cout << b << endl;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <math.h> 
#include <vector>
#include <algorithm>
#include <iomanip>      // std::setprecision
#include <map>
#include <unordered_map>
#include <string>
#include <set>
#include <unordered_set>

using namespace std;

int main()
{
	int a,N,sum = 0;
	std::vector<int> nums;
	int num_matches = 0;
	int num_unmatches = 0;
	std::cin >> N;
	for (int i = 0; i < N; i++)
	{
		std::cin >> a;
		nums.push_back(a);
	}
	for (int i = 0; i < N - 1; i++)
	{
		for (int j = i + 1; j < N; ++j)
		{
			sum += nums[i] * nums[j];
		}
	}
	std::cout << sum;	
}

Measured memory_bytes: 256
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const double EPS = 1e-9;

struct Point {
    double x, y;
    Point opBinary(string op)(in Point a) const {
        static if (op == "+" || op == "-") {
            return Point(mixin("x" ~ op ~ "a.x"),
                         mixin("y" ~ op ~ "a.y"));
        }
    }
    Point opBinary(string op)(double a) const {
        static if (op == "*" || op == "/") {
            return Point(mixin("x" ~ op ~ "a"),
                         mixin("y" ~ op ~ "a"));
        }
    }
}
double dot(in Point a, in Point b) {
    return a.x * b.x + a.y * b.y;
}
double cross(in Point a, in Point b) {
    return a.x * b.y - a.y * b.x;
}
double norm(in Point a) {
    return sqrt(a.x * a.x + a.y * a.y);
}
int CCW(Point a, Point b, Point c) {
    b = b - a; c = c - a;
    if (cross(b, c) > EPS) return +1;
    if (cross(b, c) < -EPS) return -1;
    if (dot(b, c) < 0) return 2;
    if (b.norm < c.norm) return -2;
    return 0;
}

struct Segment {
    Point a, b;
}
bool intersect(in Segment s, in Segment t) {
    return CCW(s.a, s.b, t.a) * CCW(s.a, s.b, t.b) <= 0 &&
        CCW(t.a, t.b, s.a) * CCW(t.a, t.b, s.b) <= 0;
}
Point intersection(in Segment s, in Segment t) {
    double d = cross(t.b - t.a, s.b - s.a);
    assert(abs(d) >= EPS);
    return s.a + (s.b - s.a) * (cross(t.b - t.a, t.b - s.a) / d);
}

Segment S;
Segment[] T;
int N;
int[] W;
void input() {
    scanf("%lf %lf %lf %lf\n", &S.a.x, &S.a.y, &S.b.x, &S.b.y);
    scanf("%d\n", &N);
    T = new Segment[N];
    W = new int[N];
    foreach (i; 0 .. N) {
        scanf("%lf %lf %lf %lf", &T[i].a.x, &T[i].a.y, &T[i].b.x, &T[i].b.y);
        int o, l;
        scanf("%d %d\n", &o, &l);
        W[i] = (o ^ l);
    }
}

void solve() {
    alias Tuple!(Point, int) Z;
    Z[] ips;
    foreach (i; 0 .. N) {
        if (S.intersect(T[i])) {
            ips ~= Z(S.intersection(T[i]), W[i]);
        }
    }
    ips.sort!"a[0].x < b[0].x";
    int ans = 0;
    if (ips.length <= 1) {
        ans = 0;
    } else {
        int prev = ips[0][1];
        foreach (i; ips[1 .. $].map!("a[1]")) {
            if (i == prev) continue;
            prev = i;
            ans++;
        }
    }
    ans.writeln;
}
 
void main() {
    int T; scanf("%d\n", &T);
    foreach (t; 0 .. T) {
        input;
        solve;
    }
}

Measured memory_bytes: 2848
#include "bits/stdc++.h"

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

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int N, K; cin >> N >> K;
	vector<int> p(N);
	rep(i, N)cin >> p[i];
	sort(p.begin(), p.end());
	cout << accumulate(p.begin(), p.begin() + K, 0);
}



Measured memory_bytes: 3628
using System;

namespace _1_6_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] hoge = new int[n];
            string[] str = Console.ReadLine().Split(' ');
            for(int i = 0; i < n; i += 1)
            {
                hoge[i] = int.Parse(str[i]);
            }
            Array.Reverse(hoge);
            for(int i = 0; i < n; i += 1)
            {
                if (i == 0) Console.Write(hoge[i]);
                else
                {
                    Console.Write(" ");
                    Console.Write(hoge[i]);
                }
            }
            Console.Write("\n");
        }
    }
}

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

using namespace std;

int main() {
	int W,H,r,x,y;;
	cin >> W >> H >> x >> y >> r;
	string ans;
	if (
	   (r<=x) && (x+r<=W) &&
	   (r<=y) && (y+r<=H) 
		)   ans = "Yes";	
	else	ans = "No";
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;




int main()
{
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int A,B,C,D,E;
    int result;
    
    
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&D);
    scanf("%d",&E);
    
    if(A<0) result=(-A)*C+D+B*E;
    else if(A==0)result=D+B*E;
    else result=(B-A)*E;
    
    printf("%d\n",result);
    
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
ll a[3];
ll cost(ll x[3]){
  return abs(a[0]-x[0]) + abs(a[1]-x[1]) + abs(a[2] - x[2]);
}
ll func(ll a[],ll n){
  ll minimum=10000;
  ll x[3];
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        x[0] = a[i];
        x[1] = a[j];
        x[2] = a[k];
        sort(x,x+3);
        //cout << x[0] << " " << x[1] << " " << x[2] << " " << cost(x) << endl;
        minimum = min(minimum,cost(x));
      }
    }
  }
  ll b[n];
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=0;k<n;k++){
        b[k] = a[k];
      }
      b[i] += b[j];
      b[j] = b[n-1];
      minimum = min(minimum,10+func(b,n-1));
    }
  }
  return minimum;
}
int main(){
  ll n;
  cin >> n >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  ll l[n];
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  cout << func(l,n);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,a[88];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int ans=1000;
	for(int i=0;i<n-1;i++)
	{
		if(a[i]<a[i+1])
		{
			int tmp=ans/a[i];
			ans%=a[i];
			ans+=tmp*a[i+1];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3628
// #define _GLIBCXX_DEBUG

#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <vector>
#include <chrono>
#include <cmath>

#define int long long

using namespace std;


signed main() {
  int n, k;
  cin >> n >> k;

  vector<int> counter(n);

  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      a--;
      counter[a]++;
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (counter[i] == 0) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
my $N = <STDIN>;
chomp($N);
my $S = <STDIN>;
chomp($S);
if ( $N % 2 ) {
    print 'No';
} else {
    my $n2 = $N/2;
    my $i = 0;
    my $s1 = '';
    my $s2 = '';
    foreach my $t (split("", $S) ) {
        if ( $i < $n2 ) {
            $s1 .= $t;
        } else {
            $s2 .= $t;
        }
        $i++;
    }
    if ( $s1 eq $s2 ) {
        print 'Yes';
    } else {
        print 'No';
    }
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );
	final char[] ar = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', '?', '!', ' ' };
	while ( stdin.hasNextLine() ) {

	    final String line = stdin.nextLine();
	    if ( !check( line ) ) {
		System.out.print( "NA" );
	    } else {
		for ( int i = 0; i < line.length() / 2; i++ ) {
		    int f = line.charAt( 2 * i ) - '1';
		    int b = line.charAt( 2 * i + 1 ) - '1';
		    System.out.print( ar[ 5 * f + b ] );
		}
	    }
	    System.out.println();
	}
    }

    static boolean check( final String line ) {
	if ( line.length() % 2 == 1 ) {
	    return false;
	}
	for ( int i = 0; i < line.length() / 2; i++ ) {
	    int f = line.charAt( 2 * i ) - '1';
	    int b = line.charAt( 2 * i + 1 ) - '1';
	    if ( f < 0 || 6 <= f || b < 0 || 5 <= b ) {
		return false;
	    }
	}
	return true;
    }	
}

Measured memory_bytes: 17244
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n,m,x;
    cin >> n >> m >> x;
    int l=0,r=0;
    rp(i,m){
        int a;
        cin >> a;
        if(a<x) l++;
        else r++;
    }
    print(min(l,r));
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
import sys,math,copy,queue,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(-1,0),(0,1),(0,-1))

N,M = LI()
p = []
i = 1
for j in range(M,0,-2):
    p.append([i,i+j])
    i += 1
i = M+2
for j in range(M-1,0,-2):
    p.append([i,i+j])
    i += 1
for ans in p:
    print (*ans)

Measured memory_bytes: 82596
#include "bits/stdc++.h"

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")



using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    double a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    double res=(a[0]+a[1])/2;
    for(int i=2;i<n;i++)
        res=(res+a[i])/2;
    cout<<res<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
typedef long long ll;
using namespace std;


int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> X(M);
    for(int i = 0; i < M; i++) cin >> X[i];
    sort(X.begin(),X.end());
    vector<int> diff(M-1);
    if (N >= M){
        cout << 0 << endl;
        return(0);
    }
    for(int i = 0; i < M-1; i++)
    {
        diff[i] = X[i+1] - X[i];
    }
    sort(diff.begin(),diff.end(),greater<int>());
    for(int i = 0; i < N -1; i++)
    {

       diff[i] = 0;
    }
    int res = 0;
    for(int i =0; i < M -1; i++)
    {
        res+= diff[i];
    }
    cout << res << endl;
}

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

#define CIN1(a) long long a;cin >> a;
#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1){}  //コントラクタ

    bool unionSet(int x, int y) {   //併合
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;    //統合後のroot(data[x])さえ更新すれば，findSetで後々更新できる
        }
        return x != y;
    }
    bool findSet(int x, int y) {    //同じグループか判定
        return root(x) == root(y);
    }
    int root(int x) {   
        return data[x] < 0 ? x : data[x] = root(data[x]);   //値を更新しつつハッシュを手繰る
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main(){
    CIN2(n,m)

    UnionFind h(n);

    rep(i,m){
        CIN3(x,y,z)
        h.unionSet(x-1,y-1);
    }

    set<int> v;
    int tmp = v.size();
    int ans = 0;
    rep(i,n){
        v.insert(h.root(i));
        if(tmp!=v.size()) ans++;
        tmp = v.size();
    }
    cout << ans << endl;
}





Measured memory_bytes: 5376
using System;
using System.Collections.Generic;
using System.IO;

namespace Hill
{
    class Program
    {
        static void Main()
        {
            var list = new List<int>();
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            string str;
            Console.SetOut(sw);

            for (int i = 0; i < 10; i++)
            {
                str = Console.ReadLine();
                list.Add(int.Parse(str));
            }

            list.Sort();
            list.Reverse();
            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(list[i]);
            }
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 9380
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
#define MOD 1000000007
 
ll arr[105], dp[105][100005];

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
    ll i, j, n, k;
	cin >> n >> k;
	
    for(i=1; i<=n; i++) 
        cin >> arr[i];
	
    dp[0][0] = 1;
	for(i=1; i<=k; i++) 
        dp[0][i] = 0;
	
    for(i=1; i<=n; i++){
		for(j=1; j<=k; j++)
			dp[i-1][j] = (dp[i-1][j]+dp[i-1][j-1])%MOD;
			
		for(j=0; j<=k; j++){
			ll mn=j-arr[i]-1;
			dp[i][j] = dp[i-1][j];
			if(mn>=0) 
                dp[i][j] = (dp[i][j]-dp[i-1][mn]+MOD)%MOD;
		}
	}
	cout << dp[n][k];
	return 0;
}

Measured memory_bytes: 82436
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int mod = 1000000007;

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int func(ll i, ll j) {

	if (i % j == 0) {
		return 0;
	}
	else {

		return 1;
	}
}

int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	C / B+func(C,B) <=A / D+func(A,D) ? cout << "Yes" : cout << "No";
	

}

Measured memory_bytes: 3488
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	static long[] kosu;
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		long A=sc.nextLong();
		long B=sc.nextLong();
		long[] bits=new long[48];
		bits[0]=1L;
		for(int i=1; i<48; i++) {
			bits[i]=bits[i-1]*2;
		}
		kosu=new long[48];
		for(int i=0; i<48; i++) {
			kosu[i]=0;
		}

		for(int i=0; i<48; i++) {
			kosu_p(i,B);
			if(A>0) {
				kosu_d(i,A-1);
			}
		}
		for(int i=0; i<48; i++) {
			kosu[i]%=2;
		}
		long ans=0;
		for(int i=0; i<48; i++) {
			ans+=kosu[i]*bits[i];
		}
		pl(ans);
	}
	public static void kosu_p(int bits,long range) {
		long nijyo=1L;
		for(int i=0; i<=bits; i++) {
			nijyo*=2;
		}
		long tmp=0;
		if(bits==0) {
			tmp=(range+1)/2L;
			kosu[bits]+=tmp;
		}
		else {
			tmp=((range+1)/nijyo)*(nijyo/2);
			long amr=(range+1)%nijyo;
			if(amr>nijyo/2) {
				tmp+=amr-nijyo/2;
			}
			kosu[bits]+=tmp;
		}
	}
	public static void kosu_d(int bits,long range) {
		long nijyo=1L;
		for(int i=0; i<=bits; i++) {
			nijyo*=2;
		}
		long tmp=0;
		if(bits==0) {
			tmp=(range+1)/2L;
			kosu[bits]-=tmp;
		}
		else {
			tmp=((range+1)/nijyo)*(nijyo/2);
			long amr=(range+1)%nijyo;
			if(amr>nijyo/2) {
				tmp+=amr-nijyo/2;
			}
			kosu[bits]-=tmp;
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 22612
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let d = i.read::<usize>();
    let s = match d {
        22 => "Christmas Eve Eve Eve",
        23 => "Christmas Eve Eve",
        24 => "Christmas Eve",
        25 => "Christmas",
        _ => unreachable!(),
    };
    writeln!(o, "{}", s).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4352
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),f=0;
		do {
			if(n%10==9) f=1;
			n/=10;
		}while(n!=0);
		System.out.print(f==0?"No":"Yes");
	}
}

Measured memory_bytes: 23124
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 23, 2019
 * 
 */

#include <bits/stdc++.h>

//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define _f first
#define _s second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;


bool compare( pll a , pll b) {
    return a.second < b.second;
}


bint t;
bint timecounter = 0;

bool check(pll a){
    timecounter += a.first;
    return ((timecounter<=a.second) and (timecounter <= t));
}

auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    int n;
    cin>>n;

    vpll v;
    rep(n){
        int t1 , t2 ;
        cin>>t1>>t2;
        v.pb({t1,t2});
    }
    sort(all(v),compare);
    t = v.back().second;
    
    if(all_of(v.begin() , v.end() , check))
        puts("Yes");
    else
        puts("No");

    return ;
}




int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 6512
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 5000001
#define INF -1000000
int parent(int);
int left(int);
int right(int);
void maxheapify(int *,int);
void buildmaxheap(int*);
void swap(int *,int *);
int heapextractmax(int *);
void heapincreasekey(int *,int,int);
void maxheapinsert(int *,int);
int H;
int main(){
  int max,A[MAX],id;
  char str[10];
  while(1){
  scanf("%s",str);
  if(strcmp(str,"end")==0)break;
  if(strcmp(str,"extract")==0)
    {
    max=heapextractmax(A);
    printf("%d\n",max);
    }
  if(strcmp(str,"insert")==0)
    {
      scanf("%d",&id);
      maxheapinsert(A,id);
    }
  }
  return 0;
}
void swap(int *p1,int *p2){
  int temp;
  temp=*p1;
  *p1=*p2;
  *p2=temp;
}
int parent(int i){
return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
void maxheapify(int A[],int i){
  int l,r,largest;
  l=left(i);
  r=right(i);
  if(l<=H &&A[l]>A[i])largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest])largest=r;

  if(largest!=i){
    swap(&A[i],&A[largest]);
    maxheapify(A,largest);
  }
}
void buildmaxheap(int A[]){
  int i;
  for(i=H/2;i>=1;i--){
    maxheapify(A,i);
  }
}
int heapextractmax(int A[]){
  int max;
  if(H<1){
    printf("error\n");
      exit(0);
  }
  max=A[1];
  A[1]=A[H];
  H--;
  maxheapify(A,1);
  return max;
}
void heapincreasekey(int A[],int i,int key){
  if(key<A[i]){
    printf("error1\n");
    exit(1);
  }
  A[i]=key;
  while(i>1&&A[parent(i)]<A[i]){
    swap(&A[i],&A[parent(i)]);
    i=parent(i);
  }
}
void maxheapinsert(int A[],int key){
  H++;
  A[H]=INF;
  heapincreasekey(A,H,key);
}
  
   
    
    
    
  



Measured memory_bytes: 5640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll x, t;
    cin >> x >> t;
    cout << max(0ll, x - t) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
void square() {
	ll n; cin >> n;
	vll h(n); rep(i, 0, n) cin >> h[i];
	deque<pair<ll, ll>> st;
	st.eb(-1, -1);
	ll ans = 0, pos;
	for (ll i = 0; i < n; ++i) {
		if (st.back().fi == h[i]) continue;
		pos = i;
		while (st.back().fi >= h[i]) {
			chmax(ans, st.back().fi * (i - st.back().se));
			pos = st.back().se;
			st.pop_back();
		}
		st.eb(h[i], pos);
	}
	while (!st.empty()) {
		chmax(ans, st.back().fi * (n - st.back().se));
		st.pop_back();
	}
	P(ans);
}
int main() {
	square();
	return 0;
}

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

int main() {
  int N, Y;
  cin >> N >> Y;
  
  int k;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N - i; j++) {
      k = N - i -j;
      if (10000 * i + 5000 * j + 1000 * k == Y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}


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

int main() {
  int n,m; cin>>n>>m;
  string S; cin>>S;

  bool frag = true;
  if (S.size() != n+m+1) frag=false;
  rep(i, n) if (S[i]=='-') frag=false;
  if (S[n] != '-') frag=false;
  rep(i, m) if (S[i+n+1]=='-') frag=false;
  if (frag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256