alexjercan/bugnet huggingface dataset:
Problem p02573 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> a[200500];
int used[200500];
int n, m;
int c = 0;
void dfs(int i) {
  used[i] = 1;
  c++;
  for (auto f : a[i]) {
    if (used[f] == 0)
      dfs(f);
  }
}

void solve() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  int k = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i].empty())
      k++;
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    if (used[i] == 0) {
      c = 0;
      dfs(i);
      mx = max(mx, c);
    }
  }
  cout << mx;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  // cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> a[200500];
int used[200500];
int n, m;
int c = 0;
int dfs(int i) {
  used[i] = 1;
  c++;
  for (auto f : a[i]) {
    if (used[f] == 0)
      dfs(f);
  }
}
void solve() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  int cnt = 0;
  int k = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i].empty())
      k++;
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    if (used[i] == 0) {
      c = 0;
      dfs(i);
      mx = max(mx, c);
    }
  }
  cout << mx;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  // cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
}
Problem p02573 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long double pi = acos(-1);
#define x first
#define y second
#define read(n, a)                                                             \\
  for (int i = 0; i < n; i++)                                                  \\
    cin >> a[i];
#define rep(z, n) for (int i = z; i < n; i++)

// pair<int,int> a[200002]={};
// ll b[200003]={};
ll n, m;
#define MAXNODES 200000 + 9
#define PB push_back
typedef vector<int> vi;
vector<vi> edges(MAXNODES);
bool visited[MAXNODES];
int dfs(int node) {
  int ans = 0;
  visited[node] = true;
  for (int neighbor : edges[node]) {
    if (!visited[neighbor]) {
      ans++;
      ans += dfs(neighbor);
    }
  }
  return ans;
}
// vector<set<int> >v(200002);
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  /// freopen("ss.txt","r",stdin);
  /// freopen("out.txt","w",stdout);
  int t = 1;
  // cin>>t;
  while (t--) {
    cin >> n >> m;
    rep(0, m) {
      int u, v;
      cin >> u >> v;
      edges[u].PB(v);
      edges[v].PB(u);
    }
    ll ans = 0;
    rep(1, n + 1) {
      if (!visited[i]) {
        ans = max(ans, (ll)dfs(i) + 1);
      }
    }
    cout << ans;
  }
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long double pi = acos(-1);
#define x first
#define y second
#define read(n, a)                                                             \\
  for (int i = 0; i < n; i++)                                                  \\
    cin >> a[i];
#define rep(z, n) for (int i = z; i < n; i++)

// pair<int,int> a[200002]={};
// ll b[200003]={};
ll n, m;
#define MAXNODES 100000 + 9
#define PB push_back
typedef vector<int> vi;
vector<vi> edges(MAXNODES);
bool visited[MAXNODES];
int dfs(int node) {
  int ans = 0;
  visited[node] = true;
  for (int neighbor : edges[node]) {
    if (!visited[neighbor]) {
      ans++;
      ans += dfs(neighbor);
    }
  }
  return ans;
}
// vector<set<int> >v(200002);
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  /// freopen("ss.txt","r",stdin);
  /// freopen("out.txt","w",stdout);
  int t = 1;
  // cin>>t;
  while (t--) {
    cin >> n >> m;
    rep(0, m) {
      int u, v;
      cin >> u >> v;
      edges[u].PB(v);
      edges[v].PB(u);
    }
    ll ans = 0;
    rep(1, n + 1) {
      if (!visited[i]) {
        ans = max(ans, (ll)dfs(i) + 1);
      }
    }
    cout << ans;
  }
  return 0;
}
Problem p02573 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
bool vis[200005];
vector<ll> gr[200005];

ll dfs(ll u) {
  vis[u] = true;
  ll ans = 1;
  for (auto v : gr[u]) {
    if (!vis[v]) {
      ans += dfs(v);
    }
  }
  return ans;
}

int main() {
  ll n, m;
  cin >> n >> m;
  memset(vis, false, sizeof(vis));

  ll a, b;
  map<pair<ll, ll>, ll> ma;
  while (m--) {
    cin >> a >> b;
    if (a > b)
      swap(a, b);
    if (!ma[{a, b}]) {
      gr[a].push_back(b);
      gr[b].push_back(a);
    }
  }
  ll mx = 0;
  for (ll i = 1; i <= n; ++i) {
    if (vis[i] == false) {
      mx = max(mx, dfs(i));
    }
  }
  cout << mx << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
bool vis[100005];
vector<ll> gr[100005];

ll dfs(ll u) {
  vis[u] = true;
  ll ans = 1;
  for (auto v : gr[u]) {
    if (!vis[v]) {
      ans += dfs(v);
    }
  }
  return ans;
}

int main() {
  ll n, m;
  cin >> n >> m;
  memset(vis, false, sizeof(vis));

  ll a, b;
  map<pair<ll, ll>, ll> ma;
  while (m--) {
    cin >> a >> b;
    if (a > b)
      swap(a, b);
    if (!ma[{a, b}]) {
      gr[a].push_back(b);
      gr[b].push_back(a);
    }
  }
  ll mx = 0;
  for (ll i = 1; i <= n; ++i) {
    if (vis[i] == false) {
      mx = max(mx, dfs(i));
    }
  }
  cout << mx << endl;
}
Problem p02573 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, -1, 0, 1};
const int LIT = 1e9 + 7;
int n, m;

