akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		for(int i = 0 ; i < n;i++){
			String[] s = br.readLine().split(" ");
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int j =0;j < s.length;j++){
				list.add(Integer.parseInt(s[j]));
			}
			Collections.sort(list);
			int a = list.get(0);
			int b = list.get(1);
			int c = list.get(2);
			if(a*a + b*b == c*c){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}	
		
		
	}

}

Measured memory_bytes: 26016
#include <iostream>
#include <string>

using namespace std;

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

    if (s.compare("Sunny") == 0) {
        cout << "Cloudy" << endl;
    } else if (s.compare("Cloudy") == 0) {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
if n < 2:
    print(1)
elif n < 4:
    print(2)
elif n < 8:
    print(4)
elif n < 16:
    print(8)
elif n < 32:
    print(16)
elif n <64:
    print(32)
else:
    print(64)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double a2 = (double)n/ 3;
        double a = Math.cbrt(a2);
        System.out.println(a2 * a2 * a2);
    }
}


Measured memory_bytes: 21972
#include <iostream>                                       
using namespace std;                                      
                                                          
int main(){                                               
  int S,h,m,s;                                            
                                                          
  cin >> S;                                               
                                                          
  h = S / 3600;                                           
                                                          
  m = (S - h * 3600) / 60;                                
                                                          
  s = (S - h * 3600) - m * 60;                            
                                                          
  cout << h << ":" << m << ":" << s << endl;              
                                                          
  return 0;                                               
                                                          
}

Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}


*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {

	}
}

*/

int a[100010];

bool check(int n) {

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

void ans(int n) {
	for (int i = 3; i <= n; i++) {
		if (check(i) && check(((i + 1) / 2))) { a[i] = 1; }
	}
}

int main(void) {
	int q; cin >> q;

	int l, r;

	ans(100010);


	for (int i = 1; i < 100010; i++) {
		a[i] += a[i - 1];
	}

	for (int i = 0; i < q; i++) {
		cin >> l >> r;

		cout << a[r] - a[l - 1] << endl;
	}



}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

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

	counts := make([]int, 200000)

	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		counts[tmp]++
	}

	sort.Ints(counts)

	sum := 0
	for _, v := range counts[:len(counts)-k] {
		sum += v
	}

	fmt.Println(sum)
}


Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    int n,a,mina=1000001,maxa=-1000001;
    long long sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        mina=min(mina,a);
        maxa=max(maxa,a);
        sum+=a;
    }
    cout<<mina<<" "<<maxa<<" "<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3100
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())))
q = sorted(list(map(int, input().split())))
r = sorted(list(map(int, input().split())))

filt_p = p[-x:]
filt_q = q[-y:]
filt_p.extend(filt_q)
filt_p.extend(r)
all_apples = sorted(filt_p)

ans = sum(all_apples[-x-y:])

print(str(ans))


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

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

    if (s == "ABC") {
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }
    return 0;
}

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

#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long int

