akhauriyash/Code-Regression huggingface dataset:
a, b, c, x, y = gets.chomp.split(" ").map(&:to_i)
small = []
tanpin = a * x + b * y
small << tanpin
small << c * 2 * [x,y].max
if x > y
    mix_tanpin = 2 * c * y + a * (x - y)
    small << mix_tanpin
else
    mix_tanpin = 2 * c * x + b * (y - x)
    small << mix_tanpin
end
puts small.min

Measured memory_bytes: 14276
import numpy as np

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())


if np.abs(a-b) <=k and np.abs(a-c) <= k and np.abs(a-d) <= k  and np.abs(a-e) <=k and np.abs(b-c)<=k and np.abs(b-d)<=k and np.abs(b-e)<=k and np.abs(c-d)<=k and np.abs(c-e)<=k and np.abs(d-e)<=k:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 14424
#include<stdio.h>
#define N 36

void bubble(int,int *,char *);
void selec(int,int *,char *);
int isStable(int,char *,char *);

int main(){
  int i;
  int NUMBER[N],NUMBER_se[N];
  char mark[N],mark_se[N];
  char blank;
  int num;
  int hantei;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%c%c%d",&blank,&mark[i],&NUMBER[i]);
    NUMBER_se[i]=NUMBER[i];
    mark_se[i]=mark[i];
  }

  bubble(num,NUMBER,mark);
  printf("Stable\n");

  selec(num,NUMBER_se,mark_se);
  
  for(i=0;i<num;i++){
    if(mark[i]!=mark_se[i]){
      printf("Not stable\n");
      break;
    }
  }
  if(i==num)printf("Stable\n");

  return 0;
}

void bubble(int num,int x[],char y[]){
  int i,j;
  int mask;
  char blank;

  for(i=0;i<num-1;i++){
    for(j=num-1;i<j;j--){
      if(x[j]<x[j-1]){
	mask=x[j];
	x[j]=x[j-1];
	x[j-1]=mask;

	blank=y[j];
	y[j]=y[j-1];
	y[j-1]=blank;
      }
    }
  }

  for(i=0;i<num;i++){
    if(i!=0)printf(" ");
    printf("%c%d",y[i],x[i]);
  }
  printf("\n");

}

void selec(int num,int x[],char y[]){
  int i,j,min;
  int mask;
  char blank;

  for(i=0;i<num-1;i++){
    min=i;
    for(j=i;j<num;j++){
      if(x[j]<x[min]){
	min=j;
      }
    }
    if(i!=min){
      mask=x[i];
      x[i]=x[min];
      x[min]=mask;
    
      blank=y[i];
      y[i]=y[min];
      y[min]=blank;
    }
  }

  for(i=0;i<num;i++){
    if(i!=0)printf(" ");
    printf("%c%d",y[i],x[i]);
  }
  printf("\n");
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int res=0;
  for (int i=0; i<N; i++) {
    int x;
    cin >> x;
    res += min(x, K-x) * 2;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    string s;
    cin >> s;
    int n = s.size();
    vi a(2);
    rep(i,n){
        a[s[i] - '0']++;
    }

    cout << 2*min(a[0],a[1]) << endl;
    return 0;

}


Measured memory_bytes: 512
import sys
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))


if a[0]>b[0] or b[n-1]>a[n-1]: print(0);sys.exit()
elif n<=2: print(1);sys.exit()

ans=1
for i in range(1,n-1):
    if a[i]==a[i-1] and b[i]==b[i+1]:
        ans=ans*min(a[i],b[i])%mod
    else:
        if a[i]!=a[i-1] and a[i]>b[i]: print(0);sys.exit()
        if b[i]!=b[i+1] and b[i]>a[i]: print(0);sys.exit()
print(ans)

Measured memory_bytes: 18884
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
struct P {
	ll from, to, cost;
};
vector<P>e;
ll a[10001];
const ll inf = -999999999999999999;
bool b[1001];
signed main() {
	ll n, m;
	cin >> n >> m;
	for (ll i = 0; i < m; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		e.push_back(P{ a,b,c });
	}
	for (ll i = 0; i <= n; i++) {
		a[i] = inf;
		b[i] = false;
	}
	a[1] = 0;
	ll sum = 0;
	for (ll j = 0; j < n; j++) {
		bool up = false;
		for (ll i = 0; i < m; i++) {
			P t = e[i];
			if (a[t.from] != inf&&a[t.to] < a[t.from] + t.cost) {
				a[t.to] = a[t.from] + t.cost;
				up = true;
			}
		}
		if (!up) break;
	}
	for (ll j = 0; j < n; j++) {
		for (ll i = 0; i < m; i++) {
			P t = e[i];
			if (a[t.from] != inf&&a[t.to] < a[t.from] + t.cost) {
				a[t.to] = a[t.from] + t.cost;
				b[t.to] = true;
			}
		}
	}
	if (!b[n]) {
		cout << a[n] << endl;
	}
	else {
		cout << "inf" << endl;
	}
}

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

