akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<ctime>
#include<cstdlib>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-10;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;

void solve(){
    int n;ll d;
    cin>>n>>d;
    ll x,y;int ans=0;
    rep1(i,n){
    	scanf("%lld%lld",&x,&y);
    	if(x*x+y*y<=d*d)ans++;
	}ac;
}
int main(){
	//freopen("D://data.txt","r",stdin);
	//freopen("D://out.txt","w",stdout);
    solve();
    return 0;
}

Measured memory_bytes: 3232
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	string s;
	cin >> s;
	s[0] = '2';
	s[1] = '0';
	s[2] = '1';
	s[3] = '8';
	cout << s << endl;
	

	return 0;
}





Measured memory_bytes: 256
M[100][100][2],Z=100,l=100000;main(w,h,i,j){
	M[0][0][0]=M[0][0][1]=M[1][1][0]=M[1][1][1]=1;
	for(j=1;j<Z;j++)M[0][j][0]=0,M[0][j][1]=M[0][j-1][1];
	for(i=1;i<Z;i++)for(M[i][0][0]=M[i-1][0][0],M[i][0][1]=0,j=1;j<Z;j++)M[i][j][0]=(M[i-1][j][0]+M[i-1][j-1][1])%l,M[i][j][1]=(M[i][j-1][1]+M[i-1][j-1][0])%l;
	for(;scanf("%d%d",&w,&h),w;)printf("%d\n",(M[h-1][w-1][0]+M[h-1][w-1][1])%l);exit(0);
}

Measured memory_bytes: 676
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

int mark[100005];
vector<int> m[100005];

int main(){
    int n,md;
    queue<int> q;

    cin >> n >> md;

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

    q.push(1);
    while(!q.empty()){
        int val=q.front(); q.pop();
        for(int i=0;i<m[val].size();i++){
            int next=m[val][i];
            if(mark[next]==0){
                mark[next]=val;
                q.push(next);
            }
        }
    }

    bool flg = true;
    for(int i=2;i<=n;i++){
        if(mark[i]==0)flg=false;
    }
    if(flg){
        cout << "Yes" << endl;
        for(int i=2;i<=n;i++)cout<<mark[i]<<endl;
    }else{
        cout << "No" << endl;
    }
    


    return 0;
}

Measured memory_bytes: 10040
#include <stdio.h>