int main(){
    fast_io();

    ll N;
    cin >> N;

    vector<ll> h(N);

    string ans = "Yes";

    for (int i = 0; i < N; i++) {
      cin >> h[i];
    }

    for (int i = N-1; i > 0; i--) {
      if (h[i] >= h[i-1]) {
      } else if (h[i] + 1 == h[i-1]) {
        h[i-1] -= 1;
      } else {
        ans ="No";
        break;
      }
    }

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


Measured memory_bytes: 3992
//E.H//
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int h,w,a,b;
char arr[1005][1005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>h>>w>>a>>b;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            arr[i][j]='0';
        }
    }
    for(int i=1;i<=b;i++){
        for(int j=1;j<=a;j++){
            arr[i][j]='1';
        }
    }
    for(int i=b+1;i<=h;i++){
        for(int j=a+1;j<=w;j++){
            arr[i][j]='1';
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cout<<arr[i][j];
        }
        cout<<endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n;cin>>n;
    ll sum=0;
    ll mini = INF;
    int count=0;
    rep(i,n)
    {
        ll x;
        cin >> x;
        if(x<0){count++;x = abs(x);}
        mini = min(x,abs(mini));
        sum += x;
    }
    if(count%2 == 0)cout<<sum<<endl;
    else cout<<sum-2*mini<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

ll coun[100001];

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> ans(n);
	ll sum;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	sum = a[0];
	for (int i = 1; i < n; i++){
		sum = sum ^ a[i];
	}
	for (int i = 0; i < n; i++){
		ll temp = sum ^ a[i];
		for (int j = 0; j < 40; j++){
			if (temp & (1LL<<j)){
				ans[i] += 1LL<<j;
			}
		}
	}
	for (int i = 0; i < n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}



Measured memory_bytes: 4764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
template<typename T>inline void in(T &a)
{
	T ch=getchar(),f=1;
	for(a=0;!isdigit(ch);ch=getchar())
	  ch=='-'?f=-1:f=f;
	for(;isdigit(ch);ch=getchar())
	  a=(a<<3)+(a<<1)+ch-'0';
	a*=f;
}
template<typename T>inline void print(T x)
{
	if(x<0)
	  x=-x,putchar('-');
	if(x>9)
	  print(x/10);
	putchar(x%10+'0');
}
int n;
signed main()
{
	cin>>n;
	int ans=0;
	while(n)
	{
		if(n%10==2)
		  ans++;
		n/=10;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import math
 
s = list(map(str, input().split()))
s = s[0]
n = len(s)

now = 1
amari = []
for i in range(len(s)):
    amari.append(now)
    now = (now * 10) % 13

ans = [[0 for i in range(13)] for j in range(2)]
ans[0][0] = 1
ans[1][0] = 1

for i in range(len(s)):
    now = s[n-1-i]
    ans[(i+1)%2] = [0 for i in range(13)]
    if(now=="?"):
        for k in range(10):
            plus = (amari[i] * k)%13
            for j in range(13):
                ans[(i+1)%2][(j+plus)%13] += ans[i%2][j]
        for j in range(13):
            ans[(i+1)%2][(j+plus)%13] %= 1000000007
    else:
        now = int(now)
        plus = (amari[i] * now)%13
        for j in range(13):
            ans[(i+1)%2][(j+plus)%13] = ans[i%2][j]
            
    last = (i+1)%2
            
print(ans[last][5])


Measured memory_bytes: 45680
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        System.out.print(validate(a, s));
    }

    private static String validate(Integer a, String s){
        if(a >= 3200){
            return s;
        }else{
            return "red";
        }
    }
}


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

using namespace std;

int main(){
    string S, T;
    cin >> S >> T;
    int a, b;
    cin >> a >> b;
    string U;
    cin >> U;
    if (S == U)
        cout << a - 1 << " " << b << endl;
    else
        cout << a << " " << b - 1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String input1 = sc.nextLine();
        String input2 = sc.nextLine();
        
        String[] inputs = input1.split("");
        String[] inputs2 = input2.split("");
        
        int count = 0;
        for (int i = 0; i < inputs.length; i++) {
            if (inputs[i].equals(inputs2[i])) {
                count++;
            }
        }
        System.out.println(count);
 
    }
}

Measured memory_bytes: 23892
m, d = map(int, raw_input().split())
raw_input()
if m in (1,3,5,7,8,10,12) and d == 31:
  print(1)
elif m in (4,6,9,11) and d == 30:
  print(1)
elif m == 2 and d == 28:
  print(1)
else:
  print(0)


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Node{
public:
	int v;
	list<Node>::iterator parent,left,right;
};

ll DFS(list<Node>& tree,list<Node>::iterator child,ll depth){
	ll sum = 0;
	if(child->left==tree.end() && child->right==tree.end()){
		sum += depth*child->v;
		return sum;
	}
	if(child->left!=tree.end()){
		sum += DFS(tree,child->left,depth+1);
	}
	if(child->right!=tree.end()){
		sum += DFS(tree,child->right,depth+1);
	}
	return sum;
}

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

	string S=in<string>();
	map<char,int> C;
	for(int i=0,ei=S.size();i<ei;i++){
		C[S[i]]++;
	}
	if(C.size()==1){
		out(C.begin()->second);
		return 0;
	}

	list<Node> tree;
	using NodeItr = list<Node>::iterator;
	auto comp =[](NodeItr& l,NodeItr& r){return l->v>r->v;};
	priority_queue<NodeItr,vector<NodeItr>,decltype(comp)> Q(comp);
	for(auto& x:C){
		Node n;
		n.v=x.second;
		n.parent=n.left=n.right=tree.end();
		auto itr=tree.insert(tree.end(),n);
		Q.push(itr);
	}
	while(Q.size()>1){
		auto L = Q.top();
		Q.pop();
		auto R = Q.top();
		Q.pop();
		Node n;
		n.v = L->v+R->v;
		n.left = L;
		n.right = R;
		auto itr=tree.insert(tree.end(),n);
		L->parent = itr;
		R->parent = itr;
		Q.push(itr);
	}

	auto last = Q.top();
	out(DFS(tree,last,0));
	return 0;
}



Measured memory_bytes: 3332
n, m = map(int, input().split())
flag = []
for _ in range(m): flag.append(0)
for _ in range(n):
    line = list(map(int, input().split()))
    for i in range(line[0]): flag[line[i+1]-1] += 1
