akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CDiceAndCoin solver = new CDiceAndCoin();
        solver.solve(1, in, out);
        out.close();
    }

    static class CDiceAndCoin {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();

            double answer = 0;
            for (int i = 1; i <= n; i++) {
                double amt = 1;
                for (int j = i; j < k; j *= 2) {
                    amt /= 2.0;
                }
                answer += amt;
            }

            answer /= n;

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21332
N = int(input())
mod = 10**9+7

if(N == 1):
  count = 0
else:
  Pmax = 10**N #全組み合わせ数
  P0out = 9**N #0が入らない
  P9out  = 9**N #9が入らない
  P09out = 8**N #0も9も入らない
  
  count = Pmax - P09out - (P0out - P09out) - (P9out - P09out)
  
  
print(int(count%mod))

Measured memory_bytes: 11864
#include<iostream>
#include<stdio.h>
using namespace std;
int S[1000000],n;

int binarySearch(int key){
    int left = 0;
    int right = n;
    int mid;

    while(left < right){
        mid = (left + right) / 2;
        if( key == S[mid] ) return 1;
        if( key > S[mid] ) left = mid + 1;
        else if( key <S[mid] ) right = mid;
    }
    return 0;
}

int main(){
    int i,s,q,t,count = 0;

    cin>>n;
    for(i = 0; i < n; i++){
        cin>>S[i];
    }

    cin>>q;
    for(i = 0; i < q; i++){
        cin>>t;
        if(binarySearch( t ) ){
            count++;
        } 
    }
    cout<<count<<endl;
    return 0;
}



Measured memory_bytes: 3468
#include<stdio.h>
int main(void)
{
	int h,w,i,j,masu[50+1][50+1],m[50+1][50+1];
	char c[50+1][50+1];
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++) {
		scanf("%s",c[i]);
	}
	for(i=0;i<h;i++) {
		for(j=0;j<w;j++) {
			//scanf(" %c",&c);
			masu[i][j]=c[i][j]-'0';
			m[i][j]=1000;
		}
	}
	m[0][0]=0;
	for(i=0;i<h;i++) {
		for(j=0;j<w;j++) {
			if(m[i][j]+masu[i][j+1]<m[i][j+1]) {
				m[i][j+1]=m[i][j]+masu[i][j+1];
//				printf("m=[%d][%d]=%d\n",i,j+1,m[i][j+1]);
            }
            if(m[i][j]+masu[i+1][j]<m[i+1][j]) {
                m[i+1][j]=m[i][j]+masu[i+1][j];
//				printf("m=[%d][%d]=%d\n",i+1,j,m[i+1][j]);        
            }
		}
	}
	printf("%d\n",m[h-1][w-1]);
	return 0;
}

Measured memory_bytes: 620
import math
def check(X):
	maximum = 0
	for i in range(1, math.floor(math.sqrt(X))+1):
		if i == 1:
			maximum = 1
			continue
		j = 2
		while True:
			tmp = i ** j
			if tmp > X:
				break
			if tmp >= maximum:
				maximum = tmp
			j += 1
	return maximum

print(check(int(input())))

Measured memory_bytes: 3188
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll x,y;
  cin >> x >> y;

  ll ans = 0;

  ll bef = x;
  ans ++;
  while(1)
  {
    if(bef * 2 > y)
    {
      break;
    }
    else
    {
      bef = bef * 2;
      ans++; 
    }
  }

  cout << ans << endl;



  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a;
		int sum =0;
		if(N/100==1) {
			a = N-100;
			sum+=900;
			if(a/10==1) {
				a = a-10;
				sum+=90;
				if(a/1==1) {
					sum+=9;
				}
				else if(a/9==1) {
					sum+=1;
				}
			}
			else if(a/10==9) {
				a = a-90;
				sum+=10;
				if(a/1==1) {
					sum+=9;
				}
				else if(a/1==9) {
					sum+=1;			
				}
			}
		}
		if(N/100==9) {
			a = N-900;
			sum+=100;
			if(a/10==1) {
				a = a-10;
				sum+=90;
				if(a/1==1) {
					sum+=9;
				}
				else if(a/9==1) {
					sum+=1;
				}
			}
			else if(a/10==9) {
				a = a-90;
				sum+=10;
				if(a/1==1) {
					sum+=9;
				}
				else if(a/1==9) {
					sum+=1;				
				}
			}
		}
		System.out.println(sum);
	}
}


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

