akhauriyash/Code-Regression huggingface dataset:
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  ll K, N;
  cin >> K >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> DeltaMigi(N);
  vector<ll> ANSMigi(N);
  vector<ll> DeltaHidari(N);
  ll ans = 20000000;
  rep(i, N)
  {
    cin >> A.at(i);
    ANSMigi.at(i) = K;
  }
  //支点を0に揃える
  rep(i, N)
  {
    B.at(i) = A.at(i) - A.at(0);
  }
  //差分の計算
  rep(i, N - 1)
  {
    DeltaMigi.at(i) = B.at(i + 1) - B.at(i);
  }
  DeltaMigi.at(N - 1) = K - B.at(N - 1);

  // rep(i, N)
  // {
  //   cout << "Debug " << DeltaMigi.at(i) << endl;
  // }
  //各支点から出発した場合の距離
  ANSMigi.at(0) -= DeltaMigi.at(N - 1);
  // cout << "Debug 2 =" << ANSMigi.at(0) << endl;
  for (int i = 1; i < N; i++)
  {
    ANSMigi.at(i) -= DeltaMigi.at(i - 1);
  }
  // rep(i, N)
  // {
  //   cout << ANSMigi.at(i) << endl;
  // }
  rep(i, N)
  {
    ans = min(ans, ANSMigi.at(i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
using namespace std;

#define ll long long
#define endl "\n"
#define pb push_back
#define mp make_pair

int solve()
{
  ll n,k,total=0,num;
  cin>>n>>k;
  
  for(ll i=0;i<k;i++)
  {
    cin>>num;
    total+=num;
  }
  
  if(total>n)
    cout<<-1;
  else
    cout<<n-total;

    return 0;
}

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

    /*ll t;
    cin>>t;
    while(t--)*/
        solve();

    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl
typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{	
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> x(n);
	rep(i, q)
	{
		cin >> a;
		x[a-1]++;
	}
	for(int i=0;i<n;i++)
	{
		if (k-q + x[i] > 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#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;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    ll x=a[n-1];
    cout<<x<<" ";
    a.erase(a.begin()+(n-1));
    if(x%2!=0){
        ll buf=(x+1)/2;
        auto itr=lower_bound(a.begin(),a.end(),buf);
        int k=itr-a.begin();
        ll res=a[k],ab=abs(buf-a[k]);
        if(k>=1)k--;
        if(res==x||chmin(ab,abs(buf-a[k])))res=a[k];
        cout<<res<<endl;
    }else{
        ll buf=(x+1)/2;
        auto itr=lower_bound(a.begin(),a.end(),buf);
        int k=itr-a.begin();
        ll res=a[k],ab=abs(buf-a[k]);
        if(k>=1)k--;
        if(res==x||chmin(ab,abs(buf-a[k])))res=a[k];
        cout<<res<<endl;
    }
}

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

using namespace std;

using ll = long long;

// 各 i について「S と S[i:|S|-1] の最長共通接頭辞の長さ」を記録した配列を O(|S|) で構築
// ex. aaabaaaab
//     921034210
vector<int> z_algorithm(const string& S) {
    vector<int> res(S.size());
    res[0] = S.size();
    int i = 1, j = 0;
    while (i < S.size()) {
        while (i+j < S.size() && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < S.size() && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k; j -= k;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;

    string s2 = "";
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        s2 = s[i] + s2;

        vector<int> v = z_algorithm(s2);
        int sz = n - i;
        for (int j = 0; j < sz; j++) {
            ans = max(ans, min(v[j], j));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        
        while(true){
            if(c-b <= 0){
                System.out.println("Yes");
                break;
            }else{
                c -= b;
            }
            if(a-d <= 0){
                System.out.println("No");
                break;
            }else{
                a -= d;
            }
        }
    }
}

Measured memory_bytes: 35640
import sys
sys.setrecursionlimit(3000)
k = int(input())

ans = []

def solve(x, l):
    if int(x) > 3234566667:
        return l

    l.append(int(x))
    if x[-1] == '0':
        solve(x + '0', l)
        solve(x + '1', l)
    elif x[-1] == '9':
        solve(x + '9', l)
        solve(x + '8', l)
    else:
        last_digit = int(x[-1])
        for i in range(-1, 2):
            new_digit = last_digit + i
            solve(x + str(new_digit), l)

for i in range(1, 10):
    solve(str(i), ans)
ans.sort()
print(ans[k - 1])

Measured memory_bytes: 7440
function f()
    input = map(x -> parse(Int, x), split(chomp(readline()), " "))
    N = input[1]
    M = input[2]

    A = []
    B = []

    for i in 1:N
        input = map(x -> parse(Int, x), split(chomp(readline()), " "))
        append!(A, input[1])
        append!(B, input[2])
    end

    st = sortperm(A)    
    B_new = B[st]
    A_new = A[st]

    B_new_cum = cumsum(B_new)
    use_ind =  sum(B_new_cum .< M) + 1

    A_use = A_new[1:use_ind]
    B_use = B_new[1:use_ind]
    B_use[end] = B_use[end] + (M - B_new_cum[use_ind])

    print(sum(A_use .* B_use))
    
end
f()

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

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

const long long INF = 1LL << 60;
long long h[100010];
long long dp[100010];

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &h[i]);
  }

  // 初期化 (最小化問題なので INF に初期化)
  for (int i = 0; i < 100010; ++i) dp[i] = INF;

  // 初期条件
  dp[0] = 0;

  for (int i = 1; i < N; ++i) {
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }

  printf("%lld", dp[N - 1]);
}


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

#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);++i)

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")

#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")

int main(void){
  int i,K;
  cin >> K;
  string S;
  vector<char> ans(K);
  
  cin >> S;
  if(S.size()<=K) cout << S <<endl;
  else{
    rep(i,K){ans.at(i)=S.at(i);}
    rep(i,3){ans.push_back('.');}
    rep(i,K+3){cout << ans.at(i);}
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;
//�I�[�o�[�t���[�ɋC������您����������
//�m�F�Y���Ȃ您����������

int main() {
    int n; cin >> n;
    map<int, int> m;
    rep(i,n){
        int num; cin >> num;
        m[num]++;
    }
    vector<int> v;
    for(auto stick : m){
        if(stick.second>=4) {
            v.push_back(stick.first);
            v.push_back(stick.first);
        }else if(stick.second>=2) v.push_back(stick.first);
    }
    if(v.size()<2) cout << 0 << endl;
    else{
        sort(RALL(v));
        cout << (ll)v[0]*v[1] << endl;
    }

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
void BubbleSort(vector<string>&a, int);
void SelectionSort(vector<string>, int, vector<string>);
void display(vector<string>, int);
bool Stable(vector<string> , vector<string> , int);

void BubbleSort(vector<string> &a, int n) {
  for (int i = 0; i < n-1; i++)
  {
    for (int j = n-1; j > i;j--)
    {
        if (a.at(j).at(1) < a.at(j-1).at(1))
        swap(a.at(j), a.at(j-1));
    }
  }
  display(a, n);
  cout << "Stable" << endl;
}

void SelectionSort(vector<string> b, int n, vector<string> a) {
  for (int i = 0; i < n; i++)
  {
    int minij = i;
    for (int j = i; j < n; j++)
    {
      if (b.at(minij).at(1) > b.at(j).at(1)) {
        swap(minij, j);
      }
    }
    swap(b.at(minij), b.at(i));
  }
  display(b, n);
  if (Stable(a,b,n)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  
}

void display(vector<string> a, int n) {
  for (int i = 0; i < n; i++)
  {
    cout << a.at(i);
    if (i != n-1) 
    cout << " ";
  }
  cout << endl;
}

bool Stable(vector<string> a, vector<string> b, int n)  {
  bool ans = true;
  for (int i = 0; i < n; i++)
  {
    if (a.at(i) != b.at(i)) {
      ans = false;
      break;    
    }
  }
  return ans;
}

int main(void) {
  int n;
  cin >> n;
  vector<string> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  vector<string> b(n);
  for (int i = 0; i < n; i++)
  {
    b.at(i) = a.at(i);
  }
  
  BubbleSort(a, n);
  SelectionSort(b, n, a);

}


Measured memory_bytes: 3224
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = s.toCharArray();
        int len = c.length;
        boolean[] b = new boolean[200];
        
        for (int i = 0; i < len; i++) {
            b[c[i]] = true;
        }
        String ans = "-1";
        if (len != 26) {
            ans = s + getCh(b, (char)0);
        } else {
            b[c[len-1]] = false;
            for (int i = c.length - 2; i >= 0; i--) {
                
                if (c[i] < c[i+1]) {
                    ans = s.substring(0, i) + getCh(b, c[i]);
                    break;
                }
                b[c[i]] = false;
            }
        }
        System.out.println(ans);
    }
    static String getCh(boolean[] b, char ch) {
        for (int i = 'a'; i <= 'z'; i++) {
            if (!b[i] && ch < i) return "" + (char) i;
        }
        return "";
    }
}


Measured memory_bytes: 23124
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx,avx2")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

const int inf = 1e9 + 10;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    string s;
    cin >> s;
    set<int, greater<>> a;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            a.insert(i);
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'W') {
            if (!a.empty()) {
                a.erase(a.begin());
                ans++;
            }
        } else if (s[i] == 'R') {
            auto it = a.find(i);
            if (a.end() != it) {
                a.erase(it);
            }
        }
    }
    cout << ans << '\n';

    return 0;
}


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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
#define vv(T) vector<vector<T>>
#define vvv(T) vector<vector<vector<T>>>
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
void absorb( int &x, int n ){
    x = ( x * n ) % mod ;
    if( x < 0 ) x += mod ;
}



signed main(){
    int n, k ; cin >> n >> k ;
    vector<int> a(n) ;
    for( int i = 0 ; i < n ; i++ ) cin >> a[i] ;    
    sort( all(a) ) ;
    int res = 1 ;
    if( a[n-1] <= 0 && (k&1)){
        reverse( all(a) ) ;
        for( int i = 0 ; i < k ; i++ ){
            absorb( res, a[i] ) ;
        }
        cout << res ;
    }
    else{
        int len = k, left = 0, right = n - 1 ;
        if( k & 1 ){
            absorb( res, a[right] ) ;
            right-- ;
            len-- ;
        }
        while( len > 0 ){
            int f = a[left] * a[left+1] ;
            int s = a[right] * a[right-1] ;
            if( f > s ){
                f %= mod ;
                absorb( res, f ) ;
                left += 2 ;
                len -= 2 ;
            }
            else{
                s %= mod ;
                absorb( res, s ) ;
                right -= 2 ;
                len -= 2 ;
            }
        }
        cout << res ;
        
    }
    return 0 ;   
}


Measured memory_bytes: 4748
package main

import "fmt"

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)

	k++
	if b-a <= 2 {
		fmt.Println(k)
	} else {
		k -= a
		fmt.Println(a + k/2*(b-a) + k%2)
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 111111
typedef long long int ll;
int N;
ll X;
ll A[MAX_N];
int main()
{
	scanf("%d%lld",&N,&X);
	for(int i=0;i<N;i++){
		scanf("%lld",&A[i]);
	}
	ll ans=0;
	if(A[0]>X){
		ans=A[0]-X;A[0]=X;
	}
	for(int i=1;i<N;i++){
		if(A[i-1]+A[i]<=X)continue;
		ans+=(A[i-1]+A[i]-X);
		A[i]-=(A[i-1]+A[i]-X);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    char c[1000];
    int n,k;
    scanf("%d %d ",&n,&k);
    for(int i=0; i<n; i++)
        scanf("%c",&c[i]);
    if(c[k-1]=='A')
        c[k-1]='a';
    else if(c[k-1]=='B')
        c[k-1]='b';
    else
        c[k-1]='c';
    for(int i=0; i<n; i++)
        printf("%c",c[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(std::string S)
{

    for (int i = 0; i < S.size() - 8; i++)
    {
        cout << S[i];
    }
    cout << endl;
}

int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#define rep(i,n) for(int i=0;i<(int)n;i++)

#include <bits/stdc++.h>
using namespace std;

struct Card{
    char s;
    int v;
};

void bubblesort(Card A[],int N){
    for(int fixed=0;fixed<N-1;fixed++){
        for(int i=N-2;i>=fixed;i--){
            if(A[i+1].v<A[i].v){
                swap(A[i],A[i+1]);
        }
    }
  }
}

void selectionsort(Card A[],int N){
    int mind;
    for(int i=0;i<N-1;i++){
        mind=i;
        for(int j=i;j<=N-1;j++){
            if(A[j].v<A[mind].v) mind=j;
        }
        if(i!=mind) swap(A[i],A[mind]);
    }
}

int is_stable(Card in[],Card out[],int n){
    for(int i=0;i<=n-1;i++){
        for(int j=i+1;j<=n-1;j++){
            for(int a=0;a<=n-1;a++){
                for(int b=a+1;b<=n-1;b++){
                    if(in[i].v==in[j].v && in[i].s==out[b].s && in[i].v==out[b].v && in[j].s==out[a].s && in[j].v==out[a].v){
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

int main(){
    int n;
    cin>>n;
    Card A[n],A1[n],A2[n];
    rep(i,n) cin>>A[i].s>>A[i].v;
    rep(i,n) {
        A1[i]=A[i];
        A2[i]=A[i];
    }
    //bubble
    bubblesort(A1,n);
    rep(i,n-1) cout<<A1[i].s<<A1[i].v<<" ";
    cout<<A1[n-1].s<<A1[n-1].v<<endl;

    if (is_stable(A,A1,n))
        cout<<"Stable"<<endl;
    else
        cout<<"Not Stable"<<endl;

    selectionsort(A2,n);
    rep(i,n-1) cout<<A2[i].s<<A2[i].v<<" ";
    cout<<A2[n-1].s<<A2[n-1].v<<endl;

    if (is_stable(A,A2,n))
        cout<<"Stable"<<endl;
    else
        cout<<"Not stable"<<endl;

    return 0;
}


Measured memory_bytes: 3092
# -*- coding:utf-8 -*-

def is_YY(s):
    if int(s) >= 0 and int(s) <= 99:
        return True
    return False

def is_MM(s):
    if int(s) >= 1 and int(s) <= 12:
        return True
    return False

def solve():
    S = input()
    upper = S[0:2]
    lower = S[2:]
    if is_YY(upper) and is_MM(lower):
        if is_YY(lower) and is_MM(upper):
            print("AMBIGUOUS")
            return
        print("YYMM")
    elif is_YY(lower) and is_MM(upper):
        print("MMYY")
    else:
        print("NA")


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,m,n) for(ll i = (m); i < (n); i++)
#define all(v) v.begin(), v.end()
#define print(x) cout << (x) << endl
//宣言
ll K ,S;

void solve(){
    int cnt = 0;
    for(int x = 0;x <= K;x++){
        for(int y = 0;y<= K;y++){
            int z = S-x-y;
            if(z >= 0 && z <= K) cnt++;
        }
    }
    print(cnt);
}

int main() {
    //入力忘れるなよ～//vec = vector<ll>(N,0);もね
    cin >> K >> S;

    solve();
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int g=0,k=0;
  for(int i=0; i<S.size(); i++){
    if(i%2==0){
      if(S.at(i)!='0') g++;
      else k++;
    }
    else{
      if(S.at(i)!='1') g++;
      else k++;
    }
  }
  if(g<k) cout << g << endl;
  else cout << k << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n;
int v[400005];
void update(int i,int k,int l,int r,int root){
	if(r==l){v[root]=k;return;}
	if(r<l)return;
	int m=(l+r)/2;
	if(i<=m){
		update(i,k,l,m,root*2+1);
	}else{
		update(i,k,m+1,r,root*2+2);
	}
	v[root]=min(v[root*2+1],v[root*2+2]);
}
int query(int ll,int rr,int l,int r,int root){
	if(r<ll||l>rr)return INT_MAX;
	if(ll<=l&&rr>=r)return v[root];
	int s=0;
	int m=(l+r)/2;
	return min(query(ll,rr,l,m,root*2+1),query(ll,rr,m+1,r,root*2+2));
}
int main(){
	int q;cin>>n>>q;
	for(int i=0;i<=4*n;i++)v[i]=INT_MAX;
	while(q--){
		int t,ta,tb;
		cin>>t>>ta>>tb;
		if(!t){
			update(ta,tb,0,n-1,0);
		}else{
			cout<<query(ta,tb,0,n-1,0)<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4648
N = int(input())
CSF = []
for i in range(0, N-1):
    CSF.append(list(map(int, input().split())))
for i in range(0, N):
    ans = 0
    for j in range(i, N-1):
        ans = max(CSF[j][1], ans)
        if ans % CSF[j][2] != 0:
            ans += (CSF[j][2]-ans % CSF[j][2])
        ans += CSF[j][0]
    print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 10000000007


ll dp1[300][300],dp2[300][300];
int main() {
	ll n,m,l;
	cin>>n>>m>>l;
	for(ll i=0;i<300;i++){
		for(ll j=0;j<300;j++){
			if(i!=j){
			dp1[i][j]=inf;
			}
			dp2[i][j]=inf;
		}
	}
	for(ll i=0;i<m;i++){
		ll x,y,c;
		cin>>x>>y>>c;
		x--;y--;
		dp1[x][y]=c;
		dp1[y][x]=c;
	}	
	for(ll k=0;k<n;k++){
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				dp1[i][j]=min(dp1[i][j],dp1[i][k]+dp1[k][j]);
			}
		}
	}
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			if(dp1[i][j]<=l){
				dp2[i][j]=1;
			}
		}
	}
	for(ll k=0;k<n;k++){
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				dp2[i][j]=min(dp2[i][j],dp2[i][k]+dp2[k][j]);
			}
		}
	}
	ll q;
	cin>>q;
	for(ll i=0;i<q;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
	//	cout << x<<y;
	if(dp2[x][y]==inf){
		cout << -1<<endl;
	}
	else{
		cout <<dp2[x][y]-1<<endl;
	}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
ll const INF = 1LL<<60;

int main(){
	ll N;
	cin >> N;
	ll temp = INF;
	rep(i,5){
		ll x;
		cin >> x;
		temp = min(temp,x);
	}
	if(temp >= N){
		cout << 5 << endl;
	}else{
		cout << 4 + (N+temp-1)/temp << endl;
	}
    return 0;
}



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

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

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

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


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

    ll n,m,x; cin>>n>>m>>x;
    vint c(n);
    vvint a(n, vint(m));
    rep(i,n){
        cin>>c[i];
        rep(j,m) {cin>>a[i][j];}
    }

    ll ans = LLONG_MAX;

    rep(i,(1ll<<n)){
        vint cnt(m,0);
        ll tot = 0;
        rep(j,n){
            if((i>>j)&1){
                tot+=c[j];
                rep(ii,m){
                    cnt[ii] += a[j][ii];
                }
            }
        }

        auto ok = [&](){
            for(auto e:cnt){
                if(e<x) return false;
            }
            return true;
        };

        if(ok()) chmin(ans,tot);
    }
    if(ans == LLONG_MAX) ans = -1;
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
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;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, k;
  cin >> n >> k;
  ll h[n];
    rep(i,n){
      cin >> h[i];
    }
  if(k>=n){
    cout << 0 << endl;
    return 0;
  }
  else{
    sort(h, h + n);
    ll cnt = 0;
    rep(i,n-k){
      cnt += h[i];
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  string s;
  cin>>s;
  int ans=700;
  rep(i,3){
    if(s[i]=='o')ans+=100;
  }
  cout<<ans<<endl;
  return 0;
}

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


int main() {
  int N;
  cin >> N;
  int flag = 0;
  for(int i=1; i < 10; i++){
      if(N % i ==0 && N / i < 10 ){
        flag = 1;
        break;
      } 
      else flag = 0;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;


ull gcd(ull a,ull b){
	if(!b) return a;
	return gcd(b,a%b);
}


int main(){
	string s,t,u;
	bool is_used[26] = {false};
	cin >> s;
	
	if(s == "zyxwvutsrqponmlkjihgfedcba"){
		cout << -1 << endl;
		return 0;
	}
	
	
	rep(i,0,s.size()){
		is_used[(int)(s[i] - 'a')] = true;
	}
	
	if(s.size() < 26){
		rep(i,0,26){
			if(!is_used[i]){
				cout << s << (char)(i+'a') << endl;
				break;
			}
		}
	}
	else{
		char c = 'z';
		int memo = 0;
		rep(i,0,s.size()-1){
			if(s[s.size()-i-1] > s[s.size()-i-2]){
				memo = s.size()-i;
				c = s[s.size()-i-1];
				rep(j,0,i){
					if(s[s.size()-j-1] > s[s.size()-i-2]) c = min(c,s[s.size()-j-1]);
				}
				break;
			}
		}
		
		rep(i,0,memo-2){
			cout << s[i];
		}
		cout << c << endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

const int N=100005;

int fst[N],f[N],tot=0;

struct Edge{
	int to,nxt;
}e[N*4];

void addedge(int x,int y){
	e[++tot].to=y;e[tot].nxt=fst[x];fst[x]=tot;
}

bool dfs(int x,int v){
	f[x]=v;v^=1;
	bool flag=1;
	for (int i=fst[x];i;i=e[i].nxt){
		int y=e[i].to;
		if (f[y]==-1) flag&=dfs(y,v);
			else if (f[y]!=v) flag=0;
	}
	return flag;
}

int main(){
	int n,m;
	scanf("%d%d\n",&n,&m);
	for (int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d\n",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	for (int i=1;i<=n;i++) f[i]=-1;
	long long a=0,b=0,c=0;
	for (int i=1;i<=n;i++)
	if (f[i]==-1){
		if (dfs(i,0)){
			if (!fst[i]) a++;else b++;
		}
		else c++;
	}
	printf("%lld\n",2*a*n-a*a+2*b*b+2*b*c+c*c);
}

Measured memory_bytes: 6912
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut left = 0;
    let mut right = 0;
    for (i, &c) in s.iter().enumerate() {
      if c == 'A' {
         left = i;
         break
      }
    }

    for (j, &c) in s.iter().rev().enumerate() {
      if c == 'Z' {
         right = s.len() - j - 1;
         break
      }
    }

    let ans = right - left + 1;

    print!("{}", ans);
}


Measured memory_bytes: 4352
/*input
3 4 3
1 3 3 100
1 2 2 10
2 3 2 10
*/
#include<bits/stdc++.h>
using namespace std;

#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test int t;cin>>t;while(t--)
#define X first
#define Y second
#define pb push_back
#define all(s) s.begin(),s.end()

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

const int MOD = 1e9+7;

void make(vector<vector<int>> &vcc,vector<int> &curr, int val, int n,int m){
	if(val>m){
		if(curr.size()==n){
			vcc.pb(curr);
		}	
		return;
	}
	if(curr.size()==n){
		vcc.pb(curr);
		return;
	}
	make(vcc,curr,val+1,n,m);
	// make(vcc,curr,val,n)
	curr.pb(val);
	make(vcc,curr,val,n,m);
	make(vcc,curr,val+1,n,m);
	curr.pop_back();
}

void solve(){
	int n,m,q;
	cin >> n >> m >> q;
	int a[q][4];
	for(int i=0;i<q;i++){
		cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
		a[i][1]--;
		a[i][0]--;
	}
	vector<vector<int>> vcc;
	vector<int> curr;
	make(vcc,curr,1,n,m);
	int res = 0;
	for(auto vc: vcc){
		// for(auto it: vc)
		// 	cout << it << " ";
		// cout << "--";
		int curr = 0;
		for(int i=0;i<q;i++){
			if(vc[a[i][1]]-vc[a[i][0]]==a[i][2])
				curr += a[i][3];
		}
		// cout << curr << "\n";

		res = max(res,curr);
	}
	cout << res;

}

int main(){
    FIN;   
    // test
    solve();
}

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

li = [ [int(it) for it in input().split() ] for i in range(N) ]

lix = [0]*N
liy = [0]*N
for i in range(N):
  lix[i] = (i,li[i][0])
  liy[i] = (i,li[i][1])
lix.sort( key=lambda x:x[1] )
liy.sort( key=lambda x:x[1] )

edge = [0]*(2*(N-1))
c = 0
for i in range(N-1):
  edge[c] = ( lix[i][0],lix[i+1][0], lix[i+1][1] - lix[i][1] )
  c +=1
  edge[c] = ( liy[i][0],liy[i+1][0], liy[i+1][1] - liy[i][1] )
  c +=1

edge.sort ( key = lambda x:x[2] )

class Union():
  def __init__(me,N):
    me.N = N
    me.up = [-1]*N
    me.down = [ [] for i in range(N) ]
  def union(me,a,b):
    ua = me.up[a] if me.up[a]!=-1 else a
    ub = me.up[b] if me.up[b]!=-1 else b
    if (ua == ub):
      return
    if ( len(me.down[ua]) < len(me.down[ub]) ):
      ub,ua = ua,ub
    for v in me.down[ub]:
      me.up[v] = ua
    me.down[ua].extend( me.down[ub] )
    me.down[ub] = []
    me.up[ub] = ua
    me.down[ua].append( ub )
  def count(me,a):
    ua = me.up[a] if me.up[a]!=-1 else a
    return len(me.down[ua])+1
  
u = Union(N)

cost = 0
for a,b,c in edge:
  ua = u.up[a] if u.up[a]!=-1 else a
  ub = u.up[b] if u.up[b]!=-1 else b
  if ( ua != ub ):
    u.union(ua,ub)
    cost += c
print ( cost )
  

  

Measured memory_bytes: 133464
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
    string w; cin >> w;
    map<char, int> mp;
    for(int i=0; i<w.length(); i++){
        mp[w[i]] = 0;
    }
  	for(int i=0; i<w.length(); i++){
        mp[w[i]] += 1;
    }
    bool flag = false;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr->second % 2 == 1){
            cout << "No";
            flag = true;
            break;
        }
    }
    if(!flag) cout << "Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, ls[rt]
#define Rson mid+1, R, rs[rt]
#define sys system("pause")
#define intxt freopen("in.txt","r",stdin)
const int maxn=1e3+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
inline void umax(int &p,int q){if(p<q)p=q;}
inline void umin(int &p,int q){if(p>q)p=q;}
inline ll read()
{
    ll x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,k,t,a,b,c,d;
ll C[maxn][maxn],dp[2][maxn];
void init()
{
    C[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i;j++)
        {
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
}
int main()
{
    int i,j;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    init();
    dp[t][n]=1;
    for(int i=a;i<=b;i++)
    {
        for(int j=0;j<=n;j++)dp[t^1][j]=dp[t][j];
        ll tmp=1;
        for(int j=1;j<=d;j++)
        {
            if(j*i>n)break;
            tmp=tmp*C[i*j-1][i-1]%mod;
            if(j<c)continue;
            for(int k=i*j;k<=n;k++)
            {
                dp[t^1][k-i*j]=(dp[t^1][k-i*j]+dp[t][k]*C[k][i*j]%mod*tmp%mod)%mod;
            }
        }
        t^=1;
    }
    printf("%lld\n",dp[t][0]);
    //system("Pause");
    return 0;
}


Measured memory_bytes: 7168
N, X, Y = map(int, input().split())
count = dict([[i, 0] for i in range(1, N)])
leap = Y-X-1

for frm in range(N-1):
    for to in range(frm+1, N):
        key = min(to-frm, abs((X-1) - frm) + 1 + abs((Y-1) - to))
        #print(frm, to, key)
        count[key] += 1
# print(count)
print(*[count[i] for i in range(1, N)], sep='\n')


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

int main(){
	vector<string> vs;
	map<string, int> msi;
	string s;
	string::size_type max_length = 0;
	while(cin >> s){
		max_length = max(max_length, s.size());
		vs.push_back(s);
		msi[s]++;
	}
	int max_f = 0;
	for(vector<string>::iterator iter = vs.begin();
		iter != vs.end(); iter++)
	{
		max_f = max(max_f,msi[*iter]);
	}
	for(vector<string>::iterator iter = vs.begin(); 
		iter != vs.end(); iter++)
	{
		if(msi[*iter] == max_f){
			cout << *iter << " ";
			break;
		}
	}
	for(vector<string>::iterator iter = vs.begin();
		iter != vs.end(); iter++)
	{
		if((*iter).size() == max_length){
			cout << *iter << endl;
		}
	}
	return 0;
}

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

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

const int INF = 1000000007;

int main(void){
	string S, O, E;
	cin>>O>>E;

	int lenO = O.size(), lenE = E.size();
	if(lenO - lenE == 0){
		for(int i=0;i<lenO;i++){
			S += O[i];
			S += E[i];
		}
	}
	else{
		for(int i=0;i<lenE;i++){
			S += O[i];
			S += E[i];
		}
		S += O[lenO-1];
	}

	cout<< S <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
ll n;cin>>n;
ll a=0,b=1;
while(n){
    n/=2;
    a+=b;
    b*=2;
    
}
cout<<a;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
AB = []
for _ in range(N):
    a, b = mapint()
    AB.append((a, b))
AB.sort(key=lambda x:x[1])
now = 0
for i in range(N):
    a, b = AB[i]
    if b-a<now:
        print('No')
        break
    now += a
else:
    print('Yes')

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

#define ll long long

using namespace std;

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a) {
		cout << k;
		return 0;
	}
	if (k <= a + b) {
		cout << a;
		return 0;
	}
	cout << 2*a+b-k;
}


Measured memory_bytes: 3624
S = input()
S = list(S)
s1 = int(S[0])
count = 0
for i in S[1:]:
    i = int(i)
    if s1 == i:
        count += 1
        if i == 0:
            s1 = 1
        elif i == 1:
            s1 = 0
    else:
        s1 = i
print(count)

Measured memory_bytes: 4652
import sys
sys.setrecursionlimit(10**6)

def main():
    input = sys.stdin.readline
    N = int(input())
    S = str(input().strip())
    MOD = 998244353

    #state = (_, r, g, b, rg, gb, br)
    def f(i, ans, state):
        if i > 3*N-1:
            return ans
        if min(state) < 0:
            return 0

        no_ball, r, g, b, rg, gb, br = state
        if S[i] == 'R':
            if gb > 0:
                ans = (ans * gb) % MOD
                return f(i+1, ans, [no_ball, r, g, b, rg, gb-1, br])
            elif g > 0 or b > 0:
                ans = ans * (g + b) % MOD
                s1 = [no_ball, r, g-1, b, rg+1, gb, br]
                s2 = [no_ball, r, g, b-1, rg, gb, br+1]
                return (f(i+1, ans, s1) + f(i+1, ans, s2)) % MOD
            else:
                ans = (ans * no_ball) % MOD
                return f(i+1, ans, [no_ball-1, r+1, g, b, rg, gb, br])

        elif S[i] == 'G':
            if br > 0:
                ans = (ans * br) % MOD
                return f(i+1, ans, [no_ball, r, g, b, rg, gb, br-1])
            elif r > 0 or b > 0:
                ans = ans * (r + b) % MOD
                s1 = [no_ball, r-1, g, b, rg+1, gb, br]
                s2 = [no_ball, r, g, b-1, rg, gb+1, br]
                return (f(i+1, ans, s1) + f(i+1, ans, s2)) % MOD
            else:
                ans = (ans * no_ball) % MOD
                return f(i+1, ans, [no_ball-1, r, g+1, b, rg, gb, br])

        else: #S[i] == 'B':
            if rg > 0:
                ans = (ans * rg) % MOD
                return f(i+1, ans, [no_ball, r, g, b, rg-1, gb, br])
            elif r > 0 or g > 0:
                ans = ans * (r + g) % MOD
                s1 = [no_ball, r-1, g, b, rg, gb, br+1]
                s2 = [no_ball, r, g-1, b, rg, gb+1, br]
                return (f(i+1, ans, s1) + f(i+1, ans, s2)) % MOD
            else:
                ans = (ans * no_ball) % MOD
                return f(i+1, ans, [no_ball-1, r, g, b+1, rg, gb, br])

    return f(0, 1, [N, 0, 0, 0, 0, 0, 0]) % MOD


if __name__ == '__main__':
    print(main())


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

#define FOR(i,N) for(int i=0;i<N;i++)
#define ROF(i,N) for(int i=N-1;i>=0;i--)
#define ROF1(i,a,b) for(int i=(b);i>=(a);i--)
#define FOR1(i,a,b) for(int i=(a);i<=(b);i++)
#define FORi(i,a,b,c) for(int i=(a);i<=(b);i+=(c))

#define read freopen("IN.txt","r",stdin)
#define write freopen("OT.txt","w",stdout)
#define fastread {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mem(a,b)          memset(a,b,sizeof(a))
#define EPS 1e-9
#define PI              acos(-1.0)
#define INF             2e16

#define ll              long long
#define ull             unsigned long long
#define ft              first
#define sd              second
#define bn              begin
#define en              end
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>
#define all(x) x.begin(), x.end()


#define dbg(args...) {cerr<<"-->";debugger::call(#args,args);cerr<<"\n";}
struct debugger {
    static void call(const char* it) {}
    template<typename T, typename ... aT>
    static void call(const char* it, T a, aT... rest) {
        string b;
        for (; *it&&*it != ','; ++it) if (*it != ' ')b += *it;
        cerr << b << "=" << a << " ";
        call(++it, rest...);
    }
};

int main()
{
#ifdef SunWalker
    //read;
   //write;
#endif

     int a,b,soc=0,cnt=0;
     cin>>a>>b;
     cout<<ceil(double(b-1)/double(a-1))<<"\n";
     /*
     while(soc < b-1)
     {
          cnt++;
          soc+=a-1;
     }
     cout<<cnt<<"\n";
     */
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int H, W;
  cin >> H >> W;
  if(H == 1 || W == 1) {
    cout << 1 << endl;
  }
  else {
  	cout << (H + 1) / 2 * ((W + 1) / 2) + H / 2 * (W / 2) << endl;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    int N, W; cin >> N >> W;
    vector<pair<int, int> > vw(N);
    rep(i, N){
        int a, b; cin >> a >> b;
        vw[i] = {b, a};
    }
    sort(ALL(vw));
    vector<int> v(N), w(N);
    rep(i, N){
        v[i] = vw[i].second;
        w[i] = vw[i].first;
    }

    vector<int> dp(MAX, -1);
    dp[0] = 0;
    int ans = 0;
    rep(i, N){
        rep(j, MAX){
            if(dp[j] >= 0 && j+w[i] < W + 1){
                dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
                ans = max(ans, dp[j+w[i]]);
            }
        }
    }

    print(ans);
    
    
    return 0;
}



Measured memory_bytes: 3356
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var result = 0;
            foreach(var aval in A)
            {
                var x = aval;
                while(x % 2 == 0)
                {
                    x = x / 2;
                    result++;
                }
            }
            Console.WriteLine(result);
        }
    }

}


Measured memory_bytes: 14176
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;

bool solve() {
    int a, b, c, d, e, k;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);
    if(e - a > k) return false;
    return true;
}
int main(int argc, char **argv) {
    printf(solve() ? "Yay!\n" : ":(\n");
}


Measured memory_bytes: 128
using System;

namespace abc168_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            if (n % 10 == 3)
            {
                Console.WriteLine("bon");
            }
            else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }
        }
    }
}


Measured memory_bytes: 27492