akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=1e5+5;
ll i,j;

/*


*/
ll dp[N];
void solve(){
	in2(n,W);
	for(ll item=0;item<n;item++){
		in2(w,v);
		for(i=W;i>=0;i--){
			if(i+w<=W){
				dp[i+w]=max(dp[i+w],dp[i]+v);
			}
		}
	}    
	ll best=0;
	for(i=0;i<=W;i++){
		best=max(best,dp[i]);
	}
	ce(best);
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}

/*


*/

  

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

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

int main() {
    ll K;
    cin>>K;

    vector<pair<ll, ll>> edges(K);
    for (ll k = 0; k < K; k++) {
        edges[k].first = (k+1)%K;
        edges[k].second = (k*10)%K;
    }

    // Dijkstra
    // priority_queue<(cost, to)>
    vector<ll> costs(K, inf);
    deque<pair<ll, ll>> q;
    q.push_front(make_pair(1, 1));
    while (!q.empty()) {
        auto p = q.front();
        q.pop_front();
        if (costs[p.second] < p.first) continue;
        costs[p.second] = p.first;
        if (p.second == 0) {
            cout<<p.first<<endl;
            return 0;
        }
        if (costs[edges[p.second].first] > p.first + 1)
            q.push_back(make_pair(p.first + 1, edges[p.second].first));
        if (costs[edges[p.second].second] > p.first)
            q.push_front(make_pair(p.first, edges[p.second].second));
    }
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define output(x) cout<<x<<endl;
#define fre(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define frd(i, a, b) for (int i = (int)(a); i >= b; --i)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int,int> > vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

const int maxn = 1100;
ll dp[maxn][20*maxn];
int w[maxn],s[maxn];
ll v[maxn];

int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);	
	int n;
	cin>>n;
	pair<int,int>p[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>w[i]>>s[i]>>v[i];
		p[i]={w[i]+s[i],i};
	}
	sort(p,p+n);
	// reverse(p,p+n);
	for (int i = 0; i < n; ++i)
	{
		int id=p[i].second;
		dp[i][w[id]]=v[id];
		if(i==0) continue;
		fre(j,1,s[id]){
			if(j+w[id] >= 20*maxn) break;
			dp[i][j+w[id]]=v[id]+dp[i-1][j];
		}
		fre(j,0,20*maxn){
			dp[i][j]=max(dp[i][j],dp[i-1][j]);
		}
	}
	ll ans=0;
	fre(i,0,20*maxn){
		ans=max(ans,dp[n-1][i]);
	}
	output(ans);
	return 0;
}

Measured memory_bytes: 172288
N, M, X = map(int,input().split())
A = list(map(int,input().split()))
ans0 = 0
ansn = 0
for i in range(X):
  if i in A: ans0 += 1
for i in range(X, N):
  if i in A: ansn += 1
print(min(ans0, ansn))  

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

int main(){
    int n;
    cin>>n;
    int dd=n%100;
    int uu=(n-dd)/100;
  	if(uu>=1&&uu<=12&&dd>=1&&dd<=12) cout<<"AMBIGUOUS"<<endl;
    else if(uu>=0&&uu<=99&&dd>=1&&dd<=12) cout<<"YYMM"<<endl;
    else if(uu>=1&&uu<=12&&dd>=0&&dd<=99) cout<<"MMYY"<<endl;
    else cout<<"NA"<<endl;
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N+1), B(N);
  
  for(int i=0; i<N+1; i++){
    cin >> A.at(i);
  }
  for(int i=0; i<N; i++){
    cin >> B.at(i);
  }
  
  int64_t cnt=0, dis=0;
  for(int i=0; i<N; i++){
    dis=A.at(i)-B.at(i);
    if(dis>=0){
      cnt += B.at(i);
      A.at(i) -= B.at(i);
      B.at(i)=0;
    }
    else{
      cnt += A.at(i);
      A.at(i)=0;
      B.at(i) = -dis;
    }
    dis=A.at(i+1)-B.at(i);
    if(dis>=0){
      cnt += B.at(i);
      A.at(i+1) -= B.at(i);
      B.at(i) = 0;
    }
    else{
      cnt += A.at(i+1);
      A.at(i+1) = 0;
      B.at(i) = -dis;
    }   
  }
  cout << cnt << endl;
  return 0;  
}
  

Measured memory_bytes: 1024
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

int A[maxn],has[maxn];

