akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int max(int a, int b){
    if( a > b ){
        return a;
    }else{
        return b;
    }
}

int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    int ans = max(max(a,b),c);
    cout << a + b + c - ans;
    
    return 0;
}



Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    x = II()
    n = 100
    y = 0
    while n < x:
        n = int(n * 1.01)
        y += 1
    print(y)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

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

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

}

Measured memory_bytes: 1408
# D - Not Divisible
from collections import Counter

N = int(input())
A = list(int(a) for a in input().split())
c = Counter(A)
ng = set([i[0] for i in c.items() if i[1] >= 2])
A.sort()

M = max(A)
primes = []
is_prime = [True] * (M+1)
for i, a in enumerate(A):
    if is_prime[a]:
        if a not in ng:
            primes.append(a)
        for j in range(a*2, M+1, a):
            is_prime[j] = False
print(len(primes))



Measured memory_bytes: 38216
#include <stdio.h>
#include<math.h>
int main(){
  int n,s[1001],i,sum=0;
  double ave,a=0;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0; i<n; i++){
      scanf("%d",&s[i]);
      sum+=s[i];
    }
    ave=(double)sum/n;
    for(i=0; i<n; i++){
      a+=((s[i]-ave)*(s[i]-ave));
    }
    printf("%f\n",sqrt((double)a/n));
    sum=0; a=0;
  }
  return 0;
}

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

using namespace std ;

int main(){ 
 	long long n, a, b; 
    cin >> n >> a >> b ;
    if (a < b) swap(a, b) ; 
    if ((a - b) & 1) {
      	long long ans = min((a - b - 1) / 2 + b, ((n - (b + n - a + 1))) / 2 + (n - a + 1)); 
        cout << ans << endl ; 
    }
    else cout << (a - b) / 2 << endl ; 
}

Measured memory_bytes: 256
//Partition
using System;

namespace tst
{
    class Program
    {
        public static int Partition(int[] A, int p, int r)
        {
            int x = A[r];
            int i = p - 1;
            for(int j=p; j<r; j++)
            {
                if (A[j] <= x)
                {
                    i++;
                    int temp = A[i];
                    A[i] = A[j];
                    A[j] = temp;
                }
            }
            int temp2 = A[i+1];
            A[i+1] = A[r];
            A[r] = temp2;
            return i + 1;
        }
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] In = Console.ReadLine().Split(' ');
            int[] A = new int[n];
            for(int i=0; i<n; i++)
            {
                A[i] = int.Parse(In[i]);
            }
            int index = Partition(A, 0, n - 1);
            Console.Write(A[0]);
            for (int i=1; i<n; i++)
            {
                if (i == index) Console.Write(" [{0}]",A[i]);
                else Console.Write(" {0}", A[i]);
            }
            Console.WriteLine();
        }

    }
}


Measured memory_bytes: 26188
x,k,d = map(int, input().split())

x = abs(x)
if k <= x//d:
  y = x-k*d
