akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std::literals;
using namespace std;

namespace xmaho
{
  inline namespace input
  {
    template<typename T>
      T get_value(std::istream& is = std::cin);
    template<typename C>
      C get_container(std::istream& is = std::cin, typename C::size_type length = std::numeric_limits<typename C::size_type>::max());
  }
}
using namespace xmaho;

int main()
{
  double r;
  cin >> r;
  cout << (2.0 * r * 3.14159) << endl;
  return 0;
}

class initalization
{
  class custom_numpunct: public std::numpunct<char>
  {
    public:
      using numpunct::numpunct;
    protected:
      std::string do_truename() const override { return "Yes"; }
      std::string do_falsename() const override { return "No"; }
  };

  public:
  initalization()
  {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.imbue(std::locale(std::cout.getloc(), new custom_numpunct{}));
    std::cout << std::boolalpha << std::fixed << std::setprecision(15);
  }
} initalize;

  template<typename T>
T xmaho::input::get_value(std::istream& is)
{ T v {}; is >> v; return v; }

  template<typename C>
C xmaho::input::get_container(std::istream& is, typename C::size_type length)
{
  C v {};
  if (length != std::numeric_limits<typename C::size_type>::max())
    v.reserve(length);
  typename C::value_type e {};
  for (auto i {length}; i != 0 && is >> e; --i)
    v.push_back(std::move_if_noexcept(e));
  return v;
}



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

int main() {
  int N;
  int a[110];
  cin >> N;
  rep(i, N) cin >> a[i];

  sort(a, a+N, greater<int>());
  int Alice = 0;
  int Bob = 0;
  rep(i, N) {
    if (i % 2 == 0) {
      Alice += a[i];
    } else {
      Bob += a[i];
    }
  }
  cout << Alice - Bob << endl;

  return 0;
}

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

int main(){
  int P[6];
  for(int i=0;i<6;i++){
    cin >> P[i];
  }
  sort(P,P+4);
  int sum = 0;
  for(int i=3;i>0;i--){
    sum += P[i];
  }
  sum += max(P[4],P[5]);
  cout << sum << endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin >> n;
   int k=0;
   for(int i=1;i<=n;i++){
       if(i*(i-1)+1<=2*n&&2*n<=i*(i+1)){
           k = i;
           break;
       } 
   }
   n -= k;
   cout << k << endl;
   for(int i=k-1;1<=i;i--){
       if(i<=n){
           cout << i << endl;
           n -= i;
       }
   }
}

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

#define ll long long
#define forr(i,n) for(ll i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

ll power(ll a,ll b){ll r=1;while(b--)r*=a;return r;}
int solve(vector<vector<int>> v,int n,vector<vector<int>> dp){
    for(int i=1;i<=n;i++){
        dp[i][0]=max(dp[i-1][1]+v[i-1][0],dp[i-1][2]+v[i-1][0]);
        dp[i][1]=max(dp[i-1][0]+v[i-1][1],dp[i-1][2]+v[i-1][1]);
        dp[i][2]=max(dp[i-1][1]+v[i-1][2],dp[i-1][0]+v[i-1][2]);
    }
    return max(dp[n][0],max(dp[n][1],dp[n][2]));
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    ll n,W;cin>>n>>W;
    vector<ll> w(n),v(n);
    vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));
    f(i,0,n)cin>>w[i]>>v[i];
    f(i,1,n+1){
        f(j,1,W+1){
            if(w[i-1]<=j){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
            }
            else dp[i][j]=dp[i-1][j];
        }
    }
    ll mx=0;
    for(ll i=1;i<=n;i++)mx=max(mx,dp[i][W]);cs(mx);
    

  }


Measured memory_bytes: 83164
// abc155_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

#define CHAR2INT(c) (c - '0')

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S;
    cin >> S;
    int N = (int)S.size();

    // dp[i][0] : i番目まで見て、貸し借りなしの状態
    // dp[i][1] : i番目まで見て、1足りない状態
    vector<vector<ll>> dp(N+1, vector<ll>(2, INF));
    dp[0][0] = 0;
    dp[0][1] = 1;
    REP(i, N){
        int d = S[i] - '0';
        dp[i+1][0] = min(dp[i+1][0], (min(d, 11-d) + dp[i][0]));
        dp[i+1][0] = min(dp[i+1][0], (10-d + dp[i][1]));

        dp[i+1][1] = min(dp[i+1][1], d+1 + dp[i][0]);
        dp[i+1][1] = min(dp[i+1][1], 9-d + dp[i][1]);
    }

//    print(dp);

    ll ans = dp[N][0];
    print(ans);


    return 0;
}


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

