akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

/**
 * https://abc074.contest.atcoder.jp/tasks/abc074_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] x = new int[N];
		for(int i=0; i<N; i++) x[i] = sc.nextInt();
		sc.close();
		
		long ans = 0;
		
		for(int i=0; i<N; i++){
			ans += Math.min(x[i]*2, (K-x[i])*2);
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 21716
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 105;
const ll mm = 1e+18;
void solve()
{
    int n,m;
    cin>>n>>m;
    string s1[n];
    string s2[m];
    rep0(i,n) cin>>s1[i];
    rep0(i,m) cin>>s2[i];
    rep0(i,n-m+1){
        rep0(j,n-m+1){
            bool p=true;
            repp(k,i,i+m){
                repp(l,j,j+m){
                    if(s1[k][l]!=s2[k-i][l-j]){
                        p=false;
                        break;
                    }
                }
                if(!p) break;
            }
            if(p){
                cout<<"Yes";
                return;
            }
        }
    }
    cout<<"No";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n;
    cin >> n;
    vi d(n);
    fo(i, n) cin >> d[i];

    sort(all(d));

    cout << d[n / 2] - d[n / 2 - 1] << endl;

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
char ch1,ch2;
int main(){
	scanf("%c %c",&ch1,&ch2);
	ch1-='A';ch2-='A';
	if(ch1>ch2)
		printf(">\n");
	else if(ch1==ch2)
		printf("=\n");
	else
		printf("<\n");
	return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long n, a; cin >> n >> a;
    long long ans = 1e18;
    for (int c = 0; c < 50; c++) {
        int p = c + 1;
        long long lf = 0, rg = 1e13;
        while (rg - lf > 1) {
            long long mi = (lf + rg) / 2;
            long long x = 1; bool ok = false;
            for (int i = 0; i < p; i++) {
                if (mi && n / mi < x) ok = true;
                if (n <= x * mi) ok = true;
                x *= mi;
            }
            ok |= n <= x;
            if (ok) rg = mi;
            else lf = mi;
        }
        int l = 0, r = p+1;
        while (r - l > 1) {
            int m = (r + l) / 2;
            long long x = 1; bool ok = false;
            for (int i = 0; i < p; i++) {
                long long y = (i < m) ? lf : rg;
                if (x * y >= n) ok = true;
                if (y && x > n / y) ok = true;
                x *= y;
            }
            ok |= n <= x;
            if (ok) l = m;
            else r = m;
        }
        ans = min(ans, c * a + lf * p + (p-l));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
 
string ansFizzBuzz(int n) {
    string result;
    if (n % 15 == 0) {
        result = "FizzBuzz";
    } else if (n % 3 == 0) {
        result = "Fizz";
    } else if (n % 5 == 0) {
        result = "Buzz";
    } else {
        stringstream ss;
        ss << n;
        ss >> result;
    }
    return result;
}
 
int main() {
    while (true) {
        int m, n;
        cin >> m >> n;
        if ((m | n) == 0) {
            break;
        }
        vector<int> players(m);
        for (int i = 0; i < m; i++) {
            players[i] = i + 1;
        }
        vector<string> lines(n);
        for (int i = 0; i < n; i++) {
            cin >> lines[i];
        }
        int pos = 0;
        for (int i = 0; i < n; i++) {
            if (players.size() <= 1) {
                break;
            }
            if (lines[i] != ansFizzBuzz(i + 1)) {
                players.erase(players.begin() + pos);
            } else {
                pos++;
            }
            pos = pos % players.size();
        }
        string result;
        for (vector<int>::iterator it = players.begin(); it != players.end(); it++) {
            stringstream ss;
            ss << *it;
            result += " " + ss.str();
        }
        result.erase(0, 1);
        cout << result << endl;
    }
}

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

int main() {
  int X;
  cin >> X;

  int ans=1;
  for (int b=2; b<=X; b++) {
    int power = b * b;
    for (int p=2; ; p++) {
      if (power > X) break;
      ans = max(ans,power);
      power *= b;
    }
  }

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

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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999
#define P(x)           printf("%d\n", (x));

typedef long long ll;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for(int &a : A) cin >> a;
	VSORT(A);

	int min_d = INF;

	FOR(i, 0, N-K+1){
		int d = A[i+K-1] - A[i];
		if(d < min_d)
			min_d = d;
	}

	cout << min_d << endl;

	return 0;
}



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

int main(){
	int N, L;
	cin >> N >> L;
	
	int i, tas[N], Min=1000, ans=0, index=0;
	for(i=0; i<N; i++){
		tas[i]=L+i;
		ans += tas[i];
		if(Min > abs(tas[i])){
			Min = abs(tas[i]);
			index = i;
		}
	}
	
	cout << ans-tas[index] << endl;
	
	return 0;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int AB, BC, CA;
    cin >> AB >> BC >> CA;
    cout << (AB * BC) / 2 << endl;
}

Measured memory_bytes: 256
N, = (int(x) for x in input().split())
W_arr = []
for _ in range(N):
    W_arr.append(input())

is_valid = True

W_set = set(W_arr)
if len(W_set) != len(W_arr):
    is_valid = False

for i in range(1, N):
    if W_arr[i][0] != W_arr[i-1][-1]:
        is_valid = False

if is_valid:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
//warota!w

#include <stdio.h>
 
int N = 100;
 
void out(int A[], int n){
  int i;
  for (i=0;i<n;i++){
    if (i>0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}
void swap(int *x, int *y){
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}

void selectionSort(int* A, int n){
  //???????????????????????????????????????????°?????????????????????\??????????????°?????????
  int i, j, min, count=0;
  for(i=0;i < n-1;i++){
  	min = i;
  	for(j=i+1; j<n; j++){
  		if(A[j] < A[min]){
  			min = j;
  		}
  	}
  	//????°??????¨??????
  	if(min!=i){
  		swap(&A[i], &A[min]);
  		count++;
  		//out(A, n);
  	}
  }
  out(A, n);
  printf("%d\n", count);
}
 
int main(void){
  int n, i;
  int A[N+1];
  scanf("%d", &n);
 
  for (i=0;i<n;i++) scanf("%d", &A[i]); //data input
  selectionSort(A, n);
 
  return 0;
}

Measured memory_bytes: 604
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn main() {
    let v: Vec<i32> = read_vec();
    let A: f64 = v[0].into();
    let B: f64 = v[1].into();
    let ans = ((B-1.0) / (A-1.0)).ceil() as i32;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[10];
int main()
{
	int k1=0,k2=0;
	scanf("%s",s+1);
	for(int i=1;i<=4;i++)
		s[i]-='0';
	int sm1=s[1]*10+s[2],sm2=s[3]*10+s[4];
	if(sm1<=12&&sm1>=1)
		k1=1;
	if(sm2<=12&&sm2>=1)
		k2=1;
	if(k1&&k2)
		printf("AMBIGUOUS");
	else if(k1&&!k2)
		printf("MMYY");
	else if(!k1&&k2)
		printf("YYMM");
	else
		printf("NA");
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *

n = int(input())
v = list(map(int, input().split()))
cnt1 = Counter([v[i] for i in range(n) if i%2==0])
cnt2 = Counter([v[i] for i in range(n) if i%2==1])
cnt1[-1] = 0
cnt2[-1] = 0
k1 = [k for k in cnt1.keys()]
k1.sort(key=lambda x: cnt1[x], reverse=True)
k2 = [k for k in cnt2.keys()]
k2.sort(key=lambda x: cnt2[x], reverse=True)

if k1[0]!=k2[0]:
    print(n-cnt1[k1[0]]-cnt2[k2[0]])
else:
    print(min(n-cnt1[k1[0]]-cnt2[k2[1]], n-cnt1[k1[1]]-cnt2[k2[0]]))

Measured memory_bytes: 105608
#include <bits/stdc++.h>
using namespace std;
int main(){
  double N,sumx=0,sumu=0;
  cin>>N;
  vector<double> x(N);
  vector<string> u(N);
  for(int i=0;i<N;i++){
    cin>>x.at(i)>>u.at(i);
  }
  for(int i=0;i<N;i++){
    if(u.at(i)=="BTC"){
      sumu+=380000.0*x.at(i);
    }
    if(u.at(i)=="JPY"){
      sumx+=x.at(i);
    }


  }
  cout<<sumx+sumu<<endl;





}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

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


ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}


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

    vector<ll>a(n);
    vector<ll>b(n);

    rep(i,n){
        ll x,y;
        cin >> x >> y;
        a[i] = x+y;
        b[i] = x-y;
    }

    sort(all(a));
    sort(all(b));

    ll ans = max(a[n-1]-a[0],b[n-1]-b[0]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int INT_INF = 1e9;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)

template<int mod, int base = 10007>
struct rolliha {
	vector<ll> hsh, pwr;
	ll umod(ll n) { return (n % mod + mod) % mod; }
	rolliha() {}
	rolliha(const string & s) {
		int sz = (int)s.size();
		hsh.assign(sz + 1, 0);
		pwr.assign(sz + 1, 0);
		pwr[0] = 1;
		rep(i, sz) {
			hsh[i + 1] = umod(hsh[i] * base + s[i]);
			pwr[i + 1] = umod(pwr[i] * base);
		}
	}
	ll get(int l, int r) {
		return umod(hsh[r] - hsh[l] * pwr[r - l]);
	}
	ll join(ll h1, ll h2, int h2_sz) {
		return umod(h1 * pwr[h2_sz] + h2);
	}
	ll rotate(ll idx, int len_s) {
		return join(get(idx, len_s), get(0, idx), idx);
	}
};
using rh1=rolliha<(int)1e9 + 7>;
using rh2 = rolliha<(int)1e9 + 9>;
using rh=pair<rh1, rh2>;
using H = pair<ll, ll>;
rh init(const string & s) { return make_pair(rh1(s), rh2(s)); }
H get(rh & Rh, int l, int r) { return make_pair(Rh.first.get(l, r), Rh.second.get(l, r)); }
H rotate(rh & Rh, int n, int sz) { return make_pair(Rh.first.rotate(n, sz), Rh.second.rotate(n, sz)); }

int N;
string str;

bool check(int len, rh & Rh) {
	map<H, vector<int>> mp;
	rep(frm, N - len + 1) {
		int to = frm + len;
		mp[get(Rh, frm, to)].emplace_back(frm);
	}
	for (auto& e : mp) {
		int sz = e.second.size();
		if (sz == 1)
			continue;
		int mn = e.second[0];
		int mx = e.second[sz - 1];
		if (mn + len <= mx)
			return true;
	}
	return false;
}

int main() {
	cin >> N >> str;
	rh Rh = init(str);
	ll ok = 0, ng = N / 2 + 1;
	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;
		if (check(mid, Rh)) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}

	cout << ok << endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
ll power_pow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    vec<ll> A(N+1);
    rep(i,N+1)cin >> A[i];
    vec<ll> MAXA(N+1);
    rep(i,N+1){
        ll tmp = power_pow(2, min(60,i));
        if(i == N)MAXA[i] = min(INFLL, tmp);
        else MAXA[i] = min(INFLL, tmp - 1);;
    }
    rep(i,N+1){
        if(A[i] > MAXA[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    
    if(A[N] == 0){
        cout << -1 << endl;
        return 0;
    }
    vec<ll> cnt(N+1);
    vec<ll> MAX_CNT(N+1);
    MAX_CNT[0] = 1;
    rep(i,N){
        MAX_CNT[i+1] = min(INFLL/10, 2 * MAX_CNT[i] - A[i+1]);
        if(MAX_CNT[i+1] < 0){
            cout << -1 << endl;
            return 0;
        }
    }
    cnt[N] = A[N];
    for(int i = N; i >= 1; i --){
        //MAX_CNT[i-1]と、cnt[i]の差
        cnt[i-1] = min(MAX_CNT[i-1], cnt[i]) + A[i-1];;
        ll d = cnt[i] - MAX_CNT[i-1];
    }
    /*
    cerr << "AAA";
    print(A);
    print(MAXA);
    cerr <<"c";
    print(cnt);
    print(MAX_CNT);
    */
    ll ans = 0;
    rep(i,N+1)ans += cnt[i];
    cout << ans << endl;
}



