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

Fixed submission:
import sys,queue,math,copy,itertools,bisect,collections,heapq
LI = lambda : [float(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
N = NI()
p = [0.0] + LI()
dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
dp[0][0] = 1
for i in range(1,N+1):
    for j in range(0,i+1):
        if j > 0: dp[i][j] = dp[i-1][j-1] * p[i]
        dp[i][j] += dp[i-1][j] * (1-p[i])

print(sum(dp[-1][N//2+1:]))

Buggy submission (verdict: Runtime Error):
import sys,queue,math,copy,itertools,bisect,collections,heapq
LI = lambda : [float(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
N = NI()
p = LI()
dp = [0] * (N+1)
dp[0][0] = 1
for i in range(1,N+1):
    for j in range(0,i+1):
        if j > 0:
            dp[j] = dp[j-1] * p[i-1] + dp[j] * (1-p[i-1])
        else:
            dp[j] = dp[j] *  (1-p[i-1])

print(sum(dp[N//2+1:]))

Buggy submission (verdict: Runtime Error):
import sys,queue,math,copy,itertools,bisect,collections,heapq
LI = lambda : [float(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
N = NI()
p = LI()
dp = [0] * (N+1)
dp[0][0] = 1
for i in range(1,N+1):
    for j in range(0,i+1):
        if j > 0:
            dp[j] = dp[j-1] * p[i-1] + dp[j] * (1-p[i-1])
        else:
            dp[j] = dp[j] *  (1-p[i-1])

print(sum(dp[-1][N//2+1:]))
Problem p03290 (python)

Fixed submission:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    D,G = LI()
    pc = [LI() for _ in range(D)]

    ans = INF
    for p in itertools.permutations(range(D)):
        g = G
        cnt = 0
        for i in p:
            if g < pc[i][0] * (i+1) * 100:
                cnt += math.ceil(g/((i+1)*100))
                break
            else:
                cnt += pc[i][0]
                g -= pc[i][0] * (i+1) * 100 + pc[i][1]
            if g <= 0: break
        ans = min(ans,cnt)

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    INF = 10**5
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    D,G = LI()
    pc = [LI() for _ in range(D)]
    ans = INF
    for p in itertools.permutations([0,1,2,3,4,5,6,7,8,9]):
        g = G
        cnt = 0
        for i in p:
            if g < pc[i][0] * (i+1) * 100:
                cnt += math.ceil(g/((i+1)*100))
                break
            else:
                cnt += pc[i][0]
                g -= pc[i][0] * (i+1) * 100 + pc[i][1]
            if g <= 0: break
        ans = min(ans,cnt)

    print(ans)


if __name__ == '__main__':
    main()
Problem p03482 (python)

Fixed submission:
import sys,queue,math,copy,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

S = input()
ans = len(S)
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        ans = min(ans,max(i+1,len(S)-i-1))

print (ans)

Buggy submission (verdict: Runtime Error):
import sys,queue,math,copy,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

ans = len(S)
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        ans = min(ans,max(i+1,len(S)-i-1))

print (ans)

Buggy submission (verdict: Runtime Error):
import sys,queue,math,copy,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

ans = 10**5+1
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        ans = min(ans,max(i+1,len(S)-i-1))
if ans == 0: ans = len(S)

print (ans)
Problem p03557 (python)

Fixed submission:
import sys
from bisect import bisect
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()

bc = [0 for _ in range(n)]
for i in range(len(b)):
    if b[i] >= c[n-1]:
        break
    p = bisect(c,b[i])
    bc[i] = (n-p)

for i in range(len(b)-1,0,-1):
    bc[i-1] += bc[i]
ans = 0
for i in range(len(a)):
    if a[i] >= b[n-1]:
        break
    p = bisect(b,a[i])
    ans += bc[p]

print(ans)

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

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
b.sort()
c.sort()

bc = [0 for _ in range(n)]
for i in range(len(b)):
    if b[i] >= c[n-1]:
        break
    p = bisect(c,b[i])
    bc[i] = (n-p)

for i in range(len(b)-1,0,-1):
    bc[i-1] += bc[i]
ans = 0
for x in a:
    if x < b[n-1]:
        p = bisect(b,a[i])
        ans += bc[p]

print(ans)
Problem p03599 (python)

Fixed submission:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    A,B,C,D,E,F = LI()

    w = set()
    for i in range(int(F/A/100)+1):
        for j in range(int(F/B/100)+1):
            if 0 < A*i+B*j <= int(F/100):
                w.add((A*i+B*j)*100)
    s = set()
    for i in range(int(F*E/(100+E)/C)+1):
        for j in range(int(F*E/(100+E)/D)+1):
            if 0 <= C*i+D*j <= int(F*E/(100+E)):
                s.add(C*i+D*j)

    max_E = -1.0
    ans_w = 0
    ans_s = 0
    for x in w:
        for y in s:
            if x + y <= F and y <= x/100 * E and max_E < y/(x+y) * 100:
                max_E = y/(x+y) * 100
                ans_w = x + y
                ans_s = y
    print(ans_w,ans_s)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    A,B,C,D,E,F = LI()

    w = set()
    for i in range(int(F/A/100)+1):
        for j in range(int(F/B/100)+1):
            #if 0 < A*i+B*j <= int(F/100):
                w.add((A*i+B*j)*100)
    s = set()
    for i in range(int(F*E/(100+E)/C)+1):
        for j in range(int(F*E/(100+E)/D)+1):
            if 0 <= C*i+D*j <= int(F*E/(100+E)):
                s.add(C*i+D*j)

    max_E = -1.0
    ans_w = 0
    ans_s = 0
    for x in w:
        for y in s:
            if x + y <= F and y/x*100 <= E and max_E < y/(x+y) * 100:
                max_E = y/(x+y) * 100
                ans_w = x + y
                ans_s = y
    print(ans_w,ans_s)

if __name__ == '__main__':
    main()
Problem p03682 (python)

Fixed submission:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    xy = [LI() for _ in range(N)]

    x = [(xy[i][0],i) for i in range(N)]
    y = [(xy[i][1],i) for i in range(N)]

    x.sort()
    y.sort()

    edge = []
    p,i = x[0]
    for q,j in x[1:]:
        edge.append((q-p,i,j))
        p,i = q,j

    p,i = y[0]
    for q,j in y[1:]:
        edge.append((q-p,i,j))
        p,i = q,j

    edge.sort()

    g = [i for i in range(N + 1)]
    g_num = [1 for i in range(N + 1)]

    def find(x):
        if g[x] == x: return x
        g[x] = find(g[x])
        return g[x]

    def union(x, y):
        if find(x) == find(y): return
        if g_num[g[x]] < g_num[g[y]]: x, y = y, x
        g_num[g[x]] += g_num[g[y]]
        g_num[g[y]] = 0
        g[g[y]] = g[x]

    ans = 0
    for v,i,j in edge:
        if find(i) != find(j):
            ans += v
            union(i,j)

    print(ans)



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import queue,sys,copy
sys.setrecursionlimit(10**7)
INF = 10**10
N = int(input())
x = [0 for _ in range(N)]
y = [0 for _ in range(N)]
for i in range(N):
    x[i], y[i] = map(int,input().split())
ix = [i for i in range(N)]
sort_x_ix = sorted(ix, key=lambda i:x[i])
sort_x = [x[i] for i in sort_x_ix]
sort_y_ix = sorted(ix, key=lambda i:y[i])
sort_y = [y[i] for i in sort_y_ix]

g = [i for i in range(N+1)]
def root(x):
    if g[x] == x : return x
    g[x] = root(g[x])
    return g[x]
q = []
for i in range(N-1):
    q.append((sort_x[i+1]-sort_x[i],sort_x_ix[i],sort_x_ix[i+1]))
    q.append((sort_y[i+1]-sort_y[i],sort_y_ix[i],sort_y_ix[i+1]))

q.sort()
ans = 0
cnt = N

for d,s,t in q:
    if cnt <= 1: break
    if root(s) != root(t):
        ans += d
        cnt -= 1
        root(g[t]) = g[s]
print(ans)

Buggy submission (verdict: Runtime Error):
import queue
INF = 10**10
N = int(input())
x = [0 for _ in range(N)]
y = [0 for _ in range(N)]
for i in range(N):
    x[i], y[i] = map(int,input().split())
x_ix = [*range(N)]
y_ix = [*range(N)]
sort_x_ix = sorted(x_ix, key=lambda i:x[i])
sort_x = [x[i] for i in sort_x_ix]
sort_y_ix = sorted(y_ix, key=lambda i:y[i])
sort_y = [y[i] for i in sort_y_ix]

g = [i for i in range(N+1)]
def root(x):
    if g[x] == x : return x
    g[x] = root(g[x])
    return g[x]
q = []
for i in range(N-1):
    q.append((sort_x[i+1]-sort_x[i],sort_x_ix[i],sort_x_ix[i+1]))
    q.append((sort_y[i+1]-sort_y[i],sort_y_ix[i],sort_y_ix[i+1]))
q.sort()
ans = 0
cnt = N
for d,s,t in q:
    if cnt <= 1: break
    if root(s) != root(t):
        ans += d
        cnt -= 1
        g[root(t)] = g[s]

print(ans)
Problem p03946 (python)

Fixed submission:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,_ = LI()
    N0 = 2 ** N.bit_length()
    st = [0] * (N0*2)

    def add(p,x):
        p += N0-1
        st[p] = x
        while p > 0:
            p = (p-1) // 2
            st[p] = max(st[p*2+1],st[p*2+2])

    def get(a,b,x,l,r):
        if a <= l and r <= b: return st[x]
        if a >= r or b <= l: return 0
        vl = get(a,b,x*2+1,l,(l+r)//2)
        vr = get(a,b,x*2+2,(l+r)//2,r)
        return max(vl,vr)
    A = LI()
    for e,a in enumerate(A):
        add(e+1,a)
    max_a = -1
    max_cnt = 0
    for i in range(1,N):
        a = get(i+1,N+1,0,0,N0) - A[i-1]
        if a > max_a:
            max_a = a; max_cnt = 1
        elif a == max_a:
            max_cnt += 1

    print(max_cnt)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,_ = LI()
    N0 = 2 ** N.bit_length()
    st = [0] * (N0*2)

    def add(p,x):
        p += N0-1
        st[p] = x
        while p > 0:
            p = (p-1) // 2
            st[p] = max(st[p*2+1],st[p*2+2])

    def get(a,b,x,l,r):
        if a <= l and r <= b: return st[x]
        if a >= r or b <= l: return 0
        vl = get(a,b,x*2+1,l,(l+r)//2)
        vr = get(a,b,x*2+2,(l+r)//2,r)
        return max(vl,vr)
    
    A = []
    for a in enumerate(sys.stdin.readline().split()):
        a = int(a)
        A.append(a)
        add(e+1,a)
    max_a = -1
    max_cnt = 0
    for i in range(1,N):
        a = get(i+1,N+1,0,0,N0) - A[i-1]
        if a > max_a:
            max_a = a; max_cnt = 1
        elif a == max_a:
            max_cnt += 1

    print(max_cnt)


if __name__ == '__main__':
    main()
Problem p03952 (python)

Fixed submission:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,x = LI()
    if x == 1 or x == 2*N-1:
        print('No')
        return

    ans = [0] * (2*N-1)
    ans[N-2] = x-1
    ans[N-1] = x
    ans[N] = x+1

    j = N+1
    for i in range(1,2*N):
        if i < x-1 or i > x+1:
            ans[j] = i
            j += 1
            if j >= 2 * N - 1:
                j = 0
    print('Yes')
    print(*ans,sep='\n')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,x = LI()
    if x == 1 or x == N-1:
        print('No')
        return

    ans = [0] * (2*N-1)
    ans[N-2] = x-1
    ans[N-1] = x
    ans[N] = x+1

    j = N+1
    for i in range(1,2*N):
        if i < x-1 or i > x+1:
            ans[j] = i
            j += 1
            if j >= 2 * N - 1:
                j = 0
    print('Yes')
    print(*ans,sep='\n')


if __name__ == '__main__':
    main()
Problem p03966 (python)

Fixed submission:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    b = [LI() for _ in range(N)]

    for i in range(1,N):
        if b[i][0] < b[i-1][0] or b[i][1] < b[i-1][1]:
            r = max((b[i-1][0]-1)//b[i][0],(b[i-1][1]-1)//b[i][1]) + 1
            b[i][0] *= r
            b[i][1] *= r
    print(sum(b[-1]))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    b = [LI() for _ in range(N)]

    for i in range(1,N):
        if b[i][0] < b[i-1][0] or b[i][1] < b[i-1][1]:
            r = max(math.ceil([i-1][0]/b[i][0]),math.ceil([i-1][1]/b[i][1]))
            b[i][0] *= r
            b[i][1] *= r
    print(sum(b[-1]))

if __name__ == '__main__':
    main()
Problem p03029 (python)

Fixed submission:
a=list(map(int,input().split()))
b=(3*a[0]+a[1])//2
print(b)

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))

print((3*a_1+a_2)%2)
Problem p02600 (python)

Fixed submission:
x = int(input())
print(10 - x // 200)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a_cur = a[0]

m = 1000
s = 0

for i in range(1, n):
  a_next = a[i]
  if a_cur < a_next:
    # buy current and sell next
    s = m // a_cur
    m += s * (a_next - a_cur)
    a_cur = a_next
if s > 0:
  m += s * a[-1]
print(m)
Problem p02603 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
# dp[buy][sell]
dp = [0 for j in range(n)]
dp[0] = 1000
for i in range(n):
    ai = a[i]
    m = dp[i]
    s = m // ai

    for j in range(i + 1, n):
        dp[j] = max(dp[j], m + s * (a[j] - ai))

    for j in range(n - 1):
        dp[j + 1] = max(dp[j + 1], dp[j])
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a_cur = a[0]

m = 1000
s = 0

for i in range(1, n):
  a_next = a[i]
  elif a_cur < a_next:
    # buy current and sell next
    s = m // a_cur
    m += s * (a_next - a_cur)
    a_cur = a_next
    if s > 0:
      m += s * a[-1]
      print(m)
Problem p02692 (python)

Fixed submission:
n, *x = map(int, input().split())
k = 'ABC'
ans = []
s = [input() for _ in range(n)]
for p in range(n):
    sp = s[p]
    if sp == 'AB':
        i = 0
        j = 1
    elif sp == 'BC':
        i = 1
        j = 2
    else:
        i = 0
        j = 2
    if x[i] == x[j] == 0:
        print('No')
        break
    if x[i] == x[j] and p < n - 1:
        sp1 = s[p + 1]
        if k[i] in sp1:
            x[i] += 1
            x[j] -= 1
            ans.append(k[i])
        else:
            x[i] -= 1
            x[j] += 1
            ans.append(k[j])
    elif x[i] < x[j]:
        x[i] += 1
        x[j] -= 1
        ans.append(k[i])
    else:
        x[i] -= 1
        x[j] += 1
        ans.append(k[j])
else:
    print('Yes')
    print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
n, *x = map(int, input().split())
k = 'ABC'
ans = []
s = [input() for _ in range(n)]
for p in range(n):
    sp = s[p]
    if sp == 'AB':
        i = 0
        j = 1
    elif sp == 'BC':
        i = 1
        j = 2
    else:
        i = 0
        j = 2
    if x[i] == x[j] == 0:
        print('No')
        break
    if x[i] == x[j] and i < n - 1:
        sp1 = s[p + 1]
        if k[i] in si1:
            x[i] += 1
            x[j] -= 1
            ans.append(k[i])
        else:
            x[i] -= 1
            x[j] += 1
            ans.append(k[j])
    elif x[i] < x[j]:
        x[i] += 1
        x[j] -= 1
        ans.append(k[i])
    else:
        x[i] -= 1
        x[j] += 1
        ans.append(k[j])
else:
    print('Yes')
    print(*ans, sep='\n')
Problem p02718 (python)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if a[m - 1] * 4 * m >= sum(a):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if a[m] * 4 * m >= sum(a):
    print('Yes')
else:
    print('No')
Problem p02787 (python)

Fixed submission:
h, n = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
a, b = x[0]
dp = [-(-i // a) * b for i in range(h + 1)]
for j in range(1, n):
    a, b = x[j]
    for i in range(min(h + 1, a)):
        dp[i] = min(dp[i], b)
    for i in range(a, h + 1):
        dp[i] = min(dp[i], dp[i - a] + b)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
h, n = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
a, b = x[0]
dp = [[-(-i // a) * b for i in range(h + 1)] for j in range(2)]
for j in range(1, n):
    a, b = x[j]
    for i in range(h + 1):
        if i >= a:
            dp[j % 2][i] = min(dp[1 - j % 2][i], dp[1 - j % 2][i - a] + b)
        else:
            dp[j % 2][i] = min(dp[1 - j % 2][i], b)
print(dp[j % 2][-1])
Problem p02841 (python)

Fixed submission:
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

print(int(m2 == m1 + 1 and d2 == 1))

Buggy submission (verdict: Runtime Error):
def is_cross(la, lb, x1, x2):
    ya1 = la[0] * x1 + la[1]
    ya2 = la[0] * x2 + la[1]
    yb1 = lb[0] * x1 + lb[1]
    yb2 = lb[0] * x2 + lb[1]
    if ya1 == yb1:
        return False
    return (ya1 - yb1) * (ya2 - yb2) <= 0

def get_line(c, x, y):
    return [c, y - c * x]

t = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xa = sum([ti * ai for ti, ai in zip(t, a)])
xb = sum([ti * bi for ti, bi in zip(t, b)])
if xa / sum(t) == xb / sum(t):
    print('infinity')
else:
    ans = 0
    t_pre = 0
    da = 0
    db = 0
    while(True):
        ans_t = 0
        for ti, ai, bi in zip(t, a, b):
            t_post = t_pre + ti
            la = get_line(ai, t_pre, da)
            lb = get_line(bi, t_pre, db)
            ans_t += is_cross(la, lb, t_pre, t_post)
            t_pre = t_post
            da += ti * ai
            db += ti * bi

        if ans_t == 0:
            break
        ans += ans_t
    print(ans)
Problem p02900 (python)

Fixed submission:
from fractions import gcd

def factrize(n):
    b = []
    while n % 2 == 0:
        b.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            b.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        b.append(n)
    return b

a, b = map(int, input().split())
d = gcd(a, b)
p = factrize(d)
p_unique = set(p)
print(len(p_unique) + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

def factrize(n):
    b = []
    while n % 2 == 0:
        if len(b) == 0 or b[-1] != f:
            b.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if len(b) == 0 or b[-1] != f:
                b.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        b.append(n)
    return b

a, b = map(int, input().split())
d = gcd(a, b)
p = factrize(d)
print(len(p) + 1)
Problem p02999 (python)

Fixed submission:
x, a = map(int, input().split())
if x < a:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main(){
    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
}
Problem p03006 (python)

Fixed submission:
from collections import defaultdict

n = int(input())
z = [list(map(int, input().split())) for _ in range(n)]
if n == 1:
    ans = 1
else:
    d = defaultdict(int)
    for i in range(n):
        xi, yi = z[i]
        for j in range(n):
            if i == j:
                continue
            xj, yj = z[j]
            d[(xi - xj, yi - yj)] += 1
    ans = n - max(d.values())
print(ans)

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

n = int(input())
z = [list(map(int, input().split())) for _ in range(n)]
d = defaultdict(int)
for i in range(n):
    xi, yi = z[i]
    for j in range(n):
        if i == j:
            continue
        xj, yj = z[j]
        d[(xi - xj, yi - yj)] += 1
print(n - max(d.values()))
Problem p03044 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 5 + 1)

def dfs(i, V, E):
    for k in E[i].keys():
        if V[k] >= 0:
            continue
        if E[i][k] % 2:
            V[k] = 1 - V[i]
        else:
            V[k] = V[i]
        V = dfs(k, V, E)
    return V

n = int(input())
E = {}
for i in range(n - 1):
    ui, vi, wi = map(int, input().split())
    if ui in E.keys():
        E[ui][vi] = wi
    else:
        E[ui] = {vi: wi}
    if vi in E.keys():
        E[vi][ui] = wi
    else:
        E[vi] = {ui: wi}
V = [-1 for _ in range(n + 1)]
V[1] = 0
V = dfs(1, V, E)
for vi in V[1:]:
    print(vi)

Buggy submission (verdict: Runtime Error):
def dfs(i, V, E):
    if i in E.keys():
        for k in E[i].keys():
            if V[k] >= 0:
                continue
            if E[i][k] % 2:
                V[k] = 1 - V[i]
            else:
                V[k] = V[i]
            V = dfs(k, V, E)
    return V

n = int(input())
E = {}
for i in range(n - 1):
    ui, vi, wi = map(int, input().split())
    if ui in E.keys():
        E[ui][vi] = wi
    else:
        E[ui] = {vi: wi}
    if vi in E.keys():
        E[vi][ui] = wi
    else:
        E[vi] = {ui: wi}
V = [-1 for _ in range(n + 1)]
V[1] = 0
V = dfs(1, V, E)
for vi in V[1:]:
    print(vi)

Buggy submission (verdict: Runtime Error):
def dfs(i, V, E):
    for k in E[i].keys():
        if V[k] >= 0:
            continue
        if E[i][k] % 2:
            V[k] = 1 - V[i]
        else:
            V[k] = V[i]
        V = dfs(k, V, E)
    return V

n = int(input())
E = {}
for i in range(n - 1):
    ui, vi, wi = map(int, input().split())
    if ui in E.keys():
        E[ui][vi] = wi
    else:
        E[ui] = {vi: wi}
    if vi in E.keys():
        E[vi][ui] = wi
    else:
        E[vi] = {ui: wi}
V = [-1 for _ in range(n + 1)]
V[1] = 0
V = dfs(1, V, E)
for vi in V[1:]:
    print(vi)