akhauriyash/Code-Regression huggingface dataset:
from itertools import accumulate

def solve(x,K):
    N = len(x)
    def transform(x):
        t = [0]*(N+1)
        for i,v in enumerate(x):
            t[max(i-v,0)] += 1
            t[min(i+v+1,N)] -= 1
        return tuple(v for v,_ in zip(accumulate(t),range(N)))

    for i in range(K):
        y = transform(x)
        if x == y:
            break
        x = y
    return x,i
from random import randrange
if __name__ == '__main__':
    N,K = map(int,input().split())
    x = tuple(map(int,input().split()))
    res, i = solve(x,K)
    print(*res)

    # for _ in range(10):
    #     x = tuple(randrange(2) for _ in range(10000))
    #     res,i = solve(x, 10000)
    #     print(i)


Measured memory_bytes: 202552
INF = 10 ** 6

n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

tmp = INF
ans = 0
for i in range(n):
    if tmp > abs(a - (t - 0.006 * h[i])):
        ans = i + 1
        tmp = abs(a - (t - 0.006 * h[i]))

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
int main(){
  int m,n,i,player[1000],p,ok,rem;
  char s[9];
  while(1){
    scanf("%d%d",&m,&n);
    if(m == 0 && n == 0){ break; }
    p = -1; rem = m;
    for(i = 0 ; i < m ; i++){
      player[i] = 1;
    }
    for(i = 1 ; i <= n ; i++){
      scanf("%s",s);
      if(rem == 1){ continue; }
 
      p = (p + 1) % m;
      while(!player[p]){ p++; p %= m; }
 
      if(i%15 == 0 && !strcmp(s,"FizzBuzz")){
        continue;
      }
      if(i % 5 == 0 && !strcmp(s,"Buzz")){
        continue;
      }
      if(i % 3 == 0 && !strcmp(s,"Fizz")){
        continue;
      }
      if(i == atoi(s) && !(i % 3 == 0 || i % 5 == 0)){
        continue;
      }
      player[p] = 0; rem--;
    }
    ok = 0;
    for(i = 0 ; i < m ; i++){
      if(player[i]){
        if(ok){ printf(" "); }
        ok = 1;
        printf("%d",i+1);
      }
    }
    printf("\n");
  }
  return 0;
}

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

struct segtree{
    static const int SEG=1<<20;
    vint dat;
    segtree():dat(SEG*2){}
    void update(int k,int x){
        k+=SEG-1;
        dat[k]=x;
        while(k){
            k=(k-1)/2;
            dat[k]=max(dat[k*2+1],dat[k*2+2]);
        }
    }
    int get(int a,int b,int k=0,int l=0,int r=SEG){
        if(r<=a||b<=l)return 0;
        if(a<=l&&r<=b)return dat[k];
        return max(get(a,b,k*2+1,l,(l+r)/2),get(a,b,k*2+2,(l+r)/2,r));
    }
};

int N,M;
int C[1111111];

int cnt[1111111];
int base[1111111];
vint G[1111111];

int ans[1111111];

signed main(){
    scanf("%lld%lld",&N,&M);
    rep(i,N)scanf("%lld",&C[i]),C[i]--;

    rep(i,N)cnt[C[i]]++;

    fill_n(ans,M,N);

    rep(lattemalta,2){
        rep(i,M)G[i].clear();
        memset(base,0,sizeof(base));
        segtree seg;
        rep(i,M)seg.update(i,cnt[i]);
        vint b;
        if(lattemalta==1)b.pb(C[0]);

        int cur=lattemalta;
        while(cur+1<N){
            if(C[cur]==C[cur+1]){
                base[C[cur]]+=2;
            }
            else{
                G[C[cur]].pb(C[cur+1]);
                G[C[cur+1]].pb(C[cur]);
            }
            cur+=2;
        }
        if(cur>N)b.pb(C[N-1]);

        rep(i,M){
            int a=N-cnt[i];
            int cost=G[i].size();

            for(auto t:G[i]){
                cnt[t]--;
                a--;
                seg.update(t,cnt[t]);
            }

            int tmp=0;
            if(i)tmp=seg.get(0,i);
            if(i+1!=M)chmax(tmp,seg.get(i+1,M));
            chmin(ans[i],cost+a-tmp);

            for(auto t:G[i]){
                cnt[t]++;
                seg.update(t,cnt[t]);
            }
        }
    }

    rep(i,M)printf("%lld\n",ans[i]);
    return 0;
}