else:
  if (k-x//d)%2 == 0:
    y = x%d
  else:
    y = min(abs(x%d-d),abs(x%d+d))
print(y)

Measured memory_bytes: 9140
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
  string in(9, '0');
  int n = 0, s = 0, dummy = 0;

  cin >> in;
  for(int i = 0; i < in.size(); ++i){
    dummy = (int)(in[i] - '0');
    s += dummy;
    n += dummy * pow(10, in.size() - i - 1);
  }
  if((n % s) == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n, i, ans=1, j=1;

    scanf("%d", &n);

    int P[n+2];

    for(i=1; i<=n ; i++){
        scanf("%d", &P[i]);
        if(i != P[i]){
            if(j==3){
                ans=0;
                break;
            }
            j++;
        }
    }

    if(ans)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}



Measured memory_bytes: 1648
n = int(input())

a = [int(x) for x in input().split()]

baisuu=[0]*(10**6+1)

for i in a:
	if baisuu[i]>=1:
		baisuu[i]=2
		continue

	for j in range(i,10**6+1,i):
		baisuu[j]+=1

ans=0

for i in a:
	if baisuu[i]==1:
		ans+=1

print(ans)

Measured memory_bytes: 132648
#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>;
using G = vector<vector<int>>;
    
int main(){
    int x;
    cin >> x;
    x /= 200;
    cout << 10 - x << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    scanf("%lld",&n);
    
    map<string,long long>mp;
    for(long long i=0;i<n;i++)
    {   map<string,long long>::iterator it1 ; 
        char ch[10];
        cin>>ch;
        sort(ch,ch+10);
        it1=mp.find(ch);
        if(it1!=mp.end())
        (*it1).second++;
        else
        mp.insert(make_pair(ch,1));
    }
     map<string,long long> :: iterator it;
     long long ans=0;
     
    for(it=mp.begin();it!=mp.end();it++)
    {
        long long z;
        z=(*it).second;
        ans=ans+(z*(z-1))/2;
    }
    cout<<ans;
    
}

Measured memory_bytes: 11264
#include<stdio.h>
int main(){
  char s[1206],w[1204];
  int c=0,i,a=1;
  fgets(s,1205,stdin);
  for(i=0;s[i]!=0;i++){
    if((s[i]==' ')||(s[i]=='.')||(s[i]==',')){
      if(2<c&&c<7){
	if(a==0)printf(" ");
	printf("%s",w);
	a=0;
      }
      c=0;
    }
    else{
 	w[c]=s[i];
	c++;
	w[c]='\0';
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
#include"bits/stdc++.h"

using namespace std;

int main() {
	int A, B, K;
	cin >> A >> B >> K;
	int num = 0;

	for (int i = 100; i >= 1; i--) {
		if (A%i == 0 && B%i == 0) {
			num++;
			if (num == K) {
				cout << i << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

char a[200000];
int n;
ll m;

int main()
{
	int i, j, k, l;
	scanf("%s", a);
	n=strlen(a);
	cin>>m;
	for(i=0;i<n;i++)
	{
		if(a[i] == 'a') continue;
		if(m >= 'z'-a[i]+1)
		{
			m-='z'-a[i]+1;
			a[i]='a';
		}
	}
	a[n-1]=(a[n-1]-'a'+m)%26+'a';
	printf("%s\n", a);
	return 0;
}
//*/

Measured memory_bytes: 384
N,K = map(int,input().split())
snk = [0 for i in range(N)]

for i in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for x in A:
    snk[x-1] += 1

ans = 0
for x in snk:
  if(x == 0): 
    ans += 1
print(ans)

Measured memory_bytes: 9192
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		int[] Y = new int[N];
		for (int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
		}
		if (N == 2) {
			double dx = X[1] - X[0];
			double dy = Y[1] - Y[0];
			double d = Math.sqrt(dx*dx + dy*dy);
			System.out.println(d);
			return;
		}
		double sum = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = i+1; j < N; j++) {
				double dx = X[i] - X[j];
				double dy = Y[i] - Y[j];
				sum += Math.sqrt(dx*dx + dy*dy);
			}
		}
		System.out.println(sum * 2 / N);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

vpii adj[310000];
vi rick1(310000);
int rickma = 0;
void dfs(int morty,int jerry,int rick){
	set<int> set1;
	set1.insert(rick);
	int colors = 1;
	FORR(x,adj[morty])if(x.first!=jerry){
		while(set1.count(colors))colors++;
		rick1[x.second] = colors;
		rickma = max(rickma,colors);
		dfs(x.first,morty,colors);
		colors++;
	}
}

int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall
	
	ini(n);
	FOR(i,0,n-1){
		ini(x);
		ini(x1);
		adj[x-1].push_back({x1-1,i});
		adj[x1-1].push_back({x-1,i});
	}
	dfs(0,-1,0);
	out(rickma);
	FOR(i,0,n-1){out(rick1[i]);}














	return 0;
}

Measured memory_bytes: 22144
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int x,ans=0;

int main() {
	cin>>x;
	for(int i=1;i*i<=x;i++){
		int tmp=1;
		for(int j=0;j<11&&tmp<=x;j++)
			tmp*=i;
		ans=max(ans,tmp/i);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int r,g,b;
  cin >>r>>g>>b;
  if (((r*100)+(g*10)+b)%4==0){
    cout <<"YES"<<endl;
  }
  else {
    cout <<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, "\e[31;1m"); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\e[0m")
#else
    #define eprintf(...) 42
#endif

std::string solve(const int A, const int B, const int C)
{
    if (A + B == C || B + C == A || C + A == B)
    {
        return "Yes";
    }
    return "No";
}

int main(void)
{
    int A, B, C;
    std::cin >> A >> B >> C;
    std::cout << solve(A, B, C) << std::endl;
    return 0;
}

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

using namespace std;

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

	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() 
{
  int H, W;
  cin >> H >> W ;
  vector<vector<char>> data1(50, vector<char>(50));
  vector<vector<int>> data2(50, vector<int>(50));

  
  for (int i=0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data1.at(i).at(j);
      if (data1.at(i).at(j) == '#') {
        if (j+1<W) data2.at(i).at(j+1)++;//right
        if (j>=1) data2.at(i).at(j-1)++; //left
        if (i+1<H) data2.at(i+1).at(j)++;//up
        if (i>=1) data2.at(i-1).at(j)++; //down
        if (j+1<W && i>=1) data2.at(i-1).at(j+1)++;//right down
        if (j+1<W && i+1<H) data2.at(i+1).at(j+1)++;//right up
        if (j>=1 && i>=1) data2.at(i-1).at(j-1)++;//left down
        if (j>=1 && i+1<H) data2.at(i+1).at(j-1)++;//left up
      }
    }
  }
  for (int i=0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data1.at(i).at(j) == '#') cout << data1.at(i).at(j);
      else cout << data2.at(i).at(j);
    }
      cout << endl;
  }    
  return 0;
}


Measured memory_bytes: 256
// Copyright (C) 2018 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int n = input<int>();

    vector<int> a(n), b(n);
    input_seq(ALL(a));
    input_seq(ALL(b));

    int ans = 0;
    for (int bit = 0; bit <= 28; ++bit) {
        vector<int> ac = a;
        for (int& elem: ac)
            elem %= (1 << (bit + 1));

        sort(ALL(ac));
        
        int cnt = 0;
        for (int elem: b) {
            elem %= (1 << (bit + 1));

            // (1 << bit) <= x + elem < (2 << bit)
            // or
            // (3 << bit) <= x + elem < (4 << bit)
            
            cnt xor_eq (std::lower_bound(ALL(ac), (2 << bit) - elem)
                       -std::lower_bound(ALL(ac), (1 << bit) - elem));
            
            cnt xor_eq (std::lower_bound(ALL(ac), (4 << bit) - elem)
                       -std::lower_bound(ALL(ac), (3 << bit) - elem));
        }

        ans or_eq ((cnt & 1) << bit);
    }

    cout << ans << "\n";
    
    
    return 0;
}


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

int main() {
        int N, M;
        char B, A, c;
        cin >> N;
        while (N != 0) {
                map<char, char> hen;
                rep(n, N) {
                        cin >> B >> A;
                        hen[B] = A;
                }
                cin >> M;
                rep(m, M) {
                        cin >> c;
                        if (hen.count(c)) {
                                cout << hen.at(c);
                        } else {
                                cout << c;
                        }
                }
                cout << endl;
                cin >> N;
        }

        return 0;
}



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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int dig = N % 10;

    if(dig == 3) cout << "bon" << endl;
    else if(dig == 0 || dig == 1 || dig == 6 || dig == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	long long int n,k;
	cin>>n>>k;
	vector<long long int> h(n);
	for(size_t i = 0; i<n; i++)
	{
		cin>>h[i];
	}
	sort(h.begin(),h.end(),greater<long long int>());
	long long int ans = 0;
	for(size_t i = 0; i<n; i++)
	{
		if(k!=0)
		{
			k--;
		}
		else
		{
			ans += h[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int Count(int num) {
	if (num == 1) return 1;
	else if (num == 2) return 2;
	else if (num == 3) return 4;
	else return Count(num - 1) + Count(num - 2) + Count(num - 3);
}



int main() {
	int num;
	while (1) {
		scanf("%d", &num);
		if (num == 0)break;
		printf("%d\n", (Count(num)/10)/365 + 1);
	}
	return 0;
}


Measured memory_bytes: 2572
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println( Max( Max( a+b, a-b ), a*b) );
    }
    public static int Max (int p, int q){
        int res;
        if( p >= q ) res = p;
        else         res = q;
        return(res);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define nmax 100005
using namespace std;
int64_t i,j,ras=0,n,k,r,s,p;
char x[nmax];
char uz[nmax];
int puncte(int pos)
{
    char c=x[pos];
    if(c=='r')
    {
        uz[pos]='p';
        return p;
    }
    if(c=='s')
    {
        uz[pos]='r';
        return r;
    }
    if(c=='p')
    {
        uz[pos]='s';
        return s;
    }
}

int main()
{
    cin>>n>>k>>r>>s>>p>>x;
    for(i=0; i<strlen(x); i++)
    {
        if(i>=k && x[i-k]==x[i])
        {
            //if(uz[i-k]!=x[i])
              //  ras+=puncte(i);
            x[i]='a';
        }
        else
        {
            ras+=puncte(i);
        }
    }
    cout << ras ;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
  int a1;
  scanf("%d",&a1);
  int a=a1;
  int sum=0;
  while (a!=0)
  {
      sum=sum+(a%10);
      a=a/10;
  }
  if((a1%sum)==0)
    printf("Yes");
  else
    printf("No");
}


Measured memory_bytes: 128
n = int(input())

alist, blist = [], []
for _ in range(n):
  a, b = map(int, input().split())
  alist.append(a)
  blist.append(b)

pb = 0
for a, b in zip(alist[::-1], blist[::-1]):
  a += pb
  pb += b - a % b if a % b != 0 else 0
print(pb)

Measured memory_bytes: 12588
n = int(input())
xy = []
for i in range(n):
    xx,yy = map(int,input().split())
    xy.append([xx,yy])

xy.sort()

if n == 1:
    print(1)
    exit()

sub = []
for i in range(n-1):
    for j in range(i+1,n):
        sub.append((xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]))

res = 10**9

for x,y in sub:
    used = [True]*n
    cnt = 0
    for i in range(n-1,-1,-1):
        if used[i]:
            cnt += 1
        if [xy[i][0]-x,xy[i][1]-y] in xy:
            r = xy.index([xy[i][0]-x,xy[i][1]-y])
            used[r] = False
    res = min(cnt,res)
print(res)
        



Measured memory_bytes: 42604
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

long long gcd(long long a,long long b)
{
  return b==0?a:gcd(b,a%b);
}

int main()
{
  int n;
  scanf("%d",&n);
  std::vector<long long> A(n),B(n);
  for(int i=0;i<n;i++){
    scanf("%lld%lld",&A[i],&B[i]);
  }
  std::vector<std::pair<long long,int> > P(n);
  for(int i=0;i<n;i++){
    P[i]=std::make_pair(std::max(A[i],B[i]),i);
  }
  std::sort(P.begin(),P.end(),std::greater<std::pair<long long,int> >());
  std::vector<long long> SP(n+1);
  SP[0]=0ll;
  for(int i=0;i<n;i++){
    SP[i+1]=SP[i]+P[i].first;
  }
  long long S=0ll;
  for(int i=0;i<n;i++)
    S+=A[i];
  long long ansp=0,ansq=1;
  for(int t=0;t<n;t++){
    int k=P[t].second;
    int c;
    long long s;
    if(SP[t]+B[k]>=S){
      c=std::lower_bound(SP.begin(),SP.end(),S-B[k])-SP.begin();
      s=SP[c];
    }
    else{
      c=std::lower_bound(SP.begin(),SP.end(),S-B[k]+P[t].first)-SP.begin()-1;
      s=SP[c+1]-P[t].first;	     
    }
    long long q=B[k];
    long long p=B[k]*(n-1-c)+(B[k]-std::max(0ll,S-s));
    if(ansp/ansq<p/q||(ansp/ansq==p/q&&(ansp-ansp/ansq*ansq)*q<(p-p/q*q)*ansq)){
      ansp=p;
      ansq=q;
    }
  }
  long long g=gcd(ansp,ansq*n);
  printf("%lld %lld\n",ansp/g,ansq*n/g);
  return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>

int main(){
   int n, m;
   scanf("%d %d", &n, &m);
   int a[n];
   double sum = 0;
   for(int i=0; i<n; i++){
      scanf("%d", &a[i]);
      sum += a[i];
   }
   int count = 0;
   for(int i=0; i<n; i++){
      if(a[i] >= sum/4/m){
         count++;
      }
   }

   if(count >= m){
      printf("Yes");
   } else {
      printf("No");
   }

   return 0;
}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    vector<string>s(n);
    rep(0,i,n){
        cin>>s[i];
    }
    sort(s.begin(),s.end());
    vector<pair<ll,string>> ans;
    ll c=0,maxc=0;
    string fs="";
    rep(0,i,n){
        if(fs==""){
            fs=s[i];
            ++c;
        }else if(fs==s[i]){
            ++c;
        }else{
            ans.push_back(make_pair(c,fs));
            fs=s[i];
            c=1;
        }
        maxc=max(maxc,c);
    }
    ans.push_back(make_pair(c,fs));
    sort(ans.begin(),ans.end());
    //cout<<ans.size()<<endl;
    rep(0,i,ans.size()){
        if(ans[i].first==maxc){
            cout<<ans[i].second<<endl;
        }
    }
}


Measured memory_bytes: 18676
#include<iostream>
#include<math.h>
#include<stdlib.h>
using namespace std;

int used[27],number[27];
int cnt=1;
int ln;
int n,aa=-1,bb=-1,a[10],b[10];
bool compare(int c[],int d[]){
    for(int i=1;i<=n;i++) {
        if(c[i]!=d[i]) return false;
    }
    return true;
}
void permutation(int at,int n){
    if(at==n+1){
        string s="";
        if(compare(number,a)) aa=cnt;
        if(compare(number,b)) bb=cnt;
        cnt++;
        return;
    }
    for(int i=1;i<=n;i++){
        if(!used[i]){
            used[i]=1;
            number[at]=i;
            permutation(at+1,n);
            used[i]=0;
        }
    }
}
int main()
{     
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
   
    permutation(1,n);
    cout<<abs(aa-bb);
    

}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs, x) vector<vector<T>> xs(n, vector<T>(m, x))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs, 0); For(i, n) For(j, m) cin >> xs[i][j]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    int x = 0, y = 0, t = 0;
    For(i, n){
        Cin(int, t1); t = t1 - t;
        Cin(int, x1);
        Cin(int, y1);
        int k = abs(x-x1) + abs(y-y1);
        if(t < k || ((t % 2) ^ (k % 2))){ Cout("No"); return 0; }
        t = t1, x = x1, y = y1;
    }
    Cout("Yes");
}


Measured memory_bytes: 256
N=int(input())
a=input().split()
A=[]
for _ in a:
    A.append(int(_))
E=[0]*(N+1)

for i in range (len(A)):
    _boss=A[i]
    E[_boss]+=1

for j in range(1,len(E)):
    print(E[j])
    

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    ll x[n], y[n];
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    vector<pair<int, int> > d;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            d.push_back(make_pair(x[i] - x[j], y[i] - y[j]));
            d.push_back(make_pair(x[j] - x[i], y[j] - y[i]));
        }
    }
    sort(d.begin(), d.end());
    // for(pair<int, int> di: d) cout << di.first << " " << di.second << endl;

    // count same elements
    pair<int, int> prevp = d[0];
    int cnt = 1;
    int maxcnt = 1;
    for(int i=1;i<d.size();i++){
        if(d[i] == prevp){
            cnt++;
        }else{
            maxcnt = max(cnt, maxcnt);
            cnt = 1;
            prevp = d[i];
        }
    }
    maxcnt = max(cnt, maxcnt);
    cout << n - maxcnt << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b, c;
    cin >> a >> b >> c ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;

    sort(vec.begin(), vec.end());
    //*/
    
    //*
    if( a + b + c > 21 ){
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    //*/
    
    //cout << ans << endl;

    return 0; 
}


Measured memory_bytes: 3580
// https://atcoder.jp/contests/abc147/tasks/abc147_f
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;

int main() {
    ll n,k,r,s,p;
    std::cin >> n>>k;
    std::cin >> r>>s>>p;
    string t;
    std::cin >> t;
    
    ll sum = 0;
    
    for (int i = 0; i < n; i++) {
        if(t[i]=='r'){
            sum+=p;
        }else if(t[i]=='s'){
            sum+=r;
        }else{
            sum+=s;
        }
    }
    
    for (int i = k; i < n; i++) {
        if(t[i]==t[i-k]){
            if(t[i]=='r'){
                sum-=p;
            }else if(t[i]=='s'){
                sum-=r;
            }else{
                sum-=s;
            }
            t[i]='a';
        }
    }
    
    std::cout << sum << std::endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e6+6;
const ll MOD=1e9+7;
const int Seed=1e7+7;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
typedef pair<pair<int,int>,pair<int,int> >ppp;
vector<ppp> ans;
int a[600][600];
int main(){
    int n,m;
    sf(n);sf(m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)   sf(a[i][j]);
    for(int j=1;j<=m;j++){
        for(int i=1;i<=n-1;i++){
            if(a[i][j]==0)  continue;
            if(a[i][j]%2==0)    continue;
            ans.push_back(make_pair(make_pair(i,j),make_pair(i+1,j)));
            a[i][j]--;
            a[i+1][j]++;

        }
    }
    for(int i=n;i<=n;i++){
        for(int j=1;j<=m-1;j++){
            if(a[i][j]==0)  continue;
            if(a[i][j]%2==0)    continue;
            ans.push_back(make_pair(make_pair(i,j),make_pair(i,j+1)));
            a[i][j+1]++;
            a[i][j]--;
        }
    }
    cout <<ans.size() << endl;
    for(auto t : ans){
       pair<int,int> x,y;
       x=t.first,y=t.second;
       cout <<x.F<<" "<<x.S<<" "<<y.F<<" "<<y.S<<endl;
    }

    return 0;
}


Measured memory_bytes: 5360
import java.util.*;
import java.io.*;
import java.math.BigInteger;

 
class Main implements Runnable {
  // static Scanner in;
  static FastReader in;
  static PrintWriter out;
  static int[][] dirs8 = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {-1, -1}, {-1, 1}, {1, -1}};
  static int[][] dirs = {{0, -1}, {1, 0}, {0, +1}, {-1, 0}};
 
  static int[][] E;
  // static List<int[]>[] adj;
  static List<Integer>[] adj;
  static int[] vis;
 
  static long INFL = (long) 1e15 + 7;
  static int INF = (int) 1e7 + 9;
  static int mod = 998244353;
  
  static int T, n, m, k, count, cur;
  static boolean flag;
  static int[] a, b;
  static int[][] map;

  static int[] par;
  static int[] dp;

  static void solve() throws Exception {
    n = in.nextInt();
    dp = new int[n];
    a = new int[n];
    // dp[i]: the min cost to jump to (n - 1) from i
    for (int i = 0; i < n; i++) {a[i] = in.nextInt();}
    for (int i = n - 2; i >= 0; i--) {
      dp[i] = Math.min(dp[i + 1] + Math.abs(a[i] - a[i + 1]), (i == n - 2) ? INF : dp[i + 2] + Math.abs(a[i] - a[i + 2]));
    }
    out.println(dp[0]);
  }

 

  public static void main(String[] args) throws Exception {
 
    // in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    in = new FastReader();
    out = new PrintWriter(System.out);
 
    // int numOfTests = in.nextInt();
    // for (int caseNum = 1; caseNum <= numOfTests; caseNum++) {
    //   // Thread t = new Thread(null, new Main(), "Main", 1 << 28);
    //   // t.start();
    //   // t.join();
    //   solve();
    // }
 
    // // Thread t = new Thread(null, new Main(), "Main", 1 << 28);
    // // t.start();
    // // t.join();
    solve();
 
    out.flush();
    out.close();
  }
 
  @Override
  public void run() {
    try {
      solve();
    } catch (Exception e) {
      e.printStackTrace(); 
    }
  }
 
  static class FastReader {
    public BufferedReader br; 
    StringTokenizer st; 
    public FastReader() {br = new BufferedReader(new InputStreamReader(System.in));} 
    String next() { 
      while (st == null || !st.hasMoreElements()) { 
          try {st = new StringTokenizer(br.readLine());} 
          catch (IOException e) {e.printStackTrace();} 
      } 
      return st.nextToken(); 
    } 
    int nextInt() {return Integer.parseInt(next());} 
    long nextLong() {return Long.parseLong(next());} 
    double nextDouble() {return Double.parseDouble(next());} 
    String nextLine() {
      String str = ""; 
        try {str = br.readLine();} 
        catch (IOException e) {e.printStackTrace();} 
        return str; 
    }
  }

  static void as(boolean result) throws Exception {
    if (!result) {
      throw new Exception();
    }
  }

  static int modInverse(int a, int m) { 
    int m0 = m; 
    int y = 0, x = 1; 
    if (m == 1) {return 0;} 
    while (a > 1) { 
      // q is quotient 
      int q = a / m; 
      int t = m; 
      // m is remainder now, process 
      // same as Euclid's algo 
      m = a % m; 
      a = t; 
      t = y; 
      // Update x and y 
      y = x - q * y; 
      x = t; 
    } 
    // Make x positive 
    if (x < 0) 
      x += m0; 
    return x; 
  } 
} 

Measured memory_bytes: 32464
#include<iostream>
#include<vector>
#define MAX 8*1e6
using namespace std;

int main(){
  int n, m;
  while(1) {
    scanf("%d %d\n", &m, &n);
    if(n == 0)break;
    vector<bool> isBoring(MAX, false);
    for (int i = 0; i < n; i++) {
      while(isBoring[m] == true) m++;
      for (int j = m; j < MAX; j+=m) {
        isBoring[j] = true;
      }
    }
    while(isBoring[m] == true)m++;
    std::cout << m << std::endl;
  }
  return 0;
}

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

using namespace std;

#define DIM 1009
#define MODULO 1000000007
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pairll pair<long long,long long>
#define fi first
#define se second

long long i,j,k,l,n,m;

long long dp[DIM][DIM],a[DIM][DIM];

string s;

int main()
{
    cin>>n>>m;
    for(i=1;i<=n;i++){
        cin>>s;
        for(j=0;j<m;j++){
            if(s[j]=='#')a[i][j+1]=1;
        }
    }

    if(a[1][1]!=1)dp[1][1]=1;
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            if(i==1 && j==1 || a[i][j]==1)continue;
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MODULO;
        }
    }

    cout<<dp[n][m]<<endl;

    return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
#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 fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>K;
    vec a(N), b(N);
    rep(i,N) cin>>a[i]>>b[i];
    vec ord(N);
    rep(i,N) ord[i] = i;
    sort(ord.begin(), ord.end(), [&](ll x, ll y){
        return a[x] < a[y];
    });
    ll num = 0;
    rep(i,N){
        ll id = ord[i];
        num += b[id];
        if(num >= K){
            cout<<a[id]<<endl;
            return 0;
        }
    }
}

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

