akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            var C = int.Parse(Console.ReadLine());
            var D = int.Parse(Console.ReadLine());

            Console.WriteLine(Math.Min(A, B) + Math.Min(C, D));
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
int a[1000005];
int main (void)
{
    int x,y,z,n,i;
    int t = 0;
    scanf("%d",&n);


        for (x=1; x<=100; ++x)
            for (y=1; y<=100; ++y)
                for (z=1; z<=100; ++z)
                    a[x*x+y*y+z*z+x*y+x*z+y*z]++;


    for (i=1; i<=n; ++i)
    {

     printf("%d\n",a[i]);
    }
    return 0;
}


Measured memory_bytes: 1908
void main()
{
    int[] tmp = readln.split.to!(int[]);
    int h = tmp[0], w = tmp[1];

    string[] s = new string[h];
    coord[] black;
    foreach (i; 0 .. h)
    {
        s[i] = readln.chomp;
        foreach (j, c; s[i])
        {
            if (c == '#')
            {
                black ~= coord(i, j.to!int);
            }
        }
    }

    int[] dy = [-1, 0, 1, 0], dx = [0, 1, 0, -1];
    bool ok = true;
    foreach (b; black)
    {
        bool flag;
        foreach (dir; 0 .. 4)
        {
            int y = b.y + dy[dir], x = b.x + dx[dir];
            if (y < 0 || h <= y || x < 0 || w <= x) continue;

            if (s[y][x] == '#') flag = true;
        }

        if (!flag)
        {
            ok = false;
            break;
        }
    }

    writeln(ok ? "Yes" : "No");
}

alias Tuple!(int, "y", int, "x") coord;

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int knap(  vector<vector<int > >  &dp , vector<int > &w , vector<int > &v , int curr , int W ){
    if( W<=0 || curr >= w.size() ) return 0;
    if( dp[curr][W] != 0 ) return dp[curr][W] ;
    dp[curr][W] = knap( dp , w , v , curr+1 , W );
    if( w[curr] <= W ) dp[curr][W] = max( dp[curr][W] ,v[curr]+knap(dp,w,v,curr+1,W-w[curr]) );
    return dp[curr][W];
}
#undef int
int main(){
    #define int long long
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n ,W; cin>>n>>W;
    if( n == 0 ){
    	cout << "0" << endl;
        return 0;
    }
    vector<int > w(n);
    vector<int > v(n);
    for(int i=0;i<n;i++)
        cin>> w[i] >> v[i] ;
    vector<vector<int > > dp(n,vector<int > (W+1));
    
    cout << knap(dp,w,v,0,W) << endl;
    return 0;
	
}

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

int main()
{
    double l;
    cin >> l;
    double x = l / 3;
    double ans = pow(x, 3);
    printf("%.12f\n", ans);
    return 0;
}

Measured memory_bytes: 4212
import itertools
import math
import fractions
import functools

n, m, x = map(int, input().split())
c = []
a = []
for i in range(n):
    l = list(map(int, input().split()))
    c.append(l[0])
    a.append(l[1:])

minimum = 10**10
for i in range(2**n):
    cost = 0
    rikaido = [0]*m
    ok = True
    for j in range(n):
        if i >> j & 1:
            cost += c[j]
            for index in range(m):
                rikaido[index] += a[j][index]
    for k in range(m):
        if rikaido[k] < x:
            ok = False
    if ok:
        minimum = min(minimum, cost)

if minimum == 10**10:
    print(-1)
else:
    print(minimum)


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

const int mod = 1e9 + 7;

int pref[300005];
int get_sum(int l, int r) {
 if (l == 0) {
    return pref[r];
 }
 else {
    return pref[r] - pref[l - 1];
 }
}

int32_t main() {
 int n, k;
 cin >> n >> k;
 n++;
 for (int i = 1; i <= n; i++) {
    pref[i] = pref[i - 1] + i;
 }
 int ans = 0;
 for (int i = k; i <= n; i++) {
    ans += get_sum(n - i + 1, n) - get_sum(0, i) + 1;
    ans %= mod;
 }
 cout << ans;
 return 0;
}


