Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
while a.count(["."]*len(a[0]))>0:
    a.remove(["."]*len(a[0]))

a_t = tenchi(a)
while a_t.count(["."]*len(a_t[0]))>0:
    a_t.remove(["."]*len(a_t[0]))
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

Fixed submission:
def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
while a.count(["."]*len(a[0]))>0:
    a.remove(["."]*len(a[0]))

a_t = tenchi(a)
while a_t.count(["."]*len(a_t[0]))>0:
    a_t.remove(["."]*len(a_t[0]))
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

Buggy python submission (verdict: Runtime Error):
H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
for i in range(1,H):
    if a[-i]==["."]*W:
        a.pop(-i)
a_t = tenchi(a)
for i in range(1,len(a_t)):
    if a_t[-i]==["."]*len(a):
        a_t.pop(-i)
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

Fixed submission:
def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
while a.count(["."]*len(a[0]))>0:
    a.remove(["."]*len(a[0]))

a_t = tenchi(a)
while a_t.count(["."]*len(a_t[0]))>0:
    a_t.remove(["."]*len(a_t[0]))
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

Buggy python submission (verdict: Runtime Error):
H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
for i in range(1,H):
    if a[-i]==["."]*W:
        a.pop(-i)
a_t = tenchi(a)
for i in range(1,len(a_t)):
    if a_t[-i]==["."]*len(a):
        a_t.pop(-i)
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

Fixed submission:
def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
while a.count(["."]*len(a[0]))>0:
    a.remove(["."]*len(a[0]))

a_t = tenchi(a)
while a_t.count(["."]*len(a_t[0]))>0:
    a_t.remove(["."]*len(a_t[0]))
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)
Buggy python submission (verdict: Runtime Error):
S = input()
S.sort()
if S == "abc":
	print("Yes")
else: print("No")

Fixed submission:
S =list(input())
S.sort()
if S ==["a","b","c"]:
    print("Yes")
else: print("No")
Buggy python submission (verdict: Runtime Error):
A = [int(input()) for i in range(4)]
print(min(A[0]+A[1])+min(A[2]+A[3]))

Fixed submission:
A = [int(input()) for i in range(4)]
print(min(A[0],A[1])+min(A[2],A[3]))
Buggy python submission (verdict: Runtime Error):
5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO

Fixed submission:
import collections
N = int(input())
S = [input() for i in range(N)]
SI = [S[i][0] for i in range(N)]
cnt = collections.Counter(SI)
n = [cnt["M"],cnt["A"],cnt["R"],cnt["C"],cnt["H"]]
ans = 0
for i in range(3):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans += n[i]*n[j]*n[k]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K =map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Aset = list(set(A))
Aset.sort()
NumA =[0]*len(Aset)
for i in range(len(Aset)):
    NumA[i]=A.count(Aset[i])
NumA.sort()
ans = 0
for i in range(len(Aset)-K):
    ans += NumA[i]
print(ans)

