akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

char c[100005];

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  scanf("%s", c);

  int ca=0,cb=0;
  rep(i,n){
    if(c[i]=='a'){
      if(ca+cb<a+b){
        printf("Yes\n");
        ca++;
        continue;
      }
    } else if(c[i]=='b'){
      if(ca+cb<a+b && cb<b){
        printf("Yes\n");
        cb++;
        continue;
      }
    }
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)((x).size())
#define mp make_pair

using namespace std;

typedef unsigned long long ull;
typedef pair<int,int> ii;

template<class U,class T>ostream& operator<<(ostream& out, pair<U,T> & P){
    return out << "[" << P.first << ", " << P.second << "]";
}
template<class T>ostream& operator<<(ostream& out, vector<T> & V){
    if(!V.empty())out << "[";
    for(int i = 0; i < sz(V); i++)out << V[i] << (i+1==sz(V)?"]":", ");
    return out;
}

int main(){
    ios_base::sync_with_stdio(false);
    long long A[10][10] {}, N, res = 0;
    memset(A,0,sizeof A);
    cin >> N;
    for(int i = 1; i <= N; i++){
        int l = i%10, f = i;
        while(f>=10)f/=10;
        A[f][l] += 1;
    }
    for(int i = 1; i <= N; i++){
        int l = i%10, f = i;
        while(f>=10)f/=10;
        res+=A[l][f];
    }
    cout << res << endl;
} 

Measured memory_bytes: 256
#
# File    : C.rb
# Author  : Kazune Takahashi
# Created : 2/16/2019, 9:04:43 PM
# Powered by Visual Studio Code
#

n = gets.to_i
a = gets.chomp.split(" ").map{|i| i.to_i}
ans = a[0]
a.each{|x|
  ans = ans.gcd(x)
}
puts ans



Measured memory_bytes: 9476
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
int i[100000];
int u[100000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s[100],w;
  cin >>a;
  for(int n=0;n<a;n++){
    cin >>s[n]>>i[n];
  }
  cin >>w;
  bool an=false;
  lol ans=0;
  for(int n=0;n<a;n++){
    if(an) ans+=i[n];
    if(w==s[n]) an=true;
  }
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vll = vector<vl>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
ll n;
vll act;
int main() {
	cin >> n;
	act.resize(n, vl(3));
	REP(i, n){
		REP(j, 3){
			cin >> act[i][j];
		}
	}
	vll dp(n+1, vl(3, 0));
	REP(i, n){
		REP(j, 3){
			dp[i+1][j] = max(dp[i][(j+1)%3] + act[i][(j+1)%3], dp[i][(j+2)%3] + act[i][(j+2)%3]);
		}
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
	return 0;
}


Measured memory_bytes: 14060
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0){
      break;
    }
    vector<int> D(N), P(N);
    for (int i = 0; i < N; i++){
      cin >> D[i] >> P[i];
    }
    vector<int> sum(11, 0);
    for (int i = 0; i < N; i++){
      sum[P[i]] += D[i];
    }
    for (int i = 10; i >= 0; i--){
      int d = min(sum[i], M);
      sum[i] -= d;
      M -= d;
    }
    long long ans = 0;
    for (int i = 0; i <= 10; i++){
      ans += sum[i] * i;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3068
S = input()
ans = 0

def check(s):
    for i in s:
        if not i in ['A', 'G', 'T', 'C']:
            return False
    return True

for l in range(len(S)):
    for i in range(len(S)-l+1):
        sub = S[i:i+l+1]
        
        if not check(sub):
            continue
        ans = max(len(sub), ans)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){
			int[] a = new int[10];
			int[] b = new int[10];
			
			for(int n = 1; n < 16 ; n <<= 1){
				a[sc.nextInt()] = n;
			}
			for(int n = 1; n < 16 ; n <<= 1){
				b[sc.nextInt()] = n;
			}
			
			int counthits = 0; int countblows = 0;
			
			for(int i = 0; i < a.length; i++){
				if ((a[i] & b[i]) != 0){
					counthits++;
				}else if ((a[i] * b[i] != 0)){
					countblows++;
				}
			}
			System.out.println(counthits + " " + countblows);
		}
		sc.close();
	}
}

