akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<long> dp(200010,-1);

long dfs(long i){
  if(dp.at(i) != -1) return dp.at(i);
  long x = __builtin_popcount(i);
  long r = i % x;
  return dp.at(i) = dfs(r) + 1;
}

int main(){
  long n;
  cin >> n;
  string s;
  cin >> s;
  dp.at(0) = 0;
  rep(i,n+1){
    if(dp.at(i) != -1) continue;
    dp.at(i) = dfs(i);
  }
  long num1 = 0;
  rep(i,n){
    if(s.at(i) == '1') num1++;
  }
  long up = num1 + 1;
  long dw = num1 - 1;
  vl ans(n,-1);
  long sum = 0;
  vl two(n+1,1);
  two.at(0) = 1 % up;
  rep(i,n){
    if(s.at(n-1-i) == '1'){
      sum = (sum + two.at(i)) % up;
    }
    two.at(i+1) = two.at(i) * 2 % up;
  }
  rep(i,n){
    if(s.at(n-1-i) == '0'){
      long tmp = (sum + two.at(i)) % up;
      ans.at(n-1-i) = 1 + dp.at(tmp);
    }
  }
  sum = 0;
  if(num1 == 0){
    rep(i,n) cout << ans.at(i) << endl;
    return 0;
  }else if(num1 == 1){
    rep(i,n){
      if(ans.at(i) != -1) cout << ans.at(i) << endl;
      else cout << 0 << endl;
    }
    return 0;
  }
  two.at(0) = 1 % dw;
  rep(i,n){
    if(s.at(n-1-i) == '1'){
      sum = (sum + two.at(i)) % dw;
    }
    two.at(i+1) = two.at(i) * 2 % dw;
  }
  rep(i,n){
    if(s.at(n-1-i) == '1'){
      long tmp = (sum - two.at(i) + dw) % dw;
    
      ans.at(n-1-i) = 1 + dp.at(tmp);
    }
  }
  rep(i,n) cout << ans.at(i) << endl;
}

Measured memory_bytes: 8308
n = int(input())
AB = [list(map(int,input().split())) for _ in range(n)]
AB.sort(key = lambda x:x[1])
s = 0
for ab in AB:
  s += ab[0]
  if s <= ab[1]:
    pass
  else:
    print('No')
    break
else:
  print('Yes')
  




Measured memory_bytes: 53724
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
  int n;
  double x[100]={},y[100]={},a=0,b=0,c=0,d=0;
  cin >> n;
  for(int i=0; i<n; i++) {
      cin >> x[i];
  }
  for(int i=0; i<n; i++) {
      cin >> y[i];
  }
  for(int i=0; i<n; i++) {
      a+=abs(x[i]-y[i]);
  }
  cout << fixed << setprecision(10) << a << endl;
  for(int i=0; i<n; i++) {
      b+=(x[i]-y[i])*(x[i]-y[i]);
  }
  cout << fixed << setprecision(10) << sqrt(b) << endl;
  for(int i=0; i<n; i++) {
      c+=abs(x[i]-y[i])*abs(x[i]-y[i])*abs(x[i]-y[i]);
  }
  cout << fixed << setprecision(10) << pow(c,1.0/3.0) << endl;
  for(int i=0; i<n; i++) {
      d=max(d,abs(x[i]-y[i]));
  }
  cout << fixed << setprecision(10) << d << endl;
}


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

int main(void)
{
    int64_t n;
    std::cin >> n;
    std::vector<int64_t> cost(3, 0);

    int64_t old_a=0, old_b=0, old_c=0;
    for (int64_t i=0; i<n; ++i) {
        int64_t a, b, c;
        std::cin >> a >> b >> c;
        cost.at(0) = std::max(a + old_b, a + old_c);
        cost.at(1) = std::max(b + old_a, b + old_c);
        cost.at(2) = std::max(c + old_a, c + old_b);
        old_a = cost.at(0);
        old_b = cost.at(1);
        old_c = cost.at(2);
    }

    std::cout << *std::max_element(cost.begin(), cost.end()) << std::endl;

    return 0;
}

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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll lf = 2, ls = 1, h;
    if(n == 1){
        cout << 1;
    }
    else
    {
        FOR(i,0,n-1){
            h = ls;
            ls += lf;
            lf = h;
        }
        cout << ls << endl;
    }
    
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>
// #include <multiset>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
	for (T x : s)
		cout << x << " ";
	cout << endl;
}

const int maxn = 2e5 + 7;

