akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int ps[100][2];

int main(){
    while(1){
        int n, W, D;
        cin >> n >> W >> D;

        if(W==0){
            break;
        }

        for(int i=0; i<n; i++){
            int p, s;
            cin >> p >> s;
            ps[i][0] = p;
            ps[i][1] = s;
        }

        vector<pair<int, int> > vec;
        pair<int, int> init = make_pair(W, D);
        vec.push_back(init);
        for(int i=0; i<n; i++){
            int p = ps[i][0];
            int s = ps[i][1];

            pair<int, int> wd = vec[p-1];
            vec.erase(vec.begin() + p - 1);
            int w = wd.first;
            int d = wd.second;

            int peri = w+d;
            s = s % peri;

            pair<int, int> wd1;
            pair<int, int> wd2;
            if(s < w){
                wd1.first = s;
                wd2.first = w - s;
                wd1.second = d;
                wd2.second = d;
            } else {
                wd1.first = w;
                wd2.first = w;
                wd1.second = s - w;
                wd2.second = d - wd1.second;
            }

            if(wd1.first * wd1.second < wd2.first * wd2.second){
                vec.push_back(wd1);
                vec.push_back(wd2);
            } else {
                vec.push_back(wd2);
                vec.push_back(wd1);
            }
        }

        vector<int> output(vec.size());
        for(int i=0; i<vec.size(); i++){
            pair<int, int> wd = vec[i];
            int w = wd.first;
            int d = wd.second;
            output[i] = w*d;
        }

        sort(output.begin(), output.end());
        for(int i=0; i<vec.size(); i++){
            if(i != 0){
                cout << " ";
            }
            cout << output[i];
        }
        cout << endl;
    }
}

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

