akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
//#include <intrin.h>  //AtCoder (gcc) 上ではこれがあると動かない。__popcnt用のincludeファイル。
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;


#define int long long
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const int INF = 2e9;
const ll large_P = 1e9 + 7;



//繰り返し2乗法
//N^aの、Mで割った余りを求める。
ll my_pow(ll N, ll a, ll M) {
	ll tempo;
	if (a == 0) {
		return 1;
	}
	else {
		if (a % 2 == 0) {
			tempo = my_pow(N, a / 2, M);
			return (tempo * tempo) % M;
		}
		else {
			tempo = my_pow(N, a - 1, M);
			return (tempo * N) % M;
		}
	}
}



//N_C_a を M で割った余り
ll my_combination(ll N, ll a, ll M) {
	ll answer = 1;

	rep(i, a) {
		answer *= (N - i);
		answer %= M;
	}

	rep(i, a) {
		answer *= my_pow(i + 1, M - 2, M);
		answer %= M;
	}

	return answer;
}



ll my_gcd(ll& a, ll& b) {
	if (b == 0) return a;
	ll temp = a % b;
	return my_gcd(b, temp);
}



// long long型 n を、base 進法での、i 桁目の数が入った vector にする。
void ll_to_vector(ll base, ll n, vector<ll>& v) {
	ll tempo = n;

	ll n_digit = floor(log10(n) / log10(base)) + 1;
	v.assign(n_digit, 0);

	//ll n_digit = v.size();

	for (ll i = 0; i < n_digit; i++) {
		v.at(i) = tempo / pow(base, n_digit - 1 - i);
		tempo -= v.at(i) * pow(base, n_digit - 1 - i);
	}
}



int char_to_int(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4;
	case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9;
	default: return 0;
	}
}


//target が素数かどうか判定する。
//true で初期化された vector を代入する必要がある。
void prime_judge(vector<bool>& prime_or_not) {

	prime_or_not.at(0) = false;
	prime_or_not.at(1) = false;

	ll n = prime_or_not.size() - 1;
	ll region = sqrt(n) + 1;

	for (ll i = 2; i <= n / 2; i++) {
		prime_or_not.at(2 * i) = false;
	}


	for (ll i2 = 1; i2 < n / 2; i2++) {
		ll i = 2 * i2 + 1;  //ここからは奇数のみ探索
		if (i < region && prime_or_not.at(i)) {
			ll j = i * i;
			while (j < n + 1) {
				prime_or_not.at(j) = false;
				j += 2 * i;
			}
		}
	}
};







signed main() {
	int N; cin >> N;
	int M = N;

	vector<bool> prime_or_not(N + 1, true);
	if (N < 20) prime_or_not.assign(25, true);

	prime_judge(prime_or_not);
	vector<int> p(N + 1, 0);

	rep(i, N + 1) {
		if (prime_or_not.at(i)) {
			
			int temp = 0; int beki = 1;
			while (M >= pow(i, beki)) {
				temp = M / pow(i, beki);
				p.at(i) += temp;
				p.at(i) %= large_P;

				beki++;
			}
		}
	}

	int res = 1;
	rep(i, N + 1) {
		res *= p.at(i) + 1;
		res %= large_P;
	}

	cout << res << endl;

	//rep(i, N + 1) cout << i << ": " << p.at(i) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>

using namespace std;

int main(void) {
    int n;
    int h=0, t;
    int times=0;

    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        scanf("%d", &t);
        times += max(t-h, 0);
        h = t;
    }

    printf("%d\n", times);

    return 0;
}


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

int main() {
  int n, l, c = 0;
  cin >> n >> l;
  for (int i = l; i <= n + l - 1; i++) c += i;

  if (l > 0)
    c -= l;
  else if (n + l - 1 < 0)
    c -= n + l - 1;

  cout << c << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <string>
#include <math.h>

typedef long long ll;

using namespace std;

int main()
{
	vector<ll> v;
	
	ll n;

	cin >> n;

	for (int i = 0; i < 5; i++)
	{
		ll a;
		cin >> a;
		v.push_back(a);
	}

	sort(v.begin(), v.end());

	n  = n - v[0];

	double x = (double)n / v[0];

	ll ans = (ll)ceill(x);

	cout << ans+5;

	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]

use std::cmp::{max, min};

macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };
  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };
  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };
  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };
  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: i32,
    a: i32,
    b: i32,
    s: String,
  }
  let mut x = 0;
  let mut y = 0;
  for c in s.chars() {
    if c == 'a' {
      if x < a + b {
        println!("Yes");
        x += 1;
      } else {
        println!("No");
      }
    } else if c == 'b' {
      if x < a + b && y < b {
        println!("Yes");
        x += 1;
        y += 1;
      } else {
        println!("No");
      }
    } else {
      println!("No");
    }
  }
}


