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

Fixed submission:
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    m = n
    sumM = 0
    while m >= 1:
        sumM += (m % 10)
        m = m // 10
#        print(m)
#    sumM += m
#    print(sumM)

    if n % sumM == 0:
        print("Yes")
    else:
        print("No")
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    m = n
    sumM = 0
    while m > 0:
        sumN += (m % 10)
        m /= 10

    if n % sumM == 0:
        print("Yes")
    else:
        print("No")
resolve()
Problem p03624 (python)

Fixed submission:
import string

def resolve():
    # 整数 1 つ
    s = input()
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    alpha = string.ascii_lowercase
    A = [alpha[i] for i in range(len(alpha))]

    for x in A:
        if x not in s:
            print(x)
            break
        if x == "z":
            print("None")

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    # 整数 1 つ
    s = input()
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    alpha = string.ascii_lowercase
    A = [alpha[i] for i in range(len(alpha))]

    for x in A:
        if x not in s:
            print(x)
            break
        if x == "z":
            print("None")

resolve()
Problem p03720 (python)

Fixed submission:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, m = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    A = [list(map(int, input().split())) for i in range(m)]

    towns = {}
    for i in range(n):
        towns[i] = 0

    for j in range(m):
        for k in range(2):
            towns[A[j][k] -1] += 1

    for l in range(n):
        print(towns[l])
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, m = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    A = [list(map(int, input().split())) for i in range(m)]

    towns = {}
    for i in range(n):
        towns[i] = 0

    for j in range(m):
        for k in range(2):
            towns[A[j][k]] += 1

    print(towns.values())

resolve()
Problem p02608 (python)

Fixed submission:
n = int(input())
a = [0]*((10**4)+1)
for i in range(1,101):
    for j in range(1,101):
        for  k in range(1,101):
            try:
                a[i*i+j*j+k*k+i*j+j*k+i*k]+=1
            except:
                continue
