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

Fixed submission:
import math
import decimal
a,b = map(decimal.Decimal,input().split())
ans = a*b
print(math.floor(ans))

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
if n == 1:
    print(0)
    exit()
def makeprime(value):
    flag  = [True for _ in range(value)]
    ans = []
    for i in range(1,len(flag)):
        if flag[i]:
            ans.append(i+1)
            for j in range(i,len(flag),i+1):
                flag[j] = False
    return ans
for i in range(2,int(math.sqrt(n)+1)):
    if n%i == 0:
        flag = 1
        break
else:
    flag = 0
if flag:
    u = []
    r = n
    ans = 0
    rem = makeprime(int(math.sqrt(n)))
    for i in rem:
        o = 1
        while (i**o <= n):
            u.append(i**o)
            o += 1
    u.sort()
    for i in u:
        if n%i == 0:
            ans += 1
            n //= i
    print(ans)
else:
    print(1)

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

Fixed submission:
n,k = map(int,input().split())
d = [0 for _ in range(k)]
a = []
for i in range(k):
    d[i] = int(input())
    a.append(list(map(int,input().split())))
sn = [0 for _ in range(n)]
for i in range(k):
    for j in range(d[i]):
        sn[a[i][j]-1] = 1
ans = 0
print(sn.count(0))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
d = [0 for _ in range(k)]
a = []
for i in range(k):
    d[i] = int(input())
    a.append(list(map(int,input().split())))
sn = [0 for _ in range(n)]
for i in range(k):
    for j in range(len(a[i])):
        sn[a[i][j]-1] += 1
ans = 0
for i in range(k):
    if sn[i] == 0:
        ans += 1
print(ans)
Problem p02766 (python)

Fixed submission:
n,k = map(int,input().split())
count = 1
while(n >= k):
    count += 1
    n /= k
print(count)

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
print(math.ceil(1/math.log(k,n)))

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
print(int(math.ceil(1/math.log(k,n))))
Problem p02773 (python)

Fixed submission:
n = int(input())
s = ["" for i in range(n)]
for j in range(n):
    s[j] = str(input())
s.sort()
count = [0 for _ in range(len(set(s)))]
l = 0
name = list(sorted(set(s)))
for k in range(n-1):
    count[l] += 1
    if(s[k] != s[k+1]):
        l += 1

count[-1] += 1

m_v = max(count)
ansnum = []

for h in range(len(count)):
    if(count[h] == m_v):
        ansnum.append(name[h])

print("\n".join(sorted(ansnum)))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = ["" for i in range(n)]
for j in range(n):
    s[j] = str(input())
s.sort()
count = [0 for _ in range(len(set(s)))]
l = 0
name = list(sorted(set(s)))
for k in range(n-1):
    count[l] += 1
    if(s[k] != s[k+1]):
        l += 1
if(s[-1] == s[-2]):
    count[-1] += 1
else:
    count.append(1)

m_v = max(count)
ansnum = []

for h in range(len(count)):
    if(count[h] == m_v):
        ansnum.append(name[h])

print(sorted(ansnum))
Problem p02933 (python)

Fixed submission:
a = int(input())
s = str(input())
if (a >= 3200):
    print(s)
else:
    print('red')

Buggy submission (verdict: Runtime Error):
def main():
    n,q = map(int,input().split())
    node = [[]for _ in range(n)]
    looked = [1]*n
    for i in range(n-1):
        a,b = map(int,input().split())
        node[b-1].append(a-1)
        node[a-1].append(b-1)
    counter = [0]*n
    for i in range(q):
        p,x = map(int,input().split())
        counter[p-1] += x
    queue = [0]
    looked[0] = 0
    while(queue):
        now = queue.pop(0)
        for i in node[now]:
            if looked[i]:
                queue.append(i)
                counter[i] += counter[now]
                looked[i] = 0
    print(*counter)
main()
Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
fibo = [1,1]
ans = 1

for i in range(n):
            fibo.append((fibo[-1]+fibo[-2])%1000000007)

if m:
    r = [a[0]-1]

    for i in range(m-1):
        r.append((a[i+1]-a[i])-2)
        if a[i+1]-a[i] == 1:
            print(0)
            exit()

    else:
        r.append(n-a[-1]-1)

        for i in range(len(r)):
            ans = (fibo[r[i]] * ans)%1000000007

        print(ans)
else:
    print(fibo[n])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
fibo = [1,1]
r = [a[0]-1]

for i in range(m-1):
    r.append((a[i+1]-a[i])-2)
    if a[i+1] - a[i] == 1:
        print(0)
        exit()