Measured memory_bytes: 5152
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    double money = 0;

    FOR(i, 0, N){
        double x;
        string u;
        cin >> x >> u;
        if(u=="JPY"){
            money += x;
        }else{
            money += 380000 * x;
        }
    }

    cout << setprecision(15);
    p(money);
    
    return 0;
}

Measured memory_bytes: 256
N=int(input())
num_list = [int(input()) for i in range(5)]

min_num=min(num_list)

if N < min_num :
  print(5)
else:
  if min_num==1:
    count=int(N//min_num)-1
  else:
    count=int(N//min_num)
  print(5+count)

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

int main()
{
    int N; cin>>N;
    string s; cin>>s;

    const int MAX=10;
    vector<vector<int>> pos(MAX);
    for(int i=0;i<N;i++) pos[s[i]-'0'].push_back(i);
    for(int i=0;i<MAX;i++) pos[i].push_back(N);

    int ans=0;
    for(int i=0;i<MAX;i++) for(int j=0;j<MAX;j++) for(int k=0;k<MAX;k++){
        int idx=pos[i][0];
        if(idx<N) idx=*upper_bound(pos[j].begin(),pos[j].end(),idx);
        if(idx<N) idx=*upper_bound(pos[k].begin(),pos[k].end(),idx);
        if(idx<N) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto I = readln.split.to!(long[]);
  auto N = I[0];
  auto K = I[1];

  long solve() {
    long ketasu = 1;
    for(auto i = K; N >= i; i *= K) {
      ketasu++;
    }

    return ketasu;
  }

  solve().writeln;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
bool prime[123456];
int sum[123456];
int main(){
    rep(i,100001)prime[i] = true;
    prime[0] = prime[1] = false;
    for(int i = 2; i <=100000; i++){
        if(prime[i]){
            for(int j = i; (ll)j*i <= 100000; j++){
                prime[j*i] = false;
            }
        }
    }
    rep(i,100005)if(i%2 and prime[i] and prime[(i+1)/2])sum[i]++;
    rep(i,100004)sum[i+1] += sum[i];
    int q;
    cin >> q;
    while(q--){
        int l,r;
        cin >> l >> r;
        cout << sum[r] -sum[l-1] << endl;
    }
}

Measured memory_bytes: 1152
LMIIS = lambda: list(map(int,input().split()))
X,Y,*e = LMIIS()
P = LMIIS()
Q = LMIIS()
R = LMIIS()
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
print(sum(sorted(P[:X]+Q[:Y]+R,reverse=True)[:X+Y]))

Measured memory_bytes: 114412
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n+1)

    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)

        if x == y:
            return False
        if self.Size(x) < self.Size(y):
            x, y = y, x
        self.root[x] += self.root[y]
        self.root[y] = x

        return True

    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    def Size(self, x):
        return -self.root[self.Find_Root(x)]

N, M = map(int, input().split())
X = [0] * M
Y = [0] * M
Z = [0] * M
for i in range(M):
    X[i], Y[i], Z[i] = map(int, input().split())

Uni = UnionFind(N)

for i in range(M):
    Uni.Unite(X[i], Y[i])

roots = set()
cnt = 0
for i in range(1, N+1):
    r = Uni.Find_Root(i)
    if r not in roots:
        cnt += 1
        roots.add(r)

print(cnt)

Measured memory_bytes: 21444
#include <iostream>
#include <string>
#include <algorithm>


using namespace std;

int main(void) {
	int N, K, h[100000], count = 0;

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		if (h[i] >= K) {
			count++;
		}
	}

	printf("%d", count);
	
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1000000007;

int main()
{
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  vector<ll> a(N + 1, 0), b(N + 2, 0);
  a[0] = N + 1;
  b[1] = a[0];
  for (int i = 1; i < N + 1; ++i)
  {
    a[i] = (a[i - 1] - i + N - i + MOD) % MOD;
    b[i + 1] = (b[i] + a[i]) % MOD;
  }
  cout << (b[N + 1] - b[K - 1] + MOD) % MOD << endl;

  return 0;
}


Measured memory_bytes: 5868
#include<iostream>
#include<algorithm>

using namespace std;

// Problem https://atcoder.jp/contests/abc070/tasks/abc070_b
// Reference https://atcoder.jp/contests/abc070/submissions/1798711
// Reference https://img.atcoder.jp/abc070/editorial.pdf

int main(void){
    int A,B,C,D;
    int answer;
    cin >> A >> B >> C >> D;
    int banddmin = min(B,D);
    int aandcmax = max(A,C);
    int difftime = banddmin-aandcmax;
    if(0 < difftime){
        answer = difftime;
    }
    else{
        answer = 0;
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int wa(int a);
int main(void){
    // Your code here!
    int n,a,b;cin>>n>>a>>b;
    long long int sum=0;
    
    for(int i=1;i<=n;i++)
    {
        int w=wa(i);
        if (a<=w && b>=w)
        {
            //cout<<i<<':'<<w<<'\n';
            sum+=i;
            
        }
        
    }
    cout<<sum;
    return 0;
    
    
}
int wa(const int a)
{
    if (a == 10000)
    {
        return 1;
    }
    int z1=a/1000;
    int z2=a/100-z1*10;
    int z3=a/10 -z1*100 - z2*10;
    int z4=a-z1*1000-z2*100-z3*10;
    
    return z1+z2+z3+z4;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		for(int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();
		int sum = h[0];
		for(int i = 0; i < N - 1; i++) {
			sum += Math.max(0, h[i + 1] - h[i]);
		}
		System.out.println(sum);
	}
}

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

using vp = std::vector<std::pair<int, bool>>;

int N;
std::vector<vp> x;

bool able(int);

int main()
{
	scanf("%d", &N);
	x.resize(N);
	for (auto& e: x)
	{
		int A;
		scanf("%d", &A);
		e.resize(A);
		for (auto& f: e)
		{
			int tmp;
			scanf("%d%d", &f.first, &tmp);
			f.first--;
			f.second = tmp == 1;
		}
	}
	int max{};
	for (int i{}; i < 1 << N; i++)
		if (able(i))
		{
			int num{};
			for (int j{}; j < N; j++)
				if (i >> j & 1)
					num++;
			max = std::max(max, num);
		}
	printf("%d\n", max);

	return 0;
}

bool able(int set)
{
	for (int i{}; i < N; i++)
	{
		if (~set >> i & 1) continue;
		for (auto& e: x[i])
			if ((set >> e.first & 1) && !e.second)
				return false;
			else if ((~set >> e.first & 1) && e.second)
				return false;
	}
	return true;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
n1=[]
if a<=0 and b>=0:
    n1.append(0)
elif c<=0 and d>=0:
    n1.append(0)
n1.append(a*c)
n1.append(a*d)
n1.append(b*c)
n1.append(b*d)
print(max(n1))


Measured memory_bytes: 9076
#include<stdio.h>
#include<string.h>
void replace(char *str,int a,int b,char *p)
{
  int i,count=0;
  for(i=a;i<=b;i++)
  {
    str[i]=p[count];
    count++;
  }
}
void reverse(char *str,int a,int b)
{
  int i,c;
  char tmp;
  while(a<b)
  {
    tmp=str[a];
    str[a]=str[b];
    str[b]=tmp;
    a++;
    b--;
  }
}
void print(char *str,int a,int b)
{
  int i;
  for(i=a;i<=b;i++) printf("%c",str[i]);
  printf("\n");
}
int main(void)
{
  char str[1000],order[10],p[1000];
  int q,i,a,b;
  //printf("str:");
  scanf("%s",str);
//  printf("q:");
  scanf("%d",&q);
  for(i=0;i<q;i++)
  {
    scanf("%s",order);
    if(strcmp(order,"replace")==0)
    {
      scanf("%d %d %s",&a,&b,p);
      replace(str,a,b,p);
    //  printf("%s\n",str);
    }
    if(strcmp(order,"reverse")==0)
    {
      scanf("%d %d",&a,&b);
      reverse(str,a,b);
  //  printf("%s\n",str);
    }
    if(strcmp(order,"print")==0)
    {
      scanf("%d %d",&a,&b);
      print(str,a,b);
    //  printf("%s\n",str);
    }

  }
  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n%2==0){
        cout << 0.5 << endl;
    }else{
        cout << fixed << setprecision(10);
        cout << (n+1.0)/2.0/n << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

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

    int con = (n-1)*(n-2)/2 - k;
    if(con < 0){
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int,int>> edges;
    FOR(i, 1, n){
        edges.push_back({0, i});
    }

    FOR(i, 1, n){
        FOR(j, i+1, n){
            if(con == 0)
                break;
            edges.push_back({i, j});
            con--;
        }
        if(con == 0)
            break;
    }

    cout << edges.size() << endl;
    for(auto t: edges){
        printf("%d %d\n", t.first+1, t.second+1);
    }


    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int n,m;
long long f[100010];
int w[110];
long long v[110];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&w[i],&v[i]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=m;j>=w[i];j--)
		{
			f[j]=max(f[j],f[j-w[i]]+v[i]);
		}
	}
	printf("%lld",f[m]);
	return 0;
} 


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int tenbou = scan.nextInt(), miti = scan.nextInt();
		int hyoukou[] = new int[tenbou];
		int kanri[] = new int[tenbou]; 
		
		int good = 0;
		
		for(int i = 0; i < tenbou; i++) {
			hyoukou[i] = scan.nextInt();
					
			
		}
		
		for(int i = 0; i < miti; i++) {
			int a = scan.nextInt(), b = scan.nextInt();
			
			if(kanri[a - 1] < hyoukou[b - 1]) {
				kanri[a - 1] = hyoukou[b - 1];
 			}
			
			if(kanri[b - 1] < hyoukou[a - 1]) {
				kanri[b - 1] = hyoukou[a - 1];
 			}
			
		}
		
		
		
		for(int i = 0; i < tenbou; i++) {
			boolean how = true;
			
			if(hyoukou[i] <= kanri[i]) {
					how = false;
					
			}
				
			if(how) good++;
			
			
			
		}
		
		System.out.println(good);
		
	}
		
		
		
}



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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int n, k, q, a, p[100001] ={};
    cin >> n >> k >> q;
    REP(i,q){
        cin >> a;
        p[a] ++;
    }
    for(int j=1; j <=n; j++){
        if(q - p[j] < k) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


//    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
 
using namespace std;
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
vector <set <int> > g;

 

int main()
{
    int n;
    cin>>n;
    int test=n/2;
    if(n%2>0)
        test++;
    cout<<test<<endl;

    return 0;   
}
 
 


Measured memory_bytes: 256
#![allow(dead_code, unused_imports, deprecated)]

use maplit::*;

use proconio::input;
use proconio::marker::*;
use proconio::fastout;

const INF: usize = 1_000_000_007;

#[fastout]
fn solve() {
  input!{
    n: usize,
    a: [usize; n - 1],
  };

  let mut cnt = hashmap!{};
  for i in &a {
    cnt.entry(i)
      .and_modify(|e| *e += 1 )
      .or_insert(1);
  }
  
  for i in 1..=n {
    if let Some(v) = cnt.get(&i) {
      println!("{}", v);
    } else {
      println!("0");
    }
  }
}

fn main() {
  std::thread::Builder::new()
    .name("big stack size".into())
    .stack_size(32 * 1024 * 1024)
    .spawn(|| {
      solve();
    })
    .unwrap()
    .join()
    .unwrap();
}

Measured memory_bytes: 10460
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        a: i64,
        b: i64,
    }
    println!("{}", max(max(a+b, a-b), a*b));
}


Measured memory_bytes: 2184
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}
ll dx[2]={1,0};
ll dy[2]={0,1};