Measured memory_bytes: 18128
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int X, Y;
    cin >> X >> Y;
    for (int i = 0; i < X + 1; i++){
        if (i * 2 + (X - i) * 4 == Y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 1;
        long lastAns = 1;
        boolean over = false;
        for (int i = 0; i < n; i++) {
            long v = sc.nextLong();
            if (v == 0) {
                System.out.println(0);
                return;
            }
            ans *= v;
            if (lastAns > ans || ans > 1000000000000000000L) {
                over = true;
            }
            lastAns = ans;
        }
        System.out.println(over ? -1 : ans);
    }
}

Measured memory_bytes: 59608
n = int(input()) 
  
data = []
p, q, r = (0, 0, 0)
for _ in range(n):
    (l, m, n) = map(int, input().split())
    data.append([l, m, n])
    if n:
        p = l
        q = m
        r = n
 
 
for x in range(101):
    for y in range(101):
        h = r + abs(p - x) + abs(q - y)
        if all(c == max(h - abs(a - x) - abs(b - y), 0) for a, b, c in data):
            print("{} {} {}".format(x, y, h))
            exit(0)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main()
{
	ll N;
	cin >> N;
	ll a[100000];
	map<ll, ll> mp;
	for (ll i = 0; i < N; i++)
	{
		ll t;
		cin >> t;
		mp[t]++;
	}

	ll count = 0;
	for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++)
	{
		if (it->second >= it->first)
		{
			count += (it->second - it->first);
		}
		else {
			count += it->second;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 6272
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std; 

int n,t,k;
char c[1000005];
ll ans=0;

int main(void){
	scanf("%d",&n);
	scanf("%s",c);
	int ss=0; 
	scanf("%d",&t);
	while(t--){
		scanf("%d",&k);
		ans=0ll;
		ll front=0ll,m=0ll,d=0ll;
		for(int i=0;i<n;i++){
			if(c[i]=='C')ans+=front;
			if(c[i]=='D')d++;
			if(c[i]=='M'){
				m++;
				front+=d;
			}
			if(k-1<=i){
				if(c[i-k+1]=='M')m--;
				if(c[i-k+1]=='D'){
					d--;
					front-=m;
				} 
			}
		} 
		printf("%lld\n",ans);
	}
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int count = 0;
    for(int i=0;i<n-2;i++){
        if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C'){
            count++;
        }
    }
    cout << count << endl;
}

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

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

    int m;
    if(n % 2 == 1) m = n * (n-1) / 2 - (n-1) / 2;
    if(n % 2 == 0) m = n * (n-2) / 2;

    int x;
    if(n % 2 == 1) x = n;
    if(n % 2 == 0) x = n + 1;

    cout << m << endl;
    for(int a=1; a<=n; a++){
        for(int b=a+1; b<=n; b++){
            if(a + b == x) continue;
            cout << a << " " << b << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3516
#include <iostream>
using namespace std;
int main()
{
    int N, K;
    int *x;
    int sum = 0;
    cin >> N;
    cin >> K;
    x = new int[N];
    for(int i = 0;i < N;i++)
    {
        cin >> x[i];
    }
    for (int i = 0; i < N; i++)
    {
        //Aのほうが近い
        if(x[i] - 0 < K - x[i])
        {
            sum += x[i] * 2;
        }
        else
        {
            sum += (K - x[i]) * 2;
        }
    }

    cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

bool dream(string& s){
    reverse(begin(s), end(s));
    int i = 0;
    while(i != s.size()){
        string u;
        u = s.substr(i, 5);
        if(u == "maerd" || u == "esare"){
            i += 5;
            continue;
        }
        u = s.substr(i, 6);
        if(u == "resare"){
            i += 6;
            continue;
        }
        u = s.substr(i, 7);
        if(u == "remaerd"){
            i += 7;
            continue;
        }
        return false;
    }
    return true;
}

string solve(string& s){
    return dream(s) ? "YES" : "NO";
}


int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    cout << solve(s) << endl;

    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll y,m,d;
  ll base = 999 * 39 * 5 + 333 * 5 + 1;
  rep(i,n){
    cin >> y >> m >> d;
    ll date = 0;
    date += 39 * 5 * (y-1) + ((y-1) / 3) * 5;
    if(y % 3){
      rep(i,m-1){
        date += (i % 2)? 19:20;
      }
    }
    else{
      date += (m-1)*20 ;
    }
    date += d;
    cout << base - date<<endl;
  }
  return 0;
}

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

using namespace std;

const int N = 1e5 + 7;

int n, m;
int p[N];
long long cnt;
long long sz[N];

int get(int v) {
    if (v == p[v]) return v;
    return p[v] = get(p[v]);
}

void merge(int a, int b) {
    if (get(a) != get(b)) {
        if (sz[get(a)] < sz[get(b)]) swap(a, b);
        cnt -= sz[get(a)] * 1LL * sz[get(b)];
        sz[get(a)] += sz[get(b)];
        p[get(b)] = get(a);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    vector <pair <int, int> > e;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        e.push_back({u, v});
    }
    reverse(e.begin(), e.end());
    for (int i = 1; i <= n; i++) {
        p[i] = i;
        sz[i] = 1;
    }
    cnt = n * 1LL * (n - 1) / 2;
    vector <long long> ans;
    for (int i = 0; i < m; i++) {
        ans.push_back(cnt);
        merge(e[i].first, e[i].second);
    }
    reverse(ans.begin(), ans.end());
    for (long long x : ans) {
        cout << x << '\n';
    }
    return 0;
}


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

main(){
    string str;//3文字以上の文字列
    //長さを考えて、2引く＆頭とケツ
    int length;

    cin >> str;

    length = str.size();
    cout << str.at(0) << length-2 << str.at(length - 1) << endl;
    return 0;  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
	public static long factorial(long x){
		for(long i = x - 1; i >= 2; i--){
			x = x * i % 1000000007;
		}
		
		return x;
	}
	
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		
		// input
		long dog = scan.nextLong();
		long monkey = scan.nextLong();
		
		// search
		long answer = 0;
		if(dog == monkey){
			answer = factorial(dog) * factorial(monkey) * 2 % 1000000007;
		} else if (Math.abs(dog - monkey) == 1){
			answer = factorial(dog) * factorial(monkey) % 1000000007;
		} else {
			answer = 0;
		}
		
		// answer
		System.out.println(answer);
		
	}
}

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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c&&b!=c)
		cout<<c;
	if(a==c&&a!=b&&c!=b)
		cout<<b;
	if(b==c&&b!=a&&c!=a)
		cout<<a;

	return 0;
}

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

