akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const i64 inf = (i64)1.05e17;
const i64 mod = (i64)1e9 + 7;

typedef pair<int, i64> edge;
typedef vector<edge> vertex;
typedef vector<vertex> graph;

vector<i64> compute_dist(int s, graph& g)
{
	vector<i64> dist(g.size(), inf);

	priority_queue<pair<i64,int>> q;
	q.push({-0, s});

	while(!q.empty()) {

		i64 d = -q.top().first;
		int v = q.top().second;
		q.pop();

		if(dist[v] < inf)
			continue;
		dist[v] = d;

		for(auto& e : g[v]) {
			int w = e.first;
			i64 wd = d + e.second;
			if(dist[w] == inf)
				q.push({-wd, w});
		}
	}

	return dist;
}

vector<i64> count_comb(int s, vector<i64>& dist, graph& g)
{
	vector<i64> comb(g.size(), -1);
	comb[s] = 1;

	priority_queue<pair<i64,int>> q;
	q.push({-dist[s], s});

	while(!q.empty()) {

		int v = q.top().second;
		q.pop();

		if(comb[v] > -1 && v != s)
			continue;
		if(v != s)
			comb[v] = 0;

		for(auto& e : g[v]) {

			int w = e.first;
			i64 d = e.second;

			if(comb[w] == -1)
				q.push({-dist[w], w});

			if(dist[w] + d == dist[v])
				comb[v] += comb[w];
		}

		comb[v] = comb[v] % mod;
	}

	return comb;
}

int main()
{
	int n, m;
	int s, t;

	scanf("%d%d%d%d", &n, &m, &s, &t);
	s -= 1;
	t -= 1;

	graph g(n);

	for(int i = 0; i < m; ++i) {
		int u, v, d;
		scanf("%d%d%d", &u, &v, &d);
		u -= 1;
		v -= 1;
		i64 d2 = d * 2;
		g[u].push_back({v, d2});
		g[v].push_back({u, d2});
	}

	vector<i64> s_dist = compute_dist(s, g);
	vector<i64> t_dist = compute_dist(t, g);
	vector<i64> s_comb = count_comb(s, s_dist, g);
	vector<i64> t_comb = count_comb(t, t_dist, g);

	i64 col = 0;
	i64 half = s_dist[t] / 2;
	i64 full = s_dist[t];

	for(int v = 0; v < n; ++v) {


		if(s_dist[v] == half && t_dist[v] == half) {

			// col at vertex v

			i64 sx = s_comb[v];
			i64 tx = t_comb[v];
			i64 x = sx * tx % mod;
			i64 x2 = x * x % mod;
			col = (col + x2) % mod;

			//printf("col at vertex %d: %lld\n", v, x2);
		}

		for(auto& e : g[v]) {

			int w = e.first;
			i64 d = e.second;

			if(s_dist[v] + d + t_dist[w] != full)
				continue;
			if(s_dist[v] >= half || t_dist[w] >= half)
				continue;

			// col at s -> v -> w -> t

			i64 sx = s_comb[v];
			i64 tx = t_comb[w];
			i64 x = sx * tx % mod;
			i64 x2 = x * x % mod;
			col = (col + x2) % mod;

			//printf("col at edge %d -> %d: %lld\n", v, w, x2);
		}
	}

	i64 total = s_comb[t] * s_comb[t] % mod;
	i64 ans = (total + mod - col) % mod;

	printf("%lld\n", ans);

	/*for(int v = 0; v < n; ++v) {
		printf("%d: %lld %lld | %lld %lld\n", v, s_dist[v], t_dist[v], s_comb[v], t_comb[v]);
	}*/

	return 0;
}

/* waffle */


Measured memory_bytes: 18988
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<stack>
#include<tuple>
using namespace std;
#define INF 1100000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

ll fact[10];

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

    ll x[10],y[10];
    for(int i=0;i<N;i++){
        cin>>x[i]>>y[i];
    }
    double sum=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            sum+=sqrt( (x[j]-x[i])*(x[j]-x[i]) + ( (y[j]-y[i])*(y[j]-y[i]) ) );
        }
    }
    sum*=2;
    printf("%.10lf\n",sum/N);
}



