akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.1415926535;
const ll MAX=1000000;

ll DP[3005][6005];

int main() {
  ll N,T;
  cin>>N>>T;
  pair<ll,ll> food[N];
  //ll time[N];
  ll tMax=0;
  rep(i,N){
    cin>>food[i].first>>food[i].second;
    tMax=max(tMax,food[i].first);
  }
  sort(food,food+N);
  for(int i=0;i<=N;i++){
    for(int j=0;j<=T+tMax;j++){
      if(i*j==0){
        DP[i][j]=0;
        continue;
      }
      if(j-food[i-1].first>=T){
        DP[i][j]=max(DP[i-1][j],DP[i][j-1]);
      }
      else if(j-food[i-1].first>=0){
        DP[i][j]=max(DP[i-1][j],DP[i-1][j-food[i-1].first]+food[i-1].second);
      }
      else{
        DP[i][j]=DP[i-1][j];
      }
    }
  }
  cout<<DP[N][T+tMax];
 // cout<<" "<<DP[2][200];
    
    
}

Measured memory_bytes: 141056
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;
    vector<string> ans;

    stack<string> sta;
    sta.emplace("a");
    while (!sta.empty()) {
        string s = sta.top(); sta.pop();
        int m = s.size();
        if (m == n) {
            ans.emplace_back(s);
        } else {
            char la = *max_element(s.begin(), s.end()); la++;
            for (char c = 'a'; c <= la; c++) {
                string t = s + c;
                sta.emplace(t);
            }
        }
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    for (const auto& e : ans) cout << e << '\n';
    return 0;
}

Measured memory_bytes: 10484
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int p[4], t[4];
int dp[101];

int main() {
    cin >> n;
    rep(i,4) cin >> p[i];
    rep(i,4) cin >> t[i];
    rep(i,n+1) dp[i] = MOD;
    dp[0] = 0;
    rep(i,n) {
        rep(j,4) {
            int to = min(n, i+t[j]);
            dp[to] = min(dp[to], dp[i] + p[j]);
        }
    }
    cout << dp[n] << endl;
}



Measured memory_bytes: 3112
n=int(input())
a=[int(i) for i in input().split()]
a.append(0)
x,y=1000,0
for i in range(n):
    if a[i]>a[i+1]:
        x+=y*a[i]
        y=0
    else:
        y+=x//a[i]
        x=x%a[i]
print(x+y*a[-2])

Measured memory_bytes: 61860
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

vii a,b,c,d;
int n;
int cnt[100005],to[100005],vis[100005];

map<ll,int> m,m2;

int main()
{ios_base::sync_with_stdio(false);
cin>>n;
rep(i,0,n-1)
{
	int x;
	cin>>x;
	a.pb(x);
	m[a[i]]=i;
}
rep(i,0,n-1)
{
	int x;
	cin>>x;
	b.pb(x);
	m2[b[i]]=i;
}

c=a;
d=b;

sort(all(c));
sort(all(d));


rep(i,0,n-1)
{
	if(c[i]>d[i])
	{
		ol("No");
		return 0;
	}
}
int foo=1;
set<int> s;
rep(i,0,n-1)
{
	cnt[i]=upper_bound(all(c),d[i])-c.begin();
	to[m2[d[i]]]=m[c[cnt[i]-1]];
	//o2(m2[d[i]],to[i]);on;
	if(cnt[i]>i+1)
	{
		foo=0;
	}
}

if(foo==0)
{
	ol("Yes");
	return 0;
}
int cc=0;

rep(i,0,n-1)
{
	if(!vis[i])
	{
		cc++;
		int at=i;
		vis[at]=1;
		while(1)
		{
			at=to[at];
			if(vis[at])break;
			vis[at]=1;
		}
	}
}
if(cc==1)
{
	ol("No");
	return 0;
}
ol("Yes");
return 0;
}