Measured memory_bytes: 2240
#!/usr/bin/ruby
H,W=gets.split.map &:to_i
m=H.times.map{gets.chomp}
r=0;m.each{|e|r+=e.count('.')}
d={[0,0]=>1}
q=[[0,0]]
while !q.empty?
	cy,cx=q.shift
	[[-1,0],[0,-1],[1,0],[0,1]].each{|dy,dx|
		ny=cy+dy
		nx=cx+dx
		if 0<=ny&&ny<H && 0<=nx&&nx<W && m[cy][cx]=='.' && !d[[ny,nx]]
			d[[ny,nx]]=d[[cy,cx]]+1
			q<<[ny,nx]
		end
	}
end
p d.has_key?([H-1,W-1]) ? r-d[[H-1,W-1]] : -1

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

int main () {
  string S;
  cin >> S;

  if (S.at(0) != S.at(1) && S.at(1) != S.at(2) && S.at(2) != S.at(0)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  /*
  int answer = 0;

  for (int i = 0; i < 3; i++) {
    if (S.at(i) == 'a') {
      answer ++;
    }
    else if (S.at(i) == 'b') {
      answer ++;
    }
    else if (S.at(i) == 'c') {
      answer ++;
    }
  }
  if (answer == 3) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  */
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (u == s) {
    cout << a - 1 << " " << b << endl;
  } else {
    cout << a  << " " << b - 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//This code was made by Chinese_zjc_
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int s;
string z; 
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>s>>z;
	if(s>=3200)
	{
		cout<<z;
		return 0;
	}
	cout<<"red";
	return 0;
}


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

int main(){
  int x,y; cin>>x>>y;
  bool ans=false;
  for (int i=0; i<=x; i++){
    int turu=2*i;
    int kame=4*(x-i);
    if (turu+kame==y) ans=true;
  }
  cout<<(ans ? "Yes":"No")<<endl;
}

Measured memory_bytes: 3568
#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 <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000000000;
const int MOD = 1000000007;

typedef pair<int, int> P;
int myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
bool E[101][101];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

void bfs(int start) {
    //全頂点を未訪問にして距離も初期化(INF)
    for (int i = 0; i < 101; i++) D[i] = -1;
    queue<int> Q;
    //最初の頂点をキューに入れる
    Q.push(start);
    int v;
    //最初の頂点は距離0
    D[start] = 0;
    //キューが空になるまで探索
    while (!Q.empty()) {
        v = Q.front();
        Q.pop();
        for (int i = 1; i <= N; i++) {
            //今訪問している頂点vから辺があるか&&すでに訪問済み(距離がINFではない)を確認
            if (!E[v][i]) continue;
            if (D[i] != -1) continue;
            //未訪問かつ辺があったなら元の頂点の距離に1を足す
            D[i] = D[v] + 1;
            //発見した頂点をキューに入れて再度探索
            Q.push(i);
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << i << " " << D[i] << endl;
    }
}

int main() {
    int N, W; cin >> N >> W;
    int V[101];
    int H[101];
    int dp[101][10001];
    for (int i = 0; i < N; i++) cin >> V[i] >> H[i];

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j < (H[i])) dp[i+1][j] = dp[i][j];
            else {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - H[i]] + V[i]);
            }
        }
    }

    cout << dp[N][W] << endl;
}



Measured memory_bytes: 7028
#include<bits/stdc++.h>
using namespace std;
// #pragma GCC optimize ("-O3")
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long double PI = 3.14159265358979323846;  /* pi */

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = r / d - (l-1) / d;
    cout << ans;
    return 0;
}

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

bool prime[300000];

