akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

r = 0
result = 0

for i in range(n):
    if a[i] < r + b[i]:
        result += a[i]
        r = min(b[i] + r - a[i], b[i])
    else:
        result += r + b[i]
        r = 0

if a[n] < r:
    result += a[n]
else:
    result += r
        
print(result)

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

using namespace std;  

const int maxn = 1e5 + 5;

int n;
vector<int> e[maxn];
long long a[maxn];
bool dfs(int x, int fa) {
	if(e[x].size() == 1) return true;
	long long sum = 0, mx = 0;
	for(auto &it : e[x]) {
		int v = it;
		if(v == fa) continue;
		if(!dfs(v, x)) return false;
		sum += a[v];
		mx = max(mx, a[v]);
	}
	mx = min(sum - mx, sum / 2);
	long long tmp = sum - a[x];
	if(tmp < 0 || tmp > mx) return false;
	a[x] -= tmp;
	if(x == fa) return a[x] == 0;
	return true;
}
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}
	for(int i = 1; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	if(n == 2) {
		a[1] == a[2] ? printf("YES\n") : printf("NO\n");
		return 0;
	}
	int pos = -1;
	for(int i = 1; i <= n; i++) {
		if(e[i].size() != 1) {
			pos = i;
			break;
		}
	}
	dfs(pos, pos) ? printf("YES\n") : printf("NO\n");
	return 0;
}

Measured memory_bytes: 13184
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int A, B;
    cin >> A >> B;

    int ans;
    if (A + B == 3) ans = 3;
    else if (A + B == 4) ans = 2;
    else if (A + B == 5) ans = 1;

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ii pair<int, int>
#define iill pair <ii, ll>
#define lli pair<ll, int>
#define MAXN 100010
#define EPS 1e-9
#define MAXLOG 
#define INF (long long) 1e18
#define MOD 
#define prt(a) printf("%d\n", a)
#define prt2(a, b) printf("%d %d\n", a, b)
#define prt3(a, b, c) printf("%d %d %d\n", a, b, c)
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d %d", &a, &b)
#define sc3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define readArr(arr, n) for (int i=0; i<n; i++) scanf("%d", &arr[i]);
#define EPS 1e-9
#define ll long long
using namespace std;

struct aresta {
	int de, para;
	ll custo;

	aresta (int a, int b, ll c) : de(a), para(b), custo(c) {}
};

int main() {
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	int n, m;
	ll p;
	scanf("%d %d %lld", &n, &m, &p);

	int de, para;
	ll custo;
	vector <aresta> are;
	for(int i=0; i<m; i++) {
		scanf("%d %d %lld", &de, &para, &custo);
		are.emplace_back(de, para, p - custo);		
	}

	ll dist[MAXN];
	for (int i=0; i<MAXN; i++) dist[i] = INF;
	dist[1] = 0;

	for (int i=1; i<=n*2; i++) {
		for (aresta a : are) {
			if (dist[a.de] == INF) continue;
			if (dist[a.para] > dist[a.de] + a.custo) {
				dist[a.para] = dist[a.de] + a.custo;
				if (i >= n && a.para == n) {
					printf("-1\n");
					return 0;
				}
			}
		}
	}

	printf("%lld\n", max(0LL, -dist[n]));

	return 0;
}






Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=1e6+5,M=5e3+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
vector<int>e[N],o[N];;
int fa[N],n;
int gao(int x){
	if(!e[x].size())return 0;
	re(i,0,e[x].size())o[x].pb(gao(e[x][i]));
	sort(o[x].begin(),o[x].end());reverse(o[x].begin(),o[x].end());
	int res=0;
	re(i,0,o[x].size())gmax(res,o[x][i]+i+1);
	return res;
}
int main(){
	read(n);rep(i,2,n)read(fa[i]),e[fa[i]].pb(i);
	cout<<gao(1);
}

Measured memory_bytes: 63488
#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.at(i);
  
  sort(a.begin(),a.end());
  
  cout << a.at(n-1)-a.at(0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;



int n;
#define MAX 100002

vector<int> v[MAX];
int gr[MAX];

inline void dfs(int b,int pr=-1) {
	if (v[b].size() == 1 && pr != -1) {
		gr[b] = 0;
		return;
	}
	for (int i = 0; i < v[b].size(); i++) {
		int go = v[b][i];
		if (go != pr) {
			dfs(go,b);
			gr[b] ^= (gr[go] + 1);
		}
	}
}

int main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0);
	if (gr[0]) {
		puts("Alice");
	}
	else {
		puts("Bob");
	}
	return 0;
}

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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long a, b;
vector<long long> v;

