akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, m;
    cin >> n >> m;
    int ans = 0;
    string s;
    vector<string> grid;
    unordered_set<int> visit;
    for(int i = 0; i < n; i++) {
        cin >> s;
        grid.push_back(s);
        for(int j = 0; j < m; j++) {
            if (grid[i][j] == '#') {
                visit.insert(i*m+j);
            }
        }
    }
    vector<int> dir = {1, 0, -1, 0, 1};
    vector<vector<int>> dq;
    for(auto& num: visit) {
        dq.push_back({num/m, num%m});
    }
    if (visit.size() == m*n) {
        cout << 0 << endl;
        return 0;
    }
    int dis = 0;
    while (!dq.empty()) {
        dis += 1;
        vector<vector<int>> new_dq;
        for(auto& pos: dq) {
            for(int i = 0; i < 4; i++) {
                int rr = pos[0] + dir[i];
                int cc = pos[1] + dir[i+1];
                if (rr < 0 || rr >= n || cc < 0 || cc >= m)
                    continue;
                if (visit.count(rr*m+cc) == 0 && grid[rr][cc] == '.') {
                    grid[rr][cc] = '#';
                    visit.insert(rr*m+cc);
                    new_dq.push_back({rr, cc});
                }
            }
        }
        if (new_dq.empty()) {
            dis -= 1;
            break;
        }
        dq.swap(new_dq);
    }
    cout << dis << endl;
    return 0;
}



Measured memory_bytes: 95624
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main()
{
    long n ,k;
    cin >> n >> k ;
    long p = n/k;
    if(k%2 ==0 ){
        
        if(n%k >= k/2){
            
            cout << p*p*p + (p+1)*(p+1)*(p+1);
        }
        else{
            cout << 2*p*p*p;
        }
    }
    else{
        cout << p*p*p;
    }
    
    return 0;
}

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

struct TopologicalSort {
    int n;
    vector <set<int>> G;
    vector<bool> used;
    vector<int> indeg, p;

    TopologicalSort() {}
    TopologicalSort(int sz) : n(sz), G(n), used(n), indeg(n), p(0) {}

    void add_edge(int s, int t) {
        G[s].insert(t);
    }

