qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n= int(input())
a= [int(i) for i in input().split()]
pref=[0]*n
pref[0] = a[0]%m
for i in range(1,n):
    pref[i] =  (pref[i-1]+a[i])%m
m = 10**9+7
ans = 0
#print(pref)
for i in range(n-1):
    ans+= (a[i]%m *((pref[n-1]-pref[i])%m))%m
    ans = ans%m
print(ans)
#437235829

Fixed code:
n= int(input())
a= [int(i) for i in input().split()]
pref=[0]*n
m = 10**9+7
pref[0] = a[0]%m
for i in range(1,n):
    pref[i] =  (pref[i-1]+a[i])%m
m = 10**9+7
ans = 0
#print(pref)
for i in range(n-1):
    ans+= (a[i]%m *((pref[n-1]-pref[i])%m))%m
    ans = ans%m
print(ans)
Buggy code:
n = int(input())
mod = 10 ** 9 + 7
import numpy as np
a = list(map(int, input().split()))
s=0
ss=0
for i in range(n):
    if i > 0:
        ss += a[i-1]%mod
    s += ss * a[i] % mod
print(s)


Fixed code:
n = int(input())
mod = 10 ** 9 + 7
import numpy as np
a = list(map(int, input().split()))
s=0
ss=0
for i in range(n):
    if i > 0:
        ss += a[i-1]%mod
    s += ss * a[i] % mod
print(s%mod)
Buggy code:
N=int(input())
A=list(map(int,input().split()))
ans = 0
last = 0

for i in range(N):
    ans += A[i]
last += sum(A)
last -= ans
last //= 2
print(last % 1000000007)

Fixed code:
N=int(input())
A=list(map(int,input().split()))
ans = 0
last = 0

for i in range(N):
    ans += A[i]*A[i]
last += sum(A)*sum(A)
last -= ans
last //= 2
print(last % 1000000007)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
x=0
for i in range(0,n-1):
  x+=a[i]
y=0
for j in range(1,n):
  y+=a[j]
z=x+y
print(z%(10**9+7))

Fixed code:
n=int(input())
a=list(map(int,input().split()))
x=0
for i in range(n):
  x+=a[i]
x=x**2
y=0
for j in range(n):
  y+=a[j]**2
z=(x-y)//2
print(z%(10**9+7))
Buggy code:
import decimal
n = int(input())
a = list(map(int, input().split())) 

first = a[0]

ans = first*a[1]

print(ans)
for i in range(1, n-1):
    first += a[i]
    ans += first*a[i+1]

print(ans%(10**9+7))

Fixed code:
# import decimal
n = int(input())
a = list(map(int, input().split())) 

first = a[0]

ans = first*a[1]

for i in range(1, n-1):
    first += a[i]
    ans += first*a[i+1]

print(ans%(10**9+7))
Buggy code:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

ans = 0
for i in range(N - 1):
    ans += (A[i] * A[i + 1])
    ans %= mod

ans += (A[0] * A[-1])

print(ans % mod)


Fixed code:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

ans = 0
total = sum(A)
for i in range(N - 1):
    total -= A[i]
    ans += (A[i] * total) 

print(ans % mod)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
for i in range(n-1):
  ans=ans+(a[i]*(sum(a[i+1:n])%mod))%mod
print(ans)

Fixed code:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
s=sum(a[1:n])
for i in range(n-1):
  ans=(ans+(a[i]*(s%mod))%mod)%mod
  s=s-a[i+1]
print(ans)
Buggy code:
mod = 10 ** 9 + 7
n = int(input())
a_list = list(map(int, input().split()))
result = 0
a_sum = sum(a)
for i in a_list:
    a_sum -= i
    result += i * a_sum
print(result % mod)

Fixed code:
mod = 10 ** 9 + 7
n = int(input())
a_list = list(map(int, input().split()))
result = 0
a_sum = sum(a_list)
for i in a_list:
    a_sum -= i
    result += i * a_sum
print(result % mod)
Buggy code:
def main():
    mod = 10**9+7
    #n,a = get_input()
    n = int(input())
    a = [int(x) for x in input().split()]
    aa = [a**2 % mod for x in a]
    ans = 0
    asum = sum(a) 
    p = asum ** 2 % mod
    q = sum(aa) % mod
    ans = (p - q) % mod
    if ans < 0:
      ans += mod
    if ans % 2 == 1:
      ans += mod
    ans = ans // 2
    print(ans)
    
