akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <random>
#include <cassert>
#include <complex>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef complex <LD> cld;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T1, typename T2>
T2 sum_mod(T1 x, T2 MOD) {
	if (x < 0)
		x += MOD;
	if (x >= MOD)
		x -= MOD;
	return x;
}

template <typename T1, typename T2>
T2 mul_mod(T1 x, T2 MOD) {
	if (x < 0)
		return (abs(x) % MOD == 0 ? 0 : MOD - abs(x) % MOD);
	return x % MOD;
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 gen_rand;

const int N = (int)1e5 + 7;
const int LOG = 20;
const int N_ = (int)8e2 + 7;
const int MAXN = (int)5e5 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const int CONST = 300;
const LL LINF = (i64)2e15;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1e-6;

/////////////////////////////////////////////////////////////////////

int n, a[N], p[N], q[N];

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
	gen_rand.seed(0);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	gen_rand.seed(time(0));
#endif

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		p[i]--;
	}
	for (int i = 0; i < n; i++) {
		cin >> q[i];
		q[i]--;
	}

	int p1 = -1, p2 = -1;
	for (int i = 0; i < n; i++)
		a[i] = i;
	int st = 1;
	do {
		bool fl = true;
		for (int i = 0; i < n; i++) {
			if (a[i] != p[i])
				fl = false;
		}
		if (fl) p1 = st;

		fl = true;
		for (int i = 0; i < n; i++) 
			if (a[i] != q[i])
				fl = false;

		if (fl) p2 = st;
		st++;
	} while (next_permutation(a, a + n));
	cout << abs(p1 - p2);
	

#ifdef _DEBUG 
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

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


int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	vector <ll> arr(5);
	for (int z=0;z<5;z++){
		cin >> arr[z];
	}
	ll answer = 0;
	ll mini = 10;
	for (int z=0;z<5;z++){
		if (arr[z]%10 == 0){
			answer += arr[z];
		} else {
			mini = min(mini,arr[z]%10);
			answer += 10*ceil(double(arr[z])/10);
		}
	}
	if (mini != 10){
		answer -= (10-mini);
	}
	cout << answer << endl;
	int n; cin >> n;
}

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

int main()
{
    // data (from stdin)
    char s[100],t[100];
    int l,flag;
    flag = 0;
    std::cin >> s >> t;
    l = strlen(s);
    for(int i=0;i<l;++i){
        if(flag==1){break;}
        for(int j=0;j<l;++j){
            if((j+i<l && s[j]!=t[j+i]) || (j+i>=l && s[j] != t[j+i-l])){break;}
            if(j==l-1){
                std::cout << "Yes" << endl;
                flag=1;
                break;
            }
        }
    }
    if(flag==0){std::cout << "No" << endl;}
}



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



