Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
dic = defaultdict(int)
for i in range(n):
    dic[a[i]]+=1
Q= int(input())
for q in range(Q):
    b, c = map(int, input().split())
    dic[c]+=dic[b]
    dic[b]=0
    ans = 0
    for j in dic:
        ans += dic[j]*j
    print(ans)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
dic = defaultdict(int)
for i in range(n):
    dic[a[i]]+=1
ans = 0
for j in dic:
    ans += dic[j]*j

Q= int(input())
for q in range(Q):
    b, c = map(int, input().split())
    s= dic[b]*(c-b)
    ans += s
    
    dic[c]+=dic[b]
    dic[b]=0
    
    print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n, m  = map(int, input().split())
a  = []
b = [[] for _ in range(m)]
for i in range(m):
    a.append(list(map(int, input().split())))
    

for i in range(m):
    b[a[i][0]-1].append(a[i][1])
    b[a[i][1]-1].append(a[i][0])

seen = [-1]*n
seen[0] = 1
que = deque([1])
while que:
    v = que.popleft()
    for i in b[v-1]:
        if seen[i-1] != -1:
            continue
        que.append(i)
        seen[i-1] = v

for i in range(n):
    if seen[i] == -1:
        print("No")
else:
    del seen[0]
    print("Yes")
    for i in range(n-1):
        print(seen[i])

Fixed submission:
from collections import deque
n, m  = map(int, input().split())
a  = []
b = [[] for _ in range(n)]
for i in range(m):
    a.append(list(map(int, input().split())))
    

for i in range(m):
    b[a[i][0]-1].append(a[i][1])
    b[a[i][1]-1].append(a[i][0])

seen = [-1]*n
seen[0] = 1
que = deque([1])
while que:
    v = que.popleft()
    for i in b[v-1]:
        if seen[i-1] != -1:
            continue
        que.append(i)
        seen[i-1] = v

for i in range(n):
    if seen[i] == -1:
        print("No")
else:
    del seen[0]
    print("Yes")
    for i in range(n-1):
        print(seen[i])
Buggy python submission (verdict: Runtime Error):
import sys
n, k = map(int, input().split())
a = list(map(int, input().split())) 

visited = [None]*n
cur = 0
for i in range(k):
    if visited[cur] is None:
        visited[cur] = i
        cur = a[cur]-1
    else:
        break
else:
    print(cur+1)
	sys.exit()

k -= i
k %= i-visited[cur]

for i in range(k):
    cur = a[cur]-1

print(cur+1)

Fixed submission:
s = str(input())
t = str(input())
ans = True
for i in range(len(s)):
    if s[i] == t[i]:
        continue
    else:
        ans =False
if len(s) != len(t)-1:
    ans = False

if ans:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
count = 0
Jlist = []
for j in range(2, n+1):
    if j > a_list[j-1]:
        for i in range(1, j):
            if j -a_list[j-1] == a_list[i-1] + i:
                count += 1

print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
count = 0
d={}
for i in range(n):
    if i - a[i] in d:
        count+=d[i - a[i]]
    if i + a[i] in d:
        d[i+a[i]] += 1
    else:
        d[i+a[i]] = 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
count = 0
Jlist = []
for j in range(2, n+1):
    if j > a_list[j-1]:
        for i in range(1, j):
            if j -i == a_list[i-1] + a_list[j-1]:
                count += 1

print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
count = 0
d={}
for i in range(n):
    if i - a[i] in d:
        count+=d[i - a[i]]
    if i + a[i] in d:
        d[i+a[i]] += 1
    else:
        d[i+a[i]] = 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
count = 0
Jlist = []
for j in range(2, n+1):
    if j > a_list[j-1]:
        Jlist.append(j)

for j in Jlist:
    
    for i in range(1, j):
        if j -i == a_list[i-1] + a_list[j-1]:
            count += 1

print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
count = 0
d={}
for i in range(n):
    if i - a[i] in d:
        count+=d[i - a[i]]
    if i + a[i] in d:
        d[i+a[i]] += 1
    else:
        d[i+a[i]] = 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
count = 0

for i in range(1, n):
    for j in range(i+1, n+1):
        if j - i == a_list[i-1] + a_list[j-1]:
            count += 1