else:
    r.append(n-a[-1]-1)

    for i in range(n):
        fibo.append((fibo[-1]+fibo[-2])%1000000007)

    ans = 1

    for i in range(len(r)):
        ans = (fibo[r[i]] * ans)%1000000007

    print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
fibo = [1,1]
r = [a[0]-1]

for i in range(m-1):
    r.append((a[i+1]-a[i])-2)
    if a[i+1] - a[i] == 1:
        print(0)
        exit()
else:
    r.append(n-a[-1]-1)

    for i in range(max(r)+2):
        fibo.append((fibo[-1]+fibo[-2])%1000000007)

    ans = 1

    for i in range(n):
        ans = (fibo[r[i]] * ans)%1000000007

    print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
fibo = [1,1]
r = [a[0]-1]

for i in range(m-1):
    r.append((a[i+1]-a[i])-2)
    if a[i+1] - a[i] == 1:
        print(0)
        exit()
else:
    r.append(n-a[-1]-1)

    for i in range(max(r)+2):
        fibo.append((fibo[-1]+fibo[-2])%1000000007)

    ans = 1

    for i in range(len(r)):
        ans = (fibo[r[i]] * ans)%1000000007

    print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
fibo = [1,1]
r = [a[0]-1]

for i in range(m-1):
    r.append((a[i+1]-a[i])-2)
    if a[i+1] - a[i] == 1:
        print(0)
        exit()

r.append(n-a[-1]-1)

for i in range(max(r)+2):
    fibo.append((fibo[-1]+fibo[-2])%1000000007)

ans = 1

for i in range(len(r)):
    ans = (fibo[r[i]] * ans)%1000000007

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
fibo = [1,1]
r = [a[0]-1]

for i in range(m-1):
    r.append((a[i+1]-a[i])-2)
    if a[i+1] - a[i] == 1:
        print(0)
        exit()

r.append(n-a[-1]-1)

for i in range(max(r)):
    fibo.append((fibo[-1]+fibo[-2])%1000000007)

ans = 1

for i in range(len(r)):
    ans = (fibo[r[i]] * ans)%1000000007

print(ans)
Problem p03221 (python)

Fixed submission:
import bisect
n,m = map(int,input().split())
data = []
for i in range(m):
    data.append(list(map(int,input().split())))
r = sorted(data,key= lambda x:(x[0],x[1]))
o = [[] for _ in range(100001)]

for i in range(m):
    o[r[i][0]].append(r[i][1])

for i in range(m):
    print("0"*(6-len(str(data[i][0]))),end="")
    print(data[i][0],end="")
    num = bisect.bisect_left(o[data[i][0]],data[i][1])+1
    print("0"*(6-len(str(num))),end="")
    print(num)

Buggy submission (verdict: Runtime Error):
import bisect
n,m = map(int,input().split())
data = []
for i in range(m):
    data.append(list(map(int,input().split())))
r = sorted(data,key= lambda x:(x[0],x[1]))
o = [[] for _ in range(100000)]

for i in range(m):
    o[r[i][0]].append(r[i][1])

for i in range(m):
    print("0"*(6-len(str(data[i][0]))),end="")
    print(data[i][0],end="")
    num = bisect.bisect_left(o[data[i][0]],data[i][1])+1
    print("0"*(6-len(str(num))),end="")
    print(num)
Problem p02595 (python)

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

dis2 = D**2

count = 0
for i in range(N):
    x, y = map(int, input().split())
    if x**2 + y**2 <= dis2:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")

N, D = map(int, f.readline().split())

dis2 = D**2

count = 0
for i in range(N):
    x, y = map(int, f.readline().split())
    if x**2 + y**2 <= dis2:
        count+=1
print(count)
Problem p02598 (python)

Fixed submission:
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))

hq = []

def is_ok(checking):
    cost = 0
    for i in range(n):
        cost += math.ceil(a[i]/checking)-1
    if cost <= k:
        return True
    else:
        return False

def meguru_bisect(ng, ok):
    while (abs(ok-ng)>1):
        mid = (ok+ng)//2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

ok = meguru_bisect(0, int(1e+10)) 
print(int(ok))
# 初期値の範囲は取りえる値-1～+1とする←範囲内はok,ngどちらもあり得るため

Buggy submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))

hq = []

def is_ok(checking):
    cost = 0
    for i in range(n):
        cost += math.ceil(a[i]/checking)-1
    if cost <= k:
        return True
    else:
        return False

def meguru_bisect(ng, ok):
    while (abs(ok-ng)>1):
        mid = (ok+ng)//2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

