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

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
counter = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                counter += 1
print(counter)

Buggy submission (verdict: Runtime Error):
a,b,c,x = input().strip().split()
a,b,c,x = [int(a),int(b),int(c),int(x)]
counter = 0

for i in range(a+1):
    #if 500*i > x:
        #break
    for j in range(b+1):
        #if 500*i+100*j > x:
            #break
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                counter += 1
print(counter)

Buggy submission (verdict: Runtime Error):
a,b,c,x = input().strip().split()
a,b,c,x = [int(a),int(b),int(c),int(x)]
counter = 0

for i in range(a+1):
    if 500*i > x:
        break
    for j in range(b+1):
        if 500*i+100*j > x:
            break
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                counter += 1
print(counter)
Problem p03478 (python)

Fixed submission:
n,a,b = input().strip().split()
n,a,b = [int(n),int(a),int(b)]
sum = 0

for i in range(1,n+1):
    if a<=(i//10000 + i//1000%10 + i//100%10 + i//10%10 + i%10)<=b:
        sum += i
print(sum)

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

for i in range(1,n+1):
    if a<=(i//10000 + i//1000%10 + i//100%10 + i//10%10 + i%10)<=b:
        sum += i
print(sum)
Problem p04043 (python)

Fixed submission:
a,b,c = list(map(int,input().split()))
if(a + b + c)==17:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c = int(input(),input(),input()).split()
if(a + b + c)==17:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
if(a + b + c)==17:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
if (a + b + c)==(5+7+5):
  print("YES")
else:
  print("NO")
Problem p02756 (python)

Fixed submission:
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()
S = deque(input())
rev = False
apdlft = S.appendleft
apd = S.append

for _ in range(int(input())):
    q = input().split()
    if q[0] == '1':
        rev = not(rev)
    else:
        if (q[1]=='1' and rev is False) or (q[1]=='2' and rev is True):
            apdlft(q[2])
        else:
            apd(q[2])

if rev:
    print((''.join(S))[::-1])
else:
    print(''.join(S))

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()
S = deque(input())
Q = int(input())
rev = False

for _ in range(Q):
    q = input().split()
    if q[0] == '1':
        rev = not(rev)
    else:
        if (q[1]=='1' and rev is False) or (q[1]=='2' and rev is True):
            S.appendleft(q[2])
        else:
            S.append(q[2])

for i in (range(len(S)) if rev is False: else reversed(range(len(S)))):
    print(S[i], end="")
else:
    print("")

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.buffer.readline().rstrip()
S = input()
Q = int(input())
qs = list(input() for _ in range(Q))
rev = False
for q in qs:
    q = q.split()
    if q[0] == '1':
        rev = not(rev)
    else:
        if (q[1]=='1' and rev is False) or (q[1]=='2' and rev is True):
            S = q[2] + S
        else:
            S = S + q[2]
print(S if rev == 0 else S[::-1])
Problem p02765 (python)

Fixed submission:
N, R_disp = map(int, input().split())
print(R_disp + 100 * (10 - N) if N < 10 else R_disp)

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

m = min(X)
M = max(X)

min_val = 100 * 100 * 100 * 100
for p in range(m, M+1):
    score = 0
    for x in X:
         score += (x-p)*(x-p)
    if score < min_val: min_val = score
print(min_val)
Problem p02786 (python)

Fixed submission:
import math
H = int(input())
cnt = 0
n = math.floor(math.log2(H))
ans = 0
for i in range(n+1):
    cnt += int(math.pow(2,i))
print(cnt)

Buggy submission (verdict: Runtime Error):
H = int(input())
cnt = 0
n = math.floor(math.log2(H))
ans = 0
for i in range(n+1):
    cnt += int(math.pow(2,i))
print(cnt)
Problem p02714 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from numba import njit
 
MOD = 10**9 + 7
 
N = int(readline())
S = np.array(list(read().rstrip()), np.int8)
 
R = np.sum(S == ord('R'))
B = np.sum(S == ord('B'))
G = np.sum(S == ord('G'))
 
@njit
def f(S):
    N = len(S)
    ret = 0
    for i in range(N):
        for j in range(i + 1, N):
            k = j + j - i
            if k >= N:
                break
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                ret += 1
    return ret
 
answer = R * B * G - f(S)
print(answer)

Buggy submission (verdict: Runtime Error):
mport sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from numba import njit
 
MOD = 10**9 + 7
 
N = int(readline())
S = np.array(list(read().rstrip()), np.int8)
 
R = np.sum(S == ord('R'))
B = np.sum(S == ord('B'))
G = np.sum(S == ord('G'))
 
@njit
def f(S):
    N = len(S)
    ret = 0
    for i in range(N):
        for j in range(i + 1, N):
            k = j + j - i
            if k >= N:
                break
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                ret += 1
    return ret
 
answer = R * B * G - f(S)
print(answer)
Problem p02911 (python)

Fixed submission:
import itertools
##print(ord("A"))
#n = int(input())
n,k,q = map(int,input().split())
#h = list(map(int,input().split()))	
ans_list=[input() for i in range(q)]
pnt_list = [k-q]*n
#print(pnt_list)
for i in range(q):

    pnt_list[int(ans_list[i])-1]+=1
#print(pnt_list)
for i in range(len(pnt_list)):
    if pnt_list[i]>0:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
import itertools
##print(ord("A"))
#n = int(input())
n,k,q = map(int,input().split())
#h = list(map(int,input().split()))	
ans_list=[input() for i in range(q)]
pnt_list = [k-q]*n
#print(pnt_list)
for i in range(q):

    pnt_list[int(ans_list[i])]+=1
#print(pnt_list)
for i in range(len(pnt_list)):
    if pnt_list[i]>0:
        print("Yes")
    else:
        print("No")
"""
for i in range(q):
    #print(pnt_list)
    for j in range(n):
    
        if ans_list[i]==str(j+1):
            pass
        else:
            pnt_list[j]=pnt_list[j]-1
for i in range(len(pnt_list)):
    if pnt_list[i]>0:
        print("Yes")
    else:
        print("No")
#print(pnt_list)
"""
Problem p02971 (python)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
maxi = max(a)
s = sorted(a,reverse=True)

for i in range(n):
    if a[i] != maxi:
        print(maxi)
    else:
        print(s[1])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
maxi = max(a)
for i in range(n):
    if a[i] != maxi:
        print(maxi)
    else:
        b = a.pop(a[i])
        print(max(a))
Problem p02995 (python)

Fixed submission:

import fractions
a,b,c,d = map(int,input().split())	
lcm = c * d // fractions.gcd(c, d)
#print(lcm)
def divisor(x):
	
	x_c = x//c
	x_d = x//d
	#print(x_c,x_d)
	x_lcm = x//lcm
	#print(x_c,x_d,x_lcm)
	return x-x_c-x_d+x_lcm
#print(divisor(b),divisor(a))
ans = divisor(b)-divisor(a-1)
print(ans)

Buggy submission (verdict: Runtime Error):

import fractions
a,b,c,d = map(int,input().split())	
lcm = c * d // fractions.gcd(c, d)
#print(lcm)
def divisor(x):
	
	x_c = fractions.floor(x/c)
	x_d = fractions.floor(x/d)
	#print(x_c,x_d)
	x_lcm = fractions.floor(x/lcm)
	#print(x_c,x_d,x_lcm)
	return x-x_c-x_d+x_lcm
#print(divisor(b),divisor(a))
ans = divisor(b)-divisor(a-1)
print(ans)

Buggy submission (verdict: Runtime Error):

import math
a,b,c,d = map(int,input().split())	
lcm = c * d // math.gcd(c, d)
#print(lcm)
def divisor(x):
	
	x_c = math.floor(x/c)
	x_d = math.floor(x/d)
	#print(x_c,x_d)
	x_lcm = math.floor(x/lcm)
	#print(x_c,x_d,x_lcm)
	return x-x_c-x_d+x_lcm
#print(divisor(b),divisor(a))
ans = divisor(b)-divisor(a-1)
print(ans)

Buggy submission (verdict: Runtime Error):
import statistics
import math
a,b,c,d = map(int,input().split())	
lcm = c * d // math.gcd(c, d)
#print(lcm)
def divisor(x):
	
	x_c = math.floor(x/c)
	x_d = math.floor(x/d)
	#print(x_c,x_d)
	x_lcm = math.floor(x/lcm)
	#print(x_c,x_d,x_lcm)
	return x-x_c-x_d+x_lcm
#print(divisor(b),divisor(a))
ans = divisor(b)-divisor(a-1)
print(ans)

Buggy submission (verdict: Runtime Error):
import statistics
import math
a,b,c,d = map(int,input().split())	
lcm = c * d // math.gcd(c, d)
#print(lcm)
def divisor(x):
	
	x_c = math.floor(x/c)
	x_d = math.floor(x/d)
	#print(x_c,x_d)
	x_lcm = math.floor(x/lcm)
	#print(x_c,x_d,x_lcm)
	return x-x_c-x_d+x_lcm
#print(divisor(b),divisor(a))
ans = divisor(b)-divisor(a-1)
print(ans)
Problem p02848 (python)

Fixed submission:
N = int(input())
S = input()
Answer_list = []
for i in list(S):
    num = ord(i)+N
    if num >= 65 and num <= 90:
        Answer_list.append(chr(num))
    elif num > 90:
        Answer_list.append(chr(num - 26))
print(''.join(Answer_list))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
Answer_list = []

for i in list(S):
    num = ord(i)+N
    if num >= 65 || num =< 90:
        Answer_list.append(chr(num))
    elif num < 90:
        Answer_list.append(chr(num - 26)        
print(''.join(Answer_list))
Problem p02945 (python)

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

Buggy submission (verdict: Runtime Error):

from collections import Counter

n = int(input())
s =  Counter("".join(sorted(input())) for i in range(n))

print(sum(map(lambda x : x * (x - 1) // 2, s.values())))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
s = Counter(''.join(sorted(input())) for i in range(n))#文字列をsortedした時点でlistになる
print(sum(map(lambda x : x * (x-1) // 2, s.values())))
Problem p02947 (python)

Fixed submission:
from collections import Counter

n = int(input())
s =  Counter("".join(sorted(input())) for i in range(n))

print(sum(map(lambda x : x * (x - 1) // 2, s.values())))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
s = [sorted([*input()]) for i in range(n)] #[*(hogehoge)]で一文字ずつのリストに！
s2 = [''.join(s[i]) for i in range(n)] #sortのために一文字ごとに区切ってリストのにしたものを一単語に連結
s3 = Counter(s2[i] for i in range(n))#同じものを計数
#print(s2)
#print(s3)
#print(s3.values())

print(sum(map(lambda x : x*(x-1)//2, s3.values())))#lambda式は便利

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [sorted([*input()]) for k in range(n)] #[*(hogehoge)]で一文字ずつのリストに！
count=0
for i in range(n-1):
    for j in range(i+1,n):
        if s[i] == s[j]:
            count += 1
print(count)
Problem p02994 (python)

Fixed submission:
n,l=map(int,input().split())
taste=[]
all_taste = 0
for i in range(n):
    taste.append(l+i)
    all_taste += taste[i]
if taste[0] > 0:
    print(all_taste - taste[0])
    exit()
elif taste[n-1] < 0:
    print(all_taste - taste[n-1])
    exit()
else:
    print(all_taste)

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
taste=[]
all_taste = 0
for i in range(n):
    taste.append(l+i)
    all_taste += taste[i]
if taste[0] > 0 and taste[n-1] > 0:
    print(all_taste - tasete[0])
    exit()
elif taste[0] < 0 and taste[n-1] < 0:
    print(all_taste - taste[n-1])
    exit()
else:
    print(all_taste)
Problem p03059 (python)

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

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

n=int(input())
a=[0] + list(map(int,input().split())) + [0]#a[n+1]=0とするため

l=[0]*(n+2)
r=[0]*(n+2)#r[n+1]=0としたいから
for i in range(1,n+1):
    l[i] = gcd(l[i-1],a[i])
for i in range(n,0,-1):
    r[i] = gcd(r[i+1],a[i])

z=[gcd(l[i-1],r[i+1]) for i in range(1,n+1)]

print(max(z))
Problem p03071 (python)

Fixed submission:
a,b = map(int,input().split())
if a != b:
    ans = max(a,b) + max(a,b) - 1
else:
    ans = a*2
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a != b:
    ans = max(a,b) + max(a,b) - 1
else:
    ans = a*2:
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())
if a != b:
    ans = max(a,b) + max(a,b) - 1
else:
    ans = a*2:
print(ans)
Problem p03076 (python)

Fixed submission:
a=list(int(input()) for i in range(5))

b=[-(-a[i]//10)*10 for i in range(5)]
c=[a[i]%10 for i in range(5) if a[i]%10 != 0]

if c != []:
    print(sum(b) + min(c) -10)
else:
    print(sum(b))

Buggy submission (verdict: Runtime Error):
a=list(int(input()) for i in range(5))

b=[-(-a[i]//10)*10 for i in range(5)]
c=[a[i]%10 for i in range(5) if a[i]%10 != 0]

print(sum(b) + min(c) -10)

Buggy submission (verdict: Runtime Error):
a=list(int(input()) for i in range(5))

b=[-(-a[i]//10)*10 for i in range(5)]
c=[a[i]%10 for i in range(5) if a[i]%10 != 0]
print(b)

print(sum(b) + min(c) -10)
Problem p03455 (python)

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

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

Fixed submission:
a,b,c = map(int,input().split())
print("YES" if b-a == c-b else "NO")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input.split())
print("YES" if b-a == c-b else "NO")
Problem p02812 (python)

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

print(s.count('ABC'))

Buggy submission (verdict: Runtime Error):
n,s=input().split()

print(s.count('ABC'))
Problem p02900 (python)

Fixed submission:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
import logging
import heapq
logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)

MOD = 10**9+7

def main():
    A,B=[int(x) for x in input().split()]

    max_gcd=gcd([A,B])
    P=prime_factor(max_gcd)
    P2=set(P)
    print(len(P2)+1)

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass #sortされていない

def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

main()

Buggy submission (verdict: Runtime Error):
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
import logging
import heapq
logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)

MOD = 10**9+7

def main():
    A,B=[int(x) for x in input().split()]

    max_gcd=gcd([A,B])
    P=primes(max_gcd)
    ans=1 # 1
    for p in P:
        if A%p==0 and B%p==0:
            ans+=1
    print(ans)

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

main()
Problem p02909 (python)

Fixed submission:
S=input()
if S=="Sunny":
    print("Cloudy")
elif S=="Cloudy":
    print("Rainy")
elif S=="Rainy":
    print("Sunny")

Buggy submission (verdict: Runtime Error):
S=input()
if S=="Sunny":
    print("Cloudy")
elif S=="Cloudy":
    print(Rainy)
elif S=="Rainy":
    print(Sunny)
Problem p02924 (python)

Fixed submission:
N=int(input())
print(N*(N-1)//2)

Buggy submission (verdict: Runtime Error):
N=int(input())
l=list(range(1,N))
s=[0]*N
for i in range(N-1):
    s[i+1]=s[i]+l[i]
print(s[N-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
l1=list(range(1,N+1))
#l2=sorted(l1,reverse=True)
l2=list(range(2,N+1))
l2.append(1)
M=0
for i in range(N):
    M+=l1[i]%l2[i]
print(M)
Problem p02936 (python)

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

# 隣接グラフ
to=[[] for i in range(n)] 
ans=[0 for i in range(n)]


# 深さ優先探索(再帰)
def dfs(v, p=-1):
    global ans
    for u in to[v]:
        if u==p:
            continue
        ans[u]+=ans[v]
        dfs(u,v)

# 深さ優先探索(ループ)
def dfs2():
    global ans
    queue=list()
    visit=dict()

    queue.append(0)
    for v in queue:
        visit.setdefault(v,True)
        for u in to[v]:
            if u in visit:
                continue
            ans[u]+=ans[v]
            queue.append(u)

# 隣接グラフ作成
for _ in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    to[a].append(b)
    to[b].append(a)

for _ in range(q):
    p,x=map(int,input().split())
    p-=1
    ans[p]+=x

#dfs(0)
dfs2()

for i in ans:
    print(i)

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

# 隣接グラフ
to=[[] for i in range(n)] 
ans=[0 for i in range(n)]

# 深さ優先探索
def dfs(v, p=-1):
    global to,ans
    for u in to[v]:
        if u==p:
            continue
        ans[u]+=ans[v]
        dfs(u,v)

# 隣接グラフ作成
for _ in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    to[a].append(b)
    to[b].append(a)

for _ in range(q):
    p,x=map(int,input().split())
    p-=1
    ans[p]+=x

dfs(0)

for i in ans:
    print(i)
Problem p02945 (python)

Fixed submission:
a, b = map(int, input().split())
plus = a + b
minus = a - b
mult = a * b
ans = max(plus, minus)
ans = max(ans, mult)
print(ans)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
plus = a + b
minus = a - b
mult = a * b
ans = max(plus, minus)
ans = max(ans, mult)
print ans
Problem p02947 (python)

Fixed submission:
n = int(input())
i = 0
sortedSet = {}
while i < n:
    temp = ''.join(sorted(input()))

    if temp in sortedSet:
        sortedSet[temp]+=1
    else:
        sortedSet[temp]=1
    i += 1

result = 0
for v in sortedSet.values():
    result = int(result + v*(v-1)/2)

print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [input() for i in range(n)]

mylist = []
for s in l:
    s_list = [ c for c in s]
    mylist.append("".join(sorted(s_list)))

ans=0
for i in range(len(mylist)):
    print(mylist)
    ans += mylist.count(mylist[0]) - 1
    del mylist[0]

print(ans)
Problem p03146 (python)

Fixed submission:
M=1000005
s=int(input())

def f(n,i):
    if i==1:
        return s

    if n%2==0:
        return n//2
    else:
        return 3*n+1

A={}
n=0
for i in range(1,M):
    n=f(n,i)
    A.setdefault(i,n)
    for j in range(1,i):
        if A[j]==A[i]:
            print(i)
            exit()

Buggy submission (verdict: Runtime Error):
M=1000005
s=int(input())

def f(n,i):
    if i==1:
        return s

    if n%2==0:
        return n//2
    else:
        return 3*n+1

A={}
n=0
for i in range(1,M):
    n=f(n,i)
    A.setdefault(i,n)
    for j in range(1,i):
        if A[j]==A[i]:
            print(i)
            return
Problem p02774 (python)

Fixed submission:
import numpy as np
import sys

n,k=map(int,sys.stdin.readline().split())
a=np.array(sys.stdin.readline().split(),dtype=np.int64)

a.sort()
neg=a[a<0]
zero=a[a==0]
pos=a[a>0]

def count(x):
    cnt=0
    if x>=0:
        cnt+=len(zero)*n
    cnt+=np.searchsorted(a,x//pos,side='right').sum()
    cnt+=(n-np.searchsorted(a,(-x-1)//(-neg),side='right')).sum()
    cnt-=np.count_nonzero(a*a<=x)
    return cnt//2


left=-10**18
right=10**18

while left+1<right:
    x=(left+right)//2
    out=count(x)
    if out>=k:
        right=x
    if out<k:
        left=x

print(right)

Buggy submission (verdict: Runtime Error):
import sys

n=sys.stdin.readline().rstrip()[::-1]
to=0
num=len(n)
m=0

for i in range(num):
    k=int(n[i])
    k+=m
    if k==5:
        if int(n[i+1])>=5:
            to+=10-k
            m=1
        else:
            to+=k
            m=0
    if k<5:
        to+=k
        m=0
    elif k>5:
        to+=10-k
        m=1
        if i==num-1:
            to+=1
        
print(to)

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

n,k,*a=map(int,sys.stdin.readlines().split())
a=np.array(a,dtype=np.int64)

print(n,k,a)

a.sort()
neg=a[a<0]
zero=a[a==0]
pos=a[a>0]

print(np.searchsorted(a,0//pos,side='right').sum())

def count(x):
    cnt=0
    if x>=0:
        cnt+=len(zero)
    cnt+=np.searchsorted(a,x//pos,side='right').sum()
    cnt+=(n-np.searchsorted(a,(-x-1)//(-neg),side='right')).sum()
    cnt-=np.count_nonzero(a*a<=x)
    return cnt//2


left=-10**18
right=10**18

while left+1<right:
    x=(left+right)//2
    cnt=count(x)
    if cnt>=k:
        right=x
    if cnt<k:
        left=x

print(right)
Problem p02775 (python)

Fixed submission:
import sys

n=sys.stdin.readline().rstrip()[::-1]
to=0

m=0
n+="0"
num=len(n)

for i in range(num):
    k=int(n[i])
    k+=m
    if k==5:
        if int(n[i+1])>=5:
            to+=10-k
            m=1
        else:
            to+=k
            m=0
    if k<5:
        to+=k
        m=0
    elif k>5:
        to+=10-k
        m=1
        
print(to+m)

Buggy submission (verdict: Runtime Error):
import sys

n=sys.stdin.readline().rstrip()[::-1]
to=0
num=len(n)
m=0

for i in range(num):
    k=int(n[i])
    k+=m
    if k==5:
        if int(n[i+1])>=5:
            to+=10-k
            m=1
        else:
            to+=k
            m=0
    if k<5:
        to+=k
        m=0
    elif k>5:
        to+=10-k
        m=1
        
print(to+m)

Buggy submission (verdict: Runtime Error):
import sys

n=sys.stdin.readline().rstrip()[::-1]
to=0
num=len(n)
m=0

for i in range(num):
    k=int(n[i])
    k+=m
    if k==5:
        if int(n[i+1])>=5:
            to+=10-k
            m=1
        else:
            to+=k
            m=0
    if k<5:
        to+=k
        m=0
    elif k>5:
        to+=10-k
        m=1
        if i==num-1:
            to+=1
        
print(to)

Buggy submission (verdict: Runtime Error):
import sys

n=sys.stdin.readline().rstrip()[::-1]
to=0
num=len(n)
m=0
print(n)

for i in range(num):
    k=int(n[i])
    k+=m
    if k==5:
        if int(n[i+1])>=5:
            to+=10-k
            m=1
        else:
            to+=k
            m=0
    if k<5:
        to+=k
        m=0
    elif k>5:
        to+=10-k
        m=1
        if i==num-1:
            to+=1
        
print(to)
Problem p02801 (python)

Fixed submission:
c=input()
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
print(l[l.index(c)+1])

Buggy submission (verdict: Runtime Error):
c=input()
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
print(l[l.index(c)+1]
Problem p02811 (python)

Fixed submission:
K,X=input().split()
if int(K)*500>=int(X):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
K=input()
X=input()
if int(K)*500>=int(X):
    print('Yes')
else:
    print('No')