Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, x = LI()
    a = LI()

    s = [max(a[i] + a[i+1] - x, 0) for i in range(N - 1)]
    
    ans = sum([ss[i] for i in range(len(s)) if i % 2 == 0])
    print(ans)

if __name__ == '__main__':
    resolve()


Fixed submission:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, x = LI()
    a = LI()

    # 隣り合う2つの和
    s = [a[i] + a[i+1] for i in range(N - 1)]
    # 隣り合う2つの和をx以下にしたもの
    s_after = [min(i, x) for i in s]

    # 隣り合う2つの和をx以下にしたものから元の数列を復元
    a_after = [0] * N
    a_after[0] = min(a[0], s_after[0])
    for i in range(N - 1):
        a_after[i+1] = min(s_after[i] - a_after[i], a[i+1])

    ans = sum(a) - sum(a_after)
    print(ans)

if __name__ == '__main__':
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, m = map(int, input().split())
    s = [[j] for j in range(n)]
    for _ in range(m):
        a,b  = map(int, input().split())
        a-=1
        b-=1
        s[a].append(b)
        s[b].append(a)
    for i in range(n):
        for j in s[i]:
            s[j]=list(set(s[j]+s[i]))

    ans=0
    for i in range(len(s)):
        ans=max(len(s[i]),ans)
    print(ans)
resolve()

Fixed submission:
def resolve():
    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())
    s = [j for j in range(n)]
    uf=UnionFind(n)
    for _ in range(m):
        a,b  = map(int, input().split())
        a-=1
        b-=1
        uf.union(a,b)

    ans=0
    for i in range(n):
        ans=max(uf.size(i),ans)
    print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    n=int(input())
    a=[0]*(10001)
    nn=int(n**0.5)
    for x in range(1,nn):
        for y in range(1, nn):
            for z in range(1, nn):
                a[x**2+y**2+z**2+x*y+y*z+z*x]+=1
    for i in range(n):
        print(a[i+1])
resolve()

Fixed submission:
def resolve():
    n=int(input())
    a=[0]*(60000)
    nn=int(n**0.5)
    for x in range(1,nn):
        for y in range(1, nn):
            for z in range(1, nn):
                a[x**2+y**2+z**2+x*y+y*z+z*x]+=1
    for i in range(n):
        print(a[i+1])
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n=int(input())
    a = list(map(int, input().split()))
    ans=sum(a)
    q=int(input())
    a_dict = {}
    for i in set(a):
        a_dict[str(i)] = 0
    for j in a:
        a_dict[str(j)] += 1
    ch=list(a_dict.keys())
    for _ in range(q):
        b,c = map(str, input().split())
        if b in ch:
            d = a_dict[b]
            a_dict[b]=0
            if c in ch:
                a_dict[c] += d
            else:
                a_dict[c] = d
                ch.append(c)
            ans=ans-d*(int(b)-int(c))
            print(ans)
        else:
            print(ans)
resolve()

Fixed submission:
def resolve():
    n=int(input())
    ac = list(map(int, input().split()))
    ans=sum(ac)
    q=int(input())
    a=[0]*(10**5+1)
    for i in ac:
        a[i]+=1
    for _ in range(q):
        b,c = map(int, input().split())
        g=a[b]
        a[b]=0
        a[c]+=g

        ans=ans-g*(b-c)
        print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():

    n, m,x = map(int, input().split())
    c=[]
    a=[]
    ans=10**13
    nedan=0
    rikai=[0]*m
    for i in range(n):
        A = list(map(int, input().split()))
        c.append(A[0])
        a.append(A[1:])
        for j in range(m):
            rikai[j]+=a[i][j]
    if min(rikai)>=x:
        for Bin in range(2**n):
            N = [str(x) for x in list(str(bin(Bin+2**13)))]
            N.pop(0)
            N.pop(0)
            for hon in range(n):
                if N[hon + 1] == 1:
                    for aru in range(m):
                        rikai[aru]+=a[hon][aru]
                    nedan+=c[hon]
            if min(rikai)>=x:
                ans=min(ans,nedan)
            rikai=[]
            nedan=0
        print(ans)

    else:
        print(-1)
resolve()

