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

import java.util.HashSet;
import java.util.Scanner;
import java.util.stream.LongStream;

public class ABC133_D {
	static long mod = 1000000007;
    static boolean[] marked;
	static HashSet<Integer>[] adj;
	static long k;
	static int n;

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

	    marked = new boolean[n];
	    adj = new HashSet[n];
	    for (int i = 0; i < n; ++i) {
	    	adj[i] = new HashSet<Integer>();
	    }
	    for (int i = 0; i < n - 1; ++i) {
		    int a = sc.nextInt() - 1;
		    int b = sc.nextInt() - 1;
		    adj[a].add(b);
		    adj[b].add(a);
	    }

	    long count = dfs(2, -1);
	    System.out.println(k * count % mod);

	}

	public static long dfs(int i, int from)
	{
		long num_col;
		if (from == -1) num_col = k - 1;
		else num_col = k - 2;

		marked[i] = true;
		if (k < adj[i].size()) return 0;
		long count = 1;
		for (int j : adj[i])
		{
			if (!marked[j])
			{
				count = (dfs(j, i) * count) % mod;
			}
		}
		if (adj[i].size() == 1 && from != -1) return count;

		int num_children = 0;
		if (from == -1) num_children = adj[i].size();
		else num_children = adj[i].size() - 1;
		return (count * permutation(num_col, num_children)) % mod;
	}

	public static long factorial(int n)
	{
		if (n <= 1) return 1;
		return n * factorial(n-1) % mod;
	}

	public static long permutation(long n, int m)
	{
		if (n < m) return 1;
		if (m <= 0) return 1;
		return LongStream.rangeClosed(n-m+1, n).reduce(1, (l, r) -> (l * r) % mod);
	}

}


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

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;

struct _chunk {
	int connect;
	int dist;
	int color;
};

long long int dfs(int color, vector<vector<int> > graph, int now, int parent){
	int num = graph[now].size();
	int use_color = color;
	if (parent == -1) {
		use_color--;
	} else {
		use_color-=2;
	}
	if (color < num) {
		return 0;
	} else {
		ll case_num = 1;
		for(auto e : graph[now]) {
			if (e==parent) continue;
			case_num*=use_color;
			case_num%=MOD;
			use_color--;
		}

		for(auto e : graph[now]) {
			if (e!=parent) continue;
			case_num*=dfs(color, graph, graph[now][i], now);
			case_num%=MOD;
		}

		return case_num%MOD;
	}
}

signed main(void) {
  	int N, K;
  	cin >> N >> K;
  	// 0 is the root

  	vector<vector<int> > graph(N);
  	for (int i=0; i<N-1; ++i) {
  		int a, b;
  		cin >> a >> b;
  		a--; b--;

  		graph[a].pb(b);
  		graph[b].pb(a);
  	}

  	cout << K*dfs(K, graph, 0, -1)%MOD << endl;
 
	return 0;
}


Compiler output:
a.cc: In function 'long long int dfs(int, std::vector<std::vector<int> >, int, int)':
a.cc:52:64: error: 'i' was not declared in this scope
   52 |                         case_num*=dfs(color, graph, graph[now][i], now);
      |                                                                ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6;
const int p=1e9+7;
int i,j,k,m,n,tot,ans,x,y;
int ver[N],nxt[N],edge[N],head[N],f[N],dp[N],son[N],col[N],d[N];
bool vis[N];
void add(int x,int y)
{
	ver[++tot]=y,nxt[tot]=head[x],head[x]=tot;
}
void dfs(int x,int fa)
{
	f[x]=fa;
	for(int i=head[x];i;i=nxt[i])
	{
		if(ver[i]!=fa) son[x]++,dfs(ver[i],x);
	}
	int c=k;
	if(f[x]) c--;
	if(f[f[x]]) c--;
	if(son[f[x]]) c-=son[f[x]]-1;
	ans=(ans*c)%p; 
}
int main()
{
	scanf("%lld%lld",&n,&k);
	tot=1,ans=1;
	for(int i=1;i<n;i++)
	{
		scanf("%lld%lld",&x,&y);
		d[x]++,d[y]++;
		add(x,y);
		add(y,x);
	}
	dfs(1,0);
	printf("%lld",ans);
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_E main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

const ll MOD = 1e9 + 7;
int N, K;
vvi es;
vb vis;
ll ans;
ModCombination mc;

void dfs(int x, int px) {
    vis[x] = true;

    if (px==-1) ans *= mc.P(K-1, es[x].size());
    else ans *= mc.P(K-2, es[x].size()-1);
    ans %= MOD;

    for(int nx : es[x]) {
        if (vis[nx]) continue;

        dfs(nx, x);
    }
}

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

    cin >> N >> K;
    vi A(N - 1), B(N - 1);
    REP(i, N - 1) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }

    es = vvi(N);
    REP(i,N-1){
        es[A[i]].push_back(B[i]);
        es[B[i]].push_back(A[i]);
    }

    vis = vb(N, false);
    ans = K;
    mc.init(K, MOD);
    dfs(A[0], -1);

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc:32:1: error: 'ModCombination' does not name a type
   32 | ModCombination mc;
      | ^~~~~~~~~~~~~~
a.cc: In function 'void dfs(int, int)':
a.cc:37:24: error: 'mc' was not declared in this scope
   37 |     if (px==-1) ans *= mc.P(K-1, es[x].size());
      |                        ^~
a.cc:38:17: error: 'mc' was not declared in this scope
   38 |     else ans *= mc.P(K-2, es[x].size()-1);
      |                 ^~
a.cc: In function 'int main()':
a.cc:67:5: error: 'mc' was not declared in this scope
   67 |     mc.init(K, MOD);
      |     ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int> G[100010];
int n,k,ans;
void dfs(int v,int p){
  if(p!=0){
    int a=k-1;
  }else{
    int a=k-2;
  }
  for(auto e:G[v]){
    if(e==p)continue;
    dfs(e,v);
  }
  for(auto e:G[v]){
    if(e==p)continue;
    ans=(ans*a)%1000000007;
    a--;
  }
}
int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  ans=k;
  dfs(1,0);
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:17:14: error: 'a' was not declared in this scope
   17 |     ans=(ans*a)%1000000007;
      |              ^
Language: C++

