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

Fixed submission:

import numpy as np

def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    A = np.array(A)
    A.sort()
    zero = np.count_nonzero(A==0)
    positive = A[A>0]
    negative = A[A<0]
    def count(x): # 積がx以下になるペアの個数を返す
        ans = 0
        if x >= 0:
            ans += N*zero
        ans += np.searchsorted(A, x//positive, side="right").sum()
        ans += N*len(negative) - np.searchsorted(A, -(-x//negative), side="left").sum()
        ans -= np.count_nonzero(A*A <= x) # 同じものはふたつ選べない
        return ans//2
    ok = 10**18
    ng = -ok-1
    while ok-ng>1:
        cur = (ok+ng)//2
        if count(cur)>=K:
            ok = cur
        else:
            ng = cur
    print(int(ok))


    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):

import numpy as np

def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    A = np.array(A)
    A.sort()
    zero = np.count_nonzero(A==0)
    positive = A[A>0]
    negative = A[A<0]
    def count(x): # 積がx以下になるペアの個数を返す
        ans = 0
        if x >= 0:
            ans += N*zero
        ans += np.searchsorted(A, x//positive, side="right").sum()
        ans += N*len(negative) - np.searchsorted(A, -(-x//negative), side="left").sum()
        ans -= np.count_nonzero(A*A <= x) # 同じものはふたつ選べない
        return ans//2
    ok = 10**8
    ng = -ok-1
    while ok-ng>1:
        cur = (ok+ng)//2
        if count(cur)>=K:
            ok = cur
        else:
            ng = cur
    print(int(ok))


    
if __name__ == "__main__":
    main()
Problem p02775 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    # dp:=上からi桁目まで払える最小の枚数
    S = list(map(int, '0'+input()))
    l = len(S)
    dp = [[1e18]*2 for _ in range(1001001)]
    dp[0][0]=0
    for i in range(l):
        k = S[i]
        dp[i+1][0] = min(dp[i+1][0], dp[i][0]+k)
        dp[i+1][1] = min(dp[i+1][1], dp[i][0]+k+1)
        dp[i+1][0] = min(dp[i+1][0], dp[i][1]+10-k)
        dp[i+1][1] = min(dp[i+1][1], dp[i][1]+10-k-1)
    print(dp[l][0])

    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from itertools import combinations
from bisect import bisect_left
import sys
sys.setrecursionlimit(10 ** 6)
 

def main():
    # dp:=上からi桁目まで払える最小の枚数
    S = list(map(int, input()))
    l = len(S)
    dp = [[1e18]*2 for _ in range(10**6)]
    dp[0][0]=0
    for i in range(l):
        k = int(S[i])
        dp[i+1][0] = min(dp[i+1][0], dp[i][0]+k)
        dp[i+1][1] = min(dp[i+1][1], dp[i][0]+k+1)
        dp[i+1][0] = min(dp[i+1][0], dp[i][1]+10-k)
        dp[i+1][1] = min(dp[i+1][1], dp[i][1]+10-k-1)
    print(dp[l][0])

    
if __name__ == "__main__":
    main()
Problem p02960 (python)

Fixed submission:
INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

print(dp[len(S)][5])

Buggy submission (verdict: Runtime Error):
MOD = 10**9+7
# dp[i][j] := Sの後ろからi桁を13で割った余りがjとなるようなものの個数
S = input()
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
mul = 1  
for i in range(len(S)):
    x = S[-(i+1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= MOD
    else:
        k = int(x) # これしか選ぶ余地なし
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= MOD
    mul = mul * 10 % 13
print(dp[l][5])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

# dp[dgt][mo] := dgt桁目まで確定していて, そこまでで13で割った余りがmoである組み合わせ
# ?であるときは, その数にしかできないため, その数をつかう
# ?であるときは0~9を全て試して遷移させよう
def main():
    S = input()
    l = len(S)
    dp = [[0]*(13) for _ in range(10**5)]
    dp[0][0] = 1
    for dgt in range(l):
        for mo in range(13):
            if S[dgt]=="?":
                for nxt in range(10):
                    dp[dgt+1][(mo * 10 + nxt)%13] += dp[dgt][mo]
            else:
                dp[dgt+1][(mo*10 + int(S[dgt]))%13] += dp[dgt][mo]
    print(dp[l][5]%MOD)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

# dp[dgt][mo] := dgt桁目まで確定していて, そこまでで13で割った余りがmoである組み合わせ
# ?であるときは, その数にしかできないため, その数をつかう
# ?であるときは0~9を全て試して遷移させよう
def main():
    S = input()
    l = len(S)
    dp = [[0]*(13) for _ in range(10**5)]
    dp[0][0] = 1
    for dgt in range(l):
        for mo in range(13):
            if S[dgt]=="?":
                for nxt in range(10):
                    dp[dgt+1][(mo * 10 + nxt)%13] += dp[dgt][mo]
            else:
                dp[dgt+1][(mo*10 + int(S[dgt]))%13] += dp[dgt][mo]
    print(dp[l][5]%MOD)


if __name__ == "__main__":
    main()
Problem p02996 (python)

Fixed submission:
import sys
input = sys.stdin.readline


def main():
    AB = []
    n = int(input())
    for i in range(n):
        a, b = map(int, input().split())
        AB.append([a, b])
    AB = sorted(AB, key=lambda x: (x[1], -x[0]))
    time = 0
    for span, dead in AB:
        time += span
        if time > dead:
            print('No')
            return
    print('Yes')
    return


if __name__ == "__main__":
    main()

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


def main():
    AB = []
    n = int(input())
    for i in range(n):
        a, b = map(int, input().split())
        AB.append([a, b])
    AB = sorted(AB, key=lambda x: (x[1], -x[0]))
    time = 0
    for span, dead in zip(AB):
        time += span
        if time > dead:
            print('No')
            return
    print('Yes')
    return


if __name__ == "__main__":
    main()
Problem p03044 (python)

Fixed submission:
# # ABC126D.py, ATC001A.py などを参照
import sys
sys.setrecursionlimit(1000000)
N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    edge[u-1].append([v-1, w])
    edge[v-1].append([u-1, w])


# 各頂点までの距離をdfsで求める
depth = [-1] * N
depth[0] = 0


def dfs(edge, s):
    for v in edge[s]:
        if depth[v[0]] == -1:  # 未訪問なら更新する
            depth[v[0]] = depth[s] + v[1]
            dfs(edge, v[0])


dfs(edge, 0)
for d in depth:
    if d % 2 == 0:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
# # ABC126D.py, ATC001A.py などを参照

N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    edge[u-1].append([v-1, w])
    edge[v - 1].append([u - 1, w])


# 各頂点までの距離をdfsで求める
depth = [-1] * N
depth[0] = 0


def dfs(edge, s):
    for v in edge[s]:
        if depth[v[0]] == -1:  # 未訪問なら更新する
            depth[v[0]] = depth[s] + v[1]
            dfs(edge, v[0])


dfs(edge, 0)
for d in depth:
    if d % 2 == 0:
        print(0)
    else:
        print(1)
Problem p02778 (python)

Fixed submission:
s = len(input())
print('x' * s)

Buggy submission (verdict: Runtime Error):
s = input()
for i, c in enumerate(s):
  s[i] = 'x'
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
for c, i in enumerate(s):
  s[i] = 'x'
print(s)
Problem p02789 (python)

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

print('Yes') if n == m else print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
count = 0
for i in range(1, n+1 / 2):
  for j in range(1, n+1 / 2):
    if str(i)[0] == str(j)[-1]:
      if str(j)[0] == str(i)[-1]:
        count += 1
        
print(count * 2)
Problem p02817 (python)

Fixed submission:
s, t = input().split()
print(t+s)

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

for i in range(k):
    if a > 0:
        a = a - 1
    elif b > 0:
        b = b - 1

print(a, b)
Problem p03238 (python)

Fixed submission:
n = input()
if(n == 1):
  print "Hello World"
else:
  a = input()
  b = input()
  print a + b

Buggy submission (verdict: Runtime Error):
n = input()
if(n == 1):
  print "Hello World"
else:
  a, b = map(int, raw_input().split())
  print a + b
Problem p02621 (python)

Fixed submission:
a = int(input())
b = a + a ** 2 + a ** 3
print (b)

Buggy submission (verdict: Runtime Error):
a + a ** 2 + a ** 10
Problem p02621 (python)

Fixed submission:
a = int(input())
ans = a*(1+a*(1+a))
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(intput())
ans = a*(1+a*(1+a))
print(ans)
Problem p02621 (python)

Fixed submission:
a = int(input())
ans = a + a**2 + a**3
print(ans)

Buggy submission (verdict: Runtime Error):
a = input()
ans = a + a ^ 2 + a ^ 3
print ans
Problem p02621 (python)

Fixed submission:
input = int(input())
print (input + input ** 2 + input ** 3)

Buggy submission (verdict: Runtime Error):
firstString = input()
secondString = input()
diff = 0
for i in range(len(firstString)):
    if firstString[i] != secondString[i]:
        diff += 1
print(diff)

Buggy submission (verdict: Runtime Error):
input = int(raw_input())
print (input + input ** 2 + input ** 3)
Problem p02621 (python)

Fixed submission:
a = int(input())
print(a+(a*a)+a*a*a)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
count = 0
for i in range(len(s)):
    if(s[i] != t[i]):
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
s = list(map(str,input().split()))
t = list(map(str,input().split()))
count = 0
for i in range(len(s)):
    if(s[i] != t[i]):
        count += 1
print(count)
Problem p02621 (python)

Fixed submission:
a=int(input())
print(a+a**2+a**3)

Buggy submission (verdict: Runtime Error):
a=int(intput())
print(a+a^2+a^3)

Buggy submission (verdict: Runtime Error):
a=int(intput())
a+a^2+a^3
Problem p02658 (python)

Fixed submission:
n=int(input())
a=sorted(list(map(int,input().split())))
ans=1
for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print(-1)
        break
else:
    print(ans)

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

ans = 1
for i in a:
    i = int(i)
    ans = ans * i
    if ans > 10 ** 18:
        ans = '-1'
print(ans)
Problem p02696 (python)

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

x = 0
ans = 0
if n < b:
    x = n
    ans = math.floor(a*x/b) - a * math.floor(x/b)
else:
    x = b - 1
    ans = math.floor(a*x/b) - a * math.floor(x/b)
print(ans)

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

x = 0
ans = 0
if n < b:
    x = n
    ans = math.floor(a*x/b) - a * math.floor(x/b)
else:
    x = n - 1
    ans = math.floor(a*x/b) - a * math.floor(x/b)
print(ans)
Problem p03455 (python)

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

if a*b%2:
    print('Odd')
else:
    print('Even')

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

product = a * b

if product % 2 == 0:
    print('Even')
else:
    print('Odd')
Problem p03478 (python)

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

total = 0
for i in range(n+1):
    wa = sum((map(int, str(i))))
    if a <= wa and wa <= b:
        total += i
print(total)

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

total = 0
for i in range(1, n+1):
    wa = sum((map(int, str(i))))
    if a <= wa and wa <= b:
        total += wa
print(total)
Problem p03493 (python)

Fixed submission:
s = list(input())
print(s.count('1'))

Buggy submission (verdict: Runtime Error):
s1, s2, s3 = map(int, input().split())

list = [s1, s2, s3]
ball = 0

for item in list:
    if item == 1:
        ball += 1

print(ball)
Problem p02639 (python)

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

for i in range(5):
    if X[i] == 0:
        print(i+1)

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

if N == 0:
    print(X)
else:
    for i in range(0,100):
        if i not in P:
            differ.append(abs(X - i))
        else:
            differ.append(1000)
    ans = differ.index(min(differ))
    print(ans)
Problem p02658 (python)

Fixed submission:
N=int(input())
A = [int(i) for i in input().split()]

if 0 in A:
    multiple = 0
else:
    multiple = 1
    for i in range(N):
        multiple = multiple * A[i]
        if multiple > 1000000000000000000:
            multiple = -1
            break

print(multiple)

Buggy submission (verdict: Runtime Error):
N=int(input())
A = [int(i) for i in input().split()]
multiple = 1

for i in range(N):
        if A[i]==0:
        break
    multiple = multiple * A[i]
    if (multiple > 18 ** 10):
        break
    
if multiple > 10 ** 18:
    print(-1)
else:
    print(multiple)
Problem p03493 (python)

Fixed submission:
a = input()

result =0

if a[0]=="1":
	result +=1
if a[1]=="1":
	result +=1
if a[2]=="1":
	result +=1
    
print(result)

Buggy submission (verdict: Runtime Error):
a = int(input())
print(a[0])
Problem p02621 (python)

Fixed submission:
a=int(input())

print(a+a*a+a*a*a)

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

print(a+a*a+a*a*a)
Problem p02969 (python)

Fixed submission:
r = int(input())

print(3*r*r)

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

print(3*r*r)

Buggy submission (verdict: Runtime Error):
r = input()

print(3*r*r)
Problem p02621 (python)

Fixed submission:
a = int(input())

print(round(a*a*a+a*a+a))

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

print(round(a*a*a+a*a+a)
Problem p02675 (python)

Fixed submission:
n=int(input())%10

if n == 3:
    print("bon")
elif n==0 or n==1 or n == 6 or n==8:
    print("pon")
else:
    print("hon")

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

if n == 3:
    print("bon")
elif n==0 or n==1 or n == 6 or n==8:
    print("pon")
else:
    prinh("hon")
Problem p02681 (python)

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

if t.startswith(s):
    print("Yes")
else:
    print("No")

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

r=[]
h=-1
i=0
while i+1 not in r:
    r.append(i+1)
    i = a[i]-1
    h += 1
    if k == h:
        print(i+1)
        sys.exit()
r.append(i+1)

p = r.index(r[len(r)-1])
q = len(r)-1-r.index(r[len(r)-1])
r_q = r[p:p+q]


if k+1<p:
    print(r[k])
else:
    j = (k+1-p)%q
    print(r_q[j-1])
Problem p03698 (python)

Fixed submission:
s = input()
s2 = list(s)
s3 = list(set(s2))
print('yes' if len(s2) == len(s3) else 'no')

Buggy submission (verdict: Runtime Error):
s = input()
s2 = [*s]
s3 = list(set(s2))
print('yes' if len(s2) == len(s3) else 'no')
Problem p02621 (python)

Fixed submission:
a=int(input())
print(a+a**2+a**3)

Buggy submission (verdict: Runtime Error):
a=int(input())
print(a+a**2+a***3)

Buggy submission (verdict: Runtime Error):
a=int(input())
print(a+a**2+a***3

Buggy submission (verdict: Runtime Error):
a*+a**2+a***3
Problem p02720 (python)

Fixed submission:
K=int(input())
nums=[i for i in range(1,10)]
for i in range(K):
    a=nums.pop(0)
    if a%10!=0:
        nums.append(a*10 + a%10 - 1)
    
    nums.append(a*10 + a%10)
    
    if a%10!=9:
        nums.append(a*10 + a%10 + 1)

print(a)

Buggy submission (verdict: Runtime Error):
K=int(input())
nums=[i for i in range(1,10)]
for i in range(K):
    a=nums.pop(0)
    if a%10!=0:
        nums.append(a*10 + %10 - 1)
    
    nums.append(a*10 + a%10)
    
    if a%10!=9:
        nums.append(a*10 + a%10 + 1)

print(a)

Buggy submission (verdict: Runtime Error):
K=int(input())
nums=[i for i in range(1,10)]
for i in range(K):
    a=nums.pop(0)
    if a%10!=0:
        nums.append(a*10 + %10 - 1)
    
    nums.append(a*10 + a%10)
    
    if a%10!=9:
        nums.append(a*10 + a%10 + 1)

print(a)
Problem p02814 (python)

Fixed submission:
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
    
N,M=map(int,input().split())
A=[int(i)//2 for i in input().split()]
q=lcm(*A)
#print(q)
for i in A:
    #print(i)
    if q//i%2==0:
        print(0)
        exit()
print((M//q+1)//2)

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

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
    
N,M=map(int,input().split())
A=set(map(int,input().split()))
cnt=0
B=[]
C=[]

for i in A:
    tmp=(i/2)
    if tmp%2!=0:
        B.append(i)
    else:
        C.append(i)
#print(B)        
q=lcm(*A)
#print(q)
if len(A)==len(B) or len(A)==len(C):
    if 2*M<q:
        print(0)
    elif (2*M//q)%2==0:
        print(2*M//(2*q))
    else:
        print(2*M//(2*q)+1)
else:
    print(0)
Problem p02621 (python)

Fixed submission:
a  = int(input())
print(a+a**2+a**3)

Buggy submission (verdict: Runtime Error):
s = str(input())
t = str(input())
count = 0

for i in range(len(s)):
    if s[i] != t[i]:
        count +=1

print(count)
Problem p02640 (python)

Fixed submission:
animals_num, legs_num = map(int, input().split())

answer = "No"

for i in range(animals_num + 1):
  j = animals_num - i
  if j * 4 + i * 2 == legs_num:
    answer = "Yes"
print(answer)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())

answer = "No"

for i in range(x + 1):
  b = x - i
  if a * 2 + b * 4 == y:
    answer = "Yes"

print(answer)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())

answer = "No"

for i in range(x + 1):
  y = x - i
  if a * 2 + b * 4 == y:
    answer = "Yes"

print(answer)
Problem p02765 (python)

Fixed submission:
count, outrate = map(int, input().split())

if count >= 10:
  result = outrate
  print(result)
else:
  result = outrate + 100 * (10 - count)
  print(result)

Buggy submission (verdict: Runtime Error):
number, base = map(int, input().split())
result_list = []
while number / base > 0:
  mod = number % base
  result_list.append(str(mod))
  number = number // base

result_list.reverse()
result = "".join(result_list)
print(len(result))

Buggy submission (verdict: Runtime Error):
number, base = map(int, input().split())
result_list = []
while number / base > 0:
  mod = number % base
  result_list.append(str(mod))
  number = number // base

result_list.reverse()
result = "".join(result_list)
print(result)

Buggy submission (verdict: Runtime Error):
count, outrate = input().split()
if count >= 10:
  result = outrate
  print(result)
else:
  result = outrate + 100 * (10 - count)
  print(result)

Buggy submission (verdict: Runtime Error):
count, outrate = input().split()
if count >= 10:
  result = outrate
  print(inrate)
else:
  result = outrate + 100 * (10 - count)
  print(result)
Problem p03035 (python)

Fixed submission:
n,k=tuple(map(int,input().split()))
if n >= 13:
  print(k)
elif 6 <= n <= 12:
  print(k//2)
elif n <= 5:
  print(0)

Buggy submission (verdict: Runtime Error):
age,cost =list(map(int, input().split()))
if age<=5:
  print('0')
elif age>=6 and age<=12:
  print(a//2)
elif age>=13:
  print(a)

Buggy submission (verdict: Runtime Error):
age,cost= list(map(int, input().split()))
if 0<age<100 and 2<cost<1000:
	if age<=5:
      print('0')
	elif age>=6 and age<=12:
      print(a/2)
	else:
  	  print(a)

Buggy submission (verdict: Runtime Error):
age,cost= list(map(int, input().split()))
if age<=5:
  print('0')
elif age>=6 and age<=12:
  print(a/2)
else:
  print(a)

Buggy submission (verdict: Runtime Error):
age,cost=list(map(int, input().split()))
age=x[0]
cost=x[1]
if age<=5:
  print('0')
elif age>=6 and age<=12:
  print(a/2)
else:
  print(a)

Buggy submission (verdict: Runtime Error):
x=list(map(int, input()))
age=x[0]
cost=x[1]
if age<=5:
  print('0')
elif age>=6 and age<=12:
  print(a/2)
else:
  print(a)
Problem p02755 (python)

Fixed submission:
import math
a,b=map(int,input().split())
for i in range(2000):
  if math.floor((i+1)*0.08)==a and math.floor((i+1)*0.1)==b:
    print(i+1)
    exit()
print(-1)

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
ax=set(range(math.ceil(25*a/2),math.floor(25*(a+0.99999)/2)+1))
bx=set(range(math.ceil(10*b),math.floor(10*(b+0.99999)))+1)
x=list(ax&bx)
if x:
  print(x[0])
else:
  print(-1)
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)


def count(n):
    return b // n - (a - 1) // n


a, b, c, d = map(int, input().split())
print(b - a + 1 - (count(c) + count(d) - count(lcm(c, d))))

Buggy submission (verdict: Runtime Error):
            print(i, sum)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


a, b, c, d = map(int, input().split())

def count(st, n):
    ans = (b - st + 1) // n
    return ans


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


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


sum = 0
cc = 0
cflag = True
dflag = True
cdflag = True
for i in range(a, b + 1):
    if i % c == 0 and cflag:
        sum += count(i, c)
        cc += 1
        cflag = False
    if i % d == 0 and dflag:
        if dflag:
            sum += count(i, d)
            cc += 1
            dflag = False
        if i % c == 0 and cdflag:
            l = lcm(c, d)
            sum -= count(i, l)
            cc += 1
            cdflag = False
    if cc == 3:
        break
print(b - a + 1 - sum)
Problem p03043 (python)

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


def cc(n):
    i = 0
    while True:
        if K <= (n * (2 ** i)):
            return i
        i += 1


A = 0
for n in range(1, N+1):
    A += 1.0 / N * (0.5 ** cc(n))
print(A)

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


def cc(n):
    i = 
    while True:
        if K <= (n * (2 ** i)):
            return i
        i += 1


A = 0
for n in range(1, N+1):
    A += 1.0 / N * (0.5 ** cc(n))
print(A)
Problem p02628 (python)

Fixed submission:
n,k = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
print(sum(p[0:k]))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = list(input().split())
p.sort()
print(sum(p[0:n]))
Problem p02853 (python)

Fixed submission:
a,b=map(int,input().split())
dic={1:3*10**5,2:2*10**5,3:1*10**5}
c=0
if a in dic and b in dic:
    if a==1 and b==1:
        c+=dic[a]+dic[b]+4*10**5
        print(c)
    else:
        c+=dic[a]+dic[b]
        print(c)

elif a in dic and b not in dic:
    c+=dic[a]
    print(c)


elif b in dic and a not in dic:
    c+=dic[b]
    print(c)

else:
    print(c)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
dic={3:1,2:2,1:3}
c=0
if a==1 and b==1:
	c+=dic[a]*10**5+dic[b]*10**5+4*10**5
    print(c)
    
else:
  if a in dic and b in dic:
    c+=dic[a]*10**5+dic[b]*10**5
    print(c)
   
  elif a in dic and b not in dic:
    c+=dic[a]*10**5
    print(c)
    
  elif a not in dic and b in dic:
    c+=dic[b]*10**5
    print(c)
Problem p02639 (python)

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

for i in range(len(array)):
    if array[i] == 0:
        print(i+1)
        break

Buggy submission (verdict: Runtime Error):
lists = [int(x) for x in range(1,6)]
for i in range(1,len(list)+1):
  if list[i] == 0:
    print(i)