akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  vector<vll> G(n);
  vector<pll> vp;
  REP(i, n-1){
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
    vp.push_back(pll(a, b));
  }


  queue<ll> que;
  que.push(0);
  vll visited(n, 0);
  visited[0] = 1;
  vll used_color(n, 0);
  map<pll, ll> vc;
  ll k = G[0].size();


  while(!que.empty()){
    ll v = que.front();
    que.pop();

    ll cur = 1;
    if(k<G[v].size())
      k = G[v].size();
    for(int i = 0; i < G[v].size(); i++){
      ll to = G[v][i];
      if(visited[to])
        continue;
      if(cur == used_color[v])
        cur++;

      used_color[to] = vc[pll(v, to)] = vc[pll(to, v)] = cur;
      cur++;
      visited[to] = 1;
      que.push(to);
    }
  }


  cout << k << endl;
  REP(i, n-1)
    cout << vc[vp[i]] << endl;
}


Measured memory_bytes: 22128
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
res = []
def recursion(v, E, state) -> bool:
    # base case
    if state[v]:
        return state[v] == 1
    # recursion
    state[v] = -1
    flag = all(recursion(nv, E, state) for nv in E[v])
    if flag:
        state[v] = 1
        res.append(v)
    return flag

def resolve():
    n, m = map(int,input().split())
    E = [[] for _ in range(n)]
    for _ in range(m):
        u, v = map(int,input().split())
        E[u].append(v)
    state = [0] * n # 0 : unvisited, -1 : visited & uncalculated, 1 : calculated
    for v in range(n):
        recursion(v, E, state)
    print(*res[::-1], sep = '\n')
resolve()