void is_prime(int n){
	for(int i = 0; i <= n * 2; ++i)
		prime[i] = true;
	
	prime[0] = prime[1] = false;
	
	for(int i = 2; i <= n * 2; ++i){
		if(prime[i]){
			for(int j = i * 2; j <= n * 2; j += i)
				prime[j] = false;
		}
	}
}
int main() {
	int n;
	while(cin >> n && n){
		is_prime(n);
		int ans = 0;
		for(int i = n + 1; i <= n * 2; ++i){
			if(prime[i])
				ans++;
		}
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1400
N,P=map(int,input().split())
S=input()

answer=0
if P==2 or P==5:
  for i in range(N):
    si=int(S[i])
    if si%P==0:
      answer+=i+1
else:
  mod_table=[0]*P
  mod_table[0]=1
  revS=S[::-1]
  
  modp=0
  mod10=1
  for i in range(N):
    mod10=(mod10*10)%P
    #modp=(10*modp+int(revS[i]))%P
    modp=(modp+mod10*int(revS[i]))%P
    mod_table[modp]+=1
    
  #print(mod_table)
  for i in range(P):
    answer+=mod_table[i]*(mod_table[i]-1)//2
  
print(answer)
    

Measured memory_bytes: 3500
// B.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
	int n, m;
	cin >> n >> m;
	int cnt[100001] = {};
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}
	bool ans = true;
	for (int i = 1; i <= n; ++i) {
		if (cnt[i] % 2) {
			ans = false;
		}
	}
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 640
# AOJ 0620: Swapping Bibs
# Python3 2018.7.2 bal4u

n, m = map(int, input().split())
a = [int(input()) for i in range(n)]
for k in range(1, m+1):
	for i in range(n-1):
		if a[i]%k > a[i+1]%k: a[i], a[i+1] = a[i+1], a[i]
print(*a, sep='\n')


Measured memory_bytes: 5620
while True:
    m,f,r = (int(x) for x in input().split())
    if m == f == r == -1:
        break
    
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >=65:
        print("B")
    elif m + f >= 50 or (m + f >= 30 and r >= 50):
        print("C")
    elif m + f >= 30:
        print("D")
    else:
        print("F")


Measured memory_bytes: 5604
#include<iostream>
#include<queue>
#include<limits>
// #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<math.h>
#include<iomanip>  
#include<deque> 
#include<stack>
#include<string> 
#include<string.h>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#define ll long long
#define tc(t)  while(t--)
#define V vector
#define Vp vector< pair<int,int> >
#define pb push_back
#define UM unordered_map
#define IT iterator
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define PQ priority_queue
#define _FI ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

 char ar[140000];
vector<ll> SieveOfEratosthenes(ll n) 
{ 
  vector<ll> result;
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
    int count=1;
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        {  
            for (ll i=p*p; i<=n; i += p) 
                {
                  prime[i] = false; 
                }
            count++;
        } 
    } 
  
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          {
            result.push_back(p);
          }
    return result;
}



vector<ll> Divisors (ll n)
{
  vector<ll> res;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(n/i==i)
      {
        res.pb(i);
      }
      else
      {
        res.pb(i);
        res.pb(n/i);
      }
    }
  }

  return res;
}

ll Div(ll n)
{
  for(ll i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
      return i;
  }
  return n;
}

int a[4][2]={ {1,0}, {1,-1}, {1,1}, {2,0} } ;
bool validPoint(int x,int y, int N)
{
    return (x>=0 && x<N && y>=0 && y<N);
}


int main()
{
  _FI 

  int t=1;
  // cin>>t;
  tc(t)
  {
    int n,m;
    cin>>n>>m;
    V<int> arr(m,0);
    int sum=0;
    forn(i,m)
    	{
    		cin>>arr[i];
    		sum+=arr[i];
    	}
    if(sum<=n)
    {
    	cout<<n-sum<<endl;
    }
    else
    {
    	cout<<-1<<endl;
    }

  }

  return 0;
}



Measured memory_bytes: 3184
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

x = int(input())
a = x//500
b = x % 500
c = b//5
print(a*1000+c*5)