vector<int> Map[200001];
set<pair<int, int>> s;

void solve() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b)
      swap(a, b);
    if (s.count({a, b}) == 0) {
      s.insert({a, b});
      Map[a].push_back(b);
      Map[b].push_back(a);
    }
  }

  vector<bool> bfs_visited(n + 1, false);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int cnt = 1;
    if (!bfs_visited[i]) {
      queue<int> q;
      q.push(i);
      bfs_visited[i] = true;
      while (!q.empty()) {
        int cur = q.front();
        q.pop();

        for (int j = 0; j < Map[cur].size(); j++) {
          if (!bfs_visited[Map[cur][j]]) {
            bfs_visited[Map[cur][j]] = true;
            cnt++;
            q.push(Map[cur][j]);
          }
        }
      }
    }
    ans = max(ans, cnt);
  }

  cout << ans;
}

int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, -1, 0, 1};
const int LIT = 1e9 + 7;
int n, m;

vector<int> Map[20001];
set<pair<int, int>> s;

void solve() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b)
      swap(a, b);
    if (s.count({a, b}) == 0) {
      s.insert({a, b});
      Map[a].push_back(b);
      Map[b].push_back(a);
    }
  }

  vector<bool> bfs_visited(n + 1, false);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int cnt = 1;
    if (!bfs_visited[i]) {
      queue<int> q;
      q.push(i);
      bfs_visited[i] = true;
      while (!q.empty()) {
        int cur = q.front();
        q.pop();

        for (int j = 0; j < Map[cur].size(); j++) {
          if (!bfs_visited[Map[cur][j]]) {
            bfs_visited[Map[cur][j]] = true;
            cnt++;
            q.push(Map[cur][j]);
          }
        }
      }
    }
    ans = max(ans, cnt);
  }

  cout << ans;
}

