akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a==1 && b>1){
	cout<<"Alice";
	}
	if(b==1 && a>1){
	cout<<"Bob";
	}
	if(a>b && a>1 && b>1){
	cout<<"Alice";
	}
	if(b>a && a>1 && b>1){
	cout<<"Bob";
	}
	if(a==b){
	cout<<"Draw";
	}
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

struct flow_network {
	struct edge { ll to, cap, cost; };

	ll n, s, t;
	vvl adj;
	vector<edge> e;
	
	flow_network(ll n, ll s, ll t): n(n), s(s), t(t), adj(n) { }

	void add_edge(ll a, ll b, ll cap, ll cost) {
		adj[a].pb(sz(e));
		e.pb({b,cap,cost});
		adj[b].pb(sz(e));
		e.pb({a,0,-cost});
	}

	pll mcmf() {
		vl pot(n);
		FOR(t,0,n) FOR(i,0,n) for (ll k: adj[i]) if (e[k].cap) {
			pot[e[k].to] = min(pot[e[k].to],pot[i] + e[k].cost);
		}
		ll flow = 0, cost = 0;
		while (true) {
			vl dist(n,oo), pred(n);
			set<pll> q;
			dist[s] = 0, q.insert({0,s});
			while (sz(q)) {
				ll i = begin(q)->yy;
				q.erase(begin(q));
				for (ll k: adj[i]) if (e[k].cap) {
					ll j = e[k].to, ndist = dist[i] + e[k].cost + pot[i] - pot[j];
					if (ndist >= dist[j]) continue;
					q.erase({dist[j],j});
					dist[j] = ndist, pred[j] = k;
					q.insert({dist[j],j});
				}
			}
			if (dist[t] == oo) break;

			ll cap = oo, cost1 = 0;
			for (ll i = t; i != s; i = e[pred[i]^1].to) {
				cap = min(cap,e[pred[i]].cap), cost1 += e[pred[i]].cost;
			}
			flow += cap, cost += cap*cost1;
			for (ll i = t; i != s; i = e[pred[i]^1].to) {
				e[pred[i]].cap -= cap, e[pred[i]^1].cap += cap;
			}
			FOR(i,0,n) pot[i] += dist[i];
		}
		return {flow,cost};
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll m, n;
	cin >> m >> n;

	vector<string> a(m);
	FOR(i,0,m) cin >> a[i];

	ll N = m*n + 2, s = N-2, t = N-1;
	flow_network F(N,s,t);

	auto I = [&](ll i, ll j) { return i*n + j; };

	FOR(i,0,m) FOR(j,0,n) {
		if (a[i][j] == '#') continue;
		if (a[i][j] == 'o') F.add_edge(s,I(i,j),1,0);
		F.add_edge(I(i,j),t,1,0);
		
		if (i+1 < m && a[i+1][j] != '#') F.add_edge(I(i,j),I(i+1,j),oo,-1);
		if (j+1 < n && a[i][j+1] != '#') F.add_edge(I(i,j),I(i,j+1),oo,-1);
	}
	
	ll cap, cost;
	tie(cap,cost) = F.mcmf();

	cerr << cap << endl;
	cout << -cost << endl;
}



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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll d,t,s; cin>>d>>t>>s;

    if(s*t >= d) puts("Yes");
    else puts("No");

    return 0;

}

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

void solve() {
	double W, H, x, y; cin >> W >> H >> x >> y;

	double ans = W * H / 2.0;
	int num = ((W == x + x && H == y + y) ? 1 : 0);
	cout << ans << " " << num << endl;
}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
s = input()
maxa = a+b
maxb = b
counta = 0
countb = 0
for i in range(n):
  if s[i] == 'c':
    print("No")
  elif s[i] == 'b':
    if countb < maxb and counta < maxa:
      print("Yes")
      counta += 1
      countb += 1
    elif counta < maxa:
      print("No")
    else:
      print("No")
  else:
    if counta < maxa:
      print("Yes")
    else:
      print("No")
    counta+=1


Measured memory_bytes: 52824
W,H,N = map(int,input().split())
xya = [list(map(int,input().split())) for _ in range(N)]
p1,p2 = [0,0],[W,H]

for *p,a in xya:
    if a == 1:
        if p1[0] < p[0]:
            p1[0] = p[0]
    elif a == 2:
        if p2[0] > p[0]:
            p2[0] = p[0]
    elif a == 3:
        if p1[1] < p[1]:
            p1[1] = p[1]
    else:
        if p2[1] > p[1]:
            p2[1] = p[1]

if p2[0] - p1[0] < 0 or p2[1] - p1[1] < 0:
    print(0)