    void bfs(int s) {
        queue<int> q;
        q.push(s);
        used[s] = 1;
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            p.push_back(v);
            for (int u:G[v]) {
                indeg[u]--;
                if (indeg[u] == 0 && !used[u]) {
                    used[u] = 1;
                    q.push(u);
                }
            }
        }
    }

    vector<int> build() {
        fill(used.begin(), used.end(), 0);
        fill(indeg.begin(), indeg.end(), 0);

        for (int i = 0; i < n; i++) {
            for (int v:G[i]) {
                indeg[v]++;
            }
        }

        for (int i = 0; i < n; i++) {
            if (indeg[i] == 0 && !used[i]) {
                bfs(i);
            }
        }

        return p;
    }
};

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

    int N, M;
    cin >> N >> M;
    vector<int> table[N];

    TopologicalSort ts(N);
    for (int i = 0; i < M; i++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        ts.add_edge(s, t);
        table[s].push_back(t);
    }

    auto p = ts.build();

    int dp[N];
    fill(dp, dp + N, 0);

    for (int node : p) {
        for (int next : table[node]) {
            dp[next] = max(dp[next], dp[node] + 1);
        }
    }

    int ret = -1;
    for (int i = 0; i < N; i++) {
        ret = max(ret, dp[i]);
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 16768
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x7fffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
int mod=1e9+7;
const int M=1e6+10;
const int N=2e3+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
struct node{
	int loc;
	ll val;
}a[N];
bool cmp(node x,node y){return x.val>y.val;}
int n,m,k,T;
ll ans;
ll dp[N][N];	
int main() 
{
    int i,j;
	n=read();
	for(i=1;i<=n;i++) {
		a[i].val=read();
		a[i].loc=i;
	}
	sort(a+1,a+n+1,cmp);
	int l=1,r=n;
	for(i=1;i<=n;i++) {
		dp[i][0]=dp[i-1][0]+a[i].val*abs((n-i+1)-a[i].loc);
		for(j=1;j<=i-1;j++) {
			l=j;r=n-(i-j-1);
			dp[i][j]=max(dp[i-1][j-1]+a[i].val*abs(a[i].loc-l),dp[i-1][j]+a[i].val*abs(r-a[i].loc));
		}
		dp[i][i]=dp[i-1][i-1]+a[i].val*abs(a[i].loc-i);
	}
	for(i=0;i<=n;i++) {
		ans=max(ans,dp[n][i]);
	}
	printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 26380
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

const double PI = 3.141592653589793;

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

int main() {

	ll N, K;
	cin >> N >> K;

	vi A(N);
	vi F(N);

	rep(i, N) {
		cin >> A[i];
	}
	rep(i, N) {
		cin >> F[i];
	}

	sort(all(A));
	// 逆順はstd::greater<Type>()
	sort(all(F), greater<ll>());

	ll m = 0;
	rep(i, N) {
		if (A[i] * F[i] > m) {
			m = A[i] * F[i];
		}
	}


	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = m; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		ll count = 0;
		rep(i, N) {
			ll need = A[i] - (mid / F[i]);
			count += max(0LL, need);
		}

		if (count <= K) {
			right = mid;
		}

		else left = mid;
	}

	cout << right << endl;
	return 0;
}

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

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 10;

bool bio[MAXN];

int n, idx1 = -1, idx2 = -1, x;
int a[MAXN], pos[MAXN], fact[MAXN];

int add(int a, int b) {
  a += b;
  while (a < 0) a += MOD;
  return a % MOD;
}

int mul(int a, int b) {
  return (llint) a * b % MOD;
}

int mypow(int b, int e) {
  int ret = 1;
  while (e > 0) {
    if (e & 1) ret = mul(ret, b);
    b = mul(b, b);
    e /= 2;
  }
  return ret;
}

int inv(int x) {
  return mypow(x, MOD - 2);
}

int choose(int n, int k) {
  if (k > n || k < 0) return 0;
  return mul(mul(fact[n], inv(fact[k])), inv(fact[n - k]));
}

inline void init() {
  fact[0] = 1;
  for (int i = 1; i < MAXN; ++i)
    fact[i] = mul(i, fact[i - 1]);
}

int main(void) {
  init();
  scanf("%d", &n);
  for (int i = 0; i < n + 1; ++i) {
    scanf("%d", &a[i]);
    if (bio[a[i]]) x = a[i];
    bio[a[i]] = true;
  }

  for (int i = 0; i < n + 1; ++i) {
    if (a[i] != x) continue;
    if (idx1 == -1)
      idx1 = i;
    else
      idx2 = i;
  }

  for (int i = 0; i < n + 1; ++i) {
    int A = choose(n, i), B = choose(n, i), AinterB = add(choose(idx1 + n - idx2, i), choose(n - 1, i - 1));
    int AunionB = add(add(A, B), -AinterB);
    int other = choose(n + 1 - 2, i + 1);
//    TRACE(A _ B _ AinterB);
//    TRACE(i _ AunionB _ other);
    printf("%d\n", add(AunionB, other));
  }
  return 0;
}


Measured memory_bytes: 2048
//A Five Antennas
#include<bits/stdc++.h>
using namespace std;

int main()
{
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a<=k)
  {
    cout<<"Yay!"<<endl;
  }
  else
  {
    cout<<":("<<endl;
  }
}


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

Y = [x - A for x in X]

dp = [[0] * 10000 for _ in range(N + 1)]
dp[0][5000] = 1

for m in range(1, N + 1):
    for s in range(-5000, 5001):
        if s + 5000 < 10000:
            dp[m][s + 5000] += dp[m - 1][s + 5000]
            if 0 <= s - Y[m - 1] + 5000 < 10000:
                dp[m][s + 5000] += dp[m - 1][s - Y[m - 1] + 5000]

print(dp[N][5000] - 1)

Measured memory_bytes: 7528
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=1e5+5;

