Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):

def main():
    [n,a,b] = list(map(int,input().split()))
    m = list(map(int,input().split()))
    cost = 0
    for i in range(1,n+1):
        cost += min(a*(m[i]-m[i-1]), b)
    print(cost)


if __name__ == "__main__":
    main()

Fixed submission:

def main():
    [n, a, b] = list(map(int,input().split()))
    m = list(map(int,input().split()))
    cost = 0
    for i in range(1, n):
        cost += min([a*(m[i]-m[i-1]), b])
    print(cost)


if __name__ == "__main__":
    import sys
    import os
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            filename = "input1.txt"
            fd = os.open(filename, os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

Buggy python submission (verdict: Runtime Error):

def main():
    [n,a,b] = list(map(int,input().split()))
    m = list(map(int,input().split()))
    cost = 0
    for i in range(1,n+1):
        cost += min(a*(m[i]-m[i-1]), b)
    print(cost)


if __name__ == "__main__":
    import sys
    import os
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            filename = "input1.txt"
            fd = os.open(filename, os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

Fixed submission:

def main():
    [n, a, b] = list(map(int,input().split()))
    m = list(map(int,input().split()))
    cost = 0
    for i in range(1, n):
        cost += min([a*(m[i]-m[i-1]), b])
    print(cost)


if __name__ == "__main__":
    import sys
    import os
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            filename = "input1.txt"
            fd = os.open(filename, os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()
Buggy python submission (verdict: Time Limit Exceeded):

#aまでいけそうなら動かす。駄目そうならその項は終わり
import sys


def move(s, k):
    if len(s) == 1:
        return chr(97+(ord(s) + k - 97)%26)
    if s[0] == 'a' or 123-ord(s[0]) > k:
        return s[0] + move(s[1:], k)
    else:
        return 'a' + move(s[1:], k-(123-ord(s[0])))


s = input()
K = int(input())
sys.setrecursionlimit(20000)
print(move(s,K))



Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 24 21:28:20 2016

@author: dotha
"""

#aまでいけそうなら動かす。駄目そうならその項は終わり

def move(s, k):
    if len(s) == 1:
        return chr(97+(ord(s) + k - 97)%26)
    if s[0] == 'a' or 123-ord(s[0]) > k:
        return s[0] + move(s[1:], k)
    else:
        return 'a' + move(s[1:], k-(123-ord(s[0])))

def move_(l,k):
    if l =='a' or 123-ord(l) > k:
        return (l,k)
    else:
        return ('a', k-(123-ord(l)))

s = input()
K = int(input())
answer=[]
#print(move(s,K))

for l in s:
    (x,K) = move_(l,K)
    answer.append(x)

answer[-1] = chr(97++(ord(answer[-1]) + K - 97)%26)
    
print(''.join(answer))

Buggy python submission (verdict: Runtime Error):
def move(s, k):
    if len(s) == 1:
        return chr(97+(ord(s) + k - 97)%26)
    if s[0] == 'a' or 123-ord(s[0]) > k:
        return s[0] + move(s[1:], k)
    else:
        return 'a' + move(s[1:], k-(123-ord(s[0])))






s = input()
K = int(input())
print(move(s,K))

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 24 21:28:20 2016

@author: dotha
"""

#aまでいけそうなら動かす。駄目そうならその項は終わり

def move(s, k):
    if len(s) == 1:
        return chr(97+(ord(s) + k - 97)%26)
    if s[0] == 'a' or 123-ord(s[0]) > k:
        return s[0] + move(s[1:], k)
    else:
        return 'a' + move(s[1:], k-(123-ord(s[0])))

def move_(l,k):
    if l =='a' or 123-ord(l) > k:
        return (l,k)
    else:
        return ('a', k-(123-ord(l)))

s = input()
K = int(input())
answer=[]
#print(move(s,K))

for l in s:
    (x,K) = move_(l,K)
    answer.append(x)

answer[-1] = chr(97++(ord(answer[-1]) + K - 97)%26)
    
print(''.join(answer))
Buggy python submission (verdict: Runtime Error):
primes = [2,3,5,7,11,13,17,19,23,29,31]

memo1 = {}
def factorization(n):
    result = []
    for prime in primes:
        while n % prime == 0:
            n = n / prime
            result.append(prime)
    if n != 1:
        result.append(n)
    return result

def num_of_factors(l):

    if len(l) == 1:
        return 2
    p2num = {}
    for prime in l:
        if prime not in p2num:
            p2num[prime] = 2
        else:
            p2num[prime] += 1
    return reduce(lambda x,y: x * y,p2num.values())

def factors_of_factorials(n):
    l = []
    for i in range(1,n+1):
        l += factorization(i)
    return num_of_factors(l) % (10**9 + 7)


n = int(raw_input())
print factors_of_factorials(n)

Fixed submission:
primes = [2,3,5,7,11,13,17,19,23,29,31]

memo1 = {}
def factorization(n):
    result = []
    for prime in primes:
        while n % prime == 0:
            n = n / prime
            result.append(prime)
    if n != 1:
        result.append(n)
    return result

def num_of_factors(l):
    if l == []:
        return 1
    if len(l) == 1:
        return 2
    p2num = {}
    for prime in l:
        if prime not in p2num:
            p2num[prime] = 2
        else:
            p2num[prime] += 1
    return reduce(lambda x,y: x * y,p2num.values())

def factors_of_factorials(n):
    l = []
    for i in range(1,n+1):
        l += factorization(i)
    return num_of_factors(l) % (10**9 + 7)


n = int(raw_input())
print factors_of_factorials(n)

Buggy python submission (verdict: Runtime Error):
primes = [2,3,5,7,11,13,17,19,23,29,31]

memo1 = {}
def factorization(n):
    result = []
    for prime in primes:
        while n % prime == 0:
            n = n / prime
            result.append(prime)
    if n != 1:
        result.append(n)
    return result

def factors(l):
    p2num = {}
    for prime in l:
        if prime not in p2num:
            p2num[prime] = 2
        else:
            p2num[prime] += 1
    return reduce(lambda x,y: x * y,p2num.values())

def factors_of_factorials(n):
    l = []
    for i in range(1,n+1):
        l += factorization(i)
    return factors(l) % (10**9 + 7)


n = int(raw_input())
print factors_of_factorials(n)

Fixed submission:
primes = [2,3,5,7,11,13,17,19,23,29,31]

memo1 = {}
def factorization(n):
    result = []
    for prime in primes:
        while n % prime == 0:
            n = n / prime
            result.append(prime)
    if n != 1:
        result.append(n)
    return result

def num_of_factors(l):
    if l == []:
        return 1
    if len(l) == 1:
        return 2
    p2num = {}
    for prime in l:
        if prime not in p2num:
            p2num[prime] = 2
        else:
            p2num[prime] += 1
    return reduce(lambda x,y: x * y,p2num.values())

def factors_of_factorials(n):
    l = []
    for i in range(1,n+1):
        l += factorization(i)
    return num_of_factors(l) % (10**9 + 7)


n = int(raw_input())
print factors_of_factorials(n)
Buggy python submission (verdict: Runtime Error):
  a, b, h = [int(input()) for _ in range(3)]
  print((a+b)*h / 2)


Fixed submission:
a, b, h= (int(input()) for _ in range(3))
print((a+b)*h // 2)

Buggy python submission (verdict: Runtime Error):
  a, b, h = map(int(input().split())
  print((a+b)*h / 2)


Fixed submission:
a, b, h= (int(input()) for _ in range(3))
print((a+b)*h // 2)

Buggy python submission (verdict: Runtime Error):
  a, b, h = (int(input()) for i in range(3))
  print((a+b)*h / 2)

Fixed submission:
a, b, h= (int(input()) for _ in range(3))
print((a+b)*h // 2)
Buggy python submission (verdict: Runtime Error):
n, k, x, y = map(int(input()) for i in range(4))
if k <= n:
  print(k*x)
else:
  print(k*x + (n-k)*y)

Fixed submission:
n, k, x, y = (int(input()) for i in range(4))
if k >= n:
  print(n*x)
else:
  print(k*x + (n-k)*y)

Buggy python submission (verdict: Runtime Error):
n, k, x, y = map(int, input().split())
if k <= n:
  print(k*x)
else:
  print(k*x + (n-k)*y)

Fixed submission:
n, k, x, y = (int(input()) for i in range(4))
if k >= n:
  print(n*x)
else:
  print(k*x + (n-k)*y)

Buggy python submission (verdict: Runtime Error):
n, k, x, y = map(int, input().split())
if k >= n:
  print(k*x)
else:
  print(k*x + (n-k)*y)

Fixed submission:
n, k, x, y = (int(input()) for i in range(4))
if k >= n:
  print(n*x)
else:
  print(k*x + (n-k)*y)
Buggy python submission (verdict: Runtime Error):
n = int(input())
num = 0
for num in range(n+1):
  total = total + num
print(total)


Fixed submission:
n = int(input())
total = 0
for num in range(n+1):
  total = total + num
print(total)

Buggy python submission (verdict: Runtime Error):
n = int(input())
for num in range(n+1):
  total = total + num
print(total)


Fixed submission:
n = int(input())
total = 0
for num in range(n+1):
  total = total + num
print(total)

Buggy python submission (verdict: Runtime Error):
n = input()
for num in range(n+1):
  total = total + num
print(total)

Fixed submission:
n = int(input())
total = 0
for num in range(n+1):
  total = total + num
print(total)

Buggy python submission (verdict: Runtime Error):
n = int(input().split())
for num in range(n+1):
  total = total + num
print(total)

Fixed submission:
n = int(input())
total = 0
for num in range(n+1):
  total = total + num
print(total)
Buggy python submission (verdict: Runtime Error):
s = map(int(input().split()))
if s.count('7') == 1 and s.count('5') == 2:
  print('YES')
else:
  print('NO')

Fixed submission:

s = input().split()
if s.count('7') == 1 and s.count('5') == 2:
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int(input().split()))
if count(7) == 1 and count(5) == 2:
  print('YES')
else:
  print('NO')

Fixed submission:

s = input().split()
if s.count('7') == 1 and s.count('5') == 2:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
k, s = list(map(int, input().split()))
num = 0

for x in range(k+1):
  for y in range(k+1):
    if s-k <= x+y <= s:
      num += 1

print(num)


Fixed submission:
s = input()
print(s.replace(',', ' '))
Buggy python submission (verdict: Runtime Error):
k, s = list(map(input().split()))
num = 0

for x in range(k+1):
  for y in range(k+1):
    if s-k <= x+y <= s:
      num += 1
      
print(num)

Fixed submission:
k, s = list(map(int, input().split()))
num = 0

for x in range(k+1):
  for y in range(k+1):
    if s-k <= x+y <= s:
      num += 1

print(num)

Buggy python submission (verdict: Runtime Error):
k, s = list(map(input().split()))

num = 0
for x in range(k+1):
  for y in range(k+1):
    if s-k <= x+y <= s:
      num += 1
      
print(num)

Fixed submission:
k, s = list(map(int, input().split()))
num = 0

for x in range(k+1):
  for y in range(k+1):
    if s-k <= x+y <= s:
      num += 1

print(num)
Buggy python submission (verdict: Runtime Error):
happy,newyear,enjoy

Fixed submission:
print(input().replace(',', ' '))
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
A = [A, B, C]

if A.count(5) == 2 and A.count(7) == 1:
    print("YES")
else:
    print("NO")


Fixed submission:
A = input()

if A.count('5') == 2 and A.count('7') == 1:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
A = [A, B, C]

if A.count(5) == 2 and A.count(7) == 1:
    print("YES")
else:
    print("NO")


Fixed submission:
A = input()

if A.count('5') == 2 and A.count('7') == 1:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readlines()

N = int(input[0])
T_N = list(map(int, input[1].split()))
M = int(input[2])
P_M = [None] * M
P_X = [None] * M
for PX in input[3:]:
    P_M, X_M = map(int, PX.split())

sumT = sum(T_N)
for idx1 in range(M):
    print(sumT - T_N[P_M[idx1] - 1] + X_M[idx1])


Fixed submission:
import sys
in1 = sys.stdin.readlines()

#in1 = ['5','7 2 3 8 5','3','4 2','1 7','4 13']

N = int(in1[0])
T_N = list(map(int, in1[1].split()))
M = int(in1[2])
P_M = [None] * M
X_M = [None] * M
idx1 = 0
for PX in in1[3:]:
    P_M[idx1], X_M[idx1] = map(int, PX.split())
    idx1 += 1

sumT = sum(T_N)
for idx1 in range(M):
    print(sumT - T_N[P_M[idx1] - 1] + X_M[idx1])

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
"""
in1 = '5'
in2 = '7 2 3 8 5'
in3 = '3'
in4 = ['4 2', '1 7', '4 13']

N = int(in1)
T_N = list(map(int, in2.split()))
M = int(in3)
P_M = [None] * M
X_M = [None] * M
for i in range(M):
    P_M[i], X_M[i] = (int(x) for x in in4[i].split())
"""
N = int(input())
T_N = list(map(int, input().split()))
M = int(input())
P_M = [None] * M
P_X = [None] * M
for i in range(M):
    P_M[i], X_M[i] = (int(x) for x in input().split())

sumT = sum(T_N)
for idx1 in range(M):
    print(sumT - T_N[P_M[idx1] - 1] + X_M[idx1])


Fixed submission:
import sys
in1 = sys.stdin.readlines()

#in1 = ['5','7 2 3 8 5','3','4 2','1 7','4 13']

N = int(in1[0])
T_N = list(map(int, in1[1].split()))
M = int(in1[2])
P_M = [None] * M
X_M = [None] * M
idx1 = 0
for PX in in1[3:]:
    P_M[idx1], X_M[idx1] = map(int, PX.split())
    idx1 += 1

sumT = sum(T_N)
for idx1 in range(M):
    print(sumT - T_N[P_M[idx1] - 1] + X_M[idx1])

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

N = int(input())
T_N = [int(input()) for _ in range(N)]
M = int(input())
for i in range(M):
    P_M, X_M = map(int, input().split())

sumT = sum(T_N)
for idx1 in range(M):
    print(sumT - T_N[P_M[idx1] - 1] + X_M[idx1])


Fixed submission:
import sys
in1 = sys.stdin.readlines()

#in1 = ['5','7 2 3 8 5','3','4 2','1 7','4 13']

N = int(in1[0])
T_N = list(map(int, in1[1].split()))
M = int(in1[2])
P_M = [None] * M
X_M = [None] * M
idx1 = 0
for PX in in1[3:]:
    P_M[idx1], X_M[idx1] = map(int, PX.split())
    idx1 += 1

sumT = sum(T_N)
for idx1 in range(M):
    print(sumT - T_N[P_M[idx1] - 1] + X_M[idx1])

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

N = int(input())
T_N = [int(input()) for _ in range(N)]
M = int(input())
for _ in range(M):
    P_M, X_M = map(int, input().split())

sumT = sum(T_N)
for idx1 in range(M):
    print(sumT - T_N[P_M[idx1] - 1] + X_M[idx1])


Fixed submission:
import sys
in1 = sys.stdin.readlines()

#in1 = ['5','7 2 3 8 5','3','4 2','1 7','4 13']

N = int(in1[0])
T_N = list(map(int, in1[1].split()))
M = int(in1[2])
P_M = [None] * M
X_M = [None] * M
idx1 = 0
for PX in in1[3:]:
    P_M[idx1], X_M[idx1] = map(int, PX.split())
    idx1 += 1

sumT = sum(T_N)
for idx1 in range(M):
    print(sumT - T_N[P_M[idx1] - 1] + X_M[idx1])
Buggy python submission (verdict: Runtime Error):
import sys

in1 = sys.stdin.readlines()
N = in1[0]
#N = 10 ** 18
#N = 2
"""
0 + 0 = 0
0 x 0 = 0

1 + 0 = 1
1 x 0 = 1

2 + 0 = 2
2 x 0 = 2
1 + 1 = 2
1 x 1 = 0

3 + 0 = 3
3 x 0 = 3
2 + 1 = 3
2 x 1 = 3
"""
p = 10 ** 9 + 7

def f(n):
    if n in d:
        return d[n]
    d[n] = f(n // 2) + f((n - 1) // 2) + f((n - 2) // 2)
    return d[n]

d = {0: 1, 1: 2}
print(f(N) % p)


Fixed submission:
import sys

in1 = sys.stdin.readlines()
N = int(in1[0])
#N = 10 ** 18
#N = 2
"""
0 + 0 = 0
0 x 0 = 0

1 + 0 = 1
1 x 0 = 1

2 + 0 = 2
2 x 0 = 2
1 + 1 = 2
1 x 1 = 0

3 + 0 = 3
3 x 0 = 3
2 + 1 = 3
2 x 1 = 3
"""
p = 10 ** 9 + 7

def f(n):
    if n in d:
        return d[n]
    d[n] = f(n // 2) + f((n - 1) // 2) + f((n - 2) // 2)
    return d[n]

d = {0: 1, 1: 2}
print(f(N) % p)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

if sum(a, b, c) == max(a, b, c) * 2:
    print('Yes')
else:
    print('No')


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

if a + b + c == max(a, b, c) * 2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n, t = map(int, input().split())
a = list(map(lambda x: int(x), input().split()))
#a = list(map(lambda x: int(x), in1.split()))
w_a = []
str_a = 0

for idx1 in range(len(a) - 1):
    w_a.append(a[idx1])
    if a[idx1 + 1] - min(w_a) > str_a:
        RC = 1
        str_a = a[idx1 + 1] - min(w_a)
    elif a[idx1 + 1] - min(w_a) == str_a:
        RC += 1

print(RC)


Fixed submission:
n, t = map(int, input().split())
a = list(map(lambda x: int(x), input().split()))
#a = list(map(lambda x: int(x), in1.split()))
b = []
strlow = a[0]

for idx1 in range(1, len(a)):
    b.append(a[idx1] - strlow)
    if a[idx1] < strlow:
        strlow = a[idx1]

print(b.count(max(b)))
Buggy python submission (verdict: Runtime Error):
a = int(input().split())

print(len(list(set(a)))    


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

print(len(list(set(a))))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

if a=b+c or b=c+a or c= a+b:
  print('Yes')
else:
  prine('No')

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

if a==b+c or b==c+a or c==a+b:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N,A=map(int,input().split())
x=sorted(list(map(int,input().split())))

xn=[x[i]-A for i in range(len(x)) if x[i]<A]
xn.reverse()
x0=[0 for i in range(len(xn),len(x)) if x[i]==A]
xp=[x[i]-A for i in range(len(xn)+len(x0),len(x)) if x[i]>A]

sxn=[0]
sxn_n=[1]
for x in xn:
  sxn_add=[]
  sxn_n_i=[]
  for j in range(len(sxn)):
    sxn_tmp=sxn[j]+x
    for k in range(j,len(sxn)):
      if sxn[k]<=sxn_tmp or k==len(sxn)-1:
        if sxn[k]==sxn_tmp:
          sxn_n_i.append([k,sxn_n[j]])
        elif sxn[k]<sxn_tmp:
          sxn_add.append([k,sxn_tmp,sxn_n[j]])
        else:
          sxn_add.append([k+1,sxn_tmp,sxn_n[j]])
        break
  for k in range(len(sxn_add)):
    sxn.insert(k+sxn_add[k][0],sxn_add[k][1])
    sxn_n.insert(k+sxn_add[k][0],1)
  for l in sxn_n_i:
    sxp_n[l[0]]+=l[1]    

sxp=[0]
sxp_n=[1]
for x in xp:
  sxp_add=[]
  sxp_n_i=[]
  for j in range(len(sxp)):

    sxp_tmp=sxp[j]+x

    for k in range(j,len(sxp)):
      if sxp[k]>=sxp_tmp or k==len(sxp)-1:

        if sxp[k]==sxp_tmp:
          sxp_n_i.append([k,sxp_n[j]])
        elif sxp[k]>sxp_tmp:
          sxp_add.append([k,sxp_tmp,sxp_n[j]])
        else:
          sxp_add.append([k+1,sxp_tmp,sxp_n[j]])
        break

  for k in range(len(sxp_add)):
    sxp.insert(k+sxp_add[k][0],sxp_add[k][1])
    sxp_n.insert(k+sxp_add[k][0],sxp_add[k][2])
  for l in sxp_n_i:
    sxp_n[l[0]]+=l[1]



an=0
for i in range(1,len(sxp)):
  for j in range(1,len(sxn)):

    if sxp[i]==-sxn[j]:
      an+=sxp_n[i]*sxn_n[j]
      break


print(2**len(x0)-1+an*2**(len(x0)))

Fixed submission:
N,A=map(int,input().split())
x=sorted(list(map(int,input().split())))

xn=[x[i]-A for i in range(len(x)) if x[i]<A]
xn.reverse()
x0=[0 for i in range(len(xn),len(x)) if x[i]==A]
xp=[x[i]-A for i in range(len(xn)+len(x0),len(x)) if x[i]>A]

sxn=[0]
sxn_n=[1]
for x in xn:
  sxn_add=[]
  sxn_n_i=[]
  for j in range(len(sxn)):
    sxn_tmp=sxn[j]+x
    for k in range(len(sxn)):
      if sxn[k]==sxn_tmp or k==len(sxn)-1:
        if sxn[k]==sxn_tmp:
          sxn_n_i.append([k,sxn_n[j]])
        else:
          sxn_add.append([sxn_tmp,sxn_n[j]])
        break
  for l in sxn_n_i:
    sxn_n[l[0]]+=l[1]  
  for k in sxn_add:
    sxn.append(k[0])
    sxn_n.append(k[1])
  

sxp=[0]
sxp_n=[1]
for x in xp:
  sxp_add=[]
  sxp_n_i=[]
  for j in range(len(sxp)):

    sxp_tmp=sxp[j]+x

    for k in range(j,len(sxp)):
      if sxp[k]==sxp_tmp or k==len(sxp)-1:

        if sxp[k]==sxp_tmp:
          sxp_n_i.append([k,sxp_n[j]])
        else:
          sxp_add.append([sxp_tmp,sxp_n[j]])
        break
  for l in sxp_n_i:
    sxp_n[l[0]]+=l[1]
  for k in sxp_add:
    sxp.append(k[0])
    sxp_n.append(k[1])




an=0
for i in range(1,len(sxp)):
  for j in range(1,len(sxn)):

    if sxp[i]==-sxn[j]:
      an+=sxp_n[i]*sxn_n[j]
      break


print(2**len(x0)-1+an*2**(len(x0)))
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=int(input())

b_ans=1
for b in range(2,int(n**0.5)+1):
  nn=n
  st=[]
  while(nn>0):
    st.append(nn%b)
    nn=(nn-st[-1])/b
  
  if sum(st)==s:
    b_ans=b
    break


if b_ans==1:
  for p in range(int(n**0.5)):
    b=int(n/p)
    q=n-p*b
    if s==p+q:
      b_ans=b
      break

if b_ans!=1:
  print(b_ans)
else:
  print(-1)

Fixed submission:
n=int(input())
s=int(input())

b_ans=1



if n==s:
  b_ans=n+1
if b_ans==1:
  for b in range(2,int(n**0.5)+1):
    nn=n
    st=[]
    while(nn>0):
      st.append(nn%b)
      nn=(nn-st[-1])/b
  
    if sum(st)==s:
      b_ans=b
      break

if b_ans==1:
  for p in range(int(n**0.5),0,-1):
    b=(n-s+p)/p

    if b.is_integer() and 0<=s-p<b and b>n**0.5:
      b_ans=int(b)
      break

if b_ans!=1:
  print(b_ans)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
N=int(input())

out=0
for i in range(N):
  out+=i+1
return out

Fixed submission:
N=int(input())

out=0
for i in range(N):
  out+=i+1
print(out)
Buggy python submission (verdict: Runtime Error):
N_str, K=input().split()
N_digit=list(map(int,list(N_str)))
D=sorted(list(map(int,input().split())))
l_digit=[n>D[-1] for n in N_digit]


if any(l_digit):
  N_n=l_digit.index(True)
  if not any([n<D[-1] for n in N_digit[0:N_n]]):
    out=list(str(D[1] if D[0]==0 else D[0]))
    out+=[str(D[0]) for i in range(len(N_digit))]
  else:
    out=[str(D[[n<=D[j] for j in range(int(K))].index(True)]) for n in N_digit[0:N_n]] + [str(D[0]) for n in N_digit[N_n:]]
    for k in range(N_n-1,-1,-1):
      if N_digit[k]<D[-1]:
        out[k]=str(D[[N_digit[k]<D[j] for j in range(int(K))].index(True)])
        break
    
else:
  out=[str(D[[n<=D[j] for j in range(int(K))].index(True)]) for n in N_digit]

print(int("".join(out)))



Fixed submission:
N_str, K=input().split()
K=10-int(K)
N_digit=list(map(int,list(N_str)))
D=sorted(list(map(int,input().split())))
D=[d for d in range(10) if d not in D]

l_digit=[n>D[-1] for n in N_digit]

if any(l_digit):
  N_n=l_digit.index(True)
  if not any([n is not D[-1] for n in N_digit[0:N_n]]):
    out=list(str(D[1] if D[0]==0 else D[0]))
    out+=[str(D[0]) for i in range(len(N_digit))]
  else:
    flag=False
    out=[]
    for i in range(N_n):
      if not flag:
      	for j in range(K):
          if D[j]>=N_digit[i]:
            out.append(str(D[j]))
            if D[j]!=N_digit[i]:
              flag=True
              break
      else:
        out.append(str(D[0]))
    for i in range(N_n,len(N_digit)):
      out.append(str(D[0]))
else:
  out=[]
  flag=False
  for n in N_digit:
    if not flag:
      for j in range(K):
        if D[j]>=n:
          out.append(str(D[j]))
          if D[j]>n:
            flag=True
          break
    else:
      out.append(str(D[0]))
      
print(int("".join(out)))
Buggy python submission (verdict: Runtime Error):
list = ["haiku", "atcorder", "pytho"]
print(list.replace("," , " "))


Fixed submission:
haiku = input()
print(haiku.replace("," , " "))
Buggy python submission (verdict: Runtime Error):
word = input().split()

if word == "a", "e", "i", "o", "u" :
    print("vowel")
else:
    print("consonant")

Fixed submission:
word = input()

if word=="a" or word=="e" or word=="i" or word=="o" or word=="u" :
    print("vowel")
else:
    print("consonant")
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

k, s = list(map(int, input().split()))

and = 0
for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - (i + j) <= k: ans += 1

print(ans)


Fixed submission:
# coding: utf-8
 
K_MAX = 2500
k, s = list(map(int, input().split()))
 
smz = [False] * (2 * K_MAX + 1)
 
for i in range(k + 1):
    if 0 <= s - i <= 2 * k: smz[s - i] = True
 
cnt = 0
for i in range(k + 1):
    for j in range(k + 1):
        if smz[i + j]:
            cnt += 1
 
print(cnt)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8

K_MAX = 2500
k, s = list(map(int, input().split()))

smz = [False] * (2 * K_MAX + 1)

for i in range(k + 1):
    if s - i >= 0: smz[s - i] = True

cnt = 0
for i in range(k + 1):
    for j in range(k + 1):
        if smz[i + j]:
            cnt += 1

print(cnt)


Fixed submission:
# coding: utf-8
 
K_MAX = 2500
k, s = list(map(int, input().split()))
 
smz = [False] * (2 * K_MAX + 1)
 
for i in range(k + 1):
    if 0 <= s - i <= 2 * k: smz[s - i] = True
 
cnt = 0
for i in range(k + 1):
    for j in range(k + 1):
        if smz[i + j]:
            cnt += 1
 
print(cnt)