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

Fixed submission:
import heapq
from collections import deque
import sys
input = sys.stdin.readline
x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort(reverse=True)
red_que = p[a-x:]
heapq.heapify(red_que)
green_que = q[b-y:]
heapq.heapify(green_que)
for i in range(c):
    re_mi = heapq.heappop(red_que)
    gr_mi = heapq.heappop(green_que)
    if re_mi < gr_mi:
        if re_mi < r[i]:
            heapq.heappush(red_que,r[i])
            heapq.heappush(green_que,gr_mi)
        else:
            heapq.heappush(green_que,gr_mi)
            heapq.heappush(red_que,re_mi)
            break
    else:
        if gr_mi < r[i]:
            heapq.heappush(red_que,re_mi)
            heapq.heappush(green_que,r[i])
        else:
            heapq.heappush(green_que,gr_mi)
            heapq.heappush(red_que,re_mi)
            break
print(sum(green_que) + sum(red_que))

Buggy submission (verdict: Runtime Error):
import bisect
from collections import deque
x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
red_que = deque(p[:x])
green_que = deque(q[:y])
for i in range(c):
    if red_que[-1] < green_que[-1]:
        if red_que[-1] < r[i]:
            red_que.pop()
            bisect.insort_left(red_que, r[i])
        else:
            break
    else:
        if green_que[-1] < r[i]:
            green_que.pop()
            bisect.insort_left(green_que, r[i])
print(sum(green_que) + sum(red_que))
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
ans = ["-1" for i in range(n)]
for i in range(m):
    s, c = input().split()
    s = int(s)
    if s == 1 and c == '0' and n != 1:
        print(-1)
        exit()
    if ans[s-1] == "-1":
        ans[s-1] = c
    else:
        if ans[s-1] != c:
            print(-1)
            exit()
if ans[0] == '-1':
    ans[0] = "1"
if m == 0:
    ans[n-1] = "0"
print(("".join(ans)).replace("-1","0"))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ans = ["-1" for i in range(n)]
for i in range(m):
    s, c = input().split()
    s = int(s)
    if s == 1 and c == '0':
        print(-1)
        exit()
    if ans[s-1] == "-1":
        ans[s-1] = c
    else:
        if ans[s-1] != c:
            print(-1)
            exit()
if ans[0] == '-1':
    ans[0] = 1
print(("".join(ans)).replace("-1","0"))
Problem p02804 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
mod = 10**9+7
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]
# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
#a/b = a*(b`)となるb`を求める
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod
factorial = [1 for i in range(n+1)]
factorial[0] = 1
for i in range(1,n + 1):
    factorial[i] = factorial[i-1] * i
    factorial[i] %= mod
def mod_combi(a,b):
    if b == 0:
        return 1
    elif a == 0 or a < b:
        return 0
    elif a == b:
        return 1
    else:
        return (factorial[a] * mod_inv(factorial[b], mod) * mod_inv(factorial[a-b],mod)) % mod
ans = 0
#それぞれについて、最小になる場合と最大になる場合をもとめ、ans に加算する。
for i in range(n):
    patt_max = mod_combi(i, k-1)
    patt_min = mod_combi(n-i-1, k-1)
    ans += (patt_max - patt_min) * a[i]
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
def combi(x, y):
    if x < y:
        return 0
    if (x,y) in memo:
        return memo[(x,y)]
    else:
        memo[(x,y)]  = math.factorial(x) / (math.factorial(x - y) * math.factorial(y))
        return memo[(x,y)]
import math
memo = dict()
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
mod = 10**9+7
ans = 0
for i in range(n):
    #今回の数字が、最小値として数えられる数の合計
    ans -= a[i] * combi(n - i - 1, k-1)
    #今回の数字が、最大値として数えられる数の合計
    ans += a[i] * combi(i,k-1)
    ans %= mod
print(int(ans))

Buggy submission (verdict: Runtime Error):
def combi(x, y):
    if x < y:
        return 0
    if (x,y) in memo:
        return memo[(x,y)]
    else:
        memo[(x,y)]  = math.factorial(x) / (math.factorial(x - y) * math.factorial(y))
        return memo[(x,y)]
