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

Fixed submission:
# coding: utf-8

import sys
input = sys.stdin.readline

mod = int(1e9 + 7)

def f(K, D):
    l = len(K)
    dp = [[[0] * D for _ in range(2)] for _ in range(l + 1)]
    dp[0][0][0] = 1
    for i in range(l):
        ki = int(K[i])
        for j in range(2):
            uki = 9 if j else ki
            dpij = dp[i][j]
            for d in range(D):
                for k in range(uki + 1):
                    dpij_ = dp[i + 1][j or k < ki]
                    d_ = (d + k) % D
                    dpij_[d_] += dpij[d]
                    dpij_[d_] %= mod
    # K = 0 の場合が含まれるので -1
    return((dp[-1][0][0] + dp[-1][1][0] - 1 + mod) % mod)

K = input().rstrip() # 1 <= K <= 10^10000
D = int(input()) # 1 <= D <= 100

print(f(K, D))

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

from itertools import product as prod
import sys
input = sys.stdin.readline

mod = int(1e9 + 7)

def f2(K, D):
    l = len(K)
    dp = [[[0] * D for _ in range(2)] for _ in range(l + 1)]
    dp[0][0][0] = 1

    for i, j, d in prod(range(l), range(2), range(D)):
        maxk = 9 if j else int(K[i])
        dpij = dp[i][j]
        dpi1 = dp[i + 1]
        for k in range(maxk + 1):
            dpi1j = dpi1[j or k < maxk]
            d_ = d + k
            if d_ >= D:
                d_ -= D
            dpi1j[d_] += dpij[d]
            if dpi1j[d_] >= mod:
                dpi1j[d_] -= mod
    # K = 0 の場合が含まれるので -1
    return((dp[-1][0][0] + dp[-1][1][0] - 1 + mod) % mod)

K = input().rstrip() # 1 <= K <= 10^10000
D = int(input()) # 1 <= D <= 100

print(f2(K, D))

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

from itertools import product as prod
import sys
input = sys.stdin.readline

mod = int(1e9 + 7)

def f2(K, D):
    l = len(K)
    dp = [[[0] * D for _ in range(2)] for _ in range(l + 1)]
    dp[0][0][0] = 1

    for i, j, d in prod(range(l), range(2), range(D)):
        maxk = 9 if j else int(K[i])
        dpij = dp[i][j]
        dpi1 = dp[i + 1]
        for k in range(maxk + 1):
            dpi1j = dpi1[j or k < maxk]
            d_ = d + k
            if d_ >= D:
                d_ -= D
            dpi1j[d_] += dpij[d]
            if dpi1j[d_] >= mod:
                dpi1j[d_] -= mod
    # K = 0 の場合が含まれるので -1
    return((dp[-1][0][0] + dp[-1][1][0] - 1 + mod) % mod)

K = input().rstrip() # 1 <= K <= 10^10000
D = int(input()) # 1 <= D <= 100
print(f2(K, D))
Problem p03000 (python)

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

counter = 0
coordinate = 0

while counter < n+1 and coordinate<=x:
    counter+=1
    if counter == n+1:
        break
    else:
        coordinate += l_array[counter-1]


print(counter)

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

counter = 0
coordinate = 0

while counter < n+1 and coordinate<=x:
    counter+=1
    if counter = n+1:
        break
    else:
        coordinate += l_array[counter-1]


print(counter)

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

counter = 0
coordinate = 0

while counter < n+1 and coordinate<=x:
    counter+=1
    coordinate += l_array[counter-1]

print(counter)

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

counter = 0
coordinate = 0

while counter < n+1 and coordinate<=x:
    coordinate += l_array[counter]
    counter+=1

print(counter)
Problem p03035 (python)

Fixed submission:
a, b = (int(i) for i in input().split())
res =0
if a>=13 :
  res = b
elif a<=5:
  res = 0
else:
  res = int(b/2)
print(res)

Buggy submission (verdict: Runtime Error):
r, d, x = (int(i) for i in input().split())