for i in range(1, n+1):
    print(a[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [0]*(10**4)
for i in range(1,101):
    for j in range(1,101):
        for  k in range(1,101):
            try:
                a[i*i+j*j+k*k+i*j+j*k+i*k]+=1
            except:
                continue
for i in range(1, n+1):
    print(a[i])
Problem p02718 (python)

Fixed submission:
n, m = list(map(int,input().split()))
a = list(map(int,input().split()))
s = sum(a)
x = (1/(4*m))*(s)
u = 0
for i in a:
    if(i>=x):
        u+=1
if(u>=m):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n, m = list(map(int,input().split()))
a = list(map(int,input().split()))
s = sum(a)
x = (1/(4*m))*(s)
for i in a:
    if(i>=x):
        u+=1
if(u>=m):
    print("Yes")
else:
    print("No")
Problem p02823 (python)

Fixed submission:
n,a,b = list(map(int,input().split()))
if((b-a)%2==0):
    print(int((b-a)//2))
else:
    u = (b-a-1)//2
    if(n>(a+b-1)):
        print(u+a)
    else:
        print(u+(n-b+1))

Buggy submission (verdict: Runtime Error):
n,a,b = list(map(int,input().split()))
if((b-a)%2==0):
    print((a2-a1)//2)
else:
    print(min(n-a, b-1))

Buggy submission (verdict: Runtime Error):
n,a,b = list(map(int,input().split()))
if((b-a)%2==0):
    print((a2-a1)//2)
else:
    print(min(n-a, b-1))

Buggy submission (verdict: Runtime Error):
n,a,b = list(map(int,input().split()))
if((b-a)%2==0):
    print((a2-a1)//2)
else:
    print(min(n-a, b-1))
Problem p02641 (python)

Fixed submission:
x,n = map(int,input().split())
p = list(map(int,input().split()))
sa = []
num = []
for i in range(-110,110):
    if i in p:
        continue
    sa.append(abs(x-i))
    num.append(i)

print(num[sa.index(min(sa))])

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
p = list(map(int,input().split()))
sa = []
num = []
for i in range(1,101):
    if i in p:
        continue
    sa.append(abs(x-i))
    num.append(i)

print(num[sa.index(min(sa))])
Problem p02664 (python)

Fixed submission:
print(input().replace("?","D"))

Buggy submission (verdict: Runtime Error):
s = list(input())
print(s.replace("?","D"))
Problem p02741 (python)

Fixed submission:
k = int(input())
list1 = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list1[k-1])

Buggy submission (verdict: Runtime Error):
import math
a ,b ,c = map(int,input().split())
ra = (math.sqrt(a))
rb = (math.sqrt(b))
rc = (math.sqrt(c))
if ra + rb < rc:
    print("Yes")
elif ra + rb >= rc:
    print("No")
else:
    print("No")
Problem p02743 (python)

Fixed submission:
a ,b ,c = map(int,input().split())
#4*a*b < (c-a-b)**2　両辺を２乗することを思いつかなかった。
if 4*a*b < (c-a-b)**2 and (c-a-b) > 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
a ,b ,c = map(int,input().split())
ra = (Decimal.sqrt(a))
rb = (Decimal.sqrt(b))
rc = (Decimal.sqrt(c))
if ra + rb < rc:
    print("Yes")
else:
    print("No")
Problem p02765 (python)

Fixed submission:
n,r = map(int, input().split())
if n >= 10:
	print(r)
else:
	print(r + (100*(10-n)))

Buggy submission (verdict: Runtime Error):
n,r = map(int,input().split())
rate = r - 100 * (10-n)
if 10 <= n:
   print(r)
else:
   print(int(r;+(100*(10-n))))
Problem p02817 (python)

Fixed submission:
s,t = input().split()
print(t+s)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a == 1 and b == 2:
    print(3)
elif a == 2 and b ==3:
    print(1)
else:
    pritn(2)
Problem p02952 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n+1):
    if len(str(i)) % 2 == 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(1,n+1):
    if len(str(i)) % 2 == 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
#桁が奇数の時の個数
for i in range(1,n+1):
    if len(str(i)) % 2 == 1:
        ans += 1
print(ans)
Problem p02988 (python)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
ans = 0

for i in range(1,n-1):
    a,b,c = p[i-1:i+2]
    if b != min(a,b,c,) and b != max(a,b,c):
        ans += 1
print(ans)

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

ans = 0

for i in range(1,n-1):
    if p[i-1]<p[i]<p[i+1] or p[i-1]>p[i]>i[i+1]:
        ans += 1
print(ans)
Problem p03455 (python)

Fixed submission:
a,b = map(int, input().split())
print("Even" if (a*b)%2==0 else "Odd")

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
result = a * b
if result % 2 = 0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
#整数a,bを入力
a,b = (int, input().split())
#計算
result = a * b
#判定
if result % 2 = 0:
  print("Even")
else
  print("Odd")
Problem p03760 (python)

Fixed submission:
O = input()
E = input()

ans = ""
for o,e in zip(O,E):
    ans += o
    ans += e

if len(O) > len(E):
    ans += O[-1]
print(ans)

Buggy submission (verdict: Runtime Error):
o = list(input())
e = list(input())
ans = []
for i in range(len(o)):
    ans.append(o[i])
    ans.append(e[i])
print("".join(ans))
Problem p02658 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
res = 1
a.sort()
for i in a:
    res *= i
    if res > 1000000000000000000:
        res = -1
        break
print(res)

Buggy submission (verdict: Runtime Error):
res = 1
if 0 in a:
    res = 0
else:
    for i in range(n):
        b = a.pop()
        if b != 1:
            res *= b

            if res > 1000000000000000000:
                res = -1
                break
print(res)
Problem p02713 (python)

Fixed submission:
import math

n=int(input())

sum=0
for i in range(1,n+1):
  for j in range(1,n+1):
      x=math.gcd(i,j)
      for h in range(1,n+1):
        p=math.gcd(x,h)
        sum=sum+p
print(sum)

Buggy submission (verdict: Runtime Error):
import math

n=int(input())

sum=0
for i in range(1,n):
  for j in range(1,n):
    for k in range(1,n):
      y=[[i,j,k]]
      for h in range(z):
        x=math.gcd(h[0],h[1],h[2])
        sum=sum+x
print(sum)
Problem p02802 (python)

Fixed submission:
n, m = map(int,input().split())
 
AC = 0
# 各問題でACがとれているか確認用
# 0 = まだ正解していない, 1 = すでに正解済み
AC_list = [0] * (n + 1)
WA = 0
WA_List = [0] * (n + 1)
 
for i in range(m):
    p,S = input().split()
    p = int(p)
 
    if S == "AC":
        # 初めての正解
        if AC_list[p] == 0:
            AC += 1
            WA += WA_List[p]
            AC_list[p] = 1
        # ※すでに正解している場合は加算しない
    else:
        # まだ正解していない場合
        if AC_list[p] == 0:
            WA_List[p] += 1
        # ※すでに正解している場合は加算しない
 
print(AC,WA)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
AC=0
WA=0
AC_list=[0]*(m+1)
WA_list=[0]*(m+1)

for i in range(m):
  p,s=input().split()
  p=int(p)
  if s=="AC":
    if AC_list[p]==0:
      AC=AC+1
      AC_list[p]=1
  else:
    if AC_list[p]==0:
      WA=WA+1
    
print(AC,WA)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
AC=0
WA=0
AC_list=[0]*(m+1)
WA_list=[0]*(m+1)

for i in range(m):
  p,s=input().split()
  p=int(p)
  if s=="AC":
    if AC_list[p]==0:
      AC=AC+1
      WA=WA+WA_list[p]
      AC_list[p]=1
  else:
    if AC_list[p]==0:
      WA_list[p]=WA_list[p]+1
    
print(AC,WA)
Problem p02885 (python)

Fixed submission:
a,b=map(int,input().split())
 
if a<2*b:
  print("0")
else:
  print(a-2*b)

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

if a<2b:
  print("0")
else:
  print(a-2*b)
Problem p02924 (python)

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

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

N=int(input())
print(np.arange(1,N).sum())

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

N=int(input())
print(np.arange(1,N-1).sum())
Problem p02945 (python)

Fixed submission:
A,B = map(int, input().split())
print(max([A+B,A-B,A*B]))

Buggy submission (verdict: Runtime Error):
A,B = int(input().split())
print(max([A+B,A-B,A*B]))
Problem p02952 (python)

Fixed submission:
N=input()

if len(N)==1:
  print(int(N))
elif len(N)==2:
  print(9)
elif len(N)==3:
  print(9+int(N)-99)
elif len(N)==4:
  print(909)
elif len(N)==5:
  print(909+int(N)-9999)
elif len(N)==6:
  print(90909)

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

if len(N)==1:
  print(N)
elif len(N)==2:
  print(9)
elif len(N)==3:
  print(9+N-99)
elif len(N)==4:
  print(909)
elif len(N)==5:
  print(909+N-9999)
elif len(N)==6:
  print(90909)
Problem p03059 (python)

Fixed submission:
a,b,t=map(int,input().split())
 
print(t//a*b)

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

print(t//a*b
Problem p02608 (python)

Fixed submission:
from collections import defaultdict
import math
n=int(input())
d=defaultdict(int)

if n>2:
    m=int(math.sqrt(n))
    for k in range(1,m):
        for i in range(1,m):
            for j in range(1,m):
                N=i*i+j*j+k*k+i*j+j*k+k*i
                d[N]+=1
for i in range(1,n+1):
    print(d[i])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import math
n=int(input())
d=defaultdict(int)

m=int(math.sqrt(n-2))+2
for l in range(3,m+1):
    for i in range(1,l-1):
        for j in range(1,l-i):
            k=l-i-j
            N=i*i+j*j+k*k+i*j+j*k+k*i
            d[N]+=1
for i in range(1,n+1):
    print(d[i])
Problem p02642 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
A.sort()
t=0
e=[True]*1000001
for i in range(n-1):
    a=A[i]
    if e[a]==False:
        continue
    b=a*2
    while b < 1000001:
        e[b]=False
        b+=a
    if A[i+1]==a:
        e[a]=False
for a in A:
    if e[a]:
        t+=1
print(t)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
Q=[True]*n
a.sort()
t=0
for i in range(n):
    if !Q[j]:
        continue
    b=a[i]
    for j in range(i,n):
        if !Q[j]:
            continue
        if a[j]%b==0:
            Q[j]=False
    t+=1
print(t)
Problem p02681 (python)

Fixed submission:
s=input()
t=input()
l=len(s)
if len(s)+1 == len(t):
    si=s+t[l]
else:
    si=""
if si == t and len(si) == len(t):
    print("Yes")
else:
    print("No")

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

x=[0]*(n)
before = 0
now = 0
while x[now] == 0:
    x[now]=1+x[before]
    before=now
    now = a[now]-1
    
y=x[now]-x[0]
z=x[before]-y
l=(k-y)%z+1
for i in range(n):
    if x[i] == l+y:
        print(1+i)
        break
Problem p02732 (python)

Fixed submission:
from collections import defaultdict

def r(i) :
  if i < 2:
    return 1
  else :
    return i*(i-1)/2

a = int(input())
b = list(map(int,input().split()))

total = 0
c = defaultdict(int)
for j in range(a):
  c[b[j]] += 1
for key in c.keys():
  if c[key] > 1:
    total += r(c[key])

for j in range(a):
  print(int(total - c[b[j]]+1))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

      
def r(i) :
  if i < 2:
    return 1
  else :
    return i*r(i-1)

a = int(input())
b = list(map(int,input().split()))
for i in range(a):
  total = 0
  c = defaultdict(int)
  for j in range(a):
    if j != i:
      c[b[j]] += 1
  for key in c.keys():
    if c[key] > 1:
  #    print(c[key],key)
  #    print("###")
      total += r(c[key]) / (r(2)*r(c[key]-2))
  print(int(total))
Problem p02642 (python)

Fixed submission:
# import collections


def main():
    _ = int(input())
    A = list(map(int, input().split()))

    A.sort()

    # sames = 0
    # C = collections.Counter(A)
    # for v in C.values():
    #     if v > 1:
    #         sames += 1

    a_max = A[-1]
    dp = [0] * (a_max + 1)
    # dp = [True] * a_max
    # A = set(A)

    for a in A:
        if dp[a] != 0:
            dp[a] = 2
            continue

        i = a
        while i < a_max + 1:
            dp[i] += 1
            i += a

    r = 0
    for a in A:
        if dp[a] == 1:
            r += 1

    print(r)

    #     if dp[a - 1]:
    #         tmp_a = a * 2
    #         while tmp_a < a_max + 1:
    #             dp[tmp_a - 1] = False
    #             tmp_a += a

    # r = 0
    # for a in A:
    #     if dp[a - 1]:
    #         r += 1

    # print(r - sames)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections


def main():
    _ = int(input())
    A = list(map(int, input().split()))

    A.sort()

    sames = 0
    C = collections.Counter(A)
    for v in C.values():
        if v > 1:
            sames += 1

    a_max = A[-1]
    dp = [True] * a_max
    A = set(A)

    if dp[a - 1]:
         tmp_a = a * 2
         while tmp_a < a_max + 1:
             dp[tmp_a - 1] = False
             tmp_a += a

    r = 0
    for a in A:
        if dp[a - 1]:
            r += 1

    print(r - sames)


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

Fixed submission:
X,N = list(map(int,input().split()))
if N == 0:
  print(X)
  exit()
P = sorted(list(map(int,input().split())))
ans1 = P[0] - 1
ans2 = P[-1] + 1
isx = 0
for i in range(1,N):
  if (P[i]-X) > 0:
    if not isx:
      ans1 = X
      break
    else:
      break
  if P[i-1] != (P[i]-1):
    ans1 = P[i] -1
  if P[i] == X:
    isx = 1
    break

for i in range(1,N+1):
  if (P[-i]-X) < 0:
    if not isx:
      ans1 = X
      break
    else:
      break
  if P[-i+1] != (P[-i]+1):
    ans2 = P[-i] + 1
  if P[-i] == X:
    isx = 1
    break

if not isx:
  print(X)
  exit()

aa1 = abs(X-ans1)
aa2 = abs(X-ans2)
if aa1 == aa2:
  print(ans1)
elif aa1 > aa2:
  print(ans2)
else:
  print(ans1)

Buggy submission (verdict: Runtime Error):
X,N = list(map(int,input().split()))
if N == 0:
  print(X)
  exit()
P = sorted(list(map(int,input().split())))
ans1 = P[0] - 1
ans2 = P[-1] + 1
isx = 0
for i in range(1,N+1):
  if (P[i]-X) > 0:
    if not isx:
      ans1 = X
      break
    else:
      break
  if P[i-1] != (P[i]-1):
    ans1 = P[i] -1
  if P[i] == X:
    isx = 1
    break

for i in range(1,N+1):
  if (P[-i]-X) < 0:
    if not isx:
      ans1 = X
      break
    else:
      break
  if P[-i+1] != (P[-i]+1):
    ans2 = P[-i] + 1
  if P[-i] == X:
    isx = 1
    break

if not isx:
  print(X)
  exit()

aa1 = abs(X-ans1)
aa2 = abs(X-ans2)
if aa1 == aa2:
  print(ans1)
elif aa1 > aa2:
  print(ans2)
else:
  print(ans1)
Problem p02767 (python)

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

s = 0
for i in X:
    s += i
s = s/N

muf = math.floor(s)
muc = math.ceil(s)
ansf = 0
ansc = 0
for i in X:
    ansf += (muf-i)**2
    ansc += (muc-i)**2

print(min(int(ansf),int(ansc)))

Buggy submission (verdict: Runtime Error):
import numpy as np
N = input()
X = list(map(int,input().split()))

muf = np.floor(np.mean(X))
muc = np.ceil(np.mean(X))
ansf = 0
ansc = 0
for i in X:
    ansf += (muf-i)**2
    ansc += (muc-i)**2

print(min(int(ansf),int(ansc)))
Problem p02913 (python)

Fixed submission:
n = int(input())
s = input()
D = [[0] * n for i in range(n)]
 
for i in range(n):
    D[0][i] = int(s[0]==s[i])
    D[i][0] = int(s[0]==s[i])
D[0][0] = 0

for i in range(1,n):
    for j in range(i+1,n):
        mae = D[i-1][j-1]
        if s[i] == s[j]:
            if j-i <= mae:
                D[i][j] = mae
            else:
                D[i][j] = mae + 1

print(max([max(D[i]) for i in range(n)]))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
D = [[0] * n for i in range(n)]
 
for i in range(n):
    D[0][i] = int(s[0]==s[i])
    D[i][0] = int(s[0]==s[i])
D[0][0] = 0

for i in range(1,n):
    for j in range(i+1,n):
        print(f"i,j = {i,j}")
        mae = D[i-1][j-1]
        print(f"mae = {mae}")
        if s[i] == s[j]:
            if j-i <= mae:
                D[i][j] = mae
            else:
                D[i][j] = mae + 1

print(max([max(D[i]) for i in range(n)]))
Problem p02995 (python)

Fixed submission:
def gcd(a,b):
    a,b = max(a,b),min(a,b)
    while a%b!=0:
        a,b = b,a%b
    return b

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

e = c*d//gcd(c,d)

b_c = b//c
b_d = b//d
b_e = b//e
a_c = (a-1)//c
a_d = (a-1)//d
a_e = (a-1)//e

print(b-a+1 - (b_c - a_c) - (b_d - a_d) + (b_e - a_e))

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

e = c*d//gcd(c,d)

b_c = b//c
b_d = b//d
b_e = b//e
a_c = (a-1)//c
a_d = (a-1)//d
a_e = (a-1)//e

print(b-a+1 - (b_c - a_c) - (b_d - a_d) + (b_e - a_e))
Problem p02615 (python)

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

A.sort()
A.reverse()
ans = 0
ans += A[0]

if len(A) % 2 == 0:
  tmp = 0
  for i in range(1, int((N-2)/2)+1):
    tmp += A[i] * 2
else:
  tmp = 0
  for i in range(1, int((N-1)/2)+1):
    tmp += A[i] * 2
  tmp -= A[int((N-1)/2)]

ans += tmp
print(ans)

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

A.sort()
A.reverse()
ans = 0
ans += A[0]

if len(A) % 2 == 0:
  tmp = 0
  for i in range(1, int((N-2)/2)+1):
    tmp += A[i] * 2
else:
  for i in range(1, int((N-1)/2)+1):
    tmp += A[i] * 2
  tmp -= A[int((N-3)/2)]

ans += tmp
print(ans)

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

A.sort()
A.reverse()
ans = 0
ans += A[0]

if len(A) % 2 == 0:
  tmp = 0
  for i in range(1, int((N-2)/2)+1):
    tmp += A[i] * 2
else:
  for i in range(1, int((N-3)/2)+1):
    tmp += A[i] * 2
  tmp += A[int((N-3)/2)+1]

ans += tmp
print(ans)
Problem p02642 (python)

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

A.sort()
cnt = [0] * (A[-1]+1)

for a in A:
  for i in range(a, A[-1]+1, a):
    cnt[i] += 1

ans = 0
for a in A:
  if cnt[a] == 1:
    ans += 1

print(ans)

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

A.sort()
cnt = [0] * (A[-1]+1)

for a in A:
  cnt[::a] += 1

ans = 0
for a in A:
  if cnt[a] == 1:
    ans += 1

print(ans)
Problem p02645 (python)

Fixed submission:
S = input()

print(S[:3])

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
K = min(41, K)
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N+1)
ans = [N] * N

def operation():
  global A, B, N
  for i in range(1, N+1):
    left = max(1, math.ceil(i - A[i] - 0.5))
    right = min(N, math.floor(i + A[i] + 0.5))
    B[left] += 1
    if right+1 <= N:
      B[right+1] -= 1
  for i in range(1, N+1):
    B[i] += B[i-1]


operation()

#print(A)
#print(B)

for _ in range(K):
  A = B
  B = [0] * (N+1)
  operation()

print(*A[1:])

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

N, K = map(int, input().split())
if K > 41:
  K = 41
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N+1)
ans = [N] * N

def operation():
  global A, B, N
  for i in range(1, N+1):
    left = max(1, math.ceil(i - A[i] - 0.5))
    right = min(N, math.floor(i + A[i] + 0.5))
    B[left] += 1
    B[right] -= 1
  for i in range(1, N+1):
    B[i] += B[i-1]


operation()

#print(A)
#print(B)

for _ in range(K):
  for i in range(1, N+1):
    if A[i] != B[i]:
      A[i] = B[i]
    B[i] = 0
  operation()

print(A[1:])