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

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

int main() {
  string s;
  int k;
  cin >> s >> k;
  
  int count = 1;
  vector<int> x;
  for(int i = 1; i < n; i++){
    if(s.at(i - 1) == s.at(i)) count++;
    else{
      x.push_back(count);
      count = 1;
    }
  }
  x.push_back(count);
  
  long long ans = 0;
  if(s.at(0) != s.at(s.size() - 1)){
    for(int i = 0; i < x.size(); i++){
      ans += x.at(i) / 2;
    }
    ans *= k;
  }
  else{
    if(x.size() == 1){
      ans = (s.size() * k) / 2;
    }
    else{
      ans += x.at(0) / 2;
      ans += x.at(x.size() - 1) / 2;
      
      long long keep = 0;
      x.at(0) += x.at(x.size() - 1);
      x.pop_back();
      for(int i = 0; i < x.size(); i++){
        keep += x.at(i) / 2;
      }
      keep *= k - 1;
      for(int i = 1; i < x.size(); i++){
        keep += x.at(i) / 2;
      }
      ans += keep;
    }
  }
  
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:22: error: 'n' was not declared in this scope
   11 |   for(int i = 1; i < n; i++){
      |                      ^
Language: C++

         }
   34         bl = true;
   35     }
   36     if (!bl) {
   37         if (s[n-1] == s[0]) x += (k-1);
   38     }
   39     printf("%lld\n", x);
   40 }
   41


Compiler output:
a.cc:1:10: error: expected declaration before '}' token
    1 |          }
      |          ^
a.cc:2:4: error: expected unqualified-id before numeric constant
    2 |    34         bl = true;
      |    ^~
a.cc:3:4: error: expected unqualified-id before numeric constant
    3 |    35     }
      |    ^~
a.cc:3:11: error: expected declaration before '}' token
    3 |    35     }
      |           ^
a.cc:4:4: error: expected unqualified-id before numeric constant
    4 |    36     if (!bl) {
      |    ^~
a.cc:7:4: error: expected unqualified-id before numeric constant
    7 |    39     printf("%lld\n", x);
      |    ^~
a.cc:8:4: error: expected unqualified-id before numeric constant
    8 |    40 }
      |    ^~
a.cc:8:7: error: expected declaration before '}' token
    8 |    40 }
      |       ^
a.cc:9:4: error: expected unqualified-id before numeric constant
    9 |    41
      |    ^~
Language: C

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[256] = {};
vl v;

int main(){
	ll k; scanf("%s%lld", s, &k);
	int n = strlen(s);
	// REP(i, n) s[n+i] = s[i];
	{
		int i = 0;
		while(i < n){
			int j = i;
			while(s[j] == s[i]) j++;
			DEBUG("[%d, %d)\n", i, j);
			v.EB(j-i);
			i = j;
		}
	}
	ll ans = 0;
	if(s[0] == s[n-1]){
		if((int)v.size() == 1){
			ans = n * k / 2;
		} else {
			FOR(i, 1, (int)v.size()-1){
			 	ans += v[i]/2;
			}
			ans *= k;
			ll a = *v.begin(), b = *v.rbegin();
			ans += a/2 + b/2 + (a+b)/2 * (k-1);
		}
	} else {
		for(ll &i : v) ans += i / 2;
		ans *= k;
	}
	printf("%lld\n", ans);
}


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

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
char a[200];
int n;ll sum;
int main(){
	scanf("%s",a);
	scanf("%d",&n);
	for(int i=1;i<strlen(a);i++){
		if(a[i]==a[i-1])sum++,a[i]='\n',i++;
	}
	if(a[0]==a[strlen(a)-1])printf("%d\n",sum*n+n-1);
	else printf("%lld\n",sum*n);
	return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  string s; cin >> s;
  int n; cin >> n;
  

  int ans = 0;

  for(int i=0;i<s.size()-1;){
    if(s[i]==s[i+1]){
      int cnt = 0;
      while(s[i]==s[i+1]){
        cnt++;
        i++;
      }
      ans+=(cnt+1)/2;
    }else{
      i++;
    }
  }

  cout << ans*n;

  return 0;
}

Compiler output:
a.cc:7:10: fatal error: debug.cpp: No such file or directory
    7 | #include "debug.cpp"
      |          ^~~~~~~~~~~
