akhauriyash/Code-Regression huggingface dataset:
package main

import(
      "fmt"
      "bufio"
      "io"
      "os"
      "strconv"
)

func main(){
  defer stdout.Flush()
  s := readString()
  ans := 0
  for i:=0; i<4; i++ {
    if s[i]=='2' {
      ans++
    }
  }
  fmt.Println(ans)
}

//==========================================================

type pair struct{
  first, second int
}

type pairSlice []pair

func (p pairSlice) Len() int{
  return len(p)
}
 
func (p pairSlice) Less(i, j int) bool{
  return p[i].second > p[j].second
}
 
func (p pairSlice) Swap(i, j int){
  p[i], p[j] = p[j], p[i]
}

//====  ↓↓↓ Scanner ↓↓↓  ====================================

var (
  readString func() string
  stdout     *bufio.Writer
)
 
func init() {
  readString = newReadString(os.Stdin)
  stdout = bufio.NewWriter(os.Stdout)
}
 
func newReadString(ior io.Reader) func() string {
  r := bufio.NewScanner(ior)
  r.Buffer(make([]byte, 1024), int(1e+11))
  r.Split(bufio.ScanWords)
 
  return func() string {
    if !r.Scan() {
      panic("Scan failed")
    }
    return r.Text()
  }
}
 
func readInt() int {
  return int(readInt64())
}
 
func readInt64() int64 {
  i, err := strconv.ParseInt(readString(), 0, 64)
  if err != nil {
    panic(err.Error())
  }
  return i
}
 
func readIntSlice(n int) []int {
  b := make([]int, n)
  for i := 0; i < n; i++ {
    b[i] = readInt()
  }
  return b
}
 
func readLengthAndSlice() []int {
  n := readInt()
  return readIntSlice(n)
}

//====  ↓↓↓ template functions ↓↓↓  ===========================

//min max
func minInt(a, b int) int{
  if a < b {
    return a
  }
  return b
}

func minInt64(a, b int64) int64{
  if a < b {
    return a
  }
  return b
}

func minFloat64(a, b float64) float64{
  if a < b {
    return a
  }
  return b
}

func maxInt(a, b int) int{
  if a > b {
    return a
  }
  return b
}

func maxInt64(a, b int64) int64{
  if a > b {
    return a
  }
  return b
}

func maxFloat64(a, b float64) float64{
  if a > b {
    return a
  }
  return b
}

//abs
func absInt(x int) int{
  if x < 0 {
    return -x
  }
  return x
}

func absInt64(x int64) int64{
  if x < 0 {
    return -x
  }
  return x
}

func absFloat64(x float64) float64{
  if x < 0 {
    return -x
  }
  return x
}

//gcd lcm
func gcdInt(a, b int) int{
  if b == 0 {
    return a
  }else{
    return gcdInt(b, a%b)
  }
}

func gcdInt64(a, b int64) int64{
  if b == 0 {
    return a
  }else{
    return gcdInt64(b, a%b)
  }
}

func lcmInt(a, b int) int{
  return a*b/gcdInt(a, b);
}

func lcmInt64(a, b int64) int64{
  return a*b/gcdInt64(a, b);
}

func swapInt(x, y *int){
  *x, *y = *y, *x
}

func swapInt64(x, y *int64){
  *x, *y = *y, *x
}

func swapFloat64(x, y *float64){
  *x, *y = *y, *x
}


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

using namespace std;

