Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02780 (python)

Fixed submission:
n,k = map(int,input().split())
ls = list(map(int,input().split()))
l,p = 0,0
for i in range(n):
    if l < k:
        p += (1+ls[i])/2
        l += 1
        continue
    if i == k:
        now = p
    now = now-((1+ls[i-k])/2)+((1+ls[i])/2)
    p = max(p,now)
print(p)

Buggy submission (verdict: Runtime Error):
import sys
n = int(input())
ls = list(map(int,input().split()))
for i in range(len(ls)):
    if ls.count(ls[i]) > 1:
        print("NO")
        sys.exit()
    else:
        continue
print("YES")
Problem p02783 (python)

Fixed submission:
h,a = map(int, input().split())
x = h // a
y = h / a
if x == y:
    print(x)
else:
    print(x + 1)

Buggy submission (verdict: Runtime Error):
while True:
    h,a = map(int, input().split())
    x = h // a
    y = h / a
    if x == y:
        print(x)
    else:
        print(x + 1)
Problem p02784 (python)

Fixed submission:
h,n = map(int, input().split())
ls = list(map(int, input().split()))
if sum(ls) >= h:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
while True:
    h,n = map(int, input().split())
    ls = list(map(int, input().split()))
    if sum(ls) >= h:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
while True:
    h,n = map(int, input().split())
    ls = list(map(int, input().split()))
    if sum(ls) >= h:
        print("Yes")
    else:
        print("No")
Problem p02789 (python)

Fixed submission:
n,m = map(int,input().split())
if n == m:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
ls = list(map(int,input().split()))
a = 0
for i in range(n):
    for j in range(i):
        if ls[i] =< ls[j]:
            continue    
        else:
            a += 1
            break
print(n - a)
Problem p02791 (python)

Fixed submission:
n = int(input())
ls = list(map(int,input().split()))
min = ls[0]
k = 1
for i in range(1,n):
    if ls[i] < min:
        min = ls[i]
        k += 1
print(k)

Buggy submission (verdict: Runtime Error):
n = int(input())
ls = [int(x) for x in input().split()]
a = 0
for i in range(n):
    for j in range(i):
        if ls[i] =< ls[j]:
            continue    
        else:
            a += 1
            break
print(n - a)

Buggy submission (verdict: Runtime Error):
n = int(input())
ls = list(map(int,input().split()))
a = 0
for i in range(n):
    for j in range(i):
        if ls[i] =< ls[j]:
            continue    
        else:
            a += 1
            break
print(n - a)
Problem p02811 (python)

Fixed submission:
k,x =map(int,input().split())
if k*500 >= x:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
k,x =map(int,input().split()))
if k*500 >= x:
    print("Yes")
else:
    print("No")
Problem p02812 (python)

Fixed submission:
n = int(input())
a = input()
p = 0
for i in range(n-2):
    if a[i] == "A":
        if a[i+1] == "B":
            if a[i+2] == "C":
                p += 1
print(p)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input()
p = 0
for i in range(n):
    if a[i] == "A":
        if a[i+1] == "B":
            if a[i+2] == "C":
                p += 1
print(p)
Problem p02882 (python)

Fixed submission:
import math
a,b,x = map(int,input().split())
if x > ((a**2)*b)/2:
    print(math.degrees(math.atan((2*(b-x/(a**2))/a))))
else:
    print(math.degrees(math.atan((a*(b**2))/(2*x))))