int main() {
  int n;
  stack<int> stack;
  vector<int> v;
  while(cin >> n) {
    if(n == 0) {
      v.push_back(stack.top());
      stack.pop();
    } else {
      stack.push(n);
    }
  }

  for(vector<int>::iterator it = v.begin(); it != v.end(); it++) {
    cout << *it << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
n,k=list(map(int,input().split()))
l=[0 for i in range(n)]
for i in range(k):
  input()
  a=list(map(int,input().split()))
  for j in a:
    l[j-1]=1
s=0
for i in range(n):
  if l[i]==0:
    s+=1
print(s)

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

from collections import Counter

def main(N,K,A):
    change = max(len(set(A))-K,0)
    ans = 0
    A_count = Counter(A)
    for a in A_count.most_common()[:-change-1:-1]:
        ans += a[1]
    print(ans)
    
if __name__ == '__main__':
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    main(N,K,A)

Measured memory_bytes: 48516
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // get a integer
        int s = sc.nextInt();
        // get two integers separated with half-width break
        int w = sc.nextInt();
        String str = (s <= w) ? "unsafe" : "safe";
        System.out.println(str);
    }
}

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

using namespace std;

long long n, a, b, c;
char s[100010][10];
char print[100010];

int main(void)
{
	scanf("%lld %lld %lld %lld", &n, &a, &b, &c);
	
	for(int i = 0 ; i < n ; i++)
		scanf("%s", s[i]);
	
	for(int i = 0 ; i < n - 1 ; i++)
	{
		if(strcmp(s[i], "AB") == 0)
		{
			if(a < b)
			{
				a++;
				b--;
				print[i] = 'A';
			}
			
			else if(b < a)
			{
				b++;
				a--;
				print[i] = 'B';
			}
			
			else
			{
				if(strcmp(s[i + 1], "AB") == 0)
				{
					a++;
					b--;
					print[i] = 'A';
				}
				
				else if(strcmp(s[i + 1], "BC") == 0)
				{
					b++;
					a--;
					print[i] = 'B';
				}
				
				else if(strcmp(s[i + 1], "AC") == 0)
				{
					a++;
					b--;
					print[i] = 'A';
				}
			}
		}
		
		if(strcmp(s[i], "BC") == 0)
		{
			if(b < c)
			{
				b++;
				c--;
				print[i] = 'B';
			}
			
			else if(c < b)
			{
				c++;
				b--;
				print[i] = 'C';
			}
			
			else
			{
				if(strcmp(s[i + 1], "AB") == 0)
				{
					b++;
					c--;
					print[i] = 'B';
				}
				
				else if(strcmp(s[i + 1], "BC") == 0)
				{
					b++;
					c--;
					print[i] = 'B';
				}
				
				else if(strcmp(s[i + 1], "AC") == 0)
				{
					c++;
					b--;
					print[i] = 'C';
				}
			}
		}
		
		if(strcmp(s[i], "AC") == 0)
		{
			if(a < c)
			{
				a++;
				c--;
				print[i] = 'A';
			}
			
			else if(c < a)
			{
				c++;
				a--;
				print[i] = 'C';
			}
			
			else
			{
				if(strcmp(s[i + 1], "AB") == 0)
				{
					a++;
					c--;
					print[i] = 'A';
				}
				
				else if(strcmp(s[i + 1], "BC") == 0)
				{
					c++;
					a--;
					print[i] = 'C';
				}
				
				else if(strcmp(s[i + 1], "AC") == 0)
				{
					a++;
					c--;
					print[i] = 'A';
				}
			}
		}
		
		if(a < 0 || b < 0 || c < 0)
		{
			printf("No");
			return 0;
		}
	}
	
	if(strcmp(s[n - 1], "AB") == 0)
	{
		if(a < b)
		{
			a++;
			b--;
			print[n - 1] = 'A';
		}
		
		else
		{
			b++;
			a--;
			print[n - 1] = 'B';
		}
	}
	
	if(strcmp(s[n - 1], "BC") == 0)
	{
		if(b < c)
		{
			b++;
			c--;
			print[n - 1] = 'B';
		}
		
		else
		{
			c++;
			b--;
			print[n - 1] = 'C';
		}
	}
	
	if(strcmp(s[n - 1], "AC") == 0)
	{
		if(a < c)
		{
			a++;
			c--;
			print[n - 1] = 'A';
		}
		
		else
		{
			c++;
			a--;
			print[n - 1] = 'C';
		}
	}
	
	if(a < 0 || b < 0 || c < 0)
	{
		printf("No");
		return 0;
	}
	
	printf("Yes\n");
	
	for(int i = 0 ; i < n ; i++)
		printf("%c\n", print[i]);
	
	return 0;
}