int main() {
	int h, w;
	while (cin >> h >> w && h != 0 || w != 0) {
		for (int i = 0; i < h; ++i) {
			for (int i2 = 0; i2 < w; ++i2) {
				if (i == 0 || i2 == 0 || i == h - 1 || i2 == w - 1) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  int s=0,k=0;
  for (int i=0;i<n;i++)
  {
    cin>>a[i];
    if (a[i]%2==0)
    {
      if (a[i]%3==0 or a[i]%5==0)
        k++;
      s++;
    }
  }
  if (s==k)
    cout<<"APPROVED";
  else
    cout<<"DENIED";
  
}

Measured memory_bytes: 256
s = int(input())
S_list = [s]

for i in range(1000000):
  if s%2==0:
    s = s/2
    if s in S_list:
      print(i+2)
      break
    S_list.append(s)
  else:
    s = 3*s+1
    if s in S_list:
      print(i+2)
      break
    S_list.append(s)
  


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

int main(){
  int s1,s2,g1,g2;
  cin >> s1 >> s2 >> g1 >> g2;

  int dx= g1- s1;
  int dy= g2- s2;
  
  cout << string(dx, 'R') << string(dy, 'U');
  cout << string(dx, 'L') << string(dy, 'D');
  cout << "D" << string(dx, 'R') << "RU" << string(dy, 'U') <<"L";
  cout << "U" << string(dx, 'L') << "LD" << string(dy, 'D') <<"R"<< endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;

using namespace std;

const ll mod = 1e9+7;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

const ll MX=1e6+1;
vector<ll>v;
void run(){
    int primes[MX]={0};
    for(int i=2; i<MX; i++){
        for(int y=i+i; y<MX; y+=i){primes[y]=1;}
    }
    for(int i=2; i<MX; i++){
        if(!primes[i]){v.push_back(i);}
    }
}
ll vis[MX];
void primeFactors(int n)
{
    ll c=0;
    while (n % 2 == 0)
    {
        c++;
        n = n/2;
    }
    vis[2]=max(vis[2],c);
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        c=0;
        while (n % i == 0)
        {
            c++;
            n = n/i;
        }
        vis[i]=max(vis[i],c);
    }
    if (n > 2)
        vis[n]=max(vis[n],(ll)1);
}
int main()
{
    Fastio();
    run();
    ll n,g; cin>>n;
    ll arr[n], l=1;
    for(int i=0; i<MX; i++){vis[i]=0;}
    for(int i=0; i<n; i++){
        cin>>arr[i];
        primeFactors(arr[i]);
    }
    for(int i=0; i<v.size(); i++){
        l*=fp(v[i],vis[v[i]]);
        l%=mod;
    }
    ll res=0;
    for(int i=0; i<n; i++){
        res+=(l*fp(arr[i],mod-2));
        res%=mod;
    }
    cout<<res<<'\n';


    return 0;
}


Measured memory_bytes: 12660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		boolean can = false;
		for (int i = 0; i <= X; i++) {
			if (Y == 2 * i + 2 * X) can = true;
		}
		out.println(can ? "Yes" : "No");
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 32680
N = int(input())
ab = [list(map(int, input().split())) for i in range(N)]
ab.sort(key=lambda x:x[1])
ans = 0
T = 0

for i in range(N):
    if(T+ab[i][0] <= ab[i][1]):
        ans+=1
        T += ab[i][0]
        
print(["Yes", "No"][ans!=N])

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

int main ()
{
	long long n, d, x, y, s=0;
	cin >> n >> d;
	
	for (int i=0; i<n; i++)
	{
		cin >> x >> y;
		if (x*x+y*y<=d*d) 
		s++;
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;



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

    	int N=sc.nextInt();


    	if(N == 1){
    		System.out.println("Hello World");
    	}else{
    		int A=sc.nextInt();
        	int B=sc.nextInt();

    		System.out.println(A+B);
    	}

    }
}

Measured memory_bytes: 21844
package main

import "fmt"

func mins(x ...int) int {
	mv := x[0]
	for _, v := range x[1:] {
		if v < mv {
			mv = v
		}
	}
	return mv
}

func main() {
	var q, h, s, d, n int
	fmt.Scan(&q, &h, &s, &d, &n)

	x := mins(q*4, h*2, s)
	if x*2 < d {
		fmt.Println(x * n)
	} else {
		fmt.Println(d*(n/2) + x*(n%2))
	}
}


Measured memory_bytes: 512
x, y, z, k = map(int, input().split())

xlist = sorted(list(map(int,input().split())), reverse=True)[:min(x, k)]
ylist = sorted(list(map(int,input().split())), reverse=True)[:min(y, k)]
zlist = sorted(list(map(int,input().split())), reverse=True)[:min(z, k)]


anslist = [0]
for i in range(min(x, k)):
    for j in range(min(y, k)):
        for l in range(min(z, k)):
            if (i+1)*(j+1)*(l+1) <= k:
                anslist.append(xlist[i] + ylist[j] + zlist[l])
            else:
                break

anslist = sorted(anslist, reverse=True)
for i in range(k):
    print(anslist[i])

Measured memory_bytes: 9524
#include <cstdio>
#include <iostream>
#include <vector>

int counter = 0;

bool do_binary_search(std::vector<int>& data, int wanted_value)
{
    int current_index = data.size() / 2;
    int right_index = data.size() - 1;
    int left_index = 0;
    while(current_index != right_index && current_index != left_index) {
        if(data[current_index] == wanted_value) {
            return true;
        } else if(data[current_index] < wanted_value) {
            left_index = current_index;
            current_index = (current_index + right_index) / 2;
        } else {
            right_index = current_index;
            current_index = (left_index + current_index) / 2;
        }
    }
    return data[left_index] == wanted_value || data[right_index] == wanted_value;
}

void solve(std::vector<int>& sorted_data, std::vector<int>& unsorted_data)
{
    for(int i = 0; i < unsorted_data.size(); i++) {
        if(do_binary_search(sorted_data, unsorted_data[i])) {
            counter++;
        }
    }
}

int main()
{
    int data1_size, data2_size;
    std::cin >> data1_size;
    std::vector<int> data1(data1_size);
    for(int i = 0; i < data1.size(); i++) {
        std::cin >> data1[i];
    }
    std::cin >> data2_size;
    std::vector<int> data2(data2_size);
    for(int i = 0; i < data2.size(); i++) {
        std::cin >> data2[i];
    }

    solve(data1, data2);
    printf("%d\n", counter);
    return 0;
}

Measured memory_bytes: 3376
#include<iostream>
#include<algorithm>

using namespace std;

long long comb[61][61];

int main(){
  for(int i=0;i<=60;i++){
    for(int j=0;j<=60;j++){
      comb[i][j]=
	(j>i)?0:
	(j==i||j==0)?1:
	comb[i-1][j-1]+comb[i-1][j];
    }
  }
  for(long long N,M;cin>>N>>M,N;){
    long long a[61]={1};
    for(int i=1;i<=N;i++){
      a[i]=a[i-1]+comb[N][i];
    }
    int nb=lower_bound(a,a+N+1,M)-a;
    auto cm=nb?a[nb-1]:0;
    for(int i=0;i<N;i++){
      if(nb&&cm+comb[N-i-1][nb]<M){
	cout<<1;
	cm+=comb[N-i-1][nb];
	nb--;
      }else{
	cout<<0;
      }
    }
    cout<<endl;
  }
}

  
	

  

Measured memory_bytes: 1188
# AOJ 0514: Quality Checking
# Python3 2018.6.30 bal4u

while True:
	m = sum(list(map(int, input().split())))
	if m == 0: break
	p = [2]*(m+1)
	tbl = []
	for _ in range(int(input())):
		i, j, k, r = map(int, input().split())
		if r: p[i] = p[j] = p[k] = 1;
		else: tbl.append((i, j, k))
	for t in tbl:
		r = 0
		for j in range(3):
			if p[t[j]] == 1: r += (1<<j)
		if   r == 6: p[t[0]] = 0
		elif r == 5: p[t[1]] = 0
		elif r == 3: p[t[2]] = 0
	del p[0]
	print(*p, sep='\n')


Measured memory_bytes: 5648
/* knapsack Problem */
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)


#define N_MAX 100 +10
#define W_MAX 10000 +10
int main()
{
  ios::sync_with_stdio(false);
  int N,W;
  cin >> N >> W;
  vector<int> value(N+1),weight(N+1);
  for(int i=1;i<=N;i++){
    cin >> value[i] >> weight[i];
  }
  int DP[N_MAX][W_MAX]={};
  for(int n=1;n<=N;n++){
    rep(w,W+1){
      if(weight[n]<=w){
        DP[n][w]=max(DP[n-1][w],DP[n-1][w-weight[n]]+value[n]);
      }else{
        DP[n][w]=DP[n-1][w];
      }
    }
  }
  cout<<DP[N][W]<<endl;
  
  return 0;
}

Measured memory_bytes: 5504
def has_capital_c(string):
    #print(string[2:-2].find('C') != -1)
    #print( string[2:-2].count('C') == 1)
    if string[2:-1].find('C') != -1 and string[2:-1].count('C') == 1:
        return True
    else:
        return False

def is_lower_case_except_a_c(string):
    return string.replace('A','').replace('C','').islower()

S = input()
# print(S[0]=='A')
# print(has_capital_c(S))
# print(is_lower_case_except_a_c(S))
if S[0]=='A' and has_capital_c(S) and is_lower_case_except_a_c(S):
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  
  string s;
  cin >> s;
  int n = s.size();
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      string tmp = "";
      for(int k=0;k<n;k++){
        if(i<=k && k<j) continue;
        else tmp.push_back(s[k]);
      }//k
      if(tmp == "keyence"){
        cout << "YES" << endl;
        return 0;
      }
    }//j
  }//i
  cout << "NO" << endl;
}

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