count = 0
for j in range(m):
    if(flag[j] == n): count += 1
print(count)

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        if (a % 2 == 1 && b % 2 == 1) {
            out.printf("Odd\n");
        } else {
            out.printf("Even\n");
        }
        out.flush();
    }
}

Measured memory_bytes: 23892
//annealing
//Thanks:
//http://shindannin.hatenadiary.com/entry/20121224/1356364040
//https://atcoder.jp/contests/abc139/submissions/7290142
#include<stdio.h>
#include<math.h>
#include<sys/time.h>

long long llmax(long long a,long long b){if(a>b){return a;}return b;}

unsigned long long seed;

unsigned long long xorshift(){
  seed=seed^(seed<<13);
  seed=seed^(seed>>7);
  seed=seed^(seed<<17);
  return seed;
}

long long getrand(long long lim){
  return (xorshift()%lim)+1;
}

long long getrand_zero(long long lim){
  return (xorshift()%(lim+1));
}

int main(){
  struct timeval tv;
  gettimeofday(&tv, NULL);
  seed=(tv.tv_sec*1000000+tv.tv_usec);
  long long n,a[128],b[128],i,t,typ,fx,fy,ck[128],c=0;
  long long ma[128],mb[128];
  long long p,q,nr=0,res=0,w,tr=0;
  double pr,k;
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld%lld",&a[i],&b[i]);
    ma[i]=a[i];
    mb[i]=b[i];
  }
  for(typ=0;typ<4;typ++){
    p=0;q=0;c=0;
    if(typ/2==0){fx=1;}else{fx=-1;}
    if(typ%2==0){fy=1;}else{fy=-1;}
    for(i=0;i<n;i++){
      a[i]=ma[i];
      b[i]=mb[i];
      if(a[i]*fx>=0 && b[i]*fy>=0){
        p+=a[i];q+=b[i];
        continue;
      }
      if(a[i]*fx<=0 && b[i]*fy<=0){
        continue;
      }
      c++;
      ck[c]=i;
    }
    if(c==0){
      res=p*p+q*q;
      tr=llmax(res,tr);
      continue;
    }
    for(t=0;t<10000000;t++){
      k=100.0*(10000000-t)/10000000.0;
      nr=p*p+q*q;
      w=ck[getrand(c)];
      p+=a[w];q+=b[w];
      a[w]*=-1;b[w]*=-1;
      res=p*p+q*q;
      tr=llmax(res,tr);
      pr=getrand(1000000000000000000);
      pr/=1.0e18;
      if(res<nr && exp(sqrt(res)-sqrt(nr)/k)<pr){
        p+=a[w];q+=b[w];
        a[w]*=-1;b[w]*=-1;
      }
    }
  }
  printf("%.12lf\n",sqrt(tr));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+10;
vector<int> datas[MAXN];//通道关系
int ans[MAXN];//保存最近的房间号
 
void bfs() {
    queue<int> q;
    q.push(1);
    ans[1] = 1;
 
    while (!q.empty()) {
        int u = q.front();
        q.pop();
 
        for (auto v:datas[u]) {
            if (0==ans[v]) {
                q.push(v);
                ans[v] = u;
            }
        }
    }
}
 
int main() {
    int n,m;
    scanf("%d%d", &n, &m);
    for (int i=0; i<m; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        datas[u].push_back(v);
        datas[v].push_back(u);
    }
 
    bfs();
 
    //查询
    for (int i=2; i<=n; i++) {
        if (0==ans[i]) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    for (int i=2; i<=n; i++) {
        printf("%d\n", ans[i]);
    }
 
    return 0;
}


Measured memory_bytes: 13056
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N, K, Q; std::cin >> N >> K >> Q;
  std::vector<ll> A(N);
  rep(i, Q) {
    ll a; std::cin >> a;
    A[a-1] += 1;
  }

  rep(i, N) {
    if ( K - (Q-A[i]) > 0 ) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
  }  

  return 0;
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  int a, b, c;
  cin >> a >> b >> c;
  bool ok = false;
  REP1(i, a) {
    if((b * i + c) % a == 0) {
      ok = true;
    } 
  }
  cout << (ok?"YES":"NO") << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	int N, K;
	int x;
	cin >> N >> K;

	int ans = 0;
	REP(i, N) {
		cin >> x;

		ans += min(x, K - x);
	}



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

Measured memory_bytes: 256
count = {
  "A"  => 0,
  "B"  => 0,
  "AB" => 0,
  "O"  => 0
}

while line = gets
  data = line.chomp.split(",")
  count[data[1]] += 1
end

puts count["A"]
puts count["B"]
puts count["AB"]
puts count["O"]

Measured memory_bytes: 6096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll x;cin>>x;
    f(i,x,100004){
        ll sq=sqrt(x);bool ok=0;
        f(j,2,sq){
           if(i%j==0){ok=1;break;} 
        }
        if(!ok){cout<<i<<endl;break;}
    }
    return 0;  
} 

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



