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

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

n = int(input())
a = np.array([int(i) for i in input().split()])

k = [0] * 60

for j in range(60):
    l = a & 1
    k[j] = np.count_nonzero(l)
    a >>= 1

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math

n = int(input())
a = [int(i) for i in input().split()]
bound = int(math.log2(max(a)) + 1)

k = [0] * bound

for i in a:
    for j in range(bound):
        if (i >> j) & 1:
            k[j] += 1

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))
Problem p02553 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int, input())
print(max(a*c, a*d, b*c, b*d)
Problem p02584 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(X: int, K: int, D: int):
    X=abs(X)

    mostl = X - K * D
    if mostl > 0:
        print(mostl)
        exit()

    if K%2 == 1:
        X -= D
        ans = min(abs(X), abs(X+2*D))
    else:
        ans = min(X, abs(X - K * D))

    Kh = K // 2

    N = X // (D*2)
    ans = min(ans, abs(X - D * 2 * (N - 1)))
    ans = min(ans, abs(X - D * 2 * N))
    if N < Kh:
        ans = min(ans, abs(X - D * 2 * (N + 1)))

    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(X, K, D)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(X: int, K: int, D: int):
    X=abs(X)

    mostl = X - K * D
    if mostl > 0:
        print(mostl)
        exit()

    if K%2 == 1:
        X -= D
        ans = min(ans, abs(X), abs(X+2*D))
    else:
        ans = min(X, abs(X - K * D))

    Kh = K // 2

    N = X // (D*2)
    ans = min(ans, abs(X - D * 2 * (N - 1)))
    ans = min(ans, abs(X - D * 2 * N))
    if N < Kh:
        ans = min(ans, abs(X - D * 2 * (N + 1)))

    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(X, K, D)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(X: int, K: int, D: int):
    if X<0:
        X*=-1

    mostl = X - K * D
    mostr = X + K * D
    if mostl*mostr>0:
        print(min(mostl, mostr))
        exit()

    ans=abs(X)
    if K%2 == 1:
        X -= D*flg
        K -= 1
        ans=min(ans, abs(X))

    N = X // (D*2)
    ans=min(ans, abs(X-D*2*N))
    if N < K//2:
        ans = min(ans, abs(X - D * 2 * (N+1)))

    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(X, K, D)

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

Fixed submission:
import numpy as np

d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))

for i in range(d):
  print(np.argmax(s[i])+1)

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

d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))

for i in range(d):
  if i%26=0:
    a=np.argmax(s[0])
  print((i+a)%26+1)
Problem p02640 (python)

Fixed submission:
x, y = map(int, input().split())
print("Yes" if x*2 <= y <= x*4 and y%2 == 0 else "No")

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
print("Yes" if x*2 <= y <= x*4 and x%2 = 0 else "No")
Problem p02658 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
n=int(input())
a=list(map(int,input().split()))
ans=1
 
for i in range(n):
    if a[i]==0:
        print(0)
        sys.exit()

for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print(-1)
        sys.exit()
 
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
n=int(input())
a=map(int,input().split())
ans=1
for i in range(n):
  ans*=a[i]
  if ans>10**18:
    print(-1)
    sys.exit()
print(ans)
Problem p02675 (python)

Fixed submission:
n=int(input())
n1=n%10
if n1==3:
    print("bon")
elif n1<=1 or n1==6 or n1==8:
    print("pon")
else:
    print("hon")

Buggy submission (verdict: Runtime Error):
k=int(input())
s=input()
if len(s)<=k:
    print(s)
else:
    print(s[:k]+"...")
Problem p02718 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)

#def my_index_multi(l, x):
#    return [i for i, _x in enumerate(l) if _x == x]

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    A=sorted(A,reverse=True)
    sa=sum(A)
    if N==1:
        print(YES)
    else:
        print(YES if sa/(4*M)<=A[M-1] else NO)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)