int main() {
    
    double N;
    cin >> N;
    int val = ceil(N / 1.08);
    int x = floor(val * 1.08);
    if (x != N) {
        cout << ":(" << endl;
    } else {
        cout << val << endl;
    }
    return 0;
}


Measured memory_bytes: 3676
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

string N;
ll K;

ll dp[105][2][4];
// 0: ok, 1: ?

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

  // 1桁目
  dp[0][0][0] = 1;
  dp[0][0][1] = N[0] - '0' - 1;
  dp[0][1][1] = 1;

  // 残りの桁
  for (ll i = 1; i < N.size(); i++) {
    // 0
    dp[i][0][0] += dp[i - 1][0][0];
    dp[i][0][1] += dp[i - 1][0][0] * 9;

    dp[i][0][1] += dp[i - 1][0][1];
    dp[i][0][2] += dp[i - 1][0][1] * 9;

    dp[i][0][2] += dp[i - 1][0][2];
    dp[i][0][3] += dp[i - 1][0][2] * 9;

    dp[i][0][3] += dp[i - 1][0][3];

    // 1
    if (N[i] == '0') {
      dp[i][1][1] += dp[i - 1][1][1];
      dp[i][1][2] += dp[i - 1][1][2];
      dp[i][1][3] += dp[i - 1][1][3];
    } else {
      dp[i][1][2] += dp[i - 1][1][1];
      dp[i][0][2] += dp[i - 1][1][1] * (N[i] - '0' - 1);
      dp[i][0][1] += dp[i - 1][1][1];

      dp[i][1][3] += dp[i - 1][1][2];
      dp[i][0][3] += dp[i - 1][1][2] * (N[i] - '0' - 1);
      dp[i][0][2] += dp[i - 1][1][2];

      dp[i][0][3] += dp[i - 1][1][3];
    }
  }

  ll ans = dp[N.size() - 1][0][K] + dp[N.size() - 1][1][K];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1144
//\\//\\ * * * //\\// ||
#include <bits/stdc++.h> 

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

const int N = (int) 1e5 + 10;

bool mark[N];
ll a[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, x, m;
  cin >> n >> x >> m;
  a[0] = x;
  mark[x] = true;
  for (ll i = 1; i <= m; i++) {
    a[i] = (a[i - 1] * a[i - 1]) % m;
    if (mark[a[i]]) {
      ll sum1 = 0, sum2 = 0;
      ll flag = -1;
      for (ll j = 0; j < i; j++) {
        if (a[j] != a[i]) {
          sum1 += a[j];
          continue;
        }
        sum1 += a[j];
        flag = j;
        break;
      }
      for (ll j = flag + 1; j <= i; j++) {
        sum2 += a[j];
      }
      ll len = i - flag;
      ll nn = n - (flag + 1);
      sum1 += (nn / len) * sum2;
      for (ll j = 0; j < nn % len; j++) {
        sum1 += a[j + flag + 1];
      }
      cout << sum1 << '\n';
      return 0;
    } else {
      mark[a[i]] = true;
      continue;
    }
    ll sum = 0;
    for (ll i = 0; i < n; i++) {
      sum += a[i];
    }
    cout << sum << '\n';
  }
  return 0;
}


Measured memory_bytes: 4128
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

const int INF = 1e18;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int MAX_V = 10005;