Measured memory_bytes: 4904
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    unordered_map<int, int> counter;
    vector<int> A(n);
    for(int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        A[i] = x;
        ++counter[x];
    }
    long long total = 0LL;
    for(auto & p : counter) {
        long long cnt = p.second;
        total += cnt * (cnt - 1) / 2;
    }
    for(int i = 0; i < n; ++i) {
        long long cnt = counter[A[i]];
        long long ans = total - cnt * (cnt - 1) / 2;
        --cnt;
        if(cnt >= 1) ans += cnt * (cnt - 1) / 2;
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 8392
#include <stdio.h>
int main(void)
{
  int n;        // 文字列の数
  int i, j, k;  // ループ用変数
  int a[26];    // i番目までの文字列で各アルファベットの最も少ない登場回数
  int b[26];    // i番目の各アルファベットの登場回数
  int tmp;      // アルファベットの文字コード。クッション。
  char s[51];   // 文字列
// リストの初期化
  for (i = 0; i < 26; i++) {
    a[i] = 51;    // 十分に大きい数
    b[i] = 0;
  }
// 文字列の数を入力する
  scanf("%d", &n);
// 文字列を入力しながらリストを更新する
  for (i = 0; i < n; i++) {
    // 文字列を入力する
    scanf("%s", s);
    // 文字列に含まれるアルファベットをカウントする
    j = 0;
    while (s[j] != '\0') {
      tmp = s[j++] - 'a';
      b[tmp]++;
    }
    // リストaの数より少ない場合はリストbの数にする
    for (k = 0; k < 26; k++) {
      if (b[k] < a[k]) {
        a[k] = b[k];
      }
      b[k] = 0;   // i + 1番目の文字列で利用するため初期化する
    }
  }
  // 辞書順（文字コードが小さい順）で表示する
  for (i = 0; i < 26; i++) {
    for (j = 0; j < a[i]; j++) {
      printf("%c", 'a' + i);
    }
  }
  putchar('\n');  // ラストの改行
  // for (i = 0; i < 26; i++) printf("%c : %d\n", 'a' + i, a[i]);
  return 0;
}

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


int main(){
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    
  
    while(s.size()!=0){
        if(s.substr(0,5) == "maerd") {
          s = s.substr(5);
        }
        else if(s.substr(0,7) =="remaerd") {
          s = s.substr(7);
        }
        else if(s.substr(0,5) =="esare") {
          s = s.substr(5);
        }
        else if(s.substr(0,6) =="resare"){
          s = s.substr(6);
        }
        else {
            cout << "NO" << endl;
          return 0;
        }
    }
  
    cout << "YES" << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;



int main(){
#ifdef LOCAL
	freopen("A_input.txt", "r", stdin);
	//freopen("A_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	vector <pair <int, char> > a;
	for (char c : s) {
		if (!a.size() || a.back().second != c) {
			a.push_back({1, c});
		} else {
			a.back().first++;
		}
	}
	ll res = 0;
	int now = 0;
	if (a[now].second == '>') {
		ll d = a[now++].first;
		res += d * (d + 1) / 2;
	}
	int n = a.size();
	for (; now < n - 1; now += 2) {
		ll c = a[now].first, d = a[now + 1].first;
		res += c * (c - 1) / 2;
		res += d * (d - 1) / 2;
		res += max(c, d);
	}
	if (now == n - 1) {
		ll d = a[now++].first;
		res += d * (d + 1) / 2;
	}
	cout << res << "\n";
}


Measured memory_bytes: 3352
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
int main(){
  int n,x;
  cin>>n>>x;
  vector<int> a(n);
  vector<int> m(n);
  int64_t mi=0;
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    m.at(i)=a.at(i);
    mi+=m.at(i);
  }
  for(int i=1;i<n;i++){
    int64_t s=(int64_t)x*i;
    for(int j=0;j<n;j++){
      m.at(j)=min(m.at(j),a.at((j-i+n)%n));
      s+=m.at(j);
    }
    mi=min(s,mi);
  }
  cout<<mi<<endl;
}

Measured memory_bytes: 3624
def main():
    N, K, Q = map(int, input().split())
    A = [int(input()) for _ in range(Q)]

    points = [K for _ in range(N)]
    points = list(map(lambda x: x - Q, points))

    for i in A:
        points[i - 1] += 1

    for i in points:
        if i <= 0:
            print("No")
        else:
            print("Yes")


if __name__ == "__main__":
    main()


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

const int maxn = 2e4 + 20;
int n, a[maxn], b[maxn], p[maxn], ord[maxn], ca[maxn], cb[maxn];

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

    for(int i = 0; i < n; i++){
        scanf("%d", p + i);
    }

    for(int i = 0; i < n; i++){
        ca[p[i] - 1] += i;
        cb[p[i]] += i;
    }

    int x = 0, y = 0, mn = 1e9;
    for(int i = 0; i < n; i++){
        x += ca[i];
        y += cb[i];

        a[i] = i + 1 + x;
        b[i] = n - i - y;

        mn = min(mn, min(a[i], b[i]));
    }

    for(int i = 0; i < n; i++){
        printf("%d ", a[i] - mn + 1);
    }
    printf("\n");
    for(int i = 0; i < n; i++){
        printf("%d ", b[i] - mn + 1);
    }
    printf("\n");

    return 0;
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

bool isPrime[1000006];
int dp[1000006];

int main() {
    rep(i, 1000006) isPrime[i] = true;
    isPrime[0] = isPrime[1] = false;
    rep(i, 1000006) if (isPrime[i]) {
        for (int j = i * 2; j < 1000006; j += i) isPrime[j] = false;
    }
    rep(i, 1000006) if (i) {
        dp[i] = dp[i - 1];
        if (isPrime[i]) dp[i]++;
    }
    int n;
    while (cin >> n) {
        cout << dp[n] << endl;
    }
    return 0;
}

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

using namespace std;

int n,h;

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

	cin >> h >> n;
	int s = 0;
	for (int i=1;i<=n;i++)
	{
		int x;
		cin >> x;
		s += x;
	}
	if (s >= h) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        int k = sc.nextInt();

        long[] a = new long[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }

        for(int i = k; i < n; i++){
            if(a[i - k] < a[i]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }

    }
}


