Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from math import factorial as fact
N, K = map(int, input().split())
def cnt_pairs(num1, num2):
    return fact(num1 + num2) // (fact(num1) * fact(num2))

for i in range(1, K + 1):
    blue_pairs = cnt_pairs(K - i, i - 1)
    print(cnt_pairs(N - K - i + 1, i) * blue_pairs % 1000000007)

Fixed submission:
from math import factorial as fact
N, K = map(int, input().split())
def cnt_pairs(num1, num2):
    return fact(num1 + num2) // (fact(num1) * fact(num2))

for i in range(1, K + 1):
    if (i - 1 >=  0) and (K - i >= 0) and (N - K - i + 1 >= 0):
        blue_pairs = cnt_pairs(K - i, i - 1)
        print(cnt_pairs(N - K - i + 1, i) * blue_pairs % 1000000007)
    else:
        print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
dic = defaultdict(list)
for n in range(N - 1):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)
c_list = sorted(map(int, input().split()))
M = sum(c_list[:-1])
d_list = [False] * N
for i in range(N):
    if len(dic[i]) == 1:
        break
blank = N
q = [i]
while blank:
    i = q.pop(0)
    q += dic[i]
    if not d_list[i - 1]:
        d_list[i - 1] = c_list[blank - 1]
        blank -= 1
print(M)
print(' '.join(map(str, d_list)))

Fixed submission:
from collections import defaultdict
N = int(input())
dic = defaultdict(list)
for n in range(N - 1):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)
c_list = sorted(map(int, input().split()))
M = sum(c_list[:-1])
d_list = [False] * N
for i in range(1, N + 1):
    if len(dic[i]) == 1:
        break
blank = N
q = [i]
while blank:
    i = q.pop(0)
    if not d_list[i - 1]:
        q += dic[i]
        d_list[i - 1] = c_list[blank - 1]
        blank -= 1
print(M)
print(' '.join(map(str, d_list)))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
lists = []
for _ in range(M):
    lists.append(list(map(int, input().split()))[1:])
p_list = list(map(int, input().split()))
num = 0
len_m = N
for n in range(2 ** N):
    flag = True
    for p, lis in zip(p_list, lists):
        flag = flag & ((sum([f'{n:0{len_m}b}'[l - 1] == '1' for l in lis]) % 2) == p)
    num += flag
print(num)

Fixed submission:
N, M = map(int, input().split())
lists = []
for _ in range(M):
    lists.append(list(map(int, input().split()))[1:])
p_list = list(map(int, input().split()))
num = 0
len_m = N
for n in range(2 ** N):
    flag = True
    for p, lis in zip(p_list, lists):
        flag = int(flag) * int((sum([str(bin(n)[2:]).zfill(len_m)[l - 1] == '1' for l in lis]) % 2) == p)
    num += flag
print(num)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
N =int( input())
col_nodes = defaultdict(set)
node_col = {}
col = 1
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u_col, v_col = node_col.get(u, 0), node_col.get(v, 0)
    if (0 in [u_col, v_col]) and (u_col or v_col):
        if u_col == 0:
            node_col[u] = v_col * [1, -1][w % 2]
            col_nodes[v_col] = col_nodes[v_col] | {u}
        else:
            node_col[v] = u_col * [1, -1][w % 2]
            col_nodes[u_col] = col_nodes[u_col] | {v}
        continue
    col_ = col * [1, -1][w % 2]
    node_col[u] = col
    node_col[v] = col_
    if u_col and v_col:
        col_nodes[col] = col_nodes[col] | col_nodes.pop(u_col)
        col_nodes[col_] = col_nodes[col_] | col_nodes.pop(v_col)
        continue
    col_nodes[col] =  col_nodes[col] | {u}
    col_nodes[col_] = col_nodes[col_] | {v}
    col += 1
        
for n in range(1, N + 1):
    print([0, 1][node_col[n] > 0])