typedef long long ll;
const int mod = 1e9+7;
const int ncrc = 200000;
int f[ncrc];
ll POW(ll x,ll y) {
	ll res = 1LL;
	while (y > 0) {
		if (y & 1) res = res * x % mod;
		x = x*x % mod;
		y >>= 1;
	}
	return res;
}

ll inv(ll x) {
	return POW(x,mod-2) % mod;
}

ll ncr(ll n,ll r) {
	return (((f[n] * inv(f[r]) % mod) * inv(f[n-r])) % mod);
}

void ncr_init() {
	f[0] = 1;f[1] = 1;
	for (ll i = 2;i < ncrc;i++) {f[i] = (i * f[i-1]) % mod;}
}
 
int main() {
	ncr_init();
	ll n;
	ll m;
	ll ans = 1;
	cin >> n >> m;
	ll wal = 2;
	ll cp = m;
	ll cnt = 0;
	vector<ll> so;
	queue<ll> que;
	while (wal * wal <= m) {
		if (cp%wal==0) {cp/=wal;cnt++;}
		else {if (cnt != 0) {so.push_back(cnt);}wal++;cnt = 0;}
	}
	if (cp != 1) {
		so.push_back(1);
	}
	ll xx = 1;
	for (int i = 0;i < so.size();i++) {
		xx = ncr(so[i]+n-1,n-1);
		ans = (ans*xx)%mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;

signed main() {
    int N, M;
    cin >> N >> M;
    
    if(N==1 && M==1) cout << 1;
    else if(N==1) cout << M-2;
    else if(M==1) cout << N-2;
    else cout << (N-2)*(M-2);
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt(), m = sc.nextInt();
        int[][] a = new int[m][4];

        for (int i = 0; i < m; i++) {
            a[i][0] = i;
            a[i][1] = sc.nextInt(); // city
            a[i][2] = sc.nextInt(); // year
        }

        sortYear(a);
        String[] ans = new String[m];
        int[] count = new int[n + 1];
        for (int i = 0; i < m; i++) {
            count[a[i][1]]++;
            ans[a[i][0]] = String.format("%06d", a[i][1]) + String.format("%06d", count[a[i][1]]);
        }

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < m; i++) {
            sb.append(ans[i]).append("\n");
        }
        System.out.print(sb);
    }

    static void sortYear(int[][] array) {
        Arrays.sort(array, Comparator.comparingInt(a -> a[2]));
    }
}


