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

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

n = len(v)
from collections import defaultdict
c0 = defaultdict(int)
for vi in v[0::2]:
    c0[vi] += 1
c1 = defaultdict(int)
for vi in v[1::2]:
    c1[vi] += 1

sc0 = sorted(c0.items(), key=lambda x: x[1])
sc1 = sorted(c1.items(), key=lambda x: x[1])
#print(n)
#print(sc0)
#print('------------------')
#print(sc1)
if sc0[-1][0] != sc1[-1][0]:
    #print('--1')
    print(n//2 - sc0[-1][1] + n//2 - sc1[-1][1])
    exit()
if len(sc0) == 1 and len(sc1) == 1:
    #print('--2')
    print(n//2)
    exit()
if sc0[-1][1] > sc1[-1][1]:
    #print('--3')
    print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])
    exit()
if sc0[-1][1] < sc1[-1][1]:
    #print('--4')
    print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])
    exit()
if sc0[-1][1] == sc1[-1][1]:
    if sc0[-2][1] < sc1[-2][1]:
        #print('--1',sc0[-1][1],sc1[-1][1], sc0[-2][1],sc1[-2][1])
        print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])
    else:
        #print('--1',sc0[-1][1],sc1[-1][1], sc0[-2][1],sc1[-2][1])
        print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])
    exit()

#(92753, 12393), (2054, 12394), (27775, 12395)
#(55530, 10),    (50652, 12393),   (27775, 12395)

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

n = len(v)
from collections import defaultdict
c0 = defaultdict(int)
for vi in v[0::2]:
    c0[vi] += 1
c1 = defaultdict(int)
for vi in v[1::2]:
    c1[vi] += 1

sc0 = sorted(c0.items(), key=lambda x: x[1])
sc1 = sorted(c1.items(), key=lambda x: x[1])

print(sc0)
print('-----------')
print(sc1)
if sc0[-1][0] != sc1[-1][0]:
    #print('--1')
    print(n//2 - sc0[-1][1] + n//2 - sc1[-1][1])
    exit()
if len(sc0) == 1 and len(sc1) == 1:
    #print('--2')
    print(n//2)
    exit()
if sc0[-1][1] == sc1[-1][1]:
    if sc0[-2][1] > sc1[-2][1]:
        print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])
    else:
        print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])
    exit()
if sc0[-1][1] > sc1[-1][1]:
    #print('--3')
    print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])
    exit()
else:
    #print('--4')
    print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])
    exit()
 (2054, 12394), (27775, 12395)
(50652, 12393), (27775, 12395)
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())
k = k-1
def not1(t):
    for i in range(len(t)):
        if t[i] != '1':
            return (i, t[i])
    return (-1, '1')
(j, t) = not1(s)
if j == -1:
    print('1')
    exit()
if k < j:
    print('1')
    exit()
if k >= j:
    print(t)
    exit()

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

if s[0] == '1':
    print(s[1])
else:
    print(s[0])
Problem p03309 (python)

Fixed submission:
n = int(input())
a = list(map(int , input().split()))
b = [a[i] - (i+1) for i in range(n)]

b.sort()
idx= n//2
bi = b[idx]
ans = 0
for i in range(n):
    ans += abs(a[i] - (i + 1 + bi))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int , input().split()))
b = [a[i] - (i+1) for i in range(n)]
#sa = sum(a)
b.sort()
#print(b)
ans = 10 ** 10
for j in range(3):
    bi = b[n//2+j]
    s = 0
    for i in range(n):
        s += abs(b[i] - bi)
    #print(s)
    ans = min(ans, s)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int , input().split()))
