akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    
    int x=0,y=0,z=0;
    rep(i,0,n){
        int p;
        cin>>p;
        if(p<=a) x++;
        else if(p<=b) y++;
        else z++;
    }
    
    cout<<min({x,y,z})<<endl;
}


Measured memory_bytes: 256
def fibonacciDP(i):
    if i == 0:
        return 1
    elif i == 1:
        return 1
    else:
        if dp[i-1] is None and dp[i-2] is None:
            dp[i-1] = fibonacciDP(i-1)
            dp[i-2] = fibonacciDP(i-2)
        elif dp[i-1] is None:
            dp[i-1] = fibonacciDP(i-1)
        elif dp[i-2] is None:
            dp[i-2] = fibonacciDP(i-2)

        return dp[i-1]+ dp[i-2]

def fibonacci(i):
    if i == 0:
        return 1
    elif i == 1:
        return 1
    else:
        return fibonacci(i-1)+fibonacci(i-2)



n = int(input())
dp = [None]*n

print(fibonacciDP(n))

Measured memory_bytes: 7736
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll h,a;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>h>>a;
	ll ans = h/a;
	if(h%a!=0)ans++;
	print(ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
  int n;
  int o[6] = {3,5,7,9,11,13};
  int ans = 0;
  cin >> n;
  for(int i = 0; i < 4; i++){
    for(int j = i + 1; j < 5; j++){
      for(int k = j + 1; k < 6; k++){
        if(o[i] * o[j] * o[k] % 2 == 0) continue;
        if(o[i] * o[j] * o[k] <= n) ans++;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;

int main()
{
    string n;

    cin >> n;

    string t = n;

    reverse(n.begin(), n.end());

    if (n == t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,p,now_min=INF,ans;

signed main() {
    cin >> n;
    rep(i,n) {
        cin >> p;
        now_min = min(now_min, p);
        if (now_min >= p) ans++;
    }
    cout << ans << endl;
}



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

int main()
{
    int A,B;
    cin >> A >> B;

    int count = 0;

    for(int i = A; i <= B; i++)
    {
        string s = to_string(i);
        bool notflag = false;
        for(int j = 0; j < s.size(); j++)
        {
            if(s.at(j) != s.at(s.size() - j - 1))
            {
                notflag = true;
                break;
            }
        }
        if(notflag == false)count++;
        
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
R = lambda : input().split()

n, m = map(int, R())
a = [False] * n
b = [0] * n
for _ in range(m):
  p, s = R()
  p = int(p) - 1
  if s == 'AC':
    a[p] = True
  elif not a[p]:
    b[p] += 1
b =  [y for x, y in zip(a, b) if x]
print(len(b), sum(b))


Measured memory_bytes: 5528
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n, a, b;
	while(cin >> n>> a >> b) {
		cout << min(n * a, b) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
A = list(map(lambda x:-int(x), input().split()))

import heapq
heapq.heapify(A)

for i in range(M):
  price = heapq.heappop(A)
  price *= -1
  price //= 2
  heapq.heappush(A, -price)

print(sum(A) * (-1))

Measured memory_bytes: 20304
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// ?¨??????\???????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for (int i = 0; i < values.length; i++) {
			values[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1; // a??¨b????????£???values??????????????????
			int tmp = values[a];
			values[a] = values[b];
			values[b] = tmp;
			
		}
		// values??????????????????
		for(int i = 0;i<w;i++){
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 25896
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	string ans;
	if(s.length()<t.length()){
		cout<<"UNRESTORABLE";
		return 0;
	}
	for(int i=0;i<=s.length()-t.length();i++){
		bool can=true;
		for(int j=0;j<t.length();j++){
			if(s[i+j]=='?')continue;
			if(s[i+j]!=t[j])can=false;
		}
		if(can){
			string A=s.substr(0,i);
			A+=t;
			A+=s.substr(i+t.length());
			for(int k=0;k<A.size();k++){
				if(A[k]=='?'){
					A[k]='a';
				}
				ans=A;
			}
		}
	}
	if(ans.size()==0){
			cout<<"UNRESTORABLE";
			return 0;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int n;
	//cin>>n;
	string t;
	getline(cin,t);
	n=atoi(t.c_str());
	rep(i,0,n){
		string s;
		getline(cin,s);
		//o(" "<<s);
		while(1){
			if(s.find("Hoshino")!=string::npos){
				s.replace(s.find("Hoshino"),7,"Hoshina");
			}
			else break;
		}
		o(s);
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, M;
    cin >> N >> M;
    if (N >= M) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> A(M), B(M - 1);
    for (int i = 0; i < M; i++) {
        cin >> A.at(i);
    }
    sort(ALL(A));
    for (int i = 0; i < M - 1; i++) {
        B.at(i) = A.at(i + 1) - A.at(i);
    }
    sort(rALL(B));
    int ans = A.at(M - 1) - A.at(0);
    for (int i = 0; i < N - 1; i++) {
        ans -= B.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  int ans = 0, Min = n;
  for(int i = 0; i < n; i++){
    Min = min(Min, p[i]);
    if(p[i] <= Min) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
import collections
pp = int(input()) + 1
da = list(map(int,input().split()))
da.insert(0,0)
al = 0
j = 1

for k in range(1,pp):
  da[k] += da[k-1]

p = collections.Counter(da)
p = p.values()
for i in p:
  if i >= 2:
    al += ((i -1)*i)//2

print(al)

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
     cin >> a.at(i); 
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int A_point = 0, B_point = 0;
  for (int i = 0; i < N; i++){
    if (i % 2 == 0)	A_point += a.at(i);
    else if (i % 2 == 1)	B_point += a.at(i);      
  }
  cout << A_point - B_point << endl;
}

Measured memory_bytes: 256
def f():
    n,s=int(input()),input()
    a,b=s[n-1::-1],s[n:]
    ad={}
    bd={}
    for i in range(2**n):
        sa,ta,sb,tb="","","",""
        for j in range(n):
            if i%2:
                sa+=a[j]
                sb+=b[j]
            else:
                ta+=a[j]
                tb+=b[j]
            i//=2
        ad[(sa,ta)]=(1 if (sa,ta)not in ad else ad[(sa,ta)]+1)
        bd[(sb,tb)]=(1 if (sb,tb)not in bd else bd[(sb,tb)]+1) 
    ans=0
    for k in ad:
        if k in bd:ans+=bd[k]*ad[k]
    print(ans)
if __name__ == "__main__":
    f()


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

int main(){
    int n, m;
    cin >> n >> m;
    int c[m];
    for(int i = 0; i < m; i++) cin >> c[i];

    int dp[n+1];
    for(int i = 0; i <= n; i++) dp[i] = i;

    for(int i = 1; i <= n; i++){
        for(int j = 0; j < m; j++){
            if(i >= c[j]) dp[i] = min(dp[i], dp[i-c[j]]+1);
        }
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 3288
/**
 *      ABC 60 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 02:11:18
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string A, B, C; cin >> A >> B >> C;
    int sizeA = A.size(); int sizeB = B.size();

    (A[sizeA - 1] == B[0] && B[sizeB - 1] == C[0]) ? cout << "YES" : cout << "NO";
    return 0;
}


Measured memory_bytes: 256
from itertools import product
d,g = (int(i) for i in input().split())
p = [[int(i) for i in input().split()] for i in range(d)]
q,ans = [],1001
for i in range(d): q.append(p[i][0]*(i+1)*100+p[i][1]) 
for i in product(range(2), repeat=d):
	m,n,x = 0,0,[]
	for j in range(d):
		if i[j]==1: m,n = m+q[j],n+p[j][0]
		else: x.append(j)
	if m>=g: ans = min(ans,n)
	else:
		for k in x:
			num = (g-m+99)//((k+1)*100)
			if num<p[k][0]: ans = min(ans,n+num)
print(max(1,ans))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		if ((a + b) > (c + d)) {
			System.out.println("Left");
		} else if ((a + b) < (c + d)) {
			System.out.println("Right");
		} else {
			System.out.println("Balanced");
		}
	}

}


Measured memory_bytes: 21844
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int H, W, K;
char TABLE[6][6];
char WORK[6][6];

bool match(vector<int>&choseH, vector<int>&choseW) {
    int cnt = 0;
    rep(i, H) {
        auto itr = find(choseH.begin(), choseH.end(), i);
        if(itr != choseH.end()) {
            continue;
        }
        rep(j, W) {
            itr = find(choseW.begin(), choseW.end(), j);
            if(itr != choseW.end()) {
                continue;
            }
            if(TABLE[i][j] == '#') {
                cnt++;
            }
            if(cnt > K)
                return false;
        }
    } 
#if 0
    cout << "H:";
    rep(i, choseH.size()) {
        cout << choseH[i] << ", ";

    }
    cout << endl;
    cout << "W:";
    rep(i, choseH.size()) {
        cout << choseW[i] << ", ";

    }
    cout << endl;
    cout << cnt << ", " << K << endl;
#endif
    return cnt == K;
}

int main() {
    cin >> H >> W >> K;
    rep(i, H) {
        rep(j, W) {
            cin >> TABLE[i][j];
        }
    }
    int cand = 0;
    for(int bitH=0; bitH < (1<<(H)); ++bitH) {
        vector<int> choseH;
        for(int i=0; i<H; ++i) {
            if(bitH & (1<<i))
                choseH.push_back(i);
        }
        for(int bitW=0; bitW < (1<<W); ++bitW) {
//            cout << bitH << " " << bitW << endl;
            vector<int> choseW;
            for(int i=0; i<W; ++i) {
                if(bitW & (1<<i))
                    choseW.push_back(i);
            }
            if(match(choseH, choseW)) {
                cand++;
            }
        }
    }
    cout << cand << endl;


    return 0;
}


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

int main() 
{ 
	string s;
	int c=0;
		cin>>s;
	for(int i=0; s[i]!='\0'; i++){
			if(s[i]>='0' && s[i]<='9')
				if(s[i]=='7')
					c=1;		
	}
	if(c)
		cout<<"Yes";
	else
		cout<<"No";
	
	return 0;
}

Measured memory_bytes: 3608
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;
    cin>>x>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    map<int,bool>m;
    rep(i,n)m[a[i]]=true;
    int ans;
    int b=INF;
    rep(i,100+2){
        if(abs(i-x)<b&&m[i]==false){
            b=abs(i-x);
            ans=i;
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  string a,b;
  for(;;){
    cin >> a >> b;
    if(cin.eof()) break;

    int l=max(a.size(),b.size());
    vector<int> c(l,0),d(l,0);
    for(int i=a.size()-1,j=0; i>=0; i--,j++)
      c[j] = a[i]-'0';
    for(int i=b.size()-1,j=0; i>=0; i--,j++)
      d[j] = b[i]-'0';

    int flag=0;
    for(int i=0; i<l; i++){
      if(c[i]+d[i]+flag>9)
	flag=1;
      else
	flag=0;
    }
    
    cout << l+flag << endl;
  }
}

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

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

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

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

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

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vll a(m),b(m);
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--,b[i]--;
  }
  
  UnionFind uf(n);
  
  vll ans(m);
  ans[m-1]=n*(n-1)/2;
  for(ll i=m-1; i>0; i--){
    if(!uf.isSame(a[i],b[i])){
      ll preva=uf.size(a[i]);
      ll prevb=uf.size(b[i]);
      uf.connect(a[i],b[i]);
      ans[i-1]=ans[i]-preva*prevb;
    }else{
      ans[i-1]=ans[i];
    }
  }
  rep(i,m){
    cout<<ans[i]<<endl;
  }
}

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

using namespace std;

vector<int> match(const string &t, const string &p)
{
    vector<int> res;
    bool find;
    for (int i = 0; i < t.size(); i++)
    {
        find = false;
        if (t[i] == '?' || t[i] == p[0])
        {
            for (int j = 1; j < p.size(); j++)
            {
                if (t[i + j] != '?' && t[i + j] != p[j])
                {
                    find = true;
                    break;
                }
            }
            if (!find)
                res.push_back(i);
        }
    }

    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string t, p, temp, res;
    cin >> t >> p;
    vector<int> poss = match(t, p);
    if (poss.size() != 0)
    {
        res = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
        for (auto pos : poss)
        {
            temp = t;
            for (int i = 0; i < p.size(); i++)
                temp[pos + i] = p[i];
            for (auto &i : temp)
                if (i == '?')
                    i = 'a';
            res = min(res, temp);
        }
    }
    else
        res = "UNRESTORABLE";
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int a,b;
	cin >> a >> b;
	int area = (a * b) -a -b +1;
	cout << area << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>

using namespace std;

const double EPS = 1E-9;

struct point
{
    double x, y;

    point operator + (point a) { return {x + a.x, y + a.y}; }
    point operator - (point a) { return {x - a.x, y - a.y}; }
    point operator * (double d) { return { x * d, y * d }; }
    double dist() { return hypot(x, y); }
};

struct line { double a, b, c; };

line ser_per(point a, point b) {
    line res;
    point d = a - b;
    res.a = d.x;
    res.b = d.y;
    point o = (a + b) * 0.5;
    res.c = res.a * o.x + res.b * o.y;
    return res;
}

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

    int n;
    double res = 1E100;
    cin >> n;

    vector<point> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i].x >> a[i].y;

    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
        {
            point o = (a[j] + a[i]) * 0.5;
            double r = (a[i] - o).dist();
            bool ok = true;
            for (int k = 0; k < n; k++)
                if ((a[k] - o).dist() > r + EPS)
                    ok = false;
            if (ok)
                res = min(res, r);
        }

    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            for (int k = j + 1; k < n; k++)
            {
                line q = ser_per(a[i], a[j]);
                line w = ser_per(a[i], a[k]);

                double d = q.a * w.b - q.b * w.a;
                if (abs(d) < EPS) continue;

                double dx = q.c * w.b - q.b * w.c;
                double dy = q.a * w.c - q.c * w.a;

                point o = { dx / d, dy / d };
                double r = (a[i] - o).dist();

                bool ok = true;
                for (int t = 0; t < n; t++)
                    if ((a[t] - o).dist() > r + EPS)
                        ok = false;
                if (ok)
                    res = min(res, r);
            }

    cout << fixed << setprecision(20);
    cout << res << "\n";

    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mkmap;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<vi> vv;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const ll mod=1000000007;
const int sz=1000001;
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(i=a;i<b;++i)
#define rrep(i,a,b) for(i=a;i>=b;--i)
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db(x) cout << (#x) << " = " << x << endl;

inline ll mult(ll a, ll b) {return (((a % mod) * (b % mod)) % mod);}

int dp[100001];

int fun(vi &a,int i,int k){
    if(i>=a.size()-1) return 0;
    if(dp[i]!=-1) return dp[i];
    int mx=INT_MAX,j;
    rep(j,1,k+1){
        if(i+j>=a.size()) break;
        mx=min(mx,abs(a[i]-a[i+j])+fun(a,i+j,k));
    }
    return dp[i]=mx;
}

int main(){
    fast;
    int t,tt,tti,n,m,x,y,z,i,j,k,temp,count,o,e,f,ans,sum,l,r,mx,mn;
    ll lx,ly,lz,ltemp;
    double fx,fy,fz;
    string s;
    cin>>n>>m;
    vi a(n);
    rep(i,0,n) cin>>a[i];
    memset(dp,-1,sizeof(int)*(n+1));
    cout<<fun(a,0,m);
}

/*
    
*/

Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main(){
	int a[3][3];
	bool bo[3][3] = { false };
	int co = 0, co1 = 0, co2 = 0, co3 = 0;
	int n;
	int b;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	cin >> n;
	for (int k = 0; k < n; k++) {
		cin >> b;
		for (int c = 0; c < 3; c++) {
			for (int d = 0; d < 3; d++) {
				if (a[c][d] == b) {
					bo[c][d] = true;
				}
			}
		}
	}
	for (int e = 0; e < 3; e++) {
		if (bo[e][e] == true) {
			co++;
		}
		if (bo[e][2 - e] == true) {
			co3++;
		}
	}
	if (co == 3 || co3 == 3) {
		cout << "Yes" << endl;
		return 0;
	}
	for (int f = 0; f < 3; f++) {
		for (int g = 0; g < 3; g++) {
			if (bo[f][g] == true) {
				co1++;
			}
			if (bo[g][f] == true) {
				co2++;
			}
		}
		if (co1 == 3 || co2 == 3) {
			cout << "Yes" << endl;
			return 0;
		}
		co1 = 0;
		co2 = 0;
	}
	cout << "No" << endl;
	return 0;
}

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

h,w = [int(i) for i in input().split()]
b = [input() for i in range(h)]

l = [[0]*w for _ in [0]*h] #左にある白マス（自分含む）
r = [[0]*w for _ in [0]*h]
u = [[0]*w for _ in [0]*h] #上にある白マス（自分含む）
d = [[0]*w for _ in [0]*h]
for hi in range(h):
    for wj in range(w):
        if b[hi][wj] == '.':
            l[hi][wj] = l[hi][wj-1]+1
            u[hi][wj] = u[hi-1][wj]+1
        if b[hi][w-wj-1] == '.':
            r[hi][w-wj-1] = r[hi][-wj]+1
        if b[h-hi-1][wj] == '.':
            d[h-hi-1][wj] = d[-hi][wj]+1

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, l[i][j]+r[i][j]+u[i][j]+d[i][j]-3)
        
print(ans)

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

long long mod = 1000000007LL;

long long dp[20000];

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	fill(dp,dp+20000,-1);
	
	long long h, n; cin >> h >> n;
	long long a[n];
	long long b[n];
	for(int i = 0;i < n;i++) cin >> a[i] >> b[i];
	
	long long ans = 3123213123LL;
	dp[0] = 0;
	for(int i = 1;i < 20000;i++){
		dp[i] = 123938203LL;
		for(int j = 0;j < n;j++){
			if(i - a[j] >= 0){
				dp[i] = min(dp[i], dp[i-a[j]] + b[j]);
			}
		}
		if(i >= h) ans = min(ans, dp[i]);
	}
	cout << ans;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i = n; i <= 999; ++i){
		set<int> s;
		int p = i;
		while(p != 0){
			int r = p % 10;
			s.insert(r);
			p/=10;
		}
		if(s.size() == 1){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    double ans=0;
    for(int i=1;i<=n;i++)
    {
        int pos=i;
        double tmp=(double)1/n;
        while(pos<k)
        {
            pos*=2;
            tmp*=0.5;
        }
        ans+=tmp;
    }
    printf("%.11lf\n",ans);
}


Measured memory_bytes: 256
program j01;
var n,m,ans:int64;
begin
  readln(n,m);
  if 2*n>=m then
  begin
    writeln(m div 2);halt;
  end;
  ans:=n;m:=m-2*n;
  ans:=ans+m div 4;
  writeln(ans);
end.

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> subs(N, 0);
  for(int i = 0; i < N - 1; ++i) {
    int a;
    cin >> a;
    --a;
    ++subs[a];
  }
  for(int i = 0; i < N; ++i) {
    cout << subs[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 4000
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
 
using namespace std;
 
const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-6;
const double pi = atan2(0, -1);
const int ABC = 26;
 
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 1.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    ll k;
    cin >> k;
    int n = 50;
    ll a[n];
    rep(i, 0, n)
        a[i] = i + k / n;
    k %= n;
    while (k--)
    {
        int p = 0;
        rep(i, 0, n)
            if (a[i] < a[p])
                p = i;
        rep(i, 0, n)
            if (i == p)
                a[i] += n;
            else
                a[i]--;
    }
    cout << n << "\n";
    rep(i, 0, n)
        cout << a[i] << " ";
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll k,now,a[100];int n=50;
void work(){
	int p=1;
	for (int i=1;i<=n;i++) if (a[i]>a[p]) p=i;
	a[p]-=(n+1);
	for (int i=1;i<=n;i++) a[i]++;
}
int main()
{
	scanf("%lld",&k);
	now=(k+49)/50*50;
	for (int i=1;i<=n;i++) a[i]=(k+49)/50+49;
	while (now>k) work(),now--;
	printf("%d\n",n);
	for (int i=1;i<=n;i++) printf("%lld ",a[i]);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int p = 1000000007;
	long long int ans = 0;
	long long int i;
	for (i = k; i <= n + 1; i++)
		ans = (ans + n * (n + 1) / 2 - (n - i + 1) * (n - i) / 2 - i * (i - 1) / 2 + 1) % p;
	printf("%lld\n", ans);
}

Measured memory_bytes: 1736
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;

int main(){
  ll n,m;
  cin >> n >> m;
  str S,T;
  cin >> S;
  cin >> T;

  ll big = n;
  ll small = m;
  if(n < m){
    big = m;
    small = n;
  }

  ll L = big * small;
  erep(i,1,small){
    L = big * i;
    if(L % small == 0) break;
  }

  // vc X(L);
  map<ll, char> X;
  ll j = 0;
  for(ll i=1; i<=L; i+=L/n){
    X[i] = S[j];
    j++;
  }

  j = 0;
  bool flag = true;
  for(ll i=1; i<=L; i+=L/m){
    if(X[i]){
      if(X[i] != T[j]) flag = false;
    }
    j++;
  }

  if(flag) print(L);
  else print(-1);


  return 0;
}


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

int main() {
  vector<vector<int>> vec(3,vector<int>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> vec.at(i).at(j);
    }
  }
  bool exist = true;
  if(vec.at(0).at(0) - vec.at(1).at(0) != vec.at(0).at(1) - vec.at(1).at(1) || vec.at(0).at(1) - vec.at(1).at(1) != vec.at(0).at(2) - vec.at(1).at(2)){
    exist = false;
  }
  if(vec.at(1).at(0) - vec.at(2).at(0) != vec.at(1).at(1) - vec.at(2).at(1) || vec.at(1).at(1) - vec.at(2).at(1) != vec.at(1).at(2) - vec.at(2).at(2)){
    exist = false;
  }
  if(vec.at(0).at(0) - vec.at(2).at(0) != vec.at(0).at(1) - vec.at(2).at(1) || vec.at(0).at(1) - vec.at(2).at(1) != vec.at(0).at(2) - vec.at(2).at(2)){
    exist = false;
  }
  if(vec.at(0).at(0) - vec.at(0).at(1) != vec.at(1).at(0) - vec.at(1).at(1) || vec.at(1).at(0) - vec.at(1).at(1) != vec.at(2).at(0) - vec.at(2).at(1)){
    exist = false;
  }
  if(vec.at(0).at(1) - vec.at(0).at(2) != vec.at(1).at(1) - vec.at(1).at(2) || vec.at(1).at(1) - vec.at(1).at(2) != vec.at(2).at(1) - vec.at(2).at(2)){
    exist = false;
  }
  if(vec.at(0).at(0) - vec.at(0).at(2) != vec.at(1).at(0) - vec.at(1).at(2) || vec.at(1).at(0) - vec.at(1).at(2) != vec.at(2).at(0) - vec.at(2).at(2)){
    exist = false;
  }
  
  if(exist){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
   
}

Measured memory_bytes: 256
int b[5];main(i,s){for(s=i=0;i-5&&scanf("%d",b+i);s|=1<<--b[i++]);if(i=*b<0)return 0;for(s="99909219"[s]-48;printf("%d\n",s-9?b[i]-s?2:1:3)&&++i-5;);main();}

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

const int Ma = 900000000;

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  vector<vector<int>> A(N, vector<int>(M));
  vector<int> C(N);
  rep(i,N){
    cin >> C.at(i);
    rep(j,M){
      cin >> A.at(i).at(j);
    }
  }
  int minC = Ma;
  rep(i,1<<N){
    int total = 0;
    vector<int> XX(M);
    rep(j,N){
      if(i>>j&1){
        total+=C.at(j);
        rep(k,M) XX.at(k) += A.at(j).at(k);
      }
    }
    bool over = true;
    rep(k,M) if(XX.at(k)<X) over = false;
    if(over) minC = min(minC,total);
  }
  if(minC==Ma) cout << "-1" << endl;
  else cout << minC << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
//"3ayz t4of kolo gayeb AC :D"
using namespace std;
const int N = 2e5 + 3;
int n, a[N];
int cntPos(int i, long long val) {
	int lo = i + 1, hi = n - 1, ret = i;
  	while (lo <= hi) {
    	int mid = (lo + hi) / 2;
      	if ((long long) a[i] * a[mid] <= val) {
			ret = mid;
          	lo = mid + 1;
        } else{
        	hi = mid - 1;
        }
    }
	return ret - i;
}
int cntNeg(int i, long long val) {
	int lo = i + 1, hi = n - 1, ret = n;
  	while (lo <= hi) {
    	int mid = (lo + hi) / 2;
      	if ((long long) a[i] * a[mid] <= val) {
			ret = mid;
        	hi = mid - 1;
        } else{
          	lo = mid + 1;
        }
    }
	return n - ret;
}
int main() {
	long long k;
  	cin >> n >> k;
  	for (int i = 0; i < n; ++i)
      	cin >> a[i];
  	sort(a, a + n);
	long long lo = -1e18, hi = 1e18, res = -1; 
	while (lo <= hi) {
		long long mid = (lo + hi) / 2, counter = 0;
		for (int i = 0; i < n; ++i) {
          	if (a[i] > 0)
              counter += cntPos(i, mid);
          	else
            	counter += cntNeg(i, mid);
        }
		if (counter < k) {
			lo = mid + 1;
		} else {
			res = mid;
			hi = mid - 1;
		}
	}
	cout << res << endl;	
	return 0;
}


Measured memory_bytes: 1024
//file_name:ABC53_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;
    int a,z;
    rep(i,s.size()){
        if(s[i]=='A'){
            a = i+1;
            break;
        }
    }
    drep(i,s.size()){
        if(s[i]=='Z'){
            z = i+1;
            break;
        }
    }


    ll ans = z-a+1;

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



Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main(){
	ll n,d;
	cin>>n>>d;
	ll i,j,s=0;
	ll x,y;
	for(i=0;i<n;i++){
		cin>>x>>y;
		if(sqrt(x*x+y*y)<=d)
			s++;
	}
	cout<<s<<endl;
}


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

from collections import Counter
c = Counter()

for ai in A:
    c[ai] += 1

cnt = 0
for k, v in c.items():
    if v >= 2:
        cnt += (v * (v-1))//2

# print(cnt)

for ai in A:
    n = c[ai]
    if n >= 2:
        org = (n * (n-1))//2
        new = ((n-1) * (n-2))//2
        diff = org - new
        r = cnt - diff
        print(r)
    else:
        print(cnt)


Measured memory_bytes: 26140
(defvar *next* '(111 222 333 444 555 666 777 888 999))

(defun main ()
  (let ((n (read))
        (count 0))
    (loop for x in *next*
          do (progn
               (when (> n x)
                 (incf count))))
    (princ (nth count *next*))))

(main)

Measured memory_bytes: 10344
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    String s=in.next();
    String t=in.next();
    int c=0;
    for(int i=0;i<s.length();i++)
    {
      if(s.charAt(i)!=t.charAt(i))
      {
        c++;
      }
    }
    System.out.println(c);
  }
}

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

int main()
{
    int N;
    string S;

    cin >> N >> S;

    int ans = 0;

    for (int i = 0; i < N - 2; i++)
    {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
int main() {
	int n, mini = 1000000000;
	int cnt = 1;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	mini = a.at(0);
	for (int i = 1; i < n; i++) {
		if (mini > a.at(i)) {
			cnt++;
			mini = a.at(i);
		}
	}
	cout << cnt << endl;
	return 0;
	
}

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

int main(void)
{
  unsigned long long N, T;
  cin >> N >> T;
  unsigned long long X = 0;
  unsigned long long tp = 0;
  for (unsigned long long i = 0; i < N; ++i) {
    unsigned long long t, tpn;
    cin >> t;
    tpn = t - tp;
    tp = t;
    if (i == 0) {
      X += T;
    } else if (tpn < T) {
      X += tpn;
    } else {
      X += T;
    }
  }


  cout << X << endl;
  return 0;
}


Measured memory_bytes: 384
A, B, K = map(int,input().split())
for i in range(K):
  A2, B2 = A, B
  if i % 2 == 0:
    if A2 % 2 == 1: A2 -= 1
    B2 += A2 // 2
    A2 = A2 // 2
  else:
    if B2 % 2 == 1: B2 -= 1
    A2 += B2 // 2
    B2 = B2 // 2
  A, B = A2, B2
print(A, B)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
int main(){
  int n,y;cin>>n>>y;
  for(int i=n;i>=0;--i){
    int sum=y;
    int x=10000*i;
    if(sum<x)continue;
    sum-=x;
    for(int j=n;j>=0;--j){
      int sum2=sum;
      x=5000*j;
      if(sum2<x)continue;
      sum2-=x;
      int k=n-i-j;
      if(sum2==1000*k)return cout<<i<<" "<<j<<" "<<k,0;
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1;
}

Measured memory_bytes: 256
mod=998244353
fact=[1]
for i in range(1,2*10**5+1):
  fact.append((fact[-1]*i)%mod)
revfact=[1]
for i in range(1,2*10**5+1):
  revfact.append(pow(fact[i],mod-2,mod))
n,m,k=map(int,input().split())
ans=0
for i in range(k,-1,-1):
  group=n-i
  tmp=fact[n-1]*revfact[group-1]*revfact[n-1-(group-1)]
  tmp%=mod
  tmp*=m
  tmp%=mod
  tmp*=pow(m-1,group-1,mod)
  ans+=tmp
  ans%=mod
print(ans)

Measured memory_bytes: 24848
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a1 = Integer.parseInt(sc.next());
        int a2 = Integer.parseInt(sc.next());
        int a3 = Integer.parseInt(sc.next());

        boolean judge = 22 <= (a1 + a2 + a3);
        if (judge) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }

        sc.close();
    }
}


Measured memory_bytes: 24020
#include <stdio.h>
int main(void)
{
  int k,n,i;
  int b,c;
  int d=0;
  int a[200000];
  scanf("%d",&k);
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  for(i=0;i<n;i++){
    if(i==n-1){
      b=k-a[n-1]+a[0];
    }
    else{
      b=a[i+1]-a[i];
    }
    c+=b;
      if(b>d)
        d=b;
  }
  printf("%d",c-d);
  return 0;
}


Measured memory_bytes: 2516
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
vector<int> g[100005];
int deg[100005]={0},dp[100005]={0};
queue<int> que;
int main(){
	int i,n,m,from,to;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&from,&to);
		g[from].emplace_back(to);
		deg[to]++;
	}
	for(i=1;i<=n;i++)
		if(!deg[i])
			que.push(i);
	while(que.size()){
		int v=que.front();
		que.pop();
		for(auto x:g[v]){
			dp[x]=max(dp[x],dp[v]+1);
			deg[x]--;
			if(!deg[x])
				que.push(x);
		}
	}
	printf("%d\n",*max_element(dp+1,dp+1+n));
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

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

    if(n%2==1)
    {
        cout<<0<<endl;
        return 0;
    }

    ll ans=0,tmp=5;
    while(n>tmp)
    {
        ans+=n/(tmp*2);
        tmp*=5;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

// Fenwick Tree (Binary Indexed Tree)
#ifdef _MSC_VER
#pragma warning(disable:4146)
#endif
template<class T>
class fenwick
{
    std::vector<T> a;
    static size_t msb(size_t v)
    {
        for(size_t i=1; i<sizeof(size_t)*8; i<<=1) v |= v>>i;
        return (v>>1)+1;
    }
public:
    explicit fenwick(size_t N):a(N+1,0){}
    void add(size_t i, T v)
    {
        const size_t N = a.size()-1;
        for(size_t x=i+1; x<=N; x+=x&-x) a[x]+=v;
    }
    T sum(size_t i)
    {
        T t=0;
        for(size_t x=i; x>0; x-=x&-x) t+=a[x];
        return t;
    }
    T sum(size_t i, size_t j){ return sum(j)-sum(i); }
    size_t lower_bound(T v)
    {
        if(v<=0) return 0;
        const size_t N = a.size()-1;
        size_t i=0;
        for(size_t k=msb(N); k>0; k>>=1)
            if (i+k<=N && v>a[i+k])
            {
                v -= a[i+k];
                i += k;
            }
        return i;
    }
};

int main() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    for(int N,M; std::cin >> N >> M; ) {
        std::vector<std::vector<std::pair<int,int>>> lr(M+1);
        for(int i=0; i<N; ++i) {
            int l,r; std::cin >> l >> r;
            lr[r-l+1].emplace_back(l,r);
        }
        auto n=N;
        fenwick<int> m(M+2);
        for(int d=1; d<=M; ++d) {
            for(const auto&v:lr[d]) {
                m.add(v.first,1);
                m.add(v.second+1,-1);
                --n;
            }
            int c=n;
            for(auto i=d; i<=M; i+=d) c+=m.sum(i+1);
            std::cout << c << "\n";
        }
    }
}

Measured memory_bytes: 8064