class RMQsub1{//隣接差が±1だけのRMQ
	std::vector<int> pattern;//ブロックがどのパターンか
	std::vector<std::vector<int> > minpos;//バイナリパターンに対する最小位置
	std::vector<int> dat;//葉でないノード
	std::vector<int> depth;
	int blocksize;
	int n;
	int query(int a,int b,int k,int l,int r)const{
		if(r<=a||b<=l)return -1;
		if(n-1<=k){//leaf
			if(pattern[k-(n-1)]==-1)return -1;
			int s=l<a?a%blocksize:0;
			int t=r<=b?blocksize:b%blocksize;
			return (k-(n-1))*blocksize+minpos[pattern[k-(n-1)]][s*blocksize+t-1];
		}else{
			if(a<=l&&r<=b)return dat[k];
			int vl=query(a,b,k*2+1,l,(l+r)/2);
			int vr=query(a,b,k*2+2,(l+r)/2,r);
			if(vl==-1)return vr;
			return vr==-1||depth[vl]<depth[vr]?vl:vr;
		}
	}
public:
	RMQsub1(){}
	void build(std::vector<int> &a){
		depth=a;
		int n=a.size();
		int k=1;
		while((1<<k)<a.size())k++;
		blocksize=k-1;//log(n)/2
		if(blocksize==0)blocksize=1;
		int m=(n+blocksize-1)/blocksize;//num node
		while(m&m-1)m+=m&-m;
		this->n=m;
		dat.resize(m-1,-1);
		pattern.resize(n,-1);
		minpos.resize(1<<blocksize-1);
		for(int i=0;i<(n+blocksize-1)/blocksize;i++){
			int s=i*blocksize;
			int p=0;
			for(int j=1;j<blocksize&&s+j<n;j++){
				if(a[s+j-1]>a[s+j])p|=1<<j-1;
			}
			pattern[i]=p;
			int b=(i+1)*blocksize<=n?blocksize:n-i*blocksize;
			if(minpos[p].empty()){
				minpos[p].resize(blocksize*blocksize);
				for(int j=0;j<blocksize;j++){
					int d=0,pos=j,mind=0;
					minpos[p][j*blocksize+j]=pos;
					for(int k=j+1;k<blocksize;k++){	
						if(p>>k-1&1)d--;
						else d++;
						if(d<mind){
							mind=d;
							pos=k;
						}
						minpos[p][j*blocksize+k]=pos;
					}
				}
			}
			if(m==1)break;
			int par=(m-1+i-1)/2;
			if(dat[par]==-1 || a[i*blocksize+minpos[p][0+b-1]]<a[dat[par]])
				dat[par]=i*blocksize+minpos[p][0+b-1];
		}
		dat.resize(m-1);
		for(int i=(m-2)/2-1;i>=0;i--){
			int vl,vr;
			vl=dat[2*i+1];
			vr=dat[2*i+2];
			dat[i]=vr==-1||a[vl]<a[vr]?vl:vr;
		}
	}
	int query(int a,int b)const{//[a,b)の最小値
		return query(a,b,0,0,n*blocksize);
	}
};


class LCA{
	vector<int> eulertour;
	vector<int> vertex;
	//SparseTableRMQ rmq;
	//RMQ rmq;
	RMQsub1 rmq;
	void dfs(const vector<int> edge[],int n,vector<int> &depth,int d,int u){
		eulertour[u]=vertex.size();	
		vertex.push_back(u);
		depth.push_back(d);
		for(int i=0;i<edge[u].size();i++){
			dfs(edge,n,depth,d+1,edge[u][i]);
			vertex.push_back(u);
			depth.push_back(d);
		}
	}
public:
	LCA(const vector<int> edge[],int n,int root):eulertour(n){
		vector<int> depth;
		dfs(edge,n,depth,1,root);
		vertex.push_back(root);
		depth.push_back(0);
		rmq.build(depth);
	}
	int query(int u,int v)const{
		if(u==v)return u;
		if(eulertour[u]>eulertour[v])swap(u,v);
		return vertex[rmq.query(eulertour[u], eulertour[v])];
	}
};