Measured memory_bytes: 71028
#include <stdio.h>

int main(void){

  int n;
  scanf("%d",&n);
  int i,count=0, p[n];
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for(i=1;i<n-1;i++){
    if(p[i-1]<p[i]&&p[i]<p[i+1])
      count++;
    else if(p[i-1]>p[i]&&p[i]>p[i+1])
      count++;
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
void solve()
{
    ld d,t,s;
    cin>>d>>t>>s;
    ld x=(d/s);
    if(x<=t)
        cout<<"Yes";
    else
        cout<<"No";
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int q;
    cin >> q;
    priority_queue<ll> low;
    priority_queue<ll, vector<ll>, greater<ll>> high;
    ll mid = 0;
    ll ex = 0;
    ll low_s = 0;
    ll high_s = 0;
    q--;
    int i, j, k;
    cin >> i >> j >> k;
    mid = j;
    ex += k;
    while(q--)
    {
        int x;
        cin >> x;
        if(x == 2)
        {
            cout << mid << " " << ex + low_s + high_s << endl;
        }
        else if(x == 1)
        {
            int a, b;
            cin >> a >> b;
            ex += b;
            if(a >= mid)
            {
                high.push(a);
                high_s += a - mid;
                ll lsize = low.size();
                ll hsize = high.size();
                if(lsize + 2 == hsize)
                {
                    ll newmid = high.top();
                    low_s += lsize * (newmid - mid) + newmid - mid;
                    low.push(mid);
                    high_s -= (hsize-1) * (newmid - mid);
                    high_s -= (newmid - mid);
                    high.pop();
                    mid = newmid;
                }
            }
            else
            {
                ll bsize = low.size();
                ll hsize = high.size();
                low.push(a);
                low_s += mid - a;
                if(low.size() <= high.size()) continue;
                ll newmid = low.top();
                low_s -= bsize * (mid - newmid);
                low_s -= mid - newmid;
                high.push(mid);
                high_s += hsize * (mid - newmid);
                high_s += mid - newmid;
                mid = newmid;
                low.pop();
            }
        }
    }
}


Measured memory_bytes: 3828
import numpy as np
# your code goes here
def main():
	n = int(input())
	buf = input().split()
	t = int(buf[0])
	a = int(buf[1])
	buf = input().split()
	ond = np.zeros(n)
	for i in range(n):
		ond[i] = t - int(buf[i])*0.006
	ttn = np.argmin(np.abs(ond-a))
	#print(ond)
	print(ttn+1)
	
	
main()

Measured memory_bytes: 21632
import sys

sys.setrecursionlimit(10 ** 5 + 5)


def dfs(v, p, f):
    ret = f
    child_free = k - 1 if f == k else k - 2
    for u in links[v]:
        if u == p:
            continue
        pat = dfs(u, v, child_free)
        if pat == 0:
            ret = 0
            break
        ret = ret * pat % MOD
        child_free -= 1
    # print(v, p, ret, len(links[v]))
    return ret


n, k = list(map(int, input().split()))
MOD = 10 ** 9 + 7
RK = pow(k, MOD - 2, MOD)
links = [set() for _ in range(n)]
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)
ans = dfs(0, -1, k)
print(ans)


Measured memory_bytes: 99880
// 18
#include <stdio.h>

int main(){
  
  int N;
  int i,j,k,v;
  int A[1000];
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n");
  
  
  
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0  && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    
    for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k!=N-1) printf(" ");
      else printf("\n");
      }
  }
  return 0;
}



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

