akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
int n,m,c,i,j,s,a[100005];
int main()
{
	scanf("%d%d%d",&n,&c,&m);
	fz1(i,n){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	fz1(i,n){
		j=0;s++;
		while(i+j<=n&&j<c&&a[i+j]-a[i]<=m) j++;
		i+=j-1;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
const int MAXN = 100;
const int HALFN = MAXN / 2;
int main()
{
    int a, b;
    cin >> a >> b;

    --a, --b;
    cout << MAXN << ' ' << MAXN << endl;
    
    char ans[MAXN][MAXN];
    rep(i, 0, HALFN)
    rep(j, 0, MAXN)
        ans[i][j] = '#';

    rep(i, HALFN, MAXN)
    rep(j, 0, MAXN)
        ans[i][j] = '.';
    
    rep(i, 0, a)
    {
        int x = i / HALFN;
        int y = i % HALFN;
        ans[2 * x][2 * y] = '.';
    }
    rep(i, 0, b)
    {
        int x = i / HALFN;
        int y = i % HALFN;
        ans[2 * x + HALFN + 1][2 * y] = '#';
    }

    rep(i, 0, MAXN)
    {
        rep(j, 0, MAXN)
            printf("%c", ans[i][j]);
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var _N = long.Parse(Console.ReadLine());
        var _Ps = Console.ReadLine().Split().Select(x => long.Parse(x)).ToList();
        long min = 0;
        var first = true;
        var count = 0;
        foreach(var p in _Ps)
        {
            if(first)
            {
                first = false;
                count++;
                min = p;
            }
            else
            {
                if(min >= p)
                {
                    min = p;
                    count++;
                }
            }
        }
        Console.WriteLine(count);
#if DEBUG
        Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 35676
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		double sum = 0;
 
		for (int i = 0; i < n; i++) {
			sum += 1 / scan.nextDouble();
		}
		System.out.println(1 / sum);
	}
}

Measured memory_bytes: 23252
N = int(input())
dp = [float("inf")] * N
h = list(map(int,input().split()))

dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])

Measured memory_bytes: 85924
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        int n = sc.nextInt();
        int m = sc.nextInt();

        if(n == m){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
	}
}

Measured memory_bytes: 21844
use std::io::Read;
fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let mut x: i32 = iter.next().unwrap().parse().unwrap();
    let mut ans = 0;

    ans += (x / 500) * 1000;
    x %= 500;
    ans += (x / 5) * 5;

    println!("{}", ans);
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

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

ll lcm(ll x, ll y) {
    return x / gcd(x,y) * y;
}

int main(void)
{
    IOS
    int k; cin >> k;
    k++;
    ll ans = 0;
    FOR(a,1,k) FOR(b,1,k) FOR(c,1,k) {
        ans += gcd(a,gcd(b,c));
    } 

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, ma, mb;
  cin >> n >> ma >> mb;
  vi a(n), b(n), c(n);
  rep(i, n) cin >> a[i] >> b[i] >> c[i];
  int dp[410][410];
  rep(i, 410) rep(j, 410) dp[i][j] = 1e9;
  dp[0][0] = 0;
  rep(k, n) for(int i = 409; i >= 0; i--) for(int j = 409; j >= 0; j--) {
    if(dp[i][j] == 1e9) continue;
    int ni = i + a[k], nj = j + b[k];
    dp[ni][nj] = min(dp[ni][nj], dp[i][j] + c[k]);
  }
  int ans = 1e9;
  rep2(i, 1, 410) rep2(j, 1, 410) if(i * mb == j * ma) ans = min(ans, dp[i][j]);
  cout << (ans == 1e9 ? -1 : ans) << endl;
}

Measured memory_bytes: 896
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

slashSum = 0
n.times { |i| slashSum += a[i] ** 2 }

sum = (a.sum ** 2 - slashSum) / 2

puts sum % (10 ** 9 + 7)


Measured memory_bytes: 35880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 200200;
int v[MN],w[MN];
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&v[i]);
		w[i] = v[i]-i-1;
	}
	sort(w,w+n);
	ll val = w[n/2];
	ll tot = 0;
	for(int i=0;i<n;i++) {
		tot += abs(v[i]-val-i-1);
	}
	printf("%lld\n",tot);
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int a,b,c[100000];
    cin>>a>>b;
    for(int i=0;i<a;i++){
        cin>>c[i];
    }
    a=a-b;
    if(a%(b-1)==0){
        b=a/(b-1)+1;
    }else{
        b=a/(b-1)+2;
    }
    cout<<b<<endl;
    
}

Measured memory_bytes: 640
let n = stdin.ReadLine() |> int
if (stdin.ReadLine().Split() |> Array.map int |> Array.filter (fun x -> x % 2 = 0) |> Array.forall (fun x -> x % 3 = 0 || x % 5 = 0)) then "APPROVED" else "DENIED"
|> printfn "%s"

Measured memory_bytes: 14044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> P;
#define rep(i,n) for(ll i=0;i<n;++i)
const int INF=1001001001;