if __name__ == '__main__':
    main()

Fixed code:
def main():
    mod = 10**9+7
    #n,a = get_input()
    n = int(input())
    a = [int(x) for x in input().split()]
    aa = [x**2 % mod for x in a]
    ans = 0
    asum = sum(a) 
    p = asum ** 2 % mod
    q = sum(aa) % mod
    ans = (p - q) % mod
    if ans < 0:
      ans += mod
    if ans % 2 == 1:
      ans += mod
    ans = ans // 2
    print(ans)
    
if __name__ == '__main__':
    main()
Buggy code:
def main():
    mod = 10**9+7
    #n,a = get_input()
    n = int(input())
    a = [int() for x in input().split()]
    ans = 0
    asum = sum(a) 
    for i in range(n):
        asum = asum - a[i]
        ans = ( ans + ((a[i] * asum) % mod)) % mod
    
    print(ans)
    
if __name__ == '__main__':
    main()

Fixed code:
def main():
    mod = 10**9+7
    #n,a = get_input()
    n = int(input())
    a = [int(x) for x in input().split()]
    ans = 0
    asum = sum(a) 
    for i in range(n):
        asum = asum - a[i]
        ans = ( ans + ((a[i] * asum) % mod)) % mod
    
    print(ans)
    
if __name__ == '__main__':
    main()
Buggy code:
L=[int(x) for x in input().split()]
sum=0
product=0
mod=1000000007
for i in range(n):
    sum+=L[i]%mod
for i in range(n-1):
    sum-=(L[i]%mod)
    product+=sum*(L[i]%mod)
print(product)


Fixed code:
n=int(input())
L=[int(x) for x in input().split()]
sum=0
product=0
mod=1000000007
for i in range(n):
    sum+=L[i]%mod
for i in range(n-1):
    sum-=(L[i]%mod)
    product+=sum*(L[i]%mod)
print(product%mod)
Buggy code:
N=input()
A=list(map(int,input().split()))
count1=0
count2=0
for a in A[0:]:
    count1=count1+a
    count2=count2+a**2

B=(count1**2-count2)/2
C=B%(10**9+7)
print(C)

Fixed code:
N=input()
A=list(map(int,input().split()))
count1=0
count2=0
for a in A[0:]:
    count1=count1+a
    count2=count2+a**2

B=(count1**2-count2)//2
C=B%(10**9+7)
print(C)
Buggy code:
def findProductSum(A, n):
    tmp = (10**9)+7

    array_sum = 0
    for i in range(0, n, 1):
        array_sum = array_sum + A[i]

    array_sum_square = array_sum * array_sum

    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += A[i] * A[i]
        individual_square_sum = individual_square_sum

    return ((array_sum_square - individual_square_sum) / 2) % tmp

n = int(input())
a = list(map(int,input().split()))

print(findProductSum(a,n))