Measured memory_bytes: 6364
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <unordered_set>

typedef long long ll;

using namespace std;

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

class UnionFind {
public:
    vector<ll> parent;
    UnionFind(ll n) : parent(n, -1) {}
    
    ll findParent(ll x) {
        if(parent[x] < 0) {
            return x;
        }
        
        parent[x] = findParent(parent[x]);
        return parent[x];
    }
    
    bool isSameSet(ll x, ll y) {
        return (findParent(x) == findParent(y));
    }
    
    bool mergeIfNeed(ll x, ll y) {
        ll parentX = findParent(x);
        ll parentY = findParent(y);
        
        if(parentX == parentY) {
            return false;
        }
        
        if(parent[parentX] > parent[parentY]) {
            swap(parentX, parentY);
        }
        parent[parentX] += parent[parentY];
        parent[parentY] = parentX;
        
        return true;
    }
    
    ll size(ll x) {
        return parent[findParent(x)] * (-1);
    }
};

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

    vector<int> vs;
    vector<int> ve;
    for(int i = 0; i < m; ++i) {
        int s = 0, e = 0;
        cin >> s >> e;
        vs.push_back(s);
        ve.push_back(e);
    }
    
    vector<ll> result;
    
    ll total = (n * (n - 1)) / 2;
    result.push_back(total);
    
    ll curTotal = 0;
    UnionFind uf(n + 1);
    for(ll i = m - 1; i >= 0; --i) {
        if(uf.isSameSet(vs[i], ve[i])) {
            result.push_back(total - curTotal);
        } else {
            ll s1 = uf.size(vs[i]);
            ll s2 = uf.size(ve[i]);
            
            curTotal -= s1 * (s1 - 1) / 2;
            curTotal -= s2 * (s2 - 1) / 2;
            
            uf.mergeIfNeed(vs[i], ve[i]);
            ll s = uf.size(vs[i]);
            curTotal += s * (s - 1) / 2;
            result.push_back(total - curTotal);
        }
    }
    
    for(int i = result.size() - 2; i >= 0; --i) {
        cout << result[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int main(){
	int x;
	cin>>x;

	if ( x == 200000 ){
		cout<<200000+3<<endl;
	}else{
		vector <bool> flag(200000, false);

		for (int i=2;i*i<=200000;i++){
			if ( !flag[i] ){
				for (int j=i*2;j<=200000;j+=i){
					flag[j] = true;
				}
			}
		}

		for (int i=x;i<200000;i++){
			if ( !flag[i] ){
				cout<<i<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
int a[50];
int b[50];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a, a + n);
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] != b[i])
        {
            count++;
        }
    }
    if (count >= 3)
    {
        NO;
        return 0;
    }
    YES;
}

Measured memory_bytes: 256
import itertools

N = int(input())
L = list(map(int, input().split()))
res = 0


for pair in itertools.combinations(L, 3):
  if pair[0] == pair[1] or pair[1] == pair[2] or pair[0] == pair[2]:
    continue
  if pair[0] + pair[1] <= pair[2] or pair[1] + pair[2] <= pair[0] or pair[2] + pair[0] <= pair[1]:
    continue
  res += 1
  
print(res)

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


int main(){


    int n, l, i, t;

    int k = 0;

 
    cin >> n >> l;


    vector<int> a(n + 1);


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

         cin >> a.at(i);

         }


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

         if( a.at(i) + a.at(i + 1) >= l ){

             k += 1;

             break;

             }

         }


    if( k == 1 ){

        cout << "Possible" << endl;


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

             cout << t << endl;

             }

        for( t = n - 1 ; i < t ; t = t - 1 ){

             cout << t << endl;

             }


        cout << i << endl;

        }


    else cout << "Impossible" << endl;
         

    return 0;


    }

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    boolean check = true;
    char[][] s = new char[H][W];
    for (int i =0; i<H; i++) {
      String a = sc.next();
      for (int j =0; j<W; j++) {
        s[i][j] = a.charAt(j);
      }
    }
    for (int i =1; i<H-1; i++) {
      for (int j =1; j<W-1; j++) {
        if (s[i][j] == '#') {
          if (s[i+1][j] == '.' && s[i-1][j] == '.' && s[i][j-1] == '.' && s[i][j+1] == '.') {
            check = false;
            break;
          }
        }
      }
    }
    if (s[0][0] == '#') {
      if (s[0][1] == '.' && s[1][0] == '.' ) check = false; 
    }
    if (W >= 2) {
      if (s[0][W-1] == '#') {
        if (s[0][W-2] == '.' && s[1][W-1] == '.' ) check = false; 
      }
    }
    if (H >= 2) {
      if (s[H-1][0] == '#') {
        if (s[H-2][0] == '.' && s[H-1][1] == '.' ) check = false; 
      }
    }
    if (H >= 2 && W >= 2) {
      if (s[H-1][W-1] == '#') {
        if (s[H-2][W-1] == '.' && s[H-1][W-2] == '.' ) check = false; 
      }
    }
    for (int i =1; i<H-1; i++) {
      if (s[i][0] == '#') {
        if (s[i+1][0] == '.' && s[i-1][0] == '.' && s[i][1] == '.') check = false;
      }
    }

    for (int i =1; i<H-1; i++) {
      if (s[i][W-1] == '#') {
        if (s[i+1][W-1] == '.' && s[i-1][W-1] == '.' && s[i][W-2] == '.') check = false;
      }
    }

    for (int i =1; i<W-1; i++) {
      if (s[H-1][i] == '#') {
        if (s[H-1][i+1] == '.' && s[H-1][i-1] == '.' && s[H-2][i] == '.') check = false;
      }
    }
    for (int i =1; i<W-1; i++) {
      if (s[0][i] == '#') {
        if (s[0][i+1] == '.' && s[0][i-1] == '.' && s[1][i] == '.') check = false;
      }
    }
    if (check) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}    

Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> v(n, k);
    for(int i=0; i<q; i++){
        int t;
        cin >> t;
        v[t-1]++;
    }
    for(int i=0; i<n; i++)
        v[i] -= q;
    for(int i=0; i<n; i++){
        if(v[i]>0)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}

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

