akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000000000LL
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue
 
#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)
 
#define MN 1005
int k;
int n;
int grid[MN][MN];

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

    cin >> k;
    if(k == 1){
        cout << "1\n1\n";
        return 0;
    }
    n = ((k-1)/4+1)*2;

    F0R(i, n){
        F0R(j, n){
            if(i % 2 == 0) grid[i][j] = 1+(i+j)%n;
            else grid[i][j] = (i+j)%n+n+1;

            if(grid[i][j] > k) grid[i][j] -= n;
        }
    }

    cout << n << "\n";
    F0R(i, n){
        F0R(j, n){
            cout << grid[i][j] << " ";
        }
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    vector<int> s(n), t(n), x(n);
    rep(i, n){
        scanf("%d%d%d", &s[i], &t[i], &x[i]);
        s[i] -= x[i]; t[i] -= x[i];
    }
    auto cmp1 = [&](const int &i, const int &j){return s[i] > s[j];};
    auto cmp2 = [&](const int &i, const int &j){return t[i] > t[j];};
    priority_queue<int, vector<int>, decltype(cmp1)> que1(cmp1);
    priority_queue<int, vector<int>, decltype(cmp2)> que2(cmp2);
    multiset<int> S;
    rep(i, n) que1.push(i);
    rep(_, q){
        int d;
        scanf("%d", &d);
        while(!que1.empty() && s[que1.top()] <= d){
            int i = que1.top(); que1.pop();
            S.insert(x[i]);
            que2.push(i);
        }
        while(!que2.empty() && t[que2.top()] <= d){
            int i = que2.top(); que2.pop();
            S.erase(S.find(x[i]));
        }
        printf("%d\n", S.empty() ? -1 : *S.begin());
    }
}

Measured memory_bytes: 16708
#include <algorithm>
#include <chrono>
#include <iostream>
#include <vector>

using namespace std;
using namespace std::chrono;

const int LIM = 1e+5 + 10;

struct query_t {
  int v, d, c;
};

vector<vector<int>> g(LIM);
vector<int> color(LIM, 0);
vector<vector<bool>> used(LIM, vector<bool>(11, false));

void fill_color(int v, int d, int c) {
  if (color[v] == 0)
    color[v] = c;

  if (used[v][d])
    return;

  used[v][d] = true;

  if (d == 0)
    return;

  for (int to : g[v])
    if (!used[to][d - 1])
      fill_color(to, d - 1, c);
}

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  int q;
  cin >> q;
  vector<query_t> queries(q);
  for (int i = 0; i < q; ++i)
    cin >> queries[i].v >> queries[i].d >> queries[i].c;
  reverse(queries.begin(), queries.end());

  for (const query_t& it : queries)
    fill_color(it.v - 1, it.d, it.c);

  for (int i = 0; i < n; ++i)
    cout << color[i] << '\n';

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 15072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

//string N;ll K,n;
string S;ll N,K;
ll nCr(ll nn,ll r){
    if(r>N)return 0;
    if(r==1)return nn;
    if(r==2)return nn*(nn-1)/2;
    if(r==3)return nn*(nn-1)*(nn-2)/6;
    return 0;
}

long long dp(int i, int k, int smaller) {
    if (i == N) {
        if (k == 0) return 1;
        else return 0;
    }
    if (k == 0) return 1;
    
    if (smaller) return nCr(N-i, k) * pow(9, k);
    else {
        if (S[i] == '0') return dp(i+1, k, false);
        else {
            long long zero = dp(i+1, k, true);
            long long aida = dp(i+1, k-1, true) * (S[i] - '1');
            long long icchi = dp(i+1, k-1, false);
            return zero + aida + icchi;
        }
    }
}