Measured memory_bytes: 15480
// inputに入力データ全体が入る
function Main(input) {
  // まずメインの入力の値をとる
var a = input.split("\n")[1].split(" ");
var diff = 0;
var max = Number(a[1]);
var min = Number(a[1]);
// 最大値と最小値をforEachで求める
a.forEach((e)=>{
	if(max < Number(e)){
    	max = e;
    } if(min > Number(e)) {
    	min = e
    }
})
// 最大引く最小をやってみてdifに吐き出す
dif = max -min;
//出力
console.log(dif);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
local read = io.read

local N = read("*n")
read("*l")

local str_s_result = {"AC", "WA", "TLE", "RE"}
local results = {0, 0, 0, 0}

for i = 1, N do
	local S_i = read("*l")
	for j = 1, #str_s_result do
		if S_i == str_s_result[j] then
			results[j] = results[j] + 1
		end
	end
end

for i = 1, #results do
	print(str_s_result[i].." x "..results[i])
end


Measured memory_bytes: 2776
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    md = 10**9+7
    mx, mi, ret = 0, 0, 0
    for k in range(1, N+2):
        mx += N-k+1
        mi += k-1
        ret += ((mx - mi + 1)*(k>=K))%md
    print(ret%md)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []

for i in range(N,0,-1):
    s = N // i + 1
    t = 0
    for j in range(1,N+1):
      if i*j<=N:
        t += MAP[i*j-1]
      else:
        break
    if t%2 != l[i-1]:
        ans_l.append(str(i))
        MAP[i-1] = 1
leng = len(ans_l)
print(leng)
print(" ".join(ans_l))


Measured memory_bytes: 17212
(let ((n (read))
      (lim (read))
      (ans 2000)
      temp temp2)
     (loop repeat n do
           (setf temp (read))
           (setf temp2 (read))
           (if (<= temp2 lim) (setf ans (min ans temp))))
     (princ (if (= ans 2000) "TLE" ans)))

Measured memory_bytes: 12900
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int A,B,C,X;
	int sum=0;
	cin>>A>>B>>C>>X;
	for(int i=0;i<=A;i++){
		for(int j=0;j<=B;j++){
			for(int z=0;z<=C;z++){
				if(i*500+j*100+z*50==X)
					sum++;
			}
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int S;
	int h, m, s;
	
	scanf("%d", &S);
	
	h = S / 3600;
	m = S % 3600 / 60;
	s = S % 3600 % 60 ;
	
	printf("%d:%d:%d\n", h, m, s);
	
	return (0);
}

Measured memory_bytes: 592
#include<iostream>
#include<numeric>
#include<math.h>
#include<cmath>
using namespace std;

int n, d;
double x[10][10], y[10][10];

double dd(int y, int z) {
	double ret = 0;
	for (int i = 0; i < d; i++) {
		ret += (x[y][i] - x[z][i]) * (x[y][i] - x[z][i]);
	}
	return sqrt(ret);
}

int main(void) {
	cin >> n >> d;
	int ret = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			double tmp = dd(i, j);
			if (tmp - int(tmp) == 0)
				ret++;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
 
using namespace std;


long long arr[55];

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


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

    long long ans = 0;
    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            ans += arr[i] * arr[j];
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
import           Control.Applicative
import           Control.Monad

comb :: Int -> [[Int]]
comb n = [[a, b, c] | a <- [1 .. n], b <- [a + 1 .. n], c <- [b + 1 .. n]]

main :: IO ()
main = do
    xss <- fmap (fmap read . words) . lines <$> getContents :: IO [[Int]]
    let yss = takeWhile (/= [0, 0]) xss
    forM_ yss $ \[n, x] -> do
        print $ length $ filter ((== x) . sum) (comb n)



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

using namespace std;

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

const int Nmax = 303;
int Mod, n, dp[Nmax][Nmax], sum_dp[Nmax][Nmax], comb[Nmax][Nmax], K, i, j, k;

int inm(int x, int y) { return (ll)x*y%Mod; }
int inm(int x, int y, int z) { return (ll)x*y%Mod*z%Mod; }
void add_to(int &x, int y) { x+=y; if(x>=Mod) x-=Mod; }

int main()
{
 //   freopen("input", "r", stdin);
 //   freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> n >> K >> Mod;

    comb[0][0] = 1;
    for(i=1; i<=n; ++i)
        for(j=0; j<=i; ++j)
        {
            comb[i][j] = comb[i-1][j];
            if(j) add_to(comb[i][j], comb[i-1][j-1]);
        }

    for(k=1; k<=K; ++k)
        dp[1][k] = 1, sum_dp[1][k] = k % Mod;

    for(i=2; i<=n; ++i)
        for(k=1; k<=K; ++k)
        {
            for(j=1; j<i; ++j)
                add_to(dp[i][k], inm(dp[i-j][k], sum_dp[j][k-1], comb[i-2][j-1]));

            sum_dp[i][k] = sum_dp[i][k-1];
            add_to(sum_dp[i][k], dp[i][k]);
        }

    dp[0][0] = 1;
    for(i=1; i<=n; ++i)
        for(j=1; j<=i; ++j)
            add_to(dp[0][i], inm(dp[0][i-j], comb[i-1][j-1], sum_dp[j][K]));

    cout << dp[0][n] << '\n';
}


Measured memory_bytes: 1280
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
using namespace std;


//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}

const ll mod = 1e9 + 7;
const ll N = 1e5 + 7;

ll h,w;
char c;
ll dp[1007][1007] = {};


int main()
{
    MohamedMotaz;

    cin >> h >> w;
    dp[0][0] = 1;
    f(i,0,h){
        f(j,0,w){
            cin >> c;
            if (c == '#') continue;
            //cout << "now at: " << i << " " << j << endl;
            if (i - 1 >= 0) dp[i][j] += dp[i - 1][j];//, cout << "yaya" << endl;
            if (j - 1 >= 0) dp[i][j] += dp[i][j - 1];//, cout << "yayayyaa" << endl;
            dp[i][j] %= mod;
        }
    }

    cout << dp[h - 1][w - 1];



}



Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int,int>
#define vvi vector<vector<int> >
#define vpi vector<pii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define INF 0x7fffffff
#define LINF 0x7fffffffffffffff
#define MOD 1000000007
#define mod 998244353
#define lowbit(x) x&(-x)
#define HS 173LL
using namespace std;
int read()
{
	int x=0;
	char ch=getchar();
	while(!isdigit(ch))
		ch=getchar();
	while(isdigit(ch))
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x;
}
const int maxn=2e5+10;
int n,m,cnt;
vector<int> edge[maxn];
bool vis[maxn];
void dfs(int x)
{
	vis[x]=true;
	cnt++; 
	for(auto to:edge[x])
	{
		if(!vis[to]) dfs(to);
	}
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		int a=read(),b=read();
		edge[a].pb(b);
		edge[b].pb(a);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			cnt=0;
			dfs(i);
			ans=max(ans,cnt);
		}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
 bool prime[10000000];

 prime[0]=prime[1]=false;
 for(int i=2;i<10000000;i++){
	prime[i]=true;
 }
 for(int i=2;i*i<10000000;i++){
	if(prime[i]){
		for(int j=i*i;j<10000000;j+=i){
			prime[j]=false;
		}
	}
 }
//???????????§?´???°??¨
 int n;
 while(1){
	cin>>n;
  if(n==0)break;
	for(int i=n;i>0;i--){
		if(prime[i-8]&&prime[i-6]&&prime[i-2]&&prime[i]){
			cout<<i<<endl;
			break;
		}
	}
 }
 return 0;
}
	

Measured memory_bytes: 12748
#include <cstdio>
#include <climits>
#include <algorithm>
int n;
int a[100005];
int d[100005];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
		d[i] = INT_MIN;
	}
	d[1] = a[1];
	int ans = 1;
	for (int i = 2; i <= n; i++) {
		if (a[i] <= d[ans])
			d[++ans] = a[i];
		else {
			int l = 1, r = ans, mid;
			while (l <= r) {
				mid = (l + r) / 2;
				if (d[mid] >= a[i])
					l = mid + 1;
				else
					r = mid - 1;
			}
			int pos = l;
			d[pos] = a[i];
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

const int maxn = 105;
const long long maxw = 1e5 + 5;
int n;
long long W, w[maxn];
long long v[maxn];
long long dp[maxn][maxw];

int main() {
	cin >> n >> W;
	for (int i = 1; i <= n; i++) cin >> w[i] >> v[i];
	// cout << n << " " << W << endl;
	// for (int i = 1; i <= n; i++) cout << w[i] << " " << v[i] << endl;
	for (int i = 1; i <= n; i++) {
		for (long long j = 0; j <= W; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j >= w[i]) {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			}
			// cout << dp[i][j] << " ";
		}
		// cout << endl;
	}
	cout << dp[n][W] << endl;
	return 0;
}

Measured memory_bytes: 79360
from math import log
from decimal import Decimal

N,K = map(int,input().split())
A = list(map(int,input().split()))

B = [Decimal(log(i)) for i in A]

f = sum(B[:K])
for i in range(K,N):
    if f < (f-B[i-K]+B[i]):
        print("Yes")
    else:
        print("No")
    f = f-B[i-K]+B[i]



Measured memory_bytes: 43876
w,h,n = map(int,input().split())
left = 0
right = w
under = 0
hight= h

for i in range(n):
    x,y,a = map(int,input().split())
    if a==1:
        left = max(left,x)
    elif a==2:
        right = min(right,x)
    elif a==3:
        under = max(under,y)
    else:
        hight = min(hight,y)

if left>=right or under>=hight:
    print(0)
else:
    print((right-left)*(hight-under))

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>

using namespace std;
#define long long long

typedef priority_queue<int> HeapMax;
typedef priority_queue<int, vector<int>, greater<int> > HeapMin;
int n;
long b, sp, ss;
HeapMax Pre;
HeapMin Suf;

void Type_1()
{
    int x, y;
    cin >> x >> y;
    b+=y;
    if (!sp) {Pre.push(x); sp += x; return;}

    if (x <= Pre.top()) {Pre.push(x); sp += x;}
    else {Suf.push(x); ss += x;}
}

void Type_2()
{
    int num = Pre.size() + Suf.size();
    while (Pre.size() > (num + 1) / 2) {
        int tmp = Pre.top();
        sp -= tmp, ss += tmp;
        Pre.pop(), Suf.push(tmp);
    }
    while (Pre.size() < (num + 1) / 2) {
        int tmp = Suf.top();
        ss -= tmp, sp += tmp;
        Suf.pop(); Pre.push(tmp);
    }

    int tmp = Pre.top();
    long res = (long) (tmp * Pre.size()) - sp + ss - (long) (tmp * Suf.size());
    res += b;
    cout << tmp << " " << res << "\n";
}

int main()
{
//    freopen("tam.inp", "r", stdin);
    cin >> n;
    for (int i = 0, type; i < n; ++i) {
        cin >> type;
        if (type == 1) Type_1();
        else Type_2();
    }
    return 0;
}


Measured memory_bytes: 3452
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long
#define mp make_pair

mt19937 rnd(51);

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int s, w;
	cin >> s >> w;
	if (s <= w){
        cout << "unsafe";
	}
	else{
        cout << "safe";
	}
	return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    string ans = "second";
    rep(i,N) {
        int a;
        cin >> a;
        if (a%2!=0) {
            ans = "first";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
  	int n=sc.nextInt();
    int d=sc.nextInt();
    int c=0;
    for(int i=0;i<n;i++)
    {
      long x1=sc.nextLong();
      long x2=sc.nextLong();
      x1=x1*x1;
      x2=x2*x2;
      long sum=x1+x2;
      double s=Math.sqrt(sum);
      if(s<=d)
        c++;
    }
    System.out.println(c);
}
}

Measured memory_bytes: 59116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct unionFind{
  vector<ll> par;
  vector<ll> sz;
  
  unionFind(ll n): par(n), sz(n){
    for(ll i=0; i<n; i++) {
      par[i] = i;
      sz[i] = 1;
    }
  }
  
  int root(int n){
    if(n == par[n]) return n;
    return par[n] = root(par[n]);
  }
  
  bool issame(ll x, ll y){
    ll px = root(x);
    ll py = root(y);
    return px == py;    
  }
  void unite(ll x, ll y){
    ll px = root(x);
    ll py = root(y);
    if(issame(px, py)) return;
    if(size(px) >= size(py)) swap(px, py);
    par[py] = px;
    sz[px] += sz[py];
  }
  
  ll size(ll x){
    return sz[root(x)];
  }
};
int main(void){
  ll N, M;
  cin >> N >> M;
  ll A[M], B[M];
  for(int i=0; i<M; i++){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    A[i] = a; B[i] = b;
  }
  
  unionFind uf = unionFind(N);
  
  ll ans[M];
  ans[M-1] = N*(N-1)/2; 
  for(int i=M-1; i>=1; i--){
    ll x = A[i];
    ll y = B[i];
    if(uf.issame(x, y)) ans[i-1] = ans[i];
    else {
      ans[i-1] = ans[i] - uf.size(x)*uf.size(y);
      uf.unite(x, y);
    }
  }
  for(int i=0; i<M; i++) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 5248
n = int(input())
c = input()

l = 0
r = n - 1

ans = 0

while True:
  while c[l] == 'R' and l < r:
    l += 1
  while c[r] == 'W' and l < r:
    r -= 1
  if l < r:
    ans += 1
    l += 1
    r -= 1
  else:
    print(ans)
    break

Measured memory_bytes: 67728
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<double,double> P;
double D(P a,P b) {
  int x1=floor(a.F/10)*10,x2=floor(b.F/10)*10,y1=floor(a.S/10)*10,y2=floor(b.S/10)*10;
  if(x1!=a.F&&x2!=b.F&&x1==x2&&y1!=y2) {
    double d1=fabs(a.F-x1),d2=fabs(b.F-x2);return fabs(a.S-b.S)+min(d1+d2,20-d1-d2);
  } else if(y1!=a.S&&y2!=b.S&&y1==y2&&x1!=x2) {
    double d1=fabs(a.S-y1),d2=fabs(b.S-y2);return fabs(a.F-b.F)+min(d1+d2,20-d1-d2);
  }
  return fabs(a.F-b.F)+fabs(a.S-b.S);
}
int n,M=1<<29;
P a[11111];
double solve(int x,int y,double s,double t) {
  double ans=M;
  for(double l=x-10; l<=x+10; l+=s) {
    for(double r=y-10; r<=y+10; r+=t) {
      double d=0;
      for(int i=0; i<n; i++) d=max(d,D(a[i],P(l,r)));
      ans=min(ans,d);
    }
  }
  return ans;
}
int main() {
  cin>>n;
  double Max=-M,Mix=M,May=-M,Miy=M;
  for(int i=0;i<n;i++) {
    cin>>a[i].F>>a[i].S;
    Max=max(Max,a[i].F+a[i].S);
    Mix=min(Mix,a[i].F+a[i].S);
    May=max(May,a[i].F-a[i].S);
    Miy=min(Miy,a[i].F-a[i].S);
  }
  int xx=(Max+Mix)/2,yy=(May+Miy)/2;
  int x=floor((double)(xx+yy)/20)*10,y=floor((double)(xx-yy)/20)*10;
  printf("%.10f\n",min(solve(x,y,10,0.5),solve(x,y,0.5,10)));
  return 0;
}


Measured memory_bytes: 3460
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> S(H,vector<char> (W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> S[i][j];
    }
  }
  vector<int> h(105,0);
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(S[i][j] == '#'){
        h[i]++;
        break;
      }
    }
  }
  vector<int> w(105,0);
  for(int i=0; i<W; i++){
    for(int j=0; j<H; j++){
      if(S[j][i] == '#'){
        w[i]++;
        break;
      }
    }
  }
  for(int i=0; i<H; i++){
    if(h[i] == 0){
      continue;
    }
    for(int j=0; j<W; j++){
      if(w[j] == 0){
        continue;
      }
      cout << S[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 10000002
bool prime[N];

//check prime
bool isPrime(ll n)
{
	if(n<=1)return false;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)return false;
	}
    return true;
}
//gcd
ll gcd(ll x,ll y)
{
	if(x==0)return y;
	else return gcd(y%x,x);
}
//lcm;
ll lcm(ll x,ll y)
{
	return x*y/gcd(x,y);
}

// sieve of eratosthenes
void sieve(vector<ll> &v)
{
	memset(prime,true,N);
	prime[0]=prime[1]=false;
	for(ll i=2;i*i<N;i++)
	{
		if(prime[i]==true)
		{
			for(ll j=i+i;j<N;j+=i)
			{
				prime[j]=false;
			}
		}
	}
	for(ll i=0;i<N;i++)
	{
		if(prime[i]==true)
		{
			v.push_back(i);
		}
	}
}

//count sum & divisor

ll countDivisor(vector<ll> &v,ll n)
{
	
	for(ll i=1;i*i<=n;i++)
	{
		if(i*i==n)
		{
			v.push_back(i);
		}
		else if(n%i==0)
		{
			v.push_back(i);
			v.push_back(n/i);
		}
	}
}

//primeFactorization

ll primeFactorization(vector<ll> &v,ll n)
{
	while(n%2==0)
	{
		v.push_back(2);
		n/=2;
	}
	for(ll i=3;i*i<=n;i=i+2)  
    {  
        while(n%i==0)  
        {  
			v.push_back(i); 
            n = n/i;  
        }  
    } 
	if(n>2)
    {
    	v.push_back(n);	
	}
}

//Palindrome check string
bool isPalindrome(string s)
{
	int l=0;
	int h=s.size()-1;
	while(l<h)
	{
		if(s[l++]!=s[h--])
		{
			return false;
		}
	}
	return true;
	
}

int main()
{
	ll n,x;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		x=(s[i]-'A'+n)%26;
		//cout<<x;	
		cout<<(char('A'+x));
	}
	cout<<endl;
	
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const ll INF=1e9;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  int n,k;
  cin>>n>>k;
  vector<ll> a(n);
  vector<ll> p,m;
  rep(i,n){
    cin>>a[i];
    if(a[i]<0){
      m.emplace_back(-a[i]);
    }else{
      p.emplace_back(a[i]);
    }
  }

  if(n==k){
    mint ans=1;
    rep(i,p.size()){
      ans*=p[i];
    }
    rep(i,m.size()){
      ans*=m[i];
    }
    if(m.size()%2==1){
      ans*=-1;
    }
    cout<<ans<<endl;
    return 0;
  }


  sort(m.begin(),m.end(),greater<ll>());
  sort(p.begin(),p.end(),greater<ll>());

  if(k%2==1 && p.size()==0){//すべて負かつ奇数個選ぶ場合．
    mint ans=1;
    rep(i,k){
      ans*=m[m.size()-1-i];
      ans*=-1;
    }
    cout<<ans<<endl;
    return 0;
  }
  int nm=m.size();
  int np=p.size();
  //偶数個選ぶ場合，
  int ip=0;
  int im=0;
  int isum=0;
  mint ans=1;

  if(k%2==1){//奇数個選ぶ場合
    ip=1;
    isum=1;
    ans=mint(p[0]);
  }

  while(isum<k){
      if(ip>=np-1){
        ans*=m[im];
        ans*=m[im+1];
        im+=2;
      }else if(im>=nm-1){
        ans*=p[ip];
        ans*=p[ip+1];
        ip+=2;
      }else if(p[ip]*p[ip+1]>m[im]*m[im+1]){
        ans*=p[ip];
        ans*=p[ip+1];
        ip+=2;
      }else{
        ans*=m[im];
        ans*=m[im+1];
        im+=2;
      }
      isum+=2;
  }

  cout<<ans<<endl;












}


Measured memory_bytes: 6912
import java.util.*

data class Pos(val x: Int, val y: Int, val dir: Int, val cost: Long)

fun main() {
    val builder = StringBuilder()

    val (h, w, kt) = readInputLine().split(" ").map { it.toInt() }

    val k = kt.toLong()

    val (y1, x1, y2, x2) = readInputLine().split(" ").map { it.toInt() - 1 }

    val map = Array(h) { readInputLine().toCharArray() }

    // 上向きから時計回りに0, 1, 2, 3
    val cost = Array(h) { Array(w) { LongArray(4) { Long.MAX_VALUE } } }

    // (x, y, 向き, コスト)
    val queue = PriorityQueue<Pos> { x, y -> x.cost.compareTo(y.cost) }

    queue.add(Pos(x1, y1, 0, 0L))
    queue.add(Pos(x1, y1, 1, 0L))
    queue.add(Pos(x1, y1, 2, 0L))
    queue.add(Pos(x1, y1, 3, 0L))

    cost[y1][x1][0] = 0L
    cost[y1][x1][1] = 0L
    cost[y1][x1][2] = 0L
    cost[y1][x1][3] = 0L

    while (queue.isNotEmpty()) {
        val pos = queue.poll()

        if (cost[pos.y][pos.x][pos.dir] != pos.cost) {
            continue
        }

        if (pos.x == x2 && pos.y == y2) {
            println((pos.cost + (k - 1L)) / k)
            return
        }

        when(pos.dir) {
            0 -> {
                if (pos.y > 0 && map[pos.y - 1][pos.x] != '@' && cost[pos.y - 1][pos.x][pos.dir] > pos.cost + 1L) {
                    cost[pos.y - 1][pos.x][pos.dir] = pos.cost + 1L
                    queue.add(Pos(pos.x, pos.y - 1, pos.dir, pos.cost + 1L))
                }
            }
            1 -> {
                if (pos.x < w - 1 && map[pos.y][pos.x + 1] != '@' && cost[pos.y][pos.x + 1][pos.dir] > pos.cost + 1L) {
                    cost[pos.y][pos.x + 1][pos.dir] = pos.cost + 1L
                    queue.add(Pos(pos.x + 1, pos.y, pos.dir, pos.cost + 1L))
                }
            }
            2 -> {
                if (pos.y < h - 1 && map[pos.y + 1][pos.x] != '@' && cost[pos.y + 1][pos.x][pos.dir] > pos.cost + 1L) {
                    cost[pos.y + 1][pos.x][pos.dir] = pos.cost + 1L
                    queue.add(Pos(pos.x, pos.y + 1, pos.dir, pos.cost + 1L))
                }
            }
            3 -> {
                if (pos.x > 0 && map[pos.y][pos.x - 1] != '@' && cost[pos.y][pos.x - 1][pos.dir] > pos.cost + 1L) {
                    cost[pos.y][pos.x - 1][pos.dir] = pos.cost + 1L
                    queue.add(Pos(pos.x - 1, pos.y, pos.dir, pos.cost + 1L))
                }
            }
        }

        for (i in 0..3) {
            if (i % 2 == pos.dir % 2) {
                continue
            }
            if (cost[pos.y][pos.x][i] > (pos.cost + k - 1) / k * k) {
                cost[pos.y][pos.x][i] = (pos.cost + k - 1) / k * k
                queue.add(Pos(pos.x, pos.y, i, (pos.cost + k - 1) / k * k))
            }
        }
    }

    println(-1)

//    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


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

int main(){
  int N ;
  int eight = 0;
  cin >> N;
  for(int i = 1; i <= N  ; ++i){
    int count = 0;
    for(int j = 1 ; j <= N ; j++){
      if(i%j == 0 ) count++;
    }
    if(count == 8 & i % 2 ==1 ) eight++;
    //cout << count << "\n";
  }
  cout << eight;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, 6) {
        if (s[i] == '1') cnt++;
    }
    cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long LL;
int gcd(int,int);

int main()
{
	int x,y;
	while(cin>>x>>y){
		int gy=gcd(x,y);
		if(gy==y)
			cout<<-1<<endl;
		else{
			for(int i=2;i<=1e6;i++){
				LL t=x*i;
				if(t%y!=0){
					cout<<t<<endl;
					break;
				}
			}
		}
		cout<<endl;
	}
	return 0;
} 

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;

int last(vi a){
  int n = a.size();
  //for (int i=0; i<n; ++i) a[i] = rand()%3;
  //vi oa = a;
  for (int len = n-1; len>=1; --len){
    vi b(n);
    for (int i = 0; i<len; ++i){
      b[i] = abs(a[i]-a[i+1]);
    }
    a = b;
  }
  return a[0];
}


int main(int argc, char *argv[])
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int m, n; cin>>n>>m;
    vector<string> mp(n);
    for (auto &s : mp) cin>>s;

    vector<vi> dp(n, vi(m, m*n+10));

    deque<pii> bfs;
    bfs.push_back({0, 0});
    if (mp[0][0] == '#') dp[0][0] = 1;
    else dp[0][0] = 0;

    auto push = [&](int i, int j, int l, bool front){
      if (l < dp[i][j]){
        dp[i][j] = l;
        if (front)bfs.push_front({i,j});
        else bfs.push_back({i,j});
      }
    };

    vector<vi> dir({{0,1}, {1,0}});

    while(!bfs.empty()){
      pii p = bfs.front(); bfs.pop_front();
      int l = dp[p.first][p.second];
      for (vi di : dir){
        int nx = p.first+di[0];
        int ny = p.second + di[1];
        if (nx < n && ny < m){
          int nl = l;
          if (mp[p.first][p.second] == '.' && mp[nx][ny] == '#') nl++;
          push(nx, ny, nl, nl==l);
        }
      }
    }
    cout<<dp[n-1][m-1];

    return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sz(s) (int)(s.size())
#define all(v) v.begin(),v.end()
#define endl "\n"
using namespace std;
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x % y); }
void Run() {

    // freopen("mex.in", "r", stdin);
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin); freopen("outt.txt", "w", stdout);
#endif
}