int main()
{
    char s;
    cin >> s;

    if (isupper(s))
    {
        cout << 'A' << endl;
    }
    else
    {
        cout << 'a' << endl;
    }
}

Measured memory_bytes: 3632
N = gets.to_i
as = N.times.map{gets.strip.codepoints.sort!}
h=Hash.new
cnt=0
for i in 0...N
  if h[as[i]].nil?
    h[as[i]]=0
  else
    h[as[i]]+=1
    cnt+=h[as[i]]
  end
end
puts cnt


Measured memory_bytes: 25340
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String n = sc.next();
			
			if ( n.endsWith("2") ||	n.endsWith("4") || n.endsWith("5") ||
					n.endsWith("7") || n.endsWith("9") ) {
				System.out.println("hon");
			}
			else if (n.endsWith("0") ||	n.endsWith("1") || n.endsWith("6") || n.endsWith("8")) {
				System.out.println("pon");
				
			}
			else {
				System.out.println("bon");
			}
				
		}
	}

}

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



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
 
  map<int, int> m;
  int a;
  rep(i, 0, n) {
    cin >> a;
    m[a]++;
  }
  
  int ans = 0;
  map<int, int>::iterator p;
  for (p=m.begin(); p!=m.end(); p++) {
    if(p->second %2==1) ans++;
  }
  
  cout << ans << "\n";

}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll x;std::cin >> x;
  map<ll, ll> mp;
  for(ll i=-2000;i<=2000;i++) mp.emplace(i*i*i*i*i, i);

  for(ll i=-2000;i<=2000;i++){
    ll need = x + i*i*i*i*i;
    if(mp.find(need)!=mp.end()){
      std::cout << mp.at(need) << " " << i << '\n';
      return 0;
    }
  }
  std::cout << "NONE" << '\n';
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    vector<double> v(N), w(N);
    for (int i=0; i<N; ++i) {
        cin >> v[i];
        w[i] = v[i];
    }
    sort(w.begin(), w.end());
    
    int p, q;
    for (int i=0; i<N; ++i) {
        p = lower_bound(w.begin(), w.end(), v[i]) - w.begin();
        q = upper_bound(w.begin(), w.end(), v[i]) - w.begin();
        cout << p*3+(q-p-1) << endl;
    }
    return 0;
}


