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

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
n = int(input())
l = factorization(n)
ans = 0
for c in l:
    if c[0]==1:
        break
    lim = c[1]
    num = 1
    while lim >= num:
        lim -= num
        num += 1
    ans += num-1
print(ans)

Buggy submission (verdict: Runtime Error):
from sympy import prime, sieve
from collections import Counter

N = int(input())
cnt = 0
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

li = factorization(N)
a = []
for i in range(len(li)):
    a.append(li[i][1])
for i in range(len(a)):
    if 1 <= a[i] <= 2:
        cnt += 1
    elif 3 <= a[i] <= 5:
        cnt += 2
    elif 6 <= a[i] <= 9:
        cnt +=3
print(cnt)

Buggy submission (verdict: Runtime Error):
from sympy import prime, sieve
from collections import Counter

# p = [i for i in sieve.primerange(0,10)]
N = int(input())
cnt = 0
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
li = prime_factorize(N)
li = [str(n) for n in li]
# print(li)
counter = Counter(li)
values, counts = zip(*counter.most_common())
# print(counts)
for i in range(len(counts)):
    if 1 <= counts[i] <= 2:
        cnt += 1
    elif 3 <= counts[i] <= 5:
        cnt += 2
    elif 6 <= counts[i] <= 9:
        cnt +=3
print(cnt)
Problem p02717 (python)

Fixed submission:
a = input().split(' ')
s = [int(i) for i in a]
print(s[2], s[0], s[1])

Buggy submission (verdict: Runtime Error):
a = input().split(' ')
b = input().split(' ')
a = [int(a) for a in a]
b = [int(b) for b in b]

b.sort(reverse=True)
v = sum(b)

ans = 'Yes'

if b[a[1]-1] / v < 1 /( 4 * a[1]):
    ans = 'No'
            
print(ans)
Problem p02719 (python)

Fixed submission:
a = [int(a) for a in input().split(' ')]
N = a[0]
K = a[1]
    
def abs_met(N):
    N = N % K
    if N > abs(N - K):
        N = abs(N - K)
        abs_met(N)
    else:
        print(N)
        
if K == 1:
    print(0)
else:
    abs_met(N)

Buggy submission (verdict: Runtime Error):
a = [int(a) for a in input().split(' ')]
N = a[0]
K = a[1]
    
def abs_met(N):
    if N > abs(N - K):
        N = abs(N - K)
        abs_met(N)
    else:
        print(N)
        
if K == 1:
    print(0)
else:
    abs_met(N)

Buggy submission (verdict: Runtime Error):
a = [int(a) for a in input().split(' ')]
N = a[0]
K = a[1]
    
def abs_met(N):
    if N > abs(N - K):
        N = abs(N - K)
        abs_met(N)
    else:
        print(N)
        
if K == 1:
    print(0)
else:
    abs_met(N)
Problem p03495 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
li = [0]*10**6
for i in range(N):
    li[A[i]] += 1
