akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    int N, M;
    cin >> N >> M;
    int A[N], sum = 0;
    REP (i, N) {
        cin >> A[i];
        sum += A[i];
    }

    sort(A, A+N, greater<int>());
    if (A[M-1] < (double)sum/(4*M)) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>

int cat(int a, int b) {
	return b == 0 ? a : cat(a, b / 10) * 10 + b % 10;
}

int main() {
	int a, b, n, x;

	scanf("%d%d", &a, &b);
	n = cat(a, b);
	for (x = 1; x <= sqrt(n); x++)
		if (x * x == n) {
			printf("Yes\n");
			return 0;
		}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);

            var l = new List<int>();
            l.Add(a + b);
            l.Add(a - b);
            l.Add(a * b);

            Console.WriteLine(l.Max());
        }
    }
}


Measured memory_bytes: 13268
N=int(input())
A=list(map(int,input().split()))
A.sort()
#print(A)

B=[0]
for i in range(N):
    B.append(B[i]+A[i])
#print(B)
ans=1
for j in range(N):
    if B[j]*3<B[j+1]:
        ans=1
    else:
        ans+=1
        
print(ans)
    

Measured memory_bytes: 14252
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    string S; cin >> S;
    string X = "";
    int Q; cin >> Q;
    int frag = -1;
    REP(i, Q)
    {
        int T; cin >> T;
        if(T == 1) frag *= -1;
        else
        {
            int F; cin >> F;
            char C; cin >> C;
            if(F == 1)
            {
               if(frag == 1) S.push_back(C);
               else X.push_back(C);
            }
            else
            {
                if(frag == 1) X.push_back(C);
                else S.push_back(C);
            }
        }
    }
    reverse(ALL(X));
    string ans = X+S;
    if(frag == 1) reverse(ALL(ans));
    cout << ans << endl;
}

Measured memory_bytes: 1328
import java.util.Scanner;

public class Main {
	public static long MOD = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[][] dp = new long[n+1][n+1];
		dp[1][0] = 1;
		for(int i=0;i<m;i++) {
			long[][] next = new long[n+1][n+1];
			for(int a=0;a<=n;a++) {
				for(int b=0;b<=n;b++) {
					if (dp[a][b] == 0) continue;
					next[a+b][0] = (next[a+b][0] + dp[a][b] * a) % MOD;
					next[a][b+1] = (next[a][b+1] + dp[a][b] * (n-a-b)) % MOD;
					next[a][b] = (next[a][b] + dp[a][b] * b) % MOD;
				}
			}
			dp = next;
		}
		System.out.println(dp[n][0]);
	}

}


Measured memory_bytes: 75468
//同じコードやけど通れ～～～～～～～～～～～！！！！！！！
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    ll n;
    cin>>n;
    ll a[3],b[3];
    for(ll i=0;i<3;i++){
        cin>>a[i];
    }
    for(ll i=0;i<3;i++){
        cin>>b[i];
    }
    ll ans = n;
    
    
    for (long long bit = 0; bit < (1LL<<3); ++bit){
        ll cnt = 0;
        
        for(ll i=0;i<3;i++){
            if((bit>>i&1LL)){
                cnt++;
            }
        }
        if(cnt==3){
            for(ll i=0;i*a[0]<=n;i++){
                for(ll j=0;i*a[0]+j*a[1]<=n;j++){
                    ll ret = 0;
                    ll k = (n-i*a[0]-j*a[1])/a[2];
                    ret = i*b[0] + j*b[1] + n - (i*a[0]+j*a[1]);
                    ans = max(ret,ans);
                    ret = i*b[0] + j*b[1] + k*b[2] + n - (k*a[2]+i*a[0]+j*a[1]);
                    ans = max(ret,ans);
                }
            }
        }
        else if(cnt==2){
            ll k=0,l=0,s;
            for(ll i=0;i<3;i++){
                if((bit>>i&1LL)){
                    l=k,k=i;
                }
                else s=i;
            }
            for(ll i=0;i*a[k]<=n;i++){
                ll ret = i*b[k]+ n-(i*a[k]);
                ans= max(ret,ans);
                ret = i*b[k] + (n-i*a[k])/a[l]*b[l] + n-(i*a[k] + (n-i*a[k])/a[l]*a[l]);
                ans = max(ret,ans);
                ll t=ret/b[s];
                ret = t*a[s] + (ret - t*b[s]);
                ans = max(ret,ans);
            }
            
        }
        else if(cnt==1){
            ll k,l,s;
            for(ll i=0;i<3;i++){
                if((bit>>i&1LL)){
                    s=i;
                }
                else l=k,k=i;
            }
            ll ret = n-n/a[s]*a[s] + n/a[s]*b[s];
            ans = max(ret,ans);
            for(ll i=0;i*b[k]<=ret;i++){
                ll res = i*a[k] + ret - i*b[k];
                ans = max(res,ans);
                res = i*a[k] + (ret-i*b[k])/b[l]*a[l] + ret - (i*b[k] + (ret-i*b[k])/b[l]*b[l]);
                ans = max(res,ans);
            }
            
            
        }
        else {
            for(ll i=0;i*b[0]<=n;i++){
                for(ll j=0;i*b[0]+j*b[1]<=n;j++){
                    ll ret = 0;
                    ll k = (n-i*b[0]-j*b[1])/b[2];
                    ret = i*a[0] + j*a[1] + n - (i*b[0]+j*b[1]);
                    ans = max(ans,ret);
                    ret = i*a[0] + j*a[1] + k*a[2] + n - (k*b[2]+i*b[0]+j*b[1]);
                    ans = max(ret,ans);
                }
            }
        }
    }
 
    cout << ans << endl;
 
 
 
    
}

