akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<ctype.h>
#include<cstdio>
using namespace std;
main(){
  int x,y;
  int c,d,p;
  cin>>x>>y>>c>>d>>p;
  x=x*p;
  if(c<p){
    y=y+(p-c)*d;
  }
  if(x<y){
    cout<<x<<endl;
    }
  else{
    cout<<y<<endl;
  }
}

Measured memory_bytes: 1160
N, M = map(int, input().split())
I = []
for _ in range(M):
    I.append(list(map(int, input().split())))

u = 0
o = 10 ** 9
for i in range(M):
    u = max(u, I[i][0])
    o = min(o, I[i][1])

if u > o:
    print(0)
else:
    print(o-u+1)

Measured memory_bytes: 27096
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll A, B, C, X; cin >> A >> B >> C >> X;
	ll cnt = 0;
	repe(i, 0, A) {
		repe(j, 0, B) {
			repe(k, 0, C) {
				if (X == i * 500 + j * 100 + k * 50) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
import numpy as np

N, M, X = list(map(int, input().split()))
a = np.zeros((N, M))
C = np.zeros(N)
for i in range(N):
    tmp = list(map(int, input().split()))
    C[i] += tmp[0]
    a[i] += tmp[1:]
    
answer_price = 10**10

for i in range(1 << N):
    tmp = np.zeros(M)
    cost = 0
    for j in range(N):
        if i % 2 == 1:
            tmp += a[j]
            cost += C[j]
        i = i >> 1

    if all(tmp >= X) and (cost < answer_price):
        answer_price = cost
        
if answer_price == 10**10:
    print("-1")
else:
    print(int(answer_price))

Measured memory_bytes: 27076
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vll a(3*n);
    rep(i, 3*n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    for (int i = n; i < 3*n; i += 2) {
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int res = (m * 1900 + (n - m) * 100) * (1 << m);
        System.out.println(res);
    }
}

Measured memory_bytes: 23252
#include<iostream>
using namespace std;
int main(){ 

  int a,b,c;

  cin>>a>>b>>c;
  int t;

  if(a>b){
    t=a;
    a=b;
    b=t;
  }
  if(b>c){
    t=b;
    b=c;
    c=t;
  }
  if(a>b){
    t=a;
    a=b;
    b=t;
  }

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


  return 0;
}

Measured memory_bytes: 3084
a=int(input())
if a==1:
    print(4)
    exit()
elif a==4:
    print(4)
    exit()
elif a==2:
    print(4)
    exit()

ans=1
while True:
    if a==4:
        break
    elif a%2==0:
        a=a/2
        ans+=1
    else:
        a=3*a+1
        ans+=1

print(ans+3)

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

int N, K;
vector<int> d;
vector<vector<int>> A;

void input(){
	cin >> N >> K;

	d.resize(K);
	A.resize(K, vector<int>());
	for(int i = 0; i < K; i++){
		cin >> d.at(i);
		A[i].resize(d[i]);
		for(int j = 0; j < d[i]; j++){
			cin >> A[i][j];
		}
	}
}

void solve(){
	int ans = 0;
	for(int i = 1; i <= N; i++){
		bool have = false;
		for(auto v : A){
			for(auto p : v){
				if(p == i) have = true;
			}
		}
		if(!have) ans++;
	}

	cout << ans << endl;
}

int main(){
	input();
	solve();
}

Measured memory_bytes: 3580
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

var (
	MAX      = 500000
	SENTINEL = 2000000000
	cnt      = 0
	L, R     = make([]int, MAX+2), make([]int, MAX+2)
)

func main() {
	fmt.Println(answer(os.Stdin))
}

func answer(r io.Reader) string {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	A := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
	}

	mergeSort(A, n, 0, n)

	result := strings.TrimRight(fmt.Sprintf("%+v", A)[1:], "]") + "\n"
	return result + strconv.Itoa(cnt)
}

func merge(A []int, n, left, mid, right int) {
	n1 := mid - left
	n2 := right - mid
	for i := 0; i < n1; i++ {
		L[i] = A[left+i]
	}
	for i := 0; i < n2; i++ {
		R[i] = A[mid+i]
	}
	L[n1], R[n2] = SENTINEL, SENTINEL

	i, j := 0, 0
	for k := left; k < right; k++ {
		cnt++
		if L[i] <= R[j] {
			A[k] = L[i]
			i++
			continue
		}
		A[k] = R[j]
		j++
	}
}

func mergeSort(A []int, n, left, right int) {
	if left+1 < right {
		mid := (left + right) / 2
		mergeSort(A, n, left, mid)
		mergeSort(A, n, mid, right)
		merge(A, n, left, mid, right)
	}
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    map<ll, ll> m, n;
    ll count = 0;
    rep(i, N) {
        ll temp;
        cin >> temp;
        m[i + 1 + temp]++;
        n[i + 1 - temp]++;
    }
    iter(i, m) count += n[i.first] * i.second;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 37908
n = int(input())
c = [0]*n
s = [0]*n
f = [0]*n
for i in range(1,n):
  c[i],s[i],f[i] = map(int,input().split())
for i in range(1,n+1):
  t = 0
  for j in range(i,n):
    t = max(s[j],((t+f[j]-1)//f[j])*f[j])+c[j]
  print(t)

Measured memory_bytes: 3064
n, m = map(int, input().split())
s = []
c = []
for _ in range(m):
    si, ci = map(int, input().split())
    s.append(si)
    c.append(ci)

if n == 1:
    nlist = [str(i) for i in range(10)]
elif n == 2:
    nlist = [str(i) for i in range(10, 100)]
elif n == 3:
    nlist = [str(i) for i in range(100, 1000)]

for sn in nlist:
    is_ok = True
    for si, ci in zip(s, c):
        if si > n:
            is_ok = False
            break
        if int(sn[si-1]) == ci:
            pass
        else:
            is_ok = False
            break
    if is_ok:
        print(int(sn))
        exit(0)
print(-1)

Measured memory_bytes: 38384
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let s = sc.chars();
    let white = s.iter().filter(|&&c| c == '.').count();
    let black = n - white;

    let mut left_black = 0;
    let mut ans = cmp::min(black, white);
    for i in 0..n {
        if s[i] == '#' {
            left_black += 1;
        }
        let left_white = (i + 1) - left_black;
        let right_white = white - left_white;
        let cost = left_black + right_white;
        ans = cmp::min(cost, ans);
    }

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

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int  main()
{
	string s; cin >> s;
	string key = "keyence";
	int j = 0;
	string ans;
	rep(i, s.size())
	{
		if(s[i] == key[j])
		{
			ans.push_back(s[i]);
			j++;
		}
		else
		{
			int r = s.size() - (key.size() - ans.size());
			ans += s.substr(r, (key.size() - ans.size()));
			break;
		}
	}
	if (ans == key)
		cout << "YES\n";
	else
		cout << "NO\n";
	return (0);
}


Measured memory_bytes: 384
char s[1<<18];i,a[9],A;main(k){for(scanf("%*d%d%d%d%d%s",&k,a+7,a+4,a+6,s);i<1e5;A+=a[s[i++]%9])s[i+k]*=s[i]!=s[i+k];printf("%d",A);}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int a,b,c,d,x;
	cin>>a>>b>>c>>d;
	x:
	c=c-b;
	if (c<=0)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	a=a-d;
	if (a<=0)
	{
		cout<<"No"<<endl;
		return 0;
	}
	goto x;
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<queue>
#include<climits>
#include<map>
#include<sstream>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<string, int>
const int INF = INT_MAX / 2;

int main(){
  queue<P> open;
  open.push( P("01234567", 0) );
  map<string, int> closed;

  while(!open.empty()){
    int step = open.front().second;
    string str = open.front().first;
    open.pop();

    if(closed.find(str) != closed.end() && closed[str] <= step) continue;
    closed[str] = step;

    int zero;
    REP(i, str.size()) if(str[i] == '0') zero = i;
    int mv[] = {1, -1, 4, -4};

    REP(i, 4){
      if(zero + mv[i] >= str.size()
        || zero + mv[i] < 0
        || (zero == 3 && zero + mv[i] == 4)
        || (zero == 4 && zero + mv[i] == 3)) continue;

      swap(str[zero], str[zero + mv[i]]);
      open.push( P(str, step + 1) );
      swap(str[zero], str[zero + mv[i]]);
    }
  }
  while(true){
    string fir_inp, inp = "";
    if(!getline(cin, fir_inp)) break;
    stringstream ss(fir_inp);
    while(ss >>fir_inp) inp += fir_inp;
    cout <<closed[inp] <<endl;
  }
  return 0;
}

Measured memory_bytes: 3536
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		Arrays.setAll(h, i -> sc.nextInt());
		
		long[] dp = new long[n];
		dp[0] = 0;
		for (int i = 1; i < n; i++) {
			dp[i] = dp[i - 1] + Math.abs(h[i - 1] - h[i]);
			for (int j = 2; j <= k; j++) {
				if (i - j < 0) break;
				dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i - j] - h[i]));
			}
		}
		
		System.out.println(dp[n - 1]);
		
		sc.close();
	}
}