Fixed code:
def findProductSum(A, n):
    tmp = (10**9)+7

    array_sum = 0
    for i in range(0, n, 1):
        array_sum = array_sum + A[i]

    array_sum_square = array_sum * array_sum

    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += A[i] * A[i]
        individual_square_sum = individual_square_sum

    return ((array_sum_square - individual_square_sum) // 2) % tmp

n = int(input())
a = list(map(int,input().split()))

print(findProductSum(a,n))
Buggy code:
n = int(input())
a = list(map(int, input().split()))

z = 0
for i in range(n):
    z += a[i]

y = ((z % 1000000007)** 2) % 1000000007

x = 0
for j in range(n):
    x += a[j] ** 2


p = int(((y - x) / 2) % 1000000007)
print(p)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
p = 1000000007
 
z = 0
for i in range(n):
    z += a[i]
    z = z % (2 * p)
 
y = (z ** 2) % (2 * p)
 
x = 0
for j in range(n):
    x += a[j] ** 2
    x = x % (2 * p)
 
w = int(((y - x) / 2) % p)
print(w)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0
aa=sum(a)
for i in range(n):
    aa-=a[i]
        ans += a[i]*a[j]
ans %= mod
print(ans)


Fixed code:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0
aa=sum(a)
for i in range(n):
    aa-=a[i]
    ans += a[i]*aa
ans %= mod
print(ans)
Buggy code:
n = int(input())
arr = list(map(int, input().split()))

MOD = 10**9 + 7

ans = 0
sum_arr = sum(arr)

for x in arr:
    ans += x * (sum_arr - x) // 2
    ans %= MOD

print(ans)

Fixed code:
n = int(input())
arr = list(map(int, input().split()))

MOD = 10**9 + 7

ans = 0
sum_arr = sum(arr)

for x in arr:
    sum_arr -= x
    ans += x * sum_arr
    ans %= MOD

print(ans)
Buggy code:
n = int(input())
a = list(map(int,input().split()))
b=sum(a)
score=0
for i in range(len(a)):
  b -= a[i]
  score=a[i]*b
  
print(score%(10**9+7))

Fixed code:
n = int(input())
a = list(map(int,input().split()))
b=sum(a)
score=0
for i in range(len(a)):
  b -= a[i]
  score+=a[i]*b
  
print(score%(10**9+7))
Buggy code:
f=open('in','r')
input=lambda:f.readline().strip()

n=int(input())
r=list(map(int,input().split()))
mod=1000000007
s=sum(r)%mod
x=0
for u in r:
  x+=u**2
x%=mod
t=500000004
print((s**2-x)*t%mod)

Fixed code:
# f=open('in','r')
# input=lambda:f.readline().strip()

n=int(input())
r=list(map(int,input().split()))
mod=1000000007
s=sum(r)%mod
x=0
for u in r:
  x+=u**2
x%=mod
t=500000004
print((s**2-x)*t%mod)
Buggy code:
n = int(input())
a_list = list(map(int, input().split()))

s_2 = 0
for i in a_list:
    s_2 += i**2

ans = (sum(a_list)**2 - s_2)/2  

ans = ans%(10**9+7)
print(ans)

Fixed code:
n = int(input())
a_list = list(map(int, input().split()))

s_2 = 0
for i in a_list:
    s_2 += i**2

ans = (sum(a_list)**2 - s_2)//2  

ans = ans%(10**9+7)
print(ans)
Buggy code:
n=int(input())
s=input()
p=list(s.split())
s1=0
s2=0
for i in range(0,n)
  s1=s1+int(p[i])
  s2=s2+(int(p[i])*int(p[i]))
k= ((s1**2)-s2)//2
k=k%1000000007
//abcdef
print(k)


Fixed code:
n=int(input())
s=input()
p=list(s.split())
s1=0
s2=0
for i in range(0,n):
  s1=s1+int(p[i])
  s2=s2+(int(p[i])*int(p[i]))
k= ((s1**2)-s2)//2
k=k%1000000007
print(k)
Buggy code:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


N, M=map(int,input().split())
UF=UnionFind(N)

for _ in range(M):
  A,B=map(int,input().split())
  UF.union(A,B)

ans=0

for i in range(N):
  ans = max(ans, UF.size(i));
 
 print(ans)

Fixed code:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


N, M = map(int, input().split())
UF = UnionFind(N)

for _ in range(M):
    A, B = map(int, input().split())
    UF.union(A - 1, B - 1)

ans = 0

for i in range(N):
    ans = max(ans, UF.size(i))

print(ans)
Buggy code:
#ceilevenoddformula
import math
import bisect
import copy
import time
from collections import Counter
from itertools import combinations
#map(int,input().split())
#int(x) for x in input().split()
n,m=map(int,raw_input().split())
d={i:set() for i in range(1,n+1)}
for i in range(m):
	x,y=map(int,raw_input().split())
	d[x].add(y)
	d[y].add(x)


vis=set()
for u,v in d.items():
	d[u]=list(v)
count=0
que=[]
for i in range(1,n+1):
	if i not in vis:
		que=[]
		c=1
		vis.add(i)
		que.append(i)
		while len(que)!=0:
			x=que.pop(0)
			for j in d[x]:
				if j not in vis:
					vis.add(j)
					c+=1
					que.append(j)
		count=max(c,count)

print(count)













































Fixed code:
#ceilevenoddformula
import math
import bisect
import copy
import time
from collections import Counter
from itertools import combinations
#map(int,input().split())
#int(x) for x in input().split()
n,m=map(int,input().split())
d={i:set() for i in range(1,n+1)}
for i in range(m):
	x,y=map(int,input().split())
	d[x].add(y)
	d[y].add(x)


vis={i:False for i in range(1,n+1)}
for u,v in d.items():
	d[u]=list(v)
count=0
que=[]
for i in range(1,n+1):
	if not vis[i]:
		que=[]
		c=1
		vis[i]=True
		que.append(i)
		while len(que)!=0:
			x=que.pop(0)
			for j in d[x]:
				if not vis[j]:
					vis[j]=True
					c+=1
					que.append(j)
		count=max(c,count)

print(count)
Buggy code:
from copy import deepcopy

# n, m = map(int, input().split())
# 
# pairs = [0] * m
# for i in range(m):
#     pairs[i] = set(map(int, input().split()))


N = 5
pairs = [[1,2], [3,4], [5,1]]

print(pairs)

class UnionFind:
    def __init__(self, N):
        self.r = [-1] * N

    def root(self, x):
        if self.r[x] < 0:
            return x
        self.r[x] = self.root(self.r[x])
        return self.r[x]


    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.r[x] > self.r[y]:
            x, y = y, x

        self.r[x] += self.r[y]
        self.r[y] = x
        return True

    def size(self, x):
        return -self.r[self.root(x)]

uf = UnionFind(N)
for pair in pairs:
    a = pair[0] - 1
    b = pair[1] - 1
    uf.unite(a, b)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)