// using INF = INT_MAX / 2;

#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif


// dp[w][i] := w の重さの時 i 個の荷物を入れた時の価値の総和
long long dp[105][100005];

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> w(N);
    vector<int> v(N);
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            dp[i+1][j] = max(dp[i][j], j - w[i] >= 0 ? dp[i][j - w[i]] + v[i] : dp[i][j]);
        }
    }
    long long int ans = 0;
    for (int i = 0; i <= W; ++i) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
    using namespace std;
    #define int long long
     
    signed  main() {
    	int a, b; cin >> a >> b;
    	int c = __gcd(a, b);
    	int ans = 1;
    	
    	for (int i = 2; i * i <= c; i++) {
        
    		if(!(c%i) && i<c){
        ans++;
        
        }
        while(!(c%i)){
       c/=i;
        }

      
        }

        if(c!=1){
          ans++;
        }
      
    
    
    	cout << ans << endl;
    }


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        20000000000007LL
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,a[200005],p[200005],s[200005],ans=hell;
void solve(){
    cin>>n;
    rep(i,1,n+1) cin>>a[i];
    rep(i,1,n+1) p[i]=p[i-1]+a[i];
    for(int i=n;i>=1;i--) s[i]=s[i+1]+a[i];
    rep(i,1,n) ans=min(ans,abs(p[i]-s[i+1]));
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 1600010
typedef long long LL;
template<class T>T min(T x,T y) {return x<y?x:y;}
template<class T>T max(T x,T y) {return x>y?x:y;}
LL read()
{
	LL s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
struct Edge{int to,next;
}e[maxn*10];
int n,dot,h[maxn],cnt,a[2][maxn],ch[maxn][2],dfn[maxn],low[maxn],dfx,q[maxn],v[maxn],sp,be[maxn],ls[maxn],rs[maxn],rt;
void add(int x,int y) {/*printf("%d %d\n",x,y),*/e[++cnt]=(Edge){y,h[x]},h[x]=cnt;}
std::pair<int,int> L[maxn];
void Build(int&k,int l,int r)
{
	if(l==r) return k=L[l].second,void(0);k=++dot;int mid=l+r>>1;
	Build(ch[k][0],l,mid),Build(ch[k][1],mid+1,r);
	add(k,ch[k][0]),add(k,ch[k][1]);
}
void Update(int k,int l,int r,int L,int R,int p)
{
	if(L>R) return;
	if(R<l||r<L) return;
	if(L<=l&&r<=R) return add(p,k);int mid=l+r>>1;
	Update(ch[k][0],l,mid,L,R,p),Update(ch[k][1],mid+1,r,L,R,p);
}
void Tarjan(int x)
{
	dfn[x]=low[x]=++dfx,q[++q[0]]=x,v[x]=1;
	for(int i=h[x];i;i=e[i].next) low[x]=min(low[x],dfn[e[i].to]?(v[e[i].to]?dfn[e[i].to]:0x7fffffff):(Tarjan(e[i].to),low[e[i].to]));
	if(dfn[x]==low[x]) {++sp;do{v[q[q[0]]]=0,be[q[q[0]]]=sp;}while(x^q[q[0]--]);}
}
bool isok(int mid)
{
	memset(h,0,sizeof(h)),dfx=sp=cnt=0,dot=n<<1;
	Build(rt,1,n<<1);
	for(int i=1;i<=n;i++)
		for(int k=0;k<2;k++)
		{
			int l=std::lower_bound(L+1,L+1+(n<<1),std::make_pair(a[k][i]-mid+1,0))-L,r=upper_bound(L+1,L+1+(n<<1),std::make_pair(a[k][i]+mid-1,n<<1|1))-L-1,M=std::lower_bound(L+1,L+1+(n<<1),std::make_pair(a[k][i],(k^1)*n+i))-L;
			Update(rt,1,n<<1,l,M-1,k*n+i),Update(rt,1,n<<1,M+1,r,k*n+i);
		}
	memset(dfn,0,sizeof(dfn)),memset(low,0,sizeof(low)),memset(be,0,sizeof(be));
	for(int i=1;i<=dot;i++) !dfn[i]?Tarjan(i):void(0);
	for(int i=1;i<=n;i++)
		if(be[i]==be[i+n]) return 0;
	return 1;
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++) a[0][i]=read(),a[1][i]=read();
	for(int i=1;i<=n;i++) L[(i<<1)-1]=std::make_pair(a[0][i],i+n),L[i<<1]=std::make_pair(a[1][i],i);
	std::sort(L+1,L+1+(n<<1));
	int l=0,r=1e9,mid,ans=-1;
	while(l<=r)
	{
		mid=l+r>>1;
		if(isok(mid)) l=mid+1,ans=mid;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 36268
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
      int cntAC=0;
      int cntWA=0;
      int cntTLE=0;
      int cntRE=0;
      for(int i=1;i<=N;i++){
        string tc=Console.ReadLine();
        if(tc=="AC"){
          cntAC++;
        }else if(tc=="WA"){
          cntWA++;
        }else if(tc=="TLE"){
          cntTLE++;
        }else{
          cntRE++;
        }
      }
        Console.WriteLine("AC x "+cntAC);
        Console.WriteLine("WA x "+cntWA);
        Console.WriteLine("TLE x "+cntTLE);       
        Console.WriteLine("RE x "+cntRE);  
      
    }
    
  }

}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;

	lli cnt=0;
	REP(i,0,n){
		lli a;
		cin>>a;
		while(a%2==0){
			cnt++;
			a/=2;
		}
	}

	cout<<cnt<<endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  char c; cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }

}

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