int par[MAX];
int rk[MAX];
//初期化
void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		rk[i]=0;
	}
}
//根を求める
int find(int x){
	if(par[x]==x){
		return x;
	}
	else{
		return par[x]=find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	
	if(rk[x]<rk[y]){
		par[x]=y;
	}
	else{
		par[y]=x;
		if(rk[x]==rk[y])rk[x]++;
	}
}
//xとyが同じ集合に属するか判定
bool same(int x,int y){
	return find(x)==find(y);
}

int main(){
	int N,M;
	cin>>N>>M;
	init(N);
	int ans=N;
	rep(i,M){
		int x,y,z;
		cin>>x>>y>>z;
		x--;
		y--;
		if(same(x,y))continue;
		else{
			ans--;
			unite(x,y);
		}
	}
  	cout<<ans;
}

Measured memory_bytes: 1024
let () =
let a, b, c, d = Scanf.scanf "%d\n%d\n%d\n%d\n" (fun a b c d -> a, b, c, d) in
let lst = [a+c; a+d; b+c; b+d] in
Printf.printf "%d\n" (List.fold_left min max_int lst)

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;


int main(){
    int n; 
    int ans = 0;

    cin >> n;

    for (int i = 0; i <= n; i++) {
        int x = i;
        int kcount = 0;
        while (x) {
            x /= 10;
            kcount++;
        }
        if (kcount % 2 == 1) {
            ans++;
            // cout << i << endl;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cmath>
#include <iomanip>
#include <stdio.h>
using namespace std;
int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double ans;
    double pi = 3.141592653589793238462643383279;
    if(a*b*a>2*x) ans = 90.0 - atan((2*x/a/b/b))*180/pi;
    else ans = atan((2*(a*b-x/a)/a/a))*180/pi;
    //cout << (double)(2*(a*b-x/a)/a/a)<<endl;
    //cout << setprecision(10)<<ans << endl;
    printf("%2.10f\n", ans);
}


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

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


  int n;cin>>n;
  vector<int> x(n);
  for(int i=0;i<n;i++)cin>>x[i];
  ll res=10000000;
  for(int i=1;i<=100;i++){
    ll t=0;
    for(int j=0;j<n;j++){
      t += pow(i-x[j],2);
    }
    res=min(t,res);
  }
  cout<<res<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll a, b, c, d, e, f, g;
int main(void){
    // Your code here!
    cin >> a >> b >> c >> d >> e >> f >> g;
    if (a == 0 || d == 0 || e == 0){
        cout << a - a % 2 + b + d - d % 2 + e - e % 2 << endl;
        return 0;
    }
    cout << a + b + d + e - (a % 2 + d % 2 + e % 2 == 1 || a % 2 + d % 2 + e % 2 == 2 ? 1 : 0) << endl;
}


Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include <set>

#define prev asasddlsa
#define rank aljds

using namespace std;

typedef long long ll;

template<typename T>
void print(const vector<T>& s){
    for (auto x : s)
        cout << x << " ";
    cout << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> cnt(n, 0);
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        cnt[x - 1]++;
    }
    sort(cnt.begin(), cnt.end());
    vector<int> pref(n + 1, 0);
    for (int i = 0; i < n; i++)
        pref[i + 1] = pref[i] + cnt[i];
    for (int k = 1; k <= n; k++){
        int l = 0;
        int r = n + 1;
        while (l + 1 < r){
            ll m = (l + r) / 2;
            int pos = upper_bound(cnt.begin(), cnt.end(), m) - cnt.begin();
            if (pref[pos] + (n - pos) * m >= k * m)
                l = m;
            else
                r = m;
        }
        cout << l << "\n";
    }
    return 0;
}

Measured memory_bytes: 3200
w = gets.chomp.to_i  # pos number(yoko)
n = gets.chomp.to_i  # bar number(tate)

pos = [*0..w]

1.upto(n){|i|
  from,to = gets.chomp.split(',').map{|x| x.to_i}
  kari = pos[to]
  pos[to] = pos[from]
  pos[from] = kari
}
puts pos.reject{|x|x==0}

Measured memory_bytes: 8588
//
// Created by Tzyark on 2018/9/29.
//
#include <iostream>
using namespace std;
typedef long long ll;
int n, a[100010], x;
int main() {
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i-1] + a[i] > x) {
            if (a[i-1] > x) {
                ans += 1ll * (a[i - 1] - x + a[i]);
                a[i] = 0;
            }
            else {
                ans += 1ll * (a[i-1] + a[i] - x);
                a[i] = x - a[i-1];
            }
        }
    }
    cout << ans;
    return 0;
};


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

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

  char p[128] = {};
  char q[128] = {};

  for(int i = 0;i < s.size();i++){
    if(p[t[i]] == 0){
      p[t[i]] = s[i];
    }else{
      if(p[t[i]] != s[i]){
        cout << "No" << endl;
        return 0;
      }
    }
    if(q[s[i]] == 0){
      q[s[i]] = t[i];
    }else{
      if(q[s[i]] != t[i]){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}



Measured memory_bytes: 776
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0
for i in range(n):
  a = list(map(int,input().split()))
  d = c
  for j in range(m):
    d += a[j]*b[j]
  if d > 0:
    ans += 1
print(ans)
    

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        String n = scanner.nextLine();
        String s = scanner.nextLine();

        if(n.equals(s.substring(0, s.length() - 1))){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        scanner.close();
    }

}

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

using namespace std;

int a, b;

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

	cin >> a >> b;

	if (a <= b * 2) {
		cout << "0\n";
	}
	else {
		cout << a - (b * 2) << "\n";
	}


	return 0;
}

Measured memory_bytes: 256
package main

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

var D int
var cs []int
var ss [][]int

func main() {
	D = ReadInt()
	cs = ReadInts(26)
	ss = make([][]int, D)
	for i := 0; i < D; i++ {
		ss[i] = ReadInts(26)
	}

	answers := ReadInts(D)
	scores := scores(answers)
	for _, score := range scores {
		fmt.Println(score)
	}
}

