akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <set>
#include <string>
#include <string.h>
using namespace std;

int main()
{
    long long ren;
    cin>>ren;
    long long sz[5];
    long long min;
    for(int i=0;i<5;i++)
    {
        cin>>sz[i];
    }
    min=sz[0];
    for(int i=1;i<5;i++)
    {
        if(sz[i]<min)
            min=sz[i];
    }
    if(ren%min!=0)
    {
        cout<<ren/min+1+4<<endl;
    }
    else
    {
        cout<<ren/min+4<<endl;
    }
    return 0;
}


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

int a[100];
int main() {
	int n; scanf("%d", &n);
	int Max = 0;
	rep(i, n) {
		scanf("%d", &a[i]);
		Max = max(Max, a[i]);
	}
	int d = Max / 2 + !!(Max % 2);
	for (int i = d; i <= Max; i++) {
		int nd = (Max % 2 == 0 && i == d ? 1 : 2);
		for (int j = 0; j < n&&nd; j++) {
			if (a[j] == i)a[j] = 0, nd--;
		}
		if (nd) {
			puts("Impossible"); return 0;
		}
	}
	rep(i, n) {
		if (a[i] && a[i] <= d) {
			puts("Impossible"); return 0;
		}
	}
	puts("Possible");
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int c = 1;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    do
    {
        c += (a - 1);
        ans++;
    } while (c < b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (a, b, x) = readListOfInt() 

    val restCats = x - a
    val isAble = restCats >= 0 && b >= restCats
    println(if(isAble) "YES" else "NO")
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
   int n;cin>>n;
   vector<ll> v(n);
   for(int i=0;i<n;i++)cin>>v[i];
   ll sum=0,summ=0;
   for(int i=0;i<n;i++){
       sum+=v[i];
       if(i&1)summ+=v[i];
   }
   vector<ll> ans(n);
   ans[0]=(sum-summ*2);
   for(int i=1;i<n;i++)ans[i]=2*v[i-1]-ans[i-1];
   for(ll i:ans)cout<<i<<' ';
}

Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include<string.h>
using namespace std;
int main()
{
    char s[100];
    cin >> s;
    for(int i=0;i<strlen(s);i++){
        if(s[i]=='9')
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

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

int main(){
  long long A, B;
  cin >> A >> B;
  if(A<B){
    long long temp=A;
    A=B;
    B=temp;
  }
  long long r = A % B;
  while(r!=0){
    A = B;
    B = r;
    r = A % B;
  }
  
  vector<long long> divisor;
  for(long long i=1; i*i<=B; i++){
    if(B%i!=0) continue;
    divisor.push_back(i);
    if(B/i==i) continue;
    divisor.push_back(B/i);
  }
  
  long long ans=0;
  for(long long i=0; i<divisor.size(); i++){
    long long ant=0;
    for(long long j=2; j*j<=divisor.at(i); j++){
      if(divisor.at(i)%j==0) ant++;
    }
    if(ant==0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
n = int(input())
as_ =  list(map(int, input().split()))

l = [0]*n
m = [0]*n
r = [0]*n
for i in range(n):
  l[i] = as_[i]
  m[i] = as_[n+i]
  r[i] = (-1)*as_[2*n+i]

import heapq
heapq.heapify(l)
heapq.heapify(r)

l_maxs = [0]*(n+1)
r_mins = [0]*(n+1)

sl = sum(l)
sr = sum(r)

for i in range(n+1):
  if i != 0:
    j = i-1
    heapq.heappush(l, m[j])
    a = heapq.heappop(l)
    sl += m[j] -a
    
    k = -i
    heapq.heappush(r, m[k]*(-1))
    b = heapq.heappop(r)
    sr += m[k]*(-1) - b
    
  l_maxs[i] = sl
  r_mins[i] = sr

#print(l_maxs)
#print(r_mins)

print(max([l_maxs[i] + r_mins[n-i] for i in range(n+1)]))

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

int main()
{
	int i, n, x, count, ans=0;

	cin >> n;

	int a[n];

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

	sort(a, a+n);

	x=a[0];
	count=1;
	for(i=1; i<n; i+=1)
	{
		if(a[i]==x)
			count+=1;
		else
		{
			if(count < x)
				ans+=count;
			else
				ans+=count-x;
			x=a[i];
			count=1;
		}
	}
	if(count < x)
		ans+=count;
	else
		ans+=count-x;

	cout << ans << endl;
}

Measured memory_bytes: 640
IDENTIFICATION DIVISION.
PROGRAM-ID. A-AIRPLANE.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP      PIC X(100).
01 IN-DATA.
   03 DT-X1 PIC X(10).
   03 DT-X2 PIC X(10).
   03 DT-X3 PIC X(10).
01 IN-LEN.
   03 DT-L1 PIC 9(2).
   03 DT-L2 PIC 9(2).
   03 DT-L3 PIC 9(2).
01 FL-TIME.
   03 FL-T  PIC 9(3) OCCURS 3 DEPENDING ON CNT.
01 CNT      PIC 9(1) VALUE 3.
01 OUT-TIME PIC ZZ9.
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO DT-X1 COUNT IN DT-L1
           DT-X2 COUNT IN DT-L2
           DT-X3 COUNT IN DT-L3.
  MOVE DT-X1(1:DT-L1) TO FL-T(1).
  MOVE DT-X2(1:DT-L2) TO FL-T(2).
  MOVE DT-X3(1:DT-L3) TO FL-T(3).
 
  SORT FL-T ASCENDING KEY FL-T.

  COMPUTE OUT-TIME = FL-T(1) + FL-T(2).
  DISPLAY OUT-TIME.

MAIN-EXIT.
  STOP RUN.

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    if (m == 1) {
        printf("1 2\n");
        return 0;
    }
    ll v1 = 1;
    ll v2 = m + 2;
    rreps(i, 1, m + 1) {
        printf("%lld %lld\n", v1, v1 + i);
        v1++;
        swap(v1, v2);
    }
    return 0;
}


Measured memory_bytes: 3792
from collections import deque

N = int(input())
edge = [set() for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    edge[a].add((b, i))
    edge[b].add((a, i))
    
r = [0] * (N-1)
q = deque([(0, 1)])

while q:
    preC, fromv = q.popleft()
    c = 0
    for tov, i in edge[fromv]:
        edge[tov].remove((fromv, i))
        c += 1 + (c + 1 == preC)
        q.append((c, tov))
        r[i] = c

print(max(r))
for x in r:
    print(x)

Measured memory_bytes: 51784
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=200005;
const int INF=1000000000;
long long n,a[MAXN],b[MAXN];
long long fet,t=INF;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i],&b[i]);
		fet=fet+a[i];
		if(a[i]>b[i])t=min(t,b[i]);
	}
	if(t==INF)printf("0\n");
	else printf("%lld\n",fet-t);
}


Measured memory_bytes: 512
n = int(input())
max_cnt = 0
ans = 1
for i in range(n):
    x = i + 1
    cnt = 0
    while x % 2 == 0:
        x //= 2
        cnt += 1
    if cnt > max_cnt:
        max_cnt = cnt
        ans = i + 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int n, s, t, a, b;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		a = b = 0;
		for(int i = 0; i < n; i++){
			cin >> s >> t;
			if(s > t){
				a += (s+t);
			} else if(s < t){
				b += (s+t);
			} else {
				a += s;
				b += t;
			}
		}
		
		cout << a << " " << b << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>

#define rep(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 110000
#define pb push_back

using namespace std;

int main(){
	lint n,x;
	cin>>n>>x;
	lint a[SIZE],ans=0;
	for(lint i=0;i<n;i++){
		cin>>a[i];
	}
	for(lint i=0;i<n-1;i++){
		if(a[i]+a[i+1]>x){
			if(a[i]+a[i+1]-x>a[i+1]){
				ans+=a[i]+a[i+1]-x;
				a[i]-=a[i]-x;
				a[i+1]=0;
			}
			else{
				ans+=a[i]+a[i+1]-x;
				a[i+1]-=a[i]+a[i+1]-x;
			}
		}
	}
	cout<<ans;
return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2000002)

def DFS(i, pos, connected, distances):
  if pos[i] == None:
    pos[i] = 0
  size = len(connected[i])
  for j in range(size):
    if pos[connected[i][j]] == None:
      pos[connected[i][j]] = pos[i] + distances[i][j]
      if DFS(connected[i][j], pos, connected, distances) == False:
        return False
    elif pos[connected[i][j]] != pos[i] + distances[i][j]:
      return False
  return True

N, M = map(int, input().split())
pos = [None for i in range(N + 1)]
connected = [[] for i in range(N + 1)]
distances = [[] for i in range(N + 1)]
for i in range(M):
  l, r, d = map(int, input().split())
  connected[l].append(r)
  distances[l].append(d)
  connected[r].append(l)
  distances[r].append(-d)
judge = True
for i in range(1, N + 1):
  if pos[i] == None:
    judge = DFS(i, pos, connected, distances)
    if judge == False:
      break
if judge:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 127220
#include <iostream>

using namespace std;

int M, N;

char nums[101][101];

int cnt = 0;

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

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

void dfs(int x, int y, char c) {
	if (nums[x][y] != c) {
		return;
	}
	nums[x][y] = '.';
	for (int i = 0; i < 4; i++) {
		int tx = dx[i] + x;
		int ty = dy[i] + y;
		if (tx >= 0 && tx < M && ty >= 0 && ty < N) {
			if (nums[tx][ty] == c)
				dfs(tx, ty, c);
		}
	}
}

int main() {
	while (true) {
		cin >> M;
		cin >> N;
		if (!M && !N) {
			break;
		}
		if (!M || !N) {
			cout << 0 << endl;
			continue;
		}
		for (int i = 0; i < M; i++) {
			for (int j = 0; j < N; j++) {
				cin >> nums[i][j];
			}
		}
		for (int i = 0; i < M; i++) {
			for (int j = 0; j < N; j++) {
				if (nums[i][j] != '.') {
					cnt++;
					dfs(i, j, nums[i][j]);
				}
			}
		}
		cout << cnt << endl;
		cnt = 0;
	}
	return 0;
}


Measured memory_bytes: 3556
def d_five_five_everywhere(N):
    def prime_table(n):  # nまでの素数のリスト
        is_prime = [True] * (n + 1)
        is_prime[0] = is_prime[1] = False  # 0と1は素数でない
        for j in range(2, int(n**0.5) + 1):
            if not is_prime[j]:
                continue
            for k in range(j * 2, n + 1, j):
                is_prime[k] = False  # jの倍数は素数でない
        return [i for i in range(n + 1) if is_prime[i]]

    prime_mod5_is_1 = [p for p in prime_table(55555) if p % 5 == 1]
    return ' '.join(map(str, prime_mod5_is_1[:N]))

N = int(input())
print(d_five_five_everywhere(N))

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
int n, m;
char a[10][10];
 
bool isvalid(int x, int y)
{
	if(x>=0&&x<n&&y>=0&&y<m) return true;
	return false;
}
 
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n>>m;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin>>a[i][j];
		}
	}
	int x = 0; int y = 0;
	vector<ii> moves;
	moves.pb(mp(0,0));
	for(int i = 1; i <= n + m - 2; i++)
	{
		bool c = 0; bool d = 0;
		if(isvalid(x+1,y)&&a[x+1][y]=='#')
		{
			c=1;
		}	
		if(isvalid(x,y+1)&&a[x][y+1]=='#')
		{
			d=1;
		}
		if(c^d)
		{
			if(c)
			{
				x++;
				moves.pb(mp(x,y));
			}
			else
			{
				y++;
				moves.pb(mp(x,y));
			}
		}
		else
		{
			cout<<"Impossible\n"; return 0;
		}
	}
	for(int i = 0; i < moves.size(); i++)
	{
		a[moves[i].fi][moves[i].se] = '.';
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			if(a[i][j]=='#')
			{
				cout<<"Impossible\n"; return 0;
			}
		}
	}
	cout<<"Possible\n";
}

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

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

