Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
M=10**9+7
N=10**5*2
fac=[0]*(N+1)
fac[0]=b=1
for i in range(1,N+1):fac[i]=b=b*i%M
inv=[0]*(N+1)
inv[N]=b=pow(fac[N],M-2,M)
for i in range(N,0,-1):inv[i-1]=b=b*i%M
def dfs1(v,p):
    s=1
    l=[]
    c1,c2=[1],[1]
    for w in e[v]:
        if w==p:continue
        l+=w,
        dfs1(w,v)
        u=sz1[w]
        c1+=c1[-1]*dp1[w]*inv[u]%M,
        s+=u
    for w in l[::-1]:
        c2+=c2[-1]*dp1[w]*inv[sz1[w]]%M,
    e[v]=l
    c[v]=c1,c2[::-1]
    sz1[v]=s
    dp1[v]=c1[-1]*fac[s-1]%M
n,*t=open(0).read().split()
n=int(n)
e=[[]for _ in range(n)]
for a,b in zip(*[map(int,t)]*2):
    e[a-1]+=b-1,
    e[b-1]+=a-1,
sz1,sz2=[0]*n,[0]*n
dp1,dp2=[0]*n,[0]*n
c=[[]for _ in range(n)]
dfs1(0,-1)
# print(dp1)
sz2[0]=1
dp2[0]=1
s=[0]
while s:
    v=s.pop()
    l=len(e[v])
    c1,c2=c[v]
    uv=sz2[v]-1
    tv=dp2[v]*inv[uv]
    for i,w in enumerate(e[v]):
        tw=c1[i]*c2[i+1]%M
        uw=uv+sz1[v]-sz1[w]-1
        dp2[w]=tv*tw*fac[uw]%M
        sz2[w]=uw+2
        s+=w,
# print(dp2)
a=[]
for dp1,dp2,sz1,sz2 in zip(dp1,dp2,sz1,sz2):
    sz1-=1
    sz2-=1
    a+=str(dp1*dp2*inv[sz1]*inv[sz2]*fac[sz1+sz2]%M),
print('\n'.join(a))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
M=10**9+7
N=10**6
fac=[0]*(N+1)
fac[0]=b=1
for i in range(1,N+1):fac[i]=b=b*i%M
inv=[0]*(N+1)
inv[N]=b=pow(fac[N],M-2,M)
for i in range(N,0,-1):inv[i-1]=b=b*i%M
def dfs1(v,p):
    s=1
    l=[]
    c1,c2=[1],[1]
    for w in e[v]:
        if w==p:continue
        l+=w,
        dfs1(w,v)
        u=sz1[w]
        c1+=c1[-1]*dp1[w]*inv[u]%M,
        s+=u
    for w in l[::-1]:
        c2+=c2[-1]*dp1[w]*inv[sz1[w]]%M,
    e[v]=l
    c[v]=c1,c2[::-1]
    sz1[v]=s
    dp1[v]=c1[-1]*fac[s-1]%M
n,*t=open(0).read().split()
n=int(n)
e=[[]for _ in range(n)]
for a,b in zip(*[map(int,t)]*2):
    e[a-1]+=b-1,
    e[b-1]+=a-1,
sz1,sz2=[0]*n,[0]*n
dp1,dp2=[0]*n,[0]*n
c=[[]for _ in range(n)]
dfs1(0,-1)
# print(dp1)
sz2[0]=1
dp2[0]=1
s=[0]
while s:
    v=s.pop()
    l=len(e[v])
    c1,c2=c[v]
    uv=sz2[v]-1
    tv=dp2[v]*inv[uv]
    for i,w in enumerate(e[v]):
        tw=c1[i]*c2[i+1]%M
        uw=uv+sz1[v]-sz1[w]-1
        dp2[w]=tv*tw*fac[uw]%M
        sz2[w]=uw+2
        s+=w,
# print(dp2)
for i in range(n):
    u1=sz1[i]-1
    u2=sz2[i]-1
    print(dp1[i]*dp2[i]*inv[u1]*inv[u2]*fac[u1+u2]%M)
### BUGGY CODE ###

from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def pprint(M):
	for row in M:
		print(row)
	print("~~~")