vector<int> edge[100000];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int k,v;
		cin>>k;
		for(int j=0;j<k;j++){
			cin>>v;
			edge[i].push_back(v);
		}
	}
	LCA lca(edge,n,0);
	int q,u,v;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>u>>v;
		cout<<lca.query(u,v)<<endl;
	}
	return 0;
}

Measured memory_bytes: 20504
use std::io::Read;
use std::collections::{HashMap, VecDeque};
use itertools::Itertools;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();
    let mut graph = vec![Vec::new(); n];
    for _ in 0..m {
        let ai: usize = iterator.next().unwrap().parse().unwrap();
        let bi: usize = iterator.next().unwrap().parse().unwrap();
        graph[ai - 1].push(bi - 1);
        graph[bi - 1].push(ai - 1);
    }
    let mut blocks: Vec<(usize, usize)> = Vec::new();
    for _ in 0..k {
        let ci: usize = iterator.next().unwrap().parse().unwrap();
        let di: usize = iterator.next().unwrap().parse().unwrap();
        blocks.push((ci - 1, di - 1));
    }

    let mut colors: Vec<Option<usize>> = vec![None; n];
    let mut color: usize = 0;
    let mut counts: HashMap<usize, usize> = HashMap::new();
    for i in 0..n {
        if colors[i].is_some() {
            continue;
        }
        let mut q: VecDeque<usize> = VecDeque::new();
        q.push_back(i);
        colors[i] = Some(color);
        *counts.entry(color).or_insert(0) += 1;
        while let Some(u) = q.pop_front() {
            for &v in &graph[u] {
                if colors[v].is_some() {
                    continue;
                }
                q.push_back(v);
                colors[v] = Some(color);
                *counts.entry(color).or_insert(0) += 1;
            }
        }
        color += 1;
    }

    let mut result = vec![0; n];
    for i in 0..n {
        result[i] = *counts.get(&colors[i].unwrap()).unwrap() - graph[i].len() - 1;
    }

    for b in blocks {
        if colors[b.0] == colors[b.1] {
            result[b.0] -= 1;
            result[b.1] -= 1;
        }
    }

    result.iter().map(|it| it.to_string()).join(" ")
}


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

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

    cout << "?";
    for(int i=0; i<n; i++) cout << " " << i+1;
    cout << endl;

    string left;
    cin >> left;

    int upper = n, lower = 0, mid;
    while(upper - lower > 1){
        mid = (upper + lower) / 2;

        cout << "?";
        for(int i=mid; i<mid+n; i++) cout << " " << i+1;
        cout << endl;

        string response;
        cin >> response;
        if(response == "-1") return 0;
        if(response == left) lower = mid;
        if(response != left) upper = mid;
    }
    //cout << "lower : " << lower << endl;

    vector<char> ans(2*n, '.');
    if(left == "Red"){  ans[lower] = 'R'; ans[lower+n] = 'B'; }
    if(left == "Blue"){ ans[lower] = 'B'; ans[lower+n] = 'R'; }

    for(int i=lower+n+1; i<lower+2*n; i++){
        cout << "? " << (i % (2*n) + 1);
        for(int j=lower+1; j<lower+n; j++) cout << " " << j + 1;
        cout << endl;
        string response;
        cin >> response;
        if(response == "-1")   return 0;
        if(response == "Red")  ans[i % (2*n)] = 'R';
        if(response == "Blue") ans[i % (2*n)] = 'B';
    }
    for(int i=lower+1; i<lower+n; i++){
        cout << "? " << i + 1;
        for(int j=lower+n+1; j<lower+2*n; j++) cout << " " << (j % (2*n) + 1);
        cout << endl;
        string response;
        cin >> response;
        if(response == "-1")   return 0;
        if(response == "Red")  ans[i] = 'R';
        if(response == "Blue") ans[i] = 'B';
    }
    
    cout << "! ";
    for(char a : ans) cout << a;
    cout << endl;
    return 0;
}

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