print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
count = 0
d={}
for i in range(n):
    if i - a[i] in d:
        count+=d[i - a[i]]
    if i + a[i] in d:
        d[i+a[i]] += 1
    else:
        d[i+a[i]] = 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
num = 0
last = 0
d = 1
count={}
for k in range(2019):
    count[k] = 0
    
count[0] =1  # 割り切れるとき

for i in s:
    num = (int(i) * d + num)%2019
    
    d *= 10
    count[num] += 1
    
ans = 0
for j in range(2019):
    ans += count[j] * (count[j]-1) //2
print(ans)

Fixed submission:
s = input()[::-1]
num = 0
last = 0
d = 1
count={}
for k in range(2019):
    count[k] = 0
    
count[0] =1  # 割り切れるとき

for i in s:
    num = (int(i) * d + num)%2019
    
    d *= 10
    d %= 2019
    count[num] += 1
    
ans = 0
for j in range(2019):
    ans += count[j] * (count[j]-1) //2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
num = 0
last = 0
d = 1
count={}
for k in range(2019):
    count[k] = 0
    
count[0] =1  # 割り切れるとき

for i in s:
    num = int(i) * d + last
    last = num
    num %= 2019
    d *= 10
    count[num] += 1
    
ans = 0
for j in range(2019):
    ans += count[j] * (count[j]-1) //2
print(ans)

Fixed submission:
s = input()[::-1]
num = 0
last = 0
d = 1
count={}
for k in range(2019):
    count[k] = 0
    
count[0] =1  # 割り切れるとき

for i in s:
    num = (int(i) * d + num)%2019
    
    d *= 10
    d %= 2019
    count[num] += 1
    
ans = 0
for j in range(2019):
    ans += count[j] * (count[j]-1) //2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
num = 0
last = 0
d = 1
count = [0] * 2019 # 余りの格納箱
count[0] =1  # 割り切れるとき
for i in s:
    num = int(i) * d + last
    last = num
    num %= 2019
    d *= 10
    count[num] += 1
    
ans = 0
for i in count:
    ans += i * (i-1) //2
print(ans)

Fixed submission:
s = input()[::-1]
num = 0
last = 0
d = 1
count={}
for k in range(2019):
    count[k] = 0
    
count[0] =1  # 割り切れるとき

for i in s:
    num = (int(i) * d + num)%2019
    
    d *= 10
    d %= 2019
    count[num] += 1
    
ans = 0
for j in range(2019):
    ans += count[j] * (count[j]-1) //2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
count = 0

def check(ij):
    ss = int(s[ij[0]-1:ij[1]])
    if ss % 2019 == 0:
        return True
    else:
        return False
    

def dfs(ij):
    global count
    if len(ij) == 2:
        if check(ij):
            count += 1
    elif len(ij) == 1:
        for k in range(ij[0]+3, n+1):
            ij.append(k)
            dfs(ij)
            ij.pop()
    else:
        for k in range(1, n-2):
            ij.append(k)
            dfs(ij)
            ij.pop()
            
dfs([])
print(count)

Fixed submission:
s = input()[::-1]
num = 0
last = 0
d = 1
count={}
for k in range(2019):
    count[k] = 0
    
count[0] =1  # 割り切れるとき

for i in s:
    num = (int(i) * d + num)%2019
    
    d *= 10
    d %= 2019
    count[num] += 1
    
ans = 0
for j in range(2019):
    ans += count[j] * (count[j]-1) //2
print(ans)
Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p =list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted(p)
q = sorted(q)

p = p[(len(p)-x):]
q = q[(len(q)-y):]
r.append(p)
r.append(q)
r = sorted(r)
print(sum(r[(len(r)-x-y):]))


Fixed submission:
x, y, a, b, c = map(int, input().split())
p =list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted(p)
q = sorted(q)

p = p[(len(p)-x):]
q = q[(len(q)-y):]
r = r + p
r = r + q
r = sorted(r)
print(sum(r[(len(r)-x-y):]))

Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p =list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted(p)
q = sorted(q)

p = p[(len(p)-x):]
q = q[(len(q)-y):]
r.append(p)
r.append(q)
sort(r)
print(sum(r[(len(r)-x-y):]))


Fixed submission:
x, y, a, b, c = map(int, input().split())
p =list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted(p)
q = sorted(q)