# print(li)
li.sort(reverse=True)
# print(li)
print(sum(li[K:]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
li = [0]*10**5
for i in range(N):
    li[A[i]] += 1
# print(li)
li.sort(reverse=True)
# print(li)
print(sum(li[K:]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
li = [0]*10
for i in range(N):
    li[A[i]] += 1
li.sort(reverse=True)
print(sum(li[K:]))
Problem p02802 (python)

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

acList = [False] * n
waList = [0] * n
waCount = 0
for i in range(m):
  p, s = map(str, input().split())
  p = int(p) - 1 # インデックスの調整
  if acList[p]:
    continue
  if s == 'WA':
    waList[p] += 1
    continue
  waCount += waList[p]
  acList[p] = True

print(sum(acList), waCount)

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

acList = [False] * n
waCount = 0
for i in range(m):
  p, s = map(str, input().split())
  p = int(p) - 1 # インデックスの調整
  print(acList)
  if acList[p]:
    continue
  if s == 'WA':
    waCount += 1
    continue
  acList[p] = True

print(sum(acList), waCount)
Problem p02846 (python)

Fixed submission:
import math

def main():
  t1, t2 = map(int, input().split())
  a1, a2 = map(int, input().split())
  b1, b2 = map(int, input().split())

  sumA = t1 * a1 + t2 * a2
  sumB = t1 * b1 + t2 * b2

  if sumA == sumB:
    return 'infinity'
  if sumA < sumB:
    sumA, sumB = sumB, sumA
    a1, b1 = b1, a1
    a2, b2 = b2, a2
  # A の方が sum が大きいとする

  halfA = t1 * a1
  halfB = t1 * b1
  if halfA > halfB:
    return 0
  div, mod = divmod(halfB - halfA, sumA - sumB)
  if mod == 0:
    return div * 2
  return div * 2 + 1

print(main())

Buggy submission (verdict: Runtime Error):
import math

def main():
  t1, t2 = map(int, input().split())
  a1, a2 = map(int, input().split())
  b1, b2 = map(int, input().split())

  sumA = t1 * a1 + t2 * a2
  sumB = t1 * b1 + t2 * b2

  if sumA == sumB:
    return 'infinity'
  if sumA < sumB:
    sumA, sumB = sumB, sumA
    a1, b1 = b1, a1
    a2, b2 = b2, a2
  # A の方が sum が大きいとする

  halfA = t1 * a1
  halfB = t1 * b1
  if halfA > halfB:
    return 0
  div, mod = divmod(halfB - halfA, sumA - sumB)
  if mod == 0
    return div * 2
  return div * 2 + 1

print(main())

Buggy submission (verdict: Runtime Error):
import math

def main():
  t1, t2 = map(int, input().split())
  a1, a2 = map(int, input().split())
  b1, b2 = map(int, input().split())

  sumA = t1 * a1 + t2 * a2
  sumB = t1 * b1 + t2 * b2

  if sumA == sumB:
    return 'infinity'
  if sumA < sumB:
    sumA, sumB = sumB, sumA
    a1, b1 = b1, a1
    a2, b2 = b2, a2
  # A の方が sum が大きいとする

  halfA = t1 * a1
  halfB = t1 * b1
  if halfA > halfB:
    return 0
  div, mod = divmod((halfB - halfA) // (sumA - sumB))
  if mod == 0
    return div * 2
  return div * 2 + 1

print(main())
Problem p04043 (python)

Fixed submission:
numList = input().split()

if len(numList) != 3:
  print('NO')
elif numList.count('5') != 2:
  print('NO')
elif numList.count('7') != 1:
  print('NO')
else:
  print('YES')

Buggy submission (verdict: Runtime Error):
val, size = map(int, input().split())
disabledList = [int(x) for x in input().split()] # number
enableList = list(set(range(10)) - set(disabledList)) # number
resultList = [] # str, must reverse
isTenOver = False
for char in reversed(list(str(val))):
  targetInt = int(char)
  if isTenOver:
    targetInt += 1
  if targetInt in enableList:
    isTenOver = False
    resultList.append(str(targetInt))
    continue
  resultList = [str(min(enableList))] * len(resultList)
  if targetInt > max(enableList):
    isTenOver = True
    resultList.append(str(min(enableList)))
  else:
    isTenOver = False
    minNum = min(filter(lambda x:x > targetInt, enableList))
    resultList.append(str(minNum))

if isTenOver:
  minNum = min(filter(lambda x:x > 0, enableList))
  resultList.append(str(minNum))
print(''.join(reversed(resultList)))
Problem p04045 (python)

Fixed submission:
val, size = map(int, input().split())
disabledList = [int(x) for x in input().split()] # number
enableList = list(set(range(10)) - set(disabledList)) # number
resultList = [] # str, must reverse
isTenOver = False
for char in reversed(list(str(val))):
  targetInt = int(char)
  if isTenOver:
    targetInt += 1
  if targetInt in enableList:
    isTenOver = False
    resultList.append(str(targetInt))
    continue
  resultList = [str(min(enableList))] * len(resultList)
  if targetInt > max(enableList):
    isTenOver = True
    resultList.append(str(min(enableList)))
  else:
    isTenOver = False
    minNum = min(filter(lambda x:x > targetInt, enableList))
    resultList.append(str(minNum))

if isTenOver:
  minNum = min(filter(lambda x:x > 0, enableList))
  resultList.append(str(minNum))
print(''.join(reversed(resultList)))

Buggy submission (verdict: Runtime Error):
val, size = map(int, input().split())
disabledList = [int(x) for x in input().split()] # number
enableList = list(set(range(10)) - set(disabledList)) # number
resultList = [] # str, must reverse
isTenOver = False
for char in list(str(val)).reverse():
  targetInt = int(char)
  if isTenOver:
    targetInt += 1
  if int(char) in enableList:
    isTenOver = False
    resultList.append(char)
    continue
  resultList = [min(enableList)] * len(resultList)
  if int(char) > max(enableList):
    isTenOver = True
    resultList.append(str(min(enableList)))
  else:
    isTenOver = False
    minNum = min(filter(lambda x:x > int(char), enableList))
    resultList.append(str(minNum))

if isTenOver:
  minNum = min(filter(lambda x:x > 0, enableList))
  resultList.append(str(minNum))
print(''.join(resultList.reverse()))

Buggy submission (verdict: Runtime Error):
val, size = map(int, input().split())
disabledList = [int(x) for x in input().split()] # number
enableList = list(set(range(10)) - set(disabledList)) # number
resultList = [] # int, must reverse
isTenOver = False
for char in list(str(val)).reverse():
  targetInt = int(char)
  if isTenOver:
    targetInt += 1
  if int(char) in enableList:
    isTenOver = False
    resultList.append(char)
  elif int(char) > max(enableList):
    isTenOver = True
    resultList.append(str(min(enableList)))
  else:
    isTenOver = False
    minNum = min(filter(lambda x:x > int(char), enableList))
    resultList.append(str(minNum))

if isTenOver:
  minNum = min(filter(lambda x:x > 0, enableList))
  resultList.append(str(minNum))
print(''.join(resultList.reverse()))
Problem p02934 (python)

Fixed submission:
n = int(input())

a = input().split()
print(1/sum(map(lambda x:1/int(x), a)))

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

a = input().split()
print(1/sum(map(lambda x:1/x, a)))

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

a = input().split()
print(1/sum(a.map(lambda x:1/x)))
Problem p02936 (python)

Fixed submission:
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n-1)]
ab.sort()
p = [0]*n
for i in range(q):
  a, b = map(int, input().split())
  p[a - 1] += b
s = ""
for i in ab:
  p[i[1]-1] += p[i[0]-1]
print(*p)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n-1)]
ab.sort()
p = [0]*n
for i in range(q):
  a, b = map(int, input().split())
  p[a - 1] += b
s = ""
for i in ab:
  p[i[1]-1] += p[i[0]-1]
print(" ".join(map(str, p)
Problem p02681 (python)

Fixed submission:
S = str(input())
T = str(input())

if(T[0:len(T)-1] == S):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M, X = map(int, input().split())

data = [list(map(int, input().split())) for _ in range(N)]
INF = float('inf')

data_all = []
c_min = INF

for i in range(2**N):
    data_tmp = [0]*M
    c = 0
    for j in range(N):
        if((i>>j) & 1):
            for k in range(M):
                data_tmp[k] += data[j][k+1]
            c += data[j][0]
    if(min(data_tmp) >= X):
        c_min = min(c, c_min)

if(c_min == INF):
    print(-1)
else:
    print(c_min)
Problem p02683 (python)

Fixed submission:
import numpy as np

N, M, X = map(int, input().split())

data = [list(map(int, input().split())) for _ in range(N)]
INF = float('inf')

data_all = []
c_min = INF

for i in range(2**N):
    data_tmp = [0]*M
    c = 0
    for j in range(N):
        if((i>>j) & 1):
            for k in range(M):
                data_tmp[k] += data[j][k+1]
            c += data[j][0]
    if(min(data_tmp) >= X):
        c_min = min(c, c_min)

if(c_min == INF):
    print(-1)
else:
    print(c_min)

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M, X = map(int, input().split())

data = [list(map(int, input().split())) for _ in range(N)]
INF = float('int')

data_all = []
c_min = INF

for i in range(2**N):
    data_tmp = [0]*M
    c = 0
    for j in range(N):
        if((i>>j) & 1):
            for k in range(M):
                data_tmp[k] += data[j][k+1]
            c += data[j][0]
    if(min(data_tmp) >= X):
        c_min = min(c, c_min)

if(c_min == INF):
    print(-1)
else:
    print(c_min)
Problem p02696 (python)

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

def floor(x):
    out = (A * x)//B - A * (x//B)
    return out

max = 0
#for i in range(N//2, N + 1):
    #if(floor(i) > max):
        #max = floor(i)

if(N < (B-1)):
    max = floor(N)
else:
    max = floor(B-1)

print(max)

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

def floor(x):
    out = (A * x)//B - A * (x//B)
    return out

max = 0
#for i in range(N//2, N + 1):
    #if(floor(i) > max):
        #max = floor(i)
max = max(floor(N), floor(B-1))

print(max)
Problem p02702 (python)

Fixed submission:
from collections import Counter

S = str(input())

memo = [0]
d = 0
mod = 2019


for s in S[::-1]:
    tmp = int(s) * pow(10, d, mod) % mod
    tmp = memo[-1] + tmp
    memo.append(tmp%mod)
    d += 1

c = Counter(memo)
ans = sum(v * (v-1)/2 for v in c.values())
print(int(ans))

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

S = str(input())

memo = [0]
d = 0
mod = 2019


for s in S[::-1]:
    tmp = int(s) * pow(10, d, mod) % mod
    tmp = memo[-1] + tmp
    memo.appemd(tmp%mod)
    d += 1

c = Counter(memo)
ans = sum(v * (v-1)/2 for v in c.values())
print(ans)

Buggy submission (verdict: Runtime Error):
S = str(input())

data = []

count = 0
for i in range(len(S)):
    for j in range(i+4, min(i+7,len(S)+1)):
        if(int(S[i:j]) % 2019 == 0):
            count += 1
            data.append([i,j])

for i in range(len(data)):
    if(data[i][1] == data[i+1][0]):
        count += 1

print(count)
Problem p02756 (python)

Fixed submission:
from  collections import deque

S = str(input())
Q = int(input())

#Que = [list(map(str, input().split())) for _ in range(Q)]

deque_S = deque(S)
re_flag = 1
for i in range(Q):
    que = str(input())

    if len(que) == 1:
        #S = S[::-1]
        re_flag *= -1

    else:
        if que[2] == '1':
            if re_flag == 1:
                #S = que[4:] + S
                deque_S.appendleft(que[4:])
            else:
                #S =  S + que[-1:3:-1]
                deque_S.append(que[-1:3:-1])
        if que[2] == '2':
            if re_flag == 1:
                #S = S + que[4:]
                deque_S.append(que[4:])
            else:
                #S = que[-1:3:-1] + S
                deque_S.appendleft(que[-1:3:-1])

ans = ''
if re_flag == 1:
    ans = ''.join(deque_S)
else:
    ans = ''.join(deque_S)[::-1]
#print(deque_S)

print(ans)

Buggy submission (verdict: Runtime Error):
S = str(input())
Q = int(input())

#Que = [list(map(str, input().split())) for _ in range(Q)]

for i in range(Q):
    flag, F, C = map(str, input().split())

    if flag == '1':
        S = S[::-1]

    if flag == '2':
        if F == '1':
            S = C + S
        if F == '2':
            S = S + C


print(S)
Problem p02719 (python)

Fixed submission:
N, K = map(int, input().split())
print(min(N % K, K - N % K))

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
print(min(N % K, K - N % K))
Problem p02760 (python)

Fixed submission:
a=[list(map(int,input().split()))for _ in range(3)]
for i in range(int(input())):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
a = list(list(map(int , input().split())) for l in range(3))
n = int(input())

for i in range(input()):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)
Problem p03386 (python)

Fixed submission:
import math
a , b , k = map(int , input().split())
ans = set()
for i in range(min(k , math.ceil((b - a + 1) / 2))):
  ans.add(a + i)
  ans.add(b - i)
ans = sorted(list(ans))
print('\n'.join([str(n) for n in ans]))

Buggy submission (verdict: Runtime Error):
import math
a , b , k = map(int , input().split())
ans = set()
for i in range(min(k , math.ceil((b - a + 1) / 2))):
  ans.add(a + i , b - i)
ans = sorted(list(ans))
print('\n'.join([str(n) for n in ans]))
Problem p03624 (python)

Fixed submission:
s = input()
ans = 'None'
for letter in "abcdefghijklmnopqrstuvwxyz":
  if letter not in s:
    ans = letter
    break
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in s:
  if i in alpha:
    alpha = alpha.strip(i)

print(alpha[0])
Problem p03760 (python)

Fixed submission:
o = input()
e = input()
if len(e) != len(o):
  e += ' '
password = ''
for i in range(len(o)):
  password += o[i] + e[i]
print(password)

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
if len(e) != len(o):
  e += ''
password = ''
for i in range(len(o)):
  password += o[i] + e[i]
print(password)
Problem p02639 (python)

Fixed submission:
x1,x2,x3,x4,x5,=map(int,input().split())
if 0 == x1:
    print("1")
elif 0 == x2:
    print("2")
elif 0 ==x3:
    print("3")
elif 0 == x4:
    print("4")
else:
    print("5")

Buggy submission (verdict: Runtime Error):
x, y = map(int,input().split())
z=-2
if x %2 == 0:
    for i in range(x):
        if i % 2 == 0:
            z +=4
        else:
            z +=2
    if z == y :
            print("Yes")
    elif z!=y :
            print("No")
else:
    for i in range(x):
        if i % 2 == 0:
            z +=4
        else:
            z +=2
    if z == y or z == (y-2):
            print("Yes")
    elif z!=y :
            print("No")

Buggy submission (verdict: Runtime Error):
x, y = map(int,input().split())
z=-2
if x %2 == 0:
    for i in range(x):
        if i % 2 == 0:
            z +=4
        else:
            z +=2
    if z == y :
            print("Yes")
    elif z!=y :
            print("No")
elif x%2 != 0:
    for i in range(x):
        if i % 2 == 0:
            z +=4
        else:
            z +=2
    if z == y or z == (y-2):
            print("Yes")
    elif z!=y :
            print("No")

Buggy submission (verdict: Runtime Error):
x, y = map(int,input().split())
z=-2
if x %2 == 0:
    for i in range(x):
        if i % 2 == 0:
            z +=4
        else:
            z +=2
    if z == y :
            print("Yes")
    elif z!=y :
            print("No")
elif x%2 != 0:
    for i in range(x):
        if i % 2 == 0:
            z +=4
        else:
            z +=2
    if z == y or z == (y-2):
            print("Yes")
    elif z!=y :
            print("No")

Buggy submission (verdict: Runtime Error):
x, y = map(int,input().split())
z=-2
if x %2 == 0:
    for i in range(x):
        if i % 2 == 0:
            z +=4
        else:
            z +=2
    if z == y :
            print("Yes")
    elif z!=y :
            print("No")
elif x%2 != 0
    for i in range(x):
        if i % 2 == 0:
            z +=4
        else:
            z +=2
    if z == y or z == (y-2):
            print("Yes")
    elif z!=y :
            print("No")
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
result = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        result *= A[i]
        if result > 10**18:
            print(-1)
            quit()
    print(result)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = float(input())
print(A * round(B,2))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
list=[]
for i in range(N):
    i = int(input())
    list.append(i)

if  math.prod(list) < 1000000000000000000:
    print(math.prod(list))
else:
    print(-1)
Problem p02600 (python)

Fixed submission:
X = int(input())
result = 8 - (X - 400)//200
print(str(result))

Buggy submission (verdict: Runtime Error):
X = input()
if 399 < X < 600:
  print(8)
if 599 < X < 800:
  print(7)
if 799 < X < 1000:
  print(6)
if 999 < X < 1200:
  print(5)
if 1199 < X < 1400:
  print(4)
if 1399 < X < 1600:
  print(3)
if 1599 < X < 1800:
  print(2)
if 1799 < X < 2000:
  print(1)
Problem p02700 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
while(a > 0 and c > 0):
  c -= b
  if c <= 0:
    break
  a -= d
  if a <= 0:
    break
if a > c:
  print('Yes')
else:
  print('No')

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

goods = {}
for i in range(N):
  name = input().rstrip()
  if name in goods.keys():
    goods[name] += 1
  else:
    goods[name] = 1
print(len(goods.keys()))
Problem p02612 (python)

Fixed submission:
N = input()

if len(N) <= 2:
    print(1000 - int(N)) 
    
else:
    N_1 = N[-3] + N[-2] + N[-1]
    if N_1 == "000":
        print(0)
    else:
        print(1000-int(N_1))

Buggy submission (verdict: Runtime Error):
N = input()
N_1 = N[-3] + N[-2] + N[-1]

if N_1 == "000":
    print(0)
else:
    print(1000-int(N_1))
Problem p02639 (python)

Fixed submission:
x = list(map(int, input().split()))
print(x.index(0) + 1)

Buggy submission (verdict: Runtime Error):
x,n =map(int,input().split())
 
if  n==0:
    print(x)
else:
    P =list(map(int,input().split()))
    for i in range(100):
        if  (x-i) not in P:
            print(x-i)
            break
        elif (x+i) not in P:
            print(x+i)
            break
Problem p02645 (python)

Fixed submission:
import random

def name(x):
    if len(x) > 20:
        return name()
    if len(x) < 3:
        return name()
    if x.isupper() == True:
        return name()
    if x.isalpha() == False:
        return name()
    else:
        l = list(x)
        w = random.randint(0, len(x) - 3)
        y = l[w]
        z = l.index(y)
        print(y + l[z+1] + l[z+2])
        
S=input()
name(S)

Buggy submission (verdict: Runtime Error):
import random

def name():
    S = input("S:")
    
    if len(S) > 20:
        return name()
    
    if len(S) < 3:
        return name()
    
    if s.isupper() == True:
        return name()
    
    if s.isalpha() == False:
        return name()
    
    else:
        l = list(S)
        x = random.randint(0, len(s) - 3)
        y = l[x]
        z = l.index(y)
        print(y + l[z+1] + l[z+2])
                
name()
Problem p02802 (python)

Fixed submission:
import collections

n, m = map(int, input().split())
list_ac = set()
dic = collections.defaultdict(lambda:0)

ac = 0
wa = 0

for _ in range(m):
    p, s = input().split()
    if s == "WA" and p not in list_ac:
        dic[p] += 1
    elif s =="AC" and p not in list_ac:
        list_ac.add(p)
        ac += 1
        if p in dic:
            wa += dic[p]
            
print(ac, wa)

Buggy submission (verdict: Runtime Error):
import collections

n, m = map(int, input().split())
list_ac = set()
dic = collections.defaultdict(lambda:0)

ac = 0
wa = 0

for _ in range(m):
    p, s = input().split()
    if s == "WA" and p not in list_ac:
        dic[p] += 1
    elif s =="AC" and p not in list_ac:
        list_ac.append(p)
        ac += 1
        if p in dic:
            wa += dic[p]
            
print(ac, wa)