akhauriyash/Code-Regression huggingface dataset:
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let mut n: isize = read();
    for i in 1..10 {
        if n%i == 0 {
            if n / i <= 9 {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    ll a, bn;
    string b;
    cin >> a >> b;
    bn = (b[0] - '0') * 100;
    if (b.size() >= 3) { bn += (b[2] - '0') * 10; }
    if (b.size() >= 4) { bn += (b[3] - '0'); }
    cerr << "bn=" << bn << endl;
    cout << a * bn / 100;
    return 0;
}


Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static boolean is_ok(int x, int y, int H, int W){
		if(x < 0 || x >= W || y < 0 || y >= H){
			return false;
		}else{
			return true;
		}
	}
	
	public static int[][][] move_dir = new int[][][]{{{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, -1}, {1, 1}}, {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {-1, 1}, {-1, -1}}};
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int W = sc.nextInt();
		final int H = sc.nextInt();
		
		boolean[][] is_wall = new boolean[H + 2][W + 2];
		boolean[][] visited = new boolean[H + 2][W + 2];
		
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				is_wall[i + 1][j + 1] = sc.nextInt() == 1;
			}
		}
		
		LinkedList<Integer> x_queue = new LinkedList<Integer>();
		LinkedList<Integer> y_queue = new LinkedList<Integer>();
		
		int wall_count = 0;
		
		x_queue.add(0);
		y_queue.add(0);
		visited[0][0] = true;
		
		//System.out.println(wall_count);
		
		while(!x_queue.isEmpty()){
			final int x = x_queue.poll();
			final int y = y_queue.poll();
			
			for(int[] move : move_dir[1 - y % 2]){
				final int nx = x + move[0];
				final int ny = y + move[1];
				
				if(!is_ok(nx, ny, H + 2, W + 2)){
					continue;
				}else if(visited[ny][nx]){
					continue;
				}else if(is_wall[ny][nx]){
					wall_count++;
					//System.out.println((x + 1) + " " + (y + 1) + " " + (nx + 1) + " " + (ny + 1));
					continue;
				}
				
				x_queue.add(nx);
				y_queue.add(ny);
				visited[ny][nx] = true; 				
			}
		}
		
		System.out.println(wall_count);
	}

}

Measured memory_bytes: 37028
#include <stdio.h>

int main(void)
{
	int y, m, d, y2, m2, d2;
	int i, j;
	int ans;
	char month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	
	while (1){
		scanf("%d %d %d %d %d %d", &y, &m, &d, &y2, &m2, &d2);
		
		if (y < 0 || m < 0 || d < 0 || y2 < 0 || m2 < 0 || d2 < 0){
			break;
		}
		
		ans = 0;
		
		while (1){
			
			if (y == y2 && d == d2 && m == m2){
				break;
			}
			
			ans++;
			d++;
			
			if (d > month[m - 1]){
				d = 1;
				m++;
			}
			if (m > 12){
				m = 1;
				y++;
			}
			
			if ( (y % 4 == 0 && y % 100 != 0) || y % 400 == 0){
				month[1] = 29;
			}
			else {
				month[1] = 28;
			}
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x, y, s;
    while(cin >> x >> y >> s, x || y || s){
        ll kai = 0;
        rep(a, 1, s+1) rep(b,1,s+1){
            if(a*(100 + x)/100 + b*(100 + x)/100 == s){
                chmax(kai, a*(100 + y)/100 + b*(100+y)/100);
            }
        }
        cout << kai << endl;
    }
}


Measured memory_bytes: 3212
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC178
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var x = Console.ReadLine();
            if (x == "0")
            {
                Console.WriteLine("1");
            }
            else
            {
                Console.WriteLine("0");
            }
        }
    }
}


Measured memory_bytes: 25880
N = STDIN.gets.strip.to_i
as = STDIN.gets.strip.split.map(&:to_i)

max_from_left = [as[0]]
answer = 1
1.upto(N-1) do |i|
  max_from_left[i] = [max_from_left[i-1], as[i]].max
  answer += 1 if max_from_left[i-1] <= as[i]
end
puts answer


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

int main() {
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 1e18;
    vector<ll> mincost(n, 1e18);
    rep(i, n) {
        ll tmp = 0;
        rep(j, n) {
            mincost[j] = min(mincost[j], a[(i + j) % n]);
            tmp += mincost[j];
        }
        ans = min(ans, tmp + x * i);
    }
    cout << ans << endl;
}

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