func scores(answers []int) []int {
	scores := []int{}
	last := make([]int, 26)
	score := 0
	for d := 1; d <= D; d++ {
		t := answers[d-1] - 1
		score += ss[d-1][t]
		last[t] = d
		for i := 0; i < 26; i++ {
			score -= cs[i] * (d - last[i])
		}
		scores = append(scores, score)
	}
	return scores
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}

//
//
// func main() {
// 	D := ReadInt()
// 	cs := ReadInts(26)
// 	ss := make([][]int, D)
// 	for i := 0; i < D; i++ {
// 		ss[i] = ReadInts(26)
// 	}
// 	ts := ReadInts(D)
//
// 	score := 0
// 	last := make([]int, 26)
// 	for d := 1; d <= D; d++ {
// 		t := ts[d-1] - 1
// 		score += ss[d-1][t]
// 		last[t] = d
// 		for i := 0; i < 26; i++ {
// 			score -= cs[i] * (d - last[i])
// 		}
// 		fmt.Println(score)
// 	}
// }
//
// var reader = bufio.NewReader(os.Stdin)
//
// func Scan(a ...interface{}) {
// 	if _, err := fmt.Fscan(reader, a...); err != nil {
// 		panic(err)
// 	}
// }
// func ReadInt() (i int) { Scan(&i); return }
// func ReadInts(n int) []int {
// 	v := make([]int, n)
// 	for i := 0; i < n; i++ {
// 		Scan(&v[i])
// 	}
// 	return v
// }


Measured memory_bytes: 2012
import sys

def solve():
    input = sys.stdin.readline
    A, B, C, K = map(int, input().split())
    sumL = 0
    if K <= A: 
        sumL += K
        K = 0
    else:
        sumL += A
        K -= A
    if K > B:
        K -= B
    else: K = 0
    if K > 0: sumL -= K
    print(sumL)

    return  0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9196
N, K = [int(i) for i in input().split()]
h = [0] * (N+K)
for i, j in enumerate([int(i) for i in input().split()]):
    h[i]=j

INF = 10**12

dp = [INF]*200000

dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))

print(dp[N-1])


Measured memory_bytes: 53728
num = gets.to_i
nums = gets.split(" ").map(&:to_i)

for i in 0...num
	if nums[i] % 2 == 0
		if nums[i] % 3 != 0 && nums[i] % 5 != 0
			puts "DENIED"
          	exit
		end
	end
end
puts "APPROVED"

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

int main() {
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  if (D2 == 1) cout << "1" << "\n";
  else cout << "0" << "\n";
  return 0;
}


Measured memory_bytes: 256
# import itertools
import math
# import sys
# import numpy as np

# K = int(input())
# S = input()
# n, *a = map(int, open(0))
A, B, H, M = map(int, input().split())
# H = list(map(int, input().split()))
# Q = list(map(int, input().split()))
# S = input()

# d = sorted(d.items(), key=lambda x:x[0]) # keyでsort
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement([i for i in range(1, M + 1)], N))
# print(a[0][0])
# print(conditions[0])

kakudo_H = (H * 60 + M) / 720 * 360
kakudo_M = M / 60 * 360

print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(abs(kakudo_H - kakudo_M)))))

Measured memory_bytes: 9424
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int a, b;

int main(){
    cin >> a >> b;

    if(abs(a-b) > 1){
        if(a > b){
            cout << a + (a - 1);
        } else{
            cout << b + (b - 1);
        }
    } else{
        cout << a + b;
    }


}


//g++ -std=c++14 comp.cpp; ./a.exe


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int value[] = new int[2];
		int count = 0;

		String s = br.readLine();
		String[] strArray = s.split(" ");

		try{
			for(int i=0;i<strArray.length;i++){
				if(strArray[i] != " "){
					value[count] = Integer.parseInt(strArray[i]);
					count++;
				}
			}

			if(value[0] < value[1]){
				System.out.println("a < b");
			}else if(value[0] > value[1]){
				System.out.println("a > b");
			}else{
				System.out.println("a == b");
			}

		}catch(ArrayIndexOutOfBoundsException e){
		}
	}
}

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

typedef long long ll;
ll gcd(ll a, ll b){
	return !b ? a : gcd(b, a % b); 
}

