Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# C

import itertools
import bisect

n, m, k = map(int, input().split())
a_l = [int(x) for x in input().split()]
b_l = [int(x) for x in input().split()]

cumsuma_l = list(itertools.accumulate(a_l)) 
cumsumb_l = list(itertools.accumulate(b_l))

_idx = bisect.bisect_left(cumsumb_l, k)
if _idx == m or cumsumb_l[_idx] != _tmp:
    _idx -= 1
ans = _idx + 1
    
for i in range(n):
    _a = cumsuma_l[i]
    if _a > k:
        break
    _tmp = k - _a
    _idx = bisect.bisect_left(cumsumb_l, _tmp)
    if _idx == m or cumsumb_l[_idx] != _tmp:
        _idx -= 1
    ans = max(ans, i + _idx + 2)
        
print(ans)

Fixed submission:
# C

import itertools
import bisect

n, m, k = map(int, input().split())
a_l = [int(x) for x in input().split()]
b_l = [int(x) for x in input().split()]

cumsuma_l = list(itertools.accumulate(a_l)) 
cumsumb_l = list(itertools.accumulate(b_l))

_idx = bisect.bisect_left(cumsumb_l, k)
if _idx == m or cumsumb_l[_idx] != k:
    _idx -= 1
ans = _idx + 1
    
for i in range(n):
    _a = cumsuma_l[i]
    if _a > k:
        break
    _tmp = k - _a
    _idx = bisect.bisect_left(cumsumb_l, _tmp)
    if _idx == m or cumsumb_l[_idx] != _tmp:
        _idx -= 1
    ans = max(ans, i + _idx + 2)
        
print(ans)
Buggy python submission (verdict: Runtime Error):
# C

import bisect

x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p_list = {int(x) for x in input().split()}
    q_list = {int(x) for x in range(101)}
    q_list = list(q_list - p_list)

    p = bisect.bisect_left(q_list, x)
    if p == 0:
        print(q_list[p])
    else:
        if abs(q_list[p-1] - x) <= abs(q_list[p] - x):
            print(q_list[p-1])
        else:
            print(q_list[p])

Fixed submission:
# C

import bisect

x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p_list = {int(x) for x in input().split()}
    q_list = {int(x) for x in range(102)}
    q_list = list(q_list - p_list)

    p = bisect.bisect_left(q_list, x)
    if p == 0:
        print(q_list[p])
    elif p == len(q_list):
        print(q_list[p-1])
    else:
        if abs(q_list[p-1] - x) <= abs(q_list[p] - x):
            print(q_list[p-1])
        else:
            print(q_list[p])
Buggy python submission (verdict: Time Limit Exceeded):
# C
import copy

n, k = map(int, input().split())
a_list = [int(x) for x in input().split()]
o_list = copy.deepcopy(a_list)

for i in range(k):
    _o_list = [0]*n
    for j in range(n):
        _t = o_list[j]
        _s, _e = j-_t, j+_t
        for x in range(max(_s, 0), min(_e+1, n)):
            _o_list[x] += 1
    o_list = copy.deepcopy(_o_list)
    if o_list == [n]*n:
        break
print(*o_list)

Fixed submission:
# C
import copy
import itertools

n, k = map(int, input().split())
a_list = [int(x) for x in input().split()]

for j in range(k):
    b_list = [0]*n
#     print("a:",*a_list)
    for i in range(n):
        l = max(0, i-a_list[i])
        r = min(n-1, i+a_list[i])
        b_list[l] += 1
        if r+1 < n:
            b_list[r+1] -= 1
#     print("b:",*b_list)
    cumsum = list(itertools.accumulate(b_list))
    if cumsum == [n]*n:
        break
    a_list = cumsum
print(*cumsum)
Buggy python submission (verdict: Time Limit Exceeded):
# ABC169 B Multiplication 2

from collections import deque

n = int(input())

a_list = deque([int(x) for x in input().split()])

ans = 1
for i in range(n):
    ans *= a_list.popleft()

if ans > 10**18:
    print("-1")
else:
    print(ans)

Fixed submission:
# ABC169 B Multiplication 2

from collections import deque

n = int(input())

a_list = [int(x) for x in input().split()]

if min(a_list) == 0:
    print("0")
else:
    a_dq = deque(a_list)
    ans = 1
    for i in range(n):
        ans *= a_dq.popleft()
        if ans > 10**18:
            break

    if ans > 10**18:
        print("-1")
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# ABC169 B Multiplication 2

