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

Fixed submission:
N, K = list(map(int, input().split()))
 
ans = 0
for i in range(1, N+1):
    p = 1
    x = i
    while x < K:
        p *= 0.5
        x *= 2
    
    ans += p/N
 
print(ans)

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

proba = 0
for i in range(1, N+1):
  x = i
  p = 1
  while x < K:
    p *= 0.5
    x *= 2
  proba += p/N
print(proba)

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

proba = 0.0

for i in range(1, N+1):
  x = i
  p = 1.0
  while x < K:
    p *= 0.5
    x += 1
  proba += p/N
  
print(proba)

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

proba = 0
for i in range(1, N+1):
  x = i
  p = 1
  while x < K:
    p *= 0.5
    x += 1
  proba += p/N

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

proba = 0
for i in range(1, N):
  x = i
  p = 1
  while x < K:
    p *= 0.5
    x += 1
  proba += p/N
  
print(proba)

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

proba = 0
for i in range(1, N):
  x = i
  p = 1
  while x < K:
    p *= 0.5
    x += 1
  proba += p/N

Buggy submission (verdict: Runtime Error):
import math

s = input().split()
n = s[0]
k = s[1]

proba = 0

for i in range(1, k):
  n_coin = int(math.log(k/i,2)) + 1
  print(i, n_coin)
  proba += float(1)/n*((0.5)**n_coin)

if n >= k:
	proba += float(n-k+1)/n
print(proba)

Buggy submission (verdict: Runtime Error):
import math

s = input().split()
n = s[0]
k = s[1]

proba = 0

for i in range(1, k):
  n_coin = int(math.log(k/i,2)) + 1
  print(i, n_coin)
  proba += float(1)/n*((0.5)**n_coin)

if n >= k:
	proba += float(n-k+1)/n

Buggy submission (verdict: Runtime Error):
import math

inp = input().split()
n = inp[0]
k = inp[1]
proba = 0

for i in range(1, k):
  n_coin = int(math.log(k/i,2)) + 1
  print(i, n_coin)
  proba += float(1)/n*((0.5)**n_coin)

if n >= k:
	proba += float(n-k+1)/n
Problem p03076 (python)

Fixed submission:
import math
dishes = [int(input()) for _ in range(5)]
lead_times = [int(math.ceil(t/10))*10 - t for t in dishes]
max_idx = lead_times.index(max(lead_times))
result = 0
for i in range(5):
  result += dishes[i]
  if i != max_idx:
    result += lead_times[i]
print(result)

Buggy submission (verdict: Runtime Error):
import math
dishes = [int(input()) for _ in range(5)]
lead_times = [int(math.ceil(t/10))*10 - t in dishes]
max_idx = lead_times.index(max(lead_times))
result = 0
for i in range(5):
  result += dishes[i]
  if i != max_idx:
    result += lead_times[i]
print(result)
Problem p03737 (python)

Fixed submission:
s1, s2, s3 = input().split()


print((s1[0] + s2[0] + s3[0]).upper())

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
print('LESS' if A < B else 'GREATER' if A > B else 'EQUAL')

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
print('LESS' if A < B else 'GREATER' if A > B else 'EQUAL')
Problem p03738 (python)

Fixed submission:
A = int(input())
B = int(input())

if A < B:
    print('LESS')
elif A > B:
    print('GREATER')
else:
    print('EQUAL')

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
print('LESS' if A < B else 'GREATER' A > B else 'EQUAL')
Problem p03778 (python)

Fixed submission:

W, a, b = map(int, input().split())

if a > b + W:
    print(a - (b + W))
elif b > a + W:
    print(b - (a + W))
else:
    print(0)

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

if a > b + W:
    print(a - (b + w))
elif b > a + W:
    print(b - (a + W))
else:
    print(0)
Problem p02918 (python)

Fixed submission:
# https://atcoder.jp/contests/abc140/tasks/abc140_d

n, k = map(int, input().split())
str_n = input()
first = str_n[0]
last = ""
if first == "R":
    last = "L"
else:
    last = "R"

