akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <ctime>
#include <cstdio>
#include <algorithm>
#define Pi acos(-1.0)

using namespace std;

const int N=8e5+10,Mod=924844033;

struct Edge{ int to,next;} way[N<<1];

int n,num[N],tot,A[N],B[N],P[N],F[N<<4],fact[N],fact_inv[N];

void Build(int a,int b) { way[++tot]=(Edge){b,num[a]}; num[a]=tot; }

void Init()
{
	scanf("%d",&n);
	int a,b;
	for (int i=2;i<=n;++i)
	{
		scanf("%d%d",&a,&b);
		Build(a,b); Build(b,a);
	}
}

int son[N];
void Dfs(int x,int fa)
{
	son[x]=1;
	for (int i=num[x];i;i=way[i].next)
	{
		int v=way[i].to;
		if (v==fa) continue;
		Dfs(v,x);
		son[x]+=son[v];
		A[son[v]]--;
	}
	if (n-son[x]) A[n-son[x]]--;
}

int R[N<<2],L;
int inv(int x)
{
	int t=Mod-2,ret=1;
	while (t)
	{
		if (t&1) ret=1ll*ret*x%Mod;
		x=1ll*x*x%Mod;
		t>>=1;
	}
	return ret;
}

int qpow(int x,int k)
{
	int ret=1;
	while (k)
	{
		if (k&1) ret=1ll*ret*x%Mod;
		x=1ll*x*x%Mod;
		k>>=1;
	}
	return ret;
}

void BRC(int *y,int len)
{
	for (int i=0;i<len;++i) 
		if (R[i]<i) swap(y[i],y[R[i]]);
}

void ntt(int *y,int len,int f)
{
	BRC(y,len);
	fprintf(stderr,"%d\n",clock());
	for (int h=2;h<=len;h<<=1)
	{
		int wn=qpow(5,(Mod-1)/h);
		if (f==-1) wn=qpow(wn,Mod-2);
		for (int j=0;j<len;j+=h)
		{
			int w=1;
			for (int k=j;k<j+h/2;++k)
			{
				int u=y[k],t=1ll*w*y[k+h/2]%Mod;
				y[k]=(u+t)%Mod;
				y[k+h/2]=(u-t+Mod)%Mod;
				w=1ll*w*wn%Mod;
			}
		}
	}
    if(f==-1){
        int ny=qpow(len,Mod-2);
        for(int i=0;i<len;i++) 
			y[i]=1ll*y[i]*ny%Mod;
    }
}

