akhauriyash/Code-Regression huggingface dataset:
require 'set'

def check(arr)
  arr[1..8].all?{|i| arr[0] == i} &&
  arr[10..11].all?{|i| arr[9] == i} &&
  arr[13..14].all?{|i| arr[12] == i} &&
  arr[16..17].all?{|i| arr[15] == i} &&
  arr[19..20].all?{|i| arr[18] == i} &&
  arr[22..29].all?{|i| arr[21] == i} 
end

MV = [[0,1,2,14,18,27,28,29,15,20],
      [6,7,8,12,9,21,22,23,17,11],
      [0,3,6,9,15,23,26,29,20,17],
      [2,5,8,11,12,21,24,27,18,14]]
  
gets.to_i.times do
  cube = gets.split(" ").map(&:to_i)
  s = Set.new(cube)
  q = []
  q << [cube, 0]
  until q.empty?
    tmp, cnt = q.shift
    s.add(tmp)
    if check(tmp)
      p cnt
      break
    end
    MV.each do |arr|
      tmp2 = tmp.dup
      arr[0,5].zip(arr[5,5]).each do |a, b|
        tmp2[a], tmp2[b] = tmp2[b], tmp2[a]
      end
      unless s.include?(tmp2)
        q << [tmp2, cnt+1]
      end
    end
  end
end

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

int main(){
	std::string S;
	std::cin >> S;
  
  	if(S == "AAA" || S == "BBB"){
    	std::cout << "No" << std::endl; 
    }
  	else{
    	std::cout << "Yes" << std::endl;
    }
  
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

#define nl '\n'

#define PI 3.14159265

using namespace std;

string s;
char c;
int x, d = 754;

int main(){

    vector<char> v;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        v.push_back(s[i]);
    }

    for(int i = 0; i < s.length()-2; i++){
        x = ((v[i]-'0')*100) + ((v[i+1]-'0') * 10) + (v[i+2]-'0');
        // cout << x << nl;
        if(abs(753-x) < d){
            d = abs(753-x);
            // cout << d << " " << i << nl;
        }
    }

    cout << d;





}

//g++ -std=c++14 comp.cpp -o b; ./b.exe


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

pair<int, int> h[51], p[51];

int getMan(int i, int j){
	return abs(h[i].first - p[j].first) + abs(h[i].second - p[j].second);
}