Fixed submission:
def resolve():

    n, m,x = map(int, input().split())
    c=[]
    a=[]
    ans=10**13
    nedan=0
    rikai=[0]*m
    for i in range(n):
        A = list(map(int, input().split()))
        c.append(A[0])
        a.append(A[1:])
        for j in range(m):
            rikai[j]+=a[i][j]

    if min(rikai)>=x:
        for Bin in range(1,2**n):
            rikai = [0] * m
            nedan = 0
            for hon in range(n):
                if (Bin>>hon) & 1:
                    for aru in range(m):
                        rikai[aru]+=a[hon][aru]
                    nedan+=c[hon]
            if min(rikai)>=x:
                ans=min(ans,nedan)
        print(ans)

    else:
        print(-1)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    roop=0
    iti=0
    rirekin=0
    rireki=[]
    while roop==0:
        iti=a[iti]-1
        if iti in rireki:
            mae=rireki.index(iti)
            Mae=rireki[:mae]
            del rireki[:mae]
            roop=rirekin-mae
            break
        rireki.append(iti)
        rirekin+=1
    if k <= mae:
        print(Mae[k-1]+1)
    else:
        k-=mae
        print(rireki[(k%roop)-1]+1)
resolve()

Fixed submission:
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    check=[-1]*n
    iti=0
    rireki=[]
    while True:
        iti=a[iti]-1
        if check[iti]==0:
            mae=rireki.index(iti)
            Mae=rireki[:mae]
            Loop=rireki[mae:]
            roop=len(Loop)
            break
        rireki.append(iti)

        check[iti]=0
    if k <= mae:
        print(Mae[k-1]+1)
    else:
        k-=mae
        print(Loop[(k%roop)-1]+1)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * m
    b = [0] * m
    s = [[-1] for j in range(n)]
    ans=0
    for i in range(m):
        a[i], b[i] = map(int, input().split())
    for i in range(m):
        s[a[i]-1].append(b[i])
        s[b[i]-1].append(a[i])
    for i in range(n):
        if len(s[i])!=1:
            for j in s[i]:
                if j!=-1:
                    if h[i]<=h[j-1]:
                        y=0
            if not y:
               ans+=1
            y=1
    print(ans)
resolve()

Fixed submission:
def resolve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * m
    b = [0] * m
    s = [[-1] for j in range(n)]
    ans=0
    x=1
    for i in range(m):
        a[i], b[i] = map(int, input().split())
    for i in range(m):
        s[a[i]-1].append(b[i])
        s[b[i]-1].append(a[i])
    for i in range(n):
        if len(s[i])!=1:
            for j in s[i]:
                if j!=-1:
                    if h[i]<=h[j-1]:
                        x=0
        ans+=x
        x=1
    print(ans)
resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * m
    b = [0] * m
    s = [[0] for j in range(n)]
    ans=0
    for i in range(m):
        a[i], b[i] = map(int, input().split())
    for i in range(m):
        s[a[i]-1].append(b[i])
        s[b[i]-1].append(a[i])
    for i in range(n):
        if len(s[i])!=1:
            for j in s[i]:
                if j!=0:
                    if h[i]<=h[j-1]:
                        y=0
            if not y:
               ans+=1
            y=1
    print(ans)
resolve()

Fixed submission:
def resolve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * m
    b = [0] * m
    s = [[-1] for j in range(n)]
    ans=0
    x=1
    for i in range(m):
        a[i], b[i] = map(int, input().split())
    for i in range(m):
        s[a[i]-1].append(b[i])
        s[b[i]-1].append(a[i])
    for i in range(n):
        if len(s[i])!=1:
            for j in s[i]:
                if j!=-1:
                    if h[i]<=h[j-1]:
                        x=0
        ans+=x
        x=1
    print(ans)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n=int(input())
    a = list(map(int, input().split()))
    b=[0]*n
    c=[0]*n
    ans=0
    for i in range(n):
        b[i]=a[i]+i
    for i in range(n):
        c[i]=i-a[i]
    bc=set(b).intersection(set(c))
    bd={}
    cd={}
    for i in bc:
        bd[i]=0
        for j in b:
            if j==i:
                bd[i]+=1
    for i in bc:
        cd[i]=0
        for j in c:
            if j ==i:
                cd[i]+=1
    ansb=list(bd.values())
    ansc=list(cd.values())
    for k in range(len(bc)):
        ans+=ansb[k]*ansc[k]
    print(ans)
resolve()

