Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*SS=SZB,*TT=SZB;
    inline char gc(){   if (SS==TT){  TT=(SS=SZB)+fread(SZB,1,GYN,stdin); if (SS==TT) return '\n';  }   return *SS++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);}
	void writeln(ll x){write(x);puts("");}
}using namespace SHENZHEBEI;
ll Lca(ll x,ll y){
	for(;x!=y;dep[x]<dep[y]?y=fa[y]:x=fa[x]);
	return x;
}
void Dfs(ll x){
	rep(i,0,g[x].size()){
		ll to=g[x][i];
		fa[to]=x;
		dep[to]=dep[x]+1;
		Dfs(to);
	}
}
void dfs(ll x){
	rep(i,0,g[x].size()){
		ll to=g[x][i];
		if (to==fa[x])continue;
		dfs(to);
	}
	if (x==1)return;
		
	for(set<ll>::iterator it=gg[x].begin();it!=gg[x].end();++it){
	}
}
int main(){
	n=read(),m=read();
	rep(i,1,n){ll x=read(),y=read();g[x].push_back(y);g[y].push_back(x);}
	For(i,1,m){
		A[i]=read(),B[i]=read();
		gg[a[i]=A[i]].insert(i);
		gg[b[i]=B[i]].insert(i);
	}Dfs(1);dfs(1);
	writeln(ans);
}
/*
(4x+2)^2+(4y+2)^2

16x^2+16y^2+8+16(x+y)
16(x^2+y^2+x+y)+8=256
(16x+k1)^2

%256=128
(16y+k2)^2
 k1 *x + k2 *y = (128-k1^2-k2^2)/32

循环接

*/

Compiler output:
a.cc: In function 'long long int Lca(long long int, long long int)':
a.cc:58:19: error: 'dep' was not declared in this scope; did you mean 'dup'?
   58 |         for(;x!=y;dep[x]<dep[y]?y=fa[y]:x=fa[x]);
      |                   ^~~
      |                   dup
a.cc:58:35: error: 'fa' was not declared in this scope; did you mean 'fma'?
   58 |         for(;x!=y;dep[x]<dep[y]?y=fa[y]:x=fa[x]);
      |                                   ^~
      |                                   fma
a.cc: In function 'void Dfs(long long int)':
a.cc:62:17: error: 'g' was not declared in this scope
   62 |         rep(i,0,g[x].size()){
      |                 ^
a.cc:7:44: note: in definition of macro 'rep'
    7 | #define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
      |                                            ^
a.cc:64:17: error: 'fa' was not declared in this scope; did you mean 'fma'?
   64 |                 fa[to]=x;
      |                 ^~
      |                 fma
a.cc:65:17: error: 'dep' was not declared in this scope; did you mean 'dup'?
   65 |                 dep[to]=dep[x]+1;
      |                 ^~~
      |                 dup
a.cc: In function 'void dfs(long long int)':
a.cc:70:17: error: 'g' was not declared in this scope
   70 |         rep(i,0,g[x].size()){
      |                 ^
a.cc:7:44: note: in definition of macro 'rep'
    7 | #define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
      |                                            ^
a.cc:72:25: error: 'fa' was not declared in this scope; did you mean 'fma'?
   72 |                 if (to==fa[x])continue;
      |                         ^~
      |                         fma
a.cc:77:34: error: 'gg' was not declared in this scope
   77 |         for(set<ll>::iterator it=gg[x].begin();it!=gg[x].end();++it){
      |                                  ^~
a.cc: In function 'int main()':
a.cc:81:9: error: 'n' was not declared in this scope; did you mean 'yn'?
   81 |         n=read(),m=read();
      |         ^
      |         yn
a.cc:81:18: error: 'm' was not declared in this scope; did you mean 'tm'?
   81 |         n=read(),m=read();
      |                  ^
      |                  tm
a.cc:82:41: error: 'g' was not declared in this scope
   82 |         rep(i,1,n){ll x=read(),y=read();g[x].push_back(y);g[y].push_back(x);}
      |                                         ^
a.cc:84:17: error: 'A' was not declared in this scope
   84 |                 A[i]=read(),B[i]=read();
      |                 ^
a.cc:84:29: error: 'B' was not declared in this scope
   84 |                 A[i]=read(),B[i]=read();
      |                             ^
a.cc:85:17: error: 'gg' was not declared in this scope
   85 |                 gg[a[i]=A[i]].insert(i);
      |                 ^~
a.cc:85:20: error: 'a' was not declared in this scope
   85 |                 gg[a[i]=A[i]].insert(i);
      |                    ^
a.cc:86:20: error: 'b' was not declared in this scope
   86 |                 gg[b[i]=B[i]].insert(i);
      |                    ^
a.cc:88:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   88 |         writeln(ans);
      |                 ^~~
      |                 abs