p = p[(len(p)-x):]
q = q[(len(q)-y):]
r = r + p
r = r + q
r = sorted(r)
print(sum(r[(len(r)-x-y):]))

Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p =list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted(p)
p = sorted(p)

p = p[(len(p)-x):]
q = q[(len(q)-y):]
r=r+p
r=r+q
r = sorted(r)
print(sum(r[(len(r)-x-y):]))


Fixed submission:
x, y, a, b, c = map(int, input().split())
p =list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted(p)
q = sorted(q)

p = p[(len(p)-x):]
q = q[(len(q)-y):]
r = r + p
r = r + q
r = sorted(r)
print(sum(r[(len(r)-x-y):]))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict, deque
n, m, k = map(int, input().split())
friends = defaultdict(list)
block = defaultdict(list)
for _ in range(m):
    a, b = map(int, input().split())
    friends[a].append(b)
    friends[b].append(a)
for _ in range(k):
    c, d = map(int, input().split())
    block[c].append(d)
    block[d].append(c)
#print(friends)
#print(block)

roopname = []
roop = defaultdict(list)
seen = [0]*n


for i in range(n):
    if not seen[i]==0:
        continue
    seen[i] = i+1
    roopname.append(i+1)
    roop[i+1].append(i+1)
    queue = deque(friends[i+1])
    while queue:
        p = queue.popleft()
        if  not seen[p-1]==0:continue
        seen[p-1] = i+1
        roop[i+1].append(p)
        for j in friends[p]:
            if seen[j-1]==0:
                queue.append(j)
#print(roopname)
#print(roop)
#print(seen)
ans = []
for i in range(n):
    fsum = 0
    for j in friends[i+1]:
        if j in roop[seen[i]]:
            fsum += 1
            
    bsum = 0
    for j in block[i+1]:
        if j in roop[seen[i]]:
            bsum += 1
    
    ans.append(len(roop[seen[i]])-bsum-fsum-1)

L=[str(a) for a in ans]
L=" ".join(L)
print(L)

Fixed submission:
from collections import defaultdict, deque
n, m, k = map(int, input().split())
friends = defaultdict(set)
block = defaultdict(set)
for _ in range(m):
    a, b = map(int, input().split())
    friends[a].add(b)
    friends[b].add(a)
for _ in range(k):
    c, d = map(int, input().split())
    block[c].add(d)
    block[d].add(c)
#print(friends)
#print(block)

roopname = []
roop = defaultdict(set)
seen = [0]*n


for i in range(n):
    if not seen[i]==0:
        continue
    seen[i] = i+1
    roopname.append(i+1)
    roop[i+1].add(i+1)
    queue = deque(friends[i+1])
    while queue:
        p = queue.popleft()
        if  not seen[p-1]==0:continue
        seen[p-1] = i+1
        roop[i+1].add(p)
        for j in friends[p]:
            if seen[j-1]==0:
                queue.append(j)
#print(roopname)
#print(roop)
#print(seen)
ans = [len(roop[seen[i]])-len(roop[seen[i]]&friends[i+1])-len(roop[seen[i]]&block[i+1])-1 for i in range(n)]

    

L=[str(a) for a in ans]
L=" ".join(L)
print(L)
Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
inf = 10**10
dp = [inf]*(h+1)
dp[0] = 0
for i in range(n):
    a, b = map(int, input().split())
    
    for j in range(h+1):
        if j- a>0:
            dp[j] = min(dp[j-a]+b, dp[j])
        else:
            dp[j]= min(dp[j], b)

print(dp[h])

Fixed submission:
h, n = map(int, input().split())
inf = 10**10
dp = [inf]*(h+1)
dp[0] = 0
for i in range(n):
    a, b = map(int, input().split())
    
    for j in range(h+1):
        if j- a>0:
            dp[j] = min(dp[j-a]+b, dp[j])
        else:
            dp[j]= min(dp[j], b)

print(dp[h])
Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())
if a*a*b<=2*x:
    print(90-math.degrees(math.atan(a**3/(2*b*a*a-2*x))))
else:
    print(90-math.degrees(math.atan(2*x/(a*b*b))))

Fixed submission:
import math
a, b, x = map(int, input().split())
if a*a*b==x:
    print(0)
elif a*a*b<=2*x:
    print(90-math.degrees(math.atan(a**3/(2*b*a*a-2*x))))
