akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
using ll=long long;
using namespace std;

int gcd(int a,int b){
    int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    int N;
    cin>>N;
    set<int> A;
    string ans="def";
    A.clear();
    int a;
    int pc=1;
    int nc=1;
    for(int i=0;i<N;i++){
        cin>>a;
        if(a!=1){
            if(A.find(a)==A.end()){
                A.insert(a);
            }else{
                pc=0;
            }
        }else{
            nc=0;
        }
    }
    int maxnum=1e6+1;
    int flag=0;
    if(N==1 && !A.empty()){
        pc=0;
    }

        vector<int> B(maxnum,0);
        for(auto p:A){
            B[p]++;
        }
        for(int i=2;i<maxnum;i++){
            flag=0;
            for(int j=i;j<maxnum;j+=i){
                if(B[j]==1 && flag==0){
                    flag=1;
                }else if(B[j]==1 && flag==1){
                    pc=0;
                    break;
                }
            }
        }
        if(pc==1){
            ans="pairwise coprime";
        }else{
            int g=*A.begin();
            for(auto p:A){
                g=gcd(g,p);
            }
            if(g==1 || nc==0){
                ans="setwise coprime";
            }else{
                ans="not coprime";
            }
        }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 53952
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

/* 素因数分解 */
vector<ll> PrimeFact(ll n){
    vector<ll> res;
    while(n!=1){
        if(n == 2 || n == 3){
            res.emplace_back(n); n/=n;
            continue;
        }
        bool prime_flag = false;
        for(ll i = 2;i*i <= n;i++){
            if(n%i==0){
                res.emplace_back(i); n/=i;
                prime_flag = true;
                break;
            }
        }
        if(!prime_flag){res.emplace_back(n); n/= n;}
    }
    return res;
}

void PrimeFact(ll n,map<ll,ll>& mp){
    while(n!=1){
        if(n == 2 || n == 3){
            mp[n]++; n/=n;
            continue;
        }
        bool prime_flag = false;
        for(ll i = 2;i*i <= n;i++){
            if(n%i==0){
                mp[i]++; n/=i;
                prime_flag = true;
                break;
            }
        }
        if(!prime_flag){mp[n]++; n/= n;}
    }
}

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    
    map<ll,ll> mp;
    PrimeFact(N,mp);
    // cout << mp << endl;
    for(auto p:mp){
        for(ll x = 1; ; x++){
            if(p.second >= x){
                res++;
                p.second -= x;
            }else{
                break;
            }
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3660
//cwystc <--> 陈威宇是天才  --by cwy
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const double PI=acos(-1);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define Per(i,a,b) for (int i=(a);i>(b);i--)
#define travel_set(it,a) for (set<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define travel_map(it,a) for (map<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define travel_vec(it,a) for (vector<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define p(x) cout << x << endl;
#define def cout << "find" << endl;
#define what_is(x) cout << #x << " is " << x << endl;
template <class T>T sqr(T x){return x*x;}
template <class T>T alex(T x){return (x>0)?x:-x;}
template <class T>void read(T&x){
	x=0;T f=1;char ch=getchar();
	while ((ch<48||ch>57)&&ch!=45)ch=getchar();
	if (ch==45)f=-1,ch=getchar();
	while (ch>=48&&ch<=57)x=x*10+ch-48,ch=getchar();
	x*=f;
}

//-------------------------------------------------head-------------------------------------------------

#define maxn 55
int a[maxn],b[maxn],n;
bool vis[maxn],used[maxn];
bool check(int ind){
	memset(used,0,sizeof(used));
	used[a[ind]]=true;
	per(i,50,1)if (vis[i]){
		per(k,50,0)if (used[k])used[k%i]=true;
	}
	// rep(i,0,50)if (used[i])printf("%d ",i);puts("");
	return !used[b[ind]];
}
int main(){
	read(n);
	rep(i,1,n)read(a[i]);
	rep(i,1,n)read(b[i]);
	rep(i,1,50)vis[i]=true;
	ll ans=0;
	per(t,50,1){
		bool flag=false;vis[t]=false;
		rep(i,1,n)if (check(i)){
			flag=true;break;
		}
		if (flag)vis[t]=true,ans+=1ll<<t;
	}
	// rep(i,1,50)if (vis[i])printf("%d ",i);puts("");
	bool flag=false;
	rep(i,1,n)if (check(i)){flag=true;}
	if (flag)puts("-1");else printf("%lld\n",ans);return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

struct operation {
	int y, x, yp, xp;
};

int a[501][501];
operation op[250000];

int main()
{
	int H, W, N = 0;

	cin >> H >> W;
	repc(i, 1, H) {
		repc(j, 1, W) {
			cin >> a[i][j];
		}
	}

	repc(i, 1, H) {
		repc(j, 1, W) {
			if (a[i][j] % 2 != 0) {
				if (j != W) {
					op[N].y = i;
					op[N].x = j;
					op[N].yp = i;
					op[N].xp = j + 1;

					N++;
					a[i][j]--;
					a[i][j + 1]++;
				}
				else if (i != H) {
					op[N].y = i;
					op[N].x = j;
					op[N].yp = i + 1;
					op[N].xp = j;

					N++;
					a[i][j]--;
					a[i + 1][j]++;
				}
			}
		}
	}

	cout << N << endl;
	rep(i, N) printf("%d %d %d %d\n", op[i].y, op[i].x, op[i].yp, op[i].xp);

	return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

ll calc_dsum(ll X){
    ll sum = 0;
    while(X > 0){
        sum += X % 10;
        X /= 10;
    }
    return sum;
}

void solve(istream &cin) {
    ll N;
    cin >> N;
    if(!cin) return;
    ll cc = 0;
    ll a = 1;
    while(cc + a * 9 <= N){
        cc += a * 9;
        a *= 10;
    }
    while(cc + a <= N){
        cc += a;
    }
    cout << calc_dsum(cc) << endl;
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<ll> b(n);
  for (ll i = 0; i < n; ++i) {
    cin >> b[i];
  }

  vector<ll> ans;
  for (ll i = 0; i < n; ++i) {
    for (ll j = b.size()-1; j >= 0; --j) {
      if (b[j] == j+1) {
        ans.push_back(j+1);
        b.erase(b.begin() + j);
        break;
      }
    }
  }

  if (ans.size() != n) {
    cout << -1 << endl;
    return 0;
  }

  for (ll i = ans.size()-1; i >= 0; --i) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
	int n;
	int i;
	int cnt = 0;
	int input;

	scanf("%d", &n);

	for (i = 1; i <= n; i++)
	{
		scanf("%d", &input);

		if (input != i)
		{
			cnt++;
		}
	}

	if (cnt > 2)
	{
		printf("NO\n");
	}

	else
	{
		printf("YES\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	ll ans;
	if((x/d)<=k)
	{
		if((k-(x/d))%2==0)
		ans=x-(d*(x/d));
		else
		ans=min(abs(x-(d*(x/d))+d),abs(x-(d*(x/d))-d));
	}
	else
	ans=abs(x-(k*d));
	cout<<abs(ans);
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
"""
"""


def solve(data):
    if '9' in data:
        return True
    else:
        return False


def main():
    data = input()
    result = solve(data)
    if result:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
    

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

int main()
{
	long long gx,gg,qx,qg,max;
	cin >> gx >> gg >> qx >> qg;
	
	if (gx>qx)
		max=gx;
	else
		max=qx;
	
	for (long long i=1; i<=max+2; i++)
	{
		qx-=gg;
		if (qx<=0)
		{
			cout << "Yes" << endl;
			return 0;
		}
		
		gx-=qg;
		
		if (gx<=0)
		{
			cout << "No" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include <cassert>
#include<algorithm>
#include <tuple>
#include <utility>
#include<string>
#include <cmath>
#include <functional>
#define ll long long
using namespace std;

int main(){
    ll X,D,K,ans=0;
    cin >> X >> K >> D; 
    if(X > 0){
        if(X/D >= K){
            ans = X - K*D;
            K=0;
        }else{
            K -= X/D; 
            X -= D*(X/D);
        }
        if(K>0){
            if(K%2==0){
                ans = X;
            }else{
                ans = min(abs(X+D),abs(X-D));
            }
        }
    }else{
        if(abs(X) / D >= K){
            ans = X + K*D;
            K=0;
        }else{
            K -= abs(X)/D; 
            X -= D*(X/D);
        }
        if(K>0){
            if(K%2==0){
                ans = X;
            }else{
                ans = min(abs(X+D),abs(X-D));
            }
        }
    }

    cout << abs(ans) << endl;
}


Measured memory_bytes: 3620
list=[ [0]*13 for i in range(4) ]
n=int(input())
for i in range(n):
	s=input().split()
	if s[0]=="S":
		list[0][int(s[1])-1]=1
	elif s[0]=="H":
		list[1][int(s[1])-1]=1
	elif s[0]=="C":
		list[2][int(s[1])-1]=1
	elif s[0]=="D":
		list[3][int(s[1])-1]=1
		
for i in range(4):
	for j in range(13):
		if i==0 and list[i][j]==0:
			print("S "+str(j+1))
		elif i==1 and list[i][j]==0:
			print("H "+str(j+1))
		elif i==2 and list[i][j]==0:
			print("C "+str(j+1))
		elif i==3 and list[i][j]==0:
			print("D "+str(j+1))



Measured memory_bytes: 5612
# https://atcoder.jp/contests/abc164/tasks/abc164_b

# 高橋君のモンスターは体力が A で攻撃力が B
# 青木君のモンスターは体力が C で攻撃力が D

A, B, C, D = map(int, input().split())

while (A >= 0 or C >= 0):
    
    C -= B

    if C <= 0:
        print('Yes')
        exit()

    A -= D

    if A <= 0:
        print('No')
        exit()



Measured memory_bytes: 9024
import math

def resolve():
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        for j in range(1, N + 1):
            g = math.gcd(i, j)
            for k in range(1, N + 1):
                ans += math.gcd(g,k)

    return print(ans)

if __name__ == "__main__":
    resolve()

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

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

ll mod = 1e9 + 7;

int main(){
    ll N, X, D;
    cin >> N >> X >> D;
    if (D == 0) {
        if (X == 0) cout << 1 << endl;
        else cout << (N+1) << endl;
        return 0;
    }
    ll ans = 0;
    if (D < 0) {
        X = -X;
        D = -D;
    }
    ll p = D/abs(gcd(X, D));
    for (ll M = 0; M <= N; M++) {
        //cout << ans << endl;
        if (M < p) {
            ans += ( (N*(N-1)/2 - (N-M)*(N-M-1)) + (N*(N-1)/2 - M*(M-1)) )/2+1;
            continue;
        }
        ll l = -N*(N-1)/2 + M*(M-1);
        ll r = N*(N-1)/2 - (N-M)*(N-M-1);
        ll lp = -N*(N-1)/2 + (M-p)*(M-p-1) - 2*X*p/D;
        ll rp = N*(N-1)/2 - (N-M+p)*(N-M+p-1) - 2*X*p/D;
        if (r < lp || l > rp) ans += (r-l)/2+1;
        else {
            if (l <= rp && rp <= r) ans += (r-rp)/2;
            if (l <= lp && lp <= r) ans += (lp-l)/2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

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

		var set = new HashSet<Long>();
		while (true) {
			var list = getDivisors(n);
			var z = 0L;
			for (var a : list) {
				if (!set.contains(a) && check(a)) {
					z = a;
					break;
				}
			}
			if (z == 0) {
				break;
			}
			set.add(z);
			n = n / z;
			//System.out.printf("%d %d %d\r\n", n, z, n / z);
		}
		System.out.println(set.size());
	}

	public static boolean check(long n) {
		var list = getDivisors(n);
		var p = list.get(0);
		while (n % p == 0) {
			n /= p;
		}
		return n == 1;
	}

	public static List<Long> getDivisors(long n) {
		var list = new ArrayList<Long>();
		for (var i = 1L; i < (long) Math.sqrt(n) + 1; i++) {
			if (n % i == 0) {
				list.add(i);
				var divisor = n / i;
				if (divisor != i) {
					list.add(divisor);
				}
			}
		}

		Collections.sort(list);
		if (list.size() > 0 && list.get(0) == 1) {
			list.remove(0);
		}
		return list;
	}
}


Measured memory_bytes: 37612
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        HashMap<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < l - 1; i++) {
            int item = sc.nextInt();
            map.put(item,map.getOrDefault(item,0) + 1);
        }
        for(int i = 1;i < l + 1;i++){
            System.out.println(map.getOrDefault(i,0));
        }
    }
}


Measured memory_bytes: 72852
#include<iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX

using Edge=pair<int,int>;
using Graph =vector<vector<Edge>>;
int n;
Graph G;

void dfs(int v,int p,int pc,vector<int>& res){
    int color=1;
    if(color==pc)++color;
    for(auto e:G[v]){
        if(e.first==p)continue; //逆流しない
        res[e.second]=color;
        dfs(e.first,v,color,res);
        ++color;
        if(color==pc)++color;
    }
}

int main(){
    cin>>n;
    G.assign(n,vector<Edge>());
    for(int i=0;i<n-1;++i){
        int a,b;cin>>a>>b;--a;--b;
        G[a].emplace_back(b,i);
        G[b].emplace_back(a,i);
    }
    int max_color=0;
    for(int i=0;i<n;++i)max_color=max(max_color,(int)G[i].size());
    vector<int>res(n-1,-1);
    dfs(0,-1,-1,res);
    cout<<max_color<<endl;
    for(auto v:res)cout<<v<<endl;
}

Measured memory_bytes: 8320
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
void solve() {
	int n;
	cin >> n;
	set<string> s;
	for (int i = 0; i < n; i++) {
		string st;
		cin >> st;
		s.insert(st);
	}
	cout << s.size() << endl;
}
int32_t main() {
	BOLT;
	solve();
}

Measured memory_bytes: 19276
#include<bits/stdc++.h>
        #define ll long long
        #define f   first
        #define s   second
        #define pb          push_back
        #define mod        1000000007
        #define mod1       1000000009
        #define hell        998244353
        #define inf         1000000000000000000LL
        #define pi          3.14159265358979323
        #define N           1000050
        using namespace std;
        ll n,k,sum,q,res,m,val;
        ll x,y;
        void solve()    
        {   
            
            cin>>n>>m;
            if(n%3==0 || m%3==0) {cout<<"0";return;}
            ll ans=inf;
            ll h=n,w=m;
            for(int i=1;i<w;i++)
            {
                x=(h*i);
                y=(w-i)*(h/2);
                ll z=(w-i)*(h-h/2);
                ans=min(ans,max({x,y,z})-min({x,y,z}));
            }
            swap(w,h);
            for(int i=1;i<w;i++)
            {
                x=(h*i);
                y=(w-i)*(h/2);
               ll z=(w-i)*(h-h/2);
                ans=min(ans,max({x,y,z})-min({x,y,z}));
            }
            ans=min({ans,h,w});
            cout<<ans;



        }
        int main()
        {   ios_base::sync_with_stdio(false);
            cin.tie(0);cout.tie(0);
            ll t=1;
           //cin>>t;
            for(int i=1;i<=t;i++)
                solve();
            

        }            

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
    
	
  
        FastIO

        int h,a,x;
        cin>>h>>a;
         x= h/a +1;
         if(h%a==0)
         	x--;
         cout<<x;return 0;
        }

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

int main() {
  int n;
  cin >> n;
  vector<int> dp(1e5+5);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    dp[a]++;
    a++;
    dp[a]++;
    a -= 2;
    if (a >= 0) dp[a]++;
  }
  sort(dp.rbegin(), dp.rend());
  cout << dp[0] << endl;
  return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = 1e3;
int n, k;
int ans;

void read()
{
    cin >> n >> k;
}

void solve()
{
    int h;
    for(int i = 0; i < n; ++i)
    {
        cin >> h;
        if(h >= k)
            ++ans;
    }
    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    read();
    solve();
    return 0;
}


Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

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

int main()
{
    int n,W;
    cin>>n>>W;
    long long int val[n];
    int wt[n];
    for(int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }
    long long int dp[n+1][W+1];
    for(int i=0;i<=n;i++){
        for(int w=0;w<=W;w++){
            if(i==0 || w==0){
                dp[i][w]=0;
            }
            else if(wt[i-1]<=w){
                dp[i][w]=max(val[i-1]+dp[i-1][w-wt[i-1]],dp[i-1][w]);
            }
            else {
                dp[i][w]=dp[i-1][w];
            }
        }
    }
    cout<<dp[n][W];
    //printf("Hello World");

    return 0;
}


Measured memory_bytes: 82236
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    vl A(N), B(N); rep(i, N) cin >> A[i] >> B[i];
    
    ll ans = 0;
    rep(shift, 35){
        if(((K>>shift)&1) == 0 && shift > 0) continue;
        ll KK = shift > 0 ? K ^ (1ll<<shift) : K;
        KK |= (1ll<<shift)-1;
        ll res = 0;
        rep(i, N){
            if((KK|A[i]) == KK) res += B[i];
        }
        chmax(ans, res);
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
  int A, B;
  int ANS[3];
  cin >> A >> B;

  ANS[0] = A+B;
  ANS[1] = A-B;
  ANS[2] = A*B;

  cout << *max_element(ANS, ANS+3) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#define DEC(i, x, y) for (ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;
 
// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<ii> vii;
 
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
 
ll lcm(ll a, ll b) { return (a * (b / __gcd(a, b))); }
 
// Some contants
const ll inf = 1e12 + 7;
const double eps = 1e-9;
const double pi = 1.00 * acos(-1.00);


ll v, u;

void solve(){


    cout << u*v << endl;

} 
 
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
 
    cin >> u >> v;
    solve();

 
    return 0;
 
 
}


Measured memory_bytes: 3664
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int N = 310;
ll n,dis[N][N],m,L,dis2[N][N];
const ll Inf = 1e15;


int main()
{
    cin >> n >> m >> L;
    for(int i = 1; i<=n; i++)
    {
        for(int j = 1; j<=n; j++)
        {
            dis[i][j] = Inf;
            dis2[i][j] = Inf;
        }
    }
    while(m--)
    {
        int a,b,c;
        cin >> a >> b >> c;
        dis[a][b] = c;
        dis[b][a] = c;
    }
    for(int k= 1; k<=n; k++)
    {
        for(int i = 1; i<=n; i++)
        {
            for(int j = 1; j<=n; j++)
            {
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }
    for(int i = 1; i<=n; i++)
    {
        for(int j = 1; j<=n; j++)
        {
            if(dis[i][j] <= L)
                dis2[i][j] = 1;
        }
    }
    for(int k = 1; k<=n; k++)
    {
        for(int i = 1; i<=n; i++)
        {
            for(int j = 1; j<=n; j++)
            {
                dis2[i][j] = min(dis2[i][j] , dis2[i][k] + dis2[k][j]);
            }
        }
    }
    int Q;
    cin >> Q;
    while(Q--)
    {
        int s,d;
        cin >> s >> d;
        cout << (dis2[s][d] == Inf ? -1 : dis2[s][d] - 1) << '\n';
    }
    return 0;
}


Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

class Main {

	public static void main(String[] args) throws IOException {

		StringBuilder buider = new StringBuilder();

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String n = br.readLine();

		String nums;

		int count=0;
		for(int i=0; i<Integer.parseInt(n); i++){
			 nums = br.readLine();
			if(new BigInteger(nums).isProbablePrime(1)){
				count++;
			}
		}

		System.out.println(count);

	}

}

Measured memory_bytes: 44636
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;


int ans=1,ans2;
int n,m;
vector<int> g[111111];
int flag[111111];
bool firstf;
void dfs(int v,int deep,int p){
	//cout<<p<<endl;
	flag[v]=1;
	ans*=p;ans%=MOD;

	if(!firstf){p=m-1;firstf=true;}
	else p=m-2;

	for(int i=0;i<g[v].size();i++){
		if(flag[g[v][i]])continue;
		//else p=m-2;
		dfs(g[v][i],deep+1,p);
		p--;
	}
}

signed main(){

	cin>>n>>m;
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0,0,m);
	cout<<ans<<endl;
}

Measured memory_bytes: 10240
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N = int(readline())
    if N == 0:
        return False
    f = ".*".index
    MP = [list(map(f, readline().strip())) for i in range(N)]
    D = [[0]*N for i in range(N)]
    ds = [0]*N
    for i in range(N):
        MPi = MP[i]
        Di = D[i]
        for j in range(N):
            if MPi[j]:
                ds[j] = 0
            else:
                ds[j] += 1
                Di[j] = ds[j]
    ans = 0
    def gen():
        for i in range(N):
            st = []
            Di = D[i]
            for j in range(N):
                c = Di[j]
                last = j
                while st and st[-1][1] >= c:
                    k, d = st.pop()
                    yield min(d, j-k)
                    last = k
                st.append((last, c))
            while st:
                k, d = st.pop()
                yield min(d, N-k)
    write("%d\n" % max(gen()))
    return True
while solve():
    ...



Measured memory_bytes: 45532
#include <bits/stdc++.h>
using namespace std;
#define rep(i,i0,n) for(int i=i0;i<n;++i)
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define INF12 1000000000000 //10^12
#define INF9 1000000000 //10^9
#define MOD 10000007 //10^9+7

int N,M;
vector<int> s;
vector<char> c;

bool ok(int target) {
    string t = to_string(target);
    int length = t.length();
    if(length != N) return false;
    rep(i,0,M) if(t[s[i]-1] != c[i]) return false;
    return true;
}

int main() {
    cin >> N >> M;
    // s.resize(M);
    // c.resize(M);
    rep(i,0,M) {
        int a;
        char b;
        cin >> a >> b;
        s.push_back(a);
        c.push_back(b);
    }
    int ans = 0;
    int end = pow(10,N);
    while(true) {
        if(ok(ans)) break;
        if(ans == end) {
            ans = -1;
            break;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

// int sum(vector<vector<int>> matrix, int H, int W)
// {
//   int sum = 0;
//   for (int i = 0; i < H; i++) {
//     for (int j = 0; j < W; j++)
//     {
//       sum += matrix.at(i).at(j);
//     }
//   }
//   return sum;
// }

int main()
{
  int H, W, N;
  cin >> H >> W >> N;
  vector<vector<int>> matrix(H, vector<int>(W, 0));

  int count = 0;
  int sum = 0;
  while (true) {
    if (sum >= N) {
      break;
    }

    if (H >= W) {
      count++;
      sum += H;
      // for (int i = 0; i < H; i++) {
      //   for (int j = 0; j < W; j++) {
      //     matrix.at(i).at(j) = 1;
      //   }
      //   sum = accumulate(matrix.begin(), matrix.end(), 0);
      //   cout << sum << endl;
      //   count++;
      //   if (sum > N)
      //   {
      //     break;
      //   }
      // }
    } else {
      count++;
      sum += W;
      // for (int j = 0; j < W; j++)
      // {
      //   for (int i = 0; i < H; i++)
      //   {
      //     matrix.at(i).at(j) = 1;
      //   }
      //   sum = accumulate(matrix.begin(), matrix.end(), 0);
      //   cout << sum << endl;
      //   count++;
      //   if (sum > N)
      //   {
      //     break;
      //   }
      // }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    let s = io.chars();
    let p = s.first() == s.last();
    let n = s.len();

    if (n % 2 == 1) ^ p {
        io.writeln("First");
    } else {
        io.writeln("Second");
    }
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()

#define pb push_back
#define mp(a,b) make_pair(a,b)

#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpint;

vector<vector <pii> > vec(100000);
vector<pii> ans(100000);

int main(){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int x,y;
        cin>>x>>y;
        vec[x-1].pb(mp(y,i));
    }
    rep(i,n)sort(all(vec[i]));
    rep(i,n){
        rep(j,vec[i].size()){
            ans[vec[i][j].second]=mp(i+1,j+1);
        }
    }
    rep(i,m)printf("%06d%06d\n",ans[i].first,ans[i].second);
}

Measured memory_bytes: 7808
#include<iostream>
#include<cstdio>
#define MAX 500005
#define MMIINN -2000000200
using namespace std;

typedef long long ll;

class maxHeap{
 public:
  int index;
  ll maxHeapArray[MAX];

  maxHeap(){
    index = 0;
    for(int i=0;i<MAX;i++)maxHeapArray[i]=MMIINN;
  }

  void Insert(ll v){
    ++index;
    maxHeapArray[index]=v;
  }

  ll getLeft(int i){
    return 2*i;
  }

  ll getRight(int i){
    return 2*i+1;
  }

  ll getValue(int i){
    return maxHeapArray[i];
  }

  void buildMaxHeap(){
    for(int i=index/2;i>=1;i--){
      maxHeapify(i);
    }
  }


 private:

  void maxHeapify(int i){
    ll l = getLeft(i);
    ll r = getRight(i);
   ll largest;
    if(l <= index && maxHeapArray[l] > maxHeapArray[i])largest=l;
    else largest=i;
    if(r<=index && maxHeapArray[r] > maxHeapArray[largest])largest = r;
    if(largest != i){
      ll h;
      h = maxHeapArray[i];
      maxHeapArray[i] = maxHeapArray[largest];
      maxHeapArray[largest] = h;
      maxHeapify(largest);
    } 
  }




};

int main(){
  int n;
  ll val;
  maxHeap MH = maxHeap();
  scanf("%d",&n);
  for(int i=0;i<n;i++){scanf("%lld",&val); MH.Insert(val);
  }
      MH.buildMaxHeap();
  for(int i=1;i<=n;i++){
    printf(" %lld",MH.getValue(i));
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main(){
    int i , j , h , w;
    char lei = '0', a[51][51];
    while (cin >> h >> w){

        
        for(i = 0;i < h;i++)
        {
            for(j = 0;j < w;j++)
                cin>>a[i][j];
        }
        for(i = 0;i < h;i++)
        {
            for(j = 0;j < w;j++)
            {
                lei='0';
                if(a[i][j]=='.')
                {
                    if(a[i-1][j-1]=='#')
                        lei++;
                    if(a[i][j-1]=='#')
                        lei++;
                    if(a[i+1][j-1]=='#')
                        lei++;
                    if(a[i-1][j]=='#')
                        lei++;
                    if(a[i+1][j]=='#')
                        lei++;
                    if(a[i-1][j+1]=='#')
                        lei++;
                    if(a[i][j+1]=='#')
                        lei++;
                    if(a[i+1][j+1]=='#')
                        lei++;

                    a[i][j]=lei;
                }
                else a[i][j]='#';

            }
        }
        for(i = 0;i < h;i++)
        {
            for(j = 0;j < w;j++)
                cout<<a[i][j];
            cout<<endl;
        }
    }

    return 0;
}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

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

const int NMAX = 100;
bool flag;

bool cmp(int x,int y){
    return abs(0-x)<abs(0-y);
}

int main(){
    SCIN(s);
    rep(i,s.size()){
        printf("%c",s[i]);
        i++;
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 512
/*
Original problem:
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

string to_string(string s) {return s;}
string to_string(char c) {return "" + c;}
template <typename A, typename B> string to_string(pair<A,B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(vector<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }

void debug_out() {cerr << endl;}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifndef ONLINE_JUDGE
#define debug(...) do { cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__); } while (false)
#else
#define debug(...) do { } while (false)
#endif

typedef  long long ll;
typedef double db;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

void in(ll & x) {
	ll a = scanf("%lld", &x);
}

template<typename A,typename B > inline void in(A&x,B&y) {in(x);in(y);}
template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) {in(x);in(y);in(z);}
template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) {in(x);in(y);in(z);in(d);}

const ll mod = 1e9+7;

namespace SOLVE {	
	VVVLL dp;
	vector<vector<PLL>> M;

	ll get(ll i, ll j, ll k) {
		if (i < 0 || j < 0 || k < 0) return 0;
		if (i == 0 && j == 0 && k == 0) return 1;
		if (dp[i][j][k] != -1) return dp[i][j][k];

		ll zerocount = ((i == 0) + (j == 0) + (k == 0));

		if (zerocount < 2) {
			if ((i == j) || (j == k) || (k == i)) {
				dp[i][j][k] = 0;
				return 0;
			}
		}

		ll m = max({i,j,k});
		for (PLL p : M[m]) {
			ll count = ((i >= p.first) + (j >= p.first) + (k >= p.first));
			if (count != p.second) {
				dp[i][j][k] = 0;
				return 0;
			}
		}
		
		
		ll ans = 0;
		if (m == i) {
			if (i-1 == j || i-1 == k) {
				REP(x,0,i) ans += get(x,j,k);
			} else ans = get(i-1,j,k);
		}

		if (m == j) {
			if (j-1 == i || j-1 == k) {
				REP(x,0,j) ans += get(i,x,k);
			} else ans = get(i,j-1,k);
		}

		if (m == k) {
			if (k-1 == i || k-1 == j) {
				REP(x,0,k) ans += get(i,j,x);
			} else ans = get(i,j,k-1);
		}
		ans %= mod;
		dp[i][j][k] = ans;
		return dp[i][j][k];
	}

	void main() {
		ll n, m;
		in(n,m);

		dp.resize(n+1,VVLL(n+1, VLL(n+1, -1)));
		M.resize(n+1);

		REP(i,0,m) {
			ll a, b, c;
			in(a,b,c);
			M[b].push_back({a,c});
		}
		

		ll ans = 0;
		REP(i,0,n+1) {
			REP(j,0,n+1) {
				REP(k,0,n+1) {
					if (i == n || j == n || k == n) ans += get(i,j,k);
				}
			}
		}

		ans %= mod;
		cout << ans << endl;
		

	}
}


signed main() {
	ll t;
	t = 1;
	// in(t);
	while (t--) {
		SOLVE::main();
	}

	return 0;
}


Measured memory_bytes: 216960
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>
#include <stack>

using namespace std;

const long long MOD = 1000000007;


void solve(long long N, long long K, std::vector<long long> a, std::vector<long long> b){
  vector< vector<long long> > G(N, vector<long long>());
  for (int i = 0; i < N-1; i++) {
    G[a[i]-1].push_back(b[i]-1);
    G[b[i]-1].push_back(a[i]-1);
  }

  long long ans;
  long long idx;
  long long c;
  vector<long long> visited(N, 0);

  ans = K;

  stack<long long> st;
  st.push(0);

  while (!st.empty()) {
    idx = st.top();
    st.pop();
    visited[idx] = 1;
    if (idx == 0) {
      c = K - 1;
      if (c-G[idx].size() < 0 || c < 0) {
        ans = 0;
      } else {
        for (int i = 0; i < G[idx].size(); i++) {
          ans *= c % MOD;
          ans %= MOD;
          c--;
        }
      }
    } else {
      c = K - 2;
      if (c-(G[idx].size()-1) < 0 || c < 0) {
        ans = 0;
      } else {
        for (int i = 0; i < G[idx].size()-1; i++) {
          ans *= c % MOD;
          ans %= MOD;
          c--;
        }
      }
    }

    for (int i = 0; i < G[idx].size(); i++) {
      if (visited[G[idx][i]] == 0) {
        st.push(G[idx][i]);
      }
    }
  }

  std::cout << ans % MOD << std::endl;

}

int main() {
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> a(N-1);
  std::vector<long long> b(N-1);
  for(int i = 0 ; i < N-1 ; i++){
    scanf("%lld",&a[i]);
    scanf("%lld",&b[i]);
  }
  solve(N, K, std::move(a), std::move(b));
  return 0;
}


Measured memory_bytes: 9716