akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
using namespace std;
vector<int>g[1100];
char in[1100];
int bb[1100];
int bs[1100];
int cur;
int num;
void expr(){
	int at=num;
	if(in[cur]=='('){
	//	printf("%d %d\n",at,num+1);
		num++;
		if(~at)g[at].push_back(num);
		cur++;
		expr();
		cur++;
	}else{
		num++;
	//	printf("%d %d\n",at,num+1);
		if(~at)g[at].push_back(num);
		cur++;
	}
	cur++;
	if(in[cur]=='('){
	//	printf("%d %d\n",at,num+1);
		num++;
		if(~at)g[at].push_back(num);
		cur++;
		expr();
		cur++;
	}else{
	//	printf("%d %d\n",at,num+1);
		num++;
		if(~at)g[at].push_back(num);
		cur++;
	}
}
string lb[1100];
string dfs(int a){
	if(g[a].size()==0){
		string ret="x";
		return lb[a]=ret;
	}
	string L=dfs(g[a][0]);
	string R=dfs(g[a][1]);
	if(L>R)swap(L,R);
	lb[a]="("+L+","+R+")";
	//printf("%d: %s\n",a,lb[a].c_str());
	return lb[a];
}
set<string> v1[2];
set<string> v2;
void dfs2(int a,int b){
	v2.insert(lb[a]);
	v1[b].insert(lb[a]);
	for(int i=0;i<g[a].size();i++)dfs2(g[a][i],b);
}
int dp[130][130];
int comp(int a,int b){
	if(~dp[a][b])return dp[a][b];
	if(bs[a]*bb[b]!=bs[b]*bb[a])return bs[a]*bb[b]>bs[b]*bb[a];
	if(g[a].size()==0&&g[b].size()==0)return -2;
	int lh=comp(g[a][0],g[a][1]);
	if(lh==-2)lh=0;
	int rh=comp(g[b][0],g[b][1]);
	if(rh==-2)rh=0;
	int res=comp(g[a][lh],g[b][rh]);
	if(res!=-2)return res;
	res=comp(g[a][!lh],g[b][!rh]);
	return res;
}
void dfs3(int a,int b){
	if(g[a].size()==0)return;
	if(b==0){
		if(comp(g[a][0],g[a][1])==1)swap(g[a][0],g[a][1]);
	}else{
		if(comp(g[a][0],g[a][1])==0)swap(g[a][0],g[a][1]);
	}
	for(int i=0;i<g[a].size();i++)dfs3(g[a][i],i);
}
void out(int a){
	if(g[a].size()==0){printf("x");return ;}
	printf("(");
	out(g[a][0]);
	printf(" ");
	out(g[a][1]);
	printf(")");
}
int main(){
	while(1){
		gets(in);
		if(in[0]=='0')return 0;
		//printf("%s\n",in);
		if(in[0]=='x'){
			printf("x\n");continue;
		}
		for(int i=0;i<1100;i++)g[i].clear();
		cur=0;
		num=-1;
		expr();
		dfs(0);
		for(int i=0;i<num;i++){
			if(!g[i].size()){
				bs[i]=0;
				bb[i]=1;
			}else{
				v1[0].clear();
				v1[1].clear();
				v2.clear();
				dfs2(g[i][0],0);
				dfs2(g[i][1],1);
				bb[i]=v2.size();
				bs[i]=0;
				for(set<string>::iterator it=v1[0].begin();it!=v1[0].end();it++){
					if(v1[1].count(*it))bs[i]++;
				}
			}
			//printf("%d %d\n",bs[i],bb[i]);
		}
		for(int i=0;i<130;i++)for(int j=0;j<130;j++)
			dp[i][j]=-1;
		dfs3(0,0);
		out(0);
		printf("\n");
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    vector <vector <int>> matrix(15, vector<int>(15, -1));
    REP(i, n){
       ll a; cin >> a;
       REP(_, a){
           ll x; cin >> x;
           x--;
           ll y; cin >> y;
           matrix[i][x] = y;
       }
    }
    int ans = 0;
    REP(i, pow(2, n)){
        ll j = i;
        int anska = 0;
        vector <bool> honests(15, false);
        REP(_, 15){
            honests[_] = j % 2;
            anska += j % 2;
            j /= 2;
            if (j==0){
                break;
            }
        }
        bool success = true;
        REP(x, 15) {
            REP(y, 15) {
                if (honests[x] == 0) {
                    continue;
                }
                if (matrix[x][y] == -1) {
                    continue;
                }
                if (matrix[x][y] == honests[y]) {
                    continue;
                }
                success = false;
            }
        }
        if (success){
            ans = max(ans, anska);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;
    
#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;
    
int n;
multiset<int> a;
int ans[100000][2];
int result;
int in;
int main(){

    cin >> n;
    rep(i,n){
        cin >> in;
        a.insert(in);
    }
    
    for(int i=0; i<n-2; i++){
        /*
        cout << "\t";
        for(int j=0; j<a.size(); j++){
            cout << a[j] << " ";
        }
        cout << endl;
        */
       auto target = a.begin();
       target ++; 
       auto bottom = a.end();
       bottom --;

        if(*target <= 0){
            ans[i][0] = *bottom;
            ans[i][1] = *target;
            a.erase(target);
            a.erase(bottom);
            a.insert(ans[i][0] - ans[i][1]);
        }else{
            ans[i][0] = *a.begin();
            ans[i][1] = *target;
            a.erase(target);
            a.erase(a.begin());
            a.insert(ans[i][0] - ans[i][1]);
        }
    }
    
        // cout << "\t";
        // for(int j=0; j<a.size(); j++){
        //     cout << a[j] << " ";
        // }
        // cout << endl;
    auto itr = a.begin();
    ans[n-2][1] = *itr;
    itr ++;
    ans[n-2][0] = *itr;
    //cout << "a:" << ans[n-2][0] << "\tb:" << ans[n
    result = ans[n-2][0] - ans[n-2][1];
    
    cout << result << endl;
    for(int i=0; i<n-1; i++){
        cout << ans[i][0] << " " << ans[i][1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 7808
from collections import deque

n, k = map(int, input().split())
v = list(map(int, input().split()))


res = 0

#i個取る。(0個〜k個)
for i in range(min(k+1, len(v)+1)):
    # j個を右からとり、i-j個を左から取る。
    for j in range(i):
        ans = []
        q = deque(v)
        for _ in range(j):
            ans.append(q.pop())
        for _ in range(i-j):
            ans.append(q.popleft())
        ans = sorted(ans)
        pos = 0
        for t in range(min(len(ans),k-i)):
            if ans[t] <= 0:
                pos = t + 1
            else:
                break      
        res = max(sum(ans[pos:]), res)
  
print(res)

Measured memory_bytes: 42220
n = int(input())
s = input()
ans = 10**9
w = s.count('W')
e = s.count('E')
w_count = 0
e_count = 0
for i in range(n):
    if s[i] == 'W':
        w -= 1
        ans = min(ans,e+w_count)
        w_count += 1
    else:
        e -= 1
        ans = min(ans,e+w_count)
        e_count += 1

print(ans)


Measured memory_bytes: 3828
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for m in range(M)]
AB = list(map(list, set(map(tuple, AB))))

i = []
for m in range(len(AB)):
    a = AB[m][0]
    b = AB[m][1]
    if H[a-1] > H[b-1]:
        i.append(b-1)
    elif H[a-1] < H[b-1]:
        i.append(a-1)
    else:
        i.append(a-1)
        i.append(b-1)

i = list(set(i))
print(len(H)-len(i))

Measured memory_bytes: 50392
import java.util.Scanner;

public class Main {

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

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        System.out.println(a * b % 2 == 0 ? "Even" : "Odd");
    }
}


Measured memory_bytes: 21204
#include<cstdio>
#include<cstring>
using namespace std;
const int MAXN=53;

bool G[MAXN][MAXN];
int a[MAXN],b[MAXN];

bool dfs(int u,int ed)
{
	if(u==ed)
		return true;
	for(int i=0;i<MAXN;i++)
		if(G[u][i])
			if(dfs(i,ed))
				return true;
	return false;
}

int main()
{
	long long ans=0;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",a+i);
	for(int i=1;i<=n;i++)
		scanf("%d",b+i);
	ans=(1LL<<51LL)-2LL;
	int cnt=0;
	for(int i=50;i>0;i--)
	{
		memset(G,0,sizeof G);
		for(int j=0;j<=50;j++)
			for(int k=1;k<=j;k++)
				if(k!=i&&(ans&(1LL<<(long long)k))!=0)
					G[j][j%k]=true;
		bool flag=true;
		for(int j=1;j<=n;j++)
			if(!dfs(a[j],b[j]))
			{
				flag=false;
				cnt++;
				break;
			}
		if(flag)
			ans^=(1LL<<(long long)i);
	}
	if(cnt==50)
		puts("-1");
	else
		printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
a= list(map(int, input().split()))
bc=[[0, 0]]
for i in range(m):
  bc.append(list(map(int, input().split())))
del bc[0]
bc=sorted(bc, key=lambda x: x[1], reverse=True)
a.sort()
count = 0
s = 0
for j in range(m):
  for i in range(bc[j][0]):
    if a[count] < bc[j][1]:
      s = s + bc[j][1]
      count = count + 1
    else:
      break
    if count > n - 1 :
      break
  else: 
    continue
  break
if count > n - 1:
  print(s)
else:
  print(s + sum(a[count:]))

Measured memory_bytes: 82712
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void){

    ll A,B,C,D; cin>>A>>B>>C>>D;

    ll lcm = (C*D)/__gcd(C,D);
    ll ans = B - (B/C + B/D - B/lcm);
    ans -= A-1 - ((A-1)/C + (A-1)/D - (A-1)/lcm);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (ll)(s); i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    string s; cin>>s;
    reverse(all(s));
    vector<string> box(4);
    box[0]="maerd";
    box[1]="remaerd";
    box[2]="esare";
    box[3]="resare";
    int now=0;
    bool ans=true;
    while(now<s.size()){
        bool ok=false;
        rep(i,0,4){
            if(s.substr(now,box[i].size())==box[i]){
                now+=box[i].size();
                ok=true;
                break;
            }
        }
        if(!ok){
            ans=false;
            break;
        }
    }
    if(ans) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 512
N, K = map(int, input().split())
A = list(map(int, input().split()))

dp = [False for _ in range(K + 1)]

for i in range(1, K + 1):
    for j in range(N):
        if i >= A[j]:
            dp[i] |= not dp[i - A[j]]

if dp[K]:
    print("First")
else:
    print("Second")


Measured memory_bytes: 45168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//cout << setprecision(numeric_limits<long double>::max_digits10)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
    int n, k; cin >> n >> k;
    if(n % k == 0){cout << 0 << endl; return 0;}
    else{cout << 1 << endl; return 0;}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		if(s.charAt(1) == 'B') System.out.println("ARC");
		else System.out.println("ABC");
		
	}

}


Measured memory_bytes: 35596
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABCK = GetInput_int();
            int result = 0;
            if (ABCK[0] >= ABCK[3])
            {
                result = ABCK[3];
            }else if (ABCK[0] + ABCK[1] >= ABCK[3])
            {
                result = ABCK[0];
            }
            else
            {
                var sub = ABCK[3] - (ABCK[0] + ABCK[1]);
                result = ABCK[0] - sub;
            }
            Console.WriteLine(result);
        }

        
        #region input
        

        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion

        static long mod = 1000000000 + 7;
    }

}

Measured memory_bytes: 27556
import java.util.Scanner;

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

        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();
        int sum = a1+a2+a3;

        if(sum>=22)
        {
            System.out.println("bust");
        }
        else
        {
            System.out.println("win");
        }

        sc.close();

    }
}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    //algorithmライブラリのsort関数を用いることでソートできる。
    //sort(first_itr, last_itr) でfirstからlastの範囲を(第三引数無しのときは)昇順でソートする
    //ただし、first,secondの値はイテレータ。
    //例vector<int> v = {3, 1, 4, 2, 5};　sort(v.begin(), v.end());
    //とすると v = {1, 2, 3, 4, 5}となる。
    //第三引数はプレディケート(判断基準)
    //今回はgreater(降順)
    sort(a.begin(), a.end(), greater<int>());
    int Alice = 0, Bob = 0;
    for(int i = 0; i < N; i++){
        if(i % 2 == 0){
            Alice += a.at(i);
        }else{
            Bob += a.at(i);
        }
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

while True:
   x, y, s = map(int, input().split())
   if x + y + s == 0: break
   
   smax = 0
   for i in range(1, s): 
      for j in range(i, s):
         if i * (100 + x) // 100 + j * (100 + x) // 100 == s:
            ss = i * (100 + y) // 100 + j * (100 + y) // 100
            if ss > smax:
               smax = ss
   print(smax)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
vector<long long> fact_inv, inv, Com;

//  init_nCk :二項係数のための前処理 計算量:O(n)
void init_nCk(int n, int SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
    Com.resize(SIZE + 5);
    Com[0] = 1;
    for (int i = 1; i < SIZE + 5; i++) {
        Com[i] = Com[i - 1] * ((n - i + 1) * inv[i] % MOD) % MOD;
    }
}

//  nCk :MODでの二項係数を求める(前処理 int_nCk が必要) 計算量:O(1)
long long nCk(int k) {
    assert(!(k < 0));
    return Com[k];
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main() {
    ll n,a,b; cin >>n >> a >> b;
    init_nCk(n, min(n, 2*(ll)pow(10, 5)));

    ll ans = mod((modpow(2, n, MOD) - 1), MOD);
    ans = mod(ans-((Com[a]+Com[b])%MOD), MOD);
    cout <<  ans << endl;
    return 0;
}

Measured memory_bytes: 7964
n = int(input())
s = input()

nopen = 0
sl = ''
sr = ''

for c in s:
    if c == '(':
        nopen += 1
    else:
        if nopen == 0:
            sl += '('
        else:
            nopen -= 1

nopen = sum([1 if c == '(' else -1 for c in sl + s])
sr = ')' * nopen


print(sl + s + sr)


Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int n,i,flag=0,j;
  char b;
  char s[100001];
  char a[4][100002];
  scanf("%d",&n);
  scanf("%s",s);
  a[0][0]=a[0][1]=a[1][0]=a[2][1]='S';
  a[1][1]=a[2][0]=a[3][0]=a[3][1]='W';
  for(i=0;i<4;i++){
    if((a[i][0]=='S'&&a[i][1]=='S'&&s[0]=='o')||(a[i][0]=='W'&&a[i][1]=='S'&&s[0]=='x')||(a[i][0]=='S'&&a[i][1]=='W'&&s[0]=='x')||(a[i][0]=='W'&&a[i][1]=='W'&&s[0]=='o'))
        b='S';
      else
        b='W';
    for(j=1;j<n;j++){
      if((a[i][j-1]=='S'&&a[i][j]=='S'&&s[j]=='o')||(a[i][j-1]=='W'&&a[i][j]=='S'&&s[j]=='x')||(a[i][j-1]=='S'&&a[i][j]=='W'&&s[j]=='x')||(a[i][j-1]=='W'&&a[i][j]=='W'&&s[j]=='o'))
        a[i][j+1]='S';
      else
        a[i][j+1]='W';
    }
    if(a[i][0]==a[i][n]&&b==a[i][n-1]){
      a[i][n]='\0';
      printf("%s\n",a[i]);
      return 0;
    }
  }
  printf("-1\n");
}
        


Measured memory_bytes: 768
//arc060_c.cpp
//Sat Jun 23 13:19:44 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

int a;

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

	int x[50];
	for (int i=0;i<n;i++){
		cin >> x[i+1];
	}

	ll dptable[51][51][2501];

	for (int j=0;j<=n;j++){
		for (int k=0;k<=n;k++){
			for (int s=0;s<=2500;s++){
				if (j==0 && k==0 && s==0){
					dptable[j][k][s] = 1;
				}else if (j>=1 && s<x[j]){
					dptable[j][k][s] = dptable[j-1][k][s];
				}else if (j>=1 && k>=1 && s>=x[j]){
					dptable[j][k][s] = dptable[j-1][k][s] + dptable[j-1][k-1][s-x[j]];
				}else {
					dptable[j][k][s] = 0;
				}
			}
		}
	}

	ll ans = 0;

	for (int k=1;k<=n;k++){
		ans += dptable[n][k][k*a];
	}

	cout << ans << endl;
}

