akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace cqz{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*SS=SZB,*TT=SZB;
    inline char gc(){   if (SS==TT){  TT=(SS=SZB)+fread(SZB,1,GYN,stdin); if (SS==TT) return '\n';  }   return *SS++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);}
	void writeln(ll x){write(x);puts("");}
}using namespace cqz;
const ll N=600010,mod=998244353;
ll Inv[N],fac[N],A,B,k,n,ans;
ll ppow(ll x,ll k){ll ans=1;for(;k;k>>=1,Mul(x,x))if (k&1)Mul(ans,x);return ans;}
ll C(ll x,ll y){return fac[x]*Inv[y]%mod*Inv[x-y]%mod;}
int main(){
	n=read(),A=read(),B=read(),k=read();
	fac[0]=1;For(i,1,n)fac[i]=fac[i-1]*i%mod;
	Inv[n]=ppow(fac[n],mod-2);FOr(i,n,1)Inv[i-1]=Inv[i]*i%mod;
	For(i,0,n){
		ll sum_A=i,sum_B=(k-sum_A*A)/B;
		if ((k-sum_A*A)%B)continue;
		if (sum_B<0||sum_B>n)continue;
		Add(ans,C(n,sum_A)*C(n,sum_B));
	}writeln(ans);	
}

Measured memory_bytes: 10496
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;

struct Combinations {

    long long mod;
    vector< long long > inv;
    vector< long long > fact;
    vector< long long > inv_fact;

    Combinations (int n, int m) : inv(n), fact(n), inv_fact(n), mod(m) {
        inv[1] = 1;
        for (long long i = 2; i < n; i++) {
            inv[i] = inv[mod%i] * (mod - mod / i) % mod;
        }
        fact[0] = inv_fact[0] = 1;
        for (long long i = 1; i < n; i++) {
            fact[i] = (fact[i-1] * i) % mod;
            inv_fact[i] = (inv_fact[i-1] * inv[i]) % mod;
        }
    }

    long long nPr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return fact[n] * inv_fact[n-r] % mod;
    }

    long long nCr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return nPr(n,r) * inv_fact[r] % mod;
    }

    long long nHr(long long n, long long r) {
        return nCr(n+r-1,r);
    }

};

const ll MOD = 998244353LL;

int main ()
{

    ll N,A,B,K;
    cin >> N >> A >> B >> K;

    Combinations inst(500000, MOD);

    ll ans = 0;
    for (ll cnta = 0; cnta <= K / A; cnta++) {
        ll le = K - A * cnta;
        if (le % B == 0) {
            ll a = cnta;
            ll b = le / B;
            ans += (inst.nCr(N, a) * inst.nCr(N, b)) % MOD;
            ans %= MOD;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 12032
# 2019-11-11 18:30:26(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, k, *h = (int(x) for x in sys.stdin.read().split())
    h.sort()
    diffs = []
    for i in range(n - k + 1):
        diffs.append(h[i+k-1] - h[i])
    print(min(diffs))

if __name__ == "__main__":
    main()


Measured memory_bytes: 14092
package main

import (
	"fmt"
)

func main() {
	var n, m int
	mp := make(map[int]int, n+1)
	fmt.Scan(&n, &m)
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		mp[a]++
		mp[b]++
	}
	for i := 1; i <= n; i++ {
		fmt.Println(mp[i])
	}
}


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

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define es cout<<" "
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;
template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts> 
auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

int main(void) {
    int n, k;
    cin >> n >> k;
    
    auto f = [](double n) {
        const double EPS = 1e-9;
        int i = 0;
        while (true) {
            if (n - EPS < (1 << i)) {
                return (1 << i);
            }
            ++i;
        }
    };
    
    double ans = 0.0;
    repeat_from_to (i, 1, n) {
        double t = 1.0 / (double)n;
        double s = (double)k/(double)i;
        t /= (double)f(s);
        ans += t;
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)

A = []
n.times{A << gets.chomp.split.map(&:to_i)}

B = []
m.times{B << gets.chomp.to_i}

A.each{|a|
    sum = 0
    a.zip(B){|x, y| sum += x * y}
    puts sum
}

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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << v[i];
    os << " ]";
    return os;
}


const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N+1);
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
    }

    ll ans = 0;

    for(int i = 1; i <= N; i++) {
        ll s = a[i] + a[i-1];
        if(s > x) {
            ans += s-x;
            a[i] -= (s-x);
        }
    }

    cout << ans << endl;


}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int i = 1;
		int x;
		while(true){
			x = i;
			if(x % 3 == 0){
				System.out.print(" "+i);
			}else{
				while(true){
					if(x % 10 == 3){
						System.out.print(" "+i);
						break;
					}
					x = x / 10;
					if (x == 0)break;
				}
			}
			if(++i > n)break;
		}
		System.out.println("");
	}
}