int main(void) 
{
	cin.tie(0);
	ios::sync_with_stdio(false);
		
	int a,b;

	cin >> a >> b;

	for(int i=2;i<1000;i++)
	{
		int x = (i-1)*i;
		x/=2;
		int y = i*(i+1);
		y/=2;

		int d1 = x - a;
		int d2 = y - b;

		if(d1>0 && d2>0)
		{
			if(d1==d2)
			{
				cout << d1 << '\n';
				break;
			}
		}
	}

	return 0;	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int[][] A = new int[N][M];
		int[] B = new int[M];
		for(int i = 0; i < M; i++) {
			B[i] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		sc.close();
		int cnt = 0;
		for(int i = 0; i < N; i++) {
			int sum = 0;
			for(int j = 0; j < M; j++) {
				sum += A[i][j] * B[j];
			}
			if(sum + C > 0) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23764
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]

for x in range(101):
    for y in range(101):
        h = [0]*n
        ans = 0
        for i in range(n):
            if xyh[i][2]!=0:
                h[i] = abs(xyh[i][0] - x) + abs(xyh[i][1] - y) + xyh[i][2]
                if ans == h[i] or ans ==0:
                    ans =h[i]
                else:
                    break
            if i ==n-1:
                a = 0
                for j in range(n):
                    if xyh[j][2]!= max(ans- abs(xyh[j][0] - x) - abs(xyh[j][1] - y),0):
                        a=1
                        break
                if a==0:
                    print(x, y, ans)

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ if(a>b) a=b;}


ll bin_pow(ll x, ll n, ll mod=MD){
	ll res = 1LL;
	for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
	return res;
}

ll divmod(ll x, ll y, ll mod=MD){
	return ( x * bin_pow(y, mod-2, mod)) % mod;
}

vector<bool> prime(1000100);
VI prm;
void eratos ( int n){
	prime[2] = true; prime[0] = prime[1] = false;
	for(int i = 3; i <= n; i += 2) prime[i] = true, prime[i+1] = false;
	int limit = (int)sqrt((double)n) + 1;
	for(int i = 3; i <= limit; i += 2){
		if(!prime[i]) continue;
		for(int j = i * i, k = i * 2; j <= n; j += k) prime[j] = false;
	}
	rep(i, n+1) if(prime[i]) prm.push_back(i);
}

map<ll, int> fctm2( ll x ){
	map<ll, int> fmp;
	for(int i=0; (ll)prm[i]*prm[i]<=x; i++){
		for(int pz=prm[i]; x%pz==0 && x>=pz; x/=pz) fmp[pz]++;
	}
	if(x!=1) fmp[x]++;
	return fmp;
}

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	rep(i, n) cin >>a[i];
	
	eratos(1000050);
	
	map<ll, int> mp;
	rep(i, n){
		auto rz = fctm2(a[i]);
		for(auto a: rz) mp[a.first] = max(mp[a.first], a.second);
	}
	//for(auto a :mp) cerr<<a.first<<":"<<a.second<<", "; cerr<<"\n";
	ll zcm =1;
	for(auto a:mp) rep(j, a.second) (zcm *= a.first) %=MD;
	
	ll ans=0;
	rep(i,n){
		ans += divmod(zcm, a[i], MD);
		ans%=MD;
	}
	cout <<ans <<"\n";
	return 0;
}



Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n;

  while(cin >> n ,n){
    vector<int> v(n);

    for(int i = 0 ; i < n ; i++)
      cin >> v[i];

    int cnt = 0;
    while(true){
      vector<int> next(n);
      for(int i = 0 ; i < n ; i++){
	next[i] = count(v.begin(),v.end(),v[i]);
      }

      if(v == next) break;
      cnt++;
      v = next;
    }
    cout << cnt << endl;
    for(int i = 0 ; i < n ; i++){
      if(i) cout << " " << v[i];
      else cout << v[i];
    }
    cout << endl;;
  }

  return 0;
}

Measured memory_bytes: 1216
#横判定
def judgehol(a, b):
    for i in range(3):
        flag = [False, False, False]
        for j in range(3):
            if a[i][j] in b:
                flag[j] = True
        if flag[0] and flag[1] and flag[2]:
            break
    return flag[0] and flag[1] and flag[2]

#縦判定
def judgever(a, b):
    for j in range(3):
        flag = [False, False, False]
        for i in range(3):
            if a[i][j] in b:
                flag[i] = True
        if flag[0] and flag[1] and flag[2]:
            break
    return flag[0] and flag[1] and flag[2]


#斜め判定
def judgecross(a, b):
    if a[0][0] in b and a[1][1] in b and a[2][2] in b:
        return True
    elif a[0][2] in b and a[1][1] in b and a[2][0] in b:
        return True
    else:
        return False


a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
a = [a1, a2, a3]

n = int(input())

b = [int(input()) for i in range(n)]


if judgehol(a, b) or judgever(a, b) or judgecross(a, b):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	N := nextInt()
	x := make([]int, N)
	for i := 0; i < N; i++ {
		x[i] = nextInt()
	}
	sort.Ints(x)

	min := 10000000
	for j := x[0]; j <= x[N-1]; j++ {
		tmp := 0
		for i := 0; i < N; i++ {
			tmp += (x[i] - j) * (x[i] - j)
		}
		if tmp < min {
			min = tmp
		}
	}
	fmt.Println(min)
}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/diverta2019/tasks/diverta2019_c

#include "algorithm"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