Measured memory_bytes: 256
import math

a, b, degC = [ float( i ) for i in input( ).split( " " ) ]
radC = degC*math.pi/ 180.0
h = math.sin( radC ) * b
S = (a*h)/2
x = math.cos( radC ) * b
x -= a
c = math.sqrt(  x**2 + h**2  ) 
L = a + b + c

print( S )
print( L )
print( h )

Measured memory_bytes: 6876
// ABC 049 A- 居合を終え、青い絵を覆う

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

int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3552
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    s=chomp(readline())
    ans=0
    res=0
    for i in s
        if i=='I'
            res+=1
        else
            res-=1
        end
        ans=max(res,ans)
    end
    println(ans)
end
main()

Measured memory_bytes: 108020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
  int h,a;
  cin >> h >> a;
  cout << (h%a==0? h/a: h/a+1) << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	if (k == 0) {
		cout << (ll)n * n << endl;
		return 0;
	}
	ll ans = 0;
	for (int b = 1; b <= n; ++b) {
		ll res = n / b;
		ans += res * max(0, b - k);
		ans += max(0, n % b - k + 1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1LL<<60)
#define EPS 1e-10
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> pi;
typedef pair<double, int>P;
typedef pair<pi, ll> pii;
typedef vector<int> vi;
typedef queue<int> qi;


int N;
double d[1024];
vector<P>V[1024];

void dijkstra(int s)
{
  fill(d, d+1024, (double)INF);
  priority_queue<P, vector<P>, greater<P> >Q;
  d[s] = 0.0;
  Q.push(make_pair(0, s));

  while(!Q.empty()){
    P p = Q.top(); Q.pop();
    double dist = p.first;
    int v = p.second;
    if(dist > d[v]) continue;
    for(int i=0;i<V[v].size();i++){
      P next = V[v][i];
      if(dist+next.first < d[next.second]){
	d[next.second] = dist+next.first;
	Q.push(make_pair(d[next.second], next.second));
      }
    }
  }
}

int main()
{
  vector<pii>B;
  ll xs, ys, xt, yt;
  cin >> xs >> ys >> xt >> yt;
  B.push_back(make_pair(make_pair(xs, ys), 0LL));
  cin >> N;
  rep(i, N){
    ll x, y , r;
    cin >> x >> y >> r;
    B.push_back(make_pair(make_pair(x, y), r));
  }
  B.push_back(make_pair(make_pair(xt, yt), 0LL));

  for(int i=0;i<N+2;i++){
    for(int j=i+1;j<N+2;j++){
      pi s, t; s = B[i].first; t = B[j].first;
      ll sr, tr; sr = B[i].second; tr = B[j].second;
      double dist = max(0.0, sqrt((s.first-t.first)*(s.first-t.first) + (s.second-t.second)*(s.second-t.second)) - (double)(sr+tr));
      V[i].push_back(make_pair(dist, j));
      V[j].push_back(make_pair(dist, i));
    }
  }

  dijkstra(0);

  printf("%.10lf\n", d[N+1]);
  return 0;
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 310, maxk = 310;

int n, K;
char a[maxn + 5], b[maxn + 5];
int f[maxn + 5][maxn + 5][maxk + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%s%d", a, &K);
	n = strlen(a);
	strcpy(b, a);
	reverse(b, b + n);
	REP(i, 0, n) REP(j, 0, n) if (i + j <= n - 1)
		REP(k, 0, K + 1)
		{
			if (a[i] == b[j] || k > 0) f[i][j][k] = 1 + (i + j < n - 1);
			if (i > 0 && j > 0) 
			{
				if (a[i] == b[j]) f[i][j][k] += f[i - 1][j - 1][k];
				else if (k > 0) f[i][j][k] += f[i - 1][j - 1][k - 1];
			}
			if (i > 0) chkmax(f[i][j][k], f[i - 1][j][k]);
			if (j > 0) chkmax(f[i][j][k], f[i][j - 1][k]);
			if (k > 0) chkmax(f[i][j][k], f[i][j][k - 1]);
		}
	int ans = 0;
	REP(i, 0, n) chkmax(ans, f[i][n - 1 - i][K]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 116864
// AOJ 2222 Alien's Counting
// 2018.4.25 bal4u

#include <stdio.h>
#include <malloc.h>
#include <string.h>

#define MAX_V 1002
int  V;    // 頂点数
int  *to[MAX_V], hi[MAX_V], lim[MAX_V];
int  *r_to[MAX_V], r_hi[MAX_V], r_lim[MAX_V];
int  vs[MAX_V], vsz;
char used[MAX_V];
int  cmp[MAX_V];    // 属する強連結成分のトポロジカル順序

void check_lim(int a)
{
	if (hi[a] < lim[a]) return;
	if (lim[a] == 0) {
		lim[a] = 8, hi[a] = 0;
		to[a] = malloc(sizeof(int) *lim[a]);
	} else if (hi[a] == lim[a]) {
		int k = lim[a];
		if (k > 256) k = 256;
		lim[a] += k;
		to[a] = realloc(to[a], sizeof(int) *lim[a]);
	}
}

void check_r_lim(int a)
{
	if (r_hi[a] < r_lim[a]) return;
	if (r_lim[a] == 0) {
		r_lim[a] = 8, r_hi[a] = 0;
		r_to[a] = malloc(sizeof(int) *r_lim[a]);
	} else if (r_hi[a] == r_lim[a]) {
		int k = r_lim[a];
		if (k > 256) k = 256;
		r_lim[a] += k;
		r_to[a] = realloc(r_to[a], sizeof(int) *r_lim[a]);
	}
}

void add_edge(int _from, int _to)
{
	check_lim(_from), check_r_lim(_to);
	to[_from][hi[_from]++] = _to;
	r_to[_to][r_hi[_to]++] = _from;
}

void dfs(int v)
{
	int i;
	used[v] = 1;
	for (i = 0; i < hi[v]; i++) {
		if (!used[to[v][i]]) dfs(to[v][i]);
	}
	vs[vsz++] = v;
}

void rdfs(int v, int k)
{
	int i;
	used[v] = 1;
	cmp[v] = k;
	for (i = 0; i < r_hi[v]; i++) {
		if (!used[r_to[v][i]]) rdfs(r_to[v][i], k);
	}
}

void init(int n)
{
	V = n;
	memset(  lim, 0, V<<2), memset(  hi, 0, V<<2);
	memset(r_lim, 0, V<<2), memset(r_hi, 0, V<<2);
}

// 強連結成分への分解
int scc()
{
	int v, i, k;
	memset(used, 0, V);
	vsz = 0;
	for (v = 0; v < V; v++) if (!used[v]) dfs(v);
	memset(used, 0, V);
	k = 0;
	for (i = vsz-1; i >= 0; i--) if (!used[vs[i]]) {

		rdfs(vs[i], k++);
	}
	return k;		// 得られた強連結成分の数
}

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define MOD 1000000007
int  dp[1002], nx[1002];
char mk[1002];

int main()
{
	int N, M, s, d, i, k;
	long long ans;

	V = N = in(), M = in();
//	init(N);
	while (M--) {
		s = in()-1, d = in()-1;
		add_edge(s, d);
	}

	k = scc();
	memset(nx, -1, sizeof(int)*k);
	for (i = 0; i < N; i++) if (hi[i]) nx[cmp[i]] = cmp[to[i][0]];

	ans = 1;
    for (i = 0; i < k; i++) {
        if (dp[i]) dp[i]++; else dp[i] = 2;
        if (nx[i] < 0 || nx[i] == i) ans = ans*dp[i] % MOD;
        else if (dp[nx[i]]) dp[nx[i]] = (long long)dp[nx[i]]*dp[i] % MOD;
        else                dp[nx[i]] = dp[i];
    }
	printf("%d\n", (int)ans);
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using pii = pair<int, int>;

struct SEG
{
    int n;
    vector<int> segtree;
    SEG()
    {
    }
    SEG(const vector<int> &data)
    {
        n = data.size();
        segtree.resize(4 * n);
        initialize(data, 0, n - 1, 1);
    }

    int initialize(const vector<int> &data, int l, int r, int node)
    {
        if (l == r)
            return segtree[node] = data[l];
        int mid = (l + r) / 2;
        int lmin = initialize(data, l, mid, node * 2);
        int rmin = initialize(data, mid + 1, r, node * 2 + 1);
        return segtree[node] = lmin+rmin;
    }

    int addq(int l, int r, int node, int nodeleft, int noderight)
    {
        if (r < nodeleft || noderight < l)
            return 0;
        if (l <= nodeleft && noderight <= r)
            return segtree[node];
        int mid = (nodeleft + noderight) / 2;
        return (addq(l,r,node*2,nodeleft,mid)+addq(l,r,node*2+1,mid+1,noderight));
    }

    void update(int left,int right,int node, int change_node ,int diff)
    {
        if (!(left <= change_node && change_node <= right))
            return;
        segtree[node] += diff;
        if (left != right)
        {
            int mid = (left + right) / 2;
            update(left, mid, node * 2, change_node, diff);
            update(mid +1,right, node * 2 +1, change_node, diff);
        }
    }
    int query(int l, int r)
    {
        return addq(l, r, 1, 0, n-1);
    }
    void upd(int change_node, int diff)
    {
        return update(0,n-1,1,change_node,diff);
    }
};

SEG alphabets[26];
vector <int> occ[26];
string str;
int32_t main()
{
	usecppio
    int n; cin >> n;
    cin >> str;
    int q; cin >> q;
    for (int i = 0; i<26; i++)
        occ[i].resize(n);
    for (int i = 0; i<n; i++)
        occ[str[i]-'a'][i]++;
    for (int i = 0; i<26; i++)
        alphabets[i] = SEG(occ[i]);
    while(q--)
    {
        int a;
        cin >> a;
        if (a == 1)
        {
            int b; string c;
            cin >> b >> c;
            int t = str[b-1]-'a';
            alphabets[t].upd(b-1,-1);
            alphabets[c[0]-'a'].upd(b-1, 1);
            str[b-1] = c[0];
        }
        else if (a == 2)
        {
            int l, r;
            cin >> l >> r;
            l--; r--;
            int ct = 0;
            for (int i = 0; i<26; i++)
            {
                int u = alphabets[i].query(l, r);
                if (u > 0)
                {
                    //printf("%c present %d in %d~%d\n",i+'a',u,l,r);
                    ct++;
                }
            }
            cout << ct << '\n';
        }
    }
}




Measured memory_bytes: 255004
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;
using llint = long long int;

int main()
{
  string str;
  cin >> str;
  int k;
  cin >> k;
  set<string> setsub;

  // if (str.length() <= 50)
  // {
  for (int i = 0; i < str.length(); i++)
  {
    for (int p = 1; p <= k; p++)
    {
      setsub.insert(str.substr(i, p));
    }
  }

  auto iii = setsub.begin();
  for (int i = 1; i < k; i++)
  {
    iii++;
  }
  cout << *iii << endl;
  return 0;
  // }

  // for (int i = 0; i < str.length(); i++)
  // {
  //   setsub.insert(str.substr(i, k));
  // }
  // auto itr = setsub.begin();
  // set<string> s;
  // while (true)
  // {
  //   s.insert(*itr);
  //   if (itr->length() == k) {

  //   }
  // }
  // cout << *itr << endl;
  return 0;
}


Measured memory_bytes: 1664
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {			cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


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

int main()
{
	optimize();

	ll n, d, cnt = 0;;

	cin >> n >> d;

	while ( n-- ) {
		ll x, y;
		cin >> x >> y;

		if ( sqr (x) + sqr (y) <= sqr(d) ) cnt++;
	}

	cout << cnt << endl;

	return 0;
}


















Measured memory_bytes: 3640
import java.math.*;
import java.util.*;
  
  

public class Main {
	
	static int map[][],n,m,res;
	public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
        	n=scan.nextInt();
        	m=scan.nextInt();
        	map=new int[n][m];
	        if(n==0&&m==0)break;
        	for(int i=0;i<n;i++) {
	        	for(int j=0;j<m;j++)map[i][j]=scan.nextInt();
	        }
        	res=0;
        	dfs(0);
	        System.out.println(res);
        }
        
        
        
	}
	static void dfs(int d) {
		if(d==n) {
			
			res=Math.max(res, row());
			return;
		}
		line(d);
		dfs(d+1);
		line(d);
		dfs(d+1);
		
	}
	static void line(int d) {
		for(int i=0;i<m;i++) {
			map[d][i]=map[d][i]^1;
		}
	}
	static int row() {
		int sum=0;
		for(int i=0;i<m;i++) {
			int cnt=0;
			for(int j=0;j<n;j++) {
				cnt+=map[j][i];
			}
			sum+=Math.max(cnt, n-cnt);
		}
		return sum;
	}
	
}


Measured memory_bytes: 79932
def hoge(x):
    a = x
    ans = 0
    while True:
        if a//10 == 0:
           ans += a
           break
        else:
            ans += a%10
            a = a//10
    return ans

n,a,b  = map(int,input().split())
ans = 0
for i in range(1,n+1):
    if a <=  hoge(i) <= b:
        ans +=i
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int;
using namespace std;
#define ll long long int
#define F first
#define S second
//#define endl "\n"
//#define nl cout<<endl;
#define pb push_back
#define ull unsigned long long 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define mod 100000007
#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 
bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
    return false;
}
bool cmp(int n, pair<int, int> const& p)
{
    return (p.first < n);
}
//me
ll const mod = 1e9+7;//998244353;
ll const inf = 1e18;
ll const maxn = 5e2+1;

void solve()
{    
     ll n,k; cin >> n >> k;
     string s; cin >> s;

     s[k-1] = s[k-1]+char(32);

     cout << s;
}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
        
          ll t;
          /**/t=1;
          /*/cin>>t;/**/
          f(testcases,0,t){
               //cout << "Case #" <<testcases+1<<": ";
               solve();
          }
 
 
    return 0;
}

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

int main(){
  long long N, x;
  cin >> N >> x;
  vector<long long> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  //操作
  long long ans = 0;
  if(a.at(0) > x){
    ans += a.at(0) - x;
    a.at(0) = x;
  }
  for(int i=1; i<N; i++){
    if(a.at(i-1) + a.at(i) > x){
      ans += a.at(i-1) + a.at(i) - x;
      a.at(i) = x - a.at(i-1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,arr[3000],tot,ans = 0;


int main (){
	cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> arr[i];
	}
	sort(arr + 1, arr + n + 1);
	
	for(ll i = 1; i <= n; i++){
		for(ll j = i + 1; j <= n; j++){
			ll l = j + 1, r = n, nemu = 0;
			while(l <= r){
				ll mid = (l + r) / 2;
				if((arr[i] + arr[j]) > arr[mid]){
					nemu = mid;
					l = mid + 1;
				}else r = mid - 1;
			}
			
			if(nemu > 0) ans += nemu - j;
			//cout << nemu << " " << j << endl;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N,T=get_i
ct=array(N)
N.times do|i|
    ct[i]=get_i
end
ct.sort!{|x,y| x[0]<=>y[0]}
ans=-1
ct.each do|c,t|
  if t<=T
      ans=c
      break
  end
end
if ans==-1
    puts "TLE"
else
    puts ans
end

Measured memory_bytes: 1788
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      int A =sc.nextInt();
      int B =sc.nextInt();
      int C =sc.nextInt();
      
      if(A==C&&B!=A&&C!=B){
      System.out.println("Yes");
      }
      else if(A!=C&&B==A&&C!=B){
      System.out.println("Yes");
      }
      else if(A!=C&&B!=A&&C==B){
      System.out.println("Yes");
      }
      else{
      System.out.println("No");
      }
    }
}

Measured memory_bytes: 22484
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	if ((r * 100 + g * 10 + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using P = pair<i64,i64>;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

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

    set<char> MINs;
    for (char c : s) {
        MINs.insert(c);
    }
    auto now = MINs.begin();
    set<string> ans;
    while(ans.size() < K){
        auto MIN = *now;
        ++now;
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == MIN) {
                for (int j = 1; j <= 5 && i + j <= s.size(); j++) {
                    ans.insert(s.substr(i, j));
                }
            }
        }
    }
    auto ite = ans.begin();
    while(K-- > 1) ++ite;
    cout << *ite << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
typedef long long ll;
vector<int> G[1000000];
vector<int> topo;
ll l[1000000],memo[1000000],ans=0,out[1000000],p[1000000];
queue<int> S;
ll calc(int v){
	if(memo[v]!=-1) return memo[v];
	vector<ll> vc;
	for(ll u:G[v]) vc.pb(calc(u));
	sort(all(vc));
	ll sum=0,now=0;
	for(ll k:vc){
		sum+=now;
		now+=k;
	}
	ans+=sum;
	return memo[v]=now+l[v];
}
int main(){
	int n;
	cin>>n;
	rep(i,n) memo[i]=-1;
	rep(i,n){
		cin>>l[i]>>p[i];
		if(p[i]!=-1){
			G[p[i]].pb(i);
			out[p[i]]++;
		}
	}
	rep(i,n) if(out[i]==0) S.push(i);
	while(!S.empty()){
		int v=S.front();
		S.pop();
		topo.pb(v);
		if(p[v]!=-1){
			out[p[v]]--;
			if(out[p[v]]==0) S.push(p[v]);
		}
	}
	rep(i,n) calc(topo[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 93200
A, B = map(int, input().split())

if A == 1 or B == 1:
    if A == B:
        print("Draw")
    else:
        if A == 1:
            print("Alice")
        else:
            print("Bob")
else:
    if A == B:
        print("Draw")
    elif A > B:
        print("Alice")
    else:
        print("Bob")

Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#pragma warning (disable: 4996)
using namespace std;

long long A, B, C, D;

int main() {
	cin >> A >> B >> C >> D;
	vector<long long> PA, PB;
	PA.push_back(A); PA.push_back(B);
	PB.push_back(C); PB.push_back(D);

	long long Answer = -(1LL << 60);
	for (int i = 0; i < PA.size(); i++) {
		for (int j = 0; j < PB.size(); j++) Answer = max(Answer, PA[i] * PB[j]);
	}
	cout << Answer << endl;
	return 0;
}

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

int main(){
    int n;
    int a,b;
    cin >> n >> a >> b;
    int m=n;
    
    
    int ans =0;
    for(int i=1;i<=n;i++){
        int j=i;
        int sum=0;
        while(j>0){
            sum += j%10;
            j /= 10;
        }
        if(sum >= a && sum<=b){
            ans+=i;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 256
K = int(input())

def nextrun(A):
    bflag = 1
    for i in range(len(A)-1):
        if A[-i-1] != 9 and A[-i-1] <= A[-i-2]:
            A[-i-1] += 1
            for k in range(i):
                A[-i-1+k+1] = max(A[-i-1+k] - 1,0)
            bflag = 0
            return A
    #一番大きい位まで進んだとき
    if bflag:
        if A[0] != 9:
            A[0] += 1
            for k in range(len(A)-1):
                A[-i-1-1+k+1] = max(A[-i-1-1+k] - 1,0)    
        else:
            B = [0]*(len(A)+1)
            B[0] = 1
            A = B
        return A
            
A = [0]
for i in range(K):
    A = nextrun(A)
print(''.join(map(str, A)))

Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
A.sort()

#カウンター(二次元リストver)
counter = []
count = 0
for i in range(N):
  if(i == 0):
    counter.append([A[i],1])
  else:
    if(A[i] == A[i-1]):
      counter[count][1] += 1
    else:
      count += 1
      counter.append([A[i],1])

count += 1
ans = 0
for i in range(count):
  tmp = counter[i][1]
  if((i != 0)and(i != count-1)):
    if((counter[i][0]-counter[i-1][0])==1):
      tmp += counter[i-1][1]
    if((counter[i+1][0]-counter[i][0])==1):
      tmp += counter[i+1][1]
  elif((i == count-1)and(count >= 2)):
    if((counter[i][0]-counter[i-1][0])==1):
      tmp += counter[i-1][1] 
  ans = max(ans,tmp)

print(ans)

Measured memory_bytes: 14300
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;

string from[12], to[12];

// ツ閉カツ篠堋療アツづーツ置ツつォツ環キツつヲツづゥツ！
string Replace(string s, int n) {
	string res;
	for(int i = 0; i < s.size(); ) {
		if( s.substr(i, from[n].size()) == from[n] ) {
			res += to[n];
			i += from[n].size();
		} else {
			res += s[i];
			i++;
		}
	}
	return res;
}

int solve(string start, string goal, int N) {
	map<string, int> visited;
	queue<string> q;
	q.push(start);
	visited[start] = 0;
	while( !q.empty() ) {
		string cur = q.front(); q.pop();
		int cost = visited[cur];
		if( cur == goal ) return visited[cur];
		
		for(int i = 0; i < N; i++) {
			string next = Replace( cur, i );
			if( next.size() > goal.size() ) continue;
			if( visited.count( next ) == 0 ) {
				visited[ next ] = cost + 1;
				q.push( next );
			}
		}
	}
	return -1;
}

int main() {
	for(;;) {
		int N; cin >> N;
		if( N == 0 ) break;
		for(int i = 0; i < N; i++)
			cin >> from[i] >> to[i];
		string start, goal;
		cin >> start >> goal;
		int res = solve(start, goal, N);
		cout << res << endl;
	}
}

Measured memory_bytes: 1068
#include<bits/stdc++.h>
using namespace std;
 
 
#define rep(i,n,m) for(int i=n;i<m;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define desc_sort(v) sort(v.rbegin(),v.rend())
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define M 1000000007 
#define pushll(head,d) push_into_linkedlist(&head,d)
#define popll(head) dp_delete_first(&head)
#define eol cout<<"\n"
#define N 1000000
 
typedef set<int> si;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector < vector<int> >  vii; 
 
 
int main()
{   
    ios
    int T=1;
    //cin>>T;
    while(T--)
    {
      int n;
      cin>>n;
      vector<float> v(n);
      float s=0;
      for(int i=0;i<n;i++)
      {
        	cin>>v[i];
        	v[i]=1/v[i];
        	s+=v[i];
      }
      cout<<fixed<<setprecision(20)<<1/s;
      
      
      
    }
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    ll n;
    cin >> n;
    ll num_multi_4 = 0;
    ll num_multi_2 = 0; // 4の倍数を除く

    rep(i, n) {
        ll a;
        cin >> a;
        if (a % 4 == 0) num_multi_4++;
        else if (a % 2 == 0) num_multi_2++;
    }

    n -= max(num_multi_2 - 1, 0ll);
    ll limit = n / 2;

    cout << (num_multi_4 >= limit ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll K, X; cin >> K >> X;
    string ans = (500 * K >= X) ? "Yes" : "No";
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-2-18 21:02:21
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  int N;
  cin >> N;
  int a[1010];
  for (auto i = 0; i < N; i++)
  {
    cin >> a[i];
  }
  sort(a, a + N);
  reverse(a, a + N);
  int A = 0, B = 0;
  for (auto i = 0; i < N; i++)
  {
    if (i%2 == 0) {
      A += a[i];
    } else {
      B += a[i];
    }
  }
  cout << A - B << endl;
}

Measured memory_bytes: 256
def gcd(m, n):
    while n:
        m, n = n, m % n
    return m


N = int(input())
A = list(map(int, input().split()))

"順方向累積GCD"
forward_gcd = [0]

for i in range(0, N):
    forward_gcd.append(gcd(forward_gcd[-1], A[i]))

"逆方向累積GCD"
reverse_gcd = [0]
for i in range(N-1, -1, -1):
    reverse_gcd.append(gcd(reverse_gcd[-1], A[i]))

reverse_gcd.reverse()

ans = 0
for i in range(N):
    ans = max(ans, gcd(forward_gcd[i], reverse_gcd[i+1]))

print(ans)


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
// #define endl '\n'

int main() {
  int n, m;
  cin >> n >> m;
  vi ok(n + 1, true);
  rep (i, m) {
    int a;
    cin >> a;
    ok[a] = false;
  }

  vl dp(n + 2);
  dp[0] = 1;
  rep (i, n) {
    if (!ok[i]) dp[i] = 0;
    (dp[i + 1] += dp[i]) %= MOD;
    (dp[i + 2] += dp[i]) %= MOD;
  }
  cout << dp[n] << endl;
}


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

int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	if (N % (A + B) <= A) {
		cout << (N / (A + B)) * A + (N % (A + B)) << endl;
	}
	else {
		cout << (N / (A + B) + 1) * A << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e+8;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m), b(m), c(m,0);
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        int tc;
        for(int j=0;j<b[i];j++){
            cin >> tc;
            c[i] += (1 << (tc-1));
        }
    }

    static int dp[1001][1 << 12]; // dp[i番目までの鍵][開けられた箱] = 最小金額
    for(int i=0;i<=m;i++){
        for(int j=0;j<(1 << n); j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i=1;i<=m;i++){
        for(int j=0;j<(1 << n);j++){
            if(dp[i-1][j] == INF) continue;
            dp[i][(j | c[i-1])] = min(dp[i][(j | c[i-1])],dp[i-1][j] + a[i-1]);
            dp[i][j] = min(dp[i][j],dp[i-1][j]);
        }
    }
    cout << (dp[m][(1<<n)-1] == INF?-1:dp[m][(1<<n)-1]) << endl;    
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//a^n mod p
//n > 0
//#include <cmath>
long long modpow(long long a, long long n, long long p) {
	a %= p;
	if (a == 0) return 0;
	if (a == 1) return 1;
	long long b = 1, cnt = 0;
	while (b < p && cnt < n) {
		b *= a;
		cnt++;
	}
	if (b < p) return b;
	b %= p;
	return modpow(b, n / cnt, p) * (long long)pow(a, n % cnt) % p;
}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	vll cnt(n, 0);
	for (ll i = 0; i < n; i++) cnt[a[i]]++;

	bool ans = true;
	if (n % 2 == 0) {
		for (ll i = 0; i < n; i++) {
			if (i % 2 == 0 && cnt[i] > 0) ans = false;
			if (i % 2 == 1 && cnt[i] != 2) ans = false;
		}
	}
	else {
		if (cnt[0] != 1) ans = false;
		for (ll i = 1; i < n; i++) {
			if (i % 2 == 0 && cnt[i] != 2) ans = false;
			if (i % 2 == 1 && cnt[i] > 0) ans = false;
		}
	}
	if (!ans) cout << 0 << endl;
	else {
		cout << modpow(2, n / 2, p) << endl;
	}
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)

s = A[-1]
p = [0 for _ in range(s+1)]
for i in A:
    p[i] += 1
    if p[i] > 1:
        continue
    for j in range(i*2,s+1,i):
        p[j] += 1
ans = 0
for i in A:
    if p[i] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 165368
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int64_t> vec(N);
  int64_t sum = 0;
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  int64_t sum_x = 0;
  int64_t ans = sum;
  for(int i=0; i<N; i++){
    sum_x += vec.at(i);
    int64_t x = sum - sum_x;
    ans = min(ans,abs(sum_x - x));
  }
  cout << ans << endl;
} 

Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)

	for i := range a {
		fmt.Scan(&a[i])
	}

	s := bubble(a)

	for i := range a {
		if i > 0 {
			fmt.Print(" ")
		}
		fmt.Print(a[i])
	}
	fmt.Println()

	fmt.Println(s)
}

func bubble(a []int) int {
	s := 0
	for i := 0; i < len(a); i++ {
		for j := len(a) - 1; j >= i+1; j-- {
			if a[j-1] > a[j] {
				a[j-1], a[j] = a[j], a[j-1]
				s++
			}
		}
	}

	return s
}



Measured memory_bytes: 1128
#include <iostream>

using namespace std;
using ll = long long;

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

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

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

  int ans = 0;
  for (int a = 1; a <= k; ++a) {
    for (int b = 1; b <= k; ++b) {
      for (int c = 1; c <= k; ++c) { ans += gcd(gcd(a, b), c); }
    }
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3604
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=99999;

char buff[1000];
char query(int idx) {
	printf("%d\n",idx); fflush(stdout);
	scanf("%s",buff); return buff[0];
}

int n;
void solve(int a,char ta,int b,char tb) {
	assert((b-a)%2==(ta==tb?1:0));
	assert(b-a>=2);
	int c=(a+b)/2;
	char tc=query(c);
	if(tc=='V') return;
	if((c-a)%2==(ta==tc?1:0)) solve(a,ta,c,tc); else solve(c,tc,b,tb);
}

void run() {
	scanf("%d",&n);
	char c=query(0);
	if(c=='V') return;
	solve(0,c,n,c);
}

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


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

using namespace std;
const int N = 1e4+5;
const int MOD = 1e9+7;
void add(int &a, int b)
{
    a+=b;
    if (a>=MOD)
        a-=MOD;
}
int main()
{
    string k;
    int d;
    cin >> k >> d;
    int n = k.length();
    vector< vector<int> > dp(d,vector<int>(2));
    dp[0][0] = 1;
    for (int i = 0; i<n; i++)
    {
        vector< vector<int> > new_dp(d,vector<int>(2));
        for (int sum = 0; sum<d; sum++)
            for (bool took: {false, true})
                for (int digit = 0; digit<10; digit++){
                    if (digit>k[i]-'0' && !took)
                        break;
                    bool t = (took || digit<k[i]-'0');
                    add(new_dp[(sum+digit)%d][t],dp[sum][took]);
                }
        dp = new_dp;
    }
    cout << ((dp[0][0]+dp[0][1])%MOD-1+MOD)%MOD;
}


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

#define int 		long long
#define vi 			vector <int>
#define si 			set <int>
#define pii 		pair<int,int>
#define fr(n) 		for(__typeof(n) i=0;i<n;i++)
#define rep(i,a,b) 	for(__typeof(b) i=a;i<b;i++)
#define repi(i,b,a) for(__typeof(a) i=b;i>=a;i--)
#define tr(a) 		for(auto it=a.begin();it!=a.end();it++)
#define pb 			push_back
#define mp 			make_pair
#define F 			first
#define S 			second
#define FAST 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define time_passed	1.0 * clock() / CLOCKS_PER_SEC

void solve()
{
	int n;
	cin>>n;
	string s;
	map <string,int> m;
	fr(n)
	{
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<endl;
	cout<<"WA x "<<m["WA"]<<endl;
	cout<<"TLE x "<<m["TLE"]<<endl;
	cout<<"RE x "<<m["RE"]<<endl;
}

signed main()
{
	FAST
	int test=1;
	//cin>>test;
	while(test--)
	{
		solve();
	}
	cerr<<endl<<"Time elapsed : "<<time_passed<<endl;
	return 0;
}

Measured memory_bytes: 3844
#include<iostream>
using namespace std;
int dp[200000];
int main(){
    int n;
    cin>>n;
    int a[200000];
    for(int i=0;i<n;i++)cin>>a[i];

    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);

    for(int i=2;i<n;i++){
        dp[i]+=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
    }

    cout<<dp[n-1];
}

Measured memory_bytes: 1024
//package atcoder;
 
import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for(int i=0;i<s.length();i++) {
			System.out.print("x");
		}
	}
}
		

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

typedef long long ll;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
int w,h;
char maze[200][200];
typedef pair<pair<int,int> , int > State;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

void solve(){
  queue<State> q;
  pair<int,int> goal(2*w-2,2*h-2);
  q.push(State(make_pair<int,int>(0,0),1));
  while(!q.empty()){
    State cur = q.front();q.pop();
    if(goal==cur.first){
      cout<<cur.second<<endl;
      return ;
    }
    for(int i=0;i<4;i++){
      int nx=cur.first.first+dx[i];
      int ny=cur.first.second+dy[i];
      if(nx<0||ny<0||nx>goal.first||ny>goal.second||maze[ny][nx]=='1')continue;
      nx+=dx[i];
      ny+=dy[i];
      if(nx<0||ny<0||nx>goal.first||ny>goal.second||maze[ny][nx]=='1')continue;
      maze[ny][nx]='1';
      q.push(State(make_pair<int,int>(nx,ny),cur.second+1));
    }
  }
  cout<<0<<endl;
  return;
}
int main(){
  while(cin >> w >> h && (w||h)){
    for(int i=0;i<200;i++)for(int j=0;j<200;j++)maze[i][j]='0';
    for(int i=0;i<h*2-1;i++){
      if(i%2){
	for(int j=0;j<w;j++)cin>>maze[i][j*2];
      }
      else{
	for(int j=0;j<w-1;j++)cin>>maze[i][j*2+1];
      }
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 948
#include <stdio.h>

int main(void)
{
  int a[3];
  int tmp=0;
  int i, j;
  scanf("%d %d %d", &a[0], &a[1], &a[2]);

  for (i = 0; i < 2; i++) {
    for (j = i; j < 3; j++) {
      if (a[i] > a[j]) {
        tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }

  for (i = 0; i < 3; i++) {
    printf("%d", a[i]);
    if (i == 2) {
      putchar('\n');
    } else {
      putchar(' ');
    }
  }

  return 0;
}

Measured memory_bytes: 600
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	H = getlist()
	H = sorted(H)
	ans = 0
	if K >= N:
		print(0)
		return
	
	for i in range(N - K):
		ans += H[i]

	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 75760