akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (D, G) = Slice2<long>();
            var pc = new (long p, long c)[D];
            for (var i = 0; i < D; ++i)
                pc[i] = Slice2<long>();
            var max = 2L << (int)D;
            var cnt = long.MaxValue;
            //completeする問題を決める
            for (var i = 0; i < max; ++i)
            {
                var num = 0L;
                var point = 0L;
                var used = new bool[D];
                for (long j = 0, t = i; j < D; ++j, t >>= 1)
                {
                    if (0 != (t & 1))
                    {
                        used[j] = true;
                        num += pc[j].p;
                        var qp = (j + 1) * 100;
                        point += pc[j].c + pc[j].p * qp;
                    }
                }
                var rem = G - point;
                for (var j = D - 1; 0 <= j && 0 < rem; --j)
                {
                    var qp = (j + 1) * 100;
                    if (used[j]) continue;
                    if (pc[j].p * qp < rem)
                        num = cnt;
                    else
                        num += (rem + qp - 1) / qp;
                    break;
                }
                cnt = Min(cnt, num);
            }
            WriteLine(cnt);

        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27660
W, H, N = map(int, input().split())

min_x = 0
max_x = W
min_y = 0
max_y = H

for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        min_x = max(min_x, x)
    elif a == 2:
        max_x = min(max_x, x)
    elif a == 3:
        min_y = max(min_y, y)
    else:
        max_y = min(max_y, y)