int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
Problem p02573 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <time.h>
#include <vector>
#define h 200010
#define lli long long int
#define pb push_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
using namespace std;
vector<lli> par(h);
lli func(lli a) {
  if (par[a] == a)
    return a;
  else
    return par[a] = func(par[a]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli n, e, i, x, y, u, v, ans = 0, l = 0, cnt;
  set<lli> c;
  cin >> n >> e;
  for (i = 0; i <= n; i++)
    par[i] = i;
  for (i = 0; i < e; i++) {
    cin >> x >> y;
    u = func(x);
    v = func(y);
    if (u != v)
      par[u] = v;
  }
  for (i = 1; i <= n; i++)
    u = func(i);
  sort(par.begin() + 1, par.begin() + n + 1);
  cnt = 1;
  for (i = 1; i <= n; i++) {
    c.insert(par[i]);
    if (l == c.size())
      cnt += 1;
    else {
      l += 1;
      ans = max(ans, cnt);
      cnt = 1;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;
  return 0;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <time.h>
#include <vector>
#define h 200010
#define lli long long int
#define pb push_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
using namespace std;
vector<lli> par(h);
lli func(lli a) {
  if (par[a] == a)
    return a;
  else
    par[a] = func(par[a]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli n, e, i, x, y, u, v, ans = 0, l = 0, cnt;
  set<lli> c;
  cin >> n >> e;
  for (i = 0; i <= n; i++)
    par[i] = i;
  for (i = 0; i < e; i++) {
    cin >> x >> y;
    u = func(x);
    v = func(y);
    if (u != v)
      par[u] = v;
  }
  for (i = 1; i <= n; i++)
    u = func(i);
  sort(par.begin() + 1, par.begin() + n + 1);
  cnt = 1;
  for (i = 1; i <= n; i++) {
    c.insert(par[i]);
    if (l == c.size())
      cnt += 1;
    else {
      l += 1;
      ans = max(ans, cnt);
      cnt = 1;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;
  return 0;
}
Problem p02573 (C++) — buggy submission, verdict: Runtime Error

/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\\n"
#define ll long long int
#define TestCases                                                              \\
  int T;                                                                       \\
  cin >> T;                                                                    \\
  while (T--)
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define revrep(i, a, b) for (ll i = b - 1; i >= a; i--)
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define mp(x, y) make_pair(x, y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(), c.end()
#define alld(c) c.begin(), c.end(), greater<int>()
#define mem(a, val) memset(a, val, sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}

ll maxi = 0;
bool visited[1000000];
vector<ll> G[1000000];

void dfs(int x) {
  visited[x] = true;

  for (auto &i : G[x]) {
    if (visited[i] == false) {
      dfs(i);
      maxi++;
    }
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  ll m;
  cin >> n >> m;

  rep(i, 0, m) {
    ll x, y;
    cin >> x >> y;
    G[x].pb(y);
    G[y].pb(x);
  }

  ll cnt = -1;

  rep(i, 1, n + 1) {
    if (!visited[i])
      dfs(i);
    cnt = max(cnt, maxi);
    maxi = 0;
  }
  cout << cnt + 1;
  return 0;
}


Error: WA

Fixed submission:

/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\\n"
#define ll long long int
#define TestCases                                                              \\
  int T;                                                                       \\
  cin >> T;                                                                    \\
  while (T--)
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define revrep(i, a, b) for (ll i = b - 1; i >= a; i--)
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define mp(x, y) make_pair(x, y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(), c.end()
#define alld(c) c.begin(), c.end(), greater<int>()
#define mem(a, val) memset(a, val, sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}

ll maxi = 0;
bool visited[100000];
vector<ll> G[100000];

void dfs(int x) {
  visited[x] = true;

  for (auto &i : G[x]) {
    if (visited[i] == false) {
      dfs(i);
      maxi++;
    }
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  ll m;
  cin >> n >> m;

  rep(i, 0, m) {
    ll x, y;
    cin >> x >> y;
    G[x].pb(y);
    G[y].pb(x);
  }

  ll cnt = -1;

  rep(i, 1, n + 1) {
    if (!visited[i])
      dfs(i);
    cnt = max(cnt, maxi);
    maxi = 0;
  }
  cout << cnt + 1;
  return 0;
}
Problem p02573 (C++) — buggy submission, verdict: Runtime Error

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

#define ll long long int

const int md = 1e9 + 7;
ll Parent[200005];
ll sze[200005];

void Build(int n) {
  for (ll i = 1; i <= n; i++) {
    Parent[i] = i;
    sze[i] = 1;
  }
}

ll find(ll u) {
  if (Parent[u] == u)
    return u;
  else {
    return Parent[u] = find(Parent[u]);
  }
}

void Union(ll a, ll b) {
  ll P_a = find(a);
  ll P_b = find(b);

  if (P_a != P_b) {
    sze[P_b] += sze[P_a];
    Parent[P_a] = Parent[P_b];
  }
}

int main() {
  ll n, m;
  cin >> n >> m;

  // std::vector<Edge> E(m) ;
  Build(n);

  // for(ll i=0;i<m;i++)
  // {
  //     cin>>E[i].src;
  //     E[i].src--;
  //     cin>>E[i].dest;
  //     E[i].dest--;
  //     cin>>E[i].wt;
  // }

  for (int i = 0; i < m; i++) {
    ll x, y;
    cin >> x >> y;
    Union(x, y);
  }

  unordered_map<int, int> mp;
  ll mx = 0;

  for (int i = 1; i <= n; i++) {
    int p = find(i);
    // cout<<p<<endl;
    if (mp.find(p) == mp.end()) {
      mp[p] = 1;
      mx = max(mx, sze[p]);
    }
  }

  cout << mx << endl;
}


Error: 0

Fixed submission:

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

#define ll long long int

const int md = 1e9 + 7;
ll Parent[100000];
ll sze[100000];

void Build(int n) {
  for (ll i = 1; i <= n; i++) {
    Parent[i] = i;
    sze[i] = 1;
  }
}

ll find(ll u) {
  if (Parent[u] == u)
    return u;
  else {
    return Parent[u] = find(Parent[u]);
  }
}

void Union(ll a, ll b) {
  ll P_a = find(a);
  ll P_b = find(b);

  if (P_a != P_b) {
    sze[P_b] += sze[P_a];
    Parent[P_a] = Parent[P_b];
  }
}

int main() {
  ll n, m;
  cin >> n >> m;

  // std::vector<Edge> E(m) ;
  Build(n);

  // for(ll i=0;i<m;i++)
  // {
  //     cin>>E[i].src;
  //     E[i].src--;
  //     cin>>E[i].dest;
  //     E[i].dest--;
  //     cin>>E[i].wt;
  // }

  for (int i = 0; i < m; i++) {
    ll x, y;
    cin >> x >> y;
    Union(x, y);
  }

  unordered_map<int, int> mp;
  ll mx = 0;

  for (int i = 1; i <= n; i++) {
    int p = find(i);
    // cout<<p<<endl;
    if (mp.find(p) == mp.end()) {
      mp[p] = 1;
      mx = max(mx, sze[p]);
    }
  }

  cout << mx << endl;
}
Problem p02573 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define ll long long
using namespace std;
const int MAXN = 300010;
int Numsets;
int Parent[MAXN], Rank[MAXN], Sizes[MAXN];

void initSet(int n) {
  for (int i = 0; i < n; i++) {
    Parent[i] = i;
    Rank[i] = 0;
    Sizes[i] = 1;
  }
  Numsets = n;
}

int findSet(int i) {
  return Parent[i] == i ? i : Parent[i] = findSet(Parent[i]);
}

bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }

void unionSet(int i, int j) {
  if (!isSameSet(i, j)) {
    Numsets--;
    int x = findSet(i), y = findSet(j);
    if (Rank[x] > Rank[y]) {
      Parent[y] = x;
      Sizes[x] += Sizes[y];
    } else {
      Parent[x] = y;
      Sizes[y] += Sizes[x];
      if (Rank[x] == Rank[y])
        Rank[y]++;
    }
  }
}

int numDisjoinSets() { return Numsets; }

int sizeOfSet(int i) { return Sizes[findSet(i)]; }
int main() {
  // fast;
  int n, m, a, b, ans = -1e9;
  cin >> n >> m;
  initSet(n);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--, b--;
    unionSet(a, b);
  }
  for (int i = 0; i < n; i++)
    ans = max(ans, sizeOfSet(i));
  cout << ans << "\\n";
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define ll long long
using namespace std;
const int MAXN = 100010;
int Numsets;
int Parent[MAXN], Rank[MAXN], Sizes[MAXN];

void initSet(int n) {
  for (int i = 0; i < n; i++) {
    Parent[i] = i;
    Rank[i] = 0;
    Sizes[i] = 1;
  }
  Numsets = n;
}

int findSet(int i) {
  return Parent[i] == i ? i : Parent[i] = findSet(Parent[i]);
}

bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }

void unionSet(int i, int j) {
  if (!isSameSet(i, j)) {
    Numsets--;
    int x = findSet(i), y = findSet(j);
    if (Rank[x] > Rank[y]) {
      Parent[y] = x;
      Sizes[x] += Sizes[y];
    } else {
      Parent[x] = y;
      Sizes[y] += Sizes[x];
      if (Rank[x] == Rank[y])
        Rank[y]++;
    }
  }
}

int numDisjoinSets() { return Numsets; }

int sizeOfSet(int i) { return Sizes[findSet(i)]; }
int main() {
  // fast;
  int n, m, a, b, ans = -1e9;
  cin >> n >> m;
  initSet(n);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--, b--;
    unionSet(a, b);
    ans = max(ans, sizeOfSet(a));
    ans = max(ans, sizeOfSet(b));
  }
  cout << ans << "\\n";
  return 0;
}
Problem p02573 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int fin = 0, ans = 0;
bool vis[200050];
vector<int> v[200050];
int dfs(int x) {
  if (vis[x])
    return 0;
  vis[x] = true;
  ans++;
  for (auto it : v[x])
    if (!vis[it])
      dfs(it);
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  memset(vis, false, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ans = 0;
      dfs(i);
    }
    fin = max(fin, ans);
  }
  cout << fin;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int fin = 0, ans = 0;
bool vis[200050];
vector<int> v[200050];
int dfs(int x) {
  if (vis[x])
    return 0;
  vis[x] = true;
  ans++;
  for (auto it : v[x])
    if (!vis[it])
      dfs(it);
}
int main() {
  int n, m;
  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  memset(vis, false, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ans = 0;
      dfs(i);
    }
    fin = max(fin, ans);
  }
  cout << fin;
}
Problem p02573 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long int
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define io                                                                     \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define N 200005
#define mod 1000000007
using namespace std;
vector<int> adj[N];
bool vis[N];
int c = 0;
map<pii, bool> mp;
void dfs(int x) {
  vis[x] = 1;
  c++;
  for (int i = 0; i < adj[x].size(); i++) {
    int y = adj[x][i];
    if (vis[y])
      continue;
    dfs(y);
  }
}
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (mp[{x, y}])
      continue;
    mp[{x, y}] = mp[{y, x}] = 1;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    c = 0;
    if (!vis[i])
      dfs(i);
    ans = max(ans, c);
  }
  cout << ans;
}
int main() {
  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define io                                                                     \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define N 200005
#define mod 1000000007
using namespace std;
vector<int> adj[N];
bool vis[N];
int c = 0;
int dfs(int x) {
  vis[x] = 1;
  c++;
  for (int i = 0; i < adj[x].size(); i++) {
    int y = adj[x][i];
    if (vis[y])
      continue;
    dfs(y);
  }
}
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    c = 0;
    if (!vis[i])
      dfs(i);
    ans = max(ans, c);
  }
  cout << ans;
}
int main() {
  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
  return 0;
}