/*int a[1000000001];
int devidenumber(int m) {
	if(a[m]!=0) return m/a[m];
	else {
		int k=2;
		while(m%k!=0) ++k;
		a[m]=k;
		return m/k;
	}
}
*/

int n;
int main() {
	cin >> n;
	cout << n << ":";
	while(n !=1) {
		int k=2;
		while((n%k!=0) && (k <= sqrt(n))) ++k;
		if (k > sqrt(n)) {
			cout << " " << n;
			break;
		} else {
			n = n/k;
			cout << " " << k;
			k=2;
		}
	}
	cout << endl;
}

Measured memory_bytes: 1168
#!/usr/bin/python
# coding: UTF-8

A, B, K = map(int, input().split())
Count = 1
M = max([A,B])
for i in range(M,0,-1):
    if A % i == 0 and B % i == 0:
        if Count == K:
            print(i)
            break
        Count += 1

Measured memory_bytes: 2940
import sys

n, *h = map(int, sys.stdin.read().split())
h += [float('inf')]

def main():
    prev = res = cnt = 0
    for x in h:
        if x > prev:
            res = max(res, cnt)
            cnt = 0
        else:
            cnt += 1
        prev = x
    print(res)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 14092
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
inline int mex(unordered_set<int> st)
{
    int m = 0;
    while (st.find(m) != st.end())
    {
        m += 1;
    }
    return m;
}
inline int calculateGrundy(int n)
{
    if (n == 1)
        return 0;
    unordered_set<int> mexi;
    for (int i = 1; i <= sqrt(n); i += 1)
    {
        if (n % i == 0)
        {
            if (n / i != n)
                mexi.insert(calculateGrundy(n / i));
            mexi.insert(calculateGrundy(i));
        }
    }
    return mex(mexi);
}
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    if ((s[2] == s[3]) && (s[4] == s[5]))
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

struct info {
    vector<ll> contest, minus;
    ll score;

    info(ll value) {
        contest = vector<ll>();
        minus = vector<ll>(26, 0);
        score = value;
    }

    info() {
        contest = vector<ll>();
        minus = vector<ll>(26, 0);
        score = 0;
    }
};