pair<int, int> s[maxn];


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i].second >> s[i].first;
	int t = 0;
	sort(s, s + n);
	for (int i = 0; i < n; i++){
		t += s[i].second;
		if (t > s[i].first){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;	
}	

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
int main(void) {
	char c[2];
	int s=0;
	while(scanf("%c",&c[0])!=EOF && (s || c[0]!='0')){
		c[1]='\0';
		if(c[0]=='\n'){
			printf("%d\n",s);
			s=0;
		}
		s+=atoi(c);
	}
	return 0;
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll n_2(ll x){
	return x * (x - 1) / 2ll;
}

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll n, m;
	cin >> n >> m;
	
	cout << n_2(n) + n_2(m) << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll res=0;
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		// a=i
		int from=1,to;
		if(n%i==0)
			to=n/i-1;
		else
			to=n/i;
		res+=1ll*(to-from+1);
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 3688
import sys
n = int(input())
goods = [None] * n
for i, line in enumerate(sys.stdin.readlines()):
    value, weight, serial, date, name = line.split()
    goods[i] = (int(value), int(weight), serial, int(date), name)

goods.sort() #key=lambda x: (x[0], x[1], x[2], x[3], x[4]))
print('\n'.join(map(lambda x: " ".join(map(str, x)), goods)))


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


#define	ll_int	long long int


ll_int **PQ_BOX, *PQ;	// 優先度付きキュー
int *COUNT_BOX;		// 各キューの数をカウント


void Init(int n, int pq_size)
{
	int i;

	PQ = (ll_int *)malloc(sizeof(ll_int) * n * pq_size);
	PQ_BOX = (ll_int **)malloc(sizeof(ll_int *) * n);
	for(i = 0; i < n; i++)
		PQ_BOX[i] = PQ + (i * pq_size);

	COUNT_BOX = (int *)malloc(sizeof(int) * n);
	for(i = 0; i < n; i++)
		COUNT_BOX[i] = 0;
}


// up_heap
void Insert(int t, ll_int x)
{
	int pos = ++COUNT_BOX[t];
	int parent = pos / 2;

	// 丁度良いところまで浮かび上がらせる
	while(1 < pos){
		if(PQ_BOX[t][parent] < x){
			PQ_BOX[t][pos] = PQ_BOX[t][parent];
			pos = parent;
			parent = pos / 2;
		}else
			break;
	}

	PQ_BOX[t][pos] = x;
}


void GetMax(int t)
{
	printf("%lld\n", PQ_BOX[t][1]);
}


// down_heap
void DeleteMax(int t)
{
	int pos = 1;
	int left = 2;
	int count = --COUNT_BOX[t];
	ll_int x;

	x = PQ_BOX[t][0] = PQ_BOX[t][count + 1];

	while(left <= count){
		if(left + 1 <= count && PQ_BOX[t][left] < PQ_BOX[t][left + 1])
			left++;

		if(x < PQ_BOX[t][left]){
			PQ_BOX[t][pos] = PQ_BOX[t][left];
			pos = left;
			left = 2 * pos;
		}else
			break;
	}

	PQ_BOX[t][pos] = x;
}


int main()
{
	int n, q;
	int command, t;
	ll_int x;
	int pq_size;
	int i;

	scanf("%d %d", &n, &q);

	if(n < q)
		pq_size = q;
	else
		pq_size = n;

	// 初期化
	Init(n, pq_size);


	for(i = 0; i < q; i++){
		scanf("%d", &command);

		if(command == 0){
			scanf("%d %lld", &t, &x);
			Insert(t, x);
		}else if(command == 1){
			scanf("%d", &t);
			if(COUNT_BOX[t])
				GetMax(t);
		}else if(command == 2){
			scanf("%d", &t);
			if(COUNT_BOX[t])
				DeleteMax(t);
		}
	}

	return 0;
}


Measured memory_bytes: 6740
#include<bits/stdc++.h>
using namespace std;
int a[1001][1001];
int main() {
	int n;
	scanf("%d",&n);
	int ans=0;
	if(n&1) {
		for(int i=1; i<=n; i++)
			for(int j=1; j<=n; j++)
				if(j!=n-i&&j>i)
					a[i][j]=1,ans++;
		printf("%d\n",ans);
		for(int i=1; i<=n; i++)
			for(int j=1; j<=n; j++)
				if(a[i][j])
					printf("%d %d\n",i,j);
		exit(0);
	}
	for(int i=1; i<=n; i++)
		for(int j=1; j<=n; j++)
			if(j!=n+1-i&&j>i)
				a[i][j]=1,ans++;
	printf("%d\n",ans);
	for(int i=1; i<=n; i++)
		for(int j=1; j<=n; j++)
			if(a[i][j])
				printf("%d %d\n",i,j);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(void){
   int alpha[26],i,n,t=0;
   char str[100000];

   scanf("%s",str);
   n=strlen(str);

   for(i=0;i<n;i++)
      alpha[str[i]-'a']=1;

   for(i=0;i<26;i++)
      t+=alpha[i];

   if(t==26){printf("None\n"); return 0;}

   for(i=0;i<n;i++)
      if(alpha[i]==0){printf("%c\n",'a'+i); return 0;}
   return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a%b
    return b

def divisor(a):
    i = 1
    divset = set()
    while i * i <= a:
        if a % i == 0: divset |= {i, a//i}
        i += 1
    divset.remove(1)
    return divset

def is_prime(a):
    if a <= 3: 
        prime = [False, False, True, True]
        return prime[a]
    i = 2
    while i * i <= a:
        if a % i == 0: return False
        i += 1
    else: return True

N = int(input())
A = [None] * (N+1)
for i in reversed(range(N+1)):
    A[i] = int(input())

primes_bool = [True] * (N + 1)
primes = []
for p in range(2, N+1):
    if primes_bool[p]:
        primes.append(p)
        p_mult = p * 2
        while p_mult <= N:
            primes_bool[p_mult] = False
            p_mult += p

ans = []
used = set()
gcd_of_A = abs(A[N])
for a in A[:N]:
    if a != 0: gcd_of_A = gcd(abs(a), gcd_of_A)

commondiv = divisor(gcd_of_A)
for d in commondiv:
    if d > 1 and is_prime(d): 
        ans.append(d)
        used |= {d}

for p in primes:
    if A[0] % p == 0:
        for i in range(1, p):
            coefficient = 0
            index_a = i
            while index_a <= N:
                coefficient += A[index_a]
                coefficient %= p
                index_a += p-1
            if coefficient > 0: break
        else:
            if p not in used: ans.append(p)

ans.sort()
for a in ans: print(a)

Measured memory_bytes: 46424
# 初期入力
N = int(input())

#約数
def make_divisors(n):# 商と割る数 両方を返す
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            syou,amari =divmod(n,i)
            divisors.append((syou,i))
            #if i != n // i:
            #    divisors.append(n//i)

    # divisors.sort()
    return divisors

yakusu =make_divisors(N) #商と割る数
ans =[]
for i in yakusu:
    ans.append(sum(i)-2) #（1，1）からの距離、２＜Nだから絶対値も不要 
print(min(ans))

Measured memory_bytes: 3560
a,b,k=map(int,input().split())
for i in range(k):
    if i%2==0:
        if a%2==1:
            a -= 1
            a = a//2
            b += a
        else:
            a = a//2
            b += a            
    else:
        if b%2==1:
            b -= 1
            b = b//2
            a += b
        else:
            b = b//2
            a += b

print(a,b)


Measured memory_bytes: 3060
#include <stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 1000000


int M[MAX][MAX];  // 隣接行列
int n;

int Prim(void)
{
    int color[MAX]; // vの訪問状態
    int d[MAX];     // 最小の重み
    int p[MAX];     // 親
    int minv;
    int i, u, v;
    int sum = 0;

    for (i = 0; i < n; i++)
    {
        color[i] = WHITE;
        d[i] = INFTY;
        p[i] = -1;
    }
    d[0] = 0;

    while (1)
    {
        minv = INFTY;
        u = -1;
        for (i = 0; i < n; i++)
        {
            if (minv > d[i] && color[i] != BLACK)
            {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1)
        {
            break;
        }
        color[u] = BLACK;
        for (v = 0; v < n; v++)
        {
            if (color[v] != BLACK && M[u][v] != INFTY)
            {
                if (d[v] > M[u][v])
                {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }

    for (i = 0; i < n; i++)
    {
        if (p[i] != -1)
        {
            sum += M[i][p[i]];
        }
    }

    return sum;
}

int main(void)
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            scanf("%d", &M[i][j]);
            if (M[i][j] == -1)
            {
                M[i][j] = INFTY;
            }
        }
    }

    printf("%d\n", Prim());

    return 0;
}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
struct pp{int nu,va;}p[200010];
struct qq{int ma1,ma2;}s;
struct seg{int ls,rs;qq ma;}t[5000010];
struct ss{int l1,l2,m1,m2;}a1,a2;
int n,num,ro[200010],an[200010],su[200010];
qq he(qq a,qq b){qq c;c.ma1=max(a.ma1,b.ma1);c.ma2=max(a.ma2,b.ma2);return c;}
void build(int &nu,int l,int r){
	if (nu==0) nu=++num;
	if (l==r){
		t[nu].ma.ma2=0;t[nu].ma.ma1=-INF;
	}else{
		build(t[nu].ls,l,(l+r)/2);
		build(t[nu].rs,(l+r)/2+1,r);
		t[nu].ma=he(t[t[nu].ls].ma,t[t[nu].rs].ma);
	}
}
qq que(int nu,int l,int r,int nl,int nr){
	if (l==nl&&r==nr){return t[nu].ma;}
	int mid=(l+r)/2;
	if (nl>mid) return que(t[nu].rs,mid+1,r,nl,nr);
	if (nr<=mid) return que(t[nu].ls,l,mid,nl,nr);
	return he(que(t[nu].ls,l,mid,nl,mid),que(t[nu].rs,mid+1,r,mid+1,nr));
}
void add(int &nu,int la,int l,int r,int we,qq x){
	if (nu==0) nu=++num;
	if (l==r){
		t[nu].ma=x;
	}else{
		t[nu]=t[la];
		if (we<=(l+r)/2){t[nu].ls=0;add(t[nu].ls,t[la].ls,l,(l+r)/2,we,x);}
		else{t[nu].rs=0;add(t[nu].rs,t[la].rs,(l+r)/2+1,r,we,x);}
		t[nu].ma=he(t[t[nu].ls].ma,t[t[nu].rs].ma);
	}
}
bool pan(ss x,int y){
	qq k=que(ro[y+1],1,n,max(1,x.m2),n);int j=x.l1-x.l2+su[y+1];
	if (j>=0){
		if (j%2==0){
			if (k.ma2>=j) return true;
		}else{
			if (k.ma1>=j) return true;
		}
	}
	k=que(ro[y+1],1,n,max(1,x.m1),n);j=x.l2-x.l1+su[y+1];
	if (j>=0){
		if (j%2==0){
			if (k.ma2>=j) return true;
		}else{
			if (k.ma1>=j) return true;
		}
	}
	return false;
}
int main(){
	scanf("%d",&n);
	int ma=0;
	for (int i=1;i<=n;i++){scanf("%d",&p[i].nu);if (p[i].nu>ma){p[i].va=2;ma=p[i].nu;}else p[i].va=1;}
	for (int i=n;i>=1;i--)su[i]=su[i+1]+p[i].va-1;
	build(ro[n+1],1,n);
	for (int i=n;i>=1;i--){
		s=que(ro[i+1],1,n,p[i].nu,n);
		if (p[i].va==1){
			qq u=s;
			s.ma1=max(u.ma1,u.ma2+1);
			s.ma2=max(u.ma2,u.ma1+1);
		}else{s.ma1+=2;s.ma2+=2;}
		add(ro[i],ro[i+1],1,n,p[i].nu,s);
	}
	a1.l1=a1.l2=a1.m1=a1.m2=0;
	for (int i=1;i<=n;i++){
		a2=a1;if (p[i].nu>a2.m1){a2.l1++;a2.m1=p[i].nu;}
		if (pan(a2,i)){a1=a2;an[i]=0;}
		else{
			a2=a1;
			if (p[i].nu>a2.m2){a2.l2++;a2.m2=p[i].nu;}
			if (pan(a2,i)){a1=a2;an[i]=1;}
			else{cout<<"-1"<<endl;return 0;}
		}
	}
	for (int i=1;i<=n;i++) cout<<an[i];cout<<endl;
	return 0;
}
/*
6
3 1 4 6 2 5
*/

Measured memory_bytes: 70272
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set<String> S = new HashSet<>();
		for(int i = 0;i < N;i++){
			S.add(sc.next());
		}
		System.out.println(S.size());

	}

}

Measured memory_bytes: 77224
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
using namespace std;

int main()
{
  long long int x;
  long long int s=100;
  int count=0;
  
  cin>>x;
  
  while(x>s)
  {
    s=s*1.01;
    count++;
  }
  
  cout<<count<<endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<ll> cnt(n);
    rep(i, n) cin >> cnt[i];
    ll ans = 0;
    rep(i, n) {
        if (i < n - 1 && cnt[i] % 2 == 1 && cnt[i+1] > 0) {
            ans += 1LL;
            --cnt[i];
            --cnt[i+1];
        }
        ans += cnt[i] / 2LL;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4052
n = int(input())
p = list(map(int, input().split()))
p0 = sorted(p)
key = 0
if p == p0:
    print("YES")
    key = 1
if key == 0:
    cnt = 0
    for i in range(len(p)):
        if p[i] != p0[i] and cnt == 0:
            idx1 = i
            cnt += 1
        elif p[i] != p0[i] and cnt == 1:
            idx2 = i
            cnt += 1
        if cnt >= 2:
            p[idx1], p[idx2] = p[idx2], p[idx1]
            if p == p0:
                print("YES")
                break
            else:
                print("NO")
                break
"""
    for i in range(len(p)):
        pt = p
        for j in range(len(p)):
            if i != j:
                pt[i], pt[j] = pt[j], pt[i]
                if pt == p0:
                    print("YES")
                    key = 1
                    break
"""                    


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

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

	int dist = b - a;
	if(dist % 2 == 1){
		cout <<"Borys\n";
	}
	else{
		cout <<"Alice\n";
	}
	return 0;
}


Measured memory_bytes: 3580
//46
#include<iostream>
#include<set>

using namespace std;

int main(){
  int q;
  cin>>q;
  while(q--){
    int n;
    cin>>n;
    int a;
    set<int> s;
    for(a=0;n>=10&&s.insert(n).second;a++){
      int m=0;
      for(int p=10;p<=n;p*=10){
	int h,l;
	h=n/p;
	l=n-h*p;
	if(m<h*l){
	  m=h*l;
	}
      }
      n=m;
    }
    cout<<((n<10)?a:-1)<<endl;
  }
  return 0;
}
	  

Measured memory_bytes: 1196
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
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;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n, k, c;
    cin >> n >> k >> c;

    string s;
    cin >> s;
    vector<int> l(n, -1);
    vector<int> r(n, -1);
    int cnt = 1;
    for(int i = 0; i < n; i++){
        if(s[i] == 'o'){
            l[i] = cnt;
            i += c;
            cnt++;
            if(cnt > k) break;
        }
    }

    cnt = k;

    for(int i = n - 1; i >= 0; i--){
        if(s[i] == 'o'){
            r[i] = cnt;
            i -= c;
            cnt--;
        }
    }

    rep(i, n){
        //cout << i << " " << r[i] << " " << l[i] << endl;
        if(r[i] == -1 || l[i] == -1) continue;
        if(r[i] == l[i]){
            cout << i + 1 << endl;
        }
    }
}

Measured memory_bytes: 3332
#include<iostream>
using namespace std;
long long n,m;
int main()
{
	cin>>n>>m;
	if (n==1 && m==1) cout<<1<<endl;
	else if (n==1) cout<<m-2<<endl;
	else if (m==1) cout<<n-2<<endl;
	else cout<<(n-2)*(m-2)<<endl;
	return 0;
}

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

int N, M, Q;
vector<int> A, B, C, D;
vector<int> P;
int max_val = 0;

void input_init(void) {
	cin >> N >> M >> Q;
	A.resize(Q);
	B.resize(Q);
	C.resize(Q);
	D.resize(Q);
	for (int i = 0; i < Q; ++i)
		cin >> A[i] >> B[i] >> C[i] >> D[i];
	P.resize(N + 1, 0);
}

int calcu(void) {
	int val = 0;
	for (int i = 0; i < Q; ++i) {
		if (P[B[i]] - P[A[i]] == C[i])
			val += D[i];
	}
	return val;
}

void rec(int id, int stt) {
	P[id] = stt;
	if (id == N) {
		int val = calcu();
		max_val = max(val, max_val);
		return;
	}
	for (int i = stt; i <= M; ++i)
		rec(id + 1, i);
}

int main(void) {
	input_init();
	for (int i = 1; i <= M; ++i)
		rec(1, i);
	cout << max_val << '\n';
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }


int main() {
    int n, r;
    cin >> n >> r;
    vector<int> xs{0, 1000010}, ys{0, 1000010}, zs{0, 1000010};
    using P = array<int, 6>;
    vector<array<int, 6>> v;

    for (int i = 0; i < n; ++i) {
        int a, b, c, d, e, f;
        scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
        v.emplace_back(P{a, b, c, d, e, f});
        xs.emplace_back(a); ys.emplace_back(b); zs.emplace_back(c);
        xs.emplace_back(d); ys.emplace_back(e); zs.emplace_back(f);
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    sort(ys.begin(), ys.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());
    sort(zs.begin(), zs.end());
    zs.erase(unique(zs.begin(), zs.end()), zs.end());
    auto zx = [&xs](int i){ return lower_bound(xs.begin(),xs.end(), i) - xs.begin(); };
    auto zy = [&ys](int i){ return lower_bound(ys.begin(),ys.end(), i) - ys.begin(); };
    auto zz = [&zs](int i){ return lower_bound(zs.begin(),zs.end(), i) - zs.begin(); };
    auto G = make_v(xs.size(), ys.size(), zs.size(), 0);
    for (int i = 0; i < n; ++i) {
        auto A = v[i];
        A[0] = zx(A[0]); A[1] = zy(A[1]); A[2] = zz(A[2]);
        A[3] = zx(A[3]); A[4] = zy(A[4]); A[5] = zz(A[5]);
        for (int j = 0; j < 2; ++j) {
            for (int k = 0; k < 2; ++k) {
                for (int l = 0; l < 2; ++l) {
                    if((j+k+l)&1) G[A[3*j]][A[3*k+1]][A[3*l+2]]--;
                    else G[A[3*j]][A[3*k+1]][A[3*l+2]]++;
                }
            }
        }
    }
    for (int i = 1; i < xs.size(); ++i) {
        for (int j = 0; j < ys.size(); ++j) {
            for (int k = 0; k < zs.size(); ++k) {
                G[i][j][k] += G[i-1][j][k];
            }
        }
    }
    for (int i = 0; i < xs.size(); ++i) {
        for (int j = 1; j < ys.size(); ++j) {
            for (int k = 0; k < zs.size(); ++k) {
                G[i][j][k] += G[i][j-1][k];
            }
        }
    }
    for (int i = 0; i < xs.size(); ++i) {
        for (int j = 0; j < ys.size(); ++j) {
            for (int k = 1; k < zs.size(); ++k) {
                G[i][j][k] += G[i][j][k-1];
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i+1 < xs.size(); ++i) {
        for (int j = 0; j+1 < ys.size(); ++j) {
            for (int k = 0; k+1 < zs.size(); ++k) {
                if(G[i][j][k] >= r){
                    ans += (ll)(xs[i+1]-xs[i])*(ys[j+1]-ys[j])*(zs[k+1]-zs[k]);
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {
  int64_t N,M;
  int big=1000000007;
  cin >> N >> M;
  vector<int>data(N);
  for(int i=0;i<N;i++){
    cin >> data.at(i);
  }
  int64_t res=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(data.at(i)>data.at(j)) res++;
    }
  }
  vector<int>ans(2000);
  for(int i=0;i<N;i++){
    ans.at(data.at(i)-1)++;
  }
  int64_t ress=0;
  int a=0;
  for(int i=0;i<2000;i++){
    ress+=a*ans.at(i);
    a+=ans.at(i);
    ress%=big;
  }
  
  int64_t b=(M*(M-1)/2)%big;
  int64_t aans=((res*M)%big+(ress*b)%big)%big;
  cout << aans;
}

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

char ch[5][5];

int main()
{
	for(int i = 1;i <= 3;i++){
		for(int j = 1;j <= 3;j++){
			cin >> ch[i][j];
		}
	}
	cout << ch[1][1] << ch[2][2] << ch[3][3] << endl;
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  // cout<<n<<endl;
  vll dp(2100);

  ll ans=0;
  rep(i,n){
    vll ndp(2100);
    ll now=s[i]-'0';
    ndp[now]++;
    rep(j,2019){
      // dp[i+1][j]+=dp[i][j];
      ll nxtj=((j*10)%2019+now)%2019;
      // cout<<i<<" "<<nxtj<<endl;
      ndp[nxtj]+=dp[j];
    }
    ans+=ndp[0];
    dp=ndp;
  }
  // rep(i,100) cout<<dp[n][i]<<endl;
  
  // rep(i,2019){
  //   // if(dp[n][i]!=0) cout<<i<<" "<<dp[n][i]<<endl;
  // }
  cout<<ans<<endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int dp[100001] ={0};

string solve(vector<int> &v, int k){
    
    for(int i=1;i<=k;i++){
        for(auto move : v){
            
            if(move>i)continue;
            
            else if(dp[i-move] == 0){
                dp[i] =1;
            }
        }
        
    }
    if(dp[k] == 0)return "Second";
    else return "First";
}


int main() {
    memset(dp, 0, sizeof dp);
    
	int n, k;
	cin>>n>>k;
	vector <int> v(n);
	for(int i=0;i<n;i++){
	    cin>>v[i];
	}
	for(int i=0;i<=k;i++)
	    dp[i] = 0;
	    
	cout<<solve(v, k)<<endl;
	return 0;
}

Measured memory_bytes: 3992
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int main() {
	int d;
	cin >> d;
	if (d == 25) {
		cout << "Christmas" << endl;
	}
	else if (d == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (d == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (d == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int b[27]={0},flag = 0;
	while(n--)
	{
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		if(!flag)
		{
			for(auto it:s)
				b[it-'a']++;
		}
		else
		{
			int a[27]={0};
			for(auto it:s)
				a[it-'a']++;
			for(int i = 0;i<27; i++)
				b[i] = min(b[i],a[i]);
		}
		flag = 1;
	}
	for(int i = 0;i<27 ; i++)
		for(int j = 1; j<=b[i]; j++)
		{
			char ch = 'a'+i;
			cout<<ch;
		}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, time;
    int min = 10000;

    cin >> n >> time;
    int *c = new int[n];
    int *t = new int[n];
    for (int i = 0; i < n; i++) {
        cin >> c[i] >> t[i];
        if (min > c[i] && t[i] <= time) {
            min = c[i];
        }
    }

    if (min == 10000) {
        cout << "TLE" << endl;
    } else {
        cout << min << endl;
    }


    delete[] c;
    delete[] t;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
#define REP(i, a, b) for(int i = int(a); i <= int(b); i++)
#define LOOP(i, v) for(int i = 0; i < v.size(); i++)
#define EPS 1e-9
#define INF 1e12
#define debug(x) cerr << "DEBUG : " << (#x) << " => " << (x) << endl

long long int pgcd(long long int x, long long int y)
{
  if(y == 0) return x;
  return pgcd(y, x % y);
}

int main()
{
  int T;
  scanf("%d", &T);
  long long int A,B,C,D;
  
  REP(t, 1, T)
  {
    scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
    if(A < B) printf("No\n");
    else if(D < B) printf("No\n");
    else if(C >= B-1) printf("Yes\n");
    else
    {
      long long int a = A%B;
      long long int p = pgcd(B,D);
      // Est-ce que a + k*p peut être entre C+1 et B-1 ?
      long long int k = (B-1-a)/p;
      if(a+k*p >= C+1) printf("No\n");
      else printf("Yes\n"); 
    }
  }
    
  return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

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

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N = 21;
const ll lmod = 1e9+7;

int main(){
  int n,a,b; cin >> n >> a >> b;
  if((b-a)%2==0) cout << "Alice" << endl;
  else cout << "Borys" << endl;  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main(){
    int n, m;
    cin >> n >> m;
    vector<T> py(m);
    vector<P> ans(m);
    rep(i, m) {
        int p, y;
        cin >> p >> y;
        py[i] = T(p, y, i);
    }
    int c = 1;
    sort(all(py));
    rep(i, m) {
        int next = get<0>(py[i+1]);
        ans[get<2>(py[i])] = P(get<0>(py[i]), c);
        if (next == get<0>(py[i])) {
            c++;
        } else {
            c = 1;
        }
    }
    rep(i, m) {
        printf("%06d%06d\n", ans[i].first, ans[i].second);
    }
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
const int N=1e5+5;
int n,k,a[N],b[N],c[N],d[N],e[N],f[N],g[N],i;
inline void in(int*a){for(int i=1;i<=n;++i)scanf("%d",a+i);}
inline void out(int*a){for(int i=1;i<=n;++i)printf("%d%c",a[i],i==n?'\n':' ');}
inline void I(int*a){for(int i=1;i<=n;++i)a[i]=i;}
inline void getinv(int*a){
	static int b[N];
	for(int i=1;i<=n;++i)b[a[i]]=i;
	memcpy(a+1,b+1,n<<2);
}
inline void mul(int*a,int*b,int*c){
	static int ans[N];
	for(int i=1;i<=n;++i)ans[i]=b[a[i]];
	memcpy(c+1,ans+1,n<<2);
}
inline void poww(int*a,int K,int*b){
	static int c[N];memcpy(c+1,a+1,n<<2);I(b);
	for(;K;K>>=1,mul(c,c,c))if(K&1)mul(c,b,b);
}
int main(){
	scanf("%d%d",&n,&k);
	in(a);in(b);if(k==1){out(a);return 0;}
	memcpy(c+1,a+1,n<<2);
	memcpy(d+1,b+1,n<<2);
	getinv(c);getinv(d);
	if(k>7)mul(d,a,e),mul(e,b,e),mul(e,c,e),poww(e,(k-2)/6,e);else I(e);
	if(1<k%6 && k%6<5){memcpy(f+1,b+1,n<<2);if(k%3!=2)mul(c,f,f);if(k%3==1)mul(d,f,f);}
		else{memcpy(f+1,d+1,n<<2);if(k%3!=2)mul(f,a,f);if(k%3==1)mul(f,b,f);}
	if(k>4)mul(a,d,g),mul(g,c,g),mul(g,b,g),poww(g,(k+1)/6,g);else I(g);
	mul(e,f,f);mul(f,g,g);out(g);
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define ll long long

using namespace std;

void solve(){
	string n;
	int sum=0;
	cin >>n;
	int le = n.length();
	for(int i= 0; i < le;i++)sum +=n[i]-'0';
		
		if(sum% 9 == 0){
			cout << "Yes"<<"\n";
		}else{
				cout <<"No"<<"\n";
			}
			
	
	}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	
	
	
	}


Measured memory_bytes: 3760
N = int(input())
S = ''.join([str(input())[0] for i in range(N)])
count = []
for char in 'MARCH':
    tmp = S.count(char)
    if tmp != 0:
        count.append(tmp)
ans = 0
for i in range(1<<len(count)):
    if bin(i).count('1') == 3:
        tmp = 1
        for j in range(len(count)):
            if i>>j & 1 == 1:
                tmp *= count[j]
        ans += tmp
print(ans)

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,q;
  cin>>n>>q;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  sort(as.begin(),as.end());
  for(Int i=0;i<q;i++){
    Int l,r;
    cin>>l>>r;
    auto x=upper_bound(as.begin(),as.end(),r);
    auto y=lower_bound(as.begin(),as.end(),l);
    cout<<x-y<<endl;
  }
  return 0;
}



Measured memory_bytes: 3548
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
#define MAX_V 10010
struct edge{
    int to;
    int cap;
    int cost;
    int rev;
    edge(){}
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};

int V;
vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
    G[from].push_back(edge(to,cap,cost,(int)G[to].size()));
    G[to].push_back(edge(from,0,-cost,(int)G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
    int res=0;
    while(f>0){
        fill(dist,dist+V,INF);
        dist[s]=0;
        bool update = true;
        while(update){
            update = false;
            for(int v=0; v<V ;v++){
                if(dist[v]==INF) continue;
                for(int i=0; i<G[v].size(); i++){
                    edge &e = G[v][i];
                    if(e.cap > 0 && dist[e.to] > dist[v]+e.cost) {
                        dist[e.to] = dist[v] + e.cost;
                        prevv[e.to] = v;
                        preve[e.to] = i;
                        update = true;
                    }
                }
            }
        }
        if(dist[t]==INF) return -1;
        
        int d = f;
        for(int v=t; v!=s; v=prevv[v])d=min(d,G[prevv[v]][preve[v]].cap);
        f -= d;
        res += d*dist[t];
        for(int v=t; v!=s; v=prevv[v]){
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}


int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    int M,N,K; cin >> M >> N >> K;

    V = K;
    
    int res = 0;
    vector<int> A(N);
    vector<vector<int> > B(N);
    for(int i = 0; i < N;i++) cin >> A[i];
    for(int i = 0; i < K;i++){
        int a; cin >> a; a--;
        B[a].push_back(i);
        res += A[a];
    }
    
    for(int i = 0; i < N;i++){
        if((int)B[i].size() <= 1) continue;
        for(int j = 0; j < (int)B[i].size()-1;j++){
            int s = B[i][j], t = B[i][j+1];
            if(s+1 != t){
                add_edge(s+1, t, 1, -A[i]);
            }else{
                res -= A[i];
            }
        }
    }
    for(int i = 0; i < K-1;i++){
        add_edge(i, i+1, M, 0);
    }
    cout << res + min_cost_flow(0, K-1, M-1) << endl;
	return 0;
}



Measured memory_bytes: 4444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,A,B,N,R,M,K,X,Y,Z,C;
  string S,T,U;
  cin >> N >> M;
  
  int N_tmp = 0;
  int M_tmp = 0;

  if(N == 1){
    N_tmp = 0;
  }else{
    N_tmp = (N*(N-1))/2;
  }
  if(M == 1){
    M_tmp = 0;
  }else{
    M_tmp = (M*(M-1))/2;
  }
  cout << (N_tmp+ M_tmp ) << endl;

}

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

signed main() {
    int n, i, j, k;
    cin >> n;
    vector<int> v(n), place(n + 2);
    place[0] = -1;
    place[n + 1] = -1;
    for(i = 0; i < n; i++) {
        cin >> v[i];
        place[v[i]] = i;
    }
    int cnt = 1;
    int tmp = 1;
    for(i = 1; i <= n;i++){
        if(place[i]>place[i+1]){
            cnt = max(cnt, tmp);
            tmp = 0;
        }
        tmp++;
    }
    cout << n-cnt << endl;
    return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 

int main(){
    string S;
    cin >> S;//"123"の場合S[0]=1, S[1]=2, S[2]=3になるので，
    reverse(S.begin(), S.end());//S[2]S[1]S[0]の向きにする
    //つまりS[2]=1, S[1]=2, S[0]=3;になった
    int N = S.size();

    //S[i+2]S[i+1]S[i]=S[i+2]*10^(i+2)+S[i+1]*10^(i+1)+S[i]*10^i
    //なので  その数列がa[i+2]+a[i+1]+a[i]になるようにする
    //vector<ll> a(N);
    //for(int i=0; i<N; i++) a[i] = S[i]*pow(10, i);
    // vector<ll> wa(N+1);
    // wa[0] = 0;
    // for(int i=0; i<N; i++){
    //   wa[i+1] = wa[i]+pow(10, i)*(S[i]-'0');
    // }

    const int MOD = 2019;
    map<int, int> mp;
    ll ans = 0;
    ll wa = 0;//累積和
    ll pow10_i = 1;// pow(10, i)%MOD
    for(int i=0; i<N; i++){
      mp[wa]++;//なぜこの位置なんだ??
      //累積和≡0(mod2019)となるとき，
      //S[i]~S[0]までを並べた数字自体が2019の倍数ということで
      //それは今までのmp[wa]の値に関係なく2019の倍数だから最初にmp[0]++しておくってこと?
      //別の解釈するなら S[i]~S[0]を並べた時の数字が2019の倍数となる，はじめてのiでans++されるように
      //mp[0]++しておくってこと　　かな


      //wa += (S[i] - '0') * pow(10, i);
      wa += (S[i] - '0') * pow10_i;
      wa %= MOD;
      ans += mp[wa];
      //mp[wa]++;
      pow10_i = pow10_i*10 % MOD;
    }

    cout << ans << endl;


}


Measured memory_bytes: 3732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
	var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long K = inputArray[1];

			var inputInfo = new Dictionary<long, long>();

			for (int i = 0; i < N; i++) {
				var input = retreiveLongArray();
				var a = input[0];
				var b = input[1];

				if (inputInfo.ContainsKey(a)) {
					inputInfo[a] += b;
				}
				else {
					inputInfo.Add(a, b);
				}
			}

			var sortedInfo = inputInfo.OrderBy(x => x.Key).ToDictionary(x =>x.Key,x =>x.Value);

			long count = 0;
			long ans = 0;

			foreach (var item in sortedInfo) {
				count += item.Value;
				if(count >= K) {
					ans = item.Key;
					break;
				}

			}

			//答えの出力
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 26676
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,c[100],v[100],ans=0;
  cin >> n;
  rep(i,n)cin >> v[i];
  rep(i,n)cin >> c[i];
  rep(i,n)if(v[i]>c[i])ans+=v[i]-c[i];
  printf("%lld",ans);
}

Measured memory_bytes: 256
//
//  main.cpp
//  atcoder174
//
//  Created by Keita on 2020/08/02.
//  Copyright © 2020 Keita. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

void doProblemA(){
    int X;
    cin >> X;
    if(X >= 30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

void doProblemB(){
    long long int N, D, X, Y, answer = 0;
//    D = sqrt(X * X + Y * Y);a
    cin >> N >> D;
    for(int i = 0; i < N; i++){
        cin >> X >> Y;
        if(X * X + Y * Y <= D * D){
            answer++;
        }
    }
    cout << answer << endl;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    doProblemB();
    return 0;
}


Measured memory_bytes: 3164