Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
F=H
T=True
B=max(H)
C=H.index(max(H))
if B-H[N-1]>1 and B!=H[N-1]:
    T=False
if C==N-1:
    del H[N-1]
    B=max(H)
    H=F
    C=H.index(B)
if T:
    for i in range(N-1):
        if i>C:
            if H[i]+1<H[C]:
                T=False
if T:
    print('Yes')
else:
    print('No')

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
F=H
T=True
B=max(H)
C=H.index(max(H))
if B-H[N-1]>1 and B!=H[N-1]:
    T=False
if C==N-1 and N!=1:
    del H[N-1]
    B=max(H)
    H=F
    C=H.index(B)
if T:
    for i in range(N-1):
        if i>C:
            if H[i]+1<H[C]:
                T=False
if T:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
F=H
T=True
B=max(H)
C=H.index(max(H))
if B-H[N-1]>1 and B!=H[N-1]:
    T=False
if C==N-1:
    del H[N-1]
    B=max(H)
    H=F
    C=H.index(B)
if T:
    for i in range(N-1):
        if i>C:
            if H[i]+1<H[C]:
                T=False
if T:
    print('Yes')
else:
    print('No')

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
F=H
T=True
B=max(H)
C=H.index(max(H))
if B-H[N-1]>1 and B!=H[N-1]:
    T=False
if C==N-1 and N!=1:
    del H[N-1]
    B=max(H)
    H=F
    C=H.index(B)
if T:
    for i in range(N-1):
        if i>C:
            if H[i]+1<H[C]:
                T=False
if T:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import math
N=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        if i!=t:
            for s in range(int(N[1])):
                Y=[(a[i][s]-a[t][s])**2]
                Z=sum(Y)
                if (math.sqrt(Z))- int(math.sqrt(Z))==0:
                    A+=1
        else continue
print(A)

Fixed submission:
import math
N=list(map(int,input().split()))
a=['X' for _ in range(int(N[0]))]
A=0
for i in range(int(N[0])):
    a[i]=list(map(int,input().split()))
    for t in range(int(i)):
        if i!=t:
            Y=[]
            for s in range(int(N[1])):
                Y+=[(a[i][s]-a[t][s])**2]
            Z=sum(Y)
            if (math.sqrt(Z))- int(math.sqrt(Z))==0:
                A+=1
        else:
            continue
print(A)
Buggy python submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[n-1]
sum1=0
sum2=0
count=0
for k in range(N+1):
    for i in range(n):
        if d[i]>=k:
            sum1+=1
    if sum1==n-sum1:
        count+=1
    sum1=0
    sum2=0
print(count)

Fixed submission:
S=input()
sum=[0,0,0,0]
for t in range(4):
    for i in range(4):
        if S[int(t)]==S[int(i)]:
            sum[int(i)]+=1
if sum[0] == 2 and sum[1] == 2 and sum[2] == 2 and sum[3] == 2:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[n-1]
sum1=0
sum2=0
count=0
for k in range(N+1):
    for i in range(n):
        if d[i]>=k:
            sum1+=1
        else:
            sum2+=1
    if sum1==sum2:
        count+=1
    sum1=0
    sum2=0
print(count)

Fixed submission:
S=input()
sum=[0,0,0,0]
for t in range(4):
    for i in range(4):
        if S[int(t)]==S[int(i)]:
            sum[int(i)]+=1
if sum[0] == 2 and sum[1] == 2 and sum[2] == 2 and sum[3] == 2:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[n-1]
sum1=0
sum2=0
count=0
for k in range(N+1):
    for i in range(n):
        if d[i]>=k:
            sum1+=1
        else:
            sum2+=1
    if sum1==sum2:
        count+=1
    sum1=0
    sum2=0
print(count)

Fixed submission:
S=input()
sum=[0,0,0,0]
for t in range(4):
    for i in range(4):
        if S[int(t)]==S[int(i)]:
            sum[int(i)]+=1
if sum[0] == 2 and sum[1] == 2 and sum[2] == 2 and sum[3] == 2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[n-1]
sum1=0
sum2=0
count=0
for k in range(N+1):
    for i in range(n):
        if d[i]>=k:
            sum1+=1
    if sum1==n-sum1:
        count+=1
    sum1=0
    sum2=0
