Problem p02573 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
#define pb push_back
#define fi(n) for (int i = 0; i < n; i++)
#define fi1(n) for (int i = 1; i < n; i++)
#define fj(n) for (int j = 0; j < n; j++)
#define clr(x) memset(x, 0, sizeof(x))
#define print(x)                                                               \\
  for (auto a : x)                                                             \\
    cout << a << " ";                                                          \\
  cout << "\\n"
#define nl "\\n"
#define vi vector<int>
#define si set<int>
#define mp make_pair
#define pairi pair<int, int>
#define vpairi vector<pair<int, int>>
#define ff first
#define ss second
#define inf 1e9 + 10
#define input                                                                  \\
  "C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//input.txt"
#define output                                                                 \\
  "C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//output.txt"
#define error                                                                  \\
  "C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//error.txt"

int ctoi(char a) {
  int x = a - 48 - 49;
  return x;
}
string itos(int a) {
  string out_string;
  stringstream ss;
  ss << a;
  out_string = ss.str();
  return out_string;
}
char itoc(int a) { return itos(a)[0]; }
int pow(int e, int x) {
  int ans = 1;
  while (x > 0) {
    if (x & 1)
      ans *= e;
    e *= e;
    x >>= 1;
  }
  return ans;
}
string bin(int x) {
  bitset<sizeof(1) * CHAR_BIT> bits(x);
  string b = bits.to_string();
  return b;
}

vi a(200005);
vi parent(200005);

int find(int x) {
  if (parent[x] == -1)
    return x;
  else
    return parent[x] = find(parent[x]);
}

void union1(int x, int y) {
  int a1 = find(x);
  int b = find(y);
  if (a1 != b) {
    parent[a1] = b;
    a[b] += a[a1];
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen(input, "r", stdin);
  freopen(output, "w", stdout);
  freopen(error, "w", stderr);
#endif
  int T = 1;
  // cin>>T;
  while (T--) {
    int n, k, m, x, y, z;
    cin >> n >> m;
    // vi a(n);
    // fi(n) cin>>a[i];
    // vi a(n);
    // vi parent(n);
    fi(n) {
      parent[i] = -1;
      a[i] = 1;
    }
    fi(m) {
      cin >> x >> y;
      union1(x - 1, y - 1);
      // print(a);
    }
    int ans = -1;
    fi(n) { ans = max(ans, a[i]); }
    cout << ans << nl;
  }
  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
#define pb push_back
#define fi(n) for (int i = 0; i < n; i++)
#define fi1(n) for (int i = 1; i < n; i++)
#define fj(n) for (int j = 0; j < n; j++)
#define clr(x) memset(x, 0, sizeof(x))
#define print(x)                                                               \\
  for (auto a : x)                                                             \\
    cout << a << " ";                                                          \\
  cout << "\\n"
#define nl "\\n"
#define vi vector<int>
#define si set<int>
#define mp make_pair
#define pairi pair<int, int>
#define vpairi vector<pair<int, int>>
#define ff first
#define ss second
#define inf 1e9 + 10
#define input                                                                  \\
  "C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//input.txt"
#define output                                                                 \\
  "C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//output.txt"
#define error                                                                  \\
  "C://Users//Piyush Aggarwal//Documents//Cpp files//input-output//error.txt"

int ctoi(char a) {
  int x = a - 48 - 49;
  return x;
}
string itos(int a) {
  string out_string;
  stringstream ss;
  ss << a;
  out_string = ss.str();
  return out_string;
}
char itoc(int a) { return itos(a)[0]; }
int pow(int e, int x) {
  int ans = 1;
  while (x > 0) {
    if (x & 1)
      ans *= e;
    e *= e;
    x >>= 1;
  }
  return ans;
}
string bin(int x) {
  bitset<sizeof(1) * CHAR_BIT> bits(x);
  string b = bits.to_string();
  return b;
}

vi a(100005);
vi parent(100005);

int find(int x) {
  if (parent[x] == -1)
    return x;
  else
    return parent[x] = find(parent[x]);
}

void union1(int x, int y) {
  int a1 = find(x);
  int b = find(y);
  if (a1 != b) {
    parent[a1] = b;
    a[b] += a[a1];
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen(input, "r", stdin);
  freopen(output, "w", stdout);
  freopen(error, "w", stderr);
#endif
  int T = 1;
  // cin>>T;
  while (T--) {
    int n, k, m, x, y, z;
    cin >> n >> m;
    // vi a(n);
    // fi(n) cin>>a[i];
    // vi a(n);
    // vi parent(n);
    fi(n) {
      parent[i] = -1;
      a[i] = 1;
    }
    fi(m) {
      cin >> x >> y;
      union1(x - 1, y - 1);
      // print(a);
    }
    int ans = -1;
    fi(n) { ans = max(ans, a[i]); }
    cout << ans << nl;
  }
  return 0;
}