inline ll pp(ll a)
{
    ll start = -1000, end = 1000, mid;
    while (start <= end)
    {

        mid = (start + end) / 2;
        if (mid * mid * mid * mid * mid == a)
            return mid;
        else if (mid * mid * mid * mid * mid > a)
        {
            end = mid - 1;
        }
        else if (mid * mid * mid * mid * mid < a)
        {
            start = mid + 1;
        }
    }
    return -1;

}
int main()
{
    //Run();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = -1000; i <= 1000; i++)
    {
        ll a = pow(i, 5) - n;
        ll b = pp(a);
        if (pow(i, 5) - pow(b, 5) == n)
        {
            cout << i << " " << b;
            return 0;
        }

    }
}

Measured memory_bytes: 4112
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n, a;
string s;

bool cmp(const pair<string, int> &a, const pair<string, int> &b){
  if(a.F.size() != b.F.size()) return a.F.size() < b.F.size();
  return a.F < b.F;
}

int main(){
  scanf("%d", &n);
  vector<pair<string, int> >v;
  rep(i, n){
    cin >> s >> a;
    int p = 0;
    while(v.size() > p){
      if(v[p].F == s){ v[p].S += a; break; }
      p++;
    }
    if(v.size() == p) v.PB(MP(s, a));
  }
  sort(v.begin(), v.end(), cmp);

  rep(i, v.size()) cout << v[i].F << ' ' << v[i].S << endl;
  return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#define inf 1.0e9

using namespace std;

struct vec2d{
	double x, y;
	vec2d(){}
	vec2d(double x, double y){
		this->x = x, this->y = y;
	}
	vec2d operator+(vec2d ope){
		vec2d tmp;
		tmp.x = this->x + ope.x;
		tmp.y = this->y + ope.y;
		return tmp;
	}
	vec2d operator-(vec2d ope){
		vec2d tmp;
		tmp.x = this->x - ope.x;
		tmp.y = this->y - ope.y;
		return tmp;
	}
	vec2d operator*(double t){
		vec2d tmp;
		tmp.x = this->x * t;
		tmp.y = this->y * t;
		return tmp;
	}
	double dot(vec2d ope){
		return x*ope.x + y*ope.y;
	}
	double cross(vec2d ope){
		return x*ope.y - y*ope.x;
	}
};

int N;
double sx, sy, ex, ey;
double x1[55], y_1[55], x2[55], y2[55], h[55];

bool onL(vec2d p, vec2d q, vec2d c)
{
	return ( (c-p).cross(q-p) == 0 && (c-p).dot(q-p) * (c-q).dot(p-q) >= 0);
}

double distPP(vec2d p, vec2d q)
{
	return sqrt((p-q).dot(p-q));
}

double distLP(vec2d p, vec2d q, vec2d c)
{
	if((c-p).dot(q-p) < 0) return distPP(p, c);
	if((c-q).dot(p-q) < 0) return distPP(q, c);
	
	return fabs((c-p).cross(q-p) / distPP(p, q));
}

double distLL(vec2d p, vec2d q, vec2d s, vec2d t)
{
	if((q-p).cross(t-s) == 0){
		if(onL(p, q, s) || onL(p, q, t) || onL(s, t, p) || onL(s, t, q)) return 0.0;
	}
	else{
		double T = (s-p).cross(t-s) / (q-p).cross(t-s);
		vec2d c = p + (q-p)*T;
		if(onL(p, q, c) && onL(s, t, c)) return 0.0;
	}
	
	double d = inf;
	d = min( d, distLP(p, q, s) );
	d = min( d, distLP(p, q, t) );
	d = min( d, distLP(s, t, p) );
	d = min( d, distLP(s, t, q) );
	
	return d;
}

bool check(double R)
{
	double lim;
	vec2d s(sx, sy), e(ex, ey), p, q;
	
	for(int i = 0; i < N; i++){
		if(h[i] >= R) lim = R;
		else lim = sqrt(2*h[i]*R - h[i]*h[i]);
		
		if(distLL(s, e, vec2d(x1[i], y_1[i]), vec2d(x1[i], y2[i]) ) <= lim) return false;
		if(distLL(s, e, vec2d(x1[i], y2[i]), vec2d(x2[i], y2[i]) ) <= lim) return false;
		if(distLL(s, e, vec2d(x2[i], y2[i]), vec2d(x2[i], y_1[i]) ) <= lim) return false;
		if(distLL(s, e, vec2d(x2[i], y_1[i]), vec2d(x1[i], y_1[i]) ) <= lim) return false;
	}
	return true;
}

int main(void)
{
	while(1){
		cin >> N;
		if(N == 0) break;
		
		cin >> sx >> sy >> ex >> ey;
		for(int i = 0; i < N; i++){
			cin >> x1[i] >> y_1[i] >> x2[i] >> y2[i] >> h[i];
		}
		
		double ub = 1000.0, lb = 0.0, mid;
		while(ub - lb > 1.0e-9){
			mid = (ub + lb) * 0.5;
			if(check(mid)) lb = mid;
			else ub = mid;
		}
		mid = (ub + lb) * 0.5;
		
		for(int i = 0; i < N; i++){
			if(sx >= x1[i] && sx <= x2[i] && sy >= y_1[i] && sy <= y2[i]){
				mid = 0.0;
				break;
			}
		}
		
		printf("%.8f\n", mid);
	}
	return 0;
}

Measured memory_bytes: 3160
using System;
using System.Linq;

class Program
{
  static void Main()
  {
    var N = int.Parse(Console.ReadLine());
    var A = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    
    int count = 0;
    
    while(A.All( x => x%2 == 0 ))
    {
      A = A.Select( i => i/=2 ).ToArray();
      count++;
    }

    Console.WriteLine(count);
  }
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll N;
    ll a[5];
    cin >> N;
    rep(i, 5) cin >> a[i];

    ll ans = 5;
    ll tmp = N/a[0] + bool(N%a[0]);
    rep(i, 5) {
        tmp = max(N/a[i] + bool(N%a[i]), tmp);
    }

    cout << ans + tmp -1 << endl;
}


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

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		pl(Math.max(Math.max(2*A-1, A+B), 2*B-1));
	}
	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: 22612
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)