int main(){
	ios::sync_with_stdio(false);
	ll x, y;
	while(cin >> x >> y) cout<<gcd(x,y)<<" "<<x*y/gcd(x,y)<<"\n";
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(){
    string s;
    int w;
    cin >> s >> w;
    int len = s.size();
    for (int i = 0; i < len; i++){
        if((i - w) % w == 0){
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    double d;
    cin >> d;
    double ma = d * sqrt(2);
    REP(x, 11) {
        if (d*d - x*x >= 0) {
            double y = sqrt(d*d - x*x);
            y = max(1.0, y);
            ma = max(ma, x+y);
        }
    }
    printf("%.12lf\n", ma);
}

Measured memory_bytes: 3172
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[][] x = new int[n][d];
        int ans = 0;
        for (int i=0;i<n;i++)for (int j=0;j<d;j++)x[i][j]=sc.nextInt();
        for (int i=0;i<n-1;i++){
            for (int j=i+1;j<n;j++){
                int data = 0;
                for (int k=0;k<d;k++)data+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
                if (Math.floor(Math.sqrt(data))==Math.ceil(Math.sqrt(data)))ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35908
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	x=0;char c=getchar();bool f=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0){putchar('-'),write(-x);}
	else{if(x>9)write(x/10);putchar('0'+x%10);}
}

int n;
bitset<4000005> s;

signed main(){
	read(n);
	s=1;
	while(n--){
		int x;
		read(x);
		s|=s<<x;
	}
	n=s.count()/2;
	for(int i=1;;i++) if(s[i]){
		if(--n==0){
			write(i);
			return 0;
		}
	}
}

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

const size_t sz = 1e5 + 7;

struct Solution {
  int N, M;
  vector<vector<int>> edges;
  vector<int> degree;
  vector<int> maxpath;
  vector<bool> visited;

  Solution() {
    edges.resize(sz);
    degree.resize(sz, 0);
    maxpath.resize(sz, 0);
    visited.resize(sz, false);
  }

  void dfs(int v) {
    visited[v] = true;
    for (auto u : edges[v]) {
      maxpath[u] = max(maxpath[u], maxpath[v] + 1);
      if (degree[u] > 0) {
        --degree[u];
        if (degree[u] == 0) {
          dfs(u);
        }
      }
    }
  }

  void operator()() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
      int x, y;
      cin >> x >> y;
      edges[x].push_back(y);
      ++degree[y];
    }

    for (int i = 1; i <= N; ++i) {
      if (!visited[i] && degree[i] == 0) {
        dfs(i);
      }
    }
    cout << *max_element(maxpath.begin(), maxpath.end());
  }
};

int main() {
  Solution()();
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>button(N);
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    button.at(i)=a;
  }
  int lamp=1, t=0;
  for(int i=0;i<N;i++){
    lamp=button.at(lamp-1);
    t++;
    if(lamp==1){
      t=-1;
      break;
    }
    if(lamp==2){
      break;
    }
  }
  if(t==N)
    t=-1;
  cout << t << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll mod =1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> T maxt(T x,T y) {if (x>y) return x;else return y;}
template<class T> T mint(T x,T y) {if (x>y) return y;else return x;}
//sort(v.begin(), v.end(), [](auto& x, auto& y){return x[1] < y[1];});


//小数出力
double print_double(double d){printf("%.11f", d);}

//約数列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}



// ll combination_mod(int n, int k) {
//   k = mint(k,n-k);
//   ll ans = 1;
//   if (n==0 || k ==0) return ans;
//   rep(i,k) {
//     ans = ans*(n-i)%mod;
//     ans = ans*modinv(i+1)%mod;
//   }
//   return ans;
// }

struct edge {
  int from; //出発点
  int to;   //到達点
  ll cost; //移動コスト
};

//ベルマンフォード法
vector<ll> bellman_ford (vector<edge> edges, int V, int E, int r, ll INF = 100000000000) {  
  vector<ll> cost_to(V,INF);
  cost_to[r] = 0;
  rep(i,V) {
    rep(j,E) {
      edge e = edges[j];
      if (cost_to[e.from]==INF) continue;
      if (cost_to[e.to] > cost_to[e.from] + e.cost) {
        cost_to[e.to] = cost_to[e.from] + e.cost;
        if (i==V-1) {
          printf("NEGATIVE CYCLE\n");
          return {};
        }
      }

    }
  }
  return cost_to;
}

// combination
const int MAX = 510000;
const int MOD = 1000000007;
 
long long 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;
}


template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


// 木上の探索
vector<int> cnt;
void dfs(const vector<vector<int>> &G, int v, int p) {
    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
        dfs(G, nv, v);
    }

    // 帰りがけ時に、部分木サイズを求める
    cnt[v] = 1; // 自分自身
    for (auto c : G[v]) {
        if (c == p) continue;
        cnt[v] += cnt[c]; // 子のサイズを加える
    }
}

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];
  ll ans=LONG_LONG_MAX,t;
  rep2(i,-100,101) {
    t = 0;
    rep(j,N) t+= (i-a[j])*(i-a[j]);
    chmin(ans,t);
  }
  cout << ans << endl;
}

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