Fixed code:
from copy import deepcopy

N, M = map(int, input().split())

pairs = [0] * M
for i in range(M):
    pairs[i] = list(map(int, input().split()))


# N = 5
# pairs = [[1,2], [3,4], [5,1]]


class UnionFind:
    def __init__(self, N):
        self.r = [-1] * N

    def root(self, x):
        if self.r[x] < 0:
            return x
        self.r[x] = self.root(self.r[x])
        return self.r[x]


    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.r[x] > self.r[y]:
            x, y = y, x

        self.r[x] += self.r[y]
        self.r[y] = x
        return True

    def size(self, x):
        return -self.r[self.root(x)]

uf = UnionFind(N)
for pair in pairs:
    a = pair[0] - 1
    b = pair[1] - 1
    uf.unite(a, b)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)
Buggy code:
N, M = map(int, input().split())

par = list(range(N))
rank = [1]*N
size = [1]*N

def find(x):
  if par[x] == x:
    return x
  else:
    return find(par[x])
  
def unite(x,y):
  x = find(x)
  y = find(y)
  
  if x == y:
    return
  if rank[x]<rank[y]:
    x,y = y,x
  else:
  par[y] = x
  size[x] += size[y]
  if rank[x]==rank[y]:
    rank[x]+=1
    
for i in range(M):
  a,b = [int(i)-1 for i in input().split()]
  unite(a,b)
  
print(max(size))

Fixed code:
N, M = map(int, input().split())

par = list(range(N))
rank = [1]*N
size = [1]*N

def find(x):
  if par[x] == x:
    return x
  else:
    return find(par[x])
  
def unite(x,y):
  x = find(x)
  y = find(y)
  
  if x == y:
    return
  if rank[x]<rank[y]:
    par[x]=y
    size[y]+= size[x]
  else:
    par[y] = x
    size[x] += size[y]
    if rank[x]==rank[y]:
      rank[x]+=1
    
for i in range(M):
  a,b = [int(i)-1 for i in input().split()]
  unite(a,b)
  
print(max(size))
Buggy code:
from collections import deque

n, m = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(m)]

neighbor = [[] for _ in range(n)]
for edge in edges:
    neighbor[edge[0] - 1].append(edge[1] - 1)  # 1- → 0-index
    neighbor[edge[1] - 1].append(edge[0] - 1)

print(neighbor)
visited = [-1] * n
ans = 1
for idx in range(n):
    if visited[idx] == -1:
        queue = deque()
        queue.append(idx)
        group_population = 1
        visited[idx] = 0
        while len(queue) > 0:
            vertex = queue.popleft()
            for nei in neighbor[vertex]:
                if visited[nei] == -1:
                    visited[nei] = 0
                    queue.append(nei)
                    group_population += 1

    ans = max(ans, group_population)

