akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.buffer.readline

class UnionFind:
    __slots__ = ["data"]
    
    def __init__(self, n=0):
        self.data = [-1]*(n+1)
    
    def root(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.data[x] < self.data[y]:
                self.data[x] += self.data[y]
                self.data[y] = x
            else:
                self.data[y] += self.data[x]
                self.data[x] = y
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def size(self, x):
        return -self.data[self.root(x)]
                


def main():
    n, m, k = map(int, input().split())
    friends = [0]*(n+1)
    blocks = [[] for _ in range(n+1)]
    uf = UnionFind(n)
    ans = []
    for _ in range(m):
        a, b = map(int, input().split())
        friends[a] += 1
        friends[b] += 1
        uf.unite(a, b)
    for _ in range(k):
        c, d = map(int, input().split())
        blocks[c].append(d)
        blocks[d].append(c)
    for i in range(1, n+1):
        nf = friends[i]
        nb = 0
        for b in blocks[i]:
            if uf.same(i, b):
                nb += 1
        ans.append(uf.size(i) - 1 - nf - nb)
    print(" ".join(list(map(str, ans))))


if __name__ == "__main__":
    main()

Measured memory_bytes: 33280
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define RET(x) return cout << x << endl, 0;
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

ull normalize(ull a, const vector<pair<ull, ull>>& bases) {
	ull normalized = a;
	ull bit, val;
	REPI(basis, bases) {
		tie(bit, val) = basis;
		if (((normalized >> bit) & 1LL) != 0LL) normalized ^= val;
	}
	return normalized;
}

int solve() {
	ll n;
	cin >> n;

	vector<ull> as(n);
	REPD(i, 0, n) cin >> as[i];

	string s;
	cin >> s;

	vector<pair<ull, ull>> bases;
	reverse(s.begin(), s.end());
	reverse(as.begin(), as.end());
	REPD(i, 0, n) {
		ull normalized = normalize(as[i], bases);
		if (s[i] == '0') {
			if (normalized != 0LL) REPD(bit, 0, 64) if (((normalized >> bit) & 1LL) != 0LL)bases.emplace_back(bit, normalized);
		}
		else if (normalized != 0LL) RET(1);
	}

	RET(0);
}

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

	ll t;
	cin >> t;
	REPD(i, 0, t) solve();

	return 0;
}


Measured memory_bytes: 3488
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;


int main(void){
  long N;
  cin >> N;
  long a[N];
  for (int i=0; i<N; i++){
    cin >> a[i];
  }
  
  int count[8] = {};
  int count_special = 0;
  for (int i = 0; i<N; i++){
    if (a[i] <=399){
      count[0] = 1;
    }else if(a[i] <= 799){
      count[1]=1;
    }else if(a[i] <= 1199){
      count[2]=1;
    }else if(a[i] <= 1599){
      count[3]=1;
    }else if(a[i] <= 1999){
      count[4]=1;
    }else if(a[i] <= 2399){
      count[5]=1;
    }else if(a[i] <= 2799){
      count[6]=1;
    }else if(a[i] <= 3199){
      count[7]=1;
    } else {
      count_special += 1;
    }
   }
    int count_norm = 0;
    for (int i = 0; i<8; i++){
      count_norm+= count[i];
    }
    if (count_norm == 0) cout << 1 << " " << count_special << endl;
    else cout << count_norm << " "<< count_norm+count_special << endl;
  
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    long n;

    cin >> n;

    ll a[n];
    ll table[n];
    long index = 0;
    long ans = 0;

    long i;

    rep(i, n) cin >> a[i];

    if (a[0] != 0) {
        Out(-1);
    } else {
        table[0] = index;
        repi(i, n, 1) {
            if (a[i] <= a[i - 1]) {
                index = i - a[i];
                table[i] = index;
            } else if (a[i - 1] + 1 < a[i]) {
                Out(-1);

                return 0;
            } else {
                table[i] = index;
            }
        }

        index = -1;
        nep(i, n) {
            if (table[i] == index) continue;

            ans += i - table[i];
            index = table[i];
        }

        Out(ans);
    }

    return 0;
}