Measured memory_bytes: 4148
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);

    int N;
    cin >> N;
    int A[100];
    for(int i=0; i<N; i++) cin >> A[i];

    int ans = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            ans = max(ans, abs(A[i] - A[j]));
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

int main()
{
 	int n,a=0;
 	cin>>n;
 	for(int i=1;i<=n;i++)
 	{
 		a=a+i;
 	}
 	cout<<a<<endl;
 	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<double> X(N),Y(N);
    
    for(int i=0;i<N;i++) cin>>X[i]>>Y[i];
    //for(int i=0;i<N;i++) cin>>Y[i];
    
    vector<int> id(N);
    iota(all(id),0);
    
    double ans=0.0;
    
    do{
        for(int i=1;i<N;i++){
            ans+=hypot(X[id[i]]-X[id[i-1]],Y[id[i]]-Y[id[i-1]]);
        }
        
    }while(next_permutation(all(id)));
    
    for(int i=1;i<=N;i++) ans/=i;
    
    cout<<setprecision(25)<<ans<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin>>x;
    if(x>=400 && x<=599)
    	cout<<8;
    else if(x>599 && x<=799)
    	cout<<7;
    else if(x>799 && x<=999)
    	cout<<6;
    else if(x>899 && x<=1199)
    	cout<<5;
    else if(x>1199 && x<=1399)
    	cout<<4;
    else if(x>1399 && x<=1599)
    	cout<<3;
    else if(x>1599 && x<=1799)
    	cout<<2;
    else if(x>1799 && x<=1999)
    	cout<<1;
    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>

using namespace std;

long GCD(unsigned long a,unsigned long b){
	if(b==0) return a;
	return GCD(b,a%b);
}

int main(void){

	unsigned long x,y;

	cin>>x>>y;

	cout<<GCD(x,y)<<endl;

	return 0;
}

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

int main() {

	int N, M, K;
	cin >> N >> M >> K;
	vector<ll> A(200001,0);
	vector<ll> B(200001,0);
	ll cA = 0;
	for (int i = 1; i <= N; i++) {
		ll a;
		cin >> a;
		cA += a;
		A[i] = cA;
	}
	ll cB = 0;
	for (int i = 1; i <= M; i++) {
		ll b;
		cin >> b;
		cB += b;
		B[i] = cB;
	}

	int it = N;
	int jt = M;
	while (A[it] > K && it >= 0) {
		it--;
	}
	while (A[it] + B[jt] > K && jt >= 0) {
		jt--;
	}
	int maxc = it + jt;

	while (it >= 0) {
		while (jt + 1 <= M) {
			if (A[it] + B[jt + 1] <= K) {
				jt++;
			}
			else {
				break;
			}
		}
		int c = it + jt;
		if (c > maxc) maxc = c;
		it--;
	}

	cout << maxc << endl;
	return(0);
}


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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx;
	int dy = ty - sy;

	string ans = "";
	for (int i = 0; i < dx; i++) {
		ans += "R";
	}
	for (int i = 0; i < dy; i++) {
		ans += "U";
	}
	for (int i = 0; i < dx; i++) {
		ans += "L";
	}
	for (int i = 0; i < dy; i++) {
		ans += "D";
	}

	ans += "D";
	for (int i = 0; i < dx + 1; i++) {
		ans += "R";
	}
	for (int i = 0; i < dy + 1; i++) {
		ans += "U";
	}
	ans += "L";
	ans += "U";
	for (int i = 0; i < dx + 1; i++) {
		ans += "L";
	}
	for (int i = 0; i < dy + 1; i++) {
		ans += "D";
	}
	ans += "R";

	cout << ans << endl;
}