int main(void){
    string s;
    vector<int> dict(26, 0);
    cin >> s;
    for (int i=0; i<s.size(); i++) dict[s[i]-'a'] = 1;
    for (int i=0; i<26; i++){
        if (dict[i] == 0){
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 3692
X, K, D = map(int, input().split())
ans = abs(abs(X) - D*K)

a = abs(X)//D
b = abs(X)%D
if (K - a)%2 == 1 and a < K:
    ans = D - b
elif (K - a)%2 == 0 and a < K:
    ans = b

print(ans)

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

public class Main {

	public static void main(String[] args) {
    
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		try {
			input = br.readLine();
			br.close();
		} catch (IOException e) {
		}

		String [] ab = input.split(" ");

		int a = Integer.parseInt(ab[0]);
		int b = Integer.parseInt(ab[1]);

        if(a < b){
            System.out.println("a < b");
        }


        if(a > b){
            System.out.println("a > b");
    
        }


        if(a == b){
            System.out.println("a == b");
        }
}
}



Measured memory_bytes: 24468
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
    int main() {
      int A,B;
      char op;
      cin >> A >> op >> B;
      
	if ( op == '+'){
      cout << A + B << endl;
      }
      else {
        cout << A - B << endl;
      }

      
    }

Measured memory_bytes: 256
use std::cmp::{max, min};
use std::collections::VecDeque;
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let s0 = read::<String>();
    let s = s0.chars().collect::<Vec<_>>();
    let t0 = read::<String>();
    let t = t0.chars().collect::<Vec<_>>();

    let mut last_i = usize::max_value();
    for i in 0..s.len() {
        if compare(&s, i, &t) {
            last_i = i
        }
    }

    if last_i == usize::max_value() {
        println!("UNRESTORABLE")
    } else {
        let mut ss = s0.chars().collect::<Vec<_>>();
        for i in 0..t.len() {
            ss[last_i + i] = t[i]
        }
        for i in 0..ss.len() {
            if ss[i] == '?' {
                ss[i] = 'a'
            }
        }
        println!("{}", ss.into_iter().collect::<String>());
    }

    fn compare(s: &Vec<char>, i: usize, t: &Vec<char>) -> bool {
        for ii in 0..t.len() {
            if s.len() <= i + ii {
                return false;
            }

            if s[i + ii] == '?' {
                // pass
            } else if s[i + ii] == t[ii] {
                // pass
            } else {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 4352
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N = input()
DP = [0, 0, 0]
for _ in range(N):
    a, b, c = map(int, raw_input().split())
    DP_ = [0, 0, 0]
    DP_[0] = a + max(DP[1], DP[2])
    DP_[1] = b + max(DP[0], DP[2])
    DP_[2] = c + max(DP[0], DP[1])
    DP = DP_

print max(DP)

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

int main() {
  long N;
  cin>>N;
  vector<long> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
    }
    sort(a.begin(),a.end());
  long ans=0;
for(int i=0;i<N;i++){
  for(int  j=i+1;j<N;j++){
    for(int k=j+1;k<N;k++){
      int  x=a[i],y=a[j],z=a[k];
      if(x!=y&&y!=z&&z!=x){
        if(x+y>z) ans++;
      }
    }
  }
}
cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define mp make_pair
#define ft first
#define sd second
#define ue printf("what?\n");
#define pb push_back
#define oo 0x3F3F3F3F	
#define OO 3000000000000000000LL
#define EPS 0
#define maxn 200000
#define pi acos(-1)
#define mod 1000000007
#define mdc __gcd
#define N 600005
#define M 20
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

string f(int n)
{
	if(n == 0) return "0";
	string ans;
	int resto;
	while(n != 0)
	{
		resto = n % (-2);
		n /= (-2);
		if(resto == -1) n++;
		if(resto == 0) ans += '0';
		else ans += '1';
	}
	reverse(ans.begin(), ans.end());
	return ans;
}
			

main()
{
	int n;
	scanf("%d", &n);
	cout << f(n) << endl;
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=2e5+5;
ii a[mxn];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i].se >> a[i].fi;
	}
	sort(a,a+n);
	bool ok=1;
	ll now=0LL;
	for(int i=0; i<n&&ok; i++){
		now += a[i].se;
		if(now>a[i].fi)ok=0;
	}
	if(ok)cout << "Yes \n";
	else cout << "No \n";
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 5176
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
	string a;
	int k;
	cin >> a >> k;
	int ans = 1;
	int b = a.size();
	for (int i = 0;i < min(k,b);i++) {
		if (a[i] != '1') {
			ans = stoi(a.substr(i,1)); 
			break;
		}
		// cout << a.substr(i,1) << " ";
	}
	cout << ans;
}

Measured memory_bytes: 256
program scoring
    implicit none
    integer D, day, score, wait, i
    integer, dimension(26) :: c, last
    integer, dimension(:, :), allocatable :: satisfy
    integer, dimension(:), allocatable :: typ

    read *, D
    read *, c
    last(:) = 0

    allocate(satisfy(26, D))
    allocate(typ(D))

    read *, satisfy
    read *, typ

    score = 0
    do day=1,D
        last(typ(day)) = day
        wait = 0
        do i=1,26
            wait = wait + c(i)*(day - last(i))
        enddo
        score = score + satisfy(typ(day), day) - wait
        print *, score
    enddo
end program scoring

Measured memory_bytes: 2884
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>

using namespace std;

int main(){
    string S;
    cin >> S;
    size_t N = S.length();
    unsigned int sum1 = 0, sum2 = 0;

    /* pattern 1 */
    for(int i = 0; i < N; i++){
        if(i % 2 == 0){
            if(S[i] == '0') sum1++;
        }
        else{
            if(S[i] == '1') sum1++;
        }
    }
    

    /* pattern 2 */
    for(int i = 0; i < N; i++){
        if(i % 2 == 1){
            if(S[i] == '0') sum2++;
        }
        else{
            if(S[i] == '1') sum2++;
        }
    }

    cout << min(sum1, sum2) << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair

int main() {
    ios_base::sync_with_stdio();
    cin.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a*n,b);
    return 0;
}
// 1 3 6 9 15 16 20 25


Measured memory_bytes: 256
w,h,n=map(int,input().split())
w1,h1,w2,h2=0,0,w,h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:w1=max(w1,x)
    elif a==2:w2=min(w2,x)
    elif a==3:h1=max(h1,y)
    elif a==4:h2=min(h2,y)
if w2-w1<0 or h2-h1<0:print(0)
else:print((w2-w1)*(h2-h1))

Measured memory_bytes: 3188
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;

#define LL long long
#define DB double
#define MAXM 2000
#define MAXN 4000000
#define MOD 1000000007
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000000000000000
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
	LL x=0,F=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*F;
}

int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(int a,int b){return (1LL*a*b)%MOD;}
int fst_pow(int a,int b){
	int res=1;
	while(b){
		if(b&1)res=mul(res,a);
		a=mul(a,a),b>>=1;
	}
	return res;
}

int n,k;
int fac[MAXN+5],ifac[MAXN+5];
int f[MAXM+5][MAXM+5];

void prepare(){
	fac[0]=1;
	for(int i=1;i<=MAXN;i++)fac[i]=mul(fac[i-1],i);
	ifac[MAXN]=fst_pow(fac[MAXN],MOD-2);
	for(int i=MAXN;i>=1;i--)ifac[i-1]=mul(ifac[i],i);
}
int Comb(int a,int b){
	return mul(fac[a],mul(ifac[b],ifac[a-b]));
}

int main(){
	n=read(),k=read();
	if(k==1){puts("1");return 0;}
	prepare();
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++){
			f[i][j]=f[i-1][j];
			if(j)f[i][j]=add(f[i][j],mul(mul(f[i][j-1],n-j+1),Comb(n*k-i-(k-1)*(j-1)-1,k-2)));
		}
	printf("%d",f[n][n]);
} 

Measured memory_bytes: 48740
n=int(input())
a=input()
b=input()
c=input()
al=list(a)
bl=list(b)
cl=list(c)

count=0

for i in range(n):
    if al[i]==bl[i]:
        if al[i]==cl[i]:
            plus=0
        else:
            plus=1
    elif bl[i]==cl[i]:
        plus=1
    elif al[i]==cl[i]:
        plus=1
    else:
        plus=2
        
    count+=plus
    
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll mod = 1000000007;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int r, d, x;
	cin >> r >> d >> x;
	int s = x;
	for (int i = 0; i < 10; i++) {
		s = s * r - d;
		cout << s << '\n';
	}
	
}

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

using int64 = long long;

int main() {
  int64 n;
  string s;
  cin >> n >> s;

  int64 r = 0;
  int64 g = 0;
  int64 b = 0;
  for (char& c : s) {
    switch (c) {
    case 'R': ++r; break;
    case 'G': ++g; break;
    case 'B': ++b; break;
    }
  }
  int64 all = r * g * b;
  for (int64 d = 1; d <= n / 2; ++d) {
    for (int64 i = 0; i + 2 * d < n; ++i) {
      int j = i + d;
      int k = j + d;
      if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i])
        --all;
    }
  }
  cout << all << "\n";
  
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int S = 0;
  vector<int> vecA(N-1), vecB(N), vecC(N-1);
  for(int i=0; i<N-1; i++){
    cin >> vecA.at(i);
  }
  int A;
  cin  >> A;
  for(int i=0; i<N; i++){
    cin >> vecB.at(i);
    S += vecB.at(i);
  }
  for(int i=0; i<N-1; i++){
    cin >> vecC.at(i);
  }
  for(int i=0; i<N-2; i++){
    if(vecA.at(i+1)-vecA.at(i) == 1){
      int a = vecA.at(i)-1;
      S += vecC.at(a);
    } 
  }
  if(A - vecA.at(N-2) == 1){
    S += vecC.at(vecA.at(N-2)-1);
  }
  cout << S << endl;
}
  
  
    
  


Measured memory_bytes: 256