Measured memory_bytes: 9004
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define pb push_back
int main(){
  int N,x;
  cin >> N >> x;
  vector<int> a;
  rep(i,N){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  int kohuku = 0;
  rep(i,N){
    if(i == N - 1){
      if(x == a[i]){
        kohuku++;
      }
    } else {
      if(x >= a[i]){
        kohuku++;
        x -= a[i];
      }
    }
  }
  cout << kohuku << endl;
  return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N, M;
int d[300][300];
int as[1500], bs[1500], cs[1500];

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

    std::cin >> N >> M;

    fill(&d[0][0], &d[0][0]+300*300, 1001001001);

    for(int i=0;i<N;++i){
        d[i][i] = 0;
    }
    
    for(int i=0;i<M;++i){
        std::cin >> as[i] >> bs[i] >> cs[i];
        --as[i]; --bs[i];

        d[as[i]][bs[i]] = min(d[as[i]][bs[i]], cs[i]);
        d[bs[i]][as[i]] = min(d[bs[i]][as[i]], cs[i]);
    }

    for(int k=0;k<N;++k){
        for(int i=0;i<N;++i){
            for(int j=0;j<N;++j){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int res = 0;
    for(int i=0;i<M;++i){          
        bool canUse = false;
        for(int j=0;j<N;++j){
            for(int k=j+1;k<N;++k){
                if(d[j][k] == d[j][as[i]] + cs[i] + d[bs[i]][k] ||
                   d[j][k] == d[j][bs[i]] + cs[i] + d[as[i]][k]){
                    canUse = true;
                }

            }
        }
            
        if(!canUse){++res;}
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 640
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll N, K; cin >> N >> K;
	vector<ll> h(N);
	rep(i, N)cin >> h[i];

	sort(ALL(h));

	int mi = pow(10, 9) + 1;
	for (int i = 0; i <= N - K; i++) {
		mi = fmin(mi , h[i+K -1] -h[i] );
	}

	cout << mi << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

Pi dp[1<<18];

int main(){
    int N; cin >> N;
    vector<int> A(1<<N);
    rep(i,1<<N){
        cin >> A[i];
        dp[i] = {A[i],-1};
    }

    rep(i,N)rep(j,1<<N){
        if(j>>i&1){
            vector<int> v(4);
            v[0] = dp[j].first;
            v[1] = dp[j].second;
            v[2] = dp[j^(1<<i)].first;
            v[3] = dp[j^(1<<i)].second;
            sort(v.begin(),v.end());
            dp[j].first = v[3];
            dp[j].second = v[2];
        }
    }

    int ans = -1;
    repr(i,1,1<<N){
        ans = max(ans,dp[i].first+dp[i].second);
        cout << ans << endl;
    }

}
    



Measured memory_bytes: 6144
#include "bits/stdc++.h"
using namespace std;

int main()
{
    int x;
    cin >> x;
    if (x >= 400 && x <= 599)
        cout << 8 << endl;
    else if (x >= 600 && x <= 799)
        cout << 7 << endl;
    else if (x >= 800 && x <= 999)
        cout << 6 << endl;
    else if (x >= 1000 && x <= 1199)
        cout << 5 << endl;
    else if (x >= 1200 && x <= 1399)
        cout << 4 << endl;
    else if (x >= 1400 && x <= 1599)
        cout << 3 << endl;
    else if (x >= 1600 && x <= 1799)
        cout << 2 << endl;
    else if (x >= 1800 && x <= 1999)
        cout << 1 << endl;
    return 0;
}

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

int n,q,opt,k,ans=0,mina,minb;
int a[2000005],b[2000005];

struct segmentree_a
{
	int num;
	int tag;
}treea[2000005];

struct segmentree_b
{
	int num;
	int tag;
}treeb[2000005];

inline void f_a(int rt,int l,int r,int k)
{
	treea[rt].tag=min(treea[rt].tag,k);
}

inline void f_b(int rt,int l,int r,int k)
{
	treeb[rt].tag=min(treeb[rt].tag,k);
}

inline void pushdown_a(int rt,int l,int r)
{
	int mid=(l+r)>>1;
	f_a(2*rt,l,mid,treea[rt].tag);
	f_a(2*rt+1,mid+1,r,treea[rt].tag);
}

inline void pushdown_b(int rt,int l,int r)
{
	int mid=(l+r)>>1;
	f_b(2*rt,l,mid,treeb[rt].tag);
	f_b(2*rt+1,mid+1,r,treeb[rt].tag);
}

inline void change_a(int nl,int nr,int l,int r,int rt,int k)
{
	pushdown_a(rt,l,r);
	if (nl<=l&&r<=nr)
	{
		treea[rt].tag=min(treea[rt].tag,k);
		return;
	}
	int mid=(l+r)>>1;
	if (nl<=mid)  change_a(nl,nr,l,mid,2*rt,k);
	if (nr>mid)  change_a(nl,nr,mid+1,r,2*rt+1,k);
}

inline void change_b(int nl,int nr,int l,int r,int rt,int k)
{
	pushdown_b(rt,l,r);
	if (nl<=l&&r<=nr)
	{
		treeb[rt].tag=min(treeb[rt].tag,k);
		return;
	}
	int mid=(l+r)>>1;
	if (nl<=mid)  change_b(nl,nr,l,mid,2*rt,k);
	if (nr>mid)  change_b(nl,nr,mid+1,r,2*rt+1,k);
}

inline int query_a(int nl,int l,int r,int rt)
{
	pushdown_a(rt,l,r);
	
	int mid=(l+r)>>1,ans;
	if (l==r&&l==nl)  return min(a[l],treea[rt].tag);
	if (nl<=mid)  ans=query_a(nl,l,mid,2*rt);
	else ans=query_a(nl,mid+1,r,2*rt+1);
	return ans;
}

inline int query_b(int nl,int l,int r,int rt)
{
	pushdown_b(rt,l,r);
	
	int mid=(l+r)>>1,ans;
	if (l==r&&l==nl)  return min(b[l],treeb[rt].tag);
	if (nl<=mid)  ans=query_b(nl,l,mid,2*rt);
	else ans=query_b(nl,mid+1,r,2*rt+1);
	return ans;
}

signed main()
{
	cin>>n>>q;
	mina=minb=n;
	for (int i=1;i<=n;i++)  a[i]=n;
	for (int i=1;i<=n;i++)  b[i]=n;
	a[n]=b[n]=1;
	
	for (int i=1;i<=8*n;i++)  treea[i].tag=treeb[i].tag=inf;
	while (q--)
	{
		cin>>opt>>k;
		if (opt==1)
		{
			mina=min(mina,k);
			int now=query_b(k,1,n,1);
			if (now>1)  change_a(1,now-1,1,n,1,k);
			b[k]=1;
		}
		else
		{
			minb=min(minb,k);
			int now=query_a(k,1,n,1);
			if (now>1)  change_b(1,now-1,1,n,1,k);
			a[k]=1;
		}
	}
	for (int i=1;i<=n;i++)  a[i]=query_a(i,1,n,1);
	for (int i=1;i<=n;i++)  b[i]=query_b(i,1,n,1);
	for (int i=2;i<=n-1;i++)
	{
		int cnt=max(a[i]-2ll,0ll);
		ans+=cnt;
	}
	for (int i=2;i<=n-1;i++)
	{
		int cnt=max(b[i]-2ll,0ll);
		ans+=cnt;
	}
	int another=1;
	another*=max(0ll,mina-2);
	another*=max(0ll,minb-2);
	cout<<ans-another<<endl;
	
	return 0;
}

Measured memory_bytes: 56724
import numpy as np
import copy
n,m = map(int,input().split())
A = np.array([int(i) for i in input().split()])//2
lcm_ = 1
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

for i in A:
    lcm_ = lcm(lcm_,i)
c = 0
lcm_2 = copy.deepcopy(lcm_)
for _ in range(30):
    if lcm_2 % 2 == 0:
        c += 1
        lcm_2 = lcm_2//2
if np.all(A%(2**c) == 0):
    c = m//lcm_
    print(c//2 + c%2)
else:
    print(0)





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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll a,b;
    cin>>a>>b;

    b*=2;

    if(b>=a)
        cout<<"0";
    else
        cout<<a-b<<"\n";    
    





}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<string>
using namespace std;
int main(){
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a*b>c*d){
		cout<<a*b<<endl;
	}
	if(c*d>a*b){
		cout<<c*d<<endl;
	}
	if(a*b==c*d){
		cout<<a*b<<endl;
	}


}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t>data(N);
  for(int i=0;i<N;i++){
    cin >> data.at(i);
  }
  vector<int64_t>syu(N);
  for(int i=0;i<N;i++){
    if(i+1>=data.at(i)) syu.at(i+1-data.at(i))++;
  }
  int64_t ans=0;
  for(int i=0;i<N;i++){
    if(data.at(i)+i+1<N) ans+=syu.at(data.at(i)+i+1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6300
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	vector<long long> list(M);
	vector<long long> sub(M - 1);
	for (int i = 0; i < M; i++)
	{
		cin >> list[i];
	}

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

	for (int i = 0; i < M - 1; i++)
	{
		sub[i] = abs(list[i + 1] - list[i]);
	}

	sort(sub.begin(), sub.end());
	reverse(sub.begin(), sub.end());

	long long ans = 0;
	for (int i = N - 1; i < sub.size(); i++)
	{
		ans += sub[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

void CountingSort(int *A, int *B,int *C, int n, int k){
   for(int i = 0; i < k; i++){
       C[i] = 0;
   }
    for(int j = 0; j < n; j++){
        C[A[j]] = C[A[j]]+1;
   /* C[i] now contains the number of elements equal to i */
    }
    for(int i = 1; i < k; i++){
     C[i] = C[i] + C[i-1];
    /* C[i] now contains the number of elements less than or equal to i */
}
   for(int i = 1; i < k; i++){
   }
    for(int j = n - 1; j >= 0; j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;
    }
}   
   
   
int main(int argc, char** argv) {

    int n,max, min = 1000000000;
    scanf("%d",&n);
    int *A = (int*)malloc(n * sizeof(int));
    int *B = (int*)malloc(n * sizeof(int));
    for(int a = 0; a < n; a++){
            scanf("%d",&A[a]);
            if(max<A[a])max=A[a];
            if(min>A[a])min=A[a];
            B[a] = 0;
    }
    int k = 2 + (max - min);
    int *C = (int*)malloc(k * sizeof(int));
    CountingSort(A,B,C,n,k);
    
    for(int a = 1; a < n +1; a ++){
      printf("%d",B[a]);
            if(a < n){
                printf(" ");
            } 
    }

    
    printf("\n");
    return (0);
}


Measured memory_bytes: 33804
#include <iostream>

using namespace std;


int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int l_month[12]={31,29,31,30,31,30,31,31,30,31,30,31};

bool leap(int year) {

  if((year%4==0 && year%100!=0) || year%400==0) return true;

  else return false;

}

int getdaycount(int year,int month,int day) {

  int days;

  if(month<=2) {

    year--;

    month+=12;

  }

  days=(365*year+year/4-year/100+year/400+306*(month+1)/10+day-428);

  return days;

}

int main() {

  int y1,m1,d1,y2,m2,d2;

  int day1,day2;


  while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {

    if(y1==-1 || m1==-1 || d1==-1 || y2==-1 || m2==-1 || d2==-1) break;

    day1=getdaycount(y1,m1,d1);

    day2=getdaycount(y2,m2,d2);

    cout << day2-day1 << endl;

  }

  return 0;

}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
	int a ,b ,c ,ans ,x;
	scanf("%d %d %d",&a ,&b ,&c);
	x = a - b;
	ans = c - x;
	if(ans >= 0){
		printf("%d",ans);
	} else {
		printf("0");
	}
	return 0;
}

Measured memory_bytes: 1708
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 8000000000000000000
int main(){
#define int long long
	long long n;
	cin >> n;
	vector < pair<long long, long long >> hogee;
	long long now_ans = 0;
	REP(i, n) {
		long long a, b;
		cin >> a >> b;
		hogee.push_back(make_pair(a, b));
	}
	for (int i = n - 1;i >= 0;--i) {
		long long pp = hogee[i].first + now_ans;
		pp %= hogee[i].second;
		if (pp == 0) pp = hogee[i].second;
		now_ans += hogee[i].second - pp;
	}
	cout << now_ans << endl;
	return 0;
}

Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    int n = Integer.parseInt(r.readLine());
    String[] sl = r.readLine().split("[\\s]+");
    int[] x = new int[n];
    int[] st = new int[n];
    for(int i = 0; i < n; i++)
    {
      x[i] = Integer.parseInt(sl[i]);
      st[i] = x[i];
    }
    
    Arrays.sort(st);

    int a = st[(n - 1) / 2];
    int b = st[n / 2];
    
    for(int i = 0; i < n; i++)
    {
      System.out.println(x[i] <= a ? b : a);
    }

  }

}


Measured memory_bytes: 94380
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const ll mod=1e9+7;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	ll n,q;
	cin>>n>>q;
	char s[n+10];
	cin>>s;
	ll count[n+10];
	for(ll i=0;i<=n+5;i++)
		count[i]=0;
	count[1]=0;
	for(ll i=1;i<strlen(s);i++)
	{
		if(s[i]-'C'==0&&s[i-1]-'A'==0)
			count[i+1]=count[i]+1;
		else
			count[i+1]=count[i];
	}
	/*for(ll i=0;i<=strlen(s);i++)
		cout<<count[i]<<" ";
	cout<<endl;*/
	while(q-->0){
		ll l,r;
		cin>>l>>r;
		cout<<count[r]-count[l]<<endl;
	}

}




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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/




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

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  ll sum = a[0];
  rep1(i,n-1){
    sum ^= a[i];
  }

  rep(i,n){
    ll ans = sum^a[i];
    cout << ans << endl;
  }
  return 0;
}
/********  Main() Ends Here *************/


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

bool isPrime(int n){
	for(int i=6 ; i < n ; i+=7 ){
		if( n%i == 0 ) return false;
	}
	for(int i=8 ; i < n ; i+=7 ){
		if( n%i == 0 ) return false;
	}
	return true;
}

int main(){
	int n;
	for( ; cin >> n ; ){
		if( n == 1 ) break;
		cout << n << ":";
		for(int i=7 ; i <= n+1 ; i+=7 ){
			if( n%(i-1) == 0 ){
				if( isPrime(i-1) )
					cout << " " << (i-1);
			}
			if( n%(i+1) == 0 ){
				if( isPrime(i+1) )
					cout << " " << (i+1);
			}
		}
		cout << endl;	
	}
}

Measured memory_bytes: 868
n, k, q = gets.split.map(&:to_i)
arr = readlines.map{|a| a.chomp.to_i}
ps = [k-q] * n
arr.each do |a|
  ps[a-1] += 1
end
ps.each do |pp|
  puts pp > 0 ? "Yes" : "No"
end


Measured memory_bytes: 12028
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  lld n;
  cin >> n;
  lld c[] = {0, 0, 0, 0};
  for (lld i = 0; i < n; i++) {
    string s;
    cin >> s;
    switch (s[0]) {
      case 'A':
        c[0]++;
        break;
      case 'W':
        c[1]++;
        break;
      case 'T':
        c[2]++;
        break;
      case 'R':
        c[3]++;
        break;
    }
  }
  printf("AC x %lld\n", c[0]);
  printf("WA x %lld\n", c[1]);
  printf("TLE x %lld\n", c[2]);
  printf("RE x %lld\n", c[3]);
}

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

using namespace std;

#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define ll long long
#define ull unsigned ll
#define sz(x)          (int)((x).size())

#define all(x)         (x).begin(), (x).end()


typedef pair<int, int> pii;
#define inf 10e9
const int N = (int) 2e5 + 7;

int n, q, l, r, a[N];
string s;


int main()
{
    cin >> n >> q;
    cin >> s;
    s.insert(s.begin(), '#');
    a[0] = 0;

    for(int i = 1; i<= s.size(); i++) {
        a[i] = a[i - 1];
        if(s[i] == 'C' && s[i - 1] == 'A')
            a[i]++;
    }
    while(q--) {
        scanf("%d%d", &l, &r);
        int ans = a[r] - a[l - 1];
        if(s[l-1] == 'A' && s[l] == 'C')
            ans--;
        printf("%d\n",ans );
    }

}


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

int main() {
	stack<int> S1;
	stack<pair<int, int> > S2;
	int sum = 0;
	string s;
	getline(cin, s);
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '\\')
			S1.push(i);
		else if (s[i] == '/' && S1.size() > 0) {
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j) {
				a += S2.top().second;
				S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}
	vector<int> ans;
	while (S2.size() > 0) {
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size(); i++) {
		cout << " ";
		cout << ans[i];
	}
	cout << endl;
}


Measured memory_bytes: 3276
//参加気分でさ

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	int A[1000], C[1000];
	rep(i, M) {
		int b;
		cin >> A[i] >> b;
		int tmp = 0;
		rep(j, b) {
			int c;
			cin >> c;
			tmp += 1 << (c - 1);
		}
		C[i] = tmp;
	}

	int dp[1001][1 << 12];
	rep(i, M + 1) rep(j, 1 << N) {
		dp[i][j] = 1e9;
	}

	dp[0][0] = 0;
	rep(i, M) {
		rep(j, 1 << N) {
			if (dp[i][j] < 1e9) {
				int k = j | C[i];
				dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + A[i]);
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			}
		}
	}

	if (dp[M][(1 << N) - 1] >= 1e9) co(-1);
	else co(dp[M][(1 << N) - 1]);


	Would you please return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    vector<int>sorted = a;
    sort(all(sorted),greater<int>());
    rep(i,n)
    {
        if(a[i] == sorted[0])
        {
            cout<<sorted[1]<<endl;
        }
        else
        {
            cout<<sorted[0]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <map>
using namespace std;

typedef pair<int, int> P;

int main(){
    while(1){
        int n; cin>>n;
        if(n == 0) return 0;
        map<P, bool> treasure;
        for(int i=0; i<n; i++){
            int x, y; cin>>x>>y;
            treasure[P(x, y)] = true;
        }

        int m; cin>>m;
        int cx = 10, cy = 10;
        for(int i=0; i<m; i++){
            char d; cin>>d;
            int l; cin>>l;
            if(d == 'N'){
                for(int j=0; j<l; j++){
                    cy++;
                    if(treasure[P(cx, cy)]){
                        treasure[P(cx, cy)] = false;
                    }
                }
            }
            else if(d == 'E'){
                for(int j=0; j<l; j++){
                    cx++;
                    if(treasure[P(cx, cy)]){
                        treasure[P(cx, cy)] = false;
                    }
                }
            }
            else if(d == 'S'){
                for(int j=0; j<l; j++){
                    cy--;
                    if(treasure[P(cx, cy)]){
                        treasure[P(cx, cy)] = false;
                    }
                }
            }
            else{
                for(int j=0; j<l; j++){
                    cx--;
                    if(treasure[P(cx, cy)]){
                        treasure[P(cx, cy)] = false;
                    }
                }
            }
        }

        bool valid = true;
        for(auto j : treasure){
            if(j.second) valid = false;
        }

        if(valid){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define fo(i,a) for(i = 0;i < a;i++)
using namespace std;
int main(void)
{
	int n,m,d,i,cnt=0,now=0,flag=0,x[3001]={0};
	
	cin >> n >> m ;
	while(n != 0 && m != 0){
		fo(i,n) cin >> x[i] ;
		i = 0 ;
		fo(i,m){
			cin >> d ;
			now += d + x[now + d] ;
			
			now = now > 1000 ? 1000 : now ;
			
			if(flag == 0) cnt++ ;
			if(now >= n) flag = 1 ;
		}
		cout << cnt << endl ;
		cnt = 0 ;
		now = 0 ;
		flag = 0 ;
		cin >> n >> m ;
	}
	
	return 0 ;
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(18);
  u32 N;
  cin >> N;
  vector<u32> A(N);
  ArrayInput(A);
  vector<u32> L(N), R(N);
  L[0] = 0;
  R[N - 1] = 0;
  for (u32 i = 0; i < N - 1; ++i) {
    L[i + 1] = (L[i] == 0) ? A[i] : gcd(A[i], L[i]);
    R[N - (i + 2)] = (R[N - (i + 1)] == 0)
                         ? A[N - (i + 1)]
                         : gcd(A[N - (i + 1)], R[N - (i + 1)]);
  }
  u32 res = 0;
  for (u32 i = 1; i < N - 1; ++i) {
    u32 tmp;
    tmp = gcd(L[i], R[i]);
    res = (tmp > res) ? tmp : res;
  }
  res = (R[0] > res) ? R[0] : res;
  res = (L[N - 1] > res) ? L[N - 1] : res;
  cout << res << endl;
  return 0;
}


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

template<typename T>
struct NegativeLoop_on_path{
    const T inf=numeric_limits<T>::max();
    struct edge{
        int u,v; T w;
        edge(int u,int v,T w):u(u),v(v),w(w){}
    };
    int n;
    vector<vector<int>> G;
    vector<T> d;
    vector<int> negative;
    NegativeLoop_on_path(int n):n(n),G(n),d(n,inf),negative(n,0){}
    vector<edge> es;
    void add_edge(int u,int v,T c){
        es.emplace_back(u,v,c);
        G[u].emplace_back(v);
    }
    vector<T> build0(){
        for (int i=0;i<n-1;++i){
            for (auto e:es){
                if (d[e.u]==inf) continue;
                if (d[e.u]+e.w<d[e.v]) d[e.v]=d[e.u]+e.w;
            }
        }
        return d;
    }
    void build1(){
        for (int i=0;i<n;++i){
            for (auto e:es){
                if (d[e.u]==inf) continue;
                if (d[e.u]+e.w<d[e.v]){
                    d[e.v]=d[e.u]+e.w;
                    negative[e.v]=1;
                }
                if (negative[e.u]) negative[e.v]=1;
            }
        }
    }
    T shortest_path(int from,int to,int &neg_loop){
        d[from]=0;
        vector<T> res=build0();
        build1();
        neg_loop=negative[to];
        return res[to];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,P; cin >> N >> M >> P;
    NegativeLoop_on_path<long long> NG(N);
    for (int i=0;i<M;++i){
        int A,B; long long C; cin >> A >> B >> C;
        NG.add_edge(--A,--B,-(C-P));
    }
    int ng;
    long long ans=NG.shortest_path(0,N-1,ng);
    cout << (ng?-1:max(0LL,-ans)) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/all>

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

template <class Monoid>  class SegmentTree {
  private:
    using T = typename Monoid::T;
    using size_type = std::size_t;
    size_type n;
    std::vector<T> data;
    void prop(int i) { data[i] = Monoid::op(data[2 * i], data[2 * i + 1]); }

  public:
    SegmentTree() : n(0) {}

    SegmentTree(int n, T initial = Monoid::identity()) : n(n) {
      data.resize(n * 2, initial);
      for(int i = n - 1; i > 0; i--) data[i] = Monoid::op(data[i * 2], data[i * 2 + 1]);
    }

    template <class InputIter, class = typename std::iterator_traits<InputIter>::value_type>
    SegmentTree(InputIter first, InputIter last) : SegmentTree(distance(first, last)) {
      std::copy(first, last, data.begin() + n);
      for(int i = n - 1; i > 0; i--) prop(i);
    }

    SegmentTree(std::vector<T> v) : SegmentTree(v.begin(), v.end()) {}

    SegmentTree(std::initializer_list<T> v) : SegmentTree(v.begin(), v.end()) {}

    void set(size_t i, const T &v) {
      data[i += n] = v;
      while(i >>= 1) prop(i);
    }

    void add(size_t i, const T &v) {
      data[i += n] += v;
      while(i >>= 1) prop(i);
    }

    T get(size_t i) {
      return data[i + n];
    }

    T fold(int l, int r) {
      if(l < 0) l = 0;
      if(l >= r) return Monoid::identity();
      if(r > int(n)) r = n;
      T tmpL = Monoid::identity(), tmpR = Monoid::identity();
      for(l += n, r += n; l < r; l >>= 1, r >>= 1) {
        if(l & 1) tmpL = Monoid::op(tmpL, data[l++]);
        if(r & 1) tmpR = Monoid::op(data[--r], tmpR);
      }
      return Monoid::op(tmpL, tmpR);
    }

    size_type size() { return n; }
};

template < class U = long long >
struct RangeMax {
  using T = U;
  static T op(const T &a, const T &b) { return std::max< T >(a, b); }
  static constexpr T identity() { return 0; }
};

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll n, k; std::cin >> n >> k;
  std::vector<ll> A(n);
  rep(i,n) std::cin >> A[i];

  SegmentTree<RangeMax<>> seg(300001);
  rep(i,n) {
    if ( i == 0 ) {
      seg.set(A[i], 1);
      continue;
    }
    ll l = std::max<ll>(0, A[i]-k);
    ll r = std::min<ll>(300000, A[i]+k);
    ll v = seg.fold(l,r+1);
    seg.set(A[i], v+1);
  }
  std::cout << seg.fold(0, 300002) << std::endl;
  return 0;
}



Measured memory_bytes: 10364
<?php
function chmin($a, $b) {
    if ($a > $b){
        return $b;  # PHPは値をreturnしてそれを受け取らないと反映されない。https://qiita.com/7968/items/58015344ddab5d5a8b93#第2章-値渡し
    }else{
        return $a;
    };
}

fscanf(STDIN, "%d", $n);
$harray = array();
$harray = explode(' ', trim(fgets(STDIN)));  # explodeで行全部を配列に取り込む。

# dpテーブルを作って、無限を代入する。
# ここでは0から始めたので、dp[$i-1]はiまでたどり着くのに必要な最小コストを表す。
$dp = array();
for($i = 0; $i < $n; $i++){
    $dp[$i] = 1000000000000;
}

# 初期条件。最初の足場へ行くコストはゼロ。一つ目は1通りしかない。
$dp[0] = 0;
$dp[1] = abs($harray[1] - $harray[0]);

for($j=2; $j < $n; $j++){
    $dp[$j] = chmin($dp[$j], ($dp[$j-1] + abs($harray[$j] - $harray[$j-1])));
    # $j-2 の足場から来る場合と比較
    $dp[$j] = chmin($dp[$j], ($dp[$j-2] + abs($harray[$j] - $harray[$j-2])));
}
print $dp[$n - 1];


Measured memory_bytes: 18932
#include<iostream>
#include<cstdint>
using namespace std; // 575

const int MAX = 301;
const int MAX2 = 90001;
const int MOD = 998244353;

int64_t pow(int64_t a, int b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	if (b == 2) return a * a % MOD;
	return pow(pow(a, b >> 1), 2) * pow(a, b & 1) % MOD;
}
int main() {
	int N, a[MAX2];
	cin >> N;
	for (int i = 0;i < N;++ i) cin >> a[i];
	static int64_t sum = 0, dp[MAX][MAX2], dp2[MAX][MAX2], ans = 0;
	// dp[i][j]はi個の要素を3色に塗り分けるとき、紅色がjとなるようなものの個数
	// dp2[i][j]はi個の要素を2色に塗り分けるとき、紅色がjとなるようなものの個数
	for (int i = 0;i < N;++ i) sum += a[i];
	for (int i = 0;i < MAX2;++ i) dp[0][i] = dp2[0][i] = 0;
	dp[0][0] = dp2[0][0] = 1;
	for (int i = 0;i < N;++ i) {
		for (int j = 0;j < a[i];++ j) {
			dp[i + 1][j] = (dp[i][j] * 2) % MOD;
			dp2[i + 1][j] = dp2[i][j];
		}
		for (int j = a[i];j <= sum;++ j) {
			dp[i + 1][j] = (dp[i][j - a[i]] + dp[i][j] * 2) % MOD;
			dp2[i + 1][j] = (dp2[i][j - a[i]] + dp2[i][j]) % MOD;
		}
	}
	
	for (int i = sum + 1 >> 1;i <= sum;++ i) (ans += dp[N][i] * 3) %= MOD;
	
	if (sum % 2 == 0) (ans -= dp2[N][sum / 2] * 3) %= MOD;
	cout << (pow(3, N) - ans + MOD) % MOD;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

R≧G,Bとしても一般性を失わない

……解説見た、R≧S/2だけ除外すりゃ終わり！なのか……悲しいね
*/

Measured memory_bytes: 423552
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
     

int main() {
  ll x,y,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
  bool ok = true;
  string s,t,r;
  cin >> n >> m;
  VI a(n); rep(i,n) { cin >> a[i]; z += a[i];}
  rep(i,n){
    if(a[i] >= (double)z/(4*m)){
      sum++;
    }
  }
  if(sum >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> A(R);
    rep(i, R) {
        cin >> A[i];
        A[i]--;
    }
    sort(all(A));
    vector<vector<ll>> D(N, vector<ll>(N, inf));
    rep(i, M){
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        D[a][b] = c;
        D[b][a] = c;
    }
    
    rep(k, N) rep(i, N) rep(j, N)  {
        D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
    }
    
    ll ans = 1e15;
    do {
//        voutput(A);
        ll tmp = 0;
        rep(i, 1, R){
            tmp += D[A[i]][A[i - 1]];
        }
        ans = min(ans, tmp);
    } while (next_permutation(all(A)));
    
    output(ans);
    return 0;
}

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

start = min(a)
end = max(a)

ans = float('inf')
for i in range(start, end + 1):
    temp = 0
    for j in a:
        temp += (j - i) ** 2
    ans = min(ans, temp)
print(ans)


Measured memory_bytes: 38512
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,a,b;
int main()
{
    scanf("%d%d%d",&n,&a,&b);
    int d=max(b-a,a-b);
    if(d&1) puts("Borys"); else puts("Alice");
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1005
#define int long long
using namespace std;
int n,m,a[N],cnt[N],tot;
char c[N];
bool b[N];
signed main(){
	int a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
//	scanf("%lld%lld",&n,&m);
//	for(int i=1;i<=n;i++)
	printf("%lld\n",max(0ll,c-(a-b)));
	return 0;
}

Measured memory_bytes: 256
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr <<	 #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }
#define p   200005



  
void solve()
{   
int n,m;
cin>>n>>m;
int a[n];
int s=0;
rep(i,0,n)
  {
  	cin>>a[i];
  	s+=a[i];
  }
  double z=s*1.0/(4*m);
  int c=0;
  rep(i,0,n)
    {
    if(a[i]*1.0>=z)
    	c++;
    }
   // cout<<z<<endl;
if(c>=m)
	 cout<<"Yes";
	else
		 cout<<"No";









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












Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

const mod int = 1e9 + 7

func main() {
	var h, w, k int
	fmt.Scan(&h, &w, &k)

	dp := [101][8]int{}
	dp[0][0] = 1

	for i := 0; i < h; i++ {
		for bits := 0; bits < 1<<(w-1); bits++ {
			ls := fmt.Sprintf("%0"+strconv.Itoa(w-1)+"b", bits)
			if strings.Contains(ls, "11") {
				continue
			}
			for j := 0; j < w; j++ {
				if 1 <= j && ls[j-1] == '1' {
					dp[i+1][j-1] += dp[i][j]
					dp[i+1][j-1] %= mod
				} else if j < len(ls) && ls[j] == '1' {
					dp[i+1][j+1] += dp[i][j]
					dp[i+1][j+1] %= mod
				} else {
					dp[i+1][j] += dp[i][j]
					dp[i+1][j] %= mod
				}
			}
		}
	}

	fmt.Println(dp[h][k-1])
}


Measured memory_bytes: 2100
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1250
 
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
 
using namespace std;
 
#define int long long
#define endl "\n"
 
const long long INF = (long long)1e18;
const long long MOD = 1ll<<32; 
 
string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}
 
int he2de(string hex){
    int de = 0;
     
    for(int i = 0; i < hex.size(); i++){
        de *= 16;
        if('a' <= hex[i] && hex[i] <= 'z') de += hex[i] - 'a' + 10;
        else de += hex[i] - '0';
    }
    return de;
}
 
string de2he(int de){
    string hex;
     
    for(;de; de >>= 4){
        if(de%16 <= 9) hex += '0' + de%16;
        else hex += 'a' + de%16 - 10;
    }
     
    reverse(hex.begin(), hex.end());
     
    if(hex.size() == 0) hex += '0';
     
    return hex;
}
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
     
    const int NUM = 8, MAXIMUM = 32;
    int T;
     
    cin>>T;
     
    for(int i = 0; i < T; i++){
        int sum = 0, key = 0;
        string hex;
        vector<int> N;
         
        for(int j = 0; j < NUM+1; j++){
            cin>>hex;
            N.push_back(he2de(hex));
        }
         
        for(int j = 0; j < MAXIMUM; j++){
            int sum2 = 0, sum3 = 0;
            for(int k = 0; k < NUM; k++){
                sum2 += (N[k]>>j)&1;
                sum3 += (~(N[k]>>j))&1;
            }
             
            if((sum2&1) == (((sum>>j)+(N[NUM]>>j))&1)){
                sum += sum2<<j;
            } else {
                key += 1ll<<j;
                sum += sum3<<j;
            }
        }
        cout<<de2he(key)<<endl;
    }
     
     
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
const int N=1100000;
int n,m,ans[N],tree[N],a[N],book[N];
struct Node{int l,r,place;}p[N];
inline int read()
{
	int s=0,w=1;
	char ch;ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
int lowbit(int x){return x&(-x);}
void Add(int x,int p)
{
	while(x<=n)
	{
		tree[x]+=p;
		x+=lowbit(x);
	}
}
int Ask(int x)
{
	int ans=0;
	while(x)
	{
		ans+=tree[x];
		x-=lowbit(x);
	}
	return ans;
}
bool cp(Node x,Node y){return x.r<y.r;}
int main()
{
	n=read(); m=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=m;i++) {p[i].l=read();p[i].r=read(); p[i].place=i;}
	sort(p+1,p+1+m,cp);int nxt=1;
	for(int i=1;i<=m;i++)
	{
		for(int j=nxt;j<=p[i].r;j++)
		{
			if(book[a[j]]) Add(book[a[j]],-1);
			Add(j,1);book[a[j]]=j;
		}nxt=p[i].r+1;ans[p[i].place]=Ask(p[i].r)-Ask(p[i].l-1);
	}
	for(int i=1;i<=m;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 17404
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();

    int a, b;
    cin >> a >> b;
    
    cout << (a >= 13 ? b : (a >= 6 and a <= 12) ? b / 2 : 0);
    
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

char s[40][40];
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	rep(i,0,h)scanf(" %s",s[i]);
	int ans=0;
	rep(i1,0,h)rep(j1,0,w)if(s[i1][j1]=='B'){
		rep(i2,0,h)rep(j2,0,w)if(s[i2][j2]=='B'){
			ans=max(ans,abs(i1-i2)+abs(j1-j2));
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <ctime>
#include <map>
#include <queue>
#include <functional>

using namespace std; using ll=long long; using P=pair<ll,ll>; const int INF=1e9; const ll LNF=1e18;

int main(){
  ll n,m; cin>>n>>m;
  ll ok = 0, ng = 1e12;
  while(ng - ok > 1) {
    ll md = (ng + ok) / 2;
    ll t = n, u = m;
    if (md > t) u-=(md-t)*2, t=md;
    //cout << md << " " << u << endl;
    if (u >= md * 2) ok = md;
    else ng = md;
  }
  cout<<ok<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    ll x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
pair<int, int> p[100002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> p[i].fi;
        p[i].se = i;
    }
    sort(p + 1, p + n + 1);
    for(int i = 1; i <= n; ++i)
        cout << p[i].se << " ";
    return 0;
}


Measured memory_bytes: 1664
def main():
    s_list = list(input())
    ans_list = [0] * len(s_list)

    count_r = 0
    count_l = 0
    idx_rl = -1
    for i in range(len(s_list)):
        if idx_rl < 0:
            if s_list[i] == "R":
                if s_list[i+1] == "R":
                    count_r += 1
                else:
                    idx_rl = i
            else:
                if s_list[i+1] == "L":
                    count_l += 1
                else:
                    assert "error i:{}".format(i)
        else:
            if s_list[i] == "L":
                if i+1 != len(s_list) and s_list[i + 1] == "L":
                    count_l += 1
                else:
                    temp_r = count_r // 2
                    ans_list[idx_rl] += 1 + temp_r
                    ans_list[idx_rl+1] += 1 + count_r - temp_r
                    temp_l = count_l // 2
                    ans_list[idx_rl] += count_l - temp_l
                    ans_list[idx_rl+1] += temp_l
                    count_r = 0
                    count_l = 0
                    idx_rl = -1
            else:
                assert "error i:{}".format(i)

    ans = ' '.join(map(str, ans_list))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 54924