akhauriyash/Code-Regression huggingface dataset:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = 'APPROVED'
for i in l:
	if(i&1 == 0 and not(i%3 == 0 or i%5 == 0)):
		ans = 'DENIED'
		break
# ans = solve(l)
print(ans)


Measured memory_bytes: 6244
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
const int NMAX=100666; //LOL
using namespace std;
const int INF=1000000007;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;

char c;
char A[105][105];
int h,w;

void solve()
{
    cin>>h>>w;
    for(int i=1; i<=h; ++i)
        for(int j=1; j<=w; ++j)
            cin>>A[i][j];
    for(int i=1; i<=2*h; ++i, cout<<"\n")
        for(int j=1; j<=w; ++j)
            cout<<A[(i+1)/2][j];

}

int main()
{
    // Tic
    clock_t t=clock();
   
    solve();
    cout<<"\n";
 
    //Toc
    t=clock()-t;
    //printf("It took me %d clicks (%f seconds).\n",(int)t,((float)t)/CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<climits>
using namespace std;



int m;
vector<int> cost;
void init(){
  cost.clear();
}

bool input(){
  int n;
  cin>>m>>n;
  if(n==0&&m==0)return 0;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    cost.push_back(tmp);
  }
  return 1;
}


bool judge(long long w){
  long long tmp_w=0;
  long long tmp_m=1;
  for(int i=0;i<cost.size();i++){
    if(tmp_w+cost[i]>w){
      tmp_w=0;
      tmp_m++;
      i--;
      if(tmp_m>m){
        return false;
      }
    }else{
      tmp_w+=cost[i];
    }
  }
  return true;
}

int binary_serch(long long t_min,long long t_max){
  if(t_min>=t_max)return t_max;
  long long c=(t_min+t_max)/2;
  if(judge(c)){
    return binary_serch(t_min,c);
  }else{
    return binary_serch(c+1,t_max);
  }
}

int solve(){
  return binary_serch(0,1500000); 
}


