Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)

cum_A = [0]
for ai in A:
    cum_A.append(cum_A[-1] + ai)

cur_Ai = A[P]
ans = P
j = P
for i in range(P, N):
    if (i + 1 < N) and (A[i] == A[i + 1]):
        continue

    while A[j] >= A[i] + M:
        j += 1

    if A[i] + M < A[P - 1]:
        break
    elif (
        M * (P - 1)
        + (A[i] + M) * (i + 1 - j)
        - (cum_A[i + 1] - cum_A[j])
        + M * (N - i - 1)
        >= M * V
    ):
        ans = i + 1
    else:
        break

print(ans)


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

if (B - A) % 2 == 0:
    ans = (B - A) // 2
else:
    ans = min((B - 1 + A - 1 + 1) // 2, (N - A + N - B + 1) // 2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = map(int, input().split())
MOD = 10 ** 9 + 7

counts = [0] * 60
for a in A:
    for i in range(60):
        counts[i] += (a >> i) % 2

power2 = [1]
for _ in range(59):
    power2.append((power2[-1] * 2) % MOD)


ans = sum(c * (N - c) * power2[i] for i, c in enumerate(counts))

print(ans % MOD)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

counts = [sum((a >> i) & 1 for a in A) for i in range(60)]

power2 = [1]
for _ in range(59):
    power2.append((power2[-1] * 2) % MOD)

ans = sum(c * (N - c) * power2[i] for i, c in enumerate(counts))

print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = map(int, input().split())
MOD = 10 ** 9 + 7

counts = [0] * 60
for a in A:
    for i in range(60):
        counts[i] += (a >> i) % 2

ans = sum(c * (N - c) * (2 ** i % MOD) % MOD for i, c in enumerate(counts))

print(ans % MOD)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

counts = [sum((a >> i) & 1 for a in A) for i in range(60)]

power2 = [1]
for _ in range(59):
    power2.append((power2[-1] * 2) % MOD)

ans = sum(c * (N - c) * power2[i] for i, c in enumerate(counts))

print(ans % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

S = "1234" * 3000
from itertools import product
from re import search

ans = 0
for i in product(map(str, range(10)), repeat=3):
    res = search(".*?".join(i), S)
    if res:
        ans += 1

print(ans)


Fixed submission:
from itertools import product

N = int(input())
S = input()

one = set()
two = set()
three = set()
for s in S:
    for tw in two:
        three.add(tw + s)
    for on in one:
        two.add(on + s)
    one.add(s)
print(len(three))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
s = [Counter(input()) for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            ans += 1

print(ans)


Fixed submission:
from collections import Counter

n = int(input())
s = [list(input()) for _ in range(n)]


for i in range(n):
    s[i].sort()
    s[i] = "".join(s[i])

c = Counter(s)

ans = 0

for v in c.values():
    ans += v * (v - 1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab = [(map(int, input().split())) for _ in range(n)]

jobs = [(a, -b) for a, b in ab]
jobs.sort()

ans = 0
job_index = 0
for i in range(m):
    while job_index < len(jobs):
        if jobs[job_index] + i < m:
            ans -= jobs[job_index][1]
        else:
            job_index += 1
print(ans)


Fixed submission:
from heapq import heappush, heappop

n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]


jobs = [[] for _ in range(m)]
for a, b in ab:
    if a <= m:
        jobs[a - 1].append(-b)

ans = 0
available = []
for job in jobs:
    for jo in job:
        heappush(available, jo)

    if available:
        ans -= heappop(available)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]


jobs = [[] for _ in range(m)]
for a, b in ab:
    if a <= m:
        jobs[a - 1].append(b)

ans = 0
available = []
for job in jobs:
    available += job
    available.sort()
    if available:
        ans += available.pop()

print(ans)


Fixed submission:
from heapq import heappush, heappop

n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]


jobs = [[] for _ in range(m)]
for a, b in ab:
    if a <= m:
        jobs[a - 1].append(-b)

ans = 0
available = []
for job in jobs:
    for jo in job:
        heappush(available, jo)

    if available:
        ans -= heappop(available)

print(ans)
Buggy python submission (verdict: Runtime Error):
ress = [[(10 ** i * j) % 13 for j in range(10)] for i in range(6)]

mod = 10 ** 9 + 7

keta = 0
res = 5
state = [1] + [0] * 12
for s in reversed(input()):
    if s == "?":
        new_state = [0] * 13
        for i in range(13):
            for r in ress[keta]:
                new_state[i] += state[(i - r) % 13]

        state = new_state
    else:
        res -= ress[keta][int(s)]

    if keta == 5:
        keta = 0
        for i in range(13):
            new_state[i] %= mod
    else:
        keta += 1


print(state[res % 13] % mod)


Fixed submission:
import numpy as np
from numpy.fft import fft, ifft

mod = 10 ** 9 + 7
S = input()

mat = []
for i in range(6):
    w = np.zeros(13)
    for j in range(10):
        w[(10 ** i * j) % 13] += 1
    mat.append(fft(w))

ress = [[(10 ** i * j) % 13 for j in range(10)] for i in range(6)]


state = np.zeros(13)
state[0] = 1
state = fft(state)

keta = 0
res = 5
for s in reversed(S):
    if s == "?":
        state = state * mat[keta]
    else:
        res -= ress[keta][int(s)]

    if keta == 5:
        keta = 0
        state = fft(np.remainder(np.round(np.real(ifft(state))), mod))
    else:
        keta += 1


state = ifft(state)
print(int(np.round(np.real(state[res % 13]))) % mod)

Buggy python submission (verdict: Time Limit Exceeded):
ress = [[(10 ** i * j) % 13 for j in range(10)] for i in range(6)]

mod = 10 ** 9 + 7

keta = 0
res = 0
state = [1] + [0] * 12
for s in reversed(input()):
    if s == "?":
        new_state = [0] * 13
        for i in range(13):
            for r in ress[keta % 6]:
                new_state[i] += state[(i - r) % 13]
            new_state[i] %= mod
        state = new_state
    else:
        res += ress[keta % 6][int(s)]
    keta += 1

res = (5 - res) % 13

print(state[res] % mod)


Fixed submission:
import numpy as np
from numpy.fft import fft, ifft

mod = 10 ** 9 + 7
S = input()

mat = []
for i in range(6):
    w = np.zeros(13)
    for j in range(10):
        w[(10 ** i * j) % 13] += 1
    mat.append(fft(w))

ress = [[(10 ** i * j) % 13 for j in range(10)] for i in range(6)]


state = np.zeros(13)
state[0] = 1
state = fft(state)

keta = 0
res = 5
for s in reversed(S):
    if s == "?":
        state = state * mat[keta]
    else:
        res -= ress[keta][int(s)]

    if keta == 5:
        keta = 0
        state = fft(np.remainder(np.round(np.real(ifft(state))), mod))
    else:
        keta += 1


state = ifft(state)
print(int(np.round(np.real(state[res % 13]))) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = [int(input()) for _ in range(n)]

dp = [0] * n
last_dic = {}
for i in range(n):
    if c[i] in last_dic.keys() and i - last_dic[c[i]] >= 2:
        dp[i] = 1 + sum(dp[:last_dic[c[i]]+1])
    last_dic[c[i]] = i
print(1+sum(dp))

Fixed submission:
n = int(input())
c = [int(input()) for _ in range(n)]
m = 10**9+7

dp = [-1] * n
dp[0] = 1
last_dic = {}
for i in range(n):
    if c[i] in last_dic.keys() and i - last_dic[c[i]] >= 2:
        dp[i] = (dp[i-1] + dp[last_dic[c[i]]]) % m
    elif i:
        dp[i] = dp[i-1]
    last_dic[c[i]] = i
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
dp = [[0] * 5 for _ in range(len(a) + 1)]

for i, x in enumerate(a):
    m = x % 2
    y = m + (x == 0) * 2
    z = 1 - m
    
    dp[i+1][0] = dp[i][0] + x
    dp[i+1][1] = min(dp[i][:2]) + y
    dp[i+1][2] = min(dp[i][:3]) + z
    dp[i+1][3] = min(dp[i][:4]) + y
    dp[i+1][4] = min(dp[i]) + x

print(min(dp[-1]))

Fixed submission:
a = [int(input()) for _ in range(int(input()))]

dp = [[0] * 5 for _ in range(len(a) + 1)]

for i, x in enumerate(a):
    y = x % 2 + (x == 0) * 2
    z = (x + 1) % 2
    
    dp[i+1][0] = min(dp[i][0:1]) + x
    dp[i+1][1] = min(dp[i][0:2]) + y
    dp[i+1][2] = min(dp[i][0:3]) + z
    dp[i+1][3] = min(dp[i][0:4]) + y
    dp[i+1][4] = min(dp[i][0:5]) + x

print(min(dp[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
abd = [[x[0], x[1], x[0] - x[1]] for x in ab]
abd.sort(key=lambda x: -x[2])

sol = 0
while abd:
  player = (n - len(abd)) % 2
  if len(abd) % 2:
    eat = min(range(len(abd)), key=lambda x: 2e9*abd[x][2] - abd[x][player])
  else:
    eat = min(range(len(abd)), key=lambda x: abd[x][2] - 2e9*abd[x][player])
  if player:
    sol -= abd[eat][player]
  else:
    sol += abd[eat][player]
  del abd[eat]
print(sol)
  




Fixed submission:
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=sum, reverse=True)

sol = 0

for i, x in enumerate(ab):
  if i % 2:
    sol -= ab[i][1]
  else:
    sol += ab[i][0]

print(sol)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
py = [tuple(map(int, input().split())) for _ in range(m)]

t = [[] for _ in range(n)]

for p, y in py:
  t[p-1].append(y)

for ti in t:
  ti.sort()
  
for p, y in py:
  kami = p
  shimo = t[p-1].index(y) + 1
  print('{0:06d}{1:06d}'.format(kami, shimo))

Fixed submission:
import bisect

n, m = map(int, input().split())
py = [tuple(map(int, input().split())) for _ in range(m)]

t = [[] for _ in range(n)]

for p, y in py:
  t[p-1].append(y)

for ti in t:
  ti.sort()
  
for p, y in py:
  kami = p
  shimo = bisect.bisect_left(t[p-1], y) + 1
  print('{0:06d}{1:06d}'.format(kami, shimo))
Buggy python submission (verdict: Runtime Error):
from math import ceil
n, m = map(int, input().split())
for i in range(n, ceil(m**.5), 1):
    if not m % i:
        print(m//i)
        break
for i in range(int(min((m / n), m**.5)), 0, -1):
    if not m % i:
        print(i)
        break


Fixed submission:
if input() == '1':
    print('Hello World')
    exit()
print(int(input())+int(input()))
Buggy python submission (verdict: Runtime Error):
import numpy as np
def kouho(x, y, h):
    if h:
        return np.abs(np.arange(101) - x)[:, np.newaxis]  + np.abs(np.arange(101) - y) [np.newaxis] + h

n = int(input())
arrs = []
arrs0 = [np.ones((101, 101), dtype=np.int)*1000000000]
for _ in range(n):
  x, y, h = map(int, input().split())
  if h:
    arrs.append(kouho(x, y, h))
  else:
    arr0.append(kouho(x, y, h))
    
arrs = np.array(arrs)
arrs0 = np.array(arrs0)
for i in range(101):
  for j in range(101):
    if np.all(arrs[:,i,j]==arrs[0,i,j]) and (arrs[0,i,j] <= arrs0[:,i,j].min()):
      print(i, j, arrs[0, i, j])
      break

Fixed submission:
def ni(): 
    return int(input())
def li():
    return map(int, input().split())

xyh = [tuple(li()) for _ in range(ni())]
xmax, ymax, hmax = max(xyh, key=lambda _: _[-1])

for x_cent in range(101):
    for y_cent in range(101):
        h_cent = hmax + abs(xmax-x_cent) + abs(ymax-y_cent)
        
        for x, y, h in xyh:
            if h != max(0, h_cent - abs(x-x_cent) - abs(y-y_cent)):
                break
        else:
            print(x_cent, y_cent, h_cent)

Buggy python submission (verdict: Runtime Error):
import numpy as np
def kouho(x, y, h):
    if h:
        return np.abs(np.arange(101) - x)[:, np.newaxis]  + np.abs(np.arange(101) - y) [np.newaxis] + h

n = int(input())
arrs = []
for _ in range(n):
    arrs.append(kouho(*(map(int, input().split()))))
arrs = np.array(arrs)
for i in range(101):
  for j in range(101):
    if np.all(arrs[:,i,j]==arrs[0,i,j]):
      print(i, j, arrs[0, i, j])
      break

Fixed submission:
def ni(): 
    return int(input())
def li():
    return map(int, input().split())

xyh = [tuple(li()) for _ in range(ni())]
xmax, ymax, hmax = max(xyh, key=lambda _: _[-1])

for x_cent in range(101):
    for y_cent in range(101):
        h_cent = hmax + abs(xmax-x_cent) + abs(ymax-y_cent)
        
        for x, y, h in xyh:
            if h != max(0, h_cent - abs(x-x_cent) - abs(y-y_cent)):
                break
        else:
            print(x_cent, y_cent, h_cent)

Buggy python submission (verdict: Runtime Error):
import numpy as np
def kouho(x, y, h):
    if h:
        return np.abs(np.arange(101) - x)[:, np.newaxis]  + np.abs(np.arange(101) - y) [np.newaxis] + h

n = int(input())
arrs = []
for _ in range(n):
    arrs.append(kouho(*(map(int, input().split()))))
arrs = np.array(arrs)
v = arrs.var(0)
m = arrs.mean(0)
for i in range(101):
  for j in range(101):
    if v[i, j]==0:
      print(i, j, int(m[i, j]))
      break

Fixed submission:
def ni(): 
    return int(input())
def li():
    return map(int, input().split())

xyh = [tuple(li()) for _ in range(ni())]
xmax, ymax, hmax = max(xyh, key=lambda _: _[-1])

for x_cent in range(101):
    for y_cent in range(101):
        h_cent = hmax + abs(xmax-x_cent) + abs(ymax-y_cent)
        
        for x, y, h in xyh:
            if h != max(0, h_cent - abs(x-x_cent) - abs(y-y_cent)):
                break
        else:
            print(x_cent, y_cent, h_cent)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
for i in range(int(m / n), 0, -1):
    if not m % i:
        print(i)
        break

Fixed submission:
from math import ceil
n, m = map(int, input().split())
for i in range(n, ceil(m**.5), 1):
    if not m % i:
        print(m//i)
        exit()
for i in range(int(min((m / n), m**.5)), 0, -1):
    if not m % i:
        print(i)
        break
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m = map(int, input().split())
a = [0] + list(map(int, input().split()))

a = np.array(a)

_, c = np.unique(np.cumsum(a % m) % m, return_counts=True)

print((c * (c - 1)).sum() // 2)

Fixed submission:
import numpy as np
from collections import Counter

n, m = map(int, input().split())
a = [0] + list(map(int, input().split()))
a = np.array(a)
c = Counter(np.cumsum(a % m) % m)
print(sum(i * (i - 1) for i in c.values()) // 2)
Buggy python submission (verdict: Runtime Error):
p = [1, 0, 0, 0]

for s in input():
    if s == 'A' :
        p[1] += p[0]
    if s == 'B' :
        p[2] += p[1]
    if s == 'C' :
        p[3] += p[2]
    if s == '?':
        p[3] += p[2] + p[3] * 2
        p[2] += p[1] + p[2] * 2
        p[1] += p[0] + p[1] * 2
        p[0] += p[0] * 2
        
print(int(p[3] % (1e9 + 7)))

Fixed submission:
p = [1, 0, 0, 0]
m = 1e9 + 7
def mod(x):
    return int(x % m)

for s in input():
    if s == 'A' :
        p[1] = mod(p[0] + p[1])
    if s == 'B' :
        p[2] = mod(p[1] + p[2])
    if s == 'C' :
        p[3] = mod(p[2] + p[3])
    if s == '?':
        p[3] = mod(p[2] + p[3] * 3)
        p[2] = mod(p[1] + p[2] * 3)
        p[1] = mod(p[0] + p[1] * 3)
        p[0] = mod(p[0] * 3)
        
print(int(p[3] % m))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

sl = s[:n]
sr = s[n:][::-1]

from collections import Counter
l = Counter()
r = Counter()

from itertools import product
for m in product([False, True], repeat=n):
  key = [sl[i] for i in range(n) if not m[i]]
  key += ['-']
  key += [sl[i] for i in range(n) if m[i]]
  l[''.join(key)] += 1
  
  key = ''.join([sr[i] for i in range(n) if not m[i]])
  key += '-'
  key += ''.join([sr[i] for i in range(n) if m[i]])
  r[key] += 1
  
ans = sum(l[lk] * r[lk] for lk in l.keys())
print(ans)

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

sl = s[:n]
sr = s[n:][::-1]

from collections import Counter
l = Counter()
r = Counter()

from itertools import product
for m in product([False, True], repeat=n):
  key = [sl[i] for i in range(n) if not m[i]]
  key += ['-']
  key += [sl[i] for i in range(n) if m[i]]
  l[''.join(key)] += 1
  
  key = [sr[i] for i in range(n) if not m[i]]
  key += ['-']
  key += [sr[i] for i in range(n) if m[i]]
  r[''.join(key)] += 1
  
ans = sum(l[lk] * r[lk] for lk in l.keys())

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = n

for i in range(0, n):
  kaeru = sum(s[j] == 'W' for j in range(i)) + sum(s[j] == 'E' for j in range(i+1,n))
  
  ans = min(kaeru, ans)
print(ans)


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

w = [0] * n
for i in range(n-1):
  w[i+1] = w[i] + int(s[i] == 'W')
    
    
e = [0] * n
for i in reversed(range(1, n)):
  e[i-1] = e[i] + int(s[i] == 'E')
    
print(min(ww+ee for ww, ee in zip(w, e)))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())

subs = set()

for i in range(len(s)):
  for j in range(i+1, len(s)+1):
    subs.add(s[i:j])
subs = list(subs) 
subs.sort()
print(subs[k-1])

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

subs = set()

for i in range(len(s)):
  for j in range(i+1, min(5+i+1, len(s)+1)):

    subs.add(s[i:j])
subs = list(subs) 
subs.sort()
print(subs[k-1])
Buggy python submission (verdict: Runtime Error):
n,x,t=map（int,input（）.split（））

if n%x==0 :
  print（（n//x）*t）
else :
  print（（n//x+1）*t）

Fixed submission:
n,x,t=map(int,input().split())
if n%x!=0 :
    print((n//x+1) *t)
else:
    print((n//x)*t)
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())

p=0
for i in range(k+2) :
    p+=7*(10**i)
    if p%k==0 :
        print(i+1)
        exit()
else :
    print(-1)

Fixed submission:
k=int(input())
q=[7]
Q=[0]

for i in range(k) :
    q.append((q[i]*10)%k)
    if (q[i]+Q[i])%k==0 :
        print(i+1)
        exit()
    Q.append((q[i]+Q[i])%k)
    
else :
    print(-1)
Buggy python submission (verdict: Runtime Error):
n,k=int(input())
A=list(map(int,input().split()))

right=10**9
left=1

while right-left>1 :
    mid=(left+right)//2
    count=0
    for a in A :
        count+=a//mid
        if a%mid==0 :
            count-=1
    if count<=k :
        right=mid
    else :
        left=mid

print(right)

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

right=10**9
left=0

while right-left>1 :
    mid=(left+right)//2
    count=0
    for a in A :
        count+=a//mid
        if a%mid==0 :
            count-=1
    if count<=k :
        right=mid
    else :
        left=mid

print(right)
Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce

N,K=map(int,input().split())
A=list(map(int,input().split()))

for i in range(N-K) :
    x=reduce(mul,A[i:i+K])
    y=reduce(mul,A[i+1:i+K+1])
    if x<y :
        print("Yes")
    else :
        print("No")

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

for i in range(N-K) :
    if A[i]<A[i+K] :
        print("Yes")
    elif A[i]>=A[i+K] :
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=A+B
C.sort()
if sum(C)<=K :
    print(len(C))
    sys.exit()
for i in range(len(C)) :
    if sum(C[:i])>K :
        print(i-1)
        sys.exit()

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

a=[0]
b=[0]

for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
j=M
ans=0
for i in range(N+1):#aは小さい方から
    if a[i]>K:    #a[0]=0なのでいきなりbreakすることはない
        break
    while b[j]>K-a[i] : #bは大きい方から
        j-=1            #j,ansの値は次のループに引き継がれる
    ans=max(ans,i+j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=A+B
C.sort()
for i in range(len(C)) :
    if sum(C[:i])>K :
        print(i-1)
        sys.exit()
print(len(C))

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

a=[0]
b=[0]

for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
j=M
ans=0
for i in range(N+1):#aは小さい方から
    if a[i]>K:    #a[0]=0なのでいきなりbreakすることはない
        break
    while b[j]>K-a[i] : #bは大きい方から
        j-=1            #j,ansの値は次のループに引き継がれる
    ans=max(ans,i+j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
count=0
A=[]
for K in range(1,N+1):
    for i in range(1,K+1):
        if K%i==0 :
            count+=1
    else:
        x=K*count
        A.append(x)
        count=0
print(sum(A))

Fixed submission:
N=int(input())
A=[]
for i in range(1,N+1):
    x=N//i
    y=i*x*(x+1)/2
    A.append(y)
print(int(sum(A)))
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
print(sum(p[0:K-1])

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

p.sort()
print(sum(p[0:K]))
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())  

if (y%==0) and (2*x<=y<=4*x) :
    print("Yes")
else :
    print("No")

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

Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())  
p=(y-2x)/2
if int(p) and 1<=p<=100 :
    print("Yes")
else :
    print("No")

Fixed submission:
x,y=map(int,input().split())  
 
if (y%2==0) and (2*x<=y<=4*x) :
    print("Yes")
else :
    print("No")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=[[] for i in range(n)]
for i in range(m) :
    a,b=map(int,input().split())
    A[b-1].append(a-1)
    A[a-1].append(b-1)
depth=[0 for i in range(n)]


def search(now,sum) :
    if depth[now]!=0 : #すでに訪れていた場合
        sum+=1
        if sum<depth[now] :
            depth[now]=sum
            for i in A[now] :
                now=i
                search(now,sum)

    if depth[now]==0 :
        sum+=1
        depth[now]=sum
        for i in A[now] :
            now=i
            search(now,sum)
 
    return depth

B=search(0,0)
if B.count(0)==0 :
    print("Yes")
    for i in B[1:] :
        print(i-1)

else :
    print("No")

Fixed submission:
from collections import deque
n,m=map(int,input().split())
A=[[] for i in range(n)]
for i in range(m) :
    a,b=map(int,input().split())
    A[b-1].append(a-1)
    A[a-1].append(b-1)
depth=[-1]*n
visit=deque([0])

while True :
    if len(visit)==0 :
        break
    x=visit.popleft()
    for i in A[x] :
        if depth[i]==-1 :
            depth[i]=x+1
            visit.append(i)

print("Yes")
[print(i) for i in depth[1:]]
Buggy python submission (verdict: Time Limit Exceeded):
import math
import itertools

k=int(input())

ans=0
for i in range(1,k+1) :
    for j in range(1,k+1) :
        x=math.gcd(i,j)
        for k in range(1,k+1) :
            y=math.gcd(i,k)
            z=math.gcd(x,y)
            ans+=z

print(ans)




Fixed submission:
from math import gcd

k=int(input())
ans=0

for a in range(1,k+1) :
    for b in range(1,k+1) :
        for c in range(1,k+1) :
            ans+=gcd(gcd(a,b),c)

print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
R=[list(map(int,input().split())) for n in range(N)]
B=[list(map(int,input().split())) for n in range(N)]

sorted(R,key=itemgetter(1),reverse=True)
B.sort()
ans=0

for c,d in B :
    for a,b in R :
        if a<c and b<d :
            ans+=1
            R.remove([a,b])
            break

print(ans)

Fixed submission:
from operator import itemgetter
N=int(input())
R=[list(map(int,input().split())) for n in range(N)]
B=[list(map(int,input().split())) for n in range(N)]
R.sort(key=itemgetter(1),reverse=True)
B.sort()
ans=0

for c,d in B :
    for a,b in R :
        if a<c and b<d :
            ans+=1
            R.remove([a,b])
            break

print(ans)