int main() {
  int A, B;
  string op;
  cin >> A >> op >> B;
  
  int x;
  if ( op == "+") {
    x = A + B;
  }
  else if ( op == "-") {
    x = A - B;
  }
  
  cout << x << endl;
}

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

static const int MAX = 100;
static const long long INFTY = (1LL << 32);

int n;
long long d[MAX][MAX];

void floyd() {
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            if (d[i][k] == INFTY) continue;
            for (int j = 0; j < n; j++){
                if (d[k][j] == INFTY) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    int e, u, v, c;
    cin >> n >> e;

    for (int i = 0; i < n; i++) {
        for (int j =0; j < n; j++) {
            d[i][j] = ((i==j) ? 0 : INFTY);
        }
    }

    for (int i = 0; i < e; i++) {
        cin >> u >> v >> c;
        d[u][v] = c;
    }

    floyd();

    bool negative = false;
    for (int i = 0; i < n; i++) if (d[i][i] < 0) negative = true;

    if (negative) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (j) cout << " ";
                if (d[i][j] == INFTY) cout << "INF";
                else cout << d[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3192
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 + y1 - y2
y3 = y2 + x2 - x1
x4 = x1 - y2 + y1
y4 = y1 + x2 - x1

print(x3, y3, x4, y4)

Measured memory_bytes: 2940
from itertools import product, takewhile
# count = 0


def iter_break():
    yield True
    raise StopIteration


def main():
    N, Y = (int(x) for x in input().split(" "))
    Y = Y//1000
    y10 = 10
    y5 = 5
    y1 = 1
    max_y10 = Y // y10
    max_y5 = Y // y5
    max_y1 = Y // y1
    if (max_y10) > N:
        max_y10 = N
    if (max_y5) > N:
        max_y5 = N
    # if (max_y1) > N:
    #     max_y1 = N
    for (n_y10, n_y5) in product(
        range(max_y10, -1, -1),
            range(max_y5, -1, -1)):
        n_y1 = N-n_y10-n_y5
        if n_y1 < 0 or (n_y10 * y10 + n_y5 * y5 + n_y1 * y1 != Y):
            continue
        print(n_y10, n_y5, n_y1)
        exit()
    print(-1, -1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72944
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int maxn = 2e5 + 5;
const int mod = 998244353;
int b[maxn];
vector<ll>d;
int getID(ll x) {
    return lower_bound(all(d),x)-d.begin() + 1;
}
void update(int x) {
    while(x < maxn) {
        b[x]++;
        x += x & (-x);
    }
}
int sum(int x) {
    int ret = 0;
    while(x) {
        ret += b[x];
        x -= x & (-x);
    }
    return ret;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        ll a, b;
        cin >> a >> b;
        if (a == b) {
            cout << a * 2 - 2 << '\n';
        }
        else {
            ll sq = sqrt(a * b);
            if (sq * sq == a * b) {
                sq--;
            }
            if (sq * (sq + 1) >= a * b) {
                cout << 2 * sq - 2 << '\n';
            }
            else {
                cout << 2 * sq - 1 << '\n';
            }
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
void trace(int a[],int n){
    int i;
    for(i=0;i<n;i++){
	if(i>0) printf(" ");
	printf("%d",a[i]);
    }
    printf("\n");
}

int bubbleSort(int a[],int n){
    int i,j,flag,tmp,count=0;
    flag=1;
    i=0;
    while(flag){
	flag=0;
	for(j=n-1;j>=i+1;j--){
	    if(a[j-1]>a[j]){
		tmp=a[j-1];
		a[j-1]=a[j];
		a[j]=tmp;
		flag=1;
		count++;
	    }
	}
    }
    trace(a,n);
    return count;
}
	
int main(void){
    int n,a[100],i,ans;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    ans=bubbleSort(a,n);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 604
# n = int(input())

# k = [int(i) for i in input().split()]
# a,b,c = (int(i) for i in input().split()) 
# cnt = 0
# for i in range(n):
#   sum = 0
#   for j in range(i,n):
#     sum+=a[j]
#     if sum==0:
#       cnt+=1
# print(cnt)
def f():
  a,b = (int(i) for i in input().split()) 
  s = []
  for i in range(a):
    s.append(input())
  for i in range(a):
    for j in range(b):
      if s[i][j]=='#':
        ok = False
        if i+1<a:
          if s[i+1][j]=='#':
            ok = True
        if j+1<b:
          if s[i][j+1]=='#':
            ok =True
        if i-1>=0:
          if s[i-1][j] == '#':
            ok=True
        if j-1>=0:
          if s[i][j-1]=='#':
            ok=True
        if ok==False:
          print('No')
          return
  print('Yes')
f()

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    char s[3],i,a=0,b=0,c=0;
    for(i=0;i<3;i++)
    {
        scanf("%c",&s[i]);
    }
    for(i=0;i<3;i++)
    {
        if(s[i]=='a')
        {
            a++;
        }
        if(s[i]=='b')
        {
            b++;
        }
        if(s[i]=='c')
        {
            c++;
        }
    }
    if(a==1&&b==1&&c==1)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }

}


Measured memory_bytes: 128
#include <stdio.h>

#define MAX 101
#define CORRECT 0
#define NOTCORRECT 1
#define YET 2
  
int n,d[MAX],f[MAX],g[MAX][MAX],cl[MAX],t=0;
  
void DFSV(int u){
  int v;
  cl[u] = YET;
  t++;
  d[u] = t;
  for(v=1; v<=n; v++){
    if((g[u][v] == 1)&& (cl[v] == CORRECT)){
      DFSV(v);
    }
  } 
  cl[u] = NOTCORRECT;
  f[u]= ++t;
}
  
int main(){
  int i,j,u,v,k;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      g[i][j] = 0;
    }
  }
  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      g[u][v] = 1;
    }
  }
  for(i=1;i<=n;i++){
    cl[i]=CORRECT;
  }
  for(i=1;i<=n;i++){
    if(cl[i]==CORRECT) DFSV(i);
  }
  for(i=1; i<=n; i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }  
  return 0;
}

Measured memory_bytes: 636
package main

import (
	"fmt"
	"math"
)

var A, B, ans string

func main() {
	fmt.Scan(&A, &B)

	if len(A) > len(B) {
		fmt.Println("GREATER")
	} else if len(A) < len(B) {
		fmt.Println("LESS")
	} else {
		for i := 0; i < min(len(A), len(B)); i++ {
			if string(A[i]) > string(B[i]) {
				fmt.Println("GREATER")
				return
			}
			if string(A[i]) < string(B[i]) {
				fmt.Println("LESS")
				return
			}
		}
		fmt.Println("EQUAL")
	}
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type si struct {
	s int
	i int
}

type SortBy []si

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].s < a[j].s }


Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	count := 0
	for {
		for i := 0; i < n; i++ {
			if a[i]%2 != 0 {
				fmt.Println(count)
				return
			}
			a[i] /= 2
		}
		count++
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
	int n, m, p;
	while (cin >> n >> m >> p, n|m|p) {
		m--;
		vector<int> xs = vector<int>(n);
		rep(i, n) cin >> xs[i];

		ll sum = 0;
		rep(i, n) sum += 100*xs[i];
		if (xs[m] == 0)
			cout << 0 << endl;
		else 
			cout << sum*(100-p)/(100*xs[m]) << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define F first
#define S second
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define EPS 1e-7
#define iof freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
long long mod = 1e9;
const int N = 1e9;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
typedef complex <ll> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
int n;
double ans;
int main()
{
    em3
    cin >> n;
    for(int i = 0 ; i < n ; i++)
    {
        double temp;
        cin >> temp;
        ans += (1 / temp);
    }
    cout << fixed << setprecision(5) << 1 / ans << endl;


    return 0;
}



Measured memory_bytes: 384
X,N = map(int, input().split())
if N > 0:
    p = list(map(int, input().split()))
    for i in range(100):
        now_p = X+i
        now_m = X-i
        if not now_m in p:
            ans=now_m
            break
        elif not now_p in p:
            ans = now_p
            break
else:
    ans = X

print(ans)

Measured memory_bytes: 9184
#include <stdio.h>
#include <stdlib.h>

main()
{
  int flag = 0x02;
  
  for (;;) {
    const int ch = getchar();
    if (ch == '\n') break ;
    
    if (!!(flag & 0x01)) {
      if (ch == 'Z') {
        fputs("AZ", stdout);
        flag = 0x00;
      }
    } else {
      if (ch == 'A') {
        flag |= 0x01;
      }
    }
  }
  puts(!!(flag & 0x02) ? "-1" : "");


  return EXIT_SUCCESS;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define N 110
#define mod 1000000007
typedef long long ll;
ll h[N],a[N],dp[N][N];
inline ll Pow(ll a,ll b,int p=mod) {
    if (b<=0) return 1; ll res=1;
    for (;b;b>>=1,a=1LL*a*a%p)
        if (b&1) res=1LL*res*a%p;
    return res;
}
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
int main() {
    int n=read(),tot=0; dp[0][0]=1;
    for (int i=1;i<=n;i++) a[++tot]=h[i]=read();
    sort(a+1,a+tot+1),tot=unique(a+1,a+tot+1)-a-1;
    for (int i=1;i<=n;i++) h[i]=lower_bound(a+1,a+tot+1,h[i])-a;
    for (int i=1;i<=n;i++) {
        dp[i][0]=dp[i-1][0]*2%mod;
        for (int j=h[i]+1;j<=h[i-1];j++) dp[i][0]=(dp[i][0]+dp[i-1][j]*2%mod)%mod;
        ll tmp=Pow(2,a[h[i]]-a[h[i-1]]);
        for (int j=1;j<=min(h[i-1],h[i]);j++) dp[i][j]=dp[i-1][j]*tmp%mod;
        for (int j=h[i-1]+1;j<=h[i];j++) 
            if (dp[i][j]+j==1) dp[i][j]=dp[i-1][0]*(Pow(2,a[j])-2)%mod*Pow(2,a[h[i]]-a[j])%mod;
            else dp[i][j]=dp[i-1][0]*2*(Pow(2,a[j]-a[j-1])-1)%mod*Pow(2,a[h[i]]-a[j])%mod;
    }
    ll res=0;
    for (int i=0;i<=tot;i++) res=(res+dp[n][i])%mod;
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 384
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void){
    long long n,k;
    cin >> n >> k;

    long long ans = 0;

    ans = pow(100, n) * k;

    if(k==100){
        ans = ans + pow(100, n);
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <vector>

int main(void) {
  int N;
  scanf("%d", &N);
  std::vector<std::string> W;

  for (int i = 0; i < N; i++) {
    std::string str;
    std::cin >> str;
    auto result = std::find(W.begin(), W.end(), str);
    if (i == 0 ||
        result == W.end() && W.back().back() == str.front()) {
      W.push_back(str);
    } else {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  cout << n*n*n;
  return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> edge(N+1, vector<int>());
    vector<vector<bool>> go(N+1, vector<bool>(N+1, false));
    
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        go[a][b] = true;
    }
    
    vector<int> ans;
    for (int i = 1; i <= N; i++) {
        vector<bool> check(N+1, false);
        vector<int> pre(N+1, 0);
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            int now = q.front();
            q.pop();
            for (int nxt : edge[now]) {
                if (check[nxt]) continue;
                else if (nxt != i) {
                    q.push(nxt);
                    check[nxt] = true;
                    pre[nxt] = now;
                } else {
                    int pos = now;
                    while (pos != i) {
                        ans.push_back(pos);
                        pos = pre[pos];
                    }
                    ans.push_back(i);
                    break;
                }
            }
            if (!ans.empty()) break;
        }
        if (!ans.empty()) break;
    }
    
    if (ans.empty()) {
        cout << -1 << endl;
        return 0;
    }
    
    reverse(ans.begin(), ans.end());
    
    while (true) {
        int K = (int)ans.size(); 
        bool check = true;
        for (int i = 0; i < K; i++) {
            for (int j = K-1; j >= i+2; j--) {
                if (go[ans[i]][ans[j]]) {
                    ans.erase(ans.begin()+i+1, ans.begin()+j);
                    check = false;
                    break;
                }
            }
            if (!check) break;
            for (int j = 0; j <= i-1; j++) {
                if (i == K-1 && j == 0) continue;
                if (go[ans[i]][ans[j]]) {
                    ans.erase(ans.begin()+i+1, ans.end());
                    ans.erase(ans.begin(), ans.begin()+j);
                    check = false;
                    break;
                }
            }
            
        }
        if (check) break;
    }
    cout << (int)ans.size() << endl;
    for (int n : ans) cout << n << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cstdio>
#include <string>

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define MAX_SEG (2 << 20)

struct Node{
  int sum;
  int delay;
  bool delayFlag;
  Node(){
    sum = delay = delayFlag = 0;
  }
};

int n;
Node seg[2*MAX_SEG];

//セグメントツリーの要素数の設定
void Init(int _n){
  n = 1;
  while(_n > n)
    n *= 2;
}

//遅延値の評価
inline void DelayEvaluate(int k, int a, int b){

  //遅延評価フラグが立っていないなら遅延評価を行わない
  if(!seg[k].delayFlag)
    return;

  //現在の値を遅延値に基づいて更新
  seg[k].sum += seg[k].delay * (b-a);
  
  //今見ているノードに子がある場合
  if(k < n-1){
    //遅延値を子に伝播させる
    seg[2*k+1].delay += seg[k].delay;
    seg[2*k+2].delay += seg[k].delay;
    //遅延評価フラグを立てる
    seg[2*k+1].delayFlag = seg[2*k+2].delayFlag = true;
  }

  //遅延評価を行ったので自分の遅延値等は初期化しておく
  seg[k].delay = seg[k].delayFlag = 0;

}

//ノードkの値の計算
//子の値が計算終了していることが前提
inline void UpdateNode(int k){
  seg[k].sum = seg[2*k+1].sum + seg[2*k+2].sum;
}

//[l,r)の範囲一様にvを加算する
void UpdateRange(int l, int r, int v, int k = 0, int a = 0, int b = n){

  //とりあえず遅延計算
  DelayEvaluate(k,a,b);
  
  //見ているノードが[l,r)と全く被っていない場合
  if(b <= l || r <= a){
    return;
  }
  //完全に被っている場合
  else if(l <= a && b <= r){
    seg[k].delay += v;
    seg[k].delayFlag = true;
    DelayEvaluate(k,a,b);
    return;
  }
  //ちょい被りの場合
  else{
    int mid = (a+b)/2;
    UpdateRange(l,r,v,2*k+1,a,mid);
    UpdateRange(l,r,v,2*k+2,mid,b);
    UpdateNode(k);
    return;
  }

}

//[l,r)の値の合計を出力する
int Query(int l, int r, int k = 0, int a = 0, int b = n){

  //とりあえず遅延計算
  DelayEvaluate(k,a,b);

  //今見ているノードが[l,r)と全く被っていない場合
  if(b <= l || r <= a)
    return 0;
  //完全に被っている場合
  else if(l <= a && b <= r){
    return seg[k].sum;
  }
  //ちょい被りの場合
  else{
    int vl,vr;
    int mid = (a+b)/2;
    vl = Query(l,r,2*k+1,a,mid);
    vr = Query(l,r,2*k+2,mid,b);
    return vl+vr;
  }

}

const int MAX_N = 300005;
const int MAX_M = 100005;

int N, M;
class Line{
public:
    int l, r;
    bool input() {
        cin >> l >> r;
    }
    int range() {
        return r-l+1;
    }
    bool operator < (const Line& line) const {
        return r-l < line.r-line.l;
    }
}lines[MAX_N];

signed main()
{
    cin >> N >> M;
    for(int i = 0; i < N; i++) {
        lines[i].input();
    }

    sort(lines, lines+N);

    Init(MAX_M);

    int lIndex = 0;
    for(int i = 1; i <= M; i++) {
        while(lIndex < N && lines[lIndex].range() < i) {
            const Line& line = lines[lIndex];
            UpdateRange(line.l, line.r+1, 1);
            lIndex++;
        }
        int ans = N-lIndex;
        for(int j = 1; i*j <= MAX_M; j++) {
            ans += Query(i*j, i*j+1);
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 104064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979311599796346854418516159057617187500
#define endl '\n'
const ll N=150000+5,mod=1e9+7,bit=31;
signed main()
{
    fast;
    ll pro=1,temp,t,m,k,i,j,l,r,n,mid,x,y,z,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,nxt,sum=0,flag=1,i1=-1,i2=-1;
	cin>>n;
	ll a[n];
	priority_queue<ld,vector<ld>,greater<ld>> pq;
	rep(i,0,n-1)
	{
		cin>>a[i];
		pq.push((ld)a[i]);
	}
	for(i=1;i<n;i++)
	{
		ld e1=pq.top();
		pq.pop();
		ld e2=pq.top();
		pq.pop();
		e1+=e2;
		e1=e1/2.00000000000;
		pq.push(e1);
	}
	cout<<fixed<<setprecision(15)<<pq.top()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
    int h, m, s;
    cin >> s;
    h = s / 3600;
    m = (s % 3600) / 60;
    s = s % 60;
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cmath>

void solve() {
  int a, b;
  std::cin >> a >> b;
  for (int i = 13; i <= 1000; ++i)
    if ((int)(i*0.08) == a && (int)(i*0.10) == b) {
      std::cout << i << std::endl;
      return;
    }
  std::cout << -1 << std::endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 256
//  Friendly NUKE is ready!!
#include <bits/stdc++.h>
#define SPEED ios::sync_with_stdio(false); cin.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define dbg(x) cout<<#x<<": "<<x<<endl
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mo 1000000007
#define inf 1e18
#define eps 0.0000000001
#define stp setprecision(20)
#define all(v) v.begin(),v.end()
#define endl '\n'
using namespace std;
//mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
 
#define N  int(1e5)+10
ll h[3][N] , dp[110][N] ,w[N],v[N];
int main()
{    SPEED;
      int n,Wmx;
      cin>>n>>Wmx;
      loop(i,1,n+1)cin>>w[i]>>v[i] ;
       
      loop(i,1,n+1){
      	   
      	   loop(wt,1,Wmx+1){
      	   	 if(wt-w[i]>=0)
      	   	 dp[i][wt] = max(dp[i-1][wt-w[i]]+v[i] , dp[i-1][wt]) ;
      	   	 else dp[i][wt] = dp[i-1][wt] ;
      	   }
      	   
      	   
      }      
      cout<<dp[n][Wmx] ;
}

Measured memory_bytes: 81744
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		long ans = 0;
		while(x <= y) {
			x *= 2;
			ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
h,w=map(int,input().split())
tmp=0
tmg=0
if h%2!=0:
    tmp=1+h//2
    tmg=h//2
else:
    tmp=h//2
    tmg=tmp

ans=0
if w%2!=0:
    ans=tmp*(1+w//2)+tmg*(w//2)
else:
    ans=tmp*(w//2)+tmg*(w//2)
if h==1 or w==1:
    print(1)
    exit()
print(ans)

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

using namespace std;
int main() {
  string s;
  int sum = 700;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
  	if (s[i] == 'o')
      sum += 100;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "4 4", "##.#", "....", "##.#", ".#.#" ].parse.expand.solve == "###\n###\n.##" );
	assert( [ "3 3", "#..", ".#.", "..#" ].parse.expand.solve == "#..\n.#.\n..#" );
	assert( [ "4 5", ".....", ".....", "..#..", "....." ].parse.expand.solve == "#" );
	assert( [ "7 6", "......", "....#.", ".#....", "..#...", "..#...", "......", ".#..#." ].parse.expand.solve == "..#\n#..\n.#.\n.#.\n#.#" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hw = input.front.split.to!( long[] );

	auto ass = new char[][ hw[ 0 ] ];
	foreach( ref as; ass )
	{
		input.popFront;
		as = input.front.strip.dup;
	}
	
	return tuple( hw[ 0 ], hw[ 1 ], ass );
}

auto solve( long h, long w, char[][] ass )
{
	auto hb = new bool[ h ];
	auto wb = new bool[ w ];
	
	// 黒がある行と列をマーキング
	foreach( y, as; ass )
	{
		foreach( x, a; as )
		{
			if( a == '#' )
			{
				hb[ y ] = true;
				wb[ x ] = true;
			}
		}
	}
	
	// 白のみの行を削除
	foreach_reverse( y; 0 .. h )
	{
		if( hb[ y ] ) continue;
		
		ass = ass[ 0 .. y ] ~ ass[ y + 1 .. $ ];
	}
	
	// 白のみの列を削除
	foreach_reverse( x; 0 .. w )
	{
		if( wb[ x ] ) continue;
		
		foreach( ref as; ass )
		{
			as = as[ 0 .. x ] ~ as[ x + 1 .. $ ];
		}
	}
	
	return ass.join( "\n" );
}


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

using usize = ::std::size_t;
//using u64 = ::std::int_least64_t;
using u64 = int;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

const int offset[24][2] = {
    {-1, 0}, {1, 0}, {0, 1}, {0, -1},
    {1,1},{1,-1},{-1,-1},{-1,1},
    {2,2},{2,1},{2,0},{2,-1},{2,-2},
    {-1,-2},{0,-2},{-1,-2},{-2,-2},
    {-2,-1},{-2,0},{-2,1},{-2,2},
    {-1,2},{0,2},{1,2}
};

struct edge {
    u64 r, c, weight;
    bool operator<(const edge &e) const { return weight > e.weight; }
};

int R, C;
const int MAXV = 1010;
u64 dist[MAXV][MAXV];
char grid[MAXV][MAXV];
 


void mooreDijkstra(int r, int c)
{
    for (int i = 0; i <= R; i++) {
        for (int j = 0; j <= C; j++) {
            dist[i][j] = Inf;
        }
    }
    
    dist[r][c] = 0;
    priority_queue<edge> q;
    q.push(edge{r, c, dist[r][c]});
    while (!q.empty()) {
        edge e1 = q.top(); q.pop();
        if (dist[e1.r][e1.c] < e1.weight) continue;
        for (int k = 0; k < 4; k++){
            auto v = edge{e1.r + offset[k][0], e1.c + offset[k][1], 0};
            if (v.r < 0 || v.r >= R || v.c < 0 || v.c >= C) {
                continue;
            }
            if (grid[v.r][v.c] == '.'){
                if (dist[v.r][v.c] > dist[e1.r][e1.c] + v.weight){
                    dist[v.r][v.c] = dist[e1.r][e1.c] + v.weight;
                    q.push(edge{v.r, v.c, dist[e1.r][e1.c] + v.weight});
                }
            }
        }
        
        for (int i = -2; i <= 2; i++){
            for (int j = -2; j <= 2; j++){
                auto v = edge{e1.r + i, e1.c + j, 1};
                if (v.r < 0 || v.r >= R || v.c < 0 || v.c >= C) {
                    continue;
                }
                if (grid[v.r][v.c] == '.'){
                    if (dist[v.r][v.c] > dist[e1.r][e1.c] + v.weight){
                        dist[v.r][v.c] = dist[e1.r][e1.c] + v.weight;
                        q.push(edge{v.r, v.c, dist[e1.r][e1.c] + v.weight});
                    }
                }
            }
        }
    }
}
 


int main(int argc, char *argv[])
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> R >> C;
    int Ch, Cw, Dh, Dw;
    cin >> Ch >> Cw;
    cin >> Dh >> Dw;
    Ch--, Cw--, Dh--, Dw--;
    
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            cin >> grid[i][j];
        }
    }
    
    mooreDijkstra(Ch, Cw);
    dist[Dh][Dw] = dist[Dh][Dw] * 2 >= Inf ? -1 : dist[Dh][Dw];
    cout << dist[Dh][Dw] << endl;
    
    return 0;
    
}


Measured memory_bytes: 8536
def bisect(l, r, x):
    while abs(r - l) > 1:
        if arr[l] == x or arr[r] == x:
            return 1
        mid = (l + r) // 2
        if arr[mid] == x:
            return 1
        if arr[mid] < x:
            l = mid
        else:
            r = mid
    return 0


n = int(input())
arr = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
arr.sort()

l = 0
r = n - 1

ans = 0
for x in t:
    if bisect(l, r, x):
        ans += 1

print(ans)


Measured memory_bytes: 16712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n;
	cin>>n;
	int arr[n][3];
	cin>>arr[0][0]>>arr[0][1]>>arr[0][2];
	int mx=max(arr[0][0], max(arr[0][1], arr[0][2]));
	for(int i=0;i<n-1;i++)
	{
		int a, b, c;
		cin>>a>>b>>c;
		arr[i+1][0]=max(arr[i][1], arr[i][2])+a;
		arr[i+1][1]=max(arr[i][2], arr[i][0])+b;
		arr[i+1][2]=max(arr[i][0], arr[i][1])+c;
		if(arr[i+1][0]>mx)
			mx=arr[i+1][0];
		if(arr[i+1][1]>mx)
			mx=arr[i+1][1];
		if(arr[i+1][2]>mx)
			mx=arr[i+1][2];
	}
	cout<<mx<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main()
{
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	int judge = 0;
	int roop = 0;

	while(roop == 0){
		C = C - B;
		if(C<=0){
			judge++;
			break;
		}
		A = A - D;
		if(A<=0)
			break;
	}

	if(judge == 1)
		cout << "Yes";
	else
		cout << "No";

	cin >> A;

	return 0;	
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const double EPS=1e-6;
const int N=2e5+10;
const ll mod=1e9+7;
inline ll read()
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar()) x=x*10+ch-'0';
   return x*f;
}
ll n,k;
double a[N];
bool check(double mid)
{  ll cnt=0;
   for(ll i=1;i<=n;i++)
   {  if(a[i]<=mid)continue;
      cnt=cnt+ceil((a[i]/mid));
      cnt--;
      if(cnt>k)return 0;
   }
   if(cnt>k)return 0;
   else return 1;
}
int main()
{  cin>>n>>k;
   for(int i=1;i<=n;i++)cin>>a[i];
   double l=0.0001,r=1e9+5,ans;
   while(r-l>=EPS)
   {  double mid=(l+r)/2;
      if(check(mid))
      {  ans=mid;
         r=mid-0.00000001;
      }
      else
      {  l=mid+0.00000001;
      }
   }
   printf("%.0f\n",max(1.0,ceil(ans-0.000001)));
}

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

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    ll ans = 0;
    for(int i=0; i<n; i++){
        ll a, b;
        cin >> a >> b;
        v[i] = a + b;
        ans -= b;
    }
    sort(v.rbegin(), v.rend());
    for(int i=0; i<n; i+=2) ans += v[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.on('SIGINT', function(){
    input_stdin_array = input_stdin.split("\n");
    main();
    process.exit();
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

/////////////// ignore above this line ////////////////////

function main() {
	var s = readLine();
	var vowel = 'aeiou';
	for (var i=0; i < 5; i++){
		if (s[0] == vowel[i]){
			console.log("vowel");
			return ;
		}
	}
	console.log("consonant");
}


Measured memory_bytes: 7500
#include<stdio.h>
int main(void){
    int a,b,n;
    scanf("%d",&n);
    a=n/10;
    b=n-10*a;
    if(b==2){
        printf("hon");
    }
    if(b==0){
        printf("pon");
    }
    if(b==3){
        printf("bon");
    }
    if(b==4){
        printf("hon");
    }
    if(b==1){
        printf("pon");
    }
    if(b==5){
        printf("hon");
    }
    if(b==7){
        printf("hon");
    }
    if(b==6){
        printf("pon");
    }
    if(b==9){
        printf("hon");
    }
    if(b==8){
        printf("pon");
    }
    
    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100000;
const long double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, k, val;
    cin >> n >> k;
    val = n%k;

    cout << min(val, k - val) << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
    
ll gcd(ll a,ll b)
{
  if(b==0)
      return a;
  return gcd(b,a%b);
}
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;
  ll divisor;
  
  cin >> a >> b;
  if(a>b)
      divisor=gcd(a,b);
  else
      divisor=gcd(b,a);
  int cnt=1;
  
  for(ll i=2; i<=sqrt(divisor); i++)
  {
    if(divisor%i==0)
    {
      cnt++;
      while(divisor%i==0)
     	divisor/=i;
    }
  }
  
  if(divisor!=1)
    cnt++;
  cout << cnt;
  return 0;
}

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

n, q = list(map(int, input().split()))
s = list(str(input()))


count = [0]


for i in range(1, len(s)):
    if s[i-1]+s[i] == "AC":
        count.append(count[i-1]+1)
    else:
        count.append(count[i-1])

# print(count)

for _ in range(q):
    l, r = list(map(int, input().split()))
    print(count[r-1]-count[l-1])


Measured memory_bytes: 6920
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main()
{
  int n; cin>>n; set<int> s;
  vector<int>v; 
  int sieve[10000000] = {0};  int max = 0;
  for(int i = 0; i < n; i++)
  {	int x; cin>>x;
    if(s.find(x) == s.end())
    {
      s.insert(x); v.push_back(x);
      if(x > max)
        max = x;
    }
   else
   {
     sieve[x] = 1;
   }
  }
  for(int i = 0; i < v.size(); i++)
  {
    int j = 2;
    while((v[i]*j) <= max)
    {
      sieve[v[i]*j] = 1;
      j++;
    }    
  }
  int count = 0;
  for(int i = 0; i < v.size(); i++)
  {
    if(sieve[v[i]] == 0)
      	count++;
  }
  cout<<count;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =998244353;


int main()
{	
	  ll n;
	  cin>>n;
	  ll ans=0;
	 ans=n%2?((n-1)/2)*n:((n)/2)*(n-1);

	  cout<<ans<<endl;


	   


}
    
 
    
    


Measured memory_bytes: 256
unittest
{
	assert( [ "5", "1 2 1 3 7" ].parse.expand.solve == 3 );
	assert( [ "15", "1 3 5 2 1 3 2 8 8 6 2 6 11 1 1" ].parse.expand.solve == 7 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto d = reduce!( ( a, b ) => a + b[ 1 ] - 1 )( 0L, as.sort().group );
	d += ( d % 2 == 1 );
	return as.length.signed - d;
}


Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
ll mod=998244353;
int main()
{
    ll a;
    string b;
    cin>>a;
    cin>>b;
    ll first=b[0]-'0';
    ll second=((b[2]-'0')*10)+b[3]-'0';
    ll num=first*100+second;
    cout<<(a*num)/100<<endl;


    
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int prime[10010];
bool is_prime[10010];

void sieve(int n){
	int p=0;
	for(int i=0;i<=n;i++) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
		}
	}
}

int main(){
	sieve(10000);
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		for(int i=n;i>=5;i--){
			if(is_prime[i] && is_prime[i-2]){
				o(i-2<<" "<<i);
				break;
			}
		}
	}
}

Measured memory_bytes: 1176