#include<iostream>
#include<vector>
#define MAX_N 100000
#define MOD (1000000007)
#define int long long
using namespace std;
vector<int> g[MAX_N];
int n,k,a,b;
int P(int n,int r){
  int tmp=1;
  for(int i=0;i<r;i++){
    tmp*=(n-i);
    tmp%=MOD;
  }
  return tmp%MOD;
}
int dfs(int now,int from){
  int next_val,result=1,K;
  if(from==-1){
    K=P(k-1,g[now].size());
  }else{
    K=P(k-2,g[now].size()-1);
  }
  for(int i=0;i<g[now].size();i++){
    if(g[now][i]==from) continue;
    else{
      result *=dfs(g[now][i],now);
      result %= MOD;
    }
  }
  return (K*result)%MOD;
}
int main(){
  int ans=1;
  cin >> n >> k;
  for(int i=0;i<n-1;i++){
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cout <<(dfs(0,-1)*k)%MOD<<endl;
  return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;



int main(int argc, char const *argv[])
{
  ll n, k;
  vector<vector<ll>> e(n, vector<ll>(0));
  queue<ll> q;
  queue<ll> bro;
  vector<bool> visit(n, false);
  cin >> n >> k;
  REP(i, n - 1)
  {
    ll a, b;
    cin >> a >> b;
    e[a - 1].push_back(b - 1);
    e[b - 1].push_back(a - 1);
  }
  cout << 1 << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:25:3: error: 'll' was not declared in this scope
   25 |   ll n, k;
      |   ^~
a.cc:26:17: error: template argument 2 is invalid
   26 |   vector<vector<ll>> e(n, vector<ll>(0));
      |                 ^~
a.cc:26:19: error: template argument 1 is invalid
   26 |   vector<vector<ll>> e(n, vector<ll>(0));
      |                   ^~
a.cc:26:19: error: template argument 2 is invalid
a.cc:26:24: error: 'n' was not declared in this scope
   26 |   vector<vector<ll>> e(n, vector<ll>(0));
      |                        ^
a.cc:26:36: error: template argument 2 is invalid
   26 |   vector<vector<ll>> e(n, vector<ll>(0));
      |                                    ^
a.cc:26:40: error: expression list treated as compound expression in initializer [-fpermissive]
   26 |   vector<vector<ll>> e(n, vector<ll>(0));
      |                                        ^
a.cc:27:11: error: template argument 2 is invalid
   27 |   queue<ll> q;
      |           ^
a.cc:28:11: error: template argument 2 is invalid
   28 |   queue<ll> bro;
      |           ^
a.cc:30:15: error: 'k' was not declared in this scope
   30 |   cin >> n >> k;
      |               ^
a.cc:33:7: error: expected ';' before 'a'
   33 |     ll a, b;
      |       ^~
      |       ;
a.cc:34:12: error: 'a' was not declared in this scope
   34 |     cin >> a >> b;
      |            ^
a.cc:34:17: error: 'b' was not declared in this scope
   34 |     cin >> a >> b;
      |                 ^
Language: C

#include <stdio.h>
#define Mod 1000000007

int g[100000][100000];
int used[100000] = {};
int in[100000] = {};
int k;

long long ans;

long long P(long long a, long long b){
  long long r =  1;
  if(a < b) return 0;
  for(int i = 0; (long long)i < b; i++){
    r = r * a % Mod;
    a--;
  }
  return r;
}



void dfs(int u){
  used[u] = 1; int cnt = 0;
  for(int i = 0; i < in[u]; i++){
    if(used[g[u][i]] == 0) cnt++;
   
  }
  
  ans = ans * P((long long)k - 2, (long long)cnt) % Mod;
  for(int i = 0; i < in[u]; i++){
    if(used[g[u][i]] == 0){
      used[g[u][i]] = 1;
      dfs(g[u][i]);
    }
  }
  return;
}
      
  

int
main(int argc, char *atgv[])
{
  
  int n;
  used[0] = 1;
  int a, b;
  scanf("%d %d", &n, &k);
  for(int i = 0; i < n - 1; i++){
    scanf("%d %d", &a, &b);
    a--; b--;
    g[a][in[a]] = b; in[a]++;
    g[b][in[b]] = a; in[b]++;
  }
 
    
  ans = (long long)k * P((long long)k - 1, (long long)in[0]) % Mod;

  for(int i = 0; i < in[0]; i++){
    dfs(g[0][i]);
  }

  printf("%lld\n", ans);

  return 0;
}

  
  


Compiler output:
/tmp/ccxgg1UU.o: in function `dfs':
main.c:(.text+0xaa): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccxgg1UU.o
main.c:(.text+0xf9): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccxgg1UU.o
main.c:(.text+0x11c): relocation truncated to fit: R_X86_64_PC32 against symbol `in' defined in .bss section in /tmp/ccxgg1UU.o
main.c:(.text+0x12f): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccxgg1UU.o
main.c:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccxgg1UU.o
main.c:(.text+0x185): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccxgg1UU.o
main.c:(.text+0x1c9): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccxgg1UU.o
main.c:(.text+0x208): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccxgg1UU.o
main.c:(.text+0x255): relocation truncated to fit: R_X86_64_PC32 against symbol `in' defined in .bss section in /tmp/ccxgg1UU.o
/tmp/ccxgg1UU.o: in function `main':
main.c:(.text+0x27a): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccxgg1UU.o
main.c:(.text+0x289): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> v[N];
  for(int i=1;i<N;i++){
    int a,b;cin>>a>>b;a--;b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int ans=1;
  queue<int> que;
  que.push(0);
  std::vector<int> res(N,0),used(N,0);used[k]++;
  while(que.size()){
    int q=que.front();que.pop();
    int t=0;for(int a:v[q])t+=res[a];
    ans*=max(K-res[q]-t,0LL);ans%=MOD;
    for(int p:v[q]){
      res[p]++;
      if(used[p])continue;
      que.push(p);used[p]++;
    }
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:44: error: 'k' was not declared in this scope
   22 |   std::vector<int> res(N,0),used(N,0);used[k]++;
      |                                            ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#define graph_from1 true
#define graph_tree true
#define graph_weight false
#define mod 1000000007
typedef long long ll;
using namespace std;

class Graph_func
{
public:
	int N;
	int N_edge;
	int K;
	int paintini;
	ll ans;
	vector<pair<int, int> > edgelist;
	vector<int> edgeweight;
	vector<vector<int> > adjlist;
	vector<vector<int> > adjlistweight;
	vector<int> adjnum;

	vector<int> xdist;

	vector<bool> x_fixed;

	void read_edge();
	void adjini();
	ll paint(int n, int n_old);

	bool xydist_def = false;
};

void Graph_func::read_edge()
{
	cin >> N >> K;
	if (graph_tree)
		N_edge = N - 1;// graph
	else
		cin >> N_edge;
	edgelist.resize(N_edge);
	edgeweight.resize(N_edge);
	adjnum.resize(N);
	xdist.resize(N);
	adjlist.resize(N);
	if (graph_weight)
		adjlistweight.resize(N);
	//cout << N << " " << N_edge << endl;
	for (int i = 0; i < N_edge; i++)
	{
		if (graph_weight)
			cin >> edgelist[i].first >> edgelist[i].second >> edgeweight[i];
		else
			cin >> edgelist[i].first >> edgelist[i].second;
		if (graph_from1)
		{
			edgelist[i].first--;
			edgelist[i].second--;
		}
	}
	return;
}

void Graph_func::adjini()
{
	for (int i = 0; i < N; i++)
		adjnum[i] = 0;
	for (int i = 0; i < N_edge; i++)
	{
		int x = edgelist[i].first;
		int y = edgelist[i].second;
		int xyweight = edgeweight[i];
		adjlist[x].push_back(y);
		adjlist[y].push_back(x);
		if (graph_weight)
		{
			adjlistweight[x].push_back(xyweight);
			adjlistweight[y].push_back(xyweight);
		}
		adjnum[x]++;
		adjnum[y]++;
	}
	return;
}


ll Graph_func::paint(int n, int n_old) // included adjini()
{
	int Nsum = adjnum[n];
	int count = 0;
	for (int i = 0; i < Nsum; i++)
	{
		int n_new = adjlist[n][i];
		if (n_new != n_old)
		{
			int paintN = K - 2 - count;
			if (n == paintini)
				paintN++;
			paintN = max(0, paintN);
			paintN %= mod;
			ans *= paintN;
			ans %= mod;
			count++;
			paint(n_new, n);
		}
	}
}

int main(void)
{
	Graph_func graph;
	graph.read_edge();
	graph.adjini();
	graph.ans = graph.K;
	int Nsta = 0
	graph.paintini = Nsta;
	graph.paint(Nsta, mod);
	cout << graph.ans << endl;

	return 0;
}

Compiler output:
a.cc: In member function 'll Graph_func::paint(int, int)':
a.cc:113:1: warning: no return statement in function returning non-void [-Wreturn-type]
  113 | }
      | ^
a.cc: In function 'int main()':
a.cc:122:9: error: expected ',' or ';' before 'graph'
  122 |         graph.paintini = Nsta;
      |         ^~~~~
Language: C

#include <stdio.h>
#define Mod 1000000007

int g[100000][100000];
int used[100000] = {};
int in[100000] = {};
int k;

long long ans;

long long P(long long a, long long b){
  long long r =  1;
  if(a < b) return 0;
  for(int i = 0; (long long)i < b; i++){
    r = r * a % Mod;
    a--;
  }
  return r;
}



void dfs(int u){
  used[u] = 1; int cnt = 0;
  for(int i = 0; i < in[u]; i++){
    if(used[g[u][i]] == 0) cnt++;
  }
  ans = ans * P((long long)k - 2, (long long)cnt) % Mod;
  for(int i = 0; i < in[u]; i++){
    if(used[g[u][i]] == 0){
      used[g[u][i]] = 1;
      dfs(i);
    }
  }
  return;
}
      
  

int
main(int argc, char *atgv[])
{
  int n;
  used[0] = 1;
  int a, b;
  scanf("%d %d", &n, &k);
  for(int i = 0; i < n - 1; i++){
    scanf("%d %d", &a, &b);
    a--; b--;
    g[a][in[a]] = b; in[a]++;
    g[b][in[b]] = a; in[b]++;
  }
  
    
  ans = (long long)k * P((long long)k - 1, (long long)in[0]) % Mod;

  for(int i = 0; i < in[0]; i++){
    dfs(g[0][i]);
  }

  printf("%lld\n", ans);

  return 0;
}

  
  


Compiler output:
/tmp/ccnQbRyD.o: in function `dfs':
main.c:(.text+0xaa): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccnQbRyD.o
main.c:(.text+0xf9): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccnQbRyD.o
main.c:(.text+0x11c): relocation truncated to fit: R_X86_64_PC32 against symbol `in' defined in .bss section in /tmp/ccnQbRyD.o
main.c:(.text+0x12f): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccnQbRyD.o
main.c:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccnQbRyD.o
main.c:(.text+0x185): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccnQbRyD.o
main.c:(.text+0x1c9): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccnQbRyD.o
main.c:(.text+0x208): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccnQbRyD.o
main.c:(.text+0x231): relocation truncated to fit: R_X86_64_PC32 against symbol `in' defined in .bss section in /tmp/ccnQbRyD.o
/tmp/ccnQbRyD.o: in function `main':
main.c:(.text+0x256): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccnQbRyD.o
main.c:(.text+0x265): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C

#include <stdio.h>
#define Mod 1000000007

int g[100000][100000];
int used[100000] = {};
int in[100000] = {};
int k;

long long ans;

long long P(long long a, long long b){
  long long r =  1;
  if(a < b) return 0;
  for(int i = 0; (long long)i < b; i++){
    r = r * a % Mod;
    a--;
  }
  return r;
}



void dfs(int u){
  used[u] = 1; int cnt = 0;
  for(int i = 0; i < in[u]; i++){
    if(used[g[k][i]] == 0) cnt++;
  }
  ans = ans * P((long long)k - 2, (long long)cnt) % Mod;
  for(int i = 0; i < in[u]; i++){
    if(used[g[k][i]] == 0){
      used[g[k][i]] = 1;
      dfs(i);
    }
  }
  return;
}
      
  

int
main(int argc, char *atgv[])
{
  int n;
  used[0] = 1;
  int a, b;
  scanf("%d %d", &n, &k);
  for(int i = 0; i < n - 1; i++){
    scanf("%d %d", &a, &b);
    a--; b--;
    g[a][in[a]] = b; in[a]++;
    g[b][in[b]] = a; in[b]++;
  }
  
    
  ans = (long long)k * P((long long)k - 1, (long long)in[0]) % Mod;

  for(int i = 0; i < in[0]; i++){
    dfs(g[0][i]);
  }

  printf("%lld\n", ans);

  return 0;
}

  
  


Compiler output:
/tmp/ccClIUvc.o: in function `dfs':
main.c:(.text+0xaa): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccClIUvc.o
main.c:(.text+0xc7): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccClIUvc.o
main.c:(.text+0xfc): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccClIUvc.o
main.c:(.text+0x11f): relocation truncated to fit: R_X86_64_PC32 against symbol `in' defined in .bss section in /tmp/ccClIUvc.o
main.c:(.text+0x132): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccClIUvc.o
main.c:(.text+0x14b): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccClIUvc.o
main.c:(.text+0x188): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccClIUvc.o
main.c:(.text+0x19a): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccClIUvc.o
main.c:(.text+0x1cf): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccClIUvc.o
main.c:(.text+0x1dc): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccClIUvc.o
main.c:(.text+0x211): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	i64 n, k; scanf("%lld%lld", &n, &k); std::vector<std::vector<int>> g(n);
	for(int i = 0; i < n - 1; i++) {
		int x, y; scanf("%d%d", &x, &y);
		x--; y--;
		
		g[x].push_back(y);
		g[y].push_back(x);
	}
	
	std::vector<int> degree(n, 0), sub(n, 0);
	std::function<void (int, int)> calc = [&](int v, int par) {
		sub[v] = 1;
		for(auto e: g[v]) {
			if(e == par) continue;
			sub[v]++;
			calc(e, v);
		}
	};
	std::function<void (int, int)> calc2 = [&](int v, int par) {
		degree[v] = 1;
		for(auto e: g[v]) {
			if(e == par) continue;
			degree[v] += sub[e];
			calc2(e, v);
		}
	};
	cakc(0, -1); calc2(0, -1);
	
	for(auto v: degree) {
		if(v <= k) continue;
		printf("0\n");
		return 0;
	} 
	
	const int MOD = 1e9 + 7;
	std::vector<i64> fact(n + 1, 1);
	for(int i = 0; i < n; i++) fact[i + 1] = fact[i] * (k - i - 2);

	auto dp = make_v<i64>(n);
	std::function<void (int, int)> solve = [&](int v, int par) {
		i64 latte = 1, deg = 0;
		for(auto e: g[v]) {
			if(e == par) continue;
			solve(e, v); deg++;
			
			(latte *= dp[e]) %= MOD;
		}
		
		if(par == -1) {
			i64 malta = 1;
			for(i64 i = 0; i < deg + 1; i++) (malta *= k - i) %= MOD;
			dp[v] = latte * malta % MOD;
			return;
		}
		dp[v] = latte * fact[deg] % MOD;
	};
	solve(0, -1);
	
	printf("%lld\n", dp[0]);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:9: error: 'cakc' was not declared in this scope; did you mean 'calc'?
   43 |         cakc(0, -1); calc2(0, -1);
      |         ^~~~
      |         calc
Language: C++

#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define MOD 1000000007

ll N, K;
vector<ll> G[100000];
ll color[100000];
bool visited[10000];

ll fact[100001], fact_i[100001];

ll power(int x, int y) {
    if (y == 1) return x;
    ll p = power(x, y >> 1);
    if (y & 1) return p * p % MOD * x % MOD;
    else return p * p % MOD;
}

ll inv(ll n) {
    return power(n, MOD - 2);
}

void init(int n) {
    fact[0] = 1;
    REP(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_i[n] = inv(fact[n]);
    REP(i, n) fact_i[n - i - 1] = fact_i[n - i] * (n - i) % MOD;
}

ll nCr(ll n, ll r) {
    if (n < r || n < 0 || r < 0) return 0;
    return fact[n] * fact_i[r] % MOD * fact_i[n - r] % MOD;
}

void dfs(ll n, ll before, ll c) {
    color[n] = c;
    for (ll i : G[n]) {
        if (i == before) continue;
        dfs(i, n, max(c - 1, K - 2));
    }
}

ll bfs_c(ll n) {
    queue<ll> q;
    q.push(n);
    while(!q.empty()) {
        vector<ll> tmp;
        ll f = q.front(); q.pop();
        visited[f] = true;
        for (auto i : G[f]) {
            if (!visited[i]) {
                tmp.push_back(i);
            }
        }
        if (tmp.empty()) break;
        ans = ans * nCr(color[tmp[0]], tmp.size()) % MOD;
        for (auto i : tmp) q.push(i);
    }
}

// ll ans = 1;

// bool dfs(ll n, ll before, ll c) {
//     int cnt = 0;
//     for (ll i : G[n]) {
//         if (i == before) continue;
//         cnt++;
//         if (dfs(i, n, max(c - 1, K - 2))) return true;
//     }
//     if (cnt == 0) {
//         ans
//     }
//     if (cnt <= c) {
//         ans = ans * nCr(c, cnt) % MOD;
//         cout << n << "," << before << "," << c << "," << cnt << "," << ans << endl;
//         return false;
//     } else return true;
// }

int main() {
    cin >> N >> K;
    init(100000);
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0, -1, K);
    // else cout << ans << endl;
    // REP(i, N) cout << color[i] << " "; cout << endl;
    cout << bfs_c(0) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'll bfs_c(ll)':
a.cc:70:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   70 |         ans = ans * nCr(color[tmp[0]], tmp.size()) % MOD;
      |         ^~~
      |         abs
a.cc:73:1: warning: no return statement in function returning non-void [-Wreturn-type]
   73 | }
      | ^
Language: Java

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		Map<Integer,List<Integer>> map = new HashMap<>();
		for(int i=0;i<n-1;i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			if(map.containsKey(a)) map.get(a).add(b);
			else {
				List<Integer> list = new ArrayList<>();
				list.add(b);
				map.put(a, list);
			}
			if(map.containsKey(b)) map.get(b).add(a);
			else {
				List<Integer> list = new ArrayList<>();
				list.add(a);
				map.put(b, list);
			}
		}
		/*
		long ans = k;
		long mod = 1000000007;
		Queue<Integer> que = new ArrayDeque<>();
		
		boolean[] used = new boolean[n+1];
		
		List<Integer> list = map.get(1);
		for(int i=0;i<list.size();i++) {
			que.add(list.get(i));
			ans = (ans * (k-1-i))%mod;
		}
		used[1] = true;
		*/
		
		while(!que.isEmpty()) {
			int tmp = que.poll();
			if(!used[tmp]) {
				list = map.get(tmp);
				for(int i=0;i<list.size();i++) {
					que.add(list.get(i));
				}
				for(int i=0;i<list.size()-1;i++) {
					ans = (ans * (k-2-i))%mod;
				}
				used[tmp] = true;
			}
		}
		System.out.println(ans);
		
		
		in.close();

	}

}


Compiler output:
Main.java:47: error: cannot find symbol
		while(!que.isEmpty()) {
		       ^
  symbol:   variable que
  location: class Main
Main.java:48: error: cannot find symbol
			int tmp = que.poll();
			          ^
  symbol:   variable que
  location: class Main
Main.java:49: error: cannot find symbol
			if(!used[tmp]) {
			    ^
  symbol:   variable used
  location: class Main
Main.java:50: error: cannot find symbol
				list = map.get(tmp);
				^
  symbol:   variable list
  location: class Main
Main.java:51: error: cannot find symbol
				for(int i=0;i<list.size();i++) {
				              ^
  symbol:   variable list
  location: class Main
Main.java:52: error: cannot find symbol
					que.add(list.get(i));
					^
  symbol:   variable que
  location: class Main
Main.java:52: error: cannot find symbol
					que.add(list.get(i));
					        ^
  symbol:   variable list
  location: class Main
Main.java:54: error: cannot find symbol
				for(int i=0;i<list.size()-1;i++) {
				              ^
  symbol:   variable list
  location: class Main
Main.java:55: error: cannot find symbol
					ans = (ans * (k-2-i))%mod;
					^
  symbol:   variable ans
  location: class Main
Main.java:55: error: cannot find symbol
					ans = (ans * (k-2-i))%mod;
					       ^
  symbol:   variable ans
  location: class Main
Main.java:55: error: cannot find symbol
					ans = (ans * (k-2-i))%mod;
					                      ^
  symbol:   variable mod
  location: class Main
Main.java:57: error: cannot find symbol
				used[tmp] = true;
				^
  symbol:   variable used
  location: class Main
Main.java:60: error: cannot find symbol
		System.out.println(ans);
		                   ^
  symbol:   variable ans
  location: class Main
13 errors
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[100000];

long long dfs(int prev,int now,long long k,vector<int> &used){
  int temp = G[now].size();
  long long res;
  if(prev==-1){
    res = mod(k);
    used[now]=true;
    REP(i,temp){
      res = mod(res*dfs(now,G[now][i],k,used));
    }
  }else{
    int adj = G[prev].size();
    long long no_use=0;
    REP(i,adj){
      if(G[prev][i]!=now && used[G[prev][i]]){
        no_use++;
      }
    }
    if(k-no_use-1>0){
      res = mod(k-no_use-1);
    }else{
      res = 0;
    }
    used[now] = true;
    
    REP(i,temp){
      if(G[now][i]==prev)continue;
      res = mod(res*dfs(now,G[now][i],k,used));
    }
  }
  return res;
}
    
  
int main(){
  int n;
  long long k;
  cin>>n>>k;
  
  //vector<int> G[n];
  int a,b;
  REP(i,n-1){
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  bool used[n]={};
  
  long long ans;
  ans = dfs(-1,0,k,G,used);
  cout<<ans<<endl;
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:141:20: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<int> [100000]'
  141 |   ans = dfs(-1,0,k,G,used);
      |                    ^
a.cc:91:57: note: in passing argument 4 of 'long long int dfs(int, int, long long int, std::vector<int>&)'
   91 | long long dfs(int prev,int now,long long k,vector<int> &used){
      |                                            ~~~~~~~~~~~~~^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
struct E{
	int to;
	int clr;
	int len;
};
vector<E> g[100005];
int anc[18][100005],d[100005];
void dfs(int u,int fa){
	for(auto v:g[u]){
		if(v.to==fa){
			continue;
		}
		anc[0][v.to]=u;
		d[v.to]=d[u]+1;
		dfs(v.to,u);
	}
}
int LCA(int x,int y){
	if(d[x]>d[y]){
		swap(x,y);
	}
	for(int ind=0;d[x]<d[y];++ind){
		if((d[y]-d[x])>>ind&1){
			y=anc[ind][y];
		}
	}
	if(x==y){
		return x;
	}
	for(int ind=18;ind--;){
		if(anc[ind][x]!=anc[ind][y]){
			x=anc[ind][x],y=anc[ind][y];
		}
	}
	return anc[0][x];
}
struct info{
	int ind;
	char typ;
	int clr;
	int cnt;
	info(){}
	info(int in,char ty,int cl,int cn){
		ind=in,typ=ty,clr=cl,cnt=cn;
	}
}; 
vector<info> q[100005];
int sum[100005];
int cnt[100005];
int ans[100005];
void DFS(int u,int fa,ll len){
	for(auto now:q[u]){
		if(now.typ=='d'){
			ans[now.ind]+=len*now.cnt;
		}
		else if(now.typ=='s'){
			ans[now.ind]+=sum[now.clr]*now.cnt;
		}
		else{
			ans[now.ind]+=cnt[now.clr]*now.cnt;
		}
	}
	for(auto v:g[u]){
		if(v.to==fa){
			continue;
		}
		sum[v.clr]+=v.len;
		cnt[v.clr]++;
		DFS(v.to,u,len+v.len);
		sum[v.clr]-=v.len;
		cnt[v.clr]--;
	}
}
int main(){
	int n,Q;
	cin>>n>>Q;
	for(int i=1;i<n;++i){
		int u,v,clr,leng;
		cin>>u>>v>>clr>>leng; 
		u--,v--,clr--;
		E a;
		a.to=v,a.len=leng,a.clr=clr;
		E b;
		b.to=u,b.len=leng,b.clr=clr;
		g[u].push_back(a),g[v].push_back(b);
	}
	dfs(0,0);
	for(int ind=0;ind<17;++ind){
		for(int u=0;u<n;++u){
			anc[ind+1][u]=anc[ind][anc[ind][u]];
		}
	}
	for(int i=0;i<Q;++i){
		int clr,leng,u,v;
		cin>>clr>>leng>>u>>v;
		clr--;
		u--;
		v--;
		int lca=LCA(u,v);
		q[u].emplace_back(i,'d',0,1);
		q[u].emplace_back(i,'s',clr,-1);
		q[u].emplace_back(i,'c',clr,leng);
		q[v].emplace_back(i,'d',0,1);
		q[v].emplace_back(i,'s',clr,-1);
		q[v].emplace_back(i,'c',clr,leng);
		q[lca].emplace_back(i,'d',0,-2);
		q[lca].emplace_back(i,'s',clr,2);
		q[lca].emplace_back(i,'c',clr,-2*leng);
	}
	DFS(0,0,0);
	for(int i=0;i<Q;++i){
		cout<<ans[i]<<'\n';
	}
	return 0;
}


Compiler output:
a.cc:53:23: error: 'll' has not been declared
   53 | void DFS(int u,int fa,ll len){
      |                       ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
struct node {
	int y,c,d;
};
int M = 100001;
vector<node>T[M],Q[M];
int H[M],F[M][18],D[M],C[M],CD[M],An[M];
void dfs(int x,int la,int d) {
	H[x]=H[la]+1,D[x]=d,F[x][0]=la;
	for(int i=0; i<T[x].size(); i++) {
		node nw=T[x][i];
		if(nw.y!=la)dfs(nw.y,x,d+nw.d);
	}
}
void dfs1(int x,int la){
	for(int i=0;i<Q[x].size();i++){
		node nw=Q[x][i];
		if(nw.y>0)An[nw.y]+=D[x]+C[nw.c]*nw.d-CD[nw.c];
		else An[-nw.y]-=2*(D[x]+C[nw.c]*nw.d-CD[nw.c]);
	}
	for(int i=0;i<T[x].size();i++){
		node nw=T[x][i];
		if(nw.y!=la)C[nw.c]++,CD[nw.c]+=nw.d,dfs1(nw.y,x),C[nw.c]--,CD[nw.c]-=nw.d;
	}
}
int LCA(int x,int y) {
	if(H[x]>H[y])swap(x,y);
	int s=H[y]-H[x];
	for(int i=0; i<=17; i++)if(s&(1<<i))y=F[y][i];
	if(x==y)return x;
	for(int i=17; i>=0; i--)if(F[x][i]!=F[y][i])x=F[x][i],y=F[y][i];
	return F[x][0];
}
int main() {
	int a,b,i,j,x,y,c,d;
	cin>>a>>b;
	for(i=1; i<a; i++)scanf("%d%d%d%d",&x,&y,&c,&d),T[x].push_back({y,c,d}),T[y].push_back({x,c,d});
	dfs(1,0,0);
	for(i=1; i<=17; i++)for(j=1; j<=a; j++)F[j][i]=F[F[j][i-1]][i-1];
	for(i=1; i<=b; i++)scanf("%d%d%d%d",&c,&d,&x,&y),Q[x].push_back({i,c,d}),Q[y].push_back({i,c,d}),Q[LCA(x,y)].push_back({-i,c,d});
	dfs1(1,0);
	for(i=1;i<=b;i++)printf("%d\n",An[i]);
}

Compiler output:
a.cc:7:15: error: size of array 'T' is not an integral constant-expression
    7 | vector<node>T[M],Q[M];
      |               ^
a.cc:7:20: error: size of array 'Q' is not an integral constant-expression
    7 | vector<node>T[M],Q[M];
      |                    ^
a.cc:8:7: error: size of array 'H' is not an integral constant-expression
    8 | int H[M],F[M][18],D[M],C[M],CD[M],An[M];
      |       ^
a.cc:8:12: error: size of array 'F' is not an integral constant-expression
    8 | int H[M],F[M][18],D[M],C[M],CD[M],An[M];
      |            ^
a.cc:8:21: error: size of array 'D' is not an integral constant-expression
    8 | int H[M],F[M][18],D[M],C[M],CD[M],An[M];
      |                     ^
a.cc:8:26: error: size of array 'C' is not an integral constant-expression
    8 | int H[M],F[M][18],D[M],C[M],CD[M],An[M];
      |                          ^
a.cc:8:32: error: size of array 'CD' is not an integral constant-expression
    8 | int H[M],F[M][18],D[M],C[M],CD[M],An[M];
      |                                ^
a.cc:8:38: error: size of array 'An' is not an integral constant-expression
    8 | int H[M],F[M][18],D[M],C[M],CD[M],An[M];
      |                                      ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define M 20
#define ll long long

int depth[N];
int anc[N][M];
int a[N],b[N],c[N],d[N];
vector<int> adj[N];

ll pre[N*3];
int st[N];

vector<pair<int,pair<ll,int> > > v[N];
int getLca(int u,int v) {
    if(depth[u]<depth[v]) {
        swap(u,v);
    }
    int diff = depth[u] - depth[v];
    for(int i=0;i<M;++i) {
        if(diff&(1<<i)) {
            u = anc[u][i];
        }
    }
    if(u!=v) {
        for(int i=M-1;i>=0;--i) {
            if(anc[u][i]!=anc[v][i]) {
                u = anc[u][i];
                v = anc[v][i];
            }
        }
        u = anc[u][0];
    }
    return u;
}
void dfs(int node,int p) {
    static int pos = 1;
    anc[node][0] = p;
    for(int i=1;i<M;++i) {
        anc[node][i] = anc[anc[node][i-1]][i-1];
    }
    int sz = adj[node].size();
    for(int i=0;i<sz;++i) {
        int eid = adj[node][i];
        int ch = a[eid]^b[eid]^node;
        if(ch==p) {
            continue;
        }
        depth[ch] = depth[node] + 1;
        st[ch] = pos;
        pre[pos] = pre[pos-1] + d[eid];
        int color = c[eid];
        
        pair<ll,int> g = v[color].back().second;
        g.first += d[eid];
        g.second += 1;
        v[color].push_back(make_pair(pos,g));
        
        ++pos;
        dfs(ch,node);
        pre[pos] = pre[pos-1] - d[eid];
        pair<ll,int> g = v[color].back().second;
        g.first -= d[eid];
        g.second -= 1;
        v[color].push_back(make_pair(pos,g));
        ++pos;
    }
}
pair<ll,int> find(int color,int id) {
    pair<ll,int> ret = make_pair(0,0);
    if(v[color][0].first>id) {
        return ret;
    }
    int l = 0,r = v[color].size()-1,mid;
    while(l<r) {
        mid = (l+r+1)/2;
        if(v[color][mid].first<=id) {
            l = mid;
        } else {
            r = mid-1;
        }
    }
    ret = v[color][l].second;
    return ret;
}
void solve() {
    int n,q;scanf("%d %d",&n,&q);
    for(int i=1;i<=n-1;++i) {
        v[i].push_back(make_pair(0,make_pair(0,0)));
    }
    for(int i=0;i<n-1;++i) {
        scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
        adj[a[i]].push_back(i);
        adj[b[i]].push_back(i);
    }
    dfs(1,0);
    while(q--) {
        int x,y,u,v;
        scanf("%d %d %d %d",&x,&y,&u,&v);
        int lca = getLca(u,v);
        ll dist = pre[st[u]] + pre[st[v]] - pre[st[lca]];
        pair<ll,int> tmp = find(x,st[u]);
        pair<ll,int> tmp2 = find(x,st[v]);
        tmp.first += tmp2.first;
        tmp.second += tmp2.second;
        tmp2 = find(x,st[lca]);
        tmp.first -= tmp2.first;
        tmp.second -= tmp2.second;
        dist -= tmp.first;
        dist += (ll)tmp.second*y;
        printf("%lld\n",dist);
    }
}
int main() {
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:63:22: error: redeclaration of 'std::pair<long long int, int> g'
   63 |         pair<ll,int> g = v[color].back().second;
      |                      ^
a.cc:55:22: note: 'std::pair<long long int, int> g' previously declared here
   55 |         pair<ll,int> g = v[color].back().second;
      |                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int logN=20,N=100000+1;
int  n,q,dep[N],dis[N],cnt[N],res[N],sum[N];
struct edge
{
    int to,c,dis;
};
struct query
{
    int i,c,d,coef
};
vector<vector<edge>>G(N);
vector<vector<int>> pa(N,vector<int>(logN+1,-1));
vector<vector<query>> qs(N);
void init(int u,int p=-1,int d=0)
{
    if(p>=0)
    {
        pa[u][0]=p;
        dep[u]=dep[p]+1;
        dis[u]=dis[p]+d;
    }
    for(auto g:G[u])
    {
        int v=g.to;
        if(v!=p)
            init(v,u,g.dis);
    }
}
void parent(int n)
{
    for(int i=0;i<logN;i++)
    {
        for(int j=0;j<n;j++)
            if(~pa[j][i])pa[j][i+1]=pa[pa[j][i]][i];
    }
}
int lca(int u,int v)
{
    if(dep[u]>dep[v])
    {
        int tmp=u;
        u=v;
        v=tmp;
    }
    int k=dep[v]-dep[u];
    for(int i=0;i<logN;i++)
    {
        if((k>>i)&1)
            v=pa[v][i];
    }
    if(u==v)
        return u;
    for(int i=logN-1;i>=0;i--)
    {
        if(pa[u][i]!=pa[v][i])
            u=pa[u][i],v=pa[v][i];
    }
    return pa[u][0];
}
void dfs(int u,int p=-1)
{
    for(auto q:qs[u])
    {
        int diff=q.d*cnt[q.c]-sum[q.c];
        res[q.i]+=diff*q.coef;
    }
    for(auto g:G[u])
    {
        int v=g.to;
        if(v==p) continue;
        cnt[g.c]++,sum[g.c]+=dis[g.c];
        dfs(v,u);
        cnt[g.c]--,sum[g.c]-=dis[g.c];
    }
}
int main()
{
    cin>>n>>q;
    for(int i=0;i<n;i++)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--,b--;
        G[a].push_back({b,c,d});
        G[b].push_back({a,c,d});
    }
    init(0);
    parent(n);
    for(int i=0;i<q;i++)
    {
        int x,y,u,v;
        cin>>x>>y>>u>>v;u--,v--;
        int w=lca(u,v);
        qs[u].push_back({i,x,y,1});
        qs[v].push_back({i,x,y,1});
        qs[w].push_back({i,x,y,-2});
        res[i]=dis[u]+dis[v]-2*dis[w];
    }
    dfs(0);
    for(auto a:res)
        cout<<a<<'\n';
    return 0;
}


Compiler output:
a.cc:11:15: error: expected ';' at end of member declaration
   11 |     int i,c,d,coef
      |               ^~~~
      |                   ;
Language: C++

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd = 2e5+10;
struct {int v,net,col,c;}e[maxd<<1];
int f[maxd],eid;
int n,m;
int fa[maxd],son[maxd],d[maxd],tp[maxd];
int w[maxd],col[maxd],sz[maxd];
int len[maxd];
int rt[maxd*2],cnt,ls[maxd*40],rs[maxd*40],size[maxd*40];
int val[maxd*40];

void insert(int x,int y,int z,int l)
{
    e[eid].net = f[x];
    e[eid].v = y;
    e[eid].c = l;
    e[eid].col = z;
    f[x] = eid++;
}
void init()
{
    memset(f,-1,sizeof(f));
    eid = 0;
}
void dfs(int x,int p = 0)
{
    fa[x] = p;d[x] = d[p]+1;
    sz[x]++;
    for(int i=f[x];i+1;i=e[i].net)
    {
        int v = e[i].v;
        if(v == p) continue;
        w[v] = e[i].c;
        col[v] = e[i].col;
        len[v] = 1ll * len[x] + w[v];
        dfs(v,x);
        if(sz[v] > sz[son[x]]) son[x] = v;
        sz[x] += sz[v];
    }
}
void dfs1(int x,int p = 1)
{
    tp[x] = p;
    if(son[x]) dfs1(son[x],p);
    for(int i=f[x];i+1;i=e[i].net)
    {
        int v = e[i].v;
        if(v==fa[x]||v==son[x]) continue;
        dfs1(v,v);
    }
}
int lca(int x,int y)
{
    while(tp[x]!=tp[y])
    {
        //printf("%d %d\n",x,y);
        if(d[tp[x]] < d[tp[y]]) swap(x,y);
        x = fa[tp[x]];
    }
    //printf("%d %d\n",x,y);
    return d[x] < d[y]? x:y;
}
void insert(int &root,int last,int l,int r,int x)
{

    root = ++cnt; ls[root] = ls[last],rs[root]=rs[last];
    val[root] = 1ll * val[last] + w[x]; size[root] = size[last]+1;
    if(l==r) return;
    int mid = (l+r)>>1;
    if(col[x] <= mid) insert(ls[root],ls[last],l,mid,x);
    else insert(rs[root],rs[last],mid+1,r,x);
}
int query(int root,int l,int r,int x)
{
    if(l == r ) return root;
    int mid = (l+r)>>1;
    if(x <=mid) return query(ls[root],l,mid,x);
    else return query(rs[root],mid+1,r,x);
}
void build(int x)
{
    insert(rt[x],rt[fa[x]],1,n,x);
    for(int i=f[x];i+1;i=e[i].net)
        if(e[i].v!=fa[x]) build(e[i].v);
}
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    init();
    scanf("%d %d",&n,&m);
    for(int i=1;i<n;i++)
    {
        int a,b,c,d;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        insert(a,b,c,d); insert(b,a,c,d);
    }
    dfs(1);
    dfs1(1);
    // for(int i=1;i<=n;i++)
    //     printf("%d %d\n",i,son[i]);
    //printf("%d\n",lca(4,5));
    build(1);
    int a,b,c,d;
    printf("%d")
    // for(int i=1;i<=m;i++)
    // {
    //     scanf("%d %d %d %d",&c,&d,&a,&b);
    //     int g = lca(a,b);
    //     int ans =  len[a] + len[b] - 2*len[g];
    //     g = query(g,1,n,c);
    //     a = query(rt[a],1,n,c);
    //     b = query(rt[b],1,n,c);
    //     ans += (size[a] + size[b] - 2*size[g]) * d;
    //     ans -= (val[a] + val[b] - 2*val[g]);
    //     printf("%lld\n",ans);
    // }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:108:17: error: expected ';' before 'return'
  108 |     printf("%d")
      |                 ^
      |                 ;
......
  121 |     return 0;
      |     ~~~~~~
Language: C++

#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int parent[30][100005];//parent[i][j]:jの2^i親の場所
int d[100005],depth[100005];//根からの距離,根からの深さ
int lca(int u,int v){//共通の直近の親を伝える
  if(depth[u]>depth[v])swap(u,v);
  int U=u,V=v;
  int diff=depth[v]-depth[u];
  int cnt=0;
  while(diff){
    if(diff&1)v=parent[cnt][v];
    cnt++;
    diff>>=1;
  }
  if(u==v)return u;
  int high=25,low=-1;
  for(int k=25;k>=0;k--)if(parent[k][u]!=parent[k][v])u=parent[k][u],v=parent[k][v];
  return parent[0][u];
}
//main
signed main(){
  int N,Q;cin>>N>>Q;
  typedef pair<int,int> P;
  typedef pair<int,P> PP;
  std::vector<PP> edge[N];//行き先、色、長さ
  for(int i=1;i<N;i++){
    int u,v,c,d;cin>>u>>v>>c>>d;u--;v--;
    edge[u].push_back(PP(v,P(c,d)));
    edge[v].push_back(PP(u,P(c,d)));
  }
  //ここからdを作る
  std::vector<PP> ed[N],ged[N];//根付き木として見た時に下に降りる辺と上に上がる辺に分ける
  queue<int> que;
  std::vector<int> used(N,0);
  que.push(0);d[0]=0;depth[0]=0;
  while(que.size()){
    int p=que.front();que.pop();
    if(used[p])continue;used[p]++;
    for(auto q:edge[p]){
      int u=q.first,c=q.second.first,l=q.second.second;
      if(used[u])ged[p].push_back(PP(u,P(-c,-l)));
      else{
        ed[p].push_back(q);
        d[u]=d[p]+l;
        que.push(u);
        depth[u]=depth[p]+1;
      }
    }
  }
  //ここまでdを作った
  //ここからparentを作る
  memset(parent,-1,sizeof(parent));
  for(int i=0;i<N;i++)for(auto q:ged[i])parent[0][i]=q.first;
  for(int i=1;i<30;i++)
    for(int j=0;j<N;j++)
      if(parent[i-1][j]>=0)parent[i][j]=parent[i-1][parent[i-1][j]];
  //ここまでparentを作った
  std::vector<int> qu[N],x(Q),y(Q),u(Q),v(Q);
  for(int i=0;i<Q;i++){
    cin>>x[i]>>y[i]>>u[i]>>v[i];u[i]--;v[i]--;
    qu[u[i]].push_back(x[i]);
    qu[v[i]].push_back(x[i]);
    qu[lca(u[i],v[i])].push_back(x[i]);
  }
  std::vector<int> cnum(N,0),clong(N,0);//色iの今の個数と距離の合計
  stack<PP> sta;
  map<P,P> ma;//ma[P(i,j)]:頂点iの色jの個数と距離
  sta.push(PP(0,P(0,-1)));
  fill(used.begin(),used.end(),0);
  while(sta.size()){
    PP statop=sta.top();sta.pop();
    int p=statop.first,colo=statop.second.first,lon=statop.second.second;
    if(colo){
      if(colo>0)cnum[colo]++;
      else cnum[-colo]--;
      clong[abs(colo)]+=lon;
    }
    if(used[p]==0){
      for(auto qco:qu[p])ma[P(p,qco)]=P(cnum[qco],clong[qco]);//初めて来たならmapに書き込み
      for(auto rev:ged[p])sta.push(rev);//初めて来たなら辺を張る
      for(auto nonrev:ed[p])sta.push(nonrev);
    }
    used[p]++;
  }
  for(int i=0;i<Q;i++){
    int du=d[u[i]]-ma[P(u[i],x[i])].second+ma[P(u[i],x[i])].first*y[i];
    int dv=d[v[i]]-ma[P(v[i],x[i])].second+ma[P(v[i],x[i])].first*y[i];
    int w=lca(u[i],v[i]);
    int dw=d[w]-ma[P(w,x[i])].second+ma[P(w,x[i])].first*y[i];
    cout<<du+dv-2*dw<<endl;
  }
}

/*
解説AC
LCA、クエリ先読み、dfsをうまくやると根付き木を降りて登ってがやりやすいなどいろんな知識を学べる問題だった
LCAの実装は空でかけるようになったかな？
クエリ先読みにももう一つやり方があるみたいだし公式はそもそも先読みすらしてないっぽい？
いろんな提出をしてみたいね
/*


Compiler output:
a.cc:100:1: error: unterminated comment
  100 | /*
      | ^