Measured memory_bytes: 256
def can(state, m, bulb, p):
	"""For given switch state, determine all bulbs are turned on."""
	for i in range(m):
		cnt = 0 #how many switches are on.
		for j in bulb[i]:
			if (state & (1<<(j-1))):
				cnt += 1
		if cnt % 2 != p[i]:
			return False
	return True

n, m = map(int, input().split())
bulb = []
for i in range(m):
	l = list(map(int, input().split()))
	l = l[1:]
	bulb.append(l)
p = list(map(int, input().split()))

ans = 0
for i in range(1<<n):
	if can(i, m, bulb, p):
		ans += 1
print(ans)


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

int main(){
	long long N;
	cin >> N;

	int i=1;
	long long k = N;
	while( k > 0 ){
		k -= pow(26,i);
		i++;
	}

	vector<char> s(i-1);
	k = N;
	for(int j=1; j<i-1; j++){
		k -=pow(26,j);
	}
	
	if( i==2 ){
		cout << char(k+96) << endl;
		return 0;
	}

	long long l, tmp, atmp;
	tmp = k-1;
	atmp = k-1;
	for(int j=0; j<s.size(); j++){
		l = pow(26,i-2);
		atmp = tmp/l;

		s.at(j) = char(atmp+97);

		tmp -= atmp * l; 

		i--;
	}

	for(int j=0; j<s.size(); j++){
		cout << s.at(j);
	}
	cout << endl;

}