Measured memory_bytes: 28728
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    a = [0] * 5
    for i in range(5):
        a[i] = INT()
    K = INT()
    if a[-1] - a[0] <= K:
        print('Yay!')
    else:
        print(':(')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<cstdio>
int main(){
    char a[102],b[102];
    scanf("%s%s",a,b);
    int alen=0,blen=0;
    while(a[alen]!='\0')alen++;
    while(b[blen]!='\0')blen++;
    if(alen>blen)printf("GREATER");
    else if(alen<blen)printf("LESS");
    else{
        int d=0;
        while(a[d]!='\0'){
            if(a[d]>b[d]){
                printf("GREATER");
                return 0;
            }else if(a[d]<b[d]){
                printf("LESS");
                return 0;
            }
            d++;
        }
        printf("EQUAL");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>

using namespace std;

int main() {

  int a, b, c;
  cin >> a;
  double ans, ra, rb;
  string weatherReport;
  //cin >> weatherReport;
  if(a == 1){
    cout << "Hello World";
  }else{
    cin >> a >> b;
    cout << a + b;
  }
  return 0;
}


Measured memory_bytes: 3596
def productall(a):
    N = len(a)
    if N == 0: return [1]
    A = [1] * N + a[:]
    P = 10 ** 9 + 7
    k = 12
    K = k * 8
    pa1 = (1 << k * 4 + 16) - ((1 << k * 4 + 16) % P)
    pa2 = (1 << k * 2 + 24) - ((1 << k * 2 + 24) % P)
    pa3 = (1 << k + 28) - ((1 << k + 28) % P)
    m1 = int(("1" * (k * 4 - 16) + "0" * (k * 4 + 16)) * 5050, 2)
    m2 = int(("1" * (k * 6 - 24) + "0" * (k * 2 + 24)) * 5050, 2)
    m3 = int(("1" * (k * 7 - 28) + "0" * (k + 28)) * 5050, 2)
    def modP(x):
        x -= ((x & m1) >> k * 4 + 16) * pa1
        x -= ((x & m2) >> k * 2 + 24) * pa2
        x -= ((x & m3) >> k + 28) * pa3
        return x

    for i in range(N)[::-1]:
        A[i] = modP(A[2*i] * A[2*i+1])

    t = bin(A[1])[2:] + "_"
    return [int(t[-(i+1) * K - 1:-i * K - 1], 2) % P for i in range((len(t)+K-2) // K)]
def par(a):
    L = []
    while P[a] != a:
        L.append(a)
        a = P[a]
    for l in L:
        P[l] = a
    return a
def unite(a, b):
    pa = par(a)
    pb = par(b)
    if pa == pb: return
    if LEN[pa] < LEN[pb]:
        a, b, pa, pb = b, a, pb, pa
    P[pb] = pa
    if LEN[pa] == LEN[pb]: LEN[pa] += 1
    CNT[pa] += CNT[pb]
def cnt(a):
    return CNT[par(a)]

N = int(input())
P = [i for i in range(N)]
LEN = [1] * N
CNT = [1] * N
FULL = [0] * N
A = [int(a) - 1 for a in input().split()]
for i, a in enumerate(A):
    if a < 0: continue
    if par(i) != par(a):
        unite(i, a)
    else:
        FULL[i] = 1
for i in range(N):
    if FULL[i]:
        FULL[par(i)] = 1
X = []
Y = []
for i in range(N):
    if par(i) == i:
        if FULL[i] == 0:
            X.append(CNT[i])
        else:
            Y.append(CNT[i])
M = len(X)
mod = 10 ** 9 + 7
ans = (sum(X) + sum(Y) - len(Y)) * pow(N - 1, M, mod) % mod
L = productall([(a << 96) + 1 for a in X])
if M:
    fa = 1
    ans = (ans + M * pow(N - 1, M - 1, mod)) % mod
    for i, l in enumerate(L):
        if i == 0: continue
        ans = (ans - l * fa * pow(N - 1, M - i, mod)) % mod
        fa = fa * i % mod
print(ans)

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

count1 = 0
for i in range(N):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            count1 += 1

count2 = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            count2 += 1

# print(count1)
# print(count2)

ans = K * count1 + (count2 * K * (K - 1)) // 2
ans = ans % ((10 ** 9) + 7)
print(ans)


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

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,k; cin >> n >> k;
	int ans;
	
	vector<int> h(n); rep(i,n) cin >> h[i];
	vector<int> dp(n+k,INT_MAX);
	
	dp[0]=0;
	
	rep(i,n-1) rep(j,k) chmin(dp[i+j+1],dp[i]+abs(h[i+j+1]-h[i]));
	
	ans=dp[n-1];
	
	cout << ans << "\n";
	
	return 0;
}


//vector<int> a(n);  sort(a.begin(),a.end());
//cout << "test" << "\n";


//g++ -o a a.cpp


Measured memory_bytes: 1024
#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
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

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

vector<vector<vector<ll>>> dp(110, vector<vector<ll>>(2,vector<ll>(5,0)));
//ll dp[10010][2][110];//dp[i][j][k]:uekara i keta j:1=ok k= used not0
string s;
int d;

int main(){
  cin >> s >> d;
  int sz=s.size();
  dp[0][0][0]=1;
  for(int idx=0; idx<sz; idx++)rep(k,d+1)rep(j,2){	//j==1 ok j==0 ??
    int maxi=(int)(s[idx]-'0');
    rep(l,10){						//next number
      if(j==0&&maxi<l){ continue; }
      dp[idx+1][j|(l<maxi)][k+(l>0)] += dp[idx][j][k];
    }
  }
  ll ans = dp[sz][0][d]+dp[sz][1][d];  
  cout << ans << endl;
  return 0;
}

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

void floyd_warshall(int n, ll matrix[301][301]){
	for(int k=0; k< n; k++){
		for(int i=0; i<n; i++){
			for(int j=0; j< n; j++){
				if(matrix[i][k] != LLONG_MAX and matrix[k][j] != LLONG_MAX){
					if(matrix[i][k] + matrix[k][j] < matrix[i][j]){
						matrix[i][j] = matrix[i][k] + matrix[k][j];
						
					}
				}
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	int a,b;
	int q;
	ll l;
	ll c;
	cin>>n>>m>>l;
	ll matrix[301][301];
	ll cost[301][301];
	for(int i=0; i<301; i++){
		for(int j=0; j< 301; j++){
			if(i==j){
				matrix[i][j] = 0;
				cost[i][j] = 0;
			}
			else{
				matrix[i][j] = LLONG_MAX;
				cost[i][j] = LLONG_MAX;
			}
		}
	}
	while(m--){
		cin>>a>>b>>c;
		if(c <= l){
			matrix[a-1][b-1] = c;
			matrix[b-1][a-1] = c;
		}
	}
	floyd_warshall(n, matrix);
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(i!=j)
				cost[i][j] = (matrix[i][j] <=l )? 1 : LLONG_MAX;		
		}
	}
	floyd_warshall(n, cost);
	// for(int i=0; i<n; i++){
	// 	for(int j=0; j< n; j++){
	// 		cout<<cost[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	cin>>q;
	while(q--){
		cin>>a>>b;
		if(cost[a-1][b-1] != LLONG_MAX){
			cout<<(cost[a-1][b-1]-1)<<"\n";
		}
		else{
			cout<<-1<<"\n";
		}
	}
	return 0;
}

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

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

	long long x = 0, cnt = 0;
	for (long long i = 0; i < s.size(); i++) {
		if (s[i] == 'W') {
			cnt += i - x;
			x++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        u: usize1,
        v: usize1,
        es: [(usize1, usize1); n - 1]
    }
    let mut t = vec![vec![]; n];
    for &(a, b) in &es {
        t[a].push(b);
        t[b].push(a);
    }
    let dt = dist_from(u, &t);
    let da = dist_from(v, &t);
    let mut ans = 0;
    for i in 0..n {
        if da[i] < dt[i] {
            continue;
        }
        ans = max(ans, da[i] - 1);
    }
    println!("{}", ans);
}

fn dist_from(u: usize, t: &Vec<Vec<usize>>) -> Vec<usize> {
    let n = t.len();
    let mut ret = vec![n; n];
    ret[u] = 0;
    let mut q = vec![u];
    while let Some(a) = q.pop() {
        for &b in &t[a] {
            if ret[b] + 1 == ret[a] {
                continue;
            }
            ret[b] = ret[a] + 1;
            q.push(b);
        }
    }
    ret
}


Measured memory_bytes: 14588
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];
        int V = 0;
        for (int i = 0 ; i < N ; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
            V += v[i];
        }
        long[][] dp = new long[N+1][V+1];

        for (int j = 1 ; j <= V; j++) {
            dp[0][j] = 100000000000l;
        }
        for (int i = 0 ; i < N ; i++) {
            for (int j = 0 ; j <= V; j++) {
                if (j < v[i]) {
                    dp[i + 1][j] = dp[i][j];
                } else {
                    dp[i + 1][j] = Math.min(dp[i][j], dp[i][j - v[i]] + w[i]);
                }
            }
        }
        int res = 0;
        for (int i = 0 ; i <= V ; i++) {
            if (dp[N][i] <= W) {
                res = i;
            }
        }
        System.out.println(res);

    }

}


Measured memory_bytes: 126548
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

void run (void) {
  const i32 m = 200000;
  char *s = (char *) calloc (m + 1, sizeof (char));
  scanf ("%s", s);
  i64 ans = 0;
  i32 b = 0;
  for (i32 i = 0; s[i] != '\0'; ++i) {
    if (s[i] == 'B') {
      b++;
    } else {
      ans += b;
    }
  }
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run ();
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -9223372036854775807
#define inf 9223372036854775807
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define to_low(s) for_each(s.begin(), s.end(), [](char & c) {c = ::tolower(c);})
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
void solve(){
	vvi vec(3,vi(3));
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++) cin>>vec[i][j];
	}
	vector<vector<bool>> m(3,vb(3));
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(vec[j][k]==x){
					m[j][k]=true;
				}
			}
		}
	}
	bool ok=false;
	for(int i=0;i<3;i++){
		bool okk=true;
		for(int j=0;j<3;j++){
			if(!m[i][j]){
				okk=false;
				break;
			}
		}
		if(okk) ok=true;
	}
	if(ok) cout<<"Yes"<<endl;
	else{
		if((m[0][0] && m[1][1] && m[2][2]) || (m[2][0] && m[1][1] && m[0][2])) cout<<"Yes"<<endl;
		else{
			for(int i=0;i<3;i++){
				bool okk=true;
				for(int j=0;j<3;j++){
					if(!m[j][i]){
						okk=false;
						break;
					}
				}
				if(okk) ok=true;
			}
			if(ok) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
	}
 
 
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <bits/stdc++.h>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rep(i, s, c) for (int i = s; i < c; i++)
#define MAX_N 100000
#define INF 10000000

struct edge {int to, cost;};
vector<edge> G[MAX_N];
int N;

int color[MAX_N];
bool visited[MAX_N];

bool dfs(int v, int c){
    color[v] = c;
    rep(i, 0, G[v].size()){
        if (!visited[G[v][i].to]){
            int tmp = (c+G[v][i].cost)&1;
            //cout << tmp << endl;
            visited[G[v][i].to] = true;
            dfs(G[v][i].to, tmp);
        }
        /*if (G[v][i].cost % 2 == 0 && (!visited[G[v][i].to])){
            visited[G[v][i].to] = true;
            dfs(G[v][i].to, 0);
        }
        if (G[v][i].cost % 2 != 0 && (!visited[G[v][i].to])){
            visited[G[v][i].to] = true;
            dfs(G[v][i].to, 1);
        }*/
    }
    return true;
}


int main(){
    cin >> N;
    int u, v, w;
    fill(visited, visited + N, false);
    visited[0] = true;
    rep(n, 0, N - 1){
        cin >> u >> v >> w;
        edge e1 = {v - 1, w};
        edge e2 = {u - 1, w};
        G[u - 1].push_back(e1);
        G[v - 1].push_back(e2);
    }
    bool ans = dfs(0, 0);
    rep(i, 0, N){
        cout << color[i] << endl;
    }
    /*rep(n, 0, N){
        rep(j, 0, G[n].size()){
            cout << n << "\t" << G[n][j].to << "\t" << G[n][j].cost << endl;
        }
    }*/
}


Measured memory_bytes: 8448
#include<stdio.h>
#define N 100001

typedef struct{
  char mark;
  int num;
  int turn;
}Card;

int Partition(Card*, int, int);
void Quicksort(Card*, int, int);
void Exchange(Card*, Card*);

main(){
  int n, i, count = 0;
  Card A[N];
  char a, B[N];
  
  scanf("%d%c", &n, &a);
  for(i = 1;i < n+1;i++){
    scanf("%c%c%d%c", &A[i].mark, &a, &A[i].num, &a);
    A[i].turn = i;
  } 
 
  Quicksort(A, 1, n);
  
  for(i = 1;i < n;i++){
    if(A[i].num == A[i+1].num && A[i].turn > A[i+1].turn){
      count++;
      break;
    }
  }
  
  if(count == 0){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  
  for(i = 1;i < n+1;i++){
    printf("%c %d\n", A[i].mark, A[i].num);
  }
  return 0;
}

int Partition(Card A[], int p, int r){
  int i, j;
  Card x;
  x = A[r];
  i = p-1;
  for(j = p;j < r;j++){
    if(A[j].num <= x.num){
      i++;
      Exchange(&A[i], &A[j]);
    }
  }
  Exchange(&A[i+1], &A[r]);
  return i+1;
}

void Quicksort(Card A[], int p, int r){
  int q, i;
  if(p < r){
    q = Partition(A, p, r);
    Quicksort(A, p, q-1);
    Quicksort(A, q+1, r);
  }
}

void Exchange(Card *a, Card *b){
  Card sub;
  sub = *a;
  *a = *b;
  *b = sub;
}

Measured memory_bytes: 1776
#include <stdio.h>
typedef long long ll;

ll min(ll a, ll b) {
  return a > b ? b : a;
}

ll max(ll a, ll b) {
  return a > b ? a : b;
}

int main(void) {
  ll i, j, k, l, n, ans = 0, now;
  scanf("%lld%lld", &n, &k);
  ll h[n + 2], dp[n + 2][n + 1], d[n + 2][n + 1];
  h[0] = 0, h[n + 1] = 0;
  for(i = 1; i <= n; ++i) scanf("%lld", &h[i]);
  for(i = 0; i <= n; ++i) if(h[i + 1] > h[i]) ans += h[i + 1] - h[i];
  for(i = 0; i < n + 2; ++i) for(j = 0; j <= n; ++j) dp[i][j] = d[i][j] = 0;
  for(i = 2; i < n + 2; ++i) {
    for(j = i - 1; j; --j) {
      d[i][i - j] = d[i][i - j - 1];
      if(h[j] < h[i]) {
        if(h[j - 1] > h[j]) d[i][i - j] += min(h[j - 1], h[i]) - h[j];
      } else if(h[j] > h[j - 1]) d[i][i - j] += h[j] - max(h[j - 1], h[i]);
    }
  }
  for(i = 2; i < n + 2; ++i) {
    dp[i][0] = dp[i - 1][0];
    for(j = 1; j <= k; ++j) dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    for(j = 1; j < i; ++j) for(l = 0; l <= k - j; ++l) if(dp[i - j - 1][l] + d[i][j] > dp[i][l + j]) 
      dp[i][l + j] = dp[i - j - 1][l] + d[i][j];
  }
  printf("%lld", ans - dp[n + 1][k]);
  return 0;
}

Measured memory_bytes: 1536
package main

import (
  "fmt"
  "strings"
)

func main(){
  
  var S string
  var match int
  var victory int
  
  fmt.Scan(&S)
  
  match = len(S)
  victory = strings.Count(S, "o")
  
  if (victory == 8) {
    fmt.Print("YES")
  } else if ((match <= 14) && (victory == 7)) {
    fmt.Print("YES")
  } else if ((match <= 13) && (victory == 6)) {
    fmt.Print("YES")
  } else if ((match <= 12) && (victory == 5)) {
    fmt.Print("YES")
  } else if ((match <= 11) && (victory == 4)) {
    fmt.Print("YES")
  } else if ((match <= 10) && (victory == 3)) {
    fmt.Print("YES")
  } else if ((match <= 9) && (victory == 2)) {
    fmt.Print("YES")
  } else if ((match <= 8) && (victory == 1)) {
    fmt.Print("YES")
  } else if ((match <= 7) && (victory == 0)) {
    fmt.Print("YES")
  } else {
    fmt.Print("NO")
  }
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<cmath>
#include<string>
using namespace std;

int main(){
  string in,ans="";
  cin >>in;
  int len=in.size();
  for(int i=0;i<len;i++){
    if(in[i]=='0'){
      ans+="0";
    }else if(in[i]=='1'){
      ans+="1";
    }else if(in[i]=='B'){
      if(ans.empty()==false){
	ans.erase(ans.end()-1);
      }
    }
  }

  cout << ans <<endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int H, N; cin >> H >> N;
    vector<int> a(N), b(N);
    vector<pair<int, int>> vp(N);
    for (int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
        vp[i] = {b[i], a[i]};
    }
    sort(vp.begin(), vp.end());

    int Cost[101000];
    fill(Cost, Cost+10100, MM);
    Cost[0] = 0;

    for (int i = 0; i < N; i++){
        for (int j = 0; j < 10001; j++){
            if (j < vp[i].second){
                Cost[j] = min(Cost[j], vp[i].first);
            }
            if (j + vp[i].second > 20000){
                break;
            }
            Cost[j+vp[i].second] = min(Cost[j+vp[i].second], Cost[j] + vp[i].first);
        }
    }
    cout << Cost[H] << endl;
}

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

int main() {
    int n,m; cin >> n >> m;
    vector<ll> x(m), l(m-1);
    rep(i,m) cin >> x[i];
    ll ans = 0;
    if (n < m) {
        sort(x.begin(), x.end());
        rep(i,m-1) {
            // 隣り合う地点同士の距離
            l[i] = x[i+1] - x[i];
        }
        // 全コマの合計移動回数は，全区間-訪れていない区間
        // 訪れていない区間が最大 == 最小の移動回数
        // 訪れていない区間は，コマ数nに対してn-1個ある
        // l[i]を大きいほうからn-1個取れば最大化
        sort(l.begin(), l.end());
        ll lsum = 0;
        rep(i,n-1) {
            lsum += l[m-2-i];
        }
        ans = x[m-1]-x[0]-lsum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


class DIJKSTRA {
public:
    ll V;

    struct dk_edge {
        ll to;
        ll cost;
    };

    typedef pair<ll, ll> PI; //firstは最短距離、secondは頂点の番号
    vector<vector<dk_edge> >G;
    vector<ll> d; //これ答え。d[i]:=V[i]までの最短距離
    vector<ll> prev; //経路復元

    DIJKSTRA(ll size) {
        V = size;
        G = vector<vector<dk_edge> >(V);
        prev = vector<ll> (V, -1);
    }

    void add(ll from, ll to, ll cost) {
        dk_edge e = {to, cost};
        G[from].push_back(e);
    }

    void dijkstra(ll s) {
        //greater<P>を指定することでfirstが小さい順に取り出せるようにする
        priority_queue<PI, vector<PI>, greater<PI> > que;
        d = vector<ll> (V, LLINF);
        d[s] = 0;
        que.push(PI(0, s));

        while(!que.empty()) {
            PI p = que.top();
            que.pop();
            ll v = p.second;
            if(d[v] < p.first) continue;
            for(ll i = 0; i < G[v].size(); i++) {
                dk_edge e = G[v][i];
                if(d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    prev[e.to] = v;
                    que.push(PI(d[e.to], e.to));
                }
            }
        }
    }
};

int main(void) {
    
    ll n;
    cin>>n;
    DIJKSTRA dk(n);
    rep(i,n-1){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        dk.add(a,b,c);
        dk.add(b,a,c);
    }
    ll q,k;
    cin>>q>>k;
    dk.dijkstra(k-1);
    rep(i,q){
        ll x,y;
        cin>>x>>y;
        x--;y--;
        cout<<dk.d[x]+dk.d[y]<<endl;
    }
    // dk.show();
}


Measured memory_bytes: 11888
import Foundation

let info = readLine()!.split(separator: " ").map{Double($0)!}
let A = info[0]
let B = info[1]
let H = info[2]
let M = info[3]

let rad = (H * 60  + M) * 5.5 / 180.0 * Double.pi
let C = A * A + B * B - (2 * A * B * cos(rad))
print(sqrt(C))

Measured memory_bytes: 13856
u=[0]*n=1e5
v=u.map{[]}
$<.drop(1).map{|s|s.split.map &:to_i}.map{|a,b|u[b]+=1;v[a]<<b}
r=(1..n).find{|i|u[i]<1}
y=[]
y[r]=0
s=[r]
s.map{|d|v[d].map{|e|(1>u[e]-=1)&&(y[e]=d;s<<e)}}
p *y[1,n]

Measured memory_bytes: 33148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t




int main(){
    ll N, K; cin >> N >> K;
    vector<ll> A(N+1); for(int i = 1; i < N+1; i++) cin >> A[i];
    for(int i = 0; i < N; i++) A[i+1] = A[i]+A[i+1];
    vector<bitset<41>> B;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N+1; j++){
            ll temp = A[j]-A[i];
            bitset<41> b = temp;
            B.push_back(b);
        }
    }
    ll ans = 0;
    for(int i = 41; i >= 0; i--){
        ll c = 0;
        vector<bitset<41>> B_;
        for(auto b : B){
            if(b[i] == 1) {
                c++;
                B_.push_back(b);
            }
        }
        if(c >= K) {
            ans += pow(2, i);
            B = B_;
        }


    }
    cout << ans << endl;
}

Measured memory_bytes: 6260
N = int(input())
S = [input() for i in range(N)]
C_0, C_1, C_2, C_3 = 0, 0, 0, 0
for s in S:
  if s == "AC":
    C_0 += 1
  elif s == "WA":
    C_1 += 1
  elif s == "TLE":
    C_2 += 1
  else:
    C_3 += 1
print("AC x" , C_0)
print("WA x" , C_1)
print("TLE x" , C_2)
print("RE x" , C_3)

Measured memory_bytes: 16324
#include<stdio.h>
int main()
{
	int a[3],i,j,res=0;
	for(i=0;i<3;i++) scanf("%d",&a[i]);
	for(i=0;i<2;i++)
	{
		for(j=i+1;j<3;j++)
		{
			if(a[i]>a[j])
			{
				int temp = a[i];
				a[i]=a[j];
				a[j] = temp;
			}
		}
	}
	res = a[1]-a[0];
	res = res+(a[2]-a[1]);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;



public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int an[] = new int[100];
        int n = input.nextInt();
        for(int i = 0; i < n; i++) {
            an[i] = input.nextInt();
        }

        for(int i = n - 1; i >= 1; i--){
            System.out.printf("%d ", an[i]);
        }
        System.out.printf("%d\n", an[0]);
    }
}


Measured memory_bytes: 26468
#include<stdio.h>
int main(){
  int H,W,h,w;
  scanf("%d%d%d%d",&H,&W,&h,&w);
  if(H%h||W%w){
    puts("Yes");
    for(int i=0;i<H;++i,puts("")) for(int j=0;j<W;++j)
      if(!((i+1)%h|(j+1)%w)) printf("-999999 ");
      else if(!(i%h|j%w)) printf("999998 ");
      else printf("0 ");
  }else puts("No");
  return 0;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

int main()
{
    string A;
    cin >> A;
    // Ai != Aj (i<j) であるような (i,j) のペア数を数える
    // →全ペア数から Ai == Aj であるペア数を引く
    LLONG N = A.size();         // LLONG型で宣言しないと次のN^2の計算でエラー
    LLONG ans = N * (N - 1) / 2;
    map<char, LLONG> char2NumMap;
    // 各文字の数を数える：O(N)
    for (const char &ch : A)
    {
        ++char2NumMap[ch];
    }
    // 文字ごとに Ai == Aj となりうるペア数を引く：O(1)
    for (const auto &kvp : char2NumMap)
    {
        const LLONG num = kvp.second;
        ans -= num * (num - 1) / 2;
    }
    // 「操作を行わない」１通りを加えたものが答え
    cout << ans + 1 << endl;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

//Village
public class Main{

	double[] x, y;
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double R = sc.nextDouble(), EPS = 1e-8;
		double cos1 = Math.cos(1*Math.PI/180), sin1 = Math.sin(1*Math.PI/180);
		x = new double[n]; y = new double[n];
		for(int i=0;i<n;i++){
			double X = sc.nextDouble(), Y = sc.nextDouble();
			x[i] = cos1*X-sin1*Y;
			y[i] = sin1*X+cos1*Y;
		}
		Integer[] V = new Integer[n];
		for(int i=0;i<n;i++)V[i]=i;
		Arrays.sort(V, new Comparator<Integer>() {
			public int compare(Integer o1, Integer o2) {
				return (int)Math.signum(x[o1]-x[o2]);
			}
		});
		int[] v = new int[n];
		for(int i=0;i<n;i++)v[i]=V[i];
		int res = 0;
		boolean[] u = new boolean[n];
		for(int i=0;i<n;i++){
			int idx = v[i];
			if(u[idx])continue;
			u[idx] = true;
			res++;
			double lx = x[idx]-R-EPS, rx = x[idx]+R+EPS;
			int l = 0, r = n;
			while(r-l>1){
				int m = (l+r)/2;
				if(lx<=x[v[m]])r=m;
				else l=m;
			}
			int k1 = l;
			l = 0; r = n;
			while(r-l>1){
				int m = (l+r)/2;
				if(rx<x[v[m]])r=m;
				else l=m;
			}
			int k2 = r;
			if(k2==r)k2--;
			for(int j=k1;j<=k2;j++){
				int k = v[j];
				if(u[k])continue;
				if(Math.sqrt((x[idx]-x[k])*(x[idx]-x[k]) + (y[idx]-y[k])*(y[idx]-y[k])) < R+EPS){
					u[k] = true;
				}
			}
		}
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n;
string s[maxn];
int t[maxn];

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

    cin>>n;
    for (int i=0; i<n; i++) {
	cin>>s[i]>>t[i];
    }
    string x;
    cin>>x;

    int tot = 0;
    bool flag = false;
    for (int i=0; i<n; i++) {
	if (flag) {
	    tot += t[i];
	    continue;
	}
	if (x==s[i]) {
	    flag=true;
	}
    }

    out(tot);
    
    
    return 0;
}


Measured memory_bytes: 34876
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr double BIGP = 1000000007L;
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N, D;
    cin >> N >> D;
    using Vec = vector<ll>;
    vector<Vec> vs(N);
    rep(i, N)
    {
        Vec v(D);
        rep(j, D) cin >> v[j];
        vs[i] = v;
    }
    ll ans = 0;
    rep(i, N)
    {
        rep(j, N)
        {
            if (i == j)
                continue;

            // 距離を計算する
            auto& v0 = vs[i];
            auto& v1 = vs[j];
            ll disqr = 0;
            rep(k, D)
            {
                disqr += (v0[k] - v1[k])* (v0[k] - v1[k]);
            }
            // 累乗かをチェック
            rep(k, 100000)
            {
                if (k * k == disqr)
                {
                    ++ans;
                    break;
                }
            }
        }
    }
    cout << ans/2;

    //
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)

int n,m,q;
vector<int>a,b,c,d;
int ans;

void dfs(vector<int> A) {
    if(A.size() ==n+1){
        int now =0;
        rep(i,q) {
            if(A[b[i]]-A[a[i]]==c[i]) now+=d[i];
        }
        ans =max(ans,now);
        return;
    }
    
    A.push_back(A.back());
    while (A.back()<=m){
        dfs(A);
        A.back()++;
    }
    }

int main(){
    cin>>n>>m>>q;
    a=b=c=d=vector<int>(q);
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    vector<int>A(1,1);
    dfs(A);
    cout<<ans<<endl;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define BINF 100000000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << endl;
const int LG = 22;



#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);
    
    string s;
    cin >> s;
    vector<pair<int,int>>v;
    int f = 0;
    int n = s.length();

    if(s[0] == '<') s = '>' + s;
    else s = '<' + s;
    n++;

    if(s[n - 1] == '<') s = s + '>';
    else s = s + '<';
    n++;

    if(s[0] == '<') f = 0;
    else f = 1;

    int c = 1;
    for(int i = 1; i < n; i++){
        if(s[i] == s[i - 1]) c++;
        else{
            v.push_back(make_pair(c, f));
            f ^= 1;
            c = 1;
        }
    }

    v.push_back(make_pair(c, f));

    int ans = 0, mid = 0;
    for(int i = 1; i < v.size(); i++){
        ans += (v[i].F * (v[i].F - 1)) / 2;
        if(v[i].S == 1) ans += max(v[i].F, v[i - 1].F);

    }

    cout << ans << endl;

    
return 0;  
}



Measured memory_bytes: 6028
K,X = map(int, input().split())
hajime=X-(K-1)
owari=X+(K-1)
if hajime<-1000000:
    hajime=-1000000
if owari>1000000:
    owari=1000000

kotae = [str(i) for i in range(hajime,owari+1)] #x,yは任意の数字
print(" ".join(kotae))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int visited[100010];
int ans=0;
int dfs(int node,vector<vector<int> >&graph){
    visited[node]=0;
    for(auto x:graph[node]){
        if(visited[x]==-1){
         visited[node]=max(visited[node],dfs(x,graph)+1);
        }else{
        visited[node]=max(visited[node],visited[x]+1);
        }
    }
    ans=max(ans,visited[node]);
    return visited[node];
}

int main(){
    memset(visited,-1,sizeof(visited));
    int n,m;
    cin>>n>>m;
    vector<vector<int>>graph(n+1);
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        graph[u].push_back(v);
    }
    for(int i=1;i<=n;i++){
        if(visited[i]==-1){
            dfs(i,graph);
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
 int main(){
 int A,B,C,D;
 cin>>A>>B>>C>>D;
 int X=(A+D-1)/D;
 int Y=(C+B-1)/B;
 if(X>=Y)
 {
     cout<<"Yes"<<"\n";
 }
 else
 {
     cout<<"No"<<"\n";
 }
 return 0;
 }
 

Measured memory_bytes: 3636
a,b=(int(x)-1 for x in input().split())
L=[]
for i in range(b+1):
    L.append(list(map(int,input().split())))
L.sort(key=lambda x:x[1]) 
ans=0
bridge_right=-1
for l in L:
    if not l[0]<=bridge_right<l[1]:
        bridge_right=l[1]-1
        ans+=1
print(ans)

Measured memory_bytes: 29080
#include<bits/stdc++.h>
using namespace std;
int arr[10];
int main(){
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < k; ++i){
        int x; cin >> x;
        arr[x] = 1;
    }
    while(1){
        int p = n;
        int c = 1;
        while(p){
            int d = p % 10;
            if(arr[d]) {
                c = 0;
                break;
            }
            p /= 10;
        }
        if(c){
            cout << n << '\n';
            break;
        } else{
            n++;
        }
    }
    return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S; 
    int res=0;
    for (int i=1; i<N+1; i++) {
        set<char> x(S.begin(), S.begin()+i), y(S.begin()+i, S.end());
        int t=0;
        for (char c='a'; c<='z'; c++) {
            if (x.count(c)&&y.count(c)) t++;
        }
        res = max(res, t);
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
n = int(input())
my_dict = dict()

for i in range(n-1):
    u, v, w = map(int, input().split())
    if u in my_dict:
        my_dict[u].append((v, w))
    else:
        my_dict[u] = [(v, w)]

    if v in my_dict:
        my_dict[v].append((u, w))
    else:
        my_dict[v] = [(u, w)]

visited = set()
white = set()
black = set()
candidate = [1]

white.add(1)

while candidate:
    item = candidate.pop()

    for val in my_dict[item]:
        if val[0] not in visited:
            if item in white:
                if val[1] % 2 == 0:
                    white.add(val[0])
                else:
                    black.add(val[0])
            else:
                if val[1] % 2 == 0:
                    black.add(val[0])
                else:
                    white.add(val[0])
        if val[0] not in visited:
            candidate.append(val[0])

    visited.add(item)

for i in range(n):
    if (i + 1) in white:
        print(0)
    else:
        print(1)


Measured memory_bytes: 93652