int main() {
    unsigned int a, b;
    cin >> a >> b;

    bitset<32> bsta(a), bstb(b);
    cout << (bsta & bstb) << endl;
    cout << (bsta | bstb) << endl;
    cout << (bsta ^ bstb) << endl;
    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x) {cout << #x << " = " << (x) << endl;}


int main() {
    LL N, W;
    cin >> N >> W;
    VI w(N + 1), v(N + 1);
    LL V = 0;
    FOR(i, 1, N + 1) {
        cin >> w[i] >> v[i];
        V += v[i];
    }

    VVI dp(N + 1, VI(V + 1, W + 1));
    dp[0][0] = 0;
    REP(i, N) {
        REP(j, V + 1) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if (j + v[i + 1] <= V) {
                dp[i + 1][j + v[i + 1]] = min(dp[i + 1][j + v[i + 1]], dp[i][j] + w[i + 1]);
            }
        }
    }

    for (LL j = V; j >= 0; --j) {
        LL min_w = LLONG_MAX;
        REP(i, N + 1) min_w = min(min_w, dp[i][j]);
        if (min_w <= W) {
            cout << j << endl;
            break;
        }
    }
	
    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
set<ll> st;
map<char, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

Weight dist[100005];
typedef pair<Weight, Edge> P;

int main()
{
	string a[60], b[60];
	ll n, m;
	cin >> n >> m;
	REP(i, n) cin >> a[i];
	REP(i, m) cin >> b[i];
	if(n==1)
	{
		if (a[0][0] == b[0][0]) cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	REP(i,n-m) REP(j,n-m)
	{
		bool flg = true;
		FOR(x,i,i+m) FOR(y,j,j+m)
		{
			if(a[x][y]!=b[x-i][y-j])
			{
				flg = false;
				x = i + m;
				y = j + m;
			}
		}
		if(flg)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,k;
    while(cin>>n>>k){
        vector<int> v(n+5),w(n+5),dp(k+5,0);
        for(int i=0;i<n;i++){
            cin>>w[i]>>v[i];
        }int ans=0;
        for(int i=0;i<n;i++){
            for(int j=k;j>=w[i];j--){
                dp[j]=max(dp[j-w[i]]+v[i],dp[j]);
                ans=max(ans,dp[j]);
            }
        }cout<<ans<<"\n";
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	vector<double> v(N);
	rep(i, N) {
		cin >> v.at(i);
	}
	reverse(v.begin(), v.end());
	string an = "Yes";
	rep(i, N-1) {
		if (v.at(i) >= v.at(i + 1)) {

		}
		else if(v.at(i)==v.at(i+1)-1){
			v.at(i+1)--;
		}
		else {
			an = "No";
			break;
		}
	}
	cout << an << endl;
	}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cstring>

using namespace std;
unordered_map<long long, int> exist;

int memo[5050][5050];
vector<int> vs;

int f(int x, int y) {
    if( memo[x][y] != -1 ) return memo[x][y];
    if (exist.count(2 * vs[y] - vs[x]))
        return memo[x][y] = f(y, exist[2 * vs[y] - vs[x]]) + 1;
    return 1;
}

int main() {
    memset(memo, -1, sizeof(memo));
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        exist[v] = i;
        vs.push_back(v);
    }
    int ans = 0;
    for (int i = 0; i < vs.size(); i++) {
        for (int j = 0; j < vs.size(); j++) {
            if (i != j) ans = max(ans, f(i, j) + 1);
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 103052
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    int n;
    int[][] as;
    void run() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        as = new int[n][2];
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            as[i][1] |= 1 << i;
            for (int j = 0; j < a; j++) {
                int x = sc.nextInt() - 1, y = sc.nextInt();
                as[i][y] |= 1 << x;
            }
        }
        debug(as);

        int ans = 0;
        for (int i = 0; i < (1 << n); i++) {
            if (ok(i)) ans = Math.max(ans, Integer.bitCount(i));
        }

        System.out.println(ans);
    }

    boolean ok(int x) {
        int a = 0, b = 0;
        for (int i = 0; i < n; i++) {
            if (((x >> i) & 1) == 1) {
                a |= as[i][1];
                b |= as[i][0];
            }
        }
        debug(Integer.toBinaryString(x), Integer.toBinaryString(a), Integer.toBinaryString(b));
        debug(a ^ x, b & x);
        if ((a ^ x) > 0) return false;
        if ((b & x) > 0) return false;
        return true;
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


Measured memory_bytes: 64652
from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

for i in a_list:
    print(all_count - c[i] + 1)


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

int main() {
    int i, n;
    char str[12], com[9];
    map<string, bool> T;

    cin >> n;
    for(i = 0; i < n; i++) { 
        cin >> com >> str;
        if(com[0] == 'i') {
            T[string(str)] = true;
        } else {
            if(T[string(str)]) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 47420
import Control.Monad
main = do
    n <- read <$> getLine :: IO Int
    mapM (putStrLn.reverse) (solve n)

solve :: Int -> [String]
solve 1 = ["a"]
solve n = [c:cs | cs <- solve (n-1),c <- ['a'..succ $ maximum cs],c <= 'z']

Measured memory_bytes: 10940
import math
N = int(input())
p = list(map(str, input().split()))
q = list(map(str, input().split()))

pval = [i for i in range(1, N+1)]
qval = [i for i in range(1, N+1)]

pcount, qcount = 0, 0
for x, y in zip(p, q):
    pval.remove(int(x))
    pcount += len([i for i in pval if i <= int(x)-1])*math.factorial(len(pval))
    qval.remove(int(y))
    qcount += len([i for i in qval if i <= int(y)-1])*math.factorial(len(qval))
    
print(abs(pcount-qcount))



Measured memory_bytes: 3064
#include "iostream"
#include "map"
#include "string"
using namespace std;
int main(void)
{
	int n;
	while (cin>>n,n) {
		map<char, char> m;
		for (int i = 0; i < n; i++) {
			char l,r; cin>>l>>r;
			m[l]=r;
		}
		string ans="";
		int num; cin>>num;
		while (num--) {
			char t; cin>>t;
			if(m.count(t)) ans+=m[t];
			else ans+=t;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1340
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    def bfs(a,b):
        bfs_map = [-1 for i in range(2*n+2)]
        q = [a]
        bfs_map[a] = 0
        while q:
            x = q.pop(0)
            for y in out[x]:
                if bfs_map[y] == -1:
                    q.append(y)
                    bfs_map[y] = bfs_map[x]+1
        if bfs_map[b] == -1:return 0
        d = bfs_map[b]
        path = [b]
        y = b
        while d > 0:
            for x in ent[y]:
                if bfs_map[x] == d-1:
                    path.insert(0,x)
                    y = x
                    d -= 1
                    break
        return path

    def ford_fulkerson(a,b,c):
        ans = 0
        while 1:
            path = bfs(a,b)
            if not path:break
            for i in range(len(path)-1):
                out[path[i]].remove(path[i+1])
                ent[path[i+1]].remove(path[i])
                if not c[path[i+1]][path[i]]:
                    c[path[i+1]][path[i]] = 1
                    out[path[i+1]].append(path[i])
                    ent[path[i]].append(path[i+1])
            ans += 1
        return ans
    n = I()
    r = LIR(n)
    b = LIR(n)
    c = [[0 for i in range(2*n+2)] for i in range(2*n+2)]
    out = [[] for i in range(2*n+2)]
    ent = [[] for i in range(2*n+2)]
    for i in range(n):
        c[0][i+1] = 1
        out[0].append(i+1)
        ent[i+1].append(0)
        for j in range(n):
            if r[i][0] < b[j][0] and r[i][1] < b[j][1]:
                c[i+1][n+j+1] = 1
                out[i+1].append(n+j+1)
                ent[n+j+1].append(i+1)
    for j in range(n):
        c[n+j+1][2*n+1] = 1
        out[n+j+1].append(2*n+1)
        ent[2*n+1].append(n+j+1)
    print(ford_fulkerson(0,2*n+1,c))
#D
def D():
    n = I()
    a = LI()
    b = LI()
    s = 0
    for i in range(n):
        s ^= b[i]
    ans = 0
    print(s)
    for i in range(n):
        s ^= a[i]
    print(s)

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 42864
/// referenced: https://beta.atcoder.jp/contests/abc045/submissions/1014360
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
main(){
  string S;
  cin>>S;
  int ans=0;
  int l=1<<S.size();
  for(int i=S.size()-1;i>=0;--i){
    ans+=l*(S[i]-'0');
    l=(10*l+(1<<S.size()))/2;
  }
  cout<<ans/2<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a + b >= 10) {
			System.out.println("error");
		} else {
			System.out.println(a + b);
		}
	}
}


Measured memory_bytes: 23252
N = int(input())
tasks = []
for i in range(0, N):
    tasks.append(list(map(int, input().split(' '))))
tasks = sorted(tasks, key=lambda x: x[1])
is_done = True
total = 0
for t in tasks:
    total += t[0]
    if total > t[1]:
        is_done = False
        break
if is_done:
    print('Yes')
else:
    print('No')

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

int main(){

    int N;
    cin >> N;
    vector<int> a(N);
    double ave = 0.;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        ave += a[i];
    }
    ave /= N;

    int index;
    double min = ave;
    for(int i = 0; i < N; i++){
        if(min > fabs(ave - a[i])){
            min = fabs(ave - a[i]);
            index = i;
        }
    }

    cout << index << endl;

    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


vector<int> dx{-1,0,1};
vector<int> dy{-1,0,1};

vector<vector<int>> G;
int w,h;

void dfs(vector<vector<int>> &G, int x, int y){
    if (G[y][x] == 1){
        G[y][x] = 0;

        REP(i,3){
            REP(j,3){
                int next_x = x+dx[i];
                int next_y = y+dy[j];
                if (i==1 && j==1)continue;
                if (0<=next_x && next_x<w && 0<=next_y && next_y<h){
                    dfs(G, next_x, next_y);
                }
            }
        }
    }
}

int main() {
    while(1){
        
        cin >> w >> h;
        if(w==0 && h==0) break;
        G.assign(h, vector<int>(w, 0));
        REP(i,h){
            REP(j,w){
                cin >> G[i][j];
            }
        }

        int count = 0;
        REP(i,h){
            REP(j,w){
                if (G[i][j] == 1){
                    count ++;
                    dfs(G, j, i);//G,w,h
                
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}



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

int main(){

    string a,b,c;
    cin >> a >> b >> c;

    if(a.back()==b[0]&&b.back()==c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;

int main(int argc, char const *argv[])
{
    string S;
    int K;
    cin >> K >> S;
    if (S.size()<=K)
    {
        cout << S;
    }
    else
    {
        cout << S.substr(0,K)+"...";
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>

int main(int argc, char* pArgv[])
{
  int n = 0;
  std::string s;

  std::cin >> n;
//  std::vector<int> a(n, 0);
  bool approved = true;

  for (int index = 0; index < n; index ++) {
    int v = 0;
    std::cin >> v;
//    a[n] = v;

    if (v % 2 == 0) {
      if (v % 3 != 0 && v % 5 != 0) {
        approved = false;
        break;
      }
    }
  }

  std::cout << (approved ? "APPROVED" : "DENIED") << std::endl;
  return 0;
}



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

int main(){
	string str;
	int n,a[8],i,max,min;
	cin>>n;
	while(n--){
		max = 0; min = 0;
		cin>>str;
		for(i = 0;i < 8;i++){
			a[i] = str[i] - '0';
		}

		sort(a,a+8,greater<int>());
		for(i = 0;i < 8;i++){
			max += a[i] * pow(10,7-i);
		}
		sort(a,a+8);
		for(i = 0;i < 8;i++){
			min += a[i] * pow(10,7-i);
		}
		cout<<max-min<<endl;
	}
	return 0;
}

Measured memory_bytes: 1264
#include<cstdio>
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int N,A,B,C,D[101],ans,cal;
signed main(){
    cin>>N>>A>>B>>C;
    for(int i=0;i<N;i++){
        cin>>D[i];
    }
    sort(D,D+N);
    reverse(D,D+N);
    ans=C;
    for(int i=0;i<N;i++){
        ans+=D[i];
        cal=max(cal,ans/(A+B*(i+1)));
    }
    cout<<cal<<endl;
    return 0;
}

Measured memory_bytes: 1172
#include<stdio.h>

int main(void){
    int n,m,i;
    int l,r,rmin=100000,lmax=0;
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d %d",&l,&r);
        if(l>lmax){
            lmax=l;
        }
        if(r<rmin){
            rmin=r;
        }
    }
    if(lmax>rmin){
        printf("0");
    }else if(n<lmax){
        printf("0");
    }else if(n<=rmin){
        printf("%d",n-lmax+1);
    }else{
        printf("%d",rmin-lmax+1);
    }
    return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	vector<int> a(3);
	for (int i=0; i<3; i++) cin>>a[i];
	sort(a.begin(), a.end());
	cout << (a[2]==a[1]+a[0] ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
S=input()
n=len(S)
dai='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
sho='abcdefghijklmnopqrstuvwxyz'

out='AC'
if S[0]!='A':
  out='WA'
  
counter=0
ind=0
for i in range(2, n-1):
  if S[i]=='C':
    counter+=1
    ind=i
    
if counter!=1:
  out='WA'
  
for i in range(n):
  if i!=0 and i!=ind:
    for j in range(26):
      if S[i]==dai[j]:
        out='WA'
        
print(out)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define INF 1e9
using ll = std::int64_t;

template <class T>
bool chmax(T &a, const T &b);
template <class T>
bool chmin(T &a, const T &b);
//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b);
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb);
//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str);
//素数判定
bool is_prime(std::int64_t n);
// 約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n);
// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n);

//10^9 + 7
#define yojo 1000000007
#define MAX_NUM 200001

void Main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a <= c && b >= c)
  {
    std::cout << "Yes" << std::endl;
  }
  else
  {
    std::cout << "No" << std::endl;
  }
  
  

  return;
}

int main()
{
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

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

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

//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b)
{
  // a >= b && b != 0
  std::int64_t c;
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//最大公約数安全版
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb)
{
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0)
  {
    return -1;
  }
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str)
{
  std::vector<std::pair<char, std::int64_t>> data;
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++)
  {
    if (i == str.size())
    {
      data.push_back(make_pair(str[i - 1], count));
      break;
    }
    else if (now != str[i])
    {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return data;
}

//素数判定
bool is_prime(std::int64_t n)
{
  for (std::int64_t i = 0; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      return false;
    }
  }

  return n != 1;
}

//約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n)
{
  std::vector<std::int64_t> res;
  for (int i = 0; i < n; i++)
  {
    if (n % i == 0)
    {
      res.push_back(i);
      if (i != n / i)
        res.push_back(n / i);
    }
  }
  return res;
}

// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n)
{
  std::map<std::int64_t, std::int64_t> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ++res[i];
      n /= i;
    }
  }

  if (n != 1)
  {
    res[n] = 1;
  }

  return res;
}

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

int a,b,x,sum;

int main()
{
	scanf("%d%d",&a,&b);
	sum = a + b;
	if(a == b)
		printf("%d\n",a);
	else if(sum % 2 == 0)
	{
		x = sum / 2;
		printf("%d\n",x);
	}
	else{
		x = sum / 2 + 1;
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  int d,t,s;
  cin >> d >> t >> s;
  if((d-1)/s<t)
  cout << "Yes" << endl;
  else
  cout << "No" << endl;
}



Measured memory_bytes: 3596
def numcount(x):
    ans=[0]*n
    res=1
    for i in range(n-1):
        if x[i]!=x[i+1]:
            ans[x[i]-1]=res
            res=0
        res+=1
    ans[x[n-1]-1]=res
    return ans

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

a2=numcount(a)
b2=numcount(b)
ans1=False
for i in range(n):
    if a2[i]+b2[i]>n:
        ans1=True
        break


ans2=a2[0]
res=a2[0]
for i in range(n-1):
    res+=a2[i+1]-b2[i]
    ans2=max(ans2,res)


if ans1:
    print("No")
else:
    print("Yes")
    c=[0]*n
    for i in range(n):
        c[(i+ans2)%n]=b[i]
    print(" ".join([str(n) for n in c]))


Measured memory_bytes: 115496
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	const int A = 10000;
	const int B =  5000;
	const int C =  1000;
	int z;
	int ans_x = -1;
	int ans_y = -1;
	int ans_z = -1;

	int N;
	int Y;
	
	cin >> N >> Y;

	// ちょうどYになる組み合わせを検索
	for (int i = 0; i <= N; i++) {
		
		for (int j= 0; j <= N - i; j++) {

			z = N - i - j;

			if (A * i + B * j + C * z == Y) {
				
				ans_x = i;
				ans_y = j;
				ans_z = z;

			}
		}
	}

	cout << ans_x << " " << ans_y << " " << ans_z << endl;

	return 0;
}

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

void	dfs(const Graph &graph, int v, vector<int> &color_vec, int color)
{
	color_vec.at(v) = color;
	for (int u : graph.at(v)) {
		if (color_vec[u] >= 0) continue;
		dfs(graph, u, color_vec, 1 - color);
	}
}	

int	short_long_case(int N, const vector<int> &short_vec, 
					const vector<int> &long_vec)
{
	vector<int> perm(N, -1);
	int	s_size = short_vec.size();
	int	s_idx = 0, l_idx = 0;
	int num;
	for (int i = 0; i < N; ++i) {
		num = i + 1;
		if (num % 3 == 0 && s_idx < s_size) {
			perm.at(short_vec.at(s_idx)) =num;
			++s_idx;
		} else {
			perm.at(long_vec.at(l_idx)) =num;
			++l_idx;
		}
	}
	for (int i = 0; i < N; ++i) {
		if (i == 0)
			cout << perm.at(i);
		else if (i == N - 1)
			cout << " " << perm.at(i) << endl;
		else
			cout << " " << perm.at(i);
	}
	return 0;
}

int	other_case(int N, const vector<int> &blue_vec, 
				const vector<int> &red_vec)
{
	vector<int> perm(N, -1);
	int	b_size = blue_vec.size();
	int	r_size = red_vec.size();
	int	b_idx = 0, r_idx = 0;
	int	num;
	for (; b_idx < b_size && (num = 3 * b_idx + 1) <= N; ++b_idx) {
		perm.at(blue_vec.at(b_idx)) = num;
	}
	for (; r_idx < r_size && (num = 3 * r_idx + 2) <= N; ++r_idx) {
		perm.at(red_vec.at(r_idx)) = num;
	}
	for (num = 3; num <= N; num += 3) {
		if (b_idx < b_size) {
			perm.at(blue_vec.at(b_idx)) = num;
			++b_idx;
		} else {
			perm.at(red_vec.at(r_idx)) = num;	
			++r_idx;
		}
	}
	for (int i = 0; i < N; ++i) {
		if (i == 0)
			cout << perm.at(i);
		else if (i == N - 1)
			cout << " " << perm.at(i) << endl;
		else
			cout << " " << perm.at(i);
	}
	return 0;
}

int	main()
{
	int	N;
	cin >> N;
	Graph graph(N);
	int a, b;
	for (int i = 0; i < N-1; ++i) {
		cin >> a >> b;
		--a; --b;
		graph.at(a).push_back(b);
		graph.at(b).push_back(a);
	}
	vector<int> color_vec(N, -1);
	dfs(graph, 0, color_vec, 0);
	vector<int> blue_vec;
	vector<int> red_vec;
	for (int i = 0; i < N; ++i) {
		if (color_vec.at(i) == 1)
			red_vec.push_back(i);
		else
			blue_vec.push_back(i);
	}
	if (red_vec.size() <= static_cast<size_t>(N / 3))
		return short_long_case(N, red_vec, blue_vec);
	if (blue_vec.size() <= static_cast<size_t>(N / 3))
		return short_long_case(N, blue_vec, red_vec);
	return other_case(N, blue_vec, red_vec);
}	



Measured memory_bytes: 18676
#include <stdio.h>
#include <iostream>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
#include <vector>
#include <string.h>
#define mem(x,b) memset(x,b,sizeof(x))
#define mp(a,b) make_pair(a,b)
#define debug(a) cout<<a<<endl
#define maxn 200005
using namespace std;
typedef long long ll;
typedef double db;
const int mod=1e9+7;
ll a[maxn];
ll b[maxn];
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}
ll qkp(ll a,ll b){
    ll res=1,t=a;
    while(b){
        if(b&1){
            res*=t;
            res%=mod;
        }
        b>>=1;
        t*=t;
        t%=mod;
    }
    return res;
}
int main()
{
	map<pair<ll,ll>,int>mp;
    int n;scanf("%d",&n);
    ll ans=1,sk=0;
    for(int i=1;i<=n;i++){
    	scanf("%lld%lld",&a[i],&b[i]);
        ll t=gcd(a[i],b[i]);
        if(t!=0){
            a[i]/=t;
            b[i]/=t;
        }
        if(a[i]<0){
            a[i]=-a[i];
            b[i]=-b[i];
        }       
        if(a[i]==0&&b[i]>0){
            b[i]=-b[i];
        }
        if(mp.count(make_pair(a[i],b[i]))){
            mp[make_pair(a[i],b[i])]++;
        }else{
            mp[make_pair(a[i],b[i])]=1;
        }
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        ll x=(*it).first.first;
        ll y=(*it).first.second;
        if(x==0&&y==0){
            continue;
        }
        ll num=(*it).second;
        ll as=qkp(2,num);
        mp[make_pair(x,y)]=0;
        if(x>0&&y>0){
            ll t=x;
            x=y;
            y=-t;
        }else{
            ll t=x;
            x=-y;
            y=t;
        }
        if(mp.count(make_pair(x,y))){
            as+=qkp(2,mp[make_pair(x,y)])-1;
            as%=mod;
            mp[make_pair(x,y)]=0;
        }
        ans*=as;
        ans%=mod;
    }
    ans--;
    ans+=mp[make_pair(0,0)];
    ans%=mod;
    if(ans<0)ans+=mod;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 19276
package main

import (
  "fmt"
  "sort"
)

func main() {
	var a,b,c,d,e int
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Scan(&c)
  fmt.Scan(&d)
  fmt.Scan(&e)

  k := make([]int, 5)
  n := make([]int, 5)
  t := make([]int, 120)
  m := 0
  
  k[0]=a
  k[1]=b
  k[2]=c
  k[3]=d
  k[4]=e
  
  sort.Ints(k)
  
  for j:=0; j<5; j++ {
    n[0] = k[j]
    for jj:=0; jj<5; jj++ {
      if jj != j {
        n[1] = k[jj]
        for jjj:=0; jjj<5; jjj++ {
          if jjj != jj && jjj!= j {
            n[2] = k[jjj]
            for jjjj:=0; jjjj<5; jjjj++ {
              if jjjj != jjj && jjjj != jj && jjjj != j{
                n[3] = k[jjjj]
                for jjjjj:=0; jjjjj<5; jjjjj++ {
                  if jjjjj != jjjj && jjjjj != jjj && jjjjj != jj && jjjjj != j {
                    n[4] =k[jjjjj]
                    for i:=0; i<5; i++ {
    		          t[m] += n[i]
        	          if i != 4 && t[m] % 10 !=0 {
          		        t[m] += 10 - ( t[m] % 10 )
                      }
                    }
                    m++
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  sort.Ints(t)
  
  fmt.Println(t[0])
  
}

Measured memory_bytes: 512
def resolve():
    k, n = map(int, input().split())
    A = list(map(int, input().split()))
    B=[]
    for i in range(n-1):
        B.append(A[i+1]-A[i])
    B.append(k-A[n-1]+A[0])
    print(k-max(B))
resolve()

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

#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
//#define int long long
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 0
#endif
using namespace std;

template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << ": " << arg1 << endl;
}

template<typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = (int) 5e5 + 2;
int ar[NN];
int n, m;


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

    string s;
    cin >> s;
    if (s == "RRR"){
        cout << 3 << endl;
    }
    else if (s == "RRS" || s == "SRR"){
        cout << 2 << endl;
    }
    else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R'){
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
  int n,i,d;
  long long sum;
  sum=0;
  scanf("%d", &n);
  
  int h[n];
  
  for (i=0;i<n;i++)
  {
	scanf("%d",&h[i]);    
  }
  
  for (i=0;i<n-1;i++)
  {
   if (h[i]>h[i+1])
   {
	d=h[i]-h[i+1];
	h[i+1]=h[i+1]+d;
    sum=sum+d;
   }
  }
  printf("%lld",sum);
  return 0;
}

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

using namespace std;

int main(void){
    string s;
    cin>>s;
    int odd0=0,even0=0,odd1=0,even1=0,ssize=s.size();
    for(int i=0;i<ssize;i++){
        if(i%2==0){
            if(s[i]=='0'){
                even0++;
            }else{
                even1++;
            }
        }else{
            if(s[i]=='0'){
                odd0++;
            }else{
                odd1++;
            }
        }
    }
    int result=odd0+even1<=odd1+even0?odd0+even1:odd1+even0;
    cout<<result<<endl;
    return 0;
}

Measured memory_bytes: 512
/*input

*/

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long int ull;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define fi first
#define se second
#define INF    1<<30
#define NEGINF -(1<<30)
#define LINF   1<<60
#define EPS 1e-10
#define PI 2 * acos(0)
#define NULO -1
#define endl '\n'

const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int cmp(double x, double y = 0, double tol = EPS){ return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1; }

int main(){
  int n;
  long long x[200005];
  scanf("%d", &n);
  for(int i=0;i<n;i++) {
    scanf("%lli", &x[i]);
  }
  bool p=false;
  for(int i=n-1;i>=0;i-=2) {
    if(p) putchar(' ');
    printf("%lli", x[i]);
    p=true;
  }
  for(int i=(n&1)?1 : 0;i<n;i+=2) {
    if(p) putchar(' ');
    printf("%lli", x[i]);
    p=true;
  }
  putchar('\n');
  return 0;
}


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

int main(){
  int x, a, b, a1, b1;
  cin >> x >> a >> b;
  if(x < a) {
    a1 = a - x;
  } else {
    a1 = x - a;
  }
  if(x < b) {
    b1 = b - x;
  } else {
    b1 = x - b;
  }
  if(a1 < b1){
   cout << "A" << endl;
 } else {
  cout << "B" << endl;
 }
}

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

using namespace std;
typedef long long ll;
typedef pair <int,int> pa;
const int N = 2e5+100;

int n;
int a[N];
void solve()
{
   cin>>n;
   int z=0,pos=1;
   for(int i=1;i<=n;i++) {
    cin>>a[i];
    if(abs(a[i])>abs(z)) z=a[i],pos=i;
   }
   if(z<0) {
      cout<<2*n<<endl;
      cout<<pos<<" "<<1<<endl;
      cout<<pos<<" "<<1<<endl;
      for(int i=n;i>=2;i--) {
         cout<<1<<" "<<i<<endl;
         cout<<1<<" "<<1<<endl;
      }
   }
   else if(z>0) {
     cout<<2*n<<endl;
     cout<<pos<<" "<<n<<endl;
     cout<<pos<<" "<<n<<endl;
     for(int i=1;i<n;i++) {
        cout<<n<<" "<<i<<endl;
        cout<<n<<" "<<n<<endl;
     }
   }
   else cout<<0<<endl;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3624
_,*a=map(str.split,open(0))
U,R,D,L=S="URDL"
d={i:[]for i in S}
for*z,u in a:d[u]+=[*map(int,z)],
N,P,M=9e9,"x+y,","x-y,"
for A,B,S in(U,D,"x,y,"),(R,L,"y,x,"),(R,U,P+M),(D,L,P+M),(U,L,M+P),(R,D,M+P):
 n=p=-9e9
 for x,y,r in sorted(eval(f"[({S}Q)for P,Q in[(A,1),(B,0)]for x,y in d[P]]")):
  if r:n,p=x,y
  elif x==n:N=min(N,(y-p)*5)
print(["SAFE",N][N<9e9])


Measured memory_bytes: 131292
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;



int32_t main(){
    FAST;

    string s;   cin >> s;
    int ans = 0;

    for(int x=0;x<s.size()-1;x++){
        int fi = s[x] - '0';
        int se = s[x+1] - '0';

        if(se != (!fi)){
            se = !fi;
            ans++;
            s[x+1] = se + '0';
        }


    }

   //cout << s << '\n';
   cout << ans;
    

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N;
ll R, C;

struct ST {
  int n, i;
  ll x;
};

bool operator<(const ST& a, const ST&b){
  return a.x < b.x;
}

ll trans(ll x, ll y){
  if(y==0){
    return x;
  }
  if(x==R){
    return y+R;
  }
  if(y==C){
    return (R-x)+R+C;
  }
  if(x==0){
    return (C-y)+R+C+R;
  }
  return R+C+R+C;
}


int main(){

  cin >> R >> C >> N;

  vector<ST> v;
  rep(i,N){
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    bool flg1 = false, flg2 = false;
    if(x1==0 || x1==R || y1==0 || y1==C) flg1 = true;
    if(x2==0 || x2==R || y2==0 || y2==C) flg2 = true;
    if(flg1 && flg2){
      ST st1, st2;
      st1.i = i;
      st1.n = 0;
      st1.x = trans(x1, y1);

      st2.i = i;
      st2.n = 1;
      st2.x = trans(x2, y2);

      if(st1.x > st2.x) swap(st1.x, st2.x);
      v.push_back(st1);
      v.push_back(st2);
    }
  }
  sort(ALLOF(v));

  stack<ST> st;
  rep(i,v.size()){
    if(v[i].n == 0){
      st.push(v[i]);
    }else{
      if(st.size() == 0){
        cout << "NO" << endl;
        return 0;
      }
      ST a = st.top(); st.pop();
      if(a.i != v[i].i){
        cout << "NO" << endl;
        return 0;
      }
    }
  }

  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 6384
#include <cstdio>
#include <algorithm>
#include <functional>
#include <iostream>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;

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

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());

  int end_idx = max(s.length(), t.length());
  rep(i, end_idx) {
    if (s[i] < t[i]) {
      printf("Yes\n");
      return 0;
    }
    if (s[i] > t[i]) {
      printf("No\n");
      return 0;
    }
  }
  printf("No\n");
}


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

#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
#define M_PI 3.1415
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int n;
vector<pair<int ,int > > vec;

bool comp(pair<int, int> a, pair<int, int> b){
  if(a.S == b.S) return a.F < b.F;
  return a.S < b.S;
}

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

  cin >> n;
  for(int i=0;i<n;i++){
    int a, b;
    cin >> a >> b;
    vec.push_back({a, b});
  }

  sort(vec.begin(), vec.end(), comp);

  // for(auto i : vec) cout << i.F << " " << i.S << endl;

  int atual = 0;
  for(auto i : vec){
    atual += i.F;
    if(atual > i.S){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include<iomanip>
using namespace std;
using P = pair<int, int>;
using PP = pair<P, int>;
int MOD = 1000000007;


int K, X;

int main()
{
	cin >> K >> X;
	if (K * 500 >= X) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
# Original Submission At: https://atcoder.jp/contests/abc149/submissions/16823042
import sys
sys.setrecursionlimit(1000000)

x= int(input())

def prime_check(num,count):
    if (num % count) != 0:
        if num <= count**2:
            print(num)
        else:
            prime_check(num,count+1)
    else :
        prime_check(num+1,2)

if x==2 :
    print (2)
else:
    prime_check(x,2)


Measured memory_bytes: 9400
n,x,y = map(int, input().split())
x = x-1
y = y-1

k=[0]*n

for i in range(n-1):
  for j in range(i+1,n):
    m = min(j-i,abs(x-i)+1+abs(y-j))
    k[m] += 1

for i in range(1,n):
  print(k[i])

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

int main() {

    deque<int> DQ;
    int N, A[200001];
    cin >> N;
    for (int i=0;i<N;i++) {
        cin >> A[i];
    }

    for (int i=0;i<N;i++) {
        if (i%2==0) {
            DQ.push_back(A[i]);
        } else if (i%2==1) {
            DQ.push_front(A[i]);
        }
    }

    if (N%2==0) {
        for (int i=0;i<N;i++) {
            cout << DQ[i];
            if (i!=N-1) cout << " ";
        }
    } else {
        for (int i=N-1;i>=0;i--) {
            cout << DQ[i];
            if (i!=0) cout << " ";
        }
    }
}


Measured memory_bytes: 3840
from collections import defaultdict

n, m = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [[int(i) for i in input().split()] for i in range(m)]

D = defaultdict(int)

for a in A:
    D[a] += 1

for b, c in B:
    D[c] += b

E = [(k, v) for k, v in D.items()]
E.sort(reverse=True)

cnt = 0
ans = 0

for e, f in E:
    if cnt + f <= n:
        ans += f * e
        cnt += f
    else:
        ans += (n - cnt) * e
        break

print(ans)

Measured memory_bytes: 118168
def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  s = get_str
  if s == "Sunny"
    puts "Cloudy"
  elsif s == "Cloudy"
    puts "Rainy"
  else
    puts "Sunny"
  end
end

if __FILE__ == $0
  main
end

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main()
{
	int  h, w;

	while (true)
	{
		cin >> h >> w;

		if (h == 0 && w == 0)
		{
			break;
		}

		for (int i = 0; i < h; i++)
		{
				for (int j = 0; j < w; j++)
				{
					if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					{
						cout << "#";
					}
					else
					{
						cout << ".";
					}
				}
			cout << endl;
		}
		cout << endl;
	}
}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

int main()
{
    int n;
    cin >> n;
    
    cout << (n-1)/2 + 1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<set>


using namespace std;
using vi=vector<int>;
using si=set<int>;


class v_t
{
public:
	vi c, p;
	int x;
	v_t() : x(-1) {}
};


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vector<v_t> v(n+1);

		for(int i=0;i<n-1+m;i++)
		{
			int a, b;
			scanf("%d%d", &a, &b);
			v[a].c.push_back(b);
			v[b].p.push_back(a);
		}
		int r=1;
		for(;;)
		{
			if(v[r].p.size()<=0) break;
			r=v[r].p[0];
		}
		v[r].x=0;

		vi q={r};
		for(int i=0;i<q.size();i++)
		{
			int c=q[i];

			for(auto mc:v[c].c)
			{
				if(v[mc].p.size()<=1)
				{
					v[mc].x=c;
					q.push_back(mc);
				}
				else
				{
					for(int i=0;i<v[mc].p.size();i++)
					{
						if(v[mc].p[i]==c)
						{
							v[mc].p[i]=v[mc].p.back();
							break;
						}
					}
					v[mc].p.pop_back();
				}
			}
		}
		for(int i=1;i<=n;i++)
		{
			printf("%d\n", v[i].x);
		}
	}

	return 0;
}


Measured memory_bytes: 13052
import sys
import collections
input = sys.stdin.readline

A = input().strip()
counter = 0
B = collections.Counter(A)
if len(B.keys()) == 2:
    for value in B.values():
        if value == 2:
            counter += 1
    if counter ==2:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long n, ans;
    cin >> n;
    ans = 1;
    for (int i = 1; i <= n; i++)
    {
        ans *= i;
        ans %= 1000000000 + 7;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

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

using namespace std;

int x[6];

int main(){
	rep(i, 6){
		scanf("%d", &x[i]);
	}

	int s = 0;
	rep(i, 6){
		s += x[i];
	}
	printf("%d\n", s - *min_element(x, x + 4) - min(x[4], x[5]));
	return 0;
}

Measured memory_bytes: 2736
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
#define INF 1e18
using namespace std;

//-----------------------------------------------------------------------

typedef pair<int,int> pii;
struct edge{int to,cost;};

vector<int> dijkstra(vector<vector<edge> >& G,int s)
{
    int N=G.size();
    vector<int> dist(N,INF); dist[s]=0;
    priority_queue<pii,vector<pii>,greater<pii> > Q;
    Q.push(pii(0,s));

    while(!Q.empty())
    {
	int d=Q.top().first;
	int v=Q.top().second;
	Q.pop();

	if(d>dist[v]) continue;
	for(auto e:G[v]){
	    if(dist[e.to]>d+e.cost){
		dist[e.to]=d+e.cost;
		Q.push(pii(dist[e.to],e.to));
	    }
	}
    }
    return dist;

}

signed main()
{
    int N,M,s; cin>>N>>M>>s;
    vector<vector<edge> > G(N);
    REP(i,M){
	int a,b,c; cin>>a>>b>>c;
	G[a].push_back((edge){b,c});
    }

    vector<int> dist=dijkstra(G,s);
    REP(i,N){
	if(dist[i]==INF) cout<<"INF"<<endl;
	else cout<<dist[i]<<endl;
    }
    
}



Measured memory_bytes: 19420
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
 
void solve() {
    int n;
    cin >> n;
 
  if(n%2==0)
    cout<<n<<" "<<n<<" "<<n/2<<"\n";
  else
  {
for (int i = 1; i <= 3500; i++)
        for (int j = i; j <= 3500; j++) {
            int a = i, b = j;
            int num = n * a * b;
            int deno = 4 * a * b - n * a - n * b;
            if (deno and num % deno == 0 and num / deno > 0) {
                cout << a << " " << b << " " << num/deno << endl;
                return;
            }
        }
  }
    
}
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int t = 1;
//    cin >> t;
 
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256