const ll INF = 1e18;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  vector<ll> s(n);

  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  s[0]=a[0]%k;
  rep(i,n-1){
    s[i+1]=s[i]+a[i+1];
    s[i+1]%=k;
  }
  map<ll,ll>mp;
  mp[0]++;
  ll cnt=0;
  rep(i,n){
    if (i==k-1)mp[0]--;
    if (i>=k){
      mp[s[i-k]]--;
    }
    cnt+=mp[s[i]];
  //  cout<<s[i]<<'s'<<cnt<<'c'<<i<<'i'<<endl;
    mp[s[i]]++;

  }
cout<<cnt;

}


Measured memory_bytes: 18780
#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() {
  string S;
  cin>>S;
  
  int a=S.size();
  
  rep(i,a){
    cout<<'x';
  }
  
}


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

int main() {
    string c;
    bool ans;
    
    cin >> c;
    
    switch (c[0]) {
        case 'a':
        case 'i':
        case 'u':
        case 'e':
        case 'o':
            ans = true;
            break;
        default:
            ans = false;
            break;
    }
    
    cout << (ans ? "vowel" : "consonant") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		  Scanner sc = new Scanner(System.in);
		  int N = sc.nextInt();
		  String S = sc.next();
		  sc.close();
		  
		  int answer = 0;
		  
		  for(int j = 1; j < N; j++) {
			  List<Character> aList = new ArrayList<>();
			  List<Character> bList = new ArrayList<>();
			  String a = S.substring(0, j);
			  String b = S.substring(j, N);

			  for(int i = 0; i < a.length(); i++) {
				  if(!aList.contains(a.charAt(i))) aList.add(a.charAt(i));
			  }
			  
			  for(int i = 0; i < b.length(); i++) {
				  if(!bList.contains(b.charAt(i))) bList.add(b.charAt(i));
			  }
			  
			  char alphabet = 'a';
			  int count = 0;
			  for(int i = 0; i < 26; i++) {
				  if(aList.contains((char)(alphabet + i)) && bList.contains((char)(alphabet + i))) {
					  count++;
				  }
			
			  }
			  answer = Math.max(answer, count);
		  }
		  
		  System.out.println(answer);
	          System.exit(0);
	    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int x,y;
  cin >> x >> y;
  cout << x + y/2 << endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  cout<<a.at(N-1)-a.at(0)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

int a, b, c, k;

main(){
    scanf("%d%d%d%d", &a, &b, &c, &k);
    printf("%d\n", min(k, a) - max(0, k-a-b));
}

Measured memory_bytes: 1732
#include <iostream>

void input_array(int a[], int n){
    for(int i=0; i<n; i++){
        std::cin >> a[i];
    }
}

int max_value(int a[], int n){

  int minv = a[0];
  int maxv = a[1] - minv;

  for(int i=1; i<n; i++){
    maxv = (maxv < (a[i]-minv)) ? a[i]-minv : maxv;
    minv = (minv < a[i]) ? minv : a[i];
  }

  return maxv;
}


int main(){

    int n;
    std::cin >> n;
    int R[n];
    input_array(R,n);
    int v = max_value(R,n);
    std::cout << v << '\n';
    return 0;
}



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

typedef long long ll;

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

    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        --a[i];
    }
    vector<bool> visited(n);
    vector<int> Q;
    int t = 0;
    while (!visited[t]) {
        visited[t] = true;
        Q.push_back(t);
        t = a[t];
    }
    int i = 0;
    while (i < Q.size() && Q[i] != t) ++i;
    if (k < i) {
        cout << Q[k] + 1 << '\n';
    } else {
        k = (k - i) % (Q.size() - i);
        cout << Q[i + k] + 1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 5104
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  int n;
  ci(n);
  ve<pair<int, int>> A(n);
  rep(i, n){
    int a, b;
    ci(a, b);
    A.at(i) = mp(b, a);
  }
  sort(all(A));
  int cnt = 0;
  rep(i, n){
    cnt += A.at(i).sc;
    if(cnt > A.at(i).ft){
      co("No");
      rt 0;
    }
  }
  co("Yes");
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 2e5 + 5 ; 
struct E {
	int to, next, w ; 
} e[N << 1] ; 
struct node {
	int x, y, z ; 
} st[N * 20], sk[N] ;
int n, cnt, rt, top, top2, sum, head[N], fa[N], vis[N], w[N], dp[N], sz[N] ; 
bool cmp( node x, node y ) {
	return x.z < y.z ; 
} 
void add( int x, int y, int z ) {
	e[++ cnt] = (E){ y, head[x], z }, head[x] = cnt,
	e[++ cnt] = (E){ x, head[y], z }, head[y] = cnt ; 
}
void Getrt( int x, int fa ) {
	sz[x] = 1, dp[x] = 0 ; 
	Next( i, x ) {
		int v = e[i].to ; if( v == fa || vis[v] ) continue ; 
		Getrt(v, x), sz[x] += sz[v], dp[x] = max( dp[x], sz[v] ) ; 
	} dp[x] = max( dp[x], sum - sz[x] ) ; 
	if( dp[x] <= dp[rt] ) rt = x ; 
}
void Getd( int x, int fa, int d ) {
	sz[x] = 1, sk[++ top2] = (node){ x, 0, d + w[x] } ; 
	Next( i, x ) {
		int v = e[i].to ; if( v == fa || vis[v] ) continue ; 
		Getd( v, x, d + e[i].w ), sz[x] += sz[v] ; 
	}
}
void solve( int x ) {
	vis[x] = 1, top2 = 0, Getd( x, x, 0 ) ; 
	sort( sk + 1, sk + top2 + 1, cmp ) ;
	rep( i, 2, top2 ) st[++ top] = (node){ sk[i].x, sk[1].x, sk[i].z + sk[1].z } ; 
//	printf("solve-  %d %d\n", x, top ) ; 
	Next( i, x ) {
		int v = e[i].to ; if( vis[v] ) continue ; 
		sum = dp[rt = 0] = sz[v], Getrt( v, x ), solve(rt) ; 
	}
}
int fd( int x ) {
	return ( x == fa[x] ) ? x : fa[x] = fd(fa[x]) ; 
}
int merge( int x, int y ) {
	int u = fd(x), v = fd(y) ;
	if( u == v ) return 0 ; 
	fa[u] = v ; return 1 ; 
}
signed main()
{
	n = gi() ; int x, y, z ; 
	rep( i, 1, n ) w[i] = gi() ; 
	rep( i, 2, n ) x = gi(), y = gi(), z = gi(), add( x, y, z ) ; 
	dp[rt = 0] = sum = n, Getrt( 1, 1 ) ; 
	rep( i, 1, n ) fa[i] = i ; 
	solve(rt), sort( st + 1, st + top + 1, cmp ) ; int ans = 0 ;
	//rep( i, 1, top ) printf("%d %d %d\n", st[i].x, st[i].y, st[i].z ) ; 
	rep( i, 1, top ) {
		if( merge( st[i].x, st[i].y ) ) ans += st[i].z ; 
	}
	cout << ans << endl ;  
	return 0 ;
}

Measured memory_bytes: 116252
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	double s;
	for(;cin>>s;){
		double t=s/9.8;
		double y=4.9*t*t;
		int n=y/5+1;
		if(5*n-5<y)n++;
		cout<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int a[110];

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

    for(int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    int ans = 0;

    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            if(i == j) {
                continue;
            }

            ans = max(ans, std::abs(a[i]-a[j]));
        }
    }

    cout << ans << endl;

    return 0;
}


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

