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

Fixed submission:
import math
 
def dic(s):
  l = len(s)
  if l == 0:
    return 0
  c = s[0]
  tmp = ((sorted(s)).index(c)-1) * math.factorial(l -1)
  return tmp + dic(s[1:])
 
n = input()
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
 
print(abs(dic(s1)-dic(s2)))

Buggy submission (verdict: Runtime Error):
import math

def dic(s):
  len(s)= l
  tmp = 1
  for i,c in enumerate(s):
    tmp += (int(c) - i -1) * math.factorial(l - i -1)
  return tmp

n = input()
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))

print(abs(dic(s1)-dic(s2))
Problem p02841 (python)

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

if m1 ==1 and d1 == 31:
  print('1')
elif m1==2 and d1 == 28:
  print('1')
elif m1==3 and d1 == 31:
  print('1')
elif m1==4 and d1 == 30:
  print('1')
elif m1==5 and d1 == 31:
  print('1')
elif m1==6 and d1 == 30:
  print('1')
elif m1==7 and d1 == 31:
  print('1')
elif m1==8 and d1 == 31:
  print('1')
elif m1==9 and d1 == 30:
  print('1')
elif m1==10 and d1 == 31:
  print('1')
elif m1==11 and d1 == 30:
  print('1')
else:
  print('0')

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
s = input()

num = []
for i in range(n-2):
  for j in range(i + 1, n-1):
    for k in range(j + 1, n):
      tmp = s[i] + s[j] + s[k]
      if tmp not in num:
      	num.append(tmp)
print(len(num))

Buggy submission (verdict: Runtime Error):
import math

x = int(input())

n = x // 105
for i in range(1, 1000):
  ave = x // i
  if 100 <= ave <= 105:
    if x % 105 >= 5*n:
      print('1')
    else:
      print('0')
    exit()
print('0')

Buggy submission (verdict: Runtime Error):
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1, d1 = 1,31:
  print('1')
elif m1, d1 = 2, 28:
  print('1')
elif m1, d1 = 3, 31:
  print('1')
elif m1, d1 = 4, 30:
  print('1')
elif m1, d1 = 5, 31:
  print('1')
elif m1, d1 = 6, 30:
  print('1')
elif m1, d1 = 7, 31:
  print('1')
elif m1, d1 = 8, 31:
  print('1')
elif m1, d1 = 9, 30:
  print('1')
elif m1, d1 = 10, 31:
  print('1')
elif m1, d1 = 11, 30:
  print('1')
else:
  print('0')
Problem p02741 (python)

Fixed submission:
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(l[int(input())-1])

Buggy submission (verdict: Runtime Error):
import math

a,b,c = map(int,input().split())
if a + b + c == 10 and a == b:
  print("Yes")
if math.sqrt(a * b) < (c - a - b) / 2:
  print("Yes")
else:
  print("No")
Problem p02747 (python)

Fixed submission:
s=input()
res=""
if s in	("hi", "hihi", "hihihi", "hihihihi", "hihihihihi"):
  res="Yes"
else:
  res="No"
print(res)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
minimum = a[0]+b[0]

for k in range(M):
    x,y,c = map(int,input().split())
    tmp = a[x-1]+b[y-1]-c
    if minimum > tmp:
        minimum = tmp

a.sort()
b.sort()

for i in a:
    if i + b[0] > minimum:
        break
    for j in b:
        tmp = i + j
        if minimum > tmp:
            minimum = tmp
        else:
            break

print(minimum)
Problem p02748 (python)

Fixed submission:
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
minimum = a[0]+b[0]

for k in range(M):
    x,y,c = map(int,input().split())
    tmp = a[x-1]+b[y-1]-c
    if minimum > tmp:
        minimum = tmp

a.sort()
b.sort()

for i in a:
    if i + b[0] > minimum:
        break
    for j in b:
        tmp = i + j
        if minimum > tmp:
            minimum = tmp
        else:
            break

print(minimum)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
minimum = a[0]+b[0]

for k in range(M):
    x,y,c = map(int,input().split())
    tmp = a[x-1]+a[y-1]-c
    if minimum > tmp:
        minimum = tmp

#a.sort()
#b.sort()

for i in a:
    #if i + b[0] > minimum:
        #break
    for j in b:
        tmp = i + j
        if minimum > tmp:
            minimum = tmp
        else:
            break

print(minimum)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
minimum = a[0]+b[0]

for k in range(M):
    x,y,c = map(int,input().split())
    tmp = a[x-1]+a[y-1]-c
    if minimum > tmp:
        minimum = tmp

a.sort()
b.sort()

for i in a:
    if i + b[0] > minimum:
        break
    for j in b:
        tmp = i + j
        if minimum > tmp:
            minimum = tmp
        else:
            break

print(minimum)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
minimum = a[0]+b[0]

for k in range(M):
    x,y,c = map(int,input().split())
    tmp = a[x-1]+a[y-1]-c
    if minimum > tmp:
        minimum = tmp

a.sort()
b.sort()

#tmpind = b[0]
for i in a:
#    if i + tmpind > minimum:
#        break
    for ind, j in enumerate(b):
        tmp = i + j
        if minimum > tmp:
            minimum = tmp
        else:
#            tmpind = ind
            break

print(minimum)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
minimum = a[0]+b[0]

for k in range(M):
    x,y,c = map(int,input().split())
    tmp = a[x-1]+a[y-1]-c
    if minimum > tmp:
        minimum = tmp

a.sort()
b.sort()

tmpind = b[0]
for i in a:
    if i + tmpind > minimum:
        break
    for ind, j in enumerate(b):
        tmp = i + j
        if minimum > tmp:
            minimum = tmp
        else:
            tmpind = ind
            break

print(minimum)
Problem p03284 (python)

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

if N % K >= 1:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N, K = map(input().split())

if N % K > 1:
    print(1)
else:
    print(0)
Problem p03455 (python)

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


if a % 2 ==0 or b % 2 == 0:
    print("Even")
else:
    print("Odd")

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


if a % 2 ==0 and b % 2 == 0:
    print("Even")
else:
    print("Odd")
Problem p02690 (python)

Fixed submission:
x=input()
a=[0]
d={}
d[0]=0
for i in range(1,1000):
	a+=[i**5]
	a+=[-i**5]
	d[i**5]=i
	d[-i**5]=-i

a.sort()
for i in range(len(a)):
    if x+a[i] in a:
        print d[a[i]+x],d[a[i]]
        break

Buggy submission (verdict: Runtime Error):
x=input()
a=[0]
d={}
for i in range(1,1000):
	a+=[i**5]
	a+=[-i**5]
	d[i**5]=i
	d[-i**5]=-i

a.sort()
for i in range(len(a)):
    if x+a[i] in a:
        print d[a[i]+x],d[a[i]]
        break
Problem p02690 (python)

Fixed submission:
import math

X = int(input())

for i in range(1001):
    f = round((X + i ** 5) ** 0.2)
    if f ** 5 - i ** 5 == X:
        print(int((X + i ** 5) ** 0.2), i)
        exit()

for i in range(1, 1001):
    f = round(abs(X - i ** 5) ** 0.2)
    if X - i ** 5 > 0:
        if f ** 5 - (-i) ** 5 == X:
            print(f, -i)
            exit()
    else:
        if (-f) ** 5 - (-i) ** 5 == X:
            print(-f, -i)
            exit()

Buggy submission (verdict: Runtime Error):
import math

X = int(input())

for i in range(1001):
    if ((X + i ** 5) ** 0.2).is_integer():
        print(int((X + i ** 5) ** 0.2), i)
        exit()

for j in range(1, 1001):
    if ((X - j ** 5) ** 0.2).is_integer():
        print(int((X - j ** 5) ** 0.2), -j)
        exit()
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


A, B, C, D = map(int, input().split())
c = B // C - (A - 1) // C
d = B // D - (A - 1) // D
c_d = B // lcm(C, D) - (A - 1) // lcm(C, D)
print(B - A + 1 - c - d + c_d)

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


def lcm(x, y):
    return (x * y) // gcd(x, y)


A, B, C, D = map(int, input().split())
SUM = B - A + 1
c = (B // C - (A - 1) // C)
d = (B // D - (A - 1) // D)
cd = (B // lcm(C, D) - (A - 1) // lcm(C, D))
print(B - A + 1 - (B // C - (A - 1) // C + B // D - (A - 1) // D - cd)))

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


def lcm(x, y):
    return (x * y) // gcd(x, y)


A, B, C, D = map(int, input().split())
print(B - A + 1 - (B // C - (A - 1) // C + B // D - (A - 1) // D - (B // (lcm(C, D) - (A - 1) // lcm(C, D)))))
Problem p03069 (python)

Fixed submission:
N = int(input())
S = list(input())
c = 0
a = 0
cw = [0] * N
cb = [0] * N
tw = 0
tb = 0
for i in range(N):
    if S[i] == '.':
        tw += 1
        cw[i] = tw
        cb[i] = tb
    else:
        tb += 1
        cb[i] = tb
        cw[i] = tw
A = cw[i]
for i in range(N):
    A = min(A, cb[i] + cw[N - 1] - cw[i])
print(A)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
c = 0
a = 0
cw = [0] * N
cb = [0] * N
tw = 0
tb = 0
for i in range(N):
    if S[i] == '.':
        tw += 1
        cw[i] = tw
        cb[i] = tb
    else:
        tb += 1
        cb[i] = tb
        cw[i] = tw
A = cw[N]
for i in range(N):
    A = min(A, cb[i] + cw[N - 1] - cw[i])
print(A)
Problem p03126 (python)

Fixed submission:
n, m = map(int, input().split())
a, c = [], []
for i in range(m):
    c.append(i+1)
i = 0
while i < n:
    a = list(map(int, input().split()))[1:]
    for j in range(len(c)):
        if c[j] not in a:
            c[j] = 0
    i += 1
    a = []
print(len(c)-c.count(0))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a,c=[],[]
for i in range(m):
  c.append(i+1)
i=0
while i<n:
  k,a=input().split()
  for j in range(len(c)):
    if c[j] not in a:#なかったら
      c.remove(c[j])
      j-=1
    j +=1
  a=[]
print(len(c))
Problem p03262 (python)

Fixed submission:
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b)


n, X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
x = [x[i]-x[0] for i in range(n+1)]
del x[0]
g = x[0]
for i in range(1, n):
    g = gcd(g,x[i])
print(g)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


N, X = map(int, input().split())
x = list(map(int, input().split()))
dif = [abs(X - x[0])]

if N > 1:
    for i in range(N - 1):
        dif.append(x[i + 1] - x[i])
print(gcd_list(dif))
Problem p03274 (python)

Fixed submission:
N, K = map(int, input().split())
x = list(map(int, input().split()))
m = float("INF")
for i in range(N - K + 1):
    if x[i + K - 1] * x[i] < 0:
        m = min(m, x[i + K - 1] - x[i] + min(abs(x[i + K - 1]), abs(x[i])))
    else:
        m = min(m, max(abs(x[i + K - 1]), abs(x[i])))
print(m)

Buggy submission (verdict: Runtime Error):
N, K =map(int,input().split())
x = list(map(int,input().split()))
a = 0
for i in range(100000):
    if x[i] >= 0:
        a = i
        break
s = x[a+K-1]
#print(K,s)
if a == 0:
    print(s)
else:
    for i in range(1, K):
        s = min(s,x[a+K-1-i]-x[a-i]+min(x[a+K-1-i],-x[a-i]))
    print(s)
Problem p03284 (python)

Fixed submission:
n, k = map(int, input().split())
if n % k == 0:
    print("0")
else:
    print("1")

Buggy submission (verdict: Runtime Error):
n, k = map(int, input())
if n % k == 0:
    print("0")
else:
    print("1")
Problem p03323 (python)

Fixed submission:
a, b = map(int, input().split())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")
Problem p03455 (python)

Fixed submission:
A,B=input().split()
A=int(A)
B=int(B)
if A*B%2==0 :
  print("Even")
else :
  print("Odd")

Buggy submission (verdict: Runtime Error):
a,b =input（）.split（）
c=int（a+b）
i=1
while True:
  if i *i ==c:
    print（"Yes"）
    exit（）
  elif i*i >c:
    print（"No"）
    exit（）
  else:
    i += 1
a,b = list（input（）.split（））
c=int（a+b）
i=1
while True:
  if i *i ==c:
    print（"Yes"）
    exit（）
  elif i*i >c:
    print（"No"）
    exit（）
  else:
    i += 1

Buggy submission (verdict: Runtime Error):
a,b =input（）.split（）
c=int（a+b）
i=1
while True:
  if i *i ==c:
    print（"Yes"）
    exit（）
  elif i*i >c:
    print（"No"）
    exit（）
  else:
    i += 1
a,b = list（input（）.split（））
c=int（a+b）
i=1
while True:
  if i *i ==c:
    print（"Yes"）
    exit（）
  elif i*i >c:
    print（"No"）
    exit（）
  else:
    i += 1

Buggy submission (verdict: Runtime Error):
A,B=input().split()
A=int(A)
B=int(B)
if A*B%2==0 :
  print("Even")
  else :
    print("odd")

Buggy submission (verdict: Runtime Error):
A,B=input().split()
A=int(A)
B=int(B)
if A*B%2==0 :
  print("Even")
  else :
    print("Odd")

Buggy submission (verdict: Runtime Error):
A,B=input().split()
A=int(A)
B=int(B)
if A*B%2==0:
  print("Even")
  else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
A,B=input().split()
A=int(A)
B=int(B)
if A*B%2==0:
  print("Even")
  else:
  print("Odd")
Problem p03456 (python)

Fixed submission:
a,b = list(input().split())
c=int(a+b)
i=1
while True:
  if i *i ==c:
    print("Yes")
    exit()
  elif i*i >c:
    print("No")
    exit()
  else:
    i += 1
a,b = list(input().split())
c=int(a+b)
i=1
while True:
  if i *i ==c:
    print("Yes")
    exit()
  elif i*i >c:
    print("No")
    exit()
  else:
    i += 1

Buggy submission (verdict: Runtime Error):
a,b =input（）.split（）
c=int（a+b）
i=1
while True:
  if i *i ==c:
    print（"Yes"）
    exit（）
  elif i*i >c:
    print（"No"）
    exit（）
  else:
    i += 1
a,b = list（input（）.split（））
c=int（a+b）
i=1
while True:
  if i *i ==c:
    print（"Yes"）
    exit（）
  elif i*i >c:
    print（"No"）
    exit（）
  else:
    i += 1

Buggy submission (verdict: Runtime Error):
a,b = list（input（）.split（））
c=int（a+b）
i=1
while True:
  if i *i ==c:
    print（"Yes"）
    exit（）
  elif i*i >c:
    print（"No"）
    exit（）
  else:
    i += 1
Problem p03469 (python)

Fixed submission:
y,m,d=input().split("/")
y=str(2018)
print(y+"/"+m+"/"+d)

Buggy submission (verdict: Runtime Error):
y,m,d=list(input().split())
y=2018
print(y+"/"+m+"/"+d)

Buggy submission (verdict: Runtime Error):
y,m,d=input().split()
y=2018
print(y+"/"+m+"/"+d)

Buggy submission (verdict: Runtime Error):
N = int(input())
d = []
for i in range(N):
    d.append(int(input()))
print(len(set(d)))
Problem p03477 (python)

Fixed submission:
A,B,C,D =map(int,input().split())
if A+B>C+D:
  print("Left")
elif A+B==C+D:
  print("Balanced")
else:
  print("Right")

Buggy submission (verdict: Runtime Error):
A,B,C,D =map(int,input().split())
if A+B>C+D:
  print("Left")
else A+B=C+D
  print("Balanced")
else:
  print("Right")

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
ans=0
for i in range(n+1):
    if a<=sum(list(map(int, list(str(i)))))<=b:
        ans += i
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
ans=0
for i in range(n+1):
    if a<=sum(list(map(int, sum(str(i)))))<=b:
        ans += i
print(ans)
Problem p03565 (python)

Fixed submission:
S = list(input())
T = list(input())
LS = len(S)
LT = len(T)
a = ""
for i in reversed(range(LS - LT + 1)):
    for j in range(LT):
        if S[i + j] != T[j] and S[i + j] != "?":
            break
        if j == LT - 1:
            for k in range(LT):
                S[i + k] = T[k]
            #print("".join(S))
            s = str("".join(S)).replace("?", "a")
            print(s)
            exit()
# S = S.replace("?", "a")
print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
S = list(input())
T = list(input())
LS = len(S)
LT = len(T)
a = ""
for i in range(LS - LT + 1):
    for j in range(LT):
        if S[i + j] != T[j] and S[i + j] != "?":
            break
        if j == LT - 1:
            for k in range(LT):
                S[i + k] = T[k]
            #print("".join(S))
            s = str("".join(S)).replace("?", "a")
            print(s)
            exit()
# S = S.replace("?", "a")
print("UNRESTORABLE")a
Problem p03633 (python)

Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(max(a, b), min(a, b))


N = int(input())
T = [int(input()) for i in range(N)]

A = T[0]
for i in range(N):
    A = lcm(A, T[i])
print(A)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def lcm(a, b):
    return int(a * b / gcd(max(a, b), min(a, b)))


N = int(input())
T = [int(input()) for i in range(N)]

A = T[0]
for i in range(N):
    A = lcm(A, T[i])
print(A)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def lcm(a, b):
    return int(a * b / gcd(max(a, b), min(a, b)))


N = int(input())
T = [int(input()) for i in range(N)]
if N == 1:
    print(T[0])
    exit()
A = T[0]
for i in range(1, N):
    A = lcm(A, T[i])
print(A)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def lcm(a, b):
    return int(a * b / gcd(max(a, b), min(a, b)))


N = int(input())
T = [int(input()) for i in range(N)]
A = T[0]
for i in range(1, N):
    A = lcm(A, T[i])
print(A)
Problem p03779 (python)

Fixed submission:
X = int(input())
c = 0
for i in range(1, 1000000000):
    c += i
    if c > X:
        print(i)
        exit()
    elif c == X:
        print(i)
        exit()

Buggy submission (verdict: Runtime Error):
def an(a, b):  # a is time b is place
    if a > b:
        return float('INF')
    elif a == b:
        return a
    else:
        return min(an(a + 1, b), an(a + 1, b - a))


X = int(input())
print(an(1, X))
Problem p02690 (python)

Fixed submission:
from sys import stdin
import random

#a , b = 81,79
#x = a**5 - b**5
'''
while x < 1 or x > 10**9:
    a = random.randint(-100, 100)
    b = random.randint(-100, 100)
    x = a**5 - b**5
'''
#print(a,b,x)
x = int(stdin.readline().rstrip())

fivelist = []

i = 0
while True:
    n = i**5
    # print(i,n)
    if n > 2*(10**15):
        break
    fivelist.append(n)
    i += 1


a = 0
b = 0
ans = False
for i in range(len(fivelist)):
    for j in range(len(fivelist)):
        if x == (fivelist[i] - fivelist[j]):
            a, b = i, j
            ans = True
            break
        if x == (-fivelist[i] - fivelist[j]):
            a, b = -i, j
            ans = True
            break
        if x == (fivelist[i] + fivelist[j]):
            a, b = i, -j
            ans = True
            break
        if x == (-fivelist[i] + fivelist[j]):
            a, b = -i, -j
            ans = True
            break
    if ans:
        break

print("{} {}".format(a, b))

Buggy submission (verdict: Runtime Error):
from sys import stdin

x = int(stdin.readline().rstrip())

fivelist = []

i = 0
while True:
    n = i**5
    #print(i,n)
    if n > (10**10):
        break
    fivelist.append(n)
    i+=1

for i in range(len(fivelist)):
    for j in range(len(fivelist)):
        if x == (fivelist[i] - fivelist[j]):
            a, b = i , j
            break
        if x == (-fivelist[i] - fivelist[j]):
            a, b = -i , j
            break
        if x == (fivelist[i] + fivelist[j]):
            a, b = i , -j
            break
        if x == (-fivelist[i] + fivelist[j]):
            a, b = -i , -j
            break

print("{} {}".format(a,b))

Buggy submission (verdict: Runtime Error):
from sys import stdin

x = int(stdin.readline().rstrip())

fivelist = []

i = 0
while True:
    n = i**5
    #print(i,n)
    if n > (10**10):
        break
    fivelist.append(n)
    i+=1

for i in range(len(fivelist)):
    for j in range(len(fivelist)):
        if x == (fivelist[i] - fivelist[j]):
            a, b = i , j
            break
        if x == (-fivelist[i] - fivelist[j]):
            a, b = -i , j
            break
        if x == (fivelist[i] + fivelist[j]):
            a, b = i , -j
            break
        if x == -(fivelist[i] + fivelist[j]):
            a, b = -i , -j
            break

print("{} {}".format(a,b))

Buggy submission (verdict: Runtime Error):
from sys import stdin

x = int(stdin.readline().rstrip())

fivelist = []

i = 0
while True:
    n = i**5
    #print(i,n)
    if n > 2*(10**9):
        break
    fivelist.append(n)
    i+=1

for i in range(len(fivelist)):
    for j in range(len(fivelist)):
        if x == (fivelist[i] - fivelist[j]):
            a, b = i , j
            break
        if x == (-fivelist[i] - fivelist[j]):
            a, b = -i , j
            break
        if x == (fivelist[i] + fivelist[j]):
            a, b = i , -j
            break
        if x == -(fivelist[i] + fivelist[j]):
            a, b = -i , -j
            break

print("{} {}".format(a,b))
Problem p02692 (python)

Fixed submission:
from sys import stdin

import time
def dprint(*args):
    #print(*args)
    pass


n, a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
ans = "Yes"

card = []
sentaku = []

for i in range(n):
    s = stdin.readline().rstrip()
    card.append(s)

if a+b+c == 0:
    ans = "No"

nums = {"A": a, "B": b, "C": c}


def judge(i, j, k):
    global ans
    dprint(n, i, j, k, ans, nums, sentaku)
    if nums[j] == 0 and nums[k] == 0:
        ans = "No"
        return

    if nums[j] == 0:
        nums[j] += 1
        nums[k] -= 1
        sentaku.append(j)
        return
    if nums[k] == 0:
        nums[k] += 1
        nums[j] -= 1
        sentaku.append(k)
        return

    total = sum(nums.values())
    if total > 2 or i == n-1:
        if nums[k] > 1:
            nums[j] += 1
            nums[k] -= 1
            sentaku.append(j)
        else:
            nums[k] += 1
            nums[j] -= 1
            sentaku.append(k)
        dprint("tekitou")
        return

    ns = card[i+1]
    if ns[0] == j or ns[1] == j:
        nums[j] += 1
        nums[k] -= 1
        sentaku.append(j)
        return
    else:
        nums[k] += 1
        nums[j] -= 1
        sentaku.append(k)
        return
    pass


for i in range(n):
    s = card[i]
    judge(i, s[0], s[1])

print(ans)

if ans == "Yes":
    for i in range(len(sentaku)):
        print(sentaku[i])

Buggy submission (verdict: Runtime Error):
from sys import stdin


def dprint(*args):
    #print(*args)
    pass


n, a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
ans = "Yes"

card = []
sentaku = []

for i in range(n):
    s = stdin.readline().rstrip()
    card.append(s)

if a+b+c == 0:
    ans = "No"

nums = {"A": a, "B": b, "C": c}


def judge(i, j, k):
    global ans
    dprint(i, j, k, ans, sentaku)
    if nums[j] == 0 and nums[k] == 0:
        ans = "No"
        return

    if nums[j] == 0:
        nums[j] += 1
        nums[k] -= 1
        sentaku.append(j)
        return
    if nums[k] == 0:
        nums[k] += 1
        nums[j] -= 1
        sentaku.append(k)
        return

    total = sum(nums.values())
    if total > 2 or i < n-1:
        nums[j] += 1
        nums[k] -= 1
        sentaku.append(j)
        return

    ns = card[i+1]
    if ns[0] == j or ns[1] == j:
        nums[j] += 1
        nums[k] -= 1
        sentaku.append(j)
        return
    else:
        nums[k] += 1
        nums[j] -= 1
        sentaku.append(k)
        return
    pass


for i in range(n):
    s = card[i]
    judge(i, s[0], s[1])


print(ans)

if ans == "Yes":
    for i in range(len(sentaku)):
        print(sentaku[i])