Measured memory_bytes: 51072
#include<cstdio>
using namespace std;
#define N 270001
#define mod 998244353
int a[N],b[N],n,su;
int pw(int a,int p){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
int fwt(int *a,int n,int f)
{
	for(int l=2;l<=n;l<<=1)
	for(int j=0;j<n;j+=l)
	for(int k=j;k<j+(l>>1);k++)
	if(f)
	{
		int t1=a[k],t2=a[k+(l>>1)];
		a[k]=(t1+t2)%mod;
		a[k+(l>>1)]=(t1-t2+mod)%mod;
	}
	else
	{
		int t1=a[k],t2=a[k+(l>>1)];
		a[k]=1ll*(t1+t2)*(mod+1)/2%mod;
		a[k+(l>>1)]=1ll*(t1-t2+mod)*(mod+1)/2%mod;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<1<<n;i++)scanf("%d",&a[i]),su+=a[i];
	for(int i=0;i<1<<n;i++)a[i]=1ll*a[i]*pw(su,mod-2)%mod-(i==0),b[i]=i==0?(1<<n)-1:mod-1;
	fwt(a,1<<n,1);fwt(b,1<<n,1);
	for(int i=0;i<1<<n;i++)a[i]=1ll*b[i]*pw(a[i],mod-2)%mod;
	fwt(a,1<<n,0);
	int tp=a[0];
	fwt(a,1<<n,1);
	a[0]=(a[0]+mod-1ll*tp*(1<<n)%mod)%mod;
	fwt(a,1<<n,0);
	for(int i=0;i<1<<n;i++)printf("%d\n",a[i]);
}//orz_zyw

Measured memory_bytes: 4736
A, B, C, D = map(int, input().split())
def gcd(a, b):
    return gcd(b, a%b) if b!=0 else a
lcd = C*D//gcd(C,D)
A = A-1
print( (B - B//C - B//D + B//lcd) - (A - A//C - A//D + A//lcd) )

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

struct UnionFind{
    vector<long long> par;
    UnionFind(long long N) : par(N){
        for(long long i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    long long root(long long x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(long long x, long long y){
        long long rx = root(x);
        long long ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
    }
    bool same(long long x, long long y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

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

    long long n, m;
    cin >> n >> m;
    
    UnionFind uf(n);
    vector<long long> A(m), B(m);
    for(long long i = 0; i < m; i++){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }

    long long sts = (n - 1) * (n) / 2;
    vector<long long> Ans(m);
    for(long long i = m - 1; i >= 0; i--){
        if(uf.same(A[i], B[i])){
            Ans[i] = sts;
        }else{
            long long asi = -uf.par[uf.root(A[i])];
            long long bsi = -uf.par[uf.root(B[i])];
            //cout << asi << "--" <<  bsi << endl;
            if(sts > 0) sts -= asi * bsi;
            Ans[i] = sts;
        }
        uf.unite(A[i], B[i]);
    }

    long long t = (n - 1) * (n) / 2;
    for(long long i = 1; i < m; i++){
        cout << Ans[i] << endl;
    }
    cout << t << endl;


    return 0;
}

Measured memory_bytes: 4480
N = int(input())
x = []
y = []
for i in range(N):
	xt, yt = map(int, input().split())
	x.append(xt)
	y.append(yt)

import math, itertools, statistics

res = []
for v in itertools.permutations(range(N), N):
	d = []
	for i in range(N-1):
		d.append(
			math.sqrt((x[v[i]]-x[v[i+1]])**2 + (y[v[i]]-y[v[i+1]])**2))
	res.append(sum(d))
print(statistics.mean(res))

Measured memory_bytes: 6548
<?php
  $input = fgets(STDIN);
$input2 = fgets(STDIN);
$feet_and_number = explode(" ", $input);
$house_position = explode(" ", $input2);
$social_distanse= [] ;
foreach ($house_position as $key => $value){
  if($key==0){
    $social_distanse[$key]=$feet_and_number[0]-end($house_position)+$value;
  }else{
    $social_distanse[$key]=$value-$house_position[$key-1];
  }
}
$answer=$feet_and_number[0]-max($social_distanse);
echo $answer
  ?>


Measured memory_bytes: 35568
N = gets.to_i
arr = gets.split.map(&:to_i)

current_num = -1
ans = 0
count = 1

arr.each do |n|
  if n == current_num
    count += 1
  else
    ans += count/2
    count = 1
  end
  current_num = n
end

ans += count/2

puts ans

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>

int main()
{
  char s[11];
  scanf("%s", s);
  const int len = strlen(s);
  const int lim = 1 << (len - 1);

  long long ans = 0;
  for (int i = 0; i < lim; ++i)
  {
    long long k = 0;
    for (int j = 0; j < len; ++j)
    {
      k = k * 10 + s[j] - '0';
      if (i & (1 << j))
      {
        ans += k;
        k = 0;
      }
    }
    ans += k;
  }
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(int N, int[][] A) {
    int[][] standby = new int[][](N, N);
    Tuple!(int, int)[] match;

    foreach (i; 0 .. N) {
        auto a = A[i];
        auto x = min(a.front - 1, i);
        auto y = max(a.front - 1, i);
        a.popFront;
        A[i] = a;
        if (++standby[x][y] == 2)
            match ~= tuple(x, y);
    }

    int ans;
    int done;
    Tuple!(int, int)[] nmatch = [];

    while (true) {
        ans++;
        foreach (t; match) {
            done++;
            auto x = t[0];
            auto y = t[1];

            if (!A[x].empty) {
                auto nx = A[x].front - 1;
                auto a = A[x];
                a.popFront;
                A[x] = a;
                auto x1 = min(x, nx);
                auto x2 = max(x, nx);
                if (++standby[x1][x2] == 2)
                    nmatch ~= tuple(x1, x2);
            }

            if (!A[y].empty) {
                auto ny = A[y].front - 1;
                auto a = A[y];
                a.popFront;
                A[y] = a;
                auto y1 = min(y, ny);
                auto y2 = max(y, ny);
                if (++standby[y1][y2] == 2)
                    nmatch ~= tuple(y1, y2);
            }  
        }
        if (nmatch.empty)
            break;
        match = nmatch[];
        nmatch = [];
    }

    if (done == N * (N - 1) / 2)
        return ans;
    return -1;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    int N;
    N = input.front.to!int;
    input.popFront;

    int[][] A = new int[][](cast(size_t) (N), cast(size_t) (N-1));
    foreach (i; 0 .. cast(size_t) (N)) {
        foreach (j; 0 .. cast(size_t) (N-1)) {
            A[i][j] = input.front.to!int;
            input.popFront;
        }
    }

    static if (is(ReturnType!solve == void))
        solve(N, A);
    else
        solve(N, A).writeln;
}


Measured memory_bytes: 12796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  ll n;
  cin>>n;
  if(n%1000==0){
    cout<<'0'<<endl;
  }
  else{
  ll mai=n/1000+1;
  cout<<mai*1000-n<<endl;
  }
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define int ll
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define vi vector<int>
#define pii pair<int,int>
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define MAX 100005
#define initialize(arr,elem) memset(arr,elem,sizeof(arr))
#define sz size

typedef long long ll;
// typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n,m,visited[MAX], dp[MAX];
vi graph[MAX];
int res = 0;
int solve(int n){
	if (dp[n]!= -1) return dp[n];
	if (graph[n].sz() == 0) return dp[n] = 0;

	int ans = 0;
	for (auto u:graph[n]){
		ans = max(1+solve(u),ans);
	}
	if (ans>res) res = ans;
	return dp[n] = ans;
}

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

	cin>>n>>m;
	For(i,0,m){
		int x,y;
		cin>>x>>y;
		graph[x].pb(y);
	}	
	initialize(dp,-1);
	For(i,1,n+1) solve(i);
	cout<<res;
	return 0;
}


Measured memory_bytes: 8576
def f(N): # N is string
    k = len(N)
    dp = [[[[0 for _ in range(10)] for _ in range(2)] for _ in range(2)] for _ in range(k+1)]
    for j in range(10):
        dp[1][0][0][j]=(j==int(N[0]))
        dp[1][0][1][j]=0
        dp[1][1][0][j]=(j<int(N[0]))
        dp[1][1][1][j]=0
    for i in range(2,k+1):
        for j in range(10):
            for m in range(10):
                dp[i][0][1][j] += (dp[i-1][0][0][m]+dp[i-1][0][1][m])*(abs(m-j)<=1)*(j==int(N[i-1]))
            dp[i][1][0][j]=1
            for m in range(10):
                dp[i][1][1][j] += (dp[i-1][0][0][m]+dp[i-1][0][1][m])*(abs(m-j)<=1)*(j<int(N[i-1]))\
                                    +dp[i-1][1][1][m]*(abs(m-j)<=1)
            for m in range(1,10):
                dp[i][1][1][j] += dp[i-1][1][0][m]*(abs(m-j)<=1)
    cnt = 0
    for j in range(10):
        cnt += dp[k][0][0][j]+dp[k][0][1][j]+dp[k][1][0][j]+dp[k][1][1][j]
    return cnt-1
K = int(input())
low = 0
high = 4*10**9
while high-low>1:
    mid = (high+low)//2
    n = f(str(mid))
    if n<K:
        low = mid
    elif n>=K:
        high = mid
print(high)

Measured memory_bytes: 60400
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int k; cin >> k;
    int total = 0;
    F0R(i,1,k)F0R(j,1,k)F0R(h,1,k) total += __gcd(i,__gcd(j,h));
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3624
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
N, K = lr()

def cmb(n, k):
    if k < 0 or k > n: return 0 
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

U = 2005 # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)
for i in range(1, K+1):
    answer = cmb(N-K+1, i)
    if K > i:
        #１つずつ全てに配置すると残りはK-i個、壁はi-1個
        answer *= cmb(K-i+i-1, K-i)
    print(answer % MOD)
# 38

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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    if(s[0]=='+')ans++;
    else if(s[0]=='-')ans--;
    if(s[1]=='+')ans++;
    else if(s[1]=='-')ans--;
    if(s[2]=='+')ans++;
    else if(s[2]=='-')ans--;
    if(s[3]=='+')ans++;
    else if(s[3]=='-')ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main() {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    var sum: Long = 0
    repeat(n + 1) {
        sum += fizzbuzz(it)
    }
    println(sum)
}

fun fizzbuzz(num: Int): Int {
    return if (num % 3 == 0 && num % 5 == 0) {
        0
    } else if (num % 3 == 0) {
        0
    } else if (num % 5 == 0) {
        0
    } else {
        num
    }
}

Measured memory_bytes: 36228
(defun test1(lst)
  (let ((lst0 (sort lst #'<)))
	(test0 lst0)
	))
(defun test0(lst)
  (if (null (cdr lst))
	(car lst)
	(let* ((a0 (pop lst))
		   (a1 (pop lst)))
	  (test0 (cons (/ (+ a0 a1) 2) lst)))))
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))
(defun g()
  (let* ((n (read-line nil nil))
		 (lst (mapcar #'parse-integer (splitat #\space (read-line nil nil)))))
	(format t "~F" (test1 lst))))
(g)


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    string s; cin >> s;
    int n = s.length();
    rep(i,n) if (s[i] == '?') s[i] = 'D';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3628
import sys
A = str(input())
B = int(input())
count = 0

for i in range(len(A)):
    if A[i] == "1":
        count += 1
    else:
        if B <= count:
            print(1)
            sys.exit()
        else:
            print(A[i])
            sys.exit()
print(1)


Measured memory_bytes: 9056
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] a = new int[n];
		int xorsum = 0;
		for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
			xorsum ^= a[i];
		}
		sc.close();
		PrintWriter pw = new PrintWriter(System.out);
		for(i = 0; i < n; i++) {
			pw.print(xorsum^a[i]);
			if(i==n-1) {
				pw.println();
			} else {
				pw.print(" ");
			}
		}
		pw.flush();
	}
}


Measured memory_bytes: 50292
my $N = <>;
$input = <>;
chomp $input;
my @list = split //,$input;
 
$next = "A";
$count = 0;
for($i=0;$i<=($#list-2);$i++){
  #$count++ if substr($input, $i, 3) eq "ABC";
  my $str = sprintf("$list[$i]$list[$i+1]$list[$i+2]");

  if( $str eq "ABC" ){
       $count++;
  }
}
print "$count";

Measured memory_bytes: 384
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    int num = 'a';
    while(true){
        if(num == 97){
            if(sa.empty()){
                cout << "A" << endl;
                break;
            }
            else{
                num = sa.at(0);
                sa.erase(0,1);
            }
        }
        else if(num == 98){
            if(sb.empty()){
                cout << "B" << endl;
                break;
            }
            else{
                num = sb.at(0);
                sb.erase(0,1);
            }
        }
        else if(num == 99){
            if(sc.empty()){
                cout << "C" << endl;
                break;
            }
            else{
                num = sc.at(0);
                sc.erase(0,1);
            }
        }
    }
}


Measured memory_bytes: 3572
#include<map>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int n;
long long ans;
char s[10005];
map<pair<string,string>,int>f;
int main(){
	scanf("%d%s",&n,s);
	for(int i=0;i<1<<n;i++){
		string a,b;
		for(int j=0;j<n;j++){
			if((i>>j)&1)a+=s[j];
			else b+=s[j];
		}
		f[{a,b}]++;
	}
	for(int i=0;i<1<<n;i++){
		string a,b;
		for(int j=0;j<n;j++){
		    if((i>>j)&1)a+=s[2*n-1-j];
			else b+=s[2*n-1-j]; 
		}
		ans+=f[{a,b}]; 
	}
	printf("%lld",ans);
}

Measured memory_bytes: 91904
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

using namespace std;
typedef long long ll;

int main()
{
    // Input
    ll n, m, k;
    cin >> n >> m >> k;

    vector<ll> a(n + 1), cumlativeSumA(n + 1, 0);
    REP(i, n) {
        cin >> a[i];
        cumlativeSumA[i] = cumlativeSumA[i - 1] + a[i];
    }

    vector<ll> b(m + 1), cumlativeSumB(m + 1, 0);
    REP(i, m) {
        cin >> b[i];
        cumlativeSumB[i] = cumlativeSumB[i -1] + b[i];
    }

    ll ans = 0;
    ll bNum = m;
    rep(aNum, n + 1) {
        if (cumlativeSumA[aNum] > k) {
            break;
        }
        while(cumlativeSumB[bNum] > (k - cumlativeSumA[aNum]) && bNum > 0) {
            bNum--;
        }
        ans = max(ans, aNum + bNum);
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N; cin >> N;
    VI A(N),B(N);
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    VVI dp((1<<N)+1, VI(55,INF));
    dp[0][0] = 0;
    for(int mask = 0; mask < (1<<N); mask++){
        int cnt = 0;
        REP(i,N) if((mask>>i)&1) cnt++;

        vector<PII> ords;
        int iter = cnt;
        REP(i,N) if(!((mask>>i)&1)) ords.eb(i,iter++);
        for(int s = 0; s <= 50; s++){
            if(dp[mask][s] == INF) continue;
            for(auto p : ords){
                int ns = -1;
                if(abs(p.first-cnt)%2 == 0) ns = A[p.first];
                else ns = B[p.first];
                if(ns >= s){
                    chmin(dp[mask|(1<<p.first)][ns], dp[mask][s]+abs(p.second-cnt));
                }
            }
        }
    }
    int ans = INF;
    REP(s,51) chmin(ans,dp[(1<<N)-1][s]);
    if(ans == INF) cout << -1 << endl;
    else cout << ans  << endl;


}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class T>
inline void out(T a) {
	cout<<a<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


ll N,D;
int ans;

void input() {
	cin>>N>>D;
}

void solve() {
	for(int i=0; i<N; i++) {
		ll x,y; cin>>x>>y;
		if(x*x+y*y <= D*D) ans++;
	}
	cout<<ans<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3652
function main(input) {
    const reverse = (s) => {
	return s.split('').reverse().join('');
    };

    const WORDS = ['dream','dreamer','erase','eraser'].map(reverse);
    const S = reverse(input.split('\n')[0]);

    var index = 0;

    while(true){
	var w = WORDS.find((w) => S.startsWith(w,index));
	if(!w) break;
	index += w.length;
    }
    if (S.length === index){
	console.log('YES');
    }else{
	console.log('NO');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 11416
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int n=0,a=0,sum=0;
	char s[110];
    cin>>s; 
	for(int i=0;i<strlen(s);i++)
    {
        if(s[i]=='C') a=1;
        if( s[i]=='F' && a==1 ) n=1;
    }
    if(n)
    cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 384
n, a, b = gets.strip.split.map(&:to_i)
result = 0
 
(1..n).each do |i|
  j = i
  sum = 0
  while j > 0
    sum += j % 10
    j = j / 10
  end
    result += i if sum.between?(a, b)
end
 
puts result

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  cin >> T;
  while (T--) solve();
}

// https://kmjp.hatenablog.jp/entry/2020/07/12/0900
void solve() {
  int n;
  cin >> n;

  priority_queue<pii> q[2];
  ll ans = 0;
  rep(i, n) {
    int k, l, r;
    cin >> k >> l >> r;
    k--;
    if (l > r) {
      q[0].emplace(l - r, k);
      ans += r;
    } else if (l < r) {
      q[1].emplace(r - l, n - 1 - k - 1); // q[0]と同じように扱いたい
      // n=3で, k=2ならn-1-k=0
      // i>2ならokが, i≤0ならokになる
      // だから, n-1-k-1にして, i<0ならokにする
      ans += l;
    } else ans += l;
  }

  auto calc = [&](priority_queue<pii> q) {
    int sz_ = sz(q);
    set<int> s;
    rep(i, sz_) s.emplace(i);
    rep(i, sz_) {
      int x, k;
      tie(x, k) = q.top();
      q.pop();

      auto it = s.upper_bound(k);
      // cerr << *it << "  " << s << endl;
      if (it == s.begin()) continue;
      ans += x;
      // cerr << k << " " << x << " " << *(--it) << endl; ++it;
      s.erase(*(--it));
    }
  };
  calc(q[0]); calc(q[1]);
  cout << ans << endl;
}


Measured memory_bytes: 10296
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let (n, m): (usize, usize);
    input!(n, m);
    let mut v = vec![0; n];
    for _ in 0..m {
        let (a, b): (usize, usize);
        input!(a, b);
        v[a - 1] += 1;
        v[b - 1] += 1;
    }
    for z in v {
        p(z);
    }
}

Measured memory_bytes: 4352