compilation terminated.
Language: C++

    ret = min(ret, dfs(n+1, t[n]));    
  }

  return dp[n][pre] = ret;  
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;

  int K;
  cin >> K;

  fill_n(*dp, 101*27, -1);  

  N = s.size();
  t.resize(N);  
  for ( int i = 0; i < s.size(); i++ ) {
    t[i] = s[i]-'a';    
  }

  int ret1 = dfs(0, 26);
  t.push_back(t[0]);
  N++;  
  fill_n(*dp, 101*27, -1);
  int ret2 = dfs(0, 26);

  if ( ret1 == ret2 ) {
    cout << ret1*K << endl;    
  } else {
    cout << (ret1+1)*K -1 << endl;    
  }
  
  return 0;
}


Compiler output:
a.cc:1:5: error: 'ret' does not name a type
    1 |     ret = min(ret, dfs(n+1, t[n]));
      |     ^~~
a.cc:2:3: error: expected declaration before '}' token
    2 |   }
      |   ^
a.cc:4:3: error: expected unqualified-id before 'return'
    4 |   return dp[n][pre] = ret;
      |   ^~~~~~
a.cc:5:1: error: expected declaration before '}' token
    5 | }
      | ^
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope
    8 |   cin.tie(0);
      |   ^~~
a.cc:9:3: error: 'ios_base' has not been declared
    9 |   ios_base::sync_with_stdio(0);
      |   ^~~~~~~~
a.cc:10:3: error: 'cout' was not declared in this scope
   10 |   cout << fixed << setprecision(12);
      |   ^~~~
a.cc:10:11: error: 'fixed' was not declared in this scope
   10 |   cout << fixed << setprecision(12);
      |           ^~~~~
a.cc:10:20: error: 'setprecision' was not declared in this scope
   10 |   cout << fixed << setprecision(12);
      |                    ^~~~~~~~~~~~
a.cc:12:3: error: 'string' was not declared in this scope
   12 |   string s;
      |   ^~~~~~
a.cc:13:10: error: 's' was not declared in this scope
   13 |   cin >> s;
      |          ^
a.cc:18:11: error: 'dp' was not declared in this scope
   18 |   fill_n(*dp, 101*27, -1);
      |           ^~
a.cc:18:3: error: 'fill_n' was not declared in this scope
   18 |   fill_n(*dp, 101*27, -1);
      |   ^~~~~~
a.cc:20:3: error: 'N' was not declared in this scope
   20 |   N = s.size();
      |   ^
a.cc:21:3: error: 't' was not declared in this scope
   21 |   t.resize(N);
      |   ^
a.cc:26:14: error: 'dfs' was not declared in this scope
   26 |   int ret1 = dfs(0, 26);
      |              ^~~
a.cc:33:23: error: 'endl' was not declared in this scope
   33 |     cout << ret1*K << endl;
      |                       ^~~~
a.cc:35:30: error: 'endl' was not declared in this scope
   35 |     cout << (ret1+1)*K -1 << endl;
      |                              ^~~~
Language: C++

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	std::string s;
	std::cin >> s;
	int n = s.size();
	int k = ri();
	int r0 = 0;
	std::vector<int> t;
	for (auto c : s) t.push_back(c - 'a');
	for (int i = 0; i + 1 < n; i++) {
		if (t[i] == t[i + 1]) r0++, t[i + 1] = -i;
	}
	
	bool can_continue = t[i + 1] < 0 || s[0] != s[n - 1];
	
	int r1 = 1;
	t.clear();
	for (auto c : s) t.push_back(c - 'a');
	t[0] = -100000000;
	for (int i = 0; i + 1 < n; i++) {
		if (t[i] == t[i + 1]) r1++, t[i + 1] = -i;
	}
	assert(r1 >= r0);
	
	bool can2 = t[i + 1] < 0 || s[0] != s[n - 1];
	
	if (can_continue) std::cout << (int64_t) r0 * k << std::endl;
	else if (can2) std::cout << (int64_t) (r0 + r1) * (k / 2) + r0 * (k & 1) << std::endl;
	else std::cout << r0 + (int64_t) r1 * (k - 1) << std::endl;
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:31: error: 'i' was not declared in this scope
   20 |         bool can_continue = t[i + 1] < 0 || s[0] != s[n - 1];
      |                               ^
Language: C

