akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int f(int i){
    int cc = 0;
    while (i != 0)
    {
        cc += i % 10;
        i /= 10;
    }
    return cc;
}
int main(){
    int n;
    cin >> n;
    int ans = 1 << 30;
    trep(i, 1, n)
    {
        int j = n - i;
        int cc = f(i) + f(j);
        if (ans >cc){
            ans = cc;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {

	int n, m;
	cin >> n >> m;

	map<long long, long long> count;
		
	int tmp;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		count[tmp]++;
	}

	vector<pair<int,int>> bc(m);
	int in1, in2;
	for (int i = 0; i < m; i++) {
		cin >> in1 >> in2;
		bc[i] = make_pair( in2,in1 );
	}
	sort(bc.begin(), bc.end(), greater<pair<int,int>>());

	for (int i = 0; i < m; i++) {
		in1 = bc[i].second;
		in2 = bc[i].first;
//		cin >> in1 >> in2;
		auto itr = count.begin();
		while (itr->first < in2) {
			bool brkflg = false;
			while (itr->second > 0) {
				in1--;
				itr->second--;
				count[in2]++;
				if (in1 == 0) {
					brkflg = true;
					break;
				}
				if (itr->second == 0) {
					break;
				}

			}
			if (brkflg) { break; }
			itr=next(itr, 1);
		}
		itr = count.begin();
		while(itr->second==0){
			count.erase(itr->first);
			itr = count.begin();
		}

	}

	long long res=0;
	for (auto itr = count.begin(); itr != count.end(); itr++) {
		res += itr->first*itr->second;
	}
	cout << res << endl;
	return 0;

}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        if(n % 2 == 1) {
            System.out.println((double)(n/2+1)/n);
        } else {
            System.out.println(0.5d);
        }


    }
}


Measured memory_bytes: 23764
N,H=map(int,input().split())
A=[]
B=[]
for _ in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)

B.sort(reverse=True)
A.sort(reverse=True)
B=[x for x in B if x>A[0]]
cnt=0
for i in range(len(B)):
  H-=B[i]
  cnt+=1
  if H<=0:
    print(cnt)
    exit()

A.sort(reverse=True)
print(cnt-(-H//A[0]))

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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll x;
    cin>>x;
    ll ans= (x/500) * 1000 + ((x%500)/5) * 5;
    cout<<ans<<'\n';
    return 0;
}


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();
  int c;
  if(b/10 == 0){c = 10*a + b;}
  else if(b/10 >0 && b/10 <=9){c = 100*a + b;}
  else{c = 1000*a + b;}
  int d = (int)Math.sqrt(c);
  if(d*d == c){System.out.println("Yes");}
  else {System.out.println("No");}
}
}


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

typedef long long ll;

int main() {
    string S;
    cin >> S;
    int L = S.length();
    int n;
    if (L%2==0) n = L/2;
    else n = (L+1)/2;
    int ans = 0;
    for (int i=0;i<n;i++){
        if (S[i] != S[L-i-1]) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int[] arr = new int[53];
		scan.nextLine();
		
		String suit = "";
		int rank = 0;
		for (int i=1; i<=n; i++) {
			suit = scan.next();
			rank = scan.nextInt();
			if(suit.equals("S")) arr[rank] = rank;
			if(suit.equals("H")) arr[rank+13] = rank;
			if(suit.equals("C")) arr[rank+26] = rank;
			if(suit.equals("D")) arr[rank+39] = rank;
		}
		
		for (int i=1; i<=52; i++) {
			if(arr[i] == 0 && i <= 13)
				System.out.println("S " + i);
			if(arr[i] == 0 && i > 13 && i <=26)
				System.out.println("H " + (i-13));
			if(arr[i] == 0 && i > 26 && i <=39)
				System.out.println("C " + (i-26));
			if(arr[i] == 0 && i > 39 && i <=52)
				System.out.println("D " + (i-39));
		}
	}
}



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

int main(){
    int n;
    cin >> n;
    int count[4][3][10] = {};

    for(int i=0;i<n;i++){
        int d,f,r,v;
        cin >> d >> f >> r >> v;
        if((count[d-1][f-1][r-1] + v) > 9){
            count[d-1][f-1][r-1] = 9;
        }else if ((count[d-1][f-1][r-1] + v) < 0)
        {
            count[d-1][f-1][r-1] = 0;
        }else{
            count[d-1][f-1][r-1] += v;
        }
    }
    
    for(int i=0;i<4;i++){
        if(i!=0){
            cout << "####################" << endl;
        }
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout << " " << count[i][j][k];
            }
            cout << endl;
        }
         
    }
}


