criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;


public class Main2 {

    static class Vertex {

        int num;

        List<Integer> edges = new LinkedList<>();

        public Vertex(int num) {

            this.num = num;
        }
    }

    static int N;

    static int K;

    static long result = 1;

    static long mod = 1000000007;
    static int[] leaf;

    static Vertex[] nodes;


    static boolean check[];

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        N = s.nextInt();

        K = s.nextInt();

        leaf = new int[N];

        nodes = new Vertex[N+1];

        check = new boolean[N+1];

        for (int i = 1; i <= N; i++) {

            nodes[i]= new Vertex(i);
        }

        for (int i = 0; i < N-1; i++) {

            int v1 = s.nextInt();

            int v2 = s.nextInt();

            nodes[v1].edges.add(v2);

            nodes[v2].edges.add(v1);
        }

        dfs(nodes[1],0);

        System.out.println(result);


    }

    public static void dfs(Vertex v , int depth) {

        int rank = Math.max(K-2, K-depth);

        long num = rank - leaf[depth];

        result = (result%mod * num)%mod;

        leaf[depth]++;

        check[v.num] = true;

        for (int k  : v.edges) {

            if (check[k] == false) {

                dfs(nodes[k] , depth+1);
            }
        }
    }
}


Compiler output:
Main.java:6: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2 {
       ^
1 error
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#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 repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) {
 if (a < b) { a = b; return true; } return false; 
 }
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,k;
  cin>>n>>k;
  vvll t(n,vll(0));
  rep(i,n-1){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    t[a].pb(b);
    t[b].pb(a);
  }
  vb ch(n,false);
  queue<ll> que;
  que.pu(0);
  vll ans(0);
  ans.pb(k);
  ch[0]=true;
  while(sz(que)){
    ll s=que.front();
    que.pop();
    ll k=n-2;
    if(s==0) k=n-1;
    ll j=sz(t[s])-1;
    if(s==0) j++;
    rep(i,j){
      ans.pb(k);
      k--;
    }
    for(auto p:t[s]){
      if(ch[p]) continue;
      ch[p]=true;
      que.pu(p):
    }
  }
  ll anss=1;
  rep(i,sz(ans)){
    anss*=ans[i];
    anss%=MOD;
  }
  COUT(anss);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:81:16: error: expected ';' before ':' token
   81 |       que.pu(p):
      |                ^
      |                ;
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<int> to[101010];
bool visited[101010] = {};
ll ans=1; int n, k;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int DFS(int a, int p, int depth){
  COMinit();
  int child = 0;
  visited[a] = true;
  for(int o: to[a]){
    if(o==p) continue;
    if(visited[o]) continue;
    child++;
    DFS(o, a, depth+1);
  }
  if(depth==0) ans*=(COM(k-1, child)*fac[child]%mod);
  else ans*=(COM(k-2, child)*fac[child]%mod);
  ans%=mod;
  return ans;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
const int mod = 1000000007;
vector<int> v[MAX];

int dfs(int now,int from,int color){
  int canuse;
  if(from==-1)canuse=color-1;
  else{canuse=color-2;}
  if(color<v[now].size())return 0;
  else{
  long long int co_no_iro = 1;
	for (int i=0;i<v[now].size();i++){
    if(v[now].at(i)==from)continue;
    else{
		co_no_iro *= canuse;
    canuse--;
    co_no_iro %= mod;
		}}
 	for (int i=0;i<v[now].size();i++){
    if(v[now].at(i)==from)continue;
    else{
		co_no_iro *= dfs(v[now].at(i),now,color);
    co_no_iro %= mod;
		}
  return co_no_iro;
	}
}
int main(){
  int N,K;
	cin >> N >> K;
  int a,b;
  long long int ans =0;
	for(int i=0;i<N;i++){
		cin >> a >> b;
		v[a-1].push_back(b-1);
		v[b-1].push_back(a-1);
	}
	ans = K * dfs(0,-1,K);
  ans %= mod;
	cout<< ans <<endl;
}

Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:30:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   30 | int main(){
      |         ^~
a.cc:30:9: note: remove parentheses to default-initialize a variable
   30 | int main(){
      |         ^~
      |         --
a.cc:30:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:30:11: error: a function-definition is not allowed here before '{' token
   30 | int main(){
      |           ^
a.cc:43:2: error: expected '}' at end of input
   43 | }
      |  ^
a.cc:7:36: note: to match this '{'
    7 | int dfs(int now,int from,int color){
      |                                    ^
a.cc:43:2: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      |  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
const int mod = 1000000007;
vector<int> v[MAX];

int dfs(int now,int from,int color){
  int can_use;
  if(from==-1)can_use=color-1;
  else{can_use=color-2;}
  if(color<v[now].size())return 0;
  else{
  long long int co_no_iro = 1;
	for (int i=0;i<v[now].size();i++){
    if(v[now].at(i)==now)continue;
		co_no_iro *= canuse;
    canuse--;
    co_no_iro %= mod;
		}
 	for (int i=0;i<v[now].size();i++){
    if(v[now].at(i)==now)continue;
		co_no_iro *= dfs(v[now].at(i),now,color);
    co_no_iro %= mod;
		}
  return co_no_iro;
	}
}
int main(){
  int N,K;
	cin >> N >> K;
  int a,b;
  long long int ans =0;
	for(int i=0;i<N;i++){
		cin >> a >> b;
		v[a-1].push_back(b-1);
		v[b-1].push_back(a-1);
	}
	ans = K * dfs(0,-1,K);
  ans %= mod;
	cout<< ans <<endl;
}

Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:16:30: error: 'canuse' was not declared in this scope; did you mean 'can_use'?
   16 |                 co_no_iro *= canuse;
      |                              ^~~~~~
      |                              can_use
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
const int mod = 1000000007;
vector<int> v[MAX];

void dfs(int now,int from,int color){
  int can_use;
  if(from==-1)can_use=color-1;
  else{can_use=color-2;}
  if(K<v[now].size())return 0;
  else{
  long long int co_no_iro = 1;
	for (int i=0;i<v[now].size();i++){
    if(v[now].at(i)==now)continue;
		co_no_iro *= canuse;
    canuse--;
    co_no_iro %= mod;
		}
 	for (int i=0;i<v[now].size();i++){
    if(v[now].at(i)==now)continue;
		co_no_iro *= dfs(v[now].at(i),now,color);
    co_no_iro %= mod;
		}
  return co_no_iro;
	}
}
int main(){
  int N,K;
	cin >> N >> K;
  int a,b;
  long long int ans =0;
	for(int i=0;i<N;i++){
		cin >> a >> b;
		v[a-1].push_back(b-1);
		v[b-1].push_back(a-1);
	}
	ans = K * dfs(0,-1,K);
  ans %= mod;
	cout<< ans <<endl;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:11:6: error: 'K' was not declared in this scope
   11 |   if(K<v[now].size())return 0;
      |      ^
a.cc:11:29: error: return-statement with a value, in function returning 'void' [-fpermissive]
   11 |   if(K<v[now].size())return 0;
      |                             ^
a.cc:16:30: error: 'canuse' was not declared in this scope; did you mean 'can_use'?
   16 |                 co_no_iro *= canuse;
      |                              ^~~~~~
      |                              can_use
a.cc:22:33: error: void value not ignored as it ought to be
   22 |                 co_no_iro *= dfs(v[now].at(i),now,color);
      |                              ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:25:10: error: return-statement with a value, in function returning 'void' [-fpermissive]
   25 |   return co_no_iro;
      |          ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:38:17: error: invalid operands of types 'int' and 'void' to binary 'operator*'
   38 |         ans = K * dfs(0,-1,K);
      |               ~ ^ ~~~~~~~~~~~
      |               |      |
      |               int    void
Language: C++

n, k = input().split()
n = int(n)
k = int(k)

MOD = 1000000007

g = []
for i in range(n):
    g.append([])

for i in range(n-1):
    a, b = input().split()
    a = int(a)-1
    b = int(b)-1
    g[a].append(b)
    g[b].append(a)


used = [False for i in range(n)]


def dfs(v):
    used[v] = True
    ret = 1
    num = k-2
    for to in g[v]:
        if not used[to]:
            ret *= num * dfs(to) % MOD
            ret %= MOD
            num -= 1
            if num < 0:
                num = 0
    return ret

ans = k
num = k-1
used[0] = True
for to in g[0]:
    if not used[to]:
        ans *= num * dfs(to) % MOD
        ans %= MOD
        num -= 1
        if num < 0:
            num = 0

print(ans)


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n, k = input().split()
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<long long, long long> > vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

vector<vector<int>> G;
int N,K;
ll ans;
vector<int> seen;
vector<int> color;

int main(){

    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);
		
	cin >> N >> K;

	G.resize(N);
	seen.assign(N,0);
	color.assign(N,K-1);

	rep(i,N-1){
		int a,b;
		cin >> a >> b;
		--a;--b;
		G[a].PB(b);
		G[b].PB(a);
	}

	ans = 1;

	int st = 0;
	queue<pii> q;
	q.push(pii(0,K));

	while(!q.empty()){
		pii t = q.top();
		q.pop();
		seen[t.first] = 1;

		ans *= t.second;
		ans %= MOD;
	
		int col = K - (t.first == 0?1:2);

		for(int v:G[t.first]){
			if(!seen[v]){
				q.push(pii(v,col--));
			}
		}
	}

	cout << ans << endl;
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:27: error: 'class std::queue<std::pair<int, int> >' has no member named 'top'; did you mean 'pop'?
   65 |                 pii t = q.top();
      |                           ^~~
      |                           pop
Language: C++

かんせまけとでょじうほ

Compiler output:
a.cc:1:1: error: '\U0000304b\U00003093\U0000305b\U0000307e\U00003051\U00003068\U00003067\U00003087\U00003058\U00003046\U0000307b' does not name a type
    1 | かんせまけとでょじうほ
      | ^~~~~~~~~~~~~~~~~~~~~~
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    List<List<Integer>> t = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      t.add(new ArrayList<>());
    }
    for (int i = 0; i < N-1; i++) {
      int a = sc.nextInt();
      a--;
      int b = sc.nextInt();
      b--;
      t.get(a).add(b);
      t.get(b).add(a);
    }
    
    if (N == 1) {
      System.out.println(K);
      return;
    }
    
    int[] child = new int[N];
    for (int i = 0; i < N; i++) {
      child[i] = -1;
    }
    LinkedList<Integer> q = new LinkedList<>();
    q.offer(0);
    while (!q.isEmpty()) {
      int p = q.poll();
      child[p] = 0;
      for (int c : t.get(p)) {
        if (child[c] == -1) {
          child[p]++;
          q.offer(c);
        }
      }
    }
    int[] power = new int[K+1];
    power[K] = 1;
    power[K-1]--;
    
    power[K-1]++;
    if (K-1-child[0] < 0) {
      Sustem.out.println(0);
      return;
    }
    power[K-1-child[0]]--;
    
    for (int i = 1; i < N; i++) {
      if (child[i] > 0) {
        power[K-2]++;
        if (K-2-child[i] < 0) {
          System.out.println(0);
          return;
        }
        power[K-2-child[i]]--;
      }
    }
    
    //System.out.println(Arrays.toString(power));
    
    int num = 0;
    for (int i = K; i >=0; i--) {
      num += power[i];
      power[i] = num;
    }
    
    long ans = 1;
    for (int i = 2; i <= K; i++) {
      while (power[i]-- > 0) {
        ans *= i;
        ans %= 1_000_000_007;
      }
    }
    
    //System.out.println(Arrays.toString(child));
    //System.out.println(Arrays.toString(power));
    System.out.println(ans);
  }
}

Compiler output:
Main.java:48: error: package Sustem does not exist
      Sustem.out.println(0);
            ^
1 error
Language: C++

N,K=gets.split.map(&:to_i)
connected=Array.new(N,1)
visited=Array.new(N,false)
edge=Array.new(N){Array.new}

(N-1).times do
    a,b=gets.split.map(&:to_i)
    edge[a-1].push(b-1)
    edge[b-1].push(a-1)
end

queue=Array.new
queue.push([-1,0])
res=1
until queue.empty?
    parent,e=queue.shift
    next if visited[e]
    if parent==-1 && e==0
        res*=K
        parent=0
        visited[e]=true
        edge[e].each do |n|
            queue.push([e,n])
        end
    else
        res*=K-connected[parent]
        res%=1000000007
        connected[parent]+=1
        connected[e]+=1
        visited[e]=true
        edge[e].each do |n|
            queue.push([e,n])
        end
    end 
end
puts res

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N,K=gets.split.map(&:to_i)
      | ^
a.cc:6:3: error: expected ')' before '-' token
    6 | (N-1).times do
      | ~ ^
      |   )
Language: Java

import lib.graph.Edge;
import lib.graph.GraphBuilder;

import java.util.*;

public class Main {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    // int N = Integer.parseInt(scanner.nextLine());
    // int N = scanner.nextInt(), M = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    // long[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
    static void solve(Scanner scanner) {
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        scanner.nextLine();

        GraphBuilder builder = new GraphBuilder();
        for (int i = 0; i < N - 1; i++) {
            int[] e = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            builder.addEdge(e[0], e[1]);
            builder.addEdge(e[1], e[0]);
        }
        Map<Integer, Set<Edge>> edges = builder.build();
        long ans = (K * dfs(-1, edges, new HashSet<>(), K)) % MOD;
        System.out.println(ans);
    }

    static long dfs(int s, Map<Integer, Set<Edge>> edges, Set<Integer> visited, int K) {
        long ans = 0;
        if (visited.add(s)) {
            int n = s == -1 ? K - 1 : K - 2;
            int perm = n;
            while (n > 1) {
                perm *= --n;
            }
            ans = perm;
            for (Edge edge : edges.getOrDefault(s, Collections.emptySet())) {
                ans += dfs(edge.to, edges, visited, K);
                ans %= MOD;
            }
        }
        return ans;
    }

}



Compiler output:
Main.java:1: error: package lib.graph does not exist
import lib.graph.Edge;
                ^
Main.java:2: error: package lib.graph does not exist
import lib.graph.GraphBuilder;
                ^
Main.java:36: error: cannot find symbol
    static long dfs(int s, Map<Integer, Set<Edge>> edges, Set<Integer> visited, int K) {
                                            ^
  symbol:   class Edge
  location: class Main
Main.java:25: error: cannot find symbol
        GraphBuilder builder = new GraphBuilder();
        ^
  symbol:   class GraphBuilder
  location: class Main
Main.java:25: error: cannot find symbol
        GraphBuilder builder = new GraphBuilder();
                                   ^
  symbol:   class GraphBuilder
  location: class Main
Main.java:31: error: cannot find symbol
        Map<Integer, Set<Edge>> edges = builder.build();
                         ^
  symbol:   class Edge
  location: class Main
Main.java:45: error: cannot find symbol
            for (Edge edge : edges.getOrDefault(s, Collections.emptySet())) {
                 ^
  symbol:   class Edge
  location: class Main
7 errors
Language: C++

#include<iostream> 
#include<vector> 
using namespace std;
const long long int mod=1e9+7;
long long int dfs(int K,const vector<vector<int>>&graph, int now,int from) {
int can_use_color_num; if (from==-1) {
can_use_color_num=K-1; }
else { can_use_color_num=K-2;
}
if (K<graph[now].size()) {
return 0; }
else {
long long int case_num=1; for (auto e : graph[now]) {
if(e==from)continue;
case_num*=can_use_color_num; can_use_color_num--; case_num%=mod;
}
for (auto e : graph[now]) {
if(e==from)continue;
  case_num *=dfs(K,graph,e,now);
case_num %= mod; }
return case_num; }
}
int main() {
int N,K;cin>>N>>K;
vector<vector<int>>graph(N); for(inti=0;i<N-1;++i){
int a,b;cin>>a>>b;a--;b--;
graph[a].push_back(b);
graph[b].push_back(a); }
long long int answer=K*dfs(K,graph,0,-1); answer%=mod;
cout<<answer<<endl;
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:34: error: 'inti' was not declared in this scope; did you mean 'int'?
   25 | vector<vector<int>>graph(N); for(inti=0;i<N-1;++i){
      |                                  ^~~~
      |                                  int
a.cc:25:41: error: 'i' was not declared in this scope
   25 | vector<vector<int>>graph(N); for(inti=0;i<N-1;++i){
      |                                         ^
Language: Java

import java.util.*;

public class Main {
  static long MOD = (long)Math.pow(10, 9) + 7;
  static long ans = 1;
  static ArrayList[] tree;
  static long[] kai;
  static long k;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    k = sc.nextLong();
    tree = new ArrayList[n + 1];
    for(int i = 1; i < n + 1; i++) {
      tree[i] = new ArrayList<Integer>();
    }
    for(int i = 0; i < n - 1; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      ArrayList<Integer> ta = tree[a];
      ArrayList<Integer> tb = tree[b];
      ta.add(b);
      tb.add(a);
      tree[a] = ta;
      tree[b] = tb;
    }
    kai = new long[100001];
    kai[0] = 1;
    for(long i = 1; i < 100001; i++) {
      kai[i] = (kai[i - 1] * i) % MOD;
    }
    ans = k;
    dfs(1, 0);
    System.out.println(ans);
  }

  public static void dfs(int now, int from) {
    ArrayList<Integer> list = tree[now];
    long x = list.size();
    if(now > 1) x--;
    long t = kai[(int)k - 2];
    long t1 = kai[(int)x];
    long t2 = kai[(int)(k - 2 - x)];
    t1 = func(t1, MOD - 2);
    t2 = func(t2, MOD - 2);
    t = (t * t1) % MOD;
    t = (t * t2) % MOD;
    ans = (ans * t) % MOD;
    for(int i = 0; i < list.size(); i++) {
      int g = list.get(i);
      if(g != from) dfs(g, now);
    }
  }

  public static long func(long a, long x) {
    if(x == 0) return 1;
    if(x % 2 == 0) {
      long t = func(a, x / 2);
      return (t * t) % MOD;
    } else {
      long t = func(a, x / 2);
      t = (t * t) % MOD;
      return (a * t) % MOD;      
    }
  }
}

Compiler output:
Main.java:30: error: incompatible types: possible lossy conversion from long to int
      kai[i] = (kai[i - 1] * i) % MOD;
          ^
Main.java:30: error: incompatible types: possible lossy conversion from long to int
      kai[i] = (kai[i - 1] * i) % MOD;
                      ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
Language: C++

#include<iostream>
#include<vector>
#include<functional>
#include<utility>
#include<algorithm>
#define int long long
constexpr signed int mod = 1000000007;
signed  main(){
    int N,K;
    std::cin >> N >> K;
    std::vector<std::vector<int>>edge(N);
    std::vector<bool>used(N,false);
    for(int i = 0; i < N - 1; ++i){
        int s,t;
        std:: cin >> s >> t;
        --s;--t;
        edge[s].push_back(t);
        edge[t].push_back(s);
    }
    int root = 0;
    for(int i = 0; i < edge.size(); ++i){
        if(edge[root].size() < edge[i].size())
            root = i;
    }
    std::vector<int>d(N,(1LL << 60));
    std::function<int(int)>solve = [&](int v){
        used[v] = true;
        int res = 1;
        int e_size = (int)edge[v].size();
        int tight = K - e_size;
        assert(tight > 1);
        if(v == root) d[v] = 1;
        for(auto nv : edge[v]){
            if(used[nv]) continue;
            d[nv] = (v == root ? 1 : tight);
            res *= ((solve(nv)) % mod);
            res %= mod;
        }
        return (res * d[v])  % mod;
    };
    if(edge[root].size() + 1 > K){
        std::cout << 0 << std::endl;
    } else {
        int perm = 1;
        int cnt = (int)(edge[root].size() + 1);
        for(int j = 0; j < cnt; ++j){
            perm *= (K - j);
            perm %= mod;
        }
        std::cout << (perm * solve(root)) % mod << std::endl;
    }
}




Compiler output:
a.cc: In lambda function:
a.cc:31:9: error: 'assert' was not declared in this scope
   31 |         assert(tight > 1);
      |         ^~~~~~
a.cc:6:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    5 | #include<algorithm>
  +++ |+#include <cassert>
    6 | #define int long long
Language: C++

import sys
input = sys.stdin.readline

def main():
    n,k = map(int,input().split())
    mod = 10**9+7
    edge = [[] for _ in [None]*n]

    for _ in [None]*(n-1):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
    
    p = -1
    pl = -1
    for i in range(n-1):
        if len(edge[i]) > pl:
            p = i
            pl = len(edge[i])
    
    par = [-2]*n
    par[p] = -1
    tank = []
    new = [p]
    while len(new) > 0:
        tank = []
        for e in new:
            for ko in edge[e]:
                if par[ko] == -2:
                    par[ko] = e
                    tank.append(ko)
        new = tank
    
    d = [-1]*n
    d[p] = k
    tank = []
    new = [p]
    while len(new) > 0:
        tank = []
        for e in new:
            if e == p:
                cnt = 1
            else:
                cnt = 2
            for go in edge[e]:
                if go != par[e]:
                    d[go] = k-cnt
                    cnt += 1
                    tank.append(go)
        new = tank
    
    res = 1
    for e in d:
        res = res*e%mod
    print(res)

if __name__ == '__main__':
    main()


Compiler output:
a.cc:57:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   57 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;

namespace
{
	struct modint
	{
		static constexpr ll MOD = 1000000007;
		ll x_;
		modint(ll x) : x_(x % MOD) {}
		modint& operator+=(const modint& src)
		{
			if ((x_ += src.x_) >= MOD)
				x_ -= MOD;
			return *this;
		}
		modint& operator-=(const modint& src)
		{
			if ((x_ += MOD - src.x_) >= MOD)
				x_ -= MOD;
			return *this;
		}
		modint& operator*=(const modint& src)
		{
			(x_ *= src.x_) %= MOD;
			return *this;
		}

		modint& operator/=(const modint& src)
		{
			return (*this) *= src.inv();
		}
		modint inv() const
		{
			return pow(MOD - 2);
		}
		modint pow(ll t) const
		{
			if (t == 0)
				return 1;
			modint a = pow(t >> 1);
			a *= a;
			if (t & 1)
				a *= *this;
			return a;
		}
	};
	struct Node {
		int parent;
		int dist;
		set<int> children;
	};
	vector<Node>tree;

	void dfs(Node& node, modint& ct, int K) {
		int nC = node.children.size();
		auto p = node.children.begin();
		int x = node.dist == 0 ? 1 : 2;
		for (int i = 0; i < nC; ++i, ++p)
		{
			ct *= K - x - i;
			dfs(tree[*p], ct, K);
		}

	};
}

void ABC133E()
{
	int N, K;
	cin >> N >> K;
	vector<set<int> > graph(N);
	for (int i = 0; i < N - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		graph[a - 1].insert(b - 1);
		graph[b - 1].insert(a - 1);
	}

	tree.resize(N);
	tree[0] = Node{ -1,0,graph[0] };
	queue<int> qu;
	qu.push(0);
	while (!qu.empty())
	{
		int i = qu.front(); qu.pop();
		for (auto& x : tree[i].children)
		{
			graph[x].erase(i);
			Node theNode{ i,tree[i].dist + 1, graph[x] };
			tree[x] = theNode;
			qu.push(x);
		}
	}

	modint ct = K;
	dfs(tree[0], ct, K);
	cout << ct.x_ << endl;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}


ll solve(int k, VVI &g, int p, int v) {
  int color;
  p == -1 ? color = k - 1 : color = k - 2;
  ll ret = 1;
  if(color + 1 < g[v].size()) return 0;
  for(auto u : g[v]) {
    if(u == p) continue;
    ret *= color;
    ret %= MOD;
    color--;
  }
  for(auto u : g[v]) {
    if(u == p) continue;
    ret *= solve(k, g, v, u);
    ret %= MOD;
  }
  return ret;
}


signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  VVI g(n);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ll ans = k * solve(k, g, -1, 0);
  out(ans%MOD);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:18: error: expected ';' before 'a'
   62 |     cin >> a >> b
      |                  ^
      |                  ;
   63 |     a--; b--;
      |     ~
Language: Java



import java.util.ArrayList;
import java.util.Scanner;

public class main {
	public static ArrayList<Integer>[] adj;
	static int k=0;
	static int ans=k;
	static int mod=1000000007;
	public static void dfs(int u,int p)
	{
		int count=k-1;
		if(p!=-1)count--;
		for(int to:adj[u])
		{
			if(to==p)continue;
			if(count<=0)
			{
				ans=0;
//				System.out.println("lol");
				return;
			}
//			System.out.println("g");
//			System.out.println(count);
			ans=(int)(ans*1L*count)%1000000007;
//			System.out.println(ans);
			count--;
//			ans=ans%mod;
			dfs(to,u);
		}
		
	}
	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		 k=scan.nextInt();
		adj=new ArrayList[n];
		ans=k;
		for(int i=0;i<n;i++)
		{
			adj[i]=new ArrayList<Integer>();
		}
		for(int i=0;i<n-1;i++)
		{
			int u=scan.nextInt();
			int v=scan.nextInt();
			u--;v--;
			adj[u].add(v);
			adj[v].add(u);
		}
		dfs(0,-1);
		System.out.println(ans);
	}
}


Compiler output:
Main.java:6: error: class main is public, should be declared in a file named main.java
public class main {
       ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

vector<int> G[100'010];
//vector<bool> used(n,false);
long long ans;
void dfs(int prev, int now, long long k){
  //long long res=current;
  for(int next_:G[now]){
    if(next_==prev)continue;
    if(prev==-1){
      ans *= k-1;
    }else{
      ans *= k-2;
    }
    ans = mod(ans);
    ans *= dfs(now, next_, k);
    ans = mod(ans);
  }
  return;
}
    
int main(){
  
  int n;
  long long k;
  cin>>n>>k;
  int a,b;
  REP(i,n-1){
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  ans = k;
  dfs(-1,0,k);
  
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int, long long int)':
a.cc:102:15: error: void value not ignored as it ought to be
  102 |     ans *= dfs(now, next_, k);
      |            ~~~^~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

vector<int> G[100'010];
//vector<bool> used(n,false);
long long ans;
void dfs(int prev, int now, long long k){
  //long long res=current;
  for(int next_:G[now]){
    if(next_==prev)continue;
    if(prev==-1){
      ans *= k-1;
    }else{
      ans *= k-2;
    }
    ans = mod(ans);
    ans *= dfs(now, next_);
    ans = mod(ans);
  }
  return;
}
    
int main(){
  
  int n;
  long long k;
  cin>>n>>k;
  int a,b;
  REP(i,n-1){
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  ans = k;
  dfs(-1,0,k);
  
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int, long long int)':
a.cc:102:15: error: too few arguments to function 'void dfs(int, int, long long int)'
  102 |     ans *= dfs(now, next_);
      |            ~~~^~~~~~~~~~~~
a.cc:92:6: note: declared here
   92 | void dfs(int prev, int now, long long k){
      |      ^~~
Language: C++

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

using graph = vector<vector<int>>;

int main() {
    constexpr int mod = 1e9 + 7;
    int n, k; cin >> n >> k;

    graph g(n);
    REP(i, n-1) {
        int a, b; cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    function<ll(int, int)> rec = [&](int v, int bv) {
        ll ret = 1, t = bv == -1 ? k-1 : k-2;

        for(int u : g[v]) {
            if(u != bv) {
               (ret *= t * (rec(u, v))) %= mod;
               --t;

               if(t == 0) return 0;
            }
        }

        return ret;
    };

    cout << k * rec(0, -1) % mod << endl;

    return 0;
}


Compiler output:
a.cc: In lambda function:
a.cc:43:16: error: inconsistent types 'int' and 'long long int' deduced for lambda return type
   43 |         return ret;
      |                ^~~
Language: C++

#include <iostream>
#include <vector>

const unsigned long int modulo = 1000000007;

class Tree {
public:
    Tree(){
        this->id = ++(this->nNodes);
    }
    int getColorsMod(const unsigned int colors, const unsigned int depth, const unsigned int parentId) const {
        unsigned int tmpColors = colors;
        unsigned long int colorsMod = tmpColors % modulo;
        if(depth>0){
            tmpColors = this->nColors - 1;
        }
        for(auto &child : children){
            if(child->id != parentId){
                colorsMod *= child->getColorsMod(--tmpColors, depth+1, this->id);
                colorsMod %= modulo;
            }
        }
        return colorsMod
    }
    void registerChild(const Tree &tree){
        this->children.emplace_back(&tree);
    }
    static void setNColors(const unsigned int nColors){
        Tree::nColors = nColors;
    }
private:
    unsigned int id;
    static unsigned int nNodes;
    static unsigned int nColors;
    std::vector<const Tree *> children;
};

unsigned int Tree::nNodes = 0;
unsigned int Tree::nColors = 0;

int main(int argc, char *argv[]){
    unsigned int N, K;
    std::cin >> N >> K;

    Tree tree[N];
    Tree::setNColors(K);
    unsigned int a,b;
    for(int i=1; i<N; ++i){
        std::cin >> a >> b;
        tree[--a].registerChild(tree[--b]);
        tree[b].registerChild(tree[a]);
    }
    std::cout << tree[0].getColorsMod(K,0,0) << std::endl;
    return 0;
}


Compiler output:
a.cc: In member function 'int Tree::getColorsMod(unsigned int, unsigned int, unsigned int) const':
a.cc:24:5: error: expected ';' before '}' token
   24 |     }
      |     ^
Language: C++

#include<cstdio>
#include<vector>

using namespace std;

void deeper(int, int&);

static const int A = 1e9 + 7;
static const int MAX_N = 1e5;
static const int MAX_K = 1e5;

struct node {
    vector<int> to;
    int from = 0;
};

unsigned int per[MAX_K - 2];
node vertices[MAX_N];
int n, k;
bool judge = false;

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n - 1; i++) {
        int s, t;
        scanf("%d %d", &s, &t);
        vertices[s-1].to.push_back(t-1);
        vertices[t-1].to.push_back(s-1);
    }
    
    per[0] = k - 2;
    for (int i = 1; i < k - 2; i++) {
        per[i] = (k - i - 2L) * per[i-1] % A;
    }
    
    int res;
    switch (vertices[0].to.size() + 1) {
        case 1:
            res = k;
            break;
        case 2:
            res = static_cast<long>k * (k - 1);
            deeper(0, res);
            break;
        default:
            res = static_cast<long>(k) * (k - 1) * per[vertices[0].to.size() - 2];
            deeper(0, res);
            break;
    }
    if (judge == false) printf("%d\n", res);
    else printf("0\n");
    
    return 0;
}

void deeper(int num, int &ans) {
    if (k - 2 < vertices[num].to.size() - 1) judge = true;
    if (vertices[num].to.size() > 1 && num != 0)
        ans = static_cast<long>(per[vertices[num].to.size() - 2]) * ans % A;
    while (vertices[num].to.size() > 0 && judge == false) {
        if (vertices[num].to.back() != vertices[num].from) {
            vertices[vertices[num].to.back()].from = num;
            deeper(vertices[num].to.back(), ans);
        }
        vertices[num].to.pop_back();
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:36: error: expected '(' before 'k'
   42 |             res = static_cast<long>k * (k - 1);
      |                                    ^
      |                                    (
a.cc:42:47: error: expected ')' before ';' token
   42 |             res = static_cast<long>k * (k - 1);
      |                                               ^
      |                                               )
Language: C++

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;

vector<vector<int>> to;

vector<int> depth; vector<bool> visited;

void BFS( int v){
  //vを根としてdepthをつけて行く
   depth[v] = 0; visited[v] = true;
  
   queue<int> Q; Q.push(v); 
  
  while(!Q.empty()){
    int p = Q.front(); Q.pop();
    for(int i = 0; i < to[p].size(); i++){
      int j = to[p][i]; 
      if( visited[j]){ continue;}
      
      depth[j] = depth[i] + 1; visited[j] = true; Q.push(j);}}
  
  //すべてのノードの深さをつけた
}
      
void color(int v){
  //vノードを根として色を振り分けて行く
  
  for(int x = 0; x < N; x++){
    //xノードに着目
    if( x != v){ //xは根でない
      for(int y = 0; y < to[x].size() - 1; y++){
        ans *= K - 2 - y; ans%= MOD;}}
    
    else{ //xが根の時
      for(int y = 0; y < to[x].size(); y++){
        ans *= K - 1 - y; ans %= MOD;}}
  }
  }

int main(){
 cin >> N >> K;
  
  COMinit();
  
  to.resize(N);
  for(int i = 0; i < N - 1; i++){
    int a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b); to[b].push_back(a); //向きなし
  }
  
  depth = vector<int> (N,-1); visited = vector<bool> (N, false);

  BFS(0);
  
  ans = K;
  
  color(0);
  
  
  cout << ans << endl; return 0;}


Compiler output:
a.cc: In function 'void color(int)':
a.cc:32:22: error: 'N' was not declared in this scope
   32 |   for(int x = 0; x < N; x++){
      |                      ^
a.cc:36:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |         ans *= K - 2 - y; ans%= MOD;}}
      |         ^~~
      |         abs
a.cc:36:16: error: 'K' was not declared in this scope
   36 |         ans *= K - 2 - y; ans%= MOD;}}
      |                ^
a.cc:40:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |         ans *= K - 1 - y; ans %= MOD;}}
      |         ^~~
      |         abs
a.cc:40:16: error: 'K' was not declared in this scope
   40 |         ans *= K - 1 - y; ans %= MOD;}}
      |                ^
a.cc: In function 'int main()':
a.cc:45:9: error: 'N' was not declared in this scope
   45 |  cin >> N >> K;
      |         ^
a.cc:45:14: error: 'K' was not declared in this scope
   45 |  cin >> N >> K;
      |              ^
a.cc:47:3: error: 'COMinit' was not declared in this scope
   47 |   COMinit();
      |   ^~~~~~~
a.cc:59:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   59 |   ans = K;
      |   ^~~
      |   abs
Language: C++

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

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

const ll MAX_N=131072;

int bit[MAX_N*2-1];
ll n;
vector<int> G[1000010];
ll ans=0;
//combination
const int MAX = 210000;
const int MOD = 1000000007;
ll jun(int n,int k){
  if(k<=0) return 0;
  if(k==1) return n;
  return (n*jun(n-1,k-1))%MOD;
}
int main(){
  int N,K;cin>>N>>K;
  rep(i,N-1){
    int a,b;cin>>a>>b;
    a-=1;b-=1;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  queue<P> q;
  ll ans=K;
  q.push(P(-1,0));
  while(!q.empty()){
    P p=q.front();q.pop();
    int f=p.first;int t=p.second;
    if (f==-1){
      ans*=jun(K-1,G[t].size());
      ans%=MOD;
    }else{
      ans*=jun(K-2,G[t].size()-1);
      ans%=MOD;
    }
    for(auto v:G[t]){
      if (v==f || G[v].size()==1) continue;
      q.push(P(t,v));
    }
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:48:4: error: expected '}' at end of input
   48 |   }
      |    ^
a.cc:23:11: note: to match this '{'
   23 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>

const unsigned long long div_mod = 1e9+7;

using namespace std;

unsigned long long dfs(int color, vector<vector<int>> adj, int from, int cur)
{
  int available_color = (from == -1) ? color-1 : color-2;

  if (color < adj[cur].size()) {
    return 0;
  }

  unsigned long long kind = 1;
  for (auto e: adj[cur]) {
    if (e == from) {
      continue;
    }
    kind *= available_color;
    available_color--;
    kind %= div_mod;
  }

  for (auto e: adj[cur]) {
    if (e == from) {
      continue;
    }
    kind *= dfs(color, adj, cur, adj[cur][i]);
    kind %= div_mod;
  }
  return kind;
}

int main(int argc, char* argv[])
{
  int N, K; cin >> N >> K;
  
  vector<vector<int>> adj(N);
  for (int i = 0; i < N-1; i++) {
    int a, b; cin >> a >> b; a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }

  unsigned long long ans = K*dfs(K, adj, -1, 0);
  ans %= div_mod;
  cout << ans << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'long long unsigned int dfs(int, std::vector<std::vector<int> >, int, int)':
a.cc:30:43: error: 'i' was not declared in this scope
   30 |     kind *= dfs(color, adj, cur, adj[cur][i]);
      |                                           ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define P pair<int,int>
#define all(x) x.begin(),x.end()
using namespace std;

vector<vector<ll> > g;
vector<ll> cnt;

void dfs(int x,ll k)
{
	ll num=2;
	for (int i = 0; i < g[x].size(); i++)
  	{
		int p = g[x][i];
		if(cnt[p]<0)
      	{
			cnt[p] = max(0LL,k-num);
			num++;
			dfs(p,k);
		}
	}
}

int main()
{
	ll n,k;
	cin>>n>>k;
	if(n==1)
		return cout<<k<<endl , 0;
	g.resize(n,vector<ll>());
	cnt.resize(n,-1LL);
	for (int i = 0; i < n-1; i++)
  	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int s = -1;
	for (int i = 0; i < n; i++)
		if(g[i].size()==1)
      	{
			s=i;
			break;
		}
	cnt[s] = k;
	cnt[g[s][0]] = k-1;
	dfs(g[s][0],k);

	ll ans = 1;
	for (int i = 0; i < n; i++)
		ans *= cnt[i] , ans %= mod;
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:40: error: 'mod' was not declared in this scope; did you mean 'modf'?
   54 |                 ans *= cnt[i] , ans %= mod;
      |                                        ^~~
      |                                        modf
Language: C++

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

const ll mod = 1e9+7;

ll dfs(int k, const vector<vector<int>> &graph,int now,int from){
    int can_use_color_num;
    if(from==-1){
        can_use_color_num = K-1;
    }
    else{
        can_use_color_num = K-2;
    }
    if(k<graph[now].size()){
        return 0;
    }
    else{
        ll case_num=1;
        for(auto e:graph[now]){
            if(e==from) continue;
            case_num*=can_use_color_num;
            can_use_color_num--;
            case_num%=mod;
        }
        for(auto e:graph[now]){
            if(e==from) continue;
            case_num *= dfs(k,graph,e,now);
            case_num %= mod;
        }
        return case_num;
    }
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<vector<int>> graph(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        graph[a].push_back(a);
        graph[b].push_back(b);
        ll answer = k*dfs(k,graph,0,-1);
        answer%=mod;
        cout << answer << endl;
    }
 }

Compiler output:
a.cc: In function 'll dfs(int, const std::vector<std::vector<int> >&, int, int)':
a.cc:10:29: error: 'K' was not declared in this scope
   10 |         can_use_color_num = K-1;
      |                             ^
a.cc:13:29: error: 'K' was not declared in this scope
   13 |         can_use_color_num = K-2;
      |                             ^