int main() {
    ll D;
    cin >> D;
    vector<ll> c(26);
    cin >> c;
    vector<vector<ll>> satisfaction(26, vector<ll>(D + 1));
    for (int i = 1; i <= D; i++) {
        for (int j = 0; j < 26; j++) {
            ll temp;
            cin >> temp;
            satisfaction[j][i] = temp;
        }
    }
    vector<vector<info>> dp(D + 1, vector<info>(26));
    for (int day = 1; day <= D; day++) {
        for (int now = 0; now < 26; now++) {
            for (int before = 0; before < 26; before++) {
                auto before_info = dp[day - 1][before];
                for (int i = 0; i < 26; i++) {
                    before_info.minus[i] += c[i];
                }
                before_info.contest.push_back(now);
                before_info.minus[now] = 0;
                before_info.score += satisfaction[now][day];
                for (int i = 0; i < 26; i++) {
                    before_info.score -= before_info.minus[i];
                }
                if (dp[day][now].contest.empty()) {
                    dp[day][now] = before_info;
                    continue;
                }
                if (dp[day][now].score == before_info.score) {
                    ll left = 0, right = 0;
                    for (int i = 0; i < 26; i++) {
                        left += dp[day][now].minus[i];
                        right += before_info.minus[i];
                    }
                    if (left > right) dp[day][now] = before_info;
                    continue;
                }
                if (dp[day][now].score < before_info.score) dp[day][now] = before_info;
            }
        }
    }
    auto ans = dp[D][0];
    for (int i = 0; i < 26; i++) {
        if (ans.score < dp[D][i].score) ans = dp[D][i];
    }
    for (int i = 0; i < D; i++) {
        cout << ans.contest[i] + 1 << endl;
    }
}


Measured memory_bytes: 20304
#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(){
    ll n; cin >> n;

    vector<ll> vec(3500);
    rep(i, 3500) vec[i] = i + 1;
    ll num;
    for(int i = 1; i <= 3500; i++){
        for(int j = 1; j <= 3500; j++){
            if(4 * i * j - (i + j) * n != 0){
                num = (n * i * j) / (4 * i * j - (i + j) * n);
                if((n * i * j) % (4 * i * j - (i + j) * n) != 0) continue;
                if(binary_search(vec.begin(), vec.end(), num)){
                    cout << i << " " << j << " " << num << endl;
                    return 0;
                }
            } 
        }
    }
}

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

int main(){
	string s,t;
	cin >> s >> t;
	int time = s.size() - t.size() +1;
	int length = t.size();
	int counts = 0;
	int mx = 0;
	rep(i,time){
		counts = 0;
		for(int j = i; j < length + i; j++){
			// cout << s[j] << " s    " << t[j - i] << " t     " << endl;
			if(s[j] == t[j - i]) counts++;
		}
		mx = max(mx,counts);
	}
	cout << length - mx << endl;
}

Measured memory_bytes: 3568
use proconio::input;

fn main() {
    input! {
        mut a: i64,
        mut b: i64,
        k: usize,
    };
    for i in 0..k {
        if i % 2 == 0 {
            if a % 2 != 0 {
                a -= 1;
            }
            a /= 2;
            b += a;
        } else {
            if b % 2 != 0 {
                b -= 1;
            }
            b /= 2;
            a += b;
        }
    }
    println!("{} {}", a, b);
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int f(int n){
  return (n*n+4)/8;
}

int main(){
  queue<int> que[3];
  for(int i = 0; i < 3; ++i){
    string s; cin >> s;
    for(int j = 0; j < (int)s.size(); ++j){
      int x = s[j] - 'a';
      que[i].push(x);
    }
  }
  int t = 0;
  while(1){
    if(que[t].empty())break;
    int nt = que[t].front();
    que[t].pop();
    t = nt;
  }
  cout << char('A' + t) << endl;
  return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <cctype>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	string x;
	vector<string> n;
	for (int c = 0;; ++c) {
		cin >> x;
		if (x == "0")break;
		n.push_back(x);
	}

	for (int i = 0; i < n.size();++i) {
		int sum = 0;
		for (int j = 0; n[i][j] != '\0'; ++j) {
			sum += n[i][j] - '0';
		}
		cout << sum << endl;
	}
	return 0;
}




Measured memory_bytes: 3176
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {
    char c;
    cin >> c;
    int c_ = int(c);
    if (c == 'z') cout << "a\n";
    else
        cout << char(c_ + 1) << '\n';
}


Measured memory_bytes: 256
h,w=map(int,input().split())
m=s=h*w
def f(x,y):
  global m
  g=lambda:min(m,max(p,q,r)-min(p,q,r))
  for i in (x//3,x//3+1):
    p=i*y
    q=(x-i)//2*y; r=s-p-q; m=g()
    q=y//2*(x-i); r=s-p-q; m=g()
  return m
f(h,w);f(w,h)
print(m)

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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    atcoder::dsu dsu(n);
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        dsu.merge(--a, --b);
    }

    cout << dsu.groups().size() - 1 << endl;
}

Measured memory_bytes: 8900
#include <stdio.h>

