akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>







#define typ int


const int N = 1e5 + 10;
int prnt[N];
typ d[N];
bool vst[N];
vector<pair<int,int>>adj[N];
priority_queue<pair<typ,int>,vector<pair<typ,int>>,greater<pair<typ,int>>>q;
pair<typ,int>p;

void runDijkstraAlg(int s,int n)
{
	for(int i=1;i<=n;i++)
	{
		d[i]=-1;
		vst[i]=false;
	}
	d[s]=0;
	p.first=d[s];
	p.second=s;
	q.push(p);
	while(!q.empty())
	{
		p=q.top();
		int u=p.second;
		q.pop();
		if(vst[u])continue;
		vst[u]=true;
		for(int i=0,v,w;i<adj[u].size();i++)
		{
			v=adj[u][i].first;
			w=adj[u][i].second;
			if(d[v]==-1 || d[u]+w<d[v])
			{
				prnt[v]=u;
				d[v]=d[u]+w;
				p.first=d[v];
				p.second=v;
				q.push(p);
			}
		}
	}
}







int n, m, u, v;





void solve()
{
	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		cin >> u >> v;
		adj[u].pb(mp(v, 1));
		adj[v].pb(mp(u, 1));
	}
	runDijkstraAlg(1, n);
	for(int i = 2; i <= n; i++)
	{
		if(d[i] == -1)
		{
			cout << "No\n";
			return;
		}
	}
	cout << "Yes\n";
	for(int i = 2; i <= n; i++)
	{
		cout << prnt[i] << "\n";
	}
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 13588
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int n, m; cin >> n >> m&&n;) {
		int s, g; cin >> s >> g;
		vector<vector<double>> D(n + 1, vector<double>(n + 1, INF));
		vector<vector<int>> C(n + 1, vector<int>(n + 1, 0));
		rep(i, 0, m) {
			int x, y, d, c; cin >> x >> y >> d >> c;
			D[x][y] = D[y][x] = d;
			C[x][y] = C[y][x] = c;
		}
		static double dp[33][33][33];
		rep(i, 0, 33)rep(j, 0, 33)rep(k, 0, 33)dp[i][j][k] = INF;
		using T = tuple<int, int, int>;
		queue<T> q;
		dp[s][0][0] = 0;
		q.emplace(s, 0, 0);
		while (q.size()) {
			int cur, prev, e;
			tie(cur, prev, e) = q.front(); q.pop();
			rep(next, 1, n + 1) {
				if (next == prev)continue;
				if (C[cur][next] == 0)continue;
				rep(k, e - 1, e + 2) {
					if (k <= 0)continue;
					if (C[cur][next] < k)continue;
					if (chmin(dp[next][cur][k], dp[cur][prev][e] + D[cur][next] / k))
						q.emplace(next, cur, k);
				}
			}
		}
		double ans = INF;
		rep(i, 1, n + 1) {
			if (chmin(ans, dp[g][i][1]))dump(ans);
		}
		cout << fixed << setprecision(10);
		if (ans == INF) {
			cout << "unreachable" << endl;
		}
		else {
			cout << ans << endl;
		}
	}
	return 0;
}

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

#define INF 1e9
using namespace std;