int main(){
  while(init(),input()){
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 1216
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
  cin>>n;
  vector<int> v(n);
  rep(i, n) cin>>v[i];
  ll s = 0;
  rep(i, n) s += v[i];
  int q;
  cin>>q;
  rep(i, q){
    int a, x;
    cin>>a>>x; a--;
    cout<<s+x-v[a]<<endl;
  }
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int scorea, scoreb, n, a, b;

void judge(n){
	
	//printf("あと%d回, scorea = %d, scoreb = %d", n, scorea, scoreb );
	
	if(n == 0){
		printf("%d %d\n", scorea, scoreb);
		scorea = scoreb = 0;
		return;
	}
	scanf("%d %d", &a, &b);
	if(a > b){
		scorea += a + b;
		judge(n - 1);
		return;
	}
	if(a < b){
		scoreb += a + b;
		judge(n - 1);
		return;
	}
	scorea += a;
	scoreb += b;
	judge(n - 1);
	return;
}

int main(){
	n = 1;
	scorea = scoreb = 0;
	for(;n != 0;){
	scanf("%d", &n);
	if(n != 0)judge(n);
	}
	return 0;
}


Measured memory_bytes: 1872
#include <iostream>
#include <vector>
#include <set>
#include <cmath>

using namespace std;
bool IsPrime[1005000];
vector<int> Prime;

void PrimeCalc()
{
	for(int i = 0; i < 1005000; ++i)
	{
		IsPrime[i] = true;
	}
	for(int i = 2; i < 1005000; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = i * 2; j < 1005000; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

int func(int a)
{
	set<int> Set;
	for(int i = 0; Prime[i] <= a; ++i)
	{
		if(a % Prime[i] == 0)
		{
			Set.insert(Prime[i]);
		}
	}
	int sum = 0;
	set<int>::iterator It;
	for(It = Set.begin(); It != Set.end(); ++It)
	{
		sum -= *It;
	}
	--It;
	sum += *It * 2;
	return(sum);
}

void solve()
{
	PrimeCalc();
	int a, b;
	while(cin >> a >> b, a || b)
	{
		int A = func(a);
		int B = func(b);
		A < B ? cout << "b" : cout << "a";
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
int main(){
int i,x,y,z;
for(i=1;i<=3000;i++){
scanf("%d%d",&x,&y);
if(x==0 && y==0) break;
if(x<y){
printf("%d %d\n",x,y);
}
else{
printf("%d %d\n",y,x);
}
}
return 0;
}

Measured memory_bytes: 600
<>;
@x=glob<>;
for(1..$#x){
	$X+=$x+=($x[$_]-$x[$_-1])*$_;
	$x%=1e9+7;
	$X%=1e9+7;
}
@y=glob<>;
for(1..$#y){
	$Y+=$y+=($y[$_]-$y[$_-1])*$_;
	$y%=1e9+7;
	$Y%=1e9+7;
}
print+($X*$Y)%(1e9+7),$/


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

int main() {
  long long N, cnt=0;
  cin >> N;
  vector<long> A(N), B(N+1,0);
  rep(i, N){
    cin >> A.at(i);
    B.at(A.at(i))++;
  }
  rep(i, N+1) cnt+=B.at(i)*(B.at(i)-1)/2;
  rep(i, N){
    if(B.at(A.at(i))<=1) cout << cnt << endl;
    else cout << cnt-B.at(A.at(i))+1 << endl;
  }
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#ifndef ONLINE_JUDGE
	#define ONLINE_JUDGE
#endif

#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#define pb push_back
#define mp make_pair
#define rep(i,n) for(i=0;i<n;i++)
#define repr(i,j,n) for(i=j;i<=n;i++)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<int> > graph;
const ll maxn = (ll) 1e5+9;
const ll mod = (ll) 1e9+7;

ll a[maxn],arr[2][maxn];
int main()
{
	std::ios::sync_with_stdio(0);
	ll i,j,k,t,q,m,l,r,n;
	cin>>n;
	bool f=n&1,g=1;
	repr(i,1,n)
	{
		cin>>a[i];
		if(!(f^(a[i]&1)))g=0;
	}
	if(!g){cout<<0<<endl;return 0;}

	sort(a+1,a+n+1);

	arr[1][1]=0;j=2;
	for(i=2;i<=n;i+=2) {
		arr[1][i]=j;
		arr[1][i+1]=j;
		j+=2;
	}

	j=1;
	for(i=1;i<=n;i+=2) {
		arr[0][i]=j;
		arr[0][i+1]=j;
		j+=2;
	}
	repr(i,1,n)
	{
		if(a[i] != arr[f][i]) {
			cout<<0<<endl;return 0;
		}
	}
	ll ans=1;
	m = n/2;
	rep(i,m){
		ans<<=1;
		if(ans>=mod)ans%=mod;
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

long long Max = -100000000000;

int main()
{
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 10; j++)
    {
      cin >> F[i][j];
    }
  }
  vector<vector<int>> P(N, vector<int>(11));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 11; j++)
    {
      cin >> P[i][j];
    }
  }

  /////////////////////
  for (int i = 1; i < (1 << 10); i++)
  {
    long long temp = 0;
    for (int j = 0; j < N; j++)
    {
      int cc = 0;
      for (int h = 0; h < 10; h++)
        if (F[j][h] && (i >> h) & 1)
          cc++;
      temp += P[j][cc];
    }
    Max = max(temp, Max);
  }

  cout << Max << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (h, w) = get!(usize, usize);
    let mut v = Vec::new();
    for _ in 0..h {
        let tmp = get!([i32]);
        for i in tmp.iter() {
            if *i & 1 == 0 {}
        }
        v.push(tmp);
    }
    let mut ans = Vec::new();
    for i in 0..h - 1 {
        for j in 0..w {
            if v[i][j] % 2 == 1 {
                v[i][j] -= 1;
                v[i + 1][j] += 1;
                let tv = vec![(i, j), (i + 1, j)];
                ans.push(tv);
            }
        }
    }
    for i in 0..w - 1 {
        if v[h - 1][i] % 2 == 1 {
            v[h - 1][i] -= 1;
            v[h - 1][i + 1] += 1;
            let tv = vec![(h - 1, i), (h - 1, i + 1)];
            ans.push(tv);
        }
    }
    println!("{}", ans.len());
    for i in 0..ans.len() {
        println!(
            "{} {} {} {}",
            ans[i][0].0 + 1,
            ans[i][0].1 + 1,
            ans[i][1].0 + 1,
            ans[i][1].1 + 1
        );
    }
}


Measured memory_bytes: 14332
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        int[][] link = new int[n+1][n+1];
        int inf = 1000000;
        for(int i=0;i<n+1;i++){
            for(int j=0;j<n+1;j++){
                link[i][j]=inf;
            }
        }
        int[][] edges = new int[m][3];
        for(int i=0;i<m;i++){
            int a=sc.nextInt();
            int b=sc.nextInt();
            int c=sc.nextInt();
            link[a][b] = c;
            link[b][a] = c;
            edges[i][0] = a;
            edges[i][1] = b;
            edges[i][2] = c;
        }
        //Warshall–Floyd Algorithm
        int dp[][][] = new int[n+1][n+1][n+1];
        for (int i=0;i<n+1;i++){
            for(int j=0;j<n+1;j++){
                if (i!=j) {
                    dp[0][i][j] = link[i][j];
                } else {
                    dp[0][i][j] = 0;
                }
            }
        }
        for (int k=1;k<n+1;k++){
            for(int i=1;i<n+1;i++){
                for(int j=1;j<n+1;j++){
                    dp[k][i][j]=Math.min(dp[k-1][i][j],dp[k-1][i][k]+dp[k-1][k][j]);
                }
            }
        }
        int answer = m;
        for(int e=0;e<m;e++){
            int a = edges[e][0];
            int b = edges[e][1];
            int c = edges[e][2];
            boolean shortest = false;
            for(int i=1;i<n+1;i++){
                if(shortest) break;
                for(int j=1;j<n+1;j++){
                    if(dp[n][i][a]+c+dp[n][b][j] == dp[n][i][j]){
                        shortest = true;
                    }
                    if(shortest) break;
                }
            }
            if(shortest) answer --;
        }
        System.out.println(answer);
        /*
        for (int i=1;i<n+1;i++){
            for (int j=1;j<n+1;j++){
                System.out.print(dp[n][i][j]);
                System.out.print(" ");
            }
            System.out.println("");
        }
        */
    }
}

Measured memory_bytes: 30320
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

a,b = S()
if a == b:
    print('H')
else:
    print('D')

Measured memory_bytes: 10020
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,ans=1,x,cnt[1005]={};
  cin >> n;
  for(int i=2; i<=n; i++) {
    x=i;
    for(int j=2; j<=x; j++) {
      while(x%j==0) {
        cnt[j]++,x/=j;
      }
    }
  }
  for(int i=2; i<=n; i++) {
    ans*=cnt[i]+1;
    ans%=MOD;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
long long int comb(long long int n,long long int r){
    vector<vector<long long int> > v(n+1,vector<long long int>(n+1,0));
    long long int i,j;
    rep(i,0,n+1){
        v.at(i).at(0)=1;
        v.at(i).at(i)=1;
    }
    rep(i,0,n+1){
        rep(j,0,i)v.at(i).at(j)=v.at(i-1).at(j-1)+v.at(i-1).at(j);
    }
    return v.at(n).at(r);
}
int main(void){
    char C;
    cin>>C;
    C++;
    cout<<C<<endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d",$N);
$V=trim(fgets(STDIN));
$C=trim(fgets(STDIN));
//echo($V);
$Vs=explode(" ",$V);
$Cs=explode(" ",$C);
$result=0;
$i=0;
foreach($Vs as $value){
if($Vs[$i]-$Cs[$i]>0){
$result+=$Vs[$i]-$Cs[$i];
}
$i++;
}

echo($result);

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

int main()
{
  int a,b;
  cin >>a>>b;
  if(a==1){a=14;}
  if(b==1){b=14;}
  if(a>b){
    cout <<"Alice"<<endl;
  }else if(b>a){
    cout <<"Bob"<<endl;
  }else{
    cout <<"Draw"<<endl;
  }
  return 0;
}


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

// ループによる最大公約数
int gcd(int x, int y) {
  int r;
  if ( x < y ) swap(x, y);  // y < x を保障する

  while( y > 0) {
    r = x%y;
    x = y;
    y = r;
  }
  return x;
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << gcd(a, b) << endl;

  return 0;
}


Measured memory_bytes: 3084
x = input()
N = int(input())
p = [input().split() for _ in range(N)]
for i in p:
    a,b= int(i[1]), int(i[2]) + 1
    if i[0] == 'replace':
        x = x[:a]+ i[3] + x[b:]
    elif i[0] =='reverse':
        x = x[:a] + x[a:b][::-1] + x[b:]
    elif i[0] == 'print':
        print(x[a:b])



Measured memory_bytes: 5624
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int N;
	cin >> N;

	vector<int> P(N), idx(N);
	for (int i = 0; i < N; i++) cin >> P[i];
	for (int i = 0; i < N; i++) idx[P[i] - 1] = i;

	multiset<lint> st;
	st.emplace(-1), st.emplace(-1);
	st.emplace(N), st.emplace(N); // 番兵
	lint ans = 0;
	for (int i = N - 1; i >= 0; i--) {

		auto ub1 = st.lower_bound(idx[i]);
		auto ub2 = next(ub1, 1);
		auto lb1 = --st.upper_bound(idx[i]);
		auto lb2 = prev(lb1, 1);

		ans += (idx[i] - *lb1) * (*ub2 - *ub1) * P[idx[i]];
		ans += (*ub1 - idx[i]) * (*lb1 - *lb2) * P[idx[i]];
		st.emplace(idx[i]);

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
#define ll long long
#define INF 1145141919810
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b:i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
using namespace std;

bool end_check(vector<ll> a,ll p,ll winner){
	bool flag=true;
	rep(i,a.size()) if(i!=winner && a[i]) return false;
	if(!p) return true;
	return false;
}

int main(){
	while(true){
	ll n,p; cin>>n>>p;
	if(!n&&!p) break;
	vector<ll> a(n);
	ll winner=0;
	while(true){
		//step
		if(p){
			p--;
			a[winner]++;
		}else{
			p+=a[winner];
			a[winner]=0;
		}
		
		if(end_check(a,p,winner)) break;
		
		//next
		if(winner==n-1) winner=0;
		else winner++;
		
	}cout<<winner<<endl;
	}
	return 0;
}

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

using namespace std;

///================================================================code for GCD==================================================================
//..................
template <class T>
T gcd(T a, T b)
{
    /*
    if (a%b)return b;
    else return (b, a%b);
    */
    while (b > 0)
    {
        a = a%b;
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return a;

}//...end of the code gcd






///========================================================     code for lcm     ==============================================================
//.....................
template<class T>
T lcm(T a, T b)
{
    return ((a*b) / gcd(a, b));
}


int main()
{
    //cout << "Hello world!" << endl;
    int m;
    cin >> m;
    int arr[m+1];
    for(int i=0;i<m;i++)cin>>arr[i];
    int ans = lcm(arr[0],arr[1]);
    //cout << ans << " " << endl;
    for(int i=2;i<m;i++)
    {
        ans = lcm(ans,arr[i]);
        //cout << "ans: " << ans << endl;
    }
    cout << ans << endl;


    return 0;
}

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

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> h.at(i);
    }

    if (k >= n)
    {
        cout << 0 << endl;
        return 0;
    }

    sort(h.begin(), h.end(), greater<ll>());

    ll answer = 0l;
    for (ll i = k; i < n; i++)
    {
        answer += h.at(i);
    }

    cout << answer << endl;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())

kb = 60

bits = [K]
for i in range(kb):
    if (1 << i) & K:
        bits.append((K & ~((1 << i) - 1)) - 1)


bit0_count = [0] * kb
bit1_count = [0] * kb

for A in map(int, input().split()):
    for i in range(kb):
        if A & (1 << i):
            bit1_count[i] += 1
        else:
            bit0_count[i] += 1

ans = 0
for k in bits:
    tmp = 0
    for i in range(kb):
        if k & (1 << i):
            tmp += max(bit0_count[i], bit1_count[i]) * (1 << i)
        else:
            tmp += bit1_count[i] * (1 << i)
        
    ans = max(ans, tmp)

print(ans)

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;

	vector<ll> AB(N), A(N), B(N);
	
	REP(i, N)
	{
		cin >> A[i] >> B[i];
		AB[i] = A[i] + B[i];
	}

	ll res = -accumulate(B.begin(), B.end(), 0ll);

	vector<ll> index(N);
	iota(ALL(index), 0ll);

	sort(ALL(index), [&](auto &a, auto &b)
					 {
						 return AB[a] > AB[b];
					 });

	bool ist{true};

	REP(i, N)
	{
		if (ist)
			res += AB[index[i]];
		ist ^= true;
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 3328
r={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
while True:
    try:
        N = list(input())
    except:
        break
        
    ans = 0
    i = 0
    while i < len(N):
        if i+1 < len(N) and r[N[i]] < r[N[i+1]]:
            ans += r[N[i+1]] - r[N[i]]
            i += 1
        else: ans += r[N[i]]
        i += 1
    print(ans)


Measured memory_bytes: 5556
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>

using namespace std;


int main() {
 long long int a,b,c,d[100010],e[100010];
  
  cin >> a ;
  
  for(int i=1;i<=a;i++)
   cin >> e[i] ;
   
  for(int i=1;i<=a;i++){
 d[e[i]] = i;
  }
  
   
 for(int i=1;i<=a;i++)
   cout << d[i] << " " ;
  cout << endl;
    
  }
   

Measured memory_bytes: 2432
/*
    Created by Ezio112
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
//#define inf ll(10e16)
#define mod ll(10e8+7)
#define ff first
#define ss second
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        string str;
        cin>>str;
        if(str=="ABC")
            cout<<"ARC";
        else cout<<"ABC";
    }
    return 0;
}


Measured memory_bytes: 3652
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

const MOD = 10^^9 + 7;

long calc(int h, int w, int a, int b) {
    initFactTable(h + w);

    // (a, b) -> (c, d)
    long f(int a, int b, int c, int d) {
        return nck(c - a + (d - b), d - b);
    }

    long ans = 0;
    for (int i = b; i < w; i++) {
        long x = f(0, 0, h - 1 - a, i) * f(h - a, i, h - 1, w - 1) % MOD;
        ans = (ans + x) % MOD;
    }
    return ans;
}

void main() {
    int h, w, a, b; scan(h, w, a, b);
    writeln(calc(h, w, a, b));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long[] fact; // 階乗
long[] factInv; // 階乗の逆元

void initFactTable(int n) {
    fact = new long[n + 1];
    fact[0] = 1;
    for (int i = 1; i <= n; i++)
        fact[i] = i * fact[i - 1] % MOD;

    factInv = new long[n + 1];
    factInv[n] = modPow(fact[n], MOD - 2, MOD);
    for (int i = n - 1; i >= 0; i--)
        factInv[i] = factInv[i + 1] * (i + 1) % MOD;
}

long modPow(long x, long k, long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
    return x * modPow(x, k - 1, m) % m;
}

long nck(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return (fact[n] * factInv[k] % MOD) * factInv[n - k] % MOD;
}


Measured memory_bytes: 4092
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  int N, M;
  cin >> N;
  string w;
  unordered_map<string, int> ws;
  REP(i, N) {
    cin >> w;
    ws[w]++;
  }
  cin >> M;
  REP(i, M) {
    cin >> w;
    ws[w]--;
  }
  const auto answer =
      max(0, max_element(ALL(ws), [](const auto &lhs, const auto &rhs) {
               return lhs.second < rhs.second;
             })->second);
  cout << answer << endl;
  return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;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> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

void solve(){
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  for(auto& ai:a)cin>>ai,ai--;
  ll logk=1;
  while((1LL<<logk)<k)logk++;
  auto table = vec<ll>(logk,n);
  rep(i,n)table[0][i]=a[i];
  for(int i=1;i<logk;++i){
    rep(j,n){
      table[i][j] = table[i-1][table[i-1][j]];
    }
  }
  ll now = 0;
  for(ll i=0;(1LL<<i)<k;++i){
    if((k>>i)&1)now = table[i][now];
  }
  cout<<(now+1)<<endl;
}

signed main(){

  solve();
  return 0;

  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  cin>>a;
  for(auto& ai:a)ai--;

  vector<ll> visited(n,-1);
  ll kk = k;
  ll now = 0;
  ll ord = 0;
  while(kk--){
    if(visited[now]!=-1){
      break;
    }
    visited[now] = ord++;
    dump(now,a[now]);
    now = a[now];
  }
  k -= visited[now];
  k %= (ord-visited[now]);
  dump(ord-visited[now],visited[now]);
  while(k--){
    now = a[now];
  }
  cout<<(now+1)<<endl;

}

Measured memory_bytes: 100052
#include <stdio.h>

int main() {
  int x1,x2,y1,y2;
  scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
  int dif_1,dif_2;
  dif_1 = x2 - x1;
  int y3 = y2 + dif_1;
  dif_2 = y2 - y1;
  int x3 = x2 - dif_2;
  int x4,y4;
  x4 = x3 - dif_1;
  y4 = y3 - dif_2;
  printf("%d %d %d %d\n",x3,y3,x4,y4);
  return 0;
}


Measured memory_bytes: 128
import sys
import math


def main():
    input = sys.stdin.readline
    k = int(input())
    a, b = (int(i) for i in input().split())
    res = False
    for i in range(a, b + 1):
        if i % k == 0:
            res = True

    if res:
        print("OK")
    else:
        print("NG")


main()


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(ll i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main(void) {
	ll N; cin >> N;
	reps(h, 1, 3501){
		bool f = false;
		reps(n, 1, 3501) {
			ll d1 = 4*h*n - N*(n+h);
			ll d2 = N*h*n;
			if(d1 <= 0 || d2 <= 0) continue;
			if(d2 % d1) continue;
			ll w = d2 / d1;
			if(w <= 0) continue;
			// printf("%lld %lld\n", d1, d2);
			printf("%lld %lld %lld\n", h, n, w);
			f = true;
			break;
		}
		if(f)break;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
using namespace std;

int N;
int cnt[4];
double dp[333][333][333];
double dfs(int a,int b,int c){
    if(a+b+c == 0) return 0.0;
    if(dp[a][b][c] > -0.5) return dp[a][b][c];
    double k = (double)N/(a+b+c),res = 0.0;
    if(a) res += (dfs(a-1,b,c) + k) * a/(a+b+c);
    if(b) res += (dfs(a+1,b-1,c) + k) * b/(a+b+c);
    if(c) res += (dfs(a,b+1,c-1) + k) * c/(a+b+c);
    return dp[a][b][c] = res;
}
int main(){
    // debug;
    ios;

    cin>>N;
    for(int i = 1;i<=N;i++){
        int x;cin>>x;
        ++cnt[x];
    }
    for(int i = 0;i<=N;i++)
        for(int j = 0;j<=N;j++)
            for(int k = 0;k<=N;k++)
                dp[i][j][k] = -1;
    cout.precision(12);
    cout<<dfs(cnt[1],cnt[2],cnt[3])<<'\n';

    
    return 0;
}


Measured memory_bytes: 262272
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using vi  = vector<int>;
using ii  = pair<int,int>;
using vii = vector<ii>;
using ll  = long long;

typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) int((x).size())
#define REP(i, a, b) for (auto (i) = (a); (i) <= (b); (i)++)
#define PER(i, a, b) for (auto (i) = (a); (i) >= (b); (i)--)
#define ITR(i, x) for (auto (i) = (x).begin(); (i) != (x).end(); (i)++)

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int n; cin >> n;
	if (n >= 30) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3648
hash = {}
("a".."z").to_a.each do |c|
  hash[c] = 0
end

ARGF.each_line do |line|
  line.each_char do |c|
    dc = c.downcase
    next unless ("a".."z").to_a.join.include?(dc)
    hash[dc] += 1
  end
end

hash.each do |key, value|
  puts "#{key} : #{value}"
end

Measured memory_bytes: 6104
n = int(input())
a = list(map(int, input().split()))

# bucket
count = []
for i in range(10 ** 5):
    count.append(0)

for i in a:
    if i >= 1:
        count[i - 1] += 1
    if i < 10 ** 5 - 1:
        count[i + 1] += 1
    count[i] += 1

print(sorted(count, reverse = True)[0])


Measured memory_bytes: 13964
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

typedef long double ldb;
typedef long long ll;

const int maxn = 2e5 + 100;
const int MX = 1e8;

const ldb pi = (ldb)3.141592653589793238;

struct NODE {
	int i, j;
	NODE(int _i = 0, int _j = 0) { i = _i, j = _j; }
	friend istream& operator >> (istream& xin, NODE& A) {
		xin >>  A.i >> A.j;
		return xin;
	}
	friend ostream& operator << (ostream& xout, const NODE& A) {
		xout << "(" << A.i << ", " << A.j << ")";
		return xout;
	}
	bool operator < (const NODE& A) const {
		if (i != A.i) return i < A.i;
		return j < A.j;
	}
} node[maxn];

vector<NODE> V;
vector<int> f;

NODE st, ed;

int get_bound(int L, int R, int v) {
	while (L < R) {
		int mid = (L + R) >> 1;
		if (f[mid] > v) {
			R = mid;
		}
		else L = mid + 1;
	}
	return R;
}

int n;

int main()
{
	ios::sync_with_stdio(0);
	cin >> st >> ed;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> node[i];
	}
	if (st.i > ed.i) {
		st.i *= -1, ed.i *= -1;
		for (int i = 1; i <= n; ++i) node[i].i *= -1;
	}
	if (st.j > ed.j) {
		st.j *= -1, ed.j *= -1;
		for (int i = 1; i <= n; ++i) node[i].j *= -1;
	}
	for (int i = 1; i <= n; ++i) {
		if (node[i].i <= ed.i && node[i].i >= st.i && node[i].j <= ed.j && node[i].j >= st.j) {
			V.push_back(node[i]);
		}
	}
	sort(V.begin(), V.end());
	int sz = V.size();
	if (!sz) goto nxt;
	f.push_back(V[0].j);
	for (int i = 1; i < sz; ++i) {
		int curj = V[i].j;
		if (curj > *(f.end() - 1)) f.push_back(curj);
		else {
			int t = get_bound(0, f.size() - 1, curj);
			f[t] = curj;
		}
	}
	nxt:
	int len = f.size();
	int cnt1 = 0, cnt2 = 0; //90, 180
	if (len == min(ed.i - st.i, ed.j - st.j) + 1) {
		cnt1 = len - 1, cnt2 = 1;
	}
	else {
		cnt1 = len;
	}
	ldb ans = (ldb)(ed.i - st.i + ed.j - st.j) * 100.0;
	ans -= (ldb)len * 20.0;
	ldb t = (ldb)pi * 5.0;
	cnt2 *= 2;
	ldb rem = (ldb)(cnt1 + cnt2) * t;
	ans += rem;
	cout << setprecision(14) << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 5232
#include <cstdio>
#include <deque>

int main()
{
  int n;
  char s[101];
  scanf("%d%s", &n, s);
  int depth = 0;
  std::deque<char> dq;
  for (char *p = s; *p; ++p)
  {
    if (*p == '(') ++depth;
    else --depth;
    if (depth < 0)
    {
      dq.emplace_front('(');
      dq.emplace_back(')');
      ++depth;
    }
    else
    {
      dq.emplace_back(*p);
    }
  }
  for (auto c : dq)
  {
    putchar(c);
  }
  while (depth > 0)
  {
    putchar(')');
    --depth;
  }
  putchar('\n');
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<chrono>
#include<cmath>
#include<random>
using namespace std;
using ll = long long;

int d;
vector<vector<int>> s(365,vector<int>(26));
vector<int> c(26);

auto start=chrono::system_clock::now();
inline double get_time(){
    auto end=chrono::system_clock::now();
    auto dur=end-start;
    double msec=chrono::duration_cast<chrono::microseconds>(dur).count();
    return msec;
}

random_device seed_gen;
uint64_t get_rand_range(uint64_t min_val,uint64_t max_val){
    static mt19937_64 mt64(seed_gen());
    uniform_int_distribution<uint64_t> get_rand_uni_int(min_val,max_val);
    return get_rand_uni_int(mt64);
}

ll calc(vector<int> t){
    ll score=0;
    vector<int> last(26);
    for(int i=0;i<(int)t.size();i++){
        last[t[i]]=i;
        for(int j=0;j<26;j++) score-=c[j]*(i+1-last[j]);
        score+=s[i][t[i]];
    }
    return score;
}

void solve(){
    vector<int> v(d);
    double t0=2000,t1=600;
    int cnt=0;
    double T=t0;
    for(int i=0;i<d;i++) v[i]=get_rand_range(0,25);
    ll score=calc(v);
    vector<int> b=v;
    while(1){
        cnt++;
        if(cnt%100==0){
            double t=get_time()/19e5;
            if(t>=1) break;
            T=powl(t0,1.0-t)*powl(t1,t);
        }
        ll old_score=calc(v);
        if(get_rand_range(0,1)){
            int i=get_rand_range(0,d-1);
            int q=get_rand_range(0,25);
            int old=v[i];
            v[i]=q;
            ll new_score=calc(v);
            if(old_score>new_score&&!get_rand_range(0,exp((new_score-old_score)/T))) v[i]=old;
        }else{
            int i=get_rand_range(0,d-2);
            int j=get_rand_range(i+1,min(i+16,d)-1);
            swap(v[i],v[j]);
            ll new_score=calc(v);
            if(old_score>new_score&&!get_rand_range(0,exp((new_score-old_score)/T))) swap(v[i],v[j]);
        }
        if(score<calc(v)) b=v;
    }
    for(int k : b) cout<<k+1<<endl;
}

int main(){
    cin>>d;
    for(int i=0;i<26;i++){
        cin>>c[i];
    }
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            cin>>s[i][j];
        }
    }
    solve();
}

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

#define ll long long

void solve() {
	int n;
	string s;
	cin >> n >> s;
	string a, b;
	for (int i = 0; i < n / 2; ++i)
		a += s[i];
	for (int i = n / 2; i < n; ++i)
		b += s[i];
	if (a == b)
		cout << "Yes";
	else
		cout << "No";
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


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

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int black = h * W + w * H - h * w;
    cout << H * W - black << endl;
}



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

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

    if(k % 2 != 0) cout << (n/k) * (n/k) * (n/k) << endl;
    if(k % 2 == 0){
        k /= 2;
        cout << ((n/k+1)/2) * ((n/k+1)/2) * ((n/k+1)/2) + (n/k/2) * (n/k/2) * (n/k/2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
x,y = map(int, input().split())
G1 = [1,3,5,7,8,10,12]
G2 = [4,6,9,11]
G3 = [2]
if x in G1 and y in G1:
  print("Yes")
elif x in G2 and y in G2:
  print("Yes")
elif x in G3 and y in G3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		String s = sc.next();
		String t = sc.next();
		sc.close();
		char[] q = new char[s.length()];
		char[] a = new char[t.length()];
		int yono = 10000;
		for(int i = 0 ; i < s.length() ; i++) q[i] = s.charAt(i);
		for(int i = 0 ; i < t.length() ; i++) a[i] = t.charAt(i);
		for(int i = 0 ; i < s.length() - t.length() + 1 ; i++){
			int ebi = 0;
			for(int j = 0 ; j < t.length() ; j++){
				if(q[i + j] != a[j]) ebi++;
			}
			yono = Math.min(yono , ebi);
		}
		ou.print(yono + "\n");
		ou.flush();
    }
}

Measured memory_bytes: 38452
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)
isnotempty(x)=!isempty(x)
isX(x)=x!="x"?true:false

function main()
  tmp = readline() 
  torikumi = length(tmp)
  N = split(tmp,"") |> x -> filter!(isX,x) |> x -> filter!(isnotempty,x)

  while torikumi < 15
    push!(N,"o")
    torikumi += 1;
  end
  if length(N) >= 8
  	print("YES")
  else
    print("NO")
  end
end
main()

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

int main() {
int64_t a,b,k;
    cin >> a >> b >> k;
    if (a >= k) {
        cout << a - k << ' ' << b;
    }
    else if (a < k && (k - a) <= b) {
        cout << 0 << ' ' << b - (k - a);
            }
    else if (a < k && (k - a) > b) {
    cout << 0 << ' ' << 0;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

//D

int main(void) {
	ll n;
	cin >> n;
	vector<pair<ll, ll>> v = vector<pair<ll, ll>>(n);
	rep(i, 0, n) {
		ll a, b;
		cin >> a >> b;
		v[i] = make_pair(b, a);
	}
	sort(v.begin(), v.end());
	ll time = 0;
	string ans = "Yes";
	rep(i, 0, n) {
		time += v[i].second;
		if (time > v[i].first) {
			ans = "No";
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3328
N = input()

dp = [[ [0] * 10 for i in range(len(N)) ] for j in range(2) ]

ans = 0

for i in range(len(N)): #kai

    for j in range(2): #flag

        for k in range(10): # num

            if i == 0:
                if k < int(N[i]):
                    dp[1][i][k] = k
                elif k == int(N[i]):
                    dp[0][i][k] = k

            else:

                if j == 0 and k == int(N[i]):
                    dp[0][i][k] = max(dp[0][i][k],max(dp[0][i-1]) + k)

                elif j == 0 and k < int(N[i]):
                    dp[1][i][k] = max(dp[1][i][k],max(dp[0][i-1]) + k)

                elif j == 1:
                    dp[1][i][k] = max(dp[1][i][k],max(dp[1][i-1]) + k)

print (max( max(dp[0][len(N)-1]) , max(dp[1][len(N)-1]) )  )

                


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
    int a,v,b,c,d,e,f=0,r,i,j;
    char p,s[]="abcdefghijklmnopqrstuvwxyz";
    scanf("%c",&p);
    for(i=0;i<26;i++)
    {
        if(p==s[i]){
            printf("%c",s[i+1]);
        }
    }


}


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

int main(void) {
    int a, b;
    while(scanf("%d %d", &a, &b) != EOF) {
        cout << (int)log10(a + b) + 1 << endl;
    }
    return(0);
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define md 998244353
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res)*(x))%mod;
        }
        x=((x)*(x))%mod;
        y=y/2;
    }
    return res;
}
 




 
  
int main(){
 
 /* #ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/

  ll n,x,y,i,j;

  sfl(n);sfl(x);sfl(y);

  vec<ll>ans(n,0);

  for(i=1;i<=n;i++){

      for(j=i+1;j<=n;j++){

          if(i<=x){
                
                ll d=min(j-i,abs(i-x)+abs(y-j)+1);
              ans[d]++;

            

          }

          else if(i>x&&i<y){

              ll d=min(j-i,i-x+abs(y-j)+1);

              ans[d]++;
          }

          else ans[j-i]++;
      }
  }

   
  f(i,1,n)pfl(ans[i]);

   return 0;
 
  
 
    
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
int parent[maxn], n, m;
bool visited[maxn];
vector<int>g[maxn];

int main() {
	cin>>n>>m;

	int a, b;
	for(int i=0;i<m;i++) {
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}

	queue<int>q;
	q.push(1);
	while(!q.empty()) {
		int curr = q.front();
		q.pop();

		for(int i:g[curr]) {
			if(!visited[i]) {
				visited[i] = true;
				q.push(i);
				parent[i] = curr;
			}
		}
	}

	for(int i=2;i<=n;i++) {
		if(parent[i] == 0) {
			cout<<"No\n";
			return 0;
		}
	}

	cout<<"Yes\n";
	for(int i=2;i<=n;i++) {
		cout<<parent[i]<<"\n";
	}
}

Measured memory_bytes: 10588
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------


ll GCD(ll a, ll b) { // -1はすべての倍数とする
    if (a == -1) return b;
    if (b == 0 or b == -1) return a;
    else return GCD(b, a%b);
}
struct ST{
    int N;
    vector<ll> dat;

    ST(int n) {
        N = 1;
        while(N < n) N <<= 1;
        dat.resize(2*N-1, -1); //和なら0
    }

    void update(int x, ll val) { // 0-indexed
        x += (N - 1); //最下段に移動
        dat[x] = val;
        while(x > 0) { //上に向かって更新
            x = (x - 1) / 2;
            dat[x] = GCD(dat[2*x+1], dat[2*x+2]); //和なら足す
            //cout<< x <<dat[x] <<"\n";
        }
    }

    ll getgcd(int a, int b, int k=0, int l=0, int r=-1) {
        // [a,b)をみる。現在k,範囲[l,r)。0-indexed。
        if(r<0) r=N;
        if(r <= a or b <= l) return -1; //範囲外 和なら0
        if(a <= l and r <= b) return dat[k]; //被覆
        ll vl = getgcd(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getgcd(a, b, 2*k+2, (l+r)/2, r);
        return GCD(vl, vr); //和なら足す
    }
};

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    ST st(N);
    rep(i,N) st.update(i,A[i]);
    ll ans=1;
    rep(i,N){
        maxi(ans,GCD(st.getgcd(0,i),st.getgcd(i+1,N)));
    }
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;


int main()
{
	int n;
	cin >> n;
	int total = 0;
	int t = n;
	while (n > 0) {
		total += n % 10;
		n /= 10;
	}
	if (t% total == 0) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,int>;

const int inf = 1001001001;
int main() {
  int n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  int l = 0, r = inf;
  while(l+1<r){
    int x = (l+r)/2;
    ll m = 0;
    rep(i,n) m += (a[i]+x-1)/x - 1;
    if(m>k) l = x;
    else r = x;
  }
  cout << r << endl;
}


Measured memory_bytes: 4804
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n;

int main(){
    cin >> n;
    for(int i = 1;i < n;i++){
        for(int j = i + 1;j <= n;j++){
            int level = 1;
            while((i - j) % (1 << level) == 0)level++;
            cout << level << " ";
                }cout << endl;
    }
    return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt = 0;
        for (int i = 1; i <= n; i++) {
            int x = sc.nextInt();
            if (i != x) cnt++;
        }
        System.out.println((cnt == 2 || cnt == 0) ? "YES": "NO");
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    string s;
    cin >> s;
    cout << (s.find("AC") != string::npos ? "Yes" : "No") << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

int main() {
    int H = 0;
    int W = 0;

    while (1)
    {
        cin >> H >> W ;
        
        if(H == 0 && W == 0){
            break;
        }

        for(int hFirst = 1 ; hFirst <= W ; hFirst ++){
            cout << "#";
        }

        cout << "\n";

        for(int h = 2 ; h < H ; h ++){
            cout << "#";
            for(int w = 2 ; w < W ; w ++){
                cout << ".";
            }
            cout << "#\n";
        }

        for(int hFirst = 1 ; hFirst <= W ; hFirst ++){
            cout << "#";
        }
        cout << "\n" << "\n";
    }
}


Measured memory_bytes: 2988