Measured memory_bytes: 3832
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long X = scanner.nextLong();
        scanner.close();

        long sum = 100l;
        long ans = 0l;
        while (true) {
            sum = (long) (sum * 1.01);
            ans++;
            if (sum >= X) {

                break;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35780
#include <iostream>
#include <vector>
#include <climits>

using namespace std;
using ll=long long;
struct Edge{
    int a, b, c;
};
int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> cost(n, LLONG_MIN);
    cost[0]=0;
    vector<Edge> edge(m);
    for(int i=0;i<m;++i){
        cin >> edge[i].a >> edge[i].b >> edge[i].c;
        --edge[i].a, --edge[i].b;
    }
    bool flag;
    int k;
    for(k=0;k<n;++k){
        flag=true;
        for(int i=0;i<m;++i){
            if(cost[edge[i].a]==LLONG_MIN)
                continue;
            if(cost[edge[i].b]<cost[edge[i].a]+edge[i].c){
                cost[edge[i].b]=cost[edge[i].a]+edge[i].c;
                flag=false;
            }
        }
        // for(int i=0;i<n;++i){
        //     cout << i << " " << cost[i] << endl;
        // }
        if(flag)
            break;
    }
    if(k==n && !flag){
        ll c = cost[n-1];
        for(int i=0;i<m;++i){
            if(cost[edge[i].a]==LLONG_MIN)
                continue;
            if(cost[edge[i].b]<cost[edge[i].a]+edge[i].c){
                cost[edge[i].b]=cost[edge[i].a]+edge[i].c;
            }
        }
        if(c!=cost[n-1])
            cout << "inf";
        else
            cout << cost[n-1];
    }else{
        cout << cost[n-1];
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int;
#define pb push_back;
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main() {
	ios;
	int n,k;
	cin>>n>>k;
	if(n*500 >= k) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<queue>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<ll> q;
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        q.push(a);
    }
    while(m > 0){
        ll t = q.top();
        q.pop();
        t /= 2;
        q.push(t);
        m--;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define mod 1000000007
#define mx 100003
#define ss second
#define ff first
#define ld long double
#define pii pair<int, int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;


int main()
{
    IOS;
    string s, t;
    cin >> s >> t;
    int m = s.length(), n = t.length();
    int dp[m+1][n+1];
   for (int i=0; i<=m; i++)
   {
     for (int j=0; j<=n; j++)
     {
       if (i == 0 || j == 0)
         dp[i][j] = 0;
       else if (s[i-1] == t[j-1])
         dp[i][j] = dp[i-1][j-1] + 1;
       else
         dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
     }
   }
   int index = dp[m][n];
   char lcs[index+1];
   lcs[index] = ' ';
   int i = m, j = n;
   while (i > 0 && j > 0)
   {
      if (s[i-1] == t[j-1])
      {
          lcs[index-1] = s[i-1];
          i--; j--; index--;
      }
      else if (dp[i-1][j] > dp[i][j-1])
         i--;
      else
         j--;
   }
    rep(k,0,dp[m][n]) cout << lcs[k];
}


Measured memory_bytes: 35456
def fun(x):
    K = x**2
    return(K)
Sta = 0
End = 600
while True:
    try:
        h = int(input())
        n = int(600/h)
        Sun = 0
        for i in range(1,n):
            Sun += fun(h*i) * h
        print (Sun)     
    except EOFError:
        break

Measured memory_bytes: 7556
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 long long INF = 1e18;
//const ll mod = 1000000007;
int num[1010000];
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    num[A[i]]++;
  }
  int ans = 0;
  for(int i = 0; i < N; i++) {
    bool ok = true;
    for(int j = 1; j * j <= A[i]; j++) {
      if(A[i] % j != 0) continue;
      if(num[j] >= 2) ok = false;
      if(j != A[i] and num[j] >= 1) ok = false;
      int k = A[i] / j;
      if(num[k] >= 2) ok = false;
      if(k != A[i] and num[k] >= 1) ok = false;
    }
    if(ok) {
      //cerr << i << endl;
      ans++;
    }
  }
  cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7780
// 2020 05 02
// ABC166 C Peaks
#include <algorithm>
#include <complex>
#include <string>
#include <deque>
#include <iostream>
#include <set>
#include <stack>
#include <string>
#include <queue>
#include <utility>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> height;
    vector<priority_queue<int>> ten(n);
    rep(i, n) {
        int h;
        cin >> h;
        height.push_back(h);
    }
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        ten[a].push(height[b]);
        ten[b].push(height[a]);
    }

    int ans = 0;
    rep(i, n) {
        if (ten[i].empty()) {
            ans++;
            continue;
        }
        int max_h = ten[i].top();
    //    cout << height[i] << " " << max_h << endl;
        if (max_h < height[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9460
#include<iostream>
#include <bits/stdc++.h>
#include<algorithm>
#include <cstring>
#define endl "\n"
#define SRK ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define EPS 1e-6
#define MAX 100000
typedef long long ll;
const ll MOD = 1e9 + 7;
using namespace std;

int main()
{
    string s;
    cin >> s;
    if ((s[2] == s[3]) &&(s[4] == s[5]))
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }

}


Measured memory_bytes: 3552
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
using namespace std;
//
const int inf=1e9+7;//0x3f
//
int N;
long long H[5000],P[5000];
long long DP[5001][5001];
int main(){
	cin>>N;
	vector<pair<long long,int>> V;
	for(int i=0;i<N;i++){
		cin>>H[i]>>P[i];
		V.push_back(make_pair(H[i]+P[i],i));
	}
	sort(V.begin(),V.end());
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			DP[i][j]=1e18+7;
		}
	}
	DP[0][0]=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<=i;j++){
			if(DP[i][j]==inf){
				continue;
			}
			DP[i+1][j]=min(DP[i][j],DP[i+1][j]);
			if(DP[i][j]<=H[V[i].second]){
				DP[i+1][j+1]=min(DP[i+1][j+1],DP[i][j]+P[V[i].second]);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=N;i++){
		if(DP[N][i]!=1e18+7){
			ans=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

double dist( array<int,2>, array<int,2> );

int main(){
    int N;
    array< array<int,2>, 8> points;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> points[i][0] >> points[i][1];
    }

    double total_distance = 0.0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            total_distance += dist( points[i], points[j] );
        }
    }

    // cout << total_distance * 2.0 / N << endl;
    printf("%12.10f\n", total_distance * 2.0 / N );
    
    return 0;
}

double dist( array<int,2> p1, array<int,2> p2 ){
    return sqrt((p1[0]-p2[0])*(p1[0]-p2[0]) + (p1[1]-p2[1])*(p1[1]-p2[1]));
} 


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

int main() {
	int H, W, K, a = 1;
	cin >> H >> W >> K;
	vector<string> s(H);
	for (string& i : s) cin >> i;
	vector<int> b, c;
	for (int i = 0; i < H; i++) {
		if (s[i].find('#') != string::npos) c.push_back(i);
		else b.push_back(i);
	}
	s.erase(remove_if(s.begin(), s.end(), [](string& a) { return a.find('#') == string::npos; }), s.end());
	vector<vector<int>> ans(H, vector<int>(W));
	for (int i = 0; i < s.size(); i++) {
		ans[c[i]].front() = a;
		for (int j = 1; j < s[i].size(); j++) {
			if (s[i][j - 1] == '#') {
				if (find(s[i].begin() + j, s[i].end(), '#') != s[i].end()) a++;
			}
			ans[c[i]][j] = a;
		}
		a++;
	}
	for (int i = 0; i < H; i++) {
		if (binary_search(b.begin(), b.end(), i)) {
			vector<int>::iterator d = lower_bound(c.begin(), c.end(), i);
			if (d != c.end()) ans[i] = ans[*d];
			else ans[i] = ans[*(d - 1)];
		}
	}
	for (vector<int>& i : ans) {
		for (int j = 0; j < i.size() - 1; j++) cout << i[j] << ' ';
		cout << i.back() << endl;
	}
}

Measured memory_bytes: 1280
#include <stdio.h>
int main(void)
{
    char buf[16];
    int a[10][10];
    while (scanf("%s", buf) != EOF) {
        int i, j;
        for (i=0; i<10; ++i) { a[0][i]=buf[i]-'0'; }
        for (i=1; i<10; ++i)
            for (j=0; j<10-i; ++j)
                a[i][j]=(a[i-1][j]+a[i-1][j+1])%10;
        printf("%d\n", a[9][0]);
    }
    return 0;
}

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

using namespace std;

int main()
{
    int card[4][13]={};
    int t;
    int n;
    char m;

    cin >> t;
    for(int i=0;i<t;i++)
    {
        cin >> m >> n;
        switch(m)
        {
            case 'S':
                card[0][n-1]=1;
                break;
            case 'H':
                card[1][n-1]=1;
                break;
            case 'C':
                card[2][n-1]=1;
                break;
            case 'D':
                card[3][n-1]=1;
                break;
            default:
                return -1;
        }
    }

    for(int i=0; i < 4; i++)
    {
        switch (i)
        {
            case 0:
                m = 'S';
                break;
            case 1:
                m = 'H';
                break;
            case 2:
                m = 'C';
                break;
            case 3:
                m = 'D';
                break;
            default:
                return -1;
        }
        for(int j=0; j < 13; j++)
        {
            if(card[i][j] == 0)
            {
                cout << m << ' ' << j+1 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int X; cin >> X;
    int d = X/100;
    int r = X%100;
    rep(i,101)rep(j,51)rep(k,34)rep(l,26)rep(m,21){
        if(i+2*j+3*k+4*l+5*m == r && d-i-j-k-l-m >= 0){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    string s;
    cin >> s;
    int a = 0, b = 0;
    for (int i = 0; i < s.size(); i++) {
        if(i % 2 != s[i] - '0') {
            a++; // 0101..
        } else {
            b++; // 1010..
        }
    }
    cout << min(a, b) << endl;
}

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

// Preparing for IOI 2018

using namespace std;

const int inf = (int) 1e9 + 7;
const int N = (int) 1e5 + 7;
const double PI = 3.141592653589793238462643;
const double eps = 0.000000001;

#define ok puts("OK");
#define ll long long
#define fr first
#define sc second
#define eb emplace_back
#define sz(s) ((int)s.size())
#define all(s) s.begin(), s.end()

int a[26];

inline void solve () {
	string s; cin >> s;
	int n = sz(s);    
	for (int i = 0; i < n; i++) {
		a[s[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (a[i] == 0) {
			cout << char(i + 'a');
			return ;
		}
	}
	puts("None");
}

int test = 1;

main () {
        // freopen("example.in", "r", stdin); freopen("example.out", "w', stdout);
        // scanf ("%d", &test);
        while (test--) {
                solve();
        }
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            for (char cc : in.next().toCharArray())
                out.print(cc == '1' ? '9' : '1');
            out.println();
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b < 10) {
		cout << a + b << endl;
	}
	else {
		cout << "error" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String s = fs.next();
        
        if (s.equals("ABC")) {
            System.out.println("ARC");

        } else {
            System.out.println("ABC");
        }

    }


    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }

}


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

using namespace std;



int main(){
    int n;
    cin >> n;
    int i = 1;
    while(1){
        if(i*(i+1)/2 < n){
            i++;
        }
        else{
            break;
        }
    }
    for(int j = 1; j <= i; j++){
        if(j != i*(i+1)/2 - n){
            cout << j << endl;
        }
    }
    return 0;
}


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

int main(){

    int a, b;
    char op;

    while(1){

    cin >> a >> op >> b;
    
    if( op == '?' ) break;	 

    if( op == '+' ) cout << a + b << endl;

    else if( op == '-' ) cout << a - b << endl;

    else if( op == '*' ) cout << a * b << endl;

    else if( op == '/' ) cout << a / b << endl;

    /*else {
    	
    	cout << "Invaid Input!" << endl;

    	break;
        
         }*/ //??¨?????????????????¨????????£?????????break???????????¨?????????Invaid??¨???????¶???????
             //??\??????????????¢??¨cin?????¨?????????????????¢???????????¨????????????
             //??????????????¨?????????????????????????????¶???????????¨???????????°????????????????????????
    
    }

	
	return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include<string>
#include<cstring>
#include<complex>
#include<cmath>
using namespace std;
#define rep(i, n)   for(int i = 0; i < (int)(n); i++)
#define rrp(i, n)   for(int i = ((int)(n)); i >=0; i--)
#define mpp(i,j,k)  make_pair((int)(i),make_pair((int)(j),(int)(k)))
typedef pair<int,pair<int,int > > ppp;
typedef pair<int,int> pp;
typedef vector<int> vi;
typedef vector<vi>  vvi;

int n,z,w;
long long a[2000];


int main(){
 
 cin>>n>>z>>w;
 
 rep(i,n)cin>>a[i];
 if(n==1)cout<<abs(a[0]-w)<<endl;
 else cout<<max(abs(a[n-2]-a[n-1]),abs(a[n-1]-w))<<endl;
  return 0;}




Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
int main(){
    int N,A;
    cin >> N >> A;
    cout << N*N-A << endl;
}

Measured memory_bytes: 384
<?php
    $trump = array(
      'S' => range(1,13),
      'H' => range(1,13),
      'C' => range(1,13),
      'D' => range(1,13),
    );

    $total_cards = trim(fgets(STDIN));
    for ($i = 0; $i < $total_cards; $i++){
      $card = explode(" ", trim(fgets(STDIN)));
      unset($trump[$card[0]][$card[1] -1]);
    }

    foreach($trump as $key => $type) {
      foreach($type as $value) {
        echo $key . ' ' .$value.PHP_EOL;
      }
    }

Measured memory_bytes: 9264
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=6100;
int n,mod,fac[N],inv[N],tot[4][N],invtot[4][N];
inline void add(int &a,int b){a=(a+b)%mod;}
inline void del(int &a,int b){a=(a-b+mod)%mod;}
inline void mul(int &a,int b){a=(a*b)%mod;}
inline int C(int n,int m){return fac[n]*inv[n-m]%mod*inv[m]%mod;}
inline int m_pow(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) mul(ans,a);
		b>>=1;
		mul(a,a);
	}
	return ans;
}
signed main()
{
	scanf("%lld%lld",&n,&mod);n*=3;
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=(fac[i-1]*i)%mod;
	inv[n]=m_pow(fac[n],mod-2);
	for (int i=n-1;i>=0;i--) inv[i]=(inv[i+1]*(i+1))%mod;
	for (int i=1;i<=3;i++)
	{
		for (int j=0;j<i;j++) tot[i][j]=1;
		for (int j=i;j<=n;j++) tot[i][j]=(tot[i][j-i]*C(j,i))%mod;
		for (int j=0;j<=n;j++) invtot[i][j]=m_pow(tot[i][j],mod-2);
	}
	int ans=0;
	for (int i=0;i<=n;i++)
	{
		for (int j=0;j<=i;j++)
		{
			int k=n-i-2*j,num=1,tmp=n;
			if (k<0) break;
			if (k%3!=0) continue;
			k/=3;
			mul(num,tot[1][tmp]*invtot[1][tmp-i]%mod);tmp-=i;
			mul(num,tot[2][tmp]*invtot[2][tmp-2*j]%mod);tmp-=2*j;
			mul(num,tot[3][tmp]);
			mul(num,inv[i]);mul(num,inv[j]);mul(num,inv[k]);
			mul(num,m_pow(2,k));
//			printf("1:%d 2:%d: %d\n",i,j,num);
			add(ans,num);
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3988
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
struct node {
	int a;
	int b;
	int c;
	int d;
} qs[55];
int res;
int A[15];
int n,m,q;
void dfs(int num,int step) {
	if(step > n) {
		int temp = 0;
		for(int i = 1; i <= q; i++) {
			if(A[qs[i].b] - A[qs[i].a] == qs[i].c) {
				temp += qs[i].d;
			}
		}
		res = max(res,temp);
		return;
	}
	for(int i = num;i <= m;i++){
		A[step] = i;
		dfs(i,step + 1);
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m >> q;
	for(int i = 1;i <= q;i++){
		cin >> qs[i].a >> qs[i].b >> qs[i].c >> qs[i].d;
	}
	dfs(1,1);
	cout << res << endl;
	return 0;
}

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

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

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

  int n;
  cin >> n;

  ll sum = 0;

  REP(i, n) {
    if (i % 15 == 0 || i % 3 == 0 || i % 5 == 0) {
      continue;
    } else {
      sum += i;
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3648
A,B,C,D,E,F = map(int, input().split())

# 作りうる水の量を洗い出す
waters = set()

for i in range(F//(100*A) + 1):
    for j in range((F-100*A*i)//(100*B) + 1):
        w = 100*A*i + 100*B*j
        if w != 0:
            waters.add(w)
waters = list(waters)
waters.sort()


sugars = set()
# Cを何回入れるか
for i in range(F//C + 1):
    # Dを何回いれるか
    for j in range((F - C*i) // D + 1):
        s = i*C + j*D
  
        sugars.add(s)


sugars = list(sugars)
sugars.sort()

# 最大濃度
max_conc = -1
# 最大濃度の時の水と砂糖
water = -1
sugar = -1




for w in waters:
    for s in sugars:

        # 容量を超えたらアウト
        if w+s > F: break
        # 解けきれない量でもアウト
        if s*100 > w * E: break

        conc = s / (s+w)
        if conc > max_conc:
            max_conc = conc
            water = w
            sugar = s

print(sugar+water, sugar)

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n,l; cin >> n >> l;
    int a[n]; rep(i,n) a[i] = l+i;
    int ans = 0;
    int total = 0;
    
    rep(i,n) total += a[i];

    if(l>0) ans = total - a[0];
    else if(l<=0 && l>=(-n+1)) ans = total - a[-l];
    else ans = total - a[n-1];

    cout << ans << ln;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vector<double> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  vector<double> b(n-1);
  b[0]=(a[0]+a[1])/2;
  FOR(i,1,n-1){
    b[i]=(b[i-1]+a[i+1])/2;
  }
  double k=b[n-2];
  cout << fixed << setprecision(7);
  cout << k << endl;
}

Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
s = input()
ans = 0
for i in range(4):
    if s[i] == '+':
        ans += 1
    if s[i] == '-':
        ans -= 1
print(ans)


Measured memory_bytes: 62060
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

int main()
{
    int64_t N, K;
    std::cin >> N >> K;

    struct M {
        int64_t a;
        int64_t b;
    };

    std::vector<M> m;
    for (int64_t i = 0; i < N; ++i) {
        M t;
        std::cin >> t.a >> t.b;
        m.push_back(t);
    }

    std::sort(std::begin(m), std::end(m),
              [](const auto& l, const auto& r) {
                  return l.a < r.a;
              });

    for (auto e: m) {
        K -= e.b;
        if (K <= 0) {
            std::cout << e.a << std::endl;
            return 0;
        }
    }

    std::cout << N << std::endl;

    return 0;
}


Measured memory_bytes: 2420
#include<iostream>

using namespace std;
int balls[11];
bool res;
int n;

bool dfs(int left, int right,int i){
        if(i==9) return balls[left]<balls[i] || balls[right] < balls[i];
        if(balls[i] > balls[left]) return dfs(i, right, i+1);
        else if(balls[i] > balls[right]) return dfs(left, i, i+1);
        else return false;
}

void solve(){
        for (int i = 0; i < 10; ++i) {
                cin >> balls[i];

        }
        balls[10] = -1;
        res = dfs(10,10,1);
        if(res){
                cout << "YES" << endl;
        }else{
                cout << "NO" << endl;
        }
}

int main(){
        ios_base::sync_with_stdio(false);
        cin >> n;
        for (int i = 0; i < n; ++i) {
                solve();
        }
        return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct disjoint_set {
	int n;
	vector<int> prt;
	disjoint_set (int n)
		: n(n)
		, prt(n, -1)
	{}
	bool is_root (int x) {return prt[x] < 0;}
	int size (int x) {return -prt[find(x)];}
	bool equiv (int x, int y) {return find(x) == find(y);}
	int find (int x) {
		if (is_root(x)) return x;
		else return prt[x] = find(prt[x]);
	}
	bool unite (int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return false;
		if (size(x) < size(y)) swap(x, y);
		prt[x] += prt[y];
		prt[y] = x;
		return true;
	}
};
int main() {
	cin.tie(0); cin.sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> grh(n);
	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		grh[--s].push_back(--t);
		grh[t].push_back(s);
	}
	vector<int> deg(n);
	for (int i = 0; i < n; i++) {
		deg[i] = (int) grh[i].size();
	}
	for (int i = 0; i < n; i++) {
		if (deg[i] % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if (deg[i] >= 6) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if (deg[i] >= 4) {
			disjoint_set djs(n);
			for (int j = 0; j < n; j++) {
				if (i != j) {
					for (int k : grh[j]) {
						if (i != k && j < k) {
							if (!djs.unite(j, k)) {
								cout << "Yes" << endl;
								return 0;
							}
						}
					}
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    a--;
    A[i] = a;
  }
  vector<int> ans(N);
  for (int i = 0; i < N; i++)
  {
    ans[A[i]] = i + 1;
  }
  for (int i = 0; i < N; i++)
    cout << ans[i] << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<int>());
  if(s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;
using namespace __gnu_pbds;
template <typename T> 
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N=1e5+5, MOD=1e9+7;
const lint INF=1e18;
lint _add(lint x, lint y) {
    lint ret=x+y;
    while(ret<0LL) ret+=MOD;
    return ret;
}
lint _mult(lint x, lint y) {
    x%=MOD; y%=MOD;
    lint ret=x*y;
    ret%=MOD;
    while(ret<0LL) ret+=MOD;
    return ret;
}
inline int modpow(lint base, int exp, int modulo) {
  base %= modulo;  lint result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulo;
    base = (base * base) % modulo; exp >>= 1;
  }
  return result;
}

signed main()
{
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z;   
}

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

vector<vector<int>> event;

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n; cin >> n;

    for(int i = 0; i < n; ++i){
        int a, b; cin >> a >> b;
        event.push_back({a, b, 0});
    }
    for(int i = 0; i < n; ++i){
        int a, b; cin >> a >> b;
        event.push_back({a, b, 1});
    }

    sort(event.begin(), event.end());

    set<int> pq;
    int cnt = 0;

    for(auto i : event){
            
        int x = i[0], y = i[1], t = i[2];
        
        if(t == 0){
                
            pq.insert(y);
            
        } else if(!pq.empty()){
            
            auto ite = pq.upper_bound(y);
            
            if(pq.begin() == ite)
                continue;

            pq.erase(--ite);
            ++cnt;
            
        }
    }

    cout << cnt;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int n,a;
    cin >> n >> a;
    string ans;
    if(n%500 <= a) ans = "Yes";
    else ans = "No";

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

Measured memory_bytes: 256