Measured memory_bytes: 51336
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;

int main(void) {
	int n;
	long long int total;
	long long int p = 0, q = 0;

	cin >> n;
	vector<int>a(n);
	FOR(i, 0, n-1) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	RFOR(i, n - 1, 1) {
		if (q != 0) {
			break;
		}
		if (a[i] == a[i - 1]) {
			if (p == 0) {
				p = a[i];
			}
			else {
				q = a[i];
			}
			i--;
		}
	}
	cout << p*q << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

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

	int h, w, a, b;
	cin >> h >> w >> a >> b;

	vector<string> ans(h, string(w,'-'));

	rep(i,0,h) rep(j,0,w)
		ans[i][j] = '0' + ((i<b)^(j<a));
	
	trav(s, ans) cout << s << endl;
}


Measured memory_bytes: 2304
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

char S[11];

bool C(char c) { return c == 'A' || c == 'C' || c == 'G' || c == 'T'; }

int main(void)
{
  cin >> S;
  int ans = 0;
  int cnt = 0;
  for (int i = 0; S[i] != '\0'; i++) {
    if (C(S[i]))
      cnt++;
    else
      cnt = 0;
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,s=0,b=1e6,a,i;
  scanf("%d",&n);
  for(i=1;i<n;i++){
    scanf("%d",&a);
    s+=MIN(a,b);
    b=a;
  }
  printf("%d\n",s+a);
  return 0;
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	for (int n, p; cin >> n >> p&&n;) {
		vector<int> a(n, 0);
		int owan = p;
		for (int i = 0;; (++i) %= n) {
			if (owan) {
				a[i]++;
				owan--;
				if (owan == 0 && a[i] == p) {
					cout << i << endl;
					break;
				}
			}
			else {
				owan = a[i];
				a[i] = 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2972
n=int(input())

def make_eratosthenes(n):
    A=[0]*(n+1)
    A[0],A[1]=-1,-1 #0と1は対象外
    for i in range(2,n+1):
        if A[i]==0:
            j=i
            while j<n:
                A[j]=i
                j+=i
    return A
E=make_eratosthenes(2000)
P=[]

for i in range(2001):
    if E[i]==i and i%5==1:
        P.append(i)
Ans=[]
for i in range(n):
    Ans.append(P[i])
print(*Ans,sep=" ")

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

int N, K;
vector<long long> x;

int main() {
    cin >> N >> K;
    x.resize(N); for (int i = 0; i < N; ++i) cin >> x[i];
    long long res = 1LL<<60;
    for (int i = 0; i + K - 1 < N; ++i) {
        long long left = x[i], right = x[i + K - 1];
        res = min(res, min(abs(left), abs(right)) + right - left);
    }
    cout << res << endl;
}





























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

string S;

int main()
{
    cin >> S;
    for(int i = 0; i < S.size(); i++)
    {
        if(i == 5 || i == 13)printf(" ");
        else printf("%c",S[i]);
    }printf("\n");
    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for a in range(0, A + 1):
    if X < 500 * a:
        break
    for b in range(0, B + 1):
        if X < 500 * a + 100 * b:
            break
        c = (X - 500 * a - 100 * b) / 50
        if c <= C:
            ans += 1
        b += 1
    a += 1
    
print(ans)  

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
 int N, A, B;
 cin >> N;
 if(N ==1){
  cout << "Hello World" << endl;
 }else if(N == 2){
  cin >> A >> B;
  cout << A + B << endl;
 }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define foreach(a,A) for(auto &a:A)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll k; cin >> k;
    string S; cin >> S;
    if(S.size() <= k){
        cout << S << endl;
    } else {
        string T = S.substr(0, k);
        rep(_, 3) T.push_back('.');
        cout << T << endl;
    }
}

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

int main() {
string n;
cin >> n;
if(n[0] != '7' && n[1] != '7' && n[2] != '7'){
  cout << "No" << endl;
}
else{
  cout << "Yes" << endl;
}


}

Measured memory_bytes: 3624
#include<stdio.h>
int main(void){
  int N,i,j,num[36],mini=0,temp=0,s[36],n,te=0,stable=0,c_num[36],c_s[36];
  char ma[36],T,c_ma[36];
  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf(" %c%d",&ma[i],&num[i]);
  }
  for(n = 0 ; n < N ; n++){
    s[n] = n;
  }
  for(i = 0 ; i < N ; i++){
    c_num[i] = num[i];
    c_s[i] = s[i];
    c_ma[i] = ma[i];
  }
  /*BubbleSort*/
  for(i = 0 ; i < N ; i++){
    for(j = N-1 ; j > i ; j--){
      if(num[j] < num[j-1]){
	temp = num[j];
	T = ma[j];
	te = s[j];
	num[j] = num[j-1];
	ma[j] = ma[j-1];
	s[j] = s[j-1];
	num[j-1] = temp;
	ma[j-1] = T;
	s[j-1] = te;
      }
    }
  }
  for(i = 0 ; i < N ; i++){
    printf("%c%d",ma[i],num[i]);
    if(i < N-1){
      printf(" ");
      if(num[i] == num[i+1]){
	if(s[i] > s[i+1]){
	  stable = 1;
	}
      } 
    }
    else printf("\n");
  }
  if(stable == 1){
    printf("Not stable\n");
  } else {
    printf("Stable\n");
  }
  stable = 0;
  
  /*SelectionSort*/
  for(i = 0 ; i < N ; i++){
    mini = i;
    for(j = i+1 ; j < N ; j++){
      if(c_num[j] < c_num[mini]){
	mini = j;
      }
    }
    temp = c_num[i];
    T = c_ma[i];
    te = c_s[i];

    c_num[i] = c_num[mini];
    c_ma[i] = c_ma[mini];
    c_s[i] = c_s[mini];

    c_num[mini] = temp;
    c_ma[mini] = T;
    c_s[mini] = te;
  }
  for(i = 0 ; i < N ; i++){
    printf("%c%d",c_ma[i],c_num[i]);
    if(i < N-1){
      printf(" ");
      if(c_num[i] == c_num[i+1]){
	if(c_s[i] > c_s[i+1]){
	  stable = 1;
	}
      } 
    }
    else printf("\n");
  }
  if(stable == 1){
    printf("Not stable\n");
  } else {
    printf("Stable\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int check(int n,int m) {
    int x=n*m;
    while (x>n)x=(m*(x-n)-1)/(m-1);
    return x;
}
int main(void){
    int n,m;
    while(1){
        cin>>n>>m;
        if(n==0&&m==0)break;
        cout<<check(n,m)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
from collections import Counter
h, w, *s = open(0).read().split()
h = int(h)
w = int(w)

s = Counter(''.join(s))

odd = 0
two = 0
four = 0
for k, v in s.items():
    four += v // 4
    v %= 4
    if v % 2 == 0:
        two += v // 2
    else:
        odd += 1
if h % 2 == 1 and w % 2 == 1:
    if odd == 1 and two <= h // 2 + w // 2:
        print('Yes')
    else:
        print('No')
elif h % 2 == 1:
    if odd == 0 and two <= w // 2:
        print('Yes')
    else:
        print('No')
elif w % 2 == 1:
    if odd == 0 and two <= h // 2:
        print('Yes')
    else:
        print('No')
else:
    if odd == 0 and two == 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 9536
#include <cstdio>
#include <vector>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 999999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool shortestPath(const Graph g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -2);
  bool negative_cycle = false;
  REP(k, n) REP(i, n) if(dist[i]<INF) FOR(e,g[i]) {
    if (dist[e->dst] > dist[e->src] + e->weight) {
      dist[e->dst] = dist[e->src] + e->weight;
      prev[e->dst] = e->src;
      if (k == n-1) {
        dist[e->dst] = -INF;
        negative_cycle = true;
      }
    }
  }
  return !negative_cycle;
}

int main(){
	int r,T,V,E,s,t,e,i;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d%d%d",&V,&E,&r);
		Graph g(V);
		vector<Weight> dist;
		vector<int> prev;
		for(;E--;)scanf("%d%d%d",&s,&t,&e),g[s].push_back(Edge(s,t,e));
		if(!shortestPath(g,r,dist,prev))puts("NEGATIVE CYCLE");
		else for(i=0;i<V;i++){
			if(dist[i]>=INF)puts("INF");
			else printf("%d\n",dist[i]);
		}
	//}
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

struct edge{ll to, cost;}; //edgeパラメータ
typedef pair<ll,ll> P;
struct graph{
  ll N; //ノードの個数
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> d; // dist[n] = ノードnまでのの重み長さ
  ll repeat; // 何回更新したか

  graph(ll n){ //グラフ生成時
    N = n;
    G.resize(N); //Edge情報
    d.resize(N); //Node情報,ans
    rep(i,N){d[i] = INF;}
  }

  void add_edge(ll s, ll t, ll cost){
    G[s].emplace_back((edge){t, cost});
  }

  bool bellman_ford(ll s){
    d[s] = 0;
    repeat=0;

    while(true) {
      bool update = false;
      ++repeat;
      rep(v, N) {
        if(d[v] == INF) continue;
        rep(i, G[v].size()){
          edge& E = G[v][i];
          if( d[E.to] > d[v] + E.cost) {
            d[E.to] = d[v] + E.cost;
            //cout<< i<< E.to<<E.cost<<d[i]<<"\n";
            if(E.to==N-1) update = true;
          }
        }
      }
      if(repeat>=N and update) return false;
      if(repeat>2*N) return true;
    }
  }
};


void Main(){

  ll n,M;

  cin>>n>>M;

  graph g(n);

  rep(i,M){
    ll a,b,c;
    cin>>a>>b>>c;
    g.add_edge(a-1,b-1,-c);
  }

  if(g.bellman_ford(0)){
    cout<< -g.d[n-1]<<"\n";
  }
  else{
    cout<< "inf"<<"\n";
  }



}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int N=110;

int n,m,a[N],b[N];

int main(){
  scanf("%d%d",&n,&m);
  int iodd=0;
  for(int i=1;i<=m;i++)
    scanf("%d",&a[i]),iodd+=(a[i]&1);
  if(m==1){
    if(a[1]==1) printf("%d\n1\n%d\n",1,1);
    else printf("%d\n2\n%d %d\n",a[1],a[1]-1,1);
    return 0;
  }
  if(iodd>2) puts("Impossible");
  else{
    for(int i=2;i<=m;i++)
      if(a[i]&1) (a[1]&1)?swap(a[m],a[i]):swap(a[1],a[i]);
    int t=0; if(a[1]>1) b[++t]=a[1]-1;
    for(int i=2;i<m;i++) b[++t]=a[i];
    b[++t]=a[m]+1;
    for(int i=1;i<=m;i++) printf("%d ",a[i]); putchar('\n');
    printf("%d\n",t);
    for(int i=1;i<=t;i++) printf("%d ",b[i]);
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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





















int main(){
    ll n;
    cin >> n;
    vector<ll> x(n), y(n);
    vector<pair<double, ll>> r(n);
    REP(i, n){
        cin >> x[i] >> y[i];
        double res = atan2(y[i], x[i]);
        r[i] = {res, i};
    }
    sort(r.begin(), r.end());
    long double ans = 0.0;
    REP(i, n){
        REP(j, n){
            ll sx = 0, sy = 0;
            if(i <= j){
                for(ll k = i; k <= j; k++){
                    sx += x[r[k].second];
                    sy += y[r[k].second];
                }
            }
            else{
                for(ll k = i; k <= j + n; k++){
                    sx += x[r[k % n].second];
                    sy += y[r[k % n].second];
                }
            }
            ans = max(ans, sqrt((long double)(sx * sx + sy * sy)));
        }
    }
    printf("%.12Lf\n", ans);
}

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

using namespace std;

int main(void){

    string s;
    cin >> s;

    if(stoi(s.substr(0, 4)) < 2020 && stoi(s.substr(5, 2)) < 5 && stoi(s.substr(8, 2)) < 31){
        cout << "Heisei";
    } else {
        cout << "TBD";
    }

    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        // 整数r, g, bの入力
        string[] input = Console.ReadLine().Split(' ');
        string rgb = input[0] + input[1] + input[2];
        int number = int.Parse(rgb);

        if ( (number % 4) == 0 )
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	long long int N, M;
	cin >>N>> M;
	vector<pair<int, int>> s;
	vector<pair<int, int>> c;
	int numbers[100030] = {};
	for (long long int i = 0; i < M; i++) {
		pair<int, int> key;
		int a, b;
		cin >> a >> b;
		key.first = a;
		key.second = b;
		s.push_back(key);
		c.push_back(key);
	}
	sort(s.begin(), s.end());
	map<int, string>t;
	for (long long int i = 0; i < M; i++) {
		pair<int, int> key;
		int a, b,c;
		key = s[i];
		a = key.first;
		c = key.second;
		string d = to_string(a);
		b = numbers[a] + 1;
		numbers[a]++;
		string f = to_string(b);
		string e1 = "000000";
		string e2 = "000000";
		int w = 0;
		for (int g = d.size()-1; g  >= 0; g--) {
			e1[5-w] = d[g];
			w = w + 1;
		}
		w = 0;
		for (int g = f.size()-1; g >= 0; g--) {
			e2[5-w] = f[g];
			w = w + 1;
		}
		string k = e1 + e2;
		t[c] = k;
	}
	for (int i = 0; i < M; i++) {
		pair<int, int>key;
		key = c[i];
		cout << t[key.second] << endl;
	}
}

Measured memory_bytes: 14444
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  ll n;
  ll ans=0;
  cin>>n;
  ll i=1;
  while(1){
    if((n-i)<=i*i) break;
    if((n-i)%i==0){ans+=(n-i)/i;}
    
    i++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;

int dig(int v) {
  int d = 0;
  while (v > 0) {
    d |= 1 << (v % 10);
    v /= 10;
  }
  return d;
}

int main(void){
  int n, k;
  cin >> n >> k;
  int d = 0;
  REP(i, 0, k) {
    int t; cin >> t;
    d |= 1 << t;
  }
  REP(i, n, 10 * n) {
    if ((dig(i) & d) == 0) {
      cout << i << endl;
      return 0;
    }
  }
  assert (0);
}


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

typedef long long ll;


#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18

struct Edge{
    int from,to,cost;
};

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

    int p = 20;
    while(L<(1<<p)){
        p--;
    }

    int N = p+1;

    vector<Edge> ans;
    FOR(i,1,p+1){
        ans.push_back({i, i+1,0});
        ans.push_back({i, i+1, (1<<(i-1))});
    }

    while(p>0){
        if(L-(1<<(p-1)) >= (1<<(N-1)) ){
            L -= (1<<(p-1));
            ans.push_back({p, N, L});
        }
        p--;

    }

    cout << N << " " << ans.size() << endl;



    for(auto x: ans){
        cout << x.from << " " << x.to << " " << x.cost << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vvi cnt(10,vi(10,0));
	int num=1;
	for(int i=1;i<=n;++i){
		if(10*num<=i) num*=10;
		cnt[i%10][i/num]++;
	}
	
	llong ans=0;
	for(int i=1;i<=9;++i)for(int j=1;j<=9;++j){
		ans+=(llong)cnt[i][j]*cnt[j][i];
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  F
//
//  Created by 曾憲揚 on 2020/8/8.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

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

const int N = 5e5 + 5; //N = Q

int n, q;
int c[N];

struct query{
    int l, r, id;
};
query que[N];
bool cmp(query qa, query qb){
    return qa.r < qb.r;
}


int fenwick[N];
int lowbit(int x){
    return x & (-x);
}
void init(){
    for(int x=1; x<=n; x++){
        fenwick[x] = c[x];
        int y = x-lowbit(x);
        for(int i=x-1; i>y; i-=lowbit(i))
            fenwick[x] += fenwick[i];
    }
}
void add(int val, int x){ //add val
    for(int i=x; i<=n; i+=lowbit(i)){
        fenwick[i] += val;
    }
}
int sum(int x){
    int s = 0;
    for(int i=x; i>0; i-=lowbit(i)){
        s += fenwick[i];
    }
    return s;
}

int book[N];
int ans[N];  //offline queries sadly

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    cin >> n >> q;
    
    for(int i=1; i<=n; i++){
        cin >> c[i];
    }
    for(int i=0; i<q; i++){
        int l, r; cin >> l >> r;
        que[i] = (query){l, r, i};
    }
    sort(que, que+q, cmp);
    
    
    int start = 1;
    for(int i=0; i<q; i++){
        for(int j=start; j<=que[i].r; j++){
            if(book[c[j]]) add(-1, book[c[j]]);
            add(1, j); book[c[j]] = j;
        }
        start = que[i].r+1;
        ans[que[i].id] = sum(que[i].r) - sum(que[i].l-1);
    }
    for(int i=0; i<q; i++){
        cout << ans[i] << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 17436
N, M = map(int, input().split())
H = list(map(int, input().split()))

ans = [1]*N
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] <= H[b-1]:
        ans[a-1] = 0
    if H[a-1] >= H[b-1]:
        ans[b-1] = 0
    
print(ans.count(1))

Measured memory_bytes: 20112
N = int(input())
H_list = [int(x) for x in input().split()]
result = None
elem_max = H_list[0]
for i in range(1, N):
  if H_list[i] > elem_max:
    elem_max = H_list[i]
  else:
    if elem_max - H_list[i] > 1:
      print('No')
      result = 'No'
      break
if result is None:
	print('Yes')

Measured memory_bytes: 14224
def g(a,b):x=max([a,b]);y=min([a,b]);return g(y,x%y) if x%y else y
N,X=map(int,input().split());p=[abs(int(i)-X) for i in input().split()];ans=p[0]
for i in range(1,N):ans=g(ans,p[i])
print(ans)

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = (1 << 18) + 5;

int v[MAXN];
int dp[MAXN][2];

vi cur;

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, 1 << n) {
		scanf("%d", &v[i]);
		dp[i][0] = dp[i][1] = -1;
	}
	dp[0][0] = 0;
	int last = 0;
	REP(i, 1, 1 << n) {
		cur.clear();
		REP(j, 0, n) {
			if (i & (1 << j)) {
				int i1 = i ^ (1 << j);
				REP(k, 0, 2){
					if (dp[i1][k] != -1) {
						cur.pb(dp[i1][k]);
					}
				}
			}
		}
		cur.pb(i);
		REP(k, 0, 2) {
			int maxi = -1;
			REP(j, 0, SZ(cur)) {
				if ((maxi == -1 || v[cur[j]] > v[maxi]) && cur[j] != dp[i][0]) {
					maxi = cur[j];
				}
			}
			dp[i][k] = maxi;
		}
		//printf("%d %d %d\n", i, dp[i][0], dp[i][1]);
		last = max(last, v[dp[i][0]] + v[dp[i][1]]);
		printf("%d\n", last);
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 6144
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
	long N, i, j, k, count1 = 0, cnt1 = 0;
	char C[300000];
	scanf("%d", &N);
	scanf("%s", &C);
	for (i = 0; i < N; i++) {
		if (C[i] == 'W') {
			count1++;
		}
		else {
			if (count1 > 0) {
				count1--;
				cnt1++;
			}
		}
	}
	printf("%ld",cnt1);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MAXN=60;
int n,ans,a[MAXN];
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		for (int j=1;j<i;j++) {
			ans+=a[j]*a[i];
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>

using namespace std;

int main(){
	int ih,im,is;
	int oh,om,os;
	int ah,am,as;

	for(int i=0;i<3;++i){
		scanf("%d %d %d %d %d %d",&ih,&im,&is,&oh,&om,&os);
		ah = oh-ih;
		if(om-im < 0){
			am = 60-abs(om-im);
			ah--;
		}
		else{
			am = om-im;
		}
		if(os-is < 0){
			as = 60-abs(os-is);
			if(am-1 < 0){
				am = 59;
				ah--;
			}
			else{
				am--;
			}
		}
		else{
			as = os-is;
		}

		printf("%d %d %d\n",ah,am,as);
	}
	return 0;
}

Measured memory_bytes: 1028
import sys
import io


def run(input: io.TextIOBase, output: io.TextIOBase):
    l = input.readline().split()
    a = int(l[0])
    b = int(l[1])

    count = 0

    def is_anagram(x: int):
        x_str = str(x)
        for i in range(0, len(x_str)//2):
            if x_str[i] != x_str[-i-1]:
                return False
        return True

    for x in range(a, b + 1):
        if is_anagram(x):
            count += 1
    output.write(str(count) + '\n')


if __name__ == '__main__':
    run(sys.stdin, sys.stdout)


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int n,q,i,j,count=0,true_count=0;
  scanf("%d",&n);
  int A[n+1];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  int B[q+1];
  for(i=0;i<q;i++){
    scanf("%d",&B[i]);
  }
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(A[j]==B[i]) count++;
    }
    if(count>=1) true_count++;  
    count=0;
  }
  printf("%d\n",true_count);
  return 0;
}




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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


using namespace std;



int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

   ll n,d;
   cin>>n>>d;

   ll x,y;

   ll cnt=0;

   while(n--)
   {
   	 cin>>x>>y;

   	 // y = abs(y);
   	 // x = abs(x);

   	 long double dis = sqrt((y*y + x*x));

   	 if(dis <= d)
   	 {
   	 	cnt++;
   	 }
   }
  

  cout<<cnt<<endl;

}

Measured memory_bytes: 3676
n = int(input())
h = list(map(int, input().split()))

a = [0 for _ in range(n)]
a[1] = abs(h[1] - h[0])

for i in range(2,n):
    a[i] = min(a[i-1]+abs(h[i]-h[i-1]), a[i-2]+abs(h[i]-h[i-2]))
    
print(a[-1])

Measured memory_bytes: 13908
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

struct mint {
	typedef long long ll;
	ll x, m;
	mint(ll x=0, ll m=1e9+7): x(x%m), m(m) {}
	mint operator-() const { return mint(m-x, m); }
	mint operator+(const mint o) const { return mint(x+o.x, m); }
	mint operator-(const mint o) const { return mint(x-o.x+m, m); }
	mint operator*(const mint o) const { return mint(x*o.x, m); }
	mint& operator+=(const mint o) { x = (x+o.x)%m; return *this; }
	mint& operator-=(const mint o) { x = (x-o.x+m)%m; return *this; }
	mint& operator*=(const mint o) { x = x*o.x%m; return *this; }
	bool operator==(const mint o) const { return x==o.x; }
	bool operator!=(const mint o) const { return x!=o.x; }
	template<typename T> mint& operator=(const T o) { x = o%m; return *this; }
	template<typename T> mint operator+(const T o) const { return mint(x+o, m); }
	template<typename T> mint operator-(const T o) const { return mint(x-((ll)o)%m+m, m); }
	template<typename T> mint operator*(const T o) const { return mint(x*o, m); }
	template<typename T> mint& operator+=(const T o) { x = (x+(ll)o%m)%m; return *this; }
	template<typename T> mint& operator-=(const T o) { x = (x-((ll)o)%m+m)%m; return *this; }
	template<typename T> mint& operator*=(const T o) { x = x*((ll)o%m)%m; return *this; }
	template<typename T> bool operator==(const T o) const { return x==o%m; }
	template<typename T> bool operator!=(const T o) const { return x!=o%m; }

	mint pow(ll k) const {
		if(k==0) return mint(1, m);
		if(k%2) return pow(k-1)*x;
		mint z = pow(k/2);
		return z*z;
	}

	mint inv() const { return pow(m-2); }
};

int _main(){
	for(auto x: std::vector<int>{3, 5, 7, 11, 13, 17, 19}){
		assert((mint(4, x)*mint(4, x).inv())==1);
	}
	return 0;
}

int main(){
	int N;
	ll K;
	cin >> N >> K;

	if(K>=N){
		mint ans(1);
		for(int i=0; i<N; i++) ans *= mint(i+1).inv() * (2*N-1-i);
		cout << ans.x << endl;
		return 0;
	}

	vector<mint> fact(1000000);
	fact[0] = mint(1);
	for(int i=1; i<1000000; i++) fact[i] = fact[i-1]*i;
	mint ans(0);

	for(int j=0; j<=K; j++){
		ans += fact[N]*fact[j].inv()*fact[N-j].inv() * fact[N-1]*fact[j].inv()*fact[N-1-j].inv();
		debug(fact[1].x, fact[100].x, ans.x);
	}

	cout << ans.x << endl;

	return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
 int64_t func (int x){
   int64_t sum=1;
   for(int i=1;i<=x;i++){
     sum*=i;
     sum%=1000000007;
   }
   return sum;
 }
int main() {
  int N;
  string S;
  cin>>N>>S;
  int sumw=0,sume=0;
  for(int i=0;i<N;i++){
    if(S[i]=='W'){sumw++;}
    else{sume++;}
  }
  int wL=0,eL=0;
  int ans=1000005;
  for(int i=0;i<N;i++){
    if(S[i]=='E'){eL++;}
    int tot=sume-eL+wL;
    ans=min(ans,tot);
    if(S[i]=='W'){wL++;}
    
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3904
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
	int n,id,i,f,k,a,b,jun[4001],ch[4001],da[4001];
	while (cin >> n) {
		if (n==0) break;
		memset(da,0,sizeof(da));
		memset(ch,0,sizeof(ch));
		k=0;
		for (i=0;i<n;i++) {
			cin >> id >> a >> b;
			if (ch[id]==0) { ch[id]=1; jun[k++]=id; }
			if ((a/100)*(b/100)>100 || da[id]+a*b>999999) da[id]=1000000; else da[id]+=a*b; 
		}
    f=0;
	for (i=0;i<k;i++) if (da[jun[i]]>999999) { cout << jun[i] << endl; f=1; }
	if (f==0) cout << "NA" << endl;
	}
	return 0;
	}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
int H, W;
vector<string> S;
vector<vector<bool>> B;
long long black = 0, white = 0;
bool posok(int i, int j) {
    return 0 <= i && i < H && 0 <= j && j < W;
}
void recur(int i, int j, int c)
{
    (c ? black : white) += 1;
    B[i][j] = true;
    if (posok(i-1, j) && S[i-1][j] == ".#"[c] && !B[i-1][j]) recur(i-1, j, !c);
    if (posok(i+1, j) && S[i+1][j] == ".#"[c] && !B[i+1][j]) recur(i+1, j, !c);
    if (posok(i, j-1) && S[i][j-1] == ".#"[c] && !B[i][j-1]) recur(i, j-1, !c);
    if (posok(i, j+1) && S[i][j+1] == ".#"[c] && !B[i][j+1]) recur(i, j+1, !c);
}
int main()
{
    cin >> H >> W;
    S = vector<string>(H); for (auto& s : S) cin >> s;
    B = vector<vector<bool>>(H, vector<bool>(W));
    long long ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#' && !B[i][j]) {
                black = 0, white = 0;
                recur(i, j, 0);
                ans += black * white;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 22912
// Aggressive Play

#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;

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

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

const int N = 5e5 + 5;
const ll M = 1e9 + 7;
ll power(ll x, ll y){
    x %= M;
    ll ans = 1;
    while(y){
        if(y & 1)
            ans = (ans * x) % M;
        y >>= 1LL;
        x = (x * x) % M;
    }
    return ans;
}
ll ad(ll a, ll b){
    return((a % M + b % M) % M);
}
ll sub(ll a, ll b){
    return((a % M - b % M + M) % M);
}
ll mul(ll a, ll b){
    return(((a % M) * (b % M)) % M);
}
ll divi(ll a, ll b){
    return(mul(a, power(b, M - 2)) % M);
}
ll f[N];
ll ncr(ll n, ll r){
    return(divi(f[n], mul(f[n - r], f[r])));
}
ll a[N];

int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    ll sum = 0;
    for(ll i = k; i <= n + 1; i++){
        ll fK = (i * (i - 1)) >> 1;
        ll lK = ((n * (n + 1)) >> 1);
        ll yo = n - i;
        lK -= (yo * (yo + 1)) >> 1;
        //cout << lK << " " << fK << endl;
        sum += (lK - fK + 1);
        sum %= M;
    }
    cout << sum;
return 0;
}


Measured memory_bytes: 3672
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL N;

bool getQ(LL x) {
	x %= N;
	x += N;
	x %= N;
	printf("%d\n", x);
	fflush(stdout);
	char str[10];
	scanf("%s", str);
	if (str[0] == 'V') {
		exit(0);
	}
	return (str[0] == 'M');
}

int main(void)
{
	scanf("%d", &N);
	LL lo = 0, hi = N;
	bool zero = getQ(0);
	for (;;) {
		LL mid = (lo + hi) / 2;
		bool now = getQ(mid);
		bool raw = now;
		now ^= zero;
		bool coc = (mid - lo) % 2;
		assert(mid >= lo);
		assert(lo < hi);
		if (now ^ coc) {
			//[lo,mid]
			hi = mid;
		}
		else {
			lo = mid;
			zero = raw;
		}
	}
	return 0;
}


Measured memory_bytes: 852