for count in range(k): 
    new_line = str_n
    next_last = new_line.find(last)
    next_first = new_line.find(first, next_last)
    next_line = new_line[0:next_last]
    if next_first != -1:
        next_line += new_line[next_last:next_first].replace(last, first) + new_line[next_first:]
    else:
        next_line += new_line[next_last:].replace(last, first)
    str_n = next_line

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

print(count)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc140/tasks/abc140_d

n, k = map(int, input().split())
str_n = input()
changed_str = [str_n]
first = str_n[0]
last = ""
if first == "R":
    last = "L"
else:
    last = "R"

for count in range(k): 
    new_line = changed_str[count]
    next_last = new_line.find(last)
    next_first = new_line.find(first, next_last)
    next_line = new_line[0:next_last]
    if next_first != -1:
        next_line += new_line[next_last:next_first].replace(last, first) + new_line[next_first:]
    else:
        next_line += new_line[next_last:].replace(last, first)
    changed_str.append(next_line)

count = 0
result_line = changed_str[k]
for i in range(len(changed_str[k]) - 1):
    if result_line[i] == result_line[i + 1]:
        count += 1

print(count)
Problem p02945 (python)

Fixed submission:
a, b = map(int, input().split())
print(max([a+b, a-b, a*b]))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input())
print(max([a+b, a-b, a*b]))
Problem p02953 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
ans = True
minv = 0

for i in range(len(h)-1):
    down = False
    
    if h[i] > h[i+1]:
        if h[i] - h[i+1] > 1:
            ans = False
            break
        else:
            if h[i]-1 >= minv:
                h[i] -= 1
                minv = h[i]
                down = True
            else:
                ans = False
                break
    if not down and  i!=0 and h[i-1] < h[i]:
        h[i] -= 1
        minv = h[i]


print("Yes") if ans else print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
h = map(int, input().split())
ans = True
minv = 0

for i in range(len(h)-1):
    down = False
    
    if h[i] > h[i+1]:
        if h[i] - h[i+1] > 1:
            ans = False
            break
        else:
            if h[i]-1 >= minv:
                h[i] -= 1
                minv = h[i]
                down = True
            else:
                ans = False
                break
    if not down and  i!=0 and h[i-1] < h[i]:
        h[i] -= 1
        minv = h[i]


print("Yes") if ans else print("No")
Problem p03220 (python)

Fixed submission:
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

t = [abs(A - (T - i*0.006)) for i in H]
print(t.index(min(t))+1)

Buggy submission (verdict: Runtime Error):
import pandas as pd

N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

t = [abs(A - (T - i*0.006)) for i in H]
print(pd.Series(t).idxmin()+1)

Buggy submission (verdict: Runtime Error):
import pandas as pd

N = int(input())
T, A = map(int, input().split())
H= list(map(int, input().split()))

t = []
for i in H:
    t.append(abs(A - (T - i*0.006)))

print(pd.Series(t).idxmin()+1)
Problem p03302 (python)

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

if a + b == 15 and 1 <= a <=15 and 1 <= b <=15:
    print('+')
elif  a * b == 15 and 1 <= a <=15 and 1 <= b <=15:
    print('*')
else:
    print('x')

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

if a + b == 15 and 1 <= a <=15 and 1 <= b <=15:
    print('+')
elif  a * b == 15 and 1 <= a <=15 and 1 <= b <=15:
    print('*')
else:
    print('x')
Problem p02934 (python)

Fixed submission:
# Fraction クラスを呼びだします
from fractions import Fraction
n=int(input())
m=input().split()
tmp =0

for x in range(0,n):
  a = Fraction(1, int(m[x]))
  tmp+=a
  
a_f = float(Fraction(1, tmp))
print(a_f)

Buggy submission (verdict: Runtime Error):
# Fraction クラスを呼びだします
from fractions import Fraction
n=int(input())
m=input().split()
tmp =0

for x in range(0,n):
  a = Fraction(1, int(m[x]))
  tmp+=a
  
print(Fraction(1, z))
Problem p03150 (python)