for i in range(10):
  x = r * x - d
  print(x)
Problem p03219 (python)

Fixed submission:
X,Y = input().split(' ')
x = int(X)
y = int(Y)

print(x + (y//2))

Buggy submission (verdict: Runtime Error):
X,Y = int(input().split(' '))
print(X + (Y/2))

Buggy submission (verdict: Runtime Error):
X,Y = int(input.split(' '))
print(X + (Y/2))
Problem p02999 (python)

Fixed submission:
import numpy as np
x = input()
a,b = map(int,x.split())
if(a<b):
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
a,b = map(int,x.split())
if(a<b):
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
import numpy as np
a,b = map(int,x.split())
if(a<b):
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
import numpy as np
a,b = map(int,x.split())
if(a<b):
  print(0)
else:
  print(10)
Problem p03000 (python)

Fixed submission:
import numpy as np

A = input()
B = input()

N,X = map(int,A.split())
L = np.array(list(map(int, B.strip().split())))

L_sum = 0
jump = 1

for i in range(N):
  L_sum += L[i]
  if(L_sum>X):
    jump += 0
  else:
    jump += 1

print(jump)

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

A = input()
B = input()

N,X = map(int,A.split())
L = np.array(list(map(int, B.strip().split())))

L_sum = 0
jump = 1

for i in range(N+1):
  L_sum += L[i]
  if(L_sum>X):
    jump += 0
  else:
    jump += 1

print(jump)

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

A = input()
B = input()

N,X = map(int,A.split())
L = np.array(map(int,B.split( )))
L_sum = 0
jump = 1
for i in range(N+1):
  L_sum += L[i]
  if(L_sum<X):
    jump += 1 
  else:
    jump += 0

print(jump)

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

A = input()
B = input()

N,X = map(int,A.split())
L = np.array(list(map(int,B.split( ))))
L_sum = 0
jump = 1
for i in range(N+1):
  L_sum += L[i]
  if(L_sum<X):
    jump += 1 
  else:
    jump += 0

print(jump)
Problem p03671 (python)

Fixed submission:
a, b, c = map(int, input().split())
sums = [a+b,b+c,c+a]
print(min(sums))

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

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
Problem p03238 (python)

Fixed submission:
N = int(input())
if N == 1:
    print('Hello World')
elif N == 2:
    A = int(input())
    B = int(input())
    print(A+B)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, T = map(int, input().split())
costs = []
times = []
for i in np.arange(N):
    ci, ti = map(int, input().split())
    costs.append(ci)
    times.append(ti)
index = np.argmin(times)
t_min = times[index]
if t_min < T:
    print(costs[index])
else:
    print('TLE')
Problem p03103 (python)

Fixed submission:
N, M = map(int, input().split())
AB = [0] * N
for i in range(N):
    AB[i] = list(map(int, input().split()))

AB = sorted(AB)
cnt = 0
ans = 0

for e in AB:
    if cnt + e[1] < M:
        ans += e[0] * e[1]
        cnt += e[1]
    else:
        ans += e[0] * (M - cnt) 
        break

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())

cnt = 0
ans = 0
while cnt < M:
    min_cost = min(A)
    amount = B[A.index(min_cost)]
    if cnt + amount <= M:
        ans += min_cost * amount
        cnt += amount
    else:
        ans += min_cost * (M - cnt)
        break
    A = [e for e in A if e != min_cost]
    B = [e for e in B if e != amount]
    
print(ans)
Problem p03998 (python)

Fixed submission:
a_hands = list(input())
b_hands = list(input())
c_hands = list(input())
turn = 'a'

while True:
    if turn == 'a':
        if len(a_hands) == 0:
            print('A')
            break
        turn = a_hands.pop(0)
    elif turn == 'b':
        if len(b_hands) == 0:
            print('B')
            break
        turn = b_hands.pop(0)
    elif turn == 'c':
        if len(c_hands) == 0:
            print('C')
            break
        turn = c_hands.pop(0)

Buggy submission (verdict: Runtime Error):
a_hands = [*input()]
b_hands = [*input()]
c_hands = [*input()]
turn = 'a'

while True:
    if turn == 'a':
        if len(a_hands) == 0:
            print('A')
            break
        turn = a_hands.pop(0)
    elif turn == 'b':
        if len(b_hands) == 0:
            print('B')
            break
        turn = b_hands.pop(0)
    elif turn == 'c':
        if len(c_hands) == 0:
            print('C')
            break
        turn = c_hands.pop(0)

Buggy submission (verdict: Runtime Error):
a_hands = [*input()]
b_hands = [*input()]
c_hands = [*input()]
turn = 'a'

while True:
    if turn == 'a':
        if len(a_hands) == 0:
            print('A')
            break
        turn = a_hands.pop(0)
    elif turn == 'b':
        if len(b_hands) == 0:
            print('B')
            break
        turn = b_hands.pop(0)
    elif turn == 'c':
        if len(c_hands) == 0:
            print('C')
            break
        turn = c_hands.pop(0)
Problem p04012 (python)

Fixed submission:
w = sorted(input())
ret = 'Yes'
if len(w) % 2 == 0:
    for i in range(0, len(w)-1, 2):
        if w[i] != w[i+1]:
            ret = 'No'
            break
else:
    ret = 'No'
print(ret)

Buggy submission (verdict: Runtime Error):
w = sorted(input())
ret = 'Yes'
for i in range(0, len(w), 2):
    if w[i] != w[i+1]:
        ret = 'No'
        break
print(ret)
Problem p04030 (python)

Fixed submission:
ret = []
for s in input():
    if s == '0' or s == '1':
        ret.append(s)
    elif len(ret) > 0:
        ret.pop()
print(''.join(ret))

Buggy submission (verdict: Runtime Error):
ret = []
for s in input():
    if s == 'B':
        ret.pop()
    else:
        ret.append(s)
print(''.join(ret))
Problem p03103 (python)

Fixed submission:
from collections import OrderedDict
if __name__ == "__main__":
    NM = list(map(int, input().split()))
    n = NM[0]
    m = NM[1]
    mydict = {}
    for i in range(n):
        money_can = list(map(int, input().split()))
        money = money_can[0]
        can = money_can[1]
        if(money not in mydict.keys()):
            mydict[money] = []
        mydict[money].append(can)
    buynow = 0
    moneynow = 0

    mydict = OrderedDict(sorted(mydict.items()))
    for i in mydict.keys():
        if(buynow >= m):
            break
        for canNO in mydict[i]:
            if(buynow >= m):
                break
            if(canNO + buynow < m):
                moneynow += canNO*i
                buynow += canNO
            else:
                need = m - buynow
                moneynow += need*i
                buynow += need
        else:
            continue
    print(moneynow)

Buggy submission (verdict: Runtime Error):
from collections import OrderedDict
if __name__ == "__main__":
    NM = list(map(int, input().split()))
    n = NM[0]
    m = NM[1]
    mydict = {}
    for i in range(n):
        money_can = list(map(int, input().split()))
        money = money_can[0]
        can = money_can[1]
        if(money not in mydict.keys()):
            mydict[money] = []
        mydict[money].append(can)
    buynow = 0
    moneynow = 0

    mydict = OrderedDict(sorted(mydict.items()))
    for i in mydict.keys():
        if(buynow >= m):
            break
        for canNO in mydcit[i]:
            if(buynow >= m):
                break
            if(can + buynow <= m):
                moneynow += can*i
                buynow += can
            else:
                need = m - buynow
                moneynow += need*i
                buynow += need
        else:
            continue
    print(moneynow)
Problem p02999 (python)

Fixed submission:
x,A = map(int,input().split())
if x<A:
  print(0)
else:
  print(10)

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

point=0
count=1
for i in li:
  point += i
  if point<=X:
    count+=1
print(count)
Problem p03035 (python)

Fixed submission:
x,y = map(int,input().split())
if x >= 13:
  print(y)
elif 6 <= x <= 12:
  print(int(y/2))
else:
  print(0)

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

listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;

count = 0
for i in range(1,N+1):
  for j in range(M):
    if  i < listA[j][0] or listA[j][1] < i:
      print(i)
      break;
    if j == M-1:
      count += 1


print(count)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
if x > 12:
  print(y)
else if 6 <= x <= 12:
  print(y/2)
else:
  print(0)
Problem p03262 (python)

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

x = list(map(int, input().split()))

def gcd(a, b):
    """Calculate the Greatest Common Divisor of a and b.

    Unless b==0, the result will have the same sign as b (so that when
    b is divided by it, the result comes out positive).
    """
    while b:
        a, b = b, a%b
    return a

def solve():
    x.append(X)

    sorted_x = sorted(x)
    sorted_aaa = []

    aaa = []

    for (i, item) in enumerate(sorted_x):
        if i == 0:
            continue
        aaa.append(int(sorted_x[i] - sorted_x[i - 1]))

    sorted_aaa = sorted(aaa)
    res = 100000000
    # from math import gcd
    for (k, elm) in enumerate(sorted_aaa):
        if len(sorted_aaa) == 1:
            res = sorted_aaa[k]
            break
        if k == 0:
            continue
        g = gcd(sorted_aaa[k - 1], sorted_aaa[k])
        if g < res:
            res = g
    print(res)


if __name__ == '__main__':
    solve()

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

x = list(map(int, input().split()))

x.append(X)

sorted_x = sorted(x)
sorted_aaa = []

aaa = []

for (i, item) in enumerate(sorted_x):
    if i == 0:
        continue
    aaa.append(int(sorted_x[i] - sorted_x[i - 1]))

sorted_aaa = sorted(aaa)
res = 1 << 99

for (k, elm) in enumerate(sorted_aaa):
    # if elm % sorted_aaa[0] != 0:
    #     res = 1
    if len(sorted_aaa) == 1:
        res = sorted_aaa[k]
        break
    if k == 0:
        continue
    g = math.gcd(sorted_aaa[k - 1], sorted_aaa[k])
    if g < res:
        res = g

print(res)
Problem p03282 (python)

Fixed submission:
from math import pow
s = input()
k = int(input())

char = [ss for ss in s]


res = '1'

_sum = 0
for i in range(k):
    if s[i] != '1':
        res = s[i]
        break

print(res)

Buggy submission (verdict: Runtime Error):
MOD = 1000000007
def fast_power(base, power):
    """
    Returns the result of a^b i.e. a**b
    We assume that a >= 1 and b >= 0

    Remember two things!
     - Divide power by 2 and multiply base to itself (if the power is even)
     - Decrement power by 1 to make it even and then follow the first step
    """

    result = 1
    while power > 0:
        # If power is odd
        if power % 2 == 1:
            result = (result * base) % MOD

        # Divide the power by 2
        power = power / 2
        # Multiply base to itself
        base = (base * base) % MOD

    return result


s = input()
k = int(input())

tyo = 5e15

char = [int(ss) for ss in s]

res = 0

_sum = 0
ok = 0

for i in range(k):
    _sum = _sum + (fast_power(int(s[i]), tyo))
    if _sum >= k and ok == 0:
        res = s[i]
        ok = 1

# for num in char:
#     _sum = _sum + (fast_power(num, tyo))
#     if _sum >= k and ok == 0:
#         res = num
#         ok = 1

print(res)

Buggy submission (verdict: Runtime Error):
MOD = 1000000007
def fast_power(base, power):
    """
    Returns the result of a^b i.e. a**b
    We assume that a >= 1 and b >= 0

    Remember two things!
     - Divide power by 2 and multiply base to itself (if the power is even)
     - Decrement power by 1 to make it even and then follow the first step
    """

    result = 1
    while power > 0:
        # If power is odd
        if power % 2 == 1:
            result = (result * base) % MOD

        # Divide the power by 2
        power = power / 2
        # Multiply base to itself
        base = (base * base) % MOD

    return result


s = input()
k = int(input())

tyo = 5e15

char = [int(ss) for ss in s]

res = 0

_sum = 0
ok = 0

for i in range(k):
    _sum = _sum + (fast_power(s[i], tyo))
    if _sum >= k and ok == 0:
        res = s[i]
        ok = 1

# for num in char:
#     _sum = _sum + (fast_power(num, tyo))
#     if _sum >= k and ok == 0:
#         res = num
#         ok = 1

print(res)
Problem p03607 (python)

Fixed submission:
n = int(input())
di = {}

for x in range(n):
  i = int(input())
  if (i in di.keys()):
    di.pop(i)
  else:
    di[i] = i
print(len(di))

Buggy submission (verdict: Runtime Error):
n = int(input())
di = {}

for x in range(n):
  i = int(input())
  if (i in di.keys()):
    di.pop()
  else:
    di[i] = i
print(len(di))
Problem p03632 (python)

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

start = a if a > c else c
end = b if b < d else d

ans = 0 if b < c or d < a else end - start



print(ans)

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

ans = (b - c) < 0 ? 0 : b - c

print(ans)
Problem p03633 (python)

Fixed submission:
from functools import reduce

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

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

def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

def main():
  n = int(input())
  li = []
  for i in range(n):
    inp = int(input())
    li.append(inp)

  ans = int(reduce((lambda x, y: lcm(x, y)), li))
  if ans > 1000000000000000000:
    ans = 1000000000000000000
  print(ans)

if __name__ == "__main__":
  main()

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

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

def lcm(a, b):
  return a * b / gcd(a, b)
def main():
  
  n = int(input())
  li = []
  for i in range(n):
    inp = int(input())
    li.append(inp)

  ans = int(reduce((lambda x, y: lcm(x, y)), li))
  if ans > 1e18:
    ans = 1e18
  print(ans)

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
from functools import reduce
def gcd(a, b):
  if (b == 0):
    return a;

  return gcd(b, a % b)


def lcm(a, b):
  return a * b / gcd(a, b);
def main():
  
  n = int(input())
  li = []
  for i in range(n):
    inp = int(input())
    li.append(inp)

  ans = int(reduce((lambda x, y: lcm(x, y)), li))
  if ans > 1e18:
    ans = 1e18
  print(ans)

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
from functools import reduce
def gcd(a, b):
  if (b == 0):
    return a;

  return gcd(b, a % b)


def lcm(a, b):
  return a * b / gcd(a, b);
def main():
  
  n = int(input())
  li = []
  for i in range(n):
    li.append(int(input()))

  ans = int(reduce((lambda x, y: lcm(x, y)), li))

  print(ans)

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
from functools import reduce
def gcd(a, b):
  if (b == 0):
    return a;

  return gcd(b, a % b)


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

n = int(input())
li = []
for i in range(n):
  li.append(int(input()))

ans = int(reduce((lambda x, y: lcm(x, y)), li))

print(ans)
Problem p03067 (python)

Fixed submission:
n=input().split()
for i in range(3):
    n[i]=int(n[i])
if n[0]<n[2]<n[1] or n[1]<n[2]<n[0]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
p=[]
m=0
x=s.count("#.")
c=s.count("#.")
while x>0:
    x=s.count("#.")
    s=s.replace("#.","..",x)
    m+=x
    p.append(m)
p.append(c)
print(min(p))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
p=[]
m=0
x=s.count("#.")
c=s.count("#.")
while x>0:
    x=s.count("#.")
    s=s.replace("#.","..",x)
    m+=x
    if x==0:
        p.append(m)
p.append(c)
print(min(p))
Problem p03076 (python)

Fixed submission:
a=[int(input()) for i in range (5)]
m=[]
s=0
for j in range(5):
    x=a[j]%10
    if x!=0:
        s+=a[j]+10-x
    else:
        s+=a[j]
for k in range(5):
    y=a[k]%10
    b=s
    if y!=0:
        n=10-y
        b=b-n
        m.append(b)
    else:
        m.append(b)
print(min(m))

Buggy submission (verdict: Runtime Error):
a=[int(input()) for i in range (5)]
m=[]
s=0
for i in range(5):
    x=a[i]%10
    if x!=0:
        s+=a[i]+10-x
    else:
        s+=a[i]
for k in range(5):
    y=a[k]%10
    b=s
    if y!=0:
        n=10-y
        b=s-n
        m.append(b)
    else:
        m.append(b)
print(min(m)
Problem p03000 (python)

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


ans = 1
D = 0
for i in range(N):
    if D + positions[i] <= X:
        D += positions[i]
        ans += 1
    else:
        print(ans)
        exit()
print(ans)

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


ans = 1
D = 0
for i in range(N + 1):
    if D + positions[i] <= X:
        D += positions[i]
        ans += 1
    else:
        print(ans)
        exit()
print(ans)

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


ans = 1
D = 0
for i in range(N + 1):
    if D + positions[i] < X:
        D += positions[i]
        ans += 1
    else:
        print(ans)
        exit()
print(ans)
Problem p03037 (python)

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

L_list = []
R_list = []
for i in range(M):
  L, R = map(int, input().split())
  L_list.append(L)
  R_list.append(R)

L = max(L_list)
R = min(R_list)

if R < L:
  print(0)
else:
  print(R - L + 1)

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

for i in range(M):
  L, R = map(int, input().split())
  pass_card = [i for i in range(L, R+1)]
  if  i == 0:
    ans = pass_card
  elif i > 0:
    ans = list(set(pass_card[i - 1]) & set(pass_card[i]))

print(len(ans))
Problem p03043 (python)

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

for i in range(1, N+1):
  tmp = 1 / N
  now = i
  while now < K:
    now *= 2
    tmp /= 2
  ans += tmp
print(ans)

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

N, K = map(int, input().split())
ans = 0

flag = True
score = 1
times = 0
while flag:
  times += 1
  score *= 2
  if score >= K:
    flag = False

for i in range(1, N+1):
  ans += Fraction(1, N) * (Fraction(1, 2) ** times)
  times -= 1

print(float(ans))
Problem p03062 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
count = 0

for i in range(N):
  if A[i] < 0:
    count += 1
    A[i] *= -1
print(sum(A) if count % 2 == 0 else sum(A) - min(A) * 2)

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

for i in range(N - 1):
  if A[i] < 0 :
    A[i] *= -1
    A[i + 1] *= -1
  elif i == N - 2 and A[i] == 0:
    A[i + 1] *= -1
    A[i + 2] *= -1
print(sum(A))

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

for i in range(N):
  if A[i] < 0:
    A[i] *= -1
    A[i + 1] *= -1
print(sum(A))
Problem p03068 (python)

Fixed submission:
N = int(input())
S = list(input())
K = int(input()) - 1

for i in range(len(S)):
  if S[i] != S[K]:
    S[i] = '*'
print(''.join(S))

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

for i in range(len(S)):
  if S[i] != S[K]:
    S[i] = '*'
print(''.join(S))
Problem p03043 (python)

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

import math
P = 0
if N < K:
    for i in range(1,N+1):
        P += ((0.5)**(math.ceil( math.log2(float(K/i)) )))/N
else:
    P += (N-K+1)/N 
    for i in range(1,K):
        P += ((0.5)**(math.ceil( math.log2(float(K/i)) )))/N
print(P)

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

import math
P = 0
if N < K:
for i in range(1,K):
    P += ((0.5)**(math.ceil( math.log2(float(K/i)) )))/N
else:
    P += (N-K)/N 
    for i in range(K,N+1):
        P += ((0.5)**(math.ceil( math.log2(float(K/i)) )))/N
print(P)

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

import math
P = 0
if N < K:
for i in range(1,K):
    P += ((0.5)**(math.ceil( math.log2(float(K/i)) )))/N
else:
    P += (N-K)/N 
    for i in range(K,N+1)
        P += ((0.5)**(math.ceil( math.log2(float(K/i)) )))/N
print(P)