Measured memory_bytes: 256
function Main(input) {
   
    var N = input[0].trim();

//	console.log("%s",N);

  	var result = N;
  	var sosu = 9;
  
    do{
      
      if(N % sosu == 0){
         result = N / sosu;
        if(1<=result && result <=9){      
	        console.log("Yes");
            return;
        }
      }
      sosu--;

    }while(sosu> 0)

    console.log("No");

    //console.log("%s",result == 1 ? "YES":"NO");

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

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

using namespace std;

typedef long long ll;

map<pair<string, string>, int> k[2];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    string s[2] = { "", "" };
    for (int i = 0; i < n; ++i) {
        char c;
        cin >> c;
        s[0] += c;
    }
    for (int i = 0; i < n; ++i) {
        char c;
        cin >> c;
        s[1] = c + s[1];
    }
    for (int q = 0; q < 2; ++q) {
        for (int mask = 0; mask < (1 << n); ++mask) {
            string t1 = "", t2 = "";
            for (int i = 0; i < n; ++i) {
                if (mask & (1 << i)) {
                    t1 += s[q][i];
                } else {
                    t2 += s[q][i];
                }
            }
            ++k[q][make_pair(t1, t2)];
        }
    }
    ll ans = 0;
    for (auto p : k[0]) {
        if (k[1].count(p.first)) {
            ans += ll(p.second) * k[1][p.first];
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 91904
#include <iostream>
#include <vector>

using namespace std;

#define MOD 1000000007

int main() {
	int n; cin >> n;
	vector<int> a(n), cnt(n);
	for (auto& e : a) cin >> e;
	long long ans = 1;
	for (int i = 0; i < n; ++i) {
		if (a[i] == 0) (ans *= 3 - cnt[a[i]]) %= MOD;
		else (ans *= cnt[a[i] - 1] - cnt[a[i]]) %= MOD;
		cnt[a[i]]++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        int n = sc.nextInt();

        while (n != 0) {

            int[] score = new int[n];

            double ave = 0.0;
            double val = 0.0;

            for (int i = 0; i < n; i++) {
                score[i] = sc.nextInt();
                ave += score[i];
            }
            ave /= n * 1.0;

            for(int i = 0; i < n; i++)
                val += (score[i] - ave) *  (score[i] - ave);

            val /= n *1.0;

            double sgm = Math.sqrt(val);

            System.out.printf("%f\n", sgm);

            n = sc.nextInt();
        }

        sc.close();
    }
}



Measured memory_bytes: 31856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=len(s);
    map<char,int> cnt;
    rep(i,n) cnt[s[i]]++;
    vector<ll> now;
    for(auto itr:cnt) now.push_back(itr.second);
    while(len(now)!=3) now.push_back(0);
    sort(begin(now),end(now));
    if(now[2]-now[0]<=1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int ans = N;
  for (int i = 0; i + 1 < N; i++) {
    if (S.at(i) != S.at(i + 1)) ans = min(ans, max(i + 1, N - i - 1));
  }
  cout << ans << "\n";
}

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

int main() {
  int n, a[3];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3108
import sys
sys.setrecursionlimit(10**8)

N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(M):
  a,b = map(int, input().split())
  edge[a-1].append(b-1)

def dfs(v):
  if len(edge[v])==0:
    return 0
  ans = 0
  for u in edge[v]:
    if longest[u]==-1:
      longest[u]=dfs(u)
    ans = max(ans,longest[u]+1)
  return ans

longest = [-1]*N
for i in range(N):
  if longest[i]==-1:
    longest[i] = dfs(i)
ans = max(longest)
print(ans)

Measured memory_bytes: 117688
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int n;
int x[200001];
vector<int> a;
int main()
{
	cin >> n;
	REP(i, 0, n) {
		cin >> x[i];
		a.emplace_back(x[i]);
	}
	sort(a.begin(), a.end());

	REP(i, 0, n) {
		if (x[i] <= a[n / 2 - 1]) cout << a[n / 2] << endl;
		else cout << a[n / 2 - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <vector>
#define N 100005 ///////////////////////////////////////////
using namespace std;

int n, m;
bool v[N];
vector<int> a[N], b, ans;
void f(int p) {
	int i;
	if (v[p]) return;
	v[p] = 1;
	b.push_back(p);
	for (i = 0; i < a[p].size(); i++) {
		if (!v[a[p][i]]) {f(a[p][i]); break;}
	}
}
int main()
{
	int i, t1, t2;
	cin >> n >> m;
	while (m--) {
		scanf ("%d %d", &t1, &t2);
		a[t1].push_back(t2);
		a[t2].push_back(t1);
	}
	f(1);
	for (i = 0; i < b.size(); i++) ans.push_back(b[i]);
	b.clear();
	v[1] = 0;
	f(1);
	cout << ans.size() + b.size() - 1 << endl;
	for (i = b.size() - 1; i >= 0; i--) printf("%d ", b[i]);
	for (i = 1; i < ans.size(); i++) {
		printf("%d ", ans[i]);
	}
    return 0;
}


Measured memory_bytes: 10104
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())

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

  int a[200000];
	int N; cin >> N;
	int K; cin >> K;
	map<int, int> mp;

	REP(i, N) {
		cin >> a[i];
		mp[a[i]]++;
  }

  if(K >= mp.size()) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> counts(mp.size());
  int index = 0;
  for (auto p: mp) {
    counts[index] = p.second;
    index++;
  }
  sort(counts.begin(), counts.end());

  int ans = 0;
  REP(i, mp.size() - K) {
    ans += counts[i];
  }

  cout << ans << endl;
  return 0;
}


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

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

int main(){
    ll n,k;
    cin>>n>>k;
    ll a=0;
    while(n>0){
        n/=k; a++;
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	// your code goes here
	
	    
    int A,B,C;
    
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    
    
    if(A<B&&B<C){
        printf("No");
        
    }
    if(A<C&&C<B){
        printf ("Yes");
        
        
    }
    if(C<B&&B<A){
        printf("No");
        
    
    }
    if(B<C&&C<A){
      printf("Yes");
     
      
    
    }
    if(B<A&&A<C){
       printf("No");
       
        
        
    }
    if(C<A&&A<B){
        printf("No");
        
    }
	
	
	return 0;
}


Measured memory_bytes: 128
x, y = map(int, input().split(" "))

def score(n):
    if n == 3:
        return 100000
    elif n == 2:
        return 200000
    elif n == 1:
        return 300000
    else:
        return 0

if x == y == 1:
    print("1000000")
else:
    print(str(score(x) + score(y)))



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

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    FASTIO
    string s;
    cin >> s;
    int n = s.size();
    int suffix = 0;
    int power_of_ten = 1;
    vector<int> cnt(2019,0);
    cnt[0]++;
    long long ans = 0;
    for(int i=n-1; i>=0; i--)
    {
        int d = s[i]-'0';
        suffix = (suffix + power_of_ten*d)%2019;
        power_of_ten = 10*power_of_ten%2019;
        ans += cnt[suffix];
        cnt[suffix]++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node {
	int p, l, r;
};

struct Node t[MAX];
int n;

void preParse(int u)
{
	if(u == NIL)
	{
		return;
	}
	printf(" %d", u);
	preParse(t[u].l);
	preParse(t[u].r);
}

void inParse(int u)
{
	if(u == NIL)
	{
		return;
	}
	inParse(t[u].l);
	printf(" %d", u);
	inParse(t[u].r);
}

void postParse(int u)
{
	if(u == NIL)
	{
		return;
	}
	postParse(t[u].l);
	postParse(t[u].r);
	printf(" %d", u);
}

int main()
{
	int i, v, l, r, root;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		t[i].p = NIL;
	}
	
	for(i = 0; i < n; i++)
	{
		scanf("%d %d %d", &v, &l, &r);
		t[v].l = l;
		t[v].r = r;
		if(l != NIL) t[l].p = v;
		if(r != NIL) t[r].p = v;
	}
	
	for(i = 0; i < n; i++)
	{
		if(t[i].p == NIL)
		{
			root = i;
		}
	}
	
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    vector<ll> res={1,2,4,8,16,32,64};
    rep(i,7){
        if(res[6-i]<=n){
            cout<<res[6-i]<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import copy

n = int(input())
c = [[s[0], int(s[1])] for s in input().split()]

# BubbleSort
bub_c = copy.deepcopy(c)
for i in range(n):
    for j in range(n-1, i, -1):
        if bub_c[j][1] < bub_c[j-1][1]:
            bub_c[j], bub_c[j-1] = bub_c[j-1], bub_c[j]

# SelectionSort
sel_c = copy.deepcopy(c)
for i in range(n):
    minj = i
    for j in range(i, n):
        if sel_c[j][1] < sel_c[minj][1]:
            minj = j
    sel_c[i], sel_c[minj] = sel_c[minj], sel_c[i]

shaped_bub = " ".join([c[0] + str(c[1]) for c in bub_c])
shaped_sel = " ".join([c[0] + str(c[1]) for c in sel_c])
print(shaped_bub, "Stable", sep="\n")
if [b[0] for b in bub_c] == [b[0] for b in sel_c]:
    print(shaped_sel, "Stable", sep="\n")
else:
    print(shaped_sel, "Not stable", sep="\n")


Measured memory_bytes: 6352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        long n = stdin.nextLong();
        long m = stdin.nextLong();
        
        long x = Math.min(n, m);
        long y = Math.max(n, m);
        if (x == 1) {
            if (y == 1) {
                System.out.println(1);
            } else {
                System.out.println(y - 2);
            }
        } else {
            System.out.println((x - 2) * (y - 2));
        }
    }
}


Measured memory_bytes: 23764
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

int main(){
	static char s[1000001]; scanf("%s",s);

	vector< pair<char,int> > JOI;
	for(int i=0,p=0;;i++){
		if(i>0 && s[i-1]!=s[i]){
			JOI.push_back(make_pair(s[p],i-p));
			p=i;
		}
		if(s[i]=='\0') break;
	}

	int ans=0;
	rep(i,(int)JOI.size()-2){
		if(JOI[i].first=='J' && JOI[i+1].first=='O' && JOI[i+2].first=='I'
		&& JOI[i].second>=JOI[i+1].second && JOI[i+1].second<=JOI[i+2].second){
			ans=max(ans,JOI[i+1].second);
		}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 0
N,Q = map(int, input().split())
S = input()

a = [0]*N

for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        a[i] = 1

s = [0]*(N+1)
for i in range(N):
    s[i+1] = s[i] + a[i]

for i in range(Q):
    l,r = map(int, input().split())
    ans = s[r-1]-s[l-1]
    print(ans)

Measured memory_bytes: 53080
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main(void) {
	int n;
	int ts = 0, hs = 0;
	char t[110], h[110];
	cin >> n;
	rep(i,n) {
		cin >> t >> h;
		if(strcmp(t, h) > 0) ts += 3;
		else if(strcmp(t, h) < 0) hs += 3;
		else ts += 1, hs += 1;
	}
	cout << ts << " " << hs << endl;
	
}



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

vector<pll>par(2e5+10);
void init(ll n) {
  for(ll i=0;i<n;i++) {
    par[i]=pll(i,i);
  }
}

ll root(ll x,ll flag) {
  if(flag) {
    if(par[x].first==x) {
      return x;
    }
    else {
      return par[x].first=root(par[x].first,flag);
    }
  }
  else {
    if(par[x].second==x) {
      return x;
    }
    else {
      return par[x].second=root(par[x].second,flag);
    }
  }
}

bool same(ll x, ll y,ll flag) {
  return root(x,flag)==root(y,flag);
}

void unite(ll x, ll y,ll flag) {
  if(same(x,y,flag)) return;
  if(flag) {
    par[root(x,flag)].first=root(y,flag);
  }
  else {
    par[root(x,flag)].second=root(y,flag);
  }
}

int main() {
  ll n,k,l;
  cin >> n >> k >> l;
  init(n);
  for(ll i=0;i<k;i++) {
    ll p,q;
    cin >> p >> q;
    p--;
    q--;
    unite(p,q,1);
  }
  for(ll i=0;i<l;i++) {
    ll p,q;
    cin >> p >> q;
    p--;
    q--;
    unite(p,q,0);
  }
  map<pll,ll> num;
  for(ll i=0;i<n;i++) {
    num[pll(root(i,1),root(i,0))]++;
  }
  for(ll i=0;i<n;i++) {
    cout << num[pll(root(i,1),root(i,0))];
    if(i!=n-1) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 15232
#include <cstdio>

using namespace std;

int main() {
	double a, b, c, d, e, f;
	double _b, _c, _e, _f;
	double x, y;

	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
	    _b = b * d;
	    _c = c * d;
	    _e = e * a;
	    _f = f * a;
	    
	    y = (_c - _f) / (_b - _e);
	    x = (c - b * y) / a;
	    
	    printf("%.3f %.3f\n", x, y);
	}
	
	return 0;
}

Measured memory_bytes: 1076
use proconio::input;
use std::cmp::{max, min};

const MAX_L: usize = 100_000;
const BASE_SIZE: usize = 1 << 10;

fn main() {
    input! {
        n: usize,
        vw: [(u32, u32); n],
        q: usize,
        ul: [(usize, usize); q],
    }
    let dp = make_dp(&vw);
    for (u, l) in ul {
        println!("{}", calc(&dp, &vw, u - 1, l));
    }
}

fn make_dp(vw: &Vec<(u32, u32)>) -> Vec<Vec<u32>> {
    let mut dp = Vec::<Vec<u32>>::new();

    dp.push(
        (0..=MAX_L as u32)
        .map(|i| if i < vw[0].1 { 0 } else { vw[0].0 })
        .collect()
    );

    let n = min(vw.len(), BASE_SIZE - 1);
    for c in 1..n {
        let p = (c - 1) / 2;
        dp.push(
            (0..=MAX_L)
            .map(|i| {
                let w = vw[c].1 as usize;
                let v = if i < w { 0 } else { dp[p][i - w] + vw[c].0 };
                max(dp[p][i], v)
            })
            .collect()
        );
    }

    dp
}

fn calc(
    dp: &Vec<Vec<u32>>,
    vw: &Vec<(u32, u32)>,
    u: usize, 
    l: usize,
) -> u32 {
    if u < dp.len() {
        dp[u][l]
    } else {
        let p = (u - 1) / 2;
        let w = vw[u].1 as usize;
        let pv1 = calc(dp, vw, p, l);
        let pv2 = if l < w { 0 } else { calc(dp, vw, p, l - w) + vw[u].0 };
        max(pv1, pv2)
    }
}


Measured memory_bytes: 410892
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n, m, d = f.read_int_list()

    if d == 0:
        return 1.0*n*(m-1)/n**2
    else:
        return 1.0*(n-d)*2*(m-1)/n**2


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 4616
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
vector<int> nex[214514];
int bg[214514],pa[214514];
int modpow(int x,int k){
	// x ^ k mod inf
	int res = 1;
	while(k>0){
		if(k%2)res = (res*x)%inf;
		x = (x*x)%inf;
		k >>=1;
	}
	return res;
}
void dfs(int pos, int par){
	int res = 1;
	for(int i=0;i<nex[pos].size();i++){
		int nx = nex[pos][i];
		if( nx != par ){
			pa[nx] = pos;
			dfs( nx, pos );
			res += bg[nx];
		}
	}
	bg[pos] = res;
	return;
}
signed main(){
	int n;
	int hf = modpow( 2, inf-2 );
	cin>>n;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		nex[x].pb(y);
		nex[y].pb(x);
	}
	dfs(1,0);
	int ans = 0;
	for(int i=1;i<=n;i++){
		vector<int> sz;
		int ps = n-1;
		for(int j=0;j<nex[i].size();j++){
			int nx = nex[i][j];
			if( nx != pa[i] ){
				sz.pb(bg[nx]);
				ps -= bg[nx];
			}
		}
		if(ps!=0)sz.pb(ps);
		int res = 1;
		res += ( inf - modpow( hf, n-1 ) );
		res %= inf;
		for(int j=0;j<sz.size();j++){
			int prod = modpow( hf, n-1-sz[j] ) * ( 1 + inf - modpow(hf,sz[j]) );
			prod %= inf;
			res += ( inf - prod );
			res %= inf;
		}
		res *= hf;
		res %= inf;
		ans += res;
		ans %= inf;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 26240
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
int a[4];
int main(){
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	int ans = 0;
	for(int i = 1; i < 3; i++){
		ans += abs(a[i+1]-a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace aizu
{
    class OnlineJudge
    {
        const int Max = 39;
        static void Main()
        {
            string input;
            while((input = Console.ReadLine()) != null) {
                int count = int.Parse(input) % Max;
                Console.WriteLine("3C{0:00}", count == 0 ? Max : count);
            }
        }
    }
}

Measured memory_bytes: 5744
#include<stdio.h>
#include<stdlib.h>

int main(){
	int N,M,C,i,j,s,a=0;
	int *B,*A;
	scanf("%d %d %d",&N,&M,&C);
	B=(int*)malloc(sizeof(int)*N);
	A=(int*)malloc(sizeof(int)*N*M);
	for(i=0;i<M;i++){
		scanf("%d",&B[i]);
	}
	for(i=0;i<N*M;i++){
		scanf("%d",&A[i]);
	}
	for(i=0;i<N;i++){
		s=0;
		for(j=0;j<M;j++){
			s+=A[i*M+j]*B[j];
		}
		if(s+C>0)a++;
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  int n;
  double a[110];
  cin>>n;
  rep(i,n){
    double b;
    cin>>b;
    a[i]=1/b;
  }

  double sum=0;
  rep(i,n){
    //cout<<a[i]<<endl;
    sum+=a[i];
  }

  printf("%.10lf\n",1/sum);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int l = A + B;
	int r = C + D;
	
	if (l > r) puts("Left");
	else if (l < r) puts("Right");
	else puts("Balanced");
	
	return 0;
}

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

int main(){
	int n,m;
	string s;
	vector <int> ans;
	cin>>n>>m>>s;
	for(int i=n;i>0;){
		for(int j=m;j>=0;j--){
			if(j==0){
				cout<<-1<<endl;
				return 0;
			}
			if(i>=j){
				if(s[i-j]=='0'){
					ans.push_back(j);
					i-=j;
					break;
				}
			}
		}
	}
	for(int i=ans.size()-1;i>=0;i--){
		cout<<ans[i];
		if(i==0){
			cout<<endl;
		}else{
			cout<<' ';
		}
	}
	return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
int lena,lenb;
char a[105],b[105];
bool cmp1(char x,char y)
{
	return (int)x<(int)y;
}
bool cmp2(char x,char y)
{
	return (int)x>(int)y;
}
int main()
{
	gets(a);
	gets(b);
	lena=strlen(a);
	lenb=strlen(b);
	sort(a,a+lena,cmp1);
	sort(b,b+lenb,cmp2);
	for(int i=0;i<max(lena,lenb);i++)
	{
		if(a[i]<b[i])
		{
			cout<<"Yes\n";
			return 0;
		}
		else if(a[i]>b[i])
		{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 998244353

int main(int argc, char const *argv[])
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a) << endl;
}

Measured memory_bytes: 256
// #define DEBUG

#include <bits/stdc++.h>
#define x first
#define y second
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define out(t, a) copy(all(a), ostream_iterator<t>(cout, " ")); cout << "\n";
#define int long long

using namespace std;

void set_program() {
	#ifdef DEBUG
		freopen ("test.in", "r", stdin);
		freopen ("test.out", "w", stdout);
		// freopen ("test.in", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pt;

const int ALF = 26;
const int LOGN = 20;
const int MOD = 998244353;
const int INF = 1e9;
const int MAXN = 1e5;

void solve() {
	string s;
	cin >> s;
	cout << (s[2] == s[3] && s[4] == s[5] ? "Yes\n" : "No\n");
}

signed main() {
	set_program();
	int t;
	#ifdef DEBUG
		// cin >> t;
		t = 1;
	#else
		// cin >> t;
		t = 1;
	#endif
	for (int num_test = 1; num_test <= t; ++num_test) {
		solve();
		cout << "\n";
	}
 	return 0;
}

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

int main(){
  int N;
  cin >> N;
  if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9){
    cout << "hon" << endl;
  }else if(N%10==0||N%10==1||N%10==6||N%10==8){
    cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }
      
}

Measured memory_bytes: 3640
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
       ll n,d;
       ll ans=0;
       cin>>n>>d;
       ll x[16][16];
       for(int i=1;i<=n;i++)
       {
            for(int j=1;j<=d;j++)
            	cin>>x[i][j];
       }
       for(int i=1;i<=n;i++)
       {
       	for(int j=i+1;j<=n;j++)
       	{
       		ll s=0;
       		for(int k=1;k<=d;k++)
       		{
               s+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
       		}
       		ll o=sqrt(s);
       		if(o*o==s)
       			ans++;
       	}
       }
       cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int cnt = 0;
int N;
int main(){
    cin >> N;
    int A[N], B[N], C[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(A, A + N);
    sort(C, C + N);
    ll ans = 0;
    for(int b = 0; b < N; b++){
        ll a = lower_bound(A, A + N, B[b]) - A;
        ll c = N - (upper_bound(C, C + N, B[b]) - C);
        ans += a * c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1536
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int a;
	cin>>a;

	cout<<(a+(a*a)+(a*a*a))<<endl;
}

Measured memory_bytes: 3604
# C Streamline
n,m = map(int,input().split())
Xs = list(map(int,input().split()))

if n >= m:
    print('0')
    exit()

Xs.sort()
XsDist = [b - a for a, b in zip(Xs, Xs[1:])]

XsDist.sort()
print(sum(XsDist[:m - n]))

Measured memory_bytes: 13968
#include <stdio.h>
int main(void){
    int n,i,j,k,l;
    int dice[24][6];
    int label[24][6]={{1,2,3,4,5,6},{1,3,5,2,4,6},{1,4,2,5,3,6},{1,5,4,3,2,6},{2,1,4,3,6,5},{2,3,1,6,4,5},
    {2,4,6,1,3,5},{2,6,3,4,1,5},{3,1,2,5,6,4},{3,2,6,1,5,4},{3,5,1,6,2,4},{3,6,5,2,1,4},{4,1,5,2,6,3},
    {4,2,1,6,5,3},{4,5,6,1,2,3},{4,6,2,5,1,3},{5,1,3,4,6,2},{5,3,6,1,4,2},{5,4,1,6,3,2},{5,6,4,3,1,2},
    {6,2,4,3,5,1},{6,3,2,5,4,1},{6,4,5,2,3,1},{6,5,3,4,2,1}};
    
    scanf("%d",&n);
    int dices[n][6];
    
    for(i=0;i<n;i++){
        for(j=0;j<6;j++) scanf("%d",&dices[i][j]);
    }
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            for(k=0;k<24;k++){
                for(l=0;l<6;l++) dice[k][l]=dices[j][label[k][l]-1];
            }
            for(k=0;k<24;k++){
                for(l=0;l<6;l++) {
                    if(dice[k][l]!=dices[i][l]) {
                        break;
                    }
                }
                if(l==6){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2056
import java.util.*;

public class Main

{    //f[i][j]=f[i][k-1]*f[k+1][j]+f[k][k];
	static long  gcd(long  x,long  y){
		if(y==0)return x;
		return gcd(y,x%y);
	}
    public static void main(String[] args)
	{
    	 Scanner in=new  Scanner(System.in);
    long a,b,c,d;
    int t=in.nextInt() ;
    while(t-->0) {
    a=in.nextLong();
    b=in.nextLong();
    c=in.nextLong();
    d=in.nextLong();
   	if(a<b||d<b)
   	{System.out.printf("No\n");
   	  continue;
   	}
   	if(c+1>=b)
   	{
   		System.out.printf("Yes\n");
   		continue;
   	}
   	long p=gcd(b,d);
   	if((a-c-1)/p-(a-b)/p>0)
   		System.out.printf("No\n");
   	else
   		System.out.printf("Yes\n");
   	//System.out.print(p);
   }

        
     }
 
}


Measured memory_bytes: 25672
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

void dfs(const vector<vector<pair<int64_t, int64_t>>>& links,
         vector<int64_t>& dist, int64_t current, int64_t parent) {
  for (auto p : links[current]) {
    auto v = p.first;
    auto d = p.second;
    if (v == parent) {
      continue;
    }

    dist[v] = dist[current] + d;
    dfs(links, dist, v, current);
  }
}

main() {
  int64_t n;
  cin >> n;

  vector<vector<pair<int64_t, int64_t>>> links(n);
  for (auto _ : irange(0L, n - 1)) {
    int64_t a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    links[a].emplace_back(b, c);
    links[b].emplace_back(a, c);
  }

  int64_t q, k;
  cin >> q >> k;
  --k;

  vector<int64_t> dist(n);
  dfs(links, dist, k, -1);

  for (auto _ : irange(0L, q)) {
    int64_t x, y;
    cin >> x >> y;
    --x;
    --y;

    cout << dist[y] + dist[x] << "\n";
  }
}


Measured memory_bytes: 17408
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		int mod = 1000000007;
		int N = GetInt();
		int M = GetInt();
		bool[] isBroken = new bool[N+1];
		for(int i = 0; i < M; i++)
			isBroken[GetInt()] = true;

		int[] dp = new int[N+1];
		dp[0] = 1;
		if(!isBroken[1])
			dp[1] = 1;
		for(int i = 2; i <= N; i++)
		{
			if(!isBroken[i-2])
				dp[i] = (dp[i] + dp[i-2]) % mod;

			if(!isBroken[i-1])
				dp[i] = (dp[i] + dp[i-1]) % mod;
		}

		Console.WriteLine(dp[N]);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 17336
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    vector<pii> sc;
    REP(i,m) {
        int s, c;
        cin >> s >> c;
        s--;
        sc.emplace_back(s,c);
    }

    int x = n == 1 ? 0 : pow(10,n-1);
    int e = pow(10,n);

    while(x < e) {
        string s = to_string(x);
        bool ok = true;
        REP(i,sc.size()) if (s[sc[i].first] != sc[i].second + '0') ok = false;
        if (ok) {
            OUT(s)
            return 0;
        }
        x++;
    }

    cout << -1 << '\n';

    return 0;
}

Measured memory_bytes: 256
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


k = I()
ans = -1
a = [0] * (k+1)
a[1] = 7 % k
for i in range(2, k+1):
    a[i] = (a[i-1]*10 + 7) % k

for i in range(1, k+1):
    if a[i] == 0:
        print(i)
        exit()
print(-1)


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

res = 1
maxi = 0
for i in range(1, N + 1):
    if i % 2 == 0:
        tmp = i
        cnt = 0
        while tmp % 2 == 0:
            cnt += 1
            tmp //= 2
        if maxi < cnt:
            res = i
            maxi = cnt

print(res)


Measured memory_bytes: 2940
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N,K = map(int,input().split())
V = [int(i) for i in input().split()]
#
# if N == 1:
#     print(max(0,V[0]))
#     exit()

ans = 0
for i in range(K): # 戻す数
    for j in range(K-i+1):
        if j <= N-(K-i-j):
            ans_list = V[:j]+V[N-(K-i-j):]
            ans_list.sort()
            tmp = sum(ans_list)
            for k in range(min(len(ans_list),i)):
                if ans_list[k] < 0:
                    tmp -= ans_list[k]
            ans = max(ans,tmp)
        else:
            pass

print(max(ans,0))


Measured memory_bytes: 5520
#include <iostream>

using namespace std;

void solve(long long a, long long b) {
	long long num = a * b;
	while (a != b) {
		if (a > b) {
			a -= b;
		}else if(b > a){
			b -= a;
		}

		if (a == b) {
			break;
		}
	}
	cout << a << " " << num / a << endl;
}

int main() {
	long long a, b;
	while (cin >> a >> b) {
		solve(a, b);
	}
	return 0;
}

Measured memory_bytes: 2988
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int res = 0;
        for (int i = 0; i < n; ++i) {
            int x = input.nextInt();
            if (isPrime(x)) ++res;
        }
        System.out.println(res);
    }       
    
    static boolean isPrime(int x) {
        if (x < 2) return false;
        for (int i = 2; i <= Math.sqrt(x); ++i) {
            if (x % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 31012
<?php
$rate = fgets(STDIN);

$kyu = 0;

if($rate >= 400 && $rate <= 599){
    $kyu = 8;
}
if($rate >= 600 && $rate <= 799){
    $kyu = 7;
}
if($rate >= 800 && $rate <= 999){
    $kyu = 6;
}
if($rate >= 1000 && $rate <= 1199){
    $kyu = 5;
}
if($rate >= 1200 && $rate <= 1399){
    $kyu = 4;
}
if($rate >= 1400 && $rate <= 1599){
    $kyu = 3;
}
if($rate >= 1600 && $rate <= 1799){
    $kyu = 2;
}
if($rate >= 1800 && $rate <= 1999){
    $kyu = 1;
}

echo $kyu;
?>

Measured memory_bytes: 16168
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"YES"<<endl;
#define sayno cout<<"NO"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;
string s;


bool recursive(int i,string b)
{
    int tn=b.length();
    string t=s.substr(i,tn);
    if(t!=b)return false;
    if(i+tn==s.length())return true;
    if(recursive(i+tn,"dream"))return true;
    if(recursive(i+tn,"dreamer"))return true;
    if(recursive(i+tn,"eraser"))return true;
    if(recursive(i+tn,"erase"))return true;
    return false;

}

int main()
{
    cin>>s;
    int n=s.length();
    if(recursive(0,""))
    {
        sayyes;
    }
    else
    {
        sayno;
    }
    
    

}


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

class Scanner {
    private string[] arr;
    private int count = 0;
    private int pointer = 0;
    public string next() {
        if(this.pointer >= this.count) {
            var str = Console.ReadLine();
            arr = str.Split(' ');
            count = arr.Length;
            pointer = 0;
        }
        var result = arr[pointer];
        pointer++;
        return result;
    }
    public bool hasNext() {
        return pointer < count;
    }
    public int nextInt() {
        return int.Parse(next());
    }
    public double nextDouble() {
        return double.Parse(next());
    }
}

class Run
{
  static void Main()
  {
    var scan = new Scanner();
    var N = scan.nextInt();
    List<string> array = new List<string>();
    for(var n = 0; n < N; n++)
    {
      var name = scan.next();
      var point = scan.nextInt();
      var s = String.Format("{0}{1:000}_{2}", name, 100-point, n+1);
      array.Add(s);
    }
    array.Sort();
    foreach(var s in array)
    {
      var cells = s.Split('_');
      Console.WriteLine(cells[1]);
    }
  }
}

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

using namespace std;

int main(void)
{
    int N;
    long long D;
    cin >> N >> D;

    const long long D2 = D * D;

    int count = 0;
    for(int i = 0; i < N; ++i)
    {
        long long x, y;
        cin >> x >> y;
        if(x * x + y * y <= D2)
        {
            ++count;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3632
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

import math 
def dict_order(l): # l=list(1,...,nの順列)
    n = len(l)
    order = 0 # lの辞書式順序の番号
    used = [0]*n
    for i in range(n):
        order += (l[i]-1-sum(used[:l[i]]))*math.factorial(N-1-i)
        used[l[i]-1] += 1
    return order # lの辞書式順序の番号
print(abs(dict_order(P)-dict_order(Q)))

Measured memory_bytes: 38256
def pred(i, lst, offset):
  for cmpd in lst[offset:i+1]:
    if lst[i] > cmpd:
      return False
  return True

n = int(input())
p = [int(m) for m in input().split(' ')]

sum = 0
minimum = n + 1
for i in range(n):
  if p[i] < minimum:
    sum += 1
    minimum = p[i]

#sum = 0
#offset = 0
#for i in range(n):
#  if pred(i, p, offset):
#    sum += 1
#    offset = i

print(sum)

Measured memory_bytes: 25768
#include <iostream>
#include <math.h>
#include <set>
#include<vector>
#include<string>
#include <algorithm>
#include<queue>
#include<map>
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define per(i,j,k) for(int i = (int)j;i >= (int)k;i --)
#define F(i,k) for(int i=(int)0;i<(int)k;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
const int maxn = 2e5 + 5;
const ll mod = 1e9 + 7;
using namespace std;
ll m,n,k;
int nxt[maxn];
int lst[256];
vector<ll> pos[256];
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	string s, t;
	cin >> s >> t;
	ll len = s.length();
	rep(i,0,len-1) {
	//	if (lst[s[i]] != 0)nxt[i] = lst[s[i]];
	//	lst[s[i]] = i;
		pos[s[i]].push_back((ll)i);
	}
	ll lent = t.length();
	ll p = 0;
	int f = 1;
	ll ans = 0;
	rep(i, 0, lent - 1) {
		if (pos[t[i]].empty()) {
			f = 0;
			break;
		}
		auto it= lower_bound(pos[t[i]].begin(), pos[t[i]].end(),p);
		if (it == pos[t[i]].end()) { 
			ans++;
			p = 0;
			it = lower_bound(pos[t[i]].begin(), pos[t[i]].end(), p);
		}
		p = *it+1;

	}
	if (f == 0)cout << -1 << endl;
	else cout << ans*len+p << endl;
	cin >> n;
}

/*
sam
sss
*/

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int a[maxn];
int cnt[maxn];

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int n;
	cin >> n;
	cout << 360/gcd(360,n) << endl;
}


Measured memory_bytes: 3588
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;
	
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		ans += s[i] == t[i];
	}
	cout << ans << "\n";

	return 0;
}

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

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

void solve(long long N) {
  if( N < 1000 ) cout << "ABC" << endl;
  else cout << "ABD" << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> imos(n, 0);

    int left, right;
    rep(j, k){
        rep(i, n){
            if(i - a[i] > 0) left = i - a[i];
            else left = 0;
            imos[left]++;

            if(i + a[i] + 1 < n) right = i + a[i] + 1;
            else continue;

            imos[right]--;
        }
        _rep(i, 1, n) imos[i] += imos[i - 1];
        rep(i, n) a[i] = imos[i];
        rep(i, n) imos[i] = 0;
        if(*min_element(a.begin(), a.end()) == n) break;
    }
    rep(i, n){
        if(i == n - 1){
            cout << a[i] << endl;
            return 0;
        }
        else cout << a[i] << " ";
    }
}

Measured memory_bytes: 4844
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<deque>
using namespace std;
typedef long long ll;
const int mm=1000000007;
int now;
struct data{
	int a[3],f;
	void rev(){
		if (f==now) return;
		a[0]=(a[0]+a[2])%mm;a[2]=0;
		f=now;
	}
};
struct edge{
	int t,next;
}g[410001];
deque<data> s[210001];
int i,j,k,n,m,fa[210001],h[210001],tot,pw[210001],dep[210001],c[210001],p[210001],ans;
void addedge(int x,int y){
	g[++tot].t=y;g[tot].next=h[x];h[x]=tot;
}
data merge(data x,data y){
	int i,j,k;
	data res;
	x.rev();y.rev();
	res.a[0]=res.a[1]=res.a[2]=0;
	for (i=0;i<=2;i++)
	 for (j=0;j<=2;j++){
	 	k=min(2,i+j);
	 	res.a[k]=(res.a[k]+(ll)x.a[i]*(ll)y.a[j])%mm;
	 }
	res.f=now;
	return res;
}
void comb(int x,int y){
	int i,k,t1=p[x],t2=p[y];
	if (s[t1].size()<s[t2].size()) p[x]=t2,swap(t1,t2);
	for (i=0,k=s[t2].size();i<k;i++) s[t1][i]=merge(s[t1][i],s[t2][i]);
}
void dfs(int x){
	int i;
	p[x]=x;s[x].clear();c[dep[x]]++;
	for (i=h[x];i;i=g[i].next)
	 dep[g[i].t]=dep[x]+1,dfs(g[i].t);
}
void solve(int x){
	int i,k;
	data tmp;
	for (i=h[x];i;i=g[i].next) solve(g[i].t);
	now=x;
	for (i=h[x];i;i=g[i].next) comb(x,g[i].t);
	//for (i=0,k=s[p[x]].size();i<k;i++) s[p[x]][i].a[0]=(s[p[x]][i].a[0]+s[p[x]][i].a[2])%mm,s[p[x]][i].a[2]=0;
	tmp.a[2]=0;tmp.a[0]=tmp.a[1]=1;tmp.f=x;
	s[p[x]].push_front(tmp);
	//for (i=0;i<s[p[x]].size();i++) printf("* %d %d %d\n",x,i,s[p[x]][i].a[1]);
}
int main(){
	scanf("%d",&n);n++;tot=0;memset(c,0,sizeof(c));
	for (pw[0]=i=1;i<=n;i++) pw[i]=pw[i-1]*2%mm;
	for (i=2;i<=n;i++) scanf("%d",&fa[i]),fa[i]++,addedge(fa[i],i);
	dep[1]=1;dfs(1);
	solve(1);
	for (i=0,k=s[p[1]].size();i<k;i++) ans=(ans+(ll)s[p[1]][i].a[1]*(ll)pw[n-c[i+1]]%mm)%mm;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 250880