Measured memory_bytes: 109016
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = sc.nextInt();

		int[] count = new int[200000];
		for (int i = 0; i < N; i++)
			count[A[i] - 1]++;
		int ans = 0;
		Arrays.sort(count);
		for (int i = 0; i < 200000 - K; i++)
			ans += count[i];

		System.out.println(ans);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 26328
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
#define fcout cout<<fixed<<setprecision(10)
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
//template<typename T>void pp(T x){cout<<x<<endl;}

using namespace std;
template<typename T> void test(vector<T> v){for(int i=0;i<v.size();i++){if(i)cout<<" ";cout<<v[i];}cout<<endl;}

int main(){
    int n,m;
    while(cin>>n&&n){
        cin>>m;
        vector<vector<int>> v(n,vector<int>(n,INF));
        rep(i,0,n)v[i][i]=0;
        rep(i,0,m){
            int a,b;
            cin>>a>>b;
            a--; b--;
            v[a][b]=1;
            v[b][a]=1;
        }

        rep(i,0,n){
            rep(j,0,n){
                rep(k,0,n){
                    v[j][k]=min(v[j][k],v[j][i]+v[i][k]);
                }
            }
        }
        int ans=0;
        rep(i,0,n){
            if(v[0][i]==2||v[0][i]==1)ans++;
        }
        cout<<ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll d,t,s;
  cin >> d >> t >> s;
  if(t*s>=d) pr("Yes");
  else pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3648
n,k=gets.split.map &:to_i
a=gets.split.map &:to_i
h=Hash.new 0 ; a.each{|e|h[e.to_i]+=1}
h=h.sort_by{|k,v|v} #hashをvalueでsort
s=0
for i in 0...h.size-k
s+=h[i][1]
end
p s

Measured memory_bytes: 42112
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <fstream>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

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

ll factorial(ll n) {//階乗
	ll ret = 1;
	rep(i, 1, n + 1)
		ret = (ret *i) % MODU;

	return ret;
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b, ll m) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}
ll ncr(ll n, ll r) {
	return divmod(factorial(n), (factorial(r) * (factorial(n - r))) % MODU, MODU);
}
signed main() {
	int n;
	cin >> n;
	vector<pii> pos(n);
	REP(i, n)
		cin >> pos[i].first >> pos[i].second;

	vector<pii> ori(pos);
	sort(ALL(pos));
	double sum = 0;
	do{
		pii cur = pos[0];
		rep(i, 1, n) {
			sum += sqrt(PW(cur.first - pos[i].first) + PW(cur.second - pos[i].second));
			cur = pos[i];
		}
	} while (next_permutation(ALL(pos)));

	printf("%.7f", sum / factorial(n));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int HelloWorld(){
	cout << "Hello World" << endl;
	return 0;
}

int XCubic(){
	int x;
	cin >> x;
	if (1 <= x && x <= 100){
		x = x*x*x;
		cout << x << endl;
		return 0;
	}
	return 1;
}

int Rectangle(){
	int a, b, area, perimeter;

	cin >> a >>b;
	if (1 <= a && b <= 100){
		area = a*b;
		perimeter = (a + b) * 2;
		cout << area << " " << perimeter << endl;
		return 0;
	}
	return 1;
}

int Watch(){
	int S;
	cin >> S;
	
	
	int D = 60;
	int s = S%D;
	int m = (S / D) % D;
	int h = (S / D) / D;
	if (0 <= S && S <= 86400){
		printf("%u:%u:%u\n", h, m, s);
		return 0;
	}
	
	return 1;
}

int SmallLargeOrEqual(){
	int a, b;
	cin >> a >> b;
	if (!(a <= a && b <= 1000)) return 1;
	if (a < b)		cout << "a < b" << endl;
	else if (a > b) cout << "a > b" << endl;
	else			cout << "a == b" << endl;
	return 0;
}

int Range(){
	int a, b,c;
	bool flag = true;

	cin >> a >> b >> c;
	if (!(0 <= a && a <= 100)) return 1;
	if (!(0 <= b && b <= 100)) return 1;
	if (!(0 <= c && c <= 100)) return 1;

	if (!(a < b)) flag=false;
	if (!(b < c)) flag = false;

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

int SortingThreeNumbers(){
	int a, b, c,temp;
	cin >> a >> b >> c;

	if (!(1 <= a && a <= 10000)) return 1;
	if (!(1 <= b && b <= 10000)) return 1;
	if (!(1 <= c && c <= 10000)) return 1;

	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}
	if (b > c){
		temp = b;
		b = c;
		c = temp;
	}
	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}

	printf("%u %u %u\n", a, b, c);
	
	
	return 0;
}

int CircleInARectangle(){
	int W, H, x, y, r;
	bool flag = true;
	cin >> W >> H >> x >> y >> r;
	if (!(-100 <= x && x <= 100)) return 1;
	if (!(-100 <= y && y <= 100)) return 1;
	if (!(0 <= W && W <= 100)) return 1;
	if (!(0 <= H && H <= 100)) return 1;
	if (!(0 <= r && r <= 100)) return 1;


	if ((x - r) < 0) flag = false;
	if ((y - r) < 0) flag = false;
	if (W < (x + r)) flag = false;
	if (H < (y + r)) flag = false;

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

int PrintManyHelloWorld(){
	for (int i = 0; i < 1000; i++){
		HelloWorld();
	}
	return 0;
}

int PrintTestCases(){
	int x,i=1;
	
	while (1){
		cin >> x;
		if (x == 0) break;
		cout << "Case " << i++ << ": " << x << endl;
	}

	return 0;

}

int SwappingTwoNumbers(){
	int x, y, temp;
	
	for (int i = 0;; i++){
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		if (x > y){
			temp = x;
			x = y;
			y = temp;
		}
		cout << x << " " << y << endl;
	}
	return 0;
}

int main(){
	//HelloWorld();
	//XCubic();
	//Rectangle();
	//Watch();
	//SmallLargeOrEqual();
	//Range();
	//SortingThreeNumbers();
	//CircleInARectangle();
	//PrintManyHelloWorld();
	//PrintTestCases();
	SwappingTwoNumbers();
	return 0;
}

Measured memory_bytes: 3000
/*
Author :: Shahadat Hossain Nirob
............SUST_MATH14..........
*/
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <vector>

#define Long long long
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { Long a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
#define DB if(0) 
#define D(x) cout << #x " is " << x << endl
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VII;
typedef vector<string> VS;

const int INF = 2000000009;
const int MX = 200005;
const double EPS = 1e-9;
const int MOD = 1000000007;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}

#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod)x-=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))

typedef string st;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define endl '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    */
    
    int n=II(),k=II();
    double ans=0.0;
    fogg(i,1,n)
    {
    	double temp=1.0,res=0.0;
    	int sum=i;
    	while(k-1>=sum)
    	{
    		sum=sum*2;
    		//D(sum);
    		temp*=0.50;

    	}
    	//D(temp);
    	ans+=(1/double(n))*temp;
    }
    printf("%.12lf\n",ans);
	
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;


struct Data{
	int x,y;
};

void func(int N){
	int most_left = 0,most_right = 0,most_up = 0,most_down = 0;

	int base,dist;

	Data data[N];
	data[0].x = 0,data[0].y = 0;

	for(int i = 1; i <= N-1; i++){
		scanf("%d %d",&base,&dist);
		switch(dist){
		case 0:
			data[i].x = data[base].x-1;
			data[i].y = data[base].y;
			break;
		case 1:
			data[i].x = data[base].x;
			data[i].y = data[base].y-1;
			break;
		case 2:
			data[i].x = data[base].x+1;
			data[i].y = data[base].y;
			break;
		case 3:
			data[i].x = data[base].x;
			data[i].y = data[base].y+1;
			break;
		}
		most_left = min(most_left,data[i].x);
		most_right = max(most_right,data[i].x);
		most_up = max(most_up,data[i].y);
		most_down = min(most_down,data[i].y);
	}

	printf("%d %d\n",most_right-most_left+1,most_up-most_down+1);

}

int main(){

	int N;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		if(N==1){
			printf("1 1\n");continue;
		}

		func(N);
	}

    return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
using namespace std;
ll q,n,l,r,s1=0,ans=0,dp[100000];
string s;
pair<ll,ll>a[100000];
int32_t main(){
    cin>>n;
    cin>>q;
    cin>>s;
    dp[0]=0;
    for(ll i=0;i<n-1;i++)
    if(s[i]=='A'&&s[i+1]=='C'){
    a[s1].f=i;
    a[s1].s=i+1;
    dp[i+1]=dp[i-1]+1;
    dp[i]=dp[i-1];
    i++;
    s1++;
    }else {
    dp[i]=dp[i-1];
    }
    if(dp[n-1]==0){
        dp[n-1]=dp[n-2];
    }
    while(q--){
cin>>l;
cin>>r;
ans=0;
cout<<dp[r-1]-dp[l-1]<<endl;
    }
    return 0;}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll K;
    cin >> K;
    const ll size = 50;
    vector<ll> v(50);

    ll n = K / size;
    ll m = K % size;

    REP(i, size)
    {
        v[i] = size - 1 + n;
        if (i < m)
            v[i]++;
        else
            v[i] -= m;
    }

    cout << size << endl;
    REP(i, size)
    {
        cout << v[i] << " ";
    }
    cout << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  int a[N], b[N];
  for(int i=0;i<N;i++) cin >> a[i];
  for(int i=0;i<N;i++) cin >> b[i];
  int ans = 0;
  for(int i=0;i<30;i++){
    int bitb[N];
    for(int x=0;x<N;x++){
      // b[x] mod 2^(b+1)
      bitb[x] = b[x] %(1 << (i+1));
    }
    sort(bitb, bitb+N);
    ll tot = 0;
    for(int x=0;x<N;x++){
      int bita = a[x] %(1 << (i+1));
      // count [2^i - a_i, 2*2^i - a_i)
      tot += lower_bound(bitb, bitb+N, 2*(1 << i) - bita) - lower_bound(bitb, bitb+N, (1 << i) - bita);
      // count [3*2^i - a_i, 4*2^i - a_i)
      tot += lower_bound(bitb, bitb+N, 4*(1 << i) - bita) - lower_bound(bitb, bitb+N, 3*(1 << i) - bita);
    }
    // cout << tot << endl;
    if(tot %2 == 1) ans = ans + (1 << i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	//ios::sync_with_stdio(false);
	ll N,P;
	while(cin>>N>>P) {
		VI A(N);
		REP(i, N) cin>>A[i];
		VVI dp(N, VI(2));
		dp[0][0] += 1;
		dp[0][A[0]%2] += 1;
		RANGE(i, 1, N) {
			REP(mi, 2) {
				dp[i][mi] += dp[i-1][mi];
				int pmi = (A[i-1]%2)==(A[i]%2) ? mi : 1-mi;
				dp[i][mi] += dp[i-1][pmi];
			}
		}
		
		cout<<dp[N-1][P]<<endl;
	}
	
	return 0;
}


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

int main() {
	// your code goes here
	long long int n;
	cin>>n;
	
	long long int arr[n];
	long long int i,j,k;
	long long int total=0, total2=0;
	for(i=0;i<n;i++){
	    cin>>arr[i];
	    total2 = total2 + arr[i];
	}
	    
	long long int m;
	cin>>m;
	
	while(m--){
	    long long int p,x;
	    total = total2;
	    cin>>p>>x;
	    total = total - arr[p-1];
	    total = total + x;
	    cout<<total<<"\n";
	}
	
	return 0;
}


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

int main()
{
    string S, T;
    cin >> S >> T;
    vector<int> index_candidate;
    for (int i = S.size() - T.size(); i >= 0; i--) {
        bool flag = true;
        for (int j = 0; j < T.size(); j++) {
            if (T[j] == S[i + j] || S[i + j] == '?') {
                //OK
            } else {
                flag = false;
                break;
            }
        }
        if (flag) {
            index_candidate.push_back(i);
        }
    }
    if (index_candidate.size() == 0) {
        //見つからなかった
        cout << "UNRESTORABLE" << endl;
    } else {
        vector<string> ans_candidate;
        for (int index : index_candidate) {
            string s;
            for (int i = 0; i < S.size(); i++) {
                if (i < index) {
                    if (S[i] == '?') {
                        s += "a";
                    } else {
                        s += S[i];
                    }
                } else if (i < index + T.size()) {
                    s += T[i - index];
                } else {
                    if (S[i] == '?') {
                        s += "a";
                    } else {
                        s += S[i];
                    }
                }
            }
            ans_candidate.push_back(s);
        }
        sort(ans_candidate.begin(), ans_candidate.end());
        cout << ans_candidate[0] << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;
    cin >> x;
    string  str;
    if(x==3){
        str = "YES";
    }else if(x==5){
        str = "YES";
    }else if(x==7){
        str = "YES";
    }else{
        str = "NO";
    }
    cout << str << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int [] a = new int [10];
		for(int i = 0;i < 10;i++){
			int N = in.nextInt();
			a[i] = N;
		}
		Arrays.sort(a);
		for(int i = a.length - 1;i > a.length - 4;i--){
			System.out.println(a[i]);
		}
	}
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  ll ans = 0;
  rep(i,n){
    if(a[i]%2==0){
      while(a[i]%2==0){ // max O(10^3)
	a[i] /= 2;
	ans++;
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		
		int[][] a = new int[n][m];
		int[] b = new int[m];
		int[] c = new int[n];
		
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				a[i][j] = stdIn.nextInt();
			}
		}
		for(int i=0;i<m;i++)
		{
			b[i] = stdIn.nextInt();
		}
		
		for(int i=0;i<n;i++)
		{
			c[i] = 0;
			for(int j=0;j<m;j++)
			{
				c[i] += a[i][j] * b[j];
			}
			System.out.println(c[i]);
		}
	}
}

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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


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

    int res = 0;
    for(int i = 0; i < N-1; i++)
    {
        if(a[i+1]==a[i]){
            res++;
            a[i+1]=-1;
        }
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;

int main() {
	char s[20];
	cin >> s;
	for (int i = 0; i < 20; i++) {
		if (s[i] == 44) {
			s[i] = ' ';
		}
	}
	for (int i = 0; i < 19; i++) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

lis=input().rstrip().split(" ")
print("A"+lis[1][0]+"C")
    
    




Measured memory_bytes: 65632
#A
n = int(input())
honnum = [2, 4, 5, 7, 9]
ponnum = [0, 1, 6, 8]
bonnum = [3]
if n % 10 in honnum:
    print("hon")
elif n % 10 in ponnum:
    print("pon")
elif n % 10 in bonnum:
    print("bon")

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 205;
int n;
ll A[maxn];
char str[maxn];

int cnt;
ll val[maxn];

void ins(ll x) {
  per(i, 60, 0) if (x >> i & 1) {
    if (val[i]) {
      x ^= val[i]; continue;
    }
    rep(j, 0, i - 1) if (x >> j & 1) x ^= val[j];
    rep(j, i + 1, 60) if (val[j] >> i & 1) val[j] ^= x;
    val[i] = x, cnt++;
    return;
  }
}

bool find(ll x) {
  per(i, 60, 0) if (x >> i & 1) {
    if (!val[i]) return 0;
    x ^= val[i];
  }
  return 1;
}

void solve() {
  vector <ll> v0, v1;
  cin >> n;
  rep(i, 1, n) scanf("%lld", A + i);
  scanf("%s", str + 1);
  rep(i, 1, n) if (A[i]) {
    if (str[i] == '0') {
      v0.push_back(A[i]);
    } else {
      v1.push_back(A[i]);
    }
  }
  cnt = 0;
  memset(val, 0, sizeof val);
  per(i, n, 1) {
    if (str[i] == '0') {
      ins(A[i]);
    } else {
      if (!find(A[i])) {
        puts("1");
        return;
      }
    }
  }
  puts("0");
}

int main() {
  int T = read();
  while (T--) solve();
  return 0;
}

Measured memory_bytes: 3684
var k:Int = Int(readLine()!)!
var c:Int = 0
if k % 2 == 0 || k % 5 == 0 {
  c = -1
} else {
  k = (k % 7 == 0 ? k/7:k)
  var m1:Int = 1, m2:Int = 1
  c += 1
  while m1 % k != 0 {
    m2 = (m2*10)%k
    m1 = (m1+m2)%k
    c += 1
  }
}
print(c)

Measured memory_bytes: 7692
#include <bits/stdc++.h>
 using namespace  std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const long double pi=3.1415926535897932384626433832;
const long long mod=1e9+7;
//long long primeset[5000000]={};
typedef complex<double> cd;
typedef long long ll;
//#define For(i,0,n) for(long long i = 0 ; i<n ;i++) 
cd fast_exp(cd a, long long b)
{
	if (b == 0)
		return 1;
	
	cd res = fast_exp(a, b / 2);
		
	res = res * res;
	
	if (b % 2 == 1)
		res = res * a;
	
	return res;
}

long long fastexpon(long long a,long long b,long long mod)
{
	if(b==0)
		return 1;
	
	long long res=fastexpon(a,b/2,mod);
	
	res=(res*res)%mod;
	if(b%2==1)
		res= (res * a)%mod;

	return res;
}
int n;
long double dp[3001][1505]={};
long double a[3000];
long double solver(int i , int need)
{
	
	//printf(" i = %d  need= %d \n ",i, need);
	if(n-i < need && need>0)
	{
		dp[i][need]=0;
		return dp[i][need];
	}

	if(dp[i][need]>-1)
		return dp[i][need];
	if(need == 0)
	{
		//cout<<"ullll";
		dp[i][need]=1;
		return dp[i][need];
	}
	
	else
	{
		dp[i][need]=(a[i])*solver(i+1,need-1) + (1-a[i])*solver(i+1,need);
		return dp[i][need];
	}
}
int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin>>n;
	
	for(int i=0 ; i<n ;i++)
	{
		cin>>a[i];
	}
	for(int i=0 ;i<=n ;i++)
	{
		for(int j=0 ; j<= n ;j++)
			dp[i][j]=-1;
	}
	std::cout<<std::setprecision(10)<<std::fixed;
	cout<<solver(0,(n+1)/2)<<'\n';
	//cout<<solver(3,0)<<'\n';
	// for(int i=0 ; i<=3 ;i++)
	// {
	// 	for(int j =0 ;j<=2 ;j++)
	// 	{
	// 		printf("( %d , %d )    %f  \n",i,j,dp[i][j]);
	// 		//cout<<dp[i][j]<<' ';
	// 	}
	// 	cout<<'\n';
	// }
	//cout<<'\n'<<"time elapsed: "<<clock()*1000.0 / CLOCKS_PER_SEC<<" ms"<<'\n';
	return 0;
}

Measured memory_bytes: 71168
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(void) {
    string S, T, ans;
    cin >> S >> T;

    set<string> st;
    for(int i=0; i+T.size()<=S.size(); i++) {
        bool ok = true;
        for(int j=0; j<T.size(); j++) {
            if(S[i+j] != T[j] && S[i+j] != '?') {
                ok = false;
            }
        }
        if(ok) {
            ans = S;
            for(int j=0; j<T.size(); j++) {
                ans[i+j] = T[j];
            }
            for(int j=0; j<ans.size(); j++) {
                if(ans[j] == '?') {
                    ans[j] = 'a';
                }
            }
            st.insert(ans);
        }
    }

    if(st.empty()) {
        cout << "UNRESTORABLE" << endl;
    } else {
        cout << *st.begin() << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
    int H,W;
    for(int i = 0;; i++){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }
        char a[H][W];
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i + j) % 2 == 0){
                    a[i][j] = '#';
                }
                else if((i + j) % 2 == 1){
                    a[i][j] = '.';
                }
                printf("%c",a[i][j]);
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

int main(void)
{
	int i, j, m, n, **A, *v, c;
	scanf("%d %d", &n, &m);

	A = (int **)malloc(sizeof(int *) * n);
	for (i = 0; i < n; i++) {
		A[i] = (int *)malloc(sizeof(int) * m);
	}
	v = (int *)malloc(sizeof(int) * m);

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	for (i = 0; i < m; i++) {
		scanf("%d", &v[i]);
	}
	for (i = 0; i < n; i++) {
		c = 0;
		for (j = 0; j < m; j++) {
			c += A[i][j] * v[j];
		}
		printf("%d\n", c);
	}

	return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  char s[n];
  cin>>s;
  int i,c=0;
  for(i=0;i<n;i++)
  {
      if(s[i]==s[i+1])
      c=c+1;
  }
  cout<<n-c;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
//#include<array>

#define ll long long int

using namespace std;
int main(){
    ll n,k;
    string s;
    cin >> n>>k;
    cin >>s;
    s[k-1]=s[k-1]+32;

    cout <<s<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {

        int N = nextInt();
        long A = nextLong();
        long B = nextLong();

        if(A > B) {
            writer.println(0);
        } else {
            if(N == 1) {
                if(A != B) {
                    writer.println(0);
                } else writer.println(1);
            } else {
                if(A == B) {
                    writer.println(1);
                } else {
                    long huge = (long)(N-2) * (long)B;
                    long small = (long)(N-2) * (long)A;
                    writer.println((huge-small+1));
                }
            }
        }

    }

    public static void main(String[] args) {
        new Main().run();
    }



    BufferedReader reader;
    //    BufferedReader reader2;
    StringTokenizer tokenizer;
    PrintWriter writer;
    //    BufferedWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("input.txt"));
            //            reader2 = new BufferedReader(new FileReader("1.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new     PrintWriter("output.txt");
//                                                    writer = new BufferedWriter(System.out);
            //                        writer = new BufferedWriter(new OutputStreamWriter(System.out));
            solve();
            reader.close();
            //            reader2.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    short nextShort() throws IOException {
        return Short.parseShort(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }

}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, m; cin >> n >> m;
  ll sum = 0;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  int k = 0;
  for (int i = 0; i < n; i++) {
    if (4 * m * a[i] >= sum) k++;
  }
  cout << (k >= m ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int result = t;
        for (int i = 0; i < array.length - 1; i++) {
            result += Math.min(t, array[i + 1] - array[i]);
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 48076
#include<cstdio>
#include<cstdlib>
#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX/2+2], R[MAX/2+2];

llong merge(int A[], int n, int left, int mid, int right){
    llong cnt = 0;
    int n1 = mid-left;
    int n2 = right -mid;
    for(int i=0; i<n1; i++) L[i] = A[left+i];
    for(int i=0; i<n2; i++) R[i] = A[mid+i];
    L[n1] = R[n2] = SENTINEL;

    int i=0, j=0;
    for(int k=left; k<right; k++){
        if(L[i] <= R[j]){
            A[k] = L[i++];
        }
        else{
            A[k] = R[j++];
            cnt += n1 -i; // = mid + j - k - 1
        }
    }
    return cnt;
    
}

llong mergeSort(int A[], int n, int left, int right){
    if(right-left>1){
        int mid = (left+right)/2;
        llong v1 = mergeSort(A, n, left, mid);
        llong v2 = mergeSort(A, n, mid, right);
        llong v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    }
    else return 0;
}

int main(){
    int n;
    scanf("%d", &n);
    int *A = (int *)malloc(sizeof(int)*MAX);

    for(int i=0; i<n; i++) scanf("%d", &A[i]);

    llong ans = mergeSort(A, n, 0, n);

    printf("%ld\n", ans);


    return 0;
}


Measured memory_bytes: 4244
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
int n;
int bit[100010];
void add(int v, int x) {

	while (v <= n)
	{
		bit[v] += x;
		v += v & -v;
	}
}

ll sum(int v) {
	ll r = 0;
	while (v > 0)
	{
		r += bit[v];
		v -= v & -v;
	}
	return r;
}
void put(string v) {
	cout << "a" << v<< "b" << endl;
}
void solv() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		put(" < ");
	}
	else if (a > b) {
		put(" > ");
	}
	else put(" == ");


}


int main() {
	//	COMinit();
	solv();

	return 0;
}



Measured memory_bytes: 3192
import java.util.Scanner;

class Main {

  public enum Status {
    LEFT, RIGHT, OK;
  }

  public static Status LeftRightOk(String s, String[] t, String[] d, int index) {
    char currchar = s.charAt(index);
    for (int i = 0; i < t.length; i++) {
      if (currchar == t[i].charAt(0)) {
        if (d[i].equals("R")) {
          if (index != s.length() - 1) {
            currchar = s.charAt(++index);
          } else {
            return Status.RIGHT;
          }
        } else {
          if (index != 0) {
            currchar = s.charAt(--index);
          } else {
            return Status.LEFT;
          }
        }
      }
    }
    return Status.OK;
  }

  public static int searchLeftOkIdx(String s, String[] t, String[] d) {
    int ok = s.length();
    int left = -1;
    int mid = (ok + left) / 2;
    while (ok - left > 1) {
      if (LeftRightOk(s, t, d, mid) == Status.LEFT) {
        left = mid;
      } else {
        ok = mid;
      }
      mid = (ok + left) / 2;
    }
    return ok;
  }

  public static int searchRightOkIdx(String s, String[] t, String[] d) {
    int ok = -1;
    int right = s.length();
    int mid = (ok + right) / 2;
    while (right - ok > 1) {
      if (LeftRightOk(s, t, d, mid) == Status.RIGHT) {
        right = mid;
      } else {
        ok = mid;
      }
      mid = (ok + right) / 2;
    }
    return ok;
  }

  public static void main(String[] args) {
    {
      {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int Q = Integer.parseInt(scanner.next());
        String s = scanner.next();
        String[] t = new String[Q];
        String[] d = new String[Q];
        for (int i = 0; i < Q; i++) {
          t[i] = scanner.next();
          d[i] = scanner.next();
        }
        scanner.close();
        int leftiOkdx = searchLeftOkIdx(s, t, d);
        int rightOkidx = searchRightOkIdx(s, t, d);
        int ans = rightOkidx - leftiOkdx >= 0 ? rightOkidx - leftiOkdx + 1 : 0;
        System.out.println(ans);

      }
    }
  }

}


Measured memory_bytes: 81244
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int col[200][200];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int h,w,n;
	cin>>h>>w>>n;
	int i=0,j=0;
	for(int c=1;c<=n;++c)
	{
		int x;
		cin>>x;
		while(x--)
		{
			col[i][j]=c;
			if(i%2==0)
			{
				j++;
				if(j==w)
				{
					j=w-1;
					++i;
				}
			}
			else
			{
				j--;
				if(j==-1)
				{
					j=0;
					++i;
				}
			}
		}
	}
	for(int p=0;p<h;++p)
	{
		for(int q=0;q<w;++q)
		{
			cout<<col[p][q]<<' ';
		}
		cout<<'\n';
	}
}










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

const int64_t INF = 2 << 30;

int main() {
  int N;
  cin>>N;
  int h[N], dp[N];
  for (int i=0;i<N;i++){
    cin>>h[i];
    dp[i]=INF;
  }
  
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  
  for(int i=2;i<N;i++){
  	dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
  }
  cout << dp[N-1] << endl;
}  


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

using namespace std;

int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  
  long long ans = (long long)1e18;
  ans = min(ans, B - 1);
  ans = min(ans, N - A);
  if (A % 2 == B % 2) {
    ans = min(ans, (B - A) / 2);
  }
  {
    auto a = A, b = B;
    a += N - B;
    b = N;
    if (a % 2 == b % 2) {
      ans = min(ans, (N - B) + (b - a) / 2);
    } else {
      ans = min(ans, (N - B) + (b - a) / 2 + 1);
    }
  }
  {
    auto a = A, b = B;
    b -= A - 1;
    a = 1;
    if (a % 2 == b % 2) {
      ans = min(ans, (A - 1) + (b - a) / 2);
    } else {
      ans = min(ans, (A - 1) + (b - a) / 2 + 1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256