Measured memory_bytes: 4104
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef struct node {
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
}Node;
Node *root;



void insert(Node *z){
  Node *y = NULL;
  Node *x = root;
  while(x!=NULL){
    y=x;
    if((z->key)<(x->key))x=x->l;
    else x=x->r;
  }
  z->p=y;
  if(y==NULL)root=z;
  else if(z->key<y->key)y->l=z;
  else y->r=z;
}
void inorder(Node *node){
  if(node==NULL){
    return;
  }
  inorder(node->l);
  cout<<" "<<node->key;
  inorder(node->r);
}
void preorder(Node *node){
  if(node==NULL){
    return;
  }
    cout<<" "<<node->key;
    preorder(node->l);
    preorder(node->r);
}
Node* find(Node *node,int k){
  if(node==NULL){
    return 0;
  }
  if(node->key==k){
    //cout<<"yes"<<endl;
    return node;
  }
  else if(node->key<k)find(node->r,k);
  else find(node->l,k);
}


Node* nodemini(Node *x){
  while(x->l!=NULL)x=x->l;
  return x;
}
Node* nodesuccessor(Node *x){
  Node *y;
  if(x->r!=NULL)return nodemini(x->r);
  y=x->p;
  while(y!=NULL&&x==y->r){
    x=y;
    y=y->p;
  }
  return y;
}
void nodedelete(Node* z){
  Node *y,*x;
  if(z->l==NULL||z->r==NULL)y=z;
  else y=nodesuccessor(z);
  if (y->l!=NULL)x=y->l;
  else x=y->r;
  if(x!=NULL)x->p = y->p;
  if(y->p==NULL)root=x;
  else if (y==y->p->l)y->p->l=x;
  else y->p->r=x;
  if(y!=z)z->key=y->key;
}
int main(){
  int n,i,k;
  Node *tmp;
  string str;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>str;
    if(str=="insert"){
      tmp=(Node *)malloc(sizeof(Node));
      tmp->p=tmp->l=tmp->r=NULL;
      cin>>tmp->key;
      insert(tmp);
    }
    else if(str=="find"){
      cin>>k;
      tmp=find(root,k);
      if(tmp!=NULL)cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
    else if(str=="delete"){
      cin>>k;
      nodedelete(find(root,k));
    }
    else{
      inorder(root);
      cout<<endl;
      preorder(root);
      cout<<endl;
    }
  }


  return 0;
}