const int _ = 2e5 + 7; int N , A[_];

int main(){
	ios::sync_with_stdio(0); cin >> N; for(int i = 1 ; i <= N ; ++i) cin >> A[i];
#define pii pair < int , int >
	vector < pii > trs; trs.push_back(pii(0 , 0));
	for(int i = 1 ; i <= N + 1 ; ++i){
		vector < pii > now;
		for(auto t : trs){
			int x = t.first , y = t.second , z = A[i - 1] - y;
			now.push_back(pii(x + (bool)y + (z < A[i]) , 0));
			if(y <= A[i]) now.push_back(pii(x + (A[i - 1] < A[i]) , y));
			if(z <= A[i]) now.push_back(pii(x + (y > A[i] - z) , A[i] - z));
		}
		sort(now.begin() , now.end()); trs = {now[0]};
		for(auto t : now) if(t.first != trs.back().first){trs.push_back(t); break;}
	}
	cout << trs[0].first; return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

ll n;
ll c, k;
ll a[100010];

int main(){

  n = in();
  c = in();
  k = in();

  REP( i , n ){
    a[i] = in();
  }

  sort( a , a + n );

  ll ans = 0;
  ll cnt = INF;
  ll cur = INF;
  
  REP( i , n ){
    if( cnt >= c or a[i] - cur > k ){
      ans++;
      cnt = 1;
      cur = a[i];
    } else {
      cnt++;
    }
  }

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


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

#define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i,n) FOR((i),0,(n))
#define FORCLS(i,a,b) for(int (i) = (a); i <= (b); (i)++)
#define REPCLS(i,n) FORCLS((i),1,(n))

using Int = long;
Int R,C,N;

Int getPos(Int x, Int y){
    if (x == 0) {
        return y;
    } else if (y == C) {
        return C + x;
    } else if (x == R) {
        return C + R + (C - y);
    } else if (y == 0) {
        return C + R + C + (R - x);
    } else {
        return -1;
    }
}

void solve() {
    cin >> R >> C >> N;
    vector<pair<Int,Int>> pos_inxs;
    REP(i, N){
        Int x0,y0, x1,y1;
        cin >> x0 >> y0 >> x1 >> y1;
        Int p0 = getPos(x0, y0);
        Int p1 = getPos(x1,y1);
        if (p0 >= 0 && p1 >= 0) {
            pos_inxs.push_back(make_pair(p0, i)); // (時計回りpos, index)
            pos_inxs.push_back(make_pair(p1, i));
        }
    }
    Int size = pos_inxs.size();
    if (size <= 1) {
        cout << "YES" << endl;
        return;
    }
    sort(&pos_inxs[0], &pos_inxs[0] + size);
    stack<Int> s;
    for (Int i = 0 ; i < size; i++){
        Int ix = pos_inxs[i].second;
        if (s.empty() || s.top() != ix){
            s.push(ix);
        } else {
            s.pop();
        }
    }
    cout << (s.empty() ? "YES" : "NO") << endl;
    
    return;
}

#ifdef DEBUG
#define MAIN hoge
#else
#define MAIN main
#endif

int MAIN() {
    solve();
    
    return 0;
}


Measured memory_bytes: 6384
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n,k = map(int,input().split())

for i in range(1,k+1):
	a = cmb(n-k+1,i,mod)
	b = cmb(k-1,i-1,mod)
	ans = (a*b)%mod
	
	print(ans)


Measured memory_bytes: 73884
#include <stdio.h>
int main (void)
{int a,b,c;

 scanf("%d %d %d",&a,&b,&c);
if(a==b&&b==c){printf("%d %d %d\n",a,b,c );}
else{

if(a<=b&&b<=c){printf("%d %d %d\n",a,b,c );}
else if(a<=c&&c<=b){printf("%d %d %d\n",a,c,b );}
else if(b<=a&&a<=c){printf("%d %d %d\n",b,a,c );}
else if(b<=c&&c<=a){printf("%d %d %d\n",b,c,a );}
else if(c<=a&&a<=b){printf("%d %d %d\n",c,a,b );}
else if(c<=b&&b<=a){printf("%d %d %d\n",c,b,a );}

}
return 0;	
}

Measured memory_bytes: 1800
#include <stdio.h>
int main(void){
    int a,b;
    char op;
    
    while(1){
    scanf("%d %c %d",&a, &op,&b);
    
    if(op == '+'){
        printf("%d\n",a + b);
    }else if(op == '-'){
        printf("%d\n",a - b);
    }else if(op == '*'){
        printf("%d\n",a * b);
    }else if(op == '/'){
        printf("%d\n",a / b);
    }
    else{
        break;
    }
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  string a,b;
  cin >> a >> b;
  if ((a == "H" && b == "H") || (a == "D" && b == "D")) {
    cout << "H" << "\n";
  } else {
    cout << "D" << "\n";
  }
}


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

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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
typedef long long ll;
const long long INF = 1e9;

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

  vector<int> dp(n + 1, INF);
  dp[0] = 0;
  for (int i = 1; i < n; i++)
  {
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if(i > 1){ //2つ目以降のときだけ通す
      chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
  }

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


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 3e3+5;
const int MOD = 1e9+7;


int N; 
int mat[20][20];
const ll inf = 1e15;

ll dp[(int)(1<<17)];
ll sumval[(int)(1<<17)];

ll solve(int S) {
    if(!S)   return 0;
    if(dp[S]!=inf)   return dp[S];
    ll ans = 0;
    for(int m = S; m; m=(m-1)&S) 
        ans = max(ans,sumval[m]+solve(m^S));
    return dp[S] = ans;
}

int main(){

    FIO
    cin>>N;
    f(i,0,N-1) f(j,0,N-1) cin>>mat[i][j];
    memset(sumval,0,sizeof(sumval));
    f(i,1,(1<<N)-1) {
        f(j,0,16)   f(k,j+1,16) 
            if((i>>j)&1 and (i>>k)&1)  sumval[i] += mat[j][k]; 
        dp[i] = inf;
    }
    cout<<solve(((1<<N)-1))<<endl;
    return 0;

}
    


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int di2[] = {1, 1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1};
const int dj2[] = {1, -1, 1, -1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;


int main(){
  string s; cin >> s;
  int a, b, c, d;
  a = s[0]-'0';
  b = s[1]-'0';
  c = s[2]-'0';
  d = s[3]-'0';
  vector<char> ope = {'+', '-'};
  rep(i, 2) rep(j, 2) rep(k, 2) {
    if(a + b*(int)pow(-1, i) + c*(int)pow(-1, j) + d*(int)pow(-1, k) == 7) {
      cout << a << ope[i] << b << ope[j] << c << ope[k] << d << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3816
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC070
{
    class Program
    {
        static void Main()
        {
            int[] inputs = Console.ReadLine().Split(' ')
                        .Select(int.Parse)
                        .ToArray();
            Console.WriteLine(Math.Max(0, (Math.Min(inputs[1], inputs[3]) - Math.Max(inputs[0], inputs[2]))));
        }
    }
}

Measured memory_bytes: 13268
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;

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

double dist(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

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

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

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

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}

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

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

vec eratosthenes(ll N){
  ll i;
  vec p,ch(N+1,1);
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return p;
}
int main(){
  ll i=2,j,N,M,a,b,ans=1,cnt;
  cin>>N>>M;
  N=gcd(N,M);
  vec v;
  set<ll> se;
  M=N;
  while(i*i<M){
    while(!(N%i)){
      v.push_back(i);
      se.insert(i);
      N/=i;
    }
    i++;
  }
  v.push_back(N);
  se.insert(N);
  se.insert(1);
  ans=se.size();
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    //System.out.println(n);
    int count = 0;
    for (int i = 1;i <= n; i++) {
      if(i%2 == 1) {
       count += 1; 
       //System.out.println(count);
      }else{
       count += 0;  
       //System.out.println("偶数");
      }
    }
    System.out.println((float)count / n);
  }
}


Measured memory_bytes: 21972
while true
    n, m = gets.chomp.split.map(&:to_i)
    break if [n, m] == [0, 0]

    arr = Array.new(n, 0)
    m.times{gets.chomp.split.map(&:to_i).each_with_index{|p, i| arr[i] += p}}
    puts arr.max
end


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

#define FOR(i,n)    for(lli i=0;i<(lli)(n);++i)
#define FORU(i,j,k) for(lli i=(j);i<=(lli)(k);++i)
#define FORD(i,j,k) for(lli i=(j);i>=(lli)(k);--i)

#define pb push_back
#define mt make_tuple

using namespace std;

using lli = long long int;
using pll = pair<lli, lli>;

using vi = vector<lli>;
using vvi = vector<vi>;
using pii = tuple<lli, lli>;
using vii = vector<pii>;
using vvii = vector<vii>;

#define X(a) get<0>(a)
#define Y(a) get<1>(a)
#define Z(a) get<2>(a)

string TYPE(const int*)          { return "%d";   }
string TYPE(const lli*)          { return "%lld"; }
string TYPE(const char*)         { return "%c";   }
string TYPE(const char**)        { return "%s";   }
string TYPE(const unsigned int*) { return "%u";   }

const int MAX_BUF = 100*1000+42;
char buf[MAX_BUF];

void RD() {}
template<typename T, typename... Args> 
void RD(T* v, Args... args)
{
    scanf((" " + TYPE(v)).c_str(), v);
    RD(args...);
}
template<typename... Args> 
void RD(string* v, Args... args)
{
    scanf(" %s", buf);
    (*v) = buf;
    RD(args...);
}

void PR(bool nl = true)
{ if(nl) printf("\n"); }
template<typename T, typename... Args> 
void PR(bool nl, T v, Args... args)
{
    printf((TYPE(&v) + " ").c_str(), v);
    PR(nl, args...);
}
template<typename... Args> 
void PR(bool nl, string& v, Args... args)
{
    printf("%s", v.c_str());
    PR(nl, args...);
}
template<typename... Args> 
void PR(Args... args)
{ PR(true, args...); }

const long long int oo = 1000*1000*1000;

struct Coord {
    int x, y;
    Coord(int x = 0, int y = 0) : x(x), y(y) {}
    Coord operator + (const Coord& droite) const
    { return Coord(x + droite.x, y + droite.y); }
};

struct AB {
    int k; vector<lli> arbre;
    AB(int _k = 20, lli def = 0) { k = _k;
        FOR(i, 1 << k)
            arbre.push_back(i < (1 << (k-1)) ? 0LL : def);
        FORD(i, ((1 << (k-1)) - 1), 1)
            arbre[i] = arbre[i << 1] + arbre[(i << 1) ^ 1];
    }
    void set(int i, lli x) { int feuille = i + (1 << (k-1));
        arbre[feuille] = x;
        iset(feuille >> 1);
    }
    void iset(int noeud) {
        if(noeud) {
            arbre[noeud] = arbre[noeud << 1] + arbre[(noeud << 1)  ^ 1];
            iset(noeud >> 1);
    }   }
    lli sum(int deb, int fin, int noeud = 1, int p = 0, int q = -1) {
        if(q < p) q = 1 << (k-1);
        if(deb <= p && q <= fin) return arbre[noeud];
        if(deb >= q || fin <= p) return 0LL;
        int mil = (p + q) / 2;
        return sum(deb, fin, noeud << 1, p, mil) + sum(deb, fin, (noeud << 1) ^ 1, mil, q);
    }
};

lli d[200*1000+42];
lli t[200*1000+42];

int main()
{
    int n; RD(&n);
    FOR(i, n) RD(d+i);
    sort(d, d+n);
    int m; RD(&m);
    FOR(i, m) RD(t+i);
    sort(t, t+m);
    int curD = 0;
    FOR(i, m) {
        while(curD < n && d[curD] < t[i])
            ++curD;
        if(curD == n || d[curD] > t[i]) {
            PR("NO");
            return 0;
        }
        assert(d[curD] == t[i]);
        ++curD;
    }
    PR("YES");
    return 0;
}


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

k=[0]*60
K=[0]*60
for i in range(N):
  t=A[i]
  for j in range(60):
    if t%2==1:
      k[j]+=1
    t=t//2
    if t<1:
      break
a=1
sumxor=0
for i in range(60):
  K[i]=k[i]*(N-k[i])
  a=a%(10**9+7)
  sumxor=(sumxor+K[i]*a%(10**9+7))%(10**9+7)
  a=a*2
print(sumxor)

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



int main() {
  ll n,k;
  cin>>n>>k;
  ll a[n];
  ll ok=0,temp1=0;
  rep(i,n) cin>>a[i];
  rep(i,n){
      if(temp1<a[i]) ok++,temp1=a[i];
      else break;
  }
  if(k<=ok){
      cout<<0<<endl;
      return 0;
  } 
  ll ans=100000000000000000;
  for(ll bit=0;bit<(1LL<<(n-ok));bit++){

      ll cansee=0;
      for(ll i=0;i<n-ok;i++){
          if(bit&(1LL<<i)) cansee++;
      }
      if(cansee>=k-ok){
          ll temp2=temp1;
          ll yen=0;

          for(ll i=0;i<n-ok;i++){

            if(bit&(1LL<<i)){
                if(temp2==a[i+ok]){
                     yen++;
                    temp2++;
                }
                else if(temp2>a[i+ok]){
                     yen+=(temp2-a[i+ok]+1);
                    temp2++;
                }
                else{
                    temp2=a[i+ok];
                } 
            }
            else{
                if(temp2<a[i+ok]) temp2=a[i+ok];
            }

          }
          ans=min(ans,yen);

      }
      
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    int H, W, h, w;
    Scanner in = new Scanner(System.in);
    H = in.nextInt();
    W = in.nextInt();
    h = in.nextInt();
    w = in.nextInt();
    System.out.printf("%d\n", (H-h)*(W-w));
  }
}


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

using namespace std;
using ll = long long;

int main(void)
{
    ll a, b, x, ap, bp;
    cin >> a >> b >> x;

    ap = (a + x - 1) / x;
    bp = b / x;

    cout << bp - ap + 1 << endl;

    return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
int N;
ll A[10005];
map<ll, ll> M[10005], lcp;

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

// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N) {
    map<ll, ll> ret = prime_factor(A[i]);
    M[i] = ret;
    for(auto p : ret) {
      lcp[p.first] = max(p.second, lcp[p.first]);
    }
  }

  ll mod_lcp =  1ll;
  for(auto p : lcp) {
    mod_lcp *= pow(p.first, p.second);
    mod_lcp%=MOD;
  }
  
  ll ans = 0ll;
  rep(i, N) {
    ans+=mod_lcp*modinv(A[i], MOD)%MOD;
    ans%=MOD;
  }
  while(ans<0) ans+=MOD;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3968
L, R = map(int, input().split())
if R - L > 2019:
    print(0)
else:
    ans = (L * R) % 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            if ans > (i*j)%2019:
                ans = (i*j)%2019
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	ll n, d;
	cin >> n >> d;
	ll ans = 0;
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		if (x * x + y * y <= d*d) ans++;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 3556
N = gets.to_i
a = gets.strip.split.map(&:to_i)

b = a.select{|n| n % 4 == 0}.size
c = a.select{|n| n % 2 == 1}.size

if b >= c || (N % 2 == 1 && b >= (N / 2))

    puts "Yes"

else

    puts 'No'

end

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

int n,m;
std::vector<int> edge[21];
std::vector<int> prev[21];
int color[21];
void topological(int x){
	for(int i=0;i<prev[x].size();i++){
		topological(prev[x][i]);
	}
	if(color[x])return;
	color[x]=1;
	cout<<x<<endl;
	for(int i=0;i<edge[x].size();i++){
		topological(edge[x][i]);
	}
}
int main(void){
	int a,b;
	cin>>m>>n;
	for(int i=0;i<=m;i++)color[i]=0;
	while(n--){
		cin>>a>>b;
		edge[a].push_back(b);
		prev[b].push_back(a);
	}
	/*
	for(int i=1;i<=m;i++){
		cout<<"prev:"<<i<<endl;
		for(int j=0;j<prev[i].size();j++){
			cout<<"\t"<<prev[i][j]<<endl;
		}
		cout<<"next:"<<i<<endl;
		for(int j=0;j<edge[i].size();j++){
			cout<<"\t"<<edge[i][j]<<endl;
		}
	}
	*/
	for(int i=1;i<=m;i++){
		if(prev[i].size()==0){
			topological(i);
			break;
		}
	}
	// for(int i=1;i<=m;i++){
		// if(!color[i])cout<<i<<endl;
	// }
	return 0;
}

Measured memory_bytes: 3148
n,k=map(int, input().split())
prob = 0
#サイコロの確率(1/n) 

for i in range(1,n+1):
    if i < k: #サイコロを振った時点で勝っているか？
        a = 1
        while i * (2**a) < k:
            a += 1
        prob += (1/n) * ((1/2) ** a)
    else:
        prob += (1/n)
print(prob)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
struct tim {
    int st,ed,index;
};
bool compare(tim t1,tim t2){
    if(t1.ed==t2.ed)
        return t1.st < t2.st;
    return t1.ed < t2.ed;
}
void update(int index,int* BIT,int value,int n){
    for(int i=index;i<=n;i+=(i&(-i))){
        BIT[i] += value;
    }
}
int queries(int index,int* BIT){
    int count = 0;
    for(int i=index;i>0;i-=(i&(-i))){
        count += BIT[i];
    }
    return count;
}
int main()
{
    int n,q;
    cin>>n>>q;
    int* a = new int[n+1]();
    for(int i=1;i<n+1;i++)
        cin>>a[i];
    // cin>>q;
    
    tim* query = new tim[q];
    for(int i=0;i<q;i++){
        cin>>query[i].st>>query[i].ed;
        query[i].index = i;
    }
    int* BIT = new int[n+1]();
    int* repeat = new int[n+1];
    int* arr = new int[q];
    for(int i=0;i<n+1;i++)
        repeat[i] = -1;
    
    
    sort(query,query + q,compare);
    int j = 1;
    for(int i=0;i<q;i++){
        int starttime = query[i].st;
        int endtime = query[i].ed;
        while(j<n+1 && j<=endtime)
        {
            int ind = repeat[a[j]];
            if(repeat[a[j]]!=-1)
                update(ind,BIT,-1,n);
            
            update(j,BIT,1,n);
            repeat[a[j]] = j;
            j++;
        }
        arr[query[i].index] = queries(endtime,BIT) - queries(starttime-1,BIT);
    }
    for(int i=0;i<q;i++)
        cout<<arr[i]<<endl;
    return 0;
}


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

int main()
{
	int x, r500, r5;
	cin >> x;
	r500 = x / 500;
	r500 *= 1000;
	r5 = (x % 500) / 5;
	r5 *= 5;
	cout << r500 + r5;
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d, n;
  cin >> d >> n;
  int base = pow(100, d);
  if (n != 100) {
    cout << base * n << endl;
  } else {
    cout << base * 101 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int SET(int N, int pos)  {return N=N | (1<<pos);}
int RSET(int N,int pos)  {return N= N & ~(1<<pos);}
bool CHK(int N,int pos)  {return (bool)(N & (1<<pos));}

#define ll             long long
#define pll            pair<ll,ll>
#define unique(a)      a.resize(unique(a.begin(), a.end()) - a.begin())
#define fill(v, p)     memset(v,p,sizeof v)
#define all(x)         x.begin(), x.end()
#define index(x,i)     x.find_by_order(i)
#define lesscount(x,i) x.order_of_key(i)
#define PI             acos(-1.0)
#define EPS            0.000000001
#define INF            1e18+10
#define MAX            300005
#define MOD            1000000007


signed int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(0);
	
	map<ll,ll> mp;
	ll a, b,c ;
	cin >> a >> b >> c;
	mp[a]++, mp[b]++, mp[c]++;
	
	if(mp.size() == 2) cout << "Yes\n";
	else cout << "No\n";
	
	
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
n,k,q=map(int,input().split())
data=[k-q]*n
a=[int(input()) for i in range(q)]
for i in range(q):
    data[a[i]-1]+=1
for i in data:
    if i>0:
        print('Yes')
    else:
        print('No')


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;


int main() {
    string s; cin >> s;
    int n = s.size();

    ll counter = 0;
    ll ans = 0;

    rep(i, n) {
        if (s[i] == 'B') counter++;
        else ans += counter;
    }

    cout << ans << endl;

}

Measured memory_bytes: 720
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long
int main()
{

   ll n;
   cin>>n;
   ll arr[n];
   for(ll i=0;i<n;i++)
   {
        cin>>arr[i];
   }
   ll dp[n][n][2];
   for(int i=0;i<n;i++)
   {
       dp[i][i][0]=arr[i];
       dp[i][i][1]=-arr[i];
   }
   for(int j=1;j<n;j++)
   {
       for(int i=0;i<n;i++)
       {  //cout<<i<<" "<<j<<endl;
            if(i+j>=n)
            continue;
           dp[i][i+j][0]=max(dp[i][i+j-1][1]+arr[i+j],dp[i+1][i+j][1]+arr[i]);
           dp[i][i+j][1]=min(dp[i][i+j-1][0]-arr[i+j],dp[i+1][i+j][0]-arr[i]);
           //scout<<dp[i][i+j][0]<<" ";
       }
     //  cout<<endl;
   }
   cout<<dp[0][n-1][0]<<endl;

  

}

Measured memory_bytes: 140800
import collections

n, k, q = map(int, input().split())
li = [0]*q

for i in range(q):
    li[i] = int(input())

dic = collections.Counter(li)

if q < k:
    res = ["Yes" for _ in range(n)]
else:
    res = ["No" for _ in range(n)]
    for key, val in dic.items():
        if val > q-k:
            res[key-1] = "Yes"

for s in res:
    print(s)

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

int main() {
  int a, b, c = 0;
  cin >> a;
  int d[100000] = {0};
  if(a % 2 == 0) c = 1;
  for(int i = 0; i < a; i++) {
    cin >> b;
    d[b]++;
  }
  if((c == 0 && d[0] != 1) || (c == 1 && d[0] != 0)) {
    cout << 0 << endl;
    return 0;
  }
  for(int i = 1; i < a; i++) {
    if(i % 2 == c) {
      if(d[i] != 2 && i != 0) {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  if(c == 0) a -= 1;
  long long int ans = 1;
  for(int i = 0; i < a / 2; i++) {
    ans = (ans * 2) % 1000000007;
  }
  cout << ans << endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	int64 K;
	string s;
	cin >> s >> K;
	REP(i, s.size()){
		if(s[i] != '1'){
			cout << s[i] << endl;
			return 0;
		}else if(i+1 == K){
			cout << s[i] << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
n = int(input())
mx = 1
d = {}
for i in range(n):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
    mx = max(mx, d[s])
spis = []
for k, z in d.items():
    if z == mx:
        spis.append(k)
spis.sort()
for a in spis:
    print(a)



Measured memory_bytes: 32160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();

		for (int i = 1; i <= 10; i++) {
			int ans = r * x - d;
			System.out.println(ans);
			x = ans;
		}

	}

}


Measured memory_bytes: 21972
x1, y1, x2, y2 = [int(x) for x in input().split()]

len1 = x2 - x1
len2 = y2 - y1
x3 = x2 - len2
y3 = y2 + len1

len1 = x3 - x2
len2 = y3 - y2
x4 = x3 - len2
y4 = y3 + len1

print("{} {} {} {}".format(x3, y3, x4, y4))

Measured memory_bytes: 3060