criyle/codenet-compile-errors huggingface dataset:
Language: C++

        puts("-1");
        return 0;
    }
    int ans=0;
    for(int i=1;i<n;i++)
        if(a[i]!=a[i-1]+1) ans+=a[i-1];
    ans+=a[n-1];
    printf("%d\n",ans);
    return 0;
}



Compiler output:
a.cc:1:13: error: expected constructor, destructor, or type conversion before '(' token
    1 |         puts("-1");
      |             ^
a.cc:2:9: error: expected unqualified-id before 'return'
    2 |         return 0;
      |         ^~~~~~
a.cc:3:5: error: expected declaration before '}' token
    3 |     }
      |     ^
a.cc:5:5: error: expected unqualified-id before 'for'
    5 |     for(int i=1;i<n;i++)
      |     ^~~
a.cc:5:17: error: 'i' does not name a type
    5 |     for(int i=1;i<n;i++)
      |                 ^
a.cc:5:21: error: 'i' does not name a type
    5 |     for(int i=1;i<n;i++)
      |                     ^
a.cc:7:5: error: 'ans' does not name a type
    7 |     ans+=a[n-1];
      |     ^~~
a.cc:8:11: error: expected constructor, destructor, or type conversion before '(' token
    8 |     printf("%d\n",ans);
      |           ^
a.cc:9:5: error: expected unqualified-id before 'return'
    9 |     return 0;
      |     ^~~~~~
a.cc:10:1: error: expected declaration before '}' token
   10 | }
      | ^
Language: Java

package jp.llv.atcoder;

import java.util.Scanner;
import java.io.PrintWriter;

public class Task {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int length = in.nextInt();
        if (in.nextInt() > 0) {
            System.out.println(-1);
            return;
        }
        long ans = 0;
        int prev = 0;
        for (int i = 1; i < length; i++) {
            int n = in.nextInt();
            if (n == 0) {
            } else if (n - prev > 1) {
                System.out.println(-1);
                return;
            } else if (n - prev == 1) {
                ans++;
            } else if (n - prev <= 0) {
                ans += n;
            }
            prev = n;
        }
        System.out.println(ans);
    }
}


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

#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

vector<int> cliff_top;
vector<int> a;
int n;
long long int time = -1;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int aho;
		cin >> aho;
		a.push_back(aho);
	}
	bool tf = true;
	
	int current = 0;
	for (int i = 1; i < n; ++i) {
		if (a[0] != 0) {
			tf = false;
			break;
		}
		else if (a[i] == 0 && a[i - 1] == 0) {
			current = 0;
		}
		else if (a[i] == a[i - 1] + 1) {
			current = a[i];
			if (i == n - 1) {
				cliff_top.push_back(current);
			}
		}
		else if (a[i] <= a[i - 1]) {
			cliff_top.push_back(current);
			current = 0;
			if (a[i] > 0) {
				current = a[i];
			}
		}
		else if (a[i] > a[i - 1] + 1) {
			tf = false;
			break;
		}
	}
	if (tf == true) {
		time = 0;
		for (int i = 0; i < cliff_top.size(); ++i) {
			time += cliff_top[i];
		}
	}
	cout << time;
	
}

Compiler output:
a.cc:11:15: error: 'long long int time' redeclared as different kind of entity
   11 | long long int time = -1;
      |               ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int main()':
a.cc:50:22: error: assignment of function 'time_t time(time_t*)'
   50 |                 time = 0;
      |                 ~~~~~^~~
a.cc:52:30: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                         time += cliff_top[i];
a.cc:52:30: error: assignment of read-only location 'time'
Language: C++