int main( void ) {
	int h, w, d, dSq;

	for ( ; scanf( "%d %d", &h, &w ), h; printf( "%d %d\n", h, w ) )
		for ( d = dSq = h * h + w * w; d < 30000; d++ )
			for ( h = d == dSq ? h + 1 : 1; h * h * 2 < d; h++ ) {
				w = sqrt( d - h * h );

				if ( w * w == d - h * h ) {
					d = 30000;
					break;
				}
			}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  set<string> st;
  char pre = '0';
  rep(i,n){
    string s;
    cin >> s;
    if(st.find(s)!=st.end()){
      cout << "No" << endl; return 0;
    }
    st.insert(s);
    if(i!=0 && pre!=s[0]){
      cout << "No" << endl; return 0;
    } else {
      pre = s.back();
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int cnt1 = 0, cnt2 = 0;
    string tarou, hanako;
    for(int i = 0; i < n; i++) {
        cin >> tarou >> hanako;
        if(tarou > hanako) cnt1 += 3;
        else if(tarou < hanako) cnt2 += 3;
        else {cnt1++; cnt2++;}
    }
    cout << cnt1 << ' ' << cnt2 << endl;
    return 0;
}


Measured memory_bytes: 3188
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Monster[] m = new Monster[]{
      new Monster(sc.nextInt(), sc.nextInt()),
      new Monster(sc.nextInt(), sc.nextInt())
    };
    int turn = 0;
    while (!m[turn++%2].isDead()) {
      m[turn%2].beAttacked(m[(turn-1)%2]);
    }
    
    System.out.println(turn%2 == 0 ? "Yes" : "No");
  }
  
  static class Monster {
    int hp;
    int attack;
    
    Monster(int hp, int attack) {
      this.hp = hp;
      this.attack = attack;
    }
    
    void beAttacked(Monster enemy) {
      this.hp -= enemy.attack;
    }
   
    boolean isDead() {
      return this.hp <= 0;
    }
  }
}


Measured memory_bytes: 35632
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
typedef long long ll;

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

    ll X, Y;
    cin >> X >> Y;
    int cnt = 0;
    while(X<=Y){
        cnt++;
        X*=2;
    }
    cout << cnt << endl;
    return 0;
}

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

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

	int i,j;
	int tmp;
	int counter=0;
	double ave;
	ld A,B;
	ld answer;
	vector<int> given;

	cin >> A >> B;

	
	answer=floor(A*B);
	//cout << answer << endl;
	cout << fixed << std::setprecision(0) << answer << endl;
	//cout << scientific << std::setprecision(0)  << answer << endl;
	//cout << fixed << setprecision(15) << answer << endl;

	return 0;
}



Measured memory_bytes: 3812
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def assign_color():
    _color = 1
    for m in range(vertices_num):
        if vertices_status_list[m] == -1:
            graph_dfs(m, _color)
            _color += 1
    return None


def graph_dfs(vertex, color):
    vertices_stack = list()
    vertices_stack.append(vertex)
    vertices_status_list[vertex] = color

    while vertices_stack:
        current_vertex = vertices_stack.pop()
        for v in adj_list[current_vertex]:
            if vertices_status_list[v] == -1:
                vertices_status_list[v] = color
                vertices_stack.append(v)
    return None


def solve():
    for relation in relation_info:
        key, value = map(int, relation.split())
        adj_list[key].append(value)
        adj_list[value].append(key)

    assign_color()

    # print(adj_list)
    for question in question_list:
        start, target = map(int, question.split())
        if vertices_status_list[start] == vertices_status_list[target]:
            print("yes")
        else:
            print("no")
    return vertices_status_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num, relation_num = map(int, _input[0].split())

    relation_info = _input[1:relation_num + 1]

    question_num = int(_input[relation_num + 1])
    question_list = _input[relation_num + 2:]

    adj_list = tuple([[] for _ in range(vertices_num)])
    vertices_status_list = [-1] * vertices_num
    ans = solve()