Fixed submission:
from re import fullmatch
S = input()
_s = "keyence"
flag = False
for i in range(len(_s)):
    tmp = fullmatch("(.*)" + _s[:i] + "(.*)" + _s[i:] + "(.*)", S)
    if tmp and sum([1 for j in range(1, 4) if tmp.group(j)]) <= 1:
        flag = True
print("YES") if flag else print("NO")

Buggy submission (verdict: Runtime Error):
from re import fullmatch
S = input()
_s = "keyence"
flag = False
for i in range(len(_s)):
    if fullmatch(f".*{_s[:i]}.*{_s[i:]}.*", S):
        flag = True
print("YES") if flag else print("NO")
Problem p03777 (python)

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

if a == 'H' and b == 'H':
    print('H')
elif a == 'H' and b == 'D':
    print('D')
elif a == 'D' and b == 'H':
    print('D')
else:
    print('H')

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

if a == 'H' and b == 'H':
    print('H')
elif a == 'H' and b == 'D':
    print('H')
elif a == 'D' and b == 'H':
    print('D')
else:
    print('H')

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

if a == 'H' and b == 'H':
    print('H')
elif a == 'H' and b == 'D':
    print('D')
elif a == 'D' and b == 'H':
    print('D')
else:
    print('H')
Problem p03779 (python)

Fixed submission:
X = int(input())

result = 0
for i in range(0, X):
    result += (i+1)
    if X <= result:
        print(i+1)
        break

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

for i in range(0, X):
    result += (i+1)
    if X >= result:
        print(i+1)
        break
Problem p03000 (python)

Fixed submission:
n, x = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]

d = 0
count = 0
for i in l:
    if d > x:
        break
    count += 1
    d += i

if d <= x:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n, x = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]

d = 0
count = 0
for i in l:
    if d > x:
        break
    count += 1
    d += i