int main(){
    IOS;
    make(ll,n);
    string s1,s2;
    fr(i,n){
        make(char,c); s1+=c;
    }
    fr(i,n){
        make(char,c); s2+=c;
    }
    if(s1==s2) cout<<"0 \n";
    else if(s1<s2){
        ll ans=1;
        while(next_permutation(s1.begin(),s1.end()) && s1!=s2){ ans++;
        }
        cout<<ans<<endl;
    }
    else{
        ll ans=1;
        while(next_permutation(s2.begin(),s2.end()) && s1!=s2){ans++; }
        cout<<ans<<endl;
    }


    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <set>
#include <queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define reps(i, s, n) for (int i = s; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repsl(i, s, n) for (ll i = s; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define readVarll(nam) ll nam; cin >> nam

ll x[20],y[20];
ll n;

ll calc1()
{
  ll ans = 0;

  return ans;
}

int main()
{
  cin >> n;
  
  if(n == 0) n = 1; else n = 0;
 
  cout << fixed << setprecision(15) << n << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int n;  cin >> n;
    int *h = new int[n+1];
    h[0] = 0;
    for (int i = 1; i <= n; i++)
        cin >> h[i];

    int *dp = new int[n+1];

    dp[1] = 0;
    dp[2] = abs(h[1]-h[2]);

    for (int i = 1; i <= n-2; i++) {
        dp[i+2] = min(dp[i]+abs(h[i]-h[i+2]), dp[i+1]+abs(h[i+1]-h[i+2]));
    }

    cout << dp[n] << endl;
    return 0;
}

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

int is_prime(int num)
{
	int i;

	if(num == 2)
		return 1;
	else if(num % 2 == 0)
		return 0;
	for(i = 3; i * i <= num; i += 2) {
		if(num % i == 0)
			return 0;
	}
	return 1;
}

int main(void) 
{
	int n, i, num, prime_num = 0;

	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		scanf("%d", &num);
		prime_num += is_prime(num);
	}
	printf("%d\n", prime_num);
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int A = scan.nextInt();
		int B = scan.nextInt();
		
		int answer = 0;
		int count = 1;
		
		while (count < B) {
			count += A - 1;
			answer++;
		}
		
		
		System.out.println(answer);
	}
}