else:
    print(90-math.degrees(math.atan(2*x/(a*b*b))))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)
B = [A[0]]
for i in range(1, N):
    j = 0
    while j<len(B):
        if A[i] > B[j]:
            B[j] = A[i]
            break
        j+=1
    else:
        B.append(A[i])

print(len(B))

Fixed submission:
N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)
B = [A[0]]
for i in range(1, N):

    if A[i] > B[-1]:#2分探索でどこかに入れる
        sm = -1
        la = len(B)-1
        
        while sm+1<la:
            mi = (sm+la)//2
            if B[mi]<A[i]:
                la=mi
            else:
                sm=mi
        B[la]=A[i]
        
    else:#Bに追加
        B.append(A[i])

print(len(B))
Buggy python submission (verdict: Time Limit Exceeded):
n = list(map(int,input().split()))


ans = n[1] * n[3]
for i in range(n[0],n[1]+1):
    for j in range(n[2],n[3]+1):
        ans = max(i*j,ans)
print(ans)

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


ans = n[1] * n[3]
ans = max(n[0]*n[2],ans)
ans = max(n[0]*n[3],ans)
ans = max(n[1]*n[2],ans)
ans = max(n[1]*n[3],ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = list(map(int,input().split()))


ans = n[1] * n[3]
for i in range(n[0],n[1]+1):
    for j in range(n[2],n[3]+1):
        ans = max(i*j,ans)
print(ans)

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


ans = n[1] * n[3]
ans = max(n[0]*n[2],ans)
ans = max(n[0]*n[3],ans)
ans = max(n[1]*n[2],ans)
ans = max(n[1]*n[3],ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
n = list(map(int,input().split()))

x = False
y = False

if max(n[0],n[1]) < 0:
    x = True
    
if max(n[2],n[3]) < 0:
    y = True

if n[1] > 0:
    if n[3] > 0:
        ans = n[1] * n[3]
    else:
        if n[0] < 0:
            ans = n[0] * n[2]
        else:
            ans = n[0] * n[3]
elif n[3] > 0:
    if n[2] < 0:
        ans = n[0] * n[2]
    else:
        ans = n[1] * n[2]
if n[1] == 0 and n[3] == 0:
    ans = n[0] * n[2]

print(ans)

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


ans = n[1] * n[3]
ans = max(n[0]*n[2],ans)
ans = max(n[0]*n[3],ans)
ans = max(n[1]*n[2],ans)
ans = max(n[1]*n[3],ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
As = list(map(int, input().split()))
m = 10**9 + 7
result = 0
for i in range(N-1):
  p = As[i]
  cs_mod = sum(As[i+1:]) % m
  result += ((cs_mod * p) % m)
print(result % m)

Fixed submission:
N = int(input())
As = list(map(int, input().split()))
m = 10**9 + 7
result = 0
As_sum = sum(As)
for i in range(N-1):
  As_sum = As_sum - As[i]
  result += (As[i] * As_sum) % m

print(result % m)
Buggy python submission (verdict: Runtime Error):
S = input()
suma = 0
a = t

for s in range(len(S)):
  if s == a:
    suma += 1
  else:
    suma = 0
    a = s
    
print(suma)
  

Fixed submission:
S = input()

if S == "RRR":
  print(3)
elif S in ["RSS", "SRS", "SSR", "RSR"]:
  print(1)
elif S in ["RRS", "SRR"]:
  print(2)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(li,
A = A.reshape((int(N/2), 2))[:,0] if N % 2 == 0 else np.append(A, 2, 100).reshape((int((N+1)/2), 2))[:, 0]
print((A % 2 == 1).sum())

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
A = A.reshape((int(N/2), 2))[:,0] if N % 2 == 0 else np.append(A, 2, 100).reshape((int((N+1)/2), 2))[:, 0]
print((A % 2 == 1).sum())
Buggy python submission (verdict: Runtime Error):
import math

A, B = input().split()

B_float = float(B)
A = int(A)
B_p = int(B.split(".")[0])
B_c = int(B.split(".")[1])

if (A == 0) or (B == 0):
  print(0)
else:
  print(A * B_p + int(str(A * B_c)[:-2]))

Fixed submission:
import math

A, B = input().split()

A = int(A)
B_p = int(B.split(".")[0])
B_c = int(B.split(".")[1])

if (A == 0) or (B == 0):
  print(0)
else:
  ABp = A * B_p
  ABc = int(str(A * B_c)[:-2]) if len(str(A * B_c))>2 else 0
  print(ABp+ABc)

Buggy python submission (verdict: Runtime Error):
import math

A, B = input().split()

try:
  B_float = float(B)
  A = int(A)
except:
  print(0)

B_p = int(B.split(".")[0])
B_c = int(B.split(".")[1])

print(A * B_p + int(str(A * B_c)[:-2]))

Fixed submission:
import math

A, B = input().split()

A = int(A)
B_p = int(B.split(".")[0])
B_c = int(B.split(".")[1])

if (A == 0) or (B == 0):
  print(0)
else:
  ABp = A * B_p
  ABc = int(str(A * B_c)[:-2]) if len(str(A * B_c))>2 else 0
  print(ABp+ABc)

Buggy python submission (verdict: Runtime Error):
import math

A, B = input().split()
B_float = float(B)
A = int(A)
B_p = int(B.split(".")[0])
B_c = int(B.split(".")[1])

if (A == 0) or (B == 0):
  print(0)
else:
  print(A * B_p + int(str(A * B_c)[:-2]))

Fixed submission:
import math

A, B = input().split()

A = int(A)
B_p = int(B.split(".")[0])
B_c = int(B.split(".")[1])

if (A == 0) or (B == 0):
  print(0)
else:
  ABp = A * B_p
  ABc = int(str(A * B_c)[:-2]) if len(str(A * B_c))>2 else 0
  print(ABp+ABc)

Buggy python submission (verdict: Runtime Error):
import math

A, B = input().split()
A = int(A)
B_p = int(B.split(".")[0])
B_c = int(B.split(".")[1])

print(A * B_p + int(str(A * B_c)[:-2]))

Fixed submission:
import math

A, B = input().split()

A = int(A)
B_p = int(B.split(".")[0])
B_c = int(B.split(".")[1])

if (A == 0) or (B == 0):
  print(0)
else:
  ABp = A * B_p
  ABc = int(str(A * B_c)[:-2]) if len(str(A * B_c))>2 else 0
  print(ABp+ABc)
Buggy python submission (verdict: Runtime Error):
n, x, m = map(int, input().split())

if x == 0:
    print(0)
    sys.exit()

l = [x]
s = {x}
prev = x

for i in range(1, m):
    next = prev ** 2
    next = next % m
    if next in s:
        break
    s.add(next)
    l.append(next)
    prev = next
start = l.index(next)
length = i - start

ans = 0
if n < start + length:
    ans += sum(l[:n])
else:
    ans += sum(l[:start])
    ans += sum(l[start:]) * ((n - start) // length)
    ans += sum(l[start:(start + ((n - start) % length))])

print(ans)


Fixed submission:
import sys

n, x, m = map(int, input().split())

if x == 0:
    print(0)
    sys.exit()

l = [x]
s = {x}
prev = x

for i in range(1, m):
    next = prev ** 2
    next = next % m
    if next in s:
        break
    s.add(next)
    l.append(next)
    prev = next
start = l.index(next)
length = i - start

ans = 0
if n < start + length:
    ans += sum(l[:n])
else:
    ans += sum(l[:start])
    ans += sum(l[start:]) * ((n - start) // length)
    ans += sum(l[start:(start + ((n - start) % length))])

print(ans)

Buggy python submission (verdict: Runtime Error):
n, x, m = map(int, input().split())

l = [x]
s = {x}
prev = x

for i in range(1, m):
    next = prev ** 2
    next = next % m
    if next in s:
        break
    s.add(next)
    l.append(next)
    prev = next
start = l.index(next)
length = i - start

ans = 0
if n < start + length:
    ans += sum(l[:n])
else:
    ans += sum(l[:start])
    ans += sum(l[start:]) * ((n - start) // length)
    ans += sum(l[start:(start + ((n - start) % length))])

print(ans)


Fixed submission:
import sys

n, x, m = map(int, input().split())

if x == 0:
    print(0)
    sys.exit()

l = [x]
s = {x}
prev = x

for i in range(1, m):
    next = prev ** 2
    next = next % m
    if next in s:
        break
    s.add(next)
    l.append(next)
    prev = next
start = l.index(next)
length = i - start

ans = 0
if n < start + length:
    ans += sum(l[:n])
else:
    ans += sum(l[:start])
    ans += sum(l[start:]) * ((n - start) // length)
    ans += sum(l[start:(start + ((n - start) % length))])

print(ans)
Buggy python submission (verdict: Runtime Error):
import networkx as nx

G = nx.Graph()

n, m = map(int, input().split())
for i in range(m):
    a, b = map(int, input().split())
    G.add_edge(a, b)

largest_cc = max(nx.connected_components(G), key=len)
print(len(largest_cc))


Fixed submission:
import networkx as nx
import sys

G = nx.Graph()

n, m = map(int, input().split())
if m == 0:
    print(1)
    sys.exit()
for i in range(m):
    a, b = map(int, input().split())
    G.add_edge(a, b)

largest_cc = max(nx.connected_components(G), key=len)
print(len(largest_cc))

Buggy python submission (verdict: Runtime Error):
import networkx as nx

G = nx.Graph()

n, m = map(int, input().split())
for i in range(m):
    a, b = map(int, input().split())
    G.add_edge(a, b)

largest_cc = max(nx.connected_components(G), key=len)
print(len(largest_cc))


Fixed submission:
import networkx as nx
import sys

G = nx.Graph()

n, m = map(int, input().split())
if m == 0:
    print(1)
    sys.exit()
for i in range(m):
    a, b = map(int, input().split())
    G.add_edge(a, b)

largest_cc = max(nx.connected_components(G), key=len)
print(len(largest_cc))
Buggy python submission (verdict: Runtime Error):
n = input()
while(n > 0):
    n -= 1000
print(-n)


Fixed submission:
n = int(input())
while(n > 0):
    n -= 1000
print(-n)
Buggy python submission (verdict: Time Limit Exceeded):
N, C = map(int,input().split())
D = [0] * C
for i in range(C):
    t = list(map(int,input().split()))
    D[i] = t
c = [0] * N
for i in range(N):
    t = list(map(int,input().split()))
    c[i] = t
Dsum = [0] * C
for k in range(C):
    ccc = [0, 0, 0]
    for i in range(N):
        for j in range(N):
            ccc[(i+j)%3] += D[c[i][j]-1][k]
    Dsum[k] = ccc
ans = 9876543210
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i != j and j != k and k != i:
                ans = min(ans, Dsum[i][0]+Dsum[j][1]+Dsum[k][2])
print(ans)

Fixed submission:
N, C = map(int,input().split())
D = []
for i in range(C):
    t = list(map(int,input().split()))
    D.append(t)
c = []
for i in range(N):
    t = list(map(int,input().split()))
    c.append(t)
Dsum = []
for k in range(C):
    ccc = [0, 0, 0]
    for i in range(N):
        for j in range(N):
            ccc[(i+j)%3] += D[c[i][j]-1][k]
    Dsum.append(ccc)
ans = 9876543210
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i != j and j != k and k != i:
                ans = min(ans, Dsum[i][0]+Dsum[j][1]+Dsum[k][2])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, C = map(int,input().split())
D = []
for i in range(C):
    t = list(map(int,input().split()))
    D.append(t)
c = []
for i in range(N):
    t = list(map(int,input().split()))
    c.append(t)
Dsum = []
for k in range(C):
    ccc = [0, 0, 0]
    for i in range(N):
        for j in range(N):
            ccc[(i+j)%3] += D[c[i][j]-1][k]
    Dsum.append(ccc)
ans = 9876543210
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i != j and j != k and k != i:
                ans = min(ans, Dsum[i][0]+Dsum[j][1]+Dsum[k][2])
print(ans)

Fixed submission:
N, C = map(int,input().split())
D = []
for i in range(C):
    t = list(map(int,input().split()))
    D.append(t)
c = []
for i in range(N):
    t = list(map(int,input().split()))
    c.append(t)
Dsum = []
for k in range(C):
    ccc = [0, 0, 0]
    for i in range(N):
        for j in range(N):
            ccc[(i+j)%3] += D[c[i][j]-1][k]
    Dsum.append(ccc)
ans = 9876543210
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i != j and j != k and k != i:
                ans = min(ans, Dsum[i][0]+Dsum[j][1]+Dsum[k][2])
print(ans)