Measured memory_bytes: 3096
/* ex 9_2 ABC 120 C
   nk777 */
 
#include<stdio.h>
#include <stdlib.h>
// リストの領域は動的確保
#define MAX 100000

// 次のリストのポインタのみ保持する単方向リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    // *firstは一番新しいデータを指す
    *first = new;
}

//スタックからデータを取り出す(削除)
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    // 消去した数を数えるcount, カウンターi
    int count = 0, i = 0;
    // 一時的に入力された文字列を受け取る
    char color[MAX];
    //最初のノードの指す先
    node *first = NULL;
    //入力された文字をスタックにノードを追加
    scanf("%s", color);
    while (color[i] != '\0')
    {
        if (first == NULL || color[i] == first->elem)
        {
            // 最初のキューブか、前と同じ色のとき
            push(&first, color[i]);
        }
        else
        {
            // 色が一個前と違うときスタックからデータを取り出す
            pop(&first);
            count += 2;
        }
        i++;
    }
    // 結果を出力
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 4916
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

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

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << C << endl;
    } else if (B == C) {
        cout << A << endl;
    } else {
        cout << B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# abc139_b.py
# https://atcoder.jp/contests/abc139/tasks/abc139_b

# B - Power Socket /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 高橋くんの家には電源プラグの差込口が 1口しかありません。
# そこで、高橋くんは A個口の電源タップをいくつか使って未使用の差込口を B口以上に拡張したいと考えています。
# A個口の電源タップ 1 つと未使用の差込口 1 口を使って、新たに差込口を A口増やすことができます。
# 最小でいくつの電源タップが必要でしょうか。

# 制約
#     入力は全て整数である。
#     2≤A≤20
#     1≤B≤20

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A B

# 出力
# 必要な電源タップの個数の最小値を出力せよ。

# 入力例 1
# 4 10

# 出力例 1
# 3

# 4個口の電源タップを 3 つ使うと、未使用の差込口は 10口になります。

# 入力例 2
# 8 9

# 出力例 2
# 2

# 8個口の電源タップを 2 つ使うと、未使用の差込口は 15口になります。

# 入力例 3
# 8 8

# 出力例 3
# 1


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    A, B = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(6):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(M):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = -(-(B-1)//(A-1))

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['4 10']
        lines_export = [3]
    if pattern == 2:
        lines_input = ['8 9']
        lines_export = [2]
    if pattern == 3:
        lines_input = ['8 8']
        lines_export = [1]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n,q = map(int,input().split())
	s = input()
	lr = []
	for i in range(q):
		lr.append(list(map(int,input().split())))
		lr[-1][0] -= 1
		lr[-1][1] -= 1
	ac = [0, (1 if s[0]+s[1]=='AC' else 0)]
	for i in range(1,n-1):
		ac.append((ac[-1]+1) if s[i]+s[i+1]=='AC' else ac[-1])
	for i in lr:
		print(ac[i[1]]-ac[i[0]])

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 95100
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define IN 200000
#define INPUTSIZE IN+2

int main() {
	//変数宣言
	int i, j;
	int flag;
	char Sin[INPUTSIZE], Tin[INPUTSIZE];
	char c;
	
	//入力受付
	fgets(Sin, INPUTSIZE, stdin);
	fgets(Tin, INPUTSIZE, stdin);
	int size = strlen(Sin);

	for (i = 0; i < size; i++) {
		if (Sin[i] != Tin[i]) {
			c = Sin[i];
			for (j = 0; j < size; j++) {
				if (Sin[j] == c || Sin[j] == Tin[i]) {
					if (Sin[j] == c) Sin[j] = Tin[i];
					else if(Sin[j] == Tin[i]) Sin[j] = c;
					if (j <= i && Sin[j] != Tin[j]) {
						goto MyEndFlag;
					}
				}
			}
		}
	}
	MyEndFlag:
	printf(i == size ? "Yes\n":"No\n");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define LL long long
#define mod 1000000007
using namespace std;
int main()
{
    int n,r;
    cin>>n>>r;
    int ans;
    if(n>=10)
        ans=r;
    else
        ans=r+100*(10-n);
    cout<<ans<<endl;
}


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

namespace ABC127
{
    class B
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split(' ').Select(t => int.Parse(t)).ToArray();
            int r = a[0], D = a[1], x = a[2];
            for(int i = 0; i < 10; i++)
            {
                x = x * r - D;
                Console.WriteLine(x);
            }

        }

    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll N, M; cin >> N >> M;
    vector<vector<char>> A(N, vector<char>(N)), B(M, vector<char>(M));
    rep(i, N) {
        rep(j, N) cin >> A[i][j];
    }
    rep(i, M) {
        rep(j, M) cin >> B[i][j];
    }

    bool ans = false;
    foreps(ly, 0, N) {
        foreps(lx, 0, N) {
            if (ly + M - 1 >= N || lx + M - 1 >= N) continue;

            bool match = true;
            rep(y, M) {
                rep(x, M) {
                    if (A[ly + y][lx + x] != B[y][x]) match = false;
                }
            }
            if (match) ans = true;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)

#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long ll;
const int N = 26 , M = 5e5+1, OO = 0x3f3f3f3f,MOD = 1e9+7;
set<int> arr[N];
char str[M];


int main()
{
  int n;
  scanf("%d",&n);
  scanf("%s",str);
  for(int i=0;i<n;++i) arr[str[i]-'a'].insert(i);   

  int m;
  scanf("%d",&m);
  error(m);
  while(m--)
  {
    int op,l;
    scanf("%d%d",&op,&l);
    l--;
    if(op==1)
    {
      char c;
      scanf(" %c",&c);
      arr[str[l]-'a'].erase(l);
      arr[c-'a'].insert(l);
      str[l]=c;
    }
    else
    {
      int r,ans=0;
      scanf("%d",&r);
      r--;
      for(int i=0;i<26;++i)
        if(!arr[i].empty() && arr[i].lower_bound(l)!=arr[i].end() && *arr[i].lower_bound(l)<=r) 
          ans++;


      printf("%d\n",ans);
    }
    
  }
  
  #ifdef _LOCAL_DEFINE  
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 24236
INF = 10**10 - 1 #無限大
SMAX = 3000 + 10

# 文字列入力
s1 = input()
s2 = input()

'''
dpの初期化
s1の文字列位置を一次軸、s2の文字列位置を二次軸に取り
その値として：LCSの最長値として更新していく
　　　　　　　初期値はすべて０
'''
dp = [ [0] * (SMAX) for i in range(SMAX)]

for s1pos in range(1,len(s1)+1):
    s1s = s1[s1pos-1:s1pos]
    for s2pos in range(1,len(s2)+1):
        s2s = s2[s2pos-1:s2pos]
        if s1s == s2s:
            dp[s1pos][s2pos] = dp[s1pos-1][s2pos-1] + 1
        dp[s1pos][s2pos] = max(dp[s1pos][s2pos],dp[s1pos][s2pos-1],dp[s1pos-1][s2pos])
    #print("s1pos=",s1pos,"dp=",dp[s1pos])

#print("LCS_len",dp[len(s1)][len(s2)])

res = ""
s1pos = len(s1)
s2pos = len(s2)
while (s1pos > 0 and s2pos > 0):
    # (s1pos-1, s2pos) -> (s1pos, s2pos) と更新されていた場合
    if (dp[s1pos][s2pos] == dp[s1pos-1][s2pos]):
        s1pos -= 1 # DP の遷移を遡る
    # (s1pos, s2pos-1) -> (s1pos, s2pos) と更新されていた場合
    elif (dp[s1pos][s2pos] == dp[s1pos][s2pos-1]):
        s2pos -= 1 # DP の遷移を遡る
    # (s1pos-1, s2pos-1) -> (s1pos, s2pos) と更新されていた場合
    else:
        res = s1[s1pos-1:s1pos] + res # 該当文字を取得
        s1pos -= 1 # DP の遷移を遡る
        s2pos -= 1 # DP の遷移を遡る

print(res)

Measured memory_bytes: 115932
#include<iostream>  
#include<cmath>  
#include<string>
#include<cstring>
using namespace std;
int main(){  
	int a,b,c;
	cin>>a>>b>>c;
	int ans;
	if (c>a+b+1) ans=a+b+b+1;
	else ans=c+b;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(10)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll a[5];
  ll p;
  fo(i,5)
  {
    cin>>a[i];
    if(a[i]==0)
      p=i+1;
  }
  cout<<p;
  return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int x,y;
    cin>>x>>y;
    if(y-x-x<0){
        puts("No");
        return 0;
    }
    if(y%2==1){
        puts("No");
        return 0;
    }
    int m=(y-x-x)/2;
    int n=x-m;
    if(n>=0&&m>=0){
        puts("Yes");
    }
    else{
        puts("No");
    }
    return 0;
}

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

int h,w,ans,k,map[10][10],a[10][10];
string s;

int check()
{
	int cnt=0;
	for (int i=1 ; i<=h ; i++)
	    for (int j=1 ; j<=w ; j++)
	        if (a[i][j]==1) cnt++;
	return cnt;
}

int main()
{
	scanf("%d%d%d\n",&h,&w,&k);
    for (int i=1 ; i<=h ; i++)
    {
    	cin>>s;
    	for (int j=0 ; j<w ; j++)
    	    map[i][j+1]=s[j]=='.' ?0:1,a[i][j]=map[i][j];
	}
	
	for (int s1=0 ; s1<1<<h ; s1++)
	{
		for (int s2=0 ; s2<1<<w ; s2++)
		{
			for (int i=1 ; i<=h ; i++)
			    for (int j=1 ; j<=w ; j++)
			        a[i][j]=map[i][j];
			
			for (int i=0 ; i<h ; i++)
			    if (s1&1<<i) {
			    	for (int x=1 ; x<=w ; x++) a[i+1][x]=0;
			    }
			    
			for (int i=0 ; i<w ; i++)
			    if (s2&1<<i) {
			    	for (int x=1 ; x<=h ; x++) a[x][i+1]=0;
			    }
			if (check() == k) 
			{
			/*for (int i=1 ; i<=h ; i++,printf("\n"))
			    for (int j=1 ; j<=w ; j++)
			        printf("%d ",a[i][j]);*/
                ans++;
            }
		}
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3828
import java.util.Scanner;

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

        int n = sc.nextInt();
        boolean isAns = true;
        
        for (int i = 0; i < n; i++) {
            int t = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            
            if (!isCheck(t, x, y))
                isAns = false;
        }
        
        System.out.println(isAns ? "Yes" : "No");
    }

    static boolean isCheck(int t, int x, int y) {
        int sumMove = Math.abs(x) + Math.abs(y);
        if (sumMove > t)
            return false;
        
        if (sumMove % 2 == t % 2)
            return true;
        else
            return false;
    }
}


Measured memory_bytes: 87376
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

const double PI = acos(-1);

int main() {
	double a, b, h, m; cin >> a >> b >> h >> m;
	double rad = abs((60 * h + m) / 2 - 6 * m) * PI / 180;
	printf("%.15f\n", sqrt(a * a + b * b - 2 * a * b * cos(rad)));

	return 0;
}

Measured memory_bytes: 4212
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int n, m;
    cin >> n >> m;

    vvec<bool> likes(m, vec<bool>(n));

    for (int i = 0; i < n; ++i)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j)
        {
            int like;
            cin >> like;
            --like;
            likes[like][i] = true;
        }
    }

    auto ans = accumulate(likes.cbegin(), likes.cend(), 0,
               [](int init, auto l) {
                   if (all_of(l.cbegin(), l.cend(), [](auto b) { return b; }))
                       return init + 1;
                   else
                       return init;
               });

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math
if __name__ == '__main__':

	while True:
		n = int(input())

		if n == 0:
			break

		m = math.factorial(n)
		ans = list(str(m))

		cnt = 0
		for i in reversed(ans):
			if i == "0":
				cnt += 1
			else:
				break

		print(cnt)




Measured memory_bytes: 6328
#include<vector>
#include<iostream>
#include<string>

#define rep(i,n) for (int i = 0; i < (n) ; ++i)
#define Cout(s) cout<<(s)<<endl;
using ll = long long;

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> count(N, 0);
	rep(i, K) {
		int d;
		cin >> d;
		rep(j, d) {
			int q;
			cin >> q;
			count[q-1]++;
		}
	}
	int ans=0;
	rep(i, N) {
		if (count[i] == 0) {
			ans++;
		}
	}
	Cout(ans);
	return 0;
}

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX;
const int INF = INT_MAX;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { return (a - b)*(1|((a - b)>>(8*sizeof(int)-1)));}
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数

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

	VI A(N-1);
	rbf(a, A) cin >> a;

	VI buka(N, 0);
	rbf(a, A) {
		buka[a - 1]++;
	}
	
	rbf(b, buka) {
		COL(b);
	}

	return 0;
}

Measured memory_bytes: 4756
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

class UnionFind{
public:
    ll *par, *rank, *size;
    UnionFind(int n){
        par = new ll[n];
        rank = new ll[n];
        size = new ll[n];
        REP(i,0,n){
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }
    ll root(ll x) {return par[x] == x ? x : par[x] = root(par[x]);}
    ll getsize(ll x) {return size[root(x)];}
    bool connected(ll x, ll y) {return root(x)==root(y);}
    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return;
        if(rank[rx] < rank[ry]) {
            par[rx] = ry;
            size[ry] += size[rx];
        }
        else {
            par[ry] = rx;
            size[rx] += size[ry];
            if(rank[rx] == rank[ry]) rank[rx]++;
        }
        return;
    }
};

int main()
{
    ll n, m;
    cin >> n >> m;

    UnionFind uf(n);
    ll a[100000], b[100000];
    ll ans[100000];

    REP(i,0,m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    ll c = n * (n-1) / 2;
    for(int i=m-1; i>=0; i--){
        ans[i] = c;
        if(!uf.connected(a[i],b[i])){
            ll size_a = uf.getsize(a[i]);
            ll size_b = uf.getsize(b[i]);
            c -= (ll)(size_a * size_b);
            uf.unite(a[i],b[i]);
        }
    }
    REP(i,0,m) {
        cout << ans[i] << endl;
    }
    return 0;
}


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

int main()
{
    int g[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    cin >> x >> y;

    if (g[x] == g[y])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    priority_queue<long long int>pq;
    while(cin>>s)
    {
        if(s=="end") break;
        if(s=="extract"){
            cout<<pq.top()<<endl;
            pq.pop();
        }
        else if(s=="insert"){
            long long int num;
            cin>>num;
            pq.push(num);
        }
    }
    return 0;
}



Measured memory_bytes: 11164
#include<iostream>
using namespace std;
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
string s;
main()
{
	while(cin>>s,s!="#")
	{
		long long a=0,b=1;
		bool c[99]={};
		int f=s.size()-1,n=0;
		for(;f>=0;n++)
		{
			if(s[f]=='h')
			{
				c[n]=0;
				f-=5;
			}
			else
			{
				c[n]=1;
				f-=4;
			}
			b*=2;
		}
		b/=2;
		for(int i=0;i<n;i++)
		{
			a=a*2+(c[i]?90:-90);
			if(a<0)a=0;
		}
		long long d=gcd(a,b);
		a/=d,b/=d;
		cout<<a;
		if(b>1)cout<<"/"<<b;
		cout<<endl;
	}
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;

int main(){
	int m, n;
	pair<int, int> p1[202];
	pair<int, int> p2[1002];
	while(cin >> m, m){
		fill(p1, p1+202, make_pair(-1, -1));
		fill(p2, p2+1002, make_pair(-1, -1));
		for(int i = 0;i < m;i++)cin >> p1[i].first >> p1[i].second;
		cin >> n;
		for(int i = 0;i < n;i++)cin >> p2[i].first >> p2[i].second;
		
		sort(p1, p1+m);
		sort(p2, p2+n);
		pair<int, int> t;
		int ans[3] = {0, 0, 0};
		for(int i = 0;i < n;i++){
			ans[0] = 0;
			for(int j = 1;j < m;j++){
				t.first = p2[i].first+(p1[j].first-p1[0].first);
				t.second = p2[i].second+(p1[j].second-p1[0].second);
				ans[0] += binary_search(p2, p2+n, t);
			}
			if(ans[0] == m-1){
				ans[1] = p2[i].first - p1[0].first;
				ans[2] = p2[i].second - p1[0].second;
			}
			
		}
		cout << ans[1] << " " << ans[2] << endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int a = (int)(N/1.08);
    int b = a+1;
    if((int)(a*1.08) == N)
        cout << a << endl;
    else if((int)(b*1.08) == N)
        cout << b << endl;
    else
        cout << ":(" << endl;
}


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

int main() {
	int N, K;
	std::cin >> N >> K;
	std::vector<double> v(N);
	for (int i = 0; i < N; i++) {
		std::cin >> v[i];
		v[i] += 1.;
		v[i] /= 2.;
		if (i != 0) {
			v[i] += v[i - 1];
		}
	}
	auto sum = v[K - 1];
	for (int i = K; i < N; i++) {
		sum = std::max(v[i] - v[i - K], sum);
	}
	std::cout << std::setprecision(10) << sum << std::endl;
	return 0;
}


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

using namespace std;

int main()
{
	int n;	cin>>n;
	string s;
	int runner=0,out=0,score=0;
	while(cin>>s){
		if(s=="HIT"){
			runner<<=1;
			if(runner&8)runner&=~8,score++;
			runner|=1;
		}
		else if(s=="HOMERUN"){
			for(int i=0;i<3;i++){
				runner<<=1;
				if(runner&8)runner&=~8,score++;
			}
			score++;
		}
		else{
			out++;
			if(out==3)	cout<<score<<endl,runner=out=score=0;
		}
	}
	return 0;
}

Measured memory_bytes: 0
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();
		int c = sc.nextInt();
		int sum = a + b + c;
		int max;
		if(a >= b && a >= c)
			max = a;
		else if(b >= a && b >= c)
			max = b;
		else
			max = c;
		System.out.println((sum - max == max) ? "Yes" : "No");
	}
}

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

typedef long long ll;
typedef vector<string> vs;
#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

#define MOD 1000000007

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

    int N; cin >> N;
    vs s(2); cin >> s;

    ll ans = 0;

    rep(w, N) {
        int choices = 0;
        if (s[0][w] == s[1][w]) {
            choices = (w == 0 ? 3 : (s[0][w-1]==s[1][w-1] ? 2 : 1));
        } else {
            choices = (w == 0 ? 6 : (s[0][w-1]==s[1][w-1] ? 2 : 3));
            w++;
        }
        ans = (ans==0?1:ans) * choices % MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double p[40][2] = {0};
	int ar, al, br, bl, cr, cl, dr, dl;
	int n, i;

	ar = al = br = bl = cr = cl = dr = dl = 0;

	n = 0;
	while (n < 40)
	{
		if (scanf("%lf %lf", &p[n][0], &p[n][1]) == EOF)
			break;

		n++;
	}

	if (n == 41)
		n--;

	for (i = 0; i < n; i++)
	{
		if (p[i][0] >= 1.1)
			ar++;
		else if (p[i][0] >= 0.6)
			br++;
		else if (p[i][0] >= 0.2)
			cr++;
		else 
			dr++;

		if (p[i][1] >= 1.1)
			al++;
		else if (p[i][1] >= 0.6)
			bl++;
		else if (p[i][1] >= 0.2)
			cl++;
		else 
			dl++;
	}

	printf("%d %d\n", ar, al);
	printf("%d %d\n", br, bl);
	printf("%d %d\n", cr, cl);
	printf("%d %d\n", dr, dl);
	return 0;
}

Measured memory_bytes: 628
n = int(input())
memory = set()
end = None
break_flg = False
for i in range(n):
  w = input()
  if w in memory:
    print("No")
    break_flg = True
    break
  start = w[0]
  if end == start or end is None:
    memory.add(w)
    end = w[-1]
  else:
    print("No")
    break_flg = True
    break
if not break_flg:
  print("Yes")

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

using namespace std;

int main(int argc, char *argv[]) {
  double n;
  while (cin >> n) {
    if (n <= 48.0) {
      cout << "light fly" << endl;
    } else if (n <= 51.0) {
      cout << "fly" << endl;
    } else if (n <= 54.0) {
      cout << "bantam" << endl;
    } else if (n <= 57.0) {
      cout << "feather" << endl;
    } else if (n <= 60.0) {
      cout << "light" << endl;
    } else if (n <= 64.0) {
      cout << "light welter" << endl;
    } else if (n <= 69.0) {
      cout << "welter" << endl;
    } else if (n <= 75.0) {
      cout << "light middle" << endl;
    } else if (n <= 81.0) {
      cout << "middle" << endl;
    } else if (n <= 91.0) {
      cout << "light heavy" << endl;
    } else {
      cout << "heavy" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1220
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a[]= new int[5];
		int b[]= new int[5];
		int ans=0;
        
        for(int i=0; i<5; i++){
            a[i] = sc.nextInt();
            b[i] = 10-a[i]%10;
            if(a[i]%10==0){
                b[i]=0;
            }
        }
        
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
	            if(b[j]>b[j+1]){
	                int tmp=b[j];
	                b[j]=b[j+1];
	                b[j+1]=tmp;
	                tmp=a[j];
	                a[j]=a[j+1];
	                a[j+1]=tmp;
	            }
	        }
        }
        
        for(int i=0; i<4; i++){
            if (a[i]%10!=0){
                a[i]=a[i]+(10-a[i]%10);
            }
            ans+=a[i];
        }
		
        System.out.println(ans+a[4]);
	}
}

Measured memory_bytes: 35672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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 long long INF = 1LL << 60;
long long h[100010];

int main()
{
    int N, K; cin >> N >> K;
    rep(i, N) cin >> h[i];

    vector<ll> dp(100010, INF);
    dp[0] = 0;

    rep(i, N)
    {
        Rep(j, 1, K + 1)
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	long double a,b;
	cin >> a >> b;
	long double c = a*b;
	cout << ll(c) << endl;
	
	return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
typedef long long ll;

#define inRange(x,a,b) (a <= x && x < b)
int dx[8] = {0,0,1,-1,1,1,-1,-1};
int dy[8] = {1,-1,0,0,1,-1,1,-1};

int main(){
    int h, w;
    cin >> h >> w;

    char mat[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
        }
    }

    bool visit[h][w];
    memset(visit, 0, sizeof(visit));

    ll ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(visit[i][j]) continue;
            queue<pair<int,int>> s;
            s.push({i,j});
            ll white = 0, black = 0;
            while(!s.empty()){
                auto p = s.front(); s.pop();
                if(visit[p.first][p.second])    continue;
                visit[p.first][p.second] = true;
                if(mat[p.first][p.second] == '.')   white++;
                else                                black++;
                for(int k = 0; k < 4; k++){
                    int di = p.first + dx[k], dj = p.second + dy[k];
                    if(inRange(di, 0, h) && inRange(dj, 0, w) && mat[di][dj]!=mat[p.first][p.second]){
                        s.push({di,dj});
                    }
                }
            }
            ans += black*white;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <utility>
#include <algorithm>
#include <vector>

#define MAX_N (200000L)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long N, as[MAX_N], bs[MAX_N];
  scanf("%ld", &N);
  for (long i = 0; i < N; i++) {
    scanf("%ld %ld", &as[i], &bs[i]);
  }

  // sort by finish time
  vector<pair<long, long>> ps;
  for (long i = 0; i < N; i++) {
    ps.push_back(make_pair(bs[i], as[i]));
  }
  sort(ps.begin(), ps.end());

  // solve
  long ok = 1, t = 0;
  for (long i = 0; i < N; i++) {
    const long a = ps[i].second, b = ps[i].first;
    t += a;
    if (t > b) {
      ok = 0;
    }
  }
  if (ok) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 9456
a, b = [ int(v) for v in input().split() ]
if a > 0:
  print("Positive")
elif a <= 0 and b >= 0:
  print("Zero")
elif b < 0:
  if (b - a) % 2 == 0:
    print("Negative")
  else:
    print("Positive")
  

Measured memory_bytes: 38256
import java.util.Scanner;

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

        int N = sc.nextInt();
//        int[] num = new int[N];
        int min = 0;
        int max = 0;
        for (int i = 0; i < N; i++) {
            int a = sc.nextInt();
            if (i == 0) {
                min = max = a;
                continue;
            }
            if (a > max) max = a;
            if (a < min) min = a;
        }
        System.out.println(max - min);
    }
}



Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(M,true);
  for(int i=0;i<N;i++){
    int K;
    cin>>K;
    vector<int> B(M,false);
    for(int j=0;j<K;j++){
      int a;
      cin>>a;
      B[a-1]=true;
    }
    for(int j=0;j<M;j++)
      A[j]=A[j]&&B[j];
  }
  int ans=0;
  for(bool b:A)
    if(b)
      ans++;
  cout<<ans<<endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N, W;
	cin >> N >> W;
	ll w1;
	vector<deque<int>> S(4);

	fx(N) {
		int w, v;
		cin >> w >> v;
		if (x==0) {
			S[0].push_back(v);
			w1 = w;
		}
		else {
			S[w - w1].push_back(v);
		}
	}

	fx(4) {
		sorts(S[x]);
		reverses(S[x]);
		S[x].push_front(0);
		fy(S[x].size()-1) {
			S[x][y + 1] += S[x][y];
		}
	}
	ll ans = 0;
	fx(S[0].size()) {
		ll sum = x * w1;
		ll val = S[0][x];
		if (sum > W) { break; }
		fy(S[1].size()) {
			sum += y * (w1 + 1);
			val += S[1][y];
			if (sum > W) { break; }
			fz(S[2].size()) {
				sum += z * (w1 + 2);
				val += S[2][z];
				if (sum > W) {
					sum -= z * (w1 + 2);
					val -= S[2][z];
					break;
				}
				ans = max(ans, S[3][min((W - sum) / (w1 + 3),(ll)S[3].size()-1)] + val);
				sum -= z * (w1 + 2);
				val -= S[2][z];
			}
			sum -= y * (w1 + 1);
			val -= S[1][y];
		}
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

/*
 貪欲
 ①決定問題 必ず解に含まれる(含むように変換できる)ものから決めていく みんプロ本選B
 ②最適化問題 任意の解から評価を落とさず解に含められるようなものから決めていく 区間スケジューリングとか
 ③
 */

/*
 DP
 ①DPはある程度決め打ちをするべき(解を帰納的に構成できないか？)
 */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];
	REP(i,n) cin>>c[i];
	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));
	vector<ll> sum(n);
	REP(i,n) {
		auto ite=lower_bound(ALL(a),b[i]);
		if(i==0) {
			sum[i]=(int)(ite-a.begin());
		} else {
			sum[i]=sum[i-1]+(int)(ite-a.begin());
		}
	}
	ll ret=0;
	REP(i,n) {
		auto ite=lower_bound(ALL(b),c[i]);
		if(ite==b.begin()) continue;
		ite--;
		ret+=sum[ite-b.begin()];
	}
	cout<<ret<<endl;
}