void solve() 
{
    cin>>S>>K;
    N=S.size();
    cout<<dp(0,K,0)<<endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, a[100000];
int main() {
	cin >> N;
	for (int i = 0; i != N; ++i) {
		cin >> a[i];
		if (a[i] % 2) {
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
	return 0;
	return 0;
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int d, n;
  cin >> d >> n;
  for(int i=1; ;i++){
    int tmp = i;
    int cnt = 0;
    while(1){
      if(tmp % 100) break;
      cnt++;
      tmp /= 100;
    }
    if(cnt == d) n--;
    if(n == 0){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


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

int main() {
    cin >> x >> k >> d;
    if (x < 0)
        x = -x;

    ll for_plus = x / d;
    if (k <= for_plus) {
        cout << x - k * d;
        return 0;
    }

    k -= for_plus;
    x -= d * for_plus;
    if (k % 2 == 0)
        cout << x;
    else
        cout << d - x;
    return 0;
}


Measured memory_bytes: 3628
require 'prime'

n = gets.chomp.to_i
i, count = 0, 0
arr = []

n.times{
  a = gets.chomp.to_i
  if a != 2 && a.even?
    next
  else
    arr[i] = a
    i += 1
  end
}

arr.each{ |j|
  Prime.prime?(j) == true && count += 1
}

puts count

Measured memory_bytes: 8980
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

ll dp[510][101];
ll wi[101],v[101];
int main(){
    int n,w;
    ll w1;
    cin>>n>>w;
    cin>>w1>>v[0];
    ll ww=w;
    wi[0]=0;w-=w1;
    FOR(i,1,n){
        cin>>wi[i]>>v[i];
        wi[i]-=w1;
        w-=w1;
    }
    dp[0][0]=0;
    rep(i,n){
        for(ll k=n;k>=0;--k){
            for(ll j=4*n;j>=wi[i];--j){
                if(k*w1+j+w1<=ww){
                    dp[j][k+1]=max(dp[j][k+1],dp[j-wi[i]][k]+v[i]);
                }
            }
        }
    }
    ll ans=0;
    rep(i,n+1){
        rep(j,4*n+1) ans=max(ans,dp[j][i]);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    ll X;
    cin >> X;

    if(X < 0) X = -X;

    ll sum = 0;
    ll overNum = 0;

    for(ll i = 1; i < 1000000001; i++)
    {
        sum += i;
        if(sum >= X)
        {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <ctime>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
const int MAX = 2e5 + 4;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	float avg = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		avg += a[i];
	}
	avg /= n;
	int average=avg+0.5;
//	cout << average << endl;
	int result = 0;
	for (int i = 0; i < n; i++)
	{
		result += pow(a[i] - average, 2);
	}
	cout << result;
	return 0;
}

Measured memory_bytes: 256
import Data.List  -- sortBy, group
import Data.Ord   -- comparing

modes :: [Int] -> [Int]
modes = map fst . takeModes . sortBy (flip $ comparing snd) . freqList
  where takeModes (x:xs) = takeWhile ((>= snd x) . snd) (x:xs)

freqList = map valFrq . group . sort  -- list of value-freq pairs
  where valFrq ls = (head ls, length ls)

main = do
  s <- getContents
  putStr . unlines . map show . modes . map read . lines $ s

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

long long INF = 1000000000;

void F(string S, string T, vector<long long>& V) {
	for (int i = 0; i < S.size(); i++) {
		bool check = true;
		for (int j = 0; i + j < S.size() && j < T.size(); j++) {
			if (S[i + j] != '?' && T[j] != '?' && S[i + j] != T[j]) check = false;
		}
		if (check) V.push_back(i);
	}
	V.push_back(S.size());
}

int Solve(string A, string B, string C, vector<long long>& AB, vector<long long>& BC, vector<long long>& AC) {
	int ANS = INF;
	for (int i : AB) {
		for (int j : BC) {
			if (i + j < A.size()) {
				int it = lower_bound(AC.begin(), AC.end(), i + j) - AC.begin();
				if (AC[it] == i + j) ANS = min(ANS, max({ (int)(A.size()), i + (int)(B.size()), i + j + (int)(C.size()) }));
			}
			else {
				ANS = min(ANS, max({ (int)(A.size()), i + (int)(B.size()), i + j + (int)(C.size()) }));
			}
		}
	}
	for (int i : AB) {
		for (int j : AC) {
			if (j <= i + B.size()) continue;
			ANS = min(ANS, max((int)(A.size()), j + (int)(C.size())));
		}
	}
	return ANS;
}

int main() {
	string A, B, C;
	cin >> A >> B >> C;
	vector<long long> AB, AC, BA, BC, CA, CB;
	F(A, B, AB), F(A, C, AC), F(B, A, BA), F(B, C, BC), F(C, A, CA), F(C, B, CB);
	int ANS = (int)A.size() + (int)B.size() + (int)C.size();
	ANS = min(ANS, Solve(A, B, C, AB, BC, AC));
	ANS = min(ANS, Solve(A, C, B, AC, CB, AB));
	ANS = min(ANS, Solve(B, A, C, BA, AC, BC));
	ANS = min(ANS, Solve(B, C, A, BC, CA, BA));
	ANS = min(ANS, Solve(C, A, B, CA, AB, CB));
	ANS = min(ANS, Solve(C, B, A, CB, BA, CA));
	cout << ANS << endl;
}

Measured memory_bytes: 384
# ABC137D - Summer Vacation
from heapq import heappush, heappushpop


def main():
    N, M, *A = map(int, open(0).read().split())
    # T[i] := candidates of values on i-th deadline
    T = [[] for _ in range(M + 1)]
    for a, b in zip(*[iter(A)] * 2):
        if a <= M:
            T[M - a] += [b]
    q = []  # heapq
    for i in range(M + 1):
        for v in T[i]:
            # keep i worthwhile tasks in i-th day
            if len(q) <= i:
                heappush(q, v)
            else:
                heappushpop(q, v)
    print(sum(q))


if __name__ == "__main__":
    main()

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;



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

    double sum = 0;

    ll oneT = m*1900 + (n-m)*100;
    double k = pow(0.5, m);
    rep(i, 1e5){
        double it = (i+1) * oneT * k * pow((1-k), i);
        sum += it;
        if(it < 0.01)  break;
    }

    cout << (ll)sum + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public Main() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        int[] A = new int[N+1];
        HashMap<Integer, Integer> counter = new HashMap<>();
        for (int i = 1; i <= N; i++) {
            int in = scanner.nextInt();
            A[i] = in;
            counter.put(i - in, counter.getOrDefault(i - in, 0) + 1);
        }

        long R = 0L;
        for (int i = 1; i <= N; i++) {
            int key = A[i] + i;

            if (counter.containsKey(key)){
                R += counter.get(key);
            }

            key = i - A[i];
            if (counter.get(key) == 1){
                counter.remove(key);
            } else {
                counter.put(key, counter.get(key)-1);
            }
        }

        System.out.println(R);
    }

    public static void main(String[] args){
        new Main();
    }
}


Measured memory_bytes: 70280
n = int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))
D_dict = {}
for d in D:
    if d not in D_dict:
        D_dict[d] = 1
    else:
        D_dict[d] += 1
for t in T:
    if t not in D_dict:
        print('NO')
        exit()
    else:
        if D_dict[t] == 0:
            print('NO')
            exit()
        else:
            D_dict[t] -= 1
print('YES')


Measured memory_bytes: 41316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = Math.abs(a - b);
		if(k % 2 == 0) {
			k /= 2;
			k += Math.min(a, b);
			System.out.println(k);
		} else {
			System.out.println("IMPOSSIBLE");
		}

	}

}


Measured memory_bytes: 21972
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MAX 1000
#define VMAX 10000
typedef long long ll;
using namespace std;

int n, A[MAX], s;
int B[MAX], T[VMAX+1];

int solve(){
  int ans=0;

  bool V[MAX];
  for (size_t i = 0; i < n; i++) {
    B[i]=A[i];
    V[i]=false;
  }
  sort(B, B+n);

  for (size_t i = 0; i < n; i++) T[B[i]]=i;
  for (size_t i = 0; i < n; i++) {
    if (V[i]) continue;
    int cur = i;
    int S = 0;
    int m = VMAX;
    int A_n = 0;
    while (1) {
      V[cur] = true;
      A_n++;
      int v = A[cur];
      m = min(m, v);
      S += v;
      cur = T[v];
      if (V[cur]) break;
    }
    ans += min(S + (A_n-2) * m, S + m + (A_n + 1)*s );
  }
  return ans;
}

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

  std::cin >> n;
  s = VMAX;

  for (size_t i = 0; i < n; i++) {
    std::cin >> A[i];
    s = min(s, A[i]);
  }
  int cost = solve();

  std::cout << cost << '\n';

  return 0;
}



Measured memory_bytes: 3220
n = int(input())
c = input()
lst = []
w = 0
r = 0
for i in range(n):
  if c[i] == 'R':
    r += 1
ans = max(w, r)

for k in range(n):
  if c[k] == 'W':
    w += 1
  elif c[k] == 'R':
    r -= 1
  cnt = max(w, r)
  if ans > cnt:
    ans = cnt
print(ans)


Measured memory_bytes: 9348
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

int q_sort(int d[],int left,int right);
long long func(long long a,long long n);
int main(void)
{
	int n; cin>>n;
	int a[n]; for(int i = 0; i < n; i++) cin>>a[i];
	q_sort(a,0,n-1);
	long long ans = 0;
	if(n%2 == 0){
		for(int  i = 0; i < n; i+=2){
			if(a[i] != a[i+1] || a[i+1] != i+1){
				cout<<0<<endl;
				return 0;
			}
		}
		ans = func(2,n/2);
	}
	else{
		if(a[0] != 0){
			cout<<0<<endl;
		}
		for(int i = 1; i < n; i+=2){
			if(a[i] != a[i+1] || a[i+1] != i+1){
				cout<<0<<endl;
				return 0;
			}
		}
		ans = func(2,n/2);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


int q_sort(int d[],int left,int right){
	if(left >= right) return 0;
	int pipot = d[(left+right)/2], l = left, r = right, tmp;
	while(l<r){
		while(d[l] < pipot) l++;
		while(d[r] > pipot) r--;
		if( l <=  r){
			tmp = d[l];
			d[l] = d[r];
			d[r] = tmp;
			l++;
			r--;
		}
	}
	q_sort(d,left,r);
	q_sort(d,l,right);
}

long long func(long long a, long long n){
	long long re = 1;
	while(n > 0){
		if(n & 1) re = re * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return re;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int l, r;
		scanf("%d%d", &l, &r);
		ans += r - l + 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
btns = [None]*n
for i in range(n):
    btns[i] = int(input())
cnt = 0
nb = 1
while nb != 2:
    cnt += 1
    nb = btns[nb-1]
    if cnt > n:
        break
if cnt > n:
    print(-1)
else:
    print(cnt)


Measured memory_bytes: 6900
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
    std::cout << std::fixed << std::setprecision(10);
ll n;
cin>>n;
double x;
string u;
double sum=0;
for(int i=0;i<n;i++){
    cin>>x>>u;
    if(u=="JPY"){
        sum+=x;
    }else{
        sum+=x*380000;
    }
}
cout<<sum<<endl;
}












Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[110][15],p[110][15];
int sum=-INT_MAX;
int n;
void dfs(string s)
{
	if(s.size()==10)
	{
		if(s.find('1')==string::npos)
			return;
		int cnt=0;
		for(int i=0;i<n;i++)
		{
			int ans=0;
			for(int j=0;j<10;j++)
			{
				if(f[i][j] && s[j]=='1')
				{
					ans++;
				}
			}
			cnt+=p[i][ans];
		}
		sum=max(cnt,sum);
		return;
	}
	dfs(s+'0');
	dfs(s+'1');
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<10;j++)
		{
			cin>>f[i][j];
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<11;j++)
		{
			cin>>p[i][j];
		}
	}
	dfs("");
	cout<<sum<<'\n';
	return 0;
}

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


void solve(long long N, std::vector<long long> a){
    vector<long long> cnt(1e5);
    for(long long i = 0; i < N; ++i) cnt[a[i]] += 1;
    //for(auto itr = mp.begin(); itr != mp.end(); ++itr) cout << itr->first << " " << itr->second << endl;
    long long ans = 0;
    for(long long i = 1; i < cnt.size()-1; ++i){
        ans = max(ans, cnt[i-1]+cnt[i]+cnt[i+1]);
    }
    cout << ans << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 4764
#include <iostream>
#include <string>
#include <bits/stdc++.h>

using namespace std;


// adjacency matrix
// O(V^2) storage

// adjacency list
// O(V+E) storage

// dfs O(V+E) time
// bfs O(V+E) time


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

int dfs(const vector<vector<int>>& G, vector<int>& dp, int v) {
    // get longest path from node v

    if(dp[v]!=-1) {
        return dp[v];
    }

    int res=0;
    for (auto &&u : G[v])
    {
        chmax(res, 1+dfs(G,dp,u));
    }
    return dp[v]=res;
}

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

    int N, M;
    cin>>N>>M;

    vector<int> dp(N,-1);
    vector<vector<int>> G;
    G.resize(N);
    int x,y;
    for (size_t i = 0; i < M; ++i)
    {  
        cin>>x>>y;
        G[x-1].push_back(y-1);
    }

    int res;
    for (size_t i = 0; i < N; ++i)
    {
        chmax(res, dfs(G,dp,i));
    }
    
    cout << res<<"\n";
}

Measured memory_bytes: 8832
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    long ans = 0;
    int wLen = 0;
    for (int i = 0; i < S.length(); i++) {
      if (S.charAt(i) == 'W') {
        ans += i-wLen;
        wLen++;
      }
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 27220
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    println(problem043b(s))
}

fun problem043b(s: String): String {
    var ans = ""
    for (i in 0 until s.length) {
        val si = s[i]
        when (si) {
            '0' -> ans += "0"
            '1' -> ans += "1"
            else -> ans = ans.dropLast(1)
        }
    }
    return ans
}

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

typedef long long int ll ;

ll gcd(ll aaa,ll bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

ll lcm(ll m,ll n)
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}

int main() {

	int N[3],ans = 0,t,s,I=0;
	cin >> N[0] >> N[1] >> N[2];
	sort(N,N+3);
	reverse(N,N+3);
	for(int i = 0; i < 2; i++) {
		for(int j = i+1; j < 3; j++) {
			if((N[i] - N[j]) % 2 == 0) {
				ans += (N[i] - N[j]) / 2;
				if(i == 0) {
					if(j == 1) {
						s = 2;
					}else {
						s = 1;
					}
				}else {
					s = 0;
				}
				t = max(N[i],N[j]);
				I = 1;
				break;
			}
			if(I) {
				break;
			}
		}
	}
	if(abs(N[s] - t) % 2 == 0) {
		ans += abs(N[s] - t) / 2;
	}else {
		if(N[s] > t) {
			ans += abs(N[s] - t) / 2 + 1;
		}else {
			ans += abs(N[s] - t) / 2 + 2;
		}
	}
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define allof(a) (a).begin(),(a).end()
using namespace std;

/*
const double EPS = 1e-9;
const int INF = 1L << 30;
vector<int> dx = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};

bool in_range(int x, int lb, int ub) {return lb <= x and x < ub;}
bool in_range(int x, int y, int W, int H) {return in_range(x,0,W) and in_range(y,0,H);}
void modAdd(int &a, int b, int mod) {a = (a + b) % MOD;}
template <typename T> void maxUpdate(T& a, T b){a = max(a,b);}
*/
int main() {
	
	while(1) {
	int n,m; cin >> n >> m;
	if (n + m == 0) {
		break;
	}

	vector<int> h(n+1);
	vector<int> w(m+1);
	vector<int> h_cnt(1000000);
	vector<int> w_cnt(1000000);

	int sum = 0;
	h[0] = 0;
	for (int i = 1; i <= n; i++) {
		int num; cin >> num;
		sum += num;
		h[i] = sum;
	}

	sum = 0;
	w[0] = 0;
	for (int i = 1; i <= m; i++) {
		int num; cin >> num;
		sum += num;
		w[i] = sum;
	}


	for (int i = 0; i <= n; i++) {
		for (int j = i+1; j <= n; j++) {
			h_cnt[h[j] - h[i]]++;	
		}
	}
	for (int i = 0; i <= m; i++) {
		for (int j = i+1; j <= m; j++) {
			w_cnt[w[j] - w[i]]++;	
		}
	}
	
	int ans = 0;
	for (int i = 1; i < h_cnt.size(); i++) {
		ans += h_cnt[i] * w_cnt[i];	
	}
	cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 10736
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
#define per(i, a, b) for (int i = a; i >= b; -- i)
const int mo = 1000000007, N = 1005;
using namespace std;
int n, p[N];
bool vis[N];
int main() {
	scanf("%d", &n); ll ans = 1;
	memset(vis, true, sizeof(vis));
	rep(i, 2, n) {
		if (vis[i]) {
			int tmp = n, ret = 0;
			for ( ; tmp; tmp /= i) ret += tmp / i;
			ans = (ll) ans * (ret + 1) % mo;
			p[++ p[0]] = i;
		}
		for (int j = 1; j <= p[0] && i * p[j] <= n; ++ j) {
			vis[i * p[j]] = false;
			if (i % p[j] == 0) break;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void bfs(int root, V<int> &dist, const V<V<int>> &to, const V<V<int>> &from, V<int> &cnt) {
  queue<int> q;
  q.push(root);
  while(sz(q)) {
    int v = q.front(); q.pop();
    for(int nv : to[v]) {
      cnt[nv]++;
      chmax(dist[nv], dist[v] + 1);
      if(cnt[nv] == sz(from[nv])) q.push(nv);
    }
  }
}

int main(){
  int n, m;
  cin >> n >> m;
  V<V<int>> to(n);
  V<V<int>> from(n);
  rep(i,n+m-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    from[b].push_back(a);
  }
  int root = 0;
  rep(i,n) if(from[i].empty()) root = i;
  V<int> dist(n,-1);
  dist[root] = 0;
  V<int> cnt(n);
  bfs(root, dist, to, from, cnt);
  // rep(i,n) printf("%d:%d\n", (int)i, dist[i]);
  rep(i,n) {
    int p = sz(from[i]);
    if(p == 0) cout << 0 << endl;
    else if(p == 1) cout << from[i][0]+1 << endl;
    else {
      int ans = 0;
      for(int parent : from[i]) {
        if(dist[parent]+1 == dist[i]) ans = parent+1;
      }
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 14696
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll X;
  cin>>X;
  ll ans = 0;
  ans += X/500*1000;
  X %= 500;
  ans += X/5*5;
  cout<<ans<<endl;
}



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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))
#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end())

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using vstr = std::vector<std::string>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n;
    cin >> n;

    while (true) {
        string s = to_string(n);
        if (s[0] == s[1] && s[1] == s[2]) {
            cout << n << endl;
            return;
        }
        ++n;
    }
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;


struct Node{
    vector<ll> path;
    vector<ll> weight;
    ll color;
};

ll putColor(Node T[], ll id, ll color){
    T[id].color = color;
    for(ll i = 0; i < T[id].path.size(); i++){
        ll next = T[id].path[i];
        if(T[next].color == 0){
            if(T[id].weight[i] % 2 == 0){
                putColor(T, next, color);
            }else{
                putColor(T, next, color * -1);
            }
        }
    }

    return 0;
}

int main(){
    int N;

    cin >> N;

    Node T[N + 1];

    for(ll i = 1; i < N; i++){
        ll u, v, w;
        cin >> u >> v >> w;

        T[u].path.push_back(v);
        T[u].weight.push_back(w);
        T[u].color = 0;
        T[v].path.push_back(u);
        T[v].weight.push_back(w);
        T[v].color = 0;
    }

    putColor(T, 1, 1);

    for(ll i = 1; i < N + 1; i++){
        if(T[i].color == 1){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 13696
#include <stdio.h>
#include <math.h>

int MaxV(int, int);
int MinV(int);

int x;

main(){
  int n, j, minv, maxv;

  maxv = pow(10, 9) * (-1);

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

  for( j = 1; j <= n-1; j++){

    maxv = MaxV(maxv, minv);

    minv = MinV(minv);

  }

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

  return 0;

}

int MaxV(int maxv, int minv){
  scanf("%d", &x);

  if( maxv > x - minv ) return maxv;
  else return x - minv;

}

int MinV(int minv){

  if( minv < x ) return minv;
  else return x;

}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	
	long long a[n], s[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		s[i] = a[i];
		if(i) s[i] += s[i - 1];
	}
	
	long long ret = s[n - 1];
	for(int i = 0; i < n - 1; i++){
		ret = min(ret, abs(s[n - 1] - 2 * s[i]));
	}
	
	cout << ret << endl;
	
	return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
#include<math.h>

int a[1000000];

int main()
{
	long long i,j;
	int n,ans=0;
	while(scanf("%d",&n)==1)
	{
		ans=0;

		memset(a,0,sizeof(a));

		for(i=2;i<=n;++i)
		{
			if(a[i]==0)
			{
				for(j=i*i;j<=n;j+=i)
				{
					a[j]=-1;
				}
				ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

using namespace std;

const int maxn = 30;

int n, m, k;

bool f()
{
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
		{
			int res = i * (m-j) + j * (n-i);
			if(res==k)
				return 1;
		}

	return 0;
}
int main()
{
	cin >> n >> m >> k;
	if(f())
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
N = int(input())
X = []
for i in range(N):
  X.append(list(map(int, input().split())))
  
dp = [[0] * 3 for i in range(N+1)]

for i in range(1,N+1):
  dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + X[i-1][0]
  dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + X[i-1][1]
  dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + X[i-1][2]
  
print(max(dp[N]))

Measured memory_bytes: 47280
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	vint ans;
	while (1) {
		int x, y;
		char c;
		cin >> x >> c >> y;
		if (c == '+')ans.push_back(x + y);
		if (c == '-')ans.push_back(x - y);
		if (c == '*')ans.push_back(x * y);
		if (c == '/')ans.push_back(x / y);
		if (c == '?')break;
	}
	rep(i, ans.size())cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back
#define fi first
#define be begin()
#define en end()
#define se second

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

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; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,A[(int)1e3+1],B[1001],H;
  cin>>H>>N;
  for (int i(1);i<=N;i++) cin>>A[i]>>B[i];
  vector<vector<int>> dp(N+1,vector<int>(H+1,INFint));
  dp[0][0] = 0;
  for (int i(1);i<=N;i++){
    for (int j(0);j<=H;j++){
      if (j<A[i]){
        dp[i][j] = min(dp[i-1][j],B[i]);
      }else{
        dp[i][j] = min(dp[i-1][j],dp[i][j-A[i]] + B[i]);
      }
    }
  }
  cout << dp[N][H] << endl;
  return 0;
}



Measured memory_bytes: 39424
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#define MOD 10000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define revrep(i,n) for(ll i=n;i>0;i--)

typedef long long ll;

ll mygcd(ll a, ll b) { if (b == 0) return a; return mygcd(b, a % b); }

ll mylcm(ll a, ll b) { return a / mygcd(a, b) * b; }

ll mymax(ll a, ll b) { return (a > b) ? a : b; }

ll mymin(ll a, ll b) { return (a < b) ? a : b; }

int myasc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }

int mydsc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }

ll mypow(ll a, ll b) {
	ll x;
	if (b == 0) return 1;
	else if (b % 2 == 1) return a * mypow(a, b - 1) % MOD;
	x = mypow(a, b / 2);
	return x * x % MOD;
}
ll fac[100001], inv[100001];
ll mycomb(ll a, ll b) {
	if (a < b || a < 0 || b < 0)return 0;
	return fac[a] * inv[a - b] * inv[b] % MOD;
}

int main() {
	ll n,k, a[100000];
	scanf("%lld%lld", &n,&k);
	rep(i, n) scanf("%lld", &a[i]);
	ll g = a[0],max=a[0];
	rep(i, n - 1) {
      	g = mygcd(g, a[i + 1]);
      	max=mymax(max,a[i+1]);
    }
	if (k % g != 0||k>max) printf("IMPOSSIBLE");
	else printf("POSSIBLE");

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n,a,maxs=0;
	cin >> n;
	map<int, int>mp;
	rep(i, n) {
		cin >> a;
		mp[a - 1]++;
		mp[a]++;
		mp[a + 1]++;
	}
	for (auto m : mp) {
		maxs = max(maxs, m.second);
	}
	cout << maxs << endl;
	return 0;
}


Measured memory_bytes: 7980
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
int a[N];
void solve()
{
	ll n;
	ll m;
	cin>>n>>m;
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		ll a,b;
		cin>>a>>b;
		ll res=a*a+b*b;
		if(a*a+b*b<=m*m)
			ans++;
	}
	cout<<ans<<endl;
}
signed main()
{
	ll t=1; 
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6+5;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(ll x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(ll x,char c='\n')
{
	write(x);
	putchar(c);
}
struct node
{
	int son[26];
	int c[26];
}t[N];
string xxx[N];
char a[N];
int c[N][26],cnt=0;
void add(int w,int now)
{
	if (now==0) return;
	if (!t[w].son[a[now]-'a']) t[w].son[a[now]-'a']=++cnt;
	for (int i=0;i<26;i++) t[w].c[i]+=c[now][i];
//		putchar(a[now]);putchar(' ');print(w);puts("");for (int i=0;i<26;i++) putchar(t[w].c[i]+'0');puts("");
	add(t[w].son[a[now]-'a'],now-1);
}
int query(int w,int x,int now)
{
//	putchar(xxx[x][now]);
	if (now==0) return t[w].c[xxx[x][now]-'a'];
	return query(t[w].son[xxx[x][now]-'a'],x,now-1);
}

int main()
{
	memset(t,0,sizeof(t));
	for (int k=0;k<26;k++) c[0][k]=0;
	int n=read();
	for (int i=1;i<=n;i++)
	{
		scanf("%s",a+1);
		int m=strlen(a+1);
		for (int j=1;j<=m;j++)
		{
			for (int k=0;k<26;k++) c[j][k]=c[j-1][k];
			c[j][a[j]-'a']=1;
		}
		add(0,m);//puts("XXX");print(t[0].son['y'-'a']);
		xxx[i]="";
		for (int j=1;j<=m;j++) xxx[i]+=a[j];
	}
	ll ans=0;
//	for (int i=1;i<=n;i++) print(query(0,i,xxx[i].length()-1)),puts("");
	for (int i=1;i<=n;i++) ans+=query(0,i,xxx[i].length()-1)-1;
	print(ans);

	return 0;
}

Measured memory_bytes: 338328
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int m=0,n,aa[220000],a,b,cnt=0,ab[220000];
pair<int,int> p[220000];
string s,ss[110000];
double d;
char c;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
        ab[aa[i]]++;
    }
    rep(i,n+1){
        cnt+=ab[i]*(ab[i]-1)/2;
    }
    rep(i,n){
        cout<<cnt-ab[aa[i]]+1<<endl;
    }
}

Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>
#include <string>
#include <stdlib.h>
#include <vector>
#include <climits>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <iomanip>
using namespace std; 
#define Endl '\n'
int main()
{
    long long int a,b,k;
    cin>>a>>b>>k;
    if (b>k)
    {
        cout<<floor(a*k/b)-a*floor(k/b);
    }
    else
        cout<<floor(a*(b-1)/b)-a*floor((b-1)/b);
}

Measured memory_bytes: 3784
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int i=0,a[100];
    char s[2];
    for(;~scanf("%s",s);){
        switch(*s){
            case'+':i--;a[i-1]+=a[i];break;
            case'-':i--;a[i-1]-=a[i];break;
            case'*':i--;a[i-1]*=a[i];break;
            default:a[i++]=atoi(s);
            }
    }
    printf("%d\n",a[0]);
    return 0;
}



Measured memory_bytes: 2080
N = int(input())
A1 =list(map(int, input().split()))
A2 =list(map(int, input().split()))
 
candy = []
 
def sum_A1(x):
  cnt = 0
  for i in range(x+1):
    cnt += A1[i]
  return cnt
 
def sum_A2(x):
  cnt = 0
  for i in range(x,N):
    cnt += A2[i]
  return cnt
 
for i in range(N):
  candy.append(sum_A1(i) + sum_A2(i))
  
print(max(candy))

Measured memory_bytes: 9204
main = getLine >> getLine >>= putStrLn . show . solve . map read . words
solve :: [Int] -> Int
solve xs = solve' 1 'N' $ zip xs (tail xs)
solve' n _ [] = n
solve' n t ((a,b):ps)
    | t == 'I'  = if a <= b then solve' n t ps
                            else solve' (n + 1) 'N' ps
    | t == 'D'  = if a >= b then solve' n t ps
                            else solve' (n + 1) 'N' ps
    -- t == 'N'
    | a < b     = solve' n 'I' ps
    | a > b     = solve' n 'D' ps
    | otherwise = solve' n t ps


Measured memory_bytes: 36220
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int INF=1e16;

int calc(int a,int b,int c){
        return abs(b-a)+abs(c-b);
}

signed main()
{
        int A,B,Q; cin>>A>>B>>Q;
        vint s(A+2),t(B+2);
        REP(i,A) cin>>s[i+1];
        REP(i,B) cin>>t[i+1];

        s[0]=-INF; s[A+1]=INF;
        t[0]=-INF; t[B+1]=INF;

        while(Q--){
                int x; cin>>x;
                int rs=lower_bound(ALL(s),x)-s.begin();
                int ls=rs-1;
                int rt=lower_bound(ALL(t),x)-t.begin();
                int lt=rt-1;
/*
                cout<<s[ls]<<' '<<s[rs]<<endl;
                cout<<t[lt]<<' '<<t[rt]<<endl;
*/

                int cost=INF;
                cost=min(cost,calc(x,s[ls],t[lt]));
                cost=min(cost,calc(x,t[lt],s[ls]));
                cost=min(cost,calc(x,s[ls],t[rt]));
                cost=min(cost,calc(x,t[rt],s[ls]));
                cost=min(cost,calc(x,s[rs],t[lt]));
                cost=min(cost,calc(x,t[lt],s[rs]));
                cost=min(cost,calc(x,s[rs],t[rt]));
                cost=min(cost,calc(x,t[rt],s[rs]));

                cout<<cost<<endl;
        }
}


Measured memory_bytes: 2944
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  ll N; cin>>N;
  if(N >= 30) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3588