long long solve();

int main() {
  cin >> a >> b;

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long now = GCD(a, b), ans = 1;
  for(long long i = 2; i * i <= now; ++i) {
    if(now % i == 0) {
      ++ans;
      while(now % i == 0) now /= i;
    }
  }
  if(now > 1) ++ans;
  return ans;
}

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

#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; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


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

    string s;cin>>s;
    REP(i,3){
        if (s[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3604
s = input()
m = len(s)
sl = [0]*m
for i in range(m):
    sl[i] = s[i]
pre = sl[0]
ans = 0

for i in range(m-1):
    if sl[i+1] == pre:
        ans += 1

        if sl[i+1] == "0":
            sl[i+1] = "1"
        else:
            sl[i+1] = "0"
            
        pre = sl[i+1]

    else:
        pre = sl[i+1]
    
print(ans)


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll n, m, ans = 0;
string s;
vector<ll> z1, z2;
int main() {
	cin >> n >> m;
	cin >> s;
	REP(i, s.size() - 1) {
		if (s[i] == '1' and s[i + 1] == '0')z1.push_back(i + 1);
		if (s[i] == '0' and s[i + 1] == '1')z2.push_back(i);
	}
	if (s[0] == '0')z1.push_back(0);
	if (s[s.size() - 1] == '0')z2.push_back(s.size() - 1);
	sort(ALL(z1));
	sort(ALL(z2));
	//REP(i, z1.size())cout << z1[i] << endl;
	//REP(i, z2.size())cout << z2[i] << endl;
	if (z1.size() == 0) {
		ans = n;
	}
	else {
		REP(i, z1.size()) {
			ll nz2 = z2[min(i + m - 1, (ll)z2.size() - 1)];
			ll now = nz2 - z1[i] + 1;
			if (i == 0)now += z1[i];
			else now += z1[i] - z2[i - 1] - 1;
			if (min(i + m - 1, (ll)z2.size() - 1) == (ll)z2.size() - 1)now += s.size() - nz2 - 1;
			else now += z1[min(i + m - 1, (ll)z2.size() - 1) + 1] - z2[min(i + m - 1, (ll)z2.size() - 1)] - 1;
			//cout << now << endl;
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1404
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        _: usize,
        c: Chars,
    };
    let count_r = c.iter().filter(|&&c_i| c_i == 'R').count();
    let ans = c[0..count_r].iter().filter(|&&c_i| c_i == 'W').count();
    println!("{}", ans);
}


Measured memory_bytes: 3056
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int count = 0;
    while(B <= A){
        B *= 2;
        count++;
    }
    while(C <= B){
        C *= 2;
        count++;
    }
    if (count <= K) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3640
h,w=map(int,input().split())
s=['.'*(w+2)]
for i in range(h):
    s.append('.'+input()+'.')
s.append('.'*(w+2))
for i in range(1,h+1):
    for j in range(1,w+1):
        if (s[i-1][j]==s[i][j-1]==s[i][j+1]==s[i+1][j]=='.')&(s[i][j]=='#'):
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
function main(input){
    let lines = input.split("\n");
    let args = lines[0].split(" ").map(item=>parseInt(item));
    let height = args[0];
    let width = args[1];
    let rows = lines.slice(1)
    let colSum = new Array(width+1).fill(0);
    let put = "";
    for(let i=0;i<height;i++){
        let sum =0;
        let row = rows[i].split(" ");
        for(let j=0;j<width;j++){
            sum+= parseInt(row[j]);
            colSum[j]+=parseInt(row[j]);
        }
        colSum[width]+=sum;
        put= put + rows[i]+" "+sum+"\n";
    }
    put = put+colSum.join(" ");
    console.log(put);
}



main(require("fs").readFileSync("/dev/stdin","utf-8"));


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

int S[2], T[2];

int main(){
	scanf("%d%d%d%d", &S[0], &S[1], &T[0], &T[1]);
	for(int i = 0; i < T[1] - S[1]; i++) printf("U");
	for(int i = 0; i < T[0] - S[0]; i++) printf("R");
	for(int i = 0; i < T[1] - S[1]; i++) printf("D");
	for(int i = 0; i < T[0] - S[0]; i++) printf("L");
	printf("L");
	for(int i = 0; i <= T[1] - S[1]; i++) printf("U");
	for(int i = 0; i <= T[0] - S[0]; i++) printf("R");
	printf("DR");
	for(int i = 0; i <= T[1] - S[1]; i++) printf("D");
	for(int i = 0; i <= T[0] - S[0]; i++) printf("L");
	printf("U\n");
	return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int n,w;
ll dp[222][11111];

void clear_dp(int a) {
	for(int i = a + 1;i <= n;i++){
		for(int j = 0;j <= w;j++){
			dp[i][j] = 0;
		}
	}
}

int main(){

	cin >> n >> w;
	vector<int> v(n);
	REP(i,n)cin >> v[i];

	sort(ALL(v));

	ll sum = 0;
	ll ans = 0;
	REP(i,n){
		clear_dp(i);
		if(sum > w)continue;
		dp[i+1][sum] = 1;
		for(int ii = i+1;ii < n;ii++){
			for(int jj = 0;jj <= w;jj++)if(dp[ii][jj]){
				if(jj + v[ii] <= w)(dp[ii+1][jj + v[ii]] += dp[ii][jj]) %= MOD;
				(dp[ii+1][jj] += dp[ii][jj]) %= MOD;
			}
		}

		for(int ii = 0;ii <= w;ii++) {
			if(ii + v[i] > w)(ans += dp[n][ii]) %= MOD;
		}
		sum += v[i];
	}
	if(sum <= w)(ans+=1)%=MOD;
	cout << ans << endl;

	return 0;
}



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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<double> x(N);
    vector<string> u(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> u[i];

    double sum = 0;
    for (int i = 0; i < N; i++) {
        if (u[i] == "JPY")
            sum += x[i];
        else
            sum += x[i] * 380000;
    }
    cout << sum << endl;

    return 0;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int n;
    cin >> n;
    double ret = 0;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        ret += 1.0 / x;
    }
    double ans = 1.0 / ret;
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3808
character(10**5) S
character(5)::dream="dream"
character(7)::dreamer="dreamer"
character(5)::erase="erase"
character(6)::eraser="eraser"
integer start
logical check
read*,S
start=1
check=.TRUE.
do
  if(S(start:start+6)==dreamer.and.S(start+7:start+7)/="a")then
    start=start+7
  else if(S(start:start+4)==dream)then
    start=start+5
  else if(S(start:start+5)==eraser)then
    start=start+6
  else if(S(start:start+4)==erase)then
    start=start+5
  else
    check=.false.
    exit
  endif
  if(start==len_trim(S)+1)exit
end do

print"(A)",trim(merge("YES","NO ",check))
end

Measured memory_bytes: 700
import java.io.*;

class Main {
    public static void main(String[] args) {
    	
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	boolean end = false;
		try {
			while(end == false){
				//??\?????????????????????
		    	String temp = br.readLine();
		    	String[] numbers = temp.split(" ");//????????¨??????????????????
		    	int H = Integer.parseInt(numbers[0]);;//??????
		    	int W = Integer.parseInt(numbers[1]);;//???
		    	
		    	if(H <= 300  && H >= 3 && W <= 300 &&  W >= 3){
			    	//????§???¢??????????????????
			    	for(int i = 0; i < H ; i++){
			    		
			    		if(i == 0 || i == H - 1){
				    		for(int j = 0; j < W ; j++){
				    			System.out.print("#");
				    		}
			    		}else{
			    			System.out.print("#");
				    		for(int j = 1; j < W - 1; j++){
				    			System.out.print(".");
				    		}
				    		System.out.print("#");
			    		}

			    		System.out.println();//?¬??????????
			    	}
			    	System.out.println();//??????

		    	}else if(H == 0 && W == 0){
		    		end = true;//HW?????????0??????????????????
		    	}
			}
	    	
		} catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		}
    }
 }

Measured memory_bytes: 30572
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 21145141919
typedef pair<int, int>P;
struct edge { int to, cost; };

signed main() {
	int i, o, t, j, l, s, z; cin >> i >> o >> t >> j >> l >> s >> z;
	int a = o + (i / 2) * 2 + (j / 2) * 2 + (l / 2) * 2;
	i--, j--, l--;
	int b = 0;
	if ((i + 1) && (j + 1) && (l+1))b+=3;
	b += o + (i / 2) * 2 + (j / 2) * 2 + (l / 2) * 2;
	cout << max(a, b) << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std ;
typedef long long ll ;
const int maxx = 2e3+5;
int ans[maxx];
vector < int > g[maxx];
void bfs(int idx)
{
    vector < int > lvl(maxx,0);
    queue < int > q ;
    q.push(idx);
    lvl[idx]=1;
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        for(int i=0;i<g[u].size();i++)
        {
            int v = g[u][i] ;
            if(lvl[v]==0)
            {
                lvl[v]=lvl[u]+1;
                ans[lvl[u]]++;
                q.push(v);
            }
        }
    }
}
int main()
{
    int n,x,y;
    cin >> n >> x >> y ;
    for(int i=1;i<n;i++)
    {
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);
    for(int i=1;i<=n;i++)
    {
        bfs(i);
    }
    for(int i=1;i<n;i++){cout << ans[i]/2 << endl;}
    return 0 ;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

ll solve(string s, int k){
  // 0以上N以下の整数であって、条件を満たすものの個数を求めよ
  // 条件：10進法で表した時、0でない数字が丁度K個ある
  const int L = s.size();
  
  vector<vector<vector<ll>>> dp(L+1, vector<vector<ll>>(2, vector<ll>(5, 0)));
  // dp[i][j][k]...i桁決定、jはN未満フラグ、kは0でない数字の個数(0,1,2,3,4。4はバッファ)

  dp.at(0).at(0).at(0) = 1;

  for (int i=0; i<L; i++){
    int D = s.at(i) - '0';
    for (int j=0; j<2; j++){
      for (int k=0; k<4; k++){
        for (int d=0; d<=(j ? 9 : D); d++){
          /* 添え字の遷移について
          i...次へ行くので必ずi+1
          j...元々1なら1。0なら、dがD未満なら1, そうでなければ0
          k...d==0ならそのまま。d!=0ならプラス1。
          */
          dp.at(i+1).at(j || (d < D)).at(k + (d != 0)) += dp.at(i).at(j).at(k);
          // dp.at(i+1).at(j || (d < D)).at(k || d == 4 || d == 9) += dp.at(i).at(j).at(k);
        }
      }
    }
  }
  return dp.at(L).at(0).at(k) + dp.at(L).at(1).at(k);
}

int main() {
  string s; cin >>s;
  int k; cin >>k;

  cout <<solve(s, k) <<endl;
}

Measured memory_bytes: 256
N,K,L=map(int,input().split())
G=[[] for i in range(N)]
H=[[] for i in range(N)]
#T=[-1 for i in range(N)]
#B=[-1 for i in range(N)]
for i in range(K):
    p,q=map(int,input().split())
    G[p-1].append(q-1)
    G[q-1].append(p-1)
for i in range(L):
    r,s=map(int,input().split())
    H[r-1].append(s-1)
    H[s-1].append(r-1)
def bfs(A):
    k=1
    q=[]
    reached=[0 for i in range(N)]
    res=[0 for i in range(N)]
    for i in range(N):
        if reached[i]==1:
            continue
        q.append(i)
        while(len(q)>0):
            r=q[-1]
            q.pop()
            res[r]=k
            for p in A[r]:
                if reached[p]==1:
                    continue
                q.append(p)
                reached[p]=1
        k+=1
    return res
T=bfs(G)
B=bfs(H)
TB=[(T[i],B[i]) for i in range(N)]
D=dict()
for i in range(N):
    if TB[i] in D:
        D[TB[i]]+=1
    else:
        D[TB[i]]=1
ans=[str(D[TB[i]]) for i in range(N)]
print(" ".join(ans))

Measured memory_bytes: 128076
#include <stdio.h>
int main () {
  int n;
  char p,dummy;    //char型は文字列を入れる型
  int input;
  int arr[4][13];   //int[a][b]でa*bの二次元配列に記録する
  int i,j;

  for(i = 0; i < 4; i++){
    for(j = 0; j < 13; j++){
      arr[i][j] = 0;
    }
  }

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%c",&dummy);
    scanf("%c %d",&p,&input);
    switch(p){
    case 'S':
      arr[0][input -1] = 1;
      break;
    case 'H':
      arr[1][input -1] = 1;
      break;
    case 'C':
      arr[2][input -1] = 1;
      break;
    case 'D':
      arr[3][input -1] = 1;
      break;
    }
  }

  for(i = 0; i < 4; i++){
    for(j = 0; j < 13; j++){
      if(arr[i][j] == 0){
	switch(i) {
	case 0:
	  printf("S %d\n",j + 1);
	  break;
	case 1:
	  printf("H %d\n",j +1);
	  break;
	case 2:
	  printf("C %d\n",j +1);
	  break;
	case 3:
	  printf("D %d\n",j + 1);
	  break;
	}
      }
    }
  }
  return 0;
}


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

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
	//freopen("input.txt", "r", stdin);
	
	int n; cin>>n;
	vector<int> a(n), b(n);
	
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
		 b[i] = a[i];
	}
	sort(b.begin(), b.end());
	
	for(int i=0; i<n; i++)
	{
		if(a[i] == b[n-1]) cout<<b[n-2]<<"\n";
		else cout<<b[n-1]<<"\n";
	}
	
	
	
	
	
}

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

const int MAXN=500000;
int n,D,d[MAXN],Q,q[MAXN];
int tar[MAXN+1],t[MAXN+1];

inline int _abs(int a) {return a<0 ? -a : a;}
void proc() {
	int cd=D;
	for(int i=0;i<n;i++) {
		tar[i] = cd;
		if(cd > _abs(cd-d[i])) cd = _abs(cd-d[i]);
	}
	for(int i=n-1;i>=0;i--) {
		if(d[i+1] <= 2*t[i+1]+1) t[i] = t[i+1]+d[i+1];
		else t[i] = t[i+1];
	}
}
int main() {
	scanf("%d%d",&n,&D);
	for(int i=0;i<n;i++) scanf("%d",d+i);

	proc();
	scanf("%d",&Q);
	while(Q--) {
		int idx;
		scanf("%d",&idx);
		idx--;
		if(tar[idx] <= t[idx]) puts("NO");
		else puts("YES");
	}

	return 0;
}


Measured memory_bytes: 9728
void main()
{
    int n = readln.chomp.to!int;
    string s = readln.chomp;

    writeln(s.count('R') > s.count('B') ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
def main():
    N=int(input())
    A1N=[int(_) for _ in input().split()]
    A2N=[int(_) for _ in input().split()]
    ans=0
    for i in range(N):
        ans=max(ans,sum(A1N[:i+1]+A2N[i:]))
    print(ans)
main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int A, B;
  cin >> A >> B;

  if (A + B >= 10) cout << "error" << endl;
  else cout << A + B << endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string s;
  cin >> s;

  for (int i = 0; i < s.length(); i++) {
    for (int j = i; j < s.length(); j++) {
      string frag = s.substr(0, i) + s.substr(j, s.length());
      if (frag == "keyence") {
        cout << "YES";
        return 0;
      }
    }
  }
  cout << "NO";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    int ans = 0, cur = 0;
    for(char c: s) {
        if (c == 'g') {
            cur += 1;
        } else {
            cur -= 1;
        }
        if (cur < 0) {
            cur = 0;
            ans -= 1;
        }
    }
    ans += cur / 2;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  map<int, int> mp;
  ll ans =0;
  rep(i,n) {
    int dif = i-a[i];
    int sum = i+a[i];
    ans += mp[dif];
    mp[sum]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 21028
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000;
const long long MOD = 1000000007;

std::vector<bool> IsPrime;

void sieve(size_t max)
{
  if (max + 1 > IsPrime.size())
  {                                // resizeで要素数が減らないように
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
  }
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない

  for (size_t i = 2; i * i <= max; ++i)     // 0からsqrt(max)まで調べる
    if (IsPrime[i])                         // iが素数ならば
      for (size_t j = 2; i * j <= max; ++j) // (max以下の)iの倍数は
        IsPrime[i * j] = false;             // 素数ではない
}

class Pointer{
public:
  long long p;
  long long w;
};

int main()
{
  long long H, W;
  cin >> H >> W;
  string updown;
  for (int i = 0; i < W+2;i++)
    updown += '#';

  cout << updown << endl;
  for (int i = 0; i < H;i++){
    string s;
    cin >> s;
    s = "#" + s + "#";
    cout << s << endl;
  }
  cout << updown << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long x = sc.nextLong();
		if(2*x < n){
			x = n-x;
		}
		long ans = 0;
		long m;
		while(x != 0){
			if(2*x < n){
				x = n-x;
			}
			m = n-x;
			ans += (x-x%m) * 3;
			n = m + x%m;
			x = n-m;
		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 9548
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> K;
    vi a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    dump(a);
    cout << a[K - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010];
int main()
{
    int i, j, k;
    ll H, N;
    cin >> H >> N;
    ll sum = 0;
    for(i = 0; i < N; i++) {
        ll tmp;
        scanf("%I64d", &tmp);
        sum += tmp;
    }
    if(H > sum) {
        puts("No");
    }
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> 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;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n,m;
    cin>>n>>m;
    int x[n];
    int tot=0;
    forn(i,n){
        cin>>x[i];
        tot += x[i];
    }
    sort(x,x+n);
    bool flag = true;
    for(int i=n-1;i>=n-m;i--){
        if(4*m*x[i]<tot){
            flag = false;
            break;
        }
    }
    if(flag)    cout<<"Yes\n";
    else        cout<<"No\n";
    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
fast;
ll n;cin>>n;
ll ans=1,t=n;
while(t%360!=0)
{
       ans++;
t+=n;
}
cout<<ans;

return 0;
}


Measured memory_bytes: 3636
import sys

n, m = map(int, sys.stdin.readline().split())
graph = [[] for _ in range(n+1)]
for _ in range(m):
    x, y, z = map(int, sys.stdin.readline().split())
    graph[x].append(y)
    graph[y].append(x)

def main():
    to_check = set(range(1, n+1))
    checked = set()
    cnt = 0
    while to_check:
        queue = set([to_check.pop()])
        cnt += 1
        while queue:
            v = queue.pop()
            checked.add(v)
            to_check -= set([v])
            for u in graph[v]:
                if not u in checked:
                    queue.add(u)
    return cnt

if __name__ == '__main__':
    ans = main()
    print(ans)

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

void solve() {
	int n, f, l;
	cin >> n;
	
	f = n / 100;
	l = n % 100;
	
	if ( ( f >= 1 and f <= 12 ) and ( l >= 1 and l <= 12 ) ) {
		cout << "AMBIGUOUS\n";
	}
	else if ( f >= 1 and f <= 12 ) {
		cout << "MMYY\n";
	}
	else if ( l >= 1 and l <= 12 ) {
		cout << "YYMM\n";
	}
	else {
		cout << "NA\n";
	}
}

int main() {
	precal();
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
MOD = 10**9+7
 

def input():
    return sys.stdin.readline()[:-1]
 

def main():
    n = int(input())
    a = list(map(int, input().split()))
    for i in a:
        if i%2==0:
            if i%3==0 or i%5==0:
                continue
            else:
                print('DENIED')
                exit()
    print("APPROVED")
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#https://atcoder.jp/contests/abc153/tasks/abc153_c
N,K =map(int,input().split())
M_List = sorted(list(map(int,input().split())))
if K == 0:
    print(sum(M_List))
elif N<=K:
    print(0)
else:
    print(sum(M_List[:K*(-1)]))

Measured memory_bytes: 31312
#include<stdio.h>
int main(){
  int i,j,n,temp;
  int a[100];
  int count=0;
  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%d",&a[i]);
  }

  for(i=0; i<n-1; i++){
    for(j=n-1; j>i; j--){
      if(a[j]<a[j-1]){
	temp=a[j];
	a[j]=a[j-1];
	a[j-1]=temp;
	count+=1;
      }
    }
  }
  
  for(i=0; i<n; i++){
    if(i!=n-1){
    printf("%d ",a[i]);
    }
    else{
      printf("%d",a[i]);
    }
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2104
module Main where

import           Data.Char (isLower, isUpper)
import Text.ParserCombinators.ReadP (ReadP, char, satisfy, many, eof)
import Control.Monad.State
import Data.List (delete)

parser :: ReadP ()
parser = char 'A' *> lowerChar *> many lowerChar *> char 'C' *> many lowerChar *> lowerChar *> eof
-- parser = char 'A' *> many1 lowerChar *> char 'C' *> many1 lowerChar *> eof

lowerChar :: ReadP Char
lowerChar = satisfy isLower

-- f :: String -> Result
-- f s = if not . null . readP_to_S parser $ s then AC else WA

main :: IO ()
-- main = interact $ show . f
main = print . f =<< getLine

data Result
  = AC
  | WA
  deriving (Show, Eq)

f :: String -> Result
f s = if isHeadA s && containsC s && isRemainLower s then AC else WA

isHeadA :: String -> Bool
isHeadA ('A' : _) = True
isHeadA _         = False

containsC :: String -> Bool
containsC = (1 ==) . length . filter ('C' ==) . init . drop 2

isRemainLower :: String -> Bool
isRemainLower = all isLower . remain

remain :: String -> String
remain s =
  -- filter (`notElem` "AC") s
  delete 'A' $ delete 'C' s

  -- let
  --   middle = filter ('C' /=) . init . drop 2
  -- in
  --   (s !! 1 : middle s) ++ [last s]

tests :: [Bool]
tests =
  [ test1
  , test2
  , test3
  , test4
  , test5
  ]

test1, test2, test3, test4, test5 :: Bool
test1 = f "AtCoder" == AC
test2 = f "ACoder" == WA
test3 = f "AcycliC" == WA
test4 = f "AtCoCo" == WA
test5 = f "Atcoder" == WA

-- f :: String -> Result
-- f s = runState (mapM (g (length s)) $ zip [0..] s) 0

-- g :: Int -> (Int, Char) -> State Int Bool
-- g l (0, c)
--   | c /= 'A' = return False
-- g l (i, c)
--   | isUpper c = do
--     if i == 0 || i == l - 1 || c /= 'C'
--       then return False
--       else modify succ

-- g _ _ = return True


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define pii pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (ll i = a; i <= (ll)b; ++i)
#define per(i, a, b) for (ll i = a; i >= (ll)b; --i)
#define ll long long
#define lowbit(x) ((x) & (-x))
#define debug(...) fprintf(stderr, __VA_ARGS__)
inline int __gcd(int a,int b) {return b>0 ? __gcd(b,a%b):a;}

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

int a[110];
void solve()
{
    int n,m; cin>>n>>m;
    int sum=0;
    rep(i,1,n) cin>>a[i],sum+=a[i];
    int cnt=0;
    rep(i,1,n){
        if(1ll*a[i]*4*m>=sum) cnt++;
    }
    if(cnt<m) cout<<"No\n";
    else cout<<"Yes\n";
}
int main()
{
    #ifndef local
    IOS
    #endif
    cout<<fixed<<setprecision(10);
    int t=1; 
    //cin>>t; 
    while(t--) {
        solve();
    }
}




Measured memory_bytes: 256
#include <iostream>
#include "fstream"
using namespace std;
#define O freopen("in.txt","r",stdin);

int main()
{
	//O
	long long N,D;
	cin>>N>>D;
	int cnt=0;
	for(int i=1;i<=N;i++)
	{
		long long a,b;
		cin>>a>>b;

		if( a*a + b*b<= D*D)
			cnt++;
	}
	cout<<cnt;


	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REREASE
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
int main(){
    long double A,B;
    cin>>A>>B;
    if(A==0&B==0){
        cout<<0;return 0;
    }
    REP(i,1000){
        s(floor(i*0.08),floor(i*0.10));
        if(floor(i*0.08)==A&&floor(i*0.10)==B){
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
    
    
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int n; cin >> n;
    int p[n]; rep(i, n) cin >> p[i];

    string ans = "YES";
    int swap = 0;
    for(int i = n - 1; 0 <= i; i--){
        for(int j = 0; j < i + 1; j++){
            if(p[j] <= p[i]) continue;
            if(p[i] < p[j] && swap == 0){
                int tmp = p[j];
                p[j] = p[i];
                p[i] = tmp;
                swap++;
            }else{
                swap++;
                ans = "NO";
                break;
            }
        }
        if(1 < swap) break;
    }
    OP(ans);
}


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

int main() {
  int a,b,m;
  cin>>a>>b>>m;
  vector<int> rcost(a);
  for(int i; i<a; i++){
    cin>>rcost.at(i);
  }
  vector<int> dcost(b);
  for(int i; i<b; i++){
    cin>>dcost.at(i);
  }
  int x,y,c, sum=1000000;
  for(int i; i<m; i++){
    cin>>x>>y>>c;
    if(sum>=rcost.at(x-1)+dcost.at(y-1)-c)
      sum=rcost.at(x-1)+dcost.at(y-1)-c;
  }
  sort(rcost.begin(),  rcost.end());
  sort(dcost.begin(),  dcost.end());
  if(rcost.at(0)+dcost.at(0)<=sum)
    cout<<rcost.at(0)+dcost.at(0)<<endl;
  else
    cout<<sum<<endl;
  
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def dfs(h, w):
    board[h][w] = 0
    for dh in range(-1, 2):
        for dw in range(-1, 2):
            nh = h + dh
            nw = w + dw
            if 0 <= nh < H and 0 <= nw < W and board[nh][nw] == 1:
                dfs(nh, nw)


while True:
    W, H = map(int, input().split())
    if H == 0 and W == 0:
        break
    board = [list(map(int, input().split())) for _ in range(H)]
    ans = 0
    for h in range(H):
        for w in range(W):
            if board[h][w]:
                dfs(h, w)
                ans += 1
    print(ans)



Measured memory_bytes: 7992
#include <iostream>

using namespace std;

int main() {
    int h[1010] = {0};
    int a, b;
    cin >> a >> b;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int s, f;
        cin >> s >> f;
        for(int j = s; j < f; j++) {
            h[j]++;
        }
    }
    for(int i = a; i < b; i++) {
        if(h[i] > 0) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    // for(int i = 0; i < 1010; i++) {
    //     cout << h[i] << " ";
    //     if(i % 20 == 0) cout << endl;
    // }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;
ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}


int main(){
 ll n;
 cin>>n;
 string s;
 cin>>s;
 ll d=0;
 rep(i,n-1){
   if(s[i]==s[i+1])d++;
 }
 cout<<s.size()-d<<endl;
}



Measured memory_bytes: 3756
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <sstream>

using namespace std;

typedef long long lint;

using namespace std;

void test_case() {
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int tests=1;
    //cin >> tests;
    for(int test = 0; test < tests; ++test) {
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// khodaya komak kon
/// ya navid navid
/// ye tec khaphan ke yadam bemone : age jayi didi soale masir hamiltoni mikhad rasasho bokon yal oilery;
/// age ye ja mikhasti to dp az ozv i k ta entekhab koni bejash ye log bezan (nominal) hamoon 2**k va o 1 ent kon

///\\\///\\\///\\\\\\\\\\\\\\\\\///\\\///\\\///

const int N=2e5,mod=1e9+7;
ll a[N];

int32_t main(){
    vector <int> b;
    ll n;
    cin >> n;
    ll ans=0;
    for (int i=0;i<n;i++){
        cin >> a[i];
        if (a[i]==i+1){
            b.pb(i-1);
        }

    }
    //cout << b.size() << endl;
    for (int i=0;i<b.size();i++){
        ll k=i;

        while (k+1<b.size() && b[k+1]-1==b[k]){
            k++;
        }

        ans+=(k-i+2)/2;
        i=k;
    }
    cout << ans;
}
















Measured memory_bytes: 2036
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int H, W; cin >> H >> W;
    for (int i = 0; i < H; ++i) {
        vector<char> C(W, 'x');
        for (int j = 0; j < W; ++j) {
            cin >> C[j]; printf("%c", C[j]);
        }
        printf("\n");
        for (int j = 0; j < W; ++j) printf("%c", C[j]);
        printf("\n");
    }
}


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

int main() {
  int n, a;
  cin >> n;
  bool flag = true;
  for (int i=0; i<n; i++) {
    cin >> a;
    if (a%2==0 && !(a%3==0 || a%5==0)) {
      flag = false;
    }
  }
  if (flag) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
import heapq

n = int(input())
a = sorted(map(int, input().split()))

comf = [-a.pop()]
heapq.heapify(comf)
res = 0
for _ in range(n-1):
    v = a.pop()
    res -= heapq.heappop(comf)
    heapq.heappush(comf, -v)
    heapq.heappush(comf, -v)
print(res)


Measured memory_bytes: 31788