class Edge{
	public:
		int to, cap, rev;
		Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

class Flow{
	private:
		vector<Edge> G[MAX_V];
		bool used[MAX_V];
		int level[MAX_V]; //sからの距離
		int iter[MAX_V]; //どこまで調べ終わったか
		int dfs(int v, int t, int f){
			if(v == t) return f;
			used[v] = true;
			rep(i,G[v].size()){
				Edge &e = G[v][i];
				if(not used[e.to] && e.cap > 0){
					int d = dfs(e.to, t, min(f, e.cap));
					if(d > 0){
						e.cap -= d;
						G[e.to][e.rev].cap += d;
						return d;
					}
				}
			}
			return 0;
		}
		int dfs_(int v, int t, int f){
			if(v == t) return f;
			for(int &i = iter[v]; i < G[v].size(); i++){
				Edge &e = G[v][i];
				if(e.cap > 0 && level[v] < level[e.to]){
					int d = dfs_(e.to, t, min(f, e.cap));
					if(d > 0){
						e.cap -= d;
						G[e.to][e.rev].cap += d;
						return d;
					}
				}
			}
			return 0;
		}
		void bfs(int s){
			memset(level, -1, sizeof(level));
			queue<int> que;
			level[s] = 0;
			que.push(s);
			while(not que.empty()){
				int v = que.front(); que.pop();
				rep(i,G[v].size()){
					Edge &e = G[v][i];
					if(e.cap > 0 && level[e.to] < 0){
						level[e.to] = level[v] + 1;
						que.push(e.to);
					}
				}
			}
		}
	public:
		void addEdge(int from, int to, int cap){
			G[from].push_back(Edge(to, cap, static_cast<int>(G[to].size())));
			G[to].push_back(Edge(from, 0, static_cast<int>(G[from].size() - 1)));
		}
		int fordFulkerson(int s, int t){
			int flow = 0;
			while(true){
				memset(used, 0, sizeof(used));
				int f = dfs(s, t, INF);
				if(f == 0) return flow;
				flow += f;
			}
		}
		int dinic(int s, int t){
			int flow = 0;
			while(true){
				bfs(s);
				if(level[t] < 0) return flow;
				memset(iter, 0, sizeof(iter));
				int f;
				while( (f = dfs_(s, t, INF)) > 0){
					flow += f;
				}
			}
		}
};

signed main(){
	int n, m;
	string u;
	cin >> n >> m >> u;

	Flow f;

	int S = MAX_V - 2, T = S + 1;
	rep(i,n){
		int a;
		cin >> a;
		if(u[i] == 'R'){
			f.addEdge(S, i, a);
		}else{
			f.addEdge(i, T, a);
		}
	}

	rep(i,m){
		int s, t, b;
		cin >> s >> t >> b;
		s--; t--;
		if(s > t) swap(s,t);

		f.addEdge(s, t, b);
	}
	cout << f.dinic(S, T) << endl;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s, t;
    cin >> n >> s;
    if (s.size()&1) cout << "No" << '\n';
    else {
        int len = s.size()/2;
        for (int i = 0; i < len; ++i) {
            if (s[i] != s[i+len]) {
                cout << "No" << '\n';
                return 0;
            }
        }
        cout << "Yes" << '\n';

    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, x, min, max;
    cin >> a >> b >> c; 
    if(b < a){
        x = a;
        a = b;
        b = x;
    }
    if(c < b){
        x = b;
        b = c;
        c = x;
    }
    if(b < a){
        x = a;
        a = b; 
        b = x;
    }
    cout << a << " " << b << " " << c;
    cout << endl;
}


Measured memory_bytes: 3096
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# 入力が文字のリスト
# S = list(input().split())

#入力が数字のリスト
# A = list(map(int, input().split()))

# 入力がリストのリスト
# S = [list(input()) for i in range(H)]


# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b

A = int(input())
B = int(input())
C = int(input())
D = int(input())

if A < B:
    t = A
else:
    t = B

if C < D:
    b = C
else:
    b = D

print(t + b)

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

int main(){
  int N,D,X;
  cin>>N>>D>>X;
  int A[N];
  for (int i=0;i<N;i++){
    cin>>A[i];
  }

  int sum=0;
  for(int i=0;i<N;i++){
      int temp=0; 
    while(temp<D){
      sum=sum+1;
      temp=temp+A[i];
    }
  }
  cout<<sum+X<<endl;
  
  return 0;
}

    
    
      

Measured memory_bytes: 256
/*
AizuOnline A0054
Sum of Nth decimal places
*/
#include <stdio.h>
#include <ctype.h>

main()
{
  int a,b,n;
  int i,sum;
  
  while(EOF != scanf("%d %d %d",&a,&b,&n))
    {
      sum = 0;
      for(i=1;i<=n;i++)
        {
          /*printf("1:%d\n",a);*/
          sum += a * 10 / b % 10;
          /*printf("2:%d\n",a);*/
          a = a % b *10;
          /*printf("3:%d\n",a);*/
        }
      printf("%d\n",sum);
    }
return(0);
}

Measured memory_bytes: 0
# 幅優先探索
from collections import deque
H, W = map(int, input().split())
dif = [(-1, 0), (1, 0), (0, 1), (0, -1)]
Map = [list(input()) for i in range(H)]
visited = [[False for i in range(W)] for j in range(H)]
deq = deque()


def bfs(node):
    nx, ny = node
    deq.append(node)

    visited[nx][ny] = True
    distance = [[float("inf") for i in range(W)] for j in range(H)]
    distance[nx][ny] = 0
    while deq:
        x, y = deq.popleft()
        for dx, dy in dif:
            if 0 <= x+dx < H and 0 <= y+dy < W and Map[x+dx][y+dy] == "." and visited[x+dx][y+dy] == False:
                visited[x+dx][y+dy] = True
                distance[x+dx][y+dy] = distance[x][y]+1
                deq.append((x+dx, y+dy))
    return distance


def s_bfs(node):
    nx, ny = node
    deq.append(node)
    Visited = [[False for i in range(W)] for j in range(H)]
    Visited[nx][ny] = True
    distance = [[float("inf") for i in range(W)] for j in range(H)]
    distance[nx][ny] = 0
    while deq:
        x, y = deq.popleft()
        for dx, dy in dif:
            if 0 <= x+dx < H and 0 <= y+dy < W and Map[x+dx][y+dy] == "." and Visited[x+dx][y+dy] == False:
                Visited[x+dx][y+dy] = True
                distance[x+dx][y+dy] = distance[x][y]+1
                deq.append((x+dx, y+dy))
    return distance


ans = 1
roads = deque()
for i in range(H):
    for j in range(W):
        if Map[i][j] == ".":
            roads.append((i, j))

while roads:
    x, y = roads.popleft()
    if visited[x][y] == False:
        B = s_bfs((x, y))
        s = -1
        choice=[]
        most_far_distance = 0
        for i in range(H):
            for j in range(W):
                if B[i][j] != float("inf") and B[i][j] > most_far_distance:
                    most_far_distance = B[i][j]
        for i in range(H):
            for j in range(W):
                if B[i][j] == most_far_distance:
                    choice.append((i, j))

        for s in choice:
            C = s_bfs(s)
            for i in range(H):
                for j in range(W):
                    if C[i][j] != float("inf"):
                        ans = max(ans, C[i][j])
print(ans)


Measured memory_bytes: 93860
#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> march(5,0);
  for(int i=0;i<N;i++) {
    string s;
    cin >> s;
    if(s[0]=='M') march[0]++;
    if(s[0]=='A') march[1]++;
    if(s[0]=='R') march[2]++;
    if(s[0]=='C') march[3]++;
    if(s[0]=='H') march[4]++;
  }

  ll ans=0;
  for(int i=0;i<5;i++) {
    for(int j=i+1;j<5;j++) {
      for(int k=j+1;k<5;k++) {
        ans += (march[i]*march[j]*march[k]);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n), sum(n+1, 0);
    rep(i,n){
        cin >> a[i];
        sum[i+1] = sum[i] + a[i];
    }
    ll ans = 1LL << 60;
    for(int i = 3; i < n; ++i){
        int l = 2, r = i;
        ll l1, l2, r1, r2;
        while(r - l > 1){
            int mid = (l + r) / 2;
            if(sum[mid-1] >= sum[i-1] - sum[mid-1]) r = mid;
            else l = mid;
        }
        ll s1 = llabs(sum[l-1] * 2 - sum[i-1]);
        ll s2 = llabs(sum[l] * 2 - sum[i-1]);
        if(s1 < s2){
            l1 = sum[l-1];
            r1 = sum[i-1] - sum[l-1];
        }
        else{
            l1 = sum[l];
            r1 = sum[i-1] - sum[l];
        }
        l = i+1; r = n+1;
        while(r - l > 1){
            int mid = (l + r) / 2;
            if(sum[mid-1] - sum[i-1] >= sum[n] - sum[mid-1]) r = mid;
            else l = mid;
        }
        s1 = llabs(sum[l-1] * 2 -  sum[i-1] - sum[n]);
        s2 = llabs(sum[l] * 2 - sum[i-1] - sum[n]);
        if(s1 < s2){
            l2 = sum[l-1] - sum[i-1];
            r2 = sum[n] - sum[l-1];
        }
        else{
            l2 = sum[l] - sum[i-1];
            r2 = sum[n] - sum[l];
        }
        ll mi = min({l1, l2, r1, r2});
        ll mx = max({l1, l2, r1, r2});
        chmin(ans, mx - mi);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6372
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main()
{
	int n, ans;
	cin >> n;
	if(n%2 == 0) ans = n;
	else ans=n*2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize,
        w: usize,
        s: [chars; h]
    }
    let xy = [
        // [-1i32, 1i32],
        [0i32, 1i32],
        // [1i32, 1i32],
        [-1i32, 0i32],
        [1i32, 0i32],
        // [-1i32, -1i32],
        [0i32, -1i32],
        // [1i32, -1i32],
    ];
    let mut s = s;
    for y in 0..h {
        for x in 0..w {
            if s[y][x] == '.' {
                continue;
            }
            let mut b = false;
            for i in 0..4 {
                let xx = x as i32 + xy[i][0] as i32;
                let yy = y as i32 + xy[i][1] as i32;
                if xx < 0 || w as i32 <= xx {
                    continue;
                }
                if yy < 0 || h as i32 <= yy {
                    continue;
                }
                if s[yy as usize][xx as usize] == '#' {
                    b = true;
                }
            }
            if !b {
                println!("No");
                return;
            }
        }
    }
    println!("Yes")
}


Measured memory_bytes: 4352
//ALLAH bachiye naw plz,amr 1400+ rating tulai daw plzz
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ll long long
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)
int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //testcase {
    int n,k;
    cin>>n>>k;
    vector<int>v;
    for(int i=0;i<n;i++) {
      int q;
      cin>>q;
      v.pb(q);
    }
    sort(v.begin(),v.end());
    int s=0;
    for(int i=0;i<k;i++) {
      s+=v[i];
    }
    cout<<s;
  //}
  return 0;
} 

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a1[3];
    int m = 0;
    int n = 0;
    for (int i = 0; i< 3; i++){
        cin>> a1[i];
    }
    for (int i = 0; i< 3; i++){
        m++;
        for(int j = 0; j<3; j++ ){
            if (j==i){
                continue;
            }
            else {
                if (a1[i]==a1[j]){
                    n++;
                }
                
            }
            
        }
        if (n == 1){
            m = 2;
            break;
        }
        if (n==2){
            m = 1;
            break;
        }
    }
    cout << m;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define MAX 50
  
int N, day;
bool ok[MAX][31];
bool visited[MAX];
  
void init(){
  day = 0;
  memset(ok, false, sizeof(ok));
}
  
int solve(){
  int ans = -1;
  set<int> dp[MAX];
 
  for(int i = 0 ; i < N ; i++){
    dp[i].insert(i);
  }
 
  for(int i = 0 ; i <= day ; i++){
    for(int j = 0 ; j < N-1 ; j++){
      if(!ok[j][i]) continue;
      for(int k = j+1 ; k < N ; k++){
        if(ok[k][i]){
          set<int>::iterator it;
          for(it = dp[j].begin() ; it != dp[j].end() ; ++it){
            dp[k].insert(*it);
          }
          for(it = dp[k].begin() ; it != dp[k].end() ; ++it){
            dp[j].insert(*it);
          }
        }
      }
    }
    for(int j = 0 ; j < N ; j++){
      if(dp[j].size() == N) return i+1;
    }
  }
  return ans;
}
  
int main(){
  int K, in;
  while(cin >> N && N){
    init();
    for(int i = 0 ; i < N ; i++){
      cin >> K;
      for(int j = 0 ; j < K ; j++){
        cin >> in;
        ok[i][in-1] = true;
        day = max(day, in);
      }
    }
    cout << solve() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1312
x1,x2,x3,x4,x5 = input().split()

if int(x1) == 0:
  print(1)
elif int(x2) == 0:
  print(2)
elif int(x3) == 0:
  print(3)
elif int(x4) == 0:
  print(4)
else:
  print(5)



Measured memory_bytes: 9036
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define gcd __gcd
#define int long long
#define ull unsigned long long

using namespace std;

typedef pair<int, int> pii;

const int MAX = 3010;
int a[MAX], dp[MAX][MAX][2];

main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0 ; i < n ; i++){
		cin >> a[i];
	}
	for (int i = 0 ; i < n ; i++){
		dp[i][i][0] = a[i];
		dp[i][i][1] = - a[i];
	}
	for (int i = 1 ; i < n ; i++){
		for (int j = 0 ; j + i < n ; j++){
			dp[j][j + i][0] = max (dp[j][j + i - 1][1] + a[j + i] , dp[j + 1][j + i][1] + a[j]);
			dp[j][j + i][1] = min (dp[j][j + i - 1][0] - a[j + i] , dp[j + 1][j + i][0] - a[j]);
		}
	}
	cout << dp[0][n - 1][0];
}

Measured memory_bytes: 141568
#include <iostream>
#include <cstdlib>
#include <string>
#include <stack>
using namespace std;

int main() {

    stack<int> S;
    int a,b,x;
    string s;

    while(cin>>s){
        if(s=="+"){
            a = S.top();
            S.pop();
            S.top()+=a;
        }else if(s=="-"){
            b = S.top();
            S.pop();
            a = S.top();
            S.pop();
            S.push(a-b);
        }else if(s=="*"){
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(a*b);
        }else{
            S.push(atoi(s.c_str()));
        }


    }
    cout<<S.top()<<endl;

    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int m = a[0] + (k - a[n - 1]);
    for (int i = 1; i < n; ++i)
        m = max(m, a[i] - a[i - 1]);
    cout << k - m;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using lb=long double;
using db=double;
const ll mod=1e9+7;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define INF 1e10+7
using namespace std;
typedef double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>ii;
const int MAXN=100011;
int a[MAXN],vis[MAXN];
int main()
{
    int n;
    cin>>n;
    memset(vis,0,sizeof(vis));
    a[1]=1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    int temp=a[1];
    int times=n;
    bool f=false;
    while(times--)
    {
        vis[temp]=1;
        temp=a[temp];
        if(vis[2]==1)
        {
            f=true;
            break;
        }
    }
    if(f)
        cout<<n-times<<endl;
    else
        cout<<-1<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
typedef long long ll;
ll n,k;
int main() {
	scanf("%lld%lld",&n,&k);
	n %= k;
	printf("%lld\n",min(n,k - n));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

const int mod = 1e9 + 7;

long long sum(long long x) {
	return x * (x + 1) / 2;
}


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

	long long ans = 0;
	for (int i = k; i <= n + 1; i++) {
		long long a = sum(i - 1);
		long long b = sum(n) - sum(n - i);

		// printf("k %2lld: %5lld %5lld\n", k, a, b);

		ans += b - a + 1;
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3160
void main() {
	auto S = rs, T = rs;
	foreach(i; 0..S.length) {
		string tmp = S[1..$];
		tmp ~= S[0];
		if(S == T) {
			writeln("Yes");
			return;
		}
		S = tmp;
	}
	writeln("No");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

UL N;
UL A[200000] = {};
UL X = 0;

int main() {
	scanf("%u", &N);
	rep(i, N) {
		scanf("%u", &A[i]);
		X ^= A[i];
	}
	rep(i, N) {
		if (i) printf(" ");
		printf("%u", X ^ A[i]);
	}

	return 0;
}


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

using namespace std;

int main()
{
	string s;

	cin >> s;

	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int n ;
    cin >> n ;
    int zero = 0, two = 0, shit = 0 ;
    for(int i = 0 ; i < n ; i ++)
    {
        int a ;
        cin >> a;
        a = a%4 ;
        if(a == 0)
            zero ++ ;
        else if(a == 2)
            two ++ ;
        else
            shit++ ;
    }
    //cout << zero << " " << two << " " << shit << endl ;
    if(shit >= 1 && zero == 0 )
    {
        //cout << " lol" << endl ;
        cout << "No" << endl ;
    }
    else
    {
        if(shit <= (zero+1))
        {
            if(two % 2 == 0)
                cout << "Yes" << endl ;
            else
            {
                if(shit <= (zero) )
                    cout << "Yes" << endl ;
                else
                    cout << "No" << endl ;
            }
        }
        else
            cout << "No" << endl ;
    }

}


Measured memory_bytes: 256
a,b = list(map(int,input().split()))

# def gcd(a, b):
#     if b == 0:
#         return a
#     else:
#         return gcd(b, a % b)

def factorize(n):
    b = 2
    factor=[]
    while b * b <= n:
        while n % b == 0:
            n //= b
            factor.append(b)
        b += 1
    if n > 1:
        factor.append(n)
    return factor

while b:
    a, b = b, a % b

print(len(set(factorize(a)))+1)

Measured memory_bytes: 3060
#include <iostream>
#define MAX 10000
#define NIL -1
using namespace std;

struct Node{
  int parent;
  int left;
  int right;
};

int setHeight(int);
void setDepth(int,int);
int getSibling(int);
void print(int);

struct Node T[MAX];
int n,A[MAX],H[MAX];

int main(){
  int v,l,r,i;
  int root = 0;
  cin >> n;
  for(i = 0; i < n; i++){
    T[i].parent = NIL;
  }
  for(i = 0; i < n; i++){
    cin >> v >> l >> r;
    T[v].left = l;
    T[v].right = r;
    if(l != NIL){
      T[l].parent = v;
    }
    if(r != NIL){
      T[r].parent = v;
    }
  }
  for(i = 0; i < n; i++){
    if(T[i].parent == NIL){
      root = i;
    }
  }
  setDepth(root,0);
  setHeight(root);
  for(i = 0; i < n; i++){
    print(i);
  }
  return 0;
}//end of main func


void setDepth(int u,int d){
  if( u == NIL){
    return;
  }
  A[u] = d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}


int setHeight(int u){
  int h1 = 0;
  int h2 = 0;
  if(T[u].left != NIL){
    h1 = setHeight(T[u].left)+1;
  }
  if(T[u].right != NIL){
    h2 = setHeight(T[u].right)+1;
  }
  return H[u] = (h1 > h2 ? h1 : h2);
}


int getSibling(int u){
  if(T[u].parent == NIL){
    return NIL;
  }
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL){
    return T[T[u].parent].left;
  }
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL){
    return T[T[u].parent].right;
  }
  return NIL;
}


void print(int u){
  int degree = 0;
  cout << "node " << u <<": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "sibling = " << getSibling(u) << ", ";

  if(T[u].left != NIL){
    degree++;
  }
  if(T[u].right != NIL){
    degree++;
  }
  cout << "degree = " << degree << ", ";
  cout << "depth = " << A[u] << ", ";
  cout << "height = " << H[u] << ", ";
  if(T[u].parent == NIL){
    cout << "root" << endl;
  }
  else if(T[u].left == NIL && T[u].right == NIL){
    cout << "leaf" << endl;
  }
  else{
    cout << "internal node" << endl;
  }
}

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

int main(){
    char s[55][55];
    int h,w;cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>s[i][j];
        }
    }

    bool flag = 0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#' && s[i-1][j]!='#' && s[i][j-1]!='#' && s[i+1][j]!='#' && s[i][j+1]!='#') flag = 1;
        }
    }
    if(flag) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

    

    return 0;
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl



signed main() {
    int N, M;
    cin >> N >> M;
    priority_queue<pi, vector<pi>, greater<pi> > Q1;
    priority_queue<pi> Q2;
    REP(i, N) {
        int a, b; 
        cin >> a >> b;
        Q1.push(mp(a, b));
    }

    int ans = 0;
    int day = 1;
    while (day <= M) {
        while (!Q1.empty()) {
            pi p = Q1.top();
            if (p.first > day) break;
            Q1.pop();
            Q2.push(mp(p.second, p.first));
        }
        if (!Q2.empty()) {
            pi p = Q2.top(); Q2.pop();
            ans += p.first;
        }
        day++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2548
// abc166_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  string s;
  cin>>s;
  if (s=="ARC") cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;
  return 0;
}


Measured memory_bytes: 3628
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int n,m;cin>>n>>m;
	int a[n];
	int sum=0;
	fo0(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	double t=1.0*sum/(4*m);
	int cnt=0;
	fo0(i,n){
		if(a[i]>=t){
			cnt++;
		}
	}
	if(cnt>=m){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 256
//#pragma GCC optimize(2)
//#pragma comment(linker, "/STACK:102400000,102400000")

#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
#define rrep(i, beg, end) for (int i = (beg); i >= (end); i--)
#define sp(i) setprecision(i) << fixed
typedef long long ll;
typedef pair<ll, ll> P;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const int N = 1010;
ull p_hash(ull x, ull y) { return (x + y) * (x + y + 1) / 2 + y; } //NxN->N
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int p[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin >> n;
    ll m = n;
    int ans = 0;
    rep(i, 2, m / i + 1)
    {
        if (n % i == 0)
        {
            int j = i;
            while (n % j == 0)
            {
                ans++;
                n /= j;
                j *= i;
            }
            while (n % i == 0)
            {
                n /= i;
            }
        }
    }

    if (n > 1)
        ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string.h>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>
#include <set>
 
using namespace std;
 
int main( void ) {

    int r;
    cin >> r;

    r = r <= 1 ? 1 : r * r;
    cout << r << endl;
    
    return 0;
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  ll n; cin >> n;
  ll ans = LLONG_MAX;
  for(ll i=1; i*i<=n; i++) {
    if (n%i==0) {
      ll j = n/i;
      chmin(ans, i+j-2);
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}




int main() {
    READ(0);
    ll n,d,a;cin>>n>>d>>a;
    vector<pair<ll,ll>> x(n);
    FOR(i,n) cin>>x[i].first>>x[i].second;
    sort(x.begin(),x.end());
    int idx=0;
    ll bombs=0;
    set<pair<ll,ll>> hh;
    ll acum=0;
    while(idx<n){
        while (!hh.empty() && hh.begin()->first<x[idx].first){
            acum -= hh.begin()->second;
            hh.erase(hh.begin());
        }
        if (acum>=x[idx].second){++idx;continue;}
        int b = (x[idx].second-acum)/a + ((x[idx].second-acum)%a != 0);
        bombs += b;
        hh.emplace((ll)x[idx].first+d*2,a*b);
        acum += a*b;
        ++idx;
    }
    cout << bombs;


}



Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=1000000007;

int main() {
  int64_t N,K,ans=0,zero=0;
  cin>>N>>K;
  if(K==0) ans=N*N;
  else{
    for(int b=K+1;b<=N;b++){
    ans+=(b-K)*(N/b);
    if(N%b>=K) ans+=N%b-K+1;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    lint ans = LINF;
    lint num = 1;
    REP(i, n+1){
        int a = i;
        int b = n - i;
        num = 1;
        REP(j, a){
            num *= 2;
        }
        REP(j, b){
            num += k;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
int count(int n){
    int cnt=0;
    for(int i=1; i<=n; i++){
        if(n%i==0)cnt++;
    }
    return cnt;
}
int main(){
    int k,n;
    cin >> k >> n;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int diff=0,now;
    for(int i=0; i<n-1; i++){
        if(diff<a[i+1]-a[i]){
            diff = a[i+1]-a[i];
        }
    }
    if(diff<a[0]+(k-a[n-1])){
        diff=a[0]+(k-a[n-1]);
    }

    cout << k-diff << endl;

    return 0;
}




Measured memory_bytes: 1024