akhauriyash/Code-Regression huggingface dataset:
//ConvexCut
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>
#include <vector>
#include <tuple>
using namespace std;
typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); }
xy_t projection(xy_t p, xy_t b) { return b * dot_product(p, b) / norm(b); }
xy_t MiddlePoint(xy_t a, xy_t b) { return xy_t((a.real() + b.real()) / 2, (a.imag() + b.imag()) / 2); }

std::tuple<bool, double, double> ConvexCut(vector<xy_t> Point)
{
    int n = Point.size();

    xy_t answer;
    bool flag = 1;
    if (n % 2 == 0)
    {
        for (int i = 0; i < n / 2; i++)
        {
            if (i == 0)
            {
                answer = MiddlePoint(Point.at(i), Point.at((i + n / 2) % n));
            }
            else
            {
                if (answer != MiddlePoint(Point.at(i), Point.at((i + n / 2) % n)))
                {
                    flag = 0;
                }
            }
        }
    }
    else
    {
        flag = 0;
    }

    return forward_as_tuple(flag, answer.real(), answer.imag());
}

int main()
{
    int n;
    cin >> n;
    vector<xy_t> P(n);
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        P.at(i) = xy_t(x, y);
    }

    bool answer_flag;
    double answer_real, answer_imag;
    tie(answer_flag, answer_real, answer_imag) = ConvexCut(P);
    if (answer_flag)
    {
        printf("%.6f %.6f\n", answer_real,answer_imag);
        //cout << answer_real << " " << answer_imag << endl;
    }
    else
    {
        cout << "NA" << endl;
    }
    return 0;
}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    string a, b, c; cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;

}

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A > 12) {
    cout << B << endl;
  }
  else if (A > 5) {
    cout << B / 2 << endl;
  }
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> v(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        v[i] = v[i - 1] + (S[i - 1] == 'A' && S[i] == 'C'); 
    }
    for (int i = 0, l, r; i < Q; i++) {
        cin >> l >> r;
        cout << v[r - 1] - v[l - 1] << endl;
    }
}


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

int main(){
    int n; cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    bool flag = false;
    int count = 0;
    int next = 1;
    for(int i = 1; i <= n; i++){
        next = a[next];
        count++;
        if(next == 2){
            flag = true;
            break;
        } 
    }
    if(flag) cout << count << endl;
    else cout << -1 << endl;
    return 0;
}

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