Measured memory_bytes: 3328
#include <cmath>
#include <iostream>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

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

int main() {
    string s, t, u;
    int a, b;

    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    a -= (s == u);
    b -= (t == u);

    cout << a << " " << b << endl;

    return 0;
}


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

using namespace std;

void Main() {
    long long N, K;
    cin >> N >> K;
    vector<pair<long long, long long>> ps(N, make_pair(0, 0));
    vector<long long> X(N, 0), Y(N, 0);
    for (long long i = 0; i < N; ++i) {
        long long x, y;
        cin >> x >> y;
        ps[i].first = x;
        ps[i].second = y;
        X[i] = x;
        Y[i] = y;
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());

    long long ans = 2000000000LL * 2000000000LL + 10LL;
    for (long long i = 0; i < N - 1; ++i) {
        for (long long j = 0; j < N - 1; ++j) {
            long long x0 = X[i];
            long long y0 = Y[j];
            bool less = false;
            for (long long in = i + 1; in < N; ++in) {
                for (long long jn = j + 1; jn < N; ++jn) {
                    long long xn = X[in];
                    long long yn = Y[jn];
                    long long np = 0;
                    bool ok = true;
                    for (long long p = 0; p < N; ++p) {
                        long long x = ps[p].first;
                        long long y = ps[p].second;
                        if (x0 <= x && x <= xn && y0 <= y && y <= yn) {
                            ++np;
                            if (np > K) {
                                ok = false;
                                break;
                            }
                        }
                    }
                    if (ok && np == K) {
                        ans = min(ans, (xn - x0) * (yn - y0));
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3560
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/


void solve() {
	int n, m; cin >> n >> m;
	vector<int> a(n + 1), b(n + 1, 0);
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		b[x] = max(b[x], a[y]);
		b[y] = max(b[y], a[x]);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans += (a[i] > b[i]);
	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

Measured memory_bytes: 4744
#include <iostream>

using namespace std;

int main(){
	while(true){
		int n, x;
		cin >> n >> x;
		if(n == 0 && x == 0) break;
		int count = 0;
		for(int i = 1; i <= n; i++){
			for(int j = i+1; j <= n; j++){
				for(int k = j+1; k <= n; k++){
					if(i+j+k == x) count++;
				}
			}
		}
		cout << count << endl;
	}
}



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

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

    int N;
    cin >> N;
    int cnt = 0;
    int maxv = 0;
    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;
        if (maxv <= h) {
            maxv = h;
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
/* Author : bitshar */
// #pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
ll MOD = 1e9+7;
 
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=e; i>=s; i--)
#define ln "\n"
#define sp " "
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define NEGINF -1e18
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
#define dbg(x) cout << #x << " = " << x << ln 
#define all(x) x.begin(), x.end()
 
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln
 
#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6
 
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;
 
void solve() {
 
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n);
    ll S=0;
    forn(i,n) {
        cin >> a[i];
        S+=a[i];
    }
    sort(all(a));
    reverse(all(a));
    if(a[m-1]*4*m>=S) cout << "Yes\n";
    else cout << "No\n";
}
 
int main() {
    
    #ifdef DEBUG_MODE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    fio;
    int t=1;
    //cin >> t;
    while(t--) {
        solve();
    }
}

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

long long int N, a, i;
vector<char> ch, r;
vector<long long int> x;
char c;

int main(){
    x.push_back(0);
    while((c = getchar()) > 96 && c < 123){
        if(c ^ 'x'){
            ch.push_back(c);
            r.push_back(c);
            x.push_back(0);
        }else{
            ++*(x.rbegin());
        }
    }
    reverse(r.begin(), r.end());
    if(!equal(ch.begin(), ch.end(), r.begin()))return 0 & puts("-1");
    for(int b = 0, e = x.size() - 1; b < e; ++b, --e)a += abs(x[b] - x[e]);
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 1528
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    string a,b,c;
    cin >> a >> b >> c;
    //処理
  	char d,e,f;
  	d=a[0]-32;
  	e=b[0]-32;
  	f=c[0]-32;
    //出力
    cout << d << e << f << ENT;
    return 0;
}

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


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

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c;
    
    if(c < b)
    {
        x = b;
        b = c;
        c = x;
    }
    if(b < a)
    {
        x = a;
        a = b;
        b = x;
    }
    if(c < b)
    {
        x = b;
        b = c;
        c = x;
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
#include<math.h>
int main()
{
    int i=0,n1,n2,temp,sq;
    scanf("%d %d",&n1,&n2);
    temp=n2;
    while(temp>=1){
        temp=temp/10;
        i++;
    }
    if(n2==0){
        temp=n1*10+n2;
    }
    else if(i==1){
        temp=n1*10+n2;
    }
    else if(i==2){
        temp=n1*100+n2;
    }
    else{
        temp=n1*1000+n2;
    }
    sq=sqrt(temp);
    if(sq*sq==temp){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

int a,b;
cin >> a >> b;

if(a > b) while(a--) cout << b;
else if(a <= b) while(b--) cout << a;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}


void solve(long long N, long long K){
    if(N%K==0){
        cout << 0 << endl;
        return;
    }
    ll res=N%K;
    ll mres=abs(N%K-K);
    cout << min(res,mres) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  
  if(S.at(0) == '7') cout << "Yes" << endl;
  else if(S.at(1) == '7') cout << "Yes" << endl;
  else if(S.at(2) == '7') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    vector<vector<ll>> g(n);
    REP(i, n-1) {
        ll p, q;
        cin >> p >> q;
        p--, q--;
        g[p].push_back(q);
        g[q].push_back(p);
    }

    if(n == 2) {
        if(a[0] == a[1]) cout << "YES" << endl;
        else cout << "NO" << endl;
        return 0;
    }

    ll root = 0;
    while(g[root].size() == 1) root++;

    function<ll(ll,ll)> dfs = [&](ll v, ll p) {
        if(g[v].size() == 1) return a[v];
        ll ret = 2 * a[v], sum = 0, ma = 0;
        for(auto to: g[v]) {
          if(to == p) continue;
          ll tmp = dfs(to, v);
          ret -= tmp;
          sum += tmp;
          chmax(ma, tmp);
        }
        if(IN(0LL,a[v]+1,ret) && (sum-ret)/2 <= min(sum-ma, sum/2)) {
            return ret;
        } else {
            cout << "NO" << endl;
            exit(0);
        }
    };

    if(dfs(root, -1)) cout << "NO" << endl;
    else cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 14464
import java.io.*;
import java.util.*;
public class Main{ 

	public static void main(String args[]){
		
		Scanner scan = new Scanner(System.in);
		RPN rpn = new RPN(scan.nextLine());
        rpn.analyze();

	}
}
class Stack{
    ArrayList<Integer> stk;
    public Stack(){
        stk = new ArrayList<Integer>();
    }
    public void push(int val){
        stk.add(val);
    }
    public int pop(){
        int tmp=stk.get(stk.size()-1);
        stk.remove(stk.size()-1);
        return tmp;
    }
    public int ans(){
        return stk.get(0);
    }
}
class RPN{
    String[] exp;
    Stack stack;
    public RPN(String e){
        exp = e.split(" ", 0);
        stack = new Stack();
    }

    public void analyze(){
        int num;
        for(String str : exp){
            if(str.equals("+") || str.equals("-") || str.equals("*") || str.equals("/"))
	            stack.push(calc(stack.pop(),stack.pop(),str.charAt(0)));
            else
                stack.push(Integer.parseInt(str));
        }
        System.out.println(stack.ans());
    }
    int calc(int b, int a, char op){
        if(op=='+')
            return a+b;
        if(op=='*')
            return a*b;
        if(op=='-')
            return a-b;
        System.out.println("error");
        return 0;
    }
}
 

Measured memory_bytes: 17308
kn = list(map(int, input().split()))
a = list(map(int, input().split()))

k = kn[0]
n = kn[1]

distance = []
for i in range(n-1):
    distance.append(a[i+1] - a[i])
    
distance.append(k - a[n-1] + a[0])

#print(distance)
#print(max(distance))
print(sum(distance) - max(distance))

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

int main() {
    ll N,A,B;cin >>N>>A>>B;
    if (N == 1) {
        cout << ((A == B)? 1 : 0) << endl;
        return 0;
    } else {
        if (A > B) {
            cout << 0 << endl;
            return 0;
        }
        ll minx = A*(N-1) + B, maxx = A + (N-1)*B;
        cout << (maxx - minx + 1) << endl;
    }
    return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  vector<pll> ai(n);
  rep(i,n)ai[i]={a[i],i+1};
  sort(rbegin(ai),rend(ai));

  auto dp = vec<ll>(n+1,n+1);
  for(int i=0;i<=n;++i)for(int j=0;j<=n;++j){
    if(i+j==0 || i+j>n)continue;
    auto [v,k] = ai.at(i+j-1);
    if(i>0)dp[i][j] = max(dp[i][j],dp[i-1][j]+v*abs(i-k));
    if(j>0)dp[i][j] = max(dp[i][j],dp[i][j-1]+v*abs((n-j+1)-k));
  }

  ll ans = 0;
  for(int i=0;i<=n;++i){
    ans = max(ans,dp[i][n-i]);
  }
  cout<<(ans)<<endl;

}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; i++)
    {
        if (i / 10000 == i % 10 && (i / 1000) % 10 == (i / 10) % 10)
            ans++;
    }
    c(ans);
    return 0;
}


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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 500200;
const int mod = 1e9 + 7 ;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	map<ll, ll> cnt;
	multiset<ll> res;
	fo(i, n)
	{
		int x;
		cin >> x;
		cnt[x]++;
	}
	ll ans = 0;
	for(auto g : cnt)
	{
		if(g.S >= 2)
			res.insert(g.F);
		if(g.S >= 4)
			res.insert(g.F);
	}
	while(res.size() > 2)
		res.erase(res.begin());
	if(res.size() != 2)
		return cout << 0, 0;
	ll a = *res.begin();
	res.erase(res.begin());
	ll b = *res.begin();
	cout << a * b;
	return 0;
}
               

Measured memory_bytes: 6528
import math
N = int(input())
A = list(map(int, input().split()))
A = [A[i] - i - 1 for i in range(N)]
A.sort()
c = int(math.floor(N/2))
answer = sum(list(map(abs,[A[i] - A[c] for i in range(N)])))
print(answer)

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int l,r; cin >> l >> r;
  int ans = 1 << 30;
  for(int i = l; i <= min(l+2019,r); i++){
    for(int j = i+1; j <= min(i+2019,r); j++){
      ans = min(ans,(i*j)%2019);
      //cout << i << " " << j << " " << ans << endl;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
from numba import njit
 

@njit
def f(a):
    n = len(a)
    cnt = 0
    
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                if a[k] < a[i] + a[j]:
                    cnt += 1
    return cnt


n = int(input())
a = np.array(input().split(), dtype=np.int32)
a.sort()
print(f(a))


Measured memory_bytes: 109792
// AtCoder Grand Contest 014
// D - Black and White Tree

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


const int MAX_N = 100000;

int N;
vector<int> G[MAX_N];
int match[MAX_N];
bool used[MAX_N];

bool dfs(int v) {
    if (used[v]) {
        return false;
    }
    used[v] = true;

    for (int u : G[v]) {
        if (match[u] < 0 || dfs(match[u])) {
            match[v] = u;
            match[u] = v;
            return true;
        }
    }

    return false;
}

int bipartite_matching() {
    int res = 0;
    memset(match, -1, sizeof(match));
    for (int v = 0; v < N; v++) {
        if (match[v] >= 0) {
            continue;
        }
        memset(used, 0, sizeof(used));
        if (dfs(v)) {
            res++;
        }
    }
    return res;
}


int main() {

    int a, b;

    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    cout << (bipartite_matching() * 2 == N ? "Second" : "First") << endl;

    return 0;

}





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

int main() {
  string str;
  char a, b, c, d;
  cin >> str;
  a = str.at(0);
  b = str.at(1);
  c = str.at(2);
  d = str.at(3);
  
  if(a == b && c == d && b != c){
    cout << "Yes" << endl;
  }else if(a == c && b == d && a != b){
    cout << "Yes" << endl;
  }else if(a == d && b == c && a != b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main(){
  unsigned long X;
  unsigned long DepAmo = 100;
  cin >> X;
  
  unsigned count = 0;
  
  while(DepAmo < X){
    DepAmo += DepAmo/100;
    count++;
  }
  
  cout << count;
  
  return 0;
}

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

typedef long long int ll;
//Factors of an num
/*
vector<ll> fact(ll n){
	vector<ll>v;
	for(int i=1;i*i<=n;i++){
		if(n%i ==0){
			v.push_back(i);
		
		if(i!=n/i)
			v.push_back(n/i);
	    }
	}

	return v;
}
*/


/*
Seive Of Eratos..
int N=1e5;
vector<bool> isprime(N+1,true);
void pri(int n){
	for(int i=2;i*i<=n;i++){
		if(isprime[i]){
			for(int j=i*i;j<=n;j+=i){
				isprime[j]=false;
			}
		}
	}
	return;
}
*/

/*
//Prime Factors
vector<bool> isprime(1e6+1,true);
 vector<int> primes;
 void sieve()
 {

    ll  i,j;
    isprime[0] = false;
    isprime[1] = false;

    for(i=2; i<=1e6 ;i++)
  {

    if(isprime[i])
    {

      primes.push_back(i);

      for(j=i*i; j<=1e6; j+=i)
      {
        isprime[j]=false;
      }

    }

  }
}

vector<int> primefactors(int  N)

 {

    vector<int> factors;
    ll pf_idx = 0, pf=primes[pf_idx];

    while(pf*pf<=N)
    {
        while(N % pf == 0)
        {
            N/=pf;
            factors.push_back(pf);
        }
        pf = primes[++pf_idx];
    }
    
    if(N != 1) factors.push_back(N);
    return factors;
}
 */   




int main(){
	 
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str;
    cin>>str;
    int sum=0;
   for(char i:str){
    	sum=sum+(i-'0');
    }
  //  cout<<sum<<endl;
    if(sum%9==0){
    	cout<<"Yes";
    }
else 
	cout<<"No";
   }




Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,N,L,a,b,f=0,id;
  cin>>N>>L;
  rep(i,N){
    cin>>b;
    if(a+b>=L){f=1;id=i;}
    a=b;
  }
  if(f){
    cout<<"Possible"<<endl;
  }else{
    cout<<"Impossible"<<endl;
    return 0;
  }
  rep1(i,id){
    cout<<i<<endl;
  }
  for(i=N-1;i>id;i--){
    cout<<i<<endl;
  }
  cout<<id<<endl;
  return 0;
}

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

#define MAX 22

int N,ans=0;
int A[(1<<MAX)];
int dp[(1<<MAX)];
int prx[(1<<MAX)];
int pry[(1<<MAX)];
int prz[(1<<MAX)];

void insert(int &a,int &b,int &c,int x){
  if(x==-1||a==x||b==x||c==x)return;
  c=b;
  b=a;
  a=x;
}

int main(){
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    int k,a,bit=0;
    scanf("%d",&k);
    for(int j=0;j<k;j++){
      scanf("%d",&a);
      a--;
      bit|=(1<<a);
    }
    A[bit]++;
  }
  
  for(int i=(1<<MAX)-1;i>0;i--){
    int a=-1,b=-1,c=-1;
    if(A[i]){
      dp[i]=i;
      a=i;
    }
    
    for(int j=0;j<MAX;j++){
      int nbit=i|(1<<j);
      if(i==nbit)continue;
      dp[i]|=dp[nbit];
      insert(a,b,c,prx[nbit]);
      insert(a,b,c,pry[nbit]);
      insert(a,b,c,prz[nbit]);
    }
    prx[i]=a;
    pry[i]=b;
    prz[i]=c;
    int cnt=0;
    if(a!=-1)cnt+=A[a];
    if(b!=-1)cnt+=A[b];
    if(c!=-1)cnt+=A[c];
    if(cnt>=3)ans=max(ans,__builtin_popcount(i)*__builtin_popcount(dp[i]));
  }
  printf("%d\n",ans);
  return 0;
}

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

using namespace std;

typedef long long ll;

ll mod;

ll powimod(ll x,ll n,ll mod){
    ll res=1;
    while(n){
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}

ll powi(ll x,ll n){
    ll res=1;
    while(n){
        if(n&1) res*=x;
        x*=x;
        n>>=1;
    }
    return res;
}

vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int l,r,d;
    cin>>l>>r>>d;
    int a,b;
    a=(l-1)/d;
    b=r/d;
    cout<<b-a;
}


Measured memory_bytes: 3632
a, b, c, k = (int(x) for x in input().split())
ans = 0

if k < a: ans += k * 1
elif a <= k <= a + b: ans += a * 1
elif a + b < k <= a + b + c: ans += a * 1 + (k - (a + b)) * (-1)
print(ans)

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int n;
    cin>>n;
    vector<int>v;
    while(n>0){
        int rem=n%10;
        n=n/10;
        v.push_back(rem);
    }
    int count=0;
    for(int i=0;i<v.size()-1;i++){
        if(v[i]==v[i+1])count++;
        else count=0;
        if(count>=2)break;
    }
    if(count>=2)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 14;

int sm[(1 << MAX_N)];
double dp[(1 << MAX_N)];
double pp[101];

int main()
{
    int n,m,p;
    scanf("%d%d%d",&n,&m,&p);
    pp[0] = 1;
    vp edge(m);
    rep(i,m){
        pp[i+1] = pp[i] * (p / 100.0);
        scanf("%d%d",&edge[i].fi,&edge[i].se);
    }
    rep(i,(1 << n)){
        int res = 0;
        rep(j,m){
            int u = edge[j].fi - 1,v = edge[j].se - 1;
            if((i >> u) & (i >> v) & 1){
                res++;
            }
        }
        sm[i] = res;
    }
    rep(S,(1 << n)){
        if(!(S & 1)){
            continue;
        }
        double res = 0;
        for(int T=S;T>0;T=(T-1)&S){
            res += dp[T]*pp[sm[S]-sm[T]-sm[S^T]];
        }
        dp[S] = 1.0 - res;
    }
    printf("%.12lf\n",dp[(1 << n)-1]);
    return 0;
}

Measured memory_bytes: 3400
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
 
int main() {
    long long n, a, ans = 0;
    cin >> n;
    vector<long> as(n + 1);
    vector<long> bs(n);
    for (int i = 0; i <= n; i++){
        cin >> as[i];
    }
    for (int i = 0; i < n; i++){
        cin >> bs[i];
    }
    for (int i = 0; i < n; i++){
        a = as[i];
    //    cout << max(int (0) , int (as[i] - bs[i])) << endl;
        as[i] = max(long (0) , long (as[i] - bs[i]));
        ans += a - as[i];
        bs[i] = max(long (0) , long (bs[i] - a));
        a = as[i + 1];
        as[i + 1] = max(long (0) , long (as[i + 1] - bs[i]));
        ans += a - as[i + 1];
        bs[i] = max(long (0) , long (bs[i] - a));
    //    cout << as[i] << " " << as[i + 1] << " " << bs[i] << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[ten52];
//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;


int main(void)
{
    double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1,a2,a3,sum;
    string s,s1,s2;
    char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>k>>n;
    for(i=0;i<n;i++)
    {
        cin>>m;
        num[i]=m;
    }
    m=k-num[n-1]+num[0];
    for(i=1;i<n;i++)
    {
        m=max(m,num[i]-num[i-1]);
    }
    cout<<k-m;
    return 0;
}





Measured memory_bytes: 1792
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

#N = int(input())
N, D = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
XY = [list(map(int, input().split())) for _ in range(N)]
#S = input()
#S = [input() for _ in range(N)]

answer = 0
for x, y in XY:
    if x ** 2 + y ** 2 <= D ** 2:
        answer += 1
print(answer)
    

Measured memory_bytes: 102412
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int X,Y,Z;cin>>X>>Y>>Z;
	cout<<Z<<" "<<X<<" "<<Y<<endl;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    int h[n];
    for(int i=0;i<n;i++) cin >> h[i];
    sort(h,h+n,greater<int>());
    int ans = 0;
    for(int i=0;i<n;i++){
        if(h[i] < k) break;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#include <time.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/

int main(){
    ll N;
    cin >> N;
    map<ll,ll> ma;
    ll wa = 0;
    ll n;
    rep(i,N){
        cin >> n;
        wa += n;
        ma[n]++;
    }
    ll Q;
    cin >> Q;
    vector<ll> fr(Q);
    vector<ll> to(Q);
    rep(i,Q){
        cin >> fr[i] >> to[i];
    }
    rep(i,Q){
        wa = wa + (to[i] - fr[i]) * ma[fr[i]];
        cout << wa << "\n";
        ma[to[i]] += ma[fr[i]];
        ma[fr[i]] = 0;
        /*for(auto x : ma){
            cout << x.first << ":" << x.second << "\n";
        }*/
    }
}

Measured memory_bytes: 10856
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n),c(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> c[i];
    rep(i,n) p[i]--;
    int x,now;
    long long ans = -1e18;
    rep(si,n) {
        vector<int> s;
        x = si;
        long long tot = 0;
        while(1) {
            x = p[x];
            s.push_back(c[x]);
            tot += c[x];
            if(x == si) break;
        }
        int l = s.size();
        long long t = 0;
        long long now;
        rep(i,l) {
            t += s[i];
            if(i+1 > k) break;
            now = t;
            if(tot > 0){
                long long e = (k-i-1)/l;
                now += tot*e;
            }
            ans = max(ans, now);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int a[15], n, ans;

void func(int p, int m){
	if(p == n){
		if(m == 0) ++ans;
		return;
	}
	func(p + 1, m * (1 - (a[p] & 1)));
	func(p + 1, m * (a[p] & 1));
	func(p + 1, m * (1 - (a[p] & 1)));
}

int main (){
	int i;
	scanf("%d", &n);
	for(i = 0; i < n; ++i) scanf("%d", a + i);
	func(0, 1);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3768
using System;

public class Prgram {
	public static void Main(string[] args) {
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int a = int.Parse(input[1]);
		int b = int.Parse(input[2]);
		int plan1 = n * a;
		int plan2 = b;
		if (plan1 < plan2) {
			Console.WriteLine(plan1);
		} else {
			Console.WriteLine(plan2);
		}
	}
}

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

int main(){
  int N , A , B;
  cin >> N >> A >> B;
  
  if (N * A > B)
    cout << B << endl;
  
  else if (N * A < B)
    cout << N * A << endl;
  
  else
    cout << B << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#ifdef LOCAL_ENV
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define DUMP(x)
#define DEBUG(x)
#endif

#define MAX_VALUE 9223372036854775807

int solve() {
	string N;
	cin >> N;

	ll res = 0;
	REPD(i, 0, N.size()) {
		res += N[i] - '0';
	}

	RET((res % 9 == 0 ? "Yes" : "No"));

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


Measured memory_bytes: 3736
import itertools
import math

n, d = map(int, input().split())
X = []
for i in range(n):
    X.append([int(i) for i in input().split()])

ans = 0
for i in itertools.permutations(range(n), 2):
    if i[0] < i[1]:
        x1 = X[i[0]]
        x2 = X[i[1]]
        check = 0
        for j in range(d):
            check += abs(x2[j] - x1[j]) ** 2
        if math.sqrt(check).is_integer():
            ans += 1
print(ans)

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int x, y, z;
    cin >> x >> y >> z;
    x -= z;
    cout << max(0, x / (y + z)) << endl;
}


Measured memory_bytes: 256