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

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int N = sc.nextInt();
    int ay = sc.nextInt();
    int ax = sc.nextInt();
    String S = sc.next();
    String T = sc.next();
    
    for(int i=0;i<N;i++){
      	if(S.charAt(i) == "L"){
        	ax--;
      	}else if(S.charAt(i)=="R"){
        	ax++;
      	}else if(S.charAt(i)=="U"){
        	ay--;
      	}else if(S.charAt(i)=="D"){
        	ay++;
      	}
      
      	if(ax<=0 || ax>W || ay<=0 || ay>H){
        	System.out.println("NO");
          break;
      	}
      	
      
      	if(T.charAt(i)=="L"){
          if(ax>=2){
            ax--;
          }
      	}else if(T.charAt(i)=="R"){
          if(ax<W){
            ax++;
          }
      	}else if(T.charAt(i)=="U"){
          if(ay>=2){
            ay--;
          }
      	}else if(T.charAt(i)=="D"){
          if(ay<H){
        	ay++;
          }
      	}
      }
    
    if(ax>=1 && ax<=W && ay>=1 && ay<=H){
      System.out.println("YES");
    }
  }
}

Compiler output:
Main.java:15: error: bad operand types for binary operator '=='
      	if(S.charAt(i) == "L"){
      	               ^
  first type:  char
  second type: String
Main.java:17: error: bad operand types for binary operator '=='
      	}else if(S.charAt(i)=="R"){
      	                    ^
  first type:  char
  second type: String
Main.java:19: error: bad operand types for binary operator '=='
      	}else if(S.charAt(i)=="U"){
      	                    ^
  first type:  char
  second type: String
Main.java:21: error: bad operand types for binary operator '=='
      	}else if(S.charAt(i)=="D"){
      	                    ^
  first type:  char
  second type: String
Main.java:31: error: bad operand types for binary operator '=='
      	if(T.charAt(i)=="L"){
      	              ^
  first type:  char
  second type: String
Main.java:35: error: bad operand types for binary operator '=='
      	}else if(T.charAt(i)=="R"){
      	                    ^
  first type:  char
  second type: String
Main.java:39: error: bad operand types for binary operator '=='
      	}else if(T.charAt(i)=="U"){
      	                    ^
  first type:  char
  second type: String
Main.java:43: error: bad operand types for binary operator '=='
      	}else if(T.charAt(i)=="D"){
      	                    ^
  first type:  char
  second type: String
8 errors
Language: C++

#include<cstdio>
#include<cctype>
const int N=200050;
const int dx[4]={0,0,-1,1};
const int dy[4]={-1,1,0,0};
inline int rdc(){
	char c=getchar();
	while(!isupper(c))c=getchar();
	if(c=='L')return 0;
	else if(c=='R')return 1;
	else if(c=='U')return 2;
	else if(c=='D')return 3;
}
int s[N],t[N],h,w,n;
inline bool check(int x,int y,int d){
	int i,tx,ty;
	for(i=0;i<n;++i){
		if(s[i]==d){
			x+=dx[d];y+=dy[d];
			if(!x||x>h||!y||y>w)return 1;
		}
		if(t[i]==(d^1)){
			tx=x+dx[d^1];ty=y+dy[d^1];
			if(tx&&tx<=h&&ty&&ty<=w){x=tx;y=ty;}
		}
	}
	return 0;
}
int main(){
	int x,y,i,l=1,r,m,s1,s2;
	scanf("%d%d%d%d%d",&h,&w,&n,&x,&y);
	for(i=0;i<n;++i)s[i]=rdc();
	for(i=0;i<n;++i)t[i]=rdc();
	r=w;s1=0;
	while(l<=r){
		m=l+r>>1;
		if(check(1,m,0)){s1=m;l=m+1;}
		else r=m-1;
	}
	l=1;r=w;s2=w+1;
	while(l<=r){
		m=l+r>>1;
		if(check(1,m,1)){s2=m;r=m-1;}
		else l=m+1;
	}
	if(y<=s1||y>=s2){
		puts("NO");
		return 0;
	}
	l=1;r=h;s1=0;
	while(l<=r){
		m=l+r>>
		if(check(m,1,2)){s1=m;l=m+1;}
		else r=m-1;
	}
	l=1;r=h;s2=h+1;
	while(l<=r){
		m=l+r>>1;
		if(check(m,1,3)){s2=m;r=m-1;}
		else l=m+1;
	}
	if(x<=s1||x>=s2){
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:17: error: expected primary-expression before 'if'
   53 |                 if(check(m,1,2)){s1=m;l=m+1;}
      |                 ^~
a.cc:54:17: error: 'else' without a previous 'if'
   54 |                 else r=m-1;
      |                 ^~~~
a.cc: In function 'int rdc()':
a.cc:13:1: warning: control reaches end of non-void function [-Wreturn-type]
   13 | }
      | ^
Language: C++

    #include<iostream>
    using namespace std;
    int main(){
      int H,W,N,Sr,Sc;
      string S,T;
      cin>>H>>W>>N;
      cin>>Sr>>Sc;
      cin>>S;
      cin>>T;
      int countL=0;
      int countR=0;
      int countU=0;
      int countD=0;
      for(int i =0;i<N;i++){
        switch(S[i]){
          case 'L':
            countL++;
            break;
          case 'R':
              countR++;
            break;
           case'U':
            countU++;
            break;
           case'D':
            countD++;
            break;
        }
      if((countL<=Sc)^(countR<=(W-Sc))^(countU<=Sr)^(countD<=(W-Sr))) cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
      return 0;
      }

Compiler output:
a.cc: In function 'int main()':
a.cc:32:8: error: expected '}' at end of input
   32 |       }
      |        ^
a.cc:3:15: note: to match this '{'
    3 |     int main(){
      |               ^
Language: C++

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

int main(){
  int H, W, N;
  int sr, sc;
  string S, T;
  cin >> H >> W >> N;
  cin >> sr >> sc;
  cin >> S >> T;
  
  for(int i = 0; i < N ; i++){
    if(S[i]=='L'){
      if(W%2 = 0){
        if(sc > W/2){
          sc -= 1;
        }
      }
      else{
        if(sc >= W/2 + 2){
          sc -= 1;
        }
      }
    }
    if(S[i]=='R'){
      if(W%2 = 0){
        if(sc <= W/2){
          sc += 1;
        }
      }
      else{
        if(sc < W/2 + 1){
          sc += 1;
        }
      }
    }
    if(S[i]=='U'){
      if(H%2 = 0){
        if(sr > H/2){
          sr -= 1;
        }
      }
      else{
        if(sr >= H/2 + 2){
          sr -= 1;
        }
      }
    }
    if(S[i]=='D'){
      if(H%2 = 0){
        if(sr <= H/2){
          sr += 1;
        }
      }
      else{
        if(sr < H/2 + 1){
          sr += 1;
        }
      }
    }
    if(sr == 0||sr == H + 1||sc == 0||sc == W + 1){
      cout << "NO" << endl;
      break;
    }
    
    if(T[i]=='L'){
      if(W%2 = 0){
        if(sc <= W/2){
          sc -= 1;
        }
      }
      else{
        if(sc <= W/2){
          sc -= 1;
        }
      }
    }
    if(T[i]=='R'){
      if(W%2 = 0){
        if(sc > W/2){
          sc += 1;
        }
      }
      else{
        if(sc >= W/2 + 1){
          sc += 1;
        }
      }
    }
    if(T[i]=='U'){
      if(H%2 = 0){
        if(sr <= H/2){
          sr -= 1;
        }
      }
      else{
        if(sr <= H/2 + 1){
          sr -= 1;
        }
      }
    }
    if(T[i]=='D'){
      if(H%2 = 0){
        if(sr > H/2){
          sr += 1;
        }
      }
      else{
        if(sr >= H/2 + 1){
          sr += 1;
        }
      }
    }
    if(sr == 0||sr == H + 1||sc == 0||sc == W + 1){
      cout << "NO" << endl;
      break;
    }
    if(i == N - 1){
      cout << "YES" << endl;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:11: error: lvalue required as left operand of assignment
   14 |       if(W%2 = 0){
      |          ~^~
a.cc:26:11: error: lvalue required as left operand of assignment
   26 |       if(W%2 = 0){
      |          ~^~
a.cc:38:11: error: lvalue required as left operand of assignment
   38 |       if(H%2 = 0){
      |          ~^~
a.cc:50:11: error: lvalue required as left operand of assignment
   50 |       if(H%2 = 0){
      |          ~^~
a.cc:67:11: error: lvalue required as left operand of assignment
   67 |       if(W%2 = 0){
      |          ~^~
a.cc:79:11: error: lvalue required as left operand of assignment
   79 |       if(W%2 = 0){
      |          ~^~
a.cc:91:11: error: lvalue required as left operand of assignment
   91 |       if(H%2 = 0){
      |          ~^~
a.cc:103:11: error: lvalue required as left operand of assignment
  103 |       if(H%2 = 0){
      |          ~^~
Language: C++

#include<iostream>
using namespace std;
int main(){
  int H,W,N,Sr,Sc,S,T;
  cin>>H>>W>>N;
  cin>>Sr>>Sc;
  cin>>S;
  cin>>T;
  int countL=countR=countU=coutD=0;
  for(int i =0,i<N,i++){
    switch(S[i]){
      case 'L':
        countL++;
        break;
      case 'R':
          countR++;
        break;
       case'U':
        countU++;
        break;
       case'D':
        countD++;
        break;
    }
  if((countL<=Sc)^(countR<=(W-Sc))^(countU<=Sr)^(countD<=(W-Sr))) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: 'countR' was not declared in this scope; did you mean 'countL'?
    9 |   int countL=countR=countU=coutD=0;
      |              ^~~~~~
      |              countL
a.cc:9:21: error: 'countU' was not declared in this scope; did you mean 'countL'?
    9 |   int countL=countR=countU=coutD=0;
      |                     ^~~~~~
      |                     countL
a.cc:9:28: error: 'coutD' was not declared in this scope; did you mean 'countL'?
    9 |   int countL=countR=countU=coutD=0;
      |                            ^~~~~
      |                            countL
a.cc:10:17: error: expected ';' before '<' token
   10 |   for(int i =0,i<N,i++){
      |                 ^
      |                 ;
a.cc:10:17: error: expected primary-expression before '<' token
a.cc:10:23: error: expected ';' before ')' token
   10 |   for(int i =0,i<N,i++){
      |                       ^
      |                       ;
a.cc:11:13: error: invalid types 'int[int]' for array subscript
   11 |     switch(S[i]){
      |             ^
a.cc:22:9: error: 'countD' was not declared in this scope; did you mean 'countL'?
   22 |         countD++;
      |         ^~~~~~
      |         countL
a.cc:25:50: error: 'countD' was not declared in this scope; did you mean 'countL'?
   25 |   if((countL<=Sc)^(countR<=(W-Sc))^(countU<=Sr)^(countD<=(W-Sr))) cout<<"YES"<<endl;
      |                                                  ^~~~~~
      |                                                  countL
a.cc:28:4: error: expected '}' at end of input
   28 |   }
      |    ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

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

int main() {
  int h, w, n, sr, sc;
  cin >> h >> w >> n >> sr >> sc;
  int rlim = w - sc + 1, llim = sc, ulim = sr, dlim = h - sr + 1;
  int rout = 0, lout = 0, uout = 0, dout = 0, i, ans = 0;
  
  string s, t;
  cin >> s >> t;
  
  for(i = 0; i < n; i++){
    if(s.at(i) == 'L'){
      lout++;
    }
    else if(s.at(i) == 'R'){
      rout++;
    }
    else if(s.at(i) == 'U'){
      uout++;
    }
    else{
      dout++;
    }
    
    if(lout >= llim || rout >= rlim || uout >= ulim || dout >= dlim ||){
      ans++;
      break;
    }
    
    if(t.at(i) == 'L'){
      rout--;
    }
    else if(t.at(i) == 'R'){
      lout--;
    }
    else if(t.at(i) == 'U'){
      dout--;
    }
    else{
      uout--;
    }
  }
  
  if(ans > 0){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:71: error: expected primary-expression before ')' token
   27 |     if(lout >= llim || rout >= rlim || uout >= ulim || dout >= dlim ||){
      |                                                                       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int H,W,N;
  cin>>H>>W>>N;
  int Sr,Sc;
  cin>>Sr>>Sc;
  string S,T;
  cin>>S>>T;
  int X[4]={};
  int f=1;
  rep(i,N){
    if(S[i]=='U') X[0]++;
    else if(S[i]=='D') X[1]++;
    else if(S[i]=='L') X[2]++;
    else if(S[i]=='R') X[3]++;
    if(X[0]=Sr||X[1]=H-Sr+1||X[2]=Sc||X[3]=W-Sc+1){
      cout<<"NO"<<endl;
      f=0;
      break;
    }
    if(T[i]=='U') X[1]--;
    else if(T[i]=='D') X[0]--;
    else if(T[i]=='L') X[3]--;
    else if(T[i]=='R') X[2]--;
  }
  if(f) cout<<"YES"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:37: error: lvalue required as left operand of assignment
   20 |     if(X[0]=Sr||X[1]=H-Sr+1||X[2]=Sc||X[3]=W-Sc+1){
      |                                   ~~^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int maxn=2E5+5;
int n,size,head[maxn]; 
struct edge
{
	int to,next;
}E[maxn*2];
inline void add(int u,int v)
{
	E[++size].to=v;
	E[size].next=head[u];
	head[u]=size;
}
int pos,ans;
void dfs(int u,int F,int d)
{
	if(d>ans)
		ans=d,pos=u;
	for(int i=head[u];i;i=E[i].next)
	{
		int v=E[i].to;
		if(v==F)
			continue;
		dfs(v,u,d+1);
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=2;i<=n;++i)
	{
		int x,y;
		cin>>x>>y;
		add(x,y);
		add(y,x);
	}
	dfs(1,1,1);
	dfs(pos,pos,1);
	if((ans+1)%3==0)
		cout<<"Second"<<endl;
	else
		cout<<"First"<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'void add(int, int)':
a.cc:11:13: error: reference to 'size' is ambiguous
   11 |         E[++size].to=v;
      |             ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:4:7: note:                 'int size'
    4 | int n,size,head[maxn];
      |       ^~~~
a.cc:12:11: error: reference to 'size' is ambiguous
   12 |         E[size].next=head[u];
      |           ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:4:7: note:                 'int size'
    4 | int n,size,head[maxn];
      |       ^~~~
a.cc:13:17: error: reference to 'size' is ambiguous
   13 |         head[u]=size;
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:4:7: note:                 'int size'
    4 | int n,size,head[maxn];
      |       ^~~~
Language: C++

#include <queue>
#include <vector>
#include <iostream>
using namespace std;
vector<int> shortest_path(int N, int src, vector<vector<int> >& G) {
	vector<int> dist(N, -1);
	dist[src] = 0;
	queue<int> que;
	que.push(src);
	while (!que.empty()) {
		int u = que.front(); que.pop();
		for (int i : G[u]) {
			if (dist[i] == -1) {
				dist[i] = dist[u] + 1;
				que.push(i);
			}
		}
	}
	return dist;
}
int main() {
	int N;
	cin >> N;
	vector<vector<int> > G(N);
	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);
	}
	vector<int> d1 = shortest_path(N, 0, G);
	vector<int> d2 = shortest_path(N, max_element(d1.begin(), d1.end()) - d1.begin(), G);
	cout << (*max_element(d2.begin(), d2.end()) % 3 == 1 ? "Second" : "First") << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:43: error: 'max_element' was not declared in this scope
   32 |         vector<int> d2 = shortest_path(N, max_element(d1.begin(), d1.end()) - d1.begin(), G);
      |                                           ^~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int N;
int tp;
bool used[200010];
vector<int> G[200010];

dfs(int n, int len, vector<int>& res){
    bool flag = false;

    for(auto& u : G[n]){
        if(!used[u]){
            flag = true;
            used[u] = true;
            dfs(u, len + 1, res);
        }
    }
    if(!flag) res.push_back(len);
}

int main(){
    cin >> N;
    for(int i = 1; i < N; i++){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
        if(G[a].size() > 1) tp = a;
        if(G[b].size() > 1) tp = b;
    }

    vector<int> res;
    dfs(tp, 0, res);
    sort(res.rbegin(), res.rend());
    int len = res[0] + res[1];
    cout << (len % 3 == 0 ? "Second" : "First")  << endl;
    return 0;
}

Compiler output:
a.cc:9:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
    9 | dfs(int n, int len, vector<int>& res){
      | ^~~
a.cc: In function 'int dfs(int, int, std::vector<int>&)':
a.cc:20:1: warning: no return statement in function returning non-void [-Wreturn-type]
   20 | }
      | ^
Language: C++

#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 30
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge
{
    ll to, cost, val;
};
template <class T, class U>
bool chmin(T &a, const U &b)
{
    if (a <= b)
        return false;
    a = b;
    return true;
}
template <class T, class U>
bool chmax(T &a, const U &b)
{
    if (a >= b)
        return false;
    a = b;
    return true;
}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

int d[210000];

signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin>>N;
    vector<int> V[210000];
    for(int i=0;i<N-1;i++){
        int a,b;
        cin>>a>>b;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    d[1]=0;
    queue<int> que;
    que.push(1);
    int t;
    while(!que.empty()){
        int now=que.front(); que.pop();
        for(int next:V[now]){
            if(d[next]==0){
                d[next]=d[now]+1;
                t=next;
                que.push(next);
            }
        }
    }
    for(int i=0;i<210000;i++) d[o]=0;
    que.push(t);
    int ans;
    while(!que.empty()){
        int now=que.front(); que.pop();
        for(int next:V[now]){
            if(d[next]==0){
                d[next]=d[now]+1;
                t=next;
                ans=d[next];
                que.push(next);
            }
        }
    }
    if(ans%3==2) cout<<"Second"<<endl;
    else cout<<"First"<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:79:33: error: 'o' was not declared in this scope
   79 |     for(int i=0;i<210000;i++) d[o]=0;
      |                                 ^
Language: C++

#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  cnt[n+1]={};
  for(int i=0;i<n;i++){
    int x,y;
    cin >> x >> y;
    cnt[x]++;
    cnt[y]++;
  }
  int leaf = 0;
  for(int i=1;i<=n;i++)if(cnt[i]==1)leaf++;
  if((n-leaf)%3==0){
    cout << "Second" << endl;
  }else {
    cout << "First" << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'cnt' was not declared in this scope; did you mean 'int'?
    8 |   cnt[n+1]={};
      |   ^~~
      |   int
Language: C++

#include <cstdio>
#include <algorithm>
using namespace std;
typedef pair<int, int> ii;
vector<int> adjlist[200000];
ii furthestnode(int v, int p) {
    ii ans = ii(v, 0);
    for (int i: adjlist[v]) {
        if (i == p) continue;
        ii k = furthestnode(i, v);
        if (k.second + 1 > ans.second) ans = ii(k.first, k.second + 1);
    }
    return ans;
}
int main() {
    int N, a, b;
    scanf("%d", &N);
    for (int i = 1; i < N; ++i) {
        scanf("%d %d", &a, &b);
        adjlist[a - 1].push_back(b - 1);
        adjlist[b - 1].push_back(a - 1);
    }
    int diam = furthestnode(furthestnode(0, -1).first, -1).second + 1;
    if (diam % 3 == 2) printf("Second");
    else printf("First");
    return 0;
}

Compiler output:
a.cc:5:1: error: 'vector' does not name a type
    5 | vector<int> adjlist[200000];
      | ^~~~~~
a.cc: In function 'ii furthestnode(int, int)':
a.cc:8:17: error: 'adjlist' was not declared in this scope
    8 |     for (int i: adjlist[v]) {
      |                 ^~~~~~~
a.cc: In function 'int main()':
a.cc:20:9: error: 'adjlist' was not declared in this scope
   20 |         adjlist[a - 1].push_back(b - 1);
      |         ^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}

vvi g;
vi depth;
dfs(int i,int p){
    for(int x:g[i]){
        if(x==p)continue;
        depth[x]=depth[i]+1;
        dfs(x,i);
    }
}
int main(){
    ll n;cin>>n;
    g=vvi(n);
    depth=vi(n);
    rep(i,n-1){
        ll a,b;cin>>a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    depth[0]=0;
    dfs(0,-1);
    ll k,d=0;
    rep(i,n)if(chmax(d,depth(i)))k=i;
    depth[k]=0;
    dfs(k,-1);
    rep(i,n)chmax(d,depth[i]);
    if((d+1)%3==2)cout<<"Second"<<endl;
    else cout<<"First"<<endl;
}

Compiler output:
a.cc:21:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   21 | bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
      |            ^~~~
a.cc:21:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   21 | bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
      |                    ^~~~
a.cc:22:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   22 | bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
      |            ^~~~
a.cc:22:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   22 | bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
      |                    ^~~~
a.cc:26:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
   26 | dfs(int i,int p){
      | ^~~
a.cc: In function 'int dfs(int, int)':
a.cc:32:1: warning: no return statement in function returning non-void [-Wreturn-type]
   32 | }
      | ^
a.cc: In function 'int main()':
a.cc:46:29: error: no match for call to '(vi {aka std::vector<long long int, std::allocator<long long int> >}) (long long int&)'
   46 |     rep(i,n)if(chmax(d,depth(i)))k=i;
      |                        ~~~~~^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
template<typename T1,typename T2> inline bool chmax(T1& a,T2 b)
{if (a < b) {a = b; return true;} return false;}
template<typename T1,typename T2> inline bool chmin(T1& a,T2 b)
{if (a > b) {a = b; return true;} return false;}

int N;
Graph G;

int Tree_Diameter(const Graph &G){
    int MAX_D = -1, node = 0;
    vector<bool> seen(G.size(), false);
    stack<pair<int, int>> sta; sta.emplace(0, 0);
    while(!sta.empty()){
        int dep, v; tie(v, dep) = sta.top(); sta.pop();
        seen[v] = true;
        if (chmax(MAX_D, dep)) node = v;
        for (auto e : G[v]) {
            if (seen[e]) continue;
            sta.emplace(e, dep + 1);
        }
    }
    MAX_D = -1; seen.assign(G.size(), false);
    sta.emplace(node, 0);
    while(!sta.empty()){
        int dep, v; tie(v, dep) = sta.top(); sta.pop();
        seen[v] = true; chmax(MAX_D, dep);
        for (auto e : G[v]) {
            if (seen[e]) continue;
            sta.emplace(e, dep + 1);
        }
    }
    
    return MAX_D;
}

int main(){
    int N; cin >> N;
    Graph G(N, vector<int>());
    for (int i = 1; i < N; i++) {
        int a, b; cin >> a >> b; a--; b--;
        G[a].emplace_back(b); G[b].emplace_back(a);
    }
  int R = Tree_Diameter;
  if (R % 3 == 1) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:11: error: invalid conversion from 'int (*)(const Graph&)' {aka 'int (*)(const std::vector<std::vector<int> >&)'} to 'int' [-fpermissive]
   46 |   int R = Tree_Diameter;
      |           ^~~~~~~~~~~~~
      |           |
      |           int (*)(const Graph&) {aka int (*)(const std::vector<std::vector<int> >&)}
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
vector<int>v[210];
char c[210][210];
bool dfs(int x,int c){
	color[x]=c;
	for(int g:v[x]){
		if(color[g]==c)return false;
		if(color[c]==0&&!dfs(g,-c))return false;
	}
	return true;
}
bool solve(){
	rep(i,n){
		if(color[i]==-1){
			if(dfs(i,1)==false)return false;
	}
	return true;
}	
int main(){
	cin>>n;
	rep(i,n){
		rep(j,n){
			cin>>c[i][j];
			if(c[i][j]=='1')v[i].pb(j);
		}
	}
	if(!solve()){
		puts("-1");
		return 0;
	}
}


Compiler output:
a.cc: In function 'bool dfs(int, int)':
a.cc:8:9: error: 'color' was not declared in this scope
    8 |         color[x]=c;
      |         ^~~~~
a.cc: In function 'bool solve()':
a.cc:17:20: error: 'color' was not declared in this scope
   17 |                 if(color[i]==-1){
      |                    ^~~~~
a.cc:22:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   22 | int main(){
      |         ^~
a.cc:22:9: note: remove parentheses to default-initialize a variable
   22 | int main(){
      |         ^~
      |         --
a.cc:22:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:22:11: error: a function-definition is not allowed here before '{' token
   22 | int main(){
      |           ^
a.cc:34:2: error: expected '}' at end of input
   34 | }
      |  ^
a.cc:15:13: note: to match this '{'
   15 | bool solve(){
      |             ^
a.cc:34:2: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      |  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int d[N];
int n;
int main()
{
	cin >> n ;
	cout << (n%2)?"First":"Second" << endl;
}

Compiler output:
a.cc:3:7: error: 'N' was not declared in this scope
    3 | int d[N];
      |       ^
a.cc: In function 'int main()':
a.cc:8:40: error: invalid operands of types 'const char [7]' and '<unresolved overloaded function type>' to binary 'operator<<'
    8 |         cout << (n%2)?"First":"Second" << endl;
      |                               ~~~~~~~~~^~~~~~~
Language: C++

import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

edges = []

from collections import deque
def diam_bfs(i):
  que = deque([i])
  dist = {i: 0}
  prev = {i: -1}
  while que:
    u = que.popleft()
    d = dist[u]
    for w in edges[u]:
      if w in dist:
        continue
      dist[w] = d + 1
      prev[w] = u
      que.append(w)
  w = u
  D = []
  while w != -1:
    D.append(w)
    w = prev[w]
  return u, D


def main():
  global edges
  n = int(input())
  edges = [[] for _ in range(n)]
  for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
  _, path = diam_bfs(diam_bfs(0)[0])
  if len(path) % 3 == 2:
    print('Second')
  else:
    print('First')


if __name__ == '__main__':
  main()


Compiler output:
a.cc:39:11: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   39 |     print('Second')
      |           ^~~~~~~~
a.cc:41:11: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
   41 |     print('First')
      |           ^~~~~~~
a.cc:44:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   44 | 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'
a.cc:11:3: error: 'prev' does not name a type
   11 |   prev = {i: -1}
      |   ^~~~
a.cc:12:3: error: expected unqualified-id before 'while'
   12 |   while que:
      |   ^~~~~
Language: C++

////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 2e5;
int dist[N + 5];

vector<int> lst[N + 5];
queue<int> q;

int diameter(int n) {
	memset(dist, -1, sizeof dist);
	int pos;
	q.push(1);
	dist[1] = 0;
	while(!q.empty()) {
		pos = q.front();
		q.pop();
		for(auto x: lst[pos]) {
			if(dist[x] == 0) continue;
			dist[x] = 0;
			q.push(x);
		}
	}
	q.push(pos);
	dist[pos] = 1;
	while(!q.empty()) {
		pos = q.front();
		q.pop();
		for(auto x: lst[pos]) {
			if(dist[x] != 0) continue;
			dist[x] = dist[pos] + 1;
			q.push(x);
		}
	}
	return dist[pos] % 3;
}

void hora(int tc) {
	int n;
	cin>>n;
	for(int i = 1;i < n;i++) {
		int u, v;
		cin>>u>>v;
		lst[u].PB(v);
		lst[v].PB(u);
	}
	int l = diameter(n);
	if(!zl) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Compiler output:
a.cc: In function 'void hora(int)':
a.cc:103:13: error: 'zl' was not declared in this scope; did you mean 'l'?
  103 |         if(!zl) cout<<"First"<<endl;
      |             ^~
      |             l
Language: C++

#include <iostream>
#include <vector>
#include <limits>

using namespace std;

using Graph = vector<vector<int>>;

constexpr int INF = numeric_limits<int>::max() / 3;

void dfs(Graph const& tree, vector<int>& dists, int pos) {
  for (auto v : tree[pos]) {
    if (dists[v] < INF) continue;
    dists[v] = dists[pos] + 1;
    dfs(tree, dists, v);
  }
}

int diameter(Graph const& tree) {
  int V = tree.size();
  vector<int> dists(V, INF);
  dists[0] = 0;
  dfs(tree, dists, 0);
  auto farthest = max_element(begin(dists), end(dists));
  int v = farthest - begin(dists);
  vector<int> dists2(V, INF);
  dists2[v] = 0;
  dfs(tree, dists2, v);
  return *max_element(begin(dists2), end(dists2));
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  Graph tree(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  int d = diameter(tree);
  cout << (d % 3 == 1 ? "Second" : "First") << endl;
}


Compiler output:
a.cc: In function 'int diameter(const Graph&)':
a.cc:24:19: error: 'max_element' was not declared in this scope
   24 |   auto farthest = max_element(begin(dists), end(dists));
      |                   ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int gh[210000][210000];
int distx[210000],disty[210000];
bool vis[210000];
//int f[1100][1100];
int n,m,s,t;
queue <int> q;
void SPFA1(){
	memset(vis,0,sizeof vis);
	for (int i=1;i<=n;i++) distx[i]=1e5;
	distx[s]=0;
	vis[s]=1;
	while (!q.empty()) q.pop();
	q.push(s);
	while (!q.empty()){
		int x=q.front();
		q.pop();
		for (int i=1;i<=n;i++){
			if (gh[x][i]<1e5){
				if (distx[x]+gh[x][i]<distx[i]){
					distx[i]=distx[x]+gh[x][i];
					if (!vis[i]) {
						vis[i]=1;
						q.push(i);
					}
				}
			}
		}
		vis[x]=0;
	}
}
void SPFA2(){
	memset(vis,0,sizeof vis);
	for (int i=1;i<=n;i++) disty[i]=1e5;
	disty[t]=0;
	vis[t]=1;
	while (!q.empty()) q.pop();
	q.push(t);
	while (!q.empty()){
		int x=q.front();
		q.pop();
		for (int i=1;i<=n;i++){
			if (gh[x][i]<1e5){
				if (disty[x]+gh[x][i]<disty[i]){
					disty[i]=disty[x]+gh[x][i];
					if (!vis[i]) {
						vis[i]=1;
						q.push(i);
					}
				}
			}
		}
		vis[x]=0;
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	s=1;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++)
			gh[i][j]=1e5;
	}
		
	for (int i=1;i<=n-1;i++){
		int a,b;
		cin>>a>>b;
			gh[a][b]=1;
			gh[b][a]=1;
	}
	//cout<<gh[0][0]<<endl;
	for (int i=1;i<=n;i++) gh[i][i]=0;
	SPFA1();
	int xx=0;
	for (int i=1;i<=n;i++) if (distx[i]>xx){
		xx=distx[i];
		t=i;
	}
	SPFA2();
	xx=0;
	for (int i=1;i<=n;i++) if (disty[i]>xx){
		xx=disty[i];
	}
	
	if (xx%3==2) cout<<"First"<<endl;else cout<<"Second"<<endl;
	return 0;
}

Compiler output:
/tmp/ccHeYNq2.o: in function `SPFA1()':
a.cc:(.text+0x15): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccHeYNq2.o
a.cc:(.text+0x3a): relocation truncated to fit: R_X86_64_PC32 against symbol `distx' defined in .bss section in /tmp/ccHeYNq2.o
a.cc:(.text+0x4b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccHeYNq2.o
a.cc:(.text+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccHeYNq2.o
a.cc:(.text+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `distx' defined in .bss section in /tmp/ccHeYNq2.o
a.cc:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccHeYNq2.o
a.cc:(.text+0x7d): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccHeYNq2.o
a.cc:(.text+0x8a): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/ccHeYNq2.o
a.cc:(.text+0x99): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/ccHeYNq2.o
a.cc:(.text+0xaf): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccHeYNq2.o
a.cc:(.text+0xb9): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
const int maxn=2*1e5+100;
using namespace std;
int n,m,s,t;
int G[maxn][maxn],q[maxn];
int d[2][maxn],ans;

inline int read(){
	char ch;
	int f=1,res=0;
	while((ch=getchar())<'0'||ch>'9')
		if(ch=='-') f=-1;
	while(ch>='0'&&ch<='9')
	{
		res=(res<<1)+(res<<3)+(ch^48);//注意位运算的优先级别
		ch=getchar();
	}
	return f*res;
}

void bfs(int s,int t,int p){
	//memset(d,0x3f,sizeof(d));
	 for (int i=1;i<=n;i++) d[p][i] = INF;
	int f=0,r=1;q[1]=s;d[p][s] = 0;
	
	while (f<r){
		int u=q[++f];
		for (int v=1;v<=n;v++){
			if (G[u][v]){
				if (d[p][u] + 1 <d[p][v]){
					d[p][v] = d[p][u]+1;
					q[++r]=v;
				}
			}
		}
	}
}
int main(){
	ans=0;
	memset(G,0,sizeof(G));
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >>n;
	m=n-1;
	//cin >>n >> m >>s >>t;
	//n=read();m=read();s=read();t=read();
	while (m--){
		int u,v;
		cin >> u >> v;
		G[u][v] = G[v][u] =1;
	}
	bfs(1,n,0);
	int x,maxx=-1;
	for (int i=1;i<=n;i++) if (d[0][i]>maxx)maxx=d[0][i],x=i;
	bfs(x,1,1);

	x=0,maxx=-1;
	for (int i=1;i<=n;i++) if (d[1][i]>maxx)maxx=d[1][i],x=i;
	// cout << maxx;
	maxx++;	
	cout << (maxx%3 == 2?"Second":"First");
	//for (int i=1;i<=n;i++)cout <<d[0][i]<<"&"<<d[1][i] << endl;
	// for (int i=1;i<=n;i++)
	// 	for (int j=1;j<=n;j++)
	// 		if ( !G[i][j] && i!=j) {
	// 			if (d[0][i]+d[1][j]+1 >=d[0][t] && d[0][j] + d[1][i]+1 >=d[0][t]) ans++;//,cout << "%%"<<i <<' '<< j <<endl;
	// 		}
	// cout << ans/2;
	return 0;
}

Compiler output:
/tmp/ccJoiF9U.o: in function `bfs(int, int, int)':
a.cc:(.text+0x36): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccJoiF9U.o
a.cc:(.text+0x63): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/ccJoiF9U.o
a.cc:(.text+0x87): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccJoiF9U.o
a.cc:(.text+0xab): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/ccJoiF9U.o
a.cc:(.text+0x110): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccJoiF9U.o
a.cc:(.text+0x13a): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccJoiF9U.o
a.cc:(.text+0x165): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccJoiF9U.o
a.cc:(.text+0x18f): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccJoiF9U.o
a.cc:(.text+0x1ae): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/ccJoiF9U.o
/tmp/ccJoiF9U.o: in function `main':
a.cc:(.text+0x1e2): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccJoiF9U.o
a.cc:(.text+0x346): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

const int maxn = 2e5+100;

vector<int> f[maxn];
int id1,dth,id2;
void dfs(int u,int fa,int deep)
{
	if(deep>dth) {
		dth = deep; id1=u;
	}
	for(int i=0;i<f[u].size();i++)
	{
		int v=f[u][i];
		if(v==fa) continue;
		dfs(v,u,deep+1);
	}
}
int n,x,y;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<n;i++)
	{
		cin>>x>>y;
		f[x].push_back(y);
		f[y].push_back(x);
	}
	dfs(1,-1,1);dth=0;
	dfs(id1,-1,1);
	if(dth%3!=0) cout<<"Second"<<endl;
	else cout<<"First"<<endl;
	return 0;
}

Compiler output:
a.cc:9:1: error: 'vector' does not name a type
    9 | vector<int> f[maxn];
      | ^~~~~~
a.cc: In function 'void dfs(int, int, int)':
a.cc:16:23: error: 'f' was not declared in this scope
   16 |         for(int i=0;i<f[u].size();i++)
      |                       ^
a.cc: In function 'int main()':
a.cc:31:17: error: 'f' was not declared in this scope
   31 |                 f[x].push_back(y);
      |                 ^
Language: C++

#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;
ll bit[100010], num;
ll par[100010], sz[100010];
ll n, a, b, ans, dp[100010], leaf[100010], res[2], d[400010];
vector<ll> road[100010];
bool flg[100010];

struct edge { ll to, cost; };
ll V;
vector<edge> G[300010];
ll d[300010];

ll root(int x) { // �f�[�^x��������؂̍����ċA�œ���Froot(x) = {x�̖؂̍�}
	if (par[x] == x) return x;
	return par[x] = root(par[x]);
}

void unite(int x, int y) { // x��y�̖؂𕹍�
	int rx = root(x); //x�̍���rx
	int ry = root(y); //y�̍���ry
	if (rx == ry) return; //x��y�̍�������(=�����؂ɂ���)���͂��̂܂�
	par[rx] = ry; //x��y�̍��������łȂ�(=�����؂ɂȂ�)���Fx�̍�rx��y�̍�ry�ɂ���
}

bool same(int x, int y) { // 2�̃f�[�^x, y��������؂������Ȃ�true��Ԃ�
	int rx = root(x);
	int ry = root(y);
	return rx == ry;
}

void dijkstra(ll s)
{
	priority_queue<P, vector<P>, greater<P>> que;
	for (int i = 0; i <= 300010; i++)
	{
		d[i] = INF;
	}
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty())
	{
		P p = que.top(); que.pop();
		ll v = p.second;
		if (d[v] < p.first) continue;
		for (ll i = 0; i < G[v].size(); i++)
		{
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= num)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll po(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return po(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = po(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll pow_mod(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y % 2 == 1)
		{
			(res *= x) %= mod;
		}
		(x *= x) %= mod;
		y /= 2;
	}
	return res;
}

ll div(ll x)
{
	return po(x, mod - 2);
}


ll dfs(ll x)
{
	flg[x] = true;

	vector<ll> vec;
	vec.push_back(0);
	for (int i = 0; i < road[x].size(); i++)
	{
		if (flg[road[x][i]]) continue;
		vec.push_back(dfs(road[x][i]));
	}

	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());

	if (vec.size() != 1)
	{
		ans = max(ans, vec[0] + vec[1] + 1);
	}
	
	return vec[0] + 1;
}

int main(void)
{
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		cin >> a >> b;
		road[a].push_back(b);
		road[b].push_back(a);
	}

	if (n == 1)
	{
		cout << "First" << endl;
		return 0;
	}
	if (n == 2)
	{
		cout << "Second" << endl;
		return 0;
	}

	dfs(1);

	if (ans % 3 == 2)
	{
		cout << "Second" << endl;
	}
	else
	{
		cout << "First" << endl;
	}
	
	int www;
	cin >> www;
}


Compiler output:
a.cc:25:4: error: conflicting declaration 'll d [300010]'
   25 | ll d[300010];
      |    ^
a.cc:18:52: note: previous declaration as 'll d [400010]'
   18 | ll n, a, b, ans, dp[100010], leaf[100010], res[2], d[400010];
      |                                                    ^
Language: C++

// Hacheylight
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
template <class T> void print(T a) { cout << a << endl ; exit(0) ; }
template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }
template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }
template <class T> void add(T &a, T b) { a = (1ll * a + b) % MOD ; }
template <class T> void mul(T &a, T b) { a = (ll) a * b % MOD ; }
template <class T> T read() {
    int f = 1 ; T x = 0 ;
    char ch = getchar() ;
    while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
    while (isdigit(ch)) { x = x * 10 + ch -'0' ; ch = getchar() ; }
    return x * f ;
}

 // pair <从端点开始的顶点的个数, 端点>


vi g[N] ;
int n ;


pii dfs(int x, int fat) {
	pii ans = mp(0, x) ;
	for (int to : g[x]) {
		if (to == fat) continue ;
		chmax(ans, dfs(to, x)) ;
	}
	ans.fi++ ;
	return ans ;
}

signed main() {
	scanf("%d", &n) ;
	rep(i, 1, n - 1) {
		int a, b ; scanf("%d%d", &a, &b) ;
		g[a].pb(b) ; g[b].pb(a) ;
	}
	int dia = dfs(dfs(1, -1).se, -1).fi ;
	puts((val % 3 != 2) ? "First" : "Second") ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/





Compiler output:
a.cc: In function 'int main()':
a.cc:102:15: error: 'val' was not declared in this scope
  102 |         puts((val % 3 != 2) ? "First" : "Second") ;
      |               ^~~
Language: C++

#include <queue>
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 210000;

struct edge{
	int v,next;
};

edge g[maxn << 1];
int head[maxn], dist[maxn];
queue<int> q;

void insert(int u,int v){
	static int id;
	g[++id].v = v;
	g[id].next = head[u];
	head[u] = id;
}

void bfs(int source){
	memset(dist, 0, sizeof dist);
	dist[source] = 1;
	while (!q.empty()) q.pop();
	q.push(source);
	while (!q.empty()){
		int u = q.front();
		q.pop();
		for (int i = head[u];i;i = g[i].next){
			int v = g[i].v;
			if (dist[v] == 0){
				dist[v] = dist[u] + 1;
				q.push(v);
			}
		}
	}
}

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1;i < n;i++){
		int x, y;
		scanf("%d%d",&x ,&y);
		insert(x, y);
		insert(y, x);
	}
	bfs(1);
	int maxid = 0;
	for (int i = 1;i <= n;i++){
		if (dist[i] > dist[maxid]) maxid = i;
	}
	bfs(maxid);
	int diameter = 0;
	for (int i = 1;i <= n;i++) diameter = max(diameter, dist[i]);
	if (diameter % 3 == 2) printf("Second\n");
	else printf("First\n");
    return 0;
}

Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:26:9: error: 'memset' was not declared in this scope
   26 |         memset(dist, 0, sizeof dist);
      |         ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <algorithm>
  +++ |+#include <cstring>
    5 |