def main():
	MOD = 10**9 + 7
	n, k = rli()
	A = list(rli())
	P = [A[0]]
	for i in range(1, len(A)):
		P.append(P[-1] + A[i])
	dp = [[0 for __ in range(k+1)] for _ in range(n)]
	psums = [[0 for __ in range(k+1)] for _ in range(n)]
	for c in range(min(k+1, A[0] + 1)):
		dp[0][c] = 1
	psums[0][0] = dp[0][0]
	for c in range(1, k+1):
		psums[0][c] = dp[0][c] + psums[0][c-1]
	for r in range(1, n):
		for c in range(min(k + 1, P[r] + 1)):
			cutoff = c - A[r] - 1
			dp[r][c] = psums[r-1][c] - (psums[r-1][cutoff] if cutoff >= 0 else 0)
		psums[r][0] = dp[r][0]
		for c in range(1, k + 1):
			psums[r][c] = dp[r][c] + psums[r][c-1]
	print(dp[n-1][k] % MOD)
	stdout.close()

if __name__ == "__main__":
	main()

### FIXED CODE ###

from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def pprint(M):
	for row in M:
		print(row)
	print("~~~")

def main():
	MOD = 10**9 + 7
	n, k = rli()
	A = list(rli())
	P = [A[0]]
	for i in range(1, len(A)):
		P.append(P[-1] + A[i])
	dp = [[0 for __ in range(k+1)] for _ in range(n)]
	psums = [[0 for __ in range(k+1)] for _ in range(n)]
	for c in range(min(k+1, A[0] + 1)):
		dp[0][c] = 1
	psums[0][0] = dp[0][0]
	for c in range(1, k+1):
		psums[0][c] = dp[0][c] + psums[0][c-1]
		psums[0][c] %= MOD
	for r in range(1, n):
		for c in range(min(k + 1, P[r] + 1)):
			cutoff = c - A[r] - 1
			dp[r][c] = psums[r-1][c] - (psums[r-1][cutoff] if cutoff >= 0 else 0)
			dp[r][c] %= MOD
		psums[r][0] = dp[r][0]
		for c in range(1, k + 1):
			psums[r][c] = dp[r][c] + psums[r][c-1]
			psums[r][c] %= MOD
	print(dp[n-1][k] % MOD)
	stdout.close()

if __name__ == "__main__":
	main()
### BUGGY CODE ###

mod = 10 ** 9 + 7


def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod


n, a, b = map(int, input().split())
a_comb = comb(n,a,mod)
b_comb = comb(n,b,mod)
print(2 ** n -1 - a_comb - b_comb)


### FIXED CODE ###

from functools import reduce

stdin = open(0)
N, A, B = map(int, stdin.read().split())
MOD = 10 ** 9 + 7


def f(A):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD


answer = pow(2, N, MOD) - f(A) - f(B) - 1
answer %= MOD
print(answer)
### BUGGY CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
for i in range(n):
    p = s.pop(i)
    print(max(s))
    s.insert(i,p)

### FIXED CODE ###

n = int(input())
s = []
p = []
for i in range(n):
    s.append(int(input()))
    
p = s[:] 
s.sort()
for i in p:
    if i != s[-1]:
        print(s[-1])
    else:
        print(s[-2])
### BUGGY CODE ###

if __name__ == '__main__':
    import sys
    N = int(input())
    A = []
    for i in range(N):
        row = list(map(int, sys.stdin.readline().split()))
        row = [r - 1 for r in row]
        A.append(row)

    A.append([1000] * N)

    counter = [0] * (N + 1)
    finish = 0

    ans = 0
    check_done = set()
    while finish < N * (N - 1) // 2:
        checked = set()
        ans += 1

        exit_flg = True
        for n in range(N):
            # ある日程ですでにnは戦っている
            if n in checked:
                continue
            checked.add(n)

            # nの対戦は終了
            if counter[n] == N - 1:
                continue

            n_match = A[n][counter[n]]  # nの対戦相手
            n_match_match = A[n_match][counter[n_match]]  # nの対戦相手の対戦相

            # nの対戦相手はある日の試合をすでに終えている
            if n_match in checked:
                continue

            # マッチング成立
            if n == n_match_match:
                exit_flg = False

                checked.add(n_match)

                finish += 1
                counter[n] += 1
                counter[n_match] += 1

        # 一つも組み合わせられなかった
        if exit_flg:
            print(-1)
            exit()

    print(ans)