print(ans)

Fixed code:
from collections import deque

n, m = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(m)]

neighbor = [[] for _ in range(n)]
for edge in edges:
    neighbor[edge[0] - 1].append(edge[1] - 1)  # 1- → 0-index
    neighbor[edge[1] - 1].append(edge[0] - 1)

#print(neighbor)
visited = [-1] * n
ans = 1
for idx in range(n):
    if visited[idx] == -1:
        queue = deque()
        queue.append(idx)
        group_population = 1
        visited[idx] = 0
        while len(queue) > 0:
            vertex = queue.popleft()
            for nei in neighbor[vertex]:
                if visited[nei] == -1:
                    visited[nei] = 0
                    queue.append(nei)
                    group_population += 1

    ans = max(ans, group_population)

print(ans)
Buggy code:
class UnionFind():
    def __init__(self,n):
        self.parents = [-1]*n

    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x,y = y,x
            
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        
N,M = map(int,input().split())    
uf = UnionFind(N)

for i in range(M):
    A,B = map(int,input().split())
    uf.union(A,B)
    #print(uf.parents)

print(abs(min(uf.parents)))

Fixed code:
class UnionFind():
    def __init__(self,n):
        self.parents = [-1]*n

    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x,y = y,x
            
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        
N,M = map(int,input().split())    
uf = UnionFind(N)

for i in range(M):
    A,B = map(lambda x:int(x)-1,input().split())
    uf.union(A,B)
    #print(uf.parents)

print(abs(min(uf.parents)))
Buggy code:
N,M=map(int,input().split())
par=[i for i in range(N+1)]
size=[1 for i in range(N+1)]
def find(x):
    if x!=par[x]:
        par[x]=find(par[x])
    return par[x]
def union(x,y):
    if find(x)!=find(y):
        par[y] = par[x]
        size[x] += size[y]
res=N
for i in range(M):
    s,e=map(int,input().split())
    union(s,e)
print(max(size))

Fixed code:
N,M=map(int,input().split())
par=[i for i in range(N+1)]
size=[1 for i in range(N+1)]
def find(x):
    if x!=par[x]:
        par[x]=find(par[x])
    return par[x]
def union(x,y):
    if find(x)!=find(y):
        x, y = par[x], par[y]
        par[y] = par[x]
        size[x] += size[y]
res=N
for i in range(M):
    s,e=map(int,input().split())
    union(s,e)
print(max(size))
Buggy code:
N, M = map(int, input().split())

from collections import defaultdict

# union find
class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n
 
    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x
 
    def find(self, x, y):
        return self._root(x) == self._root(y)
 
    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1

uf = UnionFind(N)

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a > b:
        c = b
        b = a
        a = c

    uf.union(a, b)

# member = defaultdict(int)
r = min(uf.table)
if r != -1:
    mm = r
    ic = 0
    for n in uf.table:
        if n == -1:
            ic += 1

    if mm < ic:
        mm += 1
else:
    mm = 1

print(mm)

Fixed code:
N, M = map(int, input().split())

from collections import defaultdict

# union find
class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n
 
    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x
 
    def find(self, x, y):
        return self._root(x) == self._root(y)
 
    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1

uf = UnionFind(N)

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a > b:
        c = b
        b = a
        a = c

    uf.union(a, b)

# member = defaultdict(int)
r = min(uf.table)
if r != -1:
    mm = abs(r)
    # ic = 0
    # for n in uf.table:
    #     if n == -1:
    #         ic += 1

    # if ic%mm != 0:
    #     mm += 1
else:
    mm = 1

print(mm)
Buggy code:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=list(map(int,input().split()))
g=UnionFind(n+1)
ans=0
for i in range(m):
    a,b=list(map(int,input().split()))
    g.union(-a,-b)

for i in range(n):
    ans=max(ans,g.size(i))
print(ans)


Fixed code:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
uf=UnionFind(n)
for i in range(m):
  a,b=map(int,input().split())
  uf.union(a-1,b-1)
ans=1
for i in range(n):
  c=uf.size(i)
  if c>ans:
    ans=c
print(ans)