import math
memo = dict()
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
mod = 10**9+7
ans = 0
for i in range(n):
    #今回の数字が、最小値として数えられる数の合計
    ans -= a[i] * combi(n - i - 1, k-1)
    #今回の数字が、最大値として数えられる数の合計
    ans += a[i] * combi(i,k-1)
    ans %= mod
print(int(ans))
Problem p02824 (python)

Fixed submission:
n,m,v,p = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
def binary_search(left, right):
    if right - left <= 1:
        return left
    middle = (left + right) // 2
    if check(middle):
        return binary_search(middle, right)
    else:
        return binary_search(left, middle)

def check(target):
    used_vote = (p + n - target - 1) * m
    sum_vote = 0
    for i in range(target-1, p-2, -1):
        if a[target] + m < a[i]:
            return False
        sum_vote += (a[target] + m) - a[i]
    if sum_vote >= (m * v - used_vote): 
        return True
    else:
        return False
print(binary_search(0,n) + 1)

Buggy submission (verdict: Runtime Error):
import itertools
n,m,v,p = map(int, input().split())
a = list(map(int, input().split()))
ans = p
a.sort(reverse=True)
def binary_search(left, right):
    if right - left <= 1:
        return left
    middle = (left + right) // 2
    if check(middle):
        return binary_search(middle, right)
    else:
        return binary_search(left, middle)

def check(target):
    used_vote = (p + n - target - 1) * m
    sum_vote = 0
    for i in range(target-1, p-2, -1):
        sum_vote += (a[target] + m) - a[i]
    if sum_vote >= m * v - used_vote: 
        return True
    else:
        return False

print(binary_search(0,n+1) + 1)