int main() {
int N;
cin >> N;
for (int i = 1000;i <= 10000;i +=1000) {
  if (i - N >= 0) {
    cout <<  i-N << endl;
    return 0;
  }

}

return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;

char L[52][52], R[52][52];
int W, H, sx1, sy1, sx2, sy2, gx1, gy1, gx2, gy2;
int dx1[4] = { 0, 0,+1,-1};
int dy1[4] = {-1,+1, 0, 0};
int dx2[4] = { 0, 0,-1,+1};
int dy2[4] = {-1,+1, 0, 0};
bool memo[52][52][52][52];

struct State{
	int x1, y1, x2, y2;
	State(int x1_, int y1_, int x2_, int y2_){
		x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_;
	}
};

void debug(int x1, int y1, int x2, int y2){
	cout << "[left]" << endl;
	for(int y=0 ; y < H ; y++ ){
		for(int x=0 ; x < W ; x++ ){
			if( x == x1 && y == y1 ){
				cout << "L";
			}else{
				cout << L[y][x];
			}
		}
		cout << endl;
	}
	cout << "[right]" << endl;
	for(int y=0 ; y < H ; y++ ){
		for(int x=0 ; x < W ; x++ ){
			if( x == x2 && y == y2 ){
				cout << "R";
			}else{
				cout << R[y][x];
			}
		}
		cout << endl;
	}
	cout << endl;
}

bool bfs(){
	for(int a=0 ; a < 52 ; a++ )
		for(int b=0 ; b < 52 ; b++ )
			for(int c=0 ; c < 52 ; c++ )
				for(int d=0 ; d < 52 ; d++ )
					memo[a][b][c][d] = false;
	queue<State> q;
	q.push( State(sx1, sy1, sx2, sy2) );
	
	while( !q.empty() ){
		int x1 = q.front().x1, y1 = q.front().y1, x2 = q.front().x2, y2 = q.front().y2;
		q.pop();
		
		if( memo[x1][y1][x2][y2] ) continue;
		memo[x1][y1][x2][y2] = true;
		
		for(int i=0 ; i < 4 ; i++ ){
			int mx1 = x1 + dx1[i], my1 = y1 + dy1[i];
			int mx2 = x2 + dx2[i], my2 = y2 + dy2[i];
			if( mx1 < 0 || my1 < 0 || W <= mx1 || H <= my1 || L[my1][mx1] == '#' ){
				mx1 = x1; my1 = y1;
			}
			if( mx2 < 0 || my2 < 0 || W <= mx2 || H <= my2 || R[my2][mx2] == '#' ){
				mx2 = x2; my2 = y2;
			}
			if( mx1 == gx1 && my1 == gy1 && mx2 == gx2 && my2 == gy2 ){
				return true;
			}else if( mx1 == gx1 && my1 == gy1 ){
			}else if( mx2 == gx2 && my2 == gy2 ){
			}else{
				if( !memo[mx1][my1][mx2][my2] ){
					q.push( State(mx1, my1, mx2, my2) );
				}
			}
		}
	}
	return false;
}

int main(){
	while( cin >> W >> H , W || H ){
		for(int y=0 ; y < H ; y++ ){
			cin >> L[y] >> R[y];
		}
		for(int y=0 ; y < H ; y++ ){
			for(int x=0 ; x < W ; x++ ){
				if( L[y][x] == 'L' ){
					sx1 = x; sy1 = y; L[y][x] = '.';
				}
				if( R[y][x] == 'R' ){
					sx2 = x; sy2 = y; R[y][x] = '.';
				}
				if( L[y][x] == '%' ){
					gx1 = x; gy1 = y; L[y][x] = '.';
				}
				if( R[y][x] == '%' ){
					gx2 = x; gy2 = y; R[y][x] = '.';
				}
			}
		}
		cout << (bfs()? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 10096
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

double eq(double x) { return fabs(x) < 0.000001; }

double f(double r, double x) {
  if (fabs(x) > r)
    return -100000000;
  if (eq(fabs(x) - r))
    return -r;
  return -(r - sqrt(r * r - x * x));
}

int main() {
  while (true) {
    int r, n;
    cin >> r >> n;
    if (r == 0 && n == 0)
      break;
    double ans = 10000000000;
    vector<pair<int, int>> x(n);
    vector<int> h(n);
    for (int i = 0; i < n; i++)
      cin >> x[i].first >> x[i].second >> h[i];
    int H[50][2] = {0};
    int offset = 25;
    for (int i = 0; i < n; i++) {
      for (int j = max(-r, x[i].first); j < min(r + 1, x[i].second); j++) {
        H[j + offset][0] = max(H[j + offset][0], h[i]);
      }
      for (int j = max(-r, x[i].first + 1); j <= min(r, x[i].second); j++) {
        H[j + offset][1] = max(H[j + offset][1], h[i]);
      }
    }
    for (int i = -r; i <= r; i++) {
      if (i < r)
        ans = min(ans, H[i + offset][0] - f(r, i));
      if (i > -r)
        ans = min(ans, H[i + offset][1] - f(r, i));
    }
    printf("%.9lf\n", ans);
  }
  return 0;
}



Measured memory_bytes: 3212
package main

import "fmt"

func main() {
	var (
		n, k int
		s    string
	)
	fmt.Scan(&n, &k, &s)
	for i := 0; i < k-1; i++ {
		fmt.Printf("%c", s[i])
	}
	switch s[k-1] {
	case 'A':
		fmt.Print("a")
	case 'B':
		fmt.Print("b")
	case 'C':
		fmt.Print("c")
	}
	for i := k; i < n; i++ {
		fmt.Printf("%c", s[i])
	}
	fmt.Println()
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
  char c;
  cin >> c;
  cout << ++c << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())

min_num = []
for n in range(1,int(N/2)+1):
	A = str(n)
	B = str(N-n)

	A_list = list(map(int,A))
	B_list = list(map(int,B))


	min_num.append(sum(A_list)+sum(B_list))

min_num.sort()
print(min_num[0])

Measured memory_bytes: 3584
import java.util.Scanner;
import java.util.Arrays;
class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = sc.nextInt(),
				m = sc.nextInt();
			if (n == 0 && m == 0) break;
			int times[] = new int[n+m];
			for (int i = 0; i < n + m; i++)
			{
				times[i] = sc.nextInt();
			}
			Arrays.sort(times);
			int max = times[0];
			for (int i = 1; i < n + m; i++)
			{
				max = Math.max(max, times[i] - times[i-1]);
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#define LL long long
using namespace std;
int sum[100001];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int a;
        memset(sum,0,sizeof(sum));
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a);
            sum[a+1]++;
            sum[a-1]++;
            sum[a]++;
        }
        sort(sum,sum+100001);
        printf("%d\n",sum[100000]);
    }
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int N, A, B;
    cin >> N >> A >> B;
    // スペース区切りの整数の入力

    // 出力
	if(((A-B)%2) ==0) {
	  cout << "Alice" << endl;
    } else {
    cout << "Borys" << endl;   
    }
    return 0;
}

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


const ll mod = 1e9+7;
long double pi = 3.141592653589793238;
ll mulmod(ll x,ll y)
{
  return (x%mod*y%mod)%mod;
}


ll addmod(ll x,ll y)
{
  return (x%mod+y%mod)%mod;
}
void testcases()
{
  ll n,m;
  cin >> n >> m;
  ll sum = 0;
  ll arr[n+1];
  for(int i=0;i<m;i++)
  {
     cin >> arr[i];
    sum+=arr[i];
  }
  n-=sum;
  if(n<0)
    cout << -1 << endl;
  else
    cout << n << endl;
}



int main()
{
    ll t;
     t = 1;
    while(t--)
      testcases();
}

Measured memory_bytes: 3680
INF = 10 ** 10
def solve(As, Bs, Ms):
    mini = min(As) + min(Bs)
    for (a, b, c) in Ms:
        cur = As[a] + Bs[b] - c
        mini = min(mini, cur)
    return mini

a, b, m = map(int, raw_input().split())
As = [INF] + map(int, raw_input().split())
Bs = [INF] + map(int, raw_input().split())
Ms = []
for i in xrange(m):
    (a, b, c) = map(int, raw_input().split())
    Ms.append((a, b, c))
print solve(As, Bs, Ms)



Measured memory_bytes: 24960
module Main where


solve :: [Integer] -> Integer
solve a =
    let accl =0 : scanl gcd 0 a
        accr =reverse $ scanl gcd 0 (reverse a)
    in  maximum $ zipWith gcd accl accr

main :: IO ()
main = do
    getLine
    a <- (map read . words) <$> getLine
    putStrLn $show $ solve a


Measured memory_bytes: 93564
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int a[100010];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n;
    cin>>n;
    long long sum=0,k=1LL*n*(n+1)/2;
    for(int i=0;i<n;i++) a[i]=gi(),sum+=a[i];
    if(sum%k) return puts("NO"),0;
    for(int i=0,t=sum/k;i<n;i++) {
	if(a[i]<t) break;
	int d=a[(i+1)%n]-a[i];
	if(d>t||(t-d)%n) break;
	if(i==n-1) return puts("YES"),0;
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 768
#include<cstdio>
using namespace std;

int a[10005];
bool Find(int n, int key)
{
    int i=0;
    a[n]=key;
    while(a[i]!=key) i++;
    if(i!=n) return true;
    else return false;
}
int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", &a[i]);
    int q, key, cnt=0;
    scanf("%d", &q);
    for(int i=0; i<q; i++)
    {
        scanf("%d", &key);
        if(Find(n, key)) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 2752
#include<cstdio>

//segment tree size==2^0+...+2^18==524287
long long a[200000], st[524287], d[524287];

long long max(long long a, long long b){
	return a < b ? b : a;
}

//O(n+qlogn)...stを作るのにdpの2倍ほど時間がかかる
int main() {
	
	int n, q, i, j, p;
	long long x, y;
	long long suma=0;

	scanf("%d%d", &n, &q);

	//start=segment treeの最下段の始まる位置=segment treeの最下段の長さ-1
	int start = 2;
	for (i = n - 2; i > 0; i = i / 2) {
		start = start * 2;
	}
	start--;
	
	//初期値の代入
	for (i = 0; i < 2 * n; i++) {
		scanf("%lld", &a[i]);
		suma += a[i];
	}
	scanf("%lld", &y);
	for (i = start; i < start + 2 * n - 2; i++) {
		scanf("%lld", &y);
		d[i] = y - a[i - start + 1];
	}
	scanf("%lld", &y);
	for (i = start + 2 * n - 2; i <= 2 * start; i++) {
		d[i] = -1000000000000000;
	}
	for (i = start; i <= start + 2 * n - 1; i++) {
		st[i] = 0;
	}

	//segment treeの作成
	for (i = start - 1; i >= 0; i--) {
		st[i] = max(st[2 * i + 1] + st[2 * i + 2], d[2 * i + 1] + d[2 * i + 2]);
		d[i] = max(st[2 * i + 1] + d[2 * i + 2], st[2 * i + 2] + d[2 * i + 1]);
	}
	
	for (i = 0; i < q; i++) {
		scanf("%d%lld%lld", &p, &x, &y);
		suma += x - a[p - 1];
		a[p - 1] = x;
		if (p != 1 && p != 2 * n) {
			j = start + p - 2;
			d[j] = y - x;
			do {
				j = (j - 1) / 2;
				st[j] = max(st[2 * j + 1] + st[2 * j + 2], d[2 * j + 1] + d[2 * j + 2]);
				d[j] = max(st[2 * j + 1] + d[2 * j + 2], st[2 * j + 2] + d[2 * j + 1]);
			} while (j > 0);
		}
		printf("%lld\n", suma + st[0]);
	}

	return 0;
}

Measured memory_bytes: 11392
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  int q;
  cin >> q;
  vector<int> t(q);
  for (int i = 0; i < q; ++i) {
    cin >> t[i];
  }
  int ans = 0;
  for (int i = 0; i < q; ++i) {
    auto it = lower_bound(s.begin(), s.end(), t[i]);
    if (it != s.end() && *it == t[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3344
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    //input
    int N, K;
    ll L, R;
    cin >> N >> K >> L >> R;
    ll a[N];
    for (int i=0;i<N;i++){
        cin >> a[i];
    }

    int hn = N/2;
    vector< vector<ll> > sumList1(hn+1);
    vector< vector<ll> > sumList2(N-hn+1);

    for (int i=0;i<(1<<hn);i++){
        ll sum = 0;
        int weight = 0;
        for (int j=0;j<hn;j++){
            if ((i>>j)&1){
                sum += a[j];
                weight++;
            }
        }
        sumList1[weight].push_back(sum);
    }

    for (int i=0;i<(1<<(N-hn));i++){
        ll sum = 0;
        int weight = 0;
        for (int j=0;j<(N-hn);j++){
            if ((i>>j)&1){
                sum += a[hn+j];
                weight++;
            }
        }
        sumList2[weight].push_back(sum);
    }

    for (int i=0;i<hn;i++){
        sort(sumList1[i].begin(), sumList1[i].end());
    }
/*
    cout << endl;
    for (int i=0;i<sumList1.size();i++){
        for (int j=0;j<sumList1[i].size();j++){
            cout << sumList1[i][j] << " ";
        }
        cout << endl;
    }

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

    cout << endl;
*/
    ll result = 0;
    for (int i=max(0, K-hn);i<min(K,N-hn)+1;i++){
        for (int j=0;j<sumList2[i].size();j++){
            vector<ll>::iterator it1 = lower_bound(sumList1[K-i].begin(), sumList1[K-i].end(), L-sumList2[i][j]);
            vector<ll>::iterator it2 = upper_bound(sumList1[K-i].begin(), sumList1[K-i].end(), R-sumList2[i][j]);
            ll dist = (ll)distance(it1, it2);
            result += dist;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 23328
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn, dt;
inline void putint(ll X) {
	int keta = 0;
	char C[20];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int N;
ll D[100001];
int E[200001], Ed[200001], E2[200001], H[100001];
void dfs(int A, ll B) {
	*(D + A) = B;
	for (int i = H[A]; i; i = E2[i]) if (!(*(D + E[i]))) dfs(E[i], B + Ed[i]);
}

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


	int N = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint();
		int b = getint();
		int c = getint();
		E[k] = b;
		Ed[k] = c;
		E2[k] = H[a];
		H[a] = k++;
		E[k] = a;
		Ed[k] = c;
		E2[k] = H[b];
		H[b] = k++;
	}
	int Q = getint();
	int K = getint();
	dfs(K, 1);
	rep(i, Q) {
		int x = getint();
		int y = getint();
		putint(*(D + x) + *(D + y) - 2);
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 9984
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vll a(n);
    REP(i,n) {
        cin >> a[i];
        a[i]--;
        a[i]%=k;
    }
    if(k==1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    map<ll,ll> mp;
    map<ll,ll> mp2;
    ll sum = 0;
    ll sk = 0;
    mp[0]=1;
    REP(i,n){
        if(i==k-1) mp[0]--;
        if(i>=k){
            sk = (sk+a[i-k])%k;
            mp[sk]--;
        }
        ans+=mp[(a[i]+sum)%k];
        //if(a[i]==0) ans++;
        sum=(sum+a[i])%k;
        mp[sum]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14336
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		String str1 = scan.next();
		String str2;
		String str3;
		
		while(!str1.equals("-"))
		{
			int[] shuffle = new int[scan.nextInt()];
			
			for(int i = 0;i < shuffle.length;i++){shuffle[i] = scan.nextInt();}
			
			for(int i = 0;i < shuffle.length;i++)
			{
				str2 = str1.substring(0,shuffle[i]);
				str3 = str1.substring(shuffle[i], str1.length());
				
				StringBuilder buf = new StringBuilder();
				buf.append(str3);
				buf.append(str2);
				str1 = buf.toString();
			}
			System.out.println(str1);
			str1 = scan.next();
		}
	}
}

Measured memory_bytes: 18260
/*
    じょえチャンネルです！
    https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
    チャンネル登録と高評価お願いします！
    最新の動画：
    【競プロ】チーム対抗！目隠しABC早解き対決 https://youtu.be/gPFr7q7eLL8
*/

#include <bits/stdc++.h>
using namespace std;

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

    int n;
    cin >> n;
    vector<int> xs(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> xs[i];
        sum += xs[i];
    }
    int m = sum / n;
    long long ans = 1e10;
    for (int i = m - 1; i <= m + 1; i++) {
        long long tmp = 0;
        for (int x : xs) {
            tmp += (x - i) * (x - i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


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


#define ll long long int
#define pb push_back
#define F first
#define S second 
#define f(i,n) for(int i = 0; i < n; i++)
using namespace std;
    // n   sum
int dp[105][100005];

int solve(int sum,int n, int a[], int w[],int W)
{
  for(int i = 0; i <= n ; i++)
  for(int j = 0; j <= sum; j++)
      dp[i][j] = 1e9 +18;
  
  f(i,n+1)
  dp[i][0] = 0;
  for(int i = 1; i <= n ; i++)
  {
    for(int j = 1; j <= sum; j++)
    {
       if(j >= a[i-1])
        dp[i][j] = min(dp[i-1][j], w[i-1] + dp[i-1][j-a[i-1]]);
       else
        dp[i][j] = dp[i-1][j];
    }
  }
  int mx = -1e9;

  for(int i = 0; i <= sum ; i++)
    if(dp[n][i] <= W)
      mx = max(mx,i);
  return mx;
    
}







int main()
{
 
     #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif
     //soe();
     int n,W; cin>>n>>W;
     int a[n],w[n];
     int sum = 0;
     f(i,n)
     {
      cin>>w[i];
      cin>>a[i];
      sum += a[i];
     }
      
     
     cout<<solve(sum,n,a,w,W);

     return 0;
}

Measured memory_bytes: 43072
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     for(int i = 1;i <= 3000;i++){
      int x = scan.nextInt();
      int y = scan.nextInt();
      if(x == 0 && y == 0){
       i = 3001;
      }else{
        if(x > y){
            int t = x;
            x = y;
            y = t;
        }
         System.out.println(x + " " + y);
         }
     }
    }
}


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll s,w;cin>>s>>w;

  if(w>=s)out("unsafe");
  else out("safe");


  return 0;
}


Measured memory_bytes: 3644
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
#define p 998244353
using namespace std;
inline ll read(){
    ll x = 0; char zf = 1; char ch = getchar();
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt,sum;
ll f(ll x){
	if(x%4==1)return 1;
	if(x%4==3)return 0;
	if(x%4==0)return x;
	if(x%4==2)return x+1;
}
int main(){
	ll L=r,R=r;if(L==0)cout<<f(R);else 
	cout<<(f(R)^f(L-1));
    return 0;
}








Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
 
#define f(i,x) for(int i=0;i<x;i++)
 
 
using namespace std;
 
int main()
{
	string a;
	cin >> a;
	cout << "ABC" + a ;
 
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int N,K;
int main(int argc, char const *argv[])
{
    cin >> N >> K;
vector<int> x(N);
int sum=0;
for(size_t i=0;i<x.size();i++){
    cin>>x[i];
    sum+=2*min(x[i],abs(K-x[i]));
}
cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
int main() {
	int M,A,a;
	char op;
	cin >> A;
	while (cin>>op){
		if (op == '='){
			break;
		}
		cin >> M;
		if (op == '+') {
			A += M;
		}
		else if (op == '-') {
			A -= M;
		}
		else if (op == '*') {
			A *= M;
		}
		else {
			A /= M;
		}
	}
	cout << A << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}

int main()
{
  int n = in();
  int r = 1;
  for (int i = 0; i < n; i++) r = lcm(r, in());
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
long long n, k, dp[5005][5005];
std::string s;
signed main(){
	std::cin>>n>>s, dp[0][0]=1, k=s.length();
	for(int i=1; i<=n; i++)
		for(int j=0; j<=n; j++)
			if(j==0) dp[i][j]=(dp[i-1][j]+dp[i-1][j+1])%1000000007;
			else dp[i][j]=(dp[i-1][j-1]*2+dp[i-1][j+1])%1000000007;
	for(int i=1; i<=k; i++) dp[n][k]=(dp[n][k]*500000004)%1000000007;
	std::cout<<dp[n][k];
}

Measured memory_bytes: 195712
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
#define INF (1<<29)
int main(){
  ll N;
  cin>>N;
  ll K=1,cnt=0;
  while(K<=N){
    cnt++;
    K*=2;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

ll dp[100000];

void solve(){
    int n,k;
    cin>>n>>k;

    vector <int> vi;

    for(int i=0;i<n;i++){
        int a; cin>>a;
        vi.push_back(a);
    }
    dp[0]=0;
    dp[1]=abs(vi[1]-vi[0]);

    for(int i=2;i<k;i++){
        vector <int> v;
        for(int j=1;j<=i;j++){
            int a=dp[i-j]+abs(vi[i]-vi[i-j]);
            v.push_back(a);
        }
        dp[i]=*min_element(v.begin(),v.end());
    }

    // for(int i=0;i<k;i++) cout<<dp[i]<<" ";

    for(int i=k;i<n;i++){
        vector <int> v;
        for(int j=1;j<=k;j++){
            int a=dp[i-j]+abs(vi[i]-vi[i-j]);
            v.push_back(a);
        }

        dp[i]=*min_element(v.begin(),v.end());
    }

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


int main(){
    fast;
    int m=1;
    // cin>>m;

    while(m--)
    {
    solve();
    }
}

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

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	long long n,m,a,b;
	long long sum;
	while(scanf("%lld",&n)==1)
	{
		sum=1;a=pow(10,9)+7;
		for(int i=1;i<=n;i++)
		{
			sum=sum*i;
		    sum=sum%a;
		}
		printf("%lld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 256
import re

S = input()
frag_1 = 0
frag_2 = 0
frag_3 = 0

if S.find("A") == 0:
  frag_1 = 1
if 1 < S.find("C") and S.find("C") < len(S)-1:
  frag_2 = 1
if len(re.findall('[A-Z]', S)) == 2:
  frag_3 = 1

if frag_1 == 1 and frag_2 == 1 and frag_3 == 1:
  print("AC")
else:
  print("WA")


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll S;
    cin >> S;

    const ll m = 1e9;

    if(S == 1e18) {
        cout << 0 << " " << 0 << " " << m << " " << 0 << " " << 0 << " " << m;
    }
    else {
        ll a = S/m;
        ll b = S%m;
        cout << 0 << " " << 0 << " " << m << " " << 1 << " " << m - b << " " << a+1;
    }

    cout << endl;
    re0;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
#define chmax(x,y) (x = max(x, y))
void solve(); int main() { solve(); return 0; }

void solve() {
  int a, b;
  cin >> a >> b;
  if (a<=b) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}


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

int main(){
    int n, m; cin >> n >> m;
    vector<int> S(n);
    rep(k, m){
        int tmp; cin >> tmp;
        rep(i, tmp){
            int a; cin >> a; a--;
            S[a] |= 1 << k;
        }
    }
    int p = 0;
    rep(i, m){
        int tmp; cin >> tmp;
        p |= tmp << i;
    }
    int success = 0;
    rep(bit, (1<<n)){
        int ok = 0;
        rep(i, n){
            if (bit >> i & 1){
                ok ^= S[i];
            }
        }
        if (ok == p) success ++;
    }
    cout << success << endl;
}

Measured memory_bytes: 3620
# -*-coding:utf-8

import fileinput
import math

def main():

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

    A = [[0 for i2 in range(n)] for i1 in range(m)]

    for i in range(m):
        tokens = list(map(int, input().split()))
        for j in range(n):
            A[i][j] = tokens[j]

    b = []
    for i in range(n):
        line = input()
        b.append(int(line))

    for i in range(m):
        sum = 0
        for j in range(n):
            sum += (A[i][j] * b[j])

        print(sum)

if __name__ == '__main__':
    main()

Measured memory_bytes: 8076
// Problem : B - Making Triangle
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int a[maxN];

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	REP(i, n) cin >> a[i];
	sort(a, a + n);
	int cnt = 0;
	REP(i, n) {
		FOR(j, i + 1, n - 1) {
			FOR(k, j + 1, n - 1) {
				if (a[i] + a[j] > a[k] && a[i] != a[j] && a[i] != a[k] && a[j] != a[k]) {
					cnt++;
				}
			}
		}
	}
	cout << cnt;
	return 0;
}
 


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  //ベクトル p2-p1 = (a,b)
  ll a = x2-x1;
  ll b = y2-y1;

  //ベクトル p4-p1 = (c,d)
  ll c = -b;
  ll d = a; 

  ll x3 = x1+a+c;
  ll y3 = y1+b+d;
  ll x4 = x1+c;
  ll y4 = y1+d;
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl; 
 }

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

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

  int e[n+2], w[n+2];
  e[0] = w[n+1] = 0;
  for (int i = 1; i <= n; ++i) {
    e[i] = e[i-1];
    if (s[i-1] == 'E') ++e[i];
  }
  for (int i = n; i >= 1; --i) {
    w[i] = w[i+1];
    if (s[i-1] == 'W') ++w[i];
  }
	
  int ans = 1e6;
  for (int i = 1; i <= n; ++i) {
    ans = min(ans, n-1-e[i-1]-w[i+1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3076
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
#include <iterator>
 
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second
 
const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int main()
{
	int n;int k = 0;
	cin >> n;
	
	vector<int> A(n);
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
		k = max(k, A[i]);
	}
	vector<int> C(k + 1);
	vector<int> B(n + 1);


	for (int j = 0; j < n; j++)
	{
		C[A[j]]++;
	}
	for (int i = 1; i <= k; i++)
	{
		C[i] += C[i - 1];
	}
	for (int j = 0 ; j < n; j++)
	{
		B[--C[A[j]]] = A[j];
	}

	for (int i = 0; i < n; i++)
	{
		cout << B[i];
		if (i < n -1)
		{
			cout << " ";
		}
		else
		{
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 18368
A, B, C, D = map(int, input().split())
if A <= C:
    if B <= C:
        print(0)
    if C < B and B <= D:
        print(B - C)
    if D < B:
        print(D - C)
if C < A:
    if D <= A:
        print(0)
    if A < D and D <= B:
        print(D - A)
    if B < D:
        print(B - A)

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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	map<int, int> mp;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		mp[d]++;
	}

	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		if (mp.count(t)) {
			if (!mp[t]) {
				cout << "NO" << endl;
				return 0;
			}

			mp[t]--;
		} else {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define Chkmin(a,b) a=a<b?a:b
using namespace std;
template<typename T>inline void read(T &x)
{
    T s=0,f=1;char k=getchar();
    while(!isdigit(k)&&(k^'-'))k=getchar();
    if(!isdigit(k)){f=-1;k=getchar();}
    while(isdigit(k)){s=s*10+(k^48);k=getchar();}
    x=s*f;
}
const int MAXN=2211;

static int n,k,q,b[MAXN];

static struct poi
{
	int w,id;
	friend bool operator<(poi a,poi b)
	{return a.w<b.w;}
}p[MAXN];

inline void init()
{
	read(n);read(k);read(q);
	Rep(i,1,n)read(p[i].w),b[i]=p[i].w,p[i].id=i;
}

inline bool Judge(int mi,int ma)
{
	static int lef,fr,cnt;cnt=lef=fr=0;
	Rep(i,1,n)
	{
		if(b[i]<mi){lef=fr=0;continue;}
		++lef;if(b[i]<=ma)++fr;
		if(lef>=k&&fr)++cnt,--fr,--lef;
	}
	return cnt>=q;
}

static int ans=1e9;

inline void solve()
{
	static int l,r,mid;
	sort(p+1,p+n+1);
	p[n+1].w=2e9;
	Rep(i,1,n-q+1)
	{
		l=i;r=n;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(Judge(p[i].w,p[mid].w))r=mid-1;
			else l=mid+1;
		}
		Chkmin(ans,p[l].w-p[i].w);
	}
	printf("%d\n",ans);
}
int main()
{
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (k, x): (usize, usize);
    input!(k, x);
    if 500 * k >= x {
        p("Yes");
    } else {
        p("No");
    }
}


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

typedef long long ll;
typedef vector<ll> vl;

const ll MOD = (ll)(1e+9) + 7;
int N, K;
vector<int> A;
vector<vl> dp;

void input_init(void) {
	cin >> N >> K;
	A.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	dp.resize(N + 1, vl(K + 1, (ll)0));
}

void solve(void) {
	for (int i = 0; i <= N; ++i)
		dp[i][0] = (ll)1;
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= K; ++j) {
			dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % MOD;
			if (j - A[i - 1] - 1 >= 0)
				dp[i][j] = (dp[i][j] + MOD - dp[i - 1][j - A[i - 1] - 1]) % MOD;
		}
	}
}

int main(void) {
	input_init();
	solve();
	ll ans = dp[N][K];
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 80256
#include <stdio.h>
int main(void){
    int n, m, l;
    int i, j, k;
    int a[101][101], b[101][101];
    long long int c[101][101];

    scanf("%d%d%d", &n, &m, &l);
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(i = 0; i < m; i++){
        for(j = 0; j < l; j++){
            scanf("%d", &b[i][j]);
        }
    }
    for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            c[i][j] = 0;
            for(k = 0; k < m; k++){
            c[i][j] += a[i][k] * b[k][j];
            }
            printf("%lld", c[i][j]);
            if(j != (l - 1)) putchar(' ');
        }printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
int mod = 1e9+7;


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

    int n, m;
    cin>>n>>m;

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

    vector<vector<int>> dp(n+1, vector<int>(m+1));
    dp[1][1]=1;
    for(int i=1; i<=n; i++){
    	for(int j=1; j<=m; j++){
    		if(grid[i-1][j-1]=='#')
    			dp[i][j]=0;
    		else dp[i][j] += (dp[i-1][j] + dp[i][j-1])%mod;
    	}
    }

    cout<<dp[n][m];

	return 0;
}		


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

int main(void) {
	string S;
	cin >> S;
	bool guusu = true;
	bool kisu = true;
	for (int i = 0; i < S.size(); i++) {
		if (i % 2 != 0 ) {
			//偶数の時
			if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D') {
				guusu = false;
			}
		}
		else {
			//奇数の時
			if (S[i] != 'R'&& S[i] != 'U' && S[i] != 'D') {
				kisu = false;
			}
		}
	}
	if (guusu == true && kisu == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>


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

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long MOD = 1'000'000'007LL;
const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	long double A, B; 
	long double P, Q, R;
	cin >> A >> B >> P >> Q >> R;
	long double t = B * P - (B - A) * Q;
	long double res = B + t / (Q + R);
	cout << fixed << setprecision(12) << res << "\n";
	return 0;

}



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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, d;
  cin >> n >> d;

  d = d * d;

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

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3652