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

Fixed submission:
s = list(str(input()))
n = len(s)
ans = [0] * n
for ri in range(2):
    cnt = 0
    for i in range(n):
        if s[i] == "R":
            cnt += 1
        else:
            ans[i] += cnt // 2
            ans[i - 1] += (cnt + 1) // 2
            cnt = 0

    s.reverse()
    ans.reverse()
    for i in range(n):
        if s[i] == "L":
            s[i] = "R"
        else:
            s[i] = "L"

print(" ".join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
_s = str(input())
 
l_arr = _s.split("L")
r_arr = _s.split("R")
l_max = max([len(x) for x in l_arr])
r_max = max([len(x) for x in r_arr])
t = max(l_max, r_max)
if t % 2 != 0:
    t -= 1
 
s = list(_s)
 
lg = len(s)
arr = [1 for i in range(lg)]
 
for i in range(t):
    next_arr = [0 for i in range(lg)]
    for j in range(lg):
        cmd = s[j]
        curr = arr[j]
        if cmd == "L":
            next_arr[j - 1] += curr
        else:
            next_arr[j + 1] += curr
    arr = next_arr
    
print(" ".join(map(str, arr)))
_s = str(input())

l_arr = _s.split("L")
r_arr = _s.split("R")
l_max = max([len(x) for x in l_arr])
r_max = max([len(x) for x in r_arr])
t = max(l_max, r_max)
if t % 2 != 0:
    t -= 1

s = list(_s)

lg = len(s)
arr = [1 for i in range(lg)]

for i in range(t):
    next_arr = [0 for i in range(lg)]
    for j in range(lg):
        cmd = s[j]
        curr = arr[j]
        if cmd == "L":
            next_arr[j - 1] += curr
        else:
            next_arr[j + 1] += curr
    arr = next_arr
    
print(" ".join(map(str, arr)))
提出情報
提出日時	2019-08-12 10:13:16
問題	D - Gathering Children
ユーザ	rororo 
言語	PyPy3 (2.4.0)
Problem p02863 (python)

Fixed submission:
import sys
import numpy as np

def main():
    input = sys.stdin.readline
    N, T = map(int, input().split())
    dishes = []
    for _ in range(N):
        a, b = map(int, input().split())
        dishes.append((a, b))
    
    dishes = sorted(dishes, key=lambda x: x[0])
    
    ans = 0
    dp = np.zeros(T, dtype=int)
    for a, b in dishes:
        ans = max(ans, dp.max() + b)
        np.maximum(dp[:-a] + b, dp[a:], out=dp[a:])

    return ans

if __name__ == '__main__':
    print(main())

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

def main():
    input = sys.stdin.readline
    N, T = map(int, input().split())
    dishes = []
    for _ in range(N):
        a, b = map(int, input().split())
        dishes.append((a, b))
    
    dishes = sorted(dishes, key=lambda x: x[0])
    
    ans = 0
    dp = np.zeros(T, dtype=int)
    for a, b in dishes:
        ans = max(ans, dp.max() + b)
        np.maximum(dp[:-a] + b, dp[a:], out=dp[a:])

    return ans

if __name__ == '__main__':
    print(main())
Problem p02892 (python)

Fixed submission:
import sys
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
sys.setrecursionlimit(10**7)


def main():
    input = sys.stdin.readline
    N = int(input())
    G = []
    for _ in range(N):
        S = [int(c) for c in str(input().strip())]
        T = []
        for i, e in enumerate(S):
            if e == 1:
                T.append(i)
        G.append(T)
    
    colors = [-1] * N
    visited = [False] * N
    def is_binarygraph(v, color):
        visited[v] = True
        for n in G[v]:
            if colors[n] == color:
                return False
            if visited[n]:
                continue
            colors[n] = (color + 1) % 2
            if not is_binarygraph(n, colors[n]):
                return False
        return True
    
    colors[0] = 0
    if not is_binarygraph(0, 0):
        return -1

    inf = 10**3
    d = [[inf]*N for _ in range(N)]
    for i in range(N):
        for j in G[i]:
            d[i][j] = 1
    for i in range(N):
        d[i][i] = 0
    
    fw = floyd_warshall(d)
    return np.max(fw) + 1

if __name__ == '__main__':
    print(int(main()))

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

def warshall_floyd(d):
    n = len(d)
    for i in range(n):
        for j in range(n):
            for k in range(n):
                d[j][k] = min(d[j][k], d[j][i] + d[i][k])
    return d

def main():
    input = sys.stdin.readline
    N = int(input())
    G = []
    for _ in range(N):
        S = [int(c) for c in str(input().strip())]
        T = []
        for i, e in enumerate(S):
            if e == 1:
                T.append(i)
        G.append(T)
    
    def is_binarygraph(v, color):
        colors = [-1] * N
        colors[v] = color
        for n in G[v]:
            if colors[n] == color:
                return False
            colors[n] = (color + 1) % 2
            if not is_binarygraph(n, (color+1)%2):
                return False
        return True
    
    if not is_binarygraph(0, 0):
        return -1

    inf = 10**3
    d = [[inf]*N for _ in range(N)]
    for i in range(N):
        for j in range(G[i]):
            d[i][j] = 1
    
    fw = warshall_floyd(d)
    return max(fw)

if __name__ == '__main__':
    print(main())
Problem p02998 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

def main():
    input = sys.stdin.readline
    V = 10**5  # max size of x
    N = int(input())
    bgraph = [[] for _ in range(2*V)]
    for _ in range(N):
        x, y = map(int, input().split())
        x -= 1
        y += V - 1
        bgraph[x].append(y)
        bgraph[y].append(x)

    def dfs(i):
        if visited[i]:
            return cnt
        visited[i] = True
        cnt[i//V] += 1
        for j in bgraph[i]:
            dfs(j)
        return cnt

    visited = [False] * (2*V)
    ans = 0
    for i in range(V):
        if visited[i]:
            continue
        cnt = [0, 0]
        cnt = dfs(i)
        ans += cnt[0] * cnt[1]

    ans -= N
    return ans


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    V = 10**5  # max size of x
    N = int(input())
    bgraph = [[] for _ in range(2*V)]
    for _ in range(N):
        x, y = map(int, input().split())
        x -= 1
        y += V - 1
        bgraph[x].append(y)
        bgraph[y].append(x)

    def dfs(i):
        if visited[i]:
            return cnt
        visited[i] = True
        cnt[i//V] += 1
        for j in bgraph[i]:
            dfs(j)
        return cnt

    visited = [False] * (2*V)
    ans = 0
    for i in range(V):
        if visited[i]:
            continue
        cnt = [0, 0]
        cnt = dfs(i)
        ans += cnt[0] * cnt[1]

    ans -= N
    return ans


if __name__ == '__main__':
    print(main())
Problem p03018 (python)

Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    S = input().strip()
    n = len(S)

    T = ''
    i = 0
    while i < n:
        if S[i] == 'A':
            T += 'A'
            i += 1
        elif S[i:i+2] == 'BC':
            T += 'D'
            i += 2
        else:
            T += S[i]
            i += 1

    ans = 0
    cnt = 0
    for c in T:
        if c == 'A':
            cnt += 1
        elif c == 'D':
            ans += cnt
        else:
            cnt = 0

    return ans


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    S = list(input().strip())
    n = len(S)

    ans = 0
    cnt = 0
    for i in range(n):
        if S[i:i+3] == ['A', 'B', 'C']:
            cnt += 1
            S[i] = 'B'
            S[i+1] = 'C'
            S[i+2] = 'A'

    S = S[::-1]
    for i in range(n):
        if S[i:i+3] == ['C', 'B', 'A']:
            cnt += 1
            S[i] = 'A'
            S[i+1] = 'C'
            S[i+2] = 'B'

    ans += cnt
    while cnt > 0:
        cnt = 0
        S = S[::-1]
        for i in range(n):
        if S[i:i+3] == ['A', 'B', 'C']:
            cnt += 1
            S[i] = 'B'
            S[i+1] = 'C'
            S[i+2] = 'A'

        S = S[::-1]
        for i in range(n):
            if S[i:i+3] == ['C', 'B', 'A']:
                cnt += 1
                S[i] = 'A'
                S[i+1] = 'C'
                S[i+2] = 'B'

        ans += cnt


    return ans


if __name__ == '__main__':
    print(main())
Problem p03038 (python)

Fixed submission:
import sys
from heapq import heappush, heappop

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    heap = []
    ans = 0
    for a in map(int, input().split()):
        heappush(heap, a)
        ans += a

    BC = []
    for _ in range(M):
        B, C = map(int, input().split())
        BC.append((B, C))

    BC = sorted(BC, key=lambda x: -x[1])
    for B, C in BC:
        for _ in range(B):
            a = heappop(heap)
            if a < C:
                heappush(heap, C)
                ans += C - a
            else:
                heappush(heap, a)
                break

    return ans


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    for _ in range(M):
        b, c = map(int, input().split())
        A += [c] * b

    A = sorted(A, key=lambda x: -x)
    return sum(A[:N]


if __name__ == '__main__':
    print(main())
Problem p03053 (python)

Fixed submission:
#ref: https://atcoder.jp/contests/agc033/submissions/5260580

import sys
import numpy as np

def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    INF = H * W
    dp = [[INF if c == '.' else 0 for c in input().strip()] for _ in range(H)]
    dp = np.array(dp)

    for i in range(1, H):
        dp[i, :] = np.minimum(dp[i, :], dp[i-1, :] + 1)

    for i in range(H-2, -1, -1):
        dp[i, :] = np.minimum(dp[i, :], dp[i+1, :] + 1)

    for i in range(1, W):
        dp[:, i] = np.minimum(dp[:, i], dp[:, i-1] + 1)

    for i in range(W-2, -1, -1):
        dp[:, i] = np.minimum(dp[:, i], dp[:, i+1] + 1)

    return np.max(dp)

if __name__ == '__main__':
    print(main())

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

def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    A = [[0 if c == '.' else 1 for c in input().strip()] for _ in range(H)]

    A = np.array(A)
    B = np.array(np.nonzero(A))
    Bx = np.tile(B[0], (H*W,1))
    By = np.tile(B[1], (H*W,1))

    _, n = B.shape
    x = list(range(H)) * W
    x.sort()
    X = np.array([x]*n)

    y = list(range(W)) * H
    Y = np.array([y]*n)

    d = np.abs(X - Bx.T) + np.abs(Y - By.T)
    return np.max(np.min(d, axis=0))

if __name__ == '__main__':
    print(main())

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

def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    A = [[0 if c == '.' else 1 for c in input().strip()] for _ in range(H)]

    A = np.array(A)
    N = np.array(np.nonzero(A))

    x = list(range(H)) * W
    x.sort()
    y = list(range(W)) * H
    P = np.array((x, y))

    dist = np.array([2001] * (H*W))

    _, n = N.shape
    for i in range(n):
        d = np.abs(P[0] - N[0][i]) + np.abs(P[1] - N[1][i])
        dist = np.minimum(d, dist)
    
    return np.max(dist)

if __name__ == '__main__':
    print(main())
Problem p03107 (python)

Fixed submission:
import sys

def main():
  input = sys.stdin.readline
  S = [int(c) for c in input().strip()]
  n1 = 0
  n0 = 0
  for i in S:
    if i == 0:
      n0 += 1
    else:
      n1 += 1
  print(min(n1, n0) * 2)


if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
import sys

def f(A, c):
  n = len(A)
  B = []
  for i in range(len(A) -1):
    if A[i] != A[i+1]:
      c += 2
      B += A[i+2:]
      break
    else:
      B.append(A[i])
  if len(B) == n:
    return c
  else:
    return f(B, c)


def main():
  input = sys.stdin.readline
  S = [int(c) for c in input().strip()]
  ans = f(S, 0)
  print(ans)


if __name__ == '__main__':
  main()
Problem p03265 (python)

Fixed submission:
import sys

def main():
  input = sys.stdin.readline
  x1, y1, x2, y2 = map(int, input().split())

  x4 = -(y2 - y1) + x1
  y4 = (x2 - x1) + y1
  x3 = x2 + x4 - x1
  y3 = y2 + y4 - y1
  print('{} {} {} {}'.format(x3, y3, x4, y4))


if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
  input = sys.stdin.readline
  x1, y1, x2, y2 = map(int, input().split())

  x4 = -(y2 - y1) + x1
  y4 = (x2 - x1) + y1
  x3 = x2 + x4 - x1
  y3 = y2 + y4 - y1
  print('{} {} {} {}'.format(x3, y3, x4, y4)


if __name__ == '__main__':
  main()
Problem p03272 (python)

Fixed submission:
import sys

def main():
  input = sys.stdin.readline
  n, i = map(int, input().split())
  print(n-i+1)


if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
  input = sys.stdin.readline
  n, i = map(int, input().split())
  print(N-i+1)


if __name__ == '__main__':
  main()
Problem p03315 (python)

Fixed submission:
import sys

def main():
  input = sys.stdin.readline
  S = str(input().strip())
  ans = 0
  for c in S:
    if c == '+':
      ans += 1
    else:
      ans -= 1
  print(ans)


if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
  input = sys.stdin.readline
  S = str(input().strip())
  ans = 0
  for c in S:
    if c == +:
      ans += 1
    else:
      ans -= 1
  print(ans)


if __name__ == '__main__':
  main()
Problem p02860 (python)

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

if n % 2 == 0 and s[:n // 2] == s[n // 2:]:
  print("Yes")
else:
  print("No")

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

if n % 2 == 0 and s[:n / 2] == s[n / 2:]:
  print("Yes")
else:
  print("No")
Problem p02935 (python)

Fixed submission:
n = input()
v = sorted(map(int, input().split()))
vt = v[0]
for vn in v[1:]:
	vt = (vt + vn)/2
print(vt)

Buggy submission (verdict: Runtime Error):
n = input()
v = sorted(map(int, input().split()))
vt = v[0]
vt = list(map(lambda x:(vt+x)/2, v[1:]))
for vn in v[1:]:
	vt = (vt + vn)/2
print(vt)
Problem p02984 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
tmp=0
fugo=-1
ans=[]
for i in range(N):
    fugo*=-1
    tmp+=fugo*A[i]
ans.append(tmp)

for i in range(N-1):
    x=ans[i%N]
    ans.append(2*A[i%N]-x)

for x in ans:
    print(x, end=' ')
print()

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
tmp=0
fugo=-1
for i in range(N):
    fugo*=-1
    tmp+=fugo*A[i]
ans.append(tmp)

for i in range(N):
    x=ans[i%N]
    ans.append(2*A[i%N]-x)

for x in ans:
    print(x_, end=' ')
print()

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
A=list(map(int,input().split()))
B_=list(map(lambda x: 2*x,A))
A=np.eye(N,N,1)+np.eye(N,N)
A[N-1][0]=1

x=np.linalg.solve(A, B_)
x=list(map(int,list(x)))

for x_ in x:
    print(x_, end=' ')
print()
Problem p03038 (python)

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

A=list(map(int,input().split()))
A.sort()
dc=[]

for i in range(M):
    B,C=map(int,input().split())
    dc.append([B,C])

dc.sort(key=lambda x: x[1],reverse=True)
bf=False
i=0
for l in dc:
    B,C=l
    if bf:
        break
    while B>0:
        if i<N and A[i]<C:
            A[i]=C
            B-=1
            i+=1
        else:
            bf=True
            break


print(sum(A))

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

A=list(map(int,input().split()))
A.sort()
dc=[]

for i in range(M):
    B,C=map(int,input().split())
    dc.append([B,C])

dc.sort(key=lambda x: x[1],reverse=True)
bf=False
i=0

for l in dc:
    B,C=l
    if bf:
        break
    while B>0:
        if A[i]<C and i<N:
            A[i]=C
            B-=1
            i+=1
        else:
            bf=True
            i+=1
            break

print(sum(A))

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

A=list(map(int,input().split()))
A.sort()
dc=[]

for i in range(M):
    B,C=map(int,input().split())
    dc.append([B,C])

dc.sort(key=lambda x: x[1],reverse=True)
bf=False
i=0

for l in dc:
    B,C=l
    if bf or i>=N:
        break
    while B>0:
        if A[i]<C:
            A[i]=C
            B-=1
            i+=1
        else:
            bf=True
            i+=1
            break

print(sum(A))
Problem p03053 (python)

Fixed submission:
H,W=map(int,input().split())
board=[[True]*(W+2)]
for i in range(H):
    board.append([True]+[a=='#' for a in input()]+[True])
board.append([True]*(W+2))

q=[]
for h in range(1,H+1):
    for w in range(1,W+1):
        if board[h][w]:
            q.append((h,w))

cnt=0
while q:
    nq=[]
    for h,w in q:
        if not board[h+1][w]:
            board[h+1][w]=True
            nq.append((h+1,w))
        if not board[h-1][w]:
            board[h-1][w]=True
            nq.append((h-1,w))
        if not board[h][w+1]:
            board[h][w+1]=True
            nq.append((h,w+1))
        if not board[h][w-1]:
            board[h][w-1]=True
            nq.append((h,w-1))

    q=nq
    cnt+=1

print(cnt-1)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
board=[[True]*(W+2)]
for i in range(H):
    board.append([True]+[a=='#' for a in input()]+[True])
board.append([True]*(W+2))

q=[]
for i in range(1,H+1):
    for j in range(1,W+1):
        if board[i][j]:
            q.append([i,j])

cnt=0
while q:
    nq=[]
    for h,w in stack:
        if not board[h+1][w]:
            board[h+1][w]=True
            nq.append([h+1,w])
        if not board[h-1][w]:
            board[h-1][w]=True
            nq.append([h-1,w])
        if not board[h][w+1]:
            board[h][w+1]=True
            nq.append([h,w+1])
        if not board[h][w-1]:
            board[h][w-1]=True
            nq.append([h,w-1])

    q=nq
    cnt+=1

print(cnt-1)
Problem p03307 (python)

Fixed submission:
N=int(input())
print(N*2 if N%2==1 else N)

Buggy submission (verdict: Runtime Error):
N=int(input())
print(N*2 if N%==1 else N)
Problem p03835 (python)

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

ans=0

for i in range(K+1):
  if 0<=S-i<=K:
    ans+=S-i+1
  elif K<S-i<=2*K:
    ans+=2*K-(S-i)+1
        
print(ans)

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

for i in range(K):
  for j in range(K-i):
    for k in range(K-i-j):
      if i+j+k==S:
        ans+=1
print(ans)
Problem p02879 (python)

Fixed submission:
a,b=map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
  print(a*b)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
A,B=int(input().split())
if 1<=A<=9 and 1<=B<=9:
    print(A*B)
else:
    print(-1)
Problem p02897 (python)

Fixed submission:
n=int(input())
if n%2==0:
    print(1/2)
else:
    print((1+n)/(2*n))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
l2=[0]*(n+1)
for i,j in enumerate(l,1):
    l2[j]=i
l2.remove(0)    
print(' '.join(map(str,l2)))
Problem p03107 (python)

Fixed submission:
S = input()

red = 0
blue = 0
for c in S:
    if c == '0':
        red += 1
    elif c == '1':
        blue += 1

print(min(red, blue)*2)

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

s = S
index = 0
ans = 0
while index < len(s)-1:
    c = s[index]
    next_c = s[index+1]
    if c != next_c:
        s = s[:index] + s[index+2:]
        index = 0
        ans += 2
    else:
        index += 1
    print(s + ' ans:' + str(ans))

print(ans)

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

s = S
index = 0
ans = 0
while index < len(s)-1:
    c = s[index]
    next_c = s[index+1]
    if c != next_c:
        s = s[:index] + s[index+2:]
        index = 0
        ans += 2
    else:
        index += 1
    print(s + ' ans:' + str(ans))

print(ans)
Problem p02925 (python)

Fixed submission:
from collections import deque

if __name__ == '__main__':
    N = int(input())
    matches = [[int(x) - 1 for x in input().split()] for _ in range(N)]
    q = deque(range(N))
    days = [0] * N
    pairs = [-1] * N
    while q:
        a = q.popleft()
        match = matches[a]
        if not match:
            continue
        b = match.pop(0)
        if pairs[b] == a:
            days[a] = days[b] = max(days[a], days[b]) + 1
            q.append(a)
            q.append(b)
        else:
            pairs[a] = b
    print(max(days) if not any(matches) else -1)

Buggy submission (verdict: Runtime Error):
def search(can):
    day = 0
    while True:
        # matchの候補をリスト化
        match = []
        for i in range(N):
            if can[can[i]] == i:
                match.append((i, can[i]))

        if len(match) == 0:
            return -1

        # 可能なmatchの組み合わせで試していく
        for i in range(1 << len(match)):
            player = [0] * N
            flag = True
            for j in range(len(match)):
                if i >> j & 1 == 1:
                    if player[i] or player[i]:
                        flag = False
                        break
                    player[i] = player[j] = 1
                if flag:
                    # matchを行う
                    for i, p in enumerate(player):
                        if p:
                            consumed[i] += 1
                            if consumed[i] != N:
                                can[i] = A[i][consumed[i]]
                    day += 1

        if sum(consumed) == N * (N-1):
            return day


if __name__ == '__main__':
    N = int(input())
    A = [[int(x)-1 for x in input().split()] for _ in range(N)]

    # 初期化
    can = dict()
    consumed = [0] * N
    for i in range(N):
        can[i] = A[i][0]

    print(search(can))
    print()
Problem p02912 (python)

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [-a for a in A]
heapq.heapify(A)

for i in range(M):
    a = heapq.heappop(A)
    a /= 2
    heapq.heappush(A, a)

ans = 0
for a in A:
    ans += - a//1
print(int(ans))

Buggy submission (verdict: Runtime Error):
import bisect
from collections import deque

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = deque(sorted(A, reverse=True))
#A.sort(reverse=True)

for i in range(M):
    a = A.popleft()
    a /= 2
    index = bisect.bisect_left(A, a)
    A.insert(index-1, a)

ans = 0
for a in A:
    ans += a//1
print(int(ans))

Buggy submission (verdict: Runtime Error):
import bisect
from collections import deque
import math

N, M = map(int, input().split())
_A = list(map(int, input().split()))
A = deque(sorted(_A, reverse=True))
#A  = sorted(_A, reverse=True)

for i in range(M):
    a = A.popleft()
    a /= 2
    index = bisect.bisect_left(A, a)
    A.insert(index-1, a)

ans = 0
for a in A:
    ans += math.floor(a)
print(int(ans))
Problem p03326 (python)

Fixed submission:
N,M = map(int, input().split())
X = [ [int(j) for j in input().split()] for _ in range(N)]
ans = 0
for i in range(1<<3):
    if M==0:
        break
    ss = [None]*N

    for n in range(0,N):
        x,y,z = X[n]
        s = (x if (i & (1<<2)) else -x) \
            + (y if (i & (1<<1)) else -y) \
            + (z if (i & (1<<0)) else -z)
        ss[n] = s
    ss.sort()
    ans = max(ans, sum(ss[N-M:]))
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
X = [ [int(j) for j in input().split()] for _ in range(N)]
ans = 0
for i in range(1<<3):
    if M=0:
        break
    dp = [ [0] * (M+1) for _ in range(N+1)]
 
    for n in range(0,N):
        x,y,z = X[n]
        s = (x if (i & (1<<2)) else -x) \
            + (y if (i & (1<<1)) else -y) \
            + (z if (i & (1<<0)) else -z) \
 
        for m in range(min(n,M-1), -1, -1 ):
            dp[n+1][m+1] =  max(dp[n+1][m+1], s + dp[n][m] )
            dp[n+1][m]   =  max(dp[n+1][m], dp[n][m])
 
        dp[n+1][M] = max(dp[n+1][M], dp[n][M])
    ans = max(ans, dp[N][M])
print(ans)