#include<bits/stdc++.h>

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>num(n);
  bool flag=true;
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  if(num[0]!=0)flag=false;
  for(int i=1;i<n;i++){
    if(abs(num[i]-num[i-1])>1){flag=false;break;}
  }
  if(flag){
    ll ans=0;
    int cnt=0;
    for(int i=1;i<n;i++){
      if(num[i]==num[i-1]){ans+=num[i];
      else if(num[i]>num[i-1]){
	cnt++;
      }else{
	ans+=cnt+num[i];
	cnt=0;
      }
    }
    cout<<ans<<endl;
  }else{
    cout<<-1<<endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:7: error: expected '}' before 'else'
   28 |       else if(num[i]>num[i-1]){
      |       ^~~~
a.cc:27:27: note: to match this '{'
   27 |       if(num[i]==num[i-1]){ans+=num[i];
      |                           ^
Language: C++

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int Q[200010];

struct interval {
    int b;
    int e;
    int n;
};

interval make(int b, int e, int n) {
    interval x;
    x.b = b;
    x.e = e;
    x.n = n;
    return x;
}

vector<interval> I;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    for (int i = 0;i < N;i++) cin >> Q[i];
    I.push_back(make(0, N - 1, -1));
    ll tol = 0;
    for (int i = N - 1;i >= 0;i--) {
        if (Q[i] == 0) {
            if (I.size() == 0) continue;
            if (I[I.size() - 1].c != -1) {
                cout << -1 << endl;
                return 0;
            }   
            continue;
        }
        int c = i - Q[i];
        if (c < 0) {
            cout << -1 << endl;
            return 0;
        }
        interval crt = I[I.size() - 1];
        if (crt.n == c) {
            I.pop_back();
            crt.e--;
            if (crt.b <= crt.e) I.push_back(crt);
        }
        else {
            tol += Q[i];
            while (I[I.size() - 1].e < c) I.pop_back();
            interval crt = I[I.size() - 1];
            I.pop_back();
            crt.e = c - 1;
            if (crt.b <= crt.e) I.push_back(crt);
            interval nn = make(c, i - 1, c);
            if (nn.b <= nn.e) I.push_back(nn);
        }
    }
    cout << tol << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:33: error: '__gnu_cxx::__alloc_traits<std::allocator<interval>, interval>::value_type' {aka 'struct interval'} has no member named 'c'
   62 |             if (I[I.size() - 1].c != -1) {
      |                                 ^
Language: C++

#include <iostream> // includes cin to read from stdin and cout to write to stdout
#define REP(i, n) for (int (i)=0; i < (n); ++(i))
using namespace std; // since cin and cout are both in namespace std, this saves some text

long A[1000000000];
long N;

long solve()
{
    long cnt = 0;
    
    long prev = 0;
    long add = 1;
    for (long i = N - 1; i > 0; --i) {
        if (A[i] != 0) {
            if (A[i] > 1 && A[i - 1] == 0) return -1;
            cnt += add;
            if (prev != 1 && prev != 0 && prev <= A[i]) ++add;
        } else {
            add = 1;
        }
        prev = A[i];
    }
    
    return cnt;
}

int main()
{
    cin >> N;
    REP(i, N) cin >> A[i];
    
    if (A[0] != 0) cout << "-1" <<endl;
    else cout << solve() << endl;
    return 0;
}

Compiler output:
/tmp/ccIGhKNy.o: in function `solve()':
a.cc:(.text+0x1f): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccIGhKNy.o
/tmp/ccIGhKNy.o: in function `main':
a.cc:(.text+0x114): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccIGhKNy.o
a.cc:(.text+0x169): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccIGhKNy.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 1e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(n) cin >> a[i];
    
    if(a[0] != 0){
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    reppp(i, n-1){
        if(a[i]+1 < a[i+1]){
            cout << -1 << endl;
            return 0;
        }else if(a[i]+1 > a[i+1]){
            ans += a[i];
        }
    }
    ans += a[n-1];
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:33:17: error: macro "reppp" requires 3 arguments, but only 2 given
   33 |     reppp(i, n-1){
      |                 ^
a.cc:5:9: note: macro "reppp" defined here
    5 | #define reppp(i, m, n) for(int i=m;i<n;i++)
      |         ^~~~~
a.cc: In function 'int main()':
a.cc:33:5: error: 'reppp' was not declared in this scope
   33 |     reppp(i, n-1){
      |     ^~~~~
Language: C++

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


int a[200050];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",a+i);
    long long phi=0,ans=0;
    for(int i=n;i>=1;i--)
    {
        if(a[i]<phi)
        {
            ans=-1;
            break;
        }
        else
        {
            if(a[i]>=i)
            {
                ans=-1;
                break;
            }
            if(a[i]>phi)
            {
                ans+=a[i];
                phi=a[i];
            }
            phi=max(0,phi-1);
        }
    }
    printf("%lld\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:20: error: no matching function for call to 'max(int, long long int)'
   32 |             phi=max(0,phi-1);
      |                 ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:32:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   32 |             phi=max(0,phi-1);
      |                 ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:32:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |             phi=max(0,phi-1);
      |                 ~~~^~~~~~~~~
Language: C++

#include <stdio.h>
#include <stdlib.h>
int main() {
	int n;
	scanf("%d", &n);
	int *data = (int *)calloc(sizeof(int), n+1);
	int *data2 = (int *)calloc(sizeof(int), n+1);
	int z;
	int *pa;
	for (z = 0; z < n; z++) {
		scanf("%d", &data[z]);
		if ((z == 0 && data[0] > 0) || (z > 0 && data[z] > data[z - 1] + 1)) {
			printf("-1");
			return 0;
		}
	}
	int count = 0;
	while (memcmp(data, data2, sizeof(int)*(n + 1))) {		//メモリ不一致
		for (z = n - 1; z >= 1; z--) {
			if (data[z] == 0) {
				data2[z] = 0;
			}
			else {		//0でない
				if (data[z + 1] == 0) {
					data2[z] = 0;
				}
				else {
					data2[z] = data[z + 1] - 1;
				}

				if (data[z] != data2[z]) {
					count++;
				}
			}
		}
		pa = data;
		data = data2;
		data2 = pa;
	}
	printf("%d", count);
	free(data);
	free(data2);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:16: error: 'memcmp' was not declared in this scope
   18 |         while (memcmp(data, data2, sizeof(int)*(n + 1))) {              //メモリ不一致
      |                ^~~~~~
a.cc:3:1: note: 'memcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <stdlib.h>
  +++ |+#include <cstring>
    3 | int main() {
Language: C++

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#define N 200008
using namespace std;
int n,rr[N];
long long ans;
bool flag;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) 
	{
		scanf("%d",&a[i]);
		if(a[i]-a[i-1]>1) flag=1;
	}
	if(a[1]!=0) {
		flag=1;
	}
	if(flag)  
	{
		cout<<"-1";
		return 0;
	}
	for(int i=1;i<=n;++i)
	{
		int k=0;
		while(a[i+k]==a[i+k+1]-1&&i+k+1<=n)
		{
			rr[i+k+1]=k+1;
			++k;
		}
		i+=k;
	}
	for(int i=n;i>=1;--i)
	{
		ans+=a[i];
		i-=rr[i];
	}
	//for(int i=1;i<=n;++i) cout<<rr[i]<<" ";  
	printf("%lld",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:29: error: 'a' was not declared in this scope
   15 |                 scanf("%d",&a[i]);
      |                             ^
a.cc:18:12: error: 'a' was not declared in this scope
   18 |         if(a[1]!=0) {
      |            ^
a.cc:29:23: error: 'a' was not declared in this scope
   29 |                 while(a[i+k]==a[i+k+1]-1&&i+k+1<=n)
      |                       ^
a.cc:38:22: error: 'a' was not declared in this scope
   38 |                 ans+=a[i];
      |                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int po[N];
    for(int i = 0; i < N; i++) cin >> po[i];
    int ans = 0;
    if(po[0]){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 1; i < N; i++){
        if(po[i - 1] + 1 < po[i] || i < po[i]){
            cout << -1 << endl;
            return 0;
        }else if(po[i - 1] + 1 == po[i]){
            ans++;
        }else if(po[i] <= po[i - 1]{
            ans += po[i];
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:36: error: expected ')' before '{' token
   19 |         }else if(po[i] <= po[i - 1]{
      |                 ~                  ^
      |                                    )
a.cc:25:5: error: expected primary-expression before '}' token
   25 |     }
      |     ^
Language: C++

#include <iostream>
using namespace std;
int main(){
long int N;
long int A[200099];
cin>>N;
for (int i = 0; i < N; i++) cin>>A[i]
if (A[0]<=9&&A[0]>=1)
cout << -1 <<endl;
else if



Compiler output:
a.cc: In function 'int main()':
a.cc:7:38: error: expected ';' before 'if'
    7 | for (int i = 0; i < N; i++) cin>>A[i]
      |                                      ^
      |                                      ;
    8 | if (A[0]<=9&&A[0]>=1)
      | ~~                                    
a.cc:10:1: error: 'else' without a previous 'if'
   10 | else if
      | ^~~~
a.cc:10:8: error: expected '(' at end of input
   10 | else if
      |        ^
      |        (
a.cc:10:8: error: expected '}' at end of input
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include<cstdio>
#include<iostream>
using namespace std;
int main()
	{
		cin>>n;
		for(int i=1;i<=n;i++)
			{
				cin>>a[i];
			}
		if(a[1]!=0) 
			{
				cout<<"-1"<<endl;
				return 0;
			}
					
		for(int i=1;i<=n;i++)
			{
				ans+=a[i]; 
			}
	cout<<ans-1<<endl;
	}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:22: error: 'n' was not declared in this scope
    6 |                 cin>>n;
      |                      ^
a.cc:9:38: error: 'a' was not declared in this scope
    9 |                                 cin>>a[i];
      |                                      ^
a.cc:11:20: error: 'a' was not declared in this scope
   11 |                 if(a[1]!=0)
      |                    ^
a.cc:19:33: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |                                 ans+=a[i];
      |                                 ^~~
      |                                 abs
a.cc:19:38: error: 'a' was not declared in this scope
   19 |                                 ans+=a[i];
      |                                      ^
a.cc:21:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |         cout<<ans-1<<endl;
      |               ^~~
      |               abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,a[N],d[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>=i)
			res=-1;
	}
	if(res!=-1)
		res=n-1;
	cout<<res<<'\n';
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:25: error: 'res' was not declared in this scope
   15 |                         res=-1;
      |                         ^~~
a.cc:17:12: error: 'res' was not declared in this scope
   17 |         if(res!=-1)
      |            ^~~
a.cc:19:15: error: 'res' was not declared in this scope
   19 |         cout<<res<<'\n';
      |               ^~~
Language: C++

#include<Cstdio>
#define maxn 200005
#define LL long long
using namespace std;
LL N,Ans,A[maxn],F[maxn];
inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
int main(){
	N=read();
	for (int i=1;i<=N;++i) A[i]=read();
	if (A[1]) return puts("-1"),0;
	for (int i=1;i<N;++i) if (A[i+1]-A[i]>1){return puts("-1"),0;}
	for (int i=2;i<=N;++i) if (A[i]-A[i-1]==1) F[i]=F[i-1]+1,F[i-1]=0; else F[i]=A[i];
	for (int i=1;i<=N;++i) Ans+=F[i];
	printf("%lld\n",Ans);
	return 0;
}

Compiler output:
a.cc:1:9: fatal error: Cstdio: No such file or directory
    1 | #include<Cstdio>
      |         ^~~~~~~~
compilation terminated.
Language: C++

#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;
void solve();
int main() {
	solve();
#ifdef DBG
	while (true);
#endif // DBG
}

int n, A[200001];
int score() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", A + i);
	A[n] = 0;
	if (A[0] != 0)
		return -1;
	for (int i = 1; i < n; i++)
		if (A[i - 1] < A[i] && A[i - 1] + 1 != A[i])
			return -1;
	ll s = 0;
	for (int i = 0; i < n; i++)
		if (A[i] + 1 != A[i + 1])
			s += A[i];
	return s;
}

Compiler output:
/usr/bin/ld: /tmp/ccwOoAT7.o: in function `main':
a.cc:(.text+0x5): undefined reference to `solve()'
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n, a[1001010];
int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i ++){
        scanf("%d", &a[i]);
    }
    for(int i = 1; i <= n; i ++){
        if(a[i] >= i || a[i] - a[i-1] > 1){
            printf("-1");
            return 0;
        }
    }
    long long int ans = 0;
    for(int i = n; i > 0; i --){
        ans += a[i];
        /*
        if(a[i] < maxv){
            printf("-1");
            return 0;
        }
        maxav = max(maxv, a[i]);
        */
        while(a[i-1] == a[i]-1){
            i --;
            maxv --;
        }
    }
    printf("%lld", ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:13: error: 'maxv' was not declared in this scope
   27 |             maxv --;
      |             ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 998244353

vector<int> G[101];
ll CS[101];

void chmax(int& x, int y) {
	x = max(x, y);
}

int dfs(int c, int p, int d) {
	int D = 0;
	if (p < 0)chmax(CS[d], G[c].size());
	else chmax(CS[d], G[c].size() - 1);
	for (int i : G[c]) {
		if (i == p)continue;
		D = max(D, dfs(i, c, d + 1));
	}
	return D + 1;
}

int main() {
	int N, a, b;
	cin >> N;
	vector<pair<int, int>> E(N);
	for (int i = 1;i < N;i++) {
		cin >> a >> b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
		E[i] = { a,b };
	}
	ll dep, lea;
	vector<pair<ll, ll>> res;
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < 101;j++)CS[j] = 0;
		dep = dfs(i, -1, 0);
		lea = 1;
		for (int j = 0;j < 101;j++) {
			if (CS[j] == 0)break;
			lea *= CS[j];
		}
		res.push_back({ dep,lea });
	}
	for (int i = 1;i < N;i++) {
		for (int j = 0;j < 101;j++)CS[j] = 0;
		tie(a, b) = E[i];
		dep = max(dfs(a, b, 0), dfs(b, a, 0));
		lea = 1;
		for (int j = 0;j < 101;j++) {
			if (CS[j] == 0)break;
			lea *= CS[j];
		}
		res.push_back({ dep,lea * 2 });
	}
	sort(all(res));
	cout << res[0].first << " " << res[0].second << endl;
}

Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:16:29: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
   16 |         if (p < 0)chmax(CS[d], G[c].size());
      |                         ~~~~^
a.cc:10:17: note:   initializing argument 1 of 'void chmax(int&, int)'
   10 | void chmax(int& x, int y) {
      |            ~~~~~^
a.cc:17:24: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
   17 |         else chmax(CS[d], G[c].size() - 1);
      |                    ~~~~^
a.cc:10:17: note:   initializing argument 1 of 'void chmax(int&, int)'
   10 | void chmax(int& x, int y) {
      |            ~~~~~^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now,int n,vvel &way) {
	vel dist1 = dis(now,way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}
int fid(int le,int st,int goal,vvel &way) {
	vel dist = dis(st, way);
	while (dist[goal] > le) {
		rep(j, way[goal].size()) {
			if (dist[goal] > dist[way[goal][j]]) {
				goal = way[goal][j];
				break;
			}
		}
	}
	return goal;
}
vvel RE() {
	vel v(3,2);
	return v.at(4);
}
signed main() {
	int n; cin >> n;
	vvel way(n);
	rep(i, n-1) {
		int a, b; cin >> a >> b; a--; b--;
		way[a].push_back(b);
		way[b].push_back(a);
	}
	int u = most_far(0,n,way).second;
	pin pi = most_far(u, n, way);
	int v = pi.second;
	int cho = pi.first;
	int kind = (cho / 2) + 1;
	cout << kind << " ";
	int mid1 = fid(cho/2, u, v, way);
	vel dist1 = dis(mid1,way);
	if (cho % 2 == 0) {
		vel ans(kind, 1);
		rep(i, n) {
			int waysz = way[i].size();
			mmax(ans[dist1[i]], waysz - 1);
		}
		ans[0]++;
		int rret = 1;
		for (int i = 0; i < kind-1; i++) {
			rret *= ans[i];
		}
		rep(j, way[mid1].size()) {
			int mid2 = way[mid1][j];
			vel dist2 = dis(mid2, way);
			ans=vel(kind, 1);
			rep(i, n) {
				int waysz = way[i].size();
				mmax(ans[min(dist1[i], dist2[i])], waysz - 1);
			}
			int ret = 1;
			for (int i = 0; i < kind - 1; i++) {
				ret *= ans[i];
			}
			mmin(rret, ret*2);
		}
		cout << rret << endl;
	}
	else {
		RE();
		int mid2 = fid(kind+1, u,v, way);
		vel dist2 = dis(mid2, way);
		vel ans(kind, 1);
		rep(i, n) {
			int waysz = way[i].size();
			mmax(ans[min(dist1[i],dist2[i])], waysz - 1);
		}
		int ret = 1;
		for (int i = 0; i < kind-1; i++) {
			ret *= ans[i];
		}
		cout << ret*2 << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'std::vector<std::vector<long long int> > RE()':
a.cc:58:20: error: could not convert 'v.std::vector<long long int>::at(4)' from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'std::vector<std::vector<long long int> >'
   58 |         return v.at(4);
      |                ~~~~^~~
      |                    |
      |                    __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}
Language: C++

#include <iostream>
#include <cmath>
#include <queue>
#include <tuple>
#include <vector>

using namespace std;
using ll = unsigned long long;

const int INF = 1 << 25;

struct Graph {
    Graph(int N) : size(N) { path.resize(N); };
    void span(int u, int v) { path[u].push_back(v); }
    vector<int> operator[](int v) { return path[v]; };

    int size;
    vector<vector<int>> path;
};

int N;
Graph tree(0);

vector<int> bfs(vector<int> rs) {
    vector<int> dist(N, INF);
    queue<int> que;

    for (int r : rs) {
        dist[r] = 0;
        que.push(r);
    }

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int sv : tree[v]) {
            if (dist[sv] <= dist[v]) continue;
            dist[sv] = dist[v] + 1;
            que.push(sv);
        }
    }
    return dist;
}

tuple<int, int, int> diameter() {
    auto dist = bfs({0});
    int l = max_element(dist.begin(), dist.end()) - dist.begin();
    dist = bfs({l});
    int r = max_element(dist.begin(), dist.end()) - dist.begin();
    return make_tuple(dist[r], l, r);
}

// centerを根としたとき、必要な葉の数
ll leaf_num(vector<int> center) {
    auto dist = bfs(center);
    vector<ll> hie(N, 0);
    // 各深さでの、子の数の最大値

    for (int v = 0; v < N; ++v) {
        ll cnt = 0;
        for (int sv : tree[v]) {
            if (dist[sv] > dist[v]) ++cnt;
        }
        hie[dist[v]] = max(hie[dist[v]], cnt);
    }

    ll ret = center.size();
    for (int d = 0; d < N; ++d) {
        if (hie[d] == 0) break;
        ret *= hie[d];
    }
    return ret;
}

int main() {
    cin >> N;

    tree = Graph(N);
    for (int i = 0; i < N - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        tree.span(u, v);
        tree.span(v, u);
    }

    int D, l, r;  // 直径とその両端点
    tie(D, l, r) = diameter();
    cout << D / 2 + 1 << " ";

    // 両端点の距離から木の中心を求める
    auto ldist = bfs({l}), rdist = bfs({r});
    vector<int> center;
    for (int v = 0; v < N; ++v) {
        if (ldist[v] + rdist[v] == D && abs(ldist[v] - rdist[v]) <= 1) center.push_back(v);
    }

    ll ans = leaf_num(center);
    if (center.size() == 1) {
        // 中心が2つになるようにすると葉の数が減ることがある
        int c = center[0];
        for (int sv : tree[c]) {
            ans = min(ans, leaf_num({c, sv}));
        }
    }

    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'std::tuple<int, int, int> diameter()':
a.cc:48:13: error: 'max_element' was not declared in this scope
   48 |     int l = max_element(dist.begin(), dist.end()) - dist.begin();
      |             ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <cassert>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
using namespace std;

int max_deg[200] ={};
set<int> vec[200]  ={};

void dfs(int x, int p, int d = 0){
    max_deg[d] = max<int>(max_deg[d], vec[x].size());
    for(auto y : vec[x])
        if(y != p)
            dfs(y, x, d + 1);  }

using ll = long long;

pair<ll, ll> solve(int center){
    memset(max_deg, 0, sizeof(max_deg));
    dfs(center, -1, 0);
    ll rez = 1;
    int i;
    for(i = 0; max_deg[i]; ++i)
        rez *= max(max_deg[i] - (i != 0), 1);
    return make_pair(i, rez); }

pair<ll, ll> solve(int x, int y){
    memset(max_deg, 0, sizeof(max_deg));
    vec[x].erase(y);
    vec[y].erase(x);


    dfs(x, -1, 0);
    dfs(y, -1, 0);

    ll rez = 1;
    int i;
    for(i = 0; max_deg[i]; ++i){
        rez *= max(max_deg[i] - (i != 0), 1); }

    vec[x].insert(y);
    vec[y].insert(x);

    return make_pair(i, 2 * rez); }

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> e;
    for(int i = 0, x, y; i < n-1; ++i){
        cin >> x >> y;
        e.emplace_back(x, y);
        vec[x].insert(y);
        vec[y].insert(x); }

    pair<ll, ll> rez = { 10000000, 0 };

    for(int i = 1 ; i <= n; ++i)
        rez = min(rez, solve(i));

    for(auto x : e)
        rez = min(rez, solve(x.first, x.second));

    cout << rez.first << ' ' << rez.second << endl;
    
    return 0; }


Compiler output:
a.cc: In function 'std::pair<long long int, long long int> solve(int)':
a.cc:21:5: error: 'memset' was not declared in this scope
   21 |     memset(max_deg, 0, sizeof(max_deg));
      |     ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include <vector>
  +++ |+#include <cstring>
    7 | using namespace std;
a.cc: In function 'std::pair<long long int, long long int> solve(int, int)':
a.cc:30:5: error: 'memset' was not declared in this scope
   30 |     memset(max_deg, 0, sizeof(max_deg));
      |     ^~~~~~
a.cc:30:5: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define maxn 110 
#define ll long long
using namespace std;
int tot,n,d[maxn],la[maxn],son[maxn];
struct edge{int v,ne;}e[maxn<<1];
struct node{int x;ll y;}ans;
inline bool operator <(node a,node b){return a.x<b.x||a.x==b.x&&a.y<b.y;}
void add(int u,int v){
	e[tot].v=v,e[tot].ne=la[u],la[u]=tot++;
}
vector<int>nd[maxn];
void init(){
	tot=0;ans=(node){1e9,1e18};
	memset(la,-1,sizeof(la));
	scanf("%d",&n);
	for(int i=1;i<n;++i){
		int u,v;scanf("%d%d",&u,&v);
		add(u,v),add(v,u);
	}
}
inline void dfs(int u,int fa){
	son[u]=0;
	for(int i=la[u];~i;i=e[i].ne){
		int v=e[i].v;if(v==fa)continue;
		d[v]=d[u]+1;dfs(v,u);++son[u];
	}
}
inline node solve(int x,int y){
	d[x]=d[y]=1;dfs(x,y),dfs(y,x);
	int ans1=0;ll ans2,s=1;
	for(int i=1;i<=n;++i)nd[i].clear();
	for(int i=1;i<=n;++i){
		ans1=max(ans1,d[i]);
		nd[d[i]].push_back(i);
	}
	ans2=nd[ans1].size();
	for(int i=ans1-1;i;--i){
		int mx=0;
		for(int j=0;j<nd[i].size();++j)mx=max(mx,son[nd[i][j]]);
		for(int j=0;j<nd[i].size();++j)ans2+=(mx-son[nd[i][j]])*s;
		s=s*mx;
	}
	return (node){ans1,ans2};
}
void solve(){
	for(int u=1;u<=n;++u){
		ans=min(ans,solve(u,u));
		for(int i=la[u];~i;i=e[i].ne){
			int v=e[i].v;
			if(v>u&&u==3&&v==6)ans=min(ans,solve(u,v));
		}
	}
	printf("%d %lld\n",ans.x,ans.y);
}
int main(){
	init();
	solve();
	return 0;
}

Compiler output:
a.cc: In function 'void init()':
a.cc:18:26: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
   18 |         tot=0;ans=(node){1e9,1e18};
      |                          ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;
const int N=1000;
const LL INF=LLONG_MAX;

int n,u,v;
int d[N],fa[N],c[N],sz[N];
vector<int> gg[N];
bool vis[N];

void bfs(int rt,int rt2) {
	memset(vis,0,sizeof(vis));
	memset(sz,0,sizeof(sz));
	queue<int> que;
	vis[rt]=1;
	d[rt]=0;
	fa[rt]=0;
	que.push(rt);
	if(rt2) {
		vis[rt2]=1;
		d[rt2]=0;
		fa[rt2]=0;
		que.push(rt2);
	}
	while(!que.empty()) {
		u=que.front();que.pop();
		for(int i=0;i<gg[u].size();i++) {
			v=gg[u][i];
			if(vis[v]) continue;
			d[v]=d[u]+1;
			vis[v]=1;
			fa[v]=u;
			sz[u]++;
			que.push(v);
		}
	}
}

int go_up(int u,int t) {
	while(t--) {
		u=fa[u];
	}
	return u;
}

LL cal(int u,int v) {
	bfs(u,v);
	memset(c,0,sizeof(c));
	for(int i=1;i<=n;i++) {
		c[d[i]+1]=max(c[d[i]+1],sz[i]);
	}
	LL res=1;
	c[0]=(v==0)?1:2;
	for(int i=0;i<=n;i++) {
		if(c[i]>0) res*=c[i];
	}
	return res;
}

void solve() {
	bfs(1,0);
	int a1=1,a2;
	for(int i=1;i<=n;i++) {
		if(d[i]>d[a1]) {
			a1=i;
		}
	}
	bfs(a1,0);
	a2=a1;
	for(int i=1;i<=n;i++) {
		if(d[i]>d[a2]) {
			a2=i;
		}
	}
	int ans1=(d[a2]+2)/2;
	LL ans2=INF;
	if(d[a2]&1) {
		int f1=go_up(a2,d[a2]/2);
		int f2=fa[f1];
		ans2=min(ans2,cal(f1,f2));
	}
	else {
		int f=go_up(a2,d[a2]/2);
		ans2=min(ans2,cal(f,0));
		for(int i=0;i<gg[f].size();i++) {
			u=gg[f][i];
			ans2=min(ans2,cal(f,u));
		}
	}
	printf("%d %lld\n",ans1,ans2);
}

int main() {
	scanf("%d",&n);
	for(int i=1;i<n;i++) {
		scanf("%d %d",&u,&v);
		gg[u].push_back(v);
		gg[v].push_back(u);
	}
	solve();
}

Compiler output:
a.cc:13:14: error: 'LLONG_MAX' was not declared in this scope
   13 | const LL INF=LLONG_MAX;
      |              ^~~~~~~~~
a.cc:10:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    9 | #include <cmath>
  +++ |+#include <climits>
   10 | using namespace std;
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
vector<int> g[100];

int dfs(int v, int par) {
    int res = 0;
    for (int to : g[v]) if (to != par) {
        res = max(res, dfs(to, v) + 1);
    }
    return res;
}

vector<int> mx;

void solve(int v, int par, int dist) {
    int cnt = 0;
    for (int to : g[v]) if (to != par) {
        ++cnt;
        solve(to, v, dist + 1);
    }
    mx[dist] = max(mx[dist], cnt);
}

pair<int, LL> solve() {
    vector<int> cand;
    int mx = 0;
    forn(i, n) {
        int cur = dfs(i, -1);
        if (cur > mx) {
            mx = cur;
            cand.clear();
        }
        if (cur == mx) {
            cand.pb(i);
        }
    }
    assert((int)cand.size() == 1 || (int)cand.size() == 2);
    mx.assign(101, 0);
    int sz = cand.size();
    forn(i, sz) {
        solve(cand[i], (sz == 1 ? -1 : cand[i ^ 1]), 0);
    }
    int res1 = 0;
    LL res2 = 1;
    forn(i, 101) if (mx[i] > 0) {
        res1++;
        res2 *= mx[i];
    }
    return mp(res1, res2);
}

int main() {
    scanf("%d", &n);
    forn(i, n - 1) {
        int from, to;
        scanf("%d%d", &from, &to), --from, --to;
        g[from].pb(to);
        g[to].pb(from);
    }
    auto ans = solve();
    ++n;
    forn(i, n - 1) {
        g[i].pb(n - 1);
        g[n - 1].pb(i);
        ans = min(ans, solve());
        g[i].pop_back();
        g[n - 1].pop_back();
    }
    cout << ans.first << ' ' << ans.second << endl;
    return 0;
}



Compiler output:
a.cc: In function 'std::pair<int, long long int> solve()':
a.cc:47:8: error: request for member 'assign' in 'mx', which is of non-class type 'int'
   47 |     mx.assign(101, 0);
      |        ^~~~~~
a.cc:54:24: error: invalid types 'int[int]' for array subscript
   54 |     forn(i, 101) if (mx[i] > 0) {
      |                        ^
a.cc:56:19: error: invalid types 'int[int]' for array subscript
   56 |         res2 *= mx[i];
      |                   ^
Language: C++

#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;
typedef long long int LL;
vector<int> path[105];
queue<int> q1;
bool used[105];
LL sa[2];

void check(int a,int b){
	int nt;
	int i,j,k;
	LL x,y,z;
	bool ill=false;
	sa[0]=0,sa[1]=1;
	memset(used,false,sizeof(used));
	q1.push(a),used[a]=true;
	if(b!=-1)q1.push(b),used[b]=true,sa[1]=2;
	else ill=true;
	while(!q1.empty()){
		nt=q1.size();
		z=0;
		sa[0]++;
		for(i=0;i<nt;i++){
			x=q1.front(),q1.pop();
			z=max(z,(int)path[x].size()-1);
			for(j=0;j<path[x].size();j++){
				y=path[x][j];
				if(used[y])continue;
				q1.push(y),used[y]=true;
			}
		}
		if(ill)z++,ill=false;
		if(z!=0)sa[1]*=z;
	}
}

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	LL s[2];
	cin>>n;
	s[0]=n,s[1]=1;
	for(i=0;i<n-1;i++){
		cin>>a>>b;
		a--,b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	for(i=0;i<n;i++){
		check(i,-1);
		if(sa[0]<s[0])s[0]=sa[0],s[1]=sa[1];
		if(sa[0]==s[0] && sa[1]<s[1])s[1]=sa[1];
		for(j=0;j<path[i].size();j++){
			if(path[i][j]<i)continue;
			check(i,path[i][j]);
			if(sa[0]<s[0])s[0]=sa[0],s[1]=sa[1];
			if(sa[0]==s[0] && sa[1]<s[1])s[1]=sa[1];
		}
	}
	cout<<s[0]<<" "<<s[1]<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'void check(int, int)':
a.cc:29:30: error: no matching function for call to 'max(LL&, int)'
   29 |                         z=max(z,(int)path[x].size()-1);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:29:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |                         z=max(z,(int)path[x].size()-1);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> con[111];
int n;


int buf[111];
int mxlen;
int dim[111];

void dfs(int u, int p, int d)
{
    buf[d] = u;
    if (d > mxlen) {
        mxlen = d;
        for (int i = 1; i <= mxlen; i++)
            dim[i] = buf[i];
    }

    for (int to: con[u]) {
        if (to == p)continue;
        dfs(to, u, d + 1);
    }
}

int mxd[111];

void dfs2(int u, int p, int d)
{
    int ch = 0;
    for (int to: con[u]) {
        if (to == p)continue;

        ch++;
        dfs2(to, u, d + 1);
    }
    mxd[d] = max(mxd[d], ch);
}

int main()
{
    cin >> n;

    for (int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;
        con[x].push_back(y);
        con[y].push_back(x);
    }

    mxlen = 0;
    dfs(1, 0, 1);

    int u = dim[mxlen];
    mxlen = 0;
    dfs(u, 0, 1);

    long long ans1 = (mxlen + 1) / 2, ans2;
    if (mxlen % 2 == 0) {
        dfs2(dim[mxlen / 2], dim[mxlen / 2 + 1], 0);
        dfs2(dim[mxlen / 2 + 1], dim[mxlen / 2], 0);
        ans2 = 2;
        for (int i = 0; mxd[i]; i++) {
            ans2 *= mxd[i];
        }
    } else {
        long long tmp = 1;
        int root = dim[mxlen / 2 + 1];
        dfs2(root, 0, 0);
        for (int i = 0; mxd[i]; i++) {
            tmp *= mxd[i];
        }
        for (int to: con[root]) {
            memset(mxd, 0, sizeof(mxd));
            dfs2(root, to, 0);
            dfs2(to, root, 0);
            long long x = 2;
            for (int i = 0; mxd[i]; i++) {
                x *= mxd[i];
            }
            if (x < tmp)
                tmp = x;
        }
        ans2 = tmp;
    }

    cout << ans1 << ' ' << ans2 << '\n';
}


Compiler output:
a.cc: In function 'int main()':
a.cc:77:13: error: 'memset' was not declared in this scope
   77 |             memset(mxd, 0, sizeof(mxd));
      |             ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
using namespace std;
#define ll long long
ll n,m,mod,f[305][305][305];
int main(){
	scanf("%lld%lld%lld",&n,&m,&mod);
	f[0][1][0]=1;
	for(ll i=0;i<=n;i++){
		for(ll t=1;t<=m;t++){
			for(ll j=i;j>=0;j--){
				if(j) f[i][t][j-1]=add(f[i][t][j-1]+f[i][t][j]);
				else f[i][t+1][i]=add(f[i][t+1][i]+f[i][t][j]);
				f[i+1][t][j]=(f[i+1][t][j]+f[i][t][j]*(j+1))%mod;
			}
		}
	}
	printf("%lld",f[n][m][0]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:52: error: 'add' was not declared in this scope
   15 |                                 if(j) f[i][t][j-1]=add(f[i][t][j-1]+f[i][t][j]);
      |                                                    ^~~
a.cc:16:51: error: 'add' was not declared in this scope
   16 |                                 else f[i][t+1][i]=add(f[i][t+1][i]+f[i][t][j]);
      |                                                   ^~~
Language: C

#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
const int N=305;
int n,m,P,C[N][N],f[N][N],s[N][N];
int Mod(int x){return x>=P?x-P:x;}
void Pre(int n){
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)C[i][j]=Mod(C[i-1][j-1]+C[i-1][j]);
	}
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),m=read(),P=read(),Pre(300);
	for(int j=0;j<=m;j++)f[1][j]=1,s[1][j]=m-j+1;
	for(int i=2;i<=n+1;i++){
		for(int j=0;j<=m;j++)
		for(int k=1;k<i;k++)f[i][j]=Mod(f[i][j]+1ll*f[k][j]*s[i-k][j+1]%P*C[i-2][k-1]%P);
		for(int j=m;j>=0;j--)s[i][j]=Mod(s[i][j+1]+f[i][j]);
	}printf("%d",f[n+1][0]);
	return 0;
}


Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
using namespace std;
long long dp[1002][1002],sum[1001][1002],C[1001][1001];
int main()
{
  int n,k,m;
  cin>>n>>k>>m;
  for (int i=1;i<=k+1;++i)
    {
     dp[1][i]=1;
     sum[1][i]=i;
    }
  for (int i=0;i<=n;++i)
    C[i][0]=1;
  for (int i=1;i<=n;++i)
    for (int j=1;j<=n;++j)
      C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
  for (int i=2;i<=n+1;++i)
    for (int j=1;j<=k+1;++j)
      {
        for (int t=1;t<=i-1;++t)
	  dp[i][j]=(dp[i][j]+dp[t][j]*sum[i-t][j-1]%m*C[i-2][t-1])%m;
	sum[i][j]=(sum[i][j-1]+dp[i][j])%m;
      }
  cout<<dp[n+1][k+1]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:39: error: 'mod' was not declared in this scope
   17 |       C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
      |                                       ^~~
Language: C++

#include<iostream>
using namespace std;
int dp[1002][1002],sum[1001][1002],C[1001][1001];
int main()
{
  int n,k,m;
  cin>>n>>k>>m;
  for (int i=1;i<=k+1;++i)
    {
     dp[1][i]=1;
     sum[1][i]=i;
    }
  for (int i=0;i<=n;++i)
    C[i][0]=1;
  for (int i=1;i<=n;++i)
    for (int j=1;j<=n;++j)
      C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
  for (int i=2;i<=n+1;++i)
    for (int j=1;j<=k+1;++j)
      {
        for (int t=1;t<=i-1;++t)
	  dp[i][j]=(dp[i][j]+dp[t][j]*sum[i-t][j-1]%m*C[i-2][t-1])%m;
	sum[i][j]=(sum[i][j-1]+dp[i][j])%m;
      }
  cout<<dp[n+1][k+1]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:39: error: 'mod' was not declared in this scope
   17 |       C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
      |                                       ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long f[333][333][333];

long long solution(int b,int x,int y){
  f[0][1][0]=1;
  for(int i=0;i<=n;i++)
    for(int j=1;j<=x;j++)
      for(int p=i;p>=0;p--){
          if(p) (f[i][j][p-1]+=f[i][j][p]) %= y;
          else (f[i][j+1][i]+=f[i][j][p]) %= y;
          (f[i+1][j][p]+=f[i][j][p]*(p+1)) %= y;
      }
  return f[n][x + 1][n];
}

int main()
{
  int n, x ,y;
  n = 2;
  x = 3;
  y = 100;
  cin>>n>>x>>y;
  long long res = solution(n, x, y);
  cout<<res<<endl;  
  return 0;
}


Compiler output:
a.cc: In function 'long long int solution(int, int, int)':
a.cc:7:18: error: 'n' was not declared in this scope
    7 |   for(int i=0;i<=n;i++)
      |                  ^
a.cc:14:12: error: 'n' was not declared in this scope
   14 |   return f[n][x + 1][n];
      |            ^
Language: C

#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(isdigit(ch))
	{
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int ch[2][1<<22],id[22][1<<21],cnt,a[22][1<<22],siz[22],c[22][1<<22],num[22][1<<22],ans[22],N,K;
inline void get()
{
	id[0][0]=++cnt;
	ch[0][id[0][0]]=ch[1][id[0][0]]=-1;
	for(int i=1;i<=20;i++)
	{
		int t=(1<<i),k=(t>>1);
		for(int s=0;s<t;s++)
		{
			id[i][s]=++cnt;
			int p=(s&k),q=(p?1:0);
			ch[q][id[i][s]]=id[i-1][s^p];
			ch[!q][id[i][s]]=ch[!q][id[i-1][s^p]];
		}
	}
}
inline void dfs(int d,int s)
{
	if(ans[d]==-1)ans[d]=s;
	for(int p=0;p<=1;p++)
	{
		int tot=0;
		for(int i=0;i<siz[d];i++)
		{
			int to=ch[p][a[d][i]];
			if(to==-1)continue;
			if(num[d+1][to]==-1)
			{
				num[d+1][a[d+1][siz[d+1]]=to]=siz[d+1];
				siz[d+1]++;
			}
			tot+=c[d][i];
			c[d+1][num[d+1][to]]+=c[d][i];
		}
		if(tot>=K)dfs(d+1,(s<<1)|p);
		for(int i=0;i<siz[d+1];i++)
		{
			num[d+1][a[d+1][i]]=-1;
			c[d+1][i]=0;
		}
		siz[d+1]=0;
	}
}
char s[1<<21];
int main()
{
	N=read();
	K=read();
	get();
	for(int i=0;i<=N;i++)for(int j=0;j<cnt;j++)num[i][j]=-1;
	for(int i=0;i<=N;i++)
	{
		scanf("%s",s);
		int t=(1<<i);
		for(int j=0;j<t;j++)if(s[j]=='1')
		{
			num[0][a[0][siz[0]]=id[i][j]]=siz[0];
			c[0][num[0][id[i][j]]]++;
			siz[0]++;
		}
		ans[i]=-1;
	}
	dfs(0,0);
	for(int i=N;i>=0;i--)if(ans[i]!=-1)
	{
		for(int j=i-1;j>=0;j--)putchar(((ans[i]>>j)&1)+'0');
		puts("");
		return 0;
	}
	return 0;
}
/*
*/

Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.