int main(){
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  if (n<=k){
    while (n>abs(n-k)){
      n=abs(n-k);
    }
    cout<<n;
    return 0;
  }
  ans+=n/k;
  n-=k*ans;
  while (n>abs(n-k)){
    n=abs(n-k);
  }
  cout<<n;


  }


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    int M = 0;
    int m = 1100000000;
    REP(i, N){
        int a;
        cin >> a;
        m = min(m, a);
        M = max(M, a);
    }
    cout << M - m << endl;
}

Measured memory_bytes: 256
import sys
a = []
while True:
    x = map(int, raw_input().split())
    if x[0] == 0 and x[1] == 0:
        break
    a.append(x)
for i in range(len(a)):
    for j in range(a[i][0]):
        for k in range(a[i][1]):
            sys.stdout.write('#')
        print ''
    print ''

Measured memory_bytes: 6380
from itertools import permutations as perm


def inpl():
    return tuple(map(int, input().split()))


N = int(input())
P = inpl()
Q = inpl()

for i, p in enumerate(perm([j+1 for j in range(N)])):
    if p == P:
        pi = i
    if p == Q:
        qi = i
print(abs(pi-qi))


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

int main() {
  int n,i,j,k,cnt=0;
  cin>>n;
  
  //cout<<n/7<<endl;
  for(i=0;i<=(n/4);i++){
    for(j=0;j<=(n/7);j++){
      //cout<<"i="<<i<<endl;
      //cout<<"j="<<j<<endl;
      if(n==4*i+7*j){
        cnt++;
      }
    }
  }
  
  if(cnt>0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
const int N = 1e5 + 7;
vi g[N];
bool vis[N];
int n, m, p[N], flag[N], flagn;
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> n >> m;  
	rep(i, 0, n) cin >> p[i], p[i]--;
	rep(i, 0, m) {
		int a, b; cin >> a >> b, a--, b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	int ans = 0;
	rep(i, 0, n) if (!vis[i]) {
		vi q; q.pb(i); vis[i] =true;
		rep(_u, 0, sz(q)) {
			int u = q[_u];
			for (auto v : g[u]) if (!vis[v]) {
				vis[v] = true;
				q.pb(v);
			}
		}
		flagn++;
		for (auto u : q) flag[u] = flagn;
		for (auto u : q) ans += flag[p[u]] == flagn;
	}
	cout << ans;
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin>>n;
	int i = 1;
	do
	{
		int x = i;
		if(x % 3 == 0)
		{
			cout << " " << i;
		} else
		{
			do
			{
				if(x % 10 == 3)
				{
					cout << " " << i;
					break;
				}

				x /= 10;
			} while(x);
		}
	} while(++i <= n);

	cout << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main(void){
  
  int n, m, a, b;
  int i;
  cin>>n>>m;
  vector<int> v1(n,0);
  for(i=0;i<m;i++) 
  {
    cin>>a>>b;
    v1.at(a-1)++;
    v1.at(b-1)++;
  }
  
  for(i=0;i<n;i++) 
  {
    cout<<v1.at(i)<<endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <stdio.h>
using namespace std;

int main(){
	int N; cin >> N;
	int d = N % 1000;
	int e;
	if (d == 0) {
		e = 0;
	}
	else {
		e = 1000 - d;
	}
	cout << e << endl;
}

Measured memory_bytes: 3624
import java.util.*;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        while(true){

            
            //各個数入力
            String input = scan.nextLine();
            
            //空白区切り
            String[] each_num = input.split(" ");
            
            
            //Int型へ変更
            int power = Integer.parseInt(each_num[0]);
            int motor = Integer.parseInt(each_num[1]);
            int cable = Integer.parseInt(each_num[2]);
            
        
            
            //終了時判定
            if ((power == 0)&&(motor == 0)&&(cable == 0)){
                break;
            }
            
            
            //テスト回数入力。その後Int型へ変換
            String input_count = scan.nextLine();
            int count = Integer.parseInt(input_count);
            

            //二次元リストを宣言
            ArrayList<ArrayList<Integer>> data = new ArrayList<ArrayList<Integer>>();
            
            //各テスト結果をリストに追加。
            for (int i=0;i<count;i++){
                String input_data = scan.nextLine();
                String[] each_data = input_data.split(" ");
                ArrayList<Integer> contents = new ArrayList<Integer>();
                contents.add(Integer.parseInt(each_data[0]));
                contents.add(Integer.parseInt(each_data[1]));
                contents.add(Integer.parseInt(each_data[2]));
                contents.add(Integer.parseInt(each_data[3]));
                data.add(contents);
            }
            
            //各部品の故障状況の配列を作成。
            int flag[] = new int[power+motor+cable+1];
            //初めは、故障か判断不可な2を格納
            for (int i=1; i<power+motor+cable+1 ; i++){
                 flag[i] = 2;
            }
            
            
            for (int i=0; i<count; i++){
                
                //テスト結果が正常な場合、その時の部品全て正常な状況を示す1をflag[]に格納する
                if(data.get(i).get(3) == 1) {
                    for(int j=0; j < 3; j++){
                        flag[data.get(i).get(j)] = 1;
                    }
                }
            }
            
            
            //故障の部品探し。テスト不可の際に、使用部品のうち、２つ正常な部品を使っている場合、残りの一つが故障と断定。
            int counter = 0;
            for (int i=0; i< count; i++){
                counter = 0;
                for (int j = 0; j<3; j++){
                    if (flag[data.get(i).get(j)] == 1){
                        counter ++;
                        
                    }
                }
                if(counter == 2){
                    for (int j = 0; j<3; j++){
                        if (flag[data.get(i).get(j)] != 1){
                            flag[data.get(i).get(j)] = 0;
                        }
                    }
                    
                }
            }
            //出力部分
            for (int i=1; i<power+motor+cable+1 ; i++){
                 System.out.println(flag[i]);
            }
        }
    }
}



Measured memory_bytes: 34924
package main

import (
	"fmt"
)

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

	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}

	ans := 0
	for i := 0; i < n - 2; i++ {
		if p[i] < p[i+1] && p[i+1] < p[i+2] {
			ans += 1
		} else if p[i] > p[i+1] && p[i+1] > p[i+2] {
			ans += 1
		}
	}
	fmt.Println(ans)
}

func main() {
	solve()
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	string input;
	cin >> N;
	cin >> input;

	int left = 0;
	int right = 0;

	for (int i = 0; i < N; i++)
	{
		if (input[i] == '(')
		{
			right++;
		}
		else
		{
			if (right == 0)
			{
				left++;
			}
			else
			{
				right--;
			}
		}
		//cout << left << " " << right << endl;
	}

	for (int i = 0; i < left; i++)
	{
		cout << "(";
	}

	cout << input;

	for (int i = 0; i < right; i++)
	{
		cout << ")";
	}
	cout << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main() {
	string S, T; cin >> S >> T;
	int ans = 0;
	for (int i = 0; i <= (S.size() - T.size()); i++)
	{
		int cnt = 0;
		for (int j = 0; j < T.size(); j++)
		{
			if (S.at(i + j) == T.at(j))cnt++;
		}
		ans = max(cnt, ans);
	}
	cout << T.size() - ans << endl;
}

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

int main(){
    string s; cin >> s;
    vector<int> res(100010, 0);
    int idx, cntr = 0, cntl = 0;
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == 'R') cntr++;
        else cntl++;
        if(s.at(i) == 'R' && i + 1 < s.size() && s.at(i + 1) == 'L') idx = i;
        else if(s.at(i) == 'L'){
            if(i == s.size() - 1 || s.at(i + 1) == 'R'){
                res.at(idx) = (cntr + 1)/2 + cntl/2;
                res.at(idx + 1) = cntr/2 + (cntl + 1)/2;
                cntr = 0;
                cntl = 0;
            }
        }
    }
    for(int i = 0; i < s.size(); i++){
        cout << res.at(i) << " ";
    }
}

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