b = [a[i] - (i+1) for i in range(n)]
#sa = sum(a)
b.sort()
#print(b)
ans = 10 ** 10
for j in range(3):
    bi = b[(n + j)//2]
    s = 0
    for i in range(n):
        s += abs(b[i] - bi)
    #print(s)
    ans = min(ans, s)
print(ans)
Problem p03324 (python)

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

if n == 100:
    print(100 ** d * (n+1))
    exit()
print(100 ** d * n)

Buggy submission (verdict: Runtime Error):
d, n = map(int, input().split())

if n == 100:
    print(100 ** d * (n+1))
    exit()
print(100 ** d * n
Problem p03402 (python)

Fixed submission:
a, b = map(int, input().split())
n = 24
unit = [
    '####',
    '#.#.',
    '#.#.',
    '....'
]
row = [
    '.' + unit[0]*n + '#',
    '.' + unit[1]*n + '#',
    '.' + unit[2]*n + '#',
    '.' + unit[3]*n + '#'
]
grid = []
for i in range(n):
    grid.append(list(row[0]))
    grid.append(list(row[1]))
    grid.append(list(row[2]))
    grid.append(list(row[3]))
"""
# 黒
for i in range(n):
    grid[0][4*(i+1)] = 'x'
for i in range(n):
    grid[4*i][4] = 'y'
# 白
for i in range(n):
    grid[2][4*(i+1)-2] = 'w'
for i in range(n):
    grid[4*(i+1)-2][2] = 'v'
"""
# 白
for i in range(a//n+1):
    for j in range(n):
        if i * n + j < a-1:
            #print('#',4*(j+1)-2,4*(i+1)-2)
            grid[4*(i+1)-2][4*(j+1)-2] = '#'

# 黒
for i in range(b//n+1):
    for j in range(n):
        if i * n + j < b-1:
            #print('.',4*j,4*(i+1))
            grid[4*i][4*(j+1)] = '.'

print(len(grid), len(grid[0]))
for i in grid:
    print(''.join(i))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
n = 3
unit = [
    '####',
    '#.#.',
    '#.#.',
    '....'
]
row = [
    '.' + unit[0]*n + '#',
    '.' + unit[1]*n + '#',
    '.' + unit[2]*n + '#',
    '.' + unit[3]*n + '#'
]
grid = []
for i in range(n):
    grid.append(list(row[0]))
    grid.append(list(row[1]))
    grid.append(list(row[2]))
    grid.append(list(row[3]))
"""
# 黒
for i in range(n):
    grid[0][4*(i+1)] = 'x'
for i in range(n):
    grid[4*i][4] = 'y'
# 白
for i in range(n):
    grid[2][4*(i+1)-2] = 'w'
for i in range(n):
    grid[4*(i+1)-2][2] = 'v'
"""
# 白
for i in range(a//n+1):
    for j in range(n):
        if i * n + j < a-1:
            #print('#',4*(j+1)-2,4*(i+1)-2)
            grid[4*(i+1)-2][4*(j+1)-2] = '#'

# 黒
for i in range(b//n+1):
    for j in range(n):
        if i * n + j < b-1:
            #print('.',4*j,4*(i+1))
            grid[4*i][4*(j+1)] = '.'

print(len(grid), len(grid[0]))
for i in grid:
    print(''.join(i))
Problem p03447 (python)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())

print((x - a)%b)

Buggy submission (verdict: Runtime Error):
x = int(input().split())
a = int(input().split())
b = int(input().split())

print((x - a)%b)
Problem p03477 (python)

Fixed submission:
a,b,c,d = map(int, input().split())
if (a+b) > (c+d):
    print('Left')
if (a+b) == (c+d):
    print('Balanced')
if (a+b) < (c+d):
    print('Right')

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int, input().split())
if (a+b) > (c,d):
    print('Left')
if (a+b) == (c,d):
    print('Balanced')
if (a+b) < (c,d):
    print('Right')
Problem p03480 (python)

Fixed submission:
s = input()
"""
s = '101'
s = '100000000'
s = '00001011'
"""
k = len(s)
for i in range(1, len(s)):
    if s[i-1] != s[i]:
        k = min(k, max(i, len(s)-i))
print(k)

Buggy submission (verdict: Runtime Error):
#s = input()
"""
s = '101'
s = '100000000'
s = '00001011'
"""
k = len(s)
for i in range(1, len(s)):
    if s[i-1] != s[i+1]:
        k = min(k, max(i, len(s)-i))
print(k)
Problem p03546 (python)

Fixed submission:
h, w = map(int, input().split())
d = []
for i in range(10):
    d.append(list(map(int, input().split())))
a = []
for i in range(h):
    a.append(list(map(int, input().split())))
for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

#for k in range(0, 10):
#    print(c[k])
#for k in range(0, 10):
#    print(d[k])
#print(d[8][1])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != -1:
            ans += d[a[i][j]][1]
print(ans)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
d = []
for i in range(10):
    d.append(map(int, input().split()))
a = []
for i in range(h):
    a.append(map(int, input().split()))
for k in range(10):
    for i in range(10):
        for j in range(10):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

#for k in range(0, 10):
#    print(c[k])
#for k in range(0, 10):
#    print(d[k])
#print(d[8][1])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != 1 or a[i][j] != -1:
            ans += d[a[i][j]][1]
print(ans)

Buggy submission (verdict: Runtime Error):
h, w = input().split()
d = []
for i in range(10):
    d.append(map(int, input().split()))
a = []
for i in range(h):
    a.append(map(int, input().split()))
for k in range(10):
    for i in range(10):
        for j in range(10):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

#for k in range(0, 10):
#    print(c[k])
#for k in range(0, 10):
#    print(d[k])
#print(d[8][1])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != 1 or a[i][j] != -1:
            ans += d[a[i][j]][1]
print(ans)

Buggy submission (verdict: Runtime Error):
x = input().split()
#x = "3 5 0 4 3 6 2 7 2 5 3 3 4 0 5 3 7 5 3 7 2 7 5 7 0 7 2 9 3 2 9 1 3 6 2 0 2 4 6 4 2 3 3 5 7 4 0 6 9 7 6 7 9 8 5 2 2 0 4 7 6 5 5 4 6 3 2 3 0 5 4 3 3 6 2 3 4 2 4 0 8 9 4 6 5 4 3 5 3 2 0 8 2 1 3 4 5 7 8 6 4 0 3 5 2 6 1 2 5 3 2 1 6 9 2 5 6".split()
#x = "2 4 0 9 9 9 9 9 9 9 9 9 9 0 9 9 9 9 9 9 9 9 9 9 0 9 9 9 9 9 9 9 9 9 9 0 9 9 9 9 9 9 9 9 9 9 0 9 9 9 9 2 9 9 9 9 9 0 9 9 9 9 9 9 9 9 9 9 0 9 9 9 9 9 9 9 9 9 9 0 9 9 9 9 9 9 2 9 9 9 0 9 9 2 9 9 9 9 9 9 9 0 -1 -1 -1 -1 8 1 1 8".split()
h = int(x[0])
w = int(x[1])
d = []
for i in range(10):
    d.append(
        list(map(int, x[2 + i * 10 : 2 + i * 10 + 10]))
    )
a = []
for i in range(h):
    a.append(
        list(map(int, x[102 + i * w: 102 + i * w + w]))
    )
#d = [[0] * 10] * 10
for k in range(10):
    for i in range(10):
        for j in range(10):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

#for k in range(0, 10):
#    print(c[k])
#for k in range(0, 10):
#    print(d[k])
#print(d[8][1])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != 1 or a[i][j] != -1:
            ans += d[a[i][j]][1]
print(ans)
Problem p02658 (python)

Fixed submission:

import sys
N = int(input())
A = list(map(int, input().split()))
A.sort()
tar = 1
for i in A:
    tar *= i
    if tar > 10 ** 18:
        print('-1')
        sys.exit()

print(tar)

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

tar = reduce(lambda x, y: x*y, A)

if tar > 10 ** 18:
    print(-1)
else:
    print(tar)

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

tar = reduce(lambda x, y: x*y, values)

if tar > 10 ** 18:
    print(-1)
else:
    print(tar)

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

tar = 1
for i in range(A):
    tar *= i

if tar > 10 ** 18:
    print(-1)
else:
    print(tar)

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

tar = 1
for i in range(A):
    tar *=  i

if tar > 10 ** 18:
    print(-1)
else:
    print(tar)

Buggy submission (verdict: Runtime Error):
N = input()
A = list(map(int, input().split))
tar = 1
for i in range(N):
    tar *= A[i]

print(tar)
Problem p02663 (python)

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

main = (data[2] - data[0]) * 60 + data[3] - data[1] - data[4]

print(main)

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

main = (data[2] - date[0]) * 60 + data[3] - date[1] - data[3]
Problem p02861 (python)

Fixed submission:
import math
from itertools import permutations

def dist(x0, y0, x1, y1):
    return math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2)

def resolve():
    N = int(input())
    x, y = [], []
    for _ in range(N):
        x_tmp, y_tmp = list(map(int, input().split()))
        x.append(x_tmp)
        y.append(y_tmp)

    ls = list(permutations(list(range(N)), N))
    ans = 0
    for l in ls:
        idx = 0
        while idx + 1 < len(l):
            ans += dist(x[l[idx]], y[l[idx]], x[l[idx+1]], y[l[idx+1]])
            idx += 1

    print(ans / len(ls))
    return

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    x, y, = [], []
    for i in range(N):
        x_tmp, y_tmp = list(map(int, input().split()))
        x.append(x_tmp)
        y.append(y_tmp)
    ans = 0
    ls = list(permutations(list(range(N)), N))
    for l in ls:
        for i in range(len(l)-1):
            ans += dist(x[l[i]], y[l[i]], x[l[i+1]], y[l[i+1]])

    print(ans / len(ls))
    return

resolve()

Buggy submission (verdict: Runtime Error):
def dist(x0, y0, x1, y1):
    return math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2)

def resolve():
    N = int(input())
    x, y = [], []
    for _ in range(N):
        x_tmp, y_tmp = list(map(int, input().split()))
        x.append(x_tmp)
        y.append(y_tmp)

    ls = list(permutations(list(range(N)), N))
    ans = 0
    for l in ls:
        idx = 0
        while idx + 1 < len(l):
            ans += dist(x[l[idx]], y[l[idx]], x[l[idx+1]], y[l[idx+1]])
            idx += 1

    print(ans / len(ls))
    return

resolve()
Problem p02971 (python)

Fixed submission:
def resolve():
    N = int(input())
    A = [int(input()) for n in range(N)]
    B = A.copy()
    B.sort()
    mx = max(A)
    count = A.count(mx)

    for i in range(N):
        if mx > A[i]:
            print(mx)
        elif mx == A[i]:
            if count >= 2:
                print(mx)
            else:
                print(B[-2])
    return


resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    A = [int(input()) for n in range(N)]
    B = A.copy()
    B.sort()
    for i in range(N):
        if max(A) > A[i]:
            print(max(A))
        elif max(A) == A[i]:
            if A.count(max(A)) >= 2:
                print(max(A))
            else:
                print(B[-2])
    return

resolve()
Problem p03281 (python)

Fixed submission:
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def resolve():
    N = int(input())
    ans = 0
    for i in range(1, N+1, 2):
        tmp = make_divisors(i)
        if len(tmp) == 8:
            ans += 1
    print(ans)
    return

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    ans = 0
    for i in range(1, N+1, 2):
        tmp = make_divisors(i)
        if len(tmp) == 8:
            ans += 1
    print(ans)
    return

resolve()
Problem p03282 (python)

Fixed submission:
def resolve():
    S = str(input())
    K = int(input())

    if S[0] != '1':
        print(S[0])
        return
    else:
        for i in range(1, K):
            if S[i] != '1':
                print(S[i])
                return
            else:
                continue
        print('1')

    return

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    S = str(input())
    K = int(input())
    idx = S.find('1')

    if idx == -1:
        print(S[0])
        return
    else:
        if idx <= K:
            print(S[idx+1])
        else:
            print(S[0])
    return

resolve()
Problem p03325 (python)

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

def resolve():
    N = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in a:
        ans += prime_factorize(i).count(2)

    print(ans)

    return

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in a:
        ans += prime_factorize(i).count(2)

    print(ans)

    return

resolve()
Problem p03386 (python)

Fixed submission:
def resolve():
    A, B, K = list(map(int, input().split()))
    if B - A + 1 >= 2 * K:
        ls = [i for i in range(A, A+K)] + [i for i in range(B-K+1, B+1)]
    else:
        ls = [i for i in range(A, B+1)]

    print('\n'.join(map(str, ls)))
    return

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    A, B, K = list(map(int, input().split()))
    l = list(range(A, B+1))
    if len(l) >= 2 * K:
        ls = [i for i in range(A, A+K)] + [i for i in range(B-K+1, B+1)]
    else:
        ls = [i for i in range(A, B+1)]
    for _ in ls:
        print(_)
    return

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    A, B, K = list(map(int, input().split()))
    l = list(range(A, B+1))
    if len(l) >= 2 * K:
        ls = l[:K] + l[-K:]
    else:
        ls = l
    for _ in ls:
        print(_)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    A, B, K = list(map(int, input().split()))
    l = list(range(A, B+1))
    if 2*K > len(l):
        mn, mx = l, l
    else:
        mn = l[:K]
        mx = l[-K:]
    ans = mn + mx
    ans = list(set(ans))
    ans.sort()
    ans = list(map(str, ans))
    print('\n'.join(ans))

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    A, B, K = list(map(int, input().split()))
    l = list(range(A, B+1))
    if K > len(l):
        mn, mx = l, l
    else:
        mn = l[:K]
        mx = l[-K:]
    ans = mn + mx
    ans = list(set(ans))
    ans.sort()
    ans = list(map(str, ans))
    print('\n'.join(ans))

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    A, B, K = list(map(int, input().split()))
    l = list(range(A, B+1))
    mn = l[:K]
    mx = l[-K:]
    ans = (mn + mx)
    ans = list(set(ans))
    ans.sort()
    ans = list(map(str, ans))
    print('\n'.join(ans))

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    A, B, K = list(map(int, input().split()))
    l = list(range(A, B+1))
    mn = l[:K]
    mx = l[-K:]
    ans = (mn + mx)
    ans = list(set(ans))
    ans.sort()
    ans = list(map(str, ans))
    print('\n'.join(ans))

resolve()
Problem p03408 (python)

Fixed submission:
def resolve():
    N = int(input())
    s = [input() for _ in range(N)]
    M = int(input())
    t = [input() for _ in range(M)]
    sdict = {k: 0 for k in set(s)}
    tdict = {k: 0 for k in set(t)}
    for w in s:
        sdict[w] += 1
    for w in t:
        tdict[w] += 1
    ks = set(s) | set(t)
    ans = 0
    for key in ks:
        ans = max(ans, sdict.get(key, 0) - tdict.get(key, 0))

    print(ans)

    return
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    A, B, C, K = list(map(int, input().split()))
    if A + B >= K:
        print(A)
    else:
        print(A-(K - A - B))

    return


resolve()
Problem p03494 (python)

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

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 10**5
    for a in A:
        a = prime_factorize(a)
        ans = min(ans, a.count(2))
    if (ans == 10 ** 5):
        ans = 0
    print(ans)
    return


resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 10**5
    for a in A:
        a = prime_factorize(a)
        ans = min(ans, a.count(2))
    if (ans == 10 ** 5):
        ans = 0
    print(ans)
    return


resolve()
Problem p03645 (python)

Fixed submission:
N, M = map(int, input().split())
a = [0] * M
b = [0] * M

for i in range(M):
    a[i], b[i] = map(int, input().split())

s = []
t = []

for i in range(M):
    if a[i] == 1:
        s.append(b[i])
    elif b[i] == N:
        t.append(a[i])

if len(set(s) & set(t)) == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [0] * M
b = [0] * M

for i in range(M):
    a[i], b[i] = map(int, input().split())

index = []
for i in range(M):
    if b[i] == N:
        index  = i

for j in range(M):
    if b[j] == a[index]:
        if a[j] == 1:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
        break

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [0] * M
b = [0] * M

for i in range(M):
    a[i], b[i] = map(int, input().split())

index = []
for i in range(M):
    if b[i] == N:
        index  = i

for j in range(M):
    if b[j] == a[index]:
        print(a[j])
        if a[j] == 1:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
        break
Problem p03680 (python)

Fixed submission:
N = int(input())
a = [input() for i in range(N)]

now = 1
count = 0

for i in range(N):
    if now != 2:
        now = int(a[now-1])
        count += 1
    else:
        print(count)
        break

if count == N:
    print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]

now = 1
count = 0

for i in range(N):
    if now != 2:
        now = int(a[now-1])
        count += 1
    else:
        print(count)
        break

if count == loop:
    print(-1)
Problem p03777 (python)

Fixed submission:
a, b = map(str, input().split())

if a == b:
    print("H")
elif not a == b:
    print("D")

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

if a + W < b:
    print(b - a - W)
elif a + W == b:
    print(0)
elif (b < a + W) & (a < b):
    print(0)
elif a == b:
    print(0)
elif b < a:
    print(0)
elif a == b + W:
    print(0)
elif b + W < a:
    print(a - b - W)
else:
    pass

Buggy submission (verdict: Runtime Error):

if a + W < b:
    print(b - a - W)
elif a + W = b:
    print(0)
elif (b < a + W) & (a < b):
    print(0)
elif a == b:
    print(0)
elif b < a:
    print(0)
elif a = b + W:
    print(0)
elif b + W < a:
    print(a - b - W)
else:
    pass

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

if a + W < b:
    print(b - a - W)
elif a + W = b:
    print(0)
elif (b < a + W) & (a < b):
    print(0)
elif a == b:
    print(0)
elif b + W <= a:
    print(a - b - W)
else:
    pass
Problem p03971 (python)

Fixed submission:
def resolve():
    N, A, B = list(map(int, input().split()))
    S = str(input())
    num = 0
    foreignnum = 1
    for i in range(N):
        if S[i] == 'a':
            if (num < A + B):
                num += 1
                print('Yes')
            else:
                print('No')

        if S[i] == 'b':
            if (num < A + B) and (foreignnum <= B):
                num += 1
                foreignnum += 1
                print('Yes')
            else:
                print('No')

        if S[i] == 'c':
            print('No')
    return
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N, A, B = list(map(int, input().split()))
    S = str(input())
    num = 0
    foreignnum = 1
    for i in range(N):
        if S[i] == 'a':
            if (num < A + B):
                num += 1
                print('Yes')
            else:
                print('No')

        if S[i] == 'b':
            if (num < A + B) and (foreignnum <= B):
                num += 1
                foreignnum += 1
                print('Yes')
            else:
                print('No')

        if S[i] == 'c':
            print('No')

    return

 resolve()
Problem p04029 (python)

Fixed submission:
N = int(input())
print(int(N * (N+1) / 2))

Buggy submission (verdict: Runtime Error):
N = int(input())
print(int(N * (N+1) / 2)