print(count)

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[int((n/2))]-dd[int((n/2)-1)]
print(N)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[n-1]
sum1=0
sum2=0
count=0
for k in range(N+1):
    for i in range(n):
        if d[i]>=k:
            sum1+=1
    if sum1==n-sum1:
        count+=1
    sum1=0
    sum2=0
print(count)

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[int((n/2))]-dd[int((n/2)-1)]
print(N)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[n-1]
sum1=0
sum2=0
count=0
for k in range(N+1):
    for i in range(n):
        if d[i]>=k:
            sum1+=1
        else:
            sum2+=1
    if sum1==sum2:
        count+=1
    sum1=0
    sum2=0
print(count)

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[int((n/2))]-dd[int((n/2)-1)]
print(N)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[n-1]
sum1=0
sum2=0
count=0
for k in range(N+1):
    for i in range(n):
        if d[i]>=k:
            sum1+=1
        else:
            sum2+=1
    if sum1==sum2:
        count+=1
    sum1=0
    sum2=0
print(count)

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[int((n/2))]-dd[int((n/2)-1)]
print(N)
Buggy python submission (verdict: Runtime Error):
N,L=list(map(int,input().split()))
taste=[]
taste1=[]
memo=[]
sum=0
for i in range(N):
    tasty=abs(L+i)
    if L+i<0:
        memo.append(L+i)
    taste.append(tasty)
    taste1.append(L+i)
    sum+=taste1[i]
tasteab=sorted(taste)
memo=sorted(memo)
pie=(sum-memo[-1])
print(pie)

Fixed submission:
N,L=list(map(int,input().split()))
taste=[]
taste1=[]
memo=[]
sum=0
for i in range(N):
    tasty=abs(L+i)
    if L+i<=0:
        memo.append(L+i)
    taste.append(tasty)
    taste1.append(L+i)
    sum+=taste1[i]
tasteab=sorted(taste)
memo=sorted(memo)
if memo!=[]:
    pie=(sum-memo[-1])
else:
    pie=(sum-tasteab[0])
print(pie)
Buggy python submission (verdict: Runtime Error):
N,K=list(map(int,input().split()))
S=input()
if S[K-1]=='A':
    S[K-1]='a'
if S[K-1]=='B':
    S[K-1]='b'
if S[K-1]=='C':
    S[K-1]='c'
print(S)

Fixed submission:
N,K=list(map(int,input().split()))
S=list(input())
if S[K-1]=='A':
    S[K-1]="a"
if S[K-1]=='B':
    S[K-1]='b'
if S[K-1]=='C':
    S[K-1]='c'
print(''.join(S))
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
k=int(input())
ss = s[k-1]
for i in range(1,n):
  if s[i] != ss:
    s[i]='*'
print(s)

Fixed submission:
n=int(input())
s=list(input())
k=int(input())
ss = s[k-1]
for i in range(0,n):
  if s[i] != ss:
    s[i]='*'
print("".join(s))
Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,k=[input() for _ in range(6)]
if a-e<=k:
    print(':(')
else:
    print('Yay!')

Fixed submission:
a,b,c,d,e,k=[int(input()) for _ in range(6)]
if e-a>k:
    print(':(')
else:
    print('Yay!')
Buggy python submission (verdict: Runtime Error):
S=input()
A=S[0]+S[1]+S[2]+S[3]
if int(S[5])!=0 and int(S[6]>5):
    print('TBD')
else:
    if int(A)<=2019:
        print('Heisei')
    else:
        print('TBD')

Fixed submission:
S=input()
S=S.split('/')
A=S[0]
if int(S[1])>=5:
    print('TBD')
else:
    if int(A)<=2019:
        print('Heisei')
    else:
        print('TBD')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(int,input().split())
