akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(), v.end()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const ll inf = 10000000000000000;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int n, k;
ll ans = inf;
ll x[100005];

int main() {

	cin >> n >> k;
	rep(i, n)cin >> x[i];

	rep(i, n - k + 1) {
		ans = min(ans, x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i])));
	}

	cout << ans << endl;

	return 0;
} 

Measured memory_bytes: 1024
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var r = int.Parse(line[1]);
        var L = h + r;
        int ans;
        if (L > 0) ans = 1;
        else if (L < 0) ans = -1;
        else ans = 0;
        Console.WriteLine(ans);
    }
}

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

int main() {
  string N;
  cin >> N;
  if (N[1] != N[2]) cout << "No" << endl;
  else if (N[0] == N[1] || N[2] == N[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

bool checkCase(int posA, int posC, string &s){
	for(int i = 0; i < s.length(); i++){
		if(i == posA || i == posC) continue;
		else if(isupper(s[i])) return false;
	}
	
	return true;
}

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

	int cnt[256], posA, posC;
	string s;
	
	cin >> s;
	memset(cnt, 0, sizeof(cnt));
	for(int i = 0; i < s.length(); i++){
		if(s[i] == 'A') cnt[s[i]]++;
		else if(s[i] == 'C') cnt[s[i]]++;
	}
	if(cnt[(int) 'A'] == 1 && cnt[(int) 'C'] == 1){
		posA = s.find('A');
		posC = s.find('C');

		if(posA == 0 && (posC >=2 && posC < s.length()-1)){
			if(checkCase(posA, posC, s)) cout << "AC\n";
			else cout << "WA\n";
		}else{
			cout << "WA\n";
		}
	}else{
		cout << "WA\n";
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        int t = s.length();

        StringBuilder result = new StringBuilder();
        for (int i = 0; i < t; i++) {
            result.append("x");
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
 
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
 
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;

int arr1[200010];
vector<int> ans;
signed main() {
 
	
	//fastio();
//	#define LOCAL_DEFINE
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif	
	//https://www.coursera.org/learn/algorithms-on-strings/home/welcome
	//https://www.coursera.org/lecture/algorithms-on-strings/suffix-array-and-suffix-tree-TV4I6
	int n;
	cin>>n;
	int arr[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
	
	for(int i=n;i>0;i--)
	{

		int ans=0;
		for(int j=2*i;j<=n;j+=i)
		{
			ans+=arr1[j];
		}
		if(ans%2==arr[i])
		{
			arr1[i]=0;
		}else{
			arr1[i]=1;
		}
	}
	int m;
	

	for(int i=1;i<=n;i++)
	{
		if(arr1[i]==1)
		{
			ans.push_back(i);
		}
	}
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++)
	{
		cout<<ans[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint A, B, C;
    cin >> A >> B >> C;
    map<lint, lint> count;
    count[A] += 1;
    count[B] += 1;
    count[C] += 1;
    cout << (count[5] == 2 && count[7] == 1 ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  vector<int> t(5);
  rep(i,5){
    cin>>t[i];
  }
  
  int sum=0;
  int ans=1000000;
  
  do{
    rep(i,4){
      if(t[i]%10==0)
        sum+=t[i];
      else
        sum+=((t[i]/10)*10+10);
    }
    sum+=t[4];
    ans=min(ans,sum);
    sum=0;
  }while(next_permutation(t.begin(),t.end()));
  
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

int D; ll G;
cin >> D >> G;
vl p(D),c(D);
rep(i,D) cin >> p[i] >> c[i];

ll ans = INF;
for(int bit = 0; bit < (1 << D); bit++) {
    ll cnt = 0, sum = 0;
    rep(i,D) {
        if(bit & (1 << i)) {
            sum += c[i] + 100*(i+1)*p[i];
            cnt += p[i];
        }
    }
    if(sum >= G) ans = min(ans, cnt);
    else {
        drep(i,D) {
            if(bit & (1 << i)) continue;
            rep(j,p[i]) {
                if(sum >= G) break;
                sum += 100*(i+1);
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 */
int main()
{
    int N;
    cin >> N;
    vector<int> B(N - 1);
    REP(i, N - 1){
        cin >> B.at(i);
    }
    int sum = 0, prev_value = 0;
    REP(i, N-1) {
        // cout << sum << " : " << prev_value << endl;
        if (!i)
        {
            sum += 2 * B.at(i);
            prev_value = B.at(i);
        } else {
            if (B.at(i) < max(B.at(i),prev_value)) {
                sum -= prev_value;
                sum += 2 * B.at(i);
                prev_value = B.at(i);
            }
            else
            {
                sum += B.at(i);
                prev_value = B.at(i);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)

int main() {
  string s; cin >> s;
  stack<char> S;
  REP(i,s.size()) {
    if (!S.empty() && s[i] == 'T' && S.top() == 'S') S.pop();
    else S.push(s[i]);
  }
  cout << S.size() << endl;
  return 0;
}

Measured memory_bytes: 644
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = (int)1e6 + 1;

	void doIt() {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int d[] = new int[N + 1];
		Arrays.fill(d, -1);
		for(int i = 0; i < M; i++) {
			int s = sc.nextInt();
			int c = sc.nextInt();
			if(d[s] != -1 && d[s] != c) {
				System.out.println(-1);
				return;
			}
			else {
				d[s] = c;
			}
		}
		if(d[1] == 0 && N != 1) {
			System.out.println(-1);
			return;
		}
		if(d[1] == -1 && N != 1) {
			d[1] = 1;
		}
		for(int i = 1; i <= N; i++) {
			System.out.print((d[i] == -1)?0:d[i]);
		}
		System.out.println();

	}

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

}


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

#define ll long long

using namespace std;


int main(){
string s;
cin>>s;
if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
}
if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
}
if(s=="Rainy"){
    cout<<"Sunny"<<endl;
}

}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
using namespace std;
int a,b;
int ans=0;
int main()
{
  cin>>a>>b;
  int che=0;
  for(int i=a;i<=b;i++)
  {
    a=i;
    for(int j=10000;j>=1;j/=10)
    {
      che+=a%10*j;
      a/=10;
    }
    if(che==i)
      ans++;
    che=0;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s1s2s3;
  cin >> s1s2s3;
  cout << s1s2s3 / 100 + ((s1s2s3 - (100 * (s1s2s3 / 100))) / 10) + s1s2s3 % 2 << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll N,H; cin>>N>>H;
    vector<ll>a(N),b(N);
    ll mx=0;
    rep(i,N){
        cin>>a[i]>>b[i];
        mx=max(mx,a[i]);
    }
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());

    ll sum=0;
    ll cnt=0;
    rep(i,N){
        if(b[i]>mx){
            sum+=b[i];
            cnt++;
        }
        if(sum>=H){
            cout<<cnt<<endl;
            return 0;
        }
    }
    ll ans =cnt+((H-sum)+mx-1)/mx;
    cout<<ans<<endl;
}




Measured memory_bytes: 1920
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;


int main(void){
  int N=0;
  int K=0;
  
  cin >> N;
  cin >> K;
  
  int array[N]={};
  
  int i=0;
  for(i=0;i<N;i++){
    cin >> array[i];
  }
  
  int countNumber=0;
  
  for(i=0;i<N;i++){
    if(array[i] >= K){
      countNumber++;
    }
  }
  
  printf("%d", countNumber);
  
  return 0;
  
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		while(n != 0) {
			long[] a = new long[n];
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}

			long max = a[0];
			long[] b = new long[n + 1];
			for(int i = 0; i < n; i++) {
				b[i + 1] = b[i] + a[i];
			}
			for(int i = 0; i < n; i++) {
				for(int j = i + 1; j <= n; j++) {
					max = Math.max(max, b[j] - b[i]);
				}
			}
			sb.append(max).append("\n");
			n = sc.nextInt();
		}
		sc.close();
		System.out.print(sb.toString());
	}
}


Measured memory_bytes: 35212
<?php
fscanf(STDIN, "%d %d", $n, $k);
if (!$k) {
	$x = $n * $n;
} else {
	$x = 0;
	for ($i = $k + 1; $i <= $n; $i++) {
		$x += floor($n / $i) * ($i - $k);
		$s = $n % $i - $k + 1;
		if ($s > 0) $x += $s;
	}
}
echo $x;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000009
#define inf 40000000007
#define eps 1e-8
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.8lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)
#define endl '\n'
using namespace std;
#define M 400002
#define T 500001
int l[M],r[M];
int main()
{
    ios;
    int n;
    cin>>n;
    int ans=n;
    for(int i=1;i<n;i++)
    {
        int a1=i;int b1=n-i;
        int sum=0;
        while(a1!=0){sum+=a1%10;a1=a1/10;}
        while(b1!=0){sum+=b1%10;b1=b1/10;}
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}





Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int n,i,ai,max,min;

double sum;

sum=0.0;

max=-1000000;

min=1000000;

scanf("%d",&n);

for(i=0;i<n;i++){

scanf("%d",&ai);

if(ai<min){

min=ai;

}

if(max<ai){

max=ai;

}

sum=sum+ai;

}

printf("%d %d %.0lf\n",min,max,sum);

return 0;

}

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

using namespace std;

class Node {
public:
	int location;
	int l, r;
};

class Point {
public:
	int id, x, y;
	Point() {
	}
	Point(int id, int x, int y) :
			id(id), x(x), y(y) {
	}
	bool operator <(const Point &p) const {
		return id < p.id;
	}
	void print() {
		printf("%d\n", id);
	}
};

bool lessX(const Point &p1, const Point &p2) {
	return p1.x < p2.x;
}
bool lessY(const Point &p1, const Point &p2) {
	return p1.y < p2.y;
}
const int NIL = -1;
const int MAX = 500000;
int np = 0;
Point P[MAX];
Node T[MAX];
int makeKDTree(int l, int r, int depth) {
	if (!(l < r)) {
		return NIL;
	}
	int mid = (l + r) / 2;
	int t = np++;
	if (depth % 2 == 0) {
		sort(P + l, P + r, lessX);
	} else {
		sort(P + l, P + r, lessY);
	}
	T[t].location = mid;
	T[t].l = makeKDTree(l, mid, depth + 1);
	T[t].r = makeKDTree(mid + 1, r, depth + 1);
	return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;

	if (sx <= x && x <= tx && sy <= y && y <= ty) {
		ans.push_back(P[T[v].location]);
	}
	if (depth % 2 == 0) {
		if (T[v].l != NIL) {
			if (sx <= x)
				find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		}
		if (T[v].r != NIL) {
			if (x <= tx)
				find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
		}
	} else {
		if (T[v].l != NIL) {
			if (sy <= y)
				find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		}
		if (T[v].r != NIL) {
			if (y <= ty)
				find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
		}
	}

}

int main() {

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		P[i] = Point(i, x, y);
		T[i].l = T[i].r = NIL;
	}

	int root = makeKDTree(0, n, 0);

	int q;
	scanf("%d", &q);
	vector<Point> ans;
	for (int i = 0; i < q; ++i) {
		int sx, tx, sy, ty;
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		ans.clear();
		find(root, sx, tx, sy, ty, 0, ans);
		sort(ans.begin(), ans.end());
		for (int j = 0; j < ans.size(); ++j) {
			ans[j].print();
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 13992
#include <iostream>
#include <vector>
using namespace std;
int dt[105][105], f[105];

int main( void ) {
    int n, m;
    cin >> n >> m;
    for( int i = 0; i < n; ++i ) {
        for( int j = 0; j < m; ++j ) {
            cin >> dt[i][j];
        }
    }
    for( int i = 0; i < m; ++i ) cin >> f[i];
    for( int i = 0; i < n; ++i ) {
        int num = 0;
        for( int j = 0; j < m; ++j ) num += f[j] * dt[i][j];
        cout << num << '\n';
    }
    return 0;
}



Measured memory_bytes: 3120
while True:
    N,X = map(int,input().split())
    if N == 0 and X == 0:
        break
    ans = 0
    for a in range(1,N+1):
        for b in range(1,N+1):
            if b <= a:
                continue
            c = X-(a+b)
            if c > b and c <= N:
                ans += 1
    print("%d"%(ans))



Measured memory_bytes: 5596
// https://atcoder.jp/contests/abc121/tasks/abc121_c

#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
//金額、本数
typedef tuple<ll, ll> mytuple;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    ll sum = 0;
    cin >> n >> m;
    vector<mytuple> v;

    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        v.push_back(make_tuple(a, b));
    }
    //昇順ソート
    sort(ALL(v));

    for (const auto& e : v) {
        ll price = get<0>(e);
        ll count = get<1>(e);
        if (m <= count) {
            sum += (price * m);
            break;
        } else {
            sum += price * count;
            m -= count;
        }
    }

    cout << sum << endl;

    return 0;
}


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

int top(int n)
{
    return n / pow(10, to_string(n).length() - 1);
}

int bottom(int n)
{
    return n % 10;
}

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

    vector<vector<ll>> cnt(10, vector<ll>(10, 0));
    rep(i, N + 1) cnt[top(i)][bottom(i)]++;
    ll ans = 0;
    rep(x, 9) rep(y, 9)
    {
        ans += cnt[x + 1][y + 1] * cnt[y + 1][x + 1];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, = map(int, input().split())

ans = 0

ans = 0
for k in range(N, 0, -1):
    mi = int(N/k)
    sum_num = (1+mi) * (mi//2) if mi%2==0 else mi * ((mi-1)//2) + mi
    ans += k * sum_num

print(ans)


Measured memory_bytes: 67592
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
const int inf=1e9+7;
const int mod=1e9+7;
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
int main(){
	int N,M;
	cin>>N>>M;
	bool f=true;
	for(int i=2;i*i<=M;i++){
		if(M%i==0){
			f=false;
			break;
		}
	}
	if(f){
		if(N==1){
			cout<<M<<endl;
		}else{
			cout<<1<<endl;
		}
		return 0;
	}
	while(M%N!=0){
		N++;
	}
	cout<<M/N<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;

int a[41],b[41],c[41];
int dp[50][500][500];
int main(){
  int n,ma,mb;
  cin>>n>>ma>>mb;
  rep(i,n){
    cin>>a[i]>>b[i]>>c[i];
  }
  rep(i,n+1)rep(j,410)rep(k,410)dp[i][j][k]=INF;

  dp[0][0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=40*10;j++){
      for(int k=0;k<=40*10;k++){
        if(dp[i][j][k]==INF)continue;
        dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
        dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
      }
    }
  }

  int ans=INF;
  for(int i=1;i<=40*10;i++){
    for(int j=1;j<=40*10;j++){
      if(i*mb==j*ma)ans=min(ans,dp[n][i][j]);
    }
  }
  if(ans==INF)cout<<"-1"<<endl;
  else cout<<ans<<endl;


}


Measured memory_bytes: 40832
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

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


int atcoder(){
    int n;
    cin >> n;
    ll a[210000];
    ll sum = 0;
    REP(i,n){
        cin >> a[i];
        sum +=a[i];
    }
    ll ans;
    
    ll tmpans = sum - 2*a[0];
    ans = abs(tmpans);
    for(int i=1; i<n-1; ++i){
        tmpans -= 2*a[i];
        ans = min(abs(tmpans),ans);
    }
    
    
    
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top=0,S[100];

void push(int x){
  S[++top]=x;
}

int pop(){
   top--;
   return S[top+1];
}

int main(){

 int a,b;
 char s[100];
	top=0;
while( scanf("%s",s)!= EOF){
 if(s[0] == '+'){
  a=pop();
  b=pop();
  push(a+b);
 }else if(s[0]== '-'){
   b=pop();
   a=pop();
   push(a-b);
 } else if(s[0]=='*'){
    a=pop();
    b=pop();
    push(a*b);
 } else{
 push(atoi(s));
 }
 }
 
 printf("%d\n",pop());
 
 return 0;
} 

Measured memory_bytes: 548
import java.util.*;
import static java.lang.Math.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        int memo = 0;
        int p[] = new int[n];
        for(int i=0; i<n; i++){
            p[i] = sc.nextInt();
            if(max<p[i]){
                max = p[i];
                memo = i;
            }
        }
        p[memo] = p[memo] / 2;
        int sum = 0;
        for(int i=0; i<n; i++){
            sum += p[i];
        }
        System.out.println(sum);
    }
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 200010;
const int mod = 1e9+7;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

ll l,r;

char st[maxn];

ll Ans[maxn];

ll f[maxn],g[maxn];

int fail[maxn];

void solve1(ll p,int t){
	REP(i,1,n-fail[n])Ans[st[i]-'a']+=p/(n-fail[n])*t;
	REP(i,1,p%(n-fail[n]))Ans[st[i]-'a']+=t;
}

void solve2(ll p,int t){
	if(p<=n*2){
		REP(i,1,p)Ans[st[i]-'a']+=t;
		return;
	}
	f[0]=0;g[0]=1;
	f[1]=1;g[1]=0;
	REP(i,2,10000){
		f[i]=f[i-1]+f[i-2];
		g[i]=g[i-1]+g[i-2];
		if(f[i]*n+g[i]*(n-fail[n])>p){
			REP(j,1,n)Ans[st[j]-'a']+=t*f[i-1];
			REP(j,1,n-fail[n])Ans[st[j]-'a']+=t*g[i-1];
			solve2(p-f[i-1]*n-g[i-1]*(n-fail[n]),t);
			return;
		}
	}
}

void Work(){
	if(!(n%(n-fail[n]))){
		solve1(r,1);solve1(l-1,-1);
	}
	else{
		solve2(r,1);solve2(l-1,-1);
	}
	REP(i,0,25)printf("%lld ",Ans[i]);
}

void Init(){
	scanf("%s",st+1);
	read(l,r);
	n=strlen(st+1)/2;
	REP(i,2,n){
		int j;
		for(j=fail[i-1];j&&st[j+1]!=st[i];j=fail[j]);
		if(st[j+1]==st[i])fail[i]=j+1;
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI mar;
set<in> us;
vector<pair<in,in> > sp;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  mar.resize(n);
  forn(i,n){
    cin>>mar[i];
    sp.PB(MP(mar[i],i));
  }
  sort(all(sp));
  in sm=0;
  us.insert(-1);
  us.insert(n);
  set<in>::iterator it;
  in u,v;
  forv(i,sp){
    it=us.lower_bound(sp[i].second);
    u=*it;
    u-=sp[i].second;
    --it;
    v=sp[i].second;
    v-=*it;
    sm+=u*v*sp[i].first;
    us.insert(sp[i].second);
  }
  cout<<sm<<endl;
  return 0;
}


Measured memory_bytes: 14316
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include <limits.h>
using namespace std;

int dis(int a, int b) {
  int D = a - b;  
  if(D > 0)    return D;
  else         return -D;
}

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> a(N);
  vector<int> b(N);
  
  for(int i = 0; i < N; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  
  vector<int> c(M);
  vector<int> d(M);
  
  for(int i = 0; i < M; i++) {
    cin >> c.at(i) >> d.at(i);
  }

  vector<int> D(M);
  for(int i = 0; i < N; i++) {
    int number = 0;
    int min = INT_MAX;
    for(int j = 0; j < M; j++) {
      D.at(j) = dis(a.at(i), c.at(j)) + dis(b.at(i), d.at(j));
      if(min > D.at(j)) {
        min = D.at(j);
        number = j;
      }
    }
    cout << number + 1 << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

signed main(){
  fastio
  int n,k;cin>>n>>k;
  map<int,int>m;
  for(int i=0;i<k;i++){
    int N;cin>>N;
    for(int i=0;i<N;i++){
      int x;cin>>x;m[x]++;
    }
  }
  cout<<n-m.size()<<"\n";
  return 0;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

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

  int size = int(s.size());

  for (char i = 'a'; i <= 'z'; i++)
  {
    bool flag = true;
    for (int j = 0; j < size; j++)
    {
      if(s[j] == i){
        flag = false;
        break;
      }
    }
    if(flag)
    {
      cout << i << endl;
      return 0;
    }
  }
  cout << "None" << endl;

}


Measured memory_bytes: 512
#![allow(unused_imports, dead_code)]
use std::f64::*;
use std::cmp::*;
use std::collections::*;

macro_rules! dump{
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const INF: i64 = 0x3f3f3f3f3f3f3f3f;
const MOD: i64 = 1000000007;
const NOTHING: usize = std::usize::MAX;
const DX: [usize; 4] = [1, 0, std::usize::MAX, 0];
const DY: [usize; 4] = [0, 1, 0, std::usize::MAX];

fn main() {
    let s: Vec<char> = readln();
    let mut l = 0;
    let mut r = s.len() - 1;

    let mut res = 0;
    while l < r {
        if s[l] == s[r] {
            l += 1;
            r -= 1;
        } else if s[l] == 'x' {
            l += 1;
            res += 1;
        } else if s[r] == 'x' {
            r -= 1;
            res += 1;
        } else {
            println!("-1");
            return;
        }
    }

    println!("{}", res);

}

trait Read {
    fn read(s: &str) -> Self;
}

fn readln<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}


Measured memory_bytes: 4352
module Int = struct
  type t = int
  let compare = compare
end

module IntMap = Map.Make (Int)

let () =
  let n, m = Scanf.scanf "%d %d\n" (fun n m -> n, m) in
  let es =
    let es = Array.make n [] in
    for i = 1 to m do
      Scanf.scanf "%d %d %d\n" (fun l r d ->
        es.(l - 1) <- (r - 1, d) :: es.(l - 1);
        es.(r - 1) <- (l - 1, -d) :: es.(r - 1))
    done;
    fun v -> es.(v) in
  let rec dfs m v =
    List.fold_left (fun m (u, d) ->
      if IntMap.mem u m then
        if IntMap.find v m + d = IntMap.find u m then m
        else raise Not_found
      else dfs (IntMap.add u (IntMap.find v m + d) m) u) m (es v) in
  try
    Array.init n (fun v -> v)
    |> Array.fold_left (fun m v ->
        if IntMap.mem v m then m
        else dfs (IntMap.add v 0 m) v) IntMap.empty
    |> (fun _ -> print_endline "Yes")
  with Not_found -> print_endline "No"

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

bool has[200];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int N, K; gi(N), gi(K);
	set<int> v;
	while(K--) {
		int g; gi(g);
		while(g--) {
			int p; gi(p);
			v.insert(p);
		}
	}
	print(N-v.size());
}


Measured memory_bytes: 3652
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val k = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    val b = Array(m) { sc.nextInt() }
    var i = -1
    var j = -1
    var ans = 0
    var time = 0L
    while (i + 1 < n && time + a[i + 1] <= k) {
        time += a[i + 1]
        i++
    }
    while (i >= -1) {
        while (j + 1 < m && time + b[j + 1] <= k) {
            time += b[j + 1]
            j++
        }
        val v = i + j + 2
        ans = maxOf(ans, v)
        if (i >= 0) {
            time -= a[i]
        }
        i--
    }
    println(ans)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

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

typedef unsigned long long ull;

int main(){
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	ull a = 1, b = 1;
	int n; cin >> n;
	for(int i = 0; i < n; i++){
		ull x, y; cin >> x >> y;
		ull l = 1, r = 1e19, s = 1;
		while(l <= r){
			ull m = (l + r) / 2;
			if(x >= (a + m - 1) / m && y >= (b + m - 1) / m){
				s = m;
				r = m - 1;
			} else l = m + 1;
		}
		a = x * s; b = y * s;
	}
	cout << a + b << '\n';
}


Measured memory_bytes: 3648
S = str(input())
flag = 0

for i in range(0,len(S)):
  if i%2 == 0:
    if S[i] != "R" and S[i] != "U" and S[i] != "D":
      flag = flag+1
  elif i%2 == 1:
    if S[i] != "L" and S[i] != "U" and S[i] != "D":
      flag = flag+1
if flag == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(),x.end()
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define PI 3.1415926535897932384626
#define mod 1000000007
#define modd 998244353

void io() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	io();
	
	ll n,d;
	cin>>n>>d;
	int ans=0;
	for(int i=0;i<n;i++) {
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d) ans++;
	}
	cout<<ans;
 	return 0;
}


Measured memory_bytes: 3652
/*
 *  Created on: 28 / 6 / 2020
 *  Author:     Eslam Waheed
 */

#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO

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

#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)
#define test(t)      while(t--)

//ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ld PI = acos(-1);
//const ll mod = 1e9 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed
        ll a; cin >> a;
    cout << (ll)(a + pow(a, 2) + pow(a, 3));
}

Measured memory_bytes: 4044
fun main(args:Array<String>):Unit{
    while(true){
        val n = readLine()!!.toInt()
        if (n == 0) return
        var max = 0
        var current = 0
        Array(n){
            val arg = readLine()!!.split(' ')
            val (sh, sm, ss) = arg.first().split(':').map(String::toInt)
            val (th, tm, ts) = arg.last().split(':').map(String::toInt)
            listOf(Time(sh, sm, ss, true), Time(th,tm,ts, false))
        }.flatMap { it }.sortedWith(compareBy(Time::hour, Time::minute, Time::second, Time::isStart)).forEach{
            if (it.isStart)
                ++current
            else
                --current
            if (current > max)
                max = current
        }
        println(max)
    }
}
data class Time(val hour:Int, val minute:Int, val second:Int, val isStart:Boolean)


Measured memory_bytes: 80344
#include<bits/stdc++.h>
#include<climits>
 
using namespace std;
 
#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()
 
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<int,int>> vpi;
 
const long long OO = 2e18;
const double pi=2*acos(0.0);
 
bool isprime(long long int a){
    if(a==1){
        return false;
    }
    for(int i=2;i*i<=a;i++){
        if(a%i==0){
            return false;
        }
    }
    return true;
} 

bool iscoprime(int a,int b){
    int i;
    for(i=2;i<=min(a,b);i++){
        if(a%i==0 && b%i==0){
            return false;
        }
    }
    return true;
}

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

int maxA(vi a){
    int m=0;
    for(int i=0;i<a.size();i++){
        m=max(m,a[i]);
    }
    return m;
}

int minA(vi a){
    int m=100000;
    for(int i=0;i<a.size();i++){
        m=min(m,a[i]);
    }
    return m;
}

vi freqN(vi a, int n){
    vi f(n);
    f={0};
    for(int i=0;i<a.size();i++){
        f[a[i]]++;
    }
    return f;
}

vi freqA(vi a){
    vi f(26);
    f={0};
    for(int i=0;i<a.size();i++){
        f[a[i]-'0']++;
    }
    return f;
}

bool mycomp(const pair<long int,long int>&p1 , const pair<long int,long int>&p2){
    if(p1.second < p2.second) return true;
    else if(p1.second==p2.second) return p1.first<p2.first;
    else return false;
}

unsigned int rightmostsetbit(unsigned int n){
    return n & -n;
}

bool cmp(pair<string,int>&p1 , pair<string,int>&p2){
    if(p1.second==p2.second) return p1.first<p2.first;
    return p1.second>p2.second;
}

int main(){
fast;
cin.tie(0);
lld n;
cin>>n;
if(n%2==1){
    cout<<"0"<<endl;
}
else{
    lld t=n/2;
    lld ans=0;
    lld e=5;
    for(lld i=1;i<=26;i++){
        ans+=(t/e);
        e*=5;
    }
    cout<<ans<<endl;
}

}

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

void KMP(string T, string P){
	int t=T.size();
	int p=P.size();
	int i,j,k;
	
	//?????????????????????
	vector<int> next(p);
	int nex;
	i=2;
	j=0;
	if(p==1){
		next[0]=-1;
		nex=0;
	}else{
		next[0]=-1;
		next[1]=0;
		while(i<p+1){
			if(P[i-1]==P[j]){
				if(i==p){
					nex=j+1;
				}else{
					next[i]=j+1;
				}
				i++;
				j++;
			}else if(j>0){
				j=next[j];
			}else{
				if(i==p){
					nex=0;
				}else{
					next[i]=0;
				}
				i++;
			}
		}
	}
	i=0;
	j=0;
	while(i<t){
		//cout << i << " "<< j<<endl;
		if(T[i+j]==P[j]){
			j++;
			if(j==p) {
				printf("%d\n",i);
				i++;
				j=nex;
			}
		}else{
			i=i+j-next[j];
			if(j>0){j=next[j];}
		}
	}
	
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string T,P;
	cin >> T >> P;
	KMP(T,P);
	return 0;
}

Measured memory_bytes: 3096
def t(h):
    a = 0
    b = h[0]
    r = 0
    for i in h[1:]:
        if b >= i:
            a += 1
            if r < a:
                r = a
        else:
            a = 0
        b = i
    return r


if __name__ == '__main__':
    n = input()
    h = list(map(int, input().split()))
    print(t(h))

Measured memory_bytes: 14252
from bisect import bisect_left,bisect_right
from itertools import combinations
N = int(input())
L = sorted(list(map(int,input().split())))
cnt = 0
for x in combinations(range(N),2):
    i,j = x[0],x[1]
    if j<i:
        i,j = j,i
    indr = bisect_left(L,L[i]+L[j])
    indl = bisect_right(L,abs(L[i]-L[j]))
    if j<indl or i>indr:
        cnt += indr-indl
    elif indr>j>=indl and i<indl:
        cnt += indr-indl-1
    elif indr>j and i>=indl:
        cnt += indr-indl-2
    elif j>=indr and indr>i>=indl:
        cnt += indr-indl-1
print(cnt//3)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001


const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}



int main() {
    ll n, k;

    cin >> n >> k;
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    for (int i=1; i<=k; i++) {
        ll ans = 0;
        ans = comb(n-k+1, i) * comb(k-1, i-1) % M;
        cout << ans << endl;
    }

}



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

using namespace std;

#define pb push_back
typedef long long int lli;

int main() {
    int x, y, z, k;
    lli a[1000], b[1000], c[1000];

    cin >> x >> y >> z >> k;
    for (int i=0; i<x; i++) scanf("%lld", &a[i]);
    for (int i=0; i<y; i++) scanf("%lld", &b[i]);
    for (int i=0; i<z; i++) scanf("%lld", &c[i]);

    vector<lli> ab;
    for (int i=0; i<x; i++) {
        for (int j=0; j<y; j++) {
            ab.pb(a[i] + b[j]);
        }
    }
    sort(ab.begin(), ab.end(), greater<lli>());

    vector<lli> abc;
    int ab_lim = min(3000, x*y);
    for (int i=0; i<ab_lim; i++) {
        for (int j=0; j<z; j++) {
            abc.pb(ab[i] + c[j]);
        }
    }
    sort(abc.begin(), abc.end(), greater<lli>());

    for (int i=0; i<k; i++) {
        cout << abc[i] << endl;
    }

    return 0;
}


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

int main(){
    int H, W;
    
    while(1){
        cin >> H >> W;
        
        if(H == 0 && W == 0) break;
        
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(i == 0 || i == (H - 1) || j == 0 || j == (W - 1)){
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3116