ok = meguru_bisect(-1, int(1e+10)) 
print(int(ok))
# 初期値の範囲は取りえる値-1～+1とする←範囲内はok,ngどちらもあり得るため
Problem p02736 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 13:54:24 2020

@author: naoki
"""
import sys
#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
a = list(map(lambda x:int(x)-1,list(input())))
   
all_odd = 0
kai = [0] * N

if (0 not in a) and (1 not in a):
    print(0)
    sys.exit()
if (1 not in a) and (2 not in a):
    print(0)
    sys.exit()
if (0 not in a) and (2 not in a):
    print(0)
    sys.exit()
    
for k in range(1,N):
    count = 0
    p = k
    for _ in range(N):
        if p % 2 == 1:
            kai[k] = kai[k-1] + count
            break
        p = p/2
        count += 1

all_num = 0
for k in range(N):
    if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
        all_num += 1

if all_num % 2 == 1:
    print(1)
elif 1 in a:
    print(0)
else:
    for i in range(N):
        a[i] = a[i]/2
    for k in range(N):
        if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
            all_num += 1
    if all_num % 2 == 1:
        print(2)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 13:54:24 2020

@author: naoki
"""
import sys
f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(f.readline())
a = list(map(lambda x:int(x)-1,list(f.readline())))
   
all_odd = 0
kai = [0] * N

if (0 not in a) and (1 not in a):
    print(0)
    sys.exit()
if (1 not in a) and (2 not in a):
    print(0)
    sys.exit()
if (0 not in a) and (2 not in a):
    print(0)
    sys.exit()
    
for k in range(1,N):
    count = 0
    p = k
    for _ in range(N):
        if p % 2 == 1:
            kai[k] = kai[k-1] + count
            break
        p = p/2
        count += 1

all_num = 0
for k in range(N):
    if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
        all_num += 1

if all_num % 2 == 1:
    print(1)
elif 1 in a:
    print(0)
else:
    for i in range(N):
        a[i] = a[i]/2
    for k in range(N):
        if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
            all_num += 1
    if all_num % 2 == 1:
        print(2)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 21 20:58:03 2020