int main(void)
{
    string x;
    cin >> x;

    int count = 0;
    for (int i = 0 ; i < x.size(); i++){
        if (x[i] == '2') count++;
    }
    cout << count << endl; 

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define ll long long

int main(void){
    int N,count=0;
    ll ans=0,mini=1000000001;
    cin>>N;
    vector<ll> A(N),B(N);
    for(int i=0;i<N;i++) {
        cin>>A.at(i);
        B.at(i)=labs(A.at(i));
        ans+=B.at(i);
        mini=min(mini,B.at(i));
        if(A.at(i)<0) count++;
    }
    if(count%2==0) cout<<ans<<endl;
    else cout<<ans-2*mini<<endl;
    return 0;
}


Measured memory_bytes: 1792
// i_m_arin

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<ll,ll> mpll;
typedef set<ll> stll;

#define f(i, a, n) 	for(ll i=a; i<(ll)n; i++)
#define f2(i, a, b) for(ll i=a; i<=(ll)b; i++)
#define pb 			push_back
#define ff 			first
#define ss 			second
#define pf			push_front
#define mp			make_pair
#define all(a)		(a).begin(),(a).end()
#define decimal(x)	fixed<<setprecision(x)
#define fsort(a)	sort(all(a))
#define rsort(a)	sort(all(a),greater<>())
#define fast_io		ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem0(a)		memset(a,0,sizeof(a))
#define mem1(a)		memset(a,-1,sizeof(a))
#define lcm(a,b)	(a*b)/__gcd(a,b)
#define ub(v,x)		upper_bound(all(v),x)-v.begin()
#define lb(v,x)		lower_bound(all(v),x)-v.begin()

const ld PI  = acos(-1);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll SIZE= 100000;


void solve(){

ll n;
cin>>n;
ll ans=0;

f(i,1,n+1){
	ll l=1,h=n;
	ll cnt=0;
	while(l<=h){
		ll mid=(l+h)/2;
		if(n-mid*i>0){
			cnt=mid;
			l=mid+1;
		}
		else{
			h=mid-1;
		}
	}
	//cout<<i<<" "<<cnt<<endl;
	ans+=cnt;
}
cout<<ans<<endl;

}


int main(){
	fast_io;
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    int ans = 1, n = a;
    while(n < b){
        n += a - 1;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
T = int(input())
for _ in range(T):
    N = int(input())
    A = [int(i) for i in input().split()]
    S = input()

    B = []
    ans = 0
    for a, s in zip(reversed(A), reversed(S)):
        for b in B:
            a = min(a, a ^ b)

        if a:
            if s == "1":
                ans = 1
                break
            B.append(a)

    print(ans)

Measured memory_bytes: 9148
/**
 *    author:  Atreus
**/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;

const int maxn = 1e5 + 10;
int a[maxn];
bool dp[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= k; i++){
		for (int j = 1; j <= n; j++){
			if (a[j] <= i){
				dp[i] |= (1 - dp[i - a[j]]);
			}
		}
	}
	if (dp[k] == 1)
		cout << "First\n";
	else
		cout << "Second\n";
}


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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
const int MOD = 1e9+7;
const int MAX = 1e5+5;

string s;
vector<int> a[30];

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  cin >> s;

  for(int i = 0 ; i < 26 ; i++)
  	a[i].pb(-1);

  for(int i = 0 ; i < (int)s.size() ; i++)
  	a[s[i] - 'a'].pb(i);

  for(int i = 0 ; i < 26 ; i++)
  	a[i].pb(s.size());
  
  int ans = s.size();

  for(int i = 0 ; i < 26 ; i++){
  	int lans = 0;
  	
  	for(int j = 1 ; j < a[i].size() ; j++)
  		lans = max(lans , a[i][j] - a[i][j-1] - 1);

  	ans = min(ans, lans);
  }

  cout << ans;
  return 0;
}  

Measured memory_bytes: 256
import sys
from collections import deque, Counter, defaultdict
from itertools import permutations
import heapq


def resolve():
    N, M = map(int, sys.stdin.readline().strip().split())
    adj_mat = [[False] * N for _ in range(N)]
    for _ in range(M):
        a, b = tuple(map(int, sys.stdin.readline().strip().split()))
        adj_mat[a-1][b-1] = True
        adj_mat[b-1][a-1] = True
    ans = 0
    for perm in permutations(range(N)):
        if perm[0] != 0:
            break
        cur = 0
        while cur < N - 1:
            if not adj_mat[perm[cur]][perm[cur+1]]:
                break
            cur += 1
        else:
            ans += 1

    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  long ans = 8;
  for(int i = 400; i <= 1999; i += 200){
    if(i <= N && N <= i + 199)break;
    ans--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>

int main(){
	int n,ining=0;
	int hit=0,out=0,count=0;
	std::cin>>n;
	while(ining!=n){
		std::string str;
		std::cin>>str;
		if(str=="HIT"){
			hit++;
			if(hit==4)hit=3,count++;
		}else if(str=="HOMERUN"){
			count+=hit+1;
			hit=0;
		}else if(str=="OUT"){
			out++;
			if(out==3){
				hit=0;
				out=0;
				ining++;
				std::cout<<count<<std::endl;
				count=0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
 
// max({a, b, c, d})

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

	string str[] = {"Sunny", "Cloudy", "Rainy"};

	if(s[0] == 'S') cout << str[1] << "\n";
	else if(s[0] == 'C') cout << str[2] << "\n";
	else cout << str[0] << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

typedef long long ll;

ll min(ll a, ll b){
	if(a<b){return a;}
	else{return b;}
}
ll max(ll a, ll b){
	if(a>b){return a;}
	else{return b;}
}

int main(){

	ll H,W;

	scanf("%lld %lld",&H,&W);

	ll i;

	ll H2=H;
	ll W2=W;

	ll ans=LLONG_MAX;

	for(i=1ll;i<W;i+=1ll){
		W2=W-i;
		ll T1=H2*i;
		ll T2=H2*W2;
		if(H2%2ll==0ll || W2%2ll==0ll){
			ans=min(ans,max(T2/2ll,T1)-min(T2/2ll,T1));
		}
		else{
		ll H3=H2/2ll;
		ll W3=W2/2ll;
		ll K1=max(max(W3*H2,T2-(W3*H2)),T1)-min(min(W3*H2,T2-(W3*H2)),T1);
		ll K2=max(max(H3*W2,T2-(H3*W2)),T1)-min(min(H3*W2,T2-(H3*W2)),T1);
		ans=min(ans,min(K1,K2));
		}
	}

	H2=H;
	W2=W;

	for(i=1ll;i<H;i+=1ll){
		H2=H-i;
		ll T1=W2*i;
		ll T2=H2*W2;
		if(H2%2ll==0ll || W2%2ll==0ll){
			ans=min(ans,max(T2/2ll,T1)-min(T2/2ll,T1));
		}
		else{
		ll H3=H2/2ll;
		ll W3=W2/2ll;
		ll K1=max(max(W3*H2,T2-(W3*H2)),T1)-min(min(W3*H2,T2-(W3*H2)),T1);
		ll K2=max(max(H3*W2,T2-(H3*W2)),T1)-min(min(H3*W2,T2-(H3*W2)),T1);
		ans=min(ans,min(K1,K2));
		}
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 128
def main():

    N = int(input())
    H = list(map(int, input().split()))
    prev = float('-inf')
    for i in range(len(H)):
        if H[i] > prev: prev = H[i]-1
        elif H[i] == prev: pass
        else: return "No"

    return "Yes"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int maxl=0;
  int wal=0;
  cin >> n;
  int l[10000];
  for(int i=0;i<n;i++){
    cin >> l[i];
    wal = wal+l[i];
    if(l[i]>=maxl){
      maxl=l[i];
  } else {}
}
if(maxl<wal-maxl){
  cout << "Yes" << endl;
} else {
  cout << "No" << endl;
}
}


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

ll x;

int main() {
    cin >> x;
    ll ans = 0;
    ll devi = x/11;
    ll modu = x%11;
    ans = devi*2;
    if (modu) ans += (modu>=7) ? 2 : 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# AOJ 1055 Huge Family
# Python3 2018.7.7 bal4u

# UNION-FIND library
class UnionSet:
	def __init__(self, nmax):
		self.size = [1]*nmax
		self.id = [i for i in range(nmax+1)]
	def root(self, i):
		while i != self.id[i]:
			self.id[i] = self.id[self.id[i]]
			i = self.id[i]
		return i
	def connected(self, p, q): return self.root(p) == self.root(q)
	def unite(self, p, q):
		i, j = self.root(p), self.root(q)
		if i == j: return
		if self.size[i] < self.size[j]:
			self.id[i] = j
			self.size[j] += self.size[i]
		else:
			self.id[j] = i
			self.size[i] += self.size[j]
# UNION-FIND library

def check(k, f):
	if cnt[k] == 0 or f > vmax[k]: cnt[k], vmax[k] = 1, f
	elif f == vmax[k]: cnt[k] += 1

while True:
	n = int(input())
	if n == 0: break
	u = UnionSet(n)
	f = [[0 for j in range(2)] for i in range(n)]
	cnt, vmax = [0]*n, [0]*n
	for i in range(n):
		a, f[i][0], b, f[i][1] = map(int, input().split())
		u.unite(i, a)
		u.unite(i, b)
	for i in range(n):
		k = u.root(i)
		check(k, f[i][0])
		check(k, f[i][1])
	ans = 1
	for i in range(n):
		if cnt[i]: ans = ans * (cnt[i] >> 1) % 10007
	print(ans)



Measured memory_bytes: 7176
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i=(a); i<(n); ++i)
#define rrep(i,a,n) for(ll i=(a); i>(n); --i)
#define erep(i,a,n) for(ll i=(a); i<=(n); ++i)
#define rerep(i,a,n) for(ll i=(a); i>=(n); --i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define print(X) cout << (X) << endl
#define _ << " " <<
static const int INF = 1e+9+7;

int main(){
  while(true){
    int n, n_min, n_max;
    cin >> n >> n_min >> n_max;
    if(n == 0 && n_max == 0 && n_min == 0) break;
    int A[1010] = {};
    rep(i,0,n) cin >> A[i];

    int tmp = 0;
    int num = 0;
    rep(i,n_min-1, n_max){
      if(tmp <= A[i] - A[i+1]){
        tmp = A[i] - A[i+1];
        num = i+1;
      }
    }
    print(num);
  }
  
  return 0;
}



Measured memory_bytes: 3084
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

int dfs(int cv, vector<vector<int>> &G){

    vector<int> depth;
    for(auto nv : G[cv]){
        int ndepth = dfs(nv, G) + 1;
        depth.emplace_back(ndepth);
    }

    sort(depth.begin(), depth.end(), greater<int>());

    int max_depth = 0;
    for(int i=0; i<depth.size(); i++){
        chmax(max_depth, depth[i] + i);
    }

    return max_depth;
}

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

    int n; cin>>n;
    vector<vector<int>> G(n);
    for(int i=1; i<n; i++){
        int a; cin>>a;
        a--;
        G[a].emplace_back(i);
    }

    cout << dfs(0, G) << endl;
}

Measured memory_bytes: 16640
#include<stdio.h>

int main(){

    int x[10000],i;

    for(i=1;i<=10000;i++)
    {
      scanf("%d",&x[i]);
      if(x[i]!=0){
         printf("Case %d: %d\n",i,x[i]);
      }else{
         break;
      }
     }
      
    return 0;

}


Measured memory_bytes: 2052
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define NMAX 100005
#define KMAX 50005

//??????????????¢??????????????¨debug()??????????????????
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int N,K,S[NMAX],T[KMAX],ans = 0;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};
void C(int num){
	int ub = N-1,lb = -1;
	while(ub - lb > 1){
		int mid = (ub+lb)/2;
		/*if(S[mid] == num){
			ans++;
			return;
		}else */if(S[mid] >= num){
			ub = mid;
		}else{
			lb = mid;
		}
	}
	if(S[ub] == num) ++ans;
}

void solve(){
	for (int i = 0; i < K; ++i)
	{
		C(T[i]);
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> S[i];
	}
	cin >> K;
	for (int i = 0; i < K; ++i)
	{
		cin >> T[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll = long long int;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll ans = a*c;
	ans = max(ans, a*d);
	ans = max(ans, b*c);
	ans = max(ans, b*d);
	cout << ans;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int M = sc.nextInt();
    Integer[] H = new Integer[N];
    for(int j = 0 ; j < N ; j++){
        H[j] = sc.nextInt();
    }
      
    Set<Integer> warui = new HashSet<>();
    for(int i = 0 ; i < M ; i++){
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      if(H[a] <= H[b])
        warui.add(a);
      if(H[b] <= H[a])
        warui.add(b);        
    }
	
	System.out.println(N - warui.size());
	}
}

Measured memory_bytes: 65200
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int D, G;
  cin >> D >> G;
  G /= 100;
  int p[D],c[D];
  FOR(i,0,D) {
    cin >> p[i] >> c[i];
    c[i] /= 100;
  }
  int ans = 1e9;
  FOR(i,0,1<<D){
    int cnt = 0, point = 0;
    int k = 0;
    FOR(j,0,D){
      // max正解
      if(i & (1 << j)) {
        point += p[j] * (j + 1) + c[j];
        cnt += p[j];
      } else {
        k = j;
      }
    }
    if(point >= G) {
      ans = min(ans, cnt);
    } else {
      FOR(j,1,p[k]+1) {
        point += k + 1;
        cnt++;
        if(point >= G) {
          ans = min(ans, cnt);
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int n = sc.nextInt();
		int a[] = new int[n];
		int d[] = new int[n];

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

		for (int i = 1; i < n; i++) {
			d[i] = a[i] - a[i - 1];
		}

		d[0] = a[0] + (k - a[n - 1]);

		Arrays.sort(d);

		int answer = 0;
		for (int i = 0; i < n - 1; i++) {
			answer += d[i];
		}

		System.out.println(answer);
		sc.close();

	}
}

Measured memory_bytes: 79740
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────


int main() {
	string s, t;
	int a, b;
	string g;
	cin >> s >> t >> a >> b >> g;
	if (s == g) a--;
	else b--;
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
vec = [0 for _ in range(4)]
for i in range(3):
    a,b = list(map(int,input().split()))
    a-=1
    b-=1
    vec[a]+=1
    vec[b]+=1

cnt = 0
for x in vec:
    if x%2==1:
        cnt+=1

if cnt >2:
    print('NO')
else:
    print('YES')

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

int main()
{
	string Tc, Hc;
	int n = 0, t = 0, h = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> Tc >> Hc;

		unsigned int j = 0;

		for (j = 0; j < max(Tc.size(), Hc.size()); j++){
			if (Tc[j] > Hc[j]) {
				t += 3;
				break;
			}
			else if (Tc[j] < Hc[j]) {
				h += 3;
				break;
			}
		}

		if ((j == Tc.size()) && (Tc.size() == Hc.size())) {
			t++;
			h++;
		}
	}

	cout << t << " " << h << endl;

    return 0;
}

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

int main(){
	int H[1000], W[1000];
	int ct = 0;
	while(true){
		cin >> H[ct] >> W[ct];
		if(H[ct] == 0 && W[ct] == 0) break;
		ct++;
	}
	for(int h = 0; h <= ct; h++){
		if(h != 0) cout << endl;
		for(int i = 0; i < H[h]; i++){
			for(int j = 0; j < W[h]; j++){
				if((i + j) % 2 == 0) cout << '#';
				else cout << '.';
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iterator>
#include <functional>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define sz(a)  int((a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define CLR(a) memset((a), 0, sizeof(a))
#define INF (1 << 31) - 1
const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1};
const int dw[8] = {0, 0, 1, -1,1,-1,1,-1};
typedef long long ll;
typedef pair<double, double> p;
typedef vector <int> VI;
typedef vector <string> VS;

int main(){
  
  int n, m;
	cin >> n;
  cin >> m;

  VI ans(n, 0);

  for(int i = 0; i < m; i++){
    int a,b;
    cin >> a;
    cin >> b;
    ans[a-1]++;
    ans[b-1]++;
  }

  for(int i = 0; i < n; i++){
    cout << ans[i] << endl;  
  }

	return 0;	
}


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

int main(){
  int a,b;
  cin >>a>>b;
  
  if(a>=13)
    cout << b << endl;
  else if(a<13 && a>5)
    cout << b/2 << endl;
  else
    cout << 0 << endl;
}

Measured memory_bytes: 256
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i,  r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define X real()
#define Y imag()
#define maxN 100005
#define oo 2000000007
#define EPS 1e-9

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

bool cmp(const ii &a, const ii &b) {
    return ((a.ff > b.ff) || (a.ff == b.ff && a.ss < b.ss));
}

int n, L, a[maxN];

int main () {
    scanf("%d%d", &n, &L);
    fto(i, 1, n) scanf("%d", &a[i]);

    int last = 0;
    fto(i, 1, n-1) {
        if (a[i]+a[i+1] >= L) last = i;
    }

    if (last == 0) puts("Impossible");
    else {
        puts("Possible");
        fto(i, 1, last-1) printf("%d\n", i);
        fdto(i, n-1, last) printf("%d\n", i);
    }

    return 0;
}


Measured memory_bytes: 1152
import heapq
from collections import defaultdict

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()


N = n()
M = 0
ds = [None] * N

edges = defaultdict(set)
ranks = [0] * N
for i in range(N-1):
    a, b = nl()
    edges[a-1].add(b-1)
    edges[b-1].add(a-1)
    ranks[a-1] += 1
    ranks[b-1] += 1
cs = sorted(nl())
M = sum(cs[:-1])

h = []
for i in range(N):
    heapq.heappush(h, (ranks[i], i))

for i in range(N):
    rank, node = heapq.heappop(h)
    ds[node] = cs[i]
    for next_node in edges[node]:
        ranks[next_node] -= 1
        heapq.heappush(h, (ranks[next_node], next_node))
        edges[next_node].remove(node)

print(M)
print(' '.join([str(d) for d in ds]))


Measured memory_bytes: 9472
#include<iostream>
using namespace std;
int calc_gcd(int a,int b){
  int x=a,y=b,z;
  if(x<y){
    z=x;
    x=y;
    y=z;
  }
  while(y>0){
    z=x%y;
    x=y;
    y=z;
  }
  return x;
}
int main(){
  int a,b;
  cin>>a>>b;
  cout<<calc_gcd(a,b)<<endl;
  return 0;
}

Measured memory_bytes: 1164
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    var x = sc.nextInt()
    val a = Array(n) { sc.nextInt() }.sorted()
    var ans = 0

    for (i in 0 until n) {
        if (x < a[i] || (i == n - 1 && x != a[i])) {
            break
        }
        ans++
        x -= a[i]
    }
    println(ans)
}


Measured memory_bytes: 36028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Input();
		long a = p[0].ToLong();
		long b = p[1].ToLong();
		long c = p[2].ToLong();
		long d = p[3].ToLong();
		
		long k = c / GCD(c,d)* d;
		long s = a / c;
		long t = a / d;
		long u = b / c;
		long v = b / d;
		
		long x = a / k;
		long y = b / k;
		
		long q = b - a;
		long r = (u - s) + (v - t) - (y - x);
		if(a % c == 0 || a % d == 0)
			r++;
		
		Console.WriteLine(q + 1 - r);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		int[] r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
	
}

Measured memory_bytes: 11092
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N;
        cin >> N;

        int ans = 0;
        for (int i = 1; i <= N; i += 2)
        {
                int cnt = 0;
                for (int j = 1; j <= i; j++)
                {
                        if (i % j == 0)
                        {
                                cnt++;
                        }
                }
                if (cnt == 8)
                {
                        ans++;
                }
        }
        cout << ans << endl;

        return 0;
}


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

using namespace std;

using ll = long long;

bool check(int mid, vector<ll> v) {
  for (int i = 1; i <= mid; ++i) {
    v[i] += v[i - 1];
  }
  for (int i = mid + 1; i < (int)v.size(); ++i) {
    if (v[i] > 2 * v[i - 1]) {
      return 0;
    } else {
      v[i] += v[i - 1];
    }
  }
  return 1;
}

int main() {
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int left = -1, right = n - 1;
  while (right - left > 1) {
    int mid = left + (right - left) / 2;

    if (check(mid, v))
      right = mid;
    else
      left = mid;
  }
  cout << n - right;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define fastIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define c(a) cout << a << "\n";
#define endl '\n'
const int MOD = 1e9 + 7;
const int N = 1e6 + 6;
vector<ll> g[N];
int main()
{

    ll n;
    cin >> n;
    ll sum = 0;
    ll ans=0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            for (int k = 1; k <= n; k++)
                ans += __gcd(k, __gcd(i, j));
        }
    }
    c(ans)

    return 0;
}

Measured memory_bytes: 27072
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main(){
    int n,a,b;
    cin >> n >> a >> b;
    if(n == 1){
        if(a == b)
        cout << 1 << endl;
        if(a != b)
        cout << 0 << endl;
    }
    if(n == 2)
    cout << 1 << endl;
    if(n >= 3){
        if( a > b)
        cout << 0 << endl;
        if(a <= b)
        {
            int ans = b * (n - 1) + a - a * (n - 1) - b + 1;
            cout << ans << endl;
        }
    }
}

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

int main() {
    int a, b, c;
    cin>>a>>b>>c;
    if (a > b) swap(a, b);
    if (a > c) swap(a, c);
    if (b > c) swap(b, c);
    cout<<a<<" "<<b<<" "<<c<<endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    string s;
    cin>>s;
    if(s[0]==s[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define ll long long
# define F first
# define S second
# define pb push_back
#define INF 1e9 + 7
 
const int N = 1e4 + 5;
typedef vector<int>vi;
typedef pair<int,int>ii;
typedef pair<int,ii>iii;
int arr[N],n;
int bs(int x){
  int l=0, r=n, m;
  while(r-l > 1){
    m = (l + r) / 2;
    if(arr[m] < x) l = m;
    else r = m;
  }
  return l;
}
int main() {
int a,b,c;  
  while(cin >> a >> b >> c){
    if(a+b+c>21)cout << "bust\n";
    else cout << "win\n";
  }    
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll a,b;
main() {
    file("dishes");
    ios;
    cin>>a>>b;
    if (a>b) swap(a,b);
    ll diff=b-a;
    if (diff&1) return !(cout<<"IMPOSSIBLE");
    cout<<a+(diff/2);
    return 0;
}
/**

*/


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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n;cin >> n;
       cout << n * (n+1)/2;
	
	return 0;
}


Measured memory_bytes: 256
class DSUWeighted():
    def __init__(self, n):
        self.n = n
        self.par_size = [-1] * n
        self.wt = [0] * n

    def leader(self, a):
        #assert 0 <= a < self.n
        x = a
        order = [x]
        while self.par_size[x] >= 0:
            x = self.par_size[x]
            order.append(x)
        for s in order[:-1][::-1]:
            self.wt[s] += self.wt[self.par_size[s]]
            self.par_size[s] = x
        return x

    def same(self, a, b):
        #assert 0 <= a < self.n
        #assert 0 <= b < self.n
        return self.leader(a) == self.leader(b)

    def merge(self, a, b, w):
        #assert 0 <= a < self.n
        #assert 0 <= b < self.n
        x = self.leader(a)
        y = self.leader(b)
        w += self.wt[a] - self.wt[b]
        if x == y: return x
        if -self.par_size[x] < -self.par_size[y]:
            x, y = y, x
            w = -w
        self.par_size[x] += self.par_size[y]
        self.par_size[y] = x
        self.wt[y] = w
        return x

    def diff(self, x, y):
        return self.wt[y] - self.wt[x]

import sys
input = sys.stdin.buffer.readline

N, M = map(int, input().split())

uf = DSUWeighted(N)

for _ in range(M):
    l, r, d = map(int, input().split())
    if uf.same(l - 1, r - 1):
        if uf.diff(l - 1, r - 1) != d:
            print('No')
            break
    else:
        uf.merge(l - 1, r - 1, d)
else:
    print('Yes')

Measured memory_bytes: 71792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		char op = sc.next().charAt(0);
		int b = sc.nextInt();

		switch(op) {
		case '+' :
			System.out.println(a + b);
			break;
		case '-' :
			System.out.println(a - b);
		}
	}
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int A,B,C;
  cin>>A>>B>>C;
  if(A==B)cout<<C<<endl;
  if(B==C)cout<<A<<endl;
  if(A==C)cout<<B<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
vector<int> G[123456];
int dp[123456],k;
void dfs(int cur,int pre,int deep,int kk){
	int sz=G[cur].size(),dd=1;
	if(deep<2) dd=0;
	for(int i=0;i<sz;i++){
		int nxt=G[cur][i];
		if(nxt==pre) continue;
		dfs(nxt,cur,deep+1,k-dd-1);
		dd++;
		dp[cur]*=dp[nxt];
		dp[cur]%=mod;
	}
	dp[cur]*=kk;
	dp[cur]%=mod;
}
int32_t main(){
	ios::sync_with_stdio();
	cin.tie(0);
	int n;cin>>n>>k;
	for(int i=0;i<=n;i++) dp[i]=1;
	for(int i=0;i<n-1;i++){
		int u,v;cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0,1,k);
	cout<<dp[1]<<endl;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<ll> sell(n);
    rep(i, n) {
        ll l = 0;
        rep(j, 10) {
            l = (l << 1);
            int k;
            cin >> k;
            if (k == 1) {
                l++;
            }
        }
        sell[i] = l;
    }

    vector<vector<ll>> benefit(n, vector<ll>(11));
    rep(i, n) rep(j, 11) cin >> benefit[i][j];
    ll ans = -INF;
    for (ll i = 1; i < (1 << 10); i++) {
        ll now = 0;
        for (int j = 0; j < n; j++) {
            ll k = i & sell[j];
            ll m = __builtin_popcountll(k);
            now += benefit[j][m];
        }
        cmax(ans, now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MOD = 1e9+7;


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) {
    int x; cin >> x;
    a[x]++;
  }
  ll ans = 1;
  int i;
  if(n%2==0) i = 1;
  else {
    i = 2;
    if(a[0]!=1) ans = 0;
  }
  while(i < n) {
    if(a[i]==2) ans *= 2;
    else ans *= 0;
    i += 2;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<cstdio>
#define ll long long
#define N 310
using namespace std;
ll C[N][N],f[N][N],s[N][N];
int n,K,mod;
int main()
{
    scanf("%d%d%d",&n,&K,&mod); 
    C[0][0]=1;
    for(int i=1;i<=n;C[i][0]=1,i++)
        for(int j=1;j<=i;j++)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
    for(int j=0;j<=K;j++)
        f[1][j]=1,s[1][j]=K-j+1;
    for(int i=2;i<=n+1;i++)
    {
        for(int j=0;j<=K;j++)
            for(int k=1;k<i;k++)
                f[i][j]=(f[i][j]+f[i-k][j]*s[k][j+1]%mod*C[i-2][k-1])%mod;  
        for(int j=K;j>=0;j--)
            s[i][j]=(f[i][j]+s[i][j+1])%mod;
    }
    printf("%lld",f[n+1][0]);           
    return 0;
}

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

int main() {
    vector<int> x;
    vector<int> y;
    int a, b;
    for(int i = 0; i < 2;i ++) {
        cin >> a >> b;
        x.push_back(a);
        y.push_back(b);
    }
    int diff_x = x[1]-x[0];
    int diff_y = y[1]-y[0];
    x.push_back(x[1]-diff_y);
    x.push_back(x[0]-diff_y);
    y.push_back(y[1]+diff_x);
    y.push_back(y[0]+diff_x);
    cout << x[2] << " " << y[2] << " " \
         << x[3] << " " << y[3] << endl;
    return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int a, b;
    cin >> a >> b;

    // 処理
    // 出力
    cout << max({a + b, a - b, a * b}) << endl;

    return 0;
}


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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i = 1; i <= N; ++i) {
    int sum = findSumOfDigits(i);
    if (sum >= A && sum <= B) {
      total += i;
    }
  }
  cout << total << endl;
}

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

int main() {
  int N; cin >> N;
  vector<string> s(N);
  for (int i =0; i<N; i++) {
    string a; cin >> a;
    sort(a.begin(),a.end());
    s.at(i) = a;
  }
  
  map<string,int> mapS;
  for (int i =0; i<N; i++) {
    if (mapS.count(s.at(i))) {
      mapS[s.at(i)]++;
    } else {
      mapS[s.at(i)] = 1;
    }
  }
  
  long count =0;
  for (auto x: mapS) {
    long countS = x.second;
    count += (countS * (countS - 1)) / 2;
  }
  cout << count << endl;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int H, W;
  cin >> H >> W;
  int A, B;
  cin >> A >> B;

  vector<string> ans(H, string(W, '1'));

  rep(i, 0, B) {
    rep(j, 0, A) { ans[i][j] = '0'; }
  }

  rep(i, B, H) {
    rep(j, A, W) { ans[i][j] = '0'; }
  }

  for (auto s : ans) {
    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 2304