#def my_index_multi(l, x):
#    return [i for i, _x in enumerate(l) if _x == x]

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    A.sort()
    sa=sum(A)
    print(YES if sa//(4*M)>A[M] else NO)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

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

Fixed submission:
H,W=map(int,input().split())
if H==1 or W==1:
    print(1)
elif H%2==0:
    print(H//2*W)
elif W%2==0:
    print(W//2*H)
else:
    print((H//2)*W+((W+1)//2))

Buggy submission (verdict: Runtime Error):
H,W=map(int,input())
if H%2==0:
    print(H//2*W)
elif W%2==0:
    print(W//2*H)
else:
    print((H//2)*W+((W+1)//2))
Problem p02756 (python)

Fixed submission:
s1=list(input())
q=int(input())
s0=[]
f=1
for i in range(q):
  a=list(input().split())
  #print(i,a,s)
  if int(a[0])==1:
    f=(f+1)%2
  else:
    if (f+int(a[1]))%2==0:
      s0.append(a[2])
    else:
      s1.append(a[2])
if f==1:
  print("".join(s0[::-1])+"".join(s1))
else:
  print("".join(s1[::-1])+"".join(s0))

Buggy submission (verdict: Runtime Error):
s1=input()
q=int(input())
s0=[]
f=1
for i in range(q):
  a=list(input().split())
  #print(i,a,s)
  if int(a[0])==1:
    f=(f+1)%2
  else:
    if (f+int(a[1]))%2==0:
      s0.append(a[2])
    else:
      s1.append(a[2])
if f==1:
  print("".join(s0[::-1])+"".join(s1))
else:
  print("".join(s1[::-1])+"".join(s0))
Problem p02797 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, S: int):
    ans=[-1]*N
    yok=0
    for i in range(N):
        if i<K:
            ans[i]=S
        else:
            if S>N:
                ans[i]=1
                yok+=1
            else:
                ans[i]=10**9
    
    for i in range(N):
        print(ans[i],end=" ")

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(N, K, S)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, S: int):
    if K==0:
        if S>N:
            ans=[0]*N
        else:
            ans=[N+1]*N
    elif K==N:
        ans=[S]*N

    else:
        for i in range(N):
            yok=0
            if i<K:
                ans[i]=S
            else:
                ans[i]=1
                yok+=1
    
        ans[K-1]-=yok
    
    for i in range(N):
        print(ans[i],end=" ")

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(N, K, S)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, S: int):
    if K==0:
        if S>N:
            ans=[0]*N
        else:
            ans=[N+1]*N
    if K==N:
        ans=[S]*N

    for i in range(N):
        yok=0
        if i<K:
            ans[i]=S
        else:
            ans[i]=1
            yok+=1
    ans[K-1]-=yok

    for i in range(N):
        print(ans[i],end=" ")

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(N, K, S)

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

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

c=0
for i in range(N):
    if (H[i]>=K):
        c=c+1

print(c)

Buggy submission (verdict: Runtime Error):
N,K = (int(i) for i in input().split())
H = [int(i) for i in input().split()]

c=0
for _ in range(N):
    if (H[N]>=K):
        c=c+1

print(c)
Problem p02899 (python)

Fixed submission:
import numpy as np
N = int(input())
b = [int(i) for i in input().split()]
s=np.argsort(b)

for i in range(N):
    print(s[i]+1, end=" ")

Buggy submission (verdict: Runtime Error):
import numpy as np
N = (int(i) for i in input().split())
b = [int(i) for i in input().split()]]
i=np.argsort(b)
print(i+1)
Problem p03165 (python)

Fixed submission:
import sys

def solve(s: str, t: str):
    ls=len(s)
    lt=len(t)
    dp=[[0]*(lt+1) for _ in range(ls+1)] # dp[0:ls+1][0:lt+1]

    for i in range(ls):
        for j in range(lt):
            if s[i]==t[j]:
                dp[i+1][j+1]=dp[i][j]+1
            if dp[i+1][j]>dp[i+1][j+1]: dp[i+1][j+1]=dp[i+1][j]
            if dp[i][j+1]>dp[i+1][j+1]: dp[i+1][j+1]=dp[i][j+1]

    ans=""
    while ls>0 and lt>0:
        if dp[ls][lt]==dp[ls-1][lt]:
            ls-=1
        elif dp[ls][lt]==dp[ls][lt-1]:
            lt-=1
        else:
            ans=s[ls-1]+ans
            ls-=1
            lt-=1

    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    t = next(tokens)  # type: str
    solve(s, t)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

def solve(s: str, t: str):
    ls=len(s)
    lt=len(t)
    dp=[[0]*(lt+1) for _ in range(ls+1)] # dp[0:ls+1][0:lt+1]

    for i in range(ls):
        for j in range(lt):
            if s[i]==t[j]:
                dp[i+1][j+1]=dp[i][j]+1
            if dp[i+1][j]>dp[i+1][j+1]: dp[i+1][j+1]=dp[i+1][j]
            if dp[i][j+1]>dp[i+1][j+1]: dp[i+1][j+1]=dp[i][j+1]

    ans=""
    la=dp[ls][lt]
    ttag=lt
    for i in reversed(range(ls+1)):
        if dp[i][ttag]<la:
            ans=s[i]+ans                                                                                                                                                      la-=1
            ttag-=1

    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    t = next(tokens)  # type: str
    solve(s, t)

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

Fixed submission:
from collections import Counter as C
n = int(input())
a = list(map(int,input().split()))
c1 = C(a[::2])
c2 = C(a[1::2])
mc1 = c1.most_common(2)
mc2 = c2.most_common(2)
if mc1[0][0] != mc2[0][0]:
  ans = n - mc1[0][1] - mc2[0][1]
else:
  if len(mc1) + len(mc2) == 2:
    ans = n // 2
  elif len(mc1) == 1:
    ans = n - mc1[0][1] - mc2[1][1]
  elif len(mc2) == 1:
    ans = n - mc1[1][1] - mc2[0][1]
  else:
    if mc1[1][1] >= mc2[1][1]:
      ans = n - mc1[1][1] - mc2[0][1]
    else:
      ans = n - mc1[0][1] - mc2[1][1]
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter as C
n = int(input())
a = list(map(int,input().split()))
c1 = C(a[::2])
c2 = C(a[1::2])
mc1 = c1.most_common(2)
mc2 = c2.most_common(2)
if mc1[0][0] == mc2[0][0]:
  if mc1[1][1] >= mc2[1][1]:
    ans = n - mc1[1][1] - mc2[0][1]
  else:
    ans = n - mc1[0][1] - mc2[][1]
print(ans)
Problem p03645 (python)

Fixed submission:
n,m=map(int,input().split())
a=[0]*m
b=[0]*m
for i in range(m):
  a[i],b[i]=map(int,input().split())
c=[0]*max(n,m)
for i in range(m):
  if a[i]==1:
    c[b[i]-1] |= 1
  if b[i]==n:
    c[a[i]-1] |= 2
print("POSSIBLE" if max(c)==3 else "IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*m
b=[0]*m
for i in range(m):
  a[i],b[i]=map(int,input().split())
c=[0]*m
for i in range(m):
  if a[i]==1:
    c[b[i]-1] |= 1
  if b[i]==n:
    c[a[i]-1] |= 2
print("POSSIBLE" if max(c)==3 else "IMPOSSIBLE")
Problem p02817 (python)

Fixed submission:
s  = input().split()
print(s[1]+s[0])

Buggy submission (verdict: Runtime Error):
s = int(input())
t = int(input())
print(t+s)
Problem p02818 (python)

Fixed submission:
t,a,k = [x for x in list(map(int,input().split()))]
if k>=t:
    if k-t > a:
        t = 0
        a = 0
    else:
        a = a - (k-t)
        t = 0
    print(t,a)
else:
    t = t-k
    print(t,a)

Buggy submission (verdict: Runtime Error):
t,a,k = [x for x in list(map(int,input().split()))]
if k>=t:
  if abs(t-k) > a:
    t = 0
    a = 0
  else:
    t = 0
    a = a-abs(t-k)
   print(t,a)
else:
  t = t-k
  print(t,a)
Problem p02555 (python)

Fixed submission:
import sys
import threading

S = int(input())
A = [-1 for _ in range(2001)]
A[0] = 0
A[1] = 0
A[2] = 0
A[3] = 1

for i in range(S+1):
  if A[i] == -1:
    A[i] = A[i-1] + A[i-3]

print(A[S]%(10**9+7))

Buggy submission (verdict: Runtime Error):
import sys
import threading

S = int(input())
A = [-1 for _ in range(S+1)]
A[0] = 0
A[1] = 0
A[2] = 0
A[3] = 1
A[4] = 1
A[5] = 1

for i in range(S+1):
  if A[i] == -1:
    A[i] = A[i-1] + A[i-3]
print(A[S]%(10**9+7))

Buggy submission (verdict: Runtime Error):
import sys
import threading

S = int(input())
A = [-1 for _ in range(S+1)]
A[0] = 0
A[1] = 0
A[2] = 0
A[3] = 1
A[4] = 1
A[5] = 1

for i in range(S+1):
  if A[i] == -1:
    A[i] = A[i-1] + A[i-3]
print(A[S]%(10**9+7))
Problem p02708 (python)

Fixed submission:
N,K = map(int,input().split())
ans = 0
temp_max = 0
temp_min = 0
for i in range(1,N+2):
  temp_max += N-i+1
  temp_min += i-1
  if i  >= K:
    ans += (temp_max - temp_min + 1)
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
ans = 0
temp_max = N
temp_min = 0
for i in range(K,N+2):
  temp_max += N-i+1
  temp_min += i-1
  ans += temp_max - temp_min + 1
print(ans%(10**9+7)
Problem p02713 (python)

Fixed submission:
import math
N = int(input())
ans = (1+N)*N/2
for i in range(1,N+1):
  for j in range(1,i):
    ans += math.gcd(i,j)*6
for i in range(1,N+1):
  for j in range(1,i):
    if i== j:
      break
    for k in range(1,j):
      if i == k or j == k:
        break
      else:
        ans += math.gcd(k,math.gcd(i,j))*6
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
ans = (1+N)*N/2
for i in range(1,N+1):
  for j in range(1,i):
    ans += math.gcd(i,j)*3
for i in range(!,N+1):
  for j in range(1,i):
    if i== j:
      break
    for k in range(1,j):
      if i == k or j == k:
        break
      else:
        ans += math.gcd(i,j,k)*6
print(ans)
Problem p02732 (python)

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

select_num = 0
count_num = [0]*(N+1)
for i in A:
  count_num[i] += 1
for i in range(1,N+1):
  select_num += (count_num[i])*(count_num[i] - 1)//2
for i in A:
  print(select_num -count_num[i] + 1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
maxim = max(A)
select_num = [0 for i in range(0,maxim+1)]
select_num2 = [0 for i in range(0,maxim+1)]
count_num = [0 for i in range(0,maxim+1)]
for i in range(1,maxim+1):
  count_num[i] = A.count(i)
  if(count_num[i] > 1):
    select_num[i] = (count_num[i] - 0)*(count_num[i] - 1)//2
  	select_num2[i] = count_num[i] - 1
sumS = sum(select_num)
for i in range(N):
  print(sumS -select_num2[A[i]])
Problem p02761 (python)

Fixed submission:
N, M = map(int,input().split())
answer = [-1]*N
ae = 0
  

for i in range(M):
  s,c = map(int,input().split())
  if answer[-s] == -1:
    answer[-s] = c
  elif answer[-s] != -1 and answer[-s] != c:
    print(-1)
    ae = 1
    break
for i in range(N):
  if answer[i] == -1:
    if i == N-1 and N > 1:
      answer[i] = 1
    else:
      answer[i] = 0
if ae == 0 and answer[N-1] == 0 and N != 1:
  print(-1)
  ae = 1
elif ae == 0:
  for i in range(N):
    print(answer[-(i+1)],end='')

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
answer = [0]*M
ae = 0

for i in range(M):
  s,c = map(int,input().split())
  if answer[-s] == 0:
    answer[-s] = c
  elif answer[-s] != 0 and answer[-s] != c:
    print(-1)
    ae = 1
    break
if ae == 0 and answer[M-1] == 0 and M != 1:
  print(-1)
  ae = 1
elif ae == 0:
  for i in range(M):
    print(answer[-(i+1)],end='')

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
answer = [0]*M
ae = 0

for i in range(M):
  s,c = map(int,input().split())
  if answer[-s] == 0:
    answer[-s] = c
  elif answer[-s] != 0 and answer[-s] != c:
    print(-1)
    ae = 1
    break
if ae == 0 and answer[-M] == 0:
  print(-1)
  ae = 1
elif ae == 0:
  for i in range(M):
    print(answer[-(i+1)],end='')

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
answer = [0]*M
ae = 0

for i in range(M):
  s,c = map(int,input().split())
  if answer[-s] == 0:
    answer[-s] = c
  elif answer[-s] != 0 and answer[-s] != c:
    print(-1)
    ae = 1
    break
if ae == 0 and answer[-M] == 0:
  print(-1)
  ae = 1
elif ae == 0:
  for i in range(M):
    print(answer[-(i+1)],end='')
Problem p03161 (python)

Fixed submission:
import numpy as np
N,K = map(int,input().split())
A = list(map(int,input().split()))
A = np.array(A)
ans = np.array([float('inf')]*N)
ans[0] = 0
K = min(N-1,K)
for i in range(1,K+1):
  ans[i] = abs(A[0]-A[i])
for i in range(K+1,N):
  ans[i] = min(ans[i],np.min(ans[i-K:i]+np.abs(A[i]-A[i-K:i])))
print(int(ans[N-1]))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = [float('inf')]*N
ans[0] = 0
for i in range(1,K+1):
  ans[i] = abs(A[0]-A[i])

for i in range(K+1,N):
  for j in range(0,min(i,K)):
    ans[i] = min(ans[i-j]+abs(A[i]-A[i-j]), ans[i-j-1]+abs(A[i]-A[i-j-1]))
print(ans[N-1])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = [float('inf')]*N
ans[0] = 0
for i in range(1,K+1):
  ans[i] = abs(A[0]-A[i])

for i in range(K+1,N):
  for j in range(1,min(i,K)):
	  ans[i] = min(ans[i-j]+abs(A[i]-A[i-j]), ans[i-j-1]+abs(A[i]-A[i-j-1]))
print(ans[N-1])
Problem p03162 (python)

Fixed submission:
import numpy as np
#N,K = map(int,input().split())
N = int(input())
A,B,C = 0,0,0
for i in range(N):
  a,b,c = map(int,input().split())
  A,B,C = a+max(B,C),b+max(A,C),c+max(A,B)
print(max(A,B,C))

Buggy submission (verdict: Runtime Error):
7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1
Problem p02612 (python)

Fixed submission:
n = int(input())
a = (1000 - (n % 1000)) % 1000
print(a)

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

for i in range(10)+1:
  if n < i * 1000:
    print(i * 1000 - n)
    break

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

for i in range(10)+1:
  if n < i * 1000:
    print(i * 1000 - n)
    break
Problem p02613 (python)

Fixed submission:
ac = 0
wa = 0
tle = 0
re = 0
 
n = int(input())
 
for i in range(n):
  s = str(input())
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  elif s == 'RE':
    re += 1

print('AC','x',ac)
print('WA','x',wa)
print('TLE','x',tle)
print('RE','x',re)

Buggy submission (verdict: Runtime Error):
ac = 0
wa = 0
tle = 0
re = 0
 
n = int(input())
 
for i in range(n):
  s = str(input())
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  elif s == 'RE':
    RE += 1

print('AC','x',ac)
print('WA','x',wa)
print('TLE','x',tle)
print('RE','x',re)

Buggy submission (verdict: Runtime Error):
ac = 0
wa = 0
tle = 0
re = 0
 
n = int(input())
 
for i in range(n):
  s = str(input())
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  elif s == 'RE':
    RE += 1
 
print('AC','x',ac)
print('WA','x',wa)
print('TLE','x',tle)
print('RE','x',re)

Buggy submission (verdict: Runtime Error):
ac = 0
wa = 0
tle = 0
re = 0

n = int(input())

for i in range(n):
  s = input()
  if s = 'AC':
    ac += 1
  elif s = 'WA':
    wa += 1
  elif s = 'TLE':
    tle += 1
  elif s = 'RE':
    RE += 1

print('AC','x',ac)
print('WA','x',wa)
print('TLE','x',tle)
print('RE','x',re)