akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;

struct Dice {
 public:
  vector<int> num = vector<int>(6);
  vector<int> tmp = vector<int>(6);

  void Roll(char ch) {
    tmp = num;
    if (ch == 'S') {
      num.at(0) = tmp.at(4);
      num.at(1) = tmp.at(0);
      num.at(2) = tmp.at(2);
      num.at(3) = tmp.at(3);
      num.at(4) = tmp.at(5);
      num.at(5) = tmp.at(1);
    } else if (ch == 'W') {
      num.at(0) = tmp.at(2);
      num.at(1) = tmp.at(1);
      num.at(2) = tmp.at(5);
      num.at(3) = tmp.at(0);
      num.at(4) = tmp.at(4);
      num.at(5) = tmp.at(3);

    } else if (ch == 'N') {
      num.at(0) = tmp.at(1);
      num.at(1) = tmp.at(5);
      num.at(2) = tmp.at(2);
      num.at(3) = tmp.at(3);
      num.at(4) = tmp.at(0);
      num.at(5) = tmp.at(4);

    } else if (ch == 'E') {
      num.at(0) = tmp.at(3);
      num.at(1) = tmp.at(1);
      num.at(2) = tmp.at(0);
      num.at(3) = tmp.at(5);
      num.at(4) = tmp.at(4);
      num.at(5) = tmp.at(2);
    } else if (ch == 'C') {
      num.at(0) = tmp.at(0);
      num.at(1) = tmp.at(2);
      num.at(2) = tmp.at(4);
      num.at(3) = tmp.at(1);
      num.at(4) = tmp.at(3);
      num.at(5) = tmp.at(5);
    }
  }
  void Print(int n) { cout << num.at(n) << endl; }
  int Check(int a) { return num.at(a); }
};