Measured memory_bytes: 21932
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void) {
	int n, m, i, a, b, s[100003] = {};

	cin >> n >> m;
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		s[a - 1]++;
		s[b - 1]++;
	}

	for (i = 0; i < n; i++) {
		if ((s[i] & 1) == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	ll n;cin>>n;
	ll ans = 10000000000000;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			chmin(ans, n/i-1+(i-1));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <stack>

using namespace std;

template<class T> bool operator<(const complex<T> &a, const complex<T> &b){
    return a.real() == b.real() ? a.imag() < b.imag() : a.real() < b.real();
}

typedef complex<double> P;
#define X real()
#define Y imag()

double dot(P a, P b){
    return (a * conj(b)).X;
}

double cross(P a, P b){
    return (a * conj(b)).Y;
}

int main() {
    int c5 = 0;
    int c7 = 0;
    int n;

    for (int i = 0; i < 3 ; ++i) {
        cin >> n;
        if(n == 5) c5++;
        if(n == 7) c7++;
    }

    if(c5 == 2 && c7 == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int a[112345];

int n;
int main () {
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i];
    long long int ans = 112345678911234;
    for(int i=0; i<2; i++) {
        long long int cnt = 0;
        long long int sum = 0;
        for(int j=0; j<n; j++) {
            if( (i+j) % 2 ) {   // odd
                sum += a[j];
                if( sum >= 0 ) {
                    cnt += sum + 1;
                    sum = -1;
                }
            } else {            // even
                sum += a[j];
                if( sum <= 0) {
                    cnt += 1 - sum;
                    sum = 1;
                }
            }
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
# ABC061D - Score Attack
import sys
input = sys.stdin.readline

def bellman_ford(N: int, M: int, E: "Array[Array[int]]") -> int or None:
    INF = float("inf")
    dist = [INF] * (N + 1)
    dist[1] = 0

    # relax edges
    for i in range(N):
        for v, u, w in E:  # w: positive -> -w
            if v != INF and dist[v] - w < dist[u]:
                dist[u] = dist[v] - w
                if i == N - 1 and u == N:  # detect negative cycles
                    return None
    return dist[-1]


def main():
    # reverse weights -> shortest path problem containing negative cycles
    N, M = tuple(map(int, input().split()))  # vertices, edges
    E = tuple(tuple(map(int, input().split())) for _ in range(M))
    ans = bellman_ford(N, M, E)
    flg = ans is not None
    print(-ans if flg else "inf")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3312
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
        mut ab:[(i64,i64);n],
    }
    ab.sort_by(|a,b|{
        a.1.cmp(&b.1)
    });
    let mut ans = true;
    // ab.reverse();
    // println!("{:?}", ab);
    let mut now:i64 = -1;
    for &(a,b) in &ab {
        // println!("{}", now);
        if now == -1 {
            if a > b {
                ans = false;
                break;
            }
            now = a;
            continue;
        }
        if now + a > b {
            ans = false;
            break;
        }
        now = now + a;
    }
    if ans {
        println!("Yes");
    }else{
        println!("No");
    }

}

Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
int n,m;
char s[1007][1007],flag[3][3];
int ans=0,ml=0;
int main(){
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            cin>>flag[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            char p=s[i][j];
            int res=0,ret=0;
            for(int k=1;k<=3;k++){
                if(k==1) s[i][j]='J';
                else if(k==2) s[i][j]='O';
                else s[i][j]='I';
                int cnt=0,ok=1;
                if(i<n-1 && j<m-1){
                    ok=1;
                    for(int ii=i;ii<=i+1;ii++){
                        for(int jj=j;jj<=j+1;jj++){
                            if(s[ii][jj]!=flag[ii-i][jj-j]) ok=0;
                        }
                    }
                    if(p==s[i][j]) res+=ok;
                    cnt+=ok;
                }
                if(i<n-1 && j>0){
                    ok=1;
                    for(int ii=i;ii<=i+1;ii++){
                        for(int jj=j-1;jj<=j;jj++){
                            if(s[ii][jj]!=flag[ii-i][jj-j+1]) ok=0;
                        }
                    }
                    cnt+=ok;
                }
                if(i>0 && j<m-1){
                    ok=1;
                    for(int ii=i-1;ii<=i;ii++){
                        for(int jj=j;jj<=j+1;jj++){
                            if(s[ii][jj]!=flag[ii-i+1][jj-j]) ok=0;
                        }
                    }
                    cnt+=ok;
                }
                if(i>0 && j>0){
                    ok=1;
                    for(int ii=i-1;ii<=i;ii++){
                        for(int jj=j-1;jj<=j;jj++){
                            if(s[ii][jj]!=flag[ii-i+1][jj-j+1]) ok=0;
                        }
                    }
                    cnt+=ok;
                }
                if(p!=s[i][j]) ret=max(ret,cnt);
            }
            s[i][j]=p;
            ml=max(ml,ret-res);
            ans+=res;
        }
    }
    cout<<ans+ml<<endl;
}

Measured memory_bytes: 4188
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
int a[1005];
void zz(int x)
{
    for(int i=2; i<=x; i++)
        while(x%i==0)
        {
            x/=i;
            a[i]++;
        }
}
int main()
{
    int n;
    while(scanf("%d",&n)!=-1)
    {
        memset(a,0,sizeof(a));
        for(int i=2;i<=n;i++)
            zz(i);
            long long ans=1;
            for(int i=2;i<=1000;i++)
            {
                if(a[i])
                    ans*=(a[i]+1);
                ans%=1000000007;
            }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    int tmp;
    sscanf((a+b).c_str(),"%d",&tmp);
    for(int i=0;i*i<100100;i++){
        if(i*i==tmp){
            puts("Yes\n");
            exit(0);
        }
    }puts("No\n");
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;


void solve() {
	int N, K; cin >> N >> K;
	vector<P>v(N);
	REP(i, N) {
		cin >> v[i].first >> v[i].second;
	}
	VSORT(v);
	int sum = 0;
	REP(i, N) {
		sum += v[i].second;
		if (sum >= K) {
			print(v[i].first); return;
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


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

int main() {
	int N;
	cin >> N;
	for(int i=1;i<=N;i++){
		int count = 0;
		int a;
		a = 2*i;
		int b = sqrt(a);
		for(int j = 2;j<=b;j++){
			int g;
			g = a;
			g -= j*j;
			int c = sqrt(g);
			for(int k = 2;k<=c;k++){
				int h;
				h = g;
				h -= k*k;
				int d = sqrt(h);
				int e = h - d*d;
				if(d >=2){
				if(e == 0){
					int x,y,z,f;
					f = j+k+d;
					if(f%2 == 0){
						f /= 2;
						x = f - j;
						y = f - k;
						z = f - d;
						if(x > 0 && y > 0 && z > 0){
							count ++;
				}

					}
				}
			}
			}
		}
		cout << count << endl;

	}
}

Measured memory_bytes: 3676