akhauriyash/Code-Regression huggingface dataset:
def is_target(num):
    count = 0
    for i in range(1, num+1):
        if num % i == 0:
            count += 1
    if count == 8:
        return True
    else:
        return False

if __name__ == "__main__":
    N = int(input())
    count = 0
    for num in range(1, N+1, 2):
        count += is_target(num)

    print(count)

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

ll lcm(ll a, ll b){
  return a / __gcd(a,b) * b;
}

int main(){
  int N; cin>>N;
  ll ans = 1;
  for(int i=0;i<N;i++){
    ll T; cin>>T;
    ans = lcm(ans,T);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
    int n, i, j;
    char c;
    char suit[] = "SHCD";
    int num;
    int cards[52];

    for(i = 0; i < 52; i++) cards[i] = 0;

    cin >> n;
    for(i = 0; i < n; i++){
        cin >> c >> num;
        for(j = 0; j < 4; j++){
            if(c == suit[j]){ cards[num + 13 * j - 1] = 1; break; }
        }
    }

    for(i = 0; i < 52; i++){
        if(cards[i] == 1) continue;
        cout << suit[i / 13] << " " << (i % 13) + 1 << endl;
    }

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    string ans = "";
    while(n != 0)
    {
        if(n%2 != 0)
        {
            n--;
            ans = '1' + ans;
        }
        else
        {
            ans = '0' + ans;
        }
        n /= -2;
    }
    if(ans == "")
    {
        ans = "0";
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 N;
  cin >> N;
  vector<tuple<i64, i64, i64>> vec;
  for(int i = 0;i < N;i++) {
    i64 a, b, c;
    cin >> a >> b >> c;
    vector<i64> v(3);
    v[0] = a;
    v[1] = b;
    v[2] = c;
    sort(all(v));
    vec.push_back(make_tuple(v[0], v[1], v[2]));
  }
  sort(all(vec));
  vec.erase(unique(all(vec)), end(vec));
  cout << N - vec.size() << endl;
}



Measured memory_bytes: 3200
#include <iostream>
#include <cmath>
#include <iomanip>

int main() {
    unsigned long N = 0, K = 0, i = 0, j = 0;
    long double A = 0, score = 0;

    // input
    std::cin >> N;
    std::cin >> K;

    //win : i*2^j>=K
    for (i = 1; i <= N; i++) {
        for (j = 0;; j++) {
            score = i * std::pow(2, j);
            if (score >= K) {
                A += (1 / (double) N) * std::pow(0.5, j);
                break;
            }
        }
    }

    // outpput
    std::cout << std::setprecision(12) << A << std::endl;
    return 0;
}

Measured memory_bytes: 256
<?php
  declare(strict_types=1);

  fscanf(STDIN, "%i", $n);
  $xs = explode(" ", trim(fgets(STDIN)));

  if ((array_sum($xs) % 2) === 0)
  {
      echo "YES".PHP_EOL;
  }
  else
  {
      echo "NO".PHP_EOL;
  }


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

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

    int H[N+1];

    bool A[N+1];

    for(int i=1; i<=N; i++){
      cin >> H[i];
      A[i] = true;
    }


    int a,b;
    for(int i=0; i<M; i++){
      cin >> a >> b;
      if(H[a]<H[b]){
        A[a] = false;
      }
      else if(H[a]>H[b]){
        A[b] = false;
      }
      else{
        A[a] = false;
        A[b] = false;
      }
    }

    int cnt = 0;

    for(int i=1; i<=N; i++){
      if(A[i]==true)
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 4072
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
#mod = 10 ** 9 + 7 
mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

K, T = MAP()
a = LIST()
A_max = max(a)

if 2*A_max <= K-1:
	print(0)
else:
	c = K - A_max + 1
	print(A_max - c)

Measured memory_bytes: 10444
# -*- coding: utf-8 -*-
"""
C - Base -2 Number
https://atcoder.jp/contests/abc105/tasks/abc105_c

"""
import sys


def solve(N):
    if not N:
        return '0'
    r = []
    while N:
        r.append(N % 2)
        N = (N - N % 2) // -2
    return ''.join(map(str, r[::-1]))


def main(args):
    N = int(input())
    ans = solve(N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# 右から
N = int(input())
AB = [[int(x) for x in input().split()] for _ in range(N)]

push = 0
for a,b in AB[::-1]:
    a += push
    push += (-a)%b
print(push)

Measured memory_bytes: 21876
n=[int(x) for x in input()]
op_cnt=len(n)-1
for i in range(2**op_cnt):
    ops=['-']*op_cnt
    for j in range(op_cnt):
        if ((i>>j)&1):
            ops[op_cnt-1-j]='+'
    num=n[0]
    for i,op in enumerate(ops):
        if op=='-':
            num-=n[i+1]
        else:
            num+=n[i+1]
    if num==7:
        print(str(n[0])+ops[0]+str(n[1])+ops[1]+str(n[2])+ops[2]+str(n[3])+'=7')
        exit()

Measured memory_bytes: 9248
N,M=map(int, input().split())
a=[int(input()) for i in range(M)]
bad=[0]*(N+1)
for i in a:
    bad[i]=1
dp=[0]*(N+1)
mod=10**9+7
dp[0]=1
if bad[1]==0:
    dp[1]=1
for i in range(2,N+1):
    if bad[i]==0:
        dp[i]=(dp[i-2]+dp[i-1])%mod
print(dp[N])

Measured memory_bytes: 8616
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  ll N,K; cin>>N>>K;
  vector<ll> A(N);
  rep(i,N)
  {
    cin>>A.at(i);
  }
  rep(i,min(K,(ll)100))
  {
    vector<ll> hoge(N,0);
    vector<ll> sirusi(N,0);
    rep(j,N)
    {
      sirusi.at(max((ll)0,j-A.at(j)))++;
      if(j+A.at(j)<N-1)
      {
        sirusi.at(j+A.at(j)+1)--;
      }
    }
    rep(j,N)
    {
      if(j==0) {hoge.at(0)=sirusi.at(0); continue;}
      hoge.at(j)=hoge.at(j-1)+sirusi.at(j);
    }
    A=hoge;
  }
  rep(i,N)
  {
    if(i!=0) {cout<<" ";}
    cout<<A.at(i);
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 8008
n=int(input())
L=list(map(int,input().split()))
ans=0
ans+=min(L)
for i in range(n):
    L[i]-=ans
L=[0]+L+[0]
while True:
    tmp=0
    for i in range(1,n+2):
        if L[i]==0 and len(L[tmp:i])!=0:
            if len(L[tmp:i])==1:
                Min=L[tmp+1]
            else:
                Min=min(L[tmp+1:i])
            ans+=Min
            for j in range(tmp+1,i):
                L[j]-=Min
            tmp=i
    if max(L)==0:
        break
print(ans)

Measured memory_bytes: 9172
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e3 + 7;
char lst[Max][Max];
int ls[Max][Max];

int main()
{
	string n;
	cin >> n;
	int sum = 0, s = 0;
	for (int i = 0; i <= n.size()-1; i++)
	{
		int t = n[i] - '0';
		sum += t;
		s *= 10;
		s += t;
	}
	if (s % sum == 0)cout << "Yes";
	else cout << "No";


}

Measured memory_bytes: 3020
s = input()

a = int(s[:2])
b = int(s[2:])

def isYear(x):
    return x >= 0

def isMonth(x):
    return x > 0 and x <= 12

if(isYear(a) and isMonth(a) and isYear(b) and isMonth(b)):
    print("AMBIGUOUS")
elif(isYear(a) and isMonth(b)):
    print("YYMM")
elif(isMonth(a) and isYear(b)):
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_b"
package main

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

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func iabs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func solve(n, k int, h []int) int {
	t := make([]int, n+k+1, n+k+1)
	for i := range t {
		t[i] = math.MaxInt64
	}
	t[0] = 0
	for i := 0; i < n; i++ {
		for j := 0; j <= k; j++ {
			if v := t[i] + iabs(h[i+j]-h[i]); v < t[i+j] {
				t[i+j] = v
			}
		}
	}
	return t[n-1]
}

func main() {
	scan := newScanner(os.Stdin)
	n, k := scan.Int(), scan.Int()
	h := make([]int, n+k+1, n+k+1)
	for i := 0; i < n; i++ {
		h[i] = scan.Int()
	}
	a := solve(n, k, h)
	fmt.Println(a)
}


Measured memory_bytes: 3924
#include <stdio.h>

int main()
{
    int c[3],r[2];

    scanf("%d%d%d%d%d",&r[0],&r[1],&c[0],&c[1],&c[2]);
	((c[0] > 0 && c[0] + c[2] <= r[0]) && (c[1] > 0 && c[1] + c[2] <= r[1])) ? printf("Yes\n") : printf("No\n");

}


Measured memory_bytes: 2700
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string s;
  cin >> s;
  int n=s.size()/2;
  int ans = 0;
  rep(i,n){
    if(s[i]!=s[s.size()-1-i])ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
from itertools import combinations

n = int(input())
s = [input() for _ in range(n)]

letters = {"M":0, "A":0, "R":0, "C":0, "H":0, }
to_check = combinations([i for i in "MARCH"], 3)

for word in s:
    if word[0] in letters:
        letters[word[0]] += 1

count = 0
for i in to_check:
    count += letters[i[0]] * letters[i[1]] * letters[i[2]]

print(count)

Measured memory_bytes: 16284
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def f(a, b):
        return max(a, b) if s[abs(a-b)-1] == "1" else min(a,b)
    n = I()
    s = S()
    # print(s)
    p = LI()
    dp = [[0 if j else p[i] for j in range(n+1)] for i in range(1 << n)]
    maxn = 1 << n
    for j in range(n):
        j1 = 1 << j
        for i in range(1 << n):
            if i + j1 >= maxn:
                # print(i+j1-n,i,j)
                dp[i][j+1] = f(dp[i][j],dp[i+j1-maxn][j])
            else:
                dp[i][j+1] = f(dp[i][j],dp[i+j1][j])
    # print(dp[0][0],dp[1][0],f(dp[0][0],dp[1][0]))
    # print(dp)
    for i in range(1 << n):
        print(dp[i][-1])
        # pass
    return

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



Measured memory_bytes: 92208
N = int(input())
a = 0
f = True
for _ in range(N):
  s = input()
  if s=="A":
    a += 1
  else:
    if a==0:
      f = False
    else:
      a -= 1
if f and a==0:
  print("YES")
else:
  print("NO")



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



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

	int s[55] = {};

	rep(i,0,m){
        itn a,b;
        cin >> a >> b;
        s[a]++;
        s[b]++;
	}

	rep(i,1,n+1)P(s[i]);

	return  0;
}

Measured memory_bytes: 256
a = input()
n = len(a)
ansa = -1
ansb = -1
for i in range(n-1):
    if a[i] ==a[i+1]:
        ansa = i
for j in range(n-2):
    if a[j] ==a[j+2]:
        ansb = j
if ansa != -1:
    print(ansa+1,ansa+2)
elif ansb != -1:
    print(ansb+1,ansb+3)
else:
    print(-1,-1)

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

import sys

def main():
    sys.setrecursionlimit(1000000)
    n, m, k = map(int, input().split())
    friends = [set() for i in range(n)]
    blocks = [set() for i in range(n)]
    parents = [i for i in range(n)]
    for i in range(m):
        a, b = map(int, input().split())
        friends[a - 1].add(b - 1)
        friends[b - 1].add(a - 1)
        unite(a - 1, b - 1, parents)
    for i in range(k):
        c, d = map(int, input().split())
        blocks[c - 1].add(d - 1)
        blocks[d - 1].add(c - 1)
    groups = [set() for i in range(n)]
    for i in range(n):
        p = find(i, parents)
        groups[p].add(i)
    res = []
    for i in range(n):
        p = find(i, parents)
        res.append(len(groups[p]) - len(friends[i]) - len(groups[p] & blocks[i]) - 1)
    print(" ".join([str(x) for x in res]))

def unite(x, y, parents):
    px = find(x, parents)
    py = find(y, parents)
    parents[py] = px

def find(x, parents):
    if parents[x] == x:
        return x
    fx = find(parents[x], parents)
    parents[x] = fx
    return fx

if __name__ == "__main__":
    main()


Measured memory_bytes: 122176
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,x,t;
  cin>>n>>x>>t;
  cout<<(n+x-1)/x*t<<endl;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a, a + n, greater<int>());
  int d=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      d+=a[i];
    }else{
      d-=a[i];
    }
  }
  cout << d <<endl;
}
    
  


Measured memory_bytes: 256
import collections


def main():
    n, q = map(int, input().split())

    # 頂点のリスト、ポイント、走査済みか
    graph = [[[], 0, False] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        graph[a-1][0].append(b-1)
        graph[b-1][0].append(a-1)

    for i in range(q):
        p, x = map(int, input().split())
        graph[p-1][1] += x

    queue = collections.deque([0])
    while queue:
        q = queue.pop()
        graph[q][2] = True
        for v in graph[q][0]:
            if graph[v][2]:
                continue
            graph[v][1] += graph[q][1]
            queue.append(v)

    for i in range(n):
        print(graph[i][1], end=' ')


if __name__ == '__main__':
    main()


Measured memory_bytes: 68852
#include<bits/stdc++.h>
 
using namespace std;
int main(){
	int n;
	cin>>n;
	int l = 0,r = 0,flag = 0;
	int a[50+5];
	for(int i = 1;i <= n;i++){
		cin>>a[i];
		if(l == 0&&i != a[i]){
			flag++;
			l = a[i];
		}else if(i != a[i]){
			flag++;
			r = a[i];
		}
	}
	if(flag == 0 || (a[l] = r&& flag == 2)){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll x, y;
    cin >> x >> y;
    ll cur = x;
    ll res = 0;
    do {
        res++;
        cur += cur;
    } while (cur <= y);
    cout << res << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
const ll INF = 1e18;

ll calc_a(ll A, ll B, vector<ll> h, ll b) {
    for (int i = 0; i < h.size(); i++) {
        h[i] = max(0LL, h[i] - B*b);
    }
    ll a = 0;
    for (int i = 0; i < h.size(); i++) {
        a += (h[i] + A - B - 1)/(A - B);
    }
    return a;
}

int main() {
    int N; ll A, B;
    cin >> N >> A >> B;
    vector<ll> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];

    ll hmax = *max_element(h.begin(), h.end());
    ll bl = 0, bu = (hmax + B - 1)/B;

    while (bu - bl > 1) {
        ll bm = (bl + bu)/2;
        ll am = calc_a(A, B, h, bm);
        if (bm < am) bl = bm;
        else bu = bm;
    }

    ll ans = min(max(bl, calc_a(A, B, h, bl)), max(bu, calc_a(A, B, h, bu)));
    cout << ans << endl;
}

/*
int calc_atimes(int A, int B, vector<int> h, int btimes) {
    for (int i = 0; i < h.size(); i++) {
        h[i] = max(0, h[i] - B*btimes);
    }
    ll ans = 0;
    for (int i = 0; i < h.size(); i++) {
        ans += ((ll)h[i] + A - B - 1)/(A - B);
    }
    return ans;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];

    int hmax = *max_element(h.begin(), h.end());
    int btimes_l = 0;
    int btimes_u = (hmax + B - 1)/B;
    
    while (btimes_u - btimes_l > 1) {
        int btimes_m = (btimes_l + btimes_u)/2;
        cout << btimes_l << ' ' << btimes_m << ' ' << btimes_u << endl;

        ll atimes = calc_atimes(A, B, h, btimes_m);

        if (btimes_m <= atimes) {
            btimes_l = btimes_m;
        } else if (btimes_m > atimes) {
            btimes_u = btimes_m;
        }
    }

    vector<ll> cand;
    for (int i = -2; i < 3; i++) {
        int b = btimes_l + i;
        if (b > 0) {
            ll a = calc_atimes(A, B, h, b);
            cand.push_back(max(a, (ll)b));
        }
    }

    ll ans = *min_element(cand.begin(), cand.end());
    cout << ans << endl;
    return 0;
}
*/

Measured memory_bytes: 2544
import os,sys
from io import BytesIO, IOBase

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

mod=1000000007

import math  

for i in range(1):
    n,k=mi()
    h=li()
    h.sort(reverse=True)
    ans=sum(h[k:n])
    print(ans)

Measured memory_bytes: 88908
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    bool turn=1,win=0;
    while(a>0 && c>0){
        if(turn){
            c -=b;
        }
        else{
            a -=d;
        }
        turn =!turn;
        if(a<=0){
            win=0;
            break;
        }
        if(c<=0){
            win=1;
            break;
        }
    }
    if(win) Yes;
    else No;
}/*
./problem.exe
*/

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  string s;cin>>s;
  int rui[n+100]={};
  int rui2[n+100]={};
  for(int i=1;i<=s.size();i++){
    if(s[i-1]=='W'){
      rui[i]+=rui[i-1]+1;
      rui2[i]+=rui2[i-1];
    }else{
      rui[i]+=rui[i-1];
      rui2[i]+=rui2[i-1]+1;
    }
  }
  int ans=INF;
  for(int i=1;i<=n;i++){
    
    ans=min(ans,rui[i-1]+rui2[n]-rui2[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main () {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  if (A + B < C + D) {
    cout << "Right" << endl;
  }
}

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

int main(void){
  int N;
  cin >> N;
  vector<int> vec(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> vec[i];
    sum += vec[i];
  }
  int diff;
  int diff_min = sum;
  int temp = 0;
  for(int i = 0; i < N; i++){
    temp += vec[i];
    diff = abs((sum - temp) - temp);
    if(diff < diff_min)diff_min = diff;
  }
  cout << diff_min;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N,A[100],i,j,temp,min,c=0,flag=0;
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  for(i=0;i<N;i++){
    min=i;
    flag=0;
    for(j=i;j<N;j++){
      if(A[j]<A[min]){
	flag=1;
	min=j;
      }
    }
    temp=A[i];
    A[i]=A[min];
    A[min]=temp;
    if(flag) c++;
  }
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",c);
  return 0;
}
    



Measured memory_bytes: 2080
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	for(int i=1; ;i++){
	    int x=sc.nextInt();
	    if(x==0)
		break;
	    else{
		System.out.printf("Case %d: %d\n",i,x);
	    }
	}
    }
}

Measured memory_bytes: 62724
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

struct UnionFind {
    vector<int> p;
    UnionFind(int n) {
        p = vector<int>(n, -1);
    }
    int parent(int a) {
        if (p[a] < 0) return a;
        return p[a] = parent(p[a]);
    }
    int same(int a, int b) {
        return parent(a) == parent(b);
    }
    int size(int a) {
        return -p[parent(a)];
    }
    bool unite(int a, int b) {
        a = parent(a);
        b = parent(b);
        if (a == b) return false;
        if (size(a) < size(b)) swap(a, b);
        p[a] += p[b];
        p[b] = a;
        return true;
    }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uni(n);
    vector<int> num1(n, 0);
    rep(i, m) {
        //cout << i << endl;
        int a, b;
        cin >> a >> b;
        --a, --b;
        ++num1[a];
        ++num1[b];
        uni.unite(a, b);
    }
    vector<int> num2(n, 0);
    rep(i, k) {
        int c, d;
        cin >> c >> d;
        --c, --d;
        if (uni.same(c, d)) {
            ++num2[c];
            ++num2[d];
        }
    }
    rep(i, n) {
        if (i != 0) cout << " ";
        //cout << uni.size(i) << " " << num1[i] << " " << num2[i] << endl;
        cout << uni.size(i) - 1 - num1[i] - num2[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        
        static void Solve()
        {
            var o = Console.ReadLine();
            var arr = o.Split(' ');
            int a = int.Parse(arr[0]);
            string op = arr[1];
            int b = int.Parse(arr[2]);
            int ans = 0;
            if( op == "+")
            {
                ans = a + b;
            }
            else
            {
                ans = a - b;
            }
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

long n,ma,mb;
long dp[405][405];

int main(int argc, char* argv[])
{
    scanf("%ld%ld%ld", &n, &ma, &mb);
    vector<long> a(n), b(n), c(n);
    long i,j,k;
    for(i=0; i<n; i++) {
        scanf("%ld%ld%ld", &a[i], &b[i], &c[i]);
    }

    for(i=0; i<=400; i++) {
        for(j=0; j<=400; j++) {
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;

    for(k=0; k<n; k++) {
        for(i=400; i>=1; i--) {
            for(j=400; j>=1; j--) {
                if((i-a[k]>=0 && j-b[k]>=0)&&(dp[i-a[k]][j-b[k]]!=INF)) {                    
                    long tmp = dp[i-a[k]][j-b[k]]+c[k];
                    dp[i][j] = MIN(dp[i][j], tmp);
                }
            }
        }
    }

    long ans=INF;
    for(i=1; i<=n; i++) {
        if(ma*i<=400 && mb*i<=400) {
            ans = MIN(ans, dp[ma*i][mb*i]);
        }
    }
    if(ans==INF) {
        printf("-1\n");
    }
    else {
        printf("%ld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 1536
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#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         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


#define lim 200000+5

ll a[lim],ans[lim];

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,XOR=0;
    sfl(n);
    for(ll i=1;i<=n;i++){
        sfl(a[i]);
        XOR ^= a[i];
    }
    ll val=0;
    for(ll i=1;i<=n;i++){
        val=0;
        for(ll j=30;j>=0;j--){
            if( !CHECK(XOR,j) ){
                if( CHECK(a[i],j) ){
                    val += (1ll<<j);
                }
            }
            else{
                if( !CHECK(a[i],j) ){
                    val += (1ll<<j);
                }
            }
        }
        ans[i]=val;
    }
    for(ll i=1;i<=n;i++) printf("%lld ",ans[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 6912
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll a, b, t;
  cin >> a >> b >> t;
  cout << (t/a)*b << endl;
  return 0;
} //good night.

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<vi> graph(N);
    REP(i, N - 1) {
        int u, v;
        cin >> u >> v, u--, v--;

        graph[u].pb(v);
        graph[v].pb(u);
    }


    priority_queue<Pin> q;
    q.emplace(0, 0);

    vector<ll> dist(N, inf), prev(N);
    dist[0] = 0;
    while(!q.empty()) {
        auto p = q.top(); q.pop();

        ll d = p.fi + 1;
        for (auto e: graph[p.se]) {
            if (dist[e] <= d) continue;

            dist[e] = d;
            prev[e] = p.se;
            q.emplace(d, e);
        }
    }

    vi ans(N);

    auto dfs = [&] (auto &&f, int from, int cur, vll& dp) -> void {
        // update dp table
        auto it = lower_bound(ALL(dp), A[cur]);

        int op, idx, value;
        if (it == dp.end()) {
            dp.pb(A[cur]);
            op = 0;
        } else {
            value = *it;
            idx = it - dp.begin();
            op = 1;
            *it = A[cur];
        }

        ans[cur] = dp.size();

        // go to next nodes
        for(auto e: graph[cur]) {
            if (prev[e] != cur) continue;
            f(f, cur, e, dp);
        }

        if (op == 0) {
            dp.pop_back();
        } else {
            dp[idx] = value;
        }
    };

    vll dp{A[0]};
    dfs(dfs, -1, 0, dp);

    REP(i, N) {
        print(ans[i]);
    }
    
}


Measured memory_bytes: 33908
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
int main() {
	int n;
	cin >> n;
	vector<int> a(2 * n);
	REP(i, 0, 2 * n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int sum = 0;
	REP(i, 0, n) {
		sum += a[i * 2];
	}
	cout << sum << endl;
	return 0;
}

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

int sss(int A[],int n,int p){
    int ans=0,ww,i=0;
    while(true){
    ans++;
    ww=0;
    while(ww+A[i]<=p&&i<n){
        ww+=A[i];
        i++;
    }
    if(i==n)return ans++;
    }
}

int minP(int A[],int n,int k){
    int sum=0,left,right,mid,m=A[0],ki;
    for(int i=0;i<n;i++){
        sum+=A[i];
        m=max(m,A[i]);
    }
    left=max(sum/k,m);
    right=((n+k-1)/k)*m;
    while(left<right){
        mid=(left+right)/2;
        ki=sss(A,n,mid);
        if(ki<k)right=mid-1;
        else if(ki>k)left=mid+1;
        else right=mid;
    }
    return left;
}

int main(){
    int n,k;
    cin>>n>>k;
    int A[n];
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    cout<<minP(A,n,k)<<endl;
}


Measured memory_bytes: 3560
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const ll MOD = 1e9 + 7;

int n;
int x[120000];
int go[120000];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", x + i);
	int now = 0;
	int nx = -1;
	for (int i = 0; i < n; ++i) {
		go[now] = i + 1;
		nx += 2;
		while (x[i] < nx)
			nx -= 2, now += 1;
	}
	for (int i = now; i < n; ++i)
		go[i] = n;
	ll ans = 1;
	for (int i = 0; i < n; ++i) {
		ans = (ans * (go[i] - i)) % MOD;
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int a,b,c;cin>>a>>b>>c;
  if(a>b)swap(a,b);
  if(a<c&&c<b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector <int>s(M), c(M);

	for (int i = 0; i < M; i++) {
		cin >> s.at(i) >> c.at(i);
		s.at(i)--;
	}

	vector<int>x(N);
	for (int i = 0; i < N; i++) {
		x.at(i) = 100;
	}

	bool check = true;
	for (int i = 0; i < M; i++) {
		if (x.at(s.at(i)) == 100) {
			x.at(s.at(i)) = c.at(i);
		}
		else if(x.at(s.at(i)) != c.at(i)) {
			check = false;
			break;
		}
	}

	for (int i = 0; i < N; i++) {
		if (x.at(i) == 100) {
			if (i == 0) {
				x.at(i) = 1;
			}
			else {
				x.at(i) = 0;
			}
		}
	}

	if (M == 0 && N == 1) {
		cout << 0 << endl;
		return 0;
	}

	if (N == 1 && x.at(0) == 0) {
		cout << 0 << endl;
		return 0;
	}

	if (check && x.at(0) != 0) {
		if (N == 1) {
			cout << x.at(0) << endl;
		}
		else if(N == 2) {
			cout << x.at(0) * 10 + x.at(1) << endl;
		}
		else {
			cout << x.at(0) * 100 + x.at(1) * 10 + x.at(2) << endl;
		}
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(char i='a';i<='z';i++)
    {
        if((count(s.begin(),s.end(),i)==0))
           {
           cout<<i<<"\n";
           return 0;
        }
    }
    cout<<"None"<<"\n";
    return 0;
}


Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        n: usize,
        ta: [(u64, u64); n]
    }

    let mut t_ret = ta[0].0;
    let mut a_ret = ta[0].1;
    for i in 1..n {
        let (t, a) = ta[i];
        let mut ok = 1u64 << 60;
        let mut ng = 0u64;
        while ok - ng > 1 {
            let mid = (ok + ng) / 2;
            if t >= (t_ret + mid - 1) / mid && a >= (a_ret + mid - 1) / mid {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        t_ret = t * ok;
        a_ret = a * ok;
    }
    println!("{}", t_ret + a_ret);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

struct uf{
  private:
    vi par, rank, size;
  public:
    uf(i64 n){ init(n); }
    void init(i64 n){
      par.resize(n);
      rank.resize(n,0);
      size.resize(n,1);
      rep(i,n) par[i] = i;
    }
    i64 root(i64 x){
      if(par[x] == x) return x;
      return par[x] = root(par[x]);
    }
    bool same(i64 x, i64 y){ return root(x) == root(y); }
    void unite(i64 x, i64 y){
      x = root(x), y = root(y);
      if(x==y) return;
      if(rank[x]==rank[y]) rank[x]++;
      if(rank[x]<rank[y]) swap(x,y);
      par[y] = x;
      size[x] += size[y];
    }
    i64 num(i64 x){ return size[root(x)]; }
};

void Main()
{
  string s;
  cin >> s;
  if(sz(s)%2==0){
    rep(i,sz(s)){
      if((i%2==0 && s[i]!='h') || (i%2==1 && s[i]!='i')){
        cout << "No\n";
        return;
      }
    }
    cout << "Yes\n";
    return;
  }
  cout << "No\n";
  return;


}

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


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    var count = 1
    var state = 0
    for (i in 1 until n) {
        if (state > 0 && a[i - 1] > a[i]) {
            count++
            state = 0
        } else if (state < 0 && a[i - 1] < a[i]) {
            count++
            state = 0
        } else if (a[i - 1] < a[i]) {
            state = 1
        } else if (a[i - 1] > a[i]) {
            state = -1
        }
    }
    println(count)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 44240
import Control.Applicative
import Control.Monad.State

step :: [Int] -> State Int [Int]
step [x]    = return [x]
step (x:xs) = step xs >>= \(y:ys) ->
              if (x > y)
              then modify (+1) >> return (y:x:ys)
              else return (x:y:ys)

bsort :: [Int] -> State Int [Int]
bsort [] = return []
bsort xs = step xs >>= \(y:ys) ->
           bsort ys >>= \zs ->
           return (y:zs)

main = do
    getLine
    xs <- map read . words <$> getLine
    let (ys, n) = runState (bsort xs) 0
    putStrLn $ unwords $ map show ys
    print n


Measured memory_bytes: 4440
import sys

x, n = map(int, input().split())
s = set(map(int, input().split()) if n != 0 else "")

i = 0
while True:
    for j in range(2):
        k = x - i * (-1)**j
        if k not in s:
            print(k)
            sys.exit()
    i += 1


Measured memory_bytes: 9204
#include<stdio.h>
#include<stdlib.h>
int main(){
  int i,nowi,sum;
  char now,stream[1001];

  scanf("%s",stream);
//    printf("%s\n",stream);
  i=0;

  while(!(stream[0]=='0' && stream[1]=='\0')){
    i=0;
    sum=0;
    while(stream[i]!='\0'){
      now=stream[i];
      if(now=='0')nowi=0;
      else if(now=='1')nowi=1;
      else if(now=='2')nowi=2;
      else if(now=='3')nowi=3;
      else if(now=='4')nowi=4;
      else if(now=='5')nowi=5;
      else if(now=='6')nowi=6;
      else if(now=='7')nowi=7;
      else if(now=='8')nowi=8;
      else if(now=='9')nowi=9;
//      printf("%d ",atoi(&now));
//      sum=sum+atoi(&now);
      sum=sum+nowi;
      i++;
    }
    printf("%d\n",sum);
    scanf("%s",stream);
//    printf("%s\n",stream);

  }

  return 0;
}

Measured memory_bytes: 2744
#include<bits/stdc++.h>
using namespace std;
int H, W;
int N;
vector<int> col;
int arr[1010][1010];
int main()
{
    scanf("%d%d%d",&H,&W, &N);
    for(int i=1; i<=N; ++i)
    {
        int t;
        scanf("%d", &t);
        while(t--) col.push_back(i);
    }
    int tp = 0;
    for(int i=0; i<H; ++i)
    {
        if(i&1)
            for(int j=0; j<W; ++j)
                arr[i][j] = col[tp++];
        else
            for(int j=W-1; j>=0; --j)
                arr[i][j] = col[tp++];
        for(int j=0; j<W; ++j)
            printf("%d ", arr[i][j]);
        puts("");
    }
}

Measured memory_bytes: 768