al=[a[2*i] for i in range(n//2)]
bo=[a[2*i+1] for i in range(n//2)]
print(sum(al)-sum(bo))

Fixed submission:
N=input()
a=list(map(int,input().split()))
alice=0
bob=0
a=sorted(a,reverse=True)
for i in range(int(N)):
    if i%2==0:
        alice+=a[i]
    else:
        bob+=a[i]
print(alice-bob)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
x=int(input())
aa=x//a
bb=x//b
cc=c//c
ans=0
for ai in range(aa):
  for bi in range(bb):
    for ci in range(cc):
      y=500*ai+100*bi+50*ci
      if x == y:
        ans+=1
      if y>x:
        break
print(ans)

Fixed submission:
A=input()
B=input()
C=input()
X=input()
sum=0
for a in range(int(A)+1):
    for b in range(int(B)+1):
        for c in range(int(C)+1):
            if 500*a+100*b+50*c==int(X):
                sum+=1
print(sum)
Buggy python submission (verdict: Runtime Error):
a,b=int(input().split())
a*=b
print("Even" if a%2 == 0 else "Odd")

Fixed submission:
a,b=list(map(int,input().split()))
if a%2==0 or b%2==0:
	print('Even')
else:
	print('Odd')

Buggy python submission (verdict: Runtime Error):
a=int(input())*int(input())
print("Even" if a%2 == 0 else "Odd")

Fixed submission:
a,b=list(map(int,input().split()))
if a%2==0 or b%2==0:
	print('Even')
else:
	print('Odd')
Buggy python submission (verdict: Time Limit Exceeded):
cond=list(map(int,input().split()))
X=int(cond[1]/1000 - cond[0])
T=True
x=0
while T and x<=int(cond[1]/10000):
    for y in range(int(cond[1]/5000)+1):
        if ((X-9*x)%4!=0):
           continue
        else:
           XX=x
           Y=(cond[1]/1000 - cond[0] - 9*x)/4
           Z=cond[0]-XX-Y
           if Z<0:
               XX=Y=Z=None
               continue
           elif Y<0:
               XX=Y=Z=None
               continue
           else:
               T=False
               break
    x+=1
if len(str(Z))==0 or Z==None:
    print('-1 -1 -1')
else:
    print(int(XX), int(Y), int(Z))

Fixed submission:
cond=list(map(int,input().split()))
X=int(cond[1]/1000 - cond[0])
T=True
x=0
while T and x<=int(cond[1]/10000):
    for y in range(int(cond[1]/5000)+1):
        if ((X-9*x)%4!=0):
           continue
        else:
           XX=x
           Y=(cond[1]/1000 - cond[0] - 9*x)/4
           Z=cond[0]-XX-Y
           if Z<0:
               XX=Y=Z=None
               continue
           elif Y<0:
               XX=Y=Z=None
               continue
           else:
               T=False
               break
    x+=1
if len(str(Z))==0 or Z==None:
    print('-1 -1 -1')
else:
    print(int(XX), int(Y), int(Z))
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  ii=list(i)
  ii=sum(ii)
  if ii in range(a,b+1):
    ans+=i
print(ans)

Fixed submission:
a=list(map(int,input().split()))
sumy=0
for i in range(int(a[0]+1)):
    b=[]
    b+=str(i)
    c=0
    for t in range(len(b)):
        c+=int(b[t])
    if c>=a[1] and c<=a[2]:
        sumy+=i
print(sumy)
Buggy python submission (verdict: Runtime Error):
import(sys)
n=int(input())
a = list(map(int,input().split()))
b=0
while(True):
  for i in range(n):
    if(a[i]%2!=0):
      print(b)
      sys.exit()
    a[i]=a[i]//2
  b+=1
print(b)

Fixed submission:
N=input()
a=list(map(int,input().split()))
i=0
count=-1
b=[]
c=True
while c:
    i=0
    count+=1
    while i<int(N):
        if a[i]%2!=0:
            c=False
            break
        else:
            a[i]=a[i]/2
            i+=1
print(int(count))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = list(map(int,input().split()))
b=0
while(True):
  for i in range(n):
    if(a[i]%2!=0):
      break
    a[i]=a[i]//2
  b+=1
print(b)

Fixed submission:
N=input()
a=list(map(int,input().split()))
i=0
count=-1
b=[]
c=True
while c:
    i=0
    count+=1
    while i<int(N):
        if a[i]%2!=0:
            c=False
            break
        else:
            a[i]=a[i]/2
            i+=1
print(int(count))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = list(map(int,input().split()))
b=0
while(True):
  for i in range(n):
    if(a[i]%2!=0):
      break
  b+=1
print(b)

Fixed submission:
N=input()
a=list(map(int,input().split()))
i=0
count=-1
b=[]
c=True
while c:
    i=0
    count+=1
    while i<int(N):
        if a[i]%2!=0:
            c=False
            break
        else:
            a[i]=a[i]/2
            i+=1
print(int(count))
Buggy python submission (verdict: Runtime Error):
def abis(l, key):
    le = 0
    ri = n
    while le < ri:
        mid = (le + ri) // 2
        if mid == n:
            return mid
        elif l[mid] == key:
            while mid<n and l[mid-1]==l[mid]:
                mid-=1
            return mid
        elif l[mid] > key:
            if mid != 0 and l[mid - 1] < key:
                return mid
            ri = mid
        else:
            le = mid + 1
    return mid + 1

def cbis(l, key):
    le = 0
    ri = n
    while le < ri:
        mid = (le + ri) // 2
        if mid == n:
            return 0
        elif l[mid] == key:
            while mid<n and l[mid+1]==l[mid]:
                mid+=1
            return n-mid-1
        elif l[mid] > key:
            if mid != 0 and l[mid - 1] < key:
                return n-mid
            ri = mid
        else:
            le = mid + 1
    return n-mid



n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
    aa = abis(a, b[i])
    ca = cbis(c, b[i])
    ans += aa * ca
print(ans)


Fixed submission:
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
    aa = bisect.bisect_left(a,b[i])
    ca = n-bisect.bisect_right(c,b[i])
    ans += aa * ca
print(ans)
Buggy python submission (verdict: Runtime Error):
a=input()
b=""
for i in range(len(a),0,-1):
  b+=a[i]
if a==b:
  print("Yes")
else:
  print("No")

Fixed submission:
a=input()
b=""
for i in range(1,len(a)+1):
  b+=a[-i]
if a==b:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
a=input()
b=""
for i in range(a,0,-1):
  b+=a[i]
if a==b:
  print("Yes")
else:
  print("No")

Fixed submission:
a=input()
b=""
for i in range(1,len(a)+1):
  b+=a[-i]
if a==b:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n=int(input())
a=[int(input()) for _ in range(n)]
l=[1]
i=0
aa=1
while True:
    aa=a[aa-1]
    if aa == 2:
        print(i+1)
        sys.exit()
    if aa in l:
        print(-1)
        sys.exit()
    l.append(aa)
    i+=1

Fixed submission:
import sys
import cProfile
input = sys.stdin.readline
def main():
    n=int(input())
    a=[int(input()) for _ in range(n)]
    l=[1]
    i=0
    aa=1
    while True:
        aa=a[aa-1]
        if aa == 2:
            print(i+1)
            sys.exit()
        if i>n:
            print(-1)
            sys.exit()
        i+=1
main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import cProfile
input = sys.stdin.readline
def main():
    n=int(input())
    a=[int(input()) for _ in range(n)]
    l=[1]
    i=0
    aa=1
    while True:
        aa=a[aa-1]
        if aa == 2:
            print(i+1)
            sys.exit()
        if aa in l:
            print(-1)
            sys.exit()
        l.append(aa)
        i+=1
main()

Fixed submission:
import sys
import cProfile
input = sys.stdin.readline
def main():
    n=int(input())
    a=[int(input()) for _ in range(n)]
    l=[1]
    i=0
    aa=1
    while True:
        aa=a[aa-1]
        if aa == 2:
            print(i+1)
            sys.exit()
        if i>n:
            print(-1)
            sys.exit()
        i+=1
main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n=int(input())
a=[int(input()) for _ in range(n)]
l=[1]
i=0
aa=1
while True:
    aa=a[aa-1]
    if aa == 2:
        print(i+1)
        sys.exit()
    if aa in l:
        print(-1)
        sys.exit()
    l.append(aa)
    i+=1
print(-1)

Fixed submission:
import sys
import cProfile
input = sys.stdin.readline
def main():
    n=int(input())
    a=[int(input()) for _ in range(n)]
    l=[1]
    i=0
    aa=1
    while True:
        aa=a[aa-1]
        if aa == 2:
            print(i+1)
            sys.exit()
        if i>n:
            print(-1)
            sys.exit()
        i+=1
main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n=int(input())
a=[int(input()) for _ in range(n)]
l=[1]
i=0
aa=1
while True:
    aa=a[aa-1]
    if aa == 2:
        print(i+1)
        sys.exit()
    if aa in l:
        print(-1)
        sys.exit()
    l.append(aa)
    i+=1
print(-1)

Fixed submission:
import sys
import cProfile
input = sys.stdin.readline
def main():
    n=int(input())
    a=[int(input()) for _ in range(n)]
    l=[1]
    i=0
    aa=1
    while True:
        aa=a[aa-1]
        if aa == 2:
            print(i+1)
            sys.exit()
        if i>n:
            print(-1)
            sys.exit()
        i+=1
main()
Buggy python submission (verdict: Runtime Error):
s=input()
ss=s[0]
sss=upper(ss)
print("A"+sss+"C")

Fixed submission:
s=input()
ss=s[8]
print("A"+ss+"C")

Buggy python submission (verdict: Runtime Error):
print('A'+upper(input()[0])+'C')

Fixed submission:
s=input()
ss=s[8]
print("A"+ss+"C")
Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = int(input())
ans = 0
for i in range(1, N):
    temp = len(make_divisors(N-i))
    #print(make_divisors(N-i), temp)
    ans += temp
print(ans)


Fixed submission:
N = int(input())
ans = 0
for i in range(1, N):
    ans += (N-1)//i
    #print(N//i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split()))

A_sum_list = [A_list[N-1]]
ans = A_list[N-1]*A_list[N-2]

for i in range(N-1, 1, -1):
    sum_temp = A_sum_list[0] + A_list[i-1]
    A_sum_list.insert(0, sum_temp)
    ans += (sum_temp * A_list[i-2])

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

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

A_sum_list = [A_list[N-1]]
ans = A_list[N-1]*A_list[N-2]
sum_temp_old = A_list[N-1]

for i in range(N-1, 1, -1):
    sum_temp = sum_temp_old + A_list[i-1]
    sum_temp_old = sum_temp
    ans += (sum_temp * A_list[i-2])

#print(A_sum_list)
print(ans%(10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
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)

ab_list = []
ans =0
for i in range(M):
    a,b = map(int, input().split())
    a, b = a-1, b-1
    ab_list.append([a, b])

for i in range(M):
    uf.union(ab_list[i][0], ab_list[i][1])

ans = 0
ans_list = list(uf.all_group_members().values())
for i in range(len(ans_list)):
    ans = max(ans,len(ans_list[i]))

print(ans)


Fixed submission:
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)

ab_list = []
ans =0
for i in range(M):
    a,b = map(int, input().split())
    a, b = a-1, b-1
    uf.union(a, b)

ans = 0
ans_list = uf.roots()
for i in range(len(ans_list)):
    ans = max(ans, uf.size(ans_list[i]))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = int(input())
A_list = list(map(int, input().split()))
A_list_min = sorted(A_list)

if gcd(*A_list) != 1:
    print("not coprime")
else:
    for i in range(len(A_list)):
        for j in range(i+1, len(A_list)):
            if gcd(A_list[i], A_list[j]) != 1:
                print("setwise coprime")
                exit()
    print("pairwise coprime")



Fixed submission:
import math
L = 10**6 + 1

N = int(input())
A = list(map(int, input().split()))
memo = [0] * L
flag = 0 # 0をpairwise coprime

for a in A:
    memo[a] += 1

for i in range(2, L): # すべてでgcdが1ということは、対象の数字ごとのステップに数字がないことと同じ
    if sum(memo[i::i]) > 1: # memo[i] + memo[2i] +... + memo[ni] memo[i]の倍数があれば sum は 2 以上になる
        flag = 1
        break

g = 0
for i in range(N):
    g = math.gcd(g, A[i])

if flag == 0:
    answer = 'pairwise coprime'
elif flag == 1 and g == 1:
    answer = 'setwise coprime'
else:
    answer = 'not coprime'

print(answer)