int main(void){
  int d,t,s;
  scanf("%d %d %d",&d,&t,&s);
  float time = (float)d/s;
  if(time<= t){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}
      

Measured memory_bytes: 1732
_ac, _bc, cc = gets.chomp.split(" ").map(&:to_i)
a_vals = gets.chomp.split(" ").map(&:to_i)
b_vals = gets.chomp.split(" ").map(&:to_i)
mins = [a_vals.min + b_vals.min]
cc.times do
  a_index, b_index, reduce_val = gets.chomp.split(" ").map(&:to_i)
  a_index -= 1
  b_index -= 1
  mins << a_vals[a_index] + b_vals[b_index] - reduce_val
end
puts mins.min

Measured memory_bytes: 20252
#include<iostream>

using namespace std;

int main(){
    int x;
    int y;
    cin >> x >> y;
    bool flag=false;
    for(int i=0;i<=x;i++){
        for(int j=0;j<=x;j++){
            if(x-i-j>=0&&(1000*i+5000*j+10000*(x-i-j))==y){
                cout << x-i-j << " " << j << " " << i << endl;
                flag=true;
                break;
            }
            if(flag) break;
        }
        if(flag) break;
    }
    if(flag==false){
        cout << -1 << " " << -1 << " " << -1 << endl;
    }
}

Measured memory_bytes: 256
from itertools import permutations
n, m = map(int,input().split())
p =  [[0] * n for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    p[a-1][b-1] = 1
    p[b-1][a-1] = 1


l = []
for i in permutations(range(1, n), n-1):
    l.append([0] + list(i))


ans= 0
for i in range(len(l)):
    k = l[i]
    for j in range(n-1):
        if p[k[j]][k[j+1]] != 1:
            break
    else:
        ans += 1

print(ans)





Measured memory_bytes: 9512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

// template <typename T>
// void print_pairvec(const vector<T> &v, ll num=0){
//   if(num == 0) num = (ll)v.size();
//   cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
// }
template <typename T>
void print_pairvec(const T &_pair, ll num=0){
  cout << endl; for(pair<ll, int> x: _pair){ cout << x.first << " " << x.second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

struct Eratosthenes{
  vector<ll> sieve;// sieve[i]: 数字iがエラトステネスで篩落とされた時の素数

  Eratosthenes(ll n): sieve(n+1){
    for(int i=0; i<=n; i++) sieve[i] = i;
    for(ll i=2; i*i<=n; i++){
      if(sieve[i] < i) continue;
      for(ll j=i*i; j<=n; j+=i) sieve[j] = min(sieve[j], i);
    } 
  }

  vector<ll> prime_divisors(ll x, bool tmp=false){
    vector<ll> res(1,1);//back()のところで ひっかかるので1を入れとかないとダメ
    while(x > 1){
      if(res.back() != sieve[x]) res.push_back(sieve[x]);
      x /= sieve[x];
    }
    return res;
  }

  map<ll, int> prime_divisors(ll x, int tmp=0){
    map<ll, int> mp;
    while(x > 1){
      mp[sieve[x]]++;
      x /= sieve[x];
    }
    return mp;
  }
};

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  for(ll i=0; i<N; i++) cin >> A[i];

  sort(A.begin(), A.end());//82行目のbreakを入れないとTLEになるらしく，それならsortしないといけない
  // const ll INF  =1e6+1;// sortじゃなくてこっちがTLEの原因?
  const ll INF = A.back()+1;
  vector<ll> vec(INF, 0);
  for(ll i=0; i<N; i++){
    for(ll j=1; j*A[i]<=INF; j++){
      vec[A[i]*j]++;
      // if(vec[A[i]*j] >= 2) break;// これいれたらWA?
    }
  }
  ll ans = 0;
  for(ll i=0; i<N; i++){
    if(vec[A[i]] == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12760
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    char c;
    cin >> c;
    switch (c){
        case 'a':
        case 'e':
        case 'i':
        case 'u':
        case 'o':
            cout << "vowel" << endl;
            break;
        default:
            cout << "consonant" << endl;
    }

    
    return 0;
}

Measured memory_bytes: 256
N=int(input())
h=list(map(int,input().split()))
dp=[0]*N
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])
print(dp[N-1])

Measured memory_bytes: 13928
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define MOD 1000000007ll
using namespace std;
void solve();
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	solve();
}

//nCk(mod p)
const ll NUM = 2;
ll fac[NUM], finv[NUM], inv[NUM];
void cmodf(ll p = MOD) {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rep(i, 2, NUM) {
		fac[i] = fac[i - 1] * i%p;
		inv[i] = p - inv[p%i] * (p / i) % p;
		finv[i] = finv[i - 1] * inv[i] % p;
	}
}
ll cmod(ll n, ll k, ll p = MOD) {
	return fac[n] * (finv[k] * finv[n - k] % p) % p;
}

//最大公約数
ll gcd(ll n, ll m) {
	ll k = n % m;
	while (k != 0) { n = m; m = k; k = n % m; }
	return m;
}
ll gcd(vector<ll> a) {
	rep(i, 1, a.size()) {
		ll k = a[i - 1] % a[i];
		while (k != 0) {
			a[i - 1] = a[i];
			a[i] = k;
			k = a[i - 1] % a[i];
		}
	}
	return a.back();
}

//最小公倍数
ll lcm(ll n, ll m) {
	ll t = n * m, k = n % m;
	while (k != 0) { n = m; m = k; k = n % m; }
	return t / m;
}
ll lcm(vector<ll> a) {
	ll n;
	rep(i, 1, a.size()) {
		n = a[i - 1] * a[i];
		ll k = a[i - 1] % a[i];
		while (k != 0) {
			a[i - 1] = a[i];
			a[i] = k;
			k = a[i - 1] % a[i];
		}
		n /= a[i];
		a[i] = n;
	}
	return n;
}

//keyの小さい方から探していった時に初めてvalueがjoken以上になる時のkey（keyが増えたらvalueも増えるか同じになるとき）
ll value(ll key) {
	/*変更*/
	return 0;
}
ll mink(ll lkey, ll rkey/*ここも調べる*/, ll joken) {
	ll mkey;
	while (lkey != rkey) {
		mkey = (lkey + rkey) / 2;
		if (value(mkey) >= joken)rkey = mkey;
		else lkey = mkey + 1;
	}
	return rkey;
}

//ペア配列の整理
struct pea {
	ll f, s;
	bool operator<(const pea &c)const {
		return f != c.f ? f < c.f : s < c.s;
	};
};

//互いに素な集合
class ufset {
public:
	vll rank, p;
	ufset(ll n) {
		rank.resize(n, 0);
		p.resize(n, 0);
		rep(i, 0, n)make(i);
	}
	void reset(ll n) {
		rank.resize(n, 0);
		p.resize(n, 0);
		rep(i, 0, n)make(i);
	}
	void make(ll i) {
		p[i] = i;
		rank[i] = 0;
	}
	bool same(ll i, ll j) { return find(i) == find(j); }
	void unite(ll i, ll j) { link(find(i), find(j)); }
	void link(ll i, ll j) {
		if (rank[i] > rank[j])p[j] = i;
		else {
			p[i] = j;
			if (rank[i] == rank[j])rank[j]++;
		}
	}
	ll find(ll i) {
		if (p[i] != i)p[i] = find(p[i]);
		return p[i];
	}
};

//変数定義

//再帰関数

//アルゴリズム
void solve() {
	ll n, q; cin >> n >> q;
	ufset a(n);
	rep(i, 0, q) {
		ll c, x, y; cin >> c >> x >> y;
		if (c == 0) {
			a.unite(x, y);
		}
		else {
			cout << a.same(x, y) << kai;
		}
	}
}


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

from collections import Counter
from operator import itemgetter


ac = Counter(a)
aci = list(ac.items())
aci = sorted(aci,key=itemgetter(1),reverse = False)  
#print(aci)

ans = aci[:-k]
cnt=0
for i in range(len(ans)):
    cnt += ans[i][1]
print(cnt)

Measured memory_bytes: 40884
use std::io::Read;

fn main() {
    let mut buf = String::new();
    let mut stdin = std::io::stdin();
    stdin.read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let s = iter.next().unwrap().chars();
    let t = iter.next().unwrap().chars();

    for i in s.zip(t) {
        print!("{}{}", i.0, i.1);
    }
    print!("\n");
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define repit(i,a) for(__typeof((a).begin()) i=(a).begin();i!=(a).end();i++)

#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int N, M;

struct edge
{
    int v, d, c;
    edge(int v, int d, int c) : v(v), d(d), c(c) {}
    bool operator<(const edge &o) const{
	return c > o.c;
    }
};

vector<vector<edge> > G;

void input()
{
    G.assign(N, vector<edge>());
    rep(i,M) {
	int u, v, d, c;
	cin >> u >> v >> d >> c;
	--u, --v;
	G[u].pb(edge(v, d, c));
	G[v].pb(edge(u, d, c));
    }
}

ll mind[10005];
struct node{
    int now;
    int cst;
    bool operator<(const node &o) const{
	return cst > o.cst;
    }
};
struct node2 {
    int pos;
    int cst;
    bool operator<(const node2 &o) const{
	return cst > o.cst;
    }
};
struct node3 {
    int now;
    int cst;
    int a;
    int b;
};

bool done[10005];
vector<bool> usable[10005];
void solve()
{
    rep(i, N) mind[i] = INF;
    priority_queue<node> pq;
    pq.push((node){0, 0});
    while(!pq.empty()) {
	int now = pq.top().now;
	ll cst = pq.top().cst;
	pq.pop();
	if(mind[now] < INF) continue;
	mind[now] = cst;
	rep(i, G[now].size()) {
	    pq.push((node){G[now][i].v, cst + G[now][i].d});
	}
    }
    //rep(i, N) cout << mind[i] << endl;
    queue<node3> q;
    rep(i, N) {
	usable[i].clear();
	usable[i].resize(G[i].size());
    }
    q.push((node3){0, 0, -1, -1});
    while(!q.empty()) {
	int now = q.front().now;
	ll cst = q.front().cst;
	int a = q.front().a;
	int b = q.front().b;
	q.pop();
	if(mind[now] < cst) continue;
	if(a >= 0) {
	    usable[a][b] = true;	
//	    cout << "b " << a << " " << b << endl;
	}
	rep(i, G[now].size()) {
	    q.push((node3){G[now][i].v, cst+G[now][i].d, now, i});
	}
    }
    priority_queue<edge> pq2;
    memset(done, 0, sizeof(done));
    ll ans = 0;
    done[0] = true;
    /*rep(i, G[0].size()) {
	if(usable[0][i]) {
	    pq2.push((node2){G[0][i].v, G[0][i].c});		
	}
	}*/
    rep(i, N) rep(j, G[i].size()) if(usable[i][j]) pq2.push(G[i][j]);
    while(!pq2.empty()) {
	edge e = pq2.top();
	pq2.pop();
	if(done[e.v]) continue;
	done[e.v] = true;
	ans += e.c;
    }
    //  rep(i, N) if(!done[i]) cout <<"a " << i << endl;
    cout << ans << endl;
}

int main()
{
    while (cin >> N >> M && N) {
	input();
	solve();
	
    }

    return 0;
}

Measured memory_bytes: 3880
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		int W = Integer.parseInt(ss0[0]);
		int H = Integer.parseInt(ss0[1]);
		int N = Integer.parseInt(ss0[2]);


		int WMin = 0;
		int WMax = W;
		int HMin = 0;
		int HMax = H;

		for(int i=0; i<N; i++){
			ss0 = br.readLine().trim().split(" ", 0);
			int x = Integer.parseInt(ss0[0]);
			int y = Integer.parseInt(ss0[1]);
			int a = Integer.parseInt(ss0[2]);
			
			
			if(a==1){ WMin = WMin > x ? WMin : x; }
			if(a==2){ WMax = WMax > x ? x : WMax; }
			if(a==3){ HMin = HMin > y ? HMin : y; }
			if(a==4){ HMax = HMax > y ? y : HMax; }
		}
		
		W = WMax - WMin;
		W = W > 0 ? W : 0;
		
		H = HMax - HMin;
		H = H > 0 ? H : 0;
		
		
		System.out.println(W * H);
    }
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }

}