Fixed submission:
def resolve():
    n=int(input())
    a = list(map(int, input().split()))
    b=[0]*n
    c=[0]*n
    ans=0
    for i in range(n):
        b[i]=a[i]+i
    for i in range(n):
        c[i]=i-a[i]
    bc=set(b).intersection(set(c))
    bd={}
    cd={}
    for i in bc:
        bd[i]=0
    for j in b:
            if j in bc:
                bd[j]+=1
    for i in bc:
        cd[i]=0
    for j in c:
            if j in bc:
                cd[j]+=1
    ansb=list(bd.values())
    ansc=list(cd.values())
    for k in range(len(bc)):
        ans+=ansb[k]*ansc[k]
    print(ans)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n=int(input())
    b=[]
    k=1
    ans=0
    for i in range(n):
        a=input()
        for j in b:
            if j==a:
                k=0
        ans+=k
        k=1
        b.append(a)
    print(ans)
resolve()

Fixed submission:
def resolve():
    n=int(input())
    s = [input() for _ in range(n)]
    print(len(set(s)))
resolve()
Buggy python submission (verdict: Runtime Error):
print((int(input())**2)

Fixed submission:
print((int(input()))**2)

Buggy python submission (verdict: Runtime Error):
r=input()
print(r**2)

Fixed submission:
print((int(input()))**2)
Buggy python submission (verdict: Runtime Error):
r,d,x=list(map(int,input().split()))
for i in 9:
  x=r*x-d
  print(x)

Fixed submission:
r,d,x=list(map(int,input().split()))
for i in range(10):
  x=r*x-d
  print(x)
Buggy python submission (verdict: Runtime Error):
def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    B=[]
    ans=0
    k=0
    j=0
    for _ in range(m):
        a, b = map(int, input().split())
        B.append([b,a])
    for i in A:
        B.append([i,1])
    B.sort(reverse=True)
    f=B[0][1]
    while f<n:
        k+=B[j][1]
        f+=B[j+1][1]
        ans+=B[j][0]*B[j][1]
        j+=1
    ans+=B[j][0]*(n-k)

    print(ans)
resolve():

Fixed submission:
def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    B=[]
    ans=0
    k=0
    j=0
    for _ in range(m):
        a, b = map(int, input().split())
        B.append([b,a])
    for i in A:
        B.append([i,1])
    B.sort(reverse=True)
    f=B[0][1]
    while f<n:
        k+=B[j][1]
        f+=B[j+1][1]
        ans+=B[j][0]*B[j][1]
        j+=1
    ans+=B[j][0]*(n-k)

    print(ans)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    for _ in range(m):
        a, b = map(int, input().split())
        for __ in range(a):
            A.append(b)
    A.sort(reverse=True)
    print(sum(A[0:n]))
resolve()

Fixed submission:
def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    B=[]
    ans=0
    k=0
    j=0
    for _ in range(m):
        a, b = map(int, input().split())
        B.append([b,a])
    for i in A:
        B.append([i,1])
    B.sort(reverse=True)
    f=B[0][1]
    while f<n:
        k+=B[j][1]
        f+=B[j+1][1]
        ans+=B[j][0]*B[j][1]
        j+=1
    ans+=B[j][0]*(n-k)

    print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=[i-j,if i-j>0 else 0 for i,j in zip(v,c)]
print(sum(t))


Fixed submission:
a,b,t = map(int,input().split())
print(b*(t//a))

Buggy python submission (verdict: Runtime Error):
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
for i in range(n)
t[i]=v[i]-c[i]
a=0
for i in range(n)
if t[i]>0 :
a+=t[i]
print(a)

Fixed submission:
a,b,t = map(int,input().split())
print(b*(t//a))

Buggy python submission (verdict: Runtime Error):
import numpy as np
n=input()
v=np.array(map(int, input().split()))
c=np.array(map(int, input().split()))
t=v-c
a=0
for i in range(n)
if t[i]>0 :
a+=t[i]
print(a)

Fixed submission:
a,b,t = map(int,input().split())
print(b*(t//a))
Buggy python submission (verdict: Runtime Error):
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=[i-j,if i-j>0 else 0 for i,j in zip(v,c)]
print(sum(t))

Fixed submission:
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=[i-j if i-j>0 else 0 for i,j in zip(v,c)]
print(sum(t))

Buggy python submission (verdict: Runtime Error):
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
for i in range(n)
t[i]=v[i]-c[i]
a=0
for i in range(n)
if t[i]>0 :
a+=t[i]
print(a)

Fixed submission:
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=[i-j if i-j>0 else 0 for i,j in zip(v,c)]
print(sum(t))

Buggy python submission (verdict: Runtime Error):
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=v-c
a=0
for i in range(n)
if t[i]>0 :
a+=t[i]
print(a)

Fixed submission:
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=[i-j if i-j>0 else 0 for i,j in zip(v,c)]
print(sum(t))

Buggy python submission (verdict: Runtime Error):
import nmpy as np
n=input()
v=np.array(map(int, input().split()))
c=np.array(map(int, input().split()))
t=v-c
a=0
for i in range(n)
if t[i]>0 :
a+=t[i]
print(a)


Fixed submission:
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=[i-j if i-j>0 else 0 for i,j in zip(v,c)]
print(sum(t))

Buggy python submission (verdict: Runtime Error):
import nmpy as np
n=input()
v=np.array(map(int, input().split()))
c=np.array(map(int, input().split()))
t=v-c
a=0
for i in range(n)
if t[i]>0 :
a+=t[i]
print(a)


Fixed submission:
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=[i-j if i-j>0 else 0 for i,j in zip(v,c)]
print(sum(t))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  if a[i] <= a[i+1]:
    b=i+2
  else:
    print(b)
    exit()

Fixed submission:
a,b=map(int, input().split())
print(max(2*a-1,2*b-1,a+b))
Buggy python submission (verdict: Runtime Error):
s=input()
a,b=0
for i in s:
  if i in "ATGC" :
    a+=1
  else:
    b=max(a,b)
    a=0
print(max(a,b))

Fixed submission:
s=input()
a=0
b=0
for i in s:
  if i in "ATGC" :
    a+=1
  else:
    b=max(a,b)
    a=0
print(max(a,b))

Buggy python submission (verdict: Runtime Error):
s=input()
a=0
for i in s:
  if i in "ATGC" :
    a+=1
  else:
    b=a
    a=0
print(max(a,b))

Fixed submission:
s=input()
a=0
b=0
for i in s:
  if i in "ATGC" :
    a+=1
  else:
    b=max(a,b)
    a=0
print(max(a,b))

Buggy python submission (verdict: Runtime Error):
s=input()
a=0
for i in s:
  if i in ATGC:
    a+=1
  else:
    b=a
    a=0
print(max(a,b))

Fixed submission:
s=input()
a=0
b=0
for i in s:
  if i in "ATGC" :
    a+=1
  else:
    b=max(a,b)
    a=0
print(max(a,b))

Buggy python submission (verdict: Runtime Error):
s=list(map(str,input().split()))
a=0
for i in s:
  if i in ATGC:
    a+=1
  else:
    b=a
    a=0
print(max(a,b))

Fixed submission:
s=input()
a=0
b=0
for i in s:
  if i in "ATGC" :
    a+=1
  else:
    b=max(a,b)
    a=0
print(max(a,b))
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s=input()
for i in range(q):
  l,r = map(int, input().split())
  t=s[l-1:r].count("AC")
  print(t)

Fixed submission:
n, q = map(int, input().split())
s=input()
d=[0]*n
c=0
for i in range(n-1):
  if s[i:i+2]=="AC":
    c+=1
  d[i+1]=c
for i in range(q):
  l,r= map(int, input().split())
  print(d[r-1]-d[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s=input()
l=[0]*q
r=[0]*q
t=[0]*q
for i in range(q):
  l[i],r[i] = map(int, input().split())
  t[i]=s[l[i]-1:r[i]].count("AC")
  print(t[i])

Fixed submission:
n, q = map(int, input().split())
s=input()
d=[0]*n
c=0
for i in range(n-1):
  if s[i:i+2]=="AC":
    c+=1
  d[i+1]=c
for i in range(q):
  l,r= map(int, input().split())
  print(d[r-1]-d[l-1])

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s=input()
for i in range(n):
  l[i],r[i] = map(int, input().split())
  t[i]=s[l[i]:r[i]+1].count("AC")
  print(t(i))

Fixed submission:
n, q = map(int, input().split())
s=input()
d=[0]*n
c=0
for i in range(n-1):
  if s[i:i+2]=="AC":
    c+=1
  d[i+1]=c
for i in range(q):
  l,r= map(int, input().split())
  print(d[r-1]-d[l-1])

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s=input()
for i in range(n):
  l[i],r[i] = map(int, input().split())
  t[i]=s[l[i]:r[i+1]].count("AC")
  print(t(i))

Fixed submission:
n, q = map(int, input().split())
s=input()
d=[0]*n
c=0
for i in range(n-1):
  if s[i:i+2]=="AC":
    c+=1
  d[i+1]=c
for i in range(q):
  l,r= map(int, input().split())
  print(d[r-1]-d[l-1])
Buggy python submission (verdict: Runtime Error):
a,b,k= map(int, input().split())
n=min(a,b)
m=[]
i=1
j=1
while n//2<m:
  if j=k:
    print(i)
    exit()
  else:
    i+=1
    if a%i==0 and b%i==0:
      j+=1

Fixed submission:
a,b,k= map(int, input().split())
i=min(a,b)
j=0
while j!=k :
    if a%i==0 and b%i==0:
      j+=1
      if j==k:
        print(i)
        exit()
    i-=1
Buggy python submission (verdict: Time Limit Exceeded):
import sys 
s=input()
t=input()
n=len(s)
for i in range(n):
        for j in range(i,n):
          if s[i]==s[j] and t[i]!=t[j]:
              print("No")
              exit()
          if s[i]!=s[j] and t[i]==t[j]:
              print("No")
              exit()
print("Yes")

Fixed submission:
s = input()
t = input()
n = len(s)
r=[-1]*26
r2=[-1]*26
abcd = 'abcdefghijklmnopqrstuvwxyz'

def f(l,l2,R):
  for i in range(n):
    if R[abcd.index(l[i])]==-1 or R[abcd.index(l[i])]==l2[i]:
       R[abcd.index(l[i])]=l2[i]
    else:
       print("No")
       exit()

f(s,t,r)
f(t,s,r2)
print("Yes")
Buggy python submission (verdict: Runtime Error):
import sys,os
import math
from fractions import Fraction 
from collections import defaultdict
from random import randint

# sys.stderr=open('err.txt','w')
# sys.stdout=open('output.txt','w')
# sys.stdin=open('input.txt','r')

def linput():
    return list(minput())

def minput():
    return map(int, sys.stdin.readline().strip().split())

###############################################################

def make_set(a,parent):
    parent[a]=a

def find_set(a,parent):
    if parent[a]==a:
        return a
    parent[a]=find_set(parent[a])
    return parent[a]

def union_set(a,b,parent):
    x=find_set(a)
    y=find_set(b)
    if x==y:
        return
    else:
        parent[y]=x

n,m=minput()
parent=[0]*n
for i in range(n):
    make_set(i,parent)
ans=0
for i in range(m):
    x,y=minput()
    if x>y:
        x,y=y,x
    x=x-1
    y=y-1
    union_set(x,y,parent)
# print(parent)
di = defaultdict(int)
for i in parent:
    di[i]+=1
# print(di)
for k,v in di.items():
    ans=max(ans,v)
print(ans)


Fixed submission:

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

par = [i for i in range(N)]

def find(x):
  if par[x] == x:
    return x
  else:
    par[x] = find(par[x])
    return par[x]
    

def unite(x, y):
  x = find(x)
  y = find(y)
  if x > y:
    par[x] = y
    find(x)
  else:
    par[y] = x
    find(y)
if M > 0:  
  for i in range(M):
    a, b = map(int, input().split())
    unite(a - 1, b - 1)
  
  ans = [0] * N
  Max = 0
  for i in range(N):
    find(i)
  for i in par:
    ans[i] += 1
  for i in ans:
    if i > Max:
      Max = i
  
  print(Max)
else:
  print(1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
s = 0
t = sum(a)
m = 10 ** 9 + 7
for i in range(n - 1):
    s += a[i] * (t - sum(a[0:i + 1])) % m
print(s % m)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
t = 0
m = 10 ** 9 + 7
for i in range(n - 1):
    s -= a[i]
    t += a[i] * s % m
print(t % m)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
a = list(map(int, input().split()))
m = 10 ** 9 + 7
s = 0
for c in itertools.combinations(range(n), 2):
    s += a[c[0]] * a[c[1]] % m
print(s % m)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
t = 0
m = 10 ** 9 + 7
for i in range(n - 1):
    s -= a[i]
    t += a[i] * s % m
print(t % m)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = [1] * (n - k + 1)
for i in range(k):
    s[0] *= a[i]
for i in range(1, n - k + 1):
    s[i] = int(s[i - 1] / a[i - 1] * a[k + i - 1])
for i in range(n - k):
    print('Yes' if s[i] < s[i + 1] else 'No')

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(1, n - k + 1):
    print('Yes' if 1 < a[k + i - 1] / a[i - 1] else 'No')

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = [0] * (n - k + 1)
for i in range(n - k + 1):
    p = 1
    for j in range(i, i + k):
        p *= a[j]
    s[i] = p
for i in range(n - k):
    print('Yes' if s[i] < s[i + 1] else 'No')

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(1, n - k + 1):
    print('Yes' if 1 < a[k + i - 1] / a[i - 1] else 'No')