print((max_x - min_x) * (max_y - min_y) if max_x > min_x and max_y > min_y else 0)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll X, Y;
    cin >> X >> Y;

    if(abs(X-Y) <=1){
        cout << "Brown" << endl;
    }
    else{
        cout << "Alice" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N; vector<int> G[100009];
int solve(int pos, int pre, int lim) {
	vector<int> v;
	for (int i : G[pos]) {
		if (i == pre) continue;
		int res = solve(i, pos, lim);
		if (res == -1) return -1;
		v.push_back(res);
	}
	if (G[pos].size() % 2 == 1) v.push_back(0);
	sort(v.begin(), v.end());
	if (pre == -1) {
		for (int i = 0; 2 * i < v.size(); i++) {
			if (v[i] + v[v.size() - i - 1] > lim) return -1;
		}
		return 0;
	}
	for (int i = 0; 2 * i < v.size() - 1; i++) {
		if (v[i] + v[v.size() - i - 2] > lim) return -1;
	}
	for (int i = v.size() - 1; i >= 1; i--) {
		int lp = v.size() - i - 1;
		if (lp >= i) lp++;
		if (v[i] + v[lp] > lim) return v[i] + 1;
	}
	return v[0] + 1;
}
int main() {
	cin >> N;
	for (int i = 1; i < N; i++) {
		int a, b;
		cin >> a >> b; a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int c = 0;
	for (int i = 0; i < N; i++) c += G[i].size() % 2;
	int l = 0, r = N;
	while (r - l > 1) {
		int m = (l + r) >> 1;
		int res = solve(0, -1, m);
		if (res == -1) l = m;
		else r = m;
	}
	cout << c / 2 << ' ' << r << endl;
	return 0;
}

Measured memory_bytes: 16384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s;
    cin >> s;
    int win = 0;
    rep(i, s.length()) {
        if ( s[i] == 'o' ) ++win;
    }
    if ( win + 15 - s.length() >= 8 ) cout << "YES" << endl;
    else                              cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint = int_fast64_t;
const lint MOD = 1e9+7;

lint pow(lint n, lint m){
        lint ret = 1;
        while(m){
                if(m&1) ret = ret * n % MOD;
                ret %= MOD;
                n = n * n % MOD;
                m >>= 1;
        }
        return ret;
}


int main(){
        lint n, a, b;
        scanf("%ld %ld %ld", &n, &a, &b);

        lint ans = pow(2, n)-1;
        std::vector<lint> comb(2e5+1);
        comb[0] = 1;
        for(lint i=1; i<=2e5; i++){
                comb[i] = (comb[i-1] * (n-i+1))%MOD * pow(i, MOD-2) %MOD;
        }

        ans -= comb[a] + comb[b];
        while(ans<0) ans += MOD;
        printf("%ld\n", ans);
        return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(true) {
		c -= b;
		if(c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if(a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_2N = 200;
int n;
int l[MAX_2N];

int main(){
  cin >> n;
  REP(i, 2 * n) cin >> l[i];
  sort(l, l + 2 * n);
  ll ans = 0;
  REP(i, n) ans += l[i * 2];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#変数の初期化
a = 0
antennas = []
k = 0
flg = True

#入力を受け付ける
a = int(input())
for i in range(4):
    antennas.append(int(input()))
k = int(input())

#計算
for i in range(4):
    if antennas[i] - a > k:
        flg = False

#出力
if flg == True:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

public class Prog
{
    public void run()
    {
        var S = Console.ReadLine();
        var flag = true;
        while(true)
        {
            if(S.Length >= 8)
            {
                var X = S.Substring(0, 8);
                if(X == "dreamdre" || X == "dreamera")
                {
                    S = S.Substring(5, S.Length - 5);
                }else if(X == "dreamerd" || X == "dreamere")
                {
                    S = S.Substring(7, S.Length - 7);
                }else if(X == "erasedre" || X == "eraseera")
                {
                    S = S.Substring(5, S.Length - 5);
                }else if(X == "eraserer" || X == "eraserdr")
                {
                    S = S.Substring(6, S.Length - 6);
                }else
                {
                    flag = false;
                    break;
                }
            }else
            {
                if(S == "dream")
                {
                    break;
                }else if(S == "dreamer")
                {
                    break;
                }else if(S == "erase")
                {
                    break;
                }else if(S == "eraser")
                {
                    break;
                }else
                {
                    flag = false;
                    break;
                }
            }
        }
        if(flag == true)
        {
            Console.WriteLine("YES");
        }else
        {
            Console.WriteLine("NO");
        }
    }
    public static void Main()
    {
        var prog = new Prog();
        prog.run();
    }
    /*
    最小公倍数
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }

    // ユークリッドの互除法 
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
    */
    //a<=c, b<=d;
}

//Array.ConvertAll(int.Parse)
//str.IndexOf("Stage",System.StringComparison.CurrentCulture)


Measured memory_bytes: 29656
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let S = read_String_Vec();
    let len = S.len()-2;
    let mut SS = String::new();
    SS.push(S[0]);
    SS = SS + &*(len.to_string());
    SS.push(S[len+1]);

    println!("{}", SS);
}


Measured memory_bytes: 4352
/*************************
author : coldbeer
2019-06-02 6:45:13 PM
*************************/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	string str;
	cin >> str;
	str = '@' + str;
	if (c == d)
	{
		cout << "No" << endl;
		return 0;
	}
	int idx = a;
	while((idx + 1) <= max(c,d)){
		if(str[idx] == '#' && str[idx + 1] == '#'){
			cout << "No" << endl;
			return 0;
		}
		idx++;
	}
	if(c > d){
		idx = b;
		while(idx <= d){
			if(str[idx] == '#'){
				idx++;
				continue;
			}
			if(str[idx + 1] == '.' && str[idx - 1] == '.'){
				cout << "Yes" << endl;
				return 0;
			}
			idx++;
		}
		cout << "No" << endl;
	}
	else
		cout << "Yes" << endl;
	return 0;
}


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

const int N = 101;

int arr[N], pos[N];

void adjust(int i, int &n) {
        for(i; i < n; i++)
                arr[i] = arr[i + 1];
        --n;
}

int main() {
        int n; cin >> n;
        for(int i = 1; i <= n; i++) {
                cin >> arr[i];
        }
        stack <int> ans;
        while(n) {
                int f = 0;
                for(int i = n; i > 0; i--)
                        if(arr[i] == i) {
                                ans.push(i);
                                adjust(i, n);
                                f = 1;
                                break;
                        }
                if(!f) {
                        cout << -1 << endl;
                        return  0;
                }
        }
        while(!ans.empty())
                cout << ans.top() << endl,
                ans.pop();

}


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

import functools

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

N,X = map(int, input().split())
x = list(map(int, input().split()))

dist = [abs(x[i] - X) for i in range(N)]
D = functools.reduce(gcd, dist)

print(D)

Measured memory_bytes: 14596
import Control.Monad
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  xs <- map (\[a,b] -> (a,b)) . map (map read . words) . lines <$> getContents :: IO [(Int,Int)]
  let v = vec xs
  print $ solve v 1 k

vec :: [(Int,Int)] -> VU.Vector Int
vec xs = 
  VU.create $ do
    vec <- VUM.replicate (10^5+1) (0::Int)
    forM_ xs $ \(a,b) -> do
      r <- VUM.read vec a
      VUM.write vec a (b+r)
    return vec

solve :: VU.Vector Int -> Int -> Int -> Int
solve vec n k
  | b >= k = n
  | otherwise = solve vec (n+1) (k-b)
    where
      b = vec VU.! n

Measured memory_bytes: 2812
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
using namespace std;

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    namespace mp = boost::multiprecision;
    using Bint = mp::cpp_int;

    int n;
    cin >> n;

    Bint fact = 1;
    for(Bint i = 1 ; i <= n + 1 ; ++i){
        fact *= i;
    }
    fact += 2;

    cout << fact << endl;
    for(int i = 0 ; i < n ; ++i){
        if(i % 2 == 0){
            cout << 2 << endl;
        }else{
            for(Bint j = 3 ; j <= fact ; ++j){
                if(fact % j == 0){
                    cout << j << endl;
                    break;
                }
            }
        }
        ++fact;
    }

    return 0;
}


Measured memory_bytes: 3292
inputs = readlines
# inputs = "SSR\nSSR\n".split("\n")

s = inputs[0]
t = inputs[1]

def solve(s, t)
  count = 0
  (0..2).each do |i|
    count += 1 if s.chars[i] == t.chars[i]
  end
  count
end

puts solve(s, t)



Measured memory_bytes: 1788
import sys
input = sys.stdin.readline

def main():
    x = input().strip() + "x"
    c = []
    pre = x[0]
    count = 1
    for i in range(1, len(x)):
        if x[i] != pre:
            c.append(count)
            count = 1
        else:
            count += 1
        pre = x[i]

    ans = len(x) - 1
    stock = 0
    if x[0] == "S":
        start = 1
    else:
        start = 2

    for i in range(start, len(c), 2):
        if c[i-1] + stock <= c[i]:            
            ans -= (c[i-1]+stock) * 2
            stock = 0
        else:
            ans -= c[i] * 2
            stock += c[i-1] - c[i]
    
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 4328
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		while(true){
		    int x = sc.nextInt();
		    int y = sc.nextInt();
		    if ( x == 0 && y == 0 ) break;  
		    if ( x < y ){
			    System.out.println(x + " " + y);
			} else {
			    System.out.println(y + " " + x);
			}
		}
		sc.close();
	}
}




Measured memory_bytes: 34564
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
  freopen("b.in", "r", stdin);
  freopen("b.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {
    vector<int> p(n * n);
    for (int& x : p) {
      scanf("%d", &x);
      --x;
    }

    vector<vector<int>> d(n, vector<int>(n));
    vector<vector<int>> c(n, vector<int>(n, 1));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min({i + 1, j + 1, n - i, n - j});
      }
    }

    ll ans = 0;
    queue<pair<int, int>> q;
    for (int id : p) {
      int row = id / n;
      int col = id % n;
      c[row][col] = 0;
      const pair<int, int> dv[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
      for (auto [dx, dy] : dv) {
        q.emplace(row + dx, col + dy);
      }
      while (!q.empty()) {
        auto [row, col] = q.front();
        q.pop();
        int dd;
        if (row < 0 || row >= n || col < 0 || col >= n) {
          dd = 0;
        } else {
          dd = d[row][col];
        }
        auto relax = [&](int row, int col, int dd) {
          if (row < 0 || row >= n || col < 0 || col >= n) {
            return;
          }
          dd += c[row][col];
          if (d[row][col] <= dd) return;
//          eprintf("! %d %d %d\n", row, col, dd);
          d[row][col] = dd;
          q.emplace(row, col);
        };
        for (auto [dx, dy] : dv) {
          relax(row + dx, col + dy, dd);
        }
      }
      ans += d[row][col];
//      eprintf("%d %d %d %d\n", id, row, col, d[row][col]);
    }
    printf("%lld\n", ans);
  }


  return 0;
}


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