@author: naoki
"""

from collections import deque
f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
a = list(map(int, list(input())))

flag1 = [-100, -100]
flag2 = [-100, -100]
flag3 = [-100, -100]

for i in range(N//2):
    if a[i] == 2:
        flag1[0] = i
    if a[N-i-1] ==2 :
        flag1[1] = N-i-1
    if (a[i] == 1 and a[i+1] == 3) or (a[i] == 3 and a[i+1] == 1):
        flag2[0] = i
    if (a[N-i-1] == 1 and a[N-i-2] == 3) or (a[N-i-1] == 3 and a[N-i-2] == 1):
        flag2[1] = N-i-1
    
    if flag1[0] > 0 and flag1[1] > 0:
        b = a[0:flag1[0]].extend(a[flag1[1]:])
        break
    if flag2[0] > 0 and flag2[1] > 0:
        b = a[0:flag2[0]].extend(a[flag2[1]:])
        break
else:
    b = a
last = []
for i in range(len(b)-1):
    if b[i] != b[i+1]:
        last.append(b[i],b[i+1])

for i in range(len(last)-1):
    last = []
    for p in range(len(last) - i):
        last[p] = abs(last[p+1] - last[p])
print(last[0])
Problem p02781 (python)

Fixed submission:
n = str(input())
p = int(input())

keta = len(n)
Dp = [[[0 for _ in range(2)] for _ in range(keta+1)]for _ in range(keta+1)]

Dp[0][0][1] = 1
10
for i in range(keta):
    for j in range(i+1):
        for k in range(10):
            if k == 0:
                if k < int(n[i]):
                    Dp[i+1][j][0] += Dp[i][j][0]
                    Dp[i+1][j][0] += Dp[i][j][1]
                    
                elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                else:
                    Dp[i+1][j][0] += Dp[i][j][0]
            
            else:
                if k < int(n[i]):
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                    Dp[i+1][j+1][0] += Dp[i][j][1]
                elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                else:
                    Dp[i+1][j+1][0] += Dp[i][j][0]

if p > keta:
    print(0)
else:
    print(sum(Dp[-1][p]))

Buggy submission (verdict: Runtime Error):
n = str(input())
p = int(input())

keta = len(n)
Dp = [[[0 for _ in range(2)] for _ in range(keta+1)]for _ in range(keta+1)]

Dp[0][0][1] = 1

for i in range(keta):
    for j in range(i+1):
        for k in range(10):
            if k == 0:
                if k < int(n[i]):
                    Dp[i+1][j][0] += Dp[i][j][0]
                    Dp[i+1][j][0] += Dp[i][j][1]
                    
                elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                else:
                    Dp[i+1][j][0] += Dp[i][j][0]
            
            else:
                if k < int(n[i]):
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                    Dp[i+1][j+1][0] += Dp[i][j][1]
                elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                else:
                    Dp[i+1][j+1][0] += Dp[i][j][0]

print(sum(Dp[-1][p]))
Problem p02862 (python)

Fixed submission:
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0:
    print(0)
    sys.exit()

A = int((2*X-Y)/3)
B = int(X-2*A)

if A<0 or B<0:
    print(0)
    sys.exit()

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0 or (2*X-Y)<0:
    print(0)
    sys.exit()

A = int((2*X-Y)/3)
B = int(Y-2*A)

if A>B:

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)
Problem p02863 (python)

Fixed submission:
N, T = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]

Dp = [0 for _ in range(T+1)]

ab = sorted(ab, key = lambda x: x[0])

for i in range(N):
    for j in range(T-1,-1, -1):
        if j+ab[i][0] <= T-1:
            kari2 = Dp[j] + ab[i][1]
            if  Dp[j+ab[i][0]] < kari2:
                Dp[j+ab[i][0]] = kari2
        else:
            kari2 = Dp[j] +ab[i][1]
            if Dp[T] < kari2:
                Dp[T] = kari2
                
print(max(Dp))

Buggy submission (verdict: Runtime Error):
f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")


N, T = map(int, f.readline().split())
ab = [list(map(int, f.readline().split())) for _ in range(N)]

Dp = [0 for _ in range(T+1)]

ab = sorted(ab, key = lambda x: x[0])

for i in range(N-1):
    for j in range(T-1,-1, -1):
        if j+ab[i][0] <= T-1:
            kari2 = Dp[j] + ab[i][1]
            if  Dp[j+ab[i][0]] < kari2:
                Dp[j+ab[i][0]] = kari2
        else:
            kari2 = Dp[j] +ab[i][1]
            if Dp[T] < kari2:
                Dp[T] = kari2
                
print(max(Dp))

Buggy submission (verdict: Runtime Error):
f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")


N, T = map(int, f.readline().split())
ab = [list(map(int, f.readline().split())) for _ in range(N)]

Dp = [0 for _ in range(T+1)]

ab = sorted(ab, key = lambda x: x[0])

for i in range(N-1):
    for j in range(T-1,-1, -1):
        if j+ab[i][0] <= T-1:
            kari2 = Dp[j] + ab[i][1]
            if  Dp[j+ab[i][0]] < kari2:
                Dp[j+ab[i][0]] = kari2
print(Dp[T-1]+ab[-1][1])

Buggy submission (verdict: Runtime Error):
def function():
    N, T = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]
    
    Dp = [0 for _ in range(T+1)]
    used_ab = [set() for _ in range(T+1)]
    
    
    for i in range(N):
        for j in range(T-1,-1, -1):
            if j+AB[i][0] <= T-1:
                kari1 = Dp[j+AB[i][0]]
                kari2 = Dp[j] + AB[i][1]
                if  kari1< kari2:
                    Dp[j+AB[i][0]] = kari2
                    kari = used_ab[j].copy()
                    kari.add(i)
                    used_ab[j+AB[i][0]] = kari
    
    answer = 0
    for i in range(T):
        max_amari = 0
        for j in range(N):
            if j not in used_ab[i] and max_amari < AB[j][1]:
                max_amari = AB[j][1]
        if Dp[i]+max_amari > answer:
            answer = Dp[i]+max_amari
    
    print(answer)
    
if __name__ = "__main__":
    function()
Problem p02948 (python)

Fixed submission:
import heapq

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.append([m+1,0])
ab = sorted(ab, key=lambda x:x[0])



max_values = [0 for _ in range(m)]
hq = []

possible_days = 0

for now in range(n+1):
    # if necessary day exceed the (now_day), extract the most valuable work
    while possible_days <= ab[now][0]:
        if len(hq) < 1:
            pass
        else:
            max_values[possible_days-2] = -heapq.heappop(hq)
        possible_days += 1
    if possible_days-2 > m-1:
        break
    heapq.heappush(hq, -ab[now][1])
print(sum(max_values))

Buggy submission (verdict: Runtime Error):
import heapq

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.append([100000,0])
ab = sorted(ab, key=lambda x:x[0])



max_values = [0 for _ in range(m)]
hq = []

possible_days = 0

for now in range(n+1):
    # if necessary day exceed the (now_day), extract the most valuable work
    if possible_days-2 >= len(max_values):
        break
    while possible_days <= ab[now][0]:
        if len(hq) < 1:
            pass
        else:
            max_values[possible_days-2] = -heapq.heappop(hq)
        possible_days += 1
    heapq.heappush(hq, -ab[now][1])
print(sum(max_values))

Buggy submission (verdict: Runtime Error):
import heapq

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.append([m+1,0])
ab = sorted(ab, key=lambda x:x[0])



max_values = [0 for _ in range(m)]
hq = []

possible_days = 0

for now in range(n+1):
    # if necessary day exceed the (now_day), extract the most valuable work
    while possible_days <= ab[now][0]:
        if len(hq) < 1:
            pass
        else:
            max_values[possible_days-2] = -heapq.heappop(hq)
        possible_days += 1
    heapq.heappush(hq, -ab[now][1])
print(sum(max_values))
Problem p03045 (python)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
N, M = map(int, input().split())
XYZs = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]

uf = UnionFind(N)

for XYZ in XYZs:
    uf.union(XYZ[0], XYZ[1])

print(uf.group_count())

Buggy submission (verdict: Runtime Error):

N, M = map(int, input().split())
XYZs = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]

groups = [-1 for _ in range(N)]
connections = set()

now = 0
for XYZ in XYZs:
    if groups[XYZ[0]] == -1 and groups[XYZ[1]] == -1:
        now += 1
        groups[XYZ[0]] = now
        groups[XYZ[1]] = now
    elif groups[XYZ[0]] == -1:
        groups[XYZ[0]] = groups[XYZ[1]]
    elif groups[XYZ[1]] == -1:
        groups[XYZ[1]] = groups[XYZ[0]]
    elif groups[XYZ[0]] != groups[XYZ[1]]:
        if groups[XYZ[0]] > groups[XYZ[1]]:
            connections.add(str(groups[XYZ[1]])+"-"+str(groups[XYZ[0]]))
        else:
            connections.add(str(groups[XYZ[0]])+"-"+str(groups[XYZ[1]]))

print(connections)

answer = 0
for i in range(N):
    if groups[i] == -1:
        answer+=1
connections_list = []
for connection in connections:
    connections_list.append(list(map(int,connection.split("-"))))

connections_list = sorted(connections_list)
groups_set = set([i for i in range(now)])

for connection in connections_list:
    groups_set.remove(connection[0])

print(answer+len(groups_set))
Problem p02759 (python)

Fixed submission:
q, mod = divmod(int(input()), 2)
if mod == 1:
  q+=1
print(q)

Buggy submission (verdict: Runtime Error):
l=[]
for i in range(3):
    l.append(list(map(int, input().split())))
n = int(input())
for i in range(n):
    m = int(input())

    for j in range(3):
        for k in range(3):
            if l[j][k] == m:
                l[j][k] = -1
o=0
p=0
for j in range(3):
    for k in range(3):
        o+=l[j][k]
        p+=l[k][j]
    if o==-3 or p==-3:
        print('Yes')
        exit()
    o=0
    p=0
if l[0][0]+l[1][1]+l[2][2]==-3 or l[0][2]+l[1][1]+l[2][0]==-3:
    print('Yes')
else:
    print('No')
Problem p02779 (python)

Fixed submission:
n = input()
a = list(map(int, input().split()))
s = set(a)
if len(a) == len(s):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
b = len(list(map(int, input().split())))
s = set(a)
if len(a) == len(s):
    print('YES')
else:
    print('NO')
Problem p02831 (python)

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

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
print(int(a * b / math.gcd(a, b)))
Problem p02836 (python)

Fixed submission:
S = input()
cnt = 0

for i in range(len(S)//2):
    if S[i] != S[-(i+1)]:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
s = input()

l = len(s)//2
if len(s)==1:
    print(0)
    exit()
elif l%2==0:
    s1 = s[:l]
    s2 = s[l:]
else:
    s1 = s[:l]
    s2 = s[l+1:]

s2=s2[::-1]
c=0
for i in range(len(s2)):
    if s1[i] != s2[i]:
        c+=1
print(c)

Buggy submission (verdict: Runtime Error):
s = input()

l = len(s)//2
if l%2==0:
    s1 = s[:l]
    s2 = s[l:]
else:
    s1 = s[:l]
    s2 = s[l+1:]

s2=s2[::-1]
c=0
for i in range(len(s2)):
    if s1[i] != s2[i]:
        c+=1
print(c)