Measured memory_bytes: 35560
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long L = long.Parse(str[0]);
		long R = long.Parse(str[1]);
		long D = long.Parse(str[2]);
		long ans = 0;
		for(var i=L;i<=R;i++){
			if(i%D==0){
				ans++;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17884
import sys
from fractions import gcd
input = sys.stdin.readline

MOD = 10 ** 9 + 7


# a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)


def main():
    A, B, C, D = map(int, input().split())
    E = lcm(C, D)

    c_count = B // C - (A - 1) // C
    d_count = B // D - (A - 1) // D
    e_count = B // E - (A - 1) // E
    print((B - A + 1) - (c_count + d_count - e_count))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63980
S = input()
if S == "SAT":
    print(1)
elif S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)


Measured memory_bytes: 2940
#include <stdio.h>
int max(int x, int y)
{
	if (x > y)
		return x;
	else
		return y;

}
int main(void)
{
	int a;
	int b;
	int P;
	int Q;
		int R;
		int M;
		int N;
		scanf("%d", &a);
		scanf("%d", &b);
		P = a + b;
		Q = a - b;
		R = a * b;
		M = max(P, Q);
		N = max(M, R);
		printf("%d", N);
		return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  for(int i = 0; i < 3; ++i){
    if(s[i] == s[i+1]){
      cout << "Bad";
      return 0;
    }
  }
  cout << "Good";
  return 0;
}


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

char f[100];
char e[100];

int main(){
	scanf("%s",&f);
	scanf("%s",&e);
	int n = strlen(f);
	int m = strlen(e);
	int x = 0;
	int y = 0;
	int c = 0;
	if ( n > m ){
		n--;
		c = 1;
	} else if ( n < m ){
		m--;
		c = 2;
	}
	for ( int i = 0; i < n+m; i++ ){
		if ( i & 1 ){
			printf("%c",e[y++]);
		} else {
			printf("%c",f[x++]);
		}
	}
	if ( c == 1 ) printf("%c",f[n]);
	else if ( c == 2) printf("%c",e[m]);
	printf("\n");
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

int main()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            if (i * (m - j) + j * (n - i) == k)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int N,T;
	SCD2(N,T);
	
	static int A[100002];
	
	ARSCD1(A,N);
	
	int buy = A[1];
	int profit = 0;
	int Tc = T/2;
	
	FORq(i,2,N){
		if (buy < A[i]){
			profit = max(profit,(A[i] - buy));
		}else{
			buy = A[i];
		}
	}
	
	set<int> flg;
	
	buy = A[1];
	int buyin = 1;
	
	FORq(i,2,N){
		if (buy < A[i]){
			if ((A[i] - buy) == profit){
				flg.insert(i);
				flg.insert(buyin);
			}
		}else{
			buy = A[i];
			buyin = i;
		}
	}
	
	PRINTD(flg.size() / 2);

	
    
   	return 0;
}

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

const int N=1e5+100,mod=1e9+7;
int n,m;
vector<int> p;
LL f[65000][32],fac[N],inv[N],ans;

LL qpow(LL x,int y)
{
	LL ret=1;
	while(y)
	{
		if(y&1) ret=ret*x%mod;
		x=x*x%mod,y>>=1;
	}
	return ret;
}

LL C(int x,int y)
{
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}

int main()
{
	scanf("%d%d",&n,&m);
	p.push_back(0);
	for(int i=1;1ll*i*i<=m;++i)
	{
		if(m%i == 0) p.push_back(i);
		if(i*i != m) p.push_back(m/i);
	}
	int ss=0,t=m;
	for(int i=2;i*i<=t;++i)
		while(t%i == 0) t/=i,++ss;
	if(t>1) ++ss;
	sort(p.begin(),p.end());
	
	f[1][0]=1;
	for(int i=2;i<p.size();++i)
		for(int j=1;1ll*p[j]*p[j]<=p[i];++j)
			if(p[i]%p[j] == 0)
			for(int k=1;k<=ss;++k)
			{
				(f[i][k]+=f[j][k-1])%=mod;
				if(p[j]*p[j] != p[i] && p[j]!=1)
				(f[i][k]+=f[lower_bound(p.begin(),p.end(),p[i]/p[j])-p.begin()][k-1])%=mod;
			}
	if(m == 1) {cout<<"1"; return 0;}
	fac[0]=1;
	for(int i=1;i<=n;++i) fac[i]=fac[i-1]*i%mod;
	inv[n]=qpow(fac[n],mod-2);
	for(int i=n-1;i>=0;--i) inv[i]=inv[i+1]*(i+1)%mod;
	int c=p.size()-1;
	for(int i=1;i<=ss;++i)
		(ans+=C(n,i)*f[c][i]%mod)%=mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 10752
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265359
using namespace std;


//const string k = "enterstringtobechecked";



int main()
{
    SYNC
    //clock_t tStart = clock();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,d; in(n)>>d;
    ll count=0;
    l(i,0,n)
    {
        ll a,b; in(a)>>b;
        double temp = a*a + b*b;
        temp = (double)sqrt(temp*1.0);
        if(temp<=d)
            count++;
    }
    o(count)<<endl;





    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);   
}


Measured memory_bytes: 3680
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;
typedef long long llong;
const int MOD=1000000007;

int main(int argc, char**argv){
    string s;
    cin >> s;
    int ans = 700;

    for (int i = 0; i < 3; i++){
        if (s[i] == 'o') ans += 100;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//15
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

bool p[400][400][81];

int dfs(vector<int> v){
  if(v.size()<=2){
    return v.back();
  }else{
    if(p[v[0]][v[1]][v.size()]++){
      return 0;
    }else{
      int n=dfs(vector<int> (v.begin()+1,v.end()));
      if(v[1]){
	v[2]+=v[0];
	v[1]--;
	n=max(n,dfs(vector<int> (v.begin()+1,v.end())));
      }
      return n;
    }
  }
}

int main(){
  int n;
  cin>>n;
  while(n--){
    int l;
    cin>>l;
    vector<int> v(l);
    for(int i=0;i<l;i++){
      cin>>v[i];
    }
    fill(p[0][0],p[400][0],false);
    cout<<dfs(v)<<endl;
  }
  return 0;
}

Measured memory_bytes: 13896
N,K,Q = map(int,input().split())
A = list(int(input()) for _ in range(Q))

correct = [K-Q] * N

for i in range(Q):
    correct[A[i]-1] += 1

for i in correct:
    if i > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 10460
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int c2 = c * 2;

	int r1 = a * x + b * y;
	
	int r2;
	if(x < y){
		r2 = x * c2 + (y - x) * b;
	} else{
		r2 = y * c2 + (x - y) * a;
	}

	int r3 = max(x, y) * c2;
	
	int result = min(r1, min(r2, r3));
	cout << result << endl;
	return 0;
}



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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// 素数。エラトステネスの篩
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}


void Main()
{
    int n = 100000+100;
    sieve(n);

    VL c(n);
    REP(i,n){
        if(i%2==1 && IsPrime[i] && IsPrime[(i+1)/2]){
            c[i]=1;
        }
    }
    FOR(i,1,n){
        c[i] += c[i-1];
    }

    int q;cin>>q;
    REP(qq,q){
        LL l,r;cin>>l>>r;
        cout<<c[r]-c[l-1]<<endl;
    }
    
	return;
}

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

Measured memory_bytes: 3864
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

const ll MOD = 1e9 + 7;

ll pow_fast(ll n, ll k) {
  if (k == 0) {
    return 1LL;
  }
  if (k == 1) {
    return n;
  }

  if (k % 2 == 0) {
    ll tmp = pow_fast(n, k / 2);
    return tmp * tmp % MOD;
  } else {
    ll tmp = pow_fast(n, (k - 1) / 2);
    tmp *= tmp;
    tmp %= MOD;
    return tmp * n % MOD;
  }
}

template <typename T>
class stack {
 private:
  vector<T> _vec;

 public:
  stack(){};

  void push(T n) {
    _vec.push_back(n);
    return;
  }

  void pop() {
    if (this->empty()) {
      return;
    }
    _vec.erase(_vec.end() - 1);
    _vec.shrink_to_fit();
    return;
  }

  size_t size() { return _vec.size(); }

  T top() { return _vec[this->size() - 1]; }
  bool empty() { return _vec.empty(); }
};

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> stick(N);

  for (ll i = 0; i < N; i++)
  {
    cin >> stick[i];
  }
  sort(stick.begin(), stick.end(), greater<ll>());

  ll sum = 0;
  for (ll i = 0; i < K; i++)
  {
    sum += stick[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3608
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    string s;
    cin >> s;
    s += "*";

    reps(i,s.size()-1){
        if(!(s[i-1] == 'h' && s[i] == 'i')){
            return cout << "No\n",0;
        }else ++i;
    }
    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


Int n, m;
Int sw[10];
Int k[10];
Int p[10], s[10][10];
Int cnt = 0;

void init(){
    for(Int i=0; i<n; i++){
        sw[i] = 0;
    }
}

void printdbg(){
    for(Int i=0; i<n; i++){
        cout << sw[i] << " ";
    }
    cout << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> m;
    init();
    for(Int i=0; i<m; i++){
        cin >> k[i];
        for(Int j=0; j<k[i]; j++){
            cin >> s[i][j];
        }
    }
    for(Int i=0; i<m; i++){
        cin >> p[i];
    }

    for(int bit=0; bit<(1<<n); bit++){
        init();
        bool flg = true;
        for(int i=0; i<n; i++){
           if(bit & (1<<i)){
               sw[i] = 1;
           }
        }
        
        for(Int i=0; i<m; i++){
            Int sum = 0;
            for(Int j=0; j<k[i]; j++){
                if(sw[s[i][j]-1] == 1){
                    sum++;
                }
            }
            if(sum%2 != p[i]){
                flg = false;
                break;
            }
        }
        if(flg){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

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

#define mx 100005
#define md 1000000007

using namespace std;

int n, m, l;

int main(){
	scanf("%d%d%d", &n, &m, &l);

	printf("%d %d\n", min(l, m), max(l + m - n, 0));
}


Measured memory_bytes: 256