Measured memory_bytes: 21716
import java.util.stream.LongStream;

public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		System.out.println(Main.calc(s.nextInt(), s.nextInt(), s.nextInt(),
				s.nextInt(), s.nextInt()));
	}

	public static long calc(int a, int b, int c, int x, int y) {
		return LongStream.rangeClosed(0, Math.max(x, y)).map(n -> n * 2).reduce(
				Long.MAX_VALUE,
				(res, cn) -> Math.min(Math.max(a * (x - cn / 2), 0)
						+ Math.max(b * (y - cn / 2), 0) + c * cn, res));

	}

}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n, m;
    cin >> n >> m;
    std::vector<std::vector<ll> > G(n);
    ll h[n];
    rep(i, n) {
        cin >> h[i];
    }
    ll a[m], b[m];
    rep(i, m) {
        cin >> a[i] >> b[i];
        G[a[i]-1].push_back(b[i]-1);
        G[b[i]-1].push_back(a[i]-1);
    }

    ll ans = 0;
    rep(i, n) {
        ll high = 1;
        rep(j, G[i].size()) {
            if ( h[i] <= h[G[i].at(j)] ) {
                high = 0;
            }
        }

        if ( high ) {
            ans++;
        }
    }

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


Measured memory_bytes: 11356
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    ll sum = accumulate(all(a),0LL);
    ll l = (ll)n*(n+1)/2;
    if(sum%l != 0) {
        YES(0);
        return 0;
    }
    ll r = sum/l;
    ll cnt = 0;
    rep(i,n) {
        int x = a[i],y = a[(i+1)%n];
        int d = y-x;
        // d + (n-1)*p - (r-p) = 0
        // n*p = r-d
        ll now = r-d;
        if(now%n != 0) {
            YES(0);
            return 0;
        }
        now /= n;
        if(now < 0 or now > r) {
            YES(0);
            return 0;
        }
        cnt += now;
    }
    YES(r == cnt);
}