int main(void) {
  int i, ans = 0, j, n;
  while(scanf("%d", &n) != EOF) {
    ans = 0;
    for(i = 0; i * n < 600; ++i) ans += n * i * i * n * n;
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2724
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int a[10];
	int sum = 0;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		if (a[i] < 40)a[i] = 40;
		sum += a[i];
	}
	cout << sum/5 << endl;
}





Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int n;
double x[10], y[10];
int d[10] = { 0,1,2,3,4,5,6,7,8,9 };
signed main() {
	cin >> n;
	rep(i, n)cin >> x[i] >> y[i];
	double sum = 0;
	do {
		double s = 0;
		rep(i, n - 1) {
			s += sqrt(pow(abs(x[d[i]] - x[d[i + 1]]), 2) + pow(abs(y[d[i]] - y[d[i + 1]]), 2));
		}
		sum += s;
	} while (next_permutation(d, d + n));
	double a = 1;
	REP(i, n + 1)a *= i;
	printf("%.12lf\n", sum / a);
}


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(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX 1000

typedef long long ll;

int main(){
    int N;
    cin >> N;
    ll ans = 0;
    Rep(i,N+100){
        if((i*54)/50 == N){
            ans = i;
            break;
        }
    }
    if(ans == 0)cout << ":(" << endl;
    else cout << ans << endl;
    //cin >> N;
}

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

int main(){
  string s, t, u;
  cin >> s >> t >> u;
  cout << s[0] << t[1] << u[2] << endl;
  return 0;
}

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

int main()
{
  long long n, k;
  
  long long a, b;
  long long ans = 0;

  cin >> n >> k;

  for ( long long i = k + 1; i <= n; i++) {
    ans += (n / i) * (i - k);//aはbの倍数に余りを足したもの
    
    if (n % i >= k && k != 0){
      ans += n % i - k + 1;
    } else if ( n % i >= k && k == 0) {
      ans += n % i;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int S[50];

int fib(int n){
  if(n==0||n==1){
    return S[n]=1;
  }
  if(S[n]!=-1){
    return S[n];
  }
  return S[n]=fib(n-1)+fib(n-2);
}

int main(){
  int i,n;
  for(i=0;i<50;i++)
    S[i]=-1;

  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}



Measured memory_bytes: 2104
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == (500 * i + 100 * j + 50 * k):
                count += 1
print(count)

Measured memory_bytes: 3064
n, k, s = map(int, input().split())

lst = []
if s == 10**9:
    for i in range(k):
        lst.append(10**9)
    for i in range(n-k):
        lst.append(1)
    print(' '.join(map(str, lst)))
else:
    for i in range(k):
        lst.append(s)
    for i in range(n-k):
        lst.append(10**9)
    print(' '.join(map(str, lst)))

Measured memory_bytes: 12056
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int sum[200010];
vector<int> G[200010];
void dfs(int x, int p = -1) {
    for(auto to: G[x]) {
        if(to == p) continue;
        sum[to] += sum[x];
        dfs(to, x);
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    rep(i, N - 1) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    while(Q--) {
        int p, x;
        cin >> p >> x;
        p--;
        sum[p] += x;
    }
    dfs(0);
    rep(i, N) {
        if (i != 0) cout << " ";
        cout << sum[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 23552
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<utility>
using namespace std;
 
 
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a<b && b<c)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int main(){

	int n = nxt();
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		cnt += nxt() % 2;
	}

	if (cnt % 2 == 1 && n > 1) {
		puts("NO");
	} else {
		puts("YES");
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Mod=1000000007;
int a[200005];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    int res=1;
    if(k==n || a[n]<0)
    {
        if(k&1)for(int i=n-k+1;i<=n;i++)
            res=1LL*res*a[i]%Mod;
        else for(int i=1;i<=k;i++)
            res=1LL*res*a[i]%Mod;
    }
    else
    {
        int l=1,r=n;
        if(k&1)res=1LL*res*a[r]%Mod,r--,k--;
        while(k)
        {
            if(1LL*a[l]*a[l+1]>1LL*a[r]*a[r-1])
                res=1LL*res*a[l]%Mod*a[l+1]%Mod,l+=2;
            else res=1LL*res*a[r]%Mod*a[r-1]%Mod,r-=2;
            k-=2;
        }
    }
    res=(res+Mod)%Mod;
    return 0*printf("%d\n",res);
}


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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        w: [i64; n],
    }
    let mut ans = 100000000000;
    for i in 0..n {
        let s1 = {
            let mut tmp = 0;
            for j in 0..i + 1 {
                tmp += w[j];
            }
            tmp
        };
        let s2 = {
            let mut tmp = 0;
            for j in i + 1..n {
                tmp += w[j];
            }
            tmp
        };
        ans = std::cmp::min(ans, (s1 - s2).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352