Fixed submission:
#ABC081C
import collections
N, K =map(int,input().split())
A = list(map(int,input().split()))
c = collections.Counter(A)
NumA = list(c.values())
NumA.sort()
ans = 0
#print(NumA)
for i in range(len(set(A))-K):
    ans += NumA[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
N =input()
if N.count(N[0])>2 or N.count(N[1]>2):
	print("Yes")
else: print("No")

Fixed submission:
N = input()
if N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
	print("Yes")
else: print("No")
Buggy python submission (verdict: Time Limit Exceeded):
def Lucas(L):
    if L == 0:
        return 2
    elif L == 1:
        return 1
    else: return Lucas(L-1)+ Lucas(L-2)

N = int(input())
print(Lucas(N))

Fixed submission:
ans = [2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349,\
       15127, 24476, 39603, 64079, 103682, 167761, 271443, 439204, 710647, 1149851, 1860498, 3010349, \
       4870847, 7881196, 12752043, 20633239, 33385282, 54018521, 87403803, 141422324, 228826127, \
       370248451, 599074578, 969323029, 1568397607, 2537720636, 4106118243, 6643838879, 10749957122, \
       17393796001, 28143753123, 45537549124, 73681302247, 119218851371, 192900153618, 312119004989, \
       505019158607, 817138163596, 1322157322203, 2139295485799, 3461452808002, 5600748293801, \
       9062201101803, 14662949395604, 23725150497407, 38388099893011, 62113250390418, 100501350283429, \
       162614600673847, 263115950957276, 425730551631123, 688846502588399, 1114577054219522, \
       1803423556807921, 2918000611027443, 4721424167835364, 7639424778862807, 12360848946698171, \
       20000273725560978, 32361122672259149, 52361396397820127, 84722519070079276, 137083915467899403, \
       221806434537978679, 358890350005878082, 580696784543856761, 939587134549734843, 1520283919093591604]

N = int(input())
print(ans[N])
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = [int(input()) for i in range(N)]
c = collections.Counter(A)
ans = 0
for i in range(len(c)):
    ans += c.most_common()[i][1] % 2
print(ans)

Fixed submission:
import collections
N = int(input())
A = [int(input()) for i in range(N)]
c = collections.Counter(A).most_common()
ans = 0
for i in range(len(c)):
    ans += c[i][1] % 2
print(ans)
Buggy python submission (verdict: Runtime Error):
print(max(0,int(input())-int(input())))

Fixed submission:
x, t =map(int,input().split())
print(max(0,x-t))
Buggy python submission (verdict: Runtime Error):
H, W = map(int,input().split())
N = int(input())
a = list(map(int,input().split()))
b =[0]*(H*W)
k = 0
for i in range(N):
    for j in range(a[i]):
        b[k] = i + 1
        k += 1
x, y = 0, 0
ans =[[0]*W for i in range(W)]
for i in range(H*W):
    ans[y][x] = b[i]
    if x == 0 and y%2 == 1 or x == W - 1 and y%2 == 0:
        y += 1
    elif y%2 == 0:
        x += 1
    else:
        x -= 1
for _ in range(H):
    print(*ans[_])

Fixed submission:
H, W = map(int,input().split())
N = int(input())
a = list(map(int,input().split()))
b =[0]*(H*W)
k = 0
for i in range(N):
    for j in range(a[i]):
        b[k] = i + 1
        k += 1
x, y = 0, 0
ans =[[0]*W for i in range(H)]
for i in range(H*W):
    ans[y][x] = b[i]
    if (x == 0 and y%2 == 1) or (x == W - 1 and y%2 == 0):
        y += 1
    elif y%2 == 0:
        x += 1
    else:
        x -= 1
for _ in range(H):
    print(*ans[_])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(M)]
c = []
d = []
ans = "IMPOSSIBLE"
for i in range(M):
    if ab[i][0] == 1:
        c.append(ab[i][1])
    elif ab[i][1] == N:
        d.append(ab[i][0])
for i in range(len(c)):
    if c[i] in d:
        ans = "POSSIBLE"
        break
print(ans)

Fixed submission:
N, M = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(M)]
c = []
d = []
ans = "IMPOSSIBLE"
for i in range(M):
    if ab[i][0] == 1:
        c.append(ab[i][1])
    elif ab[i][1] == N:
        d.append(ab[i][0])
e = list(set(c + d))
if len(e) < len(c)+ len(d):
    ans = "POSSIBLE"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
ans = 10**10
deck = sum(a)
for i in range(1,N):
    su = sum(a[:i])
    ar = deck - su
    ans = min(ans, abs(su-ar))
print(ans)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
ans = 10**10
deck = sum(a)
su = 0
for i in range(0,N-1):
    su = su + a[i]
    ar = deck - su
    ans = min(ans, abs(su-ar))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H, W = list(map(int,input().split()))