void Work(){
	if(A[n]!=A[n-1])return void(puts("Impossible"));
	REP(i,1,n)has[A[i]]++;
	if(A[n]&1){
		if(A[1]!=A[n]/2+1)return void(puts("Impossible"));
		if(has[A[1]]!=2)return void(puts("Impossible"));
		REP(i,A[1],A[n])if(has[i]<2)return void(puts("Impossible"));
		return void(puts("Possible"));
	}
	else{
		if(A[1]!=A[n]/2)return void(puts("Impossible"));
		if(has[A[1]]!=1)return void(puts("Impossible"));
		REP(i,A[1]+1,A[n])if(has[i]<2)return void(puts("Impossible"));
		return void(puts("Possible"));
	}
}

void Init(){
	read(n);
	REP(i,1,n)read(A[i]);
	sort(A+1,A+n+1);
}

int main(){
	Init();
	Work();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<functional>
#include<vector>
#include<map>
#include<string>
#include<math.h>
#include<set>
#include<string.h>
#include<unordered_set>
#include<unordered_map>
#include<list>
#include<queue>
#include<stack>
#include<deque>
using namespace std;

bool dp[3001];
signed main() {
	int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
	for (int i = 0; i *c <= f; i++) {
		dp[i*c] = true;
	}
	for (int i = 0; i <= f; i++) {
		for (int j = 0; i + j*d <= f; j++) {
			if (dp[i]) {
				dp[i + j*d] = true;
			}
		}
	}
	double m = 0;
	for (int i = 0; i <= 30; i++) {
		for (int j = 0; j <= 30; j++) {
			int k = i*a + j*b;
			for (int l = 0; l <= f; l++) {
				if (dp[l]) {
					if (k*100 + l <= f&&k*e>=l) {
						m = max(m, l / double(k + l));
					}
				}
			}
		}
	}
	for (int i = 0; i <= 30; i++) {
		for (int j = 0; j <= 30; j++) {
			int k = i*a + j*b;
			for (int l = 0; l <= f; l++) {
				if (dp[l]) {
					if (k *100+ l <= f&&k*e >= l) {
						if (l / double(k + l) == m) {
							cout << k*100+l << " " << l << endl;
							return 0;
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
typedef long long ll;
using namespace std;
int n;
void dfs(int i,string s){
    if(i==n-1){
        cout<<s<<endl;
        return;
    }else{
        int mx=0;
        rep(k,s.size()) mx=max(mx,s[k]-'a');
        rep(k,mx+2){
            string ss=s;
            ss+='a'+k;
            dfs(i+1,ss);
        }
    }
    return;
}
int main(void){
    cin>>n;
    dfs(0,"a");
    return 0;
}


Measured memory_bytes: 1536
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        //int n = sc.nextInt();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        long d = c - a - b;
        if (d>0 && 4*a*b < d*d) System.out.println("Yes");
        else System.out.println("No");

        sc.close();
    }
}

Measured memory_bytes: 23124
#!/usr/bin/env python

s = int(input())
mod = 10**9+7

if s == 1 or s == 2:
    print(0)
    exit()
if s == 3 or s == 4 or s == 5:
    print(1)
    exit()

dp = [0 for _ in range(s+1)]
dp[0] = dp[1] = dp[2] = 0 
dp[3] = dp[4] = dp[5] = 0 

for i in range(s+1):
    for j in range(i-3, 2, -1):
        dp[i] += dp[j]
    dp[i] += 1

ans = dp[s]%mod
print(ans)


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

int N;
string S;

bool nCr_mod2(int n, int r) {
    return n == (r | (n - r));
}

signed main() {

    cin >> N >> S;

    bool has_1 = false;
    for (auto&& c: S) { --c; has_1 |= c == '1'; }

    if (has_1) for (auto&& c: S) c = c == '2' ? '0' : c;
    else       for (auto&& c: S) c = c == '2' ? '1' : c;

    int res = 0;
    for (int i = 0; i < N; ++i) {
        res += nCr_mod2(N - 1, i) * (S[i] - '0');
    }
    res &= 1;

    if (not has_1) res <<= 1;
    cout << res << endl;

}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++){
        if(i%d==0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3580
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
//#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	int X; cin >> X;
	X -= 400;
	X /= 200;
	print(8 - X);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3616
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

graph = [[-1] * W for _ in range(H)]

tmp = 0
for i in range(H):
    if i % 2 == 0:
        for j in range(W):
            graph[i][j] = tmp + 1
            a[tmp] -= 1
            if a[tmp] == 0:
                tmp += 1
    if i % 2 == 1:
        for j in range(W - 1, -1, -1):
            graph[i][j] = tmp + 1
            a[tmp] -= 1
            if a[tmp] == 0:
                tmp += 1

for i in graph:
    print (*i)


Measured memory_bytes: 3920
# coding: utf-8
import re
import math
import fractions
import random
import heapq
import time
import sys
input = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
 
 
#main
N,Q=map(int,input().split())
E=[]
for a in range(N):
    s,t,x=map(int,input().split())
    E.append([s-x-0.5,1,x])
    E.append([t-x-0.5,-1,x])

for a in range(Q):
    E.append([int(input()),0,0])
E.sort(key=lambda x:x[0])
 
S=set()
H=[]
for time_,type_,x in E:
    if type_==1:
        #if(x in S):print(7329847)
        S.add(x)
        heapq.heappush(H,x)
    elif type_==-1:
        if(x in S):S.remove(x)
    else:
        while H and H[0] not in S:
            heapq.heappop(H)
        print(H[0] if H else -1)

Measured memory_bytes: 147812
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

using ll=int64_t;

#define rep(i,n) for(ll i=1;i<=n;i++)

int main() {
	ll n;
	cin >> n;
	ll ans = 1;
	rep(i, n) {
		ans *= i;
		ans %= 1000000007;
	}

	cout << ans;

}

Measured memory_bytes: 256
n,l = map(int,input().split())
taste_all = 0
taste_remain = 0
taste_ans = 0
taste_select = 1000000

for i in range(n):
    taste_all += l + i

for i in range(n):
    for j in range(n):
        if i != j:
            taste_remain += l + j
    temp = abs(taste_remain-taste_all)
    if temp < taste_select:
        taste_ans = taste_remain
        taste_select = temp
    taste_remain = 0

print(taste_ans)


Measured memory_bytes: 3064
n, k = map(int, input().split())
attacks = []
mxa = 0

for i in range(n):
    a, b = map(int, input().split())
    attacks.append([a, b])
    mxa = max(mxa, a)
attacks = sorted(attacks, key=lambda x: -x[1])

ans = 0
idx = 0
while k > 0:
    if idx < n and attacks[idx][1] > mxa:
        k -= attacks[idx][1]
        idx+=1
    else:
        ans += (k)//mxa
        if k%mxa != 0:
            ans += 1
        break
    ans+=1
print(ans)



Measured memory_bytes: 93488
input = input().split()

a = int(input[0])
b = int(input[1])

sum = a+b
min = a-b
seki = a*b

ans = 0
if sum > min:
    ans = sum
else:
    ans = min
if seki > ans:
    ans = seki
else:
    ans = ans

print(ans)



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

bool cmp(int a, int b)
{
    return (b<a);
}
int main() 
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n,cmp);
    cout<<endl;
    long long answer=0;
    int curr=0;
    for(int i=0; i<n-1; i++)
    {
        answer+=(long long)a[curr];
        if(i%2==0) curr++;
    }
    cout<<answer;
    return 0;
}

Measured memory_bytes: 4420
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/cdescription.jsp?cid=ACPC2017Day1&pid=C
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1<<30
ll N, K;
ll ans;
vector<pll> T;
vector<int> f1;
vector<ll> f2;
 
void solve(ll n, ll k) {
    k++;
    if (k > K)return;
    if (T[n].second > k) {
        T[n].second = k;
        f1[n] = 1;
        solve(T[n].first, k);
    }
    return;
}
 
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    ans = 0;
    cin >> N >> K;
    T.resize(N , { 0,INF });
    f1.resize(N , 0);
    f2.resize(N, 0);
    for (int i = 0; i < N;i++) {
        cin >> T[i].first;
        if (T[i].first == 0) {
            f1[i] = 1;
        }
        else {
            T[i].first--;
            f2[T[i].first] = 1;
        }
    }
 
    for (int i = 0; i < N;i++) {
        if (f2[i] == 0) {
            f1[i] = 1;
            solve(i, 0);
        }
    }
    for (int i = 0; i < N;i++) {
        if (f1[i] == 1)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;cin>>n>>m;
	int cnt = 0;
	int arr[n];
	for(int i = 0;i < n; ++i){
		cin>>arr[i];
		cnt += arr[i];
	}
	cnt+= 4*m - 1;
	cnt/=(4*m);
	int k = 0;
	for(int i = 0; i < n; ++i){
		if(arr[i] >=cnt){
			k++;
		}
	}
	cout<<(k>=m?"Yes":"No")<<endl;
	return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"errors"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

// NextLine reads a line text from stdin, and then returns its string.
func NextLine() string {
	sc.Scan()
	return sc.Text()
}

// NextIntsLine reads a line text, that consists of **ONLY INTEGERS DELIMITED BY SPACES**, from stdin.
// And then returns intergers slice.
func NextIntsLine() []int {
	ints := []int{}
	intsStr := NextLine()
	tmp := strings.Split(intsStr, " ")
	for _, s := range tmp {
		integer, _ := strconv.Atoi(s)
		ints = append(ints, integer)
	}
	return ints
}

// NextRunesLine reads a line text, that consists of **ONLY CHARACTERS ARRANGED CONTINUOUSLY**, from stdin.
// Ant then returns runes slice.
func NextRunesLine() []rune {
	return []rune(NextLine())
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// PowInt is integer version of math.Pow
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}
	fa := float64(a)
	fe := float64(e)
	fanswer := math.Pow(fa, fe)
	return int(fanswer)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	fa := float64(a)
	fanswer := math.Abs(fa)
	return int(fanswer)
}

// DeleteElement returns a *NEW* slice, that have the same and minimum length and capacity.
// DeleteElement makes a new slice by using easy slice literal.
func DeleteElement(s []int, i int) []int {
	if i < 0 || len(s) <= i {
		panic(errors.New("[index error]"))
	}
	// appendのみの実装
	n := make([]int, 0, len(s)-1)
	n = append(n, s[:i]...)
	n = append(n, s[i+1:]...)
	return n
}

// Concat returns a *NEW* slice, that have the same and minimum length and capacity.
func Concat(s, t []rune) []rune {
	n := make([]rune, 0, len(s)+len(t))
	n = append(n, s...)
	n = append(n, t...)
	return n
}

// sort package (snippets)
//sort.Sort(sort.IntSlice(s))
//sort.Sort(sort.Reverse(sort.IntSlice(s)))
//sort.Sort(sort.Float64Slice(s))
//sort.Sort(sort.StringSlice(s))

// copy function
//a = []int{0, 1, 2}
//b = make([]int, len(a))
//copy(b, a)

/*******************************************************************/

var a, b int

func main() {
	tmp := NextIntsLine()
	a, b = tmp[0], tmp[1]
	answer := (a + b) % 24
	fmt.Println(answer)
}


Measured memory_bytes: 640
# coding: utf-8
# このファイルはutf-8で書かれているため、日本語を書く場合は上の記述が必要

count_num = int( input())
text = input()

num_data = text.split(' ')

ans = 1
for i in num_data:
        if i == '0':
                ans = 0
                break

if ans == 1:
        for i in num_data:
                ans = ans * int(i)
                if ans > 1000000000000000000:
                        ans = -1
                        break

print(ans)

Measured memory_bytes: 19380
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    ll s;
    const int v=1e9;
    cin>>s;
    cout<<"0 0 1000000000 1 ";
    int x=(v-s%v)%v;
    int y=(s+v-1)/v;
    cout<<x<<' '<<y;
    return 0;
}


Measured memory_bytes: 256
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define f first
#define se second
#define Speedforce boost();
#define fop(s1, s2) freopen(s1, "r", stdin);freopen(s2, "w", stdout);

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const ll inf = 1e9 + 7;
const ld PI = acos(-1);

ll bin_pow(ll x, ll y){
    ll res = 1, base = x;
    while(y){
        if(y & 1){
            res *= base;
            res %= inf;
        }
        base *= base;
        base %= inf;
        y /= 2;
    }
    return res;
}

int n, a[105], m, sum;

int main(){
    Speedforce
    //fop("", "")
    cin >> n >> m;
    for(int i = 1;i <= n;i ++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a + 1, a + 1 + n);
    reverse(a + 1, a + 1 + n);
    for(int i = 1;i <= m;i ++){
        if(4 * m * a[i] < sum){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// ここにコードを挿入
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int t;
		if(k==1) {
			t=0;
		}else {
			t=n-k;
		}
		System.out.println(t);
	}

}

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

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

    vector<int> a(n);
    for (int i = 0; i < n; i++){
      cin >> a[i];
    }
    auto itr = a.begin();
    if (prev_permutation(a.begin(), a.end())){
      for (itr = a.begin(); itr!=a.end(); ++itr) {
        if (itr!=--a.end()){
          printf("%d ",*itr);
        }else{
          printf("%d\n",*itr);
        }
      }
    }else{
      printf("");
    }

    next_permutation(a.begin(), a.end());
    for (itr = a.begin(); itr!=a.end(); ++itr) {
      if (itr!=--a.end()){
        printf("%d ",*itr);
      }else{
        printf("%d\n",*itr);
      }
    }
    if (next_permutation(a.begin(), a.end())){
      for (itr = a.begin(); itr!=a.end(); ++itr) {
        if (itr!=--a.end()){
          printf("%d ",*itr);
        }else{
          printf("%d\n",*itr);
        }
      }
    }else{
      printf("");
    }
    return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007


int main(){
  int h,w;
  cin>>h>>w;
  char s[h][w];
  rep(i,h){
  	rep(j,w){
   		cin >>s[i][j];
    }
  }
  int error=0;
  rep(i,h){
  	rep(j,w){
   	  if(s[i][j]=='#'){
        int flag=0;
      	if(0<=i-1&&s[i-1][j]=='#'){flag=1;}
        if(j+1<w&&s[i][j+1]=='#'){flag=1;}
        if((i+1)<h&&s[i+1][j]=='#'){flag=1;}
        if(0<=(j-1)&&s[i][j-1]=='#'){flag=1;}
        if(flag==0){error=1;}
      }
    }
  }
  if(error==1){cout<<"No";}
  else{cout<<"Yes";}
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
lli solve(){
    lli a, b, c;
    cin>>a>>b>>c;
    if(a != c && a == b)
        cout<<"Yes\n";
    else if(a != b && a == c)
        cout<<"Yes\n";
    else if(b == c & a != c)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}


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

#define N 100
#define X 100

int n, x[N];

int main(void)
{
    cin >> n; 
    for (int i = 0; i < n; i++){
        cin >> x[i];
    }
    
    int powerMin = (1<<31)-1;
    for (int p = 0; p <= X; p++){
        int sum=0; 
        for (int i = 0; i < n; i++){
            sum += (x[i] - p)*(x[i] - p);
        }
        powerMin = min(sum,powerMin);
    }
       
    cout << powerMin << endl;
    
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

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

        int n = scan.nextInt();
        long t[] = new long[n];
        for(int i = 0;i < n;i++){
            t[i] = scan.nextLong();
        }

        long ans = t[0];
        for(int i = 0;i < n;i++){
            ans = lcm(ans, t[i]);
        }

        System.out.println(ans);
    }

    static long gcd (long a, long b){
        if(a%b == 0)return b;
        return gcd(b, a%b);
    }

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


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int n, a[300005];
int main() {
	cin >> n;
	for (int i=1; i<=n*3; i++) cin >> a[i];
	sort (a + 1, a + n * 3 + 1);
	long long ans = 0;
	int cnt = 0;
	for (int i=n*3-1; i>=1; i-=2) {
		if (cnt == n) break;
		ans += a[i];
		cnt++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s;
string t;
int q;
int cnt[2][100005];

int main(void){
	cin >> s;
	cin >> t;
	for(int i=0;i<s.size();i++){
		cnt[0][i+1]=cnt[0][i];
		if(s[i]=='A')cnt[0][i+1]++;
		else cnt[0][i+1]+=2;
	}

	for(int i=0;i<t.size();i++){
		cnt[1][i+1]=cnt[1][i];
		if(t[i]=='A')cnt[1][i+1]++;
		else cnt[1][i+1]+=2;
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int va=cnt[0][b]-cnt[0][a-1];
		int vb=cnt[1][d]-cnt[1][c-1];
		printf("%s\n",abs(va-vb)%3==0?"YES":"NO");
	}
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e5+5;
vector<ll> V;
ll dp[maxn][30];
int pos[maxn];
int main() {
    int n,L,Q;cin>>n;
    for(int i=1;i<=n;i++) cin>>pos[i];cin>>L>>Q;
	pos[n+1]=2e9+5;
	for(int l=1,r=1;l<=n;l++) {
		while(pos[r]-pos[l]<=L) r++;
		dp[l][0]=r-1;
	}
	for(int i=1;i<30;i++) for(int j=1;j<=n;j++)
		dp[j][i]=dp[dp[j][i-1]][i-1];
    for(int i=1;i<30;i++) for(int j=1;j<=n;j++)
    	if(dp[j][i]==0) dp[j][i]=n+1;
    while(Q--){
    	int l,r,ans=0;cin>>l>>r;
    	if(l>r) swap(l,r);
    	for(int i=29;i>=0;i--) {
    		if(dp[l][i]>=r) continue;
    		else ans+=(1<<i),l=dp[l][i];
    	}
   		cout<<ans+1<<endl;
    }
    return 0;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define getchar getchar_unlocked

using namespace std;

int Read(){
	char c = getchar();
	while(c > '9' || c < '0') c = getchar();
	int x = c - '0'; c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x;
}

const int N = 1e6 + 10;

int Begin[N], Next[N << 1], to[N << 1], e;

void add(int u, int v){
	to[++e] = v, Next[e] = Begin[u], Begin[u] = e;
}

int n, A[N];
bool f[N], vis[N];

void DFS(int o){
	vis[o] = true;
	f[o] = false;
	for(int i = Begin[o]; i; i = Next[i]){
		int u = to[i];
		if(A[u] >= A[o]) continue;
		if(!vis[u]) DFS(u);
		f[o] |= !f[u];
	}
}

int main(){
	n = Read();
	For(i, 1, n) A[i] = Read();
	For(i, 2, n){
		int u = Read(), v = Read();
		add(u, v), add(v, u);
	}

	For(i, 1, n) if(!vis[i]) DFS(i);

	bool fst = true;
	For(i, 1, n) if(f[i]){
		if(!fst) putchar(' ');
		fst = false;
		printf("%d", i);
	}
	return 0;
}

Measured memory_bytes: 6400
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define REP(i, x, n)	for(int i = x; i < n; ++i)
const int qq = 1e5 + 10;
int n;
LL sum[qq], num[qq];
bool cmp(LL a, LL b){
	return a > b;
}
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%lld", num + i);
	sort(num + 1, num + 1 + n, cmp);
	for(int i = n; i >= 1; --i)
		sum[i] = sum[i + 1] + num[i];
	int res = 1;
	for(int i = 2; i <= n; ++i)
		if((LL)2 * (num[i] + sum[i + 1]) >= num[i - 1])	res++;
		else{
			break;
		}
	printf("%d\n", res);
	return 0;
}


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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N;
  cin >> N;
  int ans = 0;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    while(a % 2 == 0){
      a /= 2;
      ans++;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

struct hoge {
  int w, l;
  char c;
  hoge(char c, int w, int l) : c(c), w(w), l(l) {}
};
bool operator<(const hoge &a, const hoge &b) {
  return a.w != b.w ? a.w > b.w : a.l < b.l;
}

int main() {
  int n;
  while(cin >> n, n)  {
    vector<hoge> v;
    REP(j,n) {
      char c;
      cin >> c;
      int a = 0, b = 0;
      REP(i,n-1) {
        int r;
        cin >> r;
        if (r == 0)
          a++;
        else if (r == 1)
          b++;
      }
      v.push_back(hoge(c,a,b));
    }
    sort(ALL(v));
    FOR(it,v)
      cout << it->c << endl;
  }
}

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    if (k == 1)
        printf("0\n");
    else
        printf("%d\n", n - k);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define faster ios::sync_with_stdio(false)
#define ll long long int
#define sz 200005
#define mp(x,y) make_pair(x,y) 
#define pii pair<long long int,long long int>
#define tor ::iterator
#define letsgo long long  int i,j,k,q=0,t,tmp,n,flg=0,cntr=0,maxxer = 0
#define fi first
#define se second
#define be begin()
#define en end()
#define mod 1000000007
#define debug(x) cout<<" "<<x<<endl

ll dp[105][100005] ;
ll knapsack(ll i,ll w,ll wt[],ll v[],ll n){
	// cout<<i<<"   "<<w<<"   "<<endl;
	if(i==n)
		return 0;
	if(dp[i][w]!=-1)
		return dp[i][w];
	if( wt[i]<= w){
		dp[i][w] = max(knapsack(i+1,w,wt,v,n)
			,knapsack(i+1,w-wt[i],wt,v,n)+v[i]);
	}
	else 
		dp[i][w] = knapsack(i+1,w,wt,v,n);
	return dp[i][w];
}
int main(){
	faster;
	letsgo; 
	ll w;
	cin>>n>>k;
	if(n>=13)
		cout<<k;
	else if(n<13 && n>=6)
		cout<<k/2;
	else
		cout<<0;

}

Measured memory_bytes: 256
from itertools import accumulate


def dfs(l, r):
    if memo[l][r]:
        return dp[l][r]
    for i in range(l, r):
        dp[l][r] = min(max(0, dp[l][r]), dfs(l, i) + dfs(i + 1, r) + acc_A[r] - acc_A[l - 1])
    memo[l][r] = True
    return dp[l][r]


n = int(input())
A = list(map(int, input().split()))
acc_A = [0] + list(accumulate(A))

INF = 10 ** 18
dp = [[INF] * (n + 1) for _ in range(n + 1)]
memo = [[False] * (n + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
    dp[i][i] = 0
    memo[i][i] = True


print(dfs(1, n))


Measured memory_bytes: 44764
Q = int(input())
query = [list(map(int, input().split())) for _ in range(Q)]

def is_prime(n):
  if n <= 1:
    return False
  if n == 2:
    return True
  i = 2
  while i * i <= n:
    if n % i == 0:
      return False
    i += 1
  return True

prime = [0]*100001
sum_a = [0]*100001
for n in range(1, 100000+1):
  if is_prime(n) and is_prime((n+1)//2):
    prime[n] = 1
  sum_a[n] = sum_a[n-1] + prime[n]

for l, r in query:
  print(sum_a[r] - sum_a[l-1])

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

using namespace std;

const int N = 305;
int n, a[N];
double dp[N][N][N];

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

	cout<<setprecision(15)<<"\n";
	cin>>n; 
	int one, two, three;
	one = two = three = 0;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		if(a[i] == 1)one++;
		if(a[i] == 2)two++;
		if(a[i] == 3)three++;
	}

	for(int k=0;k<=n;++k)
		for(int j=0;j<=n;++j)
			for(int i=0;i<=n;++i)if(i || j || k){
				dp[i][j][k] = (double)n/(i + j + k);
				if(i != 0)dp[i][j][k] += dp[i - 1][j][k]*i/(i + j + k);
				if(j != 0)dp[i][j][k] += dp[i + 1][j -1][k]*j/(i + j + k);
				if(k != 0)dp[i][j][k] += dp[i][j + 1][k -1]*k/(i + j + k);
			}

	cout<<dp[one][two][three]<<"\n";
	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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 (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	string s, p;
	cin >> s >> p;
	s += s;
	int a = s.find(p);
	if(a == string::npos)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3228
H, W = map(int,input().split())

def calc(a, b):
    diff=[]
    s = [0]*3
    s[0] = a*int(b/3)
    if (a*b-s[0])%2==0:
        s[1]=int((a*b-s[0])/2)
        s[2]=s[1]
    else:
        s[1]=int(max(a,b-int(b/3))/2)*min(a,b-int(b/3))
        s[2] = a*b-s[0]-s[1]
    diff.append(max(s)-min(s))
    
    s = [0]*3
    s[0] = a*(int(b/3)+1)
    if (a*b-s[0])%2==0:
        s[1]=int((a*b-s[0])/2)
        s[2]=s[1]

    else:
        s[1]=int(max(a,(b-int(b/3)-1))/2)*min(a,(b-int(b/3)-1))
        s[2] = a*b-s[0]-s[1]
    diff.append(max(s)-min(s))
    return min(diff)

print(min(calc(H,W), calc(W,H)))
    
                 


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

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

Measured memory_bytes: 3632
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int a = scan.nextInt();
        int b = scan.nextInt();
        int h = scan.nextInt();
            
        System.out.println( (a+b) * h / 2 );
	  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

int main() {
	ll x, a; cin >> x >> a;
	cout << ((x < a) ? 0 : 10) << endl;

	return 0;
}

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

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T &anth(T &a, const T &b){ return a = ant(a, b); }
template<class T> T &onth(T &a, const T &b){ return a = ont(a, b); }

int main(){
	int n, k;
	char s[100];
	std::cin >> n >> k >> s;
	for(int i = 0; i < n; ++i) putchar(i == k - 1 ? tolower(s[i]) : s[i]);
	putchar('\n');
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,d,m;
    vector<ll>vc,vc1;

    cin>>n;
    k=n/2;
    for(i=0;i<n;i++)
    {
        cin>>l;
        vc.push_back(l);

    }
    vc1=vc;
    sort(vc1.begin(),vc1.end());
    l=n-k;
    for(i=0;i<n;i++)
    {
        if(vc[i]>vc1[l-1])
        {
            cout<<vc1[l-1]<<endl;
        }
        else
        {
            cout<<vc1[l]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
 
int main()
{
    int n,m;
    scanf("%d %d\n",&n,&m);
    long long int x,y,z;
    long long int ans[8]={};
    long long int sum111[1005]={};
    long long int sum110[1005]={};
    long long int sum101[1005]={};
    long long int sum011[1005]={};
    long long int sum100[1005]={};
    long long int sum010[1005]={};
    long long int sum001[1005]={};
    long long int sum000[1005]={};
    REP(i,n)
    {
        scanf("%lld %lld %lld\n",&x,&y,&z);
        sum111[i]=x+y+z;
        sum110[i]=x+y-z;
        sum101[i]=x-y+z;
        sum011[i]=-x+y+z;
        sum100[i]=x-y-z;
        sum010[i]=-x+y-z;
        sum001[i]=-x-y+z;
        sum000[i]=-x-y-z;
    }
    sort(sum111,sum111+n,greater<long long int>());
    sort(sum110,sum110+n,greater<long long int>());
    sort(sum101,sum101+n,greater<long long int>());
    sort(sum011,sum011+n,greater<long long int>());
    sort(sum100,sum100+n,greater<long long int>());
    sort(sum010,sum010+n,greater<long long int>());
    sort(sum001,sum001+n,greater<long long int>());
    sort(sum000,sum000+n,greater<long long int>());
    REP(i,m)
    {
        ans[7]+=sum111[i];
        ans[6]+=sum110[i];
        ans[5]+=sum101[i];
        ans[3]+=sum011[i];
        ans[4]+=sum100[i];
        ans[2]+=sum010[i];
        ans[1]+=sum001[i];
        ans[0]+=sum000[i];
    }
    long long int max=0;
    REP(i,8)
    {
        if(max<ans[i])max=ans[i];
    }
    printf("%lld\n",max);
    return 0;
}

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

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    vector<int>v(m);
    for(int i=0;i<m;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    vector<int>aux;
    for(int i=1;i<v.size();i++)
        aux.push_back(v[i]-v[i-1]);
    sort(aux.begin(),aux.end());
    reverse(aux.begin(),aux.end());
    int res = v[v.size()-1]-v[0];
    for(int i=0;i<min((int)aux.size(),n-1);i++)
        res-=aux[i];
    cout<<res<<endl;
    return 0;
}


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

const int maxn=100010;
int n,m;
int fa[maxn];
int ans[maxn];
bool has[maxn];
int l[maxn],r[maxn];
int a[maxn];
struct Edge
{
	int v,next;
}	e[maxn<<1];
int g[maxn],tot;
void addedge(int x,int y)
{
	tot++;
	e[tot].v=y;
	e[tot].next=g[x];
	g[x]=tot;
}
void dfs(int t)
{
	if (a[t]!=-1)
	{
		l[t]=a[t];
		r[t]=a[t];
		has[t]=true;
	}
	for (int i=g[t];i;i=e[i].next)
	if (e[i].v!=fa[t])
	{
		fa[e[i].v]=t;
		dfs(e[i].v);
		if (!has[e[i].v])	continue;
		if (!has[t])
		{
			has[t]=true;
			l[t]=l[e[i].v]-1;
			r[t]=r[e[i].v]+1;
		}
		else
		{
			int _l=l[e[i].v]-1;
			int _r=r[e[i].v]+1;
			if ((_l%2 != l[t]%2) || (_r%2 != r[t]%2))
			{
				printf("No\n");
				exit(0);
			}
			l[t]=max(l[t],_l);
			r[t]=min(r[t],_r);
			if (l[t]>r[t])
			{
				printf("No\n");
				exit(0);
			}
		}
	}
	return;
}
void get_em(int t)
{
	ans[t]=ans[fa[t]]+1;
	for (int i=g[t];i;i=e[i].next)
	if (e[i].v!=fa[t])
		get_em(e[i].v);
	return;
}
void getans(int t)
{
	for (int i=g[t];i;i=e[i].next)
	if (e[i].v!=fa[t])
	{
		if (!has[e[i].v])
		{
			get_em(e[i].v);
			continue;
		}
		int _a=ans[t]-1;
		if (_a>=l[e[i].v] && _a<=r[e[i].v])
			ans[e[i].v]=_a;
		else
			ans[e[i].v]=ans[t]+1;
		getans(e[i].v);
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	scanf("%d",&m);
	for (int i=1;i<=n;i++)
		a[i]=-1;
	for (int i=1;i<=m;i++)
	{
		int v,x;
		scanf("%d%d",&v,&x);
		a[v]=x;
	}
	dfs(1);
	if (!has[1])
		get_em(1);
	else
	{
		ans[1]=l[1];
		getans(1);
	}
	printf("Yes\n");
	for (int i=1;i<=n;i++)	printf("%d\n",ans[i]);
	return 0;
}

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

int main(){
    int N;ll x;cin>>N>>x;
    vector<ll> a(N);
    for(int i=0;i<N;i++)cin>>a.at(i);
    ll ans=0;
    if(a.at(0)>x){
        ans+=a.at(0)-x;
        a.at(0)=x;
    }
    for(int i=0;i<N-1;i++){
        if(a.at(i)+a.at(i+1)>x){
            ans+=a.at(i+1)+a.at(i)-x;
            a.at(i+1)=x-a.at(i);
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024