void solve() {
  ll N;
  cin >> N;

  V<string> ss(N);
  rep(i, N) cin >> ss[i];

  auto get_ab_count = [](string s) {
    ll res = 0;

    repf(i, 0, s.size() - 1) {
      if (s[i] == 'A' & s[i + 1] == 'B') res++;
    }

    return res;
  };

  VL ab_counts(N);
  rep(i, N) ab_counts[i] = get_ab_count(ss[i]);

  ll a_ends = 0;
  ll b_begins = 0;
  ll a_ends_and_b_begins = 0;

  for (auto s : ss) {
    if (s[0] == 'B' && s[s.size() - 1] == 'A') a_ends_and_b_begins++;
    if (s[0] == 'B') b_begins++;
    if (s[s.size() - 1] == 'A') a_ends++;
  }

  ll res = accumulate(all(ab_counts), 0ll);

  if (a_ends_and_b_begins == a_ends && a_ends_and_b_begins == b_begins &&
      a_ends_and_b_begins > 0) {
    res += a_ends_and_b_begins - 1;
  } else {
    res += min(a_ends, b_begins);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll dp[201][654321]; ll n, W;
ll w[4321], v[4321];
ll solve() {
	fill(dp[0], dp[0] + 654321, INF);
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 654321; j++) {
			if (j < v[i]) {
				dp[i + 1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
			}
		}
	}
	ll res = 0;
	for (int i = 0; i < 654321; i++) {
		if (dp[n][i] <= W) { res = i; }
	}
	return res;
}
signed main() {
	ll a, b, cnt = INF, ans1 = 0; cin >> n >> W;
	for (int h = 0; h < n; h++) {
		cin >> w[h] >> v[h];
	}
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 518272
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
    int a, b, C;
    double S, L ,h;
    double rad, PI = acos(-1);
    cin >> a >> b >> C;
    rad = C * PI / 180;
    S = a * b * sin(rad) / 2;
    L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(rad));
    h = 2 * S / a;
    cout << fixed << setprecision(10) << S << endl<< L << endl << h << endl;
    return 0;
}


Measured memory_bytes: 3460
#include <iostream>

using namespace std;

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

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

    for (int i = n - 1; i >= 1; i--) {
        cout << a[i] << ' ';
    }
    cout << a[0] << endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long
#define lld long long double
#define pb push_back
#define mp make_pair
#define M 1000000007
using namespace std;

const int N = 2005;
ll n;
ll memo[N][N];

ll f(int i, int l, int r, pair<ll, ll>a[]) {
	if (l > r) return 0;
	ll &ans = memo[i][l];
	if (ans != -1) return ans;
	//left
	ans = f(i + 1, l + 1, r, a) + a[i].first * abs(l - a[i].second);

	//right
	ans = max(ans, f(i + 1, l, r - 1, a) + a[i].first * abs(r - a[i].second));
	return ans;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	cin >> n;
	pair<ll, ll>a[n];
	memset(memo, -1, sizeof(memo));
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		a[i].first = x;
		a[i].second = i;
	}
	sort(a, a + n);
	reverse(a, a + n);
	cout << f(0, 0, n - 1, a);
	return 0;
}

Measured memory_bytes: 35144
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    gcd = fractions.gcd(a, b)
    cnt = 1
    for i in range(2, int(gcd ** 0.5) + 1):
        while True:
            if gcd % i == 0:
                cnt += 1
                while True:
                    if gcd % i == 0:
                        gcd //= i
                    else:
                        break
            else:
                break
    print(cnt if gcd == 1 else cnt + 1)



if __name__ == '__main__':
    slove()