int main(){
	string s;
	string c;
	int i = 0;
	int j = 0;
	
	cin >> c;
	while(c[j] != '\0'){
		if(c[j] == '1'){
			if(i < 10){
				i++;
				s.push_back('1');
			}
		}
		else if(c[j] == '0'){
			if(i < 10){
				i++;
				s.push_back('0');
			}
		}
		else if(c[j] == 'B'){
			if(i > 0){
				i--;
				s.pop_back();
			} 	
		}
		j++;
	}
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 256
//Confuse them with your silence and shock them with your results;
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define booster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PB push_back
#define F first
#define S second
#define int long long 

const int mod=1e9+7;
int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }
clock_t time_p=clock();
void rtime(){ time_p=clock()-time_p; cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}


int rr[]={0,1,1,1,0,-1,-1,-1};
int cc[]={1,1,0,-1,-1,-1,0,1};


signed main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    booster;
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin >> n;
        int b[n - 1], a[n] = {0};
        for(int i = 0; i < n - 1; i++) {
            cin >> b[i];
            if(i == 0) {
                a[i] = b[i];
                a[i + 1] = b[i];
            }
            else {
                a[i] = min(a[i], b[i]);
                a[i + 1] = max(b[i], a[i + 1]);
            }
        }
        int ans = 0;
        for(int i = 0; i < n; i++) {
            ans += a[i];
            //cerr << a[i] << ' ';
        }
        cout << ans;
    }
    rtime();
    return 0;
}

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

