akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()

template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 5e18;
// const double PI = atan(1.0) * 4.0;
const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238

ll dp[5001][5001];

signed main() {
    LCIN(N);
    SCIN(S);
    REPR(i, N - 1) REPR(j, N - 1) {
        if(S[i] == S[j]) {
            dp[i][j] = dp[i + 1][j + 1] + 1;
        }
    }
    ll ans = 0;
    REP(i, N) REP(j, N) { ans = max(ans, min(dp[i][j], j - i)); }
    cout << ans << "\n";
}


Measured memory_bytes: 195584
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2")
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<set>
#include<unordered_map>
#include<assert.h>
#include<time.h>
#include<stdlib.h>
#include<random>
#include<queue>
using namespace std;
using lld = long long int;
using pll = pair<lld, lld>;
using lf = double;
using pff = pair<lf, lf>;
using pif = pair<int, lf>;
using pii = pair<int, int>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
using piii = pair<int, pii>;
#define M 998244353
int n, m;
pii a[11];
vector<pll> v[11];
/*
vector<pll> mult(vector<pll>& p, vector<pll>& q) {
	vector<pll> res;
	vector<pll> c;
	int i, j, k;
	int pl = p.size();
	int ql = q.size();
	for (i = 0; i < pl; i++) {
		for (j = 0; j < ql; j++) {
			pll cur;
			cur.first = p[i].first + q[j].first;
			cur.second = (p[i].second * q[j].second)%M;
			res.push_back(cur);
		}
	}
	sort(res.begin(), res.end());
	for (i = 0; i < res.size();) {
		lld vv = 0;
		if (res[i].first > n)break;
		for (j = i; j < res.size(); j++) {
			if (res[i].first != res[j].first) {
				break;
			}
			vv = (res[i].second + vv) % M;
		}
		c.push_back(pll(res[i].first, vv));
		i = j;
	}
	return c;
}
*/
vector<lld> divv(vector<pll>& p) {
	vector<lld> res(n + 1, 0);
	vector<lld> a(n + 1, 0);
	a[0] = 1;
	a[1] = M - 1;
	int i, j, k;
	for (i = 0; i <= n; i++) {
		if (a[i] > 0) {
			res[i] = a[i];
			for (auto& it : p) {
				j = i + it.first;
				if (j <= n) {
					lld k = (res[i] * it.second) % M;
					a[j] = (a[j] + M - k) % M;
				}
			}
		}
	}
	return res;
}
int main() {
	int i, j, k, l;
	int t = 1, tv = 0;
	//scanf("%d", &t);
	while (t--) {
		scanf("%d %d", &n, &m);
		vector<pll> r;
		r.push_back(pll(0, 1));
		r.push_back(pll(1, M-1));
		for (i = 0; i < m; i++) {
			scanf("%d %d", &a[i].first, &a[i].second);
			a[i].second++;
			r.push_back(pll(a[i].first, M - 1));
			r.push_back(pll(a[i].second, 1));
		}
		sort(r.begin(), r.end());
		vector<pll> rv;
		for (i = 0; i < r.size();) {
			lld cur = 0;
			for (j = i; j < r.size(); j++) {
				if (r[i].first != r[j].first)break;
				cur = (cur + r[j].second) % M;
			}
			rv.push_back(pll(r[i].first, cur));
			i = j;
		}
		vector<lld> res = divv(rv);
		/*
		for (auto& it : rv) {
			printf("%lld %lld\n", it.first, it.second);
		}
		for (auto& it : res) {
			printf("%lld ", it);
		}
		*/
		printf("%lld\n", res[n - 1]);
	}
	return 0;
}