Measured memory_bytes: 3456
#include<stdio.h>

int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h = S*1/60*1/60;
    S = S%3600;
    m = S/60;
    s = S%60;
    printf("%d:%d:%d\n", h,m,s);
    return 0;

}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define l first
#define r second
using namespace std;
typedef pair<int, int> ii;

ii p[100005];

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> p[i].l >> p[i].r;
	int l = 0, r = 1e9;
	int x, y;
	for (int i = 0; i < N; ++i) {
		if (p[i].l > l) {
			l = p[i].l;
			x = i;
		}
		if (p[i].r < r) {
			r = p[i].r;
			y = i;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		ans = max(max(p[i].r - p[i].l + 1, 0), ans);
	}
	ans += max(r - l + 1, 0);
	if (x == y) {		
		cout << ans << '\n';
		return 0;
	}

	sort(p, p + N);
	multiset<int> S;
	for (int i = 0; i < N; ++i) {
		S.insert(p[i].r);
	}
	for (int i = 0; i < N - 1; ++i) {
		S.erase(S.find(p[i].r));
		ans = max(max(r - p[i].l + 1, 0) + max(*S.begin() - l + 1, 0), ans);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 5760
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  cout.precision(12);

  long A, P;
  cin >> A >> P;

  long result = 0;
  cout << (A * 3 + P) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner scan = new Scanner(System.in);	
	public static void main(String[] args) {
		int n = Integer.parseInt(scan.next());
		for(int i = 1; i <= n; i++) {
			if(i % 3 == 0) {
				System.out.print(" " + i);
			} else {
			int a = i;
				while(true) {
					if(a % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					a = a / 10;
					if(a == 0) {
						break;
					}
				}
			}
		}
		System.out.println();

	}
}

Measured memory_bytes: 28548