Language: C++

#define _crt_secure_no_warnings
#define mod 1000000007
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<ll, ll> p;
struct edge { ll to, cost; };

#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(i,0,n)
#define rrep(i,n) rfor(i,n,-1)

inline ll madd(ll a, ll b) {
	a %= mod;b %= mod;
	return (a + b) % mod;
}
inline ll msub(ll a, ll b) {
	a %= mod;b %= mod;
	a += mod;
	return (a - b) % mod;
}
inline ll mmul(ll a, ll b) {
	a %= mod;b %= mod;
	return (a*b) % mod;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % mod;
		a = a * a % mod;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= mod;
	ll b = mod, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += mod;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= mod;
	a *= minv(b);
	return a%mod;
}

struct unionfind {
	vector<int> data;
	unionfind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

/*int v;
vector<edge> g[max_v];
int d[max_v]:
void dijkstra(int s) {
	priority_queue<p, vector<p>, greater<p>> q;
	fill(d, d + v, inf);


}*/


ll fact[100001];

int main(void) {
	fact[0] = 1;
	rep(i, 100000) fact[i + 1] = mmul(fact[i], i + 1);
	int n, k, a, b;
	cin >> n >> k;

	vector<vector<int>> v(n+1);
	vector<int> cnt(n + 1,0);
	vector<bool> visited(n + 1,false);
	queue<int> q;

	rep(i, n - 1) {
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	q.push(1);
	visited[1] = true;
	while (!q.empty()) {
		int vert = q.front();
		q.pop();
		for (auto neigh : v[vert]) {
			if (!visited[neigh]) {
				visited[neigh] = true;
				cnt[vert]++;
				q.push(neigh);
			}
		}
	}

	ll res = k;
	if (k - 1 < cnt[1]) {
		cout << "0";
		return 1;
	}
	res = mmul(res, fact[k - 1]);
	res = mdiv(res, fact[k - 1 - cnt[1]]);
	for(i, 2, n + 1) {
		if (cnt[i] > 0) {
			if (k - 2 < cnt[i]) {
				cout << "0";
				return 1;
			}
			res = mmul(res, fact[k - 2]);
			res = mdiv(res, fact[k - 2 - cnt[i]]);
		}
	}
	cout << res;
	return 0;
}


Compiler output:
a.cc:129:42: error: macro "for" requires 3 arguments, but only 1 given
  129 |                 for (auto neigh : v[vert]) {
      |                                          ^
a.cc:28:9: note: macro "for" defined here
   28 | #define for(i,a,b) for(ll i=(a);i<(b);++i)
      |         ^~~
a.cc: In function 'int main()':
a.cc:129:44: error: expected '(' before '{' token
  129 |                 for (auto neigh : v[vert]) {
      |                                            ^
      |                                            (
a.cc:129:44: error: expected primary-expression before '{' token
a.cc:136:9: error: expected primary-expression before '}' token
  136 |         }
      |         ^
a.cc:135:18: error: expected ';' before '}' token
  135 |                 }
      |                  ^
      |                  ;
  136 |         }
      |         ~         
a.cc:136:9: error: expected primary-expression before '}' token
  136 |         }
      |         ^
a.cc:135:18: error: expected ')' before '}' token
  135 |                 }
      |                  ^
      |                  )
  136 |         }
      |         ~         
a.cc:129:44: note: to match this '('
  129 |                 for (auto neigh : v[vert]) {
      |                                            ^
a.cc:136:9: error: expected primary-expression before '}' token
  136 |         }
      |         ^