ans = H*W
h = H
w = W
for i in range(h//3,h//2+1):
    p1 = i*w
    for j in range((h-i)//3,(h-i)//2+1):
        p2 = (h-i-j)*W
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
    for j in range(w//3,w//2+1):
        p2 = (h-i)*(w-j)
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
h = W
w = H
for i in range(h//3,h//2+1):
    p1 = i*w
    for j in range((h-i)//3,(h-i)//2+1):
        p2 = (h-i-j)*W
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
    for j in range(w//3,w//2+1):
        p2 = (h-i)*(w-j)
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
print(ans)

Fixed submission:
H, W = list(map(int,input().split()))
ans = H*W
h = H
w = W
for i in range(h//3,h//2+1):
    p1 = i*w
    for j in range((h-i)//2-1,(h-i)//2+1):
        p2 = (h-i-j)*W
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
    for j in range(w//2-1,w//2+1):
        p2 = (h-i)*(w-j)
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
h = W
w = H
for i in range(h//3,h//2+1):
    p1 = i*w
    for j in range((h-i)//2-1,(h-i)//2+1):
        p2 = (h-i-j)*H
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
    for j in range(w//2-1,w//2+1):
        p2 = (h-i)*(w-j)
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = list(map(int,input().split()))
ans = H*W
h = H
w = W
for i in range(1,h//2+1):
    p1 = i*w
    for j in range(1,(h-i)//2+1):
        p2 = (h-i-j)*W
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
    for j in range(1,w//2+1):
        p2 = (h-i)*(w-j)
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
h = W
w = H
for i in range(1,h//2+1):
    p1 = i*w
    for j in range(1,(h-i)//2+1):
        p2 = (h-i-j)*W
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
    for j in range(1,w//2+1):
        p2 = (h-i)*(w-j)
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
print(ans)

Fixed submission:
H, W = list(map(int,input().split()))
ans = H*W
h = H
w = W
for i in range(h//3,h//2+1):
    p1 = i*w
    for j in range((h-i)//2-1,(h-i)//2+1):
        p2 = (h-i-j)*W
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
    for j in range(w//2-1,w//2+1):
        p2 = (h-i)*(w-j)
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
h = W
w = H
for i in range(h//3,h//2+1):
    p1 = i*w
    for j in range((h-i)//2-1,(h-i)//2+1):
        p2 = (h-i-j)*H
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
    for j in range(w//2-1,w//2+1):
        p2 = (h-i)*(w-j)
        ans = min(ans, max(p1,p2,h*w-p1-p2)-min(p1,p2,h*w-p1-p2))
print(ans)
Buggy python submission (verdict: Runtime Error):
N =int(input())
print(N*800-(n//8)*200)

Fixed submission:
N =int(input())
print(N*800-(N//15)*200)
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
flg = 0
for dx in range(N-M):
    for dy in range(N-M):
#        print(A[dy][dx:N-1-dx],B[dy])
        if all(A[i+dy][dx:N-1-dx]==B[i+dy] for i in range(M)):
            flg =1
if flg == 1: print("Yes")
else: print("No")

Fixed submission:
N, M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
flg = 0
for dx in range(N-M+1):
    for dy in range(N-M+1):
#        for i in range(M):
#            print(A[dy+i][dx:dx+M],B[i])
        if all(A[dy+i][dx:dx+M]==B[i] for i in range(M)):
            flg =1
if flg == 1: print("Yes")
else: print("No")
Buggy python submission (verdict: Runtime Error):
if int(input())>=1200:
    print("ARC")
else print("ABC")

Fixed submission:
if int(input())>=1200:
    print("ARC")
else: print("ABC")

Buggy python submission (verdict: Runtime Error):
if int(input())>=1200:
	print("ARC")
else print("ABC")

Fixed submission:
if int(input())>=1200:
    print("ARC")
else: print("ABC")
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int,input().split())
print((b//x-a//x)

Fixed submission:
a, b, x = map(int,input().split())
print(b//x-(a-1)//x)
Buggy python submission (verdict: Runtime Error):
S = list(input())
form = "0"+str(len(S)-1)+"b"
ans = 0
for i in range(2**(len(S)-1)):
    b = format(i, form)
    eq = [S[0]]
    for j in range(len(b)):
        if b[j] == "1":
            sign = "+"
        else: sign = ""
        eq.append(sign)
        eq.append(S[j+1])
    eqstr = str("".join(eq))
    ans += eval(eqstr)
print(ans)
        

Fixed submission:
S = list(input())
form = "0"+str(len(S)-1)+"b"
ans = 0
if len(S)==1:
    print(int(S[0]))
else:
    for i in range(2**(len(S)-1)):
        b = format(i, form)
        eq = [S[0]]
        for j in range(len(b)):
            if b[j] == "1":
                sign = "+"
            else: sign = ""
            eq.append(sign)
            eq.append(S[j+1])
        eqstr = str("".join(eq))
        ans += eval(eqstr)
    print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
D = list(input())
for i in range(N, 10000):
    M = list(str(i))
    if all([M[j] not in D for j in range(len(M))]):
        ans = int("".join(M))
        break
print(ans)

Fixed submission:
N, K = map(int,input().split())
D = list(input())
for i in range(N, 100000):
    M = list(str(i))
    if all([M[j] not in D for j in range(len(M))]):
        ans = int("".join(M))
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = [int(s) for s in input().split()]
rans = []
for _ in range(K):
    l, r= [int(s) for s in input().split()]
    rans.append((l, r))
rans.sort()

prev = -1
newrans = []
for ran in rans:
    l, r = ran
    if l <= prev:
        newrans[-1] = max(r, newrans[-1])
    else:
        newrans.append([l,r])
    prev = max(prev, r)

rans = newrans
sums = [0, 1]
s = 1
# print(rans)
for i in range(2, N+1):
    # print(sums, i)
    for ran in rans:
        l = i - ran[0]
        r = max(i - ran[1] - 1, 0)
        # print(l, r, s)
        if l >= 0:
            s += sums[l] - sums[r]
    sums.append(s)
# print(sums)
if N == 1:
    print(1)
else:
    print((sums[-1] - sums[-2]) % 998244353)


Fixed submission:
N, K = [int(s) for s in input().split()]
rans = []
for _ in range(K):
    l, r= [int(s) for s in input().split()]
    rans.append((l, r))
rans.sort()

prev = -1
newrans = []
for ran in rans:
    l, r = ran
    if l <= prev:
        newrans[-1] = max(r, newrans[-1])
    else:
        newrans.append([l,r])
    prev = max(prev, r)

MOD = 998244353

rans = newrans
sums = [0, 1]
s = 1
# print(rans)
for i in range(2, N+1):
    # print(sums, i)
    for ran in rans:
        l = i - ran[0]
        r = max(i - ran[1] - 1, 0)
        # print(l, r, s)
        if l >= 0:
            s = (s + sums[l] - sums[r]) % 998244353
    sums.append(s)
# print(sums)
if N == 1:
    print(1)
else:
    print((sums[-1] - sums[-2]) % 998244353)
Buggy python submission (verdict: Runtime Error):
a, b, c, d =[int(s) for s in input().split()]
print(max(a * c, a * d, b * c, b * d)

Fixed submission:
a, b, c, d =[int(s) for s in input().split()]
print(max(a * c, a * d, b * c, b * d))

Buggy python submission (verdict: Runtime Error):
a, b, c, d = [int(s) for s in input().split()]
return max(a * c, a * d, b *c, b * d)

Fixed submission:
a, b, c, d =[int(s) for s in input().split()]
print(max(a * c, a * d, b * c, b * d))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    H, W = [int(s) for s in input().split()]
    sh, sw = [int(s) -1 for s in input().split()]
    gh, gw = [int(s) -1 for s in input().split()]
    maze = []
    for i in range(H):
        maze.append(input())
    queue = [(sh, sw)]
    skip = 0
    seen = {(sh, sw)}
    nqs = set()
    while queue:
        nq = []
        while queue:
            x, y = queue.pop()
            if x == gh and gw == y:
                print(skip)
                return
            for i,j in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
                if 0 <= i+x < H and 0 <= j+y < W:
                    ns = (i+x, j+y)
                    if maze[i+x][j+y] == '.':
                        if ns in seen:
                            continue
                        seen.add(ns)
                        queue.append(ns)
            ns = (x,y)
            if ns not in nqs:
                nqs.add(ns)
                nq.append(ns)

        skip += 1
        queue = []
        for x, y in nq:
            for i in range(-2, 3):
                for j in range(-2, 3):
                    if 0 <= i+x < H and 0 <= j+y < W:
                        if maze[i+x][j+y] == '.':
                            ns = (i+x, j+y)
                            if ns not in seen:
                                seen.add(ns)
                                queue.append(ns)
        # print(queue)
    print(-1)

main()

Fixed submission:
def main():
    H, W = [int(s) for s in input().split()]
    sh, sw = [int(s) -1 for s in input().split()]
    gh, gw = [int(s) -1 for s in input().split()]
    maze = []
    for i in range(H):
        maze.append(input())
    queue = [(sh, sw)]
    skip = 0
    seen = {(sh, sw)}
    nqs = set()
    while queue:
        nq = []
        while queue:
            x, y = queue.pop()
            if x == gh and gw == y:
                print(skip)
                return
            for i,j in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
                if 0 <= i+x < H and 0 <= j+y < W:
                    ns = (i+x, j+y)
                    if maze[i+x][j+y] == '.':
                        if ns in seen:
                            continue
                        seen.add(ns)
                        queue.append(ns)
            ns = (x,y)
            if ns not in nqs:
                nqs.add(ns)
                nq.append(ns)

        skip += 1
        queue = []
        for x, y in nq:
            for i in range(-2, 3):
                for j in range(-2, 3):
                    if 0 <= i+x < H and 0 <= j+y < W:
                        if maze[i+x][j+y] == '.':
                            ns = (i+x, j+y)
                            if ns not in seen:
                                seen.add(ns)
                                queue.append(ns)
        # print(queue)
    print(-1)

main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    H, W, M = [int(s) for s in input().split()]
    cols = [0] * W
    rows = [0] * H
    bombs = set()
    for _ in range(M):
        x, y = [int(s)-1 for s in input().split()]
        bombs.add((x, y))
        cols[y] += 1
        rows[x] += 1

    sc = sorted([(c, i) for i, c in enumerate(cols)], reverse=True)
    sr = sorted([(c, i) for i, c in enumerate(rows)], reverse=True)
    best = 0
    for v1, c in sc:
        for v2, r in sr:
            if v1 + v2 < best:
                break
            score = v1 + v2
            if (r, c) in bombs:
                score -= 1
            best = max(best, score)
    print(best)

main()

Fixed submission:
def main():
    H, W, M = [int(s) for s in input().split()]
    cols = [0] * W
    rows = [0] * H
    bombs = set()
    for _ in range(M):
        x, y = [int(s)-1 for s in input().split()]
        bombs.add((x, y))
        cols[y] += 1
        rows[x] += 1

    sc = sorted([(c, i) for i, c in enumerate(cols)], reverse=True)
    sr = sorted([(c, i) for i, c in enumerate(rows)], reverse=True)
    best = 0
    for v1, c in sc:
        for v2, r in sr:
            if v1 + v2 <= best:
                break
            score = v1 + v2
            if (r, c) in bombs:
                score -= 1
            best = max(best, score)
    print(best)

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

ans = 1
for i in a:
    if i == 0:
      	ans = 0

if ans != 0:
	for i in a:
		ans = ans*i

if ans <= 1000000000000000000:
	print(ans)
else:
  	print(-1)

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

ans = 1
for i in a:
    if i == 0:
      	ans = 0

if ans != 0:
	for i in a:
		ans = ans*i
		if ans > 1000000000000000000:
			break

if ans <= 1000000000000000000:
	print(ans)
else:
  	print(-1)

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

ans = 1
for i in a:
    ans = ans*i

if ans <= 1000000000000000000:
	print(ans)
else:
  	print(-1)

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

ans = 1
for i in a:
    if i == 0:
      	ans = 0

if ans != 0:
	for i in a:
		ans = ans*i
		if ans > 1000000000000000000:
			break

if ans <= 1000000000000000000:
	print(ans)
else:
  	print(-1)

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

ans = 1
for i in a:
    ans = ans*i

if ans <= 1000000000000000000:
	print(ans)
else:
  	print(-1)

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

ans = 1
for i in a:
    if i == 0:
      	ans = 0

if ans != 0:
	for i in a:
		ans = ans*i
		if ans > 1000000000000000000:
			break

if ans <= 1000000000000000000:
	print(ans)
else:
  	print(-1)

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

ans = 1
for i in a:
    ans = ans*i

if ans <= 1000000000000000000:
	print(ans)
else:
  	print(-1)

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

ans = 1
for i in a:
    if i == 0:
      	ans = 0

if ans != 0:
	for i in a:
		ans = ans*i
		if ans > 1000000000000000000:
			break

if ans <= 1000000000000000000:
	print(ans)
else:
  	print(-1)
Buggy python submission (verdict: Runtime Error):
import collections

class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        else:
            self.parent[x] = y

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

for i in range(M):
    A, B = map(int, input().split())
    tree.unite(A-1, B-1)

roots = [tree.find(p) for p in tree.parent]
count = collections.Counter(roots).most_common(1)[0][1]
print(count)


Fixed submission:
import collections

class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))
        self.rank = [0] * n

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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

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

for i in range(M):
    A, B = map(int, input().split())
    tree.unite(A-1, B-1)

roots = [tree.find(p) for p in tree.parent]
count = collections.Counter(roots).most_common(1)[0][1]
print(count)