int main() {

    vector<int> t(5);
    for (int i = 0; i < 5; ++i) {
        cin >> t[i];
    }

    int ans = 0;

    int min_amari = INF;
    int min_j = INF;

    for (int j = 0; j < 5; ++j) {
        if (t[j] % 10 > 0) {
            if (min_amari > t[j] % 10) {
                min_amari = t[j] % 10;
                min_j = j;
            }
        }
    }

    for (int k = 0; k < 5; ++k) {
        if (k == min_j) {
            ans += t[k];
        } else {
            if (t[k] % 10 == 0) {
                ans += t[k];
            } else {
                ans += ((t[k] / 10) + 1) * 10;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : abc111a.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	map<char, string> mp;
	mp['1'] = "9";
	mp['9'] = "1";

	string s;
	cin >> s;
	for(int i = 0; i < s.length(); ++i){
		if(s[i] == '9')s[i] = '1';
		else s[i] = '9';
	}
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
 
class Program {
  static void Main()
  {    
    int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int N = n[0];
    string[] S = new string[N];
    for (int i = 0; i < N; i++) {
      S[i] = Console.ReadLine();
    }
    S = S.OrderBy(x => x).ToArray();
    string ans = "";
    for (int i = 0; i < N; i++) {
      ans += S[i];
    }
    Console.WriteLine(ans);   
  }
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    
    map<string, int> M;
    for(int i = 0; i < n; i++){
        sort(s[i].begin(), s[i].end());
        M[s[i]]++;
    }

    long long ans = 0;
    for(auto P : M){
        ans += (long long)P.second * (P.second - 1) / 2;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 18176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,s;
    cin >> n;
    vector<int> x,cmp;
    int cnt=0;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s%10!=0){
            cmp.push_back(s);
        }
        if(s%10==0){
            cnt++;
        }
        x.push_back(s);
    }
    if(cnt==x.size()){
        cout << 0 << endl;
        return 0;
    }
    sort(x.begin(),x.end());
    sort(cmp.begin(),cmp.end());
    int ans=accumulate(x.begin(),x.end(),0),i=0;
    while(1) {
        if(ans%10==0 && ans-cmp[i]%10!=0){
            ans-=cmp[i];
            i++;
        }
        else if (ans%10!=0 || ans==0){
            break;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::i64;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let n: i64 = read();
    for _i in 0..n{
	let a: i64 = read();
	if a%2 == 0{
	    if a%3!=0 && a%5!=0 {
		println!("DENIED");
		return;
	    }
	}
    }
    println!("APPROVED");
	
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(){
  int x,y,c=1;
  int i;
  
  scanf("%d %d",&x,&y);
 
  if(y>x){
    i=x;
    x=y;
    y=i;
  }

  while(1){
    c=x%y;
    if(c==0) break;
    else{
      x=y;
      y=c;
    }
  }

  printf("%d\n",y);

  return 0;
}



Measured memory_bytes: 2084
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define INF 1e18
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int A,B,Q;
  cin>>A>>B>>Q;
  vll s(A+2),t(B+2),x(Q),ans(Q);
  s[0] = -INF;s[A+1]=INF;t[0]=-INF;t[B+1]=INF;
  vector<ll>::iterator nears,neart;
  REP2(i,1,A+1) cin >> s[i];
  REP2(i,1,B+1) cin >> t[i];
  REP(i,Q){
    cin >> x[i];
    nears = lower_bound(ALL(s),x[i]);
    neart = lower_bound(ALL(t),x[i]);
    ll ans1 = max(x[i]-*(nears-1),x[i]-*(neart-1));
    ll ans2 = max(*nears-x[i],*neart-x[i]);
    ll ans3 = 2*(*nears-x[i])+x[i]-*(neart-1);
    ll ans4 = 2*(*neart-x[i])+x[i]-*(nears-1);
    ll ans5 = 2*(x[i]-*(nears-1))+*neart-x[i];
    ll ans6 = 2*(x[i]-*(neart-1))+*nears-x[i];
    ans[i] = min({ans1,ans2,ans3,ans4,ans5,ans6});
  }


  REP(i,Q) cout << ans[i] << "\n";

  return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<ll> s(n);
    rep(i, 0, n) cin >> s[i];

    ll ans = 0;
    rep(c, 1, n)
    {
        ll score = 0;
        set<int> idx_set;
        int l = 0, r = n - 1;
        rep(x, 0, n)
        {  
            ll a = n - 1 - x * c;
            // ll b = a - c;
            if (a < c) break;
            if (x*c>= n) break;
            
            if (idx_set.count(n-1-x*c) > 0)
                break;
            idx_set.insert(n-1-x*c);

            if (idx_set.count(x*c) > 0)
                break;
            idx_set.insert(x*c);


            score += s[x*c];
            score += s[n-1-x*c];
            
            ans = max(ans, score);
            // cout << c << ' ' << x << ' ' << score << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define endl '\n'
#define sz(x) ((int)(x.size()))

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

	long long n, k;
	cin >> n >> k;
	long long p[n+1], c[n+1];
	for(int i=1; i<=n; i++) cin >> p[i];
	for(int i=1; i<=n; i++) cin >> c[i];
	bool seen[n+1];
	long long ans = -1e18;
	for(int i=1; i<=n; i++) {
		int ptr = i;
		long long tot = 0;
		vector <long long> v;
		memset(seen, 0, sizeof seen);
		while(!seen[ptr]) {
			seen[ptr] = 1;
			v.push_back(c[ptr]);
			tot += c[ptr];
			ptr = p[ptr];
		}
		long long cc = 0;
		for(int i=0; i<sz(v); i++) {
			cc += v[i];
			if(i+1 <= k) ans = max(ans, cc);
			else break;
			ans = max(ans, cc + (k - i - 1) / sz(v) * tot);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3816
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int n = sc.nextInt();
		int k = sc.nextInt()-1;
		String str = sc.next();
		
		StringBuffer sb = new StringBuffer(str);
		char cc = str.toLowerCase().charAt(k);
		sb.setCharAt(k, cc);
		System.out.print(sb.toString());
		
		
		
		
	}
	
	
	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	




static String deletestr(String base,String remove){
	boolean flag = true;
	for(int i = 0;i < remove.length();i++){
		if(i == base.length()){
			flag = false;
			break;
		}
		if(base.charAt(i) - remove.charAt(i) != 0 && base.charAt(i) - remove.charAt(i) != 32 &&remove.charAt(i) - base.charAt(i)  != 32){
			flag = false;
			break;
		}
	}

	if(flag){
		base = base.substring(remove.length());
	}

	return base;

}



}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




Measured memory_bytes: 24020
#include<iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] >= 'D') {
            s[i] -= 3;
            cout << s[i];
        } else {
            if (s[i] == 'A') {
                cout << 'X';
            } else if (s[i] == 'B') {
                cout << 'Y';
            } else {
                cout << 'Z';
            }
        }
    }
    cout << endl;
}



Measured memory_bytes: 3208
def solve():
    answers = []
    ans = []
    def square(n, rest, limit):
        if rest == 0:
            answers.append(' '.join(map(str, ans)))
        else:
            for i in range(rest, 0, -1):
                if i > limit:
                    continue
                ans.append(i)
                square(n, rest - i, i)
                ans.pop()
    
    import sys
    for n in map(int, sys.stdin.readlines()):
        if n == 0:
            break
        square(n, n, n)
    
    print('\n'.join(answers))

solve()


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

const int MAX_N = 2e5 + 10, MOD = 1e9 + 7;
int B, W, n;
int sumW[MAX_N];
int sumB[MAX_N];
int F[MAX_N];

int _sum (int a, int b) {
	int c = a + b;
	
	if (MOD <= c)
		c -= MOD;
		
	return c;
}

int _sub (int a, int b) {
	int c = a - b;
	
	if (c < 0)
		c += MOD;
		
	return c;
}

int _mul (int a, int b) {
	int c = 1LL * a * b % MOD;
	
	return c;
}

int _pow (int a, int b) {
	if (!b)
		return 1;
		
	int res = _pow(a, b >> 1);
	res = _mul(res, res);
	
	if (b & 1)
		res = _mul(res, a);
		
	return res;
}

int _choose (int a, int b) {
	if (a < 0 || b < a)
		return 0;
		
	int c = _mul(F[b], _mul(_pow(F[a], MOD - 2), _pow(F[b - a], MOD - 2)));
	return c;
}

void pre_process() {
	F[0] = 1;
	for (int i = 1; i < MAX_N; i++)
		F[i] = _mul(i, F[i - 1]);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	pre_process();
	
	cin >> B >> W;
	n = B + W;
	
	for (int i = W - 1; i < n - 1; i++) {
		int s = _mul(_choose(W - 1, i), _pow(_pow(2, i + 1), MOD - 2));
		sumW[i + 1] = s;
	}
	
	
	for (int i = B - 1; i < n - 1; i++) {
		int s = _mul(_choose(B - 1, i), _pow(_pow(2, i + 1), MOD - 2));
		sumB[i + 1] = s;
	}
	
	int w = 0, b = 0;
	for (int i = 0; i < n; i++) {
		w = _sum(w, sumW[i]);
		b = _sum(b, sumB[i]);
		int s = _sub(_sub(1, w), b);
		
		
		cout << _sum(w, _mul(s, _pow(2, MOD - 2))) << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 3840
"use strict";
function main(input) {
    var line = input.split(/\r?\n/g);
    var arr = line[0].split(" ");
    const H = arr[0], N = arr[1];
    var A = line[1].split(" ");
    var accum = 0;
    for (var i = 0; i < A.length; i++)
        accum += parseInt(A[i]);
    console.log(accum < H ? "No" : "Yes");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

#define ll long long int
int main()
{



ll x , n ;
cin>>x >>n  ;

set<ll> arr ;
for(ll i=0;i<n;i++)
{
    ll s ;
    cin>>s ;
    arr.insert(s) ;
}

for(ll st = 0 ; ; st++)
{

    if(arr.count(x-st)==0)
    {

        cout<<x-st<<endl;
        return 0 ;
    }

    if(arr.count(x+st)==0)
    {

        cout<<x+st<<endl;
        return 0 ;

    }
}


}


Measured memory_bytes: 3608
my $N = <>;
my $sum =0;
for(my $i=1;$i<=sqrt($N);$i++){
    my $j = int($N/$i);
    $sum +=  $i*($j*($j+1)/2 ); 
    if($i!=$j){
      my $k = int($N/($i+1)); 
      $sum +=  ($i*($i+1)/2)* ($j*($j+1)/2 - $k*($k+1)/2); 
    }
}    
print "$sum";

Measured memory_bytes: 4672
#!/usr/bin/env python
# -*- coding: utf-8 -*-


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

  if (b - a) % 2 == 0:
    print((b - a) // 2)
  else:
    print(min(a, n - b + 1) + (abs(b - a) - 1) // 2)


if __name__ == '__main__':
  main()


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int main(){
	int n;
	long long temp;
	long long ans;
	cin >> n;
	
	ans = 0;
	for(int i=1;i<=n;i++){
		cin >> temp;
		temp--;
		ans +=temp;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
//#define Local
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 2e5 + 5;

int n;
int a[N];

void run() {
    for(int i = 1; i <= n; i++) cin >> a[i], a[i] -= i;
    sort(a + 1, a + n + 1);
    int p = a[(n + 1) / 2];
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += abs(p - a[i]);
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
#ifdef Local
    freopen("../input.in", "r", stdin);
    freopen("../output.out", "w", stdout);
#endif
    while(cin >> n) run();
    return 0;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

const int INF = 1e9;

struct RMQ {
  int n;
  int dat[2 * (1 << 17) - 1];  // 2 * 131072
  RMQ(int n_) { init(n_); }

  void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    REP(i, 2 * n - 1) dat[i] = INF;
  }

  void update(int k, int a) {
    k += n - 1;
    dat[k] = a;
    while (0 < k) {
      k = (k - 1) / 2;
      dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  int query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) {
      return dat[k];
    } else {
      int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return min(vl, vr);
    }
  }

  int query(int a, int b) { return query(a, b, 0, 0, n); }
};

int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  RMQ rmq(n + 1);
  REP(i, n + 1) {
    if (s[i] == '0') rmq.update(i, i);
  }
  vector<int> pos;
  int p = n;
  pos.push_back(p);
  while (0 < p) {
    int nxt = rmq.query(max(0, p - m), p + 1);
    if (p == nxt) {
      cout << -1 << endl;
      return 0;
    }
    pos.push_back(nxt);
    p = nxt;
  }
  reverse(ALL(pos));
  REP(i, pos.size()) {
    if (i == 0) continue;
    cout << pos[i] - pos[i - 1] << " ";
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 2168
N, X, T = map(int, input().split())
count = 1
check = X
if X > 1:
    while True:
        value = int(N / X)
        re = N % X
        if re == 0:
            count = value
            TotalTime = T * count
            break
        else:
            count += value
            TotalTime = T * count
            break
else:
    TotalTime = T * N

print(TotalTime)

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    char c;
    cin >> c;
    string ans;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        ans = "vowel";
    } else {
        ans = "consonant";
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P){
	int i = 0;
	for(int j = 0 ; j < k ; ++j ){
		llong s = 0;
		while( s + T[i] <= P){
			s += T[i];
			++i;
			if( i == n)
				return n;
		}
	}
	return i;
}

int solve(){
	llong left = 0;
	llong right = 10000*100000;
	llong mid;
	while(left < right){
		mid = (left + right) / 2;
		int v = check(mid);
		if( v >= n) right = mid;
		else left = mid + 1;
	}
	return right;
}

int main(){
	cin >> n >> k;
	for(int i = 0 ; i < n ; ++i ){
		cin >> T[i];
	}
	llong ans = solve();
	cout << ans << endl;
}


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

int main()
{
    ll N;
    ll X[5];
    cin >> N;
    rep (i, 5) {
        cin >> X[i];
    }
    ll minV = pow(10, 16);
    rep(i, 5) {
        if (minV > X[i]) {
            minV = X[i];
        }
    }
    ll total = (N / minV);
    if (N % minV > 0) {
        total += 1;
    }
    total += 4;
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	double d,t,s;
	cin>>d>>t>>s;
	double x=d/s;
	if(t>=x){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <cmath>
#define pb push_back
#define MAX 100100

using namespace std;

int main(){
    int n;
    int aux;
    vector<int> p;
    int dp[MAX];
    p.pb(0);
    
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &aux);
        p.pb(aux);
    }
    memset(dp, 0, sizeof dp);
    dp[2] = abs(p[1] - p[2]);
    for(int i = 3; i <= n; i++){
        dp[i] = min(dp[i - 2] + abs(p[i - 2] - p[i]), dp[i - 1] + abs(p[i - 1] - p[i]));
    }
    printf("%d\n", dp[n]);
    
    
    return 0;
}

Measured memory_bytes: 1144
def solve_for_01(nums):
    # nums: 各要素が 0 or 1 のリスト。
    # 「x_{i+1, j} = x_{i, j} ^ x_{i, j+1} で定義。x_{N, 1} は？」という問題を解く。
    # a_{i} は (N-1)_C_i 回作用するので、(N-1)_C_i の偶奇で a_{i} が残るか否かが決まる。
    # (N-1)_C_i の偶奇については Lucasの定理から
    #   (N-1) & i == i <=> 奇数
    #   (N-1) & i != i <=> 偶数
    # が言える。
    N = len(nums)
    ans = 0
    for i, x in enumerate(nums):
        if (N - 1) & i == i:
            ans ^= x
    return ans


def main():
    # ref: https://atcoder.jp/contests/agc043/submissions/16398495
    N = int(input())
    A = list(map(lambda x: int(x) - 1, input()))
    if 1 in A:
        # 1が含まれる場合は答えは0 or 1になる。
        # 答えの偶奇だけ合致してればよいので、2 -> 0で置き換えて問題を解いてもこのケースでは大丈夫。
        print(solve_for_01([a % 2 for a in A]))
    else:
        # 1が含まれない場合はすべての数字は0 or 2。
        # 2で割ることで、すべての数字が0 or 1のケースに帰着可能。
        print(solve_for_01([a // 2 for a in A]) * 2)


if __name__ == '__main__':
    main()

Measured memory_bytes: 26268
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char S[200002];
char T[100002];
int Slen;
int Tlen;
int nx[26][200002];
int main(){
  int c, i, j, k;
  long long res;
  Slen = rd(S);
  Tlen = rd(T);
  for(i=0;i<(Slen);i++){
    S[i] -= 'a';
  }
  for(i=0;i<(Tlen);i++){
    T[i] -= 'a';
  }
  for(i=0;i<(Slen);i++){
    S[i+Slen] = S[i];
  }
  for(k=0;k<(26);k++){
    nx[k][2*Slen-1] = 1073709056;
    for(i=2*Slen-2;i>=0;i--){
      nx[k][i] = nx[k][i+1];
      if(S[i+1]==k){
        nx[k][i] = i+1;
      }
    }
  }
  k = Slen-1;
  res = -1;
  for(i=0;i<(Tlen);i++){
    c = T[i];
    if(nx[c][k]==1073709056){
      wt_L(-1);
      wt_L('\n');
      return 0;
    }
    k = nx[c][k];
    if(k >= Slen){
      k -= Slen;
      res++;
    }
  }
  res = res * Slen + k + 1;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190820-1

// --- original code ---
// char S[200002], T[100002];
// int Slen, Tlen;
// 
// int nx[26][200002];
// 
// {
//   int i, j, k, c;
//   ll res;
// 
//   rd(S@Slen, T@Tlen);
// 
//   rep(i,Slen) S[i] -= 'a';
//   rep(i,Tlen) T[i] -= 'a';
//   rep(i,Slen) S[i+Slen] = S[i];
// 
//   rep(k,26){
//     nx[k][2Slen-1] = int_inf;
//     for(i=2Slen-2;i>=0;i--){
//       nx[k][i] = nx[k][i+1];
//       if(S[i+1]==k) nx[k][i] = i+1;
//     }
//   }
// 
//   k = Slen-1;
//   res = -1;
//   rep(i,Tlen){
//     c = T[i];
//     if(nx[c][k]==int_inf){ wt(-1); return 0; }
//     k = nx[c][k];
//     if(k >= Slen) k -= Slen, res++;
//   }
//   res = res * Slen + k + 1;
//   wt(res);
// }


Measured memory_bytes: 20864
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, q, i;
    scanf("%d", &n);
    vector<int> a(n);
    for(i = 0; i < n; i++) scanf("%d", &a.at(i));
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        int v;
        scanf("%d", &v);
        if(binary_search(a.begin(), a.end(), v)) printf("%d\n", 1);
        else printf("%d\n", 0);
    }
}


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

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  long double a, b, h, m;
  cin >> a >> b >> h >> m;

  h += m / 60;

  long double r1 = 30 * h * M_PI / 180, r2 = 6 * m * M_PI / 180;
  long double x1 = cos(r1) * a, y1 = sin(r1) * a;
  long double x2 = cos(r2) * b, y2 = sin(r2) * b;
  cout << fixed << setprecision(10);
  cout << sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) << endl;

  return 0;
}

Measured memory_bytes: 4184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
    long n, a, b;

    std::cin >> n >> a >> b;
    long ans = (n / (a + b)) * a + (n % (a + b) < a ? (n % (a + b)) : a);

    std::cout << ans << std::endl;
}

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

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

    int m, f, r;
    int sum = 0;
    while (1) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) {
            break ;
        }
        sum = m + f;
        if (m == -1 || f == -1) {
            cout << 'F' << '\n';
        } else if (sum >= 80) {
            cout << 'A' << '\n';
        } else if (sum >= 65) {
            cout << 'B' << '\n';
        } else if (sum >= 50) {
            cout << 'C' << '\n';
        } else if (sum >= 30) {
            if (r >= 50) {
                cout << 'C' << '\n';
            } else {
                cout << 'D' << '\n';
            }
        } else {
            cout << 'F' << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define int long
const int mod = 1e9+7;
signed main(){
  int n;
  cin>>n;
  vector<int> t(n+2),a(n+2);
  for(int i=0;i<n;++i)cin>>t[i+1];
  for(int i=0;i<n;++i)cin>>a[i+1];
  t[0]=t[n+1]=a[0]=a[n+1]=0;
  int r=1,u,l;
  for(int i=1;i<=n;++i){
    u=min(a[i],t[i]),l=1;
    if(t[i-1]!=t[i]){
      if(t[i]>a[i])return cout<<0,0;
      u=l=t[i];
    }
    if(a[i]!=a[i+1]){
      if((l>1&&a[i]!=l)||a[i]>t[i])return cout<<0,0;
      u=l=a[i];
    }
    r=r*(u-l+1);
    if(r>=mod)r%=mod;
  }
  cout<<r;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind T(N);
  vector<int> F(N, 0);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    F.at(A - 1)++;
    F.at(B - 1)++;
    T.unite(A - 1, B - 1);
  }
  vector<int> A(N, 0);
  for (int i = 0; i < N; i++) {
    A.at(i) = T.size(i) - 1;
    A.at(i) -= F.at(i);
  }
  for (int i = 0; i < K; i++) {
    int C, D;
    cin >> C >> D;
    if (T.same(C - 1, D - 1)) {
      A.at(C - 1)--;
      A.at(D - 1)--;
    }
  }
  cout << A.at(0);
  for (int i = 1; i < N; i++) {
    cout << " " << A.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 4852
<?php
  
  list($n, $m) = explode(" ", trim(fgets(STDIN)));

  $array_s = [];

  if($m == 0){
    if($n == 1){
      echo "0";
      exit;
    }else{
      if($n == 2){
        echo "10";
      }else{
        echo "100";
      }      
    }
    exit;
  }
  for($i=0;$i<$m;$i++){
    list($s, $c) = explode(" ", trim(fgets(STDIN)));
    if($n != 1 && $s == 1 && $c == 0){
      echo "-1";
      exit;
    }
    if(isset($array_s[$s])){
      if($array_s[$s] != $c){
        echo "-1";
        exit;
      }
    }
    $array_s[$s] = $c;
  }
  
  $anser = [];
  for($i=1;$i<=$n;$i++){
    if(isset($array_s[$i])){
      echo $array_s[$i];      
    }else{
      if($i==1){
        echo "1";
      }else{
        echo "0";
      }
    }
  }


Measured memory_bytes: 4604
n = int(input())
al = list(map(int, input().split()))
al = [0] + al + [0]
costs = []

for i in range(n+1):
    costs.append(abs(al[i+1] - al[i]))

d = sum(costs)

for i in range(1, n+1):
    distance = d - abs(al[i] - al[i+1]) - abs(al[i-1] - al[i]) + abs(al[i-1] - al[i+1])
    print(distance)


Measured memory_bytes: 14044
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void Solve()
    {
        int N = cin.Nextint;
        var A = cin.Scanint;

        int cnt2 = A.Count(i => i % 2 == 1);
        if (cnt2 % 2 == 0)
        {
           WriteLine("YES");
        }
        else
        {
            WriteLine("NO");
        }
        
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 12248
n = int(input())
a = list(map(int, input().split()))

a.sort()
a.reverse()

#ans = 0
#seq = [a[0]]
#
#seq.append(a[1])
#ans += a[0]
#
#l = 2
#for i in range(2, n):
#    pos = 0
#    m_ans, M_ans = 0, 0
#    for p in range(l):
#        np = p + 1
#        if np == l:
#            np = 0
#        m, M = min(seq[p], seq[np]), max(seq[p], seq[np])
#        if m >= m_ans and M >= m_ans:
#            pos = np
#            m_ans = m
#            M_ans = M
#    ans += m_ans
#    seq.insert(pos, a[i])
#    l += 1
#print(ans)

ans = 0
cur = 0
cnt = 1
for i in range(n - 1):
    if cnt == 2:
        cur += 1
        cnt = 0
    ans += a[cur]
    cnt += 1
print(ans)


Measured memory_bytes: 94192
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

typedef long long ll;

int main() {
  int x, t, n;
  cin >> n >> x >> t;

  cout << ((int)ceil((double)n / x) * t) << endl;

  return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
template <typename T>
inline void read(T &x)
{
	x = 0;bool b = 0;char c;
	for (c = getchar();!isdigit(c);b |= (c == '-'), c = getchar());
	for (;isdigit(c);x = (x << 1) + (x << 3) + (c ^ 48), c = getchar());
	if (b) x = -x;
}
template <typename T>
inline void write(T x, int base = 10)
{
	if (x < 0) putchar('-'), x = -x;
	static int stk[70];
	int top = 0;
	while (x)
	{
		stk[top++] = x % base;
		x /= base;
	}
	while (top > 0)
	{
		putchar(stk[--top] ^ 48);
	}
}
bool isok(int x)
{
	return (x & 1) || (x % 3 == 0) || (x % 5 == 0);
}
int main()
{
	int n;
	read(n);
	for (int i = 0;i < n;++i)
	{
		int x;read(x);
		if (!isok(x))
		{
			puts("DENIED");
			return 0;
  		}
	}
	puts("APPROVED");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  double V[N], r; for (auto &v: V) cin >> v; sort(V, V + N); r = V[0];
  for (int i{1}; i < N; ++i) r = (r + V[i]) / 2;
  printf("%.9f", r);}

Measured memory_bytes: 3752
#include <iostream>
using namespace std;
using ll = long long;

template <class T> inline bool chmin(T& a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}

ll calc_count(ll n) {
  ll ans = 0;
  while(n % 2 == 0) {
    ans++;
    n /= 2;
  }
  return ans;
}

ll INF = 1e12;

int main() {
  int N;
  cin >> N;
  ll ans = INF;
  ll a;
  for(int i = 0; i < N; ++i) {
    cin >> a;
    chmin(ans, calc_count(a));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.imageio.IIOException;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String word = br.readLine();
      word.toLowerCase();

      Function<String,Long> findingWord =
        s -> Stream.of(s.split(" "))
          .filter(w -> word.equals(w))
          .count();

      Optional<Long> result =
        br.lines()
          .filter(w -> !"END_OF_TEXT".equals(w))
          .map(String::toLowerCase)
          .map(findingWord)
          .reduce(Long::sum);

      System.out.println(result.get());
    }
  }
}


Measured memory_bytes: 31256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

vector<int> v[26];
string S, T;


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S >> T;
    rep(i, S.length()) {
        v[S[i] - 'a'].push_back(i);
    }
    int ans = 0;
    int prev = -1;
    rep(i, T.length()) {
        if(v[T[i] - 'a'].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        int add = 0;
        auto it = lower_bound(v[T[i] - 'a'].begin(), v[T[i] - 'a'].end(), prev + 1);
        if (it == v[T[i] - 'a'].end()) {
            it = v[T[i] - 'a'].begin();
            add = S.length();
        }
        int next = *it;
        //cout << next << endl;
        ans += next - prev + add;
        //dump(ans);
        prev = next % S.length();
    }
    cout << ans << endl;
    

    

    return 0;
}


Measured memory_bytes: 1736
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n, m;
        cin >> n >> m;
        int a[n], tot = 0;
        for(int i = 0; i < n; i++) {
            cin >> a[i];
            tot += a[i];
        }

        int cnt = 0;
        for(int i = 0; i < n; i++) {
            if(a[i] * 4 * m >= tot)
                cnt++;
        }

        if(cnt >= m)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    
    return 0;
}



Measured memory_bytes: 3652
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int ans;
    if(b >= a){
        ans = a;
    }else{
        ans = a-1;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <queue>
#include <iomanip>
using namespace std;
int main(){
	long long int n, m;
	priority_queue<pair<long long int, long long int>, vector<pair<long long int, long long int> >, greater<pair<long long int, long long int> > > que[100000];
	cin >> n >> m;
	long long int p;
	long long int y;
	for(int i = 0;i < m;i++){
		cin >> p >> y;
		que[p - 1].push(make_pair(y, i));
	}
	long long int number[100000];
	long long int count;
	pair<long long int, long long int> e;
	for(long int i = 0;i < n;i++){
		count = 1;
		while(que[i].size() > 0){
			e = que[i].top();
			que[i].pop();
			number[e.second] = (i + 1) * 1000000 + count;
			count++;
		}
	}
	for(int i = 0;i < m;i++){
		cout << setfill('0') << setw(12) << right << number[i] << endl;
	}
}


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

int main() {
    int N;
    cin >> N;
    int A, B, C, D, p = 10;
    D = N % 10;
    C = ((N - D) % 100) / 10;
    B = ((N - D - C * 10) % 1000) / 100;
    A = (N - D - C * 10 - B * 100) / 1000;
    bool flag = false;
    if (A + B + C + D == 7)
    {
        flag = true;
        cout << A << '+' << B << '+' << C << '+' << D << '=' << '7';
    }
    else if (A - B + C + D == 7)
    {
        flag = true;
        cout << A << '-' << B << '+' << C << '+' << D << '=' << '7';
    }
    else if (A - B - C + D == 7)
    {
        flag = true;
        cout << A << '-' << B << '-' << C << '+' << D << '=' << '7';
    }
    else if (A - B + C - D == 7) {
        flag = true;
        cout << A << '-' << B << '+' << C << '-' << D << '=' << '7';
    }
    else if (A - B - C - D == 7) {
        flag = true;
        cout << A << '-' << B << '-' << C << '-' << D << '=' << '7';
    }
    else if (A + B - C + D == 7) {
        flag = true;
        cout << A << '+' << B << '-' << C << '+' << D << '=' << '7';
    }
    else if (A + B + C - D == 7) {
        flag = true;
        cout << A << '+' << B << '+' << C << '-' << D << '=' << '7';
    }
    else if (A + B - C - D == 7) {
        flag = true;
        cout << A << '+' << B << '-' << C << '-' << D << '=' << '7';
    }
}

Measured memory_bytes: 256
/// {{{
#include "bits/stdc++.h"
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
#define   rep(i, s, t)       for(int i = int(s); i < int(t); ++i)
using namespace std;
typedef long long i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

int N, A, B, C;
int x[10];

int slv(int idx, int lenA, int lenB, int lenC)
{
  if (idx >= N) {
    if (lenA > 0 && lenB > 0 && lenC > 0)
      return abs(A - lenA) + abs(B - lenB) + abs(C - lenC) - 30;
    else
      return INF;
  }

  return
    min({
        slv(idx+1, lenA, lenB, lenC),
        slv(idx+1, lenA+x[idx], lenB, lenC) + 10,
        slv(idx+1, lenA, lenB+x[idx], lenC) + 10,
        slv(idx+1, lenA, lenB, lenC+x[idx]) + 10
    });
}

signed main()
{
  cin >> N >> A >> B >> C;

  rep(i, 0, N) {
    cin >> x[i];
  }

  cout << slv(0, 0, 0, 0) << endl;

  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iA = int.Parse(sS[1]);
            int iB = int.Parse(sS[2]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = iN * iA > iB ? iB: iN * iA;

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
n = int(input())

def func(a, b):
    a = len(str(a))
    b = len(str(b))
    return max(a, b)

ans = float('inf')
for i in range(1, int(n**0.5)+1):
    if n%i==0: ans = min(ans, func(i, n//i))

print(ans)
            




Measured memory_bytes: 3188
//#include <bits/stdc++.h>
// utility
#include <bitset>
#include <tuple>
#include <typeinfo>
// error handling
#include <cassert>
// string
#include <cctype>
#include <cstring>
#include <string>
// container
#include <array>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// algorithm
#include <algorithm>
// iterator
#include <iterator>
// math
#include <cmath>
#include <complex>
#include <numeric>
#include <random>
// i/o
#include <cstdio>
#include <iomanip>
#include <iostream>

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  string S;
  cin >> S;

  bool f = S[0] == 'A';

  int a = count(S.begin() + 2, S.end() - 1, 'C');
  int b = 0;
  rep(i, 0, S.size()) { b+=!!(islower(S[i])); }
  dump(a, b);

  cout << (f & (a == 1) & (b == S.size() - 2) ? "AC" : "WA") << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

b = 1
s = 0
move = []

while True :
    move.append(b)
    b = a[b - 1]
    s += 1
    if b == 2 :
        print(s)
        exit(0)
    if n < s :
        print(-1)
        exit(0)


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


int main()
{
  int n;
  cin >> n;
  int a,b,c,d,e,f,g,h,i,sum;
  a = n % 10;
  b = n / 10 % 10;
  c = n / 100 % 10;
  d = n / 1000 % 10;
  e = n / 10000 % 10;
  f = n / 100000 % 10;
  g = n / 1000000 % 10;
  h = n / 10000000 % 10;
  i = n / 100000000 % 10;
  sum = a + b + c + d + e + f + g + h + i;
  if(n%sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}


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

int main() {
  string S;
  cin >> S;
  sort(S.begin(), S.end());
  bool flg = true;
  for (int i = 0; i < S.size() - 1; ++i) {
    char cur_c = S[i];
    char next_c = S[i + 1];
    if (cur_c == next_c) {
      flg = false;
      break;
    }
  }
  if (flg) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
}

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

int main() {
    string s;
    cin >> s;
    int n=s.size();
    for ( int i=0; i<n; i++ ) {
        if ( i+1<n&&s[i]==s[i+1] ) {
            cout << i+1 << ' ' << i+2 << '\n';
            return 0;
        }
        if ( i+2<n&&s[i]==s[i+2] ) {
            cout << i+1 << ' ' << i+3 << '\n';
            return 0;
        }
    }
    cout << -1 << ' ' << -1 << '\n';
    return 0;
}


Measured memory_bytes: 3724