akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
3 4 6
0 0
0 2
0 3
1 1
2 1
2 3

output:
3
"""

import sys


def graph_dfs(current, matching, visited):
    for target in range(y_num):
        if (not visited[target]) and (target in adj_table[current]):
            visited[target] = True
            if matching[target] == -1 or graph_dfs(matching[target], matching,
                                                   visited):
                matching[target] = current
                return True
    return False


def mbm():
    res = 0
    matching = [-1] * y_num
    for source in range(x_num):
        visited = [False] * y_num
        if graph_dfs(source, matching, visited):
            res += 1
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    x_num, y_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    adj_table = [set() for _ in range(x_num)]
    for edge in edges:
        vx, vy = map(int, edge)
        adj_table[vx].add(vy)
    print(mbm())

Measured memory_bytes: 9248
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	string s[50];
	int c[50][26]={};
	for(int i=0;i<n;i++){
		cin >> s[i];
		for(int j=0;j<s[i].length();j++){
			c[i][s[i][j]-'a']++;
		}
	}
	int cc[26];
	for(int i=0;i<26;i++) cc[i]=50;
	for(int i=0;i<26;i++){
		for(int j=0;j<n;j++){
			if(cc[i]>c[j][i]) cc[i]=c[j][i];
		}
	}
	for(int i=0;i<26;i++){
		if(cc[i]>0)
			for(int j=0;j<cc[i];j++)
				cout << (char)(i+'a');
	}
	cout << endl;
}


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

#define ll long long
#define endl "\n"

int main(){
	vector<vector<int>> grid(3, vector<int>(3)), check(3, vector<int>(3, 0));
	for(auto &i : grid){
		for(auto &j : i){
			cin>>j;
		}
	}
	map<int, int> m;
	int n; cin>>n;
	while(n--){
		int a; cin>>a;
		m[a]++;
	}
	for(int i = 0; i<3; i++){
		for(int j = 0; j<3; j++){
			if(m[grid[i][j]]){
				check[i][j] = 1;
			}
		}
	}
	int flag = 0;
	for(int i = 0; i<3; i++){
		int ans = 0;
		for(int j = 0; j<3; j++){
			ans+=check[j][i];
		}
		if(ans == 3){
			flag = 1;
			break;
		}
	}
	for(int i = 0; i<3; i++){
		int ans = 0;
		for(int j = 0; j<3; j++){
			ans+= check[i][j];
		}
		if(ans == 3){
			flag = 1;
			break;
		}
	}
	int a = 0, b = 0;
	for(int i = 0; i<3; i++){
		a += check[i][i];
	}
	for(int i = 0; i<3; i++){
		b += check[2-i][i];
	}
	if(a == 3 || b == 3){
		flag = 1;
	}
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    ll A,B;
    cin >> A >> B;
    ll x,y;
    if(A==0)x=A;
    else{
        ll p;
        if(A%2==0)p=0;
        else p=A-1;
        if((A/2)%2)x=1^p;
        else x=0^p;
    }
    ll p;
    if(B%2==0)p=B;
    else p=0;
    if(((B+1)/2)%2)y=1^p;
    else y=0^p;
    ll ans=x^y;
    cout << ans;
    


}

/*



 */



Measured memory_bytes: 256
//26^8>(4*10^5)^2???????????????8????????\???. 26^5>(4*10^5)*8???????????????5????????\???. ??¨??¨????????????.
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

vector<bool> is_exist[6];

int encode(string s) {
	int ret = 0;
	int mul = 1;
	
	for (int i = (int)s.length() - 1; i >= 0; i--) {
		ret += (s[i] - 'a') * mul;
		mul *= 26;
	}
	return ret;
}

string decode(int id, int length) {
	string str;
	int mul = 1;
	
	for (int i = length - 1; i >= 0; i--) {
		int val = (id / mul) % 26;
		str += (char)(val + 'a');
		mul *= 26;
	}
	
	string ret;
	for (int i = length - 1; i >= 0; i--) {
		ret += str[i];
	}
	
	return ret;
}

void input() {
	int n;
	
	cin >> n;
	
	is_exist[1].resize(26);
	is_exist[2].resize(26 * 26);
	is_exist[3].resize(26 * 26 * 26);
	is_exist[4].resize(26 * 26 * 26 * 26);
	is_exist[5].resize(26 * 26 * 26 * 26 * 26);
	for (int i = 1; i <= 5; i++) {
		for (int j = 0; j < is_exist[i].size(); j++) {
			is_exist[i][j] = false;
		}
	}
	
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < s.length(); j++) {
			string t;
			for (int k = j; k < min((int)s.length(), j + 5); k++) {
				t += s[k];
				is_exist[t.length()][encode(t)] = true;
			}
		}
	}
}

int main() {
	input();
	
	for (int i = 1; i <= 5; i++) {
		for (int j = 0; j < is_exist[i].size(); j++) {
			if (!is_exist[i][j]) {
				cout << decode(j, i) << endl;
				return 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 4976
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static String end;
	static int ans = 0;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			int n = Integer.parseInt(br.readLine());

			if (n == 0)
				break;

			ans = Integer.MAX_VALUE;

			String a[] = new String[n];
			String b[] = new String[n];

			for (int i = 0; i < n; i++) {
				String str[] = br.readLine().split(" ");

				a[i] = str[0];
				b[i] = str[1];
			}

			String start = br.readLine();
			end = br.readLine();

			dfs(n, a, b, start, 0);

			if (ans == Integer.MAX_VALUE)
				System.out.println("-1");
			else
				System.out.println(ans);
		}
	}

	static void dfs(int n, String a[], String b[], String str, int count) {
		if (str.length() > end.length() || str.length() > 10) {
			return;
		}

		if (str.equals(end)) {
			ans = Math.min(ans, count);
			return;
		}

		for (int i = 0; i < n; i++) {
			String res = str.replace(a[i], b[i]);

			if (!str.equals(res))
				dfs(n, a, b, res, count + 1);
		}
	}
}



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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
	ll k;
	string s;
	cin>>k>>s;
	ll n=s.size();
	if(k>=n) cout<<s<<en;
	else cout<<s.substr(0,k) + "..."<<en;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int d[1000000]={},p[1000000]={};
void calc(){
    for(int i=2;i<1000000;i++){
        if(d[i]==0){
            for(int j=2;j<1000000;j++){
                if(i*j>1000000) break;
                    d[i*j]=1;
            }
        }
    }
    for(int i=2;i<1000000;i++){
        if(d[i]==0)
        p[i]=p[i-1]+1;
        else
        p[i]=p[i-1];
    }
}
int main(){
    calc();
    int n;
    while(cin>>n,n){
        if(cin.eof())break;
        cout<<p[n]<<endl;
    }
    return 0;
}

Measured memory_bytes: 8972
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  char b;
  cin >> b;
  map<char, char> mp;
  mp['A'] = 'T';
  mp['T'] = 'A';
  mp['C'] = 'G';
  mp['G'] = 'C';
  cout << mp[b] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {  
    string s;
    cin >> s;
    vector<int> v(26, 0);
    for (auto ss : s) {
        v[ss - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
        if (v[i] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}




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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

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

  LL ans;
  int N;
  cin >> N;
  vector<int> B(N - 1);
  FOR(i, 0, N - 1){
    cin >> B[i];
  }

  vector<int> A(N, INF);
  FOR(i, 0, N - 1){
    if(B[i] < A[i]){
      A[i] = B[i];
    }
    if(B[i] < A[i + 1]){
      A[i + 1] = B[i];
    }
  }

  ans = accumulate(ALL(A), 0);

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3596
N, A = map(int, input().split())
x = [int(i) for i in input().split()]

table = [[[0]*(N*A+1) for i in range(N+1)] for j in range(N+1)]
table[0][0][0] = 1

for j in range(1,N+1):
  for k in range(j+1):
    for s in range(N*A+1):
      c = x[j-1]
      if s-c<0:
        table[j][k][s] = table[j-1][k][s]
      elif s-c>=0 and k>=1:
        table[j][k][s] = table[j-1][k][s] + table[j-1][k-1][s-c]
      
ans = 0
for i in range(1,N+1):
  ans += table[N][i][i*A]
print(ans)

Measured memory_bytes: 92892
#include<stdio.h>

int make_ans(int n,int x) {
    int a,b,c,total=0;
    for(a=1;a<=n;a++) {
        for(b=a+1;b<=n;b++) {
            for(c=b+1;c<=n;c++) {
                if(a+b+c==x) total++;
            }
        }
    }
    return total;
}

int main() {
    int n,x,i=0,k,limit=100,ans[limit];
    while(1) {
        scanf("%d %d",&n,&x);
        if(n==0 && x==0) break;
        ans[i] = make_ans(n,x);
        i++;
        if(i==limit-1) limit++;
    }
    for(k=0;k<i;k++) {
        printf("%d\n",ans[k]);
    }
    return 0;
}


Measured memory_bytes: 2716
#include<cstdio>
#define ll long long
const int o=998244353;
int n,k;
ll ans=0;
ll frc[500003],fic[500003];
inline ll inv(ll x)
{
	ll res=1;
	int v=o-2;
	while(v)
	{
		(v&1)&&(res=res*x%o),x=x*x%o,v>>=1;
	}
	return res;
}
int main()
{
	scanf(" %d %d",&n,&k);
	frc[0]=1;
	for(int i=1;i<=k;++i)frc[i]=frc[i-1]*i%o;
	fic[k]=inv(frc[k]);
	for(int i=k;i;--i)fic[i-1]=fic[i]*i%o;
	for(int i=n;i<=k;++i)
	{
		ans=(ans+frc[k-1]*fic[i-1]%o*fic[k-i]%o)%o;
	}
	printf("%lld\n",ans);
	return 0;
}

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

void dfs(long long n,vector<long long> &lun){
    if(n>3234566667) return;
    lun.push_back(n);
    int q = n%10;
    if(q<9) dfs(n*10+q+1,lun);
    dfs(n*10+q,lun);
    if(q>0) dfs(n*10+q-1,lun);
}

int main(){
    int k; cin >> k;
    vector<long long> lun;
    for(int i=1;i<10;++i) dfs(i,lun);
    sort(lun.begin(),lun.end());
    cout << lun[k-1] << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;



int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(N - 1);
	int full = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N - 1; i++) {
		cin >> C[i];
	}
	for(int i = 0; i < N ; i++){
      full += B[i];
    }
	for (int i = 1; i < N; i++) {
      if(A[i] - A[i-1] == 1){
        full += C[A[i]-2];
    }
      else{
        continue;
      }
      
    }
	cout << full << endl;
      
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,s;

int main()
{	cin>>n>>k>>s;
	for(int i=1;i<=k;++i)
		cout<<s<<' ';
	for(int i=k+1;i<=n;++i)
		if(s==1000000000)
			cout<<1<<' ';
		else
			cout<<1000000000<<' ';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, K;
vi A;
vv<ll> dp;

int main() {
    cin >> N >> K;
    A.resize(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    int M = (lower_bound(all(A), K) - A.begin());
    
    dp.resize(M + 1, vector<ll>(K + 1, 0));
    int ng = -1;
    int ok = M;
    while (abs(ok - ng) > 1) {
        int mid = (ng + ok) / 2;

        rep(i, M + 1) {
            rep(j, K + 1) dp[i][j] = 0;
        }
        dp[0][0] = 1;

        rep(i, 0, M) {
            if (i == mid) {
                rep(j, 0, K + 1) {
                    dp[i + 1][j] = dp[i][j];
                }
            }
            else {
                rep(j, 0, K - A[i] + 1) {
                    dp[i + 1][j] += dp[i][j];
                    dp[i + 1][j + A[i]] += dp[i][j];
                }
                rep(j, K - A[i] + 1, K + 1) {
                    dp[i + 1][K] += dp[i][j];
                }
            }
        }

        bool b = false;
        rep(i, K - A[mid], K) {
            if (dp[M][i] > 0) b = true;
        }

        if (b) ok = mid;
        else ng = mid;
    }

    write(ok);
}

Measured memory_bytes: 197888
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define all(V) V.begin(),V.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

//宣言とか
ll cnt;
//ll ans;
/*signed*/int main(void) {
    ll n;
    cin >> n;
    for (ll i = 1; i < n; ++i) {
        ll ans = (n - 1) / i;
        cnt += ans;
    }
    cout << cnt << endl;
    return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

ll mod_pow ( ll a , ll b )
{
    if ( b == 0 ) return 1 ;
    if ( b == 1 ) return a%mod ;
    if ( b == 2 ) return ((a%mod) * (a%mod)) % mod ;

    return ( mod_pow ( a , b%2 ) * mod_pow ( mod_pow ( a , b/2 ) , 2 ) % mod ) ;
}

ll ncr ( ll n , ll r )
{
    r = min ( r , n - r ) ;

    ll num = 1 ; /// numerator
    ll den = 1 ; /// denominator

    for ( int i=0 ; i < r ; i ++ )
        num *= (n - i) , num %= mod ;

    for ( int i=1 ; i <= r ; i ++ )
        den *= i , den %= mod ;

    ll inv = mod_pow ( den , mod - 2 ) ;
    ll ret = num * inv ;

    return ret ;
}

void solve ( int test_case )
{
    ll n , a , b ;
    cin >> n >> a >> b ;

    ll ans = mod_pow ( 2 , n ) ;
    ans -- ;

    a = ncr ( n , a ) ;
    b = ncr ( n , b ) ;

    ans -= a ;
    ans -= b ;

    ans %= mod ;
    if ( ans < 0 )
        ans += mod ;

    cout << ans ; line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int con(string s){
  if(s=="yotta") return 24;
  if(s=="zetta") return 21;
  if(s=="exa") return 18;
  if(s=="peta") return 15;
  if(s=="tera") return 12;
  if(s=="giga") return 9;
  if(s=="mega") return 6;
  if(s=="kilo") return 3;
  if(s=="hecto") return 2;
  if(s=="deca") return 1;
  if(s=="deci") return -1;
  if(s=="centi") return -2;
  if(s=="milli") return -3;
  if(s=="micro") return -6;
  if(s=="nano") return -9;
  if(s=="pico") return -12;
  if(s=="femto") return -15;
  if(s=="ato") return -18;
  if(s=="zepto") return -21;
  if(s=="yocto") return -24;
  return 0;
}
int main(){
  int n;
  int i,j,k,x;
  cin >> n;
  while(n--){
    x=0;
    string s1="",s2="",s3="";
    cin >> s1 >> s2;
    while(con(s2)!=0) {
      x+=con(s2);
      //cout << x << endl;
      cin >> s2;
    }
    s3=s2;
    if(s1[0]=='0'){
      k=1; 
      j=0;
      while(s1[k]!='.') {
        k++;
        j++;
      }
      k++;
      while(s1[k]=='0') {
        k++;
      }
      cout << s1[k];
      if(k!=s1.size()-1){
        cout << ".";
        for(i=k+1;i<s1.size();i++) cout << s1[i];        
      }
      cout << " * 10^" << x-(k-1)+j;
      cout << " " << s3 << endl;
    }else{
      k=1;
      bool f=false;
      if(s1.size()==1) {
        f=true;
        cout << s1[0];
      }else{
        while(s1[k]!='.') {
          k++;
          if(k>=s1.size()-1) {
            f=true;
            break;
          }
        }
        cout << s1[0];
        if(k!=1){
          cout << ".";
          for(i=1;i<k;i++) cout << s1[i]; 
          if(f&&s1[k]!=NULL) cout << s1[k];  
          for(i=k+1;i<s1.size();i++)cout << s1[i];   
        }else{
          cout << ".";
          for(i=k+1;i<s1.size();i++) cout << s1[i];   
        }
      }
      //cout << (int)x+(int)(s1.size()-1)  << endl;
      if(f) cout << " * 10^" << (int)x+(int)(s1.size()-1);
      else cout << " * 10^" << x+k-1;
      cout << " " << s3 << endl;
    }
    
  }
  return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
const int BUF = 305;
const int BIT = 61;


class State {
public:
    int bit, aCarry, bCarry, subed;
    
    State() {}
    State(int bit, int aCarry, int bCarry, int subed):
        bit(bit), aCarry(aCarry), bCarry(bCarry), subed(subed) {}

    bool operator< (const State &opp) const {
        return subed < opp.subed;
    }
};


int nVal;
long long val[BUF];

void read() {
    cin >> nVal;
    for (int i = 0; i < nVal; ++i) {
        cin >> val[i];
    }
}


bool rec(int bit, int aCarry, int bCarry, int dp[BIT][2][2], vector<State> next[BIT][2][2], long long result) {
    if (bit == BIT - 1) {
        return aCarry == 0 && bCarry == 0;
    }
    
    int &ret = dp[bit][aCarry][bCarry];
    if (ret != -1) return ret;

    ret = false;
    
    long long aBit = (val[0] - (aCarry ?  1LL << (bit) : 0)) & (1LL << bit);
    long long bBit = (val[1] + (bCarry ?  1LL << (bit) : 0)) & (1LL << bit);
    long long rBit = result & (1LL << bit);
    
 
    // A - 0,  B + 0
    if ((aBit ^ bBit) == rBit) {
        int aNexCarry = (val[0] & (1LL << bit)) == 0 && aCarry;
        int bNexCarry = (val[1] & (1LL << bit)) && bCarry;
        if (rec(bit + 1, aNexCarry, bNexCarry, dp, next, result)) {
            next[bit + 1][aNexCarry][bNexCarry].push_back(State(bit, aCarry, bCarry, false));
            ret = true;
        }
    }

    // A - (1 << bit),  B + (1 << bit)
    if ((aBit ^ bBit) == rBit) {
    // if (((aBit ^ (1LL << bit)) ^ (bBit ^ (1LL << bit))) == rBit) {
        int aNexCarry = (val[0] & (1LL << bit)) == 0 || aCarry;
        int bNexCarry = (val[1] & (1LL << bit)) || bCarry;
        if (rec(bit + 1, aNexCarry, bNexCarry, dp, next, result)) {
            next[bit + 1][aNexCarry][bNexCarry].push_back(State(bit, aCarry, bCarry, true));
            ret = true;
        }
    } 
    
    return ret;
}


void work() {
    long long result = 0;
    for (int i = 2; i < nVal; ++i) {
        result ^= val[i];
    }
    
    int dp[BIT][2][2];
    memset(dp, -1, sizeof(dp));
    
    vector<State> next[BIT][2][2];
    
    if (!rec(0, 0, 0, dp, next, result)) {
        cout << -1 << endl;
    } else {
        long long ans = 0;
        int bit = BIT - 1, aCarry = 0, bCarry = 0;
        
        while (!next[bit][aCarry][bCarry].empty()) {
            vector<State> &n = next[bit][aCarry][bCarry];
            sort(n.begin(), n.end());
            
            if (n[0].subed) {
                ans |= 1LL << (bit - 1);
            }

            bit = n[0].bit;
            aCarry = n[0].aCarry;
            bCarry = n[0].bCarry;
        }
        cout << (ans == val[0] ? -1 : ans) << endl;
    }
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;

int n;
int ul, bl, h;
const int dy[3] = {0,-1,1};
vector<string> rec(1001);
bool flag = false;

int soy(int i, int j){
	ul = bl = 0;
	h = 1;
	
	while( j < rec[i].size() && rec[i][j] == '*'){
		rec[i][j] = ' ';
		//cout << j << " , " << i << endl;
		ul++;
		j++;
	}
	j--;
	int a = -1;
	i++;
	if( i < n && j + 1 < rec[i].size() && rec[i][j+1] == '*'){
		a = 2;
	}else if( i < n && rec[i][j] == '*'){
		a = 0;
	}else if( i < n && j - 1 >= 0 && rec[i][j-1] == '*'){
		a = 1;
	} 
	h++;
	j += dy[a];
	while( i < n && j+dy[a] >= 0 && j+dy[a] < rec[i+1].size() && rec[i+1][j+dy[a]] == '*'){
		rec[i][j] = ' ';
		h++;
		i++;
		j += dy[a];
	}
	//j-=dy[a];
	//i--;
	while( j >= 0 && rec[i][j] == '*'){
		rec[i][j] = ' ';
		bl++;
		j--;
	}
	j++;

	if( i - 1 >= 0 && rec[i-1][j] == '*'){
		a = 0;
	}else if( i - 1 >= 0 && j - 1 >= 0 && rec[i-1][j-1] == '*'){
		a = 1;
	}else if( i - 1 >= 0 && j + 1 < rec[i].size() && rec[i-1][j+1] == '*'){
		a = 2;
	}

	for( int b = 0; b < h-1; b++){
		j += dy[a];
		rec[i-b-1][j] = ' ';
	}
	//cout << ul << " " << bl  << " " << h << endl;
	return (ul + bl) * h / 2;
}

int main(){
	while(cin >> n, n){
		int ans[10000] = {0};
		char stj[100];
		gets(stj);
		for(int i = 0; i < n; i++){
			rec[i].resize(0);
			char tmpc[1080];
			gets(tmpc);
			int j = 0;
			while(tmpc[j]){
				rec[i].push_back(tmpc[j]);
				j++;
			}
			//cout << rec[i] << endl;
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j < rec[i].size(); j++){
				if( rec[i][j] == '*'){
					int t = soy(i,j);
					ans[t]++;
				}
			}
		}
		if(flag) cout << "----------" << endl;
		else flag = true;
		for(int i = 0; i < 10000; i++){
			if(ans[i] != 0){
				cout << i << ' ' << ans[i] << endl;
			}
		}
	}	
}

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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  int H[N];
  for (int i = 0; i < N; i++) cin >> H[i];

  double d = abs(A - (T - H[0] * 0.006));
  int answer = 1;
  for (int i = 1; i < N; i++) {
    double d2 = abs(A - (T - H[i] * 0.006));
    if (d2 < d) {
      d = d2;
      answer = i + 1;
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){


  char str[1010];


  int i,sum;


  scanf("%s",str);


  while(str[0]!='0'){


  i=0;


  sum=0;


  while(str[i]){


sum+=str[i]-'0';


  i++;


  }


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


  scanf("%s",str);


  }
return 0;


}

Measured memory_bytes: 536
// https://atcoder.jp/contests/agc041/tasks/agc041_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, M, V, P;
  cin >> N >> M >> V >> P;

  VL as(N);
  map<ll, ll> act;

  rep(i, N) {
    ll a;
    cin >> a;
    as[i] = a;
    act[a]++;
  }

  sort(all(as));

  auto is_ok = [&](ll index) -> bool {
    ll a = as[index];
    ll rest = M * V;
    ll served = 0;

    auto over_it = upper_bound(all(as), a + M);
    ll over_index = over_it - as.begin();
    ll over_a_ct = N - over_index;
    if (over_a_ct >= P) return false;
    rest -= over_a_ct * M;
    served += over_a_ct;
    ll rr = P - over_a_ct - 1;

    if (rest <= 0) return true;

    ll smaller_a_ct = upper_bound(all(as), a) - as.begin();
    rest -= smaller_a_ct * M;
    served += smaller_a_ct;

    if (rest <= 0) return true;

    over_index -= rr;
    rest -= rr * M;
    served += rr;

    if (rest <= 0) return true;

    ll b_i = upper_bound(all(as), a) - as.begin();

    for (ll ii = b_i; ii < over_index; ii++) {
      rest -= a + M - as[ii];
      served++;
    }

    return rest <= 0 && served >= V;
  };

  if (is_ok(0)) drop(N);

  ll ng = 0;
  ll ok = N - 1;

  while (ok - ng > 1) {
    ll mid = (ng + ok) / 2;
    if (is_ok(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  ll res = N - ok;
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    cin >> n;
    lint diff = 0;
    priority_queue<lint> pq;
    for (int i = 0; i < n; i++) {
        lint a, b;
        cin >> a >> b;
        pq.push(a + b);
        diff += a;
    }
    // turn=0なら高橋くんの番
    int turn = 0;
    while (!pq.empty()) {
        lint now = pq.top();
        pq.pop();
        if (turn == 1) {
            diff -= now;
        }
        turn = 1 - turn;
    }
    cout << diff << endl;
}

Measured memory_bytes: 1400
/*
	Code written by Talant I.D.
*/
 
#include <bits/stdc++.h> 
 
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
 
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound 
#define ub upper_bound 
#define mp make_pair
#define mt make_tuple
#define mod ll(1e9+7)
#define eps double(1e-9)
#define PI 2*acos(0.0)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define curMod 998244353
 
inline bool isvowel(char ch){
	ch = tolower(ch);
	return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y');
}
 
inline bool isprime(int n){
	if(n < 2 || (n % 2 == 0 && n != 2))
		return false;
	for(int i = 3; i*i <= n; i += 2)
		if(n%i == 0) return false;
	return true;
}

int main(){
	do_not_disturb
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int k, x;
	cin >> k >> x;
	if(k*500 >= x){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
	
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
int main(){
	int n;
	std::cin >> n;
	std::vector<int> A(n);
	int ans = 0;
	for (int i = 0; i < n; ++i)std::cin >> A[i];
	for (int i = 0; i < A.size(); ++i){
		int mini = i;
		for (int j = i; j < A.size(); ++j){
			if (A[j] < A[mini])mini = j;
		}
		if (i != mini){
			std::swap(A[i], A[mini]);
			ans++;
		}
	}
	for (int i = 0; i < n; ++i){
		std::cout << A[i];
		if (i != n - 1)std::cout << " ";
	}
	std::cout << std::endl << ans << std::endl;
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
long long ans;
long long modPow(long long a, int p){
    if (p == 0) return 1;
    if (p%2 == 0) {
        long long half = modPow(a, p/2);
        return half * half % mod;
    }
    else return a * modPow(a, p-1) % mod;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> C(N);
    for (auto & c : C) cin >> c;
    sort(C.rbegin(), C.rend());
    for (int i = 0; i < N; ++i) {
        ans += (long long)C[i]*(i+2);
        ans %= mod;
    }
    ans *= modPow(4, N-1);
    ans %= mod;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) (*find_by_order(i))
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
// #define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/


void solve(){
     int a, b, c, d, k;
     cin >> a >> b >> c >> d >> k;
    //  if(d < b)d += 60, c--;
     cout << ((c-a)*60) + (d-b) - k;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3652
import math
import sys


def input():
    return sys.stdin.readline()[:-1]


N, H = map(int, input().split())

max_a = 0
max_a_b = 0
AB = []
for _ in range(N):
    ab = list(map(int, input().split()))
    AB.append(ab)
    if max_a < ab[0]:
        max_a = ab[0]
        max_a_b = ab[1]
    elif max_a == ab[0] and max_a_b > ab[1]:
        max_a = ab[0]
        max_a_b = ab[1]

AB.sort(key=lambda x: x[1], reverse=True)

throw_sum = 0
ans = 0
for i in range(N):
    if max_a < AB[i][1]:
        throw_sum += AB[i][1]
        ans += 1
        if throw_sum >= H:
            print(ans)
            exit(0)

H -= throw_sum
ans += math.ceil(H/max_a)

print(ans)


Measured memory_bytes: 28540
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
static void Main(string[] args){
  var N = int.Parse(Console.ReadLine());
  //HashSetを使うと、最初から重複を防げる
  var hash = new HashSet<int> ();
  for(int i=0;i<N;i++){
  hash.Add(int.Parse(Console.ReadLine()));
  }
  Console.WriteLine(hash.Count());
}
}

Measured memory_bytes: 13280
eval"H,W,*A="+`dd`.split*?,
t=7**5
i=0
A.pop(H*W).zip(A){|a,b|a=(a-b).abs
i%W<1&&N=0
N|=$*[-W]||0**i<<t
$*<<N=N<<a|N>>a
i+=1}
p (0..2*t).map{|i|(t-i*N[i]).abs}.min

Measured memory_bytes: 51588
#include <stdio.h>

int main(){
	int n,in[12],out[12],i,j,t,r,flag;
	
	while(~scanf("%d",&n)){
		if(n==0)break;

		t=0;
		
		for(i=0;i<n;i++){
			scanf("%d",&in[i]);
		}
		flag=1;
		while(flag){
			for(i=0;i<n;i++)out[i]=0;
			for(i=0;i<n;i++){
				for(j=0;j<n;j++){
					if(in[i]==in[j])++out[i];
				}
			}
			
			++t;
			flag=0;
			for(i=0;i<n;i++){
				if(in[i]!=out[i])flag=1;
			}
			
			for(i=0;i<n;i++){
				in[i]=out[i];
			}
		}
		printf("%d\n",t-1);
		for(i=0;i<n-1;i++){
			printf("%d ",in[i]);
		}
		printf("%d\n",in[n-1]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define var auto
using namespace std;
using ll = long long;
using P = pair<int, int>;
bool cmp(P a, P b) { return a.second < b.second; }
#ifdef DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; cout << a << endl; return 1; } cout << a << endl; return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; cout << a << endl; return 1; } cout << a << endl; return 0; }
#else
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; }
#endif
const ll INF = 1LL << 60;
const int MAX_ITEM = 10e4+10; // 10^5

int main() {
  int n,m;
  cin >> n >> m;
  vector<P> A(m);
  rep(i,m) cin >> A[i].first >> A[i].second;
  sort(A.begin(), A.end(), [](P a, P b){
    return a.second < b.second; // 終端ソート
  });

  // 串に刺したときの始点を覚えておく
  int res = 0;
  int point = 0;
  rep(i,m) {
    if (point <= A[i].first) {
      point = A[i].second;
      ++res;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
using namespace std;

int main(void)
{
  int n;
  int t1, t2;
  scanf("%d", &n);
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d %d", &t1, &t2);
    v[i] = make_pair(t2, t1);
  }

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

  int sum = 0;
  int i = 0;
  for (; i < n; i++)
  {
    sum += v[i].second;
    if (sum > v[i].first)
      break;
  }

  if (i == n)
    printf("Yes\n");
  else
    printf("No");

  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    if (a <= b) {
      System.out.println(a);
    } else {
      System.out.println(a - 1);
    }

  }
}

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

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

    int n;
    cin >> n;
    vector<int> A(4, 0);
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(s == "AC") A[0]++;
        else if(s == "WA") A[1]++;
        else if(s == "TLE") A[2]++;
        else if(s == "RE") A[3]++;
    }

    cout << "AC x " << A[0] << endl;
    cout << "WA x " << A[1] << endl;
    cout << "TLE x " << A[2] << endl;
    cout << "RE x " << A[3] << endl;


    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int x,y,a,b,c,p,q,r;
    long long sum=0;
    cin>>x>>y>>a>>b>>c;
    int n=x+y;
    priority_queue<pair<int,char>> app;
    for(int i=0;i<a;i++){
        cin>>p;
        app.push(make_pair(p,'r'));
    }
    for(int i=0;i<b;i++){
        cin>>q;
        app.push(make_pair(q,'g'));
    }
    for(int i=0;i<c;i++){
        cin>>r;
        app.push(make_pair(r,'c'));
    }
    while(n!=0){
        if(app.top().second=='r'){
            if(x!=0){
                sum+=app.top().first;
                n--;
                x--;
            }
        }
        if(app.top().second=='g'){
            if(y!=0){
                sum+=app.top().first;
                n--;
                y--;
            }
        }
        if(app.top().second=='c'){
            sum+=app.top().first;
            n--;
        }
        app.pop();
    }
    cout<<sum<<"\n";   
    return 0;
}

Measured memory_bytes: 7420
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<pair<int, int>> G[100010];
int ans[100010];
void dfs(int a, int parent, int d) {
    ans[a] = d % 2;
    for(auto to: G[a]) {
        if (to.first == parent) continue;
        dfs(to.first, a, d + to.second);
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N - 1) {
        int s, t, w;
        cin >> s >> t >> w;
        s--; t--;
        G[s].push_back({t, w});
        G[t].push_back({s, w});
    }
    dfs(0, -1, 0);
    rep(i, N) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 10240
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

fullSet = []
for i in range(N + 1):
    if i in A:
        fullSet.append(1)
    else:
        fullSet.append(0)

print(min(sum(fullSet[:X]), sum(fullSet[X:])))


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node *Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left!=NIL){
    x=x->left;
  }

  return x;
}

Node treeMaximum(Node x){

  while(x->right!=NIL){
    x=x->right;
  }

  return x;
  
}

Node treeSearch(Node u, int k){
  u=root;

  while(u!=NIL && u->key!=k){
    if(k < u->key) u=u->left;
    else u=u->right;
  }

  return u;
  
}

Node treeSuccessor(Node x){
  Node y;

  if(x->right!=NIL) return treeMinimum(x->right);

  y=x->parent;

  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }

  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;

  if(z->left==NIL || z->right==NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent=y->parent;

  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right=x;

  if(y!=z) z->key=y->key;
  
}

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }

  z->parent=y;

  if(y==NIL) root=z;
  else if (z->key < y->key) y->left=z;
  else y->right=z;

}

void inorder(Node u){
  
  if(u==NIL) return;

  if(u->left!=NIL) inorder(u->left);
  
  printf(" %d",u->key);
  
  if(u->right!=NIL) inorder(u->right);
  
}

void preorder(Node u){

  if(u==NIL) return;
  
  printf(" %d",u->key);
  
  if(u->left!=NIL) preorder(u->left);
  

  if(u->right!=NIL) preorder(u->right);
  
  
}

int main(){
  int n, i, x;
  char com[20];
  
  scanf("%d", &n);

  for(i = 0; i < n; i++ ){
    scanf("%s", com);
    if( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25136
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn :: IO Int
    [xs, ys, zs] <- replicateM 3 getLine
    print $ solve xs ys zs

solve xs ys zs = sum $ zipWith3 f xs ys zs
f x y z
  | x == y, y == z = 0
  | x == y = 1
  | y == z = 1
  | z == x = 1
  | otherwise = 2

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

main(){
  ll n;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  for(ll i=0;i<n;++i)cin>>a[i]>>b[i]>>c[i];
  vector<vector<ll> > dp(n,vector<ll>(3));
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  for(ll i=1;i<n;++i){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
}

Measured memory_bytes: 8064
#include<stdio.h>

int main(void)
{
   int a,b,c;
   scanf("%d %d",&a,&b);

   if((b%a)==0){                                                     
            c=b+a;
            printf("%d\n",c);}

   else {
         c=b-a;
         printf("%d\n",c);}

   return 0;
}


Measured memory_bytes: 128
a=[0,0,0,0,0]
b=[0,0,0,0,0]
time=0
cnt=0
a[0]=int(input())
a[1]=int(input())
a[2]=int(input())
a[3]=int(input())
a[4]=int(input())
for i in range(5):
  b[i]=a[i]%10
for i in range(10):
  for j in range(5):
    if a[j]==0:
      c=0
    else:
      if b[j]==0:
        time=time+a[j]
        a[j]=0
        cnt=cnt+1
      elif b[j]==(10-i):
        time=time+a[j]+i
        cnt=cnt+1
        a[j]=0
        if cnt==5:
          time=time-i
print(time)

Measured memory_bytes: 3064