else:
    print((p2[0] - p1[0]) * (p2[1] - p1[1]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define lint long long
//#define P pair<int, int>

lint MOD = 1e9 + 7;


int main()
{
    double H, W, x, y;
    cin >> W >> H >> x >> y;
    
    cout << H * W / 2 << " " << ((x * 2 == W) && (y * 2 == H)) << endl;
    
}

Measured memory_bytes: 256
#146A

#1.入力をちゃんと受け取ること
s=input()
#2.結果を出力する
if s=='SUN' :
    print('7')
elif s=='MON':
    print('6')
elif s=='TUE':
    print('5')
elif s=='WED':
    print('4')
elif s=='THU':
    print('3')
elif s=='FRI':
    print('2')
elif s=='SAT':
    print('1')

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	int N; cin >> N;
	vll A(N); cin >> A;
	for (auto &v : A) {
		if (v % 2 == 0 && v % 3 != 0 && v % 5 != 0) {
			cout << "DENIED" << endl;
			return (0);
		}
	}
	cout << "APPROVED" << endl;
	return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n,k; cin>>n>>k;
    vector<int> v(n);
    for(int i=0; i<n; ++i)cin>>v[i];
    int r = min(n,k);
    int ans = 0;
    for(int a = 0; a <= r;++a){
        for(int b = 0; b <= r-a; ++b){
            int temp = 0;
            vector<int> minus;
            for(int i = 0; i < a; ++i){
                temp += v[i];
                if(v[i]<0)minus.push_back(v[i]);
            }
            for(int i = 0; i < b; ++i){
                temp += v[n-i-1];
                if(v[n-i-1]<0)minus.push_back(v[n-i-1]);
            }
            sort(minus.begin(), minus.end());
            int x = minus.size();
            int d = min(k-a-b, x);
            for(int i = 0; i < d; ++i){
                temp -= minus[i];
            }
            ans = max(ans, temp);
        }
    }
    cout<<ans<<endl;
}


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll a,b;
ll ans;

int main(){
    cin >> a >> b;
    ans = -1000;
    ans = max(a+b, a-b);
    ans = max(ans, a*b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int countchildren[2];
    countchildren[0] = 0;
    countchildren[1] = 0;
    int ans[s.size()];
    bool lflag = false;
    int firstl = 0;

    rep(i, s.size()) ans[i] = 0;

    rep(i, s.size())
    {
        if (s[i] == 'R')
        {
            if (lflag)
            {
                ans[firstl] = countchildren[firstl%2];
                ans[firstl-1] = countchildren[1^(firstl%2)];
                
                lflag = false;
                countchildren[i%2] = 1;
                countchildren[(i%2)^1] = 0;
            }
            else
            {
                countchildren[i%2] += 1;
            }
            
        }
        else
        {
            if (!lflag) firstl = i;
            countchildren[i%2] += 1;
            lflag = true;
        }
    }

    ans[firstl] = countchildren[firstl%2];
    ans[firstl-1] = countchildren[1^(firstl%2)];
    rep(i, s.size()-1) cout << ans[i] << " ";
    cout << ans[s.size()-1] << endl;
}


Measured memory_bytes: 1104
N = input()
ans = 0
N1 = N[::-1]

l = 0
for i in range(len(N)):
  if int(N1[i])+l==5 and i<len(N)-1 and int(N1[i+1])>=5:
    ans +=5
    l=1
    continue
  if int(N1[i])+l>10-(int(N1[i])+l):
    if i==len(N)-1:
      ans+=10-(int(N1[i])+l)+1
      continue
    ans+=10-(int(N1[i])+l)
    l=1
  else:
    ans+=int(N1[i])+l
    l=0
#print(b[::-1])
print(ans)

Measured memory_bytes: 58608
#include <iostream>
#include <string>

#define rep(i, N) for(int i = 0;i < N;++i)

using namespace std;

int main() {
	string str;
	cin >> str;
	rep(i, 3) {
		cout << str[i];
	}
	cout << 8;
	rep(i, 6) {
		cout << str[i + 4];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIND(c, e) ((c).find(e) != (c).end())
#define NFIND(c, e) ((c).find(e) == (c).end())
#define ALL(t) (t).begin(), (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair
template<class T> T max(T a,T b,T c){return max(max(a,b),c);}
template<class T> T min(T a,T b,T c){return min(min(a,b),c);}
const int MOD = int( 1e9 ) + 7;

const int N = int( 35 ) + 69 /** :3 **/;
long long a[N];

void __answer()
{
    int n;
    cin >> n;
    a[0] = 2;
    a[1] = 1;
    for(int i = 2; i <= n; i++) a[i] = a[i - 1] + a[i - 2];
    cout << a[n] << '\n';
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cout << setprecision(11) << fixed;
    #ifdef LOCAL
        freopen("TEST2.txt", "r", stdin);
    #endif
    __answer();
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    N = int(input())

    count = 0
    for i in range(1, len(str(N))+1):
        if i % 2 == 1:
            if i == len(str(N)) and N != 10**i :
                count += N - 10**(i-1) + 1
            else:
                count += 10**i - 10**(i-1)
        # print(i, count)
    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

// 最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

// 最小公倍数(overflowに注意した)
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll n, m;
vector<ll> a;

ll maeshori(){
    // かくa[i]は、2で割れる回数が等しいことが条件なので、予め割れるだけわる。
    // (これがoverflow対策になる。)
    for(int i=0; i<n; i++){
        a[i] /= 2;
    }
    while(a[0] % 2 == 0){
        for(int i=0; i<n; i++){
            if(a[i] % 2 != 0) return 0;
            a[i] /= 2;
        }
        // 同時にmも2で割っておく
        m /= 2;
    } 
    // a[0] で判定しているので、まだ2が生き残っているかもしれない。
    for(int i=0; i<n; i++){
        if(a[i] % 2 == 0) return 0;
    }
    ll ans;
    ll Xmin = 1;
    for(int i=0; i<n; i++){
        Xmin = lcm(Xmin, a[i]);
    }
    if(m - Xmin < 0) return 0;
    ans = (m / Xmin + 1) / 2;
    return ans;
}
int main(void){
    
    cin >> n >> m;
    a.resize(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    ll ans;
    ans = maeshori();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4012
#include<iostream>

using namespace std;

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

Measured memory_bytes: 4416
package main

import (
	"bufio"
	"fmt"
	"os"
)

const Inf = 1001001001

func main() {
	N, M := ReadInt(), ReadInt()
	adjL := make([][]int, N)
	for i := 0; i < M; i++ {
		u, v := ReadInt()-1, ReadInt()-1
		adjL[u] = append(adjL[u], v)
	}
	S, T := ReadInt()-1, ReadInt()-1
	dist := make([][]int, N)
	for i := 0; i < N; i++ {
		dist[i] = make([]int, 3)
		for j := 0; j < 3; j++ {
			dist[i][j] = Inf
		}
	}
	dist[S][0] = 0
	q := make([][]int, 0)
	q = append(q, []int{S, 0})
	for len(q) > 0 {
		v, l := q[0][0], q[0][1]
		q = q[1:]
		nl := (l + 1) % 3
		for _, u := range adjL[v] {
			if dist[u][nl] != Inf {
				continue
			}
			dist[u][nl] = dist[v][l] + 1
			q = append(q, []int{u, nl})
		}
	}
	ans := dist[T][0]
	if ans == Inf {
		ans = -1
	} else {
		ans /= 3
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


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

int main() {
    int s, s1, s2, s3, ans;
    cin >> s;
    s1 = s / 100;
    s2 = (s / 10) % 10;
    s3 = s % 10;

    ans = (s1 + s2 + s3);
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){

    int n;
    cin >> n;

    vector<int> p(n), q(n);
    for(int i = 0; i < n; ++i){
        cin >> p[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> q[i];
    }

    vector<int> parm(n);

    for(int i = 0; i < n; ++i){
        parm[i] = i+1;
    }

    int a,b;

    int i = 1;
    do{
        if(p == parm)a = i;
        if(q == parm)b = i;
        ++i;
    }while(next_permutation(parm.begin(), parm.end()));

    cout << abs(a-b) << endl;

}

Measured memory_bytes: 256
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = line[0];
        var b = line[1];
        if (a[0] == '-' && b[0] == '-')
        {
            Console.Write('-');
            plus(a.Substring(1), b.Substring(1));
        }
        else if (a[0] == '-' && b[0] != '-') minus(b, a.Substring(1));
        else if (a[0] != '-' && b[0] == '-') minus(a, b.Substring(1));
        else plus(a, b);
    }
    static void minus(string s2, string t2)
    {
        if (s2 == t2) { Console.WriteLine(0); return; }
        var sL = s2.Length;
        var tL = t2.Length;
        if (sL < tL) { Console.Write('-'); minus(t2, s2); return; }
        if (tL == sL && s2.CompareTo(t2) == -1)
        { Console.Write('-'); minus(t2, s2); return; }
        if (sL > tL) t2 = new string('0', sL - tL) + t2;
        else s2 = new string('0', tL - sL) + s2;
        var s = s2.ToCharArray();
        var t = t2.ToCharArray();
        var ans = new int[sL];
        Array.Reverse(s);
        Array.Reverse(t);
        var p = 0;
        var c = false;
        while (p < sL)
        {
            var sub = s[p] - t[p];
            if (c) sub--;
            if (sub < 0) { sub += 10; c = true; }
            else c = false;
            ans[p] = sub;
            p++;
        }
        Console.WriteLine(string.Join("", ans.Reverse().SkipWhile(x => x == 0)));
    }
    static void plus(string s2, string t2)
    {
        var sL = s2.Length;
        var tL = t2.Length;
        if (tL > sL) { plus(t2, s2); return; }
        t2 = new string('0', sL - tL) + t2;
        var s = s2.ToCharArray();
        var t = t2.ToCharArray();
        var ans = new int[sL];
        Array.Reverse(s);
        Array.Reverse(t);
        var p = 0;
        var c = false;
        while (p < sL)
        {
            var add = s[p] - '0' + t[p] - '0';
            if (c) add++;
            if (add >= 10) { add -= 10; c = true; }
            else c = false;
            ans[p] = add;
            p++;
        }
        Array.Reverse(ans);
        if (c) Console.Write(1);
        Console.WriteLine(string.Join("", ans));
    }
}



Measured memory_bytes: 23108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

struct Edge {
  int f, t, c;
};

int Case = 0;
int n, m;
vector<Edge> G;
int s, t, h;
int d[105];
bool isroop[105];

void init() {
  G.clear();
  memset(d, 0, sizeof(d));
  memset(isroop, 0, sizeof(isroop));
}

bool check(int res) {
  memset(d, 0, sizeof(d));
  rep(i, m) {
    int v = G[i].f, u = G[i].t, c = G[i].c;
    if (v != res) continue;
    chmax(d[u], min(h, h + c));
  }
  rep(i, n - 1) {
    rep(j, m) {
      int v = G[j].f, u = G[j].t, c = G[j].c;
      if (!d[v]) continue;
      chmax(d[u], min(h, d[v] + c));
    }
  }
  return d[res] == h;
}

void solve() {
  rep(i, n) isroop[i] = check(i);
  memset(d, 0, sizeof(d));
  d[s] = h;
  rep(i, n - 1) {
    rep(j, m) {
      int v = G[j].f, u = G[j].t, c = G[j].c;
      if (!d[v]) continue;
      chmax(d[u], min(h, d[v] + c));
    }
    rep(j, m) {
      int v = G[j].f, u = G[j].t, c = G[j].c;
      if (!d[v]) continue;
      if (d[u] != min(h, d[v]) && isroop[u]) d[u] = h;
    }
  }
  cout << "Case " << Case << ": ";
  if (d[t]) cout << d[t];
  else cout << "GAME OVER";
  cout << '\n';
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  while (cin >> n >> m, n) {
    init();
    Case++;
    vector<Edge> tmp;
    rep(i, m) {
      int v, u, w;
      cin >> v >> u >> w;
      tmp.push_back({v, u, w});
    }
    cin >> s >> t >> h;
    for (Edge e: tmp) {
      if (e.f != t) G.push_back(e);
    }

    solve();
  }

  




  
  return 0;
}


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

int main(){
    int N, K, ans;
    cin >> N >> K;
    
    if(N == K){
        ans = 1;
    }
    else if(K == 1){
        ans = N;
    }
    else{
        ans = N - K + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
X, Y = [int(v) for v in input().split()]

v = 0

if X == 1 and Y == 1:
    v += 400000

def prize(rank):
    if rank == 3:
        return 100000
    elif rank == 2:
        return 200000 
    elif rank == 1:
        return 300000
    else:
        return 0
 
v += prize(X) + prize(Y)
print(v)

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
long long sum = 0;
long long arr[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	while(n--){
		long long temp;
		cin>>temp;
		sum+=temp;
		arr[temp]++;
	}	
	int m;
	cin>>m;
	while(m--){
		long long a,b;
		cin>>a>>b;
		sum-=a*arr[a];
		sum+=b*arr[a];
		arr[b]+=arr[a];
		arr[a] = 0;
		cout<<sum<<'\n';
	}
}

Measured memory_bytes: 3940
#include<iostream>
#include<algorithm>
using namespace std;
int t[6];
int main(){
  while(1){
    for(int i=0;i<6;i++)cin>>t[i];
    t[0]+=t[3];
    t[1]+=t[4];
    t[2]+=t[5];
    if(t[0]+t[1]+t[2]==0)break;
    int a=min(t[0],min(t[1],t[2])),ans=0;
    for(int i=max(0,a-2);i<=a;i++){
      int cnt=i;
      for(int j=0;j<3;j++)cnt+=(t[j]-i)/3;
      ans=max(ans,cnt);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int h, w;
	int dx[4] = {-1,0,1,0};
	int dy[4] = {0,1,0,-1};
	char input;
	cin >> h >> w;
	vector<vector<int>> field(h+2, vector<int>(w+2,2));
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			cin >> input;
			if (input == '.') {
				field[i][j] = 0;
			}
			else {
				field[i][j] = 1;
			}
		}
	}
	
	int count = 0;
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			if (field[i][j] == 1) {
				for (int k = 0; k < 4; k++) {
					if (field[i + dx[k]][j + dy[k]] == 1) {
						count++;
					}
				}
				if (count == 0) {
					cout << "No" << endl;
					return 0;
				}
				else {
					count = 0;
				}
			}
		}	
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#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>
#include <fstream>
using namespace std;
long long mod=998244353;
template<class T>struct nCk{
	vector<T> kai,gya,nck;
	nCk(int n){
		kai.resize(n+1);
		gya.resize(n+1);
		nck.resize(n+1);
	}
	T pow(T x,T n){
		T ret=1;
		if(n>0){
			ret=pow(x,n/2);
			if(n%2==0){
				(ret=(ret*ret))%=mod;
			}else{
				(ret=((ret*ret)%mod)*x)%=mod;
			}
		}
		return ret;
	}
	T inv(T n){
		return pow(n,mod-2);
	}
	vector<T> cul(T n){
		kai[n]=n;
		for(int i=n-1;i>0;i--){
			(kai[i]=kai[i+1]*i)%=mod;
		}
		gya[1]=inv(1);
		for(int i=2;i<=n;i++){
			(gya[i]=gya[i-1]*inv(i))%=mod;
		}
		for(int i=1;i<=n;i++){
			(nck[i]=kai[n+1-i]*gya[i])%=mod;
		}
		nck[0]=1;
		nck[n]=1;
		return nck;
	}
};
//
int main(){
	long long n,M,k;
	cin>>n>>M>>k;
	nCk<long long> nck(n-1);
	vector<long long> ans=nck.cul(n-1);
	long long ret=0;
	long long now=M;
	for(int i=0;i<n-1-k;i++){
		(now*=(M-1))%=mod;
	}
	for(long long m=k;m>=0;m--){
		long long hoge=ans[n-1-m]*now%mod;
		(now*=(M-1))%=mod;
		(ret+=hoge)%=mod;
	}
	cout<<ret<<endl;
	return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    int ans;
    vector<int> a(n);

    for (int i=0; i<m; ++i) {
        int k; cin >> k;
        for (int j=0; j<k; ++j) {
            int s; cin >> s;
            --s;
            a[s] |= 1 << i;
        }
    }
    

    int p=0;
    for (int i=0; i<m; ++i) {
        int x; cin >> x;
        p |= x << i;
    }


 
    for (int s=0; s<(1 << n); ++s) {
        int t=0;
        for (int i=0; i<n; ++i) {
            if (s>>i & 1) {
                t ^= a[i];
            }
        }
        if(t == p) {
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
S = str(input())
if S == "SUN":
  print(7)
elif S == "MON":
  print(6)
elif S == "TUE":
  print(5)
elif S == "WED":
  print(4)
elif S == "THU":
  print(3)
elif S == "FRI":
  print(2)
elif S == "SAT":
  print(1)
else:
  print(-1)

Measured memory_bytes: 3060
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *H = map(int, read().split())
cnt = 1
H.sort()
ans = H[0]
for i in H[1:]:
    ans += cnt * i
    cnt *= 2
print(ans / cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int a, b;
  cin >> a >> b;
  int ans = max({a+b, 2*a-1, 2*b -1}) ;

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


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
ll num[4004][5];
int main(){
    ll n,ans=0;
    cin>>n;
    string s;
    cin>>s;s=" "+s;
    for(ll i=1;i<s.length();i++){
        num[i][0]=num[i-1][0];
        num[i][1]=num[i-1][1];
        num[i][2]=num[i-1][2];
        if(s[i]=='R') num[i][0]++;
        if(s[i]=='B') num[i][1]++;
        if(s[i]=='G') num[i][2]++;
    }
    for(ll i=1;i<s.length();i++){
        for(ll j=i+1;j<s.length();j++){
            if(s[i]==s[j]) continue;
            if(s[i]!='R'&&s[j]!='R'){
                ans+=num[n][0]-num[j][0];
                ans-=((j+j-i<=n)&&(s[j-i+j]=='R'));
            }
            if(s[i]!='B'&&s[j]!='B'){
                ans+=num[n][1]-num[j][1];
                ans-=((j+j-i<=n)&&(s[j-i+j]=='B'));
            }
            if(s[i]!='G'&&s[j]!='G'){
                ans+=num[n][2]-num[j][2];
                ans-=((j+j-i<=n)&&(s[j-i+j]=='G'));
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll d[111111];
  d[0]=1;
  REP(i,1,111111) d[i]=(d[i-1]*i)%MAX;
  ll n,m;
  cin >> n >> m;
  ll ans=0;
  rep(i,2) {
    if(n==m||n==m+1) {
      ans+=d[n]*d[m];
      ans%=MAX;
    }
    swap(n,m);
  }
  pr(ans);
}

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


Measured memory_bytes: 1152
module ABC125

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_A

  ! variables for this <module>
  integer, private :: step_production
  integer, private :: num_production
  integer, private :: time_end

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_A

    ! STEP.01
    ! read out the given data
    read(unit=INPUT_UNIT, fmt=*) step_production, num_production, time_end

    ! STEP.02
    ! calculate & output the summation
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') time_end / step_production * num_production

    ! STEP.END
    return

  end subroutine task_A

end module ABC125


program main

  ! <module>s to import
  use, non_intrinsic :: ABC125

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

Measured memory_bytes: 384
#include <stdio.h>
int main(){
    int a,b,x,i=0;
    scanf("%d %d %d",&a,&b,&x);
    
    while(a<=b){
        
        if(x%a ==0) i++;
        a++;
    }
    printf("%d\n",i);
    return 0;
}


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

int main()
{
  ll n;
  cin>>n;
  ll W;
  cin>>W;
  ll weight[n];
  ll val[n];
  for(ll i=0;i<n;i++)
    cin>>weight[i]>>val[i];

  ll dp[n+1][W+1];
  memset(dp,0,sizeof(dp));

  /*for(ll i=1;i<=n;i++)
  {
    for(ll w=0;w<=W;w++)
    {
      cout<<dp[i][w]<<" ";
    }
    cout<<endl;
  }*/
  for(ll i=1;i<=n;i++)
  {
    for(ll w=1;w<=W;w++)
    {
      if(i==0||w==0)
      {
        dp[i][w]=0;
        continue;
      }
      dp[i][w]=max(dp[i-1][w],dp[i][w-1]);
      if(weight[i-1]<=w)
        dp[i][w]=max(dp[i][w],dp[i-1][w-weight[i-1]]+val[i-1]);
    }
  }
  cout<<dp[n][W]<<endl;
  return 0;
}

Measured memory_bytes: 82328
fun main(arr:Array<String>) {
    val s = readLine()!!
    val ans = s.indices.filter { it % 2 != 0 }.all { "LUD".contains(s[it]) } && s.indices.filter { it % 2 == 0 }.all { "RUD".contains(s[it]) }
    println(if(ans) "Yes" else "No")
}


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

int main() {
    LL I, O, T, J, L, S, Z;
    cin >> I >> O >> T >> J >> L >> S >> Z;

    LL ans = O*2;

    LL sm = I%2+J%2+L%2;
    if (I > 0 && J > 0 && L > 0 && sm >= 2) {
        ans += 6;
        I--;
        J--;
        L--;
    }

    ans += (J/2)*4;
    J &= 1;

    ans += (L/2)*4;
    L &= 1;

    ans += (I/2)*4;
    I &= 1;

    cout << ans/2 << endl;

    return 0;
}


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

bool need[256], have[256];

int main() {
#ifdef HOME
	freopen("agc3a.in", "r", stdin);
	freopen("agc3a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string str;

	cin >> str;
	for (auto ch: str)
	switch (ch) {
	case 'N': {
		need['S'] = true;
		have['N'] = true;
		break; }
	case 'S': {
		need['N'] = true;
		have['S'] = true;
		break; }
	case 'E': {
		need['W'] = true;
		have['E'] = true;
		break; }
	case 'W': {
		need['E'] = true;
		have['W'] = true;
		break; } }

	bool flag = true;
	for (auto i: {'N', 'S', 'E', 'W'})
		if (need[i] && !have[i])
			flag = false;

	cout << (flag ? "Yes" : "No") << endl;

	return 0; }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
long long N;
  cin >> N;
  long long ans = 0;
  long long d[N];
  long long mi = 1000000010;
  
  for(long long i = 0;i < N;i++){
    cin >> d[i];
    mi = min(mi, abs(d[i]));
  }
    for(long long i = 0;i < N - 1;i++){
    ans += abs(d[i]);
    if(d[i] < 0){
      d[i] = d[i] * (-1);
      d[i + 1] = d[i + 1] * (-1);
  }
  }
  ans += abs(d[N - 1]);
  
  if(d[N - 1] > 0) cout << ans << endl; 
  else cout << ans - 2 * abs(mi) << endl;
  
return 0;
  
}

Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> ac_flg(n, false);
    vector<int> wa_cnt(n, 0);
    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        --p;
        if (s == "AC") {
            ac_flg[p] = true;
        }
        else if (!ac_flg[p]) {
            ++wa_cnt[p]; 
        }
    }
    int ac_cnt = 0;
    int ans_wa_cnt = 0;
    rep(i, n) {
        //cout << i << " " << ac_flg[i] << endl;
        if (ac_flg[i]) {
            ++ac_cnt;
            ans_wa_cnt += wa_cnt[i];
        }
    }
    cout << ac_cnt << " " << ans_wa_cnt << endl;
    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#include <random>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, n; cin >> x >> n;
	bool chk[110] = { 0 };
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		chk[a] = 1;
	}
	
	int absmn = 1e9, ans = -1;
	for (int i = 0; i <= 101; i++)
		if (!chk[i] && abs(x - i) < absmn) absmn = abs(i - x), ans = i;
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>

using namespace std;

int main(){
  int n,p[15],sum=0;  
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }

  sort(p,p+n,greater<int>());
  p[0]/=2;

  for(int i=0;i<n;i++){
    sum+=p[i];
  }

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

  return (0);
}


Measured memory_bytes: 256
#include<cstdio>
int n,a,b,ans;
int main(){
	scanf("%d",&n);
	if(n==1){
		printf("Hello World");
		return 0;
	}
	else{
		scanf("%d%d",&a,&b);
		ans=a+b;
		printf("%d\n",ans);
	}
}

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

int main(){
  int n,m;cin>>n>>m;
  
  if(n*m)cout<<n*(n-1)/2+m*(m-1)/2<<endl;
  else if(n)cout<<n*(n-1)/2<<endl;
  else if(m)cout<<m*(m-1)/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define UL unsigned int
#define ULL unsigned long long int
#define LI long int
#define LL long long
#define LF double
#define LLF long double
#define FOR(a,b,c) for(a=b;a<=c;a++)
#define rFOR(a,b,c) for(a=b;a>=c;a--)
#define pb push_back
#define mp make_pair
#define IOF ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int MOD1=1000000007;
int binoMax=10000;
vector<LL> numInv(binoMax+1),factNumInv(binoMax+1),fact(binoMax+1);
// If needed call this function for generating ncrmodp
inline void generate_ncrp(LL p){
	int i;
	numInv[0]=numInv[1]=1;
	FOR(i,2,binoMax){
		numInv[i]=numInv[p%i]*(p-p/i)%p;
	}
	factNumInv[0]=factNumInv[1]=1;
	FOR(i,2,binoMax){
		factNumInv[i]=(numInv[i]*factNumInv[i-1])%p;
	}
	fact[0]=1;
	FOR(i,1,binoMax){
		fact[i]=(fact[i-1]*i)%p;
	}
}
// calculates C(n,r)%p in O(1) for many queries
LL ncrmodp(LL n,LL r,LL p){
	LL ans = ((fact[n]*factNumInv[r])%p*factNumInv[n-r])%p;
	return ans;
}

LL expmodp(LL x,LL y,LL p){
	LL res = 1;
	while(y>0){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}

int main(){
	IOF
	int N,i;
	cin>>N;
	int D[N][2];
	FOR(i,0,N-1)cin>>D[i][0]>>D[i][1];
	string ans="No";
	FOR(i,0,N-3){
		if(D[i][0]==D[i][1]&&D[i+1][0]==D[i+1][1]&&D[i+2][0]==D[i+2][1]){
			ans="Yes";
			break;
		}
	}
	
	cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define fill(x, y)     memset(x, y, sizeof(y))
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
const   int            inf = 0;
const   double         eps = 0;
const   int            ms  = 0;
const   int            md  = 0;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<a){
        cout<<k<<endl;
	}else if(k>=a && k<(a+b)){
        cout<<a<<endl;
	}else if(k>= (a+b) && k<=(a+b+c)){
        cout<<a - (k-a-b)<<endl;
	}


	return 0;
}


Measured memory_bytes: 3636
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

bool solve() {
    ll N;
    cin >> N;
    V<PLL> task(N);
    for(ll i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        task[i] = make_pair(b, a);
    }
    sort(ALL(task));
    ll now = 0;
    for(ll i = 0; i < N; i++) {
        ll b, a;
        tie(b, a) = task[i];
        if(b < now + a) return false;
        now += a;
    }
    return true;
}

int main() {
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3328
fn main(){
	let mut buf = String::new();
	std::io::stdin().read_line(&mut buf).expect("can't read X");
	
	let x:u128 = match buf.trim().parse(){
		Ok(num) => num,
		Err(_) => panic!("error"),
	};
	
	let mut a = 100;
	let mut i = 0;
	while a < x {
		a = a + (a/100);
		i = i + 1;
	}
	println!("{}", i);
}

Measured memory_bytes: 2168
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

answer = 0
for index, food in enumerate(a):
    if index == 0:
        answer += b[food - 1]
    elif a[index - 1] + 1 == food:
        answer += b[food - 1]
        answer += c[a[index - 1] - 1]
    else:
        answer += b[food - 1]

print(answer)


Measured memory_bytes: 3064
K = int(input())
List = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(List[K-1])

Measured memory_bytes: 2940
program main
implicit None
	integer(8)::a(5),b(5),c(5)
	read*,a
	c = (10-mod(a,10))
	b = (a/10+(1-c/10))*10
	c = c*(1-c/10)
	
	print "(i0)",sum(b)-maxval(c)
101 format(i0)
end program main

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100005;
struct node
{
	int a,b;
}t[maxn];
int n,h;
bool cmp(node a,node b)
{
	if(a.a!=b.a) return a.a>b.a;
	else return a.b>b.b;
}
bool cmp1(node a,node b)
{
	return a.b>b.b;
}
int main()
{
	scanf("%d%d",&n,&h);
	for(int i=1;i<=n;i++) scanf("%d%d",&t[i].a,&t[i].b);
	sort(t+1,t+n+1,cmp);
	int maxx=t[1].a;
	sort(t+1,t+n+1,cmp1);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(t[i].b>maxx)
		{
			h-=t[i].b;
			++ans;
			if(h<=0)
			{
				cout<<ans<<endl;
				return 0;
			}
		}
	}
	ans+=h/maxx;
	if(h%maxx>0) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
  int n,i;
  int f=0;
  long sum=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    if(i%3==0&&i%5==0) f=f+1;
    else if(i%3==0) f=f+1;
    else if(i%5==0) f=f+1;
    if(f==0) sum=sum+i;
    f=0;
  }
  printf("%ld",sum);
  return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>

int main() {
    int a, b;
    int i, j;
    while (1) {
        scanf("%d %d", &a, &b);
        if (a==0 && b==0) {
            break;
        }
        for ( i = 0; i < a; i++ ){
            for ( j = 0; j < b; j++ ){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include <cstdio>

const int MN = 505, MNN = 250005;

int N, B[MNN], f[MN], g[MN];

int main() {
	scanf("%d", &N);
	for (int i = 1, x; i <= N; ++i) scanf("%d", &x), B[x] = i;
	for (int i = 1, S = 0; i <= N * N; ++i) S += !B[i], B[i] ? g[B[i]] = S : 0;
	for (int i = 1; i <= N * N; ++i) {
		if (!B[i]) {
			int o = 0;
			for (int j = 1; j <= N; ++j) if (f[j] < j - 1)
				o = o ? g[o] - o + f[o] < g[j] - j + f[j] ? o : j : j;
			if (!o) for (int j = 1; j <= N; ++j) if (j <= f[j] && f[j] < N) { o = j; break; }
			if (!o) return puts("No"), 0;
			B[i] = o, ++f[o];
		} else if (++f[B[i]] != B[i]) return puts("No"), 0;
	}
	puts("Yes");
	for (int i = 1; i <= N * N; ++i) printf("%d%c", B[i], " \n"[i == N * N]);
	return 0;
}

Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
#define cs const 
#define int long long
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define pb push_back
#define fr first 
#define se second
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
#define dbg cout << "---------------------------------\n"
cs int base = 233;
cs int ff = 1e6+1;
cs int mod = 1e9+7;
cs int inf = 1e17+1;
inline int read() { int x; scanf("%lld", &x); return x; }
int fir[ff], nex[ff], to[ff], va[ff], tot;
void add(int x, int y, int z)
{
    nex[++tot] = fir[x];
    fir[x] = tot;
    to[tot] = y;
    va[tot] = z;
}
int ksm(int a, int b) { return ( b % 2 == 1 ? a : 1 ) * ( b? ksm( a * a % mod, b>>1 ) : 1 ) % mod; }
int getinv(int x) { return ksm(x, mod-2); }
int n, a, b;
int C(int x, int y)
{
	int s1 = 1, s2 = 1;
	rep(i, 1, x) s1 = s1 * i % mod, s2 = s2 * y % mod, y--;
	return s2 * getinv(s1) % mod;
}
void init()
{
	cin >> n >> a >> b;
	cout << ( ( ksm(2, n) % mod - C(a, n) - C(b, n) - 1 ) % mod + mod ) % mod;
}
signed main()
{
    int T = 1;
    while(T--) 
        init();
} 

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

int main(){
  int n,m;
  cin >> n >> m;
  int total = 0;
  for(int i; i < m; i++){
    int a;
    cin >> a;
    total += a;
  }
  
  int free = n - total;
  if(free < 0) free = -1;
  
  cout << free << endl;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
# ALDS1_3_C_Doubly_Linked_List

import collections

def doublylinkedlist(d, op):
    if "insert" in op:
        d.appendleft(op.split()[1])
    elif op == "deleteFirst":
        d.popleft()
    elif op == "deleteLast":
        d.pop()
    else:
        try:
            d.remove(op.split()[1])
        except:
            pass
        
    return d

n = int(input())
d = collections.deque()
for _ in range(n):
    doublylinkedlist(d, input())

print(" ".join(d))


Measured memory_bytes: 69852
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int r, d, x;
	cin >> r >> d >> x;
	REP(i, 10){
		x = r * x - d;
		cout << x << endl;
	}


}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    int flag = 0;
    string s;
    cin >> s;
    int n = s.length();
    for (int i = 1, j = n; i < j; i++, j--)
    {
        if (s[i - 1] != s[j - 1])
        {
            flag = 1;
            break;
        }
    }
    if (flag == 0)
    {
        for (int i = 1, j = (n - 1) / 2; i < j; i++, j--)
        {
            if (s[i - 1] != s[j - 1])
            {
                flag = 1;
                break;
            }
        }
    }
    if (flag)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

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

int main() {
  int N, M, a, b;
  vector<int> count(50);
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> a >> b;
    count.at(a - 1)++;
    count.at(b - 1)++;
  }
  for(int i = 0; i < N; i++) {
    cout << count.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  ll n,k;
  cin>>n>>k;
  vi a(n);
  rep(i,n) cin>>a[i];
  map<ll,ll> mp;
  ll state=0;
  mp[state]++;
  ll cnt=0,cntex=0;
  while(true){
    mp[a[state]-1]++;
    cnt++;
    if(cnt==k){
      cout<<a[state]<<endl;
      return 0;
    }
    if(mp[a[state]-1]==2) break;
    state=a[state]-1;
  }
  state=a[state]-1;
  while(true){
    mp[a[state]-1]++;
    cnt++;
    if(cnt==k){
      cout<<a[state]<<endl;
      return 0;
    }
    cntex++;
    if(mp[a[state]-1]==3) break;
    state=a[state]-1;
  }
  state=a[state]-1;
  cnt=(k-cnt)%cntex;
  rep(i,cnt){
    state=a[state]-1;
  }
  cout<<state+1<<endl;
}

Measured memory_bytes: 13996