Measured memory_bytes: 64364
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 200010
#define MOD 1000000007
using namespace std;
int n,a,b; 
vector<int> p0,p1,ans;
void add(int x){
	ans.push_back(x);
}
void solve(int x){
	if(x==int(p0.size()))
		return ;
	solve(x+1);
	add(p0[x]);
	solve(x+1);
}
int used[MAXN],del[MAXN];
void solve1(int x,int flag){
	if(x==int(p1.size()))
		return ;
	int now;
	if(flag==0){
		for(int i=0;i<int(p1.size());i++)
			if(del[i]==0)
				now=i;
	}
	else{
		for(int i=0;i<int(p1.size());i++)
			if(del[i]==0&&used[i]==0)
				now=i;
	}
	del[now]=1;
	solve1(x+1,0);
	solve(0);
	add(p1[now]);
	used[now]^=1;
	solve1(x+1,flag);
	if(flag==0)
		del[now]=0;
}
int main(){
	SF("%d%d%d",&n,&a,&b);
	int t=a^b;
	for(int i=0;i<n;i++){
		if(t&(1<<i))
			p1.push_back(i);
		else
			p0.push_back(i);
	}
	if(p1.size()%2==0){
		PF("NO");
		return 0;
	}
	PF("YES\n");
	solve1(0,1);
	solve(0);
	int now=a;
	for(int i=0;i<int(ans.size());i++){
		PF("%d ",now);
		used[now]=1;
		now^=(1<<ans[i]);
	}
	PF("%d",now);
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef OJ
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define sz(x) ((int)x.size())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const char en = '\n';
const int MOD = 0;
const int MAXN = 0;
const int INF = 1e9;

int solve() {
    int n; cin >> n;
    LL d; cin >> d; d *= d;
    int ans = 0;
    fori(i,n) {
        LL x, y; cin >> x >> y;
        if(x*x+y*y <= d) ans++;
    }
    cout << ans << en;
    return 0;
} 

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int ntest = 1;
    //cin >> ntest;
    int t = 1;
    fori(test, ntest) {
        //cout << "Case #" << t << ": ";
        solve();
        t++;
    }

    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int x,y;
  cin>>x>>y;
  int ans=INF;
  if(x<y){
    if( (x<0 && y<=0) || (x>=0 && y>0) ){
      ans=min(ans,y-x);
    }else{
      ans=min(ans,1+ abs(abs(x)-abs(y)));
    }
  }
  if(x>y){
    if( (x<0 && y<=0) || (x>=0 && y>0) ){
      ans=min(ans,2+abs(abs(x)-abs(y)));
    }else{
      ans=min(ans,1+ abs(abs(x)-abs(y)));
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()
#define arr array

template<typename T> void umin(T& a,T b){a = min(a,b);}
template<typename T> void umax(T& a,T b){a = max(a,b);}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){

    

}


void solve(){

    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    if(d < x){
        ll cnt = x/d;
        if(k >= cnt){
            k -= cnt;
            x %= d;
            if((k&1))
                x -= d;
            x = abs(x);
            cout << x;
        }else{
            x -= k*d;
            x = abs(x);
            cout << x; 
        }
    }else if(d > x){
        if(k&1)
            x -= d;
        x = abs(x);
        cout << x;
    }else{
        k--;
        x -= d;
        if(k&1)
            x += d;
        cout << x;
    }
     
}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input00.txt","r",stdin);
    #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

int fib[45];
int Fibonacci(int);

main(){
  int n;

  scanf("%d",&n);
  printf("%d\n",Fibonacci(n));

  return 0;
}

int Fibonacci(int n){
  int ans;
  if(n==0 || n==1) return ans = 1; 
  if(fib[n] != 0) return fib[n];
  ans = Fibonacci(n-1) + Fibonacci(n-2);
  fib[n] = ans;
  return ans;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i = (a); i < (b); i++)
#define RREP(i, a, b) for(int i = (a); i >= (b); i--)
#define pq priority_queue
#define P pair<int, int>
#define P2 pair<int, P>
#define P3 pair<int, P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF = 1e9, MOD = 1e9+7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
const int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
const ld PI = abs(acos(-1));
const int sqrtN = 512;
const int logN = 32;
const ll LINF=1e18;

int main(){
	int n; cin >> n;
	set<char> st;
	for(int i = 0; i < n; i++){
		char c; cin >> c;
		st.insert(c);
	}
	
	if(st.size() == 3) cout << "Three" << endl;
	else if(st.size() == 4) cout << "Four" << endl;
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    int buf;
    cin >> buf;
    a[i] = buf - 1;
  }
  vector<int> ans(n);
  for (int i = 0; i < n; i++)
  {
    ans[a[i]] = i + 1;
  }
  for (int i = 0; i < n; i++)
  {
    if (i)
    {
      cout << " ";
    }
    cout << ans[i];
  }
  cout << endl;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll N, M;
    cin >> N >> M;

    vector<ll> L(M), R(M);
    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
    }

    ll lmax = L[0], rmin = R[0];
    for (int i = 0; i < M; i++) {
        lmax = max(lmax, L[i]);
        rmin = min(rmin, R[i]);
    }

    if (rmin >= lmax) {
        cout << rmin - lmax + 1 << endl;
    } else {
        cout << 0 << endl;
    }
    


    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll Sum;
inline ll sum1(ll n) { return n*(n+1)/2; }
int main(){
    ll N;
    cin>>N;
    for(ll l=1,r;l<=N;l=r+1){
        r=N/(N/l);
        Sum+=(sum1(r)-sum1(l-1))*sum1(N/l);
    }
    cout<<Sum;
    return 0;
}

Measured memory_bytes: 3612