void Solve()
{
	Dfs(1,0);A[n]=n; 
	fact[0]=1; for (int i=1;i<=n;++i) fact[i]=1ll*fact[i-1]*i%Mod;
	int ny=inv(fact[n]);fact_inv[n]=ny;
	for (int i=n-1;i;--i) fact_inv[i]=1ll*fact_inv[i+1]*(i+1)%Mod;
	fact_inv[0]=1;
	for (int i=0;i<=n;++i) B[i]=fact_inv[i];
	for (int i=0;i<=n;++i) A[i]=1ll*(A[i]+Mod)*fact[i]%Mod;
	for (int i=0;i<=n;++i) P[i]=A[n-i];
	
	int len,L=0; for (len=1;len<((n+1)<<1);len<<=1) ++L;
    for(int i=0;i<len;i++)R[i]=R[i>>1]>>1|((i&1)<<(L-1));
	ntt(P,len,1); ntt(B,len,1); 
    for(int i=0;i<len;i++)F[i]=1ll*P[i]*B[i]%Mod;
//    for (int i=0;i<len;++i) printf("%d%c",F[i],i==len-1?'\n':' ');
    ntt(F,len,-1);
	for (int i=n-1;i>=0;--i) 
		printf("%lld\n",1ll*F[i]*fact_inv[n-i]%Mod);
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 42752
#include <ctype.h>
#include <cstdio>

using namespace std;

int main() {
  int x = 0;
  for (;;) {
    const int c = getchar();
    if (c == EOF)
      break;

    if (c == '\n') {
      if (!x)
        break;
      printf("%d\n", x);
      x = 0;
      continue;                                                                                                                           
    }
    if (isdigit(c))
      x += c - '0';  // convert a character to an integer                                                                                                                 
  }

  return 0;
}

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

int main() {
  long n;
  string ans="";
  cin >> n;
  for(long i=-1;n!=0;i*=-2) {
    if(labs(n)%(labs(i)*2)==0) {
      ans='0'+ans;
    } else {
      ans='1'+ans;
      n+=i;
    }
  }
  if(ans=="") ans="0";
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    System.out.print(c + " " + a + " " + b);
    System.out.println();
  }
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <cstdlib>
#include <ctime>

using namespace std;

//#define HOME
void jakos() {
#ifdef HOME
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

#define endl '\n'
#define int long long
typedef long long ll;

const int mod = 1e9 + 7;
const int base = 179;
const int INF = 1e9;
const int N = 1e5 + 7;

signed main() {
    jakos();

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

    int mx = 0;

    for (auto e : mp) {
        mx = max(mx, e.second);
    }
    for (auto e : mp) {
        if (e.second == mx) {
            cout << e.first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
int gcdd(int a,int b){
	if(b==0)return a;
	else return gcdd(b,a%b);
}
int gcd(int a,int b,int c){
	return gcdd(a,gcdd(b,c));
}
int main(){
	int n;
	scanf("%d",&n);
	long long ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
					ans+=gcd(i,j,k);
	printf("%lld\n",ans);
	
}

Measured memory_bytes: 3828
#include <iostream>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
using ll = long long;

ll size[55];
ll patty[55];

int main() {
    ll n, x; cin >> n >> x;
    size[0] = 1, patty[0] = 1;
    REP(i,n+1) size[i+1] = size[i] * 2 + 3;
    REP(i,n+1) patty[i+1] = patty[i] * 2 + 1;

    ll ans = 0;
    while(n>=0) {
        if(x==0) {break;} // left end
        else if(n==0) { // P
            ++ans;
            break;
        }

        if(x < 1 + size[n-1] + 1) { 
            --n;
            --x;
        } else if(x > 1 + size[n-1] + 1) {
            ans += patty[n-1] + 1;
            x -= 1 + size[n-1] + 1;
            --n;
        } else {
            ans += patty[n-1] + 1;
            break;
        }
    }
    cout << ans << '\n';
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;

template<typename T>
vector<T> smallest_prime_factors(T n) {

    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++) spf[i] = i;


    for (T i = 2; i * i <= n; i++) {

        // 素数だったら
        if (spf[i] == i) {

            for (T j = i * i; j <= n; j += i) {

                // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }

    return spf;
}

template<typename T>
vector<T> factolization(T x, vector<T> &spf) {
    vector<T> ret;
    while (x != 1) {
        ret.push_back(spf[x]);
        x /= spf[x];
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){

    
    constexpr int MAX = 1000000;

    auto spf = smallest_prime_factors(MAX);

    int n;
    cin >> n;
    vector<ll> p(n);
    p[0]=0;
    p[1]=1;

    for(int x=2; x<n; x++) {
        auto result = factolization(x, spf);
        ll count=1,aa=1;
        for(int i=0; i<result.size(); i++){
            if(i!=0){
                if(result[i]==result[i-1]) count++;
                else{
                    aa*=count+1;
                    count=1;
                }
            }
        }
        aa*=count+1;
        p[x]=aa;
    }
    ll sum=0;
    rep(i,n) sum+=p[i];
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 14776
A = raw_input().split()
B = []

def add(x,y):
    return x + y
def sub(x,y):
    return x - y
def mul(x,y):
    return x * y
operation = {'+':add, '-':sub, '*':mul}

for item in A:
    if item.isdigit():
        B.append(int(item))
    else:
        num2 = B.pop()
        num1 = B.pop()
        ans = operation[item](num1, num2)
        B.append(ans)
print ans

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)


LL A, B, Q;

struct Score {
	LL position;
	LL add;

	/*bool operator == (Score const& r) const {
		return false;
	}*/
	bool operator < (Score const& r) const {
		return position < r.position;
	}
};

//bool operator < (Score const& a, Score const& b) {
//	return a.position < r.position;
//}

int main()
{
	cin >> A >> B >> Q;
	vector<LL> a(A);
	vector<LL> b(B);
	REP(i, A) {
		cin >> a[i];
	}
	REP(i, B) {
		cin >> b[i];
	}
	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	vector<LL> a_add(A, 100000000000);
	vector<LL> b_add(B, 100000000000);

	vector<Score> score(A + B);

	REP(i, A) {
		int index = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
		
		if (index < B) {
			a_add[i] = abs(b[index] - a[i]);
		}

		if (index > 0) {
			a_add[i] = min(a_add[i], abs(b[index - 1] - a[i]));
		}

		score[i].position = a[i];
		score[i].add = a_add[i];
	}

	REP(i, B) {
		int index = lower_bound(a.begin(), a.end(), b[i]) - a.begin();

		if (index < A) {
			b_add[i] = abs(a[index] - b[i]);
		}

		if (index > 0) {
			b_add[i] = min(b_add[i], abs(a[index - 1] - b[i]));
		}

		score[A + i].position = b[i];
		score[A + i].add = b_add[i];
	}

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

	REP(i, Q) {
		LL q;
		cin >> q;
		Score st;
		st.position = q;

		int index = lower_bound(score.begin(), score.end(), st) - score.begin();

		if (index == 0) {
			cout << abs(q - score[index].position) + score[index].add << endl;
		}
		else if (index == score.size()) {
			cout << abs(q - score[index - 1].position) + score[index - 1].add << endl;
		}
		else {
			LL x = abs(q - score[index].position) + score[index].add;
			LL y = abs(q - score[index - 1].position) + score[index - 1].add;
			LL r = min(x, y);
			cout << r << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 7552
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSmallAndLargeIntegers solver = new BSmallAndLargeIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSmallAndLargeIntegers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt(), k = in.nextInt();

            TreeSet<Integer> answer = new TreeSet<>();
            for (int i = 0; i < k; i++) {
                int x = a + i;
                if (x <= b)
                    answer.add(x);

                x = b - i;
                if (x >= a)
                    answer.add(x);
            }

            StringBuilder sb = new StringBuilder();
            for (int x : answer) {
                sb.append(x + " ");
            }
            sb.deleteCharAt(sb.length() - 1);

            out.println(sb);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<string,int>;

int main(){

  int N;
  cin >> N;

  vector<P> p1(N);
  vector<P> p2(N);

  string s;
  int p;

  for (int i = 0; i < N; i++) {
    cin >> s >> p;
    p1[i].first = s;
    p1[i].second = p*-1;
  }
  p2 = p1;
  sort(p1.begin(), p1.end());

  for (int i = 0; i < N; i++) {
    int cnt = 0;
    for (int j = 0; j < N; j++) {
      cnt++;
      if(p1[i].second == p2[j].second) break;
    }
    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 3556
/*
 *	Argorithms and Data Structures
 *	Lectuire 2
 *	Selecton Sort
 */

#include <stdio.h>

#define MAX_N 100

int main(void){
	int A[MAX_N], N;
	int i, j, minj, hoge, count = 0;

	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%d", &A[i]);

	for( i=0; i<N; i++){
		minj = i;
		for( j = i+1; j<N; j++){
			if( A[j] < A[minj])
				minj = j;
		}
		if( minj != i){
			hoge = A[i];
			A[i] = A[minj];
			A[minj] = hoge;
			count++;
		}
	}

	for( i=0; i<N-1; i++)
		printf("%d ", A[i]);
	printf("%d\n%d\n", A[i], count);

	return 0;
}	

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a+b >= c ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
//#pragma optimization_level 3
#include <bits/stdc++.h>
#define  f               first
#define  s               second
#define  sym(s)          s = "#" + s + "#";
#define  all(x)          (x).begin(), (x).end()
#define  alll(x,n)       x+1, x+n+1
#define  newl            cout<<"\n";
#define  foo(i,a,n)      for(ll i = (a); i <= n; i++)
#define  deb1(a)         cout<<a<<"\n";
#define  deb2(a,b)       cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)     cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)   cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  debp(a)         cout<<a.f<<" "<<a.s<<"\n";
#define  debv(a)         for(auto it: a)cout<<it<<" ";newl;
#define  debm(a)         for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  deb1d(a,n)      foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)    foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}

using namespace std;
using ll              =  long long;
using ld              =  long double;
const ll   MOD        =  1e+9 + 7;
const ll   INF        =  LLONG_MAX;
const int  N          =  (int)2e+5 + 8;

ll n, a[N]; 
ll x, t;

void MAIN(int tc){  
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin>>a[i];
    }
    ll res = 0;
    for(int i = 2; i <= n; i++) {
        if(a[i-1] > a[i]) {
            res += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout<<res;
}

int main(){
    ios:: sync_with_stdio(false); 
    cin.tie(nullptr); cout.tie(nullptr);
    cout<<fixed; cout<<setprecision(10);

    int test_cases = 1;
    //cin>>test_cases;
    for(int i = 1; i <= test_cases; i++){
        MAIN(i);
    }
}

Measured memory_bytes: 5212
import math
n, m = map(int, input().split())
ans = -1
mod = pow(10, 9) + 7

if abs(n-m) > 1:
    ans = 0
else:
    if abs(n-m) == 0:
        a = math.factorial(n)
        ans = a*a*2
    if abs(n-m) == 1:
        a = math.factorial(min(n, m))
        b = a * max(n, m)
        ans = a * b

print(ans%mod)


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

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

  int h = s/60/60;
  int m = (s-h*60*60)/60;
  int ss = s-(h*60*60+m*60);

  cout << h << ":" << m << ":" << ss << endl;

  return 0;
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			String s=sc.nextLine();
			if(s.equals("END OF INPUT"))break;
			String w[] = s.split(" ");
			for (int i = 0; i < w.length; i++) {
				System.out.print(w[i].length());
			}
			System.out.println();
		}
	}
}

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

int main()
{
ll n ;
cin >> n;
ll ans = 1e18;
for(ll i = 1; i*i <= n; ++i){
    if(n % i !=0) continue;
    ll j = n/i;
    ans = min(ans,i+j-2);
}
cout << ans << endl; 
return 0;
}





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

void dfs(int cur);
int df[100][2]={};
bool dc[100]={};
bool adj[100][100]={};//初期化を忘れない
int n,u,v,k;
int t = 1;
queue<int> q;

int main(){
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> u >> k;
    for (int j=0; j<k; j++){
      cin >> v;
      adj[u-1][v-1] = true;
    }
  }
  
  //探索は一回で終わるとは限らない　グラフは非連結の場合もある？
  for (int i=0; i<n; i++){
    if (dc[i] != true)
      dfs(i);
  }
  
  
  for (int i=0; i<n; i++)
    cout << i+1 << " " << df[i][0] << " " << df[i][1] << endl;

}

void dfs(int cur){
  dc[cur] = true;
  df[cur][0] = t;
  t += 1;
  for (int i=0; i<n; i++){
    if (adj[cur][i] && !dc[i]){
      dfs(i);
    }
  }
  df[cur][1] = t; 
  t += 1;
}

Measured memory_bytes: 1212
while True :
    H, W = map(int, input().split())
    if W == 0 and H == 0 :
        break
    str = "#." * (W // 2)
    if W % 2 == 0 :
        str += "#"
    else :
        str += "#."
    for i in range(H):
        if i % 2 == 0:
            print(str[:-1])
        else :
            print(str[1:])
    print()


Measured memory_bytes: 5612
#include<stdio.h>
int main(void){
	int N,L,sum;
	scanf("%d%d",&N,&L);
	sum=N*(N-1)/2+N*L;
	if(0<=L){
		sum-=L;
	}
	else if(N<1-L){
		sum-=L+N-1;
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 1720
k, n = map(int, input().split())
a_list = list(map(int, input().split()))

max_dis = 0
sum_dis = 0
i = 0
while i < n:
  if i + 1 == n:
    dis = k - a_list[i] + a_list[0]
    # print(dis)
  else:
    dis = a_list[i + 1] - a_list[i]
    # print(dis)
  sum_dis += dis
  if max_dis < dis:
    # print(i)
    max_dis = dis
  i += 1

# print(max_dis, sum_dis)
print(sum_dis - max_dis)


Measured memory_bytes: 25840
#include<bits/stdc++.h>
using namespace std;
#define LL long long int

int main() {
	LL a,b;
	cin>>a>>b;
	if(a==b){
	    cout<<0<<endl;
	}
	else{
	    LL s=a+b;
	    if(s%2==0){
	        cout<<s/2<<endl;
	    }
	    else{
	        cout<<"IMPOSSIBLE"<<endl;
	    }
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[100000];
int i,j,n,ans;
int main()
{
	cin>>n;
	for(i=1;i<=100000;i++) a[i]=0;
	for(i=1;i<=n;i++)
    {
	cin>>j;
	a[j]++;
	a[j-1]++;
	a[j+1]++;
	}
ans=0;
for(i=1;i<=100000;i++)
if(a[i]>ans) ans=a[i];
cout<<ans;
return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;
int main()
{
    int n;
    double students[1000]={0},sum,m,div;
    while(true)
    {
        scanf("%d",&n);
        if(n==0) break;
        div=sum=0;
        for(int i=0;i<n;i++)
        {
            scanf("%lf",&students[i]);
            sum+=students[i];
        }
        m=sum/n;
        for(int i=0;i<n;i++)
        {
            div+=(students[i]-m)*(students[i]-m);
          
        }
        printf("%.8lf\n",sqrt(div/n));
    }
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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 long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  map<int, int> mp;

  ll res = 0;
  rep(i, n){
    cin >> v[i];
  }

  rep(i, n){
    int sa = i - v[i];
    int wa = i + v[i];
    res += mp[sa];
    mp[wa]++;
  }

  cout << res << endl;


}


Measured memory_bytes: 21124
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		int T;
		T=1;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			int d,t,s;
			cin>>d>>t>>s;
			if(d<=(t*s))
			cout<<"Yes";
			else
			cout<<"No";	
		}
		return 0;
	}


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int a,b; cin >> a >> b;
  string s; cin >> s;
  rep(i,s.size()){
    if(i < a && '0' <= s[i] && s[i] <= '9') continue;
    else if(i == a && s[i] == '-') continue;
    else if(a < i && '0' <= s[i] && s[i] <= '9') continue;
    else{
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
}


Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(n int, matrix [][]int) int {
        memo := make(map[int]bool, n)

        for i := range matrix {
                for _, u := range matrix[i] {
                        memo[u] = true
                }
        }
        c := 0
        for i := 1; i <= n; i++ {
                if _, ok := memo[i]; !ok {
                        c++
                }
        }
        return c
}

func main() {
        var n, k int
        fmt.Scan(&n, &k)
        matrix := make([][]int, 0, k)
        for i := 0; i < k; i++ {
                var d int
                fmt.Scan(&d)
                nums := make([]int, 0, d)
                for j := 0; j < d; j++ {
                        var n int
                        fmt.Scan(&n)
                        nums = append(nums, n)
                }
                matrix = append(matrix, nums)
        }
        fmt.Println(solution(n, matrix))
}

Measured memory_bytes: 2584
from collections import Counter
ma = 100000

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    
    for i in range(2, int(n**0.5) + 1):
        if is_prime[i] == False:
            continue
            
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
            
    return [i for i in range(n) if is_prime[i]]

q = int(input())
a = primes(100000)
b = []
for i in a:
    b.append(i*2 - 1)
    
aa = Counter(a)
bb = Counter(b)

rui = [0] * (ma+1)
for i in range(1,ma+1):
    if aa[i] == 1 and bb[i] == 1:
        rui[i] = rui[i-1] + 1
    else:
        rui[i] = rui[i-1]
        
for _ in range(q):
    l , r = map(int,input().split())
    print(rui[r] - rui[l-1])

Measured memory_bytes: 54140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}



Measured memory_bytes: 25288
import scala.io.StdIn.{readLine,readInt}

object Main extends App {

  var index = 1
  Iterator.continually(readInt).takeWhile ( w => w != 0).foreach { w =>
    val n = readInt
    val wv = Array.ofDim[Int](n+1,2)
    val m = Array.ofDim[Int](n+1,w+1)

    for(i<-1 to n) wv(i) = readLine.split(",").map(_.toInt)
    for(i<-1 to n;j<-0 to w) {
      if(j >= wv(i)(1)) {
        val x = wv(i)(0) + m(i-1)(j-wv(i)(1))
        if(m(i-1)(j) <= x) m(i)(j) = x else m(i)(j) = m(i-1)(j)
      } else
        m(i)(j) = m(i-1)(j)
    }
    println("Case "+index+":")
    println(m(n)(w))
    println((0 to w).find(m(n)(_) == m(n)(w)).get)
    index += 1
  }
}

Measured memory_bytes: 49604
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;


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

    int n;
    string s, t;

    cin >> n >> s >> t;

    for0(i, n){
        cout << s[i] << t[i];
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

using ll = long long;

int n, k;
ll a[123456];
ll rui[123456];
ll imo[123456];
ll big = 0;

int main(void)
{
	scanf("%d %d", &n, &k);
	rui[0] = 0; imo[0] = 0;
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld", a + i);
		if (a[i] > 0)big += a[i];
		rui[i + 1] = rui[i] + ((a[i] > 0) ? 0 : (-a[i]));
		imo[i + 1] = imo[i] + ((a[i] > 0) ? a[i] : 0);
	}
	ll sub = 1234567890123456;
	for (int p = 0; p <= n - k; ++p)
	{
		ll can = rui[p + k] - rui[p];
		sub = min(sub, can);
	}
	ll gen = 1234567890123456;
	for (int q = 0; q <= n - k; ++q)
	{
		ll can = imo[q + k] - imo[q];
		gen = min(gen, can);
	}
	printf("%lld\n", max(big - sub, big - gen));
	return 0;
}


Measured memory_bytes: 2560
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
sort($a);
$temp = $a[0];
for ($i=1; $i < $n; $i++) { 
    $temp = ($temp + $a[$i]) / 2;
}
echo $temp . PHP_EOL;

Measured memory_bytes: 4856
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int x =sc.nextInt(),n=sc.nextInt();
	if (n==0) System.out.println(x);
	else {
		int [] a = new int [n];
		boolean d = true;
		for (int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			if (a[i]==x) d=false;
		}
		if (d) System.out.println(x);
		else {
			for (int i=1;i<110;i++) {
				boolean  f = true;
				for (int j=0;j<n;j++) {
					if (x-i==a[j]) {f=false;break;}
				}
				if (f) {System.out.println(x-i);break;}
				f=true;
				for (int j=0;j<n;j++) {
					if (x+i==a[j]) {f=false;break;}
				}
				if (f) {System.out.println(x+i);break;}
			}
		}
		
	}
	sc.close();}}


Measured memory_bytes: 36000
def main():
    n, m, k = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    sum_A = [A[0]]
    sum_B = [B[0]]

    for i in range(n - 1):
        sum_A.append(sum_A[i] + A[i + 1])

    for i in range(m - 1):
        sum_B.append(sum_B[i] + B[i + 1])

    R = []

    b = m - 1
    flag = False
    while b > -1:
        if sum_B[b] <= k:
            R.append(b + 1)
            flag = True
            break
        else:
            b -= 1

    if not flag:
        R.append(0)

    for i in range(n):
        a = sum_A[i]

        flag = False
        while b > -1:
            if sum_B[b] <= k - a:
                R.append(i + 1 + b + 1)
                flag = True
                break
            else:
                b -= 1

        if not flag:
            if 0 <= k - a:
                R.append(i + 1)
            else:
                R.append(0)

    print(max(R))
    # while k > 0 and (a < n or b < m):
    #     if a == n:
    #         time = B[b]
    #     elif b == m:
    #         time = A[a]
    #     else:
    #         time = min(A[a], B[b])

    #     if k - time < 0:
    #         break

    #     r += 1
    #     k -= time
    #     print(k)

    #     if a == n:
    #         b += 1
    #     elif b == m:
    #         a += 1
    #     else:
    #         if A[a] >= B[b]:
    #             b += 1
    #         else:
    #             a += 1

    # print(r)


if __name__ == '__main__':
    main()


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

int main(){
  double x1,x2,y1,y2;
  double sq,pox=0,poy=0;
  
  cin>>x1>>y1>>x2>>y2;
  
  pox = pow(x1-x2,2);
  poy = pow(y1-y2,2);

  sq = sqrt(pox+poy);

  cout<<fixed<<sq<<endl;
  return 0;
}



Measured memory_bytes: 3268
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=1e5+1e2;
const int inf=0x3f3f3f3f;
int n,N;
ll nn;
ll Sum;
int a[maxn],b[maxn],s[maxn],sum[maxn];

inline void file() {
	freopen("ARC101D.in","r",stdin);
	freopen("ARC101D.out","w",stdout);
}

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) { if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) { x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

inline void solve(int l,int r) {
	if (l==r) return ;
	int mid=(l+r)/2;
	solve(l,mid); solve(mid+1,r);
	int i=l,j=mid+1,p=l;
	while (i<=mid && j<=r) {
		if (sum[i]<sum[j]) {
			Sum+=1ll*(r-j+1); s[p++]=sum[i++];
		}
		else s[p++]=sum[j++];
	}
	while (i<=mid) s[p++]=sum[i++];
	while (j<=r) s[p++]=sum[j++];
	For (i,l,r) sum[i]=s[i];
}

inline bool check(int k) {
	sum[0]=0;
	For (i,1,n) {
		int val=0;
		if (a[i]<=k) val=1;
		else val=-1;
//		cout << val << " " ;
		sum[i]=sum[i-1]+val;
	}
//	cout << endl;
//	For (i,0,n) cout << sum[i] << " "; cout << endl;
	Sum=0;
	solve(0,n);
//	For (i,0,n) cout << sum[i] << " "; cout << endl;
//	cout << "Sum=" << Sum << endl;
	if (nn<=Sum) return 1;
	return 0;
}

int main() {
//	file();
	n=read(); nn=1ll*n*(n+1)/2; nn=nn/2+1;
	For (i,1,n) a[i]=read(),b[i]=a[i];
	sort(b+1,b+n+1); N=unique(b+1,b+n+1)-(b+1);
	For (i,1,n) a[i]=lower_bound(b+1,b+N+1,a[i])-b;
/*	cout << N << endl;
	For (i,1,n) cout << a[i] << " " ; cout << endl;
	For (i,1,N) {
		cout << "k=" << b[i] << endl;
		cout << check(i) << endl;
	}*/
	int Ans=inf;
	int l=0,r=N,mid;
	while (l<=r) {
		mid=(l+r)/2;
//		cerr << l << " " << r << " " << mid << endl;
		if (check(mid)) chkmin(Ans,mid),r=mid-1;
		else l=mid+1;
	}
//	cout << Ans << endl;
	printf("%d",b[Ans]);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int t;
        int n;
        int i;

        for (i = 0; i < 4; i++) {
            t = sc.nextInt();
            n = sc.nextInt();
            if(t == 1){
                System.out.println(6000 * n);
            }
            else if (t == 2) {
                System.out.println(4000 * n);
            }
            else if (t == 3) {
                System.out.println(3000 * n);
            }
            else if (t == 4) {
                System.out.println(2000 * n);
            }
        }

    }
}



Measured memory_bytes: 26148
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M, K;
ll f[200001], s[200001], t;

ll pw(ll x, int y) {
	ll a = 1;
	while (y) {
		if (y & 1) {
			a = a*x%mod;
		}
		x = x*x%mod;
		y /= 2;
	}
	return a;
}

ll modinv(ll x) {
	return pw(x, mod - 2);
}

ll ncr(ll n, ll r) {
	return f[n]*modinv(f[r]*f[n-r]%mod)%mod;
}

int main() {
	cin >> N >> M >> K;
	f[0] = 1;
	for (int i = 1; i <= 200000; ++i) {
		f[i] = f[i - 1] * i%mod;
	}
	for (int i = 1; i <= 200000; ++i) {
		s[i] = s[i - 1] + M*i;
		s[i] %= mod;
	}
	for (int i = 0; i < N; ++i) {
		t += (s[N - 1 - i] + s[i])*M;
		t %= mod;
	}
	for (int i = 1; i <= 200000; ++i) {
		s[i] = s[i - 1] + N*i;
		s[i] %= mod;
	}
	for (int i = 0; i < M; ++i) {
		t += (s[M - 1 - i] + s[i])*N;
		t %= mod;
	}
	t *= modinv(2);
	t %= mod;
	cout << t*ncr(N*M - 2, K - 2) % mod << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(1e5) + 17;

int a, b, c, x, y;

bool read() {
    if (!(cin >> a >> b >> c >> x >> y))
        return false;

    return true;
}

void solve() {
    int res = 0;

    if (a + b >= 2 * c) {
        int t = min(x, y);
        res = t * 2 * c;
        x -= t;
        y -= t;
    }

    if (x > 0) {
        if (2 * c < a)
            res += 2 * c * x;
        else
            res += a * x;
    }

    if (y > 0) {
        if (2 * c < b)
            res += 2 * c * y;
        else
            res += b * y;
    }

    cout << res << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

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


    Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();

int[] nums;

nums = new int[3];

nums[0]=a;

nums[1]=b;

nums[2]=c;


Arrays.sort(nums);


System.out.println(nums[0]+" "+nums[1]+" "+nums[2]);
  }
}


Measured memory_bytes: 26252
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;
struct gragh{
	int V,E;
	vector<vector<pair<int,int>>> edge; //edge[from][i] ={to,cost}
	//only for 0-indexed 
	void init(int v,int e,int *from,int *to,int *cost){
		edge.resize(0);	V=v;E=e;	pair<int,int>p;
		for(int i=0;i<e;i++){
			//if(edge.size()<=from[i])edge.resize(from[i]+1);
			edge.resize(v);
			p.first=to[i];	p.second=cost[i];	edge[from[i]].push_back(p);
			p.first=from[i]; p.second=cost[i];	edge[to[i]].push_back(p);
		} }
	int dijkstra(int start,int goal){
		int done[V];	for(int i=0;i<V;i++)done[i]=0;	done[start]=1;
		int vertex[V];	for(int i=0;i<V;i++)vertex[i]=inf;	vertex[start]=0;
		queue<int> que;	que.push(start);
		int from, to, cost;
		while(que.size()!=0){
			from=que.front();
			for(int i=0; i<edge[from].size(); i++){
				to=edge[from][i].first;	cost=edge[from][i].second;
				if( vertex[to]>vertex[from]+cost){
					vertex[to]=vertex[from]+cost;
					que.push(to);
				}
			}
			que.pop();
		}
		return vertex[goal];	}
	};
	
	
int main(){
	int n, m; cin>>n>>m;
	int a[m], b[m];	for(int i=0;i<m;i++)cin>>a[i]>>b[i];
	for(int i=0;i<m;i++){ a[i]--; b[i]--; }
	gragh g;
	int a2[m-1], b2[m-1], c[m-1];
	int ans=0;
	for(int i=0; i<m; i++){
		for(int j=0; j<m; j++){
			if(i>j){a2[j]=a[j]; b2[j]=b[j]; c[j]=1; }
			if(i<j){a2[j-1]=a[j]; b2[j-1]=b[j]; c[j-1]=1;}
		}

		g.init(n,m-1,a2,b2,c);
		
		for(int j=0; j<n; j++){
		for(int k=j+1; k<n; k++){
			if(g.dijkstra(j,k)==inf){ ans++; k=n; j=n; }
		}
		}
	}

	cout<<ans<<endl;

	return 0;
}



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

void solve() {
    int N , M;
    cin >>  N >> M;
    int sum = 0;
    int a[N];
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    double qm = (double)sum / (4.0 * M);
    int x = 0;
    for (int i = 0; i < N; ++i) {
        if (qm <= a[i]) x++;
    }

    if (M <= x) cout << "Yes";
    else cout << "No";
    cout << endl;
}

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


Measured memory_bytes: 256
from heapq import heappush, heappop

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = sorted((a + b for a in A for b in B), reverse=True)[:min(X*Y, K)]
C.sort()

heap = []
min_sum = float('inf')
for ab in AB:
    if len(heap) < K:
        for c in C:
            heappush(heap, -(ab + c))
            min_sum = min(min_sum, ab + c)
    else:
        left = 0
        right = Z
        while left < right:
            mid = (left+right) // 2
            n = ab + C[mid]
            if n >= min_sum:
                left = mid + 1
            else:
                right = mid
            min_sum = min(min_sum, n)
        for c in C[:right]:
            heappush(heap, -(ab + c))


for i in range(K):
    print(-heappop(heap))


Measured memory_bytes: 148140
n = int(input())
ans = []
keta = n//26
while n != 0:
    i = n%26
    if i == 0:
        o = 'z'
        n = n//26 -1
    else:
        o = chr(n%26 +96)
        n //= 26
    ans.append(o)
ans = reversed(ans)
print(''.join(ans))

Measured memory_bytes: 8984
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int D = int.Parse(input[1]);

        List<List<int>> X = new List<List<int>>();
        int count = 0;

        for(int i = 0; i < N; i++) {
            string[] strPoint = Console.ReadLine().Split(' ');
            List<int> y = new List<int>();

            foreach(string item in strPoint) {
                y.Add(int.Parse(item));
            }

            for(int j = 0; j < X.Count; j++) {
                
                double sum = 0;
            
                for(int k = 0; k < D; k++) {
                
                    sum += Math.Pow((double)(X[j][k] - y[k]), 2);
                
                }

                double sqrt = Math.Sqrt(sum);

                if((int)sqrt == sqrt) {
                    count++;
                }

            }
            
            X.Add(y);

        }

        Console.WriteLine(count);

    }
}

Measured memory_bytes: 11220
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

bool ask(ll x){
	cout<<"? "<<x<<endl; cout<<flush;
	string s;
	cin>>s;
	return s[0]=='Y';
}

void res(ll x){
	cout<<"! "<<x<<endl;
}

int main(){
	ll s = 1e9, r = s-1;
	ll t = 0;
	rep(i, 9){
		t *= 10;
		ll lb = -1, ub = 9; // (lb, ub]
		while(ub-lb>1){
			ll md = (lb+ub+1)/2;
			ll x = (t+md)*s+r;
			if(ask(x)) ub = md;
			else lb = md;
		}
		if(i>0) t += ub;
		else t += max(ub, 1LL);
	}
	while(t%10==0) t /= 10;
	ll tt = t, t10 = t%10;
	rep(i, 10){
		if(t10!=9){
			if(ask(t+1)) break;
		} else {
			if(!ask(t-1)){
				t /= 10;
				break;
			}
		}
		t *= 10;
	}
	res(t);
	return 0;
}


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

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> V(n, 0);

    for(int i = 1; i <= n-1; ++i) {
        for(int j = i+1; j <= n; ++j) {
            int d = min(j-i, abs(x-i) + 1 + abs(y-j));
            // int d = min(j-i, x-i + 1 + abs(y-j));
            V[d]++;
                // cout << d << "\n";
            
            // else {
            //     int d = min(j-i, abs(x-i) + 1 + abs(y-j));
            //     V[d]++;
            // }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    int n;
    cin>>n;
    int k=n%10;
    if(k==2||k==4||k==5||k==7||k==9)cout<<"hon";
    else if(k==0||k==1||k==6||k==8)cout<<"pon";
    else cout<<"bon";
    return 0;
}

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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define inf (long long int) 1e18
#define vl vector<ll> 
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define mod 1000000007
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

    ll k;
    cin>>k;
    ll e=k/2;
    ll o=k-e;
    ll ans=e*o;
    cout<<ans<<endl;

}


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

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

Measured memory_bytes: 764
// D - All Your Paths are Different Lengths

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

struct Edge {
	int from;
	int to;
	int len;
};

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

	vector<Edge> edges;

	int N = 0; // 頂点数
	int M = 0; // 辺数
	int k = L;
	while(k > 0) {
		N++;
		k /= 2;
	}

	for (int i=1; i<N; i++) {
		edges.push_back(Edge{i, i+1, pow(2, i-1)});
		edges.push_back(Edge{i, i+1, 0});
		M += 2;
	}

	int p = pow(2, N-1);
	int m = L % p;
	while (m > 0) {
		for (int k=0;;k++) {
			int q = pow(2, k);
			if (q * 2 > m) {
				edges.push_back(Edge{k+1, N, p});
				p += q;
				m -= q;
				M++;
				break;
			}
		}
	}

	cout << N << " " << M << endl;
	for (Edge e : edges) {
		cout << e.from << " " << e.to << " " << e.len << endl;
	}

	return 0;
}

Measured memory_bytes: 4076
a,b,x=map(int,input().split())
import math
 
if x == a**2*b/2:
  print(float(90)-math.degrees(math.atan(a/b)))
elif x == a*a*b:
  print(0)
elif x < a**2*b/2:
  print(float(90)-math.degrees(math.atan(2*x/a/b/b)))
else:
  print(float(90)-math.degrees(math.atan((a*a*b-x)**(-1)*a**3/2)))

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
    return in % Mod;
}

int n, m, b[100005];
ll a[100005];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> n >> m;

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

    std::priority_queue<std::pair<ll, int>> que;
    for (int i = 0; i < m; ++i) {
        int b, c;
        std::cin >> b >> c;

        que.emplace(c, b);
    }

    std::sort(a, a + n);
    for (int i = 0; i < n; ++i) {
        if (!que.empty() && a[i] < que.top().first) {
            auto p = que.top();
            que.pop();

            a[i] = p.first;
            if (p.second > 1)
                que.emplace(p.first, p.second - 1);
        }
        else
            break;
    }

    ll ans = 0;
    for (int i = 0; i < n; ++i)
        ans += a[i];

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t n, k;
  cin >> n >> k;
  vector<int64_t> a(n);
  for(int i=0; i<n; i++)
    cin >> a[i];
  vector<int64_t> v;
  set<int64_t> s;
  v.push_back(1);
  s.insert(1);
  int64_t tmp=1;
  while(1){
    tmp=a[tmp-1];
    if(s.count(tmp))
      break;
    v.push_back(tmp);
    s.insert(tmp);
  }
  int64_t i;
  for(i=0; ; i++){
    if(v[i]==tmp)
      break;
  }
  if(k<v.size()){
    cout << v[k]<<endl;
    return 0;
  }
  k-=i;
  k%=(v.size()-i);
  cout << v[k+i] << endl;
  return 0;
}

Measured memory_bytes: 15360