using namespace std;

long long d[55];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long n, x = 0;
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> d[i];
	for(int i = 0; i < n; ++i) for(int j = i + 1; j < n; ++j) x += d[i] * d[j];
	cout << x;

	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <math.h>
using namespace std;
 
int K, X;

int main(){
  if(scanf("%d %d", &K, &X)==1);
  
  for(int i=1; i<2*K; i++){
    printf("%d ", X-K+i);
  }

  
  return 0;
}

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

vector<int> divs[1000005];
int cnt[1000005];


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

	for (int i = 2; i <= 1000000; ++i) {
		for (int m = i; m <= 1000000; m += i) {
			divs[m].push_back(i);
		}
	}

	int N;
	cin >> N;
	vector<int> A(N);
	for (int& e : A) cin >> e;


	bool pair = 1;

	for (int i = 0; i < N; ++i) {
		for (int d : divs[A[i]]) {
			// cout << i << " " << d << endl;
			if (cnt[d] > 0) {
				pair = 0;
			}
			cnt[d]++;
		}
	}

	if (pair) {
		cout << "pairwise coprime" << endl;
	} else {
		for (int v = 1; v <= 1000000; ++v) {
			// cout << kv.first << " " << kv.second <<endl;
			if (cnt[v] == N) {
				cout << "not coprime" << endl;
				return 0;
			}
		}
		cout << "setwise coprime" << endl;
	}
}