Measured memory_bytes: 168648
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int a[] = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };
	int x, y; cin >> x >> y;
	cout << (a[x] == a[y] ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
using namespace std;

//***********************************************************************

// hash struct for unordered_map
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************
ll mod=1000000007;
void solve()
{
    ll n;
    cin >> n;
    vector<ll> v(n);
    for(int i=0;i<n;i++)
    cin >> v[i];
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    ll ans=v[0];
    int i=1;
    n=n-2;
    while(n)
    {
        ans+=v[i];
        n--;
        if(n)
        {
            ans+=v[i];
            n--;
            i++;
        }
    }
    cout << ans  << endl;
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 4764
use std::io::Read;
use std::collections::HashSet;

fn main() {
    let (a, b, c) = {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        let a: usize = iter.next().unwrap().parse().unwrap();
        let b: usize = iter.next().unwrap().parse().unwrap();
        let c: usize = iter.next().unwrap().parse().unwrap();
        (a, b, c)
    };
    let h: HashSet<usize> = vec![a, b, c].into_iter().collect();
    print!("{}", h.len());
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    if (a==b && a==c) cout<<1<<endl;
    else if ((a!=b) && (a!=c) && (b!=c)) cout<<3<<endl;
    else cout<<2<<endl;
    return 0;
}

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

typedef struct scedule
{
	long int A;
	long int B;
} scedule_t;

int cmp(const void *p, const void *q)
{
	int r = ((scedule_t *)p)->B - ((scedule_t *)q)->B;
	if (r != 0)
		return r;
	return ((scedule_t *)p)->A - ((scedule_t *)q)->A;
}

int main()
{
	long int N;

	cin >> N;

	scedule_t T[N];

	for (int i = 0; i < N; i++)
	{
		cin >> T[i].A >> T[i].B;
	}

	qsort(T, N, sizeof(scedule_t), cmp);

	long int time_count = 0;
	long int shimekiri;

	for (long int i = 0; i < N; i++)
	{
		time_count += T[i].A;
		shimekiri = T[i].B;

		if (time_count > shimekiri)
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	/*
	cout << "----------------" << endl;

	for (int i = 1; i <= N; i++)
	{
		cout << T[i].A << " " << T[i].B << endl;
	}
	*/

	return 0;
}


Measured memory_bytes: 6524
#include <iostream>
using namespace std;
int main(void){
    int X;
    int ans;
    cin >> X;
    
    if(X <= 599)ans = 8;
    else if(X <= 799)ans = 7;
    else if(X <= 999)ans = 6;
    else if(X <= 1199)ans = 5;
    else if(X <= 1399)ans = 4;
    else if(X <= 1599)ans = 3;
    else if(X <= 1799)ans = 2;
    else ans = 1;
    
    cout << ans << endl;
}


Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest,t;
  l=2*i;
  r=2*i+1;
  if(l<=H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r<=H && A[r] > A[largest]) largest = r;
  if(largest != i){
    t=A[i];
    A[i]=A[largest];
    A[largest]=t;
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H<1) return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  int k;
  if(key < A[i]) return;
  A[i] = key;
  while(i>1 && A[i/2]<A[i]){
    k=A[i];
    A[i]=A[i/2];
    A[i/2]=k;
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H] = -INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0] == 'e' && com[1] == 'n') break;
    if(com[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else{
      printf("%d\n",extract());
    }
  }

  return 0;
}



Measured memory_bytes: 5592
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#define ll long long
using namespace std;
ll a[200006];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        memset(a,0,sizeof(a));
        for(int i=0;i<n;i++)
            scanf("%lld",&a[i]);
        int r=0;
        ll sum1=0,sum2=0,sum=0;
        for(int i=0;i<n;i++)
        {
            while((sum1^a[r])==(a[r]+sum2)&&r<n)
            {
                sum1^=a[r];
                sum2+=a[r++];
            }
            sum+=(r-i);
            sum1^=a[i];
            sum2-=a[i];
        }
        printf("%lld\n",sum);
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int zzy = 1000000007;
char s[100010];
int flag;
int n;
int nxt[100010][3], dp[100010], sum[100010];
int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    for (int i = 2; i <= n; i++) if(s[i] == s[i - 1]) flag = 1;
    if (!flag) return puts("1"), 0;
    for (int i = 1; i <= n; i++) sum[i] = (sum[i - 1] + (s[i] == 'a' ? 1 : 2)) % 3;
    memset(nxt[n + 1], -1, sizeof nxt[n + 1]);
    for (int i = n; i >= 0; i--) {
        memcpy(nxt[i], nxt[i + 1], sizeof nxt[i]);
        if (i) nxt[i][sum[i]] = i;
    }
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        if (sum[i] != 0 && ~nxt[i][0]) dp[nxt[i][0]] = (dp[nxt[i][0]] + dp[i]) % zzy;
        if (sum[i] != 1 && ~nxt[i][1]) dp[nxt[i][1]] = (dp[nxt[i][1]] + dp[i]) % zzy;
        if (sum[i] != 2 && ~nxt[i][2]) dp[nxt[i][2]] = (dp[nxt[i][2]] + dp[i]) % zzy;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (sum[i] == sum[n]) ans = (ans + dp[i]) % zzy;
    }
    return cout << ans << endl, 0;
}

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