if (N%10==2||N%10==4||N%10==5||N%10==7||N%10==9) {  
cout <<"hon"<<endl;
}    
else if (N%10==0||N%10==1||N%10==6||N%10==8) {  
cout <<"pon"<<endl;
}    
else if ( N%10==3) {  
cout <<"bon"<<endl;
} 
}    
    
    
   

Measured memory_bytes: 3636
package main

import (
        "bufio"
        "fmt"
        "math"
        "os"
        "strconv"
        "strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
        sc.Scan()
        return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

func bitCount(n uint) int {

        x := uint64(n)

        const m = 1<<64 - 1
        const m0 = 0x5555555555555555
        const m1 = 0x3333333333333333
        const m2 = 0x0f0f0f0f0f0f0f0f

        x = x>>1&(m0&m) + x&(m0&m)
        x = x>>2&(m1&m) + x&(m1&m)
        x = (x>>4 + x) & (m2 & m)
        x += x >> 8
        x += x >> 16
        x += x >> 32

        return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
        return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
func abs(a, b int) int {
        return int(math.Abs(float64(a - b)))
}

func chmin(dp []int, idx, n int) {
        if dp[idx] > n {
                dp[idx] = n
        }
}
func main() {
        line := readBigLine()
        sp := strSprit(line)
        N := parseInt(sp[0])
        K := parseInt(sp[1])

        l := readBigLine()
        h := intSprit(l)

        INF := 1 << 30

        dp := make([]int, N+1000)
        for i := 0; i < N+1000; i++ {
                dp[i] = INF
        }
        dp[0] = 0

        for i := 0; i < N; i++ {
                for j := 1; j <= K; j++ {
                        if N > i+j {
                                chmin(dp, i+j, dp[i]+abs(h[i], h[i+j]))
                        }
                }
        }
        fmt.Println(dp[N-1])
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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 gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int a,b;
    cin >> a >> b;
    int out = 0;
    int now = 1;
    while(now < b){
        out++;
        now+=(a - 1);
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 300005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,k,i,j,l;
	cin>>n>>k;
	ll ar[n+1];
	l=0;
	for(i=1;i<=n;i++){
		cin>>ar[i];
		if(ar[i]>=k) l++;
	}
	cout<<l;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main(void) {
    io;
    int a,b,h;
    cin >> a >> b >> h;
    long long result = 0;
    result = (a+b) * (h/2);
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 3540
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#include <bits/stdc++.h>
#define PI 3.141592
 
using namespace std;
 
int main(void) {
    ll r;
    cin >> r;
    cout << 2 * PI * r << endl;
    return 0;
}

Measured memory_bytes: 3776
/*
ID: alec3
LANG: C++14
PROG: highcard
*/


#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

ifstream fin("zerosum.in");
ofstream fout("zerosum.out");
const int MAXN = 100;



int main() {
    //ofstream fout("lightson.out");
    //ifstream fin("lightson.in");
    int n;
    cin >> n;

    if (n >= 30){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;


    return 0;
}


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

class Program
{
    public static void Main()
    {

        var line = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        long X = line[0];
        long A = line[1];
        if(X<A)
        {
            Console.WriteLine(0);
        }
        else
        {
            Console.WriteLine(10);
        }
    }

}


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

int n, m, q, a[50], b[50], c[50], d[50], ans = 0, arr[10];

void dfs(int l, int p) {
	if (l == n) {
		int v = 0;
		for (int i = 0; i < q; i++)
			if (arr[b[i]] - arr[a[i]] == c[i])
				v += d[i];
		ans = max(ans, v);
	} else {
		for (int i = p; i <= m; i++) {
			arr[l] = i;
			dfs(l + 1, i);
		}
	}
}

int main() {
	cin >> n >> m >> q;
	for (int i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--, b[i]--;
	}
	dfs(0, 1);
	cout << ans << endl;
}


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

int main() {
  char b;
  cin >> b;

  if(b == 'A') cout << 'T';
  if(b == 'C') cout << 'G';
  if(b == 'G') cout << 'C';
  if(b == 'T') cout << 'A';

  
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = input()
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=N[-1]
    l1=("2","4","5","7","9")
    l2=("0","1","6","8")
    if s in l1:
        print('hon')
    elif s in l2: print('pon')
    else: print("bon")






if __name__ == "__main__":
    main()

Measured memory_bytes: 68088
def examB(inf):
    N, M = LI()
    ab = [LI() for _ in range(N)]
    cd = [LI() for _ in range(M)]
    ans = []
    for i in range(N):
        cur = inf
        for j in range(M):
            k = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
            if cur>k:
                cur = k
                ansC = j
        ans.append(ansC+1)
    for v in ans:
        print(v)

import sys
import copy
import bisect
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB(inf)


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

typedef long long ll;

int main() {
    ll c,r;cin>>r>>c;
    if(r==1||c==1) cout<<1<<endl;
    else{
        ll ans=(r/2+r%2)*(c/2+c%2)+(c/2)*(r/2);
        cout<<ans<<endl;
    } 
    return 0;
}

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

int main() {
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d) cout<<"Left"<<endl;
	else if(a+b==c+d) cout<<"Balanced"<<endl;
	else cout<<"Right"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    S = input_int()
    x0 = y0 = 0
    x1 = 1
    x2 = 10**9
    y2 = -S % 10**9
    y1 = (S + y2) // 10**9

    print(x0, y0, x1, y1, x2, y2)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 61716
s=input().split()
n=int(s[0])
m=int(s[1])
l=[]
for i in range(m):
    s=input().split()
    l.append((int(s[1]),int(s[0])))
l.sort()
o=[]
for p in l:
    if len(o)>0 and p[0]>=o[-1]>p[1]:
        continue
    else:
        o.append(p[0])
print(len(o))


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define inf 1e18
#define pi acos(-1.0)
#define mod 998244353


int main(void)
{
    fastio;

    int n,i,p,c=0;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> p;
        if(p%2)c++;
    }
    if(c%2)cout << "NO\n";
    else cout << "YES\n";

    return 0;
}


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

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

using namespace std;
typedef unsigned long long ll;

vector<vector<ll>> totComb;
vector<int> people = {1, 2, 3, 4, 5};
vector<ll> ct(6, 0);
vector<ll> combination;

void go(int offset, int k) {
if (k == 0) {
    totComb.push_back(combination);
    return;
  }

  for (int i = offset; i <= people.size() - k; ++i) {
    combination.push_back(people[i]);
    go(i+1, k-1);
    combination.pop_back();
  }
}


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

    vector<string> s(n, "");
    REP(i, n) {
        cin >> s[i];
        if (s[i][0] == 'M') ct[1]++;
        if (s[i][0] == 'A') ct[2]++;
        if (s[i][0] == 'R') ct[3]++;
        if (s[i][0] == 'C') ct[4]++;
        if (s[i][0] == 'H') ct[5]++;
    }

    go(0, 3);

    ll ans = 0;

    REP(i, totComb.size()){
        ll curr = 1;
        REP(j, totComb[i].size()){
            curr *= ct[totComb[i][j]];
        }
        ans += curr;
    }

    cout << ans << endl;

}
        


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

using namespace std;

int main() {
  vector<int> f(26, -1);
  string s;
  cin>>s;
  for (char c: s) {
    f[c-'a']=1;
  }
  for (int i=0; i<26; i++) {
    if (f[i]==-1) {
      cout<<char(i+'a')<<endl;
      return 0;
    }
  }
  cout<<"None\n";
  return 0;
}

Measured memory_bytes: 3728
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 1e9+7;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
int dx[]={1, 0, -1, 0};
int dy[]={0,1, 0,-1};
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	fastio;
	int n,m,k;
	cin>>n>>m>>k;
	int d[n+5][m+5];
	int x1, x2, y1,y2;
	cin>>x1>>y1>>x2>>y2;
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			char c;
			cin>>c;
			if(c=='.') d[i][j]=INT_MAX;
			else d[i][j]=-1;
		}
	}
	d[x1][y1]=0;
	queue<pr<int, ii> > q;
	q.push({0, {x1, y1}});
	while(!q.empty())
	{
		int xu=q.front().se.fi, yu=q.front().se.se,dist=q.front().fi;
		q.pop();
		if(dist>d[xu][yu]) continue;
		for(int i=0; i<4; i++)
		{
			for(int j=1; j<=k; j++)
			{
				int xv=xu+dx[i]*j, yv=yu+dy[i]*j;
				if(1<=xv and xv<=n and 1<=yv and yv<=m and d[xv][yv]!=-1 and d[xv][yv]>d[xu][yu]+1)
				{
					d[xv][yv]=d[xu][yu]+1;
					q.push({d[xv][yv], {xv, yv}});
				}
				else if(d[xv][yv]<=d[xu][yu]) break;
			}
		}
	}
	if(-1<d[x2][y2] and d[x2][y2]<INT_MAX) cout<<d[x2][y2];
	else cout<<-1;
}




Measured memory_bytes: 13948
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;


/*
ll gcd(ll x, ll y) {
if (y == 0) return x;
return gcd(y, x%y);
}
/*
ll lcm(ll x, ll y) {
ll g = gcd(x, y);
return x / g * y;
}
ll pw(int x, int n) {
	ll y = 1;
	ll p = x;
	while (n != 0) {
		if (n % 2) {
			y = y*p%mod;
			n = n - 1;
		}
		else {
			p = p*p%mod;
			n = n / 2;
		}
	}
	return y;
}

ll modinv(ll x) {
	return pw(x, mod - 2);
}*/

ll n, x[100010], k, l, r, mn;
bool flag;

int main() {
	flag = false;
	l = r = llmax;
	cin >> n >> k;
	lp(n) {
		cin >> x[i];
		if (flag==false&&x[i] <= 0)l = i;
		if (flag == false && x[i] > 0) {
			r = i;
			flag = true;
		}
	}
	if (l == llmax) {
		cout << x[k - 1] << endl;
	}
	else if (r == llmax) {
		cout << -x[n - k] << endl;
	}
	else {
		mn = llmax;
		for (int i = r; i <= r + k - 1 &&i < n; i++) {
			if (i-k+1>=0)
				mn = min(mn, x[i]*2 - x[i - k + 1]);
		}
		for (int i = l; i >= l - k + 1 && i >= 0; i--) {
			if (i + k - 1 <= n - 1)
				mn = min(mn, -x[i] * 2 + x[i + k - 1]);
		}
		cout << mn << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int digits = 0;
		int MSB = N;
		while (MSB > 0) {
			digits++;
			MSB /= 10;
		}
		
		int total = 0;
		while (digits >= 3) {
			total += sgs(digits, N, 0);
			digits--;
		}
		
		System.out.println(total);
	}
	
	static int sgs(int digit, int N, int value) {
		if (digit == 0) {
			if (isValid(value, N)) {
				//System.out.println(value);
				return 1;
			}
			return 0;
		}
		int n1 = sgs(digit-1, N, value*10 + 3);
		int n2 = sgs(digit-1, N, value*10 + 5);
		int n3 = sgs(digit-1, N, value*10 + 7);
		return n1+n2+n3;
	}
	
	static boolean isValid(int value, int N) {
		if (value <= N) {
			int threeCount = 0;
			int fiveCount = 0;
			int sevenCount = 0;
			while (value > 0) {
				switch(value%10) {
					case 3:
						threeCount++;
						break;
					case 5:
						fiveCount++;
						break;
					case 7:
						sevenCount++;
						break;
					default:
						break;
				}
				value /= 10;
			}
			if (threeCount > 0 && fiveCount > 0 && sevenCount > 0) {
				return true;
			}
		}
		return false;
	}

}


Measured memory_bytes: 23636
#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]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,a[200010],dp1[200010][16],dp2[200010][16];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)rep(j,16)dp1[i][j]=INF;
    rep(j,16)dp1[n-1][j]=2*j;
    for(int i=n-2;i>=0;i--){
        int p=a[i];
        rep(j,16){
            int q=a[i+1];
            int k=0;
            while(p>q){
                q*=4;
                k++;
            }
            int add=0;
            if(k>=16){
                add=(k-15)*(n-1-i)*2;
                k=15;
            }
            chmin(dp1[i][j],dp1[i+1][k]+2*j+add);
            p*=4;
        }
    }
    rep(i,n)rep(j,16)dp2[i][j]=INF;
    rep(j,16)dp2[0][j]=2*j+1;
    for(int i=1;i<n;i++){
        int p=a[i];
        rep(j,16){
            int q=a[i-1];
            int k=0;
            while(p>q){
                q*=4;
                k++;
            }
            int add=0;
            if(k>=16){
                add=(k-15)*i*2;
                k=15;
            }
            chmin(dp2[i][j],dp2[i-1][k]+2*j+1+add);
            p*=4;
        }
    }
    int ans=INF;
    rep(i,n+1){
        chmin(ans,(i==0?0ll:dp2[i-1][0])+(i==n?0ll:dp1[i][0]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 55192
import fractions

def prime_function(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a

A,B=map(int,input().split())
GCD=fractions.gcd(A,B)
print(len(set(prime_function(GCD)))+1)

Measured memory_bytes: 5304
from collections import deque
N, K = map(int, input().split())

if N == 1:
    print(K)

G = {k: [] for k in range(N+1)}
for _ in range(N-1):
    a, b = map(int, input().split())
    # 無向グラフ
    G[a].append(b)
    G[b].append(a)

mod = 10**9 + 7

ans = 1
for i in range(1, N+1):
    if len(G[i]) == 1:
        que = deque([(i, 0, 0, -1)])

        while que:
            ci, d1, d2, p = que.popleft()
            ans *= max(0, K-d1-d2)
            ans %= mod
            # print(ci, d1, d2, p, ans)

            c = 0
            for ni in G[ci]:
                if ni != p:
                    que.append((ni, 1, d1+c, ci))
                    c += 1

        print(ans)
        exit()


Measured memory_bytes: 79460
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vin[200000];
  vector<int> vi(n);
  for (int i=0; i<n+m-1; i++){
    int a, b;
    cin >> a >> b;
    vin[a-1].push_back(b-1);
    vi[b-1] ++;
  }
  stack<int> s;
  for (int i=0; i<n; i++){
    if(vi[i] == 0){
      s.push(i);
    }
  }
  
  vector<int> ans(n, 0);
  while(s.size() > 0){
    int u = s.top(); s.pop();
      for (int i:vin[u]){
          vi[i] --;
          if (vi[i] == 0){
            ans[i] = u+1;
            s.push(i);
          } 
      }
  }
  
  for (int i=0; i<n; i++){
    cout << ans[i] << endl;
  }
    
  return 0;
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int n, d, a, res = 0;
    cin >> n >> d >> a;
    vector<pi> enemy(n);
    for (int i = 0; i < n; ++i) cin >> enemy[i].first >> enemy[i].second;
    sort(enemy.begin(), enemy.end());
    int r = 0;
    vector<int> dmg(n,0);
    for (int i = 0; i < n; ++i) {
        if (i) dmg[i] += dmg[i - 1];
        if (enemy[i].second <= dmg[i]) continue;
        while (i > r || (r < n && enemy[i].first + 2 * d >= enemy[r].first)) ++r;
        int hit = (enemy[i].second - dmg[i] + a - 1) / a;
        dmg[i] += hit * a;
        if(r<n)dmg[r] -= hit * a;
        res += hit;
    }
    cout << res;
}

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

int main() {
  int N;
  
  cin >> N;
  
  vector<int> L(N);
  for(int i = 0; i < N; i++){
    cin >> L.at(i);
  }
  
  int answer = 0;
  for(int i = 0; i < N-2; i++){
    for(int j = i+1; j < N-1; j++){
      for(int k = j+1; k < N; k++){
    	if( L.at(i) != L.at(j) && L.at(j) != L.at(k) && L.at(k) != L.at(i) ){
          if ( L.at(i) + L.at(j) > L.at(k) && L.at(i) + L.at(k) > L.at(j) && L.at(j) + L.at(k) > L.at(i) ){
            answer ++;
          }
        }
      }
    }
  }
  
  cout << answer << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f;

int main(){
    cin >> a >> b >> c >> d >> e >> f;
    int a_wat=0; int b_wat=0;
    int c_sug=0; int d_sug=0;
    int ans_w=100; int ans_s=0;
    while(a_wat<f){
        b_wat=0;
        while(a_wat+b_wat<f){
            c_sug=0;
            if(a_wat==0)b_wat+=b*100;
            while(a_wat+b_wat+c_sug<=f){
                d_sug=0;
                while(a_wat+b_wat+c_sug+d_sug<=f && (c_sug+d_sug)*100<=(a_wat+b_wat)*e){
                    if((c_sug+d_sug)*100==(a_wat+b_wat)*e){
                        cout << a_wat+b_wat+c_sug+d_sug << " " << c_sug+d_sug;
                        return 0;
                    }
                    else if((c_sug+d_sug)*ans_w>=(a_wat+b_wat)*ans_s){
                        ans_w=a_wat+b_wat;
                        ans_s=c_sug+d_sug;
                    }
                    d_sug+=d;
                }
                c_sug+=c;
            }
            b_wat+=b*100;
        }
        a_wat+=a*100;
    }
    cout << ans_w+ans_s << " " << ans_s;
}

Measured memory_bytes: 3624
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::BTreeSet;
use std::collections::HashMap;
use std::cmp::{max, min};
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        rs: [(i64, i64); n],
        bs: [(i64, i64); n],
    }
    let mut rs = rs;
    let mut bs = bs;

    // x 座標でソート
    rs.sort();
    bs.sort();

    let mut ys = BTreeSet::<i64>::new();
    let  mut ri = 0;  // rs の インデックス
    let mut ans = 0;

    for &(bx, by) in bs.iter() {
        // x座標において青より小さい赤を集める
        while ri < rs.len() && rs[ri].0 < bx {
            ys.insert(rs[ri].1);
            ri += 1;
        }
        let mut cand = -1;
        // y座標において青より小さい最大の赤を求める
        for &y in ys.iter() {
            if y < by && y > cand {
                cand = y;
            }
        }
        if cand >= 0 {
            ans +=1;
            ys.remove(&cand);
        }
    }
    println!("{}", ans);
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

const int N = 54;
int a[N];

void solve() {
	int n; scanf("%d", &n);
	int m = 0, M = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", a+i);
		if (a[m] > a[i]) m = i;
		if (a[M] < a[i]) M = i;
	}
	vector<pair<int, int>> vp;
	if (abs(a[M]) > abs(a[m])) {
		for (int i = 0; i < n; ++i) {
			if (a[i] >= 0) continue;
			a[i] += a[M];
			vp.emplace_back(M+1, i+1);
		}
		for (int i = 1; i < n; ++i) {
			vp.emplace_back(i, i+1);
		}
	} else {
		for (int i = 0; i < n; ++i) {
			if (a[i] <= 0) continue;
			a[i] += a[m];
			vp.emplace_back(m+1, i+1);
		}
		for (int i = n; i >= 2; --i) {
			vp.emplace_back(i, i-1);
		}
	}
	printf("%d\n", (int)vp.size());
	for (const auto &e: vp) {
		printf("%d %d\n", e.first, e.second);
	}
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

ll p[10];
ll c[10];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif


	int D, G;
	cin >> D >> G;
	for(int i = 0; i < D; i++){
		cin >> p[i] >> c[i];
	}

	int ans = 1e9;
	for(int bit = 0; bit < 1 << D; bit++){
		ll rem = G;
		int cnt = 0;
		for(int j = 0; j < D; j++){
			if(bit >> j & 1){
				rem -= (j + 1) * 100 * p[j] + c[j];
				cnt += p[j];
			}
		}
		if(rem > 0){
			for(int j = D - 1; j >= 0 && rem > 0; j--){
				if(~bit >> j & 1){
					for(int k = 0; k < p[j] && rem > 0; k++){
						rem -= (j + 1) * 100;
						cnt++;
					}
				}
			}
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
 class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        char s=sc.nextLine().toCharArray()[0];
        boolean b=Character.isLowerCase(s);
        if(b){
            System.out.println("a");
        }
        else{
            System.out.println("A");
        }
    }
    
}

Measured memory_bytes: 35724
#include <stdio.h>
#define Fori(g) for(int i=0;i<g;i++)
#define	Forj(g) for(int j=0;j<g;j++)
#define min(aa,bb) return (aa<bb)?aa:bb
#define max(aa,bb) return (aa<bb)?bb:aa

int main(){
	int n;
	scanf("%d",&n);
	printf("%d\n",(n-1)/2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int n;
vector<double> p;

double dp[3000][3000];

int main(){
    cin >> n;
    p.resize(n);
    rep(i,n){
        cin >> p[i];
    }

    dp[0][0] = 1.0;

    for(int i=0; i<n; i++){
        for(int j=0; j<=i; j++){
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }

    double ans=0.0;

    for(int i=(n+1)/2; i<=n; i++){
        ans += dp[n][i];
    }

    cout << fixed << setprecision(10) << ans << endl;
}
    

Measured memory_bytes: 68864
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	LL q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	LL one = min(q * 4, min(h * 2, s));
	LL two = min(d, one * 2);
	//cout << one << " " << two << endl;
	cout << (n / 2)*two + (n % 2)*one << endl;
}

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

typedef pair<string, int> proc;

int main(){
	int n, q, sumTime=0;
	queue< proc > que;
	cin >> n >> q;
	for( int i=0; i<n; i++ ){
		proc p;
		cin >> p.first;
		cin >> p.second;
		que.push(p);
	}
	while( !que.empty() ){
		proc p = que.front();
		que.pop();
		if( p.second <= q ){
			sumTime += p.second;
			cout << p.first << " " << sumTime << endl;
		}else{
			sumTime += q;
			p.second -= q;
			que.push(p);
		}
	}
	return 0;
}

Measured memory_bytes: 1300
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

int n;
struct point{
	double x,y;
	point(){}
	point(double xx,double yy){
		x=xx;
		y=yy;
	}

	point operator + (point p){
		return point(x+p.x,y+p.y);
	}
	point operator / (double d){
		return point(x/d,y/d);
	}
};

point p[101];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			scanf("%lf,%lf",&p[i].x,&p[i].y);
		}
		if(n==1)printf("1\n");
		else{
			int res=1;
			for(int i=0;i<n;i++){
				for(int j=i+1;j<n;j++){
					point mid=(p[i]+p[j])/2.0;
					double ang=atan2(mid.y-p[i].y,mid.x-p[i].x);
					double len=(p[i].x-mid.x)*(p[i].x-mid.x)+(p[i].y-mid.y)*(p[i].y-mid.y);
					double np=sqrt(1-len);
					point pp=mid+point(np*cos(ang+M_PI/2.0),np*sin(ang+M_PI/2.0));
					int cnt=2;
					for(int k=0;k<n;k++){
						if(k==i || k==j)continue;
						if((pp.x-p[k].x)*(pp.x-p[k].x)+(pp.y-p[k].y)*(pp.y-p[k].y)<=1.0)cnt++;
					}
					res=std::max(res,cnt);
					pp=mid+point(np*cos(ang-M_PI/2.0),np*sin(ang-M_PI/2.0));
					cnt=2;
					for(int k=0;k<n;k++){
						if(k==i || k==j)continue;
						if((pp.x-p[k].x)*(pp.x-p[k].x)+(pp.y-p[k].y)*(pp.y-p[k].y)<=1.0)cnt++;
					}
					res=std::max(res,cnt);
				}
			}
			printf("%d\n",res);
		}
	}
	return 0;
}

Measured memory_bytes: 1168