Measured memory_bytes: 121472
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
print(1-(N//2)/N)

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

#define _ ios::sync_with_stdio(0);
#define __ cin.tie(0);
#define ___ cout.tie(0);
#define endl "\n";
#define fr first
#define se second

using namespace std;

int main() { _ __ ___

	string s;
cin >> s;
for(int i=0; i<12; i++) {
cout << s[i];
if(i == 3) cout << " ";
}	
cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef pair<pair<int, int>, string> p;
int main() {
	int n; bool b = false;
	while (cin >> n, n) {
		if (b)cout << endl;
		p l[11];
		for (int i = 0; i < n; i++) {
			cin >> l[i].second;
			int a, b, c; cin >> a >> b >> c;
			l[i].first = make_pair(a * 3 + c, n - i);
		}
		sort(l, l + n);
		for (int i = n - 1; i >= 0; i--) {
			cout << l[i].second << ',' << l[i].first.first << endl;
		}
		b = true;
	}
}

Measured memory_bytes: 3124
#include<iostream>
using namespace std;
int d[11][1<<20];
main()
{
	int n,k;cin>>n>>k;
	d[0][1]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<1e5;j++)
		{
			if(d[i][j])
			{
				d[i+1][j+k]=d[i+1][2*j]=1;
			}
		}
	}
	for(int i=0;i<1e5;i++)
	{
		if(d[n][i])
		{
			cout<<i<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 20736
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 998244353;
const ll INF = 1000000000000000;
ll n, g[100010];



ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}



int main(void)
{
	
	cin >> n;

	ll d[100010];
	ll lar = 0;
	ll ans = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> d[i];
		g[d[i]]++;
		lar = max(lar, d[i]);
	}
	

	for (int i = 1; i <= lar; i++)
	{
		(ans *= pow(g[i - 1], g[i])) %= mod;
	}

	if (d[0] != 0 || g[0] != 1)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << ans << endl;
	}


	int xxx;
	cin >> xxx;
}


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

int main() { 
    int H, W;
    cin >> H >> W;
    vector<vector<char>> field(H, vector<char> (W));
    vector<vector<int>> dist(H, vector<int> (W, -1));
    queue<pair<int, int>> q;
    vector<int> dx = {-1, 1, 0, 0};
    vector<int> dy = {0, 0, 1, -1};
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> field[i][j];
            if (field[i][j] == '#') {
                dist[i][j] = 0;
                q.push(make_pair(i, j));
            }
        }
    }

    while(q.size()) {
        int h = q.front().first; int w = q.front().second;
        q.pop();
        for (int i = 0; i < 4; i++) {
            int nh = h+dx[i]; int nw = w+dy[i];
            if (nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
            if (dist[nh][nw] == -1) {
                dist[nh][nw] = dist[h][w]+1;
                q.push(make_pair(nh, nw));
            }       
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(ans, dist[i][j]);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13456
d = input().split()
ans = []
cnt = 0
for day in range(int(d[1])+1):
    if (day >= 22):
        if (int(str(day)[0]) >=2 and int(str(day)[1]) >=2 ):
            ans.append(int(str(day)[0]) * int(str(day)[1]))
for date in range(2, int(d[0])+1):
    cnt = cnt + ans.count(date)
print(cnt)
    

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){

	int m,n;
	scanf("%d %d", &m, &n);
	int a[m][n],b[n];
	int i,j;

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

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


	int c[m];
	for(i=0;i<m;i++){
		c[i]=0;
		for(j=0;j<n;j++){
			c[i]+=a[i][j]*b[j];
		}
		printf("%d\n",c[i]);
	}

return 0;
}


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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

int main() {
    int a, b, c; cin>>a>>b>>c;
    int x = max({a, b, c});

    if((a + b + c) % 2 == x % 2) cout << (3 * x - (a + b + c)) / 2 << endl;
    else cout << (3 * (x + 1) - (a + b + c)) / 2 << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C
import Data.Map (Map)
import qualified Data.Map as Map

main :: IO ()
main = do
  [n, m] <- readInts
  input <- toTup2 <$> readNInts m
  print $ solve n input

solve :: Int -> [(Int, Int)] -> Int
solve n input = foldl' (\a x -> a + testH x) 0 perms
  where
    inputMap = Map.fromList $ zip input (repeat ())
    perms = map (1 :) $ permutations [2 .. n]
    toAdjList vs = foldl' (\a x -> makeAdj x : a) [] [0 .. n - 2]
      where
        makeAdj x = if v1 < v2 then (v1, v2) else (v2, v1)
          where
            v1 = vs !! x
            v2 = vs !! (x + 1)
    testH vs = case foldM foldFunc () (toAdjList vs) of
      Just _  -> 1
      Nothing -> 0
    foldFunc _ x = Map.lookup x inputMap

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


Measured memory_bytes: 1020
N, K = map(int, input().split())

ans = 0
for i in reversed(range(1, N+1)):
    n = 1
    # i番目のサイコロの目（=i）がKを超えるには何回コインで面を出す必要があるか
    while i < K:
        # 2倍にしている
        n <<= 1
        i <<= 1
    # Kを超える確率（=超えるために必要なコインが連続で表になる確率をansに加算する）
    ans += 1/n

# ansには各目が出る確率の合計が格納されているので値をN（サイコロの目の数）で割る
print(ans/N)


Measured memory_bytes: 2940
n = int(input())
s = input()
r = len(list(filter(lambda c: c == 'R', s)))
g = len(list(filter(lambda c: c == 'G', s)))
b = len(list(filter(lambda c: c == 'B', s)))
ans = r * g * b - sum([sum([1 for j in range(i + 1, (n + i + 1) // 2) if s[i] != s[j] and s[j] != s[(k := 2 * j - i)] and s[k] != s[i]]) for i in range(n)])
print(ans)


Measured memory_bytes: 9192
N = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = float("inf")

for loop in range(2 ** N):

    s = format(loop,'b').zfill(N) #sはどのカードが奇数番目かを表す。ビットの組み合わせを2^N通り入れて全探索。
    on = 0
    
    for j in s:
        if j == "1":
            on += 1

    if on != (N+1)//2: #sの立っているビットの数が奇数番目の位置の個数に合っていなかったら飛ばす
        continue

    q = []  #奇数番目に置くカードの集合
    q2 = [] #偶数番目に置くカードの集合

    for i in range(N): #カードの位置の偶奇に合わせて表裏を決める
        if s[i] == "1":
            if i % 2 == 0:
                q.append([A[i],i])
            else:
                q.append([B[i],i])
        else:
            if i % 2 != 0:
                q2.append([A[i],i])
            else:
                q2.append([B[i],i])           

    q.sort()
    q2.sort()
    q2.append([float("inf"),0]) #偶数番目は1枚少ないことがあるので番兵
    

    flag = True #昇順になっているかのフラグ
    nmax = 0    #現在の最大値(昇順判定に使う)

    for i in range((N+1)//2): #昇順判定プロセス


        if nmax > q[i][0]:
            flag = False
        nmax = q[i][0]

        if nmax > q2[i][0]:
            flag = False
        nmax = q2[i][0]

    if flag: #昇順だったらrにカードの番号(not 書かれている数字)を入れてく
        r = []
        for i in range((N+1)//2):
            r.append(q[i][1])
            r.append(q2[i][1])

        #ここから転倒数の計算(無理やりシミュレーション)
        now = 0
        z = [i for i in range(N)]
        for i in range(N):
            for j in range(len(z)):
                if z[j] == r[i]:
                    now += j
                    del z[j]
                    break
        ans = min(now,ans) #求める答えは転倒数の最小値

if ans == float("inf"):
    ans = -1
print (ans)

Measured memory_bytes: 55416
// Problem : B - Easy Linear Programming
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define ll long long
#define endl "\n"
#define lb "lower_bound"
#define ub "upper_bound"
#define bs "binary_search"

int dif(int a,int b){if(a > b)return a - b;else return b - a;}
int min(int a,int b){if(a > b)return b;else return a;}
int max(int a,int b){if(a > b)return a;else return b;}
int gcd(int a, int b){if(b == 0)return a;return gcd(b, a%b);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    ll sum = 0;
    if(k > a)
    {
    	sum += a;
    	k = k - a;
    }
    else
    {
    	cout<<k;
    	return 0;
    }
    if(k <= b)
    {
    	cout<<sum;
    	return 0;
    }
    else
    {
    	k = k - b;
    }
    sum -= min(k,c);
    cout<<sum;
	return 0;
}


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


void solve()
{
  int x,n;
  cin>>x>>n;
  if(n==0)
  {
      cout<<x;
      return;
  }
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];

  sort(arr,arr+n);
//  int start=arr[0];
  int end=arr[n-1];
  int ans=abs(x-arr[0]+1);
  int ref=arr[0]-1;
  
//int ref;
  for(int i=0;i<n-1;i++)
  {  
     for(int j=arr[i]+1;j<arr[i+1];j++)
     {
       if(ans>abs(x-j))
       {
       ref=j;
       ans=abs(x-j);
       //continue;
       }
     }
  }
 if(ans>abs(x-(arr[n-1]+1)))
  {
   ans=abs(x-(arr[n-1]+1));
 ref=arr[n-1]+1;
  }
 
  cout<<ref;
}
int main()
{
solve();
}


Measured memory_bytes: 3600
/**********************************
 ***                            ***
 ***     MD.Eklasur Rahman      ***
 ***                            ***
 **********************************/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<iomanip>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<math.h>
#include<iterator>
#include<algorithm>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#define sci(x)   scanf("%d%*c",&(x))
#define scll(x)  scanf("%lld%*c",&(x))
#define scc(c)   scanf("%c%*c",&(x))
#define scd(d)   scanf("%lf%*c",&(x))
#define scf(f)   scanf("%f%*c",&(x))
#define scstr(s) scanf("%s",(s))
#define pfi(x)   printf("%d",(x))
#define pfd(x)   printf("%lf",(x))
#define pff(x)   printf("%f",(x))
#define pn       printf("\n")
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
using ll  = long long int ;
using ld  = long double ;
using pii = pair<int,int>;
using pdd = pair<double,double>;
using pff = pair<float,float>;
using Pll = pair<long long int,long long int>;
using pcc = pair<char,char>;
using psi = pair<string,int>;
using pis = pair<int,string>;
using vi  = vector<int>;
using vd  = vector<double>;
using vll = vector<long long int>;
using vld = vector<long double>;
using vc  = vector<char>;
using vs  = vector<string>;
using spi = set<pii>;
using vpii = vector<pii>;
using vpll = vector<Pll>;
using vpcc = vector<pcc>;
using vpff = vector<pff>;
using vpdd = vector<pdd>;
using vpis = vector<pis>;
using vpsi = vector<psi>;
///Main Function
int main()
{
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int A,B,C;
    sci(A);sci(B);sci(C);
    if(A==B)
        cout<<C<<endl;
    else
    {
        A=A-B;
        if(A>=C)
            cout<<0<<endl;
        else
        {
            cout<<C-A<<endl;
        }
    }
    return 0;
}





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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    ll n, a, b, c, d; cin>>n>>a>>b>>c>>d;
    for(ll i=0; i<n; i++){
        if(c*i-d*(n-i-1)<=b-a && b-a<=d*i-c*(n-i-1)){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdlib>
using namespace std;
int n;
int S[100];
int s =0;
int main()
{
 	string str;
 	getline(cin, str);
 	stringstream ss(str);
 	char val[8];
 	while(!ss.eof())
	 {
	 	ss >> val;
		switch(val[0])
		{
		case '+': --s; S[s-1] += S[s]; break;
		case '-': --s; S[s-1] -= S[s]; break;
		case '*': --s; S[s-1] *= S[s]; break;
		default: S[s++] = atoi(val);
		}
	}
	cout << S[s-1] << endl;
	return 0;
}

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

int n,p,ans=0;
int a[200005],b[200005],c[10005];

int quick_power(int a,int b)
{
	int res=1;
	for (;b;b=b>>1,a=(a*a)%p)
	{
		if (b&1)  res=(res*a)%p;
	}
	return res;
}

signed main()
{
	cin>>n>>p;
	c[0]=1;
	
	for (int i=1;i<=n;i++)
	{
		char x;
		cin>>x;
		a[i]=x-'0';
	}
	if (p==2)
	{
		for (int i=1;i<=n;i++)
		{
			if (a[i]%2==0)  ans+=i;
		}
		cout<<ans<<endl;
		return 0;
	}
	else if (p==5)
	{
		for (int i=1;i<=n;i++)
		{
			if (a[i]==0||a[i]==5)  ans+=i;
		}
		cout<<ans<<endl;
		return 0;
	}
	for (int i=n;i>=1;i--)  b[i]=(b[i+1]+(a[i]*quick_power(10,n-i+1))%p)%p;
	for (int i=1;i<=n;i++)  c[b[i]]++;
	for (int i=0;i<=p-1;i++)  ans=ans+((c[i]*c[i]-c[i])/2);
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3456
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int64 fn(int64 x){
    int64 sum=0ull;
    string s = to_string(x);
    for(uint i=0; i<s.size(); ++i){
        sum += s[i] - '0';
    }
    return sum;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int64 X; cin >> X;
    
    int64 fx = fn(X);
    cout << (X % fx == 0 ? "Yes":"No") << endl;
    
    return 0;
}

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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;

    int cnt_0 = 0, cnt_1 = 0;
    for (char c: s) {
        if (c == '0') ++cnt_0;
        else ++cnt_1;
    }
    cout << cnt_0 + cnt_1 - (max(cnt_0, cnt_1) - min(cnt_0, cnt_1)) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve() 
{
    int n;cin>>n;
    int a[n];int xr=0;set<int>avb;
    REP(i,n)cin>>a[i],xr^=a[i],avb.insert(a[i]^(a[i]-1));
    int ans=0;
    for(int i=29;i>=0;i--){
        if((xr>>i)&1){
            if(!avb.count((1<<i+1)-1)){cout<<-1<<endl;return;}
            xr^=(1<<i+1)-1;
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,p,a[200010],pow10[200010] = {1};
	string s;
	cin >> n >> p >> s;
	for(int i = 0;i < n;i++) a[i] = s[i] - '0';
	for(int i = 1;i <= n;i++) pow10[i] = pow10[i - 1] * 10 % p;
	map<int,int> cnt;
	cnt[0]++;
	int ans = 0,sum = 0;
	for(int i = 0;i < n;i++){
		sum = (sum * 10 + a[i]) % p;
		int tmp = sum * pow10[n - i - 1] % p;
		if((p != 2 && p != 5) || a[i] % p == 0) ans += cnt[tmp];
		cnt[tmp]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4100
#include <stdio.h>
#include <string.h>
#include <limits.h>

#define WHITE 0
#define BLACK 1
#define NIL -1


int prim(int);


int w[101][101];

int main(){
  int n, sum;
  int i, j;
  
  scanf("%d", &n);

  for(i =  1; i <= n; i++){
    for(j = 1; j <= n; j++){
      scanf("%d", &w[i][j]);
    }
  }
  
  sum = prim(n);

  printf("%d\n", sum);
  
  return 0;
}

int prim(int n){
  int d[101];
  int pi[101];
  int color[101];
  int mincost, sum = 0;
  int u, v, i;
  
  for(u = 1; u <= n; u++){
    d[u] = INT_MAX;
    pi[u] = NIL;
    color[u] = WHITE;
  }

  d[1] = 0;

  while(1){
    mincost = INT_MAX;

    for(i = 1; i <= n; i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }

    if(mincost == INT_MAX) break;

    color[u] = BLACK;

    for(v = 1; v <= n; v++){
      if(color[v] != BLACK && -1 < w[u][v] && w[u][v] < d[v]){
	pi[v] = u;
	d[v] = w[u][v];
      }
    }
  }

  for(i = 1; i <= n; i++) sum = sum + d[i];

  return sum;
}



Measured memory_bytes: 2112
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int n = sc.nextInt();
    boolean[] line = new boolean[105];
    for (int i = 0; i < n; i++) {
      line[sc.nextInt()] = true;
    }

    int pointerLeft = x;
    int pointerRight = x;
    while (true) {
      if (line[pointerLeft] == false) {
        System.out.println(pointerLeft);
        break;
      } else if (line[pointerRight] == false) {
        System.out.println(pointerRight);
        break;
      }
      pointerLeft--;
      pointerRight++;
    }
  }
}


Measured memory_bytes: 36072
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

int main() {
	long double a, b;
	ll h, m;
	cin >> a >> b >> h >> m;
	long double theta_m, theta_h;
	theta_m = m * 6;
	theta_h = 30 * h + 0.5 * m;
	long double theta = theta_h - theta_m;
	cout << setprecision(20) << sqrt(a * a + b * b - 2 * a * b * cos(theta/360 * 2 * acos(-1))) << endl;
} 

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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

ll lcm(ll x,ll y){
    return (x*y)/(__gcd(x,y));
}

int sm(ll n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int fact(ll n){
    if(n==1)
        return 1;
    else
        return n*fact(n-1);
}

signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        ld d;
        cin>>n>>d;
        ll p,q;
        int count=0;
        for(int i=0;i<n;i++){
            cin>>p>>q;
            ld x=sqrt((p*p)+ (q*q))/1.0;
            //cout<<x<<" ";
            if( x<=d)
                count++;
        }
        cout<<count<<endl;
    }   
    return 0;
}


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

constexpr int INF = 1e9;

int main() {
    int n, k;
    while(cin >> n >> k, n) {
        vector<vector<int>> d(n, vector<int>(n, INF));
        for(int i=0; i<n; ++i) {
            d[i][i] = 0;
        }
        for(int i=0; i<k; ++i) {
            int a;
            cin >> a;
            if(a == 0) {
                int b, c;
                cin >> b >> c;
                b--; c--;
                cout << (d[b][c] == INF ? -1 : d[b][c]) << endl;
            } else {
                int b, c, e;
                cin >> b >> c >> e;
                b--; c--;
                if(d[b][c] <= e) {
                    continue;
                }
                for(int j=0; j<n; ++j) {
                    for(int l=0; l<n; ++l) {
                        d[j][l] = min(d[j][l], min(d[j][b] + d[c][l], d[j][c] + d[b][l]) + e);
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 3152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int main() {
	int N;
	cin >> N;
	map<int, int> cnt;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	int ans = 0;
	for (auto i : cnt) {
		if (i.second >= i.first) ans += i.second - i.first;
		else ans += i.second;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4736
#かっこ列とは…( = +1 ) = -1「途中でマイナスにならない」
N = int(input())
AllMinPlus = []
AllMinMinus = []
AllMinZero = []
for n in range(N):
    S = input()
    minkakko = 10000000
    cur = 0
    for s in S:
        if s == "(":
            cur += 1
        else:
            cur -= 1
        minkakko = min(minkakko,cur)
    if cur >= 0:
        AllMinPlus.append((cur,minkakko))
    elif cur == 0:
        AllMinZero.append((cur,minkakko))
    else:
        AllMinMinus.append((cur,minkakko))
AllMinPlus.sort(key = lambda x:x[1],reverse=True)
AllMinMinus.sort(key = lambda x:x[0]-x[1],reverse=True)
AllMin = AllMinPlus + AllMinZero + AllMinMinus

if sum([x[0] for x in AllMin]) == 0:
    pos = 0
    for a,m in AllMin:
        if pos < -m:
            print("No")
            exit()
        pos += a
        if pos < 0:
            print("No")
            exit()        
    #プラス組のなかでMinが大きい順に積んでいく
    #マイナス組のなかでMinが小さい順に積んでいく
    print("Yes")
else:
    print("No")

Measured memory_bytes: 288432
#include <cstdio>
#define MOD 1000000007
typedef long long ll;
ll dp[55][105], C[55][55]; 
int main()
{
	// freopen("AGC022-F.in", "r", stdin); 
	for (int i = 0; i <= 50; i++)
	{
		C[i][0] = 1; 
		for (int j = 1; j <= i; j++)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD; 
	}
	int n; 
	scanf("%d", &n); 
	dp[1][n] = dp[1][n - 1] = 1; 
	for (int i = 1; i < n; i++)
	{
		for (int j = -n; j <= n; j++)
		{
			for (int a = 0; a < n; a++)
			{
				for (int b = 0; b < n; b++)
				{
					if ((a || b) && i + a + b <= n && j <= a + b && -a - b <= j && !(j + a - b & 1))
						(dp[i + a + b][(j + a - b) / 2 + n] += dp[i][j + n] * C[i + a + b][i] % MOD * C[a + b][a]) %= MOD; 
				}
			}
		}
	}
	printf("%lld\n", dp[n][n]);
	return 0; 
}


Measured memory_bytes: 256
//shivamgor498
// https://codeforces.com/gym/100886/problem/G
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define hell 1000000007
#define hell1 1000000006
#define pb push_back
#define x first
#define y second
#define MAXL 100005
#define pll pair<ll,ll>
#define L 1000000000
using namespace std;
//vector<ll>prime(15000002,0);
ll mM(ll a,ll b,ll mod){ll res = 0;a %= mod;while(b){if (b & 1)res = (res + a) % mod;a = (2 * a) % mod;b >>= 1;}return res;}
ll fpow(ll x,ll y,ll p){x=x%p;ll res=1;while(y){if(y&1)res=(res*x)%p;res%=p;if(res<0)res=(res+p)%p;y=y>>1;x=(x*x)%p;if(x<0)x=(x+p)%p;x%=p;}return res;}
ll inv(ll n,ll p){return fpow(n,p-2,p);}
ll modmul(ll x,ll y){return (x*y)%hell;}
ll modadd(ll x,ll y){if(x>=hell)x-=hell;if(y>=hell)y-=hell;ll temp=x+y;if(temp>=hell)temp-=hell;if(temp<0)temp = temp+hell;return temp;}
/*void sieve(){
	prime[0] = -1;
	prime[1] = 0;
	for(ll i=2;i<=15000000;i++)
		if(!prime[i])
			for(ll j=i;j<=15000000;j+=i)
				if(!prime[j])
					prime[j] = i;
}*/
ll h,w;
ll a[1005][1005];
ll dp[1005][1005];
int main(){
	ios
	ll t = 1;
	//cin >> t;
	//sieve();
	while(t--){
		cin >> h >> w;
		for(int i=1;i<=h;i++)
			for(int j=1;j<=w;j++)
			{
				char c;
				cin >> c;
				if(c=='.')
					a[i][j] = 1;
				else
					a[i][j] = 0;
			}
		dp[h][w] = 1;
		for(int i=h;i>0;i--)
			for(int j=w;j>0;j--)
			{
				if(i+1<=h && a[i+1][j])
					dp[i][j] = modadd(dp[i][j],dp[i+1][j]);
				if(j+1<=w && a[i][j+1])
					dp[i][j] = modadd(dp[i][j],dp[i][j+1]);
				if(a[i][j]==0)
					dp[i][j] = 0;
			}
		cout << dp[1][1] << "\n";
	}
}


Measured memory_bytes: 16000
#include <utility> // pair make_pair
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    int n;
    int m;
    cin >> n >> m;
    Vec<int> e(m);
    FOR(i, 0, m) {
        cin >> e[i];
    }
    Vec<bool> check(n, true);
    REFOR(i, m - 1, 0) {
        if (check[e[i] - 1] == true) {
            cout << e[i] << endl;
            check[e[i] - 1] = false;
        }
    }
    FOR(i, 0, n) {
        if (check[i] == true) {
            cout << i + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3360
#include<stdio.h>
int main(void)
{
	int a,s,d;
	scanf("%d %d %d",&a,&s,&d);
	if(a<1 && s<1 && d>0){
		printf("Open\n");
	}
	else if(a>0 && s>0 && d<1){
		printf("Open\n");
	}
	else{
		printf("Close\n");
	}
	
	return 0;
}

Measured memory_bytes: 1012
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <cassert>
#define int int64_t
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

int dp[5050][5050];
void printdp(int n) {
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            cout << dp[i][j] << '\t';
        }
        cout << endl;
    }
}

signed main() {
    int n;
    cin >> n;
    vii hp;
    for (int i = 0; i < n; i++) {
        int h, p;
        cin >> h >> p;
        hp.push_back(ii(h, p));
    }
    sort(hp.begin(), hp.end(), [](ii a, ii b){return a.first + a.second < b.first + b.second;});
    
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    
    for (int i = 0; i < 5050; i++) {
        for (int j = 0; j < 5050; j++) {
            if (j == 0) {
                dp[i][j] = 0;
            } else {
                dp[i][j] = 1e18;
            }
        }
    }
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= i; j++) {
            if (dp[i - 1][j - 1] > hp[i - 1].first) {
                dp[i][j] = dp[i - 1][j];
                continue;
            }
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] + hp[i - 1].second);
        }
    }

//    printdp(n);
    for (int i = 1;; i++) {
        if (dp[n][i] == 1e18) {
            cout << i - 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 199680