### FIXED CODE ###

N = int(input())

# 初期化
G = [None] * (10 ** 6 + 1)  # グラフ
for i in range(10 ** 6 + 1):
    G[i] = set()
U = [None] * (10 ** 6 + 1)  # 入次数
D = [0] * (10 ** 6 + 1)  # 根からの距離


# 変換用
def x(i, j):
    return j + 1000 * i


# グラフを構築
for i in range(1, N + 1):
    A = list(map(int, input().split()))
    for j in range(N - 2):
        fv1, fv2 = min(i, A[j]), max(i, A[j])
        tv1, tv2 = min(i, A[j + 1]), max(i, A[j + 1])
        G[x(fv1, fv2)].add(x(tv1, tv2))
        U[x(fv1, fv2)] = 0
        U[x(tv1, tv2)] = 0


# 入次数をカウント
for i in range(10 ** 6 + 1):
    for v in G[i]:
        U[v] += 1

        
# トポロジカルソート
U_zero_nodes = []
for i in range(10 ** 6 + 1):
    if U[i] is None:
        continue

    if U[i] == 0:
        U_zero_nodes.append(i)


topological_order = []
while U_zero_nodes:
    n = U_zero_nodes.pop()
    topological_order.append(n)

    for v in G[n]:
        U[v] -= 1
        if U[v] == 0:
            U_zero_nodes.append(v)


# 不可能判定
if len(topological_order) != N * (N - 1) // 2:
    print(-1)
    exit()


# 最長経路を計算
for t_n in topological_order:
    for v in G[t_n]:
        D[v] = max(D[v], D[t_n] + 1)
print(max(D) + 1)
### BUGGY CODE ###

import numpy as np
n = int(input())
a =np.array([int(x) for x in input().split()])
q = int(input())
bc = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*bc)]

for i in range(q):
    ans = 0
    for j in range(len(a)):
        if a[j] == b[i]:
            a[j] = c[i]
        ans += a[j]
    print(ans)

### FIXED CODE ###

import numpy as np
import collections

n = int(input())
a =np.array([int(x) for x in input().split()])
q = int(input())
bc = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*bc)]

count_dict = collections.Counter(a)
ans = np.sum(a)
for i in range(q):
    if count_dict[b[i]] > 0:
        ans += count_dict[b[i]]*(c[i]-b[i])
        count_dict[c[i]] += count_dict[b[i]]
        count_dict[b[i]] = 0
    print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
INF = 10**9
dp = [INF] * N
dp[0] = 0
for i in range(N):
    for k in range(1, K+1):
        if i + k < N:
            dp[i+k] = min(dp[i+k], dp[i]+abs(h[i] - h[i+k]))
print(dp[N-1])

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
INF = 10**9
dp = [INF] * N
dp[0] = 0
for i in range(N):
    for k in range(1, K+1):
        if i + k < N:
            dp[i+k] = min(dp[i+k], dp[i]+abs(h[i] - h[i+k]))
