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

Fixed submission:
import sys
N = int(input())
A = [int(x) for x in input().split()]

def solve(N, A):
    S = 0
    C = [A[0]]
    for i in range(1,N):
        if A[i] == C[-1]:
            continue
        C.append(A[i])
    A = C
    if len(C) == 1:
        print(1000)
        return
    C = [(A[0], '-' if A[0] <A[1] else '+')]

    for i in range(1,len(A)-1):
        if C[-1] ==  A[i]:
            continue
        if A[i-1] > A[i] <= A[i+1]:
            C.append((A[i], "-"))
        elif A[i-1] < A[i] >= A[i+1]:
            C.append((A[i], "+"))
    if C[-1][0] != A[-1]:
        C.append((A[-1], '+' if A[-1] > C[-1][0] else '-'))

    S = 0
    m = 1000
    if C and C[0][1] == '+':
        C = C[1:]
    if C and C[-1][1] == '-':
        C = C[:-1]
    #print(C,file=sys.stderr) 

    for p, s in C:
        m_ = m
        S_ = S
        if s == '+':
            m += p * S 
            S = 0
        else:
            # buy stock
            m -= (m_ // p) * p
            S = (m_ // p)
        #print(s, p, "money(%d -> %d)"%(m_, m), "stock(%d -> %d)"% (S_, S))
    print(m)

solve(N, A)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())
A = [int(x) for x in input().split()]

def solve(N, A):
    S = 0
    C = [A[0]]
    for i in range(1,N):
        if A[i] == C[-1]:
            continue
        C.append(A[i])
    A = C
    C = [(A[0], '-' if A[0] <A[1] else '+')]
    for i in range(1,len(A)-1):
        if C[-1] ==  A[i]:
            continue
        if A[i-1] > A[i] <= A[i+1]:
            C.append((A[i], "-"))
        elif A[i-1] < A[i] >= A[i+1]:
            C.append((A[i], "+"))
    if C[-1][0] != A[-1]:
        C.append((A[-1], '+' if A[-1] > C[-1][0] else '-'))

    S = 0
    m = 1000
    if C and C[0][1] == '+':
        C = C[1:]
    if C and C[-1][1] == '-':
        C = C[:-1]
    #print(C,file=sys.stderr) 

    for p, s in C:
        m_ = m
        S_ = S
        if s == '+':
            m += p * S 
            S = 0
        else:
            # buy stock
            m -= (m_ // p) * p
            S = (m_ // p)
        #print(s, p, "money(%d -> %d)"%(m_, m), "stock(%d -> %d)"% (S_, S))
    print(m)

solve(N, A)
Problem p02706 (python)

Fixed submission:
N, M = map(int, input().split())
A = sum([int(x) for x in input().split()])
if N - A < 0:
  print(-1)
else:
  print(N-A)

Buggy submission (verdict: Runtime Error):
N, M
A = sum([int(x) for x in input().split()])
if N - M < 0:
  print(-1)
else:
  print(N-M)
Problem p02787 (python)

Fixed submission:
def solve(H, N, AB):
    INF = 10e10
    dp = [[INF] * (H+1) for i in range(N+1)]
    dp[0][0] = 0
    A, B = AB[0]
    for j in range(H+1):
        dp[0][j] = min(dp[0][j], dp[0][max(0, j-A)]+B)
    for i in range(1,N):
        A, B = AB[i]
        for h in range(H+1):
            dp[i][h] = min(dp[i-1][h], dp[i][max(0, h-A)]+B)
        #print(i, *dp[i], sep="\t")
    
    return(dp[N-1][H])


def main():
    H, N = map(int, input().split())
    AB = []
    for i in range(N):
        A, B = map(int, input().split())
        AB.append((A, B))
    print(solve(H, N, AB))
main()

Buggy submission (verdict: Runtime Error):
def solve(H, N, AB):
    INF = 10e10
    dp = [[INF] * (H+1) for i in range(N+1)]
    dp[0][0] = 0
    A, B = AB[0]
    #print(" ", *range(H+1), sep="\t")
    for j in range(H+1):
        dp[0][j] = min(dp[0][j], dp[0][j-A]+B)
    #print(0, *dp[0], sep="\t")
    for i in range(1,N):
        A, B = AB[i]
        for h in range(H+1):
            dp[i][h] = min(dp[i-1][h], dp[i][max(0, h-A)]+B)
        #print(i, *dp[i], sep="\t")
    
    return(dp[N-1][H])


def main():
    H, N = map(int, input().split())
    AB = []
    for i in range(N):
        A, B = map(int, input().split())
        AB.append((A, B))
    print(solve(H, N, AB))
main()
Problem p02813 (python)

Fixed submission:
from itertools import permutations
N = int(input())

o = {}
for i, p in enumerate(permutations(range(1,N+1))):
  	o[p] = i
P = tuple(int(x) for x in input().split())
Q = tuple(int(x) for x in input().split())
print(abs(o[P] - o[Q]))

Buggy submission (verdict: Runtime Error):
from itertools import permutations
N = int(input())

o = {}
for i, p in enumerate(permutation(range(1,N+1))):
  	o[p] = i
P = tuple(int(x) for x in input().split())
Q = tuple(int(x) for x in input().split())
print(abs(o[P] - o[Q]))
Problem p02972 (python)

Fixed submission:


def solve(A, N):
    B = [0] * len(A)
    for i in range(1, N+1)[::-1]:
        A2 = A[i*2] if i*2 <= N else 0
        x = A[i]
        for j in range(i*2, N+1, i):
            x ^= B[j]
        B[i] = x
    return B

#from random import randint
#solve([0] + list(randint(0, 1) for _ in range(1000)), 1000)
def main():
    N = int(input())
    A = [0] + [int(x) for x in input().split()]
    B = solve(A, N)
    print(sum(B))
    for i in range(1, N+1):
        if B[i]:
            print(i)

main()

Buggy submission (verdict: Runtime Error):
from math import log


def solve(A, N):
    r = N // 2
    l = N
   
    M = set()
    for i in range(r, l):
        if A[i]:
            M.add(i)
    l = r
    r //=2

    while l > 0:
        for i in range(r, l):
            if A[i] and A[i<<1]:
                M.add(i)
                A[i] = 1
            else:
                A[i] = 0
        l = r
        r //=2

    return M


def main():
    N = int(input())
    X = [0] * (2**15)
    A = [int(x) for x in input().split()]
    for i in range(len(A)):
        X[i] = A[i]
    m = solve(X, 2**15)
    print(len(m))
    for i in m:
        print(i+1)

main()
Problem p02995 (python)

Fixed submission:
from fractions import gcd

def debug(*args):
    import sys
    #print(*args, file=sys.stderr)

def solve(A, B, C, D):
    L = C * D // gcd(C, D)
    A-=1
    debug("A=%d, B=%d, C=%d, D=%d" %(A,B,C,D))
    debug((B//C, A//C), (B//D, A//D) , (B//L , A//L))
    debug((B//C - A//C), (B//D - A//D) , (B//L - A//L))
    return B-A- ((B//C - A//C) + (B//D - A//D) - (B//L - A//L))

def main():
    A, B, C, D = [int(x) for x in input().split()]
    print(solve(A, B, C, D))
    pass

main()

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

def debug(*args):
    import sys
    #print(*args, file=sys.stderr)

def solve(A, B, C, D):
    L = C * D // gcd(C, D)
    A-=1
    debug("A=%d, B=%d, C=%d, D=%d" %(A,B,C,D))
    debug((B//C, A//C), (B//D, A//D) , (B//L , A//L))
    debug((B//C - A//C), (B//D - A//D) , (B//L - A//L))
    return B-A- ((B//C - A//C) + (B//D - A//D) - (B//L - A//L))

def main():
    A, B, C, D = [int(x) for x in input().split()]
    print(solve(A, B, C, D))
    pass

main()
Problem p03006 (python)

Fixed submission:
from collections import Counter
def solve(N, XY):
    if N == 1:
        return 1
    XY = sorted(XY)
    cnt = Counter()
    d = []
    for x0, y0 in XY:
        for x1, y1 in XY:
            if x0 == x1 and y0 == y1:
                continue
            d.append((x0 - x1, y0 - y1))
    m = Counter(d).most_common()[0]
    return len(XY) - m[1]

def main():
    N = int(input())

    XY = []
    for i in range(N):
        XY.append(tuple([int(x) for x in input().split()]))

    print(solve(N, XY))

main()

Buggy submission (verdict: Runtime Error):
from collections import Counter
def solve(N, XY):
    XY = sorted(XY)
    cnt = Counter()
    d = []
    for x0, y0 in XY:
        for x1, y1 in XY:
            if x0 == x1 and y0 == y1:
                continue
            d.append((x0 - x1, y0 - y1))
    m = Counter(d).most_common()[0]
    return len(XY) - m[1]

def main():
    N = int(input())

    XY = []
    for i in range(N):
        XY.append(tuple([int(x) for x in input().split()]))

    print(solve(N, XY))

main()

Buggy submission (verdict: Runtime Error):
from collections import Counter
def solve(N, XY):
    XY = sorted(XY)
    cnt = Counter()
    d = []
    for (x0, y0), (x1, y1) in zip(XY, XY[1:]):
        d.append((x0 - x1, y0 - y1))
    m = Counter(d).most_common()[0]
    return len(XY) - m[1]

def main():
    N = int(input())

    XY = []
    for i in range(N):
        XY.append(tuple([int(x) for x in input().split()]))

    print(solve(N, XY))

main()
Problem p03037 (python)

Fixed submission:
N, M = [int(x) for x in input().split()]

def check(n, LR):
    return 1 if all(l <= n <=r for l, r in LR) else 0

L = 0
R = N
for _ in range(M):
    l, r = [int(x) for x in input().split()]
    if L < l:
        L = l
    if r < R:
        R = r

if L <= R:
    print(R - L + 1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]

LR = []
for _ in range(M):
  LR.append([int(x) for x in input().split()])

print(sum(check(n) for n in range(1, N+1)))
def check(n):
  return 1 if all(l <= n <=r for l, r in range LR) else 0
Problem p03049 (python)

Fixed submission:
# N < 10000
N = int(input())

# len(s) < 10

count = 0
a, b, ba = 0, 0, 0
for i in range(N):
    s = input().rstrip()
    count += s.count("AB")

    if s[-1] == 'A':
        if s[0] == 'B':
            ba += 1
        else:
            a += 1
    elif s[0] == 'B':
        b += 1

#e = int(input())
#print("*A=",a, ", B*=",b, "B*A=",ba, ",AB=", count, ",expected=", e)

if ba > 1:
    count += ba - 1
    ba = 1

if a + b > 0:
    #count += max(min(a + ba, b),min (a, b + ba))
    count += min(a,b) + ba
print(count)

Buggy submission (verdict: Runtime Error):
# N < 10000
N = int(input())

# len(s) < 10

count = 0
a, b, ba = 0, 0, 0
for i in range(N):
    s = input().rstrip()
    count += s.count("AB")

    if s[-1] == 'A':
        if s[0] == 'B':
            ba += 1
        else:
            a += 1
    elif s[0] == 'B':
        b += 1

#e = int(input())
#print("*A=",a, ", B*=",b, "B*A=",ba, ",AB=", count, ",expected=", e)

if ba > 1:
    count += ba - 1
    ba = 1

if ba == 1:
    c0 = 1 + min(a, b)
count+=max(min(a+ba,b),min(a,b+ba), c0)
print(count)

Buggy submission (verdict: Runtime Error):
# N < 10000
N = int(input())

# len(s) < 10

count = 0
a, b, ba = 0, 0, 0
for i in range(N):
    s = input().rstrip()
    i = 0
    while True:
        i = s.find("AB", i)
        if i < 0:
            break
        i += 2
        count+=1

    if s[-1] == 'A':
        if s[0] == 'B':
            ba += 1
        else:
            a += 1
    elif s[0] == 'B':
        b += 1

e = int(input())
#print("*A=",a, ", B*=",b, "B*A=",ba, ",AB=", count, ",expected=", e)

if ba > 1:
    count += ba - 1
    ba = 1
count+=max(min(a+ba,b),min(a,b+ba))
print(count)
Problem p03060 (python)

Fixed submission:
N = int(input())
V = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
            
print(
  sum(
    max(v - c, 0) for v, c in zip(V,C)
  )
)

Buggy submission (verdict: Runtime Error):
N = int(input()
V = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
        
print(
  sum(
    max(v - c, 0) for v, c in zip(V,C)
  )
)
Problem p03062 (python)

Fixed submission:
N = int(input())
# N < 10 ** 5
A = sorted([int(x) for x in input().split()])
# - 10 ** 9 < A < 10 ** 9

B = [-a for a in A if a < 0]
D = [a for a in A if a >= 0]

if len(B) % 2 == 1:
    B[-1] = -B[-1]
    if D and -B[-1] > D[0]:
        B[-1] = -B[-1]
        D[0] = -D[0]

print(sum(B)+sum(D))

Buggy submission (verdict: Runtime Error):
N = int(input())
# N < 10 ** 5
A = sorted([int(x) for x in input().split()])
# - 10 ** 9 < A < 10 ** 9

B = [-a for a in A if a < 0]
D = [a for a in A if a >= 0]

if len(B) % 2 == 1:
    B[-1] = -B[-1]
    if -B[-1] > D[0]:
        B[-1] = -B[-1]
        D[0] = -D[0]

print(sum(B)+sum(D))
Problem p03238 (python)

Fixed submission:
N = input()
if N == '1':
  print("Hello World")
else:
  print(int(input()) + int(input()))

Buggy submission (verdict: Runtime Error):
N = input()
if N == '1':
  print("Hello World")
else:
  print(int(input()) + int(input())
Problem p03239 (python)

Fixed submission:
N, T = [int(x) for x in input().split()]

ok = 2000
for _ in range(N):
  c, t = [int(x) for x in input().split()]
  if t <= T:
    ok = min(ok, c)

print("TLE" if ok == 2000 else ok)

Buggy submission (verdict: Runtime Error):
N, T = [int(x) for x in input().strip()]

ok = 2000
for _ in range(N):
  c, t = [int(x) for x in input().strip()]
  if t <= T:
    ok = min(ok, c)

print("TLE" if ok == 2000 else ok)
Problem p03261 (python)

Fixed submission:
N = int(input())
words = [input().strip() for _ in range(N)]

def solve(words):
  s = {words[0]}
  for p, w in zip(words, words[1:]):
    if p[-1] != w[0]:
      return "No"
    if w in s:
      return "No"
    s.add(w)
  return "Yes"

print(solve(words))

Buggy submission (verdict: Runtime Error):
N = int(input())                                                                                                                                                                                                  
for i in range(N):
    W.append(input())

prev = W[0]

answer = "Yes"

for w in W[1:]:
    if prev[-1] != w[0]:
        answer = "No"

print(answer)
Problem p03264 (python)

Fixed submission:
N = int(input())

even = N // 2
odd = N - even
print(even * odd)

Buggy submission (verdict: Runtime Error):
N = int(input())

even = N // 2
odd = N - even
print(event * odd)
Problem p03293 (python)

Fixed submission:
S0 = input().strip()
S1 = input().strip()
ok = "No"
for i in range(len(S0)):
  if S0 == S1[i:] + S1[:i]:
    ok = "Yes"
print(ok)

Buggy submission (verdict: Runtime Error):
S0 = input().strip()
S1 = input().strip()
ok = "No"
for i in range(len(S0)):
  if S0 == Si[i:] + S1[:i]:
    ok = "Yes"
print(ok)
Problem p03361 (python)

Fixed submission:
def solve(H, W, S):
    for h in range(1, H):
        for w in range(1, W):
            if S[h][w] == '#':
                if not (S[h-1][w] == '#' or S[h+1][w] == '#' or S[h][w+1] == '#' or S[h][w-1] == '#'):
                    return "No"
    return "Yes"


H, W = [int(x) for x in input().split()]
# H, W < 50
S = []
S.append('.' * (W+2))
for _ in range(H):
    S.append("."+input().strip()+".")
S.append('.' * (W+2))
import sys
for row in S:
    print(row, file=sys.stderr)
print(solve(H, W, S))

Buggy submission (verdict: Runtime Error):
def solve(H, W, S):
    for h in range(1, H):
        for w in range(1, W):
            if S[h][w] == '#':
                if not (S[h-1][w] == '#' or S[h+1][w] == '#' or S[h][w+1] == '#' or S[h][w-1] == '#'):
                    return "No"
    return "Yes"


H, W = [int(x) for x in input().split()]
# H, W < 50
S = []
S.append('.' * (H+2))
for _ in range(H):
    S.append("."+input().strip()+".")
S.append('.' * (H+2))
print(solve(H, W, S))
Problem p03386 (python)

Fixed submission:
A, B, K = [int(x) for x in input().split()]

u = set(range(A, min(B+1, A+K)))
l = set(range(B, max(A-1, B-K),-1))
for i in sorted(u | l):
    print(i)

Buggy submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split()]

X = list(range(A, B+1))

Buggy submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split()]

X = list(range(A, B+1))

o = set()
for i in X[:K]:
    print(i)
    o.add(i)

for i in X[-K:]:
    if i not in o:
        print(i)

Buggy submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split()]
X = list(range(A, B+1)))

o = set()
for i in X[:K]:
    print(i)
    o.add(i)

for i in X[-K:]:
    if i not in o:
        print(i)

Buggy submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split()]
X = list(range(A, B+1)))
for i in sorted(set(X[:K]) | set(X[-K:])):
    print(i)

Buggy submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split()]

X = sorted(range(A, B+1))
for i in sorted(set(X[:K]) | set(X[-K:])):
    print(i)

Buggy submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split()]

X = sorted(range(A, B+1))
for i in sorted(set(X[:K]) | set(X[-K:])):
    print(i)
Problem p03437 (python)

Fixed submission:
X, Y = [int(x) for x in input().split()]

def solve(X, Y):
    if X == Y:
        return -1
    if Y < X:
        if X % Y == 0:
            return -1

    for x in range(X, 10**18+1, X):
        if x % Y != 0:
            return x
print(solve(X, Y))

Buggy submission (verdict: Runtime Error):
X, Y = [int(x) for x in input()]

def solve(X, Y):
    if X == 1:
        return -1
    if X == Y:
        return -1
    for x in range(X, 10**18+1, X):
        if x % Y != 0:
            return x
solve(X, Y)
Problem p03476 (python)

Fixed submission:
from math import sqrt, ceil

cache = {3}
primes = {2,3}
def isprime(n):
    if n in primes:
        return True
    for i in range(3, ceil(sqrt(n))+1, 2):
        if n % i == 0:
            return False
    primes.add(n)
    return True

def prepare():
    l = 5
    r = 10**5-1
    for n in range(l, r+1, 4):
        if n in cache:
            continue
        m = (n - 1) // 2
        if isprime(m+1) and isprime(n):
            cache.add(n)

def solve(l, r):
    cnt = 0
    if l <= 3 <= r:
        cnt = 1
        l = 5
    if l % 4 == 3:
        l += 2
    for n in range(l, r+1, 4):
        if n in cache:
            cnt += 1
            continue
        m = (n - 1) // 2
        assert n % 4 == 1
        if isprime(m+1) and isprime(n):
            cache.add(n)
            cnt += 1
    return cnt

def main():
    global cache
    from bisect import bisect_left, bisect_right
    cache = sorted(cache)
    Q = int(input())
    for _ in range(Q):
        l, r = map(int, input().split())
        i = bisect_left(cache, l)
        j = bisect_right(cache, r)
        print(j-i)

prepare()
main()

Buggy submission (verdict: Runtime Error):
def main():
    cache = set()
    primes = {2}

    def isprime(n):
        if n in primes:
            return True
        for i in range(3, math.sqrt(n)+1, 2):
            if n % i == 0:
                return False
        primes[n] = True
        return True

    Q = int(input())

    for i in range(Q):
        l, r = map(int, input().split())
        cnt = 0
        if l % 4 == 3:
            l += 2
        for n in range(l, r+1, 4):
            m = (n - 1) // 2
            assert n % 4 == 1
            if isprime(m+1) and isprime(n)
                cnt += 1
        print(cnt)
main()
Problem p03478 (python)

Fixed submission:




def main():
    N, A, B = [int(x) for x in input().split()]
    a = 0
    for n in range(N+1):
        s = sum(int(x) for x in str(n))
        if A <= s <= B:
          	a += n
    return a
print(main())

Buggy submission (verdict: Runtime Error):
def main():
    N, A, B = [int(x) for x in input().split()]
    a = 0
	for n in range(N+1):
      s = sum(int(x) for x in n)
      if A <= s <= B:
        a += n
    return a
main()
Problem p03486 (python)

Fixed submission:
A = "".join((sorted(input())))
B = "".join(sorted(input(), reverse=True))
print("Yes" if A < B else "No")

Buggy submission (verdict: Runtime Error):
A = sorted(input())
B = sorted(input(), revese=True)
print("Yes" if A < B else "No")

Buggy submission (verdict: Runtime Error):
A = sorted(input())
B = sorted(input(), reversed=True)
if A < B:
  print("Yes")
else:
  print("No")
Problem p03543 (python)

Fixed submission:
A = input().strip()
if A[0] == A[1] == A[2] or A[1] == A[2] == A[3]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A = input().split()

if A[0] == A[1] == A[2]:
  print("Yes"):
else:
  A = A[::-1]
  if A[0] == A[1] == A[2]:
    print("Yes"):
  else:
    print("No")
Problem p03545 (python)

Fixed submission:
from itertools import product

A, B, C, D = [x for x in input().strip()]

for x in ["".join(x) for x in product(A, '+-', B, '+-', C, '+-', D)]:
    if eval(x) == 7:
        print(x+"=7")
        break

Buggy submission (verdict: Runtime Error):
from itertools import product as p
A,B,C,D=input();o="+-"
for x in map("".join,p(A,o,B,o,C,o,D)):if eval(x) == 7:print(x+"=7");break
Problem p03549 (python)

Fixed submission:
N, M = [int(x) for x in input().split()]

print((M * 1900+(N-M)*100)*(2**M))

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]

print(M * 1900+(N-M)*100)*(2**M)

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]

if N == M:
    print((1900*M)/(2**N))
else:
    print(M * 1900+(N-M)*100)*(2**M)
Problem p03605 (python)

Fixed submission:
N=input()
if '9' in N:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=input()
if any(c=='9'):
  print("Yes")
else:
  print("No")
Problem p03633 (python)

Fixed submission:
N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())

# N < 100
# gcd(a,b) lcd(a,b) = ab

from fractions import gcd
def lcd(a, b):
    return a*b//gcd(a,b)

l = 1
g = 0
for t in T:
    l = lcd(l, t)
    g = gcd(g, t)
print(l)

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

# N < 100
# gcd(a,b) lcd(a,b) = ab

from math import gcd
def lcd(a, b):
    return a*b//gcd(a,b)

l = 1
g = 0
for t in T:
    l = lcd(l, t)
    g = gcd(g, t)
print(l)
Problem p03645 (python)

Fixed submission:
N, M = [int(x) for x in input().split()]
E = [[] for x in range(N+1)]
visited = set()

for i in range(M):
    A, B = [int(x) for x in input().split()]
    E[A].append(B)
    E[B].append(A)

if set(E[1]) & set(E[N]):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N, M = [x for x in input().split()]
E = [[] for x in range(N+1)]
visited = set()

for i in range(M):
    A, B = [x for x in input().split()]
    E[A].append(B)
    E[B].append(A)

if E[1] & E[N]:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Problem p03680 (python)

Fixed submission:
N = int(input())
A = [0]+[int(input()) for _ in range(N)]

v = set()
v.add(1)
x = 1
a = 0
while True:
  x = A[x]
  a += 1
  if x in v:
    print(-1)
    break
  if x == 2:
    print(a)
    break
  v.add(x)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0]+[int(input()) for _ in range(N)]

v = {1}
x = 1
a = 0
while True:
  x = A[x]
  a += 1
  if x in v:
    print(-1)
    break
  if x == 2:
	print(a)
    break
  v.add(x)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0]+[int(input()) for _ in range(N)]

v = {1}
x = 1
a = 0
while True:
  x = A[x]
  a += 1
  if x in v:
    print(-1)
    break
  if x == 2:
	print(a)
    break
Problem p03693 (python)

Fixed submission:
print("YES" if int("".join(x for x in input().split())) % 4 == 0 else "NO")

Buggy submission (verdict: Runtime Error):
print("YES" if int("".join(list(input()))) % 4 == 0 else "NO")
Problem p03699 (python)

Fixed submission:
# 2^100
# WAが残ったので解説見た
def main(N, S):
    total = sum(S)
    if total % 10 != 0:
        return total
    victim = sorted(x for x in S if x % 10 != 0)
    if len(victim) == 0:
        return 0
    else:
        return total - victim[0]

N = int(input())
S = [None] * N
for i in range(N):
    S[i] = int(input())
print(main(N, S))

Buggy submission (verdict: Runtime Error):
# 2^100

N = int(input())
S = [None] * N
for i in range(N):
    S[i] = int(input())
S.sorted(reverse=True)
total = sum(S)

for i in range(N):
    if total % 10 != 0:
        break
    total -= S[i]
print(total)
Problem p03720 (python)

Fixed submission:
N, M = [int(x) for x in input().split()]
count = [0]*N
for i in range(M):
	x, y = [int(x) for x in input().split()]
	count[x-1] += 1
	count[y-1] += 1
for c in count:
	print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
count = [0]*N
for i in range(N):
	x, y = [int(x) for x in input().split()]
    count[x-1] += 1
    count[y-1] += 1
for c in count:
    print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
count = [0]*N
for i in range(N):
	x, y = [int(x) for x in input().split()]
    count[x-1] += 1
    count[y-1] += 1
for c in N:
    print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
count = [0]*N
for i in range(N):
	x, y = [int(x) for x in input().split()]
    count[x] += 1
    count[y] += 1
for c in N:
    print(c)
Problem p03737 (python)

Fixed submission:
print("".join(
  x[0].upper() for x in input().split()))

Buggy submission (verdict: Runtime Error):
print("".join(x[0].upper()for x input().split()))