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

Fixed submission:
x=int(input())
if x<=11:
    if x<=6:
        print(1)
    else:
        print(2)
else:
    if x%11==0:
        print(2*(x//11))
    elif x-11*(x//11)<=6:
        print(2*(x//11)+1)
    else:
        print(2*(x//11)+2)

Buggy submission (verdict: Runtime Error):
if x<=11:
    if x<=6:
        print(1)
    else:
        print(2)
else:
    if x%11==0:
        print(2*(x//11))
    elif x-11*(x//11)<=6:
        print(2*(x//11)+1)
    else:
        print(2*(x//11)+2)
Problem p03853 (python)

Fixed submission:
h,w=map(int,input().split())
for _ in range(h):
	s=input()
	print(s)
	print(s)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
for i in range(n):
  s=input()
  for j in range(2):
    print(s)
Problem p03944 (python)

Fixed submission:
w,h,n=map(int,input().split())
x1,x2=0,w
y1,y2=0,h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        x1 = max(x1,x)
    elif a==2:
        x2 = min(x2,x)
    elif a==3:
        y1 = max(y1,y)
    elif a==4:
        y2 = min(y2,y)
print(max((x2-x1)*(y2-y1),0) if x2-x1>0 else 0)

Buggy submission (verdict: Runtime Error):
w, h, n = map(int, input().split())
xl, xr = 0, w
yd, yu = 0, h
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        if x < xl:
            continue
        elif xl <= x <= xr:
            xl = x
        else:
            xl, xr = 0
    elif a == 2:
        if xr < x:
            continue
        elif xl <= x <= xr:
            xr = x
        else:
            xl, xr = 0, 0
    elif a == 3:
        if y < yd:
            continue
        elif yd <= y <= yu:
            yd = y
        else:
            yd, yu = 0, 0
    elif a == 4:
        if y > yu:
            continue
        elif yd <= y <= yu:
            yu = y
        else:
            yd, yu = 0, 0

print((xr - xl) * (yu - yd))
Problem p04011 (python)

Fixed submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(n*x) if n<k else print(k*x+(n-k)*y)

Buggy submission (verdict: Runtime Error):
print(n*x) if n<k else print(k*x+(n-k)*y)
Problem p04012 (python)

Fixed submission:
s = input()
from collections import Counter
c = Counter(s)

flag = True
for v in c.values():
    if v%2!=0: flag = False
    
print('Yes' if flag else 'No')

Buggy submission (verdict: Runtime Error):
s = input()
from collections import Counter
c = Counter(s)

flag = True
for v in c.values():
    if v%2!=0: flag = False
    
print('Yes' if bl else 'No')
Problem p02573 (python)

Fixed submission:
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
import collections

N, M = map(int, input().split())
edge = np.array([input().split() for _ in range(M)], dtype=np.int64).T

if M == 0:
    print(1)
else:
    tmp = np.ones(M, dtype=np.int64).T
    graph = csr_matrix((tmp, (edge[:] - 1)), (N, N))

    n, labels = connected_components(graph)

    c = collections.Counter(labels)

    print(max(c.values()))

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
import collections

N, M = map(int, input().split())
edge = np.array([input().split() for _ in range(M)], dtype=np.int8).T

if M == 0:
    print(1)
else:

    tmp = np.ones(M, dtype=np.int8).T
    graph = csr_matrix((tmp, (edge[:] - 1)), (N, N))

    n, labels = connected_components(graph)

    c = collections.Counter(labels)

    print(max(c.values()))

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
import collections

N,M = map(int,input().split())
if M == 0:
    print(N)
else:
    edge = np.array([input().split() for _ in range(M)], dtype = np.int8).T
    tmp = np.ones(M, dtype = np.int8).T
    graph = csr_matrix((tmp, (edge[:] -1)), (N, N))

    n, labels = connected_components(graph,directed = False, connection = 'weak')

    c = collections.Counter(labels)

    print(max(c.values()))

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
import collections

N,M = map(int,input().split())
N = 2*(10**5)
edge = np.array([input().split() for _ in range(M)], dtype = np.int64).T
tmp = np.ones(M, dtype = np.int64).T
graph = csr_matrix((tmp, (edge[:] -1)), (N, N))

n, labels = connected_components(graph)

c = collections.Counter(labels)

print(max(c.values()))

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
import collections

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

grid = []
for i in range(m):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)

l = np.zeros((n,n))

for i in range(m):
    l[grid[i][0]-1][grid[i][1]-1] = 1

n, labels = connected_components(csr_matrix(l))

c = collections.Counter(labels)

print(max(c.values()))
Problem p02618 (python)

Fixed submission:
t_list = [i % 26 for i in range(365)]
for i in range(365):
	print(t_list[i]+1)

Buggy submission (verdict: Runtime Error):
    import time
     
    start_time = time.time()
     
    #input
    D = int(input())
    c_list = list(map(int, input().split()))
     
    s_grid = []
    for i in range(D):
        array = list(map(int, input().strip().split(' ')))
        s_grid.append(array)
     
    t_list = [1 for i in range(D)] #task_list
     
    def calculate_score(t_list,score_list,last_grid,change_query_number):
        score_list = score_list[:change_query_number]
        last_grid = last_grid[:change_query_number]
     
        if len(score_list) > 1:
            score = score_list[change_query_number-1]
            last_list = last_grid[change_query_number-1]
        else:
            score = 0
            last_list = [0 for i in range(26)]
     
        for d in range(change_query_number,D):
            score += s_grid[d][t_list[d]]
            last_list = [n+1 for n in last_list]
            last_list[t_list[d]] = 0
            for i in range(26):
                score -= c_list[i]*last_list[i]
            score_list.append(score)
            last_grid.append(last_list)
        return score_list, last_grid
     
    #first cal.
    previous_s, previous_l = calculate_score(t_list,[],[[0 for i in range(26)]],0)
    score = previous_s[-1]
     
    for k in range(1, D):
        X = -1  # k-日目に変える番号を探す
        t_list_loop = t_list
        for i in range(26):  # 26通り試す
            t_list_loop[k] = i
            score_list_k, last_grid_k = calculate_score(t_list_loop, previous_s, previous_l, k)
            if score_list_k[-1] > score:
                X = i
                score = score_list_k[-1]
                score_list_t = score_list_k
                last_grid_t = last_grid_k
     
        if X != -1:
            t_list[k] = X
            previous_s = score_list_t
            previous_l = last_grid_t
     
        # print(k,X,score)
     
        if time.time() - start_time > 1.99:
            break
     
    #final result
    for j in range(len(t_list)):
        print(int(t_list[j]) + 1)
Problem p02924 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input(n))
print(n*(n-1)/2)
Problem p03262 (python)

Fixed submission:
def gratest_common_factor(x,y):
    while y:
        amari = x % y

        x = y
        y = amari
    return x


n, x = map(int, input().split())
l = map(int, input().split())

l2 = list(map(lambda t: t-x, l))

for i in range(n-1):
    l2[1] = gratest_common_factor(l2[0],l2[1])
    del l2[0]

print(abs(l2[0]))

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

n, x = map(int, input().split())
l = map(int, input().split())

l2 = map(lambda t: t-x, l)

gcd = functools.reduce(math.gcd, l2)
print(gcd)
Problem p02555 (python)

Fixed submission:
S = int(input())

if S < 3:
    print(0)
    exit()

if S < 6:
    print(1)
    exit()

x = [0] * (S + 1)
x[3] = x[4] = x[5] = 1
for i in range(6, S + 1):
    x[i] += 1
    for j in range(3, i - 3 + 1):
        x[i] += x[i - j]

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

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

if S < 3:
    print(0)
    exit()

x = [0] * (S + 1)
x[3] = x[4] = x[5] = 1
for i in range(6, S + 1):
    x[i] += 1
    for j in range(3, i - 3 + 1):
        x[i] += x[i - j]

print(x[S] % (10 ** 9 + 7))
Problem p02573 (python)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)


N, M = map(int, input().split())
C = [set([]) for i in range(N)]


def dfs(n, y):
    seen[n] = True
    y += 1
    for c in C[n]:
        if seen[c]:
            continue
        else:
            y = dfs(c, y)
    return y


for i in range(M):
    a, b = map(int, input().split())
    C[a - 1].add(b - 1)
    C[b - 1].add(a - 1)

ans = 0
seen = [False] * N
for i in range(N):
    if seen[i]:
        continue
    x = 0
    x = dfs(i, x)
    ans = max(ans, x)

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
C = [set([]) for i in range(N)]


def dfs(n, y):
    seen[n] = True
    y += 1
    for c in C[n]:
        if seen[c]:
            continue
        else:
            y = dfs(c, y)
    return y


for i in range(M):
    a, b = map(int, input().split())
    C[a - 1].add(b - 1)
    C[b - 1].add(a - 1)

ans = 0
seen = [False] * N
for i in range(N):
    if seen[i]:
        continue
    x = 0
    x = dfs(i, x)
    ans = max(ans, x)

print(ans)
Problem p02660 (python)

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

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

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

    return arr


N = int(input())
p = factorization(N)
count = 0
for x in p:
    if N == 1:
        break
    for j in range(1, x[1] + 1):
        if N % (x[0] ** j) == 0:
            N /= x[0] ** j
            count += 1
        else:
            break
print(count)

Buggy submission (verdict: Runtime Error):
import math


def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

        # nの平方根まで計算する
    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
    return True


N = int(input())
if N == 1:
    print(0)
elif isPrime(N):
    print(1)
else:
    count = 0
    for i in range(2, N//2):
        if not isPrime(i):
            continue
        if isPrime(N) and i > N:
            break
        for j in range(1, 10):
            if N % i**j == 0:
                N = N / i**j
                count += 1
                if N == 1 or N % i != 0:
                    break
print(count)
Problem p02732 (python)

Fixed submission:
from scipy.special import comb
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
x = 0

for c in C.values():
    x += comb(c, 2, exact=True)

for i in range(N):
    y = x - comb(C[A[i]], 2, exact=True) + comb(C[A[i]] - 1, 2, exact=True)
    print(y)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
x = 0

for c in C.values():
    x += comb(c, 2, exact=True)

for i in range(N):
    y = x - comb(C[A[i]], 2, exact=True) + comb(C[A[i]] - 1, 2, exact=True)
    print(y)
Problem p03161 (python)

Fixed submission:
import numpy as np


N, K = map(int, input().split())
h = np.array([int(i) for i in input().split()])
dp = np.full(N, 10 ** 10)

# 初期条件
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    ik = max(0, i - K)
    dp[i] = np.min(dp[ik:i] + np.abs(h[i] - h[ik:i]))

print(int(dp[-1]))

Buggy submission (verdict: Runtime Error):
import math


N, K = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [math.inf] * N

# 初期条件
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    for j in range(1, K + 1):
        if i - j < 0:
            break
            
        dp[i] = min(
            dp[i],
            dp[i - j] + abs(h[i] - h[i - j])
        )

print(dp[N - 1])
Problem p03339 (python)

Fixed submission:
n = int(input())
S = input()
e_sum = [0] * n
w_sum = [0] * n
ew_sum = [0] * n
for i in range(2, n + 1):
    e_sum[-i] = e_sum[-i + 1] + 1 if S[-i + 1] == 'E' else e_sum[-i + 1]
    ew_sum[-i] = e_sum[-i]
for i in range(1, n):
    w_sum[i] = w_sum[i - 1] + 1 if S[i - 1] == 'W' else w_sum[i - 1]
    ew_sum[i] += w_sum[i]

print(min(ew_sum))

Buggy submission (verdict: Runtime Error):
n = int(input())
S = input()
count = 0
answer = n - 1
for i in range(n):
    print(S[:i], S[i + 1:])
    count = S[:i].count('W') + S[i + 1:].count('E')
    answer = min(answer, count)
    count = 0

print(answer)
Problem p02675 (python)

Fixed submission:
n = (input())
s=int(n[-1])
if s in (2,4,5,7,9):
  print("hon")
elif s in (1,6,8,0):
  print("pon")
else:
  print("bon")

Buggy submission (verdict: Runtime Error):
import math
n, k = map(int,input().split())
g={}
for i in range(n):
    g[i]=[]
for i in range(k):
    a,b= map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
ans = [-1] * n
queue = [0]
visited = [False] * n
 

while queue:
    x = queue.pop(0)
    for n in g[x]:
        if visited[n] == False: 
            queue.append(n)
            if ans[n] == -1: 
                ans[n] = x
                visited[n] = True
 
if -1 in ans[1:]:
    print('No')
else:
    print('Yes')
    for a in ans[1:]:
        print(a+1)

Buggy submission (verdict: Runtime Error):
import math
n, k = map(int,input().split())
g={}
for i in range(n):
    g[i]=[]
for i in range(k):
    a,b= map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
ans = [-1] * n
queue = [0]
visited = [False] * n
 

while queue:
    x = queue.pop(0)
    for n in g[x]:
        if visited[n] == False: 
            queue.append(n)
            if ans[n] == -1: 
                ans[n] = x
                visited[n] = True
 
if -1 in ans[1:]:
    print('No')
else:
    print('Yes')
    for a in ans[1:]:
        print(a+1)
Problem p02681 (python)

Fixed submission:
from math import sqrt
s = input()
t= input()

if t==(s+t[-1]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
l =[0]+ list(map(int,input().split()))
q=l[1]
cnt=1
d=[]
d.append(q)
while True and cnt<=n:
    q=l[q]
    cnt+=1
    if q in d:
        d.append(q)
        break
    else:
        d.append(q)
a=d.index(d[-1])
la=len(d)-1
cir=la-a
k=k-a
k=k%cir

print(d[a+k-1])
Problem p02690 (python)

Fixed submission:
x = int(input())
for i in range(-1000,1000):
    for j in range(-1000,1000):
        if x == i**5 - j ** 5:
            print(i,j)
            exit()

Buggy submission (verdict: Runtime Error):

n= int(input())
x=0
while True:
    if int((n-(x**5))**(1/5))==(n-(x**5))**(1/5):
        print(-x,int((n+(x**5))**(1/5)))
        break
    if  int((n+(x**5))**(1/5))==(n+(x**5))**(1/5):
        print(x,int((n+(x**5))**(1/5)))
    x=x+1
Problem p02717 (python)

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

Buggy submission (verdict: Runtime Error):
n,m= map(int,input().split())
l = list(map(int,input().split()))
s = sum(l)
r=s/(4*m)
cnt=0
for i in l:
    
    if i>=r:
        cnt=cnt+1

if cnt>=m:
    print("Yes")
else:
    print("No")
Problem p03813 (python)

Fixed submission:
x=int(input())
if x<1200:
  print("ABC")
else:
  print("ARC")

Buggy submission (verdict: Runtime Error):
from collections import Counter
 
N = int(input())
A = sorted(list(map(int,input().split())))
 
edible = sum(i-1 for i in Counter(A).values())
print(len(set(A))-edible%2)
Problem p02658 (python)

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

while len(arr) > 1:
    m = len(arr)
    if m & 1:
        arr.append(1)
        m += 1

    left, right = arr[:m // 2], arr[m // 2:]
    arr = [x * y for x, y in zip(left, right)]

x = arr[0]
if x > 10 ** 18:
    print(-1)
else:
    print(x)

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

while len(arr) > 1:
    m = len(arr)
    if m & 1:
        arr.append(1)
        m += 1

    left, right = arr[:n // 2], arr[n // 2:]
    arr = [x * y for x, y in zip(left, right)]

x = arr[0]
if x > 10 ** 18:
    print(-1)
else:
    print(x)
Problem p02719 (python)

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

print(min(n % k, k - (n % k)))

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

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

x = gcd(max(k, n), min(k, n))
if n % k == 0:
    print(0)
elif n < k:
    print(min(n, abs(n - k)))
else:
    exit(1)
    print(1)

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

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

x = gcd(max(k, n), min(k, n))
if n % k == 0:
    print(0)
elif n < k:
    exit(1)
    print(min(n, abs(n - k)))
else:
    print(1)
Problem p02585 (python)

Fixed submission:
n,k=map(int,input().split())
p=[0]+list(map(int,input().split()))
c=[0]+list(map(int,input().split()))
ans=-10**18
for i in range(1,n+1):
  vis=set()
  now=i
  a=[0]
  m=k
  while m:
    vis.add(now)
    now=p[now]
    a+=[c[now]+a[-1]]
    m-=1
    if now in vis:break
  if m==0 or a[-1]<=0:
    cnt=max(a[1:])
  else:
    cnt=(k//(k-m))*a[-1]
    if k%(k-m):cnt+=max(a[1:k%(k-m)+1])
    elif max(a[1:])>a[-1]:
      cnt=cnt=(k//(k-m)-1)*a[-1]+max(a[1:])
  ans=max(ans,cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
p=[0]+list(map(int,input().split()))
c=[0]+list(map(int,input().split()))
ans=-10**18
for i in range(1,n+1):
  vis=set()
  now=i
  a=[0]
  m=k
  while m:
    vis.add(now)
    now=p[now]
    a+=[c[now]+a[-1]]
    m-=1
    if now in vis:break
  if m==0 or a[-1]<=0:
    cnt=max(a[1:])
  else:
    cnt=k//(k-m)*a[-1]+max(a[1:k%(k-m)+1])
  ans=max(ans,cnt)
print(ans)
Problem p02586 (python)

Fixed submission:
h,w,k=map(int,input().split())
dp=[[[0]*(w+2) for _ in range(h+2)] for _ in range(4)]
f=[[0]*(w+1) for _ in range(h+1)]
for _ in range(k):
  r,c,v=map(int,input().split())
  f[r][c]=v
for i in range(1,h+1):
  for j in range(1,w+1):
    for k in range(3,-1,-1):
      if k:dp[k][i][j]=max(dp[k][i][j],dp[k-1][i][j]+f[i][j])
      dp[0][i+1][j]=max(dp[0][i+1][j],dp[k][i][j])
      dp[k][i][j+1]=max(dp[k][i][j+1],dp[k][i][j])
print(max(dp[k][h][w] for k in range(4)))

Buggy submission (verdict: Runtime Error):
h,w,n=map(int,input().split())
dp=[[[0]*4 for _ in range(w+1)] for _ in range(h+1)]
v=[[0]*(w+1) for _ in range(h+1)]
for _ in range(n):
  r,c,f=map(int,input().split())
  v[r][c]=f
for i in range(1,h+1):
  for x in 0,1,2:
    for j in range(1,w+1):
      dp[i][j][x+1]=max(dp[i][j][x],max(dp[i][j+1][x],(x<1)*dp[i+1][j][3])+v[i][j],dp[i+1][j][x+1])
print(dp[-1][-1][-1])

Buggy submission (verdict: Runtime Error):
h,w,n=map(int,input().split())
dp=[[[0]*4 for _ in range(w+1)] for _ in range(h+1)]
v=[[0]*(w+1) for _ in range(h+1)]
for _ in range(n):
  r,c,f=map(int,input().split())
  v[r][c]=f
for i in range(h):
  for x in 1,2,3:
    for j in range(w):
      dp[i+1][j+1][x]=max(dp[i+1][j+1][x-1],max(dp[i][j+1][x],(x<2)*dp[i+1][j][3])+v[i+1][j+1],dp[i+1][j][x]
print(dp[-1][-1][-1])
Problem p02609 (python)

Fixed submission:
n=int(input())
x=input()
pc=[0]
m=2*10**5
for i in range(1,m+2):
  cnt=0
  j=i
  while i:
    cnt+=i%2
    i//=2
  pc+=[j%cnt]
f=[0]*(m+2)
for i in range(1,m+2):
  if pc[i]==0:f[i]=1
  else:f[i]=f[pc[i]]+1
cnt=x.count('1')
ix=int(x,2)
ixp=ix%(cnt+1)
ixm=ix%(cnt-1) if cnt-1 else 0
d=1<<(n-1)
for i in range(n):
  dp=pow(2,n-i-1,cnt+1)
  if cnt-1:dm=pow(2,n-i-1,cnt-1)
  if x[i]=='0':print(f[(ixp+dp)%(cnt+1)]+1)
  else:
    if cnt-1:print(f[(ixm-dm)%(cnt-1)]+1)
    else:print(0)

Buggy submission (verdict: Runtime Error):
def f(n):
  if n==0:return 0
  else:return f(pc[n])+1
n=int(input())
x=input()
pc=[0]
m=10**5
for i in range(1,m+1):
  cnt=0
  j=i
  while i:
    cnt+=i%2
    i//=2
  pc+=[j%cnt]
cnt=x.count('1')
ix=int(x,2)
d=2**(n-1)
for i in range(n):
  if x[i]=='0':print(f((ix+d)%(cnt+1))+1)
  else:
    if ix-d>m:print(f((ix-d)%(cnt-1))+1)
    else:print(f(ix-d))
  d//=2

Buggy submission (verdict: Runtime Error):
n=int(input())
x=input()
pc=[0]*(2*10**5+1)
pc[1]=1
for i in range(1,2*10**5+1):
  pc[i]=pc[i>>1]+pc[i&1]
f=[0]*(2*10**5+1)
for i in range(1,2*10**5+1):
  f[i]=f[i%pc[i]]+1
xx=int(x,2)
j=2**(n-1)
cnt=x.count('1')
xm=xx%(cnt-1)
xp=xx%(cnt+1)
for i in range(n):
  if x[i]=='1':
    c=cnt-1
    nx=(xm-(j>>i)%c)%c
  else:
    c=cnt+1
    nx=(xp+(j>>i)%c)%c
  print(f[nx]+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
x=input()
pc=[0]*(2*10**5+1)
pc[1]=1
for i in range(1,2*10**5+1):
  pc[i]=pc[i>>1]+pc[i&1]
f=[0]*(2*10**5+1)
for i in range(1,2*10**5+1):
  f[i]=f[i%pc[i]]+1
xx=int(x,2)
j=2**(n-1)
cnt=x.count('1')
for i in range(n):
  if x[i]=='1':
    c=cnt-1
    nx=(xx-(j>>i))%c
  else:
    c=cnt+1
    nx=(xx+(j>>i))%c
  print(f[nx]+1)
Problem p02615 (python)

Fixed submission:
n=int(input())
a=sorted(list(map(int,input().split())))[::-1]
ans=0
for i in range(1,n):
  ans+=a[i//2]
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter 
n=int(input())
a=sorted(list(map(int,input().split())))
b=[]
c=[]
for i in list(Counter(a).values()):
  b.append(i)
for i in list(Counter(a).keys()):
  c.append(i)
ans=c.pop()*((b[-1])-1)
m=a[-1]
f=len(b)
for _ in range(f-2,-1,-1):
  if b[-1]>b[i]:
    b[-1]-=b[i]
    b.pop(i)
    c.pop(i)    
    ans+=b[i]*m
  else:
    ans+=m*b[-1]
    b[i]-=b[-1]
    m=c.pop()
    ans+=m*b[i]
    b.pop()
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter 
n=int(input())
a=sorted(list(map(int,input().split())))
b=[]
c=[]
for i in list(Counter(a).values()):
  b.append(i)
for i in list(Counter(a).keys()):
  c.append(i)
ans=c.pop()*((b[-1])-1)
m=a[-1]
f=len(b)
for _ in range(f-2,-1,-1):
  i=-2
  if b[-1]>b[i]:
    b[-1]-=b[i]
    b.pop(i)
    c.pop(i)    
    ans+=b[i]*m
  else:
    ans+=m*b[-1]
    b[i]-=b[-1]
    m=c.pop()
    ans+=m*b[i]
    b.pop()
print(ans)
Problem p02642 (python)

Fixed submission:
def sieve(n=10**6):
  p=[-1]*(n+1)
  for i in a:
    if p[i]==-1:
      p[i]=1
      for j in range(2*i,n+1,i):p[j]=0
    elif p[i]==1:
      p[i]=0
  return p
n=int(input())
a=sorted(list(map(int,input().split())))
p=sieve()
ans=0
for i in a:
  ans+=p[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
dp=[True]*a[-1]
for i in a:
  for j in range(i,a[-1]):
    if j%i==0:
      dp=False
cnt=0
for i in a:
  if dp[i]:
    cnt+=1
print(cnt)
Problem p02647 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for _ in range(min(k,41)):
  b=[0]*(n+1)
  for i in range(n):
    l=max(0,i-a[i])
    r=min(n,i+a[i]+1)
    b[l]+=1
    b[r]-=1
  for i in range(n-1):
    b[i+1]+=b[i]
  a=b[:n]
print(*a)

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

for i in range(k):
  b=[0]*n
  cnt=0
  for j in range(n):
    if a[j]>=max(n-j,j)
    cnt+=1
  if cnt==n:
    for j in range(n):
      a[j]=(k-i)*n
    break
  for j in range(n):
    for m in range(j-a[j],j+a[j]+1):
      if 0<=m<=n-1:
        b[m]=b[m]+1
  a=b
for i in a:
  print(i,end=' ')

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

for i in range(k):
  b=[0]*n
  cnt=0
  for j in range(n):
    if a[j]>=max(n-j,j)
    cnt+=1
  if cnt==n:
    for i in j in range(n):
      a[j]=(k-i)*n
    break
  for j in range(n):
    for m in range(j-a[j],j+a[j]+1):
      if 0<=m<=n-1:
        b[m]=b[m]+1
  a=b
for i in a:
  print(i,end=' ')
Problem p02731 (python)

Fixed submission:
print((int(input())/3)**3)

Buggy submission (verdict: Runtime Error):
print(int(input()/3)**3)