Fixed submission:
N = int(input())
lis = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    lis[u] += [v * [-1, 1][w % 2]]
    lis[v] += [u * [-1, 1][w % 2]]
colors = [-1 for _ in range(N + 1)]

q = [1]
colors[1] = 0
while q:
    start = abs(q.pop(0))
    nodes = lis[start]
    for node in nodes:
        if colors[abs(node)] < 0:
            if node < 0:
                colors[abs(node)] = colors[start]
            else:
                colors[abs(node)] = int(colors[start] == 0)
            q.append(abs(node))

for c in colors[1:]:
    print(c)
Buggy python submission (verdict: Runtime Error):
input()
lis = list(map(int, input().split()))
print(len([n for i, n in enumerate(lis[1:]) if n >= max(lis[:i + 1])]) + 1

Fixed submission:
input()
lis = list(map(int, input().split()))
print(len([n for i, n in enumerate(lis[1:]) if n >= max(lis[:i + 1])]) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
st = input()
num = 0
state = 0
cumsum = []
for s in st:
    if int(s) == state:
        num += 1
    else:
        cumsum.append(num)
        state = [1, 0][state]
        num = 1
cumsum.append(num)
cumsum = [0] + cumsum # odd 
if len(cumsum) % 2:
    cumsum += [0]
l = min(k * 2, len(cumsum) - 1 - (len(cumsum) % 2))
print(max([sum(cumsum[n: n + l + 1])
           for n in range(0, len(cumsum) - l + 1, 2)]))

Fixed submission:
n, k = map(int, input().split())
st = input()
num = 0
state = 0
cumsum = []
for s in st:
    if int(s) == state:
        num += 1
    else:
        cumsum.append(num)
        state = [1, 0][state]
        num = 1
cumsum.append(num)
cumsum = [0] + cumsum + [0, 0]
if (len(cumsum) % 2) == 0:
    cumsum += [0]
l = min(k * 2, len(cumsum) - 1 - (len(cumsum) % 2))
sumsum = sum(cumsum[:l + 1])
max_sum = sumsum
start_idx = 0
end_idx = l + 1
if len(cumsum) - l + 1 > 3:
    for n in range(2, len(cumsum) - l + 1, 2):
        sumsum = (
            sumsum - sum(cumsum[start_idx: start_idx + 2])
            + sum(cumsum[end_idx: end_idx + 2])
        )
        start_idx += 2
        end_idx += 2
        max_sum = max(max_sum, sumsum)

print(max_sum)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
import re
from itertools import product

atcg = ['A', 'T', 'C', 'G']
num = int(input())

def validate(tpl):
    string = tpl[0] + tpl[1] + tpl[2] + tpl[3]
    for pat in [r'A.GC', r'AG.C', 'ACG', 'AGC', 'GAC']:
         if re.search(pat, string):
                return False
    return True

def transition(dic):
    new_dic = defaultdict(int)
    for k, v in dic.items():
        for c in atcg:
            tpl = *k[1:], c
            if validate(tpl):
                new_dic[tpl] += v
    return new_dic

it = product(atcg, atcg, atcg, atcg)
dic = {}
for s in it:
    if validate(s):
        dic[s] = 1

if num == 3:
    print(61)
elif num == 4:
    print(230)
else:
    for n in range(num - 4):
        dic = transition(dic)
    print(sum(dic.values()) % 1000000007)

Fixed submission:
from collections import defaultdict
import re
from itertools import product

atcg = ['A', 'T', 'C', 'G']
num = int(input())

def validate(tpl):
    string = tpl[0] + tpl[1] + tpl[2] + tpl[3]
    for pat in [r'A.GC', r'AG.C', 'ACG', 'AGC', 'GAC']:
         if re.search(pat, string):
                return False
    return True

def transition(dic):
    new_dic = defaultdict(int)
    for k, v in dic.items():
        for c in atcg:
            tpl = k[1], k[2], k[3], c
            if validate(tpl):
                new_dic[tpl] += v
    return new_dic

it = product(atcg, atcg, atcg, atcg)
dic = {}
for s in it:
    if validate(s):
        dic[s] = 1

if num == 3:
    print(61)
elif num == 4:
    print(230)
else:
    for n in range(num - 4):
        dic = transition(dic)
    print(sum(dic.values()) % 1000000007)
Buggy python submission (verdict: Runtime Error):
H, W = input().split()
h, w = input().split()

total = H * W
num_del = h * W + H * w - h * w
print(total - num_del)

Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())
 
total = H * W
num_del = h * W + H * w - h * w
print(total - num_del)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

input()
arr = np.array(list(map(int, input().split())))
nums = set(arr)

res = 0
for n in nums:
    res = max(sum((arr < (n+2))[arr > (n-2)]), res)
print(res)

Fixed submission:
from collections import defaultdict
n = input()
nums = list(map(int, input().split()))
dic = defaultdict(int)
for num in nums:
    dic[num] += 1
keys = sorted(list(dic.keys()))
cnt = 1
for key in keys:
    cnt = max(dic[key] + dic[key + 1] + dic[key - 1], cnt)
print(cnt)
Buggy python submission (verdict: Runtime Error):
input()
nums = list(map(int, input().split()))
lis = [num - (i + 1) for i, num in enumerate(nums)]
cnt = 0
i = 0
while i < len(lis):
    if lis[i] == 0:
        cnt += 1
        if lis[i + 1] == 0:
            i += 1
    i += 1
print(cnt)

Fixed submission:
input()
nums = list(map(int, input().split()))
lis = [num - (i + 1) for i, num in enumerate(nums)]
cnt = 0
i = 0
while i < len(lis):
    if lis[i] == 0:
        cnt += 1
        if i == (len(lis) - 1):
            break
        if lis[i + 1] == 0:
            i += 1
    i += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
input()
nums = list(map(int, input().split()))
lis = [num - (i + 1) for i, num in enumerate(nums)]
cnt = 0
i = 0
while i < len(lis):
    if lis[i] == 0:
        cnt += 1
        if lis[i + 1] == 0:
            i += 1
    i += 1
print(cnt)

Fixed submission:
input()
nums = list(map(int, input().split()))
lis = [num - (i + 1) for i, num in enumerate(nums)]
cnt = 0
i = 0
while i < len(lis):
    if lis[i] == 0:
        cnt += 1
        if i == (len(lis) - 1):
            break
        if lis[i + 1] == 0:
            i += 1
    i += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def count_linear_process(lis):
    length = len(lis)
    return [l // length for l in lis]


def linear_process(lis):
    length = len(lis)
    return [l % length for l in lis]


def check_end(lis):
    return max(lis) < len(lis)


def add_processed(lis, counts):
    sum_cnt = sum(counts)
    return [l + sum_cnt - cnt for l, cnt in zip(lis, counts)]


def update(lis, n_process=0):
    if check_end(lis):
        return n_process
    next_lis = linear_process(lis)
    counts = count_linear_process(lis)
    return update(
        add_processed(next_lis, counts), 
        n_process + sum(counts)
    )


def solve(N: int, a: "List[int]"):
    print(update(a))
    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
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


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

sys.setrecursionlimit(2000000)


def count_linear_process(lis):
    length = len(lis)
    return [l // length for l in lis]


def linear_process(lis):
    length = len(lis)
    return [l % length for l in lis]


def check_end(lis):
    return max(lis) < len(lis)


def add_processed(lis, counts):
    sum_cnt = sum(counts)
    return [l + sum_cnt - cnt for l, cnt in zip(lis, counts)]


def update(lis, n_process=0):
    if check_end(lis):
        return n_process
    next_lis = linear_process(lis)
    counts = count_linear_process(lis)
    return update(
        add_processed(next_lis, counts), 
        n_process + sum(counts)
    )


def solve(N: int, a: "List[int]"):
    print(update(a))
    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
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import collections

def calc_sum(c):
    sum_val = 0
    for key, val in c.items():
        sum_val += key * val
    return sum_val

N = int(input())
arr = list(map(int, input().split()))
Q = int(input())

actions = []

for i in range(Q):
    B, C = map(int, input().split())
    actions.append({'B':B, 'C':C})

c = collections.Counter(arr)

for i in range(Q):
    B = actions[i]['B']
    C = actions[i]['C']
    if B in c:
        c[C] += c[B]
        c.pop(B)
    print(calc_sum(c))

Fixed submission:
import collections

def calc_sum(c):
    sum_val = 0
    for key, val in c.items():
        sum_val += key * val
    return sum_val

N = int(input())
arr = list(map(int, input().split()))
Q = int(input())

actions = []

for i in range(Q):
    B, C = map(int, input().split())
    actions.append({'B':B, 'C':C})

c = collections.Counter(arr)
sum_val = calc_sum(c)

for i in range(Q):
    B = actions[i]['B']
    C = actions[i]['C']
    if B in c:
        c[C] += c[B]
        sum_val += c[B] * C - c[B] * B
        c.pop(B)

    print(sum_val)
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
x = input()

count = 0

for i_a in range(a):
  for i_b in range(b):
    for i_c in range(c):
      if 500*a + 100*b + 50*c == x:
        count += 1
        
print(count)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i_a in range(a + 1):
  for i_b in range(b + 1):
    for i_c in range(c + 1):
      if 500*i_a + 100*i_b + 50*i_c == x:
        count += 1
        
print(count)
Buggy python submission (verdict: Runtime Error):
a, b = map.(int, input().split())
print("Even" if a * b % 2 == 0 else "Odd")

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

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

Fixed submission:
a, b = map(int, input().split())
print("Even" if a * b % 2 == 0 else "Odd")
Buggy python submission (verdict: Runtime Error):
can_reach = True
for i in range(N):
  next_T, next_X, next_Y = map(int, input().split())
  
  z = next_T - T - abs(X - next_X) - abs(Y - next_Y)
  if z >= 0 and z % 2 == 0:
    T, X, Y = next_T, next_X, next_Y
  else:
    can_reach = False
    break
    
if can_reach:
  print('Yes')
else:
  print('No')

Fixed submission:
N = int(input())
T, X, Y = 0, 0, 0

can_reach = True
for i in range(N):
  next_T, next_X, next_Y = map(int, input().split())
  
  z = next_T - T - abs(X - next_X) - abs(Y - next_Y)
  if z >= 0 and z % 2 == 0:
    T, X, Y = next_T, next_X, next_Y
  else:
    can_reach = False
    break
    
if can_reach:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())

if Y / 1000 == N:
  print('0 0',N)

man_max = Y // 10000
gosen_max = Y // 5000

is_exist = False

for i_m in range(man_max+1):
  for i_g in range(gosen_max+1):
    if 99000*i_m + 4000*i_g == Y - 1000*N:
      print(i_m, i_g, int(Y / 1000 - 10*i_m - 5*i_g))
      is_exist = True
      break
      
if not is_exist:

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

man_max = Y // 10000
gosen_max = Y // 5000

for x in range(man_max+1):
  for y in range(gosen_max+1):
    z = N - x - y
    if 0 <= z <= 2000 and 10000*x + 5000*y + 1000*z == Y:
      print(x, y, z)
      exit()
      
print(-1, -1, -1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [[0,0] for _ in range(n)]

for i in range(n):
    a[i][0],a[i][1]=map(int,input().split())
a.sort()
cnt=0
now=0
temp=1
for i in range(n-1):
    if a[now][0]+a[now][1]>a[now+temp][0]+a[now+temp][1]:
        now+=temp
        cnt+=1
    elif  a[now+temp][0]-a[now+temp][1]<a[now][0]+a[now][1]:
        temp+=1
        cnt+=1
    else:
        now+=temp
        temp=1

print(n-cnt)

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

for i in range(n):
    a[i][0],a[i][1]=map(int,input().split())
    a[i][0],a[i][1]=(a[i][0]-a[i][1]),(a[i][0]+a[i][1])
a.sort(key=lambda x: x[1])
INF = 10**10
preR = -INF
cnt=0
for L,R in  a:
    if L<preR:
        continue
    cnt+=1
    preR=R
print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [[0,0] for _ in range(n)]

for i in range(n):
    a[i][0],a[i][1]=map(int,input().split())
a.sort()
cnt=0
now=0
temp=1
for i in range(n-1):
    if a[now][0]+a[now][1]>a[now+temp][0]+a[now+temp][1]:
        cnt+=1
        now+=temp
    elif  a[now+temp][0]-a[now+temp][1]<a[now][0]+a[now][1]:
        cnt+=1
        temp+=1
    else:
        now+=temp
        temp=1

print(n-cnt)

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

for i in range(n):
    a[i][0],a[i][1]=map(int,input().split())
    a[i][0],a[i][1]=(a[i][0]-a[i][1]),(a[i][0]+a[i][1])
a.sort(key=lambda x: x[1])
INF = 10**10
preR = -INF
cnt=0
for L,R in  a:
    if L<preR:
        continue
    cnt+=1
    preR=R
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
A = list(map(int,input().split()))
print(min(abs(sum(A[0:i+1])-sum(A[i+1:n])) for i in range(n-1)))


Fixed submission:
n = int(input())
A = list(map(int,input().split()))
Asum = sum(A)
Al = 0
ans = Asum
for a in A:
    Al += a
    Ar = Asum-Al
    ans = min(ans,abs(Ar-Al))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
print(min(abs(sum(A[0:i+1])-sum(A[i+1:n])) for i in range(n-1)))


Fixed submission:
n = int(input())
A = list(map(int,input().split()))
Asum = sum(A)
Al = 0
ans = Asum
for a in A:
    Al += a
    Ar = Asum-Al
    ans = min(ans,abs(Ar-Al))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
A = np.array(list(map(int,input().split())), dtype=np.int64)
print(min(abs(sum(A[0:i+1])-sum(A[i+1:n])) for i in range(n-1)))


Fixed submission:
n = int(input())
A = list(map(int,input().split()))
Asum = sum(A)
Al = 0
ans = Asum
for a in A:
    Al += a
    Ar = Asum-Al
    ans = min(ans,abs(Ar-Al))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
print(min(abs(sum(A[0:i+1])-sum(A[i+1:n])) for i in range(n-1)))


Fixed submission:
n = int(input())
A = list(map(int,input().split()))
Asum = sum(A)
Al = 0
ans = Asum
for a in A:
    Al += a
    Ar = Asum-Al
    ans = min(ans,abs(Ar-Al))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
B = [0]*(n-1)
for i in range(n-1):
    B[i]=abs(sum(A[0:i+1])-sum(A[i+1:n]))
print(min(B))

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
Asum = sum(A)
Al = 0
ans = Asum
for a in A:
    Al += a
    Ar = Asum-Al
    ans = min(ans,abs(Ar-Al))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = [0]*n
for i in range(n):
    ans[i]=a.index(i+1)+1
print(*ans,sep=' ')


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = [0]*n
b = 0
for i in a:
    ans[i-1]=b+1
    b += 1
print(*ans,sep=' ')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
n,k,q = map(int,input().split())
p = np.array([k]*n)
for i in range(q):
    p[int(input())-1] += 1
    p -= 1
for i in range(n):
    print('Yes' if p[i]>=1 else 'No')


Fixed submission:
import numpy as np
import sys
n,k,q = map(int,input().split())
p = np.array([k]*n)
if k > q:
    for i in range(q):
        a = int(input())
    for i in range(n):
        print('Yes')
    sys.exit()
for i in range(q):
    p[int(input())-1] += 1
for i in range(n):
    print('Yes' if p[i]>=q+1 else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    j = 0
    count=0
    while h[i+j]>=h[i+j+1]:
        count+=1
        ans=max(ans,count)
        j+=1
        if i+j+1>=n:
            break
print(ans)


Fixed submission:
n = int(input())
h = list(map(int,input().split()))
ans = 0
count=0
for i in range(n-1):
    if h[i]>=h[i+1]:
        count+=1
        ans=max(ans,count)
    else:
        count=0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(n-1):
    ans += (i+1)%(i+2)
print(ans)


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

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
listN = np.array([i+1 for i in range(n)])
listM = np.array([j+2 for j in range(n-1)]+[1])
print(np.sum(listN%listM))


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

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
listN = np.array([i+1 for i in range(n)])
listM = np.array([j+2 for j in range(n-1)]+[1])
print(sum(listN%listM))



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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
listN = [i+1 for i in range(n)]
listM = [j+2 for j in range(n-1)]
listM.append(1)
ans = [x%y for (x,y) in zip(listN,listM)]
print(sum(ans))


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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
listN = [i+1 for i in range(n)]
listM = [j+2 for j in range(n-1)]
listM.append(1)
ans = 0
for k in range(n-1):
    ans += listN[k]%listM[k]
print(ans)


Fixed submission:
n = int(input())
print(((n-1)*n)//2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=np.array(list(map(int,input().split())))
print(1/sum(1/A))


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

print(1/s)
Buggy python submission (verdict: Runtime Error):
S=input()
s=S[0]
for i in range(len(S)-1):
    if S[i+1]==s:
        print('Bad')
        sys.exit()
    s=S[i+1]
print('Good')

Fixed submission:
import numpy as np
import sys
import math

S=input()
s=S[0]
for i in range(len(S)-1):
    if S[i+1]==s:
        print('Bad')
        sys.exit()
    s=S[i+1]
print('Good')
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
for i in range(q):
    l,r = map(int,input().split())
    print(s[l-1:r].count('AC'))


Fixed submission:
n,q = map(int,input().split())
s = input()
count = [0]*n
for i in range(1,n):
    count[i]+=count[i-1]
    if s[i-1:i+1] == 'AC':
        count[i]+=1
for j in range(q):
    l,r = map(int,input().split())
    print(count[r-1]-count[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
a,b,k = map(int,input().split())
for i in range(b-a+1):
    if i < k or b-a-i < k:
        print(a+i)


Fixed submission:
import numpy as np
import sys
a,b,k = map(int,input().split())
for i in range(k):
    if i <= b-a:
        print(a+i)
for i in range(k):
    if k-i-1 <= b-a-k:
        print(b-k+i+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [0] + list(map(int,input().split())) + [0]
B = [0]*n
C = [0]*(n+1)

for i in range(n):
    B[i]=abs(A[i]-A[i+2])
for i in range(n+1):
    C[i]=abs(A[i]-A[i+1])
for i in range(n):
    print(sum(C[0:i])+B[i]+sum(C[i+2:n+1]))

Fixed submission:
n = int(input())
A = [0] + list(map(int,input().split())) + [0]
B = [0]*n
C = [0]*(n+1)

for i in range(n):
    B[i]=abs(A[i]-A[i+2])
for i in range(n+1):
    C[i]=abs(A[i]-A[i+1])
sumC = sum(C)
for i in range(n):
    print(sumC+B[i]-C[i]-C[i+1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = set()
for _ in range(n):
    a ^= {input()}
print(len(a))

Fixed submission:
n=input()
print('Yes' if n[0]==str(9) or n[1]==str(9) else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
import math

n=int(input())
A=np.array(sorted(list(map(int,input().split()))))
B=np.append(np.append(A,A+1),A-1)
ans=0
for i in set(B):
    ans=max(ans,np.count_nonzero(B==i))
print(ans)

Fixed submission:
import numpy as np
import sys
import math

n=int(input())
A=np.array(sorted(list(map(int,input().split()))))
C=np.bincount(A)
D=C.copy()
D[1:]+=C[:-1]
D[:-1]+=C[1:]
print(np.max(D))