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

Fixed submission:
N = int(input())
A = [0]+list(map(int, input().split(" ")))

dp_list = [{0, 0}, {0: 0, 1: A[1]}, {0: 0, 1: A[1] if A[1] > A[2] else A[2]}]

for i in range(3, N+1):
    b = (i-1)//2
    f = (i+1)//2
    dp_list.append({})
    for j in range(b, f+1):
        if j in dp_list[i-1]:
            dp_list[i][j] = dp_list[i-2][j-1]+A[i] if dp_list[i -
                                                              2][j-1]+A[i] > dp_list[i-1][j] else dp_list[i-1][j]
        else:
            dp_list[i][j] = dp_list[i-2][j-1]+A[i]

print(dp_list[-1][N//2])

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(2*1000000)

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



def dp(i, j):
    if i >= N:
        return (-1*1000000000)
    if (N//2)-j < (i-1)//2:
        return (-1*1000000000)
    if j == 1:
        return A[i]
	else:
        temp = max([dp(i+2, j-1)+A[i], dp(i+1, j)])
        dp_dict[(i, j)] = temp
        return temp


select = N//2
if select == 1:
    print(max(A))
else:
    print(dp(0, select))

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

dp_dict = {}


def dp(i, j):
    print(i, j)
    if i >= N:
        return (-1*10e+9)-1
    if j == 1:
        return A[i]
    if (i, j) in dp_dict:
        return dp_dict[(i, j)]
    else:
        temp = max([dp(i+2, j-1)+A[i], dp(i+1, j)])
        dp_dict[(i, j)] = temp
        return temp


print(dp(0, (N//2)))

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

dp_dict = {}


def dp(i, j):
    if i >= N:
        return -1*10e+9
    if (i+1)//2 > (N//2)-j+1:
        return -1*10e+9
    if j == 1:
        return A[i]
    if (i, j) in dp_dict:
        return dp_dict[(i, j)]
    else:
        temp = max([dp(i+2, j-1)+A[i], dp(i+1, j)])
        dp_dict[(i, j)] = temp
        return temp


print(dp(0, (N//2)))

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

dp_dict = {}


def dp(i, j):
    if j == 1:
        return A[i]
    # if (i-1)//2 > (N//2)-j:
        # return -1*10e+9
    if (N-1)-i < j:
        return -1*10e+9

    if (i, j) in dp_dict:
        return dp_dict[(i, j)]
    else:
        temp = max([dp(i+2, j-1)+A[i], dp(i+1, j)])
        dp_dict[(i, j)] = temp
        return temp


print(dp(0, N//2))

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


dp_dict = {}


def dp(i, j):
    if j == 1:
        return A[i]
    if (i-1)//2 > (N//2)-j:
        return -1*10e+9
    if (N-1)-i < j:
        return -1*10e+9

    if (i, j) in dp_dict:
        return dp_dict[(i, j)]
    else:
        temp = max([dp(i+2, j-1)+A[i], dp(i+1, j)])
        dp_dict[(i, j)] = temp
        return temp


print(dp(0, N//2))
Problem p02584 (python)

Fixed submission:
x, k, d = map(int, input().split())
if x >= 0:
    if x - k*d >= 0:
        ans = abs(x - k*d)
    else:
        pre = x//d
        x -= pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif k%2 == 1:
            ans = min(abs(x-d), abs(x+d))
elif x <= 0:
    if x + k*d <= 0:
        ans = abs(x + k*d)
    else:
        pre = abs(x)//d
        x += pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif k%2 == 1:
            ans = min(abs(x-d), abs(x+d))
print(ans)

Buggy submission (verdict: Runtime Error):
x, k, d = map(int, input().split())
if x >= 0:
    if x - k*d >= 0:
        ans = x - k*d
    else:
        pre = x//d
        x -= pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif pre%2 == 1:
            ans = min(abs(x-d), abs(x+d))
elif x <= 0:
    if x + k*d <= 0:
        ans = x + k*d
    else:
        pre = abs(x)//d
        x += pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif pre%2 == 1:
            ans = min(abs(x-d), abs(x+d))
print(ans)
Problem p02900 (python)

Fixed submission:
def factorization(n):
    arr = [[1, 1]]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
a, b = map(int, input().split())
g = gcd(a, b)
l = factorization(g)
print(len(l))

Buggy submission (verdict: Runtime Error):
import math
#素因数分解
def factorization(n):
    arr = [[1, 1]]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a, b = map(int, input().split())
g = math.gcd(a, b)
l = factorization(g)
print(len(l))
Problem p02952 (python)

Fixed submission:
n = int(input())
if 1 <= n and n <= 9:
    print(n)
elif 10 <= n and n <= 99:
    print(9)
elif 100 <= n and n <= 999:
    print(9+n-99)
elif 1000 <= n and n <= 9999:
    print(9+999-99)
elif 10000 <= n and n <= 99999:
    print(9+999-99+n-9999)
elif 100000 <= n and n <= 999999:
    print(9+999-99+99999-9999)

Buggy submission (verdict: Runtime Error):
n = int(input())
if 1 <= n and n <= 9:
    pint(n)
elif 10 <= n and n <= 99:
    print(9)
elif 100 <= n and n <= 999:
    print(9+n-99)
elif 1000 <= n and n <= 9999:
    print(9+999-99)
elif 10000 <= n and n <= 99999:
    print(9+999-99+n-9999)
elif 100000 <= n and n <= 999999:
    print(9+999-99+999999-99999)
Problem p02995 (python)

Fixed submission:
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
a, b, c, d = map(int, input().split())
print(b-(a-1) - b//c + (a-1)//c - b//d + (a-1)//d + b//lcm(c, d) - (a-1)//lcm(c, d))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a, b, c, d = map(int, input().split())
print(b-(a-1) - b//c + (a-1)//c - b//d + (a-1)//d + b//lcm(c,d) + (a-1)//lcm(c, d))
Problem p03067 (python)

Fixed submission:
a, b, c = (int(i) for i in input().split())  

if a < b and a < c and c < b:
  print('Yes')
elif b < a and b < c and c < a:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
s = list(s)
t = s
cnt = 0
for i in range(n-2):
  if s[i] == '.' and s[i+1] == '#' and s[i+2] == '.':
    s[i+1] = '.'
    cnt+=1

for i in range(n-1):
  if s[i] == '#' and s[i+1] == '.':
    s[i+1] = '#'
    cnt+=1

print(cnt)
Problem p03071 (python)

Fixed submission:
a,b = (int(i) for i in input().split())  
sum = 0
sum += max(a,b)
if a > b:
  a -= 1
else:
  b -= 1
sum += max(a,b)
print(sum)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
s = list(s)
ans = s
len = []
for i in range(n):
  l = 0
  if s[i] == '0':
    l += 1
    j = i
    while s[j+1] != '0':
      l += 1
  len.append(l)
print(len)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
sum = 0
sum += max(a,b)
if a < b:
  a -= 1
else:
  b -= 1
sum += max(a,b)
print(sum)
Problem p03074 (python)

Fixed submission:
n, k = map(int, input().split())
a = input()
l = []
if a[0] == '0':
    l.append(0)
sum = []
i = 0
while i < len(a):
    j = i
    while j < len(a) and a[j] == a[i]:
        j += 1
    l.append(j-i)
    i = j
if a[-1] == '0':
    l.append(0)
num = [0]*(len(l)+1)
for i in range(0, len(l)):
    num[i+1] = num[i]+l[i]
ans = -1
for i in range(0, len(num), 2):
    j = i + k*2+1
    if j >= len(num):
        j = len(num)-1
    ans = max(ans, num[j] - num[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
s = list(s)
ans = s
len = []
for i in range(n):
  l = 0
  if s[i] == '0':
    l += 1
    j = i
    while s[j+1] != '0':
      l += 1
  len.append(l)
print(len)
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy submission (verdict: Runtime Error):
a = input().split() 
n = a[0]
q = a[1]
s = a[2]
s = list(s)
cnt = []
l = []
r = []
for i in range(int(q)):
  l.append(a[3+i*2])
  r.append(a[4+i*2])
  cnt.append(0)
print(a)
for i in range(int(q)):
  for j in range(int(l[i]), int(r[i])):
    if j == len(s)-1:
      break
    if s[j-1] == 'A' and s[j] == 'C':
      cnt[i] += 1
for i in range(len(cnt)):
  print(cnt[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
q = int(input())
s = input()
s = list(s)
cnt = []
l = []
r = []
for i in range(q):
  l.append(int(input()))
  r.append(int(input()))
  cnt.append(0)
for i in range(q):
  for j in range(l[i], r[i]):
    if j == len(s)-1:
      break
    if s[j-1] == 'A' and s[j] == 'C':
      cnt[i] += 1
for i in range(len(cnt)):
  print(cnt[i])
Problem p03125 (python)

Fixed submission:
a, b = map(int, input().split())
if b%a == 0:
  print(a+b)
else:
  print(b-a)

Buggy submission (verdict: Runtime Error):
8 20
Problem p03161 (python)

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [int(10000000000)]*100000
dp[0] = 0
cost = 0
if k > len(h):
  k = len(h)
for i in range(0, n):
  for j in range(1, k+1):
    if dp[i] > dp[i-j]+abs(h[i]-h[i-j]):
      dp[i] = dp[i-j]+abs(h[i]-h[i-j])
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [int(10000000000)]*100000
dp[0] = 0
cost = 0
for i in range(0, n):
  for j in range(1, k+1):
    if dp[i] > dp[i-j]+abs(h[i]-h[i-j]):
      dp[i] = dp[i-j]+abs(h[i]-h[i-j])
print(dp[n-1])
Problem p03293 (python)

Fixed submission:
s = input()
t = input()
flag = False
for i in range(len(s)):
    if s == t:
        flag =True
    s = s[-1] + s[0:len(s)-1]
if flag:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
flag = False
for i in range(len(s)):
    if s == t:
        flag =True
    s = s[-1] + s[::len(s)-1
if flag:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
for i in range(len(s)):
    if s[i] != t[-i-1]:
        flag = false
if flag:
    print("Yes")
else:
    print("No")
Problem p03379 (python)

Fixed submission:
import copy
n = int(input())
x = list(map(int, input().split()))
y = copy.copy(x)
y.sort()
cen1 = y[(n-1)//2]
cen2 = y[n//2]
for i in range(n):
    if x[i] < y[n//2]:
        print(cen2)
    else:
        print(cen1)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
y = x.copy()
y.sort()
cen1 = y[(n-1)//2]
cen2 = y[n//2]
for i in range(n):
    if x[i] < y[n//2]:
        print(cen2)
    else:
        print(cen1)
Problem p03380 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = max(a)
a = sorted(a)
ans = 0
for i in a:
    if abs(m/2-i) < abs(m/2-ans):
        ans = i
print(m, ans)

Buggy submission (verdict: Runtime Error):
import bisect
import copy
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = a.copy()
b.pop()
if len(b) == 1:
    idx = 0
else:
    if abs(a[-1]/2 - b[bisect.bisect_left(b, a[-1]/2)]) < abs(a[-1]/2 - b[bisect.bisect_right(b, a[-1]/2)]):
        idx = bisect.bisect_left(b, a[-1]/2)
    else:
        idx = bisect.bisect_right(b, a[-1]/2)
print(a[-1], b[idx])
Problem p03471 (python)

Fixed submission:
n, y = map(int, input().split())
ans = [-1, -1, -1]
for i in range(n+1):
  for j in range(n+1-i):
    k = n-i-j
    if i*10000+j*5000+k*1000 == y and k>=0:
      ans[0] = i
      ans[1] = j
      ans[2] = k
      break
print(ans[0], ans[1], ans[2])

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())
ans = [-1, -1, -1]
for i in range(n+1):
  for j in range(n+1-x):
    k = n-i-j
    if i*10000+j*5000+k*1000 == y and k>=0:
      ans[0] = i
      ans[1] = j
      ans[2] = k
      break
print(ans)
Problem p03607 (python)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    s = int(input())
    a.append(s)
a.sort()
i = 0
cnt = 0
while i < n:
    j = i+1
    chk = 1
    if j >= n:
        cnt += 1 
        break
    while a[i] == a[j]:
        chk += 1
        j += 1
        if j >= n:
            break
    if chk%2 == 1:
        cnt += 1 
    i = j
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    s = int(input())
    a.append(s)
a.sort()
i = 0
cnt = 0
while i < n:
    j = i+1
    chk = 0
    while a[i] == a[j]:
        chk += 1
        j += 1
        if j >= n:
            break
    if chk%2 == 1:
        cnt += 1 
    i = j
print(cnt)
Problem p03625 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 0
x = 0
y = 0
while i < n-1:
    if x == 0:
        if a[i] == a[i+1]:
            x = a[i]
            i += 1
    elif y == 0:
        if a[i] == a[i+1]:
            y = a[i]
            i += 1
    i += 1
print(x*y)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 0
x = 0
y = 0
while i < n:
    if x == 0:
        if a[i] == a[i+1]:
            x = a[i]
            i += 1
    elif y == 0:
        if a[i] == a[i+1]:
            y = a[i]
            i += 1
    i += 1
print(x*y)
Problem p03640 (python)

Fixed submission:
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
field = [[0 for j in range(w)] for i in range(h)]
#[y, x]
d = [[0, 1], [1, 0], [0, -1], [-1, 0]]
y, x = 0, 0
if h == 1 and w == 1:
    print(1)
else:
    for i in range(n):
        cnt = a[i]
        while cnt > 0:
            for j in range(len(d)):
                if 0 <= y + d[j][0] and y + d[j][0] < h and 0 <= x + d[j][1] and x + d[j][1] < w:
                    if field[y+d[j][0]][x+d[j][1]] == 0: 
                        dy, dx = d[j][0], d[j][1]
                        break
            field[y][x] = i+1
            y += dy
            x += dx
            cnt -= 1
    for i in range(h):
        for j in range(w):
            print(field[i][j], end=' ')
        print()

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
field = [[0 for j in range(w)] for i in range(h)]
#[y, x]
d = [[0, 1], [1, 0], [0, -1], [-1, 0]]
y, x = 0, 0
for i in range(n):
    cnt = a[i]
    while cnt > 0:
        for j in range(len(d)):
            if 0 <= y + d[j][0] and y + d[j][0] < h and 0 <= x + d[j][1] and x + d[j][1] < w:
                if field[y+d[j][0]][x+d[j][1]] == 0: 
                    dy, dx = d[j][0], d[j][1]
                    break
        field[y][x] = i+1
        y += dy
        x += dx
        cnt -= 1
for i in range(h):
    for j in range(w):
        print(field[i][j], end=' ')
    print()
Problem p03777 (python)

Fixed submission:
a, b = map(str, 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')
elif a == 'D' and b == 'D':
    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')
elif a == 'D' and b == 'D':
    print('H')
Problem p02684 (python)

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

if K <= 200000:
  i = 1
  for _ in range(K):
    i = A[i-1]
  print(i)
  exit()

visited = {1}
order = [1]

i = 1
for count in range(1, 200001):
  i = A[i-1]
  if i in visited:
    break
  else:
    visited.add(i)
  order.append(i)

idx = order.index(i)
order2 = order[idx:]
# print(order2)
mod = (K+1-idx) % len(order2)

print(order2[mod-1])

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

if K <= 200000:
  i = 1
  for _ in range(K):
    i = A[i-1]
  print(i)
  exit()

visited = {1}
order = []

i = 1
for count in range(1, 200001):
  i = A[i-1]
  if i in visited:
    break
  else:
    visited.add(i)
  order.append(i)

idx = order.index(i)
order2 = order[idx:]
mod = (K-idx) % len(order2)

print(order2[mod-1])
Problem p02743 (python)

Fixed submission:
a, b, c = map(int, input().split())
# import math
# left = a + b + 2 * math.sqrt(a * b)
left = 4 * a * b
right = (c - a - b) ** 2
if (c - a - b) >= 0 and left < right:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
# import math
# left = a + b + 2 * math.sqrt(a * b)
left = 4 * a * b
right = (c - a - b) ** 2
if (c - a - b) >= 0　and left < right:
  print('Yes')
else:
  print('No')
Problem p02900 (python)

Fixed submission:
import math
import fractions

def is_one_or_prime(num):
    dest = int(math.sqrt(num))
    for i in range(2, dest+1):
        if num % i == 0:
            return False
    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

a, b = map(int, input().split())
g = fractions.gcd(a, b)
l = make_divisors(g)
count = 0
for e in l:
  if is_one_or_prime(e):
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import fractions

def is_prime(num):
    dest = int(fractions.sqrt(num))
    for i in range(2, dest+1):
        if num % i == 0:
            return False
    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

a, b = map(int, input().split())
g = math.gcd(a, b)
if is_prime(g):
  print(2)
  exit()

l = make_divisors(g)
count = 0
for e in l:
  if is_prime(e):
    count += 1
print(count)
Problem p02963 (python)

Fixed submission:
s = int(input())
xy = [0, 0, 10**9, 1, 0, 0]

m = s % xy[2]
d = s // xy[2]

xy[4] = 0 if m == 0 else (xy[2] - m)
xy[5] = d if m == 0 else (d + 1)

print(*xy)

Buggy submission (verdict: Runtime Error):
s = int(input())
xy = [0, 0, 10**9, 1, 0, 0]

m = s % xy[2]
d = s // x[2]

xy[4] = 0 if m == 0 else (xy[2] - m)
xy[5] = d if m == 0 else (d + 1)

print(*xy)
Problem p03006 (python)

Fixed submission:
from sys import stdin
from collections import Counter

input = stdin.readline

n = int(input())
if n == 1:
  print(1)
  exit()

xy = [tuple(map(int, input().split())) for _ in range(n)]

l = []
append = l.append
for i in range(n):
  for j in range(n):
    if not i == j:
      append((xy[j][0]-xy[i][0], xy[j][1]-xy[i][1]))
c = Counter(l)
print(n-c.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
from sys import stdin
from collections import Counter

input = stdin.readline

n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]

l = []
append = l.append
for i in range(n):
  for j in range(n):
    if not i == j:
      append((xy[j][0]-xy[i][0], xy[j][1]-xy[i][1]))
c = Counter(l)
print(n-c.most_common()[0][1])
Problem p03032 (python)

Fixed submission:
n, k = map(int, input().split())
v = list(map(int, input().split()))

def solve(L, R, D):
  # print((L, R, D))
  LL = v[:L] if L > 0 else []
  RR = v[-R:] if R > 0 else []
  targetList = LL + RR
  # print(targetList)
  targetList.sort()
  ret = 0
  newList = targetList[::]
  for i in range(min(len(targetList), D)):
    if targetList[i] < 0:
      del newList[0]
  ret = sum(newList)
  # print((ret, newList))
  return ret

result = 0
for i in range(min(k+1, n+1)):
  for j in range(min(k+1, n+1)-i):
    t = solve(i, j, k-i-j)
    if t > result:
      result = t

print(result)

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

def solve(L, R, D):
  # print((L, R, D))
  LL = v[:L] if L > 0 else []
  RR = v[-R:] if R > 0 else []
  targetList = LL + RR
  # print(targetList)
  targetList.sort()
  ret = 0
  newList = targetList.copy()
  for i in range(min(len(targetList), D)):
    if targetList[i] < 0:
      del newList[0]
  ret = sum(newList)
  # print((ret, newList))
  return ret

result = 0
for i in range(min(k+1, n+1)):
  for j in range(min(k+1, n+1)-i):
    t = solve(i, j, k-i-j)
    if t > result:
      result = t

print(result)
Problem p03043 (python)

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

r = 0
for i in range(1, 1+n):
  t = i
  p = 1.0
  while(True):
    if t >= k:
      r += p
      break
    t *= 2
    p *= 0.5
print(r/n)

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

t = []
d = k
while(True):
  d = d / 2
  t.append(d)
  if d <= 1:
    break
# print(t)

t2 = []
nn = 1+n if n < k else k
for i in range(1, nn):
  for j in range(len(t)):
    if i >= t[j]:
      t2.append(j+1)
      break
# print(t2)

t3 = [0.5]
for i in range(1, math.ceil(math.log2(k))):
  t3.append(t3[i-1]*0.5)
# print(t3)

r = 0
for t in t2:
  r += t3[t-1]
r /= n
if n >= k:
  r += (n-k+1) / n
print(r)

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

t = []
d = k
while(True):
  d = d / 2
  t.append(d)
  if d <= 1:
    break
# print(t)

t2 = []
nn = 1+n if n < k else k
for i in range(1, nn):
  for j in range(len(t)):
    if i >= t[j]:
      t2.append(j+1)
      break
# print(t2)

t3 = [0.5]
for i in range(1, len(t2)+2):
  t3.append(t3[i-1]*0.5)
# print(t3)

r = 0
for t in t2:
  r += t3[t-1]
r /= n
if n >= k:
  r += (n-k+1) / n
print(r)

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

t = []
d = k
while(True):
  d = d / 2
  t.append(d)
  if d <= 1:
    break
# print(t)

t2 = []
nn = 1+n if n < k else n-k
for i in range(1, nn):
  for j in range(len(t)):
    if i >= t[j]:
      t2.append(j+1)
      break
# print(t2)

t3 = [0.5]
for i in range(1, len(t2)+2):
  t3.append(t3[i-1]*0.5)
# print(t3)

r = 0
for t in t2:
  r += t3[t-1]
r /= n
if n >= k:
  r += k / n
print(r)

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

t = []
d = k
while(True):
  d = d / 2
  t.append(d)
  if d <= 1:
    break
# print(t)

t2 = []
for i in range(1, 1+n):
  for j in range(len(t)):
    if i >= t[j]:
      t2.append(j+1)
      break
# print(t2)

t3 = [0.5]
for i in range(1, len(t2)+2):
  t3.append(t3[i-1]*0.5)
# print(t3)

r = 0
for t in t2:
  r += t3[t-1]
print(r/n)

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

t = []
d = k
while(True):
  d = d / 2
  t.append(d)
  if d <= 1:
    break
# print(t)

t2 = []
for i in range(1, 1+n):
  for j in range(len(t)):
    if i >= t[j]:
      t2.append(j+1)
      break
# print(t2)

t3 = [0.5]
for i in range(1, len(t2)+1):
  t3.append(t3[i-1]*0.5)
# print(t3)

r = 0
for t in t2:
  r += t3[t-1]
print(r/n)
Problem p02787 (python)

Fixed submission:

hp, n = map(int,input().split())

list = [[0] * 2 for i in range(n)]
for i in range(n):
    list[i][0], list[i][1] = map(int,input().split())

dp = [[10000000000] * (hp+1) for i in range(n+1)]

dp[0][0] = 0
for i, lista in enumerate(dp):
    dp[i][0] = 0
    for j, value in enumerate(lista):
        if i == 0:
            continue
        if j < list[i-1][0]:
            dp[i][j] = min(list[i-1][1], dp[i-1][j])
        else:
            target = j - list[i-1][0]
            dp[i][j] = min((dp[i][target] + list[i-1][1]), dp[i-1][j])

print(int(dp[n][hp]))

Buggy submission (verdict: Runtime Error):
import numpy as np
hp, n = map(int,input().split())

list = np.zeros((n,2))
for i in range(n):
    list[i][0], list[i][1] = map(int,input().split())

dp = np.full((n+1, hp+1), 100000000000000000)

dp[0][0] = 0
for i, lista in enumerate(dp):
    dp[i][0] = 0
    for j, value in enumerate(lista):
        if i == 0:
            continue
        if j < list[i-1][0]:
            dp[i][j] = min(list[i-1][1], dp[i-1][j])
        else:
            target = int(j - list[i-1][0])
            dp[i][j] = min((dp[i][target] + list[i-1][1]), dp[i-1][j])

print(dp[n][hp])