#include<bits/stdc++.h>
using namespace std;
#define ll long long
char a[200];
int n;ll sum;
int main(){
	scanf("%s",a);
	scanf("%d",&n);
	for(int i=1;i<strlen(a);i++){
		if(a[i]==a[i-1])sum++,a[i]='\n',i++;
	}
	if(a[0]==a[strlen(a)-1])printf("%d\n",sum*n+n-1);
	else printf("%lld\n",sum*n);
	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++

S = input()
K = int(input())

if len(set(S)) == 1:
    ans = K * len(S) // 2
    print(0)
    exit()

ans = 0

T = list(S)
b = 0

for i, t in enumerate(T[1:], start=1):
    if t == T[i - 1] and T[i - 1] != '.':
        b += 1
        T[i] = '.'

print(ans + b * K)

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

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

char s[105];
int n,k,ans;

int main()
{
	scanf("%s%d",&s,&k);
	n=strlen(s);
	s[n++]=s[0];
	for(int i=1;i<n;++i) if(s[i]==s[i-1]) s[i]=-1,ans++;
	printf("%lld",(long long)ans*k;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:39: error: expected ')' before ';' token
   13 |         printf("%lld",(long long)ans*k;
      |               ~                       ^
      |                                       )
Language: C++

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

#include "library/graph/Graph.hpp"
int N;
string S[202];
Graph<int> G;

void solve() {
    if (!G.test_bipartite()) {
        cout << -1 << endl;
        return;
    }
    int ans = 1;
    auto M = G.WarshallFloyd();
    for (int i = 0; i < N; i++) {
        chmax(ans, *max_element(all(M[i])) + 1);
    }
    cout << ans << endl;
}

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

    cin >> N;
    G.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        for (int j = 0; j < N; j++) {
            if (S[i][j] == '1') {
                G.add_edge_directed(i, j);
            }
        }
    }


    solve();
    return 0;
}


Compiler output:
a.cc:80:10: fatal error: library/graph/Graph.hpp: No such file or directory
   80 | #include "library/graph/Graph.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const ll N=1e5+5;
const ll mod=1e9+7;
int n;
char s[205][205];
int vis[205];
int dep[205];
struct node{
    int a,b,d;
};
queue<node>q;
vector<int>v[205];
void clear(queue<node>& q){
    queue<node> empty;
    swap(empty,q);
}
 
int flag=1;
 
int main(){
    std::ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>s[i];
    for(int i=1;i<=n;i++){
        for(int j=0;j<n;j++)
            if(s[i][j]=='1')
                v[i].push_back(j+1);  
    node t,g;
    int ans=0;
    int fff=1;
    for(int k=1;k<=n;k++){
        flag=1;
        memset(vis,0,sizeof(vis));
        for(int i=0;i<=n;i++) dep[i]=-1;
        int pp=0;
        t.a=0,t.b=k,t.d=1;
        q.push(t);
        while(!q.empty()){
            t=q.front();
            q.pop();
            int b=t.b;
            if(vis[b]) continue;  //TLE
            vis[b]=1;
            dep[b]=t.d;
            pp=b;
            for(int i=0;i<v[b].size();i++){
                if(vis[v[b][i]]==1){
                    if(abs(dep[v[b][i]]-dep[b])!=1)
                        flag=0;
                    continue;
                }
                else{
                    g.a=b,g.b=v[b][i];
                    g.d=t.d+1;
                    q.push(g);
                }
            }
        }
 
        memset(vis,0,sizeof(vis));
        clear(q);
        if(flag){
            t.a=0,t.b=pp,t.d=1;
            q.push(t);
            while(!q.empty()){
                t=q.front();
                q.pop();
                ans=max(ans,t.d);
                int b=t.b;
                if(vis[b]) continue;  //TLE
                vis[b]=1;
                for(int i=0;i<v[b].size();i++){
                    if(vis[v[b][i]]==1){
                        continue;
                    }
                    else{
                        g.a=b,g.b=v[b][i];
                        g.d=t.d+1;
                        q.push(g);
                    }
                }
            }
        }
        if(flag==0) fff=0;
    }
    if(!fff) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}
 

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

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

const i64 INF = 1LL << 50;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  cin.ignore();
  vector<vector<i64>> adj(N, vector<i64>(N, INF));
  REP(i, N) {
    string s;
    getline(cin, s);
    REP(j, N) {
      if (s[j] == '1') {
        adj[i][j] = 1;
      } else if (j == i) {
        adj[i][j] = 0;
      }
    }
  }

  vector<int> color(N, -1);
  auto dfs = [&](auto rec, int v, int p, int c) -> bool {
    if (color[v] != -1) {
      if (color[v] != c) return false;
      return true;
    }
    color[v] = c;
    REP(x, N) {
      if (x == v || x == p || adj[v][x] != 1) continue;
      if (!rec(rec, x, v, c ^ 1)) return false;
    }
    return true;
  };

  if (!dfs(dfs, 0, -1, 0)) {
    cout << -1 << endl;
    return 0;
  }

  i64 diam = 0;
  REP(k, N) REP(i, N) REP(j, N) {
    adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
    if (adj[i][j] != INF && diam < adj[i][j]) {
      diam = adj[i][j];
      DEBUG(i, j, diam);
    }
  }
  cout << (diam + 1) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:7: error: 'DEBUG' was not declared in this scope
   52 |       DEBUG(i, j, diam);
      |       ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vint e[500];
bool isBipartite(int n) {
    vint color(n, -1);
    rep(i, n) {
        if (color[i] != -1) continue;
        if (!dfs_bipartite(i, color, 0)) return false;
    }
    return true;
}
bool dfs_bipartite(int v, vint &color, int c) {
    color[v] = c;
    for (auto u : e[v]) {
        if (color[u] != -1) {
            if (color[u] == c) return false;
            continue;
        }
        if (!dfs_bipartite(u, color, 1-c)) return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vstr s(n);
    rep(i, n) cin >> s[i];

    vvint d(n, vint(n, INF));
    rep(i, n) rep(j, n) {
        if (i==j) d[i][j] = 0;
        if (s[i][j] == '0') continue;
        e[i].push_back(j);
        e[j].push_back(i);
        d[i][j] = 1;
    }

    if (!isBipartite(n)) {
        puts("-1");
        return 0;
    }

    rep(k, n) rep(i, n) rep(j, n) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }

    int ans = 0;
    rep(i, n) ans = max(ans, vmax(d[i]));
    ++ans;

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

Compiler output:
a.cc: In function 'bool isBipartite(int)':
a.cc:48:14: error: 'dfs_bipartite' was not declared in this scope; did you mean 'isBipartite'?
   48 |         if (!dfs_bipartite(i, color, 0)) return false;
      |              ^~~~~~~~~~~~~
      |              isBipartite
Language: C++

// シャキョウ of youyin
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i = 0; i < n; i++)
#define MAX 1<<29

typedef long long ll;
const int inf = 1e5;
int main() {
	ll N;
	cin >> N;

	vector<vector<int>> to(N);

	vector<vector<int>> to(N);
	
	vector<vector<int>> dist(N,vector<int>(N,inf));
	for(int i = 0; i < N; i++) dist[i][i] = 0;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++){
			char c; cin >> c;
			if(c == '1') {
				to[i].push_back(j);
				dist[i][j] = 1;
			}
		}
	}

	vector<ll> visited(N,-1);

	queue<int> Q; Q.push(0);
	while(!Q.empty()){
		int p = Q.front(); Q.pop();

		for(auto u :to[p]){
			if(visited[u] != -1) { // -1 は未到達を意味する
				if(visited[u] == visited[p]) {
					cout << -1 << endl; return 0; // この時、二部グラフ構成出来ない。　
				} else {
					continue;
				}
			}

			visited[u] = visited[p] + 1;
			Q.push(u);
		}
	}

	// ここを通過すれば、二部グラフと言える
	// 次に、最長の距離を求める

	// Warshall - Floyd
	rep(k,N) rep(i,N) rep(j,N){
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	}
	ll ans = 0;
	rep(i,N){
		ans = (ans, *max_element(dist[i].begin(),dist[i].end()));
	}
	cout << ans + 1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:29: error: redeclaration of 'std::vector<std::vector<int> > to'
   16 |         vector<vector<int>> to(N);
      |                             ^~
a.cc:14:29: note: 'std::vector<std::vector<int> > to' previously declared here
   14 |         vector<vector<int>> to(N);
      |                             ^~
Language: C++

#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <queue>

using std::vector;
#define rep(i,n) for(int i=0;i<(n);++i)

int main() {
  int n, m = 0;
  std::cin >> n;
  vector<vector<bool>> edges(n, vector<bool>(n));
  vector<vector<int>> graph(n);

  rep(i, n) {
    std::string s;
    std::cin >> s;
    rep(j, n) {
      edges[i][j] = s[j] == '1';
      if (edges[i][j]) {
        graph[i].push_back(j);
        ++m;
        // sstd::cerr << i << " " << j << std::endl;
      }
    }
  }

  int ans=-1;
  rep(i, n) {
    std::queue<std::pair<int,int>> que;
    std::vector<int> dist(n, -1);
    que.push({i,-1});
    dist[i] = 0;
    bool ok=true;
    while(not que.empty()) {
      std::pair<int,int> pr = que.front(); que.pop();
      int now = pr.first, bk = pr.second;
      for (int next: graph[now]) {
        if (dist[next] == -1) {
          dist[next] = dist[now] + 1;
          que.push({next,now});
        } else if(
          dist[next] == dist[now] ||
          dist[next] != dist[now] + 1 && !edges[now][next]
        ) {
          ok = false;
        }
      }
    }
    int r=*std::max_element(dist.begin(), dist.end()) + 1;
//    if (ok) std::cerr << i << " " << r << std::endl;
    if(ok) ans=std::max(ans,r);
  }
  std::cout << ans << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:17: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
   51 |     int r=*std::max_element(dist.begin(), dist.end()) + 1;
      |                 ^~~~~~~~~~~
      |                 tuple_element
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef __int64 LL;
//typedef long long int LL;
typedef pair<int,int> P;
vector<int> G[220];

const int MOD=1000000007;

int d[220][220];
int color[220];
int n;

bool nibu(int v,int c)
{
	color[v]=c;
	for(int i=0;i<G[v].size();i++)
	{
		int w=G[v][i];
		if(color[v]==color[w])return false;
		else if(color[w]==0 && !nibu(w,-c))return false;
	}
	return true;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		for(int j=0;j<n;j++)	
		{
			if(s[j]=='0' && i!=j)d[i][j]=MOD;
			else if(s[j]=='1')d[i][j]=1;
			else d[i][j]=0;
			if(d[i][j]==1)
			{
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	
	if(!nibu(0,1)){cout<<-1<<"\n";return 0;}
	
	int diam=0;
	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)diam=max(diam,d[i][j]);
	cout<<diam+1<<"\n";	
	return 0;
}

Compiler output:
a.cc:13:9: error: '__int64' does not name a type; did you mean '__int64_t'?
   13 | typedef __int64 LL;
      |         ^~~~~~~
      |         __int64_t
Language: C++

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

vll color(n,0,vvll &g);
bool dfs(ll v,ll c){
	color[v]=c;
	rep(i,sz(g[v])){
	  if(color[g[v][i]]==c)  return false;
	  if(color[g[v][i]]==0 && !dfs(g[v][i],-c,g)) return false;
	}
	return true;
}
int main(){
  cin>>n;
  vstr s(n);
  vvll g(n,vll(0));
  rep(i,n) cin>>s[i];
  rep(i,n){
    rep(j,n){
      if(s[i][j]=='1'){
        g[i].pb(j);
      }
    }
  }
  if(dfs(0,1,g)){
    vvll t(n,vll(n,INF));
    rep(i,n)rep(j,n) if(s[i][j]=='1') t[i][j]=1;
    rep(i,n){
      t[i][i]=0;
    }
    rep(k,n){
      rep(i,n){
        rep(j,n){
          t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
        }
      }
    }
    ll ans=INF;
    rep(i,n){
      rep(j,n){
        ans=min(ans,t[i][j]);
      }
    }
    COUT(ans);
  }
  else{
    COUT(-1);
  }
}


Compiler output:
a.cc:51:20: error: expected primary-expression before '&' token
   51 | vll color(n,0,vvll &g);
      |                    ^
a.cc:51:21: error: 'g' was not declared in this scope
   51 | vll color(n,0,vvll &g);
      |                     ^
a.cc: In function 'bool dfs(long long int, long long int)':
a.cc:54:18: error: 'g' was not declared in this scope
   54 |         rep(i,sz(g[v])){
      |                  ^
a.cc:10:39: note: in definition of macro 'rep'
   10 | #define rep(i, n) for (ll i = 0; i < (n); i++)
      |                                       ^
a.cc:54:15: note: in expansion of macro 'sz'
   54 |         rep(i,sz(g[v])){
      |               ^~
a.cc: In function 'int main()':
a.cc:72:9: error: too many arguments to function 'bool dfs(long long int, long long int)'
   72 |   if(dfs(0,1,g)){
      |      ~~~^~~~~~~
a.cc:52:6: note: declared here
   52 | bool dfs(ll v,ll c){
      |      ^~~
Language: C++

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

vll color(n,0);
bool dfs(ll v,ll c,vvll &g){
	color[v]=c;
	rep(i,sz(g[v])){
	  if(color[g[v][i]]==c)  return false;
	  if(color[g[v][i]]==0 && !dfs(g[v][i],-c,g)) return false;
	}
	return true;
}
int main(){
  cin>>n;
  vvll g(n,vll(0));
  vstr s(n);
  rep(i,n) cin>>s[i];
  rep(i,n){
    rep(j,n){
      if(s[i][j]=='1'){
        g[i].pb(j);
      }
    }
  }
  if(dfs(0,1LL)){
    vvll t(n,vll(n,INF));
    rep(i,n)rep(j,n) if(s[i][j]=='1') t[i][j]=1;
    rep(i,n){
      t[i][i]=0;
    }
    rep(k,n){
      rep(i,n){
        rep(j,n){
          t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
        }
      }
    }
    ll ans=INF;
    rep(i,n){
      rep(j,n){
        ans=min(ans,t[i][j]);
      }
    }
    COUT(ans);
  }
  else{
    COUT(-1);
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:72:9: error: too few arguments to function 'bool dfs(long long int, long long int, vvll&)'
   72 |   if(dfs(0,1LL)){
      |      ~~~^~~~~~~
a.cc:52:6: note: declared here
   52 | bool dfs(ll v,ll c,vvll &g){
      |      ^~~
Language: C++

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

vll color(n,0);
bool dfs(ll v,ll c,vvll g){
	color[v]=c;
	rep(i,sz(g[v])){
	  if(color[g[v][i]]==c)  return false;
	  if(color[g[v][i]]==0 && !dfs(g[v][i],-c)) return false;
	}
	return true;
}
int main(){
  cin>>n;
  vvll g(n,vll(0));
  vstr s(n);
  rep(i,n) cin>>s[i];
  rep(i,n){
    rep(j,n){
      if(1){
        g[i].pb(j);
      }
    }
  }
  
}


Compiler output:
a.cc: In function 'bool dfs(long long int, long long int, vvll)':
a.cc:56:39: error: too few arguments to function 'bool dfs(long long int, long long int, vvll)'
   56 |           if(color[g[v][i]]==0 && !dfs(g[v][i],-c)) return false;
      |                                    ~~~^~~~~~~~~~~~
a.cc:52:6: note: declared here
   52 | bool dfs(ll v,ll c,vvll g){
      |      ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vector<string> S(N);
  rep(i,0,N) cin>>S[i];
  int ans=0;
  rep(i,0,N){
    vi F(N,-1);
    F[i]=0;
    queue<int> Q;
    Q.push(i);
    Q.push(-1);
    int count=1;
    bool flag=1;
    while(Q.size()>1){
      int X=Q.front();
      Q.pop();
      if(X==-1){
        count++;
        Q.push(-1);
      }
      else{
        rep(j,0,N){
          if(S[X][j]=='1'){
            if(F[j]==-1){
              F[j]=count;
              Q.push(j);
            }
            else{
              if((count-F[j])%2==1) flag=0;
            }
          }
        }
      } 
    }
    rep(j,0,N) ans=max(ans,F[j]);
  }
  if(flag) cout<<ans<<endl;
  else cout<<-1<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:55:6: error: 'flag' was not declared in this scope
   55 |   if(flag) cout<<ans<<endl;
      |      ^~~~
Language: C++

#include "iostream"

int main(){
  cout << -1 << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    4 |   cout << -1 << endl;
      |   ^~~~
      |   std::cout
In file included from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:4:17: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
    4 |   cout << -1 << endl;
      |                 ^~~~
      |                 std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C

//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 200
typedef long long i64;

int n;
char g[MAXN][MAXN+1];
int vis[MAXN];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	for (int i=0; i<n; i++) {
		scanf("%s", g[i]);
		for (int j=0; g[i][j]; j++)
			g[i][j] -= '0';
	}
	return 1;
}

void init() {
}

int dfs(int v, int c) {
	vis[v] = c;
	for (int i=0; i<n; i++)
		if (g[v][i]) {
			if (vis[i]) {
				if (vis[i]==c) return 0;
			}
			else {
				if (!dfs(i, 3-c)) return 0;
			}
		}
	return 1;
}

int solve() {
	memset(vis, 0, sizeof(vis));
	if (!dfs(0, 1)) return -1;
	for (int k=0; k<n; k++)
		for (int i=0; i<n; i++)
			for (int j=0; j<n; j++)
				if (i!=j && g[i][k] && g[k][j]) {
					int d = g[i][k] + g[k][j];
					if (!g[i][j] || g[i][j]>d)
						g[i][j] = d;
				}
	int d = 0;
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			if (g[i][j]>d)
				d = g[i][j];
	return d+1;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




Compiler output:
main.c:4:10: fatal error: map: No such file or directory
    4 | #include <map>
      |          ^~~~~
compilation terminated.
Language: C++

#include <cstdio>
int main() {
  cout << -1 << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cout' was not declared in this scope
    3 |   cout << -1 << endl;
      |   ^~~~
a.cc:3:17: error: 'endl' was not declared in this scope
    3 |   cout << -1 << endl;
      |                 ^~~~
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        // graph list
        LinkedList<ArrayList<Integer>> edge_2 = new LinkedList<ArrayList<Integer>>();
        for (int i=0;i<N;i++) {
            ArrayList<Integer> add = new ArrayList<Integer>();
            edge_2.add(add);
        }
        ArrayList<ArrayList<Integer>> edge = new ArrayList<ArrayList<Integer>>(edge_2);
      

        //graph matrix
        char[][] graph = new char[N][N];
        for (int i=0;i<N;i++) {
            String S = sc.next();
            for (int j=0;j<N;j++) {
                char flag = S.charAt(j);
                graph[i][j] = flag;

                // graph list add
                if (flag=='1') {
                    edge.get(i).add(j);
                }
            }
        }
        int flag = 0;
        int tmp_depth = 0;

        loop:for (int j=0;j<N;j++) {
            int[] used = new int[N];
            for (int i=0;i<N;i++) {
                used[i] = -1;
            }
            int root = j;
            ArrayDeque<int[]> queue = new ArrayDeque<int[]>();
            int[] add = {root, 0};
            queue.add(add);
            while (!queue.isEmpty()) {
                int[] rem = queue.remove();int index = rem[0];int depth = rem[1];
                // System.out.println("rem : " + Arrays.toString(rem));
                tmp_depth = Math.max(tmp_depth, depth);
                used[index] = depth;
                LinkedList<Integer> edge_list = edge.get(index);
                for (Integer i : edge_list) {
                    if (used[i]==-1) {
                        int[] add_q = {i, depth+1};
                        queue.add(add_q);
                    } else if (used[i]!=depth-1) {
                        flag=1;
                        break loop;
                    }
                }
            }
        }
        if (flag==1) {
            System.out.println(-1);
        } else {
            System.out.println(tmp_depth+1);
        }

        // for (ArrayList<Integer> aaa : edge) {
            // System.out.println(aaa);
        // }
        // System.out.println("used " + Arrays.toString(used));
    }
}


Compiler output:
Main.java:48: error: incompatible types: ArrayList<Integer> cannot be converted to LinkedList<Integer>
                LinkedList<Integer> edge_list = edge.get(index);
                                                        ^
1 error
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<int> G[210];
int N,maxi=-1;
char a;

int check(int start){
    int visited[N];
    rep(i,N){
        visited[i]=-1;
    }
    queue<int> q;
    q.push(start);
  	visited[start]=1;
    while(q.size()!=0){
        int now = q.front();
        q.pop();
        for(int next:G[now]){
            if(visited[next]==-1){
                visited[next]=visited[now]+1
                q.push(next);
            }
            else{
                if(visited[next]==(visited[now]-1))continue;
                else return -1;
            }
        }
    }
    return visited[now];

}

int main(){
    cin>>N;
    rep(i,N){
        rep(j,N){
            cin>>a;
            if(a=='1')G[i].push_back(j);
        }
    }
    rep(i,N){
        maxi = max(maxi,check(i));
    }
    out(maxi);
    

}


Compiler output:
a.cc: In function 'int check(int)':
a.cc:43:45: error: expected ';' before 'q'
   43 |                 visited[next]=visited[now]+1
      |                                             ^
      |                                             ;
   44 |                 q.push(next);
      |                 ~                            
a.cc:52:20: error: 'now' was not declared in this scope; did you mean 'pow'?
   52 |     return visited[now];
      |                    ^~~
      |                    pow
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<int> G[210];
int N,maxi=-1;
char a;

int check(int start){
    int visited[N];
    rep(i,N){
        visited[i]=-1;
    }
    queue<int> q;
    q.push(start);
  	visited[start]=1;
    while(q.size()!=0){
        int now = q.front();
        q.pop();
        for(int next:G[p.first]){
            if(visited[next]==-1){
                visited[next]=visited[now]+1
                q.push(next);
            }
            else{
                if(visited[next]==(visited[now]-1))continue;
                else return -1;
            }
        }
    }
    return visited[now];

}

int main(){
    cin>>N;
    rep(i,N){
        rep(j,N){
            cin>>a;
            if(a=='1')G[i].push_back(j);
        }
    }
    rep(i,N){
        maxi = max(maxi,check(i));
    }
    out(maxi);
    

}


Compiler output:
a.cc: In function 'int check(int)':
a.cc:41:24: error: 'p' was not declared in this scope
   41 |         for(int next:G[p.first]){
      |                        ^
a.cc:43:45: error: expected ';' before 'q'
   43 |                 visited[next]=visited[now]+1
      |                                             ^
      |                                             ;
   44 |                 q.push(next);
      |                 ~                            
a.cc:52:20: error: 'now' was not declared in this scope; did you mean 'pow'?
   52 |     return visited[now];
      |                    ^~~
      |                    pow
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const int N = 200;
    const int INF = 1e8;
    int n; cin >> n;
    vector<string> s(n);
    REP(i,n) cin >> s[i];
    int ans = 0;

    vector<vector<int>> d(n,vector<int>(n,INF));
    REP(i,n) d[i][i] = 0;
    // 2部グラフ判定
    bitset<N> b1{1}, b2;
    REP(i,n) {
        bitset<N> b;
        REP(j,s[i].size()) {
            if (s[i][j] == '1') {
                b[j] = true;
            }
        if (b1[i]) b2 |= b;
        else b1 |= b;
    }

    bool can = true;
    if ((b1 & b2) != 0) can = false;
	REP(i,n)REP(j,n)d[i][j]=(s[i][j]=='1'?1:1e9);
	REP(i,n)d[i][i]=0;
	REP(k,n) {
		REP(i,n) {
			REP(j,n) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	REP(i,n)REP(j,n)ans=max(ans,d[i][j]);
	cout<<(can?ans+1:-1)<<endl;
	return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const int N = 200;
    const int INF = 1e8;
    int n; cin >> n;
    vector<string> s(n);
    REP(i,n) cin >> s[i];
    int ans = 0;

    vector<vector<int>> d(n,vector<int>(n,INF));
    REP(i,n) v[i][i] = 0;
    // 2部グラフ判定
    bitset<N> b1{1}, b2;
    REP(i,n) {
        bitset<N> b;
        REP(j,s[i].size()) {
            if (s[i][j] == '1') {
                b[j] = true;
            }
        if (b1[i]) b2 |= b;
        else b1 |= b;
    }

    bool can = true;
    if ((b1 & b2) != 0) can = false;
	rep(i,n)rep(j,n)d[i][j]=(s[i][j]=='1'?1:1e9);
	rep(i,n)d[i][i]=0;
	rep(k,n) {
		rep(i,n) {
			rep(j,n) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	rep(i,n)rep(j,n)ans=max(ans,d[i][j]);
	cout<<(can?ans+1:-1)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:14: error: 'v' was not declared in this scope
   25 |     REP(i,n) v[i][i] = 0;
      |              ^
a.cc:40:9: error: 'rep' was not declared in this scope
   40 |         rep(i,n)rep(j,n)d[i][j]=(s[i][j]=='1'?1:1e9);
      |         ^~~
a.cc:42:13: error: 'k' was not declared in this scope
   42 |         rep(k,n) {
      |             ^
a.cc:52:2: error: expected '}' at end of input
   52 | }
      |  ^
a.cc:15:1: note: to match this '{'
   15 | {
      | ^
Language: C++

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

vector<int> g[222];
int c[222] = {};
bool used[222] = {};

void dfs(int now, int color){
  if(used[now]) return;
  used[now] = true;
  c[now] = color;
  for(auto p: g[now]){
    if(c[p] == color){
      cout << -1;
      exit(0);
    }
    dfs(p, 3 - color);
  }
}

int main(){
    int n;
    string s;
    cin >> n;
  　if(n==2){cout<<2;return 0;}
    int dist[222][222]={};
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)dist[i][j]=100000;
    for(int i=0;i<n;i++){
      cin >> s;
      for(int j = 0; j < n; j++){
        if(s[j] == '1'){
        	 g[i].push_back(j);
             dist[i][j]=dist[j][i]=1;
        }
      }
    }
    dfs(0, 1);
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)for(int k=0;k<n;k++)dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
    int res=0;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)res=max(res,dist[i][j]);
    cout<<res+1<<endl;
}


Compiler output:
a.cc:25:3: error: extended character 　 is not valid in an identifier
   25 |   　if(n==2){cout<<2;return 0;}
      |   ^
a.cc: In function 'int main()':
a.cc:25:3: error: '\U00003000if' was not declared in this scope
   25 |   　if(n==2){cout<<2;return 0;}
      |   ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000

// 条件を満たすような分割が出来る=>2部グラフになっている
// もし2部グラフでないなら、分割不可。2部グラフならグラフの直径+1が最大分割数となる
int main() {
    int n;
    cin >> n;
    vector<vector<int>> s(n, vector<int>(n));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
          #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;  char c;
          
            cin >> c;
            if (c == '0') s[i][j] = INF;
            else s[i][j] = 1;
        }
    }

    for (int k = 0; k < s.size(); k++) {
        for (int i = 0; i < s.size(); i++) {
            for (int j = 0; j < s.size(); j++) {
                if (s[i][k] == INF || s[k][j] == INF)
                    continue;
                s[i][j] = min(s[i][j], s[i][k] + s[k][j]);
            }
        }
    }

    set<vector<int>> sv;
    int diam = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j)
                diam = max(s[i][j], diam);
            s[i][j] = s[i][j] % 2;
        }
        sv.insert(s[i]);
    }

    int k;
    if (sv.size() != 2) k = -1;
    else k = diam + 1;
    cout << k << endl;
    return 0;
}


Compiler output:
a.cc:9:1: error: expected ',' or ';' before 'int'
    9 | int main() {
      | ^~~