Measured memory_bytes: 3704
import java.util.Scanner;

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

        int X = scanner.nextInt();
        int Y = scanner.nextInt();
        int Z = scanner.nextInt();

        System.out.printf("%d %d %d%n", Z, X ,Y);
    }
}


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


def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    hashTable = {}

    for i in range(M):
        if hashTable.get(P[i]) == None:
            hashTable[P[i]] = [Y[i]]
        else:
            hashTable[P[i]].append(Y[i])
    
    # Year: idnumber
    answerTable = {}

    for key,value in hashTable.items():
        value.sort()
        
        for i,v in enumerate(value):
            answerTable[v] = str(key).zfill(6) + str(i+1).zfill(6)
    
    for i in range(M):
        print(answerTable[Y[i]])

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]"
    Y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    solve(N, M, P, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 44268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int a, b; cin >> a >> b;
	if(a >= 13) cout << b;
	else if(6 <= a && a <= 12) cout << b/2;
	else cout << 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int tedad;
    char str[3];
    cin >> str;
    if(str[0] == '1')
    {
        tedad++ ;
    }
    if(str[1] == '1')
    {
        tedad++;
    }
    if(str[2] == '1')
    {
        tedad++;
    }
    cout << tedad;

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long LL;

int main(){
	LL n,x;
	scanf("%lld %lld",&n,&x);
	LL a=max(n-x,x);
	LL b=min(n-x,x);
	LL ans=n;
	while(1){
		if(a%b==0){
			ans+=b*(2*(a/b)-1);
			break;
		}
		else{
			ans+=b*(2*(a/b));
			a=a%b;
			swap(a,b);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import Control.Monad.State.Strict
import qualified Data.ByteString.Char8 as C
import Data.Coerce
import Data.Ix
import Data.Vector.Unboxed ((!))
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Algorithms.Intro as A

main = sol <$> gett >>= print

geti = coerce $ C.readInt . C.dropWhile (<'-') :: StateT C.ByteString Maybe Int

gett = V.unfoldr (runStateT $ (,) <$> geti <*> geti) <$> C.getContents

sol v = minimum [(xs!r - xs!l)*(ys!u - ys!d) | l <- [0..n-2], r <- [l+1..n-1], d <- [0..n-2], u <- [d+1..n-1], f l r d u]
  where
  (n,k) = v!0
  ps = V.tail v
  xs = V.modify A.sort $ V.map fst ps
  ys = V.modify A.sort $ V.map snd ps
  f l r d u = (k<=) . V.length $ V.filter (\(x,y) -> inRange (xs!l,xs!r) x && inRange (ys!d,ys!u) y) ps

Measured memory_bytes: 7244
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k;
  int mx = (n - 1) * (n - 2) / 2;
  if(mx < k) {
    cout << -1 << endl;
    return 0;
  }

  vector<P> ans;
  REP(i, n - 1) {
    ans.push_back(P(i + 1, n));
  }

  int add = mx - k;
  vector<P> edge;
  REP(i, n - 1) FOR(j, i + 1, n - 1) edge.push_back(P(i + 1, j + 1));

  REP(i, add) ans.push_back(edge[i]);
  cout << ans.size() << endl;
  REP(i, ans.size()) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 int N;
 cin>>N;
 vector<int>H(N);
 for(int i=0;i<N;i++){
   cin>>H[i];
 }
 int ans=0;
 int cnt=0;
 for(int i=0;i<N-1;i++){
   if(H[i]>=H[i+1]){cnt++;}
   else{cnt=0;}
   ans=max(ans,cnt);
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 3680
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main()
    {
        var n = Read().ToList();
        var mid= n.Count/2;
        for (int i = 1; i <= mid; ++i)
        {
            for (int j = 0; j < n[i].Count; ++j)
            {
                try
                {
                    n[i][j] += Math.Max(n[i - 1][j - 1], n[i - 1][j]);
                }
                catch when (j != 0)
                {
                    n[i][j] += n[i - 1][j - 1];
                }
                catch when (j != n[i].Count - 1)
                {
                    n[i][j] += n[i - 1][j];
                }
                catch
                {
                    throw;
                }
            }
        }
        for (int i = mid + 1; i < n.Count; ++i)
        {
            for (int j = 0; j < n[i].Count; ++j)
            {
                n[i][j] += Math.Max(n[i - 1][j], n[i - 1][j + 1]);
            }
        }
        Console.WriteLine(n[n.Count-1].Max());
    }

    private static IEnumerable<List<int>> Read()
    {
        string n;
        while (!string.IsNullOrEmpty(n = Console.ReadLine()))
            yield return n.Split(',').Select(int.Parse).ToList();
    }
}


Measured memory_bytes: 16320
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int q;cin>>q;
    map<string,int> mp;
    rep(i,0,q){
        int cmd;cin>>cmd;
        if(cmd==0){
            string key;int x;cin>>key>>x;
            mp[key]=x;
        }else if(cmd==1){
            string key;cin>>key;
            cout<<mp[key]<<endl;
        }else if(cmd==2){
            string key;cin>>key;
            mp[key]=0;
        }else {
             string l,r;cin>>l>>r;
             auto low=mp.lower_bound(l);
             auto high=mp.upper_bound(r);
             for(auto it=low;it!=high;it++)if(it->second!=0)cout<<it->first<<" "<<it->second<<endl;
        }
    }
    
    
}



/*

*/



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


struct Problem {

	UL N;
	ULL A[100000], B[100000];
	
	void Solve() {
		cin >> N;
		rep(i, N) cin >> A[i] >> B[i];
		ULL ans = 0;
		rep(i, N) {
			UL ix = N - i - 1;
			A[ix] += ans;
			ULL p = (B[ix] - A[ix] % B[ix]) % B[ix];
			ans += p;
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 1920
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

#define int long long

using namespace std;

void Main()
{
	string n;
	cin >> n;
	for (auto i : n) {
		if (i == '7') {
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c,d;
    cin >> a>> b >> c >>d;
     int p1=(c/b)+1;
     int p2= (a/d)+1;
     if(c%b==0)p1-=1;
     if(a%d==0)p2-=1;
     if(p1<=p2)cout << "Yes" <<endl;
     else cout << "No" << endl;
    return 0;
}


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

int main(){
 int  N,A,B;
 cin >> N >> A >> B;
  
  if(N*A > B){
  	cout << B << endl;
  }else if(N*A < B){
  	cout << N*A << endl;
  }else{
  	cout << B << endl;
  }
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

using Data = pair<ll, vector<int>>;

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

  // priority_queue の練習問題
  // https://drken1215.hatenablog.com/entry/2019/04/07/001000
  vector<int> N(3); rep(i,3) cin>>N[i];
  int K; cin>>K;
  vector<vector<ll>> v(3);
  rep(i,3) {
    v[i].resize(N[i]);
    rep(j,N[i]) cin>>v[i][j];
    sort(ALL(v[i]), greater<ll>());
  }

  priority_queue<Data> que;
  set<vector<int>> se;
  que.push(Data(v[0][0]+v[1][0]+v[2][0], vector<int>({0,0,0})));
  rep(i,K) {
    Data c = que.top(); que.pop();
    cout << c.first << endl;

    rep(j,3) {
      if(c.second[j] < N[j]-1) {
        ll sum = c.first - v[j][c.second[j]] + v[j][c.second[j]+1];
        vector<int> num = c.second; num[j]++;
        Data d = Data(sum, num);
        if(se.count(num)==0) se.insert(num), que.push(d);
      }
    }
  }

  return 0;
}


Measured memory_bytes: 1408
n=int(input())
x=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append([b,a])
x=sorted(x)
t=0
for j in range(n):
    t+=x[j][1]
    if t>x[j][0]:
        print("No")
        exit()
print("Yes") 


Measured memory_bytes: 37272
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int m,k;
	cin>>m>>k;
	ll p = 1;
	for(int i = 1; i <= m; i++){
		p *= 2LL;
	}
	if(p <= k){
		cout<<-1<<endl;
		return 0;
	}
	if(m==1){
		if(k==0){
			printf("%d %d %d %d\n", 0,0,1,1);
		}else{
			cout<<-1<<endl;
		}
		return 0;
	}

	deque<ll> ans;
	ans.push_front(k);
	for(int i = 0; i < p; i++){
		if(i!=k){
			ans.push_back(i);
			ans.push_front(i);
		}
	}
	ans.push_front(k);
	for(auto v : ans)
		cout<<v<<" ";
	printf("\n");
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
#define N 100007
#define pb push_back;
vector<ll> v[N];
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
}

Measured memory_bytes: 5972
#include<iostream>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int weight[n];
int val[n];
for(int i=1;i<=n;i++)
{
cin>>weight[i]>>val[i];
}
long long  dp[n+1][k+1]={0};
for(int i=0;i<=n;i++)
{
for(int j=0;j<=k;j++)
{
if(i==0||j==0)
dp[i][j]=0;
else if(j>=weight[i])
dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight[i]]+val[i]);
else
dp[i][j]=dp[i-1][j];
}
}
cout<<dp[n][k]<<endl;
return 0;
}

Measured memory_bytes: 79104
// vim:ts=4:sts=4:sw=4:et
// MOSCOW IPT JINOTEGA
// Table #14
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;
typedef long long i64;

const int M = 2017;
const int N = M * M;

bitset<N> x;

int n, a[M];

void gen() {
    n = 2000;
    for (int i = 0; i < n; ++i)
        a[i] = 1 + (rand() % 2000);
}

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

void kill() {
    x[0] = 1;
    for (int i = 0; i < n; ++i)
        x |= x << a[i];
    int s = 0;
    for (int i = 0; i < n; ++i)
        s += a[i];
    for (int i = (s + 1) / 2; i <= s; ++i)
        if (x[i]) {
            cout << i << endl;
            return;
        }
    assert(false);
}

int main() {
#ifdef LOCAL
    assert(freopen("c.in", "r", stdin));
#endif
    //ios_base::sync_with_stdio(false);

    read();
    //gen();
    kill();

    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n,m;cin>>n>>m;
    vector<pair<ll,ll>> p(n),p1(m); 
    rep(i,n){
        cin>>p[i].first>>p[i].second;
    }
    rep(i,m){
        cin>>p1[i].first>>p1[i].second;
    }
    rep(i,n){
        ll buf=1e10;
        int buf1=-1;
        rep(j,m){
            ll x=p[i].first,nx=p1[j].first,y=p[i].second,ny=p1[j].second;
            ll buf2=abs(x-nx)+abs(y-ny);
            if(chmin(buf,buf2)) buf1=j;
        }
        cout<<buf1+1<<endl;
    }
}

Measured memory_bytes: 3600
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){
  if( double(a)/__gcd(a,b)*double(b) > 100000000000000ll ) return -1;
  return a/__gcd(a,b)*b;
}

vector<ll> pf(ll a)
{
  if( a == 1 ) return vector<ll>(1,1);
  vector<ll> res;
  ll i = 2;
  while( i*i <= a ) {
    while( a%i == 0 ) {
      res.push_back(i);
      a /= i;
    }
    ++i;
  }
  if( a != 1 ) res.push_back(a);
  return res;
}

int solve(vector<ll> v)
{
  vector<int> dp(v.size()+1,0);
  vector<int> g;
  dp[0] = 1;
  for( int i = 1; i < int(v.size()); i++ ) {
    if( v[i-1] != v[i] ) {
      g.push_back(i);
      dp[i] = 1;
    }
  }
  for( int i = 0; i < int(v.size()); i++ ) {
    dp[v.size()] += dp[i];
    if( i+1 < int(v.size()) && v[i+1] == v[i] ) {
      dp[i+1] += dp[i];
    }
    for( int j = 0; j < int(g.size()); j++ ) {
      if( g[j] > i ) {
        dp[g[j]] += dp[i];
      }
    }
  }
  return dp[v.size()];
}

int main(void)
{
  int n,m;
  ll a[11],b[11];
  vector<ll> aa[11];
  scanf("%d%d",&n,&m);
  for( int i = 0; i < n; i++ ) scanf("%lld",a+i);
  for( int i = 0; i < m; i++ ) scanf("%lld",b+i);
  ll bb = 1;
  for( int i = 0; i < m; i++ ) {
    bb = lcm(bb,b[i]);
    if( bb < 0 ) {
      puts("0");
      return 0;
    }
  }
  for( int i = 0; i < n; i++ ) {
    if( a[i]%bb != 0 ) {
      puts("0");
      return 0;
    }
    a[i] /= bb;
  }
  ll aaa = a[0];
  for( int i = 1; i < n; i++ ) {
    aaa = gcd(aaa,a[i]);
  }
  if( aaa == 1 ) {
    puts("1");
    return 0;
  }
  vector<ll> p = pf(aaa);
  printf("%d\n",solve(p)+1);
  return 0;
}


Measured memory_bytes: 1052