const ll MOD = 1e9 + 7;

const int MAX = 100001;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

int main(void) {
    cin >> n >> k;
    vector<ll> aa(n);
    vector<unsigned long long int> kaijou(n, 1);

    COMinit();

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

    sort(aa.begin(), aa.end());

    ll summax = 0, summin = 0;

    for (int i = 0; i < n; ++i) {
        ll rmar = n - i - 1;
        ll lmar = i;

        ll sur = COM(lmar, k - 1) * aa[i] % MOD;
        ll sul = COM(rmar, k - 1) * aa[i] % MOD;

        summax += sur;
        summin += sul;
    }

    cout << (summax - summin) % MOD << endl;

    return 0;
}



Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    ll i,j,k,ans=0;
    vector<ll> l(n);
    for(i=0;i<n;i++) cin>>l[i];
    sort(l.begin(),l.end());
    for(i=1;i<n;i++)
    {
        for(j=0;j<i;j++)
        {
            ll tmp = l[i] + l[j];
            ans+=(lower_bound(l.begin(), l.end(), tmp)-l.begin()-i-1);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int A, B, C, total, count = 0;
    bool flag = false;
    
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> total;
    
    for(int i=0; i<=A; i++){
        for(int j=0; j<=B; j++){
            for(int k=0; k<=C; k++){
                if(total == 500*i + 100*j + 50*k){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;    
}


Measured memory_bytes: 256
N,K=map(int,raw_input().split( ))
numlist=map(int,raw_input().split( ))
def checknum(num):
    t = num
    while(t):
        check=t%10
        k=0
        while(k<K):
            if check == numlist[k]:
                return 0
            k+=1
        t=t/10
    return 1


while(1):
    if(checknum(N)):
        print N
        break
    N+=1


Measured memory_bytes: 2568
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
using ll = long long int;
int a[4];
char ac[4];
string Sans;
void DFS(int i, int sum, string S) {
    if (i == 4 && sum == 7) {Sans = S; return;}
    else if (i == 4) return;
    else {
        char c;
        c = '0'+a[i];
        DFS(i+1,sum+a[i],S+'+'+c); DFS(i+1,sum-a[i],S+'-'+c);
    }
}

int main() {
    string S;
    for (int i = 0; i < 4; i++) {
        cin >> ac[i];
        a[i] = ac[i]-'0';
    }
    S += ac[0];
    DFS(1,a[0],S);
    cout << Sans  << "=7" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
using ll = long long;

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

    ll ans=0;
    for(ll i=k;i<=n+1;i++){
        ll l=(i-1)/2*i;
        ll r=(n-i+1+n)/2*i;
        ans+=r-l+1;
        ans%=1000000007;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
    int n;
    int a[100] = {0};

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

    sort(a,a+n,greater<int>());

    int alice=0,bob=0;

    for(int i = 0; i < n; i+= 2)
    {
        alice += a[i];
    }
    for(int i = 1; i < n; i+=2)
    {
        bob+= a[i];
    }

    cout << alice - bob << endl;

    return 0;
}

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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	string s[2];
	for(int i=0; i<2; i++) {
		cin >> s[i];
	}
	for(int i=0;i<n*2; i++) {
		int a = i/2, b = i&1;
			cout << s[b][a];
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<long long>A(N), B(N);
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
	long long ans = 0;
	for (int i = N - 1; i >= 0; i--) {
		if (B[i] == 1) continue;
		if ((A[i] + ans) % B[i] == 0) continue;
		ans += B[i] - (A[i] + ans) % B[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>

typedef long long LL;
const LL Infll = 0x3f3f3f3f3f3f3f3f;
const int MN = 505;

int N;
LL A[MN][MN], B[MN][MN], f[MN][MN], Ans;

inline LL val(int k, int j, int i) {
	return B[j + 1][i] + A[N][j] - A[N][k] - A[i][j] + A[i][k];
}

int main() {
	scanf("%d", &N), Ans = Infll;
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= N; ++j)
			if (j != i) scanf("%lld", &A[i][j]);
	for (int j = 1; j <= N; ++j)
		for (int i = j; i >= 1; --i)
			B[i][j] = B[i + 1][j] + B[i][j - 1] - B[i + 1][j - 1] + A[i][j];
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= N; ++j)
			A[i][j] += A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1];
	for (int i = 1; i <= N - 1; ++i) {
		f[i][0] = val(0, 0, i);
		Ans = std::min(Ans, f[i][0] + val(0, i, N));
		for (int j = 1; j < i; ++j) {
			f[i][j] = Infll;
			for (int k = 0; k < j; ++k)
				f[i][j] = std::min(f[i][j], f[j][k] + val(k, j, i));
			Ans = std::min(Ans, f[i][j] + val(j, i, N));
		}
	}
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 6144