int main() {
	int n, m, a, b;
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		cin >> a >> b;
		h[i] = MP(a, b);
	}
	for(int i = 0;i < m;i++){
		cin >> a >> b;
		p[i] = MP(a, b);
	}

	for(int i = 0;i < n;i++){
		int minDis = INF, point = 0;
		for(int j = 0;j < m;j++){
			int now = getMan(i, j);
			if(minDis > now){
				point = j + 1;
				minDis = now;
			}
		}
		cout << point << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;



int main() {
	int n,k,q;
	cin >> n>>k>>q;
	int a;
	vector<long long> score(n);

	for (int i = 0; i < q; i++) {
		cin >> a;
		score[a - 1] += 1;

		/*for (int j = 0; j < n; j++) {

			cout << j + 1 << "ばんめのひと　" << score[j] << endl;

		}*/

	}

	

	for (int i = 0; i < n; i++) {
		

		if (k-q+score[i]>0) {
			cout << "Yes" << endl;

		}
		else {
			cout << "No" << endl;
		}

		
	}


	//system("pause");
	return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    int L[M],R[M];
    for (int m=0; m<M; m++){
        cin >> L[m] >> R[m];
    }
    int l=1, r=N;
    for (int m=0; m<M; m++){
        if(L[m] > l) l=L[m];
        if(R[m] < r) r=R[m];
    }
    int res = r-l+1;
    if(res >= 0) cout << res << endl;
    else cout << 0 << endl;
}


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

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

using namespace std ;

# define Size 1000000

inline int readInt ( )  {
	register int x, c ;
	static char buf [Size], *ss, *tt ;
	# define pick( ) ( (ss == tt) ? ( tt = buf + fread ( ss = buf, 1, Size, stdin ), ( ss == tt ) ? -1 : *ss ++ ) : *ss ++ )
	while ( ! isdigit ( c = pick ( ) ) ) ;
	for ( x = -48 + c ; isdigit ( c = pick ( ) ) ; x = x * 10 + c - 48 ) ;
	return x ;
	# undef pick
}

inline void smin ( long long& d, long long x )  {  ( d > x ) ? d = x : 0 ;  }

const long long inf = ( ~0ull >> 1 ) ;
const int N = 200010 ;

int q [N] ;
bool inq [N] ;
long long a [N] ;

struct edge  {
	int to, w ; edge* nxt ;
} g [N], *head [N], *NewEdge ;

int main ( )  {
	int h, w, n ;
	h = readInt ( ), w =  readInt ( ), n = readInt ( ) ;
	NewEdge = g ;
	for ( int i = 0 ; i < n ; ++ i )  {
		int x = readInt ( ), y = readInt ( ), z = readInt ( ) ;
		-- x, -- y ;
		*( ++ NewEdge ) = ( edge ) {  h + y, z, head [x]  } ; head [x] = NewEdge ;
		*( ++ NewEdge ) = ( edge ) {  x, z, head [h + y]  } ; head [h + y] = NewEdge ;
	}
	for ( int i = 0, l = h + w ; i < l ; ++ i )  {
		if ( ! inq [i] )  {
			register edge* it ;
			register int fr ( 0 ), tl ( 0 ) ;
			a [i] = 0 ;
			q [++ tl] = i ;
			inq [i] = true ;
			while ( fr ^ tl )  {
				int u = q [++ fr] ;
				for ( it = head [u] ; it ; it = it -> nxt )  {
					int r = it -> to, v = it -> w ;
					if ( inq [r] )  {
						if ( a [u] + a [r] != v )  {
							return puts ( "No" ), 0 ;
						}
						continue ;
					}
					q [++ tl] = r ;
					inq [r] = true ;
					a [r] = v - a [u] ;
				}
			}
			long long m1 = inf, m2 = inf ;
			while ( tl )  {
				( q [tl] < h ) ? smin ( m1, a [q [tl --]] ) : smin ( m2, a [q [tl --]] ) ;
			}
			if ( m1 + m2 < 0 )  {
				return puts ( "No" ), 0 ;
			}
		}
	}
	return puts ( "Yes" ), 0 ;
}

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

int main() {

  int n;
  cin >> n;

  for(int q=0;q<n;q++) {

    int s;
    cin >> s;
    
    int t = s;
    int a[2],max;
    int count = 0;
    while(t >= 10) {
      count++;
     
      a[0] = t % 10;
      t /= 10;
      a[1]  = t;
      max = a[0] * a[1];
      int k = 10;
      // cout << a[0] <<"&"<< a[1] << "||"<<a[0]*a[1]<<endl;
      while(t) {
	a[0] += k*(t%10);
	k *=10;
	t /= 10;
	a[1] = t;
	//	cout << a[0] <<"&"<< a[1] << "||"<<a[0]*a[1]<<endl;
	if(a[0] * a[1] > max) max = a[0]*a[1];

      }
      t = max;

      if(count > 50000) break;

    }

    if(t < 10) cout << count << endl;
    else cout << -1 << endl;

  }

  return 0;
}

Measured memory_bytes: 1164
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
P = [0] * N
for i in range(Q):
    P[A[i] - 1] += 1
for i in range(N):
    if (K - (Q - P[i]) <= 0): print('No')
    else: print('Yes')


Measured memory_bytes: 8620
#include <iostream>
#include <unordered_set>

class Organizer {
private:
	std::unordered_set<std::string> _candidates;

	static std::string reverse(const std::string&);
	void into_departure(const std::string& a, const std::string& b);
	void into_storage(const std::string& a, const std::string& b);
public:
	void organize(const std::string& original);
	size_t count() const;
};

void Organizer::organize(const std::string& original) {
	for (size_t i = 1; i < original.length(); ++i) {
		into_storage(original.substr(0, i), original.substr(i));
	}
}

void Organizer::into_storage(const std::string& a, const std::string& b) {
	into_departure(a, b);
	into_departure(reverse(a), b);
	into_departure(a, reverse(b));
	into_departure(reverse(a), reverse(b));
}

std::string Organizer::reverse(const std::string& str) {
	return std::string(str.rbegin(), str.rend());
}

void Organizer::into_departure(const std::string& a, const std::string& b) {
	_candidates.emplace(a + b);
	_candidates.emplace(b + a);
}

size_t Organizer::count() const {
	return _candidates.size();
}

int main() {
	size_t count;
	std::cin >> count;
	for (size_t i = 0; i < count; ++i) {
		Organizer o;
		std::string line;
		std::cin >> line;
		o.organize(line);
		std::cout << o.count() << std::endl;
	}
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
   
  int N,H;
  cin >> N >> H;
  int a[N],b[N];
  rep(i,N) cin >> a[i] >> b[i];
  sort(a,a+N);
  sort(b,b+N);
  int bi=N-1;
  //  cout << b[bi] << endl;
  int ans=0;
  while(H>0){
    if(bi>=0){
      if(a[N-1]<b[bi]){
	H-=b[bi];
	bi--;
      }else{
	if(H%a[N-1]==0) ans+=H/a[N-1];
	else ans += H/a[N-1]+1;
	//	cout <<  H/a[N-1]<< endl;
	break;       	
      }
    }
    else{
      if(H%a[N-1]==0) ans+=H/a[N-1];
      else ans += H/a[N-1]+1;
      //      cout <<  H/a[N-1]<< endl;
      break;
    }
    ans++;
  }
  cout << ans << endl;

  
  return 0;

}


Measured memory_bytes: 1024
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7
import math
import statistics
n = I()
xl = LI()

# n人が消費する体力の総和の最小値
# 数直線上にn人が住んでいる
# i番目がXi
# n人全員が参加する集会
# 任意の整数値の座標で集会を開く。座標pで集会を開くときはi番目の人は(Xi-p))**2の体力を消費する。

xl_ceil_mean = math.ceil(statistics.mean(xl))
xl_floor_mean =math.floor(statistics.mean(xl))

sigma_pow1 = sum([(x-xl_ceil_mean)**2 for x in xl])
sigma_pow2 = sum([(x-xl_floor_mean)**2 for x in xl])

if sigma_pow1 > sigma_pow2:
    print(sigma_pow2)
else:
    print(sigma_pow1)

Measured memory_bytes: 10936
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner((System.in));
		String str1 = sc.next();
		String[] str2 = sc.next().split("");
		String key = "";
		String key1 = "";
		for(String str : str2) {
			key1 += str;
			key += "[" + str +  "\\?]";
		}
		Pattern p = Pattern.compile(key);
		for(int i = str1.length() - str2.length; i >= 0; i--) {
			Matcher m = p.matcher(str1.substring(i));
			if(m.find()) {
				System.out.println((str1.substring(0,i) + key1 + str1.substring(i + key1.length())).replace("?", "a"));
				//System.out.println(str1.substring(0,i+1) + key + str1.substring(i+1+key.length()));
				return;
			}
		}
		System.out.println("UNRESTORABLE");
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

vector<pint> vp[100001];
int d[100001];
int INF=1000100010;
int n;
int dijkstra(int st){
    priority_queue<pint,vector<pint>,greater<pint> > pq;
    rep(i,n) d[i]=INF;
    d[st]=0;
    pq.push(make_pair(0,st));
    while(!pq.empty()){
        pint pi=pq.top();pq.pop();
        int t=pi.second;
        if(d[t]<pi.first) continue;
        for(auto it:vp[t]){
            if(d[it.second]>d[t]+it.first){
                d[it.second]=d[t]+it.first;
                pq.push(make_pair(d[it.second],it.second));
            }
        }
    }
}
int dmg[100001];
int main(){
    int m,s,t,a,b;
    cin>>n>>m>>s>>t;
    --s,--t;
    rep(i,n) cin>>dmg[i];
    rep(i,m){
        cin>>a>>b;
        --a,--b;
        vp[a].pb(dmg[b],b);
    }
    rep(i,n-1){
        vp[i+1].pb(0,i);
    }
    dijkstra(s);
    cout<<d[t]<<endl;
    return 0;
}


Measured memory_bytes: 11232
#include <iostream>

using namespace std;

// 線形探索
int search(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while (A[i] != key) i++;
    return i != n;
}

int main() {
    int i, n, A[10000+1], q, key, sum = 0;

    cin >> n;
    for (i = 0; i < n; i++) cin >> A[i];

    cin >> q;
    for (i = 0; i<q; i++){
        cin >> key;
        if (search(A, n, key)) sum++;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3156
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		ArrayList<Integer> as = new ArrayList<>();
		for (int i=0; i<n; i++) {
			as.add(scanner.nextInt());
		}
		Collections.sort(as);

		int max = as.get(n-1);
		int cand = -1;
		int candabs = max*2;
		for (int a:as) {
			int abs = Math.abs(a*2-max);
			if (abs<candabs && a!=max) {
				cand = a;
				candabs = abs;
			}
		}
		System.out.println(max + " " + cand);
	}

}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

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

const int mod = 1000000007;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s, t;
    cin >> s;
    cin >> t;

    vector<string> candidate;

    int len_s = s.size();
    int len_t = t.size();


    for (int first = 0; first <= len_s - len_t; first++) {
        bool flag = true;
        for(int i = first; i < first + len_t; i++) {
            if (s.at(i) != t.at(i - first) && s.at(i) != '?'){
                flag = false;
                break;
            }
        }
        if (flag) {
            string s2 = s;
            for(int i = 0; i < len_t; i++) {
                s2.at(first + i) = t.at(i);
            }
            for(int i = 0; i < len_s; i++) {
                if (s2.at(i) == '?') s2.at(i) = 'a';
            }
            candidate.push_back(s2);
        }
    }

    if (candidate.empty()) {
        cout << "UNRESTORABLE" << endl;
    } else {
        sort(ALL(candidate));
        cout << candidate.at(0) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let a33: number[] = [];
    let n: number = 0;
    let bn: number[] = [];
    let ans: string = "";
    // init
    a33.push(... input.shift().split(" ").map(x => Number(x)));
    a33.push(... input.shift().split(" ").map(x => Number(x)));
    a33.push(... input.shift().split(" ").map(x => Number(x)));
    n = Number(input.shift());
    for (let nx = 0; nx < n; nx++) {
        bn[nx] = Number(input.shift());
        var bx = a33.indexOf(bn[nx]);
        if (0 <= bx) a33[bx] = 0;
    }
    ans = "No"
    if (a33[0] == 0 && a33[1] == 0 && a33[2] == 0) ans = "Yes";
    if (a33[3] == 0 && a33[4] == 0 && a33[5] == 0) ans = "Yes";
    if (a33[6] == 0 && a33[7] == 0 && a33[8] == 0) ans = "Yes";
    if (a33[0] == 0 && a33[3] == 0 && a33[6] == 0) ans = "Yes";
    if (a33[1] == 0 && a33[4] == 0 && a33[7] == 0) ans = "Yes";
    if (a33[2] == 0 && a33[5] == 0 && a33[8] == 0) ans = "Yes";
    if (a33[0] == 0 && a33[4] == 0 && a33[8] == 0) ans = "Yes";
    if (a33[2] == 0 && a33[4] == 0 && a33[6] == 0) ans = "Yes";
    // solve
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 29596
#include <stdio.h>
#include <string.h>
int main()
{
  int H, W, i, j;
  scanf("%d %d%*c", &H, &W);
  char arr[H+2][W+1];
  for (i=0; i<H+2; i++) {
    char str[102];
    if (i==0 || i==H+1) {
      for (j=0; j<W; j++) {
        str[j] = '#';
      }
      str[j] = '\0';
      strcpy(arr[i], str);
    } else {
      scanf("%s%*c", arr[i]);
    }
  }
  for (i=0; i<H+2; i++) {
    printf("#%s#\n", arr[i]);
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 


int32_t main() {
  fastio;
  ll a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;//Òç³ö»á±ä³É¸ºÖµ 
typedef long double ldb;
typedef unsigned long long ull;//×Ô¶¯È¡Ä£2^64 
const double pi=acos(-1.0);
const int mod = 1e9+7; // 998244353;
const int inf = 0x7fffffff;//2^31-1
const ll INF = 0x7fffffffffffffff;
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
//ll begin_time=clock();    ll end_time=clock();  cout<<"time = "<<end_time-begin_time<<" ms!"<<endl;
//bool operator < (const mmp &a) const{return x<a.x||x==a.x&&y<a.y;}       //map<int,map<int,int> >z;
//map<int,int>::iterator it;for(it=z.begin();it!=z.end();it++)printf("%d %d\n",it->first,it->second);
//ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}  //¿ìËÙÃÝÈ¡Ä£ 
//lower_bound(begin,end,num); µÚÒ»¸ö>=numµÄÊý×Ö upper_bound(begin,end,num); µÚÒ»¸ö>numµÄÊý×Ö,·µ»ØµØÖ·
//freopen("input.in","r",stdin);     freopen("output.out","w",stdout);      //ÎÄ¼þ¶ÁÐ´Ìá½» 
//reverse(s.begin(),s.end());   //·­×ª×Ö·û´®        floor(); ÏòÏÂÈ¡Õû  ceil(); ÏòÉÏÈ¡Õû
//ÊýÖáÉÏµÄn¸öµãÒÆ¶¯µ½Í¬Ò»Î»ÖÃ£¬ÒÆ¶¯µ½¸Ã×éÊý×ÖµÄÖÐÎ»ÊýµÄ×Ü¾àÀë×î¶Ì
//bool isPrime(int n){if(n==2||n==3)return 1;if(n%6!=1&&n%6!=5)return 0;
//int t=sqrt(n);for(int i=5;i<=t;i+=6)if(n%i==0||n%(i+2)==0)return 0;return 1;}//ÅÐ¶ÏËØÊý   


int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	ll a,b,c,d,e,f,g,T;   
	cin>>a>>b>>c>>d>>e;
	if(!a)cout<<1<<endl;
	else if(!b)cout<<2<<endl;
	else if(!c)cout<<3<<endl;
	else if(!d)cout<<4<<endl;
	else if(!e)cout<<5<<endl;
	
}



Measured memory_bytes: 3632
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int a[3000 * 100 + 5];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, ans = 0;
	cin >> n;
	for(int i = 0; i < 3 * n; i++)
		cin >> a[i];
	sort(a , a + 3 * n, greater < int > ());
	for(int i = 1; i < 2 * n; i += 2)
		ans += a[i];
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int a[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    scanf("%d",&k);
    printf("%d\n",a[k-1]);
    
    return 0;
}



Measured memory_bytes: 256
l = [1, 2, 3, 4, 5, 6, 7, 8, 9]
l_temp = [1, 2, 3, 4, 5, 6, 7, 8, 9]

def f(x):
    temp = list(str(x))
    t = int(temp[-1])
    if t == 0:
        return int(str(x) + str(t)), int(str(x) + str(t + 1))
    elif t == 9:
        return int(str(x) + str(t - 1)), int(str(x) + str(t))
    else:
        return int(str(x) + str(t - 1)), int(str(x) + str(t)), int(str(x) + str(t + 1))
       

while len(l) < 10 ** 5:
    temp = []
    for l_t in l_temp:
        tem = list(f(l_t))
        for t in tem:
            temp.append(t)
    for t in temp:
        l.append(t)
    l_temp = temp

K = int(input())
print(l[K-1])

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

d = dict(zip([i for i in range(1, N+1)], [[] for _ in range(N)]))

for i in range(N-1):
  u, v, w = map(int, input().split())
  d[u].append([v, w])
  d[v].append([u, w])

colors = [0 for i in range(N)]
l = [[1, 1]]
while l:
  node, parent = l.pop()
  edges = d[node]
  for v, w in edges:
    if v == parent:
      continue
    
    colors[v-1] = (colors[node-1]+w)%2
    l.append([v, node])

for c in colors:
  print(c)

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

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

  vector<int> p(n);
  int wrong = 0;
  for (int i = 0; i < n; i++){
    cin >> p.at(i);
    if (p.at(i) != i + 1){
      wrong++;
    }
    if (wrong > 2){
      break;
    }
  }

  if (wrong <= 2){
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
n,h = map(int,input().split())

info = [list(map(int,input().split())) for i in range(n)]

maxFuru = max(list(zip(*info))[0])


nageru = []
for i in range(n):
  if info[i][1] > maxFuru:
    nageru.append(info[i][1])
nageru = sorted(nageru)

nokori = h
ans = 0

while nokori>0:
  if nageru:
    nokori -= nageru[-1]
    del nageru[-1]
    ans += 1
  else:
    ans += -((-nokori)//maxFuru)
    nokori = 0

print(ans)

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

int main() {
	int i, x;
	
		cin >> x;

	for (i = 3;i<=x; i++) {

		if (i % 3 == 0 ) {
			cout << " " << i;
		}
		else if (i % 10 == 3) {
			cout << " " << i;
		}
		else if ((i / 10) % 10 == 3 || (i / 100) % 10 == 3 || (i / 1000) % 10 == 3) {
			cout << " " << i;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include <stdlib.h>
using namespace std;
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int n,k;
long long h[201010],ans;
int main(){
    cin >> n >> k;
    for(int i = 0;i<n;i++){
        cin >> h[i];
    }
if(k>=n){
    cout << 0 << endl;
    return 0;
}
qsort(h,n,sizeof(long long),compare_int);
/*for(int i=0;i<n;i++){
    cout << h[i] << endl;
}*/
for(int i=k;i<n;i++){
    ans += h[i];
}
cout << ans << endl;
return 0;
}

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

using namespace std;

int main() {
  long N;
  cin >> N;
  
  vector<long> amounts(N, 0l);
  long sum = 0;
  for (size_t n = 0; n < N; ++n) { cin >> amounts[n]; sum += amounts[n]; }

  vector<long> res(N, 0);
  res[0] = sum;
  for (size_t i = 1; i < N; i+= 2) res[0] -= amounts[i] * 2;
  for (size_t i = 1; i < N; ++i) res[i] = amounts[i-1] * 2 - res[i-1];
  
  cout << res[0];
  for (size_t i = 1; i < N; ++i) cout << " " << res[i];
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 2944
/**
 * 	author: MahfuzAhmed
 * 	created: 21.07.2019 
**/

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

typedef long long ll;
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int MAX_N = 1e6+5;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
       
    #ifdef _DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
	int n, a, b; cin >> n >> a >> b;
    
    cout << min(n*a, b) << "\n";
    

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <queue>
#include <utility>

using namespace std;

using ll = long long;
using Pll = pair<ll, ll>;

constexpr int MAX_N = 101*101;
constexpr int MAX_L = 100;

class Dijkstra {
    public:
    ll d[MAX_N];
    priority_queue< Pll, vector<Pll>, greater<Pll> > que;
    vector<tuple<int, int, int>> edges[MAX_N];

    Dijkstra(){}

    void dijkstra(ll start, int l){
        fill(d, d+MAX_N, 1LL<<60);
        d[start*(MAX_L+1) + l] = 0;
        que.push(Pll(0, start*(MAX_L+1) + l));

        while(!que.empty()){
            Pll v = que.top(); que.pop();
            int v_node = v.second/(MAX_L+1), v_l = v.second % (MAX_L+1);
            if(d[v.second] < v.first) continue;
            for(auto e: edges[v_node]){
                int e_node, e_dist, e_theives;
                tie(e_node, e_dist, e_theives) = e;

                // 護衛をつける
                // cerr << v_node << ", " << v_l << " -> " << e_node << ", " << e_dist << ", " << e_theives << endl;
                if(v_l-e_dist >= 0 && d[e_node*(MAX_L+1)+(v_l-e_dist)] > d[v.second]){
                    d[e_node*(MAX_L+1)+(v_l-e_dist)] = d[v.second];
                    que.push(Pll(d[e_node*(MAX_L+1)+(v_l-e_dist)], e_node*(MAX_L+1)+(v_l-e_dist)));
                }

                // 護衛をつけない
                if(d[e_node*(MAX_L+1)+v_l] > d[v.second] + e_theives) {
                    d[e_node*(MAX_L+1)+v_l] = d[v.second] + e_theives;
                    que.push(Pll(d[e_node*(MAX_L+1)+v_l], e_node*(MAX_L+1)+v_l));
                }
            }
        }
    }
};

ll solve(int n, int m, int l) {
    int a,b,d,e;
    Dijkstra dijkstra = Dijkstra();
    for(int i=0;i<m;++i) {
        cin >> a >> b >> d >> e;
        --a; --b;
        dijkstra.edges[a].push_back(make_tuple(b, d, e));
        dijkstra.edges[b].push_back(make_tuple(a, d, e));
    }

    dijkstra.dijkstra(0, l);

    // for(int i=0;i<n;++i) {
    //     for(int j=0;j<=l;++j) {
    //         cout << dijkstra::d[i*(MAX_L+1)+j] << " ";
    //     }
    //     cout << endl;
    // }
    
    ll ret = 1<<30;
    for(int i=0;i<=l;++i) {
        ret = min(ret, dijkstra.d[(n-1)*(MAX_L+1)+i]);
    }
    return ret;
}

int main() {
    int n,m,l;
    while(cin >> n >> m >> l && n) {
        cout << solve(n, m, l) << endl;
    }
}


Measured memory_bytes: 4032
N = int(input())
A = list(map(int,input().split()))

sum_A = 1

for i in range(0,len(A)):
  if(A[i] == 0):
        print(0)
        exit()

for i in range(0,len(A)):
  if(sum_A > 1000000000000000000):
        break
  sum_A *= A[i]
if(sum_A > 1000000000000000000):
        print("-1")
        exit()
print(sum_A)


Measured memory_bytes: 21424
#include <stdio.h>

int main(void)
{
    int k, x, n, y, i, total = 0;
    scanf("%d%d%d%d",&n, &k, &x, &y);

    if (n - k > 0)
    {
        for (i = 0; i < k; i++) total += x;
        for (i = 0; i < n - k; i++) total += y;

    }
    else
    {
        for (i = 0; i < n; i++) total += x;
    }

    printf("%d\n", total);

    return (0);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int add(int N){
  int S=0,a;
  for(int i=1;i<11;i++){
    a=N%10;
    S+=a;
    N/=10;
  }
  return S;
}

int main(){
  int N;
  cin >> N;
  int S=0;
  S=add(N);
  if(N%S==0)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n, k, i;
    scanf("%d", &n);
    char s[n];
    scanf("%s", s);
    scanf("%d", &k);
    for(i=0;i<n;i++){
        if(s[k-1] == s[i]){
            printf("%c", s[i]);
        } else{
            printf("*");
        }
    }
    
    return 0;
}


Measured memory_bytes: 128
N,M = map(int,input().split())
ps = [list(map(str,input().split())) for _ in range(M)]

wacnt = [0]*(N+1)
is_ac = [False]*(N+1)
for pp,s in ps:
    p = int(pp)
    if s=='AC':
        is_ac[p] = True
    else:
        if not is_ac[p]:
            wacnt[p] += 1
num = 0
ans = 0
for l in range(N+1):
    if is_ac[l]:
       ans += wacnt[l]
       num += 1
       
print(num,ans)

Measured memory_bytes: 33692
#!/usr/bin/env python3

def main():
    n = int(input())
    mod = 10**9 + 7
    if n == 1:
        ans = 0
    else:
        ans = 10**n % mod - 9**n % mod - 9**n % mod + 8**n % mod
    print(ans % mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10724
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x,t;
  cin >> n >> x >> t;
  int ans=0;
  if(n%x==0) ans=n/x*t;
  else ans=(n/x+1)*t;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#!/usr/bin/perl
#abc84_b.pl
#Sun Jan  7 18:40:35 2018
#

use warnings;
use strict;

my $nums = <STDIN>;
chomp $nums;
my @numbers = split(" ",$nums);
my $letter = <STDIN>;
chomp $letter;

my @letters = split("\-",$letter);

#print $letters[0],"\n";

if ($#letters!=1){
	print "No\n";
}elsif(length($letters[0])==$numbers[0]){
	print "Yes\n";
}else{
	print "No\n";
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <cstdio>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}
bool isnum(char t){
	if(t>='0'&&t<='9') return true;
	return false;
}
int aaa;
vint maa(26);

int foo1(string a){
	int c=1;
	int ret=0;
	rep(i,a.size()){
		if(isnum(a[i])){
			c=a[i]-'0';
		}
		else{
			ret+=c*maa[a[i]-'a'];
			c=1;
		}
	}
	return ret;
}
vector<char> tt(1001);
string foo2(int a){
	// cout<<"a "<<a<<endl;
	string ret;
	stringstream ss;
	int c = 1000;
	bool f=false;
	while(1){
		if(a>=c){
			int t=a/c;
			//cout<<t<<endl;
			if(t>1) ss<<t;
			ss<<tt[c];
			a%=c;
			f=true;
		}
		//else if(f) ss<<0;
		if(c==1) break;
		c/=10;
	}
	ss>>ret;
	return ret;
}
int main(){
	maa['m'-'a']=1000;
	maa['c'-'a']=100;
	maa['x'-'a']=10;
	maa['i'-'a']=1;
	tt[1]='i';
	tt[10]='x';
	tt[100]='c';
	tt[1000]='m';
	int n;
	cin>>n;
	rep(i,n){
		string s1,s2;
		cin>>s1>>s2;
		// cout<<foo1(s1)<<" "<<foo1(s2)<<endl;
		cout<<foo2(foo1(s1)+foo1(s2))<<endl;
	}
	return 0;
}

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

int main() {
  string s;
  cin>>s;
  long long a=0;
  long long b=0;
  for(int i=0;i<s.size();i++){
    if(i%2==0&&s.at(i)!='0'){
      a++;
    }
    if(i%2==1&&s.at(i)!='1'){
      a++;
    }
    if(i%2==0&&s.at(i)!='1'){
      b++;
    }
    if(i%2==1&&s.at(i)!='0'){
      b++;
    }
  }
  if(a>=b){
    cout<<b<< endl;
  }
  else{
    cout<<a<< endl;
  }
}
      
  

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const ll INF = 1e9+1;

bool gr(ll a, ll b) {
    return a > b;
}

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    for (int i = 0; i < X; i++) cin >> A[i];
    for (int i = 0; i < Y; i++) cin >> B[i];
    for (int i = 0; i < Z; i++) cin >> C[i];

    sort(A.begin(),A.end(),gr);
    sort(B.begin(),B.end(),gr);
    sort(C.begin(),C.end(),gr);

    vector<ll> D(X*Y,0);

    int a = 0, b = 0, c = 0;

    priority_queue<ll> que;
    
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            D[Y * i + j] = A[i] + B[j];
        }
    }
    sort(D.begin(),D.end(),gr);
    int cnt = 0;
    for (int i = 0; i < min(K,X*Y); i++) {
        for (int j = 0; j < min(K,Z); j++) {
            que.push(D[i]+C[j]);
        }
    }
    for (int i = 0; i < K; i++) {
        cout << que.top() << endl;
        que.pop();
    }






   
}
    





Measured memory_bytes: 42984
#include <iostream>
#include <vector>
#include <iomanip>
#include <ios>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int T, X;
    cin >> T >> X;
    double ans = 1.0 / X * T;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    ll n, k;
    cin >> n >> k;
    
    vector<ll> a(n);
    ll sum = 0;
    REP(i, n){
        cin >> a[i];
        sum += a[i];
    }
    
    if(sum < k){
        cout << n << endl;
        return 0;
    }
    
    sort(a.begin(), a.end(), greater<ll>());
    
    ll le = 0, ri = n, ce = (le + ri) / 2;
    while(ri - le > 1){
        bitset<5005> dp;
        dp[0] = true;
        REP(i, n){
            if(i == ce)continue;
            
            dp |= (dp << min(a[i], k));
        }
        
        bool need = false;
        for(ll i = max(0LL, k - a[ce]); i < k; i++){
            if(dp[i]){
                need = true;
                break;
            }
        }
        if(need){
            le = ce;
        }
        else{
            ri = ce;
        }
        ce = (le + ri) / 2;
    }
    
    cout << n - ce - 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

// const int maxn = 
// const int mo = 1e9 + 7;

// int n;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int a, b;
	cin >> a >> b;
	
	if (a <= 5)
		b = 0;
	else if (a <= 12)
		b /= 2;

	cout << b << endl;

	return 0;
}

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

int main() {
    long long n;
    cin >> n;
    string res;
    while (n) {
        --n;
        res += (n % 26) + 'a';
        n /= 26;
    }   
    reverse(res.begin(), res.end());
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll x,k,d;
	cin >> x >> k >> d;
	ll t = abs(x) / d;
	if(x >= 0){
		ll gl1 = x - d*t;
		ll gl2 = x - d*(t +1);
		if(abs(gl1) < abs(gl2)){
			if(t > k){
				cout << abs(x - d*k) << endl;;
			}else{
				if((k - t) % 2 == 0){
					cout << abs(gl1) << endl;
				}else{
					cout << abs(gl2) << endl;
				}
			}
		}else{
			if(t + 1 > k){
				cout << x - d*k << endl;
			}else{
				if((k - (t+1)) % 2 == 0){
					cout << abs(gl2) << endl;
				}else{
					cout << abs(gl1) << endl;
				}
			}
		}
	}else{	
		ll gl1 = x + d*t;
		ll gl2 = x + d*(t +1);
		if(abs(gl1) < abs(gl2)){
			if(t > k){
				cout << abs(x + d*k) << endl;;
			}else{
				if((k - t) % 2 == 0){
					cout << abs(gl1) << endl;
				}else{
					cout << abs(gl2) << endl;
				}
			}
		}else{
			if(t + 1 > k){
				cout << abs(x + d*k) << endl;
			}else{
				if((k - (t+1)) % 2 == 0){
					cout << abs(gl2) << endl;
				}else{
					cout << abs(gl1) << endl;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main
{
	public static void main(String arg[])throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();
		System.out.println(str.toUpperCase());
	}

}

Measured memory_bytes: 9360
#include <bits/stdc++.h>
#include<bitset>
using namespace std;
#define M 1000000007
#define rep(i, a, b) for(int i=a; i<b; i++)

typedef long long ll;
typedef unsigned long long int llt;
const int N = 2e5 + 10;


int main()
{
    int a, b;
    cin>>a>>b;
    b = b *2;
    if(a <= b) puts("0");
    else cout<<(a-b)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include  <iostream>
#include  <vector>
#include  <algorithm>

using namespace std;

typedef long long ll;

class Job {
public:
	int a;
	int b;
};

bool operator<(const Job& left, const Job& right)
{
	return left.b < right.b;
}

bool operator>(const Job& left, const Job& right)
{
	return left.b > right.b;
}

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

	vector <Job> time(n);
	for (int i = 0; i < n; i++)  cin >> time[i].a >> time[i].b;

	sort(time.begin(), time.end());

	ll sum = 0;
	bool ans;
	for (int i = 0; i < n; i++) {
		sum += time[i].a;
		if (sum > time[i].b) {
			ans = false;
			break;
		}
		else {
			ans = true;
		}
	}

	if (ans)  cout << "Yes" << endl;
	else  cout << "No" << endl;

	
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main() {
	int A, B, C, tmp;
	cin >> A >> B >> C;
	tmp = C;
	C = B;
	B = A;
	A = tmp;
	cout << A <<" "<< B <<" "<< C << "\n";
	return 0;
}

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

void swap(int &a, int &b) {
	int tmp = b;
	b = a;
	a = tmp;
}

void bubbleSort(vector<int> &v) {
	int N = v.size();
	bool flag = true;
	int i = 0;
	while (flag) {
		flag = false;
		for (int j = N - 1; j > i; j--) {
			// cout << v[j - 1] << " " << v[j] << endl;
			if (v[j - 1] > v[j]) {
				flag = true;
				swap(v[j - 1], v[j]);
			}
			// cout << v[j - 1] << " " << v[j] << endl;
			// getchar();
		}
		i++;
	}
}

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

	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}

	bubbleSort(v);

	double ans = (double) v[0];
	for (int i = 1; i < N; i++) {
		ans = (v[i] + ans) / 2.;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

ll solve(int N) {

  static ll dp[2][1<<16]; zero(dp);

  rep(i, N) {
    int M; ll L; cin >> M >> L;

    int bit = 0;
    rep(_, M) {
      int s, t; cin >> s >> t;
      REP(j, s-6, t-6) {
        bit |= 1<<j;
      }
    }

    rep(S, 1<<16) dp[(i+1)&1][S] = dp[i&1][S];

    rep(S, 1<<16) {
      if((S ^ bit) == (S + bit)) {
        int nS = S ^ bit;
        maximize(dp[(i+1)&1][nS], dp[i&1][S] + L);
      }
    }
  }

  return *max_element(dp[N&1], dp[N&1]+(1<<16));
}

int main() {

  for(int N; cin >> N && N;) {
    cout << solve(N) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4172
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// type alias
using ll = long long;
using ull = unsigned long long;

inline ll floor(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return a / llb;
	}
	else
	{
		return - ( (-a + llb - 1) / llb);
	}
}

inline ll ceil(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return (a + llb - 1) / llb;
	}
	else
	{
		return - (-a / llb);
	}
}

inline bool isPower2(ull a)
{
	if (a == 0)
	{
		return false;
	}
	return !(a & (a - 1));
}

inline ll getMaxEffectiveBit(ull a)
{
	ll index = -1;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

inline ll getSpecifiedBit(ull a, unsigned bit)
{
	return (a & (1LL << bit)) >> bit;
}

// computational complexity: o(log(max(a, b))) 
inline ull getGcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

template<class Integer>
inline Integer getPower(Integer base, ull exponential)
{
	Integer result = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			result = result * base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return result;
}

ll val(ll a, ll c, ll d)
{
	ll m = c / getGcd(c, d) * d;
	return a - a / c - a / d + a / m;
}

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

	string S;
	cin >> S;

	map<char, ll> a;
	
	for (ll i = 0; i < S.size(); ++i)
	{
		if (a.count(S[i]) == 0)
		{
			a[S[i]] = 0;
		}
		++a[S[i]];
	}

	bool isYes = true;
	for (auto iter = a.begin(); iter != a.end(); ++iter)
	{
		if (iter->second != 2)
		{
			isYes = false;
			break;
		}
	}

	cout << (isYes ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
W, H, N = map(int, input().split())
field = []
for i in range(0, W):
	lst = []
	for j in range(0, H):
		lst.append(1)
	field.append(lst)
for i in range(0, N):
	x, y, a = map(int, input().split())
	paint = []
	if a == 1: paint = [[0, x], [0, H]]
	elif a == 2: paint = [[x, W], [0, H]]
	elif a == 3: paint = [[0, W], [0, y]]
	elif a == 4: paint = [[0, W], [y, H]]
	for i in range(paint[0][0], paint[0][1]):
		for j in range(paint[1][0], paint[1][1]):
			field[i][j] = 0
cnt = 0
for i in range(0, W):
	for j in range(0, H):
		cnt += field[i][j]
print(cnt)

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

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

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 80 + 10;

int n;
ll a[maxN], dp[maxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for1(i, n)
    {
        cin >> a[i];
    }
    dp[0] = 1000;
    for1(i, n)
    {
        for1(j, i)
        {
            uax(dp[i], dp[j - 1] + (a[i] - a[j]) * (dp[j - 1] / a[j]));
        }
    }
    cout << dp[n];
    return 0;
}


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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<int> SUM(N + 1);
	SUM[0] = 0;
	map<int, int> m;

	for (int i = 0; i < A.size(); i++) {
		SUM[i + 1] = (SUM[i] + A[i]) % M;
	}

	long ans = 0;
	for (int i = 0; i < SUM.size(); i++) {
		ans += m[SUM[i]];
		m[SUM[i]]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3968
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
// }}}

struct FastIO {
    FastIO() { cin.tie(nullptr); ios::sync_with_stdio(false); }
} fastIO_ydk ;

signed main()
{
    int N;
    i64 a, b;

    cin >> N;
    cin >> a >> b;

    rep(i, 0, N-1) {
        i64 x, y;
        cin >> x >> y;
        i64 k = max((a + x - 1) / x, (b + y - 1) / y);
        a = x * k;
        b = y * k;
    }

    cout << (a+b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MB 1000000007
#define NB 1000000000
#define N5 100007
#define ll long long int
string N;
int A,B,C;
int num[100];

int main()
{
	cin >> A>> B >> C;

	if((A==B&&A!=C) || (B==C&&B!=A) || (C==A&&C!=B))
	cout << "Yes";
	else
		cout << "No";


}






Measured memory_bytes: 256