class pd {
public:
    pd(int N, vector<int> vecN) {
        m_vecN = vecN;
        m_N = N;
        m_digits = vector<int>(N+1, -100000);
        for (size_t i = 0; i <= N; i++)
        {
            initialise(i);
        }
    }
    int get(int N) {
        if (N < 0)
            return -100000;
        else
            return m_digits[N];
    }
private:
    void initialise(int i) {
        if (i == 0)
            m_digits[i] = 0;
        else {
            for (auto n : m_vecN) {
                int temp = get(i - n) + 1;
                if (temp > m_digits[i])
                    m_digits[i] = temp;
            }
        }
    }


    int m_N;
    vector<int> m_vecN;
    vector<int> m_digits;
};


int main() {
    int N, M;
    cin >> N >> M;
    vector<int> vecA;

    for (int i = 0; i < M; ++i) {
        int a;
        cin >> a;
        vecA.push_back(a);
    }
    sort(vecA.begin(), vecA.end(), greater<int>());
    vector<int> nMatches = { 2,5,5,4,5,6,3,7,6 };
    vector<int> vecN;
    for (auto a : vecA) {
        vecN.push_back(nMatches[a-1]);
    }
    pd digits(N, vecN);
    string ret = "";
    int max_digits = digits.get(N);
    for (size_t i = max_digits; i > 0; --i)
    {
        for (size_t j = 0;  j < vecA.size();  j++)
        {
            if (digits.get(N) == digits.get(N - vecN[j]) + 1) {
                ret += to_string(vecA[j]);
                N -= vecN[j];
                break;
            }
        }
    }
    cout << ret << endl;

    //system("pause");

    return 0;
}


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

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

    int n;
    cin >> n;
    int o=0, e=0;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(a&1)e++;
        
    }
    if(e%2==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}