print(count
Problem p02918 (python)

Fixed submission:
#

def happiness(s):
    h = 0
    c = s[0]
    for i in range(1,len(s)):
        if s[i] == c:
            h = h + 1
        else:
            c = s[i]
    return h

def schrun(s,l):
    c = s[l]
    i = l+1
    while (i<len(s)) and (s[i] == c) :
        i = i+1
    return i
        
#
n, k = map(int, input().split())
s = input()
#
h = happiness(s)
i = 0
l = 0
while( (i<k) and (l<n) and (h<n-1)):
    l = schrun(s,l)
    r = schrun(s,l)-1
    if r == n-1:
        h = h + 1
    else:
        h = h + 2
    i = i + 1
    l = r + 1

print(h)

Buggy submission (verdict: Runtime Error):
#
def happiness(s):
    h = 0
    c = s[0]
    for i in range(1,len(s)):
        if s[i] == c:
            h = h + 1
        else:
            c = s[i]
    return h

def schrun(s,l):
    c = s[l]
    i = l+1
    while (i<len(s)) and (s[i] == c) :
        i = i+1
    return i
        
#
n, k = map(int, input().split())
s = input()
#
h = happiness(s)
i = 0
l = 0
while( (i<k) and (l<n) ):
    l = schrun(s,l)
    r = schrun(s,l)-1
    if r == n-1:
        h = h + 1
    else:
        h = h + 2
    i = i + 1
    l = r + 1

print(h)
Problem p02921 (python)

Fixed submission:
S=input()
T=input()
a=0
for i in range(len(S)):
  if S[i]==T[i]:
    a=a+1
print(a)

Buggy submission (verdict: Runtime Error):
S=list(map(input().split()))
T=list(map(input().split()))
a==0
for i in S:
  if S[i]==T[i]:
    a=a+1
print(a)
Problem p02934 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
b=0
for i in range(N):
  b=b+1/A[i]
print(1/b)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
b=0
for i in range(N):
  b=b+1/A[i]
print 1/b

Buggy submission (verdict: Runtime Error):
N=int(input())
A=input()
b=0
for i in range(N):
  b=b+1/A[i]
print 1/b

Buggy submission (verdict: Runtime Error):
N=int(input())
A=map(int,input().split())
b=0
for i in range(N):
  b=b+1/A[i]
print 1/b
Problem p02945 (python)

Fixed submission:
a,b=map(int,input().split())
c=[a+b,a-b,a*b]
c.sort()
print(c[2])

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
c=[a+b,a-b,a*b]
c.sort()
print(c[3])
Problem p02958 (python)

Fixed submission:
N=int(input())
list1=list(map(int,input().split()))
list2=[]
for i in range(1,N):
  list2.append(i)
a=0
for j in range(0,N-1):
  if not list1[j]==list2[j]:
    a+=1
if a>2:
  print("NO")
else:
  print("YES")

Buggy submission (verdict: Runtime Error):
N=int(input())
list1=list(map(int,input().split()))
list2=[]
for i in range(1,N):
  list2.append(i)
a=N
for j in range(0,N-1):
  if list1[j]==list[j]:
    a=a-1
if a>2:
  print("NO")
else:
  print("YES")
Problem p03292 (python)

Fixed submission:
A=list(map(int,input().split(' ')))
A.sort()
cost=A[1]-A[0]
cost+=A[2]-A[1]
print(cost)

Buggy submission (verdict: Runtime Error):
moji_S=input()
moji_T=input()

flag=0
for i in range(len(moji_S)):
	if moji_S==moji_T:
		flag =1
		break
	moji_S=moji_S[-1]+moji_S[0:-1]
if flag:
	print("Yes")
else:
	print("No")
Problem p03293 (python)

Fixed submission:
#! python3

moji_S=input()
moji_T=input()

flag=0
for i in range(len(moji_S)):
	if moji_S==moji_T:
		flag =1
		break
	moji_S=moji_S[-1]+moji_S[0:-1]
if flag:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
moji_S=input()
moji_T=input()

flag=0
for i in range(len(moji_S)):
	if moji_S==moji_T:
		flag =1
		break
	s=s[-1]+s[0:len-1]
if flag:
	print("Yes")
else:
	print("No")
Problem p02918 (python)

Fixed submission:
#D-Face Produces Unhappiness
N, K = map(int, input().split())
S = str(input())

def count_LRorRL(l):
    ans = 0
    l_index = [l[i]+l[i+1] for i in range(0,N-1)]
    ans += l_index.count('LR')
    ans += l_index.count('RL')
    return ans

def count_LLorRR(l):
    ans = 0
    l_index = [l[i]+l[i+1] for i in range(0,N-1)]
    ans += l_index.count('LL')
    ans += l_index.count('RR')
    return ans
  
if count_LRorRL(S) > 2*K:
    print(count_LLorRR(S)+2*K)
else:
    print(count_LLorRR(S)+count_LRorRL(S))

Buggy submission (verdict: Runtime Error):
#D-Face Produces Unhappiness
N, K = map(int, input().split())
S = str(input())
l_index = [l[i]+l[i+1] for i in range(0,N-1)]

count_LRorRL =0
count_LRorRL += S.count('LR')
count_LRorRL += S.count('RL')

count_LLorRR = 0
count_LLorRR += S.count('LL')
count_LLorRR += S.count('RR')

if count_LRorRL > 2*K:
    print(count_LLorRR+2*K)
else:
    print(count_LLorRR+count_LRorRL)
Problem p03068 (python)

Fixed submission:
input()
B = input()
k = int(input())
for v in B:
    print(v if B[k-1] == v else "*",end="")

Buggy submission (verdict: Runtime Error):
input()
B = input()
k = int(input())
for v in B:
    print(B if k[k-1] == B else "*",end="")

Buggy submission (verdict: Runtime Error):
A = int(input())
B = input()
k = int(input())
for v in B:
    print(B if k[k-1] == B else "*",end="")

Buggy submission (verdict: Runtime Error):
A = int(input())
B = input()
k = int(input())
for v in B:
    print(B if k[k-1] == B else "*")
Problem p03085 (python)

Fixed submission:
a = input()
print("T" if a == "A" else "A" if a == "T" else "G" if a == "C" else "C")

Buggy submission (verdict: Runtime Error):
a = int(input())
print("T" if a == "A" else "A" if a == "T" else "G" if a == "C" else "C")
Problem p03145 (python)

Fixed submission:
a,b,c = map(int,input().split())
print(a*b//2)

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

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

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input(),split())
print(a*b/2)
Problem p03243 (python)

Fixed submission:
a = int(input())
print((((a-1)//111)+1)*111)

Buggy submission (verdict: Runtime Error):
a = input()
print((((a-1)//111)+1)*111)
Problem p03280 (python)

Fixed submission:
a,b = map(int,input().split())
print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
a,b = map(int(input().split()))
print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
a,b = map(int(input().split()))
print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
a,b = map(int(input()).split())
print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
a,b = map(int(input()).split())
print((a-1)*(b-1))
Problem p03447 (python)

Fixed submission:
x,a,b = [int(input()) for i in range(3)]
print((x-a)%b)

Buggy submission (verdict: Runtime Error):
x,a,b = [int(input) for i in range(3)]
print((x-a)%b)
Problem p03486 (python)

Fixed submission:
print("Yes" if sorted((input())) < sorted((input()))[::-1] else "No")

Buggy submission (verdict: Runtime Error):
print("Yes" if sorted(int(input())) < sorted(int(input()))[::-1] else "No")
Problem p03729 (python)

Fixed submission:
a,b,c = input().split()
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")
Problem p04043 (python)

Fixed submission:
n = input().split()
print("YES" if n.count("5") ==2 and n.count("7") == 1 else "NO")

Buggy submission (verdict: Runtime Error):
n = input().split()
print("YES") if n.count("5") ==2 and n.count("7") == 1 else "NO")
Problem p04044 (python)

Fixed submission:
N,L = map(int,input().split())
S = sorted([input() for i in range(N)])
print(*S,sep = "")

Buggy submission (verdict: Runtime Error):
N,L = map(int,input().split())
S = sorted([input() for i in range(n)])
print(*s,sep = "")
Problem p03068 (python)

Fixed submission:
N = input()
S = input()
K = input()

char = S[int(K)-1]

#print(char)

ans = []

for j in range(len(S)):
  #print(S[j])
  if char != S[j]:
    ans.append("*")
    #print("!=")   
  else:
    ans.append(char)
    continue

print("".join(ans))

Buggy submission (verdict: Runtime Error):
N = input()
S = input()
K = input()

char = S[int(K)-1]

#print(char)

ans = []

for j in range(len(S)):
  #print(S[j])
  if char != S[j]:
    #print(S[j])
    S_t =S.replace(S[j], "*")
    #print(S_t)
    #print("!=") 
    S = S_t 
  else:
    #ans.append(char)
    continue

#print(" ".join(ans))
print(S_t)
Problem p03544 (python)

Fixed submission:
N = int(input())
L0 = 2
L1 = 1
if N == 1:
  	ans = 1

else:
	for i in range(N-1):
		ans = L0 + L1
		L0 = L1
		L1 = ans
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
L0 = 2
L1 = 1
for i in range(N-1):
  ans = L0 + L1
  L0 = L1
  L1 = ans
  
print(ans)
Problem p03659 (python)

Fixed submission:
N = int(input())
l = list(map(int,input().split()))
ans = 100000000000000
x = 0
S = sum(l)
for i in range(N-1):
  #print("l["+str(i)+"]="+str(l[0]))
  x = x + l[i]
  #print(x,S-x)
  ans = min(ans, abs(x - (S - x)))
  #print(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
l = list(map(int,input().split()))
ans = 100000000000000
S = sum(l)
for i in range(N):
  x = x - l[i]
  ans = min(ans, abs(x - (S - x)))
 
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
l = list(map(int,input().split()))
ans = 100000000000000
s = sum(l)
for i in range(N):
  x = x - l[i]
  ans = min(ans, abs(x - (S - x)))
 
print(ans)
Problem p03721 (python)

Fixed submission:
N,K = list(map(int,input().split()))
l = [0]*(10**5+1)
for i in range(N):
  a, b = list(map(int,input().split()))
  l[a] += b 
  
for j in range(1,int(len(l))+2):
  if K > l[j]:
    K -= l[j]
  else:
    print(j)
    break

Buggy submission (verdict: Runtime Error):
N,K = list(map(int,input().split()))
l = [0]*(10**5+1)
for i in range(N):
  a, b = list(map(int,input().split()))
  l[a] += b 
  
for j in range(1,int(len(l))+1):
  if K >= l[j]:
    K -= l[j]
  else:
    print(j)
    break
Problem p02947 (python)

Fixed submission:
from collections import Counter
from collections import defaultdict
import math

def combination(n, r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

N = int(input())
L = defaultdict(int)
ans = 0
for _ in range(N):
    s = sorted(list(input()))
    L[str(s)] += 1

for c in L.values():
    if c > 1:
        ans += combination(c, 2)
print(ans)

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

def combination(n, r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

N = int(input())
L = defaultdict(int)
ans = 0
for _ in range(N):
    s = sorted(list(input()))
    L[s] += 1

for c in L.items():
    ans += combination(c, 2)
print(ans)

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

def combination(n, r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

N = int(input())
L = defaultdict(int)
ans = 0
for _ in range(N):
    s = sorted(list(input()))
    L[s] += 1

for c in L.items():
    ans += combination(c)
print(ans)
Problem p03032 (python)

Fixed submission:
from collections import deque

N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
O = min(N, K)
for i in range(O+1):
    for j in range(O-i+1):
        if i + j > O:
            break
        DV = deque(V)
        S = 0
        nums = []
        for _ in range(i):
            nums.append(DV.popleft())
        for _ in range(j):
            nums.append(DV.pop())
        nums.sort()
        S = sum(nums)
        for n in range(min(K-i-j, len(nums))):
            if nums[n] >= 0:
                break
            S -= nums[n]
        ans = max(ans, S)
print(ans)

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

N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
O = min(N, K)
for i in range(O+1):
    for j in range(O-i+1):
        if i + j > O:
            break
        DV = deque(V)
        S = 0
        nums = []
        for _ in range(i):
            nums.append(DV.popleft())
        for _ in range(j):
            nums.append(DV.pop())
        nums.sort()
        for n in range(min(K-i-j, len(nums))):
            if nums[n] >= 0:
                break
            del nums[n]
        ans = max(ans, sum(nums))
print(ans)
Problem p03050 (python)

Fixed submission:
import math

N = int(input())
ans = 0
ms = set()
sqi = math.sqrt(N)
for i in range(1, int(sqi)+1):
    if N % i == 0:
        ms.add(i-1)
        ms.add(N//i-1)
for m in ms:
    if m <= 0:
        continue
    if N//m == N%m:
        ans += m
print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
ans = 0
sqi = math.sqrt(N)
for i in range(1, int(sqi)+1):
    if (N-i)%i == 0:
        m = (N-i)//i
        if N//m == N%m:
        	ans += (N-i)//i
print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
ans = 0
sqi = math.sqrt(N)
for i in range(1, int(sqi)+1):
    if (N-i)%i == 0:
        m = (N-1)//i
        if N//m == N%m:
        	ans += (N-i)//i
print(ans)
Problem p03068 (python)

Fixed submission:
N = int(input())
S = input()
K = int(input())

for i in range(N):
    if i == K-1:
        continue
    if S[i] != S[K-1]:
        S = S[:i] + '*' + S[i+1:]

print(S)

Buggy submission (verdict: Runtime Error):
9
education
7
Problem p03089 (python)

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

a = []
n = N
while len(b):
    index = -1
    for i in range(n):
        if i+1 == b[i]:
            index = i
    if index > -1:
        a.insert(0, b.pop(index))
        n -= 1
    elif index == -1:
        print(index)
        quit()

for e in a:
    print(e)

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

a = []
index = -1
n = N
while len(b):
    for i in range(n):
        if i+1 == b[i]:
            index = i
    if index > -1:
        a.insert(0, b.pop(index))
        n -= 1

if len(a):
    for e in a:
        print(e)
else:
    print(index)