Measured memory_bytes: 8276
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

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

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll tt, a, b;
    vector < pair < ll, ll > > v;
    w(tt){
        cin >> a >> b;
        v.eb(a,b);
    }
    sort(all(v), comp);
    ll s = 0;
    rep(i, sz(v)){
        s += v[i].ff;
        if(s > v[i].ss){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}



Measured memory_bytes: 6512
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

#define INF LONG_MAX/3

long long N, M;

long A[1005];
long state[1005];
long long dp[1005][5000];

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

	rep(i, M) {
		long long b;
		cin >> A[i];
		cin >> b;

		long long s = 0;
		rep(j, b) {
			long long c;
			cin >> c; c--;
			s += (1<<c);
		}
		state[i] = s;
	}

	rep(i, 1005) rep(j, 5000) dp[i][j] = INF;

	dp[0][0] = 0;
	rep(i, M) {
		long long s = state[i];
		rep(j, 5000) {
			if(dp[i][j] == INF) continue;

			//使う
			dp[i+1][j|s] = min(dp[i+1][j|s], dp[i][j] + A[i]);
			//使わない
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
		}
	}

	if(dp[M][(1<<N)-1] == INF) {
		cout << -1 << endl;
	} else {
		cout << dp[M][(1<<N)-1] << endl;
	}





}