using namespace std;

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

	int long_edge = 0;

	for (int i = 0; i < N; i++) {
		long_edge = max(long_edge, L[i]);
	}

	int sum = 0;
	bool once = true;

	for (int i = 0; i < N; i++) {
		if (L[i] == long_edge && once) {
			once = false;
			continue;
		}
		else sum += L[i];
	}

	if (long_edge < sum) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3608
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;
vector<string> v(0);

void dfs(ll a, ll n, string p, vector<string> &v){
    if(a == n){
        v.emplace_back(p);
        return;
    }
    char mx = a - 1;
    rep(i, 0, a){
        string m = p;
        m.push_back(p[i]);
        dfs(a+1, n, m, v);
        mx = max(mx, p[i]);
    }
    string z = p;
    z.push_back(mx + 1);
    dfs(a+1, n, z, v);
}

int main(){
    ll N; cin >> N;
    vector<string> v(0);
    string p = "a";
    dfs(1, N, p, v);
    set<string> h;
    for(auto x : v){
        h.insert(x);
    }
    for(auto x: h){
        prtl(x);
    }
}

Measured memory_bytes: 258784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mem(x,v) memset(x,v,sizeof(x))
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define gc getchar
#define pc putchar
#define fi first
#define se second
inline ll read(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);pc('\n');}
inline void wri(ll x){write(x);pc(' ');}
const int maxn = 2e5+233;;
//我好菜啊（题题看题解）神仙结论
int e,n,o,a[maxn];
bool solve(){ 
	if(!e) return 0;//都是偶数 
	if(e&1) return 1;//先手有优势 
	if(o!=1) return 0;
	int g=0;Rep(i,1,n)if(a[i]!=1){if(a[i]&1)a[i]--;g=__gcd(g,a[i]);}
	e=o=0;Rep(i,1,n)if(a[i]!=1){a[i]/=g;if(a[i]!=1)o+=a[i]&1,e+=!(a[i]&1);}
	return !solve();
}
int main(){
	n = read();
	Rep(i,1,n){
		a[i] = read();
		if(a[i] != 1) o += a[i] & 1,e += !(a[i] & 1);
	}
	puts(solve()?"First":"Second");
	return 0;
}
/*
wzporz 
zzdorz
clyorz
lyxorz
cljorz
zxorz
sxdorz
yzrorz
ykorz  ...9 people
qyorz ...9 people
Emmmmm这TM还想进省队，我是找死吗？
小官人，该醒醒了，你文化课凉地很呀 
 
我有一个梦想
I have a dream.
	//I'd like to get AU in NOI
	//当然，我从来没有过上面这样的不切实际的幻想
	//Ofcourse,not such unrealistic dream.
我的梦想还是比较现实的，应该是
My dream is still more realistic, it should be
有学上 
I want to go to university.

啊，普爱的耶和华呀
啊，可敬的玉皇大帝呀
啊，慈悲的如来佛祖呀
啊，无上的元始天尊呀 
赐予我力量吧 
*/ 

Measured memory_bytes: 640
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}
//

#pragma endregion

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

int main() {
    i64 n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    vector<i64> v(200);
    v[s[0]] = 1;
    for(int i = 1; i < n - 1; ++i){
        v[s[i]] = (v[s[i]] + v[t[i]]) % MOD;
    }
    cout << v[t[n - 1]] << endl;
}



Measured memory_bytes: 3324
#include <stdio.h>

int main(void)
{
	int number[30];
	int i;
	int w;
	int n;
	char conma;
	int a1;
	int a2;
	int swap;
	
	for (i = 0; i < 30; i++){
		number[i] = i + 1;
	}
	
	scanf("%d", &w);
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d %c %d", &a1, &conma, &a2);
		swap = number[a1 - 1];
		number[a1 - 1] = number[a2 - 1];
		number[a2 - 1] = swap;
	}
	
	for (i = 0; i < w; i++){
		printf("%d\n", number[i]);
	}
	
	return 0;
}