Measured memory_bytes: 3616
n,m = gets.split.map!(&:to_i)

road = Array.new(n+1).map!{[]}
m.times do
    a,b = gets.split.map!(&:to_i)
    road[a] << b
    road[b] << a
end

root = [[1]]
ans = 0
while x = root.shift do
    l = x.last

    road[l].each do |y|
        if x.include?(y)

            if (x.size == n)
                ans += 1
                break
            end
            
        else
            root << (x + [y])
        end
    end
    #p root
end

puts ans

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

struct node {
    int a, b, c, d;
}nd[100];
int n, m, q, arr[100], ans;

void dfs(int loc, int val) {
    if (loc == n+1) {
        int res = 0;
        forn(i, q) {
            if (arr[nd[i].b]-arr[nd[i].a] == nd[i].c) res += nd[i].d;
        }
        ans = max(ans, res);
        return;
    }
    for (int i = val; i <= m; ++i) {
        arr[loc] = i;
        dfs(loc+1, i);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    ans = 0;
    cin >> n >> m >> q;
    forn(i, q) {
        cin >> nd[i].a >> nd[i].b >> nd[i].c >> nd[i].d;
    }
    dfs(1, 1);
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a;
    map<ll,ll> mp;
    multiset<ll> ms;
    ll x;
    rep(i,n){
        cin>>x;
        ms.insert(x);
        
    }
    ll ans=0;
    rep(i,m){
        auto itr = ms.rbegin();
        ms.insert((*itr)>>1);
        ms.erase(ms.find(*itr));
    }
    for(auto itr = ms.begin(); itr != ms.end(); ++itr) {
        ans+=*itr;
    }
    
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;

    cout << (1000 - N%1000) % 1000 << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>

using namespace std;

int main() {

	int n, a; 
	cin >> n >> a;

	int tmp = n % 500;

	if (tmp <= a) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
      int n,x;
      cin>>n;
      for(int i=1;i<=n;i++){
            x=i;
            if(x%3==0){
                  cout <<" "<<i;
            }
            else
            while(x){
            if(x%10==3){
                  cout <<" "<<i;
                  break;
                  }
                  x/=10;
            }
      }
      cout << endl;
      return 0;
}


Measured memory_bytes: 3108
def combi(n,k)
  k=n-k if 2*k > n
  return 1 if k == 0
  ((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end
require 'prime'
N,M=gets.split.map &:to_i
f=M.prime_division
c=1
f.each{|x|
  c*=combi(x[1]+N-1,N-1)
  c=c%(10**9+7)
}
p c

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

int main(){
	int h,w,dp[51][51];
	string s[51];

	cin >> h >> w;
	for(int i=0 ; i<h ; i++ ){
		cin >> s[i];
	}
	for(int y=0 ; y<h ; y++ ){
		for(int x=0 ; x<w ; x++ ){
			dp[y][x] = 10000;
		}
	}
	dp[0][0] = 0;
	for(int y=0 ; y<h ; y++ ){
		for(int x=0 ; x<w ; x++ ){
			if( y != 0 ){
				dp[y][x] = min( dp[y][x] , dp[y-1][x] + (s[y][x]-'0') );
			}
			if( x != 0 ){
				dp[y][x] = min( dp[y][x] , dp[y][x-1] + (s[y][x]-'0') );
			}
		}
	}
	cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 0
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#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
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;
// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

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

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

  vector<pair<int, int>> p(M);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
	a--;
	b--;
    p.at(i) = make_pair(a,b);
  }
  vector<int> cnt(N);
  rep(i,N){
	  rep(j,M){
		  if(i == p[j].first){
			  cnt[i]++;
		  }
		  if(i == p[j].second){
			  cnt[i]++;
		  }
	  }
  }
  rep(i,N){
	  cout << cnt[i] << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

struct Point {
  double x, y;
};

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

void koch(int n, Point a, Point b) {
  if (n == 0)
    return;
  Point s, t, u;
  double th = PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

int main(int argc, char const *argv[]) {
  Point a, b;
  int n;

  cin >> n;

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);
  return 0;
}



Measured memory_bytes: 3128
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	if K == 1 {
		fmt.Println(0)
		return
	}
	x := N
	min := math.MaxInt64
	for i := 0; i < 1000000; i++ {
		x = Min(x%K, Abs(x-K))
		min = Min(min, x)
	}
	fmt.Println(min)
}
func Min(a, b int) int {
	if b < a {
		return b
	}
	return a
}
func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

Measured memory_bytes: 512
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let (n, k) = input!(usize, i64);
    let mut vec: Vec<(i64, i64)> = Vec::with_capacity(n);
    for _ in 0..n {
        vec.push(input!(i64, i64));
    }

    let mut counter: i64 = 0;
    vec.sort_by_key(|pair| pair.0);
    for pair in vec.iter() {
        counter += pair.1;
        if counter >= k {
            println!("{}", pair.0);
            break;
        }
    }
}


Measured memory_bytes: 6396
Sd = input()
T  = input()

S_r = Sd[::-1]
T_r = T[::-1]

lenS = len(Sd)
lenT = len(T)

Flag2 = True

if lenS < lenT:
    pass
else:
    for i in range(lenS - lenT + 1):
        for j in range(lenT):
            Flag1 = True
            if S_r[i+j] == "?" or S_r[i+j] == T_r[j]:
                pass
            else:
                Flag1 =False
                break
        if Flag1:
            Flag2 = False
            S_r = S_r.replace(S_r[i:i+lenT],T_r,1)
            S_r = S_r.replace("?","a")
            ans = S_r[::-1]
            break

if Flag2:
    ans = "UNRESTORABLE"
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
    for(int i=0;i<n;i++){
    cin>>b[i];
      ans+=b[i];
  }
    for(int i=0;i<n-1;i++){
    cin>>c[i];
  }

  for(int i=0;i<n-1;i++){
    if(a[i]+1==a[i+1]){
      ans+=c[a[i]-1];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
 int n;
scanf("%d",&n);
 
  if(n==1)
   printf("1");
  else if(n==2||n==3)
   printf("2");
   else if(4<=n&&n<=7)
   printf("4");
  else if(8<=n&&n<15)
   printf("8");
  else if(16<=n&&n<=31)
   printf("16");
  else if(32<=n&&n<=63)
   printf("32");
  else if(64<=n&&n<=100)
   printf("64");
 
  return 0;
}
    

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//AtCoder以外ではコメントアウトを忘れずに！
//#include <atcoder/all>
//using namespace atcoder;
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path; vs S;
int main() {
	cin >> X;
	if (X == 1) cout << 0;
	else cout << 1;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
const int MAX = 100005;
bool is_prime[MAX] = {};

template<class T>
struct FT{
    vector<T> d;
    FT(size_t n):d(n+1){}
    T sum(size_t i){T s{};for(++i;i>0;i-=i&-i)s+=d[i];return s;}
    T sum(size_t i,size_t j){return i?sum(j)-sum(i-1):sum(j);}
    void add(size_t i,T x){for(++i;i<d.size();i+=i&-i)d[i]+=x;}
};

FT<int> ft(MAX);

int main(){
  rep(i,MAX)  is_prime[i] = 1;
  is_prime[0] = is_prime[1] = 0;
  rep(i,MAX){
    if(is_prime[i])
      for(int j = i + i; j < MAX; j += i)
        is_prime[j] = 0;
  }
  int q; cin >> q;
  rep(i,MAX){
    if(i%2 && is_prime[i] && is_prime[(i+1)/2])  ft.add(i,1);
  }
  while(q--){
    int l,r; cin >> l >> r;
    cout << ft.sum(l,r) << endl;
  }
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int H, W;
	cin >> H >> W;
	vector<string> C(H);
	REP(i, H) cin >> C[i];
	REP(i, 2 * H) cout << C[i / 2] << "\n";

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
using ll = long long;
 
// DAG - directed acyclic graph
 
const int nax = 1e5 + 5;
vector<int> edges[nax];
int in_degree[nax]; // the number of edges going to 'b'
int dist[nax];
bool visited[nax];
 
void dfs(int a) {
    assert(!visited[a]);
    visited[a] = true;
    for(int b : edges[a]) {
        dist[b] = max(dist[b], dist[a] + 1);
        --in_degree[b];
        if(in_degree[b] == 0) {
            dfs(b);
        }
    }
}
 
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    while(m--) {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].push_back(b);
        ++in_degree[b];
    }
    for(int i = 1; i <= n; ++i) {
        if(!visited[i] && in_degree[i] == 0) {
            dfs(i);
        }
    }
    int answer = 0;
    for(int i = 1; i <= n; ++i) {
        answer = max(answer, dist[i]);
    }
    printf("%d\n", answer);
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  ll a, b, c;
  cin >> a >> b >> c;
  // 2√(ab) < c-a-b 
  // 2 乗
  cout << (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long int n, m;
    long long int i, j;
    cin>>n>>m;
    long long int w[n+10],v[n+10],f[n+10][m+10];
	for(long long int i=1; i<=n; i++)
    {
        cin>>w[i]>>v[i];
    }
    for (i = 0; i<= n; i++)
        f[i][0]=0;

    for (j = 0;j <= m; j++)
        f[0][j]=0;
    for (i = 1;i<=n;i++)
    {
        for (j = 1; j <= m; j++ )
            if ( w[i] > j)
            {
                f[i][j] = f[i-1][j];
            }
            else
            {
                f[i][j] = max((f[i-1][ j-w[i] ]+v[i]),(f[i-1][j] ));
            }
    }
    cout<<f[n][m]<<endl;
}


Measured memory_bytes: 80896
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
int main(){
    int N;
    cin>>N;
    multimap<long long ,long long >task={};
    
    long long time=0;
    long long x,y;
    for(int i=0;i<N;i++){
            cin >> x>>y;
            task.insert(make_pair(y,x));
    }
    
int answer=0;

    for(auto iter=task.begin();iter !=task.end();++iter){
       
           if((iter->first)-time>=(iter->second)) {
               time+=iter->second;
           }
           else{
               answer=-1;
               break;
           }
    }
    if(answer==0){
    cout << "Yes" <<endl;
    }
    else{
        cout <<"No"<<endl;
    }

 return 0;
}

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

int balls[10];

bool dfs(int left, int right, int currentID){
	if(currentID > 9) return true;
	
	bool ok = false;
	if (left < balls[currentID]){
		ok = dfs(balls[currentID], right, currentID+1);
	}
	if (right < balls[currentID]){
		ok = dfs(left, balls[currentID], currentID+1);
	}
	return ok;
}

int main() {
	int n; cin >> n;
	
	while(n--){
		for (int i = 0; i < 10; i++) cin >> balls[i];
		cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 3072