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

Fixed submission:
def main():
    n,x,m = map(int,input().split())
    if m == 0:
        print(0)
        return
    t = [x]
    k = -1
    for _ in range(n-1):
        x = x**2 % m
        if x in t:
            k = x
            break
        t.append(x)
    if k not in t:
        print(sum(t))
        return
    else:
        s = t.index(k)
        ans = sum(t[0:s])
        b = t[s:len(t)]
        n -= s
        ans += sum(b) * (n//len(b))
        ans += sum(b[0:n%len(b)])
        print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,x,m = map(int,input().split())
    if m == 0:
        print(0)
        return
    t = [x]
    k = -1
    for _ in range(n):
        x = x**2 % m
        if x in t:
            k = x
            break
        t.append(x)
    s = t.index(k)
    if s == -1:
        print(sum(t))
        return
    else:
        ans = sum(t[0:s])
        b = t[s:len(t)]
        n -= s
        ans += sum(b) * (n//len(b))
        ans += sum(b[0:n%len(b)])
        print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,x,m = map(int,input().split())
    t = [x]
    k = -1
    for _ in range(n):
        x = x**2 % m
        if x in t:
            k = x
            break
        t.append(x)
    s = t.index(k)
    if s == -1:
        print(sum(t))
        return
    else:
        ans = sum(t[0:s])
        b = t[s:len(t)]
        n -= s
        ans += sum(b) * (n//len(b))
        ans += sum(b[0:n%len(b)])
        print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
def main():
    n,x,m = map(int,input().split())
    d = defaultdict(bool)
    t = [x]
    k = -1
    for _ in range(n):
        x = x**2 % m
        if d[x]:
            k = x
            break
        else:
            d[x] = True
        t.append(x)
    s = t.index(k)
    if s == -1:
        print(sum(t))
        return
    else:
        ans = sum(t[0:s])
        b = t[s:len(t)]
        n -= s
        ans += sum(b) * (n//len(b))
        ans += sum(b[0:n%len(b)])
        print(ans)

if __name__ == "__main__":
    main()
Problem p02623 (python)

Fixed submission:
import sys
n,m,k=map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = 1
c = [0]
d = [0]
for i in range(1,n+1):
    c.append(c[i-1] + a[i-1])
    if(c[i] > k):
        c.pop()
        break
for i in range(1,m+1):
    d.append(d[i-1] + b[i-1])
    if(d[i] > k):
        d.pop()
        break


leng = len(c)
lend = len(d)
ans = leng - 1
temp = 0
for i in range(leng):
    p = c[leng-i-1]
    t = temp
    while(t < lend and p+d[t] <= k):
        t += 1
        if(t==lend):
            print(max(ans,leng-i-2+t))
            sys.exit()
    ans = max(ans,leng-i-2+t)
    temp = t

print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
while(k>0):
    if(len(a) == 0 or len(b) == 0):
        if(len(a) == 0 and len(b)==0):
            break        
        elif(len(a) == 0):
            if(k >= b[0]):
                k -= b.pop(0)
                ans += 1
            else:
                break
        elif(len(b) == 0):
            if(k >= a[0]):
                k -= a.pop(0)
                ans += 1
            else:
                break
    else:
        if(a[0]>b[0]):
            if(k >= b[0]): 
                k -= b.pop(0)
                ans +=1
            else:
                break
        else:
            if(k >= a[0]):
                k -= a.pop(0)
                ans += 1
            else:
                break
    print(a,b,k)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m,k=map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a = deque(a)
b = deque(b)
ans = 0
while(n!=m):
    if(n>m):
        b.append(10**9+1)
        m += 1
    else:
        a.append(10**9+1)
        n +=1
while(k>0):
    if(a[0]>b[0]):
        if(k >= b[0]): 
            k -= b.popleft()
            ans +=1
        else:
            break
    else:
        if(k >= a[0]):
            k -= a.popleft()
            ans += 1
        else:
            break
print(ans)
Problem p02624 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n+1):
    k = n//i
    ans += k*(k+1)//2 * i

print(ans)

Buggy submission (verdict: Runtime Error):
import sympy
n = int(input())
ans = 0
for i in range(1,n+1):
    k = n//i
    ans += k*(k+1)//2 * i

print(ans)
Problem p02676 (python)

Fixed submission:
K = int(input())
S = input()
if len(S) <= K:
    print(S)
else:
    for i in range(K):
        print(S[i],end="")
    print("...")

Buggy submission (verdict: Runtime Error):
K = int(input())
S = input()
if len(S) <= K:
    print(S)
else:
    for i in range(K):
        print(S[i],end="")
    print("..."3)
Problem p02729 (python)

Fixed submission:
N,M = map(int,input().split())
print(int(N*(N-1)/2+M*(M-1)/2))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
print(N(N+1)/2+M(M+1)/2)
Problem p03135 (python)

Fixed submission:
N, Q = [float(i) for i in input().split()]
print(N/Q)

Buggy submission (verdict: Runtime Error):
N,K = [int(i) for i in input().split()]
num = list(map(int, input().split()))
k = K
ans = 0
count = 0
print(K)
if K == 0:
    print(sum(num))
else:
    K2 = []
    while K>0:
        K2.append(K % 2)
        K //= 2
    data = []
    for i in num:
        num2 = []
        while i > 0:
            num2.append(i % 2)
            i //= 2
        while len(num2) < len(K2):
            num2.append(0)
        data.append(list(reversed(num2)))
    for i in range(len(K2)):
        t = 0
        b = 2**(len(K2) - i - 1) #べき乗
        for j in range(N):
            t += data[j][i]
        if t >= N-t:
            ans += b * t
        else:
            count += b
            if count <= k:
                ans += b * (N-t)
            else:
                ans += b * t
    print(ans)
Problem p02897 (python)

Fixed submission:
n=int(input())
if n%2==0:
    print(0.5)
else:
    print((n+1)/(2*n))

Buggy submission (verdict: Runtime Error):
N=input()
if N%2==0:
  ans=0.5
else:
  ans=(N+1)/(2*N)
print(ans)
Problem p02688 (python)

Fixed submission:
n,k = map(int,input().split())
a = [0]*n
for _ in range(k):
    kind = int(input())
    for i in list(map(int,input().split())):
        a[i-1] += 1
print(a.count(0) if 0 in a else 0)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = [0]*3
for _ in range(k):
    kind = int(input())
    for i in list(map(int,input().split())):
        a[i-1] += 1
print(a.count(0))
Problem p02777 (python)

Fixed submission:
def resolve():
    s,t = input().split()
    a,b = map(int,input().split())
    u = input()
    print(a-(s==u),b-(t==u))
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    s,t = input().split()
    a,b = map(int,input().split())
    u = input()
    print(a-(s==u),b-(t==u))
reoslve()
Problem p02831 (python)

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

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(a*b//math.gcd(a,b))
Problem p03775 (python)

Fixed submission:
import math
n = int(input())
for i in range(int(n**0.5),0,-1):
    if n%i == 0:
        a = max(i,n//i)
        print(int(math.log10(a))+1)
        break

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(int(n**0.5),0,-1):
    if n%i == 0:
        a = max(i,n//i)
        print(int(math.log10(a))+1)
        break
Problem p02729 (python)

Fixed submission:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,m = map(int,input().split())
ans = 0
if n >= 2:
    ans += combinations_count(n, 2)
if m >= 2:
    ans += combinations_count(m, 2)
print(str( ans ))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

H,W,K = map(int,input().split())
choco = [input() for _ in range(H)]
num =(2**(H-1))

white_count = list()
min_div_count =10**6
for i in range(num):
    bin_str = format(i, 'b')
    zero = str()
    if H != len(bin_str):
        for i in range(H-len(bin_str)):
            zero += "0"
        bin_str = zero + bin_str
    white_count = [0 for s in bin_str if s == "1"]
    white_count.append(0)
    div_count=len(white_count)-1
    j = 0
    while j < W:
        block_count = 0
        for k in range(len(bin_str)):
            if bin_str[k] == "1":
                block_count += 1
            white_count[block_count] += int(choco[k][j])
            if white_count[block_count] > K:
                div_count +=1
                white_count = [0 for s in bin_str if s == "1"]
                white_count.append(0)
                break
        else:
            j+=1
    if min_div_count > div_count:
        min_div_count = div_count
print(min_div_count)
Problem p02779 (python)

Fixed submission:
N=int(input())
li = list(map(int,input().split()))	
num = {}
for l in li:
    if str(l) not in num :
        num[str(l)] = 1
    elif num[str(l)]==1:
        print("NO")
        break
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
N=int(input())
li = list(map(int,input().split()))	
num = {}
for l in li:
    print(num)
    if str(l) not in num  :
        num[l] = 1
    else:
        print("NO")
        break
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
N=int(input())
li = list(map(int,input().split()))	
num = [0]*100000000
for l in li:
    if num[l] == 0:
        num[l] = 1
    elif num[l] == 1:
        print("NO")
        break
else:
    print("YES")
Problem p02831 (python)

Fixed submission:

def gcd(a,b):
    x = max(a,b)
    y = min(a,b)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z



def lcm(m,n):
    return int(m * n/gcd(m,n))

a,b = map(int,input().split())
print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math

a,b = map(int,input().split())

print(str((a * b) // math.gcd(a, b)))

Buggy submission (verdict: Runtime Error):
import math

a = int(input())
b = int(input())

print(str((a * b) // math.gcd(a, b)))
Problem p03013 (python)

Fixed submission:
N, M = map(int,input().split())
alist = list()
for _ in range(M):
    alist.append(int(input()))


li = {}
li[0] = 1

for i in range(1,N+1):
    if len(alist)>=1 and i ==  alist[0]:
        li[i] = 0
        alist.pop(0)
    else:
        if i == 1:
            li[i] = 1
        else:
            li[i] = ((li[i-1] + li[i-2])%(10**9+7))
print(li[N]%(10**9+7))

Buggy submission (verdict: Runtime Error):
, M = map(int,input().split())
alist = list()
for _ in range(M):
    alist.append(int(input()))


li = {}
li[0] = 1

for i in range(1,N+1):
    if i in alist:
        li[i] = 0
    else:
        if i == 1:
            li[i] = 1
        else:
            li[i] = (li[i-1] + li[i-2])%(10**9+7)
print(li[N]%(10**9+7))

Buggy submission (verdict: Runtime Error):
#n段の上り方のバリエーションはフィボナッチ数列になっている

def Fib(dan):
    
    if dan == 0:
        return 0
    elif dan == 1:
        return 1
    else:
        return Fib(dan-1)+Fib(dan-2)

N, M = map(int,input().split())
ans = 1
lasthole = 0
if M == 0:
    print(Fib(N+1)%1000000007)
else:
    alist = list()
    for i in range(M):
        alist.append( int(input()))
    for a in alist:
        dan = a - lasthole 
        lasthole = a +1
        ans *= Fib(dan)
        ans = ans % 1000000007
    ans *= Fib(N - alist[M-1])
    
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
def Fib(dan):
    
    if dan == 0:
        return 0
    elif dan == 1:
        return 1
    else:
        return Fib(dan-1)+Fib(dan-2)

N, M = map(int,input().split())
ans = 1
lasthole = 0
if M == 0:
    print(Fib(N+1))
else:
    alist = list()
    for i in range(M):
        alist.append( int(input()))
    for a in alist:
        dan = a - lasthole 
        lasthole = a +1
        ans *= Fib(dan)
    ans *= Fib(N - alist[M-1])
print(ans%1000000007)
Problem p02833 (python)

Fixed submission:
n = int(input())
if n % 2:
    print(0)
else:
    ans, x = 0, 5
    while(x <= n):
        ans += ((n // x) // 2)
        x *= 5
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 2:
    print(0)
else:
    ans, x = 0, 5
    while(x <= n):
        ans += ((n // x) // 2)
        x *= 5
print(ans)
Problem p02723 (python)

Fixed submission:
S = str(input())
if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C =  [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.append(0)
B.append(0)
C.append(0)
ux_1 = 0
uy_1 = 0
for i in range(X):
    ux_1 += max(max(A),max(C))
    if max(A) >= max(C):
        A.pop(A.index(max(A)))
    else:
        C.pop(C.index(max(C)))
for i in range(Y):
    uy_1 += max(max(B),max(C))
    if max(B) >= max(C):
        B.pop(B.index(max(B)))
    else:
        C.pop(C.index(max(C)))
print(ux_1+uy_1)

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
C_copy = C.copy()
for i in range(30):
    C_copy.append(0)
    C.append(0)
ux_1 = 0
uy_1 = 0
for i in range(X):
    ux_1 += max(max(A),max(C_copy))
    if max(A) >= max(C_copy):
        A.pop(A.index(max(A)))
    else:
        C_copy.pop(C_copy.index(max(C_copy)))
for i in range(Y):
    uy_1 += max(max(B),max(C_copy))
    if max(B) >= max(C_copy):
        B.pop(B.index(max(B)))
    else:
        C_copy.pop(C_copy.index(max(C_copy)))
print(ux_1 + uy_1)
Problem p02753 (python)

Fixed submission:
a = str(input())
if a == 'AAA' or a == 'BBB':
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
a = str(input())
q = int(input())
s = [input().split() for i in range(q)]
for i in range(q):
    if int(s[i][0]) == 1 and len(a)>1:
        a = a[::-1]
    elif int(s[i][0])== 2 and int(s[i][1])==1:
        a=s[i][2]+a
    else:
        a=a+s[i][2]
print(a)
Problem p02754 (python)

Fixed submission:
L = list(map(int,input().split()))
q = L[0]//(L[1]+L[2])
mod = L[0]%(L[1]+L[2])
if mod > L[1]:
    print(q*L[1]+L[1])
elif L[1]==0:
    print(0)
else:
    print(q*L[1]+mod%L[1])

Buggy submission (verdict: Runtime Error):
L = list(map(int,input().split()))
q = L[0]//(L[1]+L[2])
mod = L[0]%(L[1]+L[2])
if mod > L[1]:
    print(q*L[1]+L[1])
else:
    print(q*L[1]+mod%L[1])
Problem p02881 (python)

Fixed submission:
n = int(input())
div = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        div.append(i)
        if i != n // i:
            div.append(n//i)
i = 0
div.sort()
while True:
    if div[i]*div[i+1] == n:
        print(div[i]+div[i+1]-2)
        break
    elif div[i]*div[i] == n:
        print(div[i]+div[i]-2)
        break     
    else:
        i += 1

Buggy submission (verdict: Runtime Error):
n = int(input())
divisors = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        divisors.append(i)
        if i != n // i:
            divisors.append(n//i)
i = 0
div = make_divisors(n)
div.sort()
while True:
    if div[i]*div[i+1] == n:
        print(div[i]+div[i+1]-2)
        break
    elif div[i]*div[i] == n:
        print(div[i]+div[i]-2)
        break     
    else:
        i += 1
Problem p02594 (python)

Fixed submission:
def main():
    x = int(input())
    if x>=30:
        print("Yes")
    else:
        print("No")  
main()

Buggy submission (verdict: Runtime Error):
def main():
    x = int(input())
    if x>=30:
        print("Yes")
    else:
        print("No")  
main(9
Problem p02596 (python)

Fixed submission:
import sys
def main():
    k = int(input())
    
    if k == 7 or k == 1:
        print(1)
        sys.exit()
    
    r = 7%k
    g = {r}
    ans = 1
    while True:
        ans+=1
        r = (10*r+7)%k
        if r==0:
            print(ans)
            break
        if r in g:
            print(-1)
            break
        else:
            g.add(r)
main()

Buggy submission (verdict: Runtime Error):
def main():
    k = int(input())
    
    if k == 7:
        print(1)
        sys.exit()
    
    r = 7%k
    g = {r}
    ans = 1
    while True:
        ans+=1
        r = (10*r+7)%k
        if r==0:
            print(ans)
            break
        if r in g:
            print(-1)
            break
        else:
            g.add(r)
main()
Problem p02623 (python)

Fixed submission:
def main():
    import bisect
    n,m,k = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))

    A_ac = [0]
    B_ac = [0]
    a_ac = 0
    b_ac = 0
    for a in A:
        a_ac+=a
        A_ac.append(a_ac)
    for b in B:
        b_ac+=b
        B_ac.append(b_ac)
    
    i_mx = bisect.bisect_right(A_ac,k)
    i = i_mx-1
    ct = [0]

    while i >= 0:
        k_left = k-A_ac[i]
        j = bisect.bisect_right(B_ac,k_left)-1
        ct.append(i+j)
        i-=1
    

    print(max(ct))
main()

Buggy submission (verdict: Runtime Error):
def main():
    import bisect
    n,m,k = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))

    A_ac = [0]
    B_ac = [0]
    a_ac = 0
    b_ac = 0
    for a in A:
        a_ac+=a
        A_ac.append(a_ac)
    for b in B:
        b_ac+=b
        B_ac.append(b_ac)
    
    i_mx = bisect.bisect_right(A_ac,k)
    i = i_mx-1
    ct = []

    while i > 0:
        k_left = k-A_ac[i]
        j = bisect.bisect_right(B_ac,k_left)-1
        ct.append(i+j)
        i-=1
    
    print(max(ct))
main()
Problem p02659 (python)

Fixed submission:
import io,sys
sys.setrecursionlimit(10**6)

def main():
    s = sys.stdin.readline().rstrip().split()
    a = int(s[0])

    b = int(float(s[1])*100+0.1)

    print(a*b//100)
main()

Buggy submission (verdict: Runtime Error):
import io,sys
sys.setrecursionlimit(10**6)

def main():
    s = sys.stdin.readline().rstrip().split()
    a = int(s[0])

    b = int(float(s[1])*100+0.1)

    print(ans=a*b//100)
main()

Buggy submission (verdict: Runtime Error):
def main():
    s = sys.stdin.readline().rstrip().split()
    a = int(s[0])

    b = int(float(s[1])*100)

    ans=a*b//100
    l = []
    while ans!=0:
        p = ans%10
        ans //=10
        l.append(p)
        
    for i in l[::-1]:
        print(i,end="")
main()
Problem p02711 (python)

Fixed submission:
n = str(input())
seven = "7"
if seven in n:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = input()
if 7 in n:
    print("Yes")
else:
    print("No")
Problem p02723 (python)

Fixed submission:
s = input()
if s[2]==s[3] and s[4]==s[5]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split(" "))
houses = list(map(int, input().split(" ")))
dif_houses = [houses[x+1]-houses[x] for x in range(k-1)]
dif_houses.append(houses[0]-houses[k-1]+n)

max_dif = max(dif_houses)
print(n-max_dif)
Problem p02735 (python)

Fixed submission:
def main():
    h,w = map(int,input().split(" "))
    s = [list(input()) for i in range(h)]
    
    dp = [[0]*w for i in range(h)]
    dp[0][0] = 1 if s[0][0]=="#" else 0

    for i in range(1,h):
        sgmdown = 1 if s[i][0]=="#" and s[i-1][0]=="." else 0
        dp[i][0] = dp[i-1][0] + sgmdown
    
    for j in range(1,w):
        sgmright = 1 if s[0][j]=="#" and s[0][j-1]=="." else 0
        dp[0][j] = dp[0][j-1] + sgmright

    for i in range(1,h):
        for j in range(1,w):
            sgmdown = 1 if s[i][j]=="#" and s[i-1][j]=="." else 0
            sgmright = 1 if s[i][j]=="#" and s[i][j-1]=="." else 0
            dp[i][j] = min(dp[i-1][j]+sgmdown, dp[i][j-1]+sgmright)

    print(dp[h-1][w-1])
main()

Buggy submission (verdict: Runtime Error):
def main():
    h,w = map(int,input().split(" "))
    s = [list(input()) for i in range(h)]
    
    dp = [[0]*h for i in range(w)]
    dp[0][0] = 1 if s[0][0]=="#" else 0

    for i in range(1,h):
        sgmdown = 1 if s[i][0]=="#" and s[i-1][0]=="." else 0
        dp[i][0] = dp[i-1][0] + sgmdown
    
    for j in range(1,w):
        sgmright = 1 if s[0][j]=="#" and s[0][j-1]=="." else 0
        dp[0][j] = dp[0][j-1] + sgmright

    for i in range(1,h):
        for j in range(1,w):
            sgmdown = 1 if s[i][j]=="#" and s[i-1][j]=="." else 0
            sgmright = 1 if s[i][j]=="#" and s[i][j-1]=="." else 0
            dp[i][j] = min(dp[i-1][j]+sgmdown, dp[i][j-1]+sgmright)

    print(dp[h-1][w-1])
main()

Buggy submission (verdict: Runtime Error):
def main():
    h,w = map(int,input().split(" "))
    s = [list(input()) for i in range(h)]
    
    dp = [[0]*h for i in range(w)]
    dp[0][0] = 1 if s[0][0]==1 else 0

    for i in range(1,h):
        sgmdown = 1 if s[i][0]=="#" and s[i-1][0]=="." else 0
        dp[i][0] = dp[i-1][0] + sgmdown
    
    for j in range(1,w):
        sgmright = 1 if s[0][j]=="#" and s[0][j-1]=="." else 0
        dp[0][j] = dp[0][j-1] + sgmright

    for i in range(1,h):
        for j in range(1,w):
            sgmdown = 1 if s[i][j]=="#" and s[i-1][j]=="." else 0
            sgmright = 1 if s[i][j]=="#" and s[i][j-1]=="." else 0
            dp[i][j] = min(dp[i-1][j]+sgmdown, dp[i][j-1]+sgmright)

    print(dp[h-1][w-1])
main()
Problem p02762 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

def dfs(GF,group,gn,i):
    size = 1
    group[i]=gn
    for node in GF[i]:
        if group[node]==-1:
            group[node]=gn
            size+=dfs(GF,group,gn,node)
    return size

def main():
    from sys import stdin
    n,m,k = map(int,stdin.readline().rstrip().split())
    F=[]
    for _ in range(m):
        F.append(list(map(int,stdin.readline().rstrip().split())))
    GF = [[] for _ in range(n+1)]
    for a,b in F:
        GF[a].append(b)
        GF[b].append(a)
    
    B=[]
    for _ in range(k):
        B.append(list(map(int,stdin.readline().rstrip().split())))
    GB = [[] for _ in range(n+1)]
    for a,b in B:
        GB[a].append(b)
        GB[b].append(a)    

    U = []
    group= [-1]*(n+1)
    gn = 0

    for i in range(1,n+1):
        if group[i] == -1:
            sz = dfs(GF,group,gn,i)
            gn+=1
            U.append(sz)
    
    for i in range(1,n+1):
        g = group[i]
        ans = U[g]-1-len(GF[i])

        for b in GB[i]:
            if group[b]==g:
                ans-=1
        print(ans,end=" ")
main()

Buggy submission (verdict: Runtime Error):
def dfs(GF,group,gn,i):
    size = 1
    group[i]=gn
    for node in GF[i]:
        if group[node]==-1:
            group[node]=gn
            size+=dfs(GF,group,gn,node)
    return size

def main():
    from sys import stdin
    n,m,k = map(int,stdin.readline().rstrip().split())
    F=[]
    for _ in range(m):
        F.append(list(map(int,stdin.readline().rstrip().split())))
    GF = [[] for _ in range(n+1)]
    for a,b in F:
        GF[a].append(b)
        GF[b].append(a)
    
    B=[]
    for _ in range(k):
        B.append(list(map(int,stdin.readline().rstrip().split())))
    GB = [[] for _ in range(n+1)]
    for a,b in B:
        GB[a].append(b)
        GB[b].append(a)    

    U = []
    group= [-1]*(n+1)
    gn = 0

    for i in range(1,n+1):
        if group[i] == -1:
            sz = dfs(GF,group,gn,i)
            gn+=1
            U.append(sz)
    
    for i in range(1,n+1):
        g = group[i]
        ans = U[g]-1-len(GF[i])

        for b in GB[i]:
            if group[b]==g:
                ans-=1
        print(ans,end=" ")
main()
Problem p03207 (python)

Fixed submission:
n=int(input())
a=[]
for i in range(n):
    p=int(input())
    a.append(p)
a.sort()
a[n-1]=int(a[n-1]/2)
print(sum(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n)
    p=int(input())
    a.append(p)
a.sort()
a[n-1]=int(a[n-1]/2)
print(sum(a))