int main() {
  Dice D, E;
  for (int i = 0; i < 6; i++) {
    cin >> D.num.at(i);
  }
  for (int i = 0; i < 6; i++) {
    cin >> E.num.at(i);
  }
  int a = E.num.at(0), b = E.num.at(1);
  if (a == D.Check(3))
    D.Roll('E');
  else if (a == D.Check(2))
    D.Roll('W');
  while (a != D.Check(0)) D.Roll('S');
  while (b != D.Check(1)) D.Roll('C');

  bool ans = D.Check(0) == E.Check(0) && D.Check(1) == E.Check(1) &&
             D.Check(2) == E.Check(2) && D.Check(3) == E.Check(3) &&
             D.Check(4) == E.Check(4) && D.Check(5) == E.Check(5);
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;
int a[1000000] = {0};
signed main(){
    
    ll n;
    cin >> n;
    

    
    REP(i,n){
        int x;
        cin  >> x;
        a[x]++;
    }
    int c = 1;
    if(n%2 == 0){
        for(int i = 0;i <= n-1;i++){
            if(i%2 == 1) if(a[i] != 2) c = 0;
            if(i%2 == 0) if(a[i] != 0) c = 0;
        }
    }
    if(n%2 == 1){
        for(int i = 1;i <= n-1;i++){
            if(i%2 == 1) if(a[i] != 0) c = 0;
            if(i%2 == 0) if(a[i] != 2) c = 0;
        }
        if(a[0] != 1) c = 0;
    }

    if(c == 0) cout << 0 << endl;
    else{
        ll ans = 1;
        REP(i,n/2) {
            ans *= 2;
            ans %=1000000007;
        }
        cout << ans; 
    }




    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <tuple>
using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define eb emplace_back

int main() {
    int n,m,a;
    while(cin >> n >> m >> a && n){
        typedef tuple<int,int,int> L;
        L line[1010];
        rep(i,m){
            int h,p,q;
            cin >> h >> p >> q;
            line[i] = tie(h,p,q);
        }
        sort(line, line+m);
        int dst[1010];
        rep(i,n+1) dst[i] = i;
        loop(i,1,n+1) dst[i] = i;
        rep(i,m) swap(dst[get<1>(line[i])], dst[get<2>(line[i])]);
        cout << dst[a] << endl;
    }
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 29)
using namespace std;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    rep(i,n){
        int inp;
        cin >> inp;
        if(not (inp >= a && inp < b)) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b || b == c || c == a)&&!(a==b&&b==c)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

const ll INF = 1LL<<60;
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 main(void) {
    int n; cin >> n;
    vector<int> d;
    int sum = 0;
    REP(i, n) {
        int a; cin >> a;
        for (auto v : d) sum += v * a;
        d.push_back(a);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readInt()
    val a = readIntList().sorted()
    val r = a.last() / 2.0
    var prev = a[a.lastIndex - 1]
    for (i in n - 3 downTo 1) {
        if (Math.abs(a[i] - r) > Math.abs(prev - r)) {
            println("${a.last()} $prev")
            return
        } else {
            prev = a[i]
        }
    }
    println("${a.last()} ${a[0]}")
}

fun printYesOrNo(flag: Boolean) {
    println(if (flag) "YES" else "NO")
}

fun readIntList(): List<Int> = readLine()!!.split(' ').map { it.toInt() }

fun readInt(): Int = readLine()!!.toInt()

fun err(print: Any) {
    System.err.println(print)
}

Measured memory_bytes: 56572
import sys
import collections as col
input=sys.stdin.readline

def main():
	#N,K=map(int,input().split())
	#N=input().rstrip()
	N=int(input())
	vA=list(map(int,input().split()))
	
	vE = [a for a in vA if a%2<1]
	for a in vE:
		if a%3 and a%5:
			res = "DENIED"
			break
	else:
		res = "APPROVED"
	
	print(res)


main()


Measured memory_bytes: 3316
m = 10 ** 9 + 7

s = int(input())

dp = [0] * (s + 1)
dp[0] = 1

for i in range(1,s+1):
    for j in range(0,i-3+1):
        dp[i] += dp[j]
        dp[i] %= m

print(dp[s])

Measured memory_bytes: 8948
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;


int gcd(int a,int b){
  if(a < b) gcd(b, a);
  if(b==0) return 0;
  int r;
  while ((r=a%b)) {
	a = b;
	b = r;
  }
  return b;
}


int main(int argc, const char * argv[]) {
	int a,b,g,k;
	cin >> a >> b >> k;
	g = gcd(a,b);
	int c=0;
	for(int i = g;i>0;i--){
		if(g%i==0){
			c++;
			if(k==c){
				println(i);
				return 0;
			}
		}
	}


	return 0;
}


Measured memory_bytes: 256
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//printf<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll A,B,C,K;
    cin >>A>>B>>C;
    cin >>K;
    rep(i,K){
        if(B<=A) B*=2; 
        else C*=2;
    }
    cout << ((A<B && B<C) ? "Yes" : "No") <<'\n';


    return (0);
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    int ret=0;
    cin>>a>>b;

    //한번누르면 버튼이 1씩 감소 근데 총 두 번 누르는게 가능 
    //거기서 가장 최대의 코인 값을 얻어낼 경우를 구해라
    if(a>b){
        ret += a;
        a-=1;
        if(a>b){
            ret += a;
            a-=1;
        }
        else{
            ret+=b;
            b-=1;
        }
    }
    else{
        ret+=b;
        b-=1;
        if(a>b){
            ret+=a;
            a-=1;
        }
        else{
            ret+=b;
            b-=1;
        }
    }
    cout<<ret;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <cstdlib>
#define rep(i,o,u) for(int i = o;i < u; i++)
using namespace std;
int a[10000+1];
int search(int k,int n){
	rep(i,0,n){
		if(a[i] == k){
			return 1;
		}
	}
	return 0;
}
int main(){
	int n;
	cin >> n;
	rep(i,0,n) cin >> a[i];
	int m;
	cin >> m;
	int k;
	int ans = 0;
	while(m--){
		cin >> k;
		if(search(k,n)) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int h[31]={},w=0,hh,ww,a,b,i;
	cin >> hh;
	for(i=1;i<=hh;i++){
		h[i] = i;
	}
	cin >> ww;
	for(i=1;i<=ww;i++){
		scanf("%d,%d",&a,&b);
		swap(h[a],h[b]);
	}
	for(int i=1;i<=hh;i++){
		cout << h[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int H, W;
  cin >> H >> W;
  char s[H][W];
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> s[i][j];
    }
  }

  vector<int> yoko[H];
  for(int i = 0; i < H; i++) yoko[i].push_back(-1);
  vector<int> tate[W];
  for(int i = 0; i < W; i++) tate[i].push_back(-1);
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(s[i][j] == '#'){
        yoko[i].push_back(j);
        tate[j].push_back(i);
      }
    }
  }
  for(int i = 0; i < H; i++) yoko[i].push_back(W);
  for(int i = 0; i < W; i++) tate[i].push_back(H);

  /*for(int i = 0; i < H; i++){
    for(int j = 0; j < yoko[i].size(); j++){
      cout << yoko[i][j] << " ";
    }
    cout << endl;
  }*/

  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(s[i][j] != '#'){
        int y = *lower_bound(yoko[i].begin(), yoko[i].end(), j) - *(lower_bound(yoko[i].begin(), yoko[i].end(), j) - 1) - 1;
        //cout << y << endl;
        int t = *lower_bound(tate[j].begin(), tate[j].end(), i) - *(lower_bound(tate[j].begin(), tate[j].end(), i) - 1) - 1;

        ans = max(ans, y + t - 1);
      }
    }
  }

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

Measured memory_bytes: 38272
using System;

namespace abc103_b
{
	class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string t = Console.ReadLine();
			bool ret = false;
			for (int i = 0; i <= s.Length; i++)
			{
				if (s == t) ret = true;
				s = s.Substring(1, s.Length - 1) + s[0];
			}
			Console.WriteLine(ret ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 11092
"""
2**n -1 -combintion(n,a)-combination(n,b)  mod
"""
n,a,b=map(int,input().split())
mod=10**9+7
def combination(p,k):
    a,b=1,1  
    for i in range(k):
        a*=(p-i)
        a%=mod
        b*=(i+1)
        b%=mod
    return (a*pow(b,mod-2,mod))%mod
print((pow(2,n,mod)-1-combination(n,a)-combination(n,b))%mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define UNWORDS(vec, str) for(int i = 0; i < (vec).size(); ++i) cout << (i ? str : "") << (vec)[i]
#define UNLINES(vec) for(int i = 0; i < (vec).size(); ++i) cout << (vec)[i] << endl
using namespace std;

class Data{
public:
	int i, p, q, r;
	Data() : i(0), p(0), q(0), r(0) {}
	Data(int _i, int _p, int _q, int _r) {i = _i; p = _p, q = _q; r = _r;}
};

int main(){
	int n, i, p, q, r, sp, sq, sr, sc, cnt;
	vector< Data > dat;
	
	while(cin >> n, n){
		dat.resize(n);
		REP(j, n){
			cin >> i >> p >> q >> r;
			dat[j] = Data(i, p, q, r);
		}
		cin >> sp >> sq >> sr >> sc;
		
		cnt = 0;
		REP(j, n){
			int cal = (dat[j].p + dat[j].r) * 4 + dat[j].q * 9;
			if(dat[j].p > sp or dat[j].r > sr or dat[j].q > sq or cal > sc) continue;
			
			++cnt;
			cout << dat[j].i << endl;
		}
		if(!cnt) cout << "NA" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

/*bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) { // 素数ではない
			return false;
		}
	}
	// 素数である
	return true;
}*/
/*ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/
/*ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}*/
/*ll modpow(ll x, ll y, ll mod) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}*/
/*ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}*/
//printf("%.10f\n", n);

ll test[123456];
signed main() {
	string s, t;
	ll n, m, k, a, b, c, cnt = 0, ans = INF;
	cin >> s >> t; n = s.size(); m = t.size();
	rep(i, n - m + 1) {
		cnt = 0;
		rep(j, m) {
			if (s[i + j] != t[j]) { cnt++; }
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int N, K;
  cin >> N >> K;
  vector<double> p(N);
  rep(i, N) cin >> p[i];

  vector<double> sum(N + 1, 0);
  rep(i, N) {
    sum[i + 1] = sum[i];
    sum[i + 1] += p[i] * (p[i] + 1) / 2 / p[i];
    //    cout << sum[i + 1] << endl;
  }

  double ans = 0;
  REP(i, K, N + 1) {
    //    cout << sum[i] - sum[i - K] << endl;
    ans = max(ans, sum[i] - sum[i - K]);
  }

  printf("%.10f\n", ans);
}


Measured memory_bytes: 3328
N,K,C = map(int,input().split())
S = input()
def solve():
    if C==0:
        a = [i+1 for i,c in enumerate(S) if c=='o']
        if len(a)==K:
            print(*a, sep='\n')
        else:
            print()
        exit()
    l = []
    y = 0
    for i,c in enumerate(S):
        if y:
            y -= 1
            continue
        if c=='o':
            y = C
            l.append(i+1)
            if len(l) == K:
                break
    r = []
    y = 0
    for i,c in enumerate(S[::-1]):
        if y:
            y -= 1
            continue
        if c=='o':
            y = C
            r.append(N-i)
            if len(r) == K:
                break
    r.reverse()
    ans = [a for a,b in zip(l,r) if a==b]
    print(*ans, sep='\n')
solve()

Measured memory_bytes: 15848
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(V) V.begin(), V.end()
#define PB push_back
using namespace std;
typedef long long ll;

int main() {
    int n;
    ll d;
    cin >> n >> d;
    int cnt = 0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y <= d*d) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		int[] ary=new int[N];
		long MOD=998244353L;
		int sum=0;
		long ans=1L;
		for(int i=0; i<N; i++) {
			ary[i]=sc.nextInt();
			sum+=ary[i];
		}
		for(int i=0; i<N; i++) {
			ans*=3L;
			ans%=MOD;
		}
		long[][] dp=new long[N+1][sum+1];
		for(int i=0; i<=N; i++) {
			Arrays.fill(dp[i],0);
		}
		dp[0][0]=1L;
		for(int i=0; i<N; i++) {
			for(int j=0; j<=sum; j++) {
				if(dp[i][j]>0) {
					dp[i+1][j]+=dp[i][j]*2;
					dp[i+1][j+ary[i]]+=dp[i][j];
					dp[i+1][j]%=MOD;
					dp[i+1][j+ary[i]]%=MOD;
				}
			}
		}
		long biggest=0;
		for(int i=0; i<=sum; i++) {
			if(i>=(sum+1)/2) {
				biggest+=dp[N][i]*3;
				biggest%=MOD;
			}
		}
		long[][] kasanari=new long[N+1][sum+1];
		for(int i=0; i<=N; i++) {
			Arrays.fill(kasanari[i],0);
		}
		kasanari[0][0]=1L;
		for(int i=0; i<N; i++) {
			for(int j=0; j<=sum; j++) {
				if(kasanari[i][j]>0) {
					kasanari[i+1][j]+=kasanari[i][j];
					kasanari[i+1][j+ary[i]]+=kasanari[i][j];
					kasanari[i+1][j]%=MOD;
					kasanari[i+1][j+ary[i]]%=MOD;
				}
			}
		}
		long kaburi=0;
		if(sum%2==0) {
			kaburi=kasanari[N][sum/2]*3;
			kaburi%=MOD;
		}
		else {
			kaburi=0;
		}
		ans-=biggest;
		if(ans<0) {
			ans+=MOD;
		}
		ans+=kaburi;
		pl(ans%MOD);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 442916
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	int n,m;
	cin>>n>>m;
	if(n==m)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

// 插入此處
namespace Number {
    typedef long long int LL;
    // 求取 a, b 的最大公因數
    LL gcd(LL a, LL b) {
        if (a % b == 0) {
            return b;
        }
        return gcd(b, a % b);
    }
    // 求取 a, b 的最大公因數 gcd
    // 以及 x, y 使得 a*x + b*y = gcd
    LL gcd_extend(LL a, LL b, LL *x, LL *y) { 
        if (a == 0) { 
            *x = 0, *y = 1; 
            return b; 
        } 
    
        LL x1, y1; // To store results of recursive call 
        LL gcd = gcd_extend(b%a, a, &x1, &y1); 
    
        *x = y1 - (b/a) * x1; 
        *y = x1; 
    
        return gcd; 
    }
    // 求 a_inv 使得 (a * a_inv) % m = gcd(a, m)
    // 若 a, m 互質，即求 a 在 mod m 群的反元素 a_inv 
    LL mod_inv(LL a, LL m) { 
        LL x, y; 
        LL g = gcd_extend(a, m, &x, &y); 
        // 處理 x 爲負的情形 
        LL a_inv = (x%m + m) % m; 
        return a_inv;
    }
    // 求 x^n % m
    LL mod_pow(LL x, LL n, LL m) {
        if (n == 0) {
            return 1;
        } else if (n & 1) {
            LL half = mod_pow(x, n/2, m);
            return (half * half % m) * x % m;
        } else {
            LL half = mod_pow(x, n/2, m);
            return half * half % m;
        }
    }
    // 連乘
    LL mul(LL from, LL to, LL m) {
        LL ret = 1;
        for (LL i = from; i <= to; i++) {
            ret *= i;
            ret %= m;
        }
        return ret;
    }
    // 求 (C n 取 k) % m
    LL mod_comb(LL n, LL k, LL m) {
        LL mi = k < n-k ? k : n-k;
        LL up = mul(n - mi + 1, n, m);
        LL down = mul(1, mi, m);
        return (up * mod_inv(down, m)) % m;
    }
}
  

const LL M = (LL)1e9 + 7;

LL up[100005];
LL down[100005];

using namespace Number;

int main() {
    LL h, w, a, b;
    scanf("%lld%lld%lld%lld", &h, &w, &a, &b);
    LL ans = 0;
    {
        LL i = b + 1;
        up[i] = mod_comb(i - 1 + (h - a) - 1, i - 1, M);
        down[i] = mod_comb(a - 1 + w - i, a - 1, M);
        ans += up[i] * down[i];
        ans %= M;
    }
    for (LL i = b + 2; i <= w; i++) {
        up[i] = up[i - 1] * (i - 1 + (h - a) - 1) % M;
        up[i] = up[i] * mod_inv((i - 1 + (h - a) - 1) - (h - a - 1), M) % M;
        down[i] = down[i - 1] * mod_inv((a - 1 + w - i + 1), M) % M;
        down[i] = down[i] * (w - i + 1) % M;
        ans += up[i] * down[i];
        ans %= M;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1792
def main():
    N, K, Q = list(map(int, input().split()))
    S =[K-Q]*N
    A=[]
    for i in range(Q):
        A.append(int(input())-1)
    for i in A:
        S[i] = S[i]+1
    for i in range(N):
        if S[i]<1:
            print('No')
        else:
            print('Yes')
if __name__ == '__main__':
    main()

Measured memory_bytes: 56152
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}


long double ans = 0,a[2020],ans1;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

	
	int n;
	cin >> n;

	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	sort(a+1,a+n+1);
	ans = a[1];
	for(int i=2;i<=n;i++){
		ans = (ans+a[i])/2.000;
	}
	ans1=a[n];
	for(int i=n-1;i>=1;i--){
		ans1 = (ans1 + a[i])/2.000;
	}

	cout << max(ans, ans1) << endl;

return 0;
}
///....


Measured memory_bytes: 256
// 参考：http://pekempey.hatenablog.com/entry/2017/04/02/010647

#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
 
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
 
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
 
#define pb push_back
#define mp make_pair
#define mt make_tuple

// 頂点vから距離dの範囲の塗りつぶしを、時刻dp[d][v]に出された命令により行う
int dp[11][100000];

int main(void)
{
    cin.sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> edges(M);

    REP(m, M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        edges[m] = mp(a, b);
    }
    // 便宜上、自分から自分にもエッジが張られているとする
    REP(n, N) edges.pb(mp(n, n));

    int Q;
    cin >> Q;
    // 時刻tの色を保持  便宜上t = 0は色0とする
    vector<int> colors(Q + 1); 
    REP(q, Q) {
        int v, d, c;
        cin >> v >> d >> c;
        --v;
        dp[d][v] = q + 1;
        colors[q+1] = c;
    }

    for(int i = 10; i >= 1; --i) {
        for(auto edge: edges) {
            int u, v;
            tie(u, v) = edge;
            dp[i-1][u] = max(dp[i-1][u], dp[i][v]);
            dp[i-1][v] = max(dp[i-1][v], dp[i][u]);
        }
    }
    REP(v, N) {
        cout << colors[dp[0][v]] << endl;
    }
    return 0;
}


Measured memory_bytes: 8404
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
int c,n,m,s,t;
int dp[11][100];
main()
{
	while(cin>>c>>n>>m>>s>>t,c)
	{
		for(int i=0;i<=c;i++)for(int j=0;j<n;j++)dp[i][j]=1e9;
		vector<vector<pair<int,int> > >G(n);
		for(int i=0;i<m;i++)
		{
			int u,v,C;cin>>u>>v>>C;
			u--,v--;
			G[u].push_back(make_pair(v,C));
			G[v].push_back(make_pair(u,C));
		}
		s--,t--;
		priority_queue<pair<int,pair<int,int> > >P;
		P.push(make_pair(0,make_pair(s,c)));
		dp[c][s]=0;
		while(!P.empty())
		{
			int d=-P.top().first,u=P.top().second.first,s=P.top().second.second;
			P.pop();
			for(int i=0;i<G[u].size();i++)
			{
				int cost=G[u][i].second;
				int v=G[u][i].first;
				if(s>0)
				{
					if(dp[s-1][v]>d+cost/2)
					{
						dp[s-1][v]=d+cost/2;
						P.push(make_pair(-dp[s-1][v],make_pair(v,s-1)));
					}
				}
				if(dp[s][v]>d+cost)
				{
					dp[s][v]=d+cost;
					P.push(make_pair(-dp[s][v],make_pair(v,s)));
				}
			}
		}
		int ans=1e9;
		for(int i=0;i<=c;i++)ans=min(ans,dp[i][t]);
		cout<<ans<<endl;
	}
}



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

long int saidaikouyakusuu_gcd(long int a, long int b);

int main(void) {
	long int n, x; cin >> n >> x;
	cout << 3 * (n - saidaikouyakusuu_gcd(n, x));

	return 0;
}
long int saidaikouyakusuu_gcd(long int a,long int b) {
	if (a < b) {
		long tmp = a;
		a = b;
		b = tmp;
	}
	while (b) {
		long m = a % b;
		a = b;
		b = m;
	}
	return a;
}

Measured memory_bytes: 256
#include<cstdio>

int main() {
    int a,b;
    scanf("%d%d",&a,&b);
    /*メモリに整数をメモるためのxという領域を取る。そこに１という数字をセットする*/
    printf("%d %d\n",a*b,(a+b)*2);
    return 0;
}



Measured memory_bytes: 2680
// 2012/07/16 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int cnt[10];
		for(int i=0; i<10; i++){
			cnt[i] = 0;
		}

		for(int i=0; i<n; i++){
			int ice;
			cin >> ice;

			cnt[ice]++;
		}

		for(int i=0; i<10; i++){
			if(cnt[i]==0){
				cout << '-' << endl;
			}
			else{
				for(int j=0; j<cnt[i]; j++){
					cout << '*';
				}
				cout << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
 /*   double t,x;
    cin>>t>>x;
    t=t/x;
    cout<<t*1.0<<'\n';*/
  
   /* int a,b,c;
    cin>>a>>b>>c;
    cout<<(a*b)/2<<'\n';*/

    int d;
    cin>>d;
    if(d==22){
        cout<<"Christmas Eve Eve Eve"<<'\n';
    }else if(d==23){
        cout<<"Christmas Eve Eve"<<'\n';
    }else if(d==24){
        cout<<"Christmas Eve"<<'\n';
    }else if(d==25){
        cout<<"Christmas"<<'\n';
    }
}

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

using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,X,Y;
    cin>>N>>X>>Y;
    
    vector<int> count(N,0);
    for(int i=1;i<=N;++i){
        for(int j=i+1;j<=N;++j){
            int d=abs(j-i);
            d=min(d,abs(X-i)+1+abs(Y-j));
            d=min(d,abs(Y-i)+1+abs(X-j));
            ++count[d];
        }
    }
    for(int i=1;i<N;++i)cout<<count[i]<<endl;
}

Measured memory_bytes: 256
/*****************
 *   I<3   C++   *
 *  IWANT ANYAC  *
 * ILOVEPROGRAM! *
 *IT'SINTERESTING*
 * ILOVEPROGRAM! *
 *  INCONTESTS   *
 *   GETSCORE    *
 *    ACCODE     *
 *     LETS      *
 *      GO       *
 *****************/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
#define MASK(a) (1<<(a))
#define MASKX(x,a) ((x)<<(a))
#define BIT(a,b) ((a>>b)&1)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;

int n;
int a,b;
int cnt1,cnt2;

vint bfs(int b,vector<vint> nei)
{
	vint bss(n);
	queue<int> q,bs;
	set<int> lgl;
	q.push(b);
	bs.push(0);
	lgl.insert(b);
	bss[b]=0;
	while(!q.empty())
	{
		int qq=q.front(),bb=bs.front();
		q.pop();bs.pop();
		for(int i=0;i<SZ(nei[qq]);i++)
		{
			int ii=nei[qq][i];
			if(!lgl.count(ii))
			{
				lgl.insert(ii);
				q.push(ii);
				bs.push(bb+1);
				bss[ii]=bb+1;
			}
		}
	}
	return bss;
}

int main()
{
	scanf("%d",&n);
	vector<vint> nei(n);
	for(int i=0;i<n-1;i++)
	{
		scanf("%d%d",&a,&b);
		nei[a-1].push_back(b-1);
		nei[b-1].push_back(a-1);
	}
	vint v1=bfs(0,nei);
	vint v2=bfs(n-1,nei);
	for(int i=0;i<n;i++)
		if(v1[i]<=v2[i])cnt1++;
		else cnt2++;
	if(cnt1>cnt2)OVER("Fennec");
	else OVER("Snuke");
}

Measured memory_bytes: 16600
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pp pair<int, int>
#define ppp pair<pp, int>
#define pp4 pair<pp, pp>
#define pp3 pair<ll, pair<int, int> > 
#define fi first
#define se second
#define N  2020
#define mod 1000000007
#define inf 2000000001
#define esp 1e-9
#define BLOCK 333
#define BITNUM 555
#define BASE 311097
typedef long long ll;
// const ll oo = (ll)1e18 + 1;
using namespace std;
int n, x, y;
int d[N];

int main() {
    ios::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    cin >> n >> x >> y;
    for (int i = 1; i < n; i++)
    	for (int j = i + 1; j <= n; j++) {
    		int z = j - i;

    	 	{
    			int f = abs(x - i);
    			int s = abs(j - y);

    			int t = f + s + 1;
    			if (t < z) {
    				z = t;			
    			}
    		}
    		d[z]++;
    	}

    for (int i = 1; i < n; i++)
    	cout << d[i] << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N,i=0,r,x,draw=30;	//10^9⇒2^30
  cin >> N;
  while(i<N)
  {
    r=0;
    cin >> x;
    while(x%2==0)
    {x/=2;r++;}
    if(draw>r){draw=r;}
    i++;
  }
  cout << draw << endl;
}

Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := mint(getNextInt64(scanner))
	b := mint(getNextInt64(scanner))
	x := mint(getNextInt64(scanner))
	var ans mint
	for x-(a-1) >= 0 {
		c := (x - (a - 1)) / (a - b)
		if c == 0 {
			break
		}
		ans.addAs(a.mod().mul(c.mod()))
		x -= c * (a - b)
	}
	if x >= a {
		ans.addAs(x - a).addAs(a.mod()).addAs(b.mod())
	} else {
		ans.addAs(x.mod())
	}
	fmt.Fprintln(writer, ans)
}

type mint int64

func (mt mint) mod() mint {
	m := mint(1e9 + 7)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) inv() mint {
	return mt.pow(mint(0).sub(2))
}
func (mt mint) pow(n mint) mint {
	p := mint(1)
	for n > 0 {
		if n&1 == 1 {
			p.mulAs(mt)
		}
		mt.mulAs(mt)
		n >>= 1
	}
	return p
}
func (mt mint) add(x mint) mint {
	return (mt + x).mod()
}
func (mt mint) sub(x mint) mint {
	return (mt - x).mod()
}
func (mt mint) mul(x mint) mint {
	return (mt * x).mod()
}
func (mt mint) div(x mint) mint {
	return mt.mul(x.inv())
}
func (mt *mint) addAs(x mint) *mint {
	*mt = mt.add(x)
	return mt
}
func (mt *mint) subAs(x mint) *mint {
	*mt = mt.sub(x)
	return mt
}
func (mt *mint) mulAs(x mint) *mint {
	*mt = mt.mul(x)
	return mt
}
func (mt *mint) divAs(x mint) *mint {
	*mt = mt.div(x)
	return mt
}



Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define  clr(v,val)      memset(v,val,sizeof(v))
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
ll setBit1(ll num, ll idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=400000+9;

int main(){
    GO();

    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

























































































































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

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;

	if (s.at(k-1) == 'A') s.at(k-1) = 'a';
	else if (s.at(k-1) == 'B') s.at(k-1) = 'b';
	else s.at(k-1) = 'c';

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
def modpow(d, b, p, mod=2019):
    ret = 1
    while p > 0:
        if p % 2 == 1:
            ret = ret * b % mod
        b = b * b % mod
        p //= 2
    return (d * ret) % mod


S = input()
C = [0]
for i in range(len(S)):
    C.append((C[-1] + modpow(int(S[-(i + 1)]), 10, i)) % 2019)
Cd = {}
for c in C[1:]:
    Cd[c] = Cd.get(c, 0) + 1
print(Cd.get(0, 0) + sum([v * (v - 1) // 2 for v in Cd.values()]))


Measured memory_bytes: 81060
/*
 * test.cpp
 *
 *  Created on: 2018/01/10
 *      Author: joi
 */




#include <bits/stdc++.h>

using namespace std;

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

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

int main(){
	int q;
	cin >> q;
	int d[100010];
	for(int i = 1; i < 100010; i += 2){
		if(i == 1){
			d[1] = 0;
		}else{
			int flag = 1;
			for(int j = 2; j < sqrt(i) + 1; j++){
				if(i % j == 0) flag = 0;
			}
			for(int j = 2; j < sqrt((i + 1) / 2) + 1; j++){
				if((i + 1) / 2 == 2){
					break;
				}
				if(((i + 1) / 2) % j == 0) flag = 0;
			}
			d[i] = d[i - 2] + flag;
		}
	}
	REP(i, q){
		int l, r;
		cin >> l >> r;
		if(l == 1) l = 3;
		cout << d[r] - d[l - 2] << endl;
	}
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
    int i,j,in[100],hum,ans,mx=0,mn=1000;
    for(;scanf("%d",&hum),hum!=0;)
    {
        for(i=0,mx=0,mn=1000,ans=0;i<hum;i++)
        {
            scanf("%d",&in[i]);
            mx=mx<in[i]?in[i]:mx;
            mn=mn>in[i]?in[i]:mn;
            ans+=in[i];
        }
        ans=ans-(mn+mx);
        printf("%d\n",ans/(hum-2));
    }
    return 0;
}

Measured memory_bytes: 1188
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nab = IO.RSInt;
            if ((nab[1] - nab[2]) % 2 == 0)
            {
                WriteLine("Alice");
            }
            else
            {
                WriteLine("Borys");
            }
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 19072
#include<iostream>
#include<cmath>

using namespace std;
typedef long long ll;

ll A, B;

/*
F(A) = 0xor1xor2xor3xor...xorA だとすると、XORの単位元の定義と交換法則により
f(A, B) = F(A - 1) xor F(B)
*/

ll F(ll a) {
	
	if (a % 2 == 0) {
		if((a / 2) % 2 == 1)
			return (1 ^ a);
		else return a;
	}
	else {
		if ((a + 1) / 2 % 2 == 1)
		return 1;
		else return 0;
	}
}

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

	if (A == B) {
		cout << A << endl;
		return 0;
	}

	if (A == 0) {
		cout << B << endl;
		return 0;
	}

	if (B == 0) {
		cout << A << endl;
		return 0;
	}

	cout << (F(A - 1) ^ F(B)) << endl;

	return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

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

    if(x<=3){
        cout<<x<<endl;
        return 0;
    }

    if(x%2==0){
        x++;
    }

    for(int i=x;i<=100003;i+=2){
        bool jdg=true;
        for(int j=3;j<=sqrt(i);j+=2){
            if(i%j==0){
                jdg=false;
                break;
            }
        }
        if(jdg){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
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;


	void doIt() {
		int N = sc.nextInt();
		int W = sc.nextInt();
		int w[] = new int[N];
		int v[] = new int[N];
		long dp[] = new long[W + 1];
		for(int i = 0; i < N; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		//O(1e7)
		for(int i = 0; i < N; i++) {
			for(int j = W; j >= w[i]; j--) {
				int idx = j - w[i];
				dp[j] = Math.max(dp[j], dp[idx] + v[i]);
			}
		}
		System.out.println(dp[W]);

	}
	int diff(int a, int b) {
		return Math.abs(a - b);
	}




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


Measured memory_bytes: 21972
import java.util.*;

public class Main {
	
	public static void main(String[] args) {

		//input
		Scanner sc = new Scanner(System.in).useDelimiter(System.getProperty("line.separator"));
		
		String[] s;
		int hit,blow;
		int[][] ar = new int[2][4];
		while(sc.hasNext()){
			hit = blow = 0;
			for(int i=0;i<2;i++){
				s = sc.next().split("\\s");
				for(int j=0;j<4;j++){ar[i][j] = Integer.parseInt(s[j]);}
			}

			//calculation
			for(int i=0;i<4;i++){if(ar[0][i] == ar[1][i]){hit++;}}
			for(int i=0;i<4;i++){
				for(int j=0;j<4;j++){
					if(ar[0][i] == ar[1][j] && i != j){
						blow++;
					}
				}
			}

		//output
		System.out.println(hit + " " + blow);
		}
	}
}

Measured memory_bytes: 17156
#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <vector>

using namespace std;
using ll = long long;

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

#define MOD ((ll)1000000007)

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	cin >> N;

	vector<int> A1(N, 0);
	vector<int> A2(N, 0);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A1[i];
	}
	for (size_t i = 0; i < N; i++)
	{
		cin >> A2[i];
	}

	vector<int> d1(N, 0);
	vector<int> d2(N, 0);
	d1[0] = A1[0];
	d2[0] = A1[0] + A2[0];
	for (size_t i = 1; i < N; i++)
	{
		d1[i] = d1[i - 1] + A1[i];
		d2[i] = max(d1[i], d2[i - 1]) + A2[i];
	}
	cout << d2[N - 1] << endl;
	return 0;
}


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

int main() {
  int N, X, c = 0;
  cin >> N >> X;
  vector<int> a(N);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
   }
  if(X - accumulate(a.begin(), a.end(), 0) > 0) {
    cout << N -1;
  }else{
    sort (a.begin(), a.end());
    for(int i = 0; i < N; i++){
      if (X - a.at(i) >= 0){
        X = X - a.at(i);
        c++;
      }else break;
    }
    cout << c;
  }
}

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

int main()
{
  int n;
  cin>>n;
  int ara[n+1];
  int cnt=0;
  for(int i=1;i<=n;i++)
  {
    cin>>ara[i];
    if(i!=ara[i]) cnt++;
  }
  if(cnt<=2) printf("YES");
  else printf("NO");
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if((A==B&&A!=C) || (B==C&&B!=A) || (C==A&&C!=B) ) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3560