int main(){
 int N;
 cin >> N;
 vector<int> A(N);
 for(int i = 0;i<N;i++){
   cin >> A[i];
 }
  
  int c = 0;
  bool flag1 = false;
  
  while(true){
  for(int i = 0;i<N;i++){
    if(A[i]%2 != 0){
      flag1 = true;
      break;
    }
    else A[i] = A[i]/2;
  }
    if(flag1) break;
   c++;
  }
  cout << c << endl;
 
 }

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

int main(void){
    string str;
    cin >> str;

    int ans = 0;
    rep(i,str.length()) {
        if (str[i] == 'R') {
            int cnt = 0;
            while (str[i] == 'R') {
                cnt++;
                i++;
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long[] k=new long[5];
		for(int i=0;i<5;i++){
			k[i]=sc.nextLong();
		}
		Arrays.sort(k);
		System.out.println(n%k[0]==0?n/k[0]+4:n/k[0]+5);
	}
	
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
const double pi = acos(-1);
int n,m,a;
int main(){
    scanf("%d %d",&n,&m);
    for(int i=1;i<=m;++i){
        scanf("%d",&a);
        n-=a;
    }
    if(n>=0) printf("%d\n",n);
    else printf("-1\n");
}

Measured memory_bytes: 3816
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;文字列 -> 整数
(defn Int [s] (Integer/parseInt s))
;文字列 -> 文字列
(defn Str [s] s)

;scanf的なノリで1行をいい感じに読み取る
;定数が重いので注意
(defn input [varTypes]
    (mapv 
        (fn [f s] (f s)) ;文字列sに関数fを適用する
        varTypes         ;適用する関数
        (clojure.string/split 
            (read-line)  ;1行を読み込み
            #" "         ;区切り文字
        )
    )
)

;スペース区切りの整数を受け取る
;速い
(defn inputFast [varType]
    (map
        varType
        (clojure.string/split 
            (read-line)  ;1行を読み込み
            #" "         ;区切り文字
        )
    )
)

(defn floor [a b] (quot a b))
(defn ceil [a b] (floor (- (+ a b) 1) b))
(defn abs [a] (if (>= a 0) a (- 0 a)))

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
(def one (first "1"))
(dosync
(let [[s] (inputFast Str)]
    (let [n (count s) ret (ref 0)]
        (doseq [i (range n)]
            (alter ret + (if (= one (nth s i)) 1 0 ))
        )
        (println (deref ret))
    )
)
)

Measured memory_bytes: 67044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
#define _DEBUG
     
int main() {
  int n, q, ans=0;
  cin >> n;
  vector<int> s(n);
  rep (i, n) cin >> s[i];
  cin >> q;
  vector<int> t(q);
  rep (i, q) cin >> t[i];

  sort(t.begin(), t.end());

  int tmp = s[0];
  auto itrl = lower_bound(t.begin(),t.end(),tmp);
  auto itru = upper_bound(t.begin(),t.end(),tmp);
  if (itru - itrl) ++ans;

  for (int i=1; i<n; ++i) {
    if (tmp != s[i]) {
      auto itrl = lower_bound(t.begin(),t.end(),s[i]);
      auto itru = upper_bound(t.begin(),t.end(),s[i]);
      if (itru - itrl) ++ans;
      tmp = s[i];
    }
  }
 
  cout << ans << endl;
}


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

int main(){ 
  int n;
  cin>>n;
  set<string> s;
  rep(i,n) {
    string x;
    cin>>x;
    s.insert(x);
  }
  
  cout<<s.size()<<endl;
}

Measured memory_bytes: 19152
#include<iostream>
using namespace std;
int main(void){
  int n, cnt=0, tmp;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> tmp;
    while(1) {
      if(tmp%2==1) break;
      cnt++;
      tmp /= 2;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
total= ((N+1)*N)//2
F = 0
for i in range(1,N):
    if i*15 > N:break
    else:F += i*15

for i in range(1,N):
    if i*5 > N:break
    elif i*5%15==0:continue
    else:F += i*5

for i in range(1,N):
    if i*3 > N:break
    elif i*3%15 == 0:continue
    else:F += i*3
print(total-F)

Measured memory_bytes: 9200
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	private static final String HEADER = "3C"; //????????????????????????????????????
	private static final int STUDENT = 39; //???????????°

	public static void main(String[] args) {
		while(sc.hasNext()) {
			int candy = sc.nextInt();
			int ans = candy % STUDENT;

			if(ans == 0) {
				ans = STUDENT;
			}
			System.out.println(HEADER + String.format("%02d", ans));
		}
	}
}

Measured memory_bytes: 26040
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

vector<bool> done;
vector<vector<int> > to;
vector<vector<int> > dist;
vector<int> x;

bool dfs(int id,int d)
{
	if(done[id]==true)
	{
		if(x[id]!=d)
		{
			return false;
		}
		else
			return true;
	}

	done[id]=true;
	x[id]=d;

	for(int i=0;i<to[id].size();i++)
	{
		int nxid=to[id][i];
		int nxd=d+dist[id][i];
		if(!dfs(nxid,nxd))
			return false;
	}
	return true;
}

int main()
{
	int n,m;
	cin >> n >> m;
	vector<int> l(m),r(m),d(m);
	for(int i=0;i<m;i++)
	{
		cin >> l[i] >> r[i] >> d[i];
		l[i]--;r[i]--;
	}
	done=vector<bool>(n,false);
	to=vector<vector<int> >(n);
	dist=vector<vector<int> >(n);
	x=vector<int>(n,0);

	for(int i=0;i<m;i++)
	{
		to[l[i]].push_back(r[i]);
		dist[l[i]].push_back(d[i]);
		to[r[i]].push_back(l[i]);
		dist[r[i]].push_back(-d[i]);
	}

	bool can=true;
		
	for(int i=0;i<n;i++)
		if(done[i]==false)
			if(!dfs(i,0))
				can=false;


	cout << (can ? "Yes":"No") << endl;
}


Measured memory_bytes: 17920
import java.util.Scanner

object Main {

  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt

    val A = Array.fill[Int](1 << N)(sc.nextInt)
    for (i <- 0 until N) {
      for (j <- 0 until 1 << N by 1 << (i + 1)) {
        if (A(j) != A(j + (1 << (i)))) (
          A(j) = math.abs(A(j) - A(j + (1 << (i))))
          )
      }
    }

    println(A(0))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 95604
///Nahid Hasan Raju
#include <bits/stdc++.h>
#define ll long long
#define MS(ARRAY,VALUE) memset(ARRAY,VALUE,sizeof(ARRAY))
#define Fin freopen("input.txt","r",stdin)
using namespace std;

#define P1(XX) cerr<<"db1: "<<XX<<endl
#define P2(XX,YY) cerr<<"db2: "<<XX<<" "<<YY<<endl
#define P3(XX,YY,ZZ) cerr<<"db3: "<<XX<<" "<<YY<<" "<<ZZ<<endl
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Fout freopen("output.txt","w",stdout)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define EPS 0.00000001
#define INF INT_MAX
#define PI 2*acos(0.0)
#define set(XX,POS) XX|=(1<<POS)
#define reset(XX,POS) XX&=(~(1<<POS))
#define check(XX,POS) (bool)(XX&(1<<POS))
#define toggle(XX,POS) (XX^(1<<POS))
#define SORT(v) sort(v.begin(),v.end())
#define REVERSE(V) reverse(v.begin(),v.end())
#define VALID(X,Y,R,C) X>=0 && X<R && Y>=0 && Y<C
#define SIZE(ARRAY) sizeof(ARRAY)/sizeof(ARRAY[0])
#define RT printf("Run Time : %0.3lf seconds\n", clock()/(CLOCKS_PER_SEC*1.0))
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree< pair<int,int> , null_type, less< pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;

#define MOD 1000000007ll
#define MX 200006  ///200005

ll m, n;
ll a[MX];
bool f(ll p)
{
    ll c=0,u;
    for(int i=0;i<n;i++)
    {
        if(a[i]<=p)break;
        u=(((a[i]+p-1)/p)-1);
        c+=u;
        if(c>m)return 0;
    }
    P1(c);
    if(c<=m)return 1;
    return 0;
}

int main()
{
    #ifndef ONLINE_JUDGE
    Fin;
    #endif
    int test=1, tc=0, i, j;
    ll k, ans;
    ll c,y,x,mid;
    //scanf("%d", &test);
    while(test--)
    {
        ans=0;
        cin>>n>>m;

        for(i=0;i<n;i++)cin>>a[i];
        sort(a,a+n);
        reverse(a,a+n);

        x=1; y=INT_MAX;
        while(x<y)
        {

            mid=(x+y)/2;
            P3(x,mid,y);
            if(f(mid)){
                y=mid;
            }
            else{
                x=mid+1;
            }
        }
        if(!f(mid))mid++;

        printf("%lld\n", mid);
    }
    return 0;
}



Measured memory_bytes: 5296
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;



int main() {
	//fios;
	
	int h1, h2, m1, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	cout << (h2*60 + m2) - (h1 * 60 + m1) - k << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(int i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,K;
    cin >> N >> K;
    vector<ll> vec(N);
    ll up = 0;
    rep(i,N){
        cin >> vec[i];
        chmax(up,vec[i]);
    }
    if(up < K){
        cout << "IMPOSSIBLE\n";
        return 0;
    }
    ll num = vec[0];
    rep(i,N){
        num = gcd(num,vec[i]);
    }
    if(K % num == 0){
        cout << "POSSIBLE\n";
    }
    else cout << "IMPOSSIBLE\n";
}

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

using namespace std;

int main() {

    int N;
    //vector<int> p;
    cin >> N;
    //p.resize(N);
    int index = 0;
    int j = 0;
    for (int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        ++index;
        if (p != index) ++j;
        else continue;
    }
    if (j <= 2) {
        cout << "YES" << endl;
    }
    else if (j > 2) {
        cout << "NO" << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
import collections
n, k, q = map(int, input().split())
A = [int(input()) for _ in range(q)]
c = collections.Counter(A)
for i in range(1, 1+n):
  m = q - c.get(i, 0)
  # print((i, m, k-m))
  print('Yes' if (k-m) > 0 else 'No')


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

int main() {
    int ans = 0;
    int i,a,b,c;
    cin >> a >> b >> c;
    for(i=a;i <= b;i++){
        if(c%i == 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3084
#include <iostream>

int a, b, c;

int main()
{
  std::cin >> a >> b >> c;

  int ave = (a+b+c)/2;

  if( (a+b+c)%2 == 0 && ( a == ave || b == ave || c == ave ) )
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;

  return 0;
}

Measured memory_bytes: 256
S = input()
if S.count('RRR') == 1:
    print(3)
elif S.count('R') == 2 and S.count('RR') == 1:
    print(2)
elif S.count('R') >= 1 and S.count('R') < 3 and S.count('RR') == 0:
    print(1)
else:
    print(0)

Measured memory_bytes: 9060
//g++でビルド

#include "bits/stdc++.h"

using namespace std;

int n, m;
vector<pair<int, int> > ts;

int main(){
    cin >> n >> m;
    for(int i=0; i<m; i++){
        int s, t;
        cin >> s >> t;
        
        ts.push_back(make_pair(t,s));
    }

    sort(ts.begin(), ts.end());

    int result = 0;
    int start = 0;

    for(int i = 0; i<m; i++){
        if(start < ts[i].first){
            if(start <= ts[i].second){
                start = ts[i].first;
                result ++;
            }
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	string s,t;
	cin >> N >> s >> t;
	for(int i=0; i<=N; i++){
		bool flg = true;
		for(int j=i; j<N; j++){
			if(s[j] != t[j-i]){
				flg = false;
				break;
			}
		}
		if(flg){
			cout << (s.substr(0,i) + t).size() << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define For(i, a, n) for (ll (i) = (a); (i) < (n); (i)++)
#define prl(x) cout << (x) << endl
#define pr(x) cout << (x)
#define all(v) (v).begin(), (v).end()

template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {return '"' + s + '"';}
string to_string(char c){return string(1, c);}
string to_string(const char* s) {return to_string((string) s);}
string to_string(bool b){return (b ? "true" : "false");}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p){return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p){return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) res += ", ";
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
  return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template<typename T>
string to_string(priority_queue<T>& q){
    priority_queue<T> copy;
    bool first = true;
    string res = "{";
    while(!q.empty()){
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(q.top());
        copy.push(q.top());
        q.pop();
    }

    swap(q, copy);
    res += "}";
    return res;
}

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

int main(void){
    ll n;
    cin >> n;
    if (n % 1000 == 0){
        cout << 0 << endl;
    }else{
        cout << 1000 - n % 1000 << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
N,T = gets.split.map(&:to_i)
ct = N.times.map { gets.split.map(&:to_i) }

min = 1001
N.times do |i|
  next if ct[i][1] > T
  min = ct[i][0] if min > ct[i][0]
end

if min == 1001
  puts 'TLE'
else
  puts min
end

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N, A);
  int rest = N % 500;
  // cout << rest << endl;
  OK(rest <=  A);

  return 0;
}



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

typedef pair<int, int> P;
const int INF = 10000000;
const int H_MX = 1000, W_MX = 1000;
int h, w;
char field[H_MX][W_MX];
int d[H_MX][W_MX];
int d_r[4] = {0, -1, 1, 0}, d_c[4] = {-1, 0, 0, 1};

int bfs() {
    int blk_num = 0;
    int op_num = 0;
    queue<P> que;
    fill(d[0], d[H_MX], INF);
    //最初に黒のマスをqueにすべて入れる
    for (int r = 0; r < h; r++) {
        for (int c = 0; c < w; c++) {
            if (field[r][c] == '#') {
                que.push(P(r, c));
                d[r][c] = 0;
                blk_num++;
            }
        }
    }
    while (blk_num < h * w) {
        P p = que.front();
        que.pop();
        for (int i = 0; i < 4; i++) {
            int nr = p.first + d_r[i], nc = p.second + d_c[i];
            if (nr >= 0 && nr < h && nc >= 0 && nc < w) {
                if (field[nr][nc] == '.' && d[nr][nc] == INF) {
                    que.push(P(nr, nc));
                    d[nr][nc] = d[p.first][p.second] + 1;
                    op_num = d[nr][nc];
                    blk_num++;
                }
            }
        }
    }
    return op_num;
}

int main() {
    cin >> h >> w;
    //入力
    for (int r = 0; r < h; r++) {
        for (int c = 0; c < w; c++) {
            cin >> field[r][c];
        }
    }

    cout << bfs() << endl;

    return 0;
}

Measured memory_bytes: 16032
#define  _CRT_SECURE_NO_WARNiINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <cassert>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define cycle_per_sec 2806192512
int bad[1000000] = {};
int main() {
#define int long long
	int n, k, query;
	cin >> n >> k >> query;
	vector<int> a;
	vector<pair<int, int>> hoge;
	REP(i, n) {
		int b;
		cin >> b;
		a.push_back(b);
		hoge.push_back(make_pair(b, i));
	}
	sort(hoge.begin(), hoge.end());
	long long ans = 0;
	vector<int> nyaw;
	for (int i = 0; i < n; ++i) {
		vector<int> going;
		for (int q = 0; q < n; ++q) {
			if (bad[q] == 1) {
				if (nyaw.size() >= k) {
					sort(nyaw.begin(), nyaw.end());
					for (int j = 0; j < nyaw.size() - k + 1; ++j) {
						going.push_back(nyaw[j]);
					}
				}
				if (nyaw.size() != 0) {
					nyaw.clear();
				}
			}
			else {
				nyaw.push_back(a[q]);
			}
		}
		if (nyaw.size() >= k) {
			sort(nyaw.begin(), nyaw.end());
			for (int j = 0; j < nyaw.size() - k + 1; ++j) {
				going.push_back(nyaw[j]);
			}
		}
		if (nyaw.size() != 0) nyaw.clear();
		sort(going.begin(), going.end());
		if (going.size() < query) break;
		long long pre_ans = going[query - 1] - hoge[i].first;
		if (i == 0) ans = pre_ans;
		ans = min(pre_ans, ans);
		bad[hoge[i].second] = 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
function main(input) {
    var line = input.split(/\r?\n/g);
    var arr = line[0].split(" ");
    const a = arr[0], b = arr[1];
    var an = "";
    var bn = "";
    for (var i = 0; i < b; i++)
        an += a;
    for (var i = 0; i < a; i++)
        bn += b
    console.log(an < bn ? an : bn)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main() {
    int N;
    cin >> N;
    int P[N];
    for(int i=0; i<N; i++) cin >> P[i];

    /*int count = N;
    for(int i=1; i<N; i++) {
        if(P[i] > P[i-1]) {
            count--;
            continue;
        }
        for(int j=0; j<=i; j++) {
            if(P[i] > P[j]) {
                count--;
                break;
            }
        }
    }*/

    int min = P[0];
    int count = N;
    for(int i=1; i<N; i++) {
        if(min > P[i]) min = P[i];
        else count--;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
  int a[N];
  if(s.at(0) == 'E'){
    a[0] = 1;
  }
  else{
    a[0] = 0;
  }
  
  for(int i = 1;i<N;i++){
    if(s.at(i) == 'E'){
      a[i] = a[i-1] + 1;
    }
    else{a[i] = a[i-1];
        }
  }
  
  int ans = a[N-1] - a[0];
  for(int i = 1;i<N;i++){
    ans = min(ans,i-a[i-1] + a[N-1] - a[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1796
import math
N = int(input())

min_f = float('inf')
for i in range(1, int(math.sqrt(N) + 1)):
    if N % i == 0:
        A = str(int(i))
        B = str(int(N // i))
        F = max(len(A), len(B))
        min_f = min(min_f, F)
print(min_f)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = long long;
using P = pair<int,int>;


int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N-1);

    rep(i,N) cin >> A[i],A[i]--;
    rep(i,N) cin >> B[i];
    rep(i,N-1) cin >> C[i];

    int ans = 0;
    rep(i,N){
        ans += B[A[i]];
        if(i != 0 ){
            if(A[i]-1 == A[i-1]) ans += C[A[i]-1];
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,x;
    cin >>x;

    {
        if(x<1200)cout <<"ABC"<<endl;
        else cout <<"ARC"<<endl;
    }

    dbg cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


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


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    P = list(map(int, input().split()))
    ans = 0
    mini = INF
    for i in range(N):
        ans += mini >= P[i]
        mini = min(mini, P[i])
    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


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

int A, B;

void solve() {
    cin >> A >> B;
    if(A >= 10 || B >= 10) {
        cout << -1 << endl;
    }
    else{
        cout << A*B << endl;
    }
    return; 
}

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


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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 998244353;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

#define F first
#define S second

void dfs (LL st, vector<vector<LL>> &adj, vector<LL> &vis) {
	if (!vis[st]) {
		vis[st] = 1;
		for (auto e : adj[st]) {
			dfs(e, adj, vis);
		}
	}
}

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

	vector<vector<LL>> adj(n);

	for (LL i = 0; i < m; ++i) {
		LL u, v;
		cin >> u >> v;
		adj[u-1].push_back(v-1);
		adj[v-1].push_back(u-1);
	}

	LL cnt = 0;
	vector<LL> vis(n, 0);
	for (LL i = 0; i < n; ++i) {
		if (!vis[i]) {
			dfs(i, adj, vis);
			cnt++;
		}
	}
	cout << cnt-1 << "\n";
}

Measured memory_bytes: 11088
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

char s[200];

bool check(int msk) {
  static int bit[20];
  for (int i = 0; i < 19; ++ i) bit[i] = (msk >> i) & 1;
  int inner[7];
  inner[0] = s[bit[13] | (bit[14] << 1) | (bit[12] << 2) | (bit[0] << 3) | (bit[1] << 4) | (bit[2] << 5) | (bit[3] << 6)];
  inner[1] = s[bit[14] | (bit[15] << 1) | (bit[0] << 2) | (bit[1] << 3) | (bit[16] << 4) | (bit[3] << 5) | (bit[4] << 6)];
  inner[2] = s[bit[12] | (bit[0] << 1) | (bit[11] << 2) | (bit[2] << 3) | (bit[3] << 4) | (bit[10] << 5) | (bit[5] << 6)];
  inner[3] = s[bit[0] | (bit[1] << 1) | (bit[2] << 2) | (bit[3] << 3) | (bit[4] << 4) | (bit[5] << 5) | (bit[6] << 6)];
  inner[4] = s[bit[1] | (bit[16] << 1) | (bit[3] << 2) | (bit[4] << 3) | (bit[17] << 4) | (bit[6] << 5) | (bit[18] << 6)];
  inner[5] = s[bit[2] | (bit[3] << 1) | (bit[10] << 2) | (bit[5] << 3) | (bit[6] << 4) | (bit[9] << 5) | (bit[8] << 6)];
  inner[6] = s[bit[3] | (bit[4] << 1) | (bit[5] << 2) | (bit[6] << 3) | (bit[18] << 4) | (bit[8] << 5) | (bit[7] << 6)];
  for (int i = msk = 0; i < 7; ++ i) msk |= inner[i] << i;
  int once = inner[3], twice = s[msk];
  return once == twice;
}

int main() {
  while (scanf("%s", s) == 1 && s[0] != '#') {
    for (int i = 0; i < 128; ++ i) s[i] -= '0';
    bool flag = true;
    for (int msk = 0; msk < (1 << 19) && flag; ++ msk) {
      flag &= check(msk);
    }
    puts(flag ? "yes" : "no");
  }
  return 0;
}

Measured memory_bytes: 1100
a,b,c,x,y = gets.split.map(&:to_i)

min = 10**9

200001.times{|i|
  at = bt = i/2
  an = (x > at) ? x-at : 0
  bn = (y > bt) ? y-bt : 0
  cost = c*i + an*a + bn*b
  min = cost if min > cost
}

p min

Measured memory_bytes: 1788
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
using u4t = std::uint32_t;
using i4t = std::int32_t;
using u8t = std::uint64_t;
using i8t = std::int64_t;

int main() {
  i8t N,A,B;
  std::cin >> N>>A>>B;
  i8t b = B-A;
  std::cout << (b<0||N==1&&A!=B?0: b*(N-2)+1) << std::endl;
  return 0;
}



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

int main() {
  int K,A,B;
  int C;
  cin >> K >> A >> B;
  C = B / K * K;
  if(C >= A) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
  return 0;
}





Measured memory_bytes: 3624
n=int(input())
w=[input() for _ in range(n)]
l=w[0][-1]
said=set()
said.add(w[0])
f=True
for i in range(1,n):
    if w[i][0] == l:
        l=w[i][-1]
    else:
        f=False
        break
    if w[i] in said:
        f=False
        break
    said.add(w[i])
print('Yes' if f else 'No')

Measured memory_bytes: 3064
tmp = list(map(int,input().split()))
n,t = tmp[0],tmp[1]
ts = list(map(int,input().split()))
ans = t
for i in range(n-1):
  if ts[i+1] - ts[i] < t:
    ans += ts[i+1] - ts[i]
  else:
    ans += t
print(ans)

Measured memory_bytes: 26836
import math

List = list(map(int, input().split()))

min8 = math.ceil(List[0]/0.08)
max8 = math.floor((List[0]+1)/0.08) - 1

min10 = math.ceil(List[1]/0.1)
max10 = math.floor((List[1]+1)/0.1) - 1

if max8 < min10 or max10 < min8:
    print('-1')
elif min8 <= min10:
    print(min10)
elif min10 <= min8:
    print(min8)

Measured memory_bytes: 3064
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
char mp[25][25];
bool bj[25][25];
struct node{
	int x,y,dis;
};
int fx[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
void bfs(int nx,int ny){
	if(mp[nx][ny]=='#')return ;
	memset(bj,false,sizeof(bj));
	queue<node>q;
	q.push((node){nx,ny,0});
	bj[nx][ny]=1;
	while(!q.empty()){
		node now=q.front();
		q.pop();
//		cout<<now.x<<" "<<now.y<<endl;
		ans=max(ans,now.dis);
		for(int i=0;i<4;++i){
			int vx=now.x+fx[i][0],vy=now.y+fx[i][1];
			if(vx<=0||vx>n||vy<=0||vy>m||mp[vx][vy]=='#'||bj[vx][vy])continue;
			q.push((node){vx,vy,now.dis+1});
			bj[vx][vy]=true;
		}
	}
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%s",mp[i]+1);
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)bfs(i,j);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int d;
  //int n=0;//
  cin >>d;
  int c[26]; int s[d][26];
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
    //n+=c[i];//
  }
  for (int i = 0; i < d; i++) {
    for (int ii = 0; ii < 26; ii++) {
      cin >> s[i][ii];
    }
  }
  long long int la[d];
  int lad[26];
  for (int i = 0; i < 26; i++) {
    lad[i]=-1;
  }
  int mm,md;
  //long long int m=0;//満足度確認用
  for (int i = 0; i < d; i++) {
    md=0;
    //la[i]=(n-c[0])*(-i-1)+s[i][0];//
    la[i]=s[i][0];
    for(int ii = 1; ii < 26; ii++) {
      la[i]-=(i-lad[ii])*c[ii];
    }
    for (int ii = 1; ii < 26; ii++) {
      //mm=(n-c[ii])*(-i-1)+s[i][ii];//
      mm=s[i][ii];
      for(int iii = 0; iii < 26; iii++) {
        if(ii!=iii) mm-=(i-lad[iii])*c[iii];
      }
      if((la[i]<mm)||(la[i]==mm&&c[md]<c[ii])){
        la[i]=mm; md=ii;
      }
    }
    lad[md]=i;
    cout<<md+1<<endl;
    //m+=la[i];//満足度確認用
    //cout<<m<<endl;//満足度確認用
  }
  //cout<<m<<endl;//満足度確認用
  //cout<<n<<endl;//
}

Measured memory_bytes: 3656
package main

import (
	"fmt"
)

func getTemp(T, H float64) (temp float64) {
	temp = T - 0.006*H
	return
}

func abs(x float64) float64 {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var N int
	var T, A float64
	fmt.Scan(&N, &T, &A)
	nums := make([]float64, N)
	p := 0
	for i := 0; i < N; i++ {
		fmt.Scan(&nums[i])
	}
	for i := 0; i < N; i++ {
		if abs(getTemp(T, nums[i])-A) < abs(getTemp(T, nums[p])-A) {
			p = i
		}
	}
	fmt.Println(p + 1)
}


Measured memory_bytes: 512
N, M = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)
limit = sum(A)/(4*M)

ans = 0
for a in A[-1::-1]:
    if a < limit:
        break
    else :
        ans += 1

if ans >= M:
    print('Yes')
else :
    print('No')


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>

using namespace std;

int main(){
    int n, a, b, c, d;
    scanf("%d %d %d %d %d\n", &n, &a, &b, &c, &d);
    a--; b--; c--; d--;

    string s;
    getline(cin, s);

    if(c < d){
        // a b c d or a c b d
        bool check_bd = true;
        for(int i = b; i < d; ++i){
            if(s.at(i) == '#' && s.at(i+1) == '#'){
                check_bd = false;
                break;
            }
        }
        if(!check_bd){
            printf("No\n"); return 0;
        }

        bool check_ac = true;
        for(int i = a; i < c; ++i){
            if(s.at(i) == '#' && s.at(i+1) == '#'){
                check_ac = false;
                break;
            }
        }
        if(!check_ac){
            printf("No\n"); return 0;
        }
    }else{
        // a b d c
        bool check_ac = true;
        for(int i = a; i < c; ++i){
            if(s.at(i) == '#' && s.at(i+1) == '#'){
                check_ac = false;
                break;
            }
        }
        if(!check_ac){
            printf("No\n"); return 0;
        }

        bool check_bc_3 = false;
        for(int i = b - 1; i < d; ++i){
            if(s.at(i) == '.' && s.at(i + 1) == '.' && s.at(i + 2) == '.'){
                check_bc_3 = true;
                break;
            }
        }
        if(!check_bc_3){
            printf("No\n"); return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main() {
  int number_n, current_score = 1, add_number, i, temp_number;
  scanf("%d", &number_n);
  scanf("%d", &add_number);
  for(i = 0; i < number_n; i++) {
    if(current_score * 2 < current_score + add_number) {
      current_score *= 2;
    } else {
      current_score += add_number;
    }
  }
  printf("%d\n", current_score);
  return 0;
}


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

int main(){
  string p, s, ploop;
  cin >> p >> s;
  while(ploop.size() <= 100){
    ploop += p;
  }
  if(ploop.find(s) != string::npos) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



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

int N, K;

int main() {
    cin >> N >> K;
    int ans;
    if (K == 1) {
        ans = 0;
    }
    else {
        ans = N - K;
    }
    cout << ans << endl;

    
    return 0;
}

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

int main()
{
	int A = 0, P = 0;
	cin >> A >> P;
	if (0 > A || 100 < A ||
		0 > P || 100 < P) return -1;

	int res = ((A*3) + P)/2;
	printf("%d", res);
	cin >> res;
	return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int a = Integer.parseInt(tokenizer.nextToken());
         a*= Integer.parseInt(tokenizer.nextToken());

        for (int i = 1; i < 4; i++) {
            if (((a*i) & 1) != 0) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {
	
	int n, k;
	cin >> n >> k;
	vi a(n);
	rep(i, n)cin >> a[i];

	while(k--) {

		vi imos(n + 1);
		rep(i, n) {
			int l = max(0, i - a[i]);
			int r = min(n, i + a[i] + 1);
			imos[l]++;
			imos[r]--;
		}
		vi b(n);
		b[0] = imos[0];
		rep1(i, n - 1)b[i] = b[i - 1] + imos[i];

		a = b;

		bool all_n=true;
		rep(i, n)if (a[i] != n)all_n = false;
		if (all_n)break;
	}

	rep(i, n)cout << a[i] << " ";
	cout << endl;

}

Measured memory_bytes: 5620
x = gets
y = x.split()

strlength= y.map{|str| str.length }

numlength = strlength.max

maxlengthin = strlength.find_index{|k| k == numlength}

strcount = []
i = 0
while i < y.length
 numcount = y.count{|a| y[i] == a}
 strcount << numcount
 i += 1
end

nummax = strcount.max

maxstr = strcount.find_index{|n| n == nummax}

puts "#{y[maxstr]} #{y[maxlengthin]}"


Measured memory_bytes: 6836
# Problem - 単語の検索

# input
W = input()

# initialization
word_count = 0
is_finish = False

# count
while True:
    word_list = input().split()
    for w in word_list:
        if w=='END_OF_TEXT':
            is_finish = True
            break
        w = w.lower()
        if w==W:
            word_count += 1
    if is_finish:
        break

# output
print(word_count)



Measured memory_bytes: 5556
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef long long ll;
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define rep(i, n) for(int i = 0; i < n; ++i) 
#define foreach(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it) 

#define TRACE(x...) x
#define watch(x) TRACE(cout << #x" = " << x << endl)
#define watcharr(i, x) TRACE(cout << #x" = "); rep(i, sz(x)) cout << x[i] << " "; cout << endl

int main() {
	
	ifstream infile("input.in");
	if(infile.good()) cin.rdbuf(infile.rdbuf());
	
    long long A, B, N;
    cin >> A >> B >> N;

    ll res = ll(A * N / B) - A * ll(N / B);
    long long v = ll(N / B); v = v * B - 1; v = min(v, N);
    res = max(res, ll(A * v / B) - A * ll(v / B));

    cout << res << endl;
	
	if(infile.good()) infile.close();
	return 0;
	
}



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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

class item
{
public:
	int w, v;
	bool operator < (item& rhs){
		if(rhs.v == v)
			return rhs.w > w;
		return rhs.v < v;
	}
};

int N, W;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> N >> W;

	vector<item> items(N, item());
	REP(i, 0, N)
		cin >> items[i].w >> items[i].v;

	int minweight = items[0].w;
	vector<VVI> cache(N + 1, VVI(N + 1, VI((N + 1) * 3, 0)));
	for(int i = 0; i < N; ++i)
		for(int j = 0; j <= i; ++j)
			for(int h = 0; h <= 3 * j; ++h)
			{
				int& dp1 = cache[i + 1][j][h];
				int& dp2 = cache[i + 1][j + 1][h + items[i].w - minweight];

				dp1 = max(dp1, cache[i][j][h]);
				dp2 = max(dp2, items[i].v + cache[i][j][h]);

				int a = 10;
			}

	int ans = 0;
	for(int i = 0; i <= N; ++i)
	{
		for(int j = 0; j <= 3 * i; ++j)
		{
			LL curwt = (LL)minweight * i + j;
			if(curwt <= W)
				ans = max(ans, cache[N][i][j]);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12928
s = input()
n = len(s)
a = list(set(list(s)))
ans = 1000
for x in a:
    t = 0
    l = r = 0
    while l < n:
        while r < n and s[r] != x:
            r += 1
        t = max(t, r - l)
        l = r + 1
        r = l
    ans = min(ans, t)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
const lli inf = 1e18;
lli mod = 1e6 +3;

lli ExGCD(lli a, lli b, lli &x, lli &y){
	lli d=a;
	x=1; y=0;
	if(b!=0){ d=ExGCD(b, a%b, y, x); y-=a/b*x; }
	return d;
}
lli inverse(lli a){
	lli x,y;
	ExGCD(a, mod, x, y);
	return x>0? x: mod+x;
}

lli fact[1000004];
void maketable(){
	fact[0] = 1;
	for(int i=0; i<1000003; i++){
		fact[i+1] = fact[i]*(i+1) %mod;
	}
}

lli nCr(lli n, lli r){
	return fact[n] *inverse(fact[n-r]) %mod *inverse(fact[r]) %mod;
}

lli modpow(lli a, lli p){
	lli ret = 1;
	for(int i=63; i>=0; i--){
		ret *= ret;
		ret %= mod;
		if((1LL<<i & p) != 0){
			ret *= a;
			ret %= mod;
		}
	}
	return ret;
}

int main(){
	maketable();
	int q;
	cin >> q;
	for(int rep=0; rep<q; rep++){
		lli x,d,n;
		cin >> x >> d >> n;
		if(d == 0){
			cout << modpow(x, n) << endl;
			continue;
		}
		lli mxod = (mod-x)*inverse(d)%mod;
		if(mxod -n < 0){
			cout << 0 << endl;
			continue;
		}
		lli ans = 1;
		ans *= modpow(mod-d, n);
		ans %= mod;
		ans *= fact[mxod]*inverse(fact[mxod-n]);
		ans %= mod;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 8704