Buggy submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
if x > ((a**2)*b)/2:
    print(math.degrees(math.atan((2*(b-x/(a**2))/a)))
else:
    print(math.degrees(math.atan((a*(b**2))/(2*x))))

Buggy submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
if x > ((a**2)*b)/3:
    print(math.degrees(math.atan((2*(b-x/(a**2))/a)))
else:
    print(math.degrees(math.atan((a*(b**2))/(2*x))))
Problem p02947 (python)

Fixed submission:
import collections
import math
n = int(input())
a = [0]*n
b = 0
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for j in range(n):
    t = list(input())
    t.sort()
    m = " ".join(t)
    a[j] = m
c = collections.Counter(a)
d = list(c)
for k in range(len(d)):
    if c[d[k]] > 1:
        b += combinations_count(c[d[k]], 2)
    else:
        continue
print(b)

Buggy submission (verdict: Runtime Error):
import collections
import math
n = int(input())
ls = list(input() for i in range(n))
a = []
b = 0
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for j in range(n):
    t = list(ls[j])
    t.sort()
    m = " ".join(t)
    a.append(m)
c = collections.Counter(a)
for k in range(len(c)):
    b += combinations_count(c.most_common()[k][1], 2)
print(b)
Problem p02953 (python)

Fixed submission:
import sys
n = int(input())
ls = list(map(int,input().split()))
mx = -float("inf")
for i in ls:
    if i < mx:
        if i + 1 != mx:
            print("No")
            sys.exit()
        else:
            mx = i + 1
    else:
        mx = i
print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
n = int(input())
ls = list(map(int,input().split()))
if len(list(set(ls))) <=2 and abs(list(set(ls))[0]-list(set(ls))[1]) <=1:
    print("Yes")
    sys.exit()
mx = ls[0]
for i in range(n-1):
    if (ls[i+1] - ls[i]) == -1:
        ls[i] -= 1
        if ls[i] < mx:
            print("No")
            sys.exit()
        else:
            mx = ls[i]
    elif ls[i+1] - ls[i] <-1:
        print("No")
        sys.exit()
    else:
        if ls[i] > mx:
            mx = ls[i]
print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
n = int(input())
ls = list(map(int,input().split()))
if len(list(set(ls))) <=2 and abs(list(set(ls))[0]-list(set(ls))[1]) <=1:
    print("Yes")
    sys.exit()
mx = ls[0]
for i in range(n-1):
    if (ls[i+1] - ls[i]) == -1:
        ls[i] -= 1
        if ls[i] < mx:
            print("No")
            sys.exit()
        else:
            mx = ls[i]
    elif ls[i+1] - ls[i] <-1:
        print("No")
        sys.exit()
    else:
        if ls[i] > mx:
            mx = ls[i]
print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
n = int(input())
ls = list(map(int,input().split()))
for i in range(n-1):
    if (ls[i+1] == ls[i]) or (ls[i+1] - ls[i] >=1):
        continue
    elif ls[i+1] - ls[i] == -1 :
        ls[i] = ls[i] - 1
        if ls[i+2] - ls[i+1] <0:
             print("No")
             sys.exit()
    else:
        print("No")
        sys.exit()
print("Yes")
Problem p02995 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
cc = b//c -(a-1)//c
dd = b//d -(a-1)//d
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#a,bの最小公倍数
def lcm(a, b):
	return a * b // gcd (a, b)
cd = lcm(c, d)
cdcd = b//cd -(a-1)//cd
print(b-a+1-cc-dd+cdcd)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
a,b,c,d = map(int,input().split())
ls = [e for e in range(a,b+1)]
y = lambda x,z = c:x%z
ss = ls[:]
cmil = list(map(y,ss))
cmin = cmil.index(0) + a
bb = ls[::-1]
cmal = list(map(y,bb))
cmax = b - cmal.index(0) 
y = lambda x,z = d:x%z
dmil = list(map(y,ss))
dmin = dmil.index(0) + a
dmal = list(map(y,bb))
dmax = b - dmal.index(0)
y = lambda x,z = (c*d)/gcd(c,d):x%z
cdmil = list(map(y,ss))
cdmin = cdmil.index(0) + a
cdmal = list(map(y,bb))
cdmax = b - cdmal.index(0)
ca = (cmax - cmin)/c +1
da = (dmax - dmin)/d +1
cda = (cdmax - cdmin)/((c*d)/gcd(c,d)) +1
print(int(b-a+1-ca-da+cda))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
if c <=0 or d <= 0:
    print("No")
ans = c * d // math.gcd(c,d)
i = a
j = a
while True:
    if i % c == 0:
        break
    i += 1
while True:
    if j % d == 0:
        break
    j += 1
k = min(i,j)
while True:
    if k % ans == 0:
        break
    k += 1
ii = (b-i)//c 
jj = (b-j)//d 
kk = (b-k)//ans 
print(b-a-ii-jj+kk)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
ans = c * d // math.gcd(c,d)
i = a
j = a
while True:
    if i % c == 0:
        break
    i += 1
while True:
    if j % d == 0:
        break
    j += 1
k = min(i,j)
while True:
    if k % ans == 0:
        break
    k += 1
ii = (b-i)//c 
jj = (b-j)//d 
kk = (b-k)//ans 
print(b-a-ii-jj+kk)
Problem p03076 (python)

Fixed submission:
a = [0]*(5)
for l in range(5):
    a[l] = str(input())
ls = [a[0],a[1],a[2],a[3],a[4]]
new = [0]*(5)
s = 0
for i in range(5):
    new[i] = int(a[i][-1])
for p in ls:
    if int(p) % 10 ==0:
        s += int(p)
    else:
        s += ((int(p)//10) + 1) *10
if sum(new) !=0:
    ans = min([e for e in new if e !=0])
    print(s-10+ans)
else:
    print(s)

Buggy submission (verdict: Runtime Error):
a = [0]*(5)
for l in range(5):
    a[l] = str(input())
ls = [a[0],a[1],a[2],a[3],a[4]]
new = [0]*(5)
s = 0
for i in range(5):
    new[i] = int(a[i][-1])
ans = min([e for e in new if e !=0])
for p in ls:
    if int(p) % 10 ==0:
        s += int(p)
    else:
        s += ((int(p)//10) + 1) *10
print(s-10+ans)
Problem p03086 (python)

Fixed submission:
s = str(input())
mx = 0
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        cnt = j-i
        p = 0
        for k in list(s[i:j]):
            if k in ["A","C","G","T"]:
                p += 1
        if p == cnt:
            if p > mx:
                mx = p
print(mx)

Buggy submission (verdict: Runtime Error):
s = str(input())
mx = 0
for i in range(n):
    for j in range(i+1,n+1):
        cnt = j-i-1
        p = 0
        for k in list(s[i:j]):
            if k in ["A","C","G","T"]:
                p += 1
        if p == cnt:
            if p > mx:
                mx = p
print(mx)

Buggy submission (verdict: Runtime Error):
s = str(input())
ls = ["A","G","T","C"]
di = []
for i in range(len(s)):
    k = 0
    for j in range(len(s)-i):
        if s[i+j] in ls:
            k += 1
        else:
            di.append(k)
            k = 0
print(max(di))
Problem p03087 (python)

Fixed submission:
n,q = map(int,input().split())
s = str(input())
a = [0]
for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    u,t = map(int,input().split())
    print(a[t-1]-a[u-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = str(input())
a = [0]
for i in range(1,n):
    if s[i-1] == "A":
        if s[i] == "C":
            a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    u,t = map(int,input().split())
    print(a[t-1]-a[u-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = str(input())
ls = [list(map(int,input().split())) for _ in range(q)]
a = [0]
for i in range(1,n):
    if s[i-1] == "A":
        if s[i] == "C":
            a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    (u,t) = (ls[j][0],ls[j][1])
    print(a[t-1]-a[u-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = str(input())
ls = [list(map(int,input().split())) for _ in range(q)]
a = [0]
for i in range(1,n):
    if s[i-1] == "A":
        if s[i] == "C":
            a.append(a[-1]+1)
    else:
        a.append(a[-1])
print(a)
for j in range(q):
    (u,t) = (ls[j][0],ls[j][1])
    print(a[t-1]-a[u-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = str(input())
ls = [list(map(int,input().split())) for _ in range(q)]
c = 0
a = [0]
for i in range(1,n):
    if s[i-1] == "A":
        if s[i] == "C":
            a.append(a[-1]+1)
    else:
        a.append(a[-1])
for j in range(q):
    (u,t) = (ls[j][0],ls[j][1])
    print(a[t-1]-a[u-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = str(input())
ls = [list(map(int,input().split())) for _ in range(q)]
c = 0
a = [0]
for i in range(1,n):
    if s[i-1] == "A":
        if s[i] == "C":
            a.append(a[i-1]+1)
    else:
        a.append(a[i-1])
for j in range(q):
    (u,t) = (ls[j][0],ls[j][1])
    print(a[t-1]-a[u-1])
Problem p03161 (python)

Fixed submission:
n,k = map(int,input().split())
ls = list(map(int,input().split()))
dp = [10000000000] *n
dp[0] = 0
dp[1] = abs(ls[1]-ls[0])
p = 10000000000
for i in range(2,n):
    for j in range(i-k,i):
        if (dp[j] >= p) or (abs(ls[j] - ls[i]) >= p):
            pass
        else:
            a = dp[j] + abs(ls[j] - ls[i])
            if a < p:
                p = a
                a = 0
            else:
                a = 0
    dp[i] = p
    p = 10000000000
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
n,k = map(int,input().split())
ls = np.array(list(map(int,input().split())))
inf = float("inf")
dp = [inf] *n
dp[0] = 0
dp[1] = abs(ls[1]-ls[0])
for i in range(2,n):
    st = max(0,i-k)
    dp[i] = np.min(dp[st:i]+abs(ls[i]-ls[st:i]))
print(int(dp[n-1]))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
ls = list(map(int,input().split()))
dp = [100000000] *n
dp[0] = 0
dp[1] = abs(ls[1]-ls[0])
p = inf
for i in range(2,n):
    for j in range(i-k,i):
        if (dp[j] >= p) or (abs(ls[j] - ls[i]) >= p):
            pass
        else:
            a = dp[j] + abs(ls[j] - ls[i])
            if a < p:
                p = a
                a = 0
            else:
                a = 0
    dp[i] = p
    p = 100000000
print(dp[n-1])
Problem p03164 (python)

Fixed submission:
n,w = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(n)]
inf = float("inf")
dp = [[inf]*(100000+1) for _ in range(n+1)]
dp[0][0] = 0
ans = 0
for i in range(n):
    for v in range(100001):
        if v - ls[i][1] >= 0:
            dp[i+1][v] = min(dp[i][v],dp[i][v-ls[i][1]]+ls[i][0])
        else:
            dp[i+1][v] = dp[i][v]
for j in range(100001):
    if dp[n][j] <= w:
        ans = j
print(ans)

Buggy submission (verdict: Runtime Error):
n,w = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(n)]
dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    for p in range(w+1):
        if p >= ls[i][0]:
            dp[i+1][p] = max(dp[i][p],dp[i][p-ls[i][0]]+ls[i][1])
        else:
            dp[i+1][p] = dp[i][p]
print(dp[n][w])

Buggy submission (verdict: Runtime Error):
n,w = map(int,input().split())
inf = float("inf")
dp = [[-inf]*(w+1) for _ in range(n+1)]
for j in range(w+1):
    dp[0][j] = 0
for i in range(n):
    s,t = map(int,input().split())
    for l in range(w+1):
        if l-s >=0:
            dp[i+1][l] = max(dp[i][l],dp[i][l-s]+t)
        else:
            dp[i+1][l] = dp[i][l]
print(dp[-1][w])
Problem p03262 (python)

Fixed submission:
from fractions import gcd
n,x = map(int,input().split())
ls = list(map(int,input().split()))
new = [0]*n
for i in range(n):
    new[i] = abs(ls[i]-x)
ans = new[0]
for j in range(1,n):
    ans = gcd(ans,new[j])
print(ans)

Buggy submission (verdict: Runtime Error):
from functions import gcd
n,x = map(int,input().split())
ls = list(map(int,input().split()))
new = [0]*n
for i in range(n):
    new[i] = abs(ls[i]-x)
ans = new[0]
for j in range(1,n):
    ans = functions.gcd(ans,new[j])
print(ans)

Buggy submission (verdict: Runtime Error):
import math 
n,x = map(int,input().split())
ls = list(map(int,input().split()))
new = [0]*n
for i in range(n):
    new[i] = abs(ls[i]-x)
ans = new[0]
for j in range(1,n):
    ans = math.gcd(ans,new[j])
print(ans)
Problem p03379 (python)

Fixed submission:
n = int(input())
ls = list(map(int,input().split()))
new = sorted(ls)
for i in ls:
    if i < new[int(n/2)]:
        print(new[int(n/2)])
    else:
        print(new[int(n/2)-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
w = sorted(ls)
p = w[int(n/2)]
for i in l:
    if i < p:
        print(p)
    else:
        print(w[int(n/2)-1])
Problem p03495 (python)

Fixed submission:
import sys
n,k = map(int,input().split())
ls = list(map(int,input().split()))
p = len(list(set(ls)))
if p <= k:
    print(0)
    sys.exit()
di=[float("inf")]*n
for i in range(n):
    if di[ls[i]-1] == float("inf"):
        di[ls[i]-1] = 1
    else:
        di[ls[i]-1] += 1
di.sort(reverse=True)
q = 0 
while True:
    s = di.pop()
    p -= 1
    q += s
    if p <= k:
        print(q)
        sys.exit()

Buggy submission (verdict: Runtime Error):
import collections
import sys
n,k = map(int,input().split())
ls = list(map(int,input().split()))
a = list(set(ls))
c = collections.Counter(ls)
p = 0
if len(a) > k:
    di = [0]*(len(a))
    new = c.most_common()[::-1]
    for i in range(len(a)):
        di[i] = new[i][1]
    import numpy 
    new_ls = numpy.cumsum(numpy.array(di))
    for j in range(len(a)):
        if len(a) - k <=new_ls[j]:
            print(new_ls[j])
            sys.exit()
else:
    print(0)
Problem p03611 (python)

Fixed submission:
n = int(input())
ls = list(map(int,input().split()))
di = [0]*(max(ls)+3)
for i in ls:
    di[i] += 1
    di[i+1] += 1
    di[i+2] += 1
print(max(di))

Buggy submission (verdict: Runtime Error):
n = int(input())
ls = list(map(int,input().split()))
a = min(ls)
b = max(ls)
c = len(ls)
s = 0
def sub(p,q):
    return p-q
ans = []
aaa = [0]*(len(ls))
for i in range(a,b+1):
    new = [i]*(c)
    ans = map(sub,ls,new)
    ans = list(map(str,ans))
    s = ans.count("-1") + ans.count("1") + ans.count("0")
    aaa[i] = s
print(max(aaa))

Buggy submission (verdict: Runtime Error):
n = int(input())
ls = list(map(int,input().split()))
a = min(ls)
b = max(ls)
c = len(ls)
s = 0
def sub(p,q):
    return p-q
ans = []
aaa = [0]*(b-a+1)
for i in range(a,b+1):
    new = [i]*(c)
    ans = map(sub,ls,new)
    ans = list(map(str,ans))
    s = ans.count("-1") + ans.count("1") + ans.count("0")
    aaa[i-1] = s
print(aaa)
print(max(aaa))

Buggy submission (verdict: Runtime Error):
n = int(input())
ls = list(map(int,input().split()))
a = min(ls)
b = max(ls)
c = len(ls)
s = 0
def sub(p,q):
    return p-q
ans = []
aaa = [0]*(b-a+2)
for i in range(a,b+1):
    new = [i]*(c)
    ans = map(sub,ls,new)
    ans = list(map(str,ans))
    s = ans.count("-1") + ans.count("1") + ans.count("0")
    aaa[i] = s
print(max(aaa))
Problem p03612 (python)

Fixed submission:
n = int(input())
ls = list(map(int,input().split()))
di = []
ans = 0 
now = 0
for i in range(n):
    if ls[i] == i+1:
        now += 1
    else:
        if now != 0:
            di.append(now)
            now = 0
if now != 0:
    di.append(now)
for j in di:
    if j % 2 == 0:
        ans += j//2
    else:
        ans += (j//2) + 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
n = int(input())
ls = list(map(int,input().split()))
di = []
ans = 0 
def culc(n):
    if n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        if n % 2 == 0:
            a = culc(n/2)*2
        else:
            a = culc(n/2)+culc((n/2)+1)
        return a
now = 0
for i in range(n):
    if ls[i] == i+1:
        now += 1
    else:
        if now != 0:
            di.append(now)
            now = 0
if now != 0:
    di.append(now)
for j in di:
    ans += culc(j)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
n = int(input())
ls = list(map(int,input().split()))
di = []
ans = 0 
def culc(n):
    if n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        if n % 2 == 0:
            a = culc(n/2)*2
        else:
            a = culc(n/2)+culc((n/2)+1)
        return a
now = 0
for i in range(n):
    if ls[i] == i+1:
        now += 1
    else:
        if now != 0:
            di.append(now)
            now = 0
if now != 0:
    di.append(now)
for j in di:
    ans += culc(j)
print(ans)
Problem p03625 (python)

Fixed submission:
import collections
import sys
n = int(input())
ls = list(map(int,input().split()))
c =collections.Counter(ls)
d = list(c)
p = []
q = []
mm = 0
mx3 = 0
for i in range(len(d)):
    if c[d[i]] >=4:
        p.append(d[i])
    if c[d[i]] >=2:
        q.append(d[i])
if p == [] and len(q) < 2:
    print(0)
    sys.exit()
if len(q) >= 2:
    mx1 = max(q)
    q.remove(mx1)
    mx2 = max(q)
    mm = mx1 * mx2
if p != []:
    mx3 = max(p)**2
print(max(mm,mx3))

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
ls = list(map(int,input().split()))
c =collections.Counter(ls)
d = list(c)
p = []
for i in range(len(d)):
    if c[d[i]] >1:
        p.append(d[i])
mx1 = max(p)
p.remove(mx1)
mx2 = max(p)
print(mx1 * mx2)
Problem p03998 (python)

Fixed submission:
import sys
sa = list(input())
sb = list(input())
sc = list(input())
sa = sa[::-1]
sb = sb[::-1]
sc = sc[::-1]
p = "a"
while True:
    if p == "a":
        if len(sa) > 0:
            p = sa.pop(-1)
        if len(sa) == 0 and p == "a":
            print("A")
            sys.exit()
    elif p == "b":
        if len(sb) > 0:
            p = sb.pop(-1)
        if len(sb) == 0 and p == "b":
            print("B")
            sys.exit()
    else:
        if len(sc) > 0:
            p = sc.pop(-1)
        if len(sc) == 0 and p == "c":
            print("C")
            sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
sa = list(input())
sb = list(input())
sc = list(input())
sa = sa[::-1]
sb = sb[::-1]
sc = sc[::-1]
p = "a"
while True:
    if p == "a":
        p = sa.pop(-1)
        if len(sa) == 0 and p == "a":
            print("A")
            sys.exit()
    elif p == "b":
        p = sb.pop(-1)
        if len(sb) == 0 and p == "b":
            print("B")
            sys.exit()
    else:
        p = sc.pop(-1)
        if len(sc) == 0 and p == "c":
            print("C")
            sys.exit()
Problem p02573 (python)

Fixed submission:
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。ノード番号は１から開始なのでn+1個。
        # par[x]<0の時そのノードは根で、par[x]の絶対値はグループのサイズ
        self.parents = [-1] * (n+1)

    # 親の親の...を辿って根を見つける
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            # 再度検索する時に手間がかからないよう根を繋ぎかえる
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # xの属するグループとyの属するグループを併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xが属するグループのサイズを返す
    def size(self, x):
        x = self.find(x)
        return -self.parents[x]

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

UF = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    UF.union(a, b)

biggest = 0
for i in range(1, n+1):
    biggest = max(biggest, UF.size(i))

print(biggest)

Buggy submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
friends = [[] for _ in range(N)]

for _ in range(M):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  friends[a].append(b)
  friends[b].append(a)

check = [False] * N
ans = 0

for i in range(N):
  if check[i] == False:
    check[i] = True
    D = deque(friends[i])
    tmp = 1
    while D:
      f = D.popleft()
      if check[f] == False:
        check[f] = True
        tmp += 1
        for j in friends[j]:
          D.append(j)
    ans = max(ans, tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
friends = [[] for _ in range(N)]

for _ in range(M):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  friends[a].append(b)
  friends[b].append(a)

check = [False] * N
ans = 0

for i in range(N):
  if check[i] == False:
    check[i] = True
    D = deque(friends[i])
    tmp = 1
    while D:
      f = D.popleft()
      if check[f] == False:
        check[f] = True
        tmp += 1
        for j in friend[j]:
          D.append(j)
    ans = max(ans, tmp)

print(ans)