Measured memory_bytes: 596
# imos 法
N = int(input())
a = list(map(int, input().split()))

t = [0] * (10 ** 5 + 3)  # t[X + 1] は ai = X となる i の個数
for x in a:
    t[x] += 1
    t[x + 3] -= 1

for i in range(1, 10 ** 5 + 3):
    t[i] += t[i-1]

print(max(t))


Measured memory_bytes: 13964
n = int(input())
mod = int(1e9 + 7)
ans = 0
if n <= 1:
    print(ans)
else :
    ans = pow(10, n, mod) - 2 * pow(9, n, mod) + pow(8, n, mod)
    ans += 2 * mod
    ans %= mod
    print(ans)

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    vector<vector<int> >dp(s.length()+1,vector<int>(t.length()+1));
    for(int i=0;i<s.length();i++){
        for(int j=0;j<t.length();j++){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }else{
                dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
            }
        }
    }
    string ans = "";
    int j = t.length();
    int i = s.length();
    while(i > 0 && j > 0){
        if(s[i-1] == t[j-1]){
            ans = s[i-1] + ans;
            i--;
            j--;
        }else{
            if(dp[i][j] == dp[i-1][j]){
                i--;
            }else{
                j--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 38924
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const int big=1e9+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
int main(void){
	int bi,i,j,n,m,all=0;cin>>n>>m;
	int hen[15][15];
	for(i=0;i<15;i++){
		for(j=0;j<15;j++){
			hen[i][j]=-big;
		}
	}
	for(i=0;i<m;i++){
		int a,b,c;cin>>a>>b>>c;a--;b--;
		all+=c;
		hen[a][b]=c;
		hen[b][a]=c;
	}
	int waka[32768]={0};
	//bitが立っているところでの残す道のア
	for(bi=0;bi<(1<<n);bi++){
		for(i=0;i<n;i++){
			if((bi&(1<<i))==0){continue;}
			for(j=0;j<i;j++){
				if((bi&(1<<j))==0){continue;}
				waka[bi]+=max(0,hen[i][j]);
			}
		}
	}
	static int dp[32768][15]={0};
	for(bi=0;bi<(1<<n);bi++){for(j=0;j<15;j++){dp[bi][j]=-big;}}
	for(bi=0;bi<(1<<(n-1));bi++){dp[bi][0]=waka[bi];}
	for(bi=0;bi<(1<<n);bi++){
		for(int bjj=0;bjj<(1<<n);){
			if((bi&bjj)!=0){
				bjj+=(bi&bjj);
				
				continue;
			}
			for(i=0;i<n;i++){
				if((bi&(1<<i))==0){continue;}
				for(j=0;j<n;j++){
					if((bjj&(1<<j))==0){continue;}
					maxeq(dp[bjj+bi][j],dp[bi][i]+waka[bjj]+hen[i][j]);
				}
			}
			bjj++;
		}
	}
	cout<<all-dp[(1<<n)-1][n-1]<<endl;
	RE;
}

Measured memory_bytes: 2432
#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
	cin>>s;
	string s1=s;
	int n=s.length();
	if(n%2){cout<<"No";return 0;}
	for(int i=0;i<n/2;++i)
	{		
		if(s1[i]=='b')s1[i]='d';
		else if(s1[i]=='d')s1[i]='b';
		else if(s1[i]=='q')s1[i]='p';
		else if(s1[i]=='p')s1[i]='q';
		if(s1[n-i-1]=='b')s1[n-i-1]='d';
		else if(s1[n-i-1]=='d')s1[n-i-1]='b';
		else if(s1[n-i-1]=='q')s1[n-i-1]='p';
		else if(s1[n-i-1]=='p')s1[n-i-1]='q';
		char t=s1[i];s1[i]=s1[n-i-1];s1[n-i-1]=t;
	}
//	cout<<s1<<endl<<s;
	if(s1==s)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18
int main(){
    ll n,key,ans=0;
    cin>>n;
    vector<ll>a(n);
    for(int i=0;i<n;i++){
        ll hoge;
        cin>>hoge;
        a[i]=hoge-i-1;
    }
    sort(a.begin(),a.end());
    if(n%2==1){
        key=a[n/2];
    }
    else{
        key=(a[n/2]+a[n/2-1])/2;
    }
    for(int i=0;i<n;i++){
        ans+=abs(a[i]-key);
    }
    cout<<ans<<endl;

}




Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;
using llong = long long;

int freq[100001];
int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;++i){
    int a;
    cin >> a;
    freq[a]++;
  }
  int num = N;
  int num2 = 0;
  for(int i=1;i<=100000;++i){
    if(freq[i]>=3){
      num -= (freq[i]-1)/2*2;
      freq[i] -= (freq[i]-1)/2*2;
    }
    if(freq[i]==2) num2++;
  }
  num -= (num2+1)/2*2;
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

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

int main(){
    int n,X;
    cin>>n>>X;
    vector<int> x(n);
    vector<int> dis(n);
    for(int i = 0;i < n;i++){
        cin >> x[i];
        dis[i] = abs(X-x[i]);
    }
    int d = dis[0];
    for(int i=1;i<n;i++){
        d = gcd(max(dis[i],d),min(dis[i],d));
    }
    
    cout<<d<<endl;
}

Measured memory_bytes: 1024
n,y = map(int, input().split())

for i in range(n+1):
    for j in range(n+1-i):
        k = n -i -j
        if i *10000 + j *5000 + k *1000 == y:
            print(i,j,k)
            exit()
print('-1 -1 -1')






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

int main(){
    int n;
    int ans = 0;
    std::string x;
    const std::string search_str="ABC";
    std::cin>>n;
    std::cin>>x;
    std::string::size_type pos = x.find(search_str);
    while (pos != std::string::npos) {
        // std::cout << pos << std::endl;
        pos = x.find(search_str, pos + search_str.length());
        ans++;
    }
    
       std::cout<<ans<<std::endl;
   
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sqn, lst[200005], cd[200005], ba[200005], ans[200005];
struct query
{
    ll id, l, r;
    bool operator < (const query &rhs) const
    {
        if(l / sqn == rhs.l / sqn) return r < rhs.r;
        return l / sqn < rhs.l / sqn;
    }
}q[200005];
char s[200005];
map<ll, ll> Map;
int main()
{
    ll n, m, p, l = 1, r = 0, cur = 0, bt = 1;
    m=1;
    scanf("%lld%lld%s",&n, &p, s + 1);
    n = strlen(s + 1), sqn = (ll)sqrt(n * 1.0);
    if(p != 2 && p != 5)
    {
        for(ll i = n; i; i--)
        {
            bt = bt * 10 % p;
            lst[i] = (lst[i + 1] + (s[i] - 48) * bt) % p;
            cd[i] = lst[i];
        }
        sort(cd + 1, cd + n + 1);
        for(ll i = 1; i <= n + 1; i++)
            Map[cd[i]] = i;
        for(ll i = 1; i <= n + 1; i++)
            lst[i] = Map[lst[i]];
        for(ll i = 1; i <= m; i++)
        {
        	q[i].l=1,q[i].r=n;
            q[i].id = i, q[i].r++;
        }
        sort(q + 1, q + m + 1);
        for(ll i = 1; i <= m; i++)
        {
            while(r < q[i].r) cur += ba[lst[++r]]++;
            while(l > q[i].l) cur += ba[lst[--l]]++;
            while(l < q[i].l) cur -= --ba[lst[l++]];
            while(r > q[i].r) cur -= --ba[lst[r--]];
            ans[q[i].id] = cur;
        }
        for(ll i = 1; i <= m; i++)
            printf("%lld\n", ans[i]);
    }
    else
    {
        for(ll i = 1; i <= n; i++)
            if(!((s[i] - 48) % p))
                ba[i] = ba[i - 1] + 1, cd[i] = cd[i - 1] + i;
            else
                ba[i] = ba[i - 1], cd[i] = cd[i - 1];
        for(ll i = 1; i <= m; i++)
        {
            l=1,r=n;
            printf("%lld\n", cd[r] - cd[l - 1] - (ba[r] - ba[l - 1]) * (l - 1));
        }
    }
    return 0;
}

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


void solve_2_5(int N, int P, const string& S){
  ll ret = 0;
  rep(i,N){
    if(((int)(S[i]-'0'))%P == 0) ret += (i+1);
  }
  cout << ret << endl;
}

void solve_dp(int N, int P, const string& S){
  vector<ll> v(P, 0);

  ll ret = 0;
  rep(i,N){
    vector<ll> nv(P, 0);
    rep(j,P){
      int nj = (j*10+(int)(S[i]-'0'))%P;
      nv[nj] += v[j];
    }
    nv[((int)(S[i]-'0'))%P]++;
    ret += nv[0];
    swap(v, nv);
  }

  cout << ret << endl;
}

int main(){
  int N, P;
  cin >> N >> P;
  string S;
  cin >> S;

  if(P==2 || P==5){
    solve_2_5(N, P, S);
    return 0;
  }
  
  reverse(ALLOF(S));
  vector<int> v(N, 0);
  int base = 1;
  rep(i,N){
    v[i] = base * (int)(S[i]-'0');
    v[i] %= P;
    base *= 10;
    base %= P;
  }

  vector<int> sum(N+1,0);
  rep(i,N){
    sum[i+1] = (sum[i] + v[i])%P;
  }

  ll ret = 0;
  map<int,ll> memo;
  rep(i,N){
    if(sum[i+1]==0) ret++;
    ret += memo[sum[i+1]];
    memo[sum[i+1]]++;
  }
  
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 2564
n,a,b,c,d=map(int,input().split())
s=input()
a,b,c,d=a-1,b-1,c-1,d-1
#ぬかさないケース
if c<b:
  if s[a:c].find("##")==-1 and s[b:d].find("##")==-1:
    print("Yes")
  else:
    print("No")
elif s[a:d].find("##")==-1:
  if c<d:
    print("Yes")
  else:
    if s[b-1:d+2].find("...")==-1:
      print("No")
    else:
      print("Yes")
else:
  print("No")


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

int main() {
  int H, N;
  cin >> H >> N;

  int A = 0;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    A += vec.at(i);
  }
  if (A >= H) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n;
    cin >> n;
    string ans="No";
    for(int i=1; i<=9; i++){
        if(n%i==0 && (n/i)<=9)ans="Yes";
    }
    cout << ans << endl;
    return 0;
}

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

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

typedef long long LL;
typedef __int128 Int;
const LL MOD=1e9+7;
const LL INF=1e16;


typedef vector<LL> V;
typedef vector<V> VV;
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto &it:v)is>>it;return is;}
#define SPACE " "
template<typename T> ostream& operator<<(ostream& os,vector<T>& v){for(int i=0,sz=v.size();i<sz;i++)os<<(!i)+SPACE<<v[i];return os;}

int AB[100000][32];
int BA[100000][32];
void calc(V& x,LL L){
    int N=x.size();
    for(int i=0;i<N;i++){
        int can=i,cannot=N;
            while(abs(cannot-can)>1){
                const int mid=(can+cannot)/2;
                if(abs(x[mid]-x[i])<=L)can=mid;
                else cannot=mid;
            }
            AB[i][0]=can;
    }
    for(int i=0;i<N;i++){
        int can=i,cannot=-1;
            while(abs(cannot-can)>1){
                const int mid=(can+cannot)/2;
                if(abs(x[mid]-x[i])<=L)can=mid;
                else cannot=mid;
            }
            BA[i][0]=can;
    }
    for(int k=1;k<30;k++)
        for(int i=0;i<N;i++){
            AB[i][k]=AB[AB[i][k-1]][k-1];
            BA[i][k]=BA[BA[i][k-1]][k-1];
        }
}

int main(){
    int N,Q;LL L;
    cin>>N;
    V x(N);
    cin>>x;
    cin>>L>>Q;
    calc(x,L);
    vector<int> a(Q),b(Q);
    for(int i=0;i<Q;i++){
        cin>>a[i]>>b[i];a[i]--;b[i]--;
    }
    for(int i=0;i<Q;i++){
        LL res=0;
        int now=a[i];
        if(a[i]<b[i]){
            int k=25; 
            while(now<b[i]){
                while(k>0&&AB[now][k]>=b[i])k--;
                res+=(1<<k);
                now=AB[now][k];
            }
            cout<<res<<endl;
        }
        else{
            int k=25; 
            while(now>b[i]){
                while(k>0&&BA[now][k]<=b[i])k--;
                res+=(1<<k);
                now=BA[now][k];
            }
            cout<<res<<endl;

        }
    }
    return 0;
}


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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

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

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

   int N;
   cin>>N;
   vector<int>a(N);
   for(int i=0;i<N;i++)cin>>a[i];
   ll ans = 0;
   for(int i=0;i<N;i++){
      while(a[i]%2==0){
         a[i] /= 2;
         ans++;
      }
   }
   cout<<ans<<endl;
   return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

int n,p;
vector<ll> v;

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

	cin>>n>>p;
	ll sum=0;
	REP(i,n) {
		ll w,b;cin>>w>>b;
		sum+=(-p)*b;
		v.pb(w*(100-p)+p*b);
	}
	sort(ALL(v));reverse(ALL(v));
	REP(i,n) {
		sum+=v[i];
		if(sum>=0) {
			cout<<i+1<<endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 1400
import math
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
h_count = [0] * n
ab_list = []
count = 0
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    ab_list.append([a, b])


for i in range(m):
    if h_list[ab_list[i][0]] > h_list[ab_list[i][1]]:
        h_count[ab_list[i][1]] += 1
    elif h_list[ab_list[i][0]] < h_list[ab_list[i][1]]:
        h_count[ab_list[i][0]] += 1
    else:
        h_count[ab_list[i][1]] += 1
        h_count[ab_list[i][0]] += 1


print(h_count.count(0))


Measured memory_bytes: 92156
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N * 3);
  for (int i = 0; i < N * 3; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  long long ans = 0;
  for (int i = 0; i < N; i++){
    ans += A[i * 2 + 1];
  }
  cout << ans << endl;
}

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

UL D;
UL C[26];
UL S[400][26];

UL T[400];
LL Last[26];
LL Score[26] = {};
LL Sum = 0;

void CalcScore(UL i){
 Sum -= Score[i];
 Score[i]=0;
 Last[i]=-1;
 rep(d,D){
  if(T[d]==i) {
   Score[i] += S[d][i];
   Last[i]=d;
  }
  Score[i] -= C[i] * ((LL)d-Last[i]);
 }
 Sum += Score[i];
}

int main() {
 scanf("%u", &D);
 rep(i,26) scanf("%u",&C[i]);
 rep(i,D)rep(j,26) scanf("%u",&S[i][j]);
 rep(i,D) {scanf("%u",&T[i]); T[i]--;}
 
 rep(i,26) CalcScore(i);
 
 UL M;
 scanf("%u",&M);
 rep(m,M){
  UL d,q; scanf("%u%u",&d,&q); d--;q--;
  UL buf = T[d];
  T[d]=q;
  CalcScore(buf);
  CalcScore(q);
  printf("%lld\n", Sum);
 }

 return 0;
}



Measured memory_bytes: 3852
import numpy as np

N = int(input())
A = list(map(int, input().split()))

diff = []
for i in range(N):
    diff.append(A[i] - (i+1))

b = int(np.median(diff))

ans = 0
for i in range(N):
    ans += abs(A[i] - (b + (i+1)))

print(ans)

Measured memory_bytes: 34220
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define IGNORE
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
#define INSIDE(i,j,H,W) ((i) >= 0 && (i) < (H) && (j) >= 0 && (j) < (W))
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) {string s; ist >> s; return ist;}

// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif
int N, M;
int main() {
	cin >> N >> M;
	cout << (1 << M) * (M * 1900 + (N - M) * 100) << endl;
	return 0;
}


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

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

    if (s == "Sunny")
    {
        cout << "Cloudy" << endl;
        return 0;
    }
    else if (s == "Cloudy")
    {
        cout << "Rainy" << endl;
        return 0;
    }
    else // (s == "Cloudy")
    {
        cout << "Sunny" << endl;
        return 0;
    }
    return 0;

}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

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

int main() {
    int X,N;
    cin >> X >> N;
    vector <int> p(N);
    for (int i=0; i<N; i++) cin >> p.at(i);
    sort(p.begin(), p.end());
    auto result = std::find(p.begin(), p.end(), X);
    if (result == p.end()) {
        cout << X << endl;
        return 0;
    } //else {
//        if (p.at(0)==X) {
//            cout << p.at(0)-1 << endl;
//            return 0;
//        }
//        else if (p.at(N-1)==X) {
//            cout << p.at(N-1)+1 << endl;
//            return 0;
//        }
    else {
        for (int i=0; i<N; i++) {
            if (p.at(i)==X) {
                int l=X-1;
                int h=X+1;
                while (true) {
                    //cout << l << "," << h<< endl;
                    result = std::find(p.begin(), p.end(), l);
                    if (result == p.end()) {
                        cout << l << endl;
                        return 0;
                    }
                    result = std::find(p.begin(), p.end(), h);
                    if (result == p.end()) {
                        cout << h << endl;
                        return 0;
                    }
                    l-=1;
                    h+=1;
                }
            }
        }
    }
}

Measured memory_bytes: 3636