print(dp[N-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()

def dfs(start, remain):
    if len(remain) == 0:
        return 1
    else:
        ans = 0
        for i in range(1, 3):
            if start == remain[:i]:
                continue
            else:
                ans = max(ans, 1 + dfs(remain[:i], remain[i:]))
        return ans

ans = 0
if len(s) == 1:
    print(ans)
    sys.exit(0)
for i in range(1, 3):
    ans = max(ans, dfs(s[:i], s[i:]))
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()
if len(s) == 1:
    print(0)
    sys.exit(0)
if len(s) == 2 and s[0] == s[1]:
    print(0)
    sys.exit(0)

# [i][0]: index iが1文字分割
# [i][1]: index iが2文字分割
dp = [[0] * 2 for _ in range(len(s))]
# 3文字以上では1文字/2文字の仮想結果が使われる
# 1文字
dp[0][0] = dp[0][1] = 1
# 2文字
if s[0] == s[1]:
    # 実際には常に2文字分割になる
    dp[1][0] = dp[1][1] = 1
else:
    dp[1][0] = 2
    dp[1][1] = 1

# 3文字以上
for i in range(2, len(s)):

    # [i][0]: 末尾の分割を1文字にする場合

    # 末尾2文字が同じ場合
    # - 1つ前を2文字分割にしなくてはならない
    if s[i] == s[i-1]:
        dp[i][0] = dp[i-1][1] + 1
    # 末尾2文字が異なる場合
    # - 1つ前が1文字分割
    # - 1つ前が2文字分割
    else:
        dp[i][0] = max(dp[i-1][0] + 1, dp[i-1][1] + 1)


    # [i][1]: 末尾の分割を2文字にする場合
    # 末尾前の2文字が末尾の2文字と同じ場合
    # 末尾前を1文字分割にしなくてはならない
    if s[i-3:i-1] == s[i-1:i+1]:
        dp[i][1] = dp[i-2][0] + 1
    # 末尾前の2文字が末尾の2文字と異なる場合
    # - 末尾前が1文字分割
    # - 末尾前が2文字分割
    else:
        dp[i][1] = max(dp[i-2][0] + 1, dp[i-2][1] + 1)

print(max(dp[-1][0], dp[-1][1]))
### BUGGY CODE ###

# coding: utf-8
import itertools
H, W = list(map(int, input().split()))
S = []
for _ in range(H):
    S.append(list(input()))

_w = list(range(H+W-2))

min_change = H * W
paths = list(itertools.combinations(_w,W-1))
for path in paths:
    state = [0, 0]
    pathway = [0] * (H+W-2)
    change = 0
    for i in path:
        pathway[i] = 1
    # init Flag
    black_flag = True if S[0][0] == '#' else False
    
    for go in pathway:
        state[go] += 1
        if S[state[0]][state[1]] == '#':
            if state == [H-1, W-1]:
                change += 1
                break
            if black_flag:
                continue
            else:
                black_flag = True
        else:
            if black_flag:
                change += 1
                black_flag = False
            else:
                continue
    if min_change > change:
        min_change = change

print(min_change)

### FIXED CODE ###

# coding: utf-8
H, W = list(map(int, input().split()))
S = []
for _ in range(H):
    S.append(list(input()))

grid = [[0 for _ in range(W)] for _ in range(H)]

for h in range(1,H):
  if S[h-1][0] == '#' and S[h][0] == '.':
    grid[h][0] = grid[h-1][0] + 1
  else:
    grid[h][0] = grid[h-1][0]
    
for w in range(1,W):
  if S[0][w-1] == '#' and S[0][w] == '.':
    grid[0][w] = grid[0][w-1] + 1
  else:
    grid[0][w] = grid[0][w-1]
for w in range(1,W):
  for h in range(1,H):
    if S[h-1][w] == '#' and S[h][w] == '.':
      next_h = grid[h-1][w] + 1
    else:
      next_h = grid[h-1][w]      
    if S[h][w-1] == '#' and S[h][w] == '.':
      next_w = grid[h][w-1] + 1
    else:
      next_w = grid[h][w-1]
    grid[h][w] = min([next_w, next_h])
if S[H-1][W-1] == '#':
  grid[H-1][W-1] += 1
print(grid[H-1][W-1])
### BUGGY CODE ###

n = int(input())
print(0)
sys.stdout.flush()
maes = input()
if maes == "Vacant":
    exit()
print(n-1)
sys.stdout.flush()
maes = input()
if maes == "Vacant":
    exit()
lef = 0
rig = n -1 
print((lef+rig)//2 - ((lef+rig)//2)%2)
sys.stdout.flush()
p = 0
while abs(rig-lef)<=2:
    s = input()
    if s == "Vacant":
        exit()
    else:
        if maes == s:
            if p == 0:
                lef = (lef+rig)//2 - ((lef+rig)//2)%2
            elif p == 1:
                rig = (lef+rig)//2 + ((lef+rig)//2)%2
        elif maes != s:
            if p == 0:
                p = 1
                rig = (lef+rig)//2 + ((lef+rig)//2)%2
            elif p == 1:
                lef = (lef+rig)//2 - ((lef+rig)//2)%2
    maes = s
    print((lef+rig)//2 - ((lef+rig)//2)%2)
    sys.stdout.flush()

print((lef+rig)//2)
sys.stdout.flush()
if maes == "Vacant":
    exit()

### FIXED CODE ###

n = int(input())

print(0)
lf = input()
if lf == "Vacant":
    exit()

print(n-1)
rf = input()
if rf == "Vacant":
    exit()
l = 0
r = n-1

while True:
    k = (l+r)//2
    print(k)
    f = input()
    if f == "Vacant":
        exit()
    else:
        if (abs(r-k) % 2 == 1 and rf == f) or (abs(r-k) % 2 == 0 and rf != f):
            l = k
            lf = f
        elif (abs(l-k) % 2 == 1 and lf == f) or (abs(l-k) % 2 == 0 and lf != f):
            r = k
            rf = f
### BUGGY CODE ###

#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float("inf")

x = int(input())


def find(x):
    for a in range(10 ** 4):
        for b in range(10 ** 4):
            b = -b
            if a ** 5 - b ** 5 == x:
                return [a, b]


a, b = find(x)
print(a, b)


### FIXED CODE ###

#!/usr/bin/env python3

import sys

input = sys.stdin.buffer.readline

x = int(input())


def find(x):
    for a in range(-300, 300):
        for b in range(-300, 300):
            b = -b
            if a ** 5 - b ** 5 == x:
                return [a, b]


a, b = find(x)
print(a, b)
### BUGGY CODE ###

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

for i in range(K):
    num = H.index(max(H))
    H[num] = 0

print(sum(H))

### FIXED CODE ###

N,K = map(int, input().split())
H =  list(map(int, input().split()))
H.sort(reverse=True)
sum = 0

for i in range(N):
    if i < K:
        pass
    else:
        sum += H[i]

print(sum)
### BUGGY CODE ###

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

list = []
for i in range(n//k + 2) :
    list.append(abs(n-k))
    n = abs(n-k)

print(min(list))


### FIXED CODE ###

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

if n < k :
    if n >= abs(n-k):
        ans = abs(n-k)
    else :
        ans = n
elif n%k != 0 :
    ans = abs(n%k - k)
else :
    ans = 0

print(ans)
### BUGGY CODE ###

import numpy as np
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
arr = np.array(a)
for i in range(m):
    ind = arr.argmax()
    arr[ind] = arr[ind]//2
print(arr.sum(dtype=np.int64))

### FIXED CODE ###

import heapq
n,m = map(int,input().split())
a = list(map(lambda x: -int(x),input().split()))
heapq.heapify(a)
for _ in range(m):
    tmp = (-heapq.heappop(a)) // 2
    heapq.heappush(a, -tmp)
print(-sum(a))
### BUGGY CODE ###

N=int(input())
A=list(int(i) for i in input().split())
S=0
for i in range(N):
    for j in range(i+1,N):
        S+=A[i]*A[j]
print(S%((pow(10,9)+7)))

### FIXED CODE ###

N=int(input())
A=input().split()
A=[int(i) for i in A]
S=0
A_sum=0
for i in range(N):
    A_sum+=A[i]
    

B=A_sum
for i in range(N):
    B-=A[i]
    S+=A[i]*B

print(S%(pow(10,9)+7))
### BUGGY CODE ###

import bisect
n, m = map(int, input().split())
price = sorted(list(map(int, input().split())))

while m >= 1:
    new_price = price[-1] // 2
    bisect.insort_left(price, new_price)
    del price[-1]
    m -= 1
    
print(sum(price))

### FIXED CODE ###

import heapq
n, m = map(int, input().split())
price = list(map(lambda x: -x, map(int, input().split())))
heapq.heapify(price)

while m >= 1:
    a = (heapq.heappop(price) + 1) // 2
    heapq.heappush(price, a)
    m -= 1
    
print(sum(price) * (-1))
### BUGGY CODE ###

import numpy as np

N = int(input())

N_list = np.array(range(N))

N_np   = np.sum(np.array(N_list))

print(int(N_np))

### FIXED CODE ###

N = int(input())

print((N*(N-1))//2)
### BUGGY CODE ###

N, M = [int(s) for s in input().split(' ')]
As = [int(s) for s in input().split(' ')]
for m in range(M):
    B, C = [int(s) for s in input().split(' ')]
    As += [C] * B
As.sort()
print(sum(As[-N:]))



### FIXED CODE ###

N, M = [int(s) for s in input().split(' ')]
As = [int(s) for s in input().split(' ')]
CBs = []
for m in range(M):
    B, C = [int(s) for s in input().split(' ')]
    CBs.append((C, B))
As.sort(reverse=True)
CBs.sort(reverse=True)
CBs.append((0, 0))
ret = 0
a = 0
bc = 0
n = 0
while n < N:
    C, B = CBs[bc]
    if As[a] < C:
        bc += 1
        pick = min(N - n, B)
        ret += pick * C
        n += pick
    else:
        ret += As[a]
        a += 1
        n += 1
print(ret)
### BUGGY CODE ###

N, M = (int(i) for i in input().split(' '))
ten = [i+1 for i in range(N)]
H = [int(i) for i in input().split(' ')]
dic = {}
for i in range(len(H)):
    list_item = H[i]
    dic[i+1] = list_item
A = []
for i in range(M):
    x, y = (int(a) for a in input().split(' '))
    if x in ten and y in ten:
        if dic[x] == dic[y]:
            A.append(x)
            A.append(y)
        elif dic[x] > dic[y]:
            A.append(y)
        else:
            A.append(x)
    
B = set(A)
for i in B:
    ten.remove(i)
print(len(ten))

### FIXED CODE ###

n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=0
for v in range(1,n+1):
  for u in g[v]:
    if arr[u]>=arr[v]:
      break
  else:
    ans+=1
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, L: "List[int]"):
    L.sort()

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            from bisect import bisect_left, bisect_right
            k = bisect_left(L, L[i]+L[j])
            ans += (k-(j+1))

    print(ans)

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

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

from bisect import bisect_left, bisect_right



def solve(N: int, L: "List[int]"):
    ans = 0
    L.sort()

    for x in range(N):
        for y in range(x+1,N):
            ze = bisect_left(L, L[x]+L[y])            
            ans += (ze-y-1)
            
    print(ans)

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

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
n = int(sys.stdin.readline())
s = sys.stdin.readline().strip()
i = 0
cnt = 0
while i <= n -3:
  if s[i:i+3] == 'ABC':
    cnt += 1
print(cnt)

### FIXED CODE ###

import sys
n = int(sys.stdin.readline())
s = sys.stdin.readline().strip()
i = 0
cnt = 0
while i <= n -3:
  if s[i:i+3] == 'ABC':
    cnt += 1
  i += 1
print(cnt)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

N = int(input())

count = 0
for A in range(1, N+1):
    head_A = str(A)[0]
    tail_A = str(A)[-1]
    for B in range(A, N+1):
        head_B = str(B)[0]
        tail_B = str(B)[-1]
        if head_A == tail_B and tail_A == head_B:
            if A == B:
                count += 1
            else:
                count += 2

print(count)


### FIXED CODE ###

# -*- coding: utf-8 -*-

# input
N = int(input())

# create and init dictionary
heads_and_tails = {}
for head in range(1, 10):
    for tail in range(1, 10):
        heads_and_tails[(head, tail)] = 0

# create dictionary contents
for num in range(1, N+1):
    if num%10 == 0:
        continue
    head = int(str(num)[0])
    tail = int(str(num)[-1])
    heads_and_tails[(head, tail)] +=1

# count
count = 0
for head in range(1, 10):
    for tail in range(1, 10):
        count += heads_and_tails[(head, tail)] * heads_and_tails[(tail, head)]

print(count)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
result = 1
for i in A:
  result *= i
if result > 10**18:
  print(-1)
else:
  print(result)

### FIXED CODE ###

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

  if 0 in A:
    print(0)
    return
  
  num = 1
  max_num = 10**18
  for i in A:
    num *= i
    
    if num > max_num:
      print(-1)
      return
  
  print(num)
  
main()
### BUGGY CODE ###

d = {}
N = int(input())

for _ in range(N):
    s = str(input())
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

max_list = [kv for kv in d.items() if kv[1] == max(d.values())]

sml = sorted(max_list)

for _ in range(len(sml)):
    print(sml[_][0])

### FIXED CODE ###

N = int(input())
l = []

for _ in range(N):
    s = str(input())
    l.append(s)

import collections
c = collections.Counter(l)
c = c.most_common()

most_count = c[0][1]
c.sort()

for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))

p=1
for i in range(k):
    p*=a[i]


for i in range(n-k):
    tmp=p
    p//=a[i]
    p*=a[i+k]
    p//(10**9 +7)

    if p>tmp:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))

for i in range(n-k):

    if a[i]<a[k+i]:
        print("Yes")
    else:
        print("No")