Buggy submission (verdict: Runtime Error):
n ,a, b = map(int, input().split())
dis = b - a
if dis % 2 == 0:
    print(dis // 2)
else:
    shiftR = (n-b)
    shiftL = (a-1)
    ans = min(n-a,b-1, shiftR + 1 + ((n - (a + 1) + shiftR) //2), shiftL + 1 + (((b - 1) - shiftL - 1) // 2))
    print(ans)
Problem p02838 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.reverse()
    mod = 7 + 10**9
    leng = len(format(max(a), 'b'))
    bit_acc = [0 for i in range(leng)]
    for i in range(n):
        #先頭から二進数を0埋めした
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                bit_acc[j] += 1
    ans = 0
    p = [pow(2,leng - 1 - j, mod) for j in range(leng)]
    for i in range(n):
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                ans += (n - bit_acc[j]) * p[j]
            else:
                ans += bit_acc[j] * p[j]
            ans %= mod
    print((ans * 500000004) % mod)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque
n = int(input())
a = list(map(int, input().split()))
a.reverse()
mod = 7 + 10**9
leng = 61
data = [[0 for i in range(leng+1)]for j in range(n)]
#pre
for i in range(n):
    k = deque(bin(a[i]))
    k.reverse()
    for j in range(1, leng+1):
        if j - 1 >= len(k):
            data[i][j] = data[i - 1][j]
            continue
        if k[j - 1] == "1":
            data[i][j] = data[i - 1][j] + 1
        else:
            data[i][j] = data[i-1][j]
ans = 0
a.reverse()
data.reverse()
for i in range(n-1):
    k = deque(bin(a[i]))
    k.reverse()
    k.pop()
    k.pop()
    k = deque((map(int, k)))
    k = k + deque([0 for i in range(leng - len(k))])
    for j in range(leng):
        if k[j] == 1:
            ans += ((n - i - 1) - data[i+1][j+1]) * (2**j)
            ans %= mod
        else:
            ans += data[i+1][j+1] * (2**j)
            ans %= mod
print(ans)
Problem p02839 (python)

Fixed submission:
import sys
input = sys.stdin.readline
h, w = map(int, input().split())
grid = []
bias_inf = 2000
for i in range(h):
    k = list(map(int, input().split()))
    grid.append(k)
for i in range(h):
    k = list(map(int, input().split()))
    for j in range(w):
        grid[i][j] = abs(grid[i][j] - k[j])

dp = [[[0 for i in range(-bias_inf,bias_inf)] for j in range(w)] for k in range(h)]
dp[0][0][0 - grid[0][0]] = 1
dp[0][0][0 + grid[0][0]] = 1
for i in range(h):
    for j in range(w):
        for k in range(-bias_inf,bias_inf):
            if i == h-1 and j == w-1:
                break
            if dp[i][j][k]:
                if i != h-1 and j != w-1:
                    dp[i][j+1][k + grid[i][j+1]] = 1
                    dp[i+1][j][k + grid[i+1][j]] = 1
                    dp[i][j+1][k - grid[i][j+1]] = 1
                    dp[i+1][j][k - grid[i+1][j]] = 1
                elif j == w-1:
                    dp[i+1][j][k - grid[i+1][j]] = 1
                    dp[i+1][j][k + grid[i+1][j]] = 1
                else:
                    dp[i][j+1][k - grid[i][j+1]] = 1
                    dp[i][j+1][k + grid[i][j+1]] = 1
ans = bias_inf
for i in range(-bias_inf,bias_inf):
    if dp[-1][-1][i]:
        ans = min(ans, abs(i))
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
input = sys.stdin.readline
h, w = map(int, input().split())
grid = []
bias_inf = 2000
for i in range(h):
    k = list(map(int, input().split()))
    grid.append(k)
for i in range(h):
    k = list(map(int, input().split()))
    for j in range(w):
        grid[i][j] = abs(grid[i][j] - k[j])

dp = np.full((h,w,bias_inf*2), False)
dp[0][0][0 - grid[0][0]] = True
dp[0][0][0 + grid[0][0]] = True
for i in range(h):
    for j in range(w):
        for k in range(-bias_inf,bias_inf):
            if i == h-1 and j == w-1:
                break
            if dp[i][j][k]:
                if i == h-1:
                    dp[i][j+1][k - grid[i][j+1]] = True
                    dp[i][j+1][k + grid[i][j+1]] = True
                elif j == w-1:
                    dp[i+1][j][k - grid[i+1][j]] = True
                    dp[i+1][j][k + grid[i+1][j]] = True
                else:
                    dp[i][j+1][k + grid[i][j+1]] = True
                    dp[i+1][j][k + grid[i+1][j]] = True
                    dp[i][j+1][k - grid[i][j+1]] = True
                    dp[i+1][j][k - grid[i+1][j]] = True
ans = bias_inf
for i in range(-bias_inf,bias_inf):
    if dp[-1][-1][i]:
        ans = min(ans, abs(i))
print(ans)
Problem p02846 (python)

Fixed submission:
t1, t2 = map(int, input().split())
a1,a2 = map(int, input().split())
b1, b2 = map(int, input().split())
#t1で生まれる差
P = (a1 - b1) * t1
#t2で生まれる差
Q = (a2 - b2) * t2
#P < 0 のことを仮定する
if P > 0:
    P *= -1
    Q *= -1

if P + Q < 0:
    print(0)
elif P + Q == 0:
    print("infinity")
else:
    #つぎのPを足したときに、負にいくかどうか？
    i = P * (-1)
    if i % (P + Q) == 0:
        print(2 * (i // (P + Q)))
    else:
        print(2 * (i // (P + Q)) + 1)

Buggy submission (verdict: Runtime Error):
t1, t2 = map(int, input().split())
a1,a2 = map(int, input().split())
b1, b2 = map(int, input().split())
#t1で生まれる差
P = (a1 - b1) * t1
#t2で生まれる差
Q = (a2 - b2) * t2
#P < 0 のことを仮定する
if P > 0:
    P *= -1
    Q *= -1

if P + Q < 0:
    print(0)
elif P == Q:
    print("infinity")
else:
    #つぎのPを足したときに、負にいくかどうか？
    if (-P) % (P + Q) == 0:
        print(2 * ((-P) // (P + Q)) + 2)
    else:
        print(2 * ((-P) // (P + Q)) + 1)
Problem p02898 (python)

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
sum = 0
for i in h:
    if i >= k:
        sum += 1
print(sum)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
sum = 0
for i in h:
    if h >= k:
        sum += 1
print(sum)
Problem p02900 (python)

Fixed submission:
import math
def euqlid(x,y):
    while x % y != 0:
        tmp = x % y
        x = y
        y = tmp
    return y
a, b = map(int, input().split())
if a < b:
    tmp = a
    a = b
    b = tmp
k = euqlid(a, b)
sum = 0
i = 2
if k == 1:
    print(1)
    exit()
while i <= math.sqrt(k):
    flag = False
    while k % i == 0:
        k = k // i
        flag = True
    if flag:
        sum += 1
    i += 1
if i <= k:
    sum += 1
print(sum + 1)

Buggy submission (verdict: Runtime Error):
import sympy
def euqlid(x,y):
    if x < y:
        tmp = x
        x  = y
        y = tmp
    while x % y != 0:
        tmp = x % y
        x = y
        y = tmp
    return y
a, b = map(int, input().split())
k = euqlid(a, b)
data = sympy.factorint(k)
print(len(data) + 1)

Buggy submission (verdict: Runtime Error):
import sympy
def euqlid(x,y):
    if x < y:
        tmp = x
        x  = y
        y = tmp
    while x % y != 0:
        tmp = x % y
        x = y
        y = tmp
    return y
a, b = map(int, input().split())
k = euqlid(a, b)
data = sympy.factorint(k)
print(len(data) + 1)
Problem p02901 (python)

Fixed submission:
from collections import deque
n , m = map(int, input().split())
keys = deque()
def trans(k):
    res = [0 for i in range(n)]
    for i in k:
        res[-i] = 1
    res = int("".join(map(str, res)), 2)
    return res

for i in range(m):
    a, b = list(map(int, input().split()))
    c = deque(list(map(int, input().split())))
    c.appendleft(a)
    keys.append(c)
inf = 10 ** 8
dp = [inf for i in range(2**n)]
dp[0] = 0
for i in range(m):
    key_value = keys[i].popleft()
    can_open = keys[i]
    p = trans(can_open)
    for j in range(2**n):
        next = j | p
        dp[next] = min(dp[next], dp[j] + key_value)
#print(dp)
if dp[-1] >= inf:
    print(-1)
else:
    print(dp[-1])

Buggy submission (verdict: Runtime Error):
from collections import deque
n , m = map(int, input().split())
keys = deque()
def trans(k):
    res = [0 for i in range(n)]
    for i in k:
        res[-i] = 1
    res = int("".join(map(str, res)), 2)
    return res

for i in range(m):
    a, b = list(map(int, input().split()))
    c = deque(list(map(int, input().split())))
    keys.append(deque([a]) + c)
inf = 10 ** 8
dp = [inf for i in range(2**n)]
dp[0] = 0
for i in range(m):
    key_value = keys[i-1].popleft()
    can_open = keys[i-1]
    for j in range(2**n):
        next = j | trans(can_open)
        dp[next] = min(dp[next], dp[j] + key_value)
#print(dp)
if dp[-1] >= inf:
    print(-1)
else:
    print(dp[-1])

Buggy submission (verdict: Runtime Error):
from collections import deque
n , m = map(int, input().split())
keys = deque()
def trans(k):
    res = [0 for i in range(n)]
    for i in k:
        res[-i] = 1
    res = int("".join(map(str, res)), 2)
    return res

for i in range(m):
    a, b = list(map(int, input().split()))
    c = deque(list(map(int, input().split())))
    keys.append(deque([a]) + c)
inf = 10 ** 8
dp = [inf for i in range(2**n)]
dp[0] = 0
for i in range(m):
    key_value = keys[i-1].popleft()
    can_open = keys[i-1]
    for j in range(2**n):
        next = j | trans(can_open)
        dp[next] = min(dp[next], dp[j] + key_value)
#print(dp)
if dp[-1] >= inf:
    print(-1)
else:
    print(dp[-1])
Problem p02903 (python)

Fixed submission:
import numpy as np
h, w, a, b = list(map(int, input().split()))
Ans = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if ( i < b and j >= a ) or ( i >= b and j < a) :
            Ans[i][j] = 1
for i in range(h):
    print(''.join(list(map(str, Ans[i]))))

Buggy submission (verdict: Runtime Error):
import numpy as np
h, w, a, b = list(map(int, input().split()))
Ans = [[0 for i in range(h)] for j in range(w)]
for i in range(h):
    for j in range(w):
        if ( i < b and j >= a ) or ( i >= b and j < a) :
            Ans[i][j] = 1
for i in range(h):
    print(''.join(list(map(str, Ans[i]))))
Problem p02918 (python)

Fixed submission:
n, k = map(int, input().split())
s = input()
pre = 0
sepS = []
happyCount = 0
RLcount = 0
for i in range(1, n):
    if s[i] == s[i - 1]:
        happyCount += 1
    if s[i] == 'L' and s[i - 1] == 'R':
        RLcount += 1
#print("now HP =>{}".format(happyCount))
happyCount += min(k, RLcount) * 2
if k > RLcount:
    happyCount += 1
print(min(n - 1, happyCount))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
pre = 0
sepS = []
happyCount = 0
RLcount = 0
for i in range(1, n):
    if s[i] == s[i - 1]:
        happyCount += 1
    if s[i] == 'L' and s[i - 1] == 'R':
        RLcount += 1
#print("now HP =>{}".format(happyCount))
happyCount += min(k, RLcount) * 2
if k > RLcount:
    happyCount += 1
print(min(n - 1, happyCount)
Problem p02924 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = list(range(1,n+1))
if n >= 3:
    print(sum(ans[1:-1]) + 1)
elif n == 2:
    print(1)
else:
    print(0)
Problem p02936 (python)

Fixed submission:
import sys
from queue import *
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, q = list(map(int, input().split()))

adjacent_list = [[] for i in range(n+1)]
for i in range(n - 1):
    a, b = map(int, input().split())
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)
tree_value = [0]*(n+1)
for i in range(q):
    p, x = map(int, input().split())
    tree_value[p] += x
searched = set()
"""
def dfs(node, count):
    searched.add(node)
    tree_value[node] += count
    for i in adjacent_list[node]:
        if i not in searched:
            dfs(i, tree_value[node])
"""
used = [0 for i in range(n+1)]
que = Queue()
que.put(1)
while que.qsize() != 0:
    m = que.get()
    used[m] = 1
    for i in adjacent_list[m]:
        if not used[i]:
            tree_value[i] += tree_value[m]
            que.put(i)
for i in range(1,n+1):
    print("{} ".format(tree_value[i]), end = "")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

n, q = list(map(int, input().split()))
adjacent_list = [[] for i in range(n+1)]
for i in range(n - 1):
    a, b = map(int, input().split())
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)
tree_value = [0]*(n+1)
for i in range(q):
    p, x = map(int, input().split())
    tree_value[p] += x
searched = set()
def dfs(node, count):
    searched.add(node)
    tree_value[node] += count
    for i in adjacent_list[node]:
        if i not in searched:
            dfs(i, tree_value[node])
dfs(1,0)
for i in range(1,n+1):
    print(tree_value[i])

Buggy submission (verdict: Runtime Error):
n, q = list(map(int, input().split()))
adjacent_list = [[] for i in range(n+1)]
for i in range(n - 1):
    a, b = map(int, input().split())
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)
tree_value = [0]*(n+1)
for i in range(q):
    p, x = map(int, input().split())
    tree_value[p] += x
searched = set()
def dfs(node, count):
    searched.add(node)
    tree_value[node] += count
    for i in adjacent_list[node]:
        if i not in searched:
            dfs(i, tree_value[node])
dfs(1,0)
for i in range(1,n+1):
    print(tree_value[i])

Buggy submission (verdict: Runtime Error):
n, q = list(map(int, input().split()))
adjacent_list = [[] for i in range(n+1)]
for i in range(n - 1):
    a, b = map(int, input().split())
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)
tree_value = [0]*(n+1)
for i in range(q):
    p, x = map(int, input().split())
    tree_value[p] += x
searched = set()
def dfs(node, count):
    searched.add(node)
    tree_value[node] += count
    for i in adjacent_list[node]:
        if i not in searched:
            dfs(i, tree_value[node])
dfs(1,0)
for i in range(1,n):
    print(tree_value[i])
Problem p02937 (python)

Fixed submission:
import bisect
s = input()
t = input()
data = {}
max_s = len(s) + 1
for i in range(26):
    data[chr(i + ord('a'))] = []
for i in range(len(s)):
    data[s[i]].append(i+1)
for i in range(26):
    data[chr(i + ord('a'))].append(max_s)
pre = 0
ans = 0
for i in range(len(t)):
    char = t[i]
    if len(data[char]) == 1:
        print(-1)
        exit()
    else:
        index = bisect.bisect_left(data[char], pre+1)
        if data[char][index] == max_s:
            ans += len(s) - pre
            pre = data[char][0]
            ans += pre
        else:
            ans += data[char][index] - pre
            pre = data[char][index]
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
data = {}
max = len(s)
for i in range(24):
    data[chr(i + ord('a'))] = max + 1
for i in range(len(s)):
    if data[s[i]] > i + 1:
        data[s[i]] = i + 1
ans = 0
pre = max
for i in range(len(t)):
    if data[t[i]] == max + 1:
        print(-1)
        exit()
    else:
        if pre < data[t[i]]:
            ans += (data[t[i]] - pre)
            pre = data[t[i]]
        else:
            ans += (max + data[t[i]] - pre)
            pre = data[t[i]]
    
print(ans)
Problem p02963 (python)

Fixed submission:
import math
s = int(input())
r = math.floor(math.sqrt(s)) + 1
k = r**2 - s
if r == 10**9 + 1:
    print("{} {} {} {} {} {}".format(0, 0, 1,r - 1,r - 1, 0))
    exit()
def search_prime(k):
    p = math.floor(math.sqrt(k))
    for i in range(2,p + 1):
        if k % i == 0:
            return i
    return 1
prime = search_prime(k)
print("{} {} {} {} {} {}".format(0, 0, prime,r,r, int(k / prime)))

Buggy submission (verdict: Runtime Error):
import math
s = int(input())
r = math.floor(math.sqrt(s + 1)) 
k = r**2 - s
def search_prime(k):
    p = math.floor(math.sqrt(k))
    for i in range(2,p + 1):
        if k % i == 0:
            return i
    return 1
prime = search_prime(k)
print("{} {} {} {} {} {}".format(0, 0, prime,r,r, int(k / prime)))

Buggy submission (verdict: Runtime Error):
import math
s = int(input())
r = math.floor(math.sqrt(s)) + 1 - 1
k = r**2 - s
def search_prime(k):
    p = math.floor(math.sqrt(k))
    for i in range(2,p + 1):
        if k % i == 0:
            return i
    return 1
prime = search_prime(k)
print("{} {} {} {} {} {}".format(0, 0, prime,r,r, int(k / prime)))

Buggy submission (verdict: Runtime Error):
import math
s = int(input())
r = math.floor(math.sqrt(s))
k = r**2 - s
def search_prime(k):
    p = math.floor(math.sqrt(k))
    for i in range(2,p + 1):
        if k % i == 0:
            return i
    return 1
prime = search_prime(k)
print("{} {} {} {} {} {}".format(0, 0, prime,r,r, int(k / prime)))

Buggy submission (verdict: Runtime Error):
import math
s = int(input())
r = math.floor(math.sqrt(s)) + 1
def search_prime(k):
    p = math.floor(math.sqrt(k))
    for i in range(2,p + 1):
        if k % i == 0:
            return i
    return 1
prime = search_prime(k)
print("{} {} {} {} {} {}".format(0, 0, prime,r,r, int(k / prime)))
Problem p02969 (python)

Fixed submission:
r = int(input())
print(3 * r * r)

Buggy submission (verdict: Runtime Error):
r = input()
print(3 * r * r)
Problem p02973 (python)

Fixed submission:
import bisect
from collections import deque
n = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[i] = int(input())
count = deque()
count.append(a[0])
for i in range(1, n):
    
    index = bisect.bisect_left(count, a[i])
    
    if index == 0:
        count.appendleft(a[i])
    else:
        count[index - 1] = a[i]
    #print("{}  {}".format(count, index))
print(len(count))

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
count = 0
min = a[0]
for i in range(n):
    if min > a[i]:
        min = a[i]
        count += 1
print(count)