Measured memory_bytes: 5952
#include<stdio.h>
#include<string.h>
int main()
{
	int n,s,b;
	scanf("%d",&n);
	s=0;
	b=n;
	while(n!=0){
		s+=n%10;
		n/=10;
	}
	if(b%s==0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    d={"a":0,"b":1,"c":2}
    win=["A","B","C"]
    s=[0]*3
    s[0]=list(readline().rstrip())
    s[1]=list(readline().rstrip())
    s[2]=list(readline().rstrip())

    turn=0
    while 1:
        if len(s[turn])==0:
            print(win[turn])
            return
        turn=d[s[turn].pop(0)]
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()


Measured memory_bytes: 5628
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int A[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	sort(A,A+n);
	if(A[0]==A[n-1])
	{
		if(A[0]==n-1) puts("Yes");
		else
		{
			int s=1,t=n/2;
			if(s<=A[0]&&A[0]<=t) puts("Yes");
			else puts("No");
		}
	}
	else
	{
		if(A[0]+1<A[n-1])
		{
			puts("No");
		}
		else
		{
			int c=0,d=0;
			for(int j=0;j<n;j++)
			{
				if(A[j]==A[0]) c++;
				else d++;
			}
			if(d==1) puts("No");
			else
			{
				int s=c+1,t=c+d/2;
				if(s<=A[n-1]&&A[n-1]<=t) puts("Yes");
				else puts("No");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    string s;
    bool ok=true;
    cin>>s;
    int cnt=0;
    if (s[0]!='A') ok=false;
    for (int i=2; i<=s.size()-2; i++) if (s[i]=='C') cnt++;
    if (cnt!=1) ok=false;
    cnt=0;
    for (int i=1; i<s.size(); i++)
    {
        if (!(s[i]>='a' && s[i]<='z')) cnt++;
    }
    if (cnt!=1) ok=false;
    if (ok) cout<<"AC\n";
    else cout<<"WA\n";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
lists = []
AC = 0
TLE = 0
WA = 0
RE = 0
for i in range(N):
    S = str(input())
    lists.append(S)
for o in lists:
    if o == "AC":
        AC +=1
    elif o == "TLE":
        TLE +=1
    elif o == "WA":
        WA +=1
    elif o == "RE":
        RE +=1
print("AC x "+str(AC))
print("WA x "+str(WA))
print("TLE x "+str(TLE))
print("RE x "+str(RE))

Measured memory_bytes: 16148
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD=1e9+7;
void solve(){
	int n,m,c;
	cin>>n>>m>>c;
	vector<int> b(m);
	for(auto &it:b)cin>>it;
	vector< vector<int> > a(n,vector<int>(m));
	for(int i=0;i<n;i++){
	  for(int j=0;j<m;j++){
		   cin>>a[i][j]; 
		 }	
	 }
	int val=0;
    for(int i=0;i<n;i++){
	  int cnt=0;
	  for(int j=0;j<m;j++){
		   cnt+=a[i][j]*b[j];
		 }
		if(cnt>-c)val++;
	}
	cout<<val<<endl;
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
  }

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

const ll N_MAX = 202020;

struct RAQSB{
	ll N;
	ll sN;
	ll data[N_MAX];
	ll bucket[N_MAX];

	RAQSB(ll n){
		sN = (ll)sqrt(n) + 1;
		N = sN * sN;
		REP(i, N_MAX){
			data[i] = 0;
			bucket[i] = 0;
		}
	}

	void add(ll s, ll t, ll x){
		ll ss = s/sN;
		ll tt = t/sN;
		if(ss==tt){
			for(int i=s;i<t;i++){
				data[i] += x;
			}
		}else{
			for(int i=s;i<(ss+1)*sN;i++){
				data[i] += x;
			}
			for(int i=tt*sN;i<t;i++){
				data[i] += x;
			}
			for(int i=ss+1;i<tt;i++){
				bucket[i] += x;
			}
		}
	}

	ll get_val(ll i){
		return data[i] + bucket[i/sN];
	}
};

int main(){
	ll n, q;
	cin >> n >> q;
	RAQSB raqsb(n);
	REP(i, q){
		ll a, b, c, d;
		cin >> a;
		if(a==0){
			cin >> b >> c >> d;
			b--;c--;
			raqsb.add(b, c+1, d);
		}else{
			cin >> b;
			b--;
			cout << raqsb.get_val(b) << endl;
		}
	}
    return 0;
}


Measured memory_bytes: 6248
import copy
import math
import time
import statistics
import math
import itertools
import bisect
import sys
from decimal import *
from collections import deque


def get_int():
    return int(input())

def get_string():
    return input()

def get_int_list():
    return [int(x) for x in input().split()]

def get_string_list():
    return input().split()

def get_int_multi():
    return map(int, input().split())

def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# a_list = [0] * a
sys.setrecursionlimit(10 ** 6)

def main():
    start = time.time()

    s = get_string()
    t = get_string()

    ans = 10**5
    for i in range(len(s)-len(t)+1):
        wk = 0
        for ii in range(len(t)):
            if s[i+ii] != t[ii]:
                wk += 1
        ans = min(ans, wk)
    print(ans)



    #print(time.time() - start)


if __name__ == '__main__':
    main()

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

signed main(){
	int h;
	cin>>h;
	int a=1;
	int cnt=1;
	while(a*2<=h){
		a*=2;
		cnt=cnt*2+1;
	}
	a/=2;
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int s;
	cin >> s;
	int a = s / 100, b = s % 100;
	if ((a > 12 || a == 0) && (b == 0 || b > 12)) {
		cout << "NA\n";
	}
	else if (a > 12 || a == 0) {
		cout << "YYMM\n";
	}
	else if (b > 12 || b == 0) {
		cout << "MMYY\n";
	}
	else {
		cout << "AMBIGUOUS\n";
	}
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[[] for _ in range(n)]
ans=[None]*m

for i in range(m):
  p,y=map(int,input().split())
  a[p-1].append((y,i))
  
for i,b in enumerate(a):
  b.sort()
  for j,(y,k) in enumerate(b):
    ans[k]='%06d%06d' % (i+1,j+1)
    
print(*ans,sep='\n')

Measured memory_bytes: 37480
def solve(string):
    count = dict([])
    n, *rest = string.split()
    n = int(n)
    blues = rest[:n]
    m = rest[n]
    reds = rest[n + 1:]
    for key in blues:
        if key in count:
            count[key] += 1
        else:
            count[key] = 1
    for key in reds:
        if key in count:
            count[key] -= 1
        else:
            count[key] = -1
    num = 0
    for k, v in count.items():
        if num < v:
            num = v
    return str(num)


if __name__ == '__main__':
    n = int(input())
    ins = '{}\n'.format(n) + '\n'.join([input() for _ in range(n)])
    m = int(input())
    print(solve(ins + '\n{}\n'.format(m) + '\n'.join([input() for _ in range(m)])))


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

int main() {
  long long N;
  string S;
  cin >> N >> S;
  
  char c;
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if (c != S[i]) {
      c = S[i];
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 512
//Integral????§£???????????????????????????????????°10??? ????????¢???????????¢?????????????¨????????????????
#include <iostream>
using namespace std;

int main() {
  int d;
  while(cin >> d) {
    int sum = 0;
    int n = 1;
    while(n * d < 600) {
      sum += n*d * n*d * d;
      n++;
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 3016
let ans, n = ref 0, Scanf.scanf " %d" (+) 0
let ls = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let g i k a = a.(i) <= k
let f k l a = let l, r = ref @@ l - 1, ref @@ Array.length a in while !r - !l > 1 do let m = !l + (!r - !l) / 2 in if g m k a then r := m else l := m done; !r
let _ = Array.(sort (fun x y -> y - x) ls; for i = 0 to n - 3 do for j = i + 1 to n - 2 do ans := !ans + f (ls.(i) - ls.(j)) (j + 1) ls - j - 1 done; done); Printf.printf "%d\n" !ans

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N, M;
  cin >> N >> M;
  set<int> n1;
  set<int> n2;
  int a, b;
  rep(i, 0, M) {
    cin >> a >> b;
    if (a == 1) n1.insert(b);
    if (b == N) n2.insert(a);
  }
  vector<int> num;
  set_intersection(all(n1), all(n2), back_inserter(num));
  if (num.size() > 0)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 9600
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};
const main=()=>{
  let [w,h,x,y]=tnn(4),d=0
  if(h/2==y&&w/2==x)d=1
  to(w*h/2+' '+d)
}
main()


Measured memory_bytes: 7628
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<unordered_map>
 
#include<unordered_map>
#include<algorithm>
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
 
#define ii pair<int,int>
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;
 
const int maxn = 1e5 + 10;
const int MAX = 5e3 + 10;
typedef long long ll;
typedef vector< int> vi;		



//~ https://www.youtube.com/watch?v=WuWDvG1AXF4


int main (){
	
	int x, y;
	cin >> x >> y;
	string a, b;
	for(int i = 0 ;i < y;i++){
		a+=x+48;
	}
	for(int i = 0 ;i < x;i++){
		b+=y+48;
	}
	
	if ( a < b )
		cout << a << '\n';
	else
		cout << b << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 610000;

int a[maxn],n,k;
int sum;
void mul()
{
	for(int i=0;i<n;i++) a[i]*=9;
	for(int i=0;i<n;i++) if(a[i]>9)
	{
		a[i+1]+=a[i]/10;
		a[i]%=10;
	}
	while(a[n]) n++;
	for(int i=0;i<n;i++) sum+=a[i];
}
void add()
{
	a[0]+=9; sum+=9;
	int nowi=0;
	while(a[nowi]>9)
	{
		sum++; a[nowi+1]++;
		sum-=10; a[nowi++]-=10;
	}
	if(a[n]) n++;
}

int main()
{
	char c;
	while((c=getchar())>='0'&&c<='9') a[n++]=c-'0';
	for(int i=0;i<n-i-1;i++) swap(a[i],a[n-i-1]);
	mul();
	for(int k=1;k<=n;k++)
	{
		add();
		if(sum<=9*k) return printf("%d\n",k),0;
	}
	
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	cout << fixed << setprecision(10);
	double x = double(n) / 3;
	cout << x * x * x << endl;
}


Measured memory_bytes: 256
import sys
from collections import deque
read = sys.stdin.read

def main():
    N, *ab = map(int, read().split())
    E = [[] for _ in range(N + 1)]
    edge_order = []
    
    for a, b in zip(*[iter(ab)] * 2):
        E[a].append(b)
        edge_order.append(b)
    
    # 頂点1から幅優先探索
    queue = deque([1])
    color = [0] * (N+1) 
    while queue:
        V = queue.popleft()
        c = 1
        for i in E[V]:
            if c == color[V]:
                c += 1
            color[i] = c
            c += 1
            queue.append(i)

    print(max(color))
    for i in edge_order:
        print(color[i])


if __name__ == "__main__":
    main()


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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL
// {{{ define basic macro
// #define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii, vii, greater<pii> > spq;  //pop, topで最小値
int dx[]={1, -1, 0, 0, 0};
int dy[]={0, 0, 1, -1, 0};
//}}}


int solve(){
  string s, t;
  cin >>s>>t;

  string u;
  rep(i, sz(s)){
    u = s.substr(sz(s)-i, i) + s.substr(0, sz(s)-i);
    if (u==t) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll dp[105][100005];
ll w[105],v[105];
ll n,k;

int main(){
    cin>>n>>k;

    ll sum=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=100000;j++)
            dp[i][j]=1e18;
    }
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }

    for(int i=1;i<=n;i++){
        for(int j=0;j<=100000;j++)
            dp[i][j]=dp[i-1][j];
        dp[i][v[i-1]]=min(dp[i][v[i-1]],w[i-1]);

        for(int j=0;j<=100000;j++){
            if(j+v[i-1]<=100000)
                dp[i][j+v[i-1]]=min(dp[i][j+v[i-1]],dp[i-1][j]+w[i-1]);
        }
    }

    int ans=0;

    for(int i=0;i<=100000;i++){
        if(dp[n][i]<=k)
            ans=i;
    }
    cout<<ans;
}

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

#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

void solve(void) {

	int n;
	cin >> n;

	int base = 1;
	while(base <= n) {
		base *= 2;
	}

	vector<ll> tree(2*base);

	vector<ll> A(n), h(n);

	for(ll& x : h) cin >> x;
	for(ll& x : A) cin >> x;

	vector<ll> dp(n+1);
	// dp[i] = max total beauty so far if last taken flower has height i

	for(int flower = 0; flower < n; flower++) {
		int x = h[flower] + base;

		ll best = 0;
		while(x > 1) {
			if(x % 2 == 1) {
				best = max(best, tree[x-1]);
			}
			x /= 2;
		}

		dp[h[flower]] = best + A[flower];

		// update the segment tree
		for(int i = base + h[flower]; i >= 1; i /= 2) {
			tree[i] = max(tree[i], dp[h[flower]]);
		}

		// for(int i = 0; i < x; i++) {
		// 	dp[x] = max(dp[x], dp[i] + A[flower]);
		// }
	}

	ll ans = 0;
	for(int i = 0; i <= n; i++) {
		ans = max(ans, dp[i]);
	}

	cout << ans << '\n';
}

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


Measured memory_bytes: 9088
# C　Sum of product of pairs
N = int(input())
A = list(map(int, input().split()))
t = sum(A)
x = t - A[0]
mod = 10 ** 9 + 7
ct = 0
for i in range(N-1):
    ct += A[i] * x
    x = x - A[i+1]

print((ct % mod))
int((ct % mod))


Measured memory_bytes: 31692
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int k;
  cin>>k;
  string s;
  cin>>s;
  if (s.size() > k) {
    cout<<s.substr(0,k)<<"...\n";
  } else {
    cout<<s<<endl;
  }
  return 0;
}


Measured memory_bytes: 3612
# https://atcoder.jp/contests/abc064/tasks/abc064_c

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

def main():
    N = int(input())
    A = list(map(int, input().split()))

    ratings = [0] * 9
    for a in A:
        ratings[min(a // 400, 8)] += 1

    # print(ratings)

    fixed_colors = 0
    for r in range(len(ratings) - 1):
        if ratings[r] > 0:
            fixed_colors += 1

    everything_ok = ratings[-1]

    min_colors = fixed_colors if fixed_colors > 0 else 1
    max_colors = fixed_colors + everything_ok
    print('{} {}'.format(min_colors, max_colors))


if __name__ == '__main__':
    main()


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


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


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

	int n[100001][26];

	int tugi[26];
	rep(i, 26) tugi[i] = -1;
	for (int i = N - 1; i >= 0; i--) {
		rep(j, 26) n[i][j] = tugi[j];
		int c = S[i] - 'a';
		tugi[c] = i;
	}
	for (int i = N - 1; i >= 0; i--) {
		rep(j, 26) n[i][j] = tugi[j];
		int c = S[i] - 'a';
		tugi[c] = i;
	}


	int OK = 1;
	ll kotae = 0;
	int k = N - 1;
	rep(i, (int)T.size()) {
		int c = T[i] - 'a';
		int k2 = n[k][c];
		if (k2 == -1) {
			OK = 0;
			break;
		}

		if (k2 > k) kotae += k2 - k;
		else kotae += k2 - k + N;
		k = k2;
	}

	if (OK) co(kotae);
	else co(-1);

	Would you please return 0;
}

Measured memory_bytes: 10704
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n >> s;
	bool ans = true;
	if (n % 2){
		ans = 0;
	}
	for (int i = 0; i < n / 2; i++){
		if (ans&&s.at(i) != s.at(i + (n / 2))) {
			ans = 0;
			break;
		}
	}
	if (ans){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

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

int main(){
   int N, M, X;
   cin >> N >> M >> X;
   vector<int> C(N);
   vector<vector<int>> A(N, vector<int> (M));
   for (int i=0; i<N; i++){
      cin >> C.at(i);
      for (int j=0; j<M; j++){
         cin >> A.at(i).at(j);
      }
   }

   int price_min = accumulate(C.begin(), C.end(), 0);
   bool flag = false;
   for (int i=0; i<=pow(2, N)-1; i++){
      stringstream ss;
      ss << bitset<12>(i);
      string bi = ss.str();
      reverse(bi.begin(), bi.end());
      vector<int> Asum(M, 0);
      int price = 0;
      for (int i=0; i<N; i++){
         if (bi.at(i) == '1'){
            price = price + C.at(i);
            for (int j=0; j<M; j++){
               Asum.at(j) = Asum.at(j) + A.at(i).at(j);
            }
         }
      }
      //std::cerr << bi << " " << price << " ";
      //for (int j=0; j<M; j++){
      //   std::cerr << Asum.at(j) << " ";
      //}
      //std::cerr << std::endl;
      if (std::all_of(Asum.begin(), Asum.end(), [=](auto val){return val >= X;})){
         price_min = min(price, price_min);
         flag = true;
      }
   }
   if (flag)
      std::cout << price_min << std::endl;
   else
      std::cout << -1 << std::endl;

}



Measured memory_bytes: 4104
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] w = new int[n];

        long minP = 0;
        long maxP = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            minP = Math.max(minP, w[i]);
            maxP += w[i];
        }

        // kは固定して、pをminPからmaxPまで調べる。
        // tempN = f(p, k, w) が初めてn以上になるpを求める。
        long midP = 0;
        while (maxP > minP) {
            midP = (maxP + minP) / 2;
            int tempN = f(midP, k, w);
            
            if (tempN >= n) maxP = midP;
            else if (tempN < n) minP = midP + 1;
        }
        System.out.println(maxP);
    }
    
    // 最大積載量pのトラックk台に、wの要素はいくつ載せられるか?
    static int f(long p, int k, int[] w) {
        int i = 0;
        for (int iK = 0; iK < k; iK++) {
            int pK = 0;
            while (pK + w[i] <= p) {
                pK += w[i];
                i++;
                if (i == w.length) return w.length;
            }
        }
        return i;
    }
}



Measured memory_bytes: 70468
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
 
#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;
 
ll n, k, cnt;
 
int main() {
	cin >> n >> k;
	cnt = 0;
	if (k == 0) {
		cnt = n*n;
	}
	else
		for (int i = k + 1; i <= n; i++)
			cnt += (i - k)*(n / i) + max(ll(0), n%i - (k - 1));
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int m;
  cin>>m;
  vector<int>b(m);
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  if(n<m){
    cout<<"NO"<<endl;
  }else{
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int j=0;
    int cnt=0;
    for(int i=0;i<b.size();i++){
      int flag=0;
      for(;j<a.size();j++){
	if(b[i]==a[j]){
	  cnt++;
	  j++;
	  break;
	}else if(b[i]<a[j]){
	  flag=1;
	  break;
	}
      }
      if(flag)
	break;
    }
    if(cnt==m)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<ctime>
#include<set>
#include<iomanip>
#define sqr(x) (x)*(x)
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
//#define T_ int
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
//struct bit_2d{T_ a[2005][2005];int lowbit(int x){return x&(-x);}void add(int x,int y,T_ z){int i,j;for (i=x;i<=2000;i+=lowbit(i)){for (j=y;j<=2000;j+=lowbit(j)){a[i][j]+=z;}}}T_ query(int x,int y){int i,j;T_ s=0;for (i=x;i;i-=lowbit(i)){for (j=y;j;j-=lowbit(j)){s+=a[i][j];}}return s;}T_ query(int x,int y,int xx,int yy){return query(xx,yy)-query(x-1,yy)-query(xx,y-1)+query(x-1,y-1);}};
long long n,m,i,j,f[200005],g[200005],a[200005],ans;
int main()
{
	scanf("%lld%lld",&n,&m);
	ans=m*(n-1);
	fz1(i,n)
	{
		scanf("%lld",&a[i]);
		ans+=a[i];
	}
	f[0]=g[n+1]=(1ll<<60);
	fz1(i,n)
	{
		f[i]=min(a[i],f[i-1]+m);
	}
	fd1(i,n)
	{
		g[i]=min(a[i],g[i+1]+m);
	}
	fz(i,2,n-1) ans+=min(f[i],g[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main()
{
    int n{};
    int k{};
    cin >> n >> k;
    int h{};
    int cnt;
    for (int i=1;i<=n;i++){
        cin >> h;
        if (h>=k)
            ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cerr<<"\tDEBUG: "<<#x<<" = "<<(x)<<endl
#define debug2(a,x) cerr<<#a<<"\tDEBUG: "<<#x<<" = "<<(x)<<endl
using namespace std;
const int maxn=1e5+100,P=1e9+7;
int n,K;
int tot,head[maxn],to[maxn<<1],nxt[maxn<<1];
void add_edge(int u,int v){
	to[++tot]=v;
	nxt[tot]=head[u];
	head[u]=tot;
}
long long qpow(long long p,long long q){
	long long res=1;
	while(q){
		if(q&1)res=res*p%P;
		p=p*p%P;
		q>>=1;
	}
	return res;
}
long long f[maxn],fr[maxn];
void init(){
	f[0]=1;
	for(int i=1;i<maxn;i++)
		f[i]=f[i-1]*i%P;
	for(int i=0;i<maxn;i++)
		fr[i]=qpow(f[i],P-2);
}
long long C(int a,int b){
	if(a-b<0)return 0;
	return f[a]*fr[b]%P*fr[a-b]%P;
}
long long A(int a,int b){
	if(a-b<0)return 0;
	return f[a]*fr[a-b]%P;
}
long long dp[maxn];
int cnt[maxn];
void dfs(int f,int x){
	long long tmp=1;
	for(int i=head[x];i;i=nxt[i]){
		int y=to[i];
		if(y==f)continue;
		dfs(x,y);
		tmp=tmp*dp[y]%P*qpow(C(K-1,cnt[y]),P-2)%P*C(K-2,cnt[y])%P;
		cnt[x]++;
	}
	tmp=tmp*A(K-1,cnt[x])%P;
	dp[x]=tmp;
}
int main(){
	init();
	cin>>n>>K;
	if(K==1){
		if(n==1)puts("1");
		else puts("0");
		return 0;
	}else if(K==2){
		if(n==1)puts("2");
		else if(n==2)puts("2");
		else puts("0");
		return 0;
	}
	for(int i=1,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		add_edge(x,y);
		add_edge(y,x);
	}
	dfs(0,1);
	cout<<dp[1]*K%P<<endl;
    return 0;
}

Measured memory_bytes: 10752
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first2 1
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n , m ;
	cin>>n >> m ;
	ll ans = (n*(n-1))/2 + (m*(m-1))/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// Author by Md. Jashim Uddin_RMSTU

#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long int
#define     fast            ios_base :: sync_with_stdio(false);cin.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)

#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     min3(a,b,c)     min(a,min(b,c)
#define     M             32000

int main()
{
    ll n;
    cin>>n;
    if(n%2!=0) cout<<(n/2)+1<<endl;
    else cout<<n/2<<endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)

int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};
int dxx[]={1,1,0,-1,-1,-1,0,1};
int dyy[]={0,-1,-1,-1,0,1,1,1};
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;


int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n;
  cin >>n;
  if(n<1200) cout<<"ABC\n";
  else if(n<2800) cout<<"ARC\n";
  else cout<<"AGC\n";
  


  

  return 0;
}


Measured memory_bytes: 256
from collections import deque
n, q = map(int, input().split())

deq = deque()

for i in range(n):
    name, time = input().split()
    deq.append((name, int(time)))

sum = 0

while deq:
    name, time = deq.popleft()
    if time <= q:
        sum += time
        print(name, sum)
    else:
        sum += q
        deq.append((name, time - q))



Measured memory_bytes: 12528
def iread():
    return int(input())


def sread():
    return input()


def aread(t="int"):
    if t == "int":
        ret = [int(i) for i in input().split()]
    elif t == "str":
        ret = list(input())
    else:
        ret = tmp
    return ret


def scan():
    return list(map(int, input().split()))
    


def main():
    a,b = scan()
    print(max(a + b, a * b, a - b))        

if __name__ == '__main__':
    main()

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			String line = sc.next();
			int length = Integer.MAX_VALUE;
			while (line.replaceFirst("^.*\\[([0-9]*)\\].*$", "$1").length() != length) {
				String num = line.replaceFirst("^.*(\\[[0-9]*\\]).*$", "$1");
				num = num.replaceAll("[\\[\\]]", "");
				int tmp = Integer.parseInt(num);
				tmp = (tmp + 1) / 2;

				line = line.replaceAll("\\[" + num + "\\]", String.valueOf(tmp)
						+ " ");
				length = line.length();
			}
			while (line.indexOf("[") != -1) {
				String area = line.replaceFirst("^.*\\[([0-9 ]*)\\].*$", "$1");

				String[] areaS = area.trim().split(" ");
				int[] areaBox = new int[areaS.length];
				for (int j = 0; j < areaBox.length; j++) {
					areaBox[j] = Integer.parseInt(areaS[j]);
				}
				Arrays.sort(areaBox);
				int need = 0;
				for (int j = 0; j < (areaBox.length + 1) / 2; j++) {
					need += areaBox[j];
				}
				line = line.replaceAll("\\[" + area + "\\]",
						String.valueOf(need) + " ");
			}
			System.out.println(line.trim());
		}
		sc.close();
	}
}

Measured memory_bytes: 118932
#include <cstdio>
#include <algorithm>
long long a, b, c, d, n;
int main()
{
	scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &d, &n);
	b = std::min(b, a << 1);
	c = std::min(c, b << 1);
	d = std::min(d, c << 1);
	printf("%lld\n", d * (n >> 1) + c * (n & 1));
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,i,max1,max2,min1,min2,temp1,temp2;
  cin >> n;
  long long int x[n],y[n],sw1[n],sw2[n];
  
  cin >> x[0] >> y[0];
  max1=x[0]+y[0];
  min1=x[0]+y[0];
  max2=x[0]-y[0];
  min2=x[0]-y[0];
  
  for(i=1;i<n;++i)
  {
  cin >> x[i] >> y[i];
  temp1=x[i]+y[i];
  temp2=x[i]-y[i];
  if(max1 < temp1) max1=temp1;
  if(min1 > temp1) min1=temp1; 
  if(max2 < temp2) max2=temp2;
  if(min2 > temp2) min2=temp2; 
  }

  cout << max(max1-min1,max2-min2);
  
return 0;}

Measured memory_bytes: 6764
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a=0,b,c,d,e=0,f;
  string s;
  cin >>s;
  for(int n=0;n<6;n++){
    if(s[n]=='1') e++;
  }
  cout <<e<<'\n';
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
    int n, h[100];
    int i, cnt=0, max = 0;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &h[i]);
    }

    cnt++;

    for(i=0; i<n-1; i++){
        if(max < h[i])
            max = h[i];

        if(max <= h[i+1])
            cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int x1, y1, x2, y2;cin>>x1>>y1>>x2>>y2;
  int ax=(x2-x1), ay=(y2-y1);
  double d=sqrt(pow(ax, 2)+pow(ay, 2));
  double theta = M_PI/2*(ay>0?1:-1);
  if(ax != 0) theta = atan(double(ay)/double(ax));
  if(ax<0)theta += M_PI;
  // cout << theta <<  endl;
  int bx=round(d*cos(theta+M_PI/2)), by=round(d*sin(theta+M_PI/2));
  // cout << ax << " " << ay << endl;
  // cout << bx << " " << by << endl;
  cout << x2+bx << " ";
  cout << y2+by << " ";
  cout << x1+bx << " ";
  cout << y1+by << endl;
}


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

vector< vector<int> > make_combination(int m,int n) {
  vector< vector<int> > combination;

  if( n == 1 ) { for(int i = 0;i < m;i++) { combination.push_back( vector<int>(1,i+1) ); }
  } else {
    for(int i = 0;i < m;i++) {
      vector< vector<int> > combination_0 = make_combination(m-i,n-1);
      for(int j = 0;j < (int)combination_0.size();j++) {
        combination_0[j].push_back(m-i);
        combination.push_back( combination_0[j] );
      }
    }
  }

  return combination;
}

int main() {
  int n,m,q,sum,sum_max; cin >> n >> m >> q;
  int a[q],b[q],c[q],d[q]; for(int i = 0;i < q;i++) { cin >> a[i] >> b[i] >> c[i] >> d[i]; }
  vector< vector<int> > A = make_combination(m,n);

  sum_max = 0;
  for(int i = 0;i < (int)A.size();i++) {
    sum = 0;
    for(int j = 0;j < q;j++) {
      if( A[i][ b[j] - 1 ] - A[i][ a[j] - 1 ] == c[j] ) { sum += d[j]; }
    }
    if( sum_max < sum ) { sum_max = sum; }
  }

  cout << sum_max << endl;
  return 0;
}


Measured memory_bytes: 12852
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>

using namespace std;

string s;

int main()
{
    cin>>s;
    if (s[2]==s[3] && s[4]==s[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int cnt = 0;
  long long int sum = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'W') {
      sum += i-cnt;
      cnt++;
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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(){
int x;
cin >> x;

int uhen=x/100;
int sahen= x%100;
int a=sahen%5;
sahen/=5;
if(a>0)
sahen++;

if(uhen >= sahen)
{cout << 1 << endl;}
else{
  cout << 0 <<endl;
}

return 0;
}
//

Measured memory_bytes: 256