n = int(input())

a_list = [int(x) for x in input().split()]

ans = 1
for i in range(n):
    ans *= a_list[i]

if ans > 10**18:
    print("-1")
else:
    print(ans)

Fixed submission:
# ABC169 B Multiplication 2

from collections import deque

n = int(input())

a_list = [int(x) for x in input().split()]

if min(a_list) == 0:
    print("0")
else:
    a_dq = deque(a_list)
    ans = 1
    for i in range(n):
        ans *= a_dq.popleft()
        if ans > 10**18:
            break

    if ans > 10**18:
        print("-1")
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# E
# This Message Will Self-Destruct in 5s
import numpy as np

N = int(input())
A_list = np.array([int(x) for x in input().split()])
Num_list = np.arange(1,N+1,1)

L_list = Num_list + A_list
R_list = Num_list - A_list
ans = 0
for i in range(N):
    ans += sum((R_list == L_list[i])[i+1:])

print(ans)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
ans=0
l=[]
r=[]
for i,j in enumerate(a):
    l.append(i+j)
    r.append(i-j)

b=Counter(r)
for i in l:
    ans+=b.get(i,0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# E
# This Message Will Self-Destruct in 5s
import numpy as np

N = int(input())
A_list = [int(x) for x in input().split()]
Num_list = np.arange(1,N+1,1)

ans = 0

for i in Num_list:
    for j in range(i+1,N+1):
        if (j-i) == (A_list[j-1] + A_list[i-1]):
            ans += 1

print(ans)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
ans=0
l=[]
r=[]
for i,j in enumerate(a):
    l.append(i+j)
    r.append(i-j)

b=Counter(r)
for i in l:
    ans+=b.get(i,0)

print(ans)
Buggy python submission (verdict: Runtime Error):
# D
# Multiple of 2019

s = input()

d = len(s)

ans = 0

if d < 5:
    if int(s)%2019 == 0:
        print("1")
    else:
        print("0")
else:
    for j in range(4,d,1):
        for i in range(j-3):
            _tmp = int(s[i:j+1])
            if _tmp % 2019 == 0:
                ans +=1

    print(ans)

Fixed submission:
# A
# Sheep and Wolves

s, w = map(int, input().split())

if s <= w:
    print("unsafe")
else:
    print("safe")

Buggy python submission (verdict: Runtime Error):
# A
# Sheep and Wolves

s w = map(int, input().split())

if s <= w:
    print("unsafe")
else:
    print("safe")

Fixed submission:
# A
# Sheep and Wolves

s, w = map(int, input().split())

if s <= w:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
# D
# Multiple of 2019
import itertools

s = input()

d = len(s)

_list = [None]*d
_map = [0]*2019

ans = 0

for i in range(d):
    _tmp = int(s[i:])%2019
    _list[i] = _tmp
    if _tmp == 0:
        ans += 1
    elif _map[_tmp] ==1:
        ans += 1
    _map[_tmp] = 1
        
print(ans)

Fixed submission:
# D
# Multiple of 2019
import itertools

s = input()[::-1]

d = len(s)

# _list = [None]*d
_map = [0]*2019
_map[0] = 1

ans = 0
j,_ = 1,0

for i in s:
    _ += int(i) * j
    _tmp = _ % 2019
    j = (j*10)%2019
    _map[_tmp] += 1
    
for _l in _map:
    ans += _l * (_l - 1) / 2
    
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
# D
# Multiple of 2019
import itertools

s = input()

d = len(s)

_list = [None]*d

ans = 0

for i in range(d):
    _tmp = int(s[i:])%2019
    _list[i] = _tmp
    if _tmp == 0:
        ans += 1

for _ in itertools.combinations(_list,2):
    if _[0] == _[1]:
        ans += 1

print(ans)

Fixed submission:
# D
# Multiple of 2019
import itertools

s = input()[::-1]

d = len(s)

# _list = [None]*d
_map = [0]*2019
_map[0] = 1

ans = 0
j,_ = 1,0

for i in s:
    _ += int(i) * j
    _tmp = _ % 2019
    j = (j*10)%2019
    _map[_tmp] += 1
    
for _l in _map:
    ans += _l * (_l - 1) / 2
    
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
# D
# Multiple of 2019

s = input()

d = len(s)

ans = 0

if d < 5:
    if int(s)%2019 == 0:
        print("1")
    else:
        print("0")
else:
    for j in range(4,d,1):
        for i in range(j-3):
            _tmp = int(s[i:j+1])
            if _tmp % 2019 == 0:
                ans +=1

    print(ans)

Fixed submission:
# D
# Multiple of 2019
import itertools

s = input()[::-1]

d = len(s)

# _list = [None]*d
_map = [0]*2019
_map[0] = 1

ans = 0
j,_ = 1,0

for i in s:
    _ += int(i) * j
    _tmp = _ % 2019
    j = (j*10)%2019
    _map[_tmp] += 1
    
for _l in _map:
    ans += _l * (_l - 1) / 2
    
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
# D
# Multiple of 2019

s = input()

d = len(s)

ans = 0

for j in range(d):
    for i in range(j):
        _tmp = int(s[i:j+1])
        if _tmp % 2019 == 0:
            ans +=1

print(ans)

Fixed submission:
# D
# Multiple of 2019
import itertools

s = input()[::-1]

d = len(s)

# _list = [None]*d
_map = [0]*2019
_map[0] = 1

ans = 0
j,_ = 1,0

for i in s:
    _ += int(i) * j
    _tmp = _ % 2019
    j = (j*10)%2019
    _map[_tmp] += 1
    
for _l in _map:
    ans += _l * (_l - 1) / 2
    
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
# ABC154 D Dice in Line

n, k = map(int, input().split())
p_list = [int(x) for x in input().split()]
e_list = [None]*n

for i in range(n):
    e_list[i] = (1 + p_list[i])/2

ans = 0
for i in range(n-k+1):
    _ = sum(e_list[i:i+k])
    if ans < _:
        ans = _

print(ans)

Fixed submission:
# ABC154 D Dice in Line

import itertools

n, k = map(int, input().split())
p_list = [int(x) for x in input().split()]
e_list = [None]*n

for i in range(n):
    e_list[i] = (1 + p_list[i])/2

cumsum = list(itertools.accumulate(e_list))
ans = cumsum[k-1]

for i in range(k,n):
    _ = cumsum[i] - cumsum[i-k]
    if ans < _:
        ans = _

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# 6
# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN

import itertools
from collections import deque

n = int(input())
s = input()

ans = 0
iter = itertools.product("0123456789", repeat=3)

for it in iter:
    _s_dq = deque(s)
    for i in it:
        while len(_s_dq) > 0:
            _s = _s_dq.popleft()
            if _s == i:
                break
        else:
            break
    else:
        ans += 1
        
print(ans)


Fixed submission:
# 6
# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN

import itertools
import copy
from collections import deque

n = int(input())
s = input()

ans = 0
iter = itertools.product("0123456789", repeat=3)

for it in iter:
    _s = copy.deepcopy(s)
    for i in it:
        try:
            _idx = _s.index(i)
            _s = _s[_idx+1:]
        except:
            break
    else:
        ans += 1
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# ABC143 D Triangles

n = int(input())
l_list = [int(x) for x in input().split()]

l_list.sort()
ans = 0

# (i < j < k) -> (_a < _b < _c)
for i in range(n-2):
    _a = l_list[i]
    for j in range(i+1,n-1):
        _b = l_list[j]
        _tmp = _a + _b
        for k in range(j+1,n):
            _c = l_list[k]
            if _c < _tmp:
                ans += 1
            else:
                break

print(ans)

Fixed submission:
# ABC143 D Triangles

import bisect

n = int(input())
l_list = [int(x) for x in input().split()]

l_list.sort()
ans = 0

for i in range(n-2):
    _a = l_list[i]
    for j in range(i+1,n-1):
        _b = l_list[j]
        _tmp = bisect.bisect_left(l_list, _a+_b)
        if j < _tmp:
            ans += _tmp - j - 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# ABC139
# D
# ModSum

n = int(input())
print(sum(i for i in range(n)))

Fixed submission:
# ABC139
# D
# ModSum

n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
# 26

import sys

sys.setrecursionlimit(10**9)

n, q = map(int, input().split())
ans_l = [0] * n
graph = [[] for x in range(n)]

def dfs(v, p=-1):
    if p >= 0:
        ans_l[v] += ans_l[p]
    for i in range(len(graph[v])):
        _v = graph[v][i]
        if _v != p:
            dfs(_v, v)
        
for i in range(n-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
    
for j in range(q):
    p, x = map(int, input().split())
    ans_l[p-1] += x
    
dfs(0)

print(*ans_l)

Fixed submission:
# 26

import sys

sys.setrecursionlimit(10**9)

n, q = map(int, input().split())
ans_l = [0] * n
graph = [[] for x in range(n)]

def dfs(v, p=-1):
    if p >= 0:
        ans_l[v] += ans_l[p]
    for i in range(len(graph[v])):
        _v = graph[v][i]
        if _v != p:
            dfs(_v, v)
        
for i in range(n-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
    
for j in range(q):
    p, x = map(int, input().split())
    ans_l[p-1] += x
    
dfs(0)

print(*ans_l)
Buggy python submission (verdict: Runtime Error):
# ABC129 C

MOD = 10**9 + 7
n, m = map(int, input().split())
a_l = [int(input()) for _ in range(m)]

dp = [0] * (n+1)
dp[0] = 1
k = 0
if m > 0 and a_l[0] == 1:
    k += 1
else:
    dp[1] = 1

for i in range(2, n+1):
    if m > 0 and i == a_l[k]:
        k = min(k+1, m-1)
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
    
print(dp[n])

Fixed submission:
# ABC129 C

MOD = 10**9 + 7
n, m = map(int, input().split())
a_l = [int(input()) for _ in range(m)]

dp = [0] * (n+1)
dp[0] = 1
k = 0
if m > 0 and a_l[0] == 1:
    k = min(k+1, m-1)
else:
    dp[1] = 1

for i in range(2, n+1):
    if m > 0 and i == a_l[k]:
        k = min(k+1, m-1)
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
    
print(dp[n])

Buggy python submission (verdict: Runtime Error):
# ABC129 C

MOD = 10**9 + 7
n, m = map(int, input().split())
a_l = [int(input()) for _ in range(m)]

dp = [0] * (n+1)
dp[0] = 1
k = 0
if a_l[0] == 1:
    k += 1
else:
    dp[1] = 1

for i in range(2, n+1):
    if i == a_l[k]:
        k = min(k+1, m-1)
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
    
print(dp[n])

Fixed submission:
# ABC129 C

MOD = 10**9 + 7
n, m = map(int, input().split())
a_l = [int(input()) for _ in range(m)]

dp = [0] * (n+1)
dp[0] = 1
k = 0
if m > 0 and a_l[0] == 1:
    k = min(k+1, m-1)
else:
    dp[1] = 1

for i in range(2, n+1):
    if m > 0 and i == a_l[k]:
        k = min(k+1, m-1)
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
    
print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
# 79
# ABC106 D


def solve():
    N, M, Q = map(int, input().split())
    LR_L = tuple([int(x) for x in input().split()] for y in range(M))
    Q_L = tuple([int(x) for x in input().split()] for y in range(Q))

    imos_l = [[0] * (N+2) for _ in range(N+1)]

    for l, r in LR_L:
        imos_l[l][l] += 1
        imos_l[l][r+1] -= 1
    for i in range(1, N+1):
        for j in range(1, N+2):
            imos_l[i][j] += imos_l[i][j-1]

    for p, q in Q_L:
        ans = 0
        for i in range(p, q+1):
            ans += imos_l[i][i] - imos_l[i][q+1]
        print(ans)


solve()


Fixed submission:
# 79
# ABC106 D


def solve():
    N, M, Q = map(int, input().split())
    LR_L = tuple([int(x) for x in input().split()] for y in range(M))
    Q_L = tuple([int(x) for x in input().split()] for y in range(Q))

    imos_l = [[0] * (N+2) for _ in range(N+1)]

    for l, r in LR_L:
        imos_l[l][l] += 1
        imos_l[l][r+1] -= 1
    for i in range(1, N+1):
        for j in range(1, N+2):
            imos_l[i][j] += imos_l[i][j-1]

    for p, q in Q_L:
        ans = 0
        for i in range(p, q+1):
            ans += imos_l[i][i] - imos_l[i][q+1]
        print(ans)


solve()

Buggy python submission (verdict: Time Limit Exceeded):
# 79
# ABC106 D

N, M, Q = map(int, input().split())
LR_L = tuple([int(x) for x in input().split()] for y in range(M))
Q_L = tuple([int(x) for x in input().split()] for y in range(Q))

imos_l = [[0] * (N+2) for _ in range(N+1)]

for l, r in LR_L:
    imos_l[l][l] += 1
    imos_l[l][r+1] -= 1
for i in range(1, N+1):
    for j in range(1, N+2):
        imos_l[i][j] += imos_l[i][j-1]

for p, q in Q_L:
    ans = 0
    for i in range(p, q+1):
        ans += imos_l[i][i] - imos_l[i][q+1]
    print(ans)


Fixed submission:
# 79
# ABC106 D


def solve():
    N, M, Q = map(int, input().split())
    LR_L = tuple([int(x) for x in input().split()] for y in range(M))
    Q_L = tuple([int(x) for x in input().split()] for y in range(Q))

    imos_l = [[0] * (N+2) for _ in range(N+1)]

    for l, r in LR_L:
        imos_l[l][l] += 1
        imos_l[l][r+1] -= 1
    for i in range(1, N+1):
        for j in range(1, N+2):
            imos_l[i][j] += imos_l[i][j-1]

    for p, q in Q_L:
        ans = 0
        for i in range(p, q+1):
            ans += imos_l[i][i] - imos_l[i][q+1]
        print(ans)


solve()
Buggy python submission (verdict: Runtime Error):
# ABC072
# C
# Together
import itertools

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

a.sort()
gr = itertools.groupby(a)
hoge_list = [0]*10001
ans = 0

for key, group in gr:
    hoge_list[key] = len(list(group))

for i in range(1,10000,1):
    _tmp = hoge_list[i-1] + hoge_list[i] + hoge_list[i+1]
    if ans < _tmp:
        ans = _tmp

print(ans)
    

Fixed submission:
# ABC072
# C
# Together
import itertools

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

a.sort()
gr = itertools.groupby(a)
hoge_list = [0]*100001
ans = 0

for key, group in gr:
    hoge_list[key] = len(list(group))

for i in range(1,100000,1):
    _tmp = hoge_list[i-1] + hoge_list[i] + hoge_list[i+1]
    if ans < _tmp:
        ans = _tmp

print(ans)

Buggy python submission (verdict: Runtime Error):
# ABC072
# C
# Together
import itertools

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

a.sort()
gr = itertools.groupby(a)
hoge_list = [0]*10001
ans = 0

for key, group in gr:
    hoge_list[key] = len(list(group))

for i in range(1000):
    _tmp = hoge_list[i-1] + hoge_list[i] + hoge_list[i+1]
    if ans < _tmp:
        ans = _tmp

print(ans)
    

Fixed submission:
# ABC072
# C
# Together
import itertools

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

a.sort()
gr = itertools.groupby(a)
hoge_list = [0]*100001
ans = 0

for key, group in gr:
    hoge_list[key] = len(list(group))

for i in range(1,100000,1):
    _tmp = hoge_list[i-1] + hoge_list[i] + hoge_list[i+1]
    if ans < _tmp:
        ans = _tmp

print(ans)
Buggy python submission (verdict: Runtime Error):
# ABC064
# C
# Colorful Leaderboard

n = int(input())
a_list = list(map(int, input().split()))

color_list = [0]*8
over = 0
for i in range(n):
    _ = a_list[i] // 400
    if _ < 8:
        color_list[_] = 1
    else:
        over += 1

_tmp = sum(color_list)
if _tmp == 0:
    print("1 %d"%_over)
else:
    print("%d %d"%(_tmp, _tmp+over))

Fixed submission:
# ABC064
# C
# Colorful Leaderboard

n = int(input())
a_list = list(map(int, input().split()))

color_list = [0]*8
over = 0
for i in range(n):
    _ = a_list[i] // 400
    if _ < 8:
        color_list[_] = 1
    else:
        over += 1

_tmp = sum(color_list)
if _tmp == 0:
    print("1 %d"%over)
else:
    print("%d %d"%(_tmp, _tmp+over))

Buggy python submission (verdict: Runtime Error):
# ABC064
# C
# Colorful Leaderboard

n = int(input())
a_list = list(map(int, input().split()))

color_list = [0]*8
over = 0
for i in range(n):
    _ = a_list[i] // 400
    if _ < 8:
        color_list[i] = 1
    else:
        over += 1

_tmp = sum(color_list)
print("%d %d"%(_tmp, _tmp+over))

Fixed submission:
# ABC064
# C
# Colorful Leaderboard

n = int(input())
a_list = list(map(int, input().split()))

color_list = [0]*8
over = 0
for i in range(n):
    _ = a_list[i] // 400
    if _ < 8:
        color_list[_] = 1
    else:
        over += 1

_tmp = sum(color_list)
if _tmp == 0:
    print("1 %d"%over)
else:
    print("%d %d"%(_tmp, _tmp+over))
Buggy python submission (verdict: Runtime Error):
# AGC011 A Airport Bus
import bisect
from collections import deque

n, c, k = map(int, input().split())
t_list = [int(input()) for _ in range(n)]

t_list.sort()
t_list = deque(t_list)
ans = 0

while len(t_list) > 0:
    _tmp = t_list.popleft() + k
    _idx = bisect.bisect_right(t_list, _tmp)
    if c <= _idx + 1:
        for _ in range(c):
            t_list.popleft()
    else:
        for _ in range(_idx):
            t_list.popleft()
    ans += 1

print(ans)

Fixed submission:
# AGC011 A Airport Bus
import bisect
from collections import deque

n, c, k = map(int, input().split())
t_list = [int(input()) for _ in range(n)]

t_list.sort()
t_list = deque(t_list)
ans = 0

while len(t_list) > 0:
    _tmp = t_list.popleft() + k
    _idx = bisect.bisect_right(t_list, _tmp)
    if c-1 <= _idx:
        for _ in range(c-1):
            t_list.popleft()
    else:
        for _ in range(_idx):
            t_list.popleft()
    ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# AGC011 A Airport Bus
import bisect

n, c, k = map(int, input().split())
t_list = [int(input()) for _ in range(n)]

t_list.sort()
ans = 0

while len(t_list) > 0:
    _tmp = t_list[0] + k
    _idx = bisect.bisect_right(t_list, _tmp)
    if c <= _idx + 1:
        t_list = t_list[c:]
    else:
        t_list = t_list[_idx:]
    ans += 1

print(ans)

Fixed submission:
# AGC011 A Airport Bus
import bisect
from collections import deque

n, c, k = map(int, input().split())
t_list = [int(input()) for _ in range(n)]

t_list.sort()
t_list = deque(t_list)
ans = 0

while len(t_list) > 0:
    _tmp = t_list.popleft() + k
    _idx = bisect.bisect_right(t_list, _tmp)
    if c-1 <= _idx:
        for _ in range(c-1):
            t_list.popleft()
    else:
        for _ in range(_idx):
            t_list.popleft()
    ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]

ans = 0
MOD = 10**9 + 7
for i in range(N-1):
    for j in range(i+1, N):
        ans = (ans % MOD + A[i] * A[j] % MOD)%MOD

print(ans)

Fixed submission:
MOD = 10**9 + 7

import time

def solve(N, A):
    ans = 0
    asum = sum(A)
    for i in range(N-1):
        asum -= A[i]
        ans = (ans + A[i] * asum) % MOD
    return ans

if __name__ == '__main__':
    N = int(input())
    A = [int(a)%MOD for a in input().split()]
    ans = solve(N, A)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]

ans = 0
MOD = 10**9 + 7
for i in range(N-1):
    for j in range(i+1, N):
        ans = (ans + (A[i]%MOD)*(A[j]%MOD))%MOD

print(ans)

Fixed submission:
MOD = 10**9 + 7

import time

def solve(N, A):
    ans = 0
    asum = sum(A)
    for i in range(N-1):
        asum -= A[i]
        ans = (ans + A[i] * asum) % MOD
    return ans

if __name__ == '__main__':
    N = int(input())
    A = [int(a)%MOD for a in input().split()]
    ans = solve(N, A)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]

ans = 0
MOD = 10**9 + 7
for i in range(N-1):
    for j in range(i+1, N):
        ans = (ans + (A[i]%MOD)*(A[j]%MOD))%MOD

print(ans)

Fixed submission:
MOD = 10**9 + 7

import time

def solve(N, A):
    ans = 0
    asum = sum(A)
    for i in range(N-1):
        asum -= A[i]
        ans = (ans + A[i] * asum) % MOD
    return ans

if __name__ == '__main__':
    N = int(input())
    A = [int(a)%MOD for a in input().split()]
    ans = solve(N, A)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]

ans = 0
MOD = 10**9 + 7
for i in range(N-1):
    for j in range(i+1, N):
        ans += (A[i]%MOD)*(A[j]%MOD)%MOD
print(ans%MOD)

Fixed submission:
MOD = 10**9 + 7

import time

def solve(N, A):
    ans = 0
    asum = sum(A)
    for i in range(N-1):
        asum -= A[i]
        ans = (ans + A[i] * asum) % MOD
    return ans

if __name__ == '__main__':
    N = int(input())
    A = [int(a)%MOD for a in input().split()]
    ans = solve(N, A)
    print(ans)