Measured memory_bytes: 42872
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int n, m;
int as[MAX_N];

/* subroutines */

/* main */

int main() {
  for (;;) {
    cin >> n >> m;
    if (n == 0) break;

    for (int i = 0; i < n; i++) cin >> as[i];

    int mint = INF, mina = INF, mini = n - 1;

    for (int i = 0; i < n; i++) {
      int ai = as[i];
      int t = (m / ai) * ai;

      if (mint > t)
	mint = t, mina = ai, mini = i;
      else if (mint == t) {
	if (mina > ai)
	  mina = ai, mini = i;
	else if (mina == ai)
	  mini = n - 1;
      }
    }

    cout << (mini + 1) << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=2005;
bitset<N> a[N],f[N],g[N];
int ans,n;

signed main(){
	read(n);
	for(int i=2,x;i<=n;i++) for(int j=1;j<i;j++) scanf("%1d",&x),a[i][j]=x,a[j][i]=!x;
	for(int i=1;i<=n;i++) f[i][i]=g[i][i]=1;
	for(int len=2;len<=n;len++) for(int l=1,r=len;r<=n;l++,r++){
		f[r][l]=(g[l+1]&f[r]&a[l]).count()>0;
		g[l][r]=(g[l]&f[r-1]&a[r]).count()>0;
	}
	write((g[1]&f[n]).count());
}

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

int main() {
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  
  vector<ll> p(a), q(b), r(c);
  
  for (int i = 0; i < a; i++)
    cin >> p.at(i);
  for (int i = 0; i < b; i++)
    cin >> q.at(i);
  for (int i = 0; i < c; i++)
    cin >> r.at(i);
  
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  
  vector<ll> data;
  for (int i = 0; i < x; i++) {
    data.push_back(p.at(i));
  }
  for(int i = 0; i < y; i++) {
    data.push_back(q.at(i));
  }
  for (int i = 0; i < c; i++) {
    data.push_back(r.at(i));
  }
  
  sort(data.rbegin(), data.rend());
  
  ll sum = 0;
  for (int i = 0; i < x + y; i++) {
    sum += data.at(i);
  }
  
  cout << sum << endl;
 
    
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int n,k;
    cin>>n>>k;

    if(k==1)
    {
    	cout<<0;
    	return 0;
    }
        cout<<((n-k));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	map<int,int> m;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		m[a[i]]++;
	}
	sort(a+1,a+n+1);
	bool b[a[n]+10];
	memset(b,true,sizeof(b));
	for(int i=1;i<=n;i++)
		if(b[a[i]])
			for(int j=a[i]+a[i];j<=a[n];j+=a[i])
				b[j]=0;
	int ans=0;
	for(int i=1;i<=n;i++)
		if(m[a[i]]<=1&&b[a[i]])
			ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 14564
#!/usr/bin/env python3
import sys

inf = float('inf')

def solve(N: int, M: int, P: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    V = list(range(N))
    
    next_v = [[] for v in V]
    for i in range(M):
        next_v[a[i]-1].append((b[i]-1, c[i]))
    
    D = [-inf for v in V]
    D[0] = 0
    
    prev = [None for v in V]

    positive = [False for v in V]

    for i in range(N-1):
        for u in V:
            for v, w in next_v[u]:
                alt = D[u] + w
                if alt > D[v]:
                    D[v] = alt
                    prev[v] = u
    ans = D[N-1]
    
    for i in range(N-1):
        for u in V:
            for v, w in next_v[u]:
                alt = D[u] + w
                if alt > D[v]:
                    D[v] = alt
                    positive[v] = True
                if positive[u]:
                    positive[v] = True

    if positive[N-1]:
        print(-1)
    else:
        print(max(0, ans))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]" 
    B = [int()] * (M)  # type: "List[int]" 
    C = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = (int(next(tokens))-P)
    solve(N, M, P, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 55772
#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 a,b,c,k; cin >> a >> b >> c >> k;
    if(k <= a) cout << k << endl;
    else if(k <= a+b) cout << a << endl;
    else{
        int s = k-a-b;
        cout << a-s << endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define SETBIT(x) __builtin_popcountll(x)
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;

ll A[N], B[N];


ll exp(ll x, ll n, ll mod){
    ll ans = 1LL, X = x, N = n;
    while(N > 0){
        if(N & 1) ans = (ans * X) % mod;
        X = (X * X) % mod;
        N >>= 1;
    }
    return ans;
}


ll countOperations(ll number) {
    int operation_count = 0;

    while(number > 0) {
        ll bit = SETBIT(number);
        number %= bit;
        operation_count++;
    }
    return operation_count;
}


int main() {
    fast;

    int n; cin >> n;
    string s; cin >> s;


    int cnt = 0;
    for(int i = 0; i < n; i++) if(s[i] == '1') cnt++;

    if(cnt == 0) {
        for(int i = 0; i < n; i++) {
            if(s[i] == '0') cout << 1 << "\n";
            else
                cout << 0 << "\n";
        }
    }
    else if(cnt == 1) {

        // pow of 2
        A[0] = 1, B[0] = 1;
        for(ll i = 1; i < N; i++)  {
            B[i] = (B[i-1] * 2) % (cnt + 1);
        }

        ll _10 = 0, _01 = 0;
        for(int i = 0; i < n; i++) {
            if(s[i] == '1') {
                _01 = (_01 + B[n - 1 - i]) % (cnt + 1);
            }
        }


        for(int i = 0; i < n; i++) {
            if(s[i] == '1') cout << 0 << "\n";
            else {
                // refer to B, 0 -> 1
                ll value = (_01 + B[n - 1 - i] + cnt + 1) % (cnt + 1);
                cout << countOperations(value) + 1<< "\n";
            }
        }
    }
    else {

        // pow of 2
        A[0] = 1, B[0] = 1;
        for(ll i = 1; i < N; i++)  {
            A[i] = (A[i-1] * 2) % (cnt - 1);
            B[i] = (B[i-1] * 2) % (cnt + 1);
        }

        ll _10 = 0, _01 = 0;
        for(int i = 0; i < n; i++) {
            if(s[i] == '1') {
                _10 = (_10 + A[n - 1 - i]) % (cnt - 1);
                _01 = (_01 + B[n - 1 - i]) % (cnt + 1);
            }
        }


        for(int i = 0; i < n; i++) {
            if(s[i] == '1') {
                // refer to A, 1 -> 0
                ll value = (_10 - A[n - 1 - i] + cnt - 1) % (cnt - 1);
                cout << countOperations(value) + 1 << "\n";
            }
            else {
                // refer to B, 0 -> 1
                ll value = (_01 + B[n - 1 - i] + cnt + 1) % (cnt + 1);
                cout << countOperations(value) + 1 << "\n";
            }
        }

    }

    return 0;
}

Measured memory_bytes: 6888
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll n,m;
  std::cin>>n>>m;

  std::vector<bool> red(n,false);
  std::vector<ll> cnt(n,1);
  red[0]=true;

  while(m--){
    ll x,y;
    std::cin>>x>>y;
    x--;y--;
    if(red[x]){
      red[y]=true;
      if(cnt[x]==1)red[x]=false;
    }
    cnt[x]--;cnt[y]++;
  }

  ll ret=0;
  rep(i,0,n)if(red[i])ret++;
  std::cout<<ret<<"\n";



  return 0;
}

Measured memory_bytes: 3968
//  Twitter@KonoLv1 2020年春からエンジニア見習いデビュー！（修正版）
 
//  標準入出力を扱うヘッダーファイルの読み込み
#include <stdio.h>
 
int main(void){
 
    unsigned long int a,b,n,ans;
 
    scanf("%lu %lu %lu",&n,&a,&b);
    
    //  aとbの間隔が奇数か偶数かの判定
    if ((b - a) % 2 == 0){
        
        //  偶数なら間隔÷２で最小
        printf("%lu",((b - a) / 2));
        
    }else{

        //  奇数ならbとaのどちらが対なる端に近いか判定
        //  aかbが一度端に2連続で存在することによりその後交差することなく合流できる。
        
        if (b - 1 <= n - a){
            ans = (((b - a) / 2) + 1) +  (a - 1);
        }else{
            ans = (((b - a) / 2) + 1) + (n - b);
        }
        printf("%lu",ans);
    }
}
 

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  string s;
  while(cin>>s){
    if(s == "0")break;
    int sm = 0;
    for(int i = 0; s.size( ) > i; i++){
      sm += s[i]-'0';
    }
    cout << sm << endl;
  }
}


Measured memory_bytes: 3228
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
X = input()
cnt = 0
ans = 0
for i in range(len(X)):
    if X[i] == 'S':
        cnt += 1
    else:
        if cnt > 0:
            cnt -= 1
            ans += 2
print(len(X) - ans)


Measured memory_bytes: 5788
import sys
S = input()
ans = 0

if S == "RRR":
    print(3)
    sys.exit()
elif (S[:2]=="RR" or S[1:] == "RR"):
    print(2)
    sys.exit()
elif (S[0] == "R" or S[1] == "R" or S[2] == "R"):
    print(1)
    sys.exit()
else:
    print(0)



Measured memory_bytes: 9112
a, b, c, d, e, f = map(int, input().split())

water = []
for i in range(30):
    for j in range(30):
        x = 100*a*i + 100*b*j
        if x <= f:
            water.append(x)

sugar = []
for i in range(3001):
    for j in range(3001):
        y = c*i + d*j
        if y <= f:
            sugar.append(y)
#print(water)
#print(sugar)
ans = []
for x in water:
    if x == 0:
        continue
    for y in sugar:
        if x + y > f:
            continue
        if (x//100)*e < y:
            continue
        noudo = 100*y / (x+y)
        all_weight = x + y
        sugar_weight = y
        ans.append([noudo, all_weight, sugar_weight])
#print(ans)
ans.sort(key=lambda x:x[0])
print(ans[-1][1], ans[-1][2])


Measured memory_bytes: 177772
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;


int main(int argc, const char * argv[]) {
	ll n,k;
	cin >> n >> k;
	ll EPS = 1e+9 + 7;
	ll ret = 0;
	ll minimum,maximum;
	FOR(i,k,n+1){ // i = number of "number to choose"
//		println(i);
		minimum = i*(i-1)/2;
		maximum = i*(2*n-i+1)/2;
//		cout << minimum << "~~" << maximum << endl;
		ret = (ret+maximum-minimum+1)%EPS;
	}
	println(ret);
	return 0;
}


Measured memory_bytes: 3624
//ツ甘板暗。ツづ?づБOJツづ個づ卍つ、ツづ?津アツ出ツつオツつスツづ個づ?つキツつイツつュツつォツづ慊つクツつ「
//2ツ嘉アツ暗δつ「ツ甘板暗。ツづ?つスツつッツづ?PPATSU


#include<iostream>
#include<map>
#include<vector>
#define F first
#define S second
using namespace std;

typedef pair<int,int> P;
typedef pair<P,P> P2;
typedef pair<P2,string> info;

int main(){
  int n,m,H,W,num,x1,x2,y1,y2;
  string s,s2,now;
  while(cin >> n && n){
    multimap<string,info> web;
    cin >> W >> H;
    for(int j=0;j<n;j++){
      cin >> s >> num;
      if(j == 0)now = s;
      for(int i=0;i<num;i++){
	cin >> x1 >> y1 >> x2 >> y2 >> s2;
	web.insert(multimap<string,info>::value_type(s,info(P2(P(x1,y1),P(x2,y2)),s2)));
      }
    }
    cin >> m;
    string op,Back,Forward;
    string *history = new string[10005];//ツ配ツ療アツ妥・ツつォツつュツつオツつスツづァツ津環づ?つス
  
    int nx,ny,Index=0,len=0;
    int pointer = 0;
    //history[Index++] = now;
    history[pointer]=now;

    //cout << "now is " << now << endl;
    Back.clear();
    Forward.clear();
    for(int i=0;i<m;i++){
      cin >> op;
      if(op == "click"){
	cin >> nx >> ny;
	for(int i=pointer+1;i<=len;i++){
	  history[i].clear();
	}

	bool found = false;
	multimap<string,info>::iterator it = web.begin();	
	while(it != web.end() ){
	  if((*it).first == now){

	    if((*it).S.F.F.F <=nx && nx <=(*it).S.F.S.F && (*it).S.F.F.S <=ny && ny <= (*it).S.F.S.S){
	      now = (*it).S.S;
	      //history[Index++] = now; 
	      history[++pointer] = now;
	      len++;
	      break;
	    }

	  }
	  it++;
	}
	//cout << now << endl;
	//cout << "--------------" << endl;
 
      }
      else if(op == "show")cout << now << endl;
      else if(op == "back"){
	//if(Index-1 >=0 ){
	  //Index--;
	  //now = history[Index-1];
	  // cout << "back to "<< now << endl;
	if(pointer-1 >=0){
	  now = history[--pointer];
	}
      }
      else if(op == "forward"){
	//if(Index+1 <= len){
	//now = history[Index];
	//Index++;
	if(!history[pointer+1].empty()){
	//if(pointer+1 < len){
	  now = history[++pointer];
	}
      }


    }
    /*
    cout << "---------"<< endl;
    for(int i=0;i<=len;i++){
      cout << history[i] << endl;
    }
    */
    delete [] history;
  }
  return 0;
}

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

void Solve() {
	ULL N; cin >> N;
	if (N % 2 == 1) {
		cout << 0 << endl;
	}
	else {
		ULL ans = 0;
		N /= 2;
		while (N >= 5) {
			N /= 5;
			ans += N;
		}
		cout << ans << endl;
	}
}
int main() { Solve(); return 0; }


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    ll ans = 1;
    for(ll i = m/n; i > 1; i--){
        if((m-i*n)%i == 0){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

ans = [0] * (10 ** 4 + 1)
for x in range(1, 101):
	for y in range(1, 101):
		for z in range(1, 101):
			n = pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x
			if n > 10 ** 4:
				continue
			ans[n] += 1

print(*ans[1:N + 1], sep="\n")


Measured memory_bytes: 73856
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(1e5)+10;
int n,m,ans;
struct node {
	int day,val;
	bool operator < (const node t) const {
		return day<t.day;
	}
} d[maxn];
priority_queue<int,vector<int>,greater<int> > q;
int main() {
//	freopen("1.txt","r",stdin);
	read(n); read(m);
	for (int i=1;i<=n;i++)
		read(d[i].day),d[i].day=max(0,m-d[i].day+1),
		read(d[i].val);
	sort(d+1,d+n+1);
	for (int i=1;i<=n;i++) {
		if (q.size()<d[i].day) q.push(d[i].val);
		else if (!q.empty()&&q.top()<d[i].val) {
			q.pop(); q.push(d[i].val);
		}
	}
	while (!q.empty()) ans+=q.top(),q.pop();
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1660
O = list(input())
E = list(input())
res = ''
iter = 0
while len(O) != 0 or len(E) != 0:
    if len(O) > 0:
        res += O.pop(0)
    if len(E) > 0:
        res += E.pop(0)
    iter += 1
print(res)




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

using namespace std;

#undef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool x) { return (x ? "T" : "F"); }
string to_string(const char* s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename V>
string to_string(V v) {
    bool f = true; string res = "[";
    for (const auto& x: v) {
        if (!f) res += ", ";
        f = false;
        res += to_string(x); } res += "]";
    return res;
}
void debug() { cerr << endl; }
template <typename H, typename... T>
void debug(H h, T... t) { cerr << " " << to_string(h); debug(t...); }
#ifdef LOCAL
#define dbg(args...) cerr<<"("<<#args<<") =", debug(args)
#else
#define dbg(args...) 2019
#endif

// z[i] = len of lcp of s, s[i..]; lcp(longest common prefix)
vector<int> z_fn(const string& s) {
    int n = s.size();
    vector<int> z(n, 0);
    for (int i = 1, l = 0, r = 0; i < n; i++) {
        if (i <= r)
            z[i] = min(r-i+1, z[i-l]);
        while (i+z[i] < n && s[z[i]] == s[i+z[i]]) {
            z[i]++;
        }
        if (i+z[i]-1 > r) {
            l = i; r = i+z[i]-1;
        }
    }
    return z;
}

void f(string& s){
    auto z = z_fn(s);
    int n = s.size();
    int i = n/2 + 1;
    while (i < n) {
        if (z[i] == n-i) break;
        i++;
    }
    for (int j = 0; j < 2*i-n; j++) {
        s.push_back(s[j+n-i]);
    }
}

int min_prefix(const string& s){
    int n = s.size();
    auto z = z_fn(s);
    for (int i = 1; i < n; i++) {
        if (z[i] == n-i) return i;
    }
    return n;
}

using ll=long long ;
using Freq=array<ll,26>;
Freq& operator+=(Freq& a, const Freq& b){
    for (int i = 0; i < 26; i++) {
        a[i] += b[i];
    }
    return a;
}
const long long INF = 0x3f3f3f3f3f3f3f3f;

void solve() {
    string s; cin >> s;
    f(s);
    s.resize(s.size()/2);
    int k = min_prefix(s);
    int n = s.size();
    dbg(s,k,n);

    vector<ll> fib = {k, n};
    vector<Freq> cnt(100);
    for (int i = 0; i < k; i++) {
        cnt[0][s[i]-'a']++;
    }
    for (int i = 0; i < n; i++) {
        cnt[1][s[i]-'a']++;
    }
    while (fib.back() < INF) {
        int n = fib.size();
        fib.emplace_back(fib[n-1] + fib[n-2]);
        for (int i = 0; i < 26; i++) {
            cnt[n][i] = cnt[n-1][i] + cnt[n-2][i];
        }
    }
    dbg(fib);
    dbg(cnt);

    int m = fib.size();
    dbg(m);
    dbg(cnt[m-1]);
    auto till = [&](ll r){
        Freq res = {};
        if (r <= 0) return res;
        for (int i = m-1; i >= 0; i--) {
            if (r < fib[i]) continue;
            res += cnt[i];
            r -= fib[i];
            dbg(i, res, r);
        }
        assert(r < n);
        for (int i = 0; i < r; i++) {
            res[s[i]-'a']++;
        }
        return res;
    };

    ll l, r;
    cin >> l >> r;
    auto x = till(l-1);
    auto y = till(r);
    for (int i = 0; i < 26; i++) {
        cout << (y[i]-x[i]) << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using lint = long long;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    lint N, T;
    cin >> N >> T;

    lint min_cost = INF;
    rep(i, N) {
        lint c, t;
        cin >> c >> t;

        if(t <= T) {
            min_cost = min(min_cost, c);
        }
    }

    if(min_cost == INF) {
        cout << "TLE" << endl;
    } else {
        cout << min_cost << endl;
    }
}

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

Measured memory_bytes: 3616
A, B, C, X, Y = list(map(int, input().split()))
pri = 0

if A + B <= 2 * C:
    pri = A * X + B * Y
else:
    while min(X, Y) != 0:
        pri += C * 2
        X -= 1
        Y -= 1
    if A * X + B * Y >= 2 * C * (X + Y):
        pri += 2 * C * (X + Y)
    else:
        pri += A * X + B * Y

print(pri)


Measured memory_bytes: 3060
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <map>
#include <cstring>

using namespace std;

void print(int n,int *X){

  for(int i=0;i<n;i++){
    cout<<X[i];
    if(i!=n-1)cout<<" ";
  }
  cout<<endl;

}

int selection_sort(int n,int *X){

  int minid=0;
  int ch=0;
  
  for(int i=0;i<n;i++){
    minid = i;
    for(int j=i+1;j<n;j++){
      if(X[j]<X[minid])
	minid = j;
    }
    if(minid!=i){
      swap(X[minid],X[i]);
      ch++;
    }
  }
  print(n,X);
  return ch;
}

void insertion_sort(int n,int *X){

  print(n,X);
  
  for(int i=1;i<n;i++){
    int v = X[i];
    int j=i-1;
    while(j>=0 && v<X[j]){
      X[j+1]=X[j];
      j--;
    }
    X[j+1] = v;
    print(n,X);
  }
}

int bubble_sort(int n, int *X){

  int ch=0;
  //bool flag=false;
  int j=0;
  
  while(j<n-1){
    
    for(int i=0;i<n-j-1;i++){
      if(X[i]>X[i+1]){
	swap(X[i],X[i+1]);
	ch++;
      }
    }
    j++;
  }
  print(n,X);
  return ch;
}


int main(){

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

  //insertion_sort(N,A);
  //cout<<bubble_sort(N,A)<<endl;
  cout<<selection_sort(N,A)<<endl;
 
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n,s1=0,s2=0;
  cin>>n;
  int a[n],min = 100000;
  for(int i=0;i<n;i++)
  {
      cin >> a[i];
      s1 += a[i];
  }
  for(int i=0;i<n;i++)
  {
      s2 += a[i];
      s1 -= a[i];
      if(abs(s1 - s2) < min) min = abs(s1 - s2);
  }
  cout << min << endl;
  return 0;
}



Measured memory_bytes: 256
from math import factorial
N ,M = [int(x) for x in input().split()]

sumodd = 0
sumeven = 0

if N == 0 or N == 1:
    sumeven = 0
else: 
    sumeven = factorial(N) // factorial(2) // factorial(N-2)
if M == 0 or M == 1:
    sumodd = 0
else: 
    sumodd = factorial(M) // factorial(2) // factorial(M-2)
print(sumeven + sumodd)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MOD 1000000007
#define MAX_LOGN 100000

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }
llong powi(llong x, llong y) { return pow(x, y) + EPS; }

string L;
llong dp[MAX_LOGN + 1][2];  //j...既にL未満かどうか

int main(int argc, char **argv) {
    cin >> L;
    int N = L.size();

    dp[0][0] = 1;
    dp[0][1] = 0;
    for(int i = 1; i <= N; ++i) {
        if(L[i - 1] == '1') {
            //ここまでLと同じ
            /*1*/    dp[i][0] += dp[i - 1][0] * 2;

            //L未満になった
            /*0*/    dp[i][1] += dp[i - 1][0] + dp[i - 1][1];
            /*1*/    dp[i][1] += dp[i - 1][1] * 2;

        } else if(L[i - 1] == '0') {
            //ここまでLと同じ
            /*0*/    dp[i][0] += dp[i - 1][0];

            //L未満になった
            /*0*/    dp[i][1] += dp[i - 1][1];
            /*1*/    dp[i][1] += dp[i - 1][1] * 2;
        }
        dp[i][0] %= MOD;
        dp[i][1] %= MOD;
    }

    llong res = (dp[N][0] + dp[N][1]) % MOD;
    cout << res << endl;
}

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

using namespace std;

vector<int>g[51];
int n,m;
int x[51];
int main() {
  cin >> n >> m;

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

  bool ok = true;

  while(ok) {
    ok = false;
    for(int i = 0; i < n; i++) {
      if(x[i] == 1) {
	x[i]--;
	for(int j = 0;  j < g[i].size(); j++) {
	  int u = g[i][j];
	  x[u]--;
	}
	ok = true;
	ans++;
      }
    }
  }

  cout << ans << endl;
}
    


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

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d[i];

	int ans = 0;
	rep(i, n) rep(j, n) {
		if (i == j) continue;
		ans += d[i] * d[j];
	}
	cout << ans/2 << endl;
}

Measured memory_bytes: 256