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

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

s = 0
for i in range(1, n):
    for k in range(0, n - i):
        if a[k] > i:
            continue
        else:
            if a[k] + a[k + i] == i:
                s += 1
print(s)

### FIXED CODE ###

# %%time
n = int(input())
a = list(map(int, input().split()))

# n = 10000
# a = np.random.randint(1, 1000, n)

import numpy as np
from collections import Counter

a = np.array(a)
ap = a + np.arange(n)
am = a - np.arange(n)
am = -am

c = Counter(am)

s = 0
for k in range(n):
    s += c[ap[k]]
    c[am[k]] -= 1

print(s)
### BUGGY CODE ###

N = int(input())
X = input()

def popcount(x):
    tmp = x
    count = 0
    while tmp > 0:
        if tmp & 1 == 1:
            count += 1
        tmp >>= 1
    
    return count

def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

tmp_pop_X = X.count('1')
X_tmp = int(X,2)

for i in range(N):
    if X[i] == '0':
        X_next = X_tmp + pow_k(2,N-1-i)
        X_pop_next = tmp_pop_X + 1
    else:
        X_next = X_tmp - pow_k(2,N-1-i)
        X_pop_next = tmp_pop_X - 1
        
    if X_pop_next == 0:
        print(0)
        continue
        
    X_next = X_next % X_pop_next
    ans = 1
    
    while X_next != 0:
        X_next = X_next % popcount(X_next)
        ans += 1
        
    print(ans)

### FIXED CODE ###

n = int(input())
s = input()
x = int(s, 2)
pcx = s.count("1")
pc1 = x % (pcx - 1) if pcx > 1 else 0
pc2 = x % (pcx + 1)

def f(j):
    cnt = 0
    while j:
        j %= bin(j).count("1")
        cnt += 1
    return cnt

for i, y in enumerate(s):
    k = n - 1 - i
    if y == "0":
        print(f((pc2 + pow(2, k, pcx + 1)) % (pcx + 1)) + 1)
    elif pcx > 1:
        print(f((pc1 - pow(2, k, pcx - 1)) % (pcx - 1)) + 1)
    else:
        print(0)
### BUGGY CODE ###

N = int(input())
N = str(N)
N = tuple(map(int, N))

ans = 0
flag = False
flag5 = False
i = len(N)-1


for x in reversed(N):
    if flag or (flag5 and x >= 5):
        x += 1
    flag5 = False
    flag = False
    if x > 5:
        ans += (10 - x)
        flag = True
        if i == 0:
            ans += 1
    else:

        ans += x
    if x == 5:
        flag5 = True
    i -= 1

print(ans)


### FIXED CODE ###

N = tuple(input())
N = tuple(map(int, N))

ans = 0
flag = False
flag5 = False
i = len(N)-1


for x in reversed(N):
    if flag or (flag5 and x >= 5):
        x += 1
    flag5 = False
    flag = False
    if x > 5:
        ans += (10 - x)
        flag = True
        if i == 0:
            ans += 1
    else:

        ans += x
    if x == 5:
        flag5 = True
    i -= 1

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

import sys
input = sys.stdin.readline

N,M,S=map(int,input().split())
E=[[] for i in range(N+1)]
for i in range(M):
    u,v,a,b=map(int,input().split())
    E[u].append((v,a,b))
    E[v].append((u,a,b))

C=[(0,0)]+[tuple(map(int,input().split())) for i in range(N)]
DP=[[1<<64]*5001 for i in range(51)]

import heapq

Q=[(0,min(S,5000),1)]
DP[1][min(S,5000)]=0

while Q:
    time,money,town = heapq.heappop(Q)

    for to,pmoney,ptime in E[town]:
        if money>=pmoney and DP[to][money-pmoney]>time+ptime:
            DP[to][money-pmoney]=time+ptime
            heapq.heappush(Q,(time+ptime,money-pmoney,to))
            
    if DP[town][min(money+C[town][0],5000)]>time+C[town][1]:
        DP[town][min(money+C[town][0],5000)]=time+C[town][1]
        heapq.heappush(Q,(time+C[town][1],min(money+C[town][0],5000),town))
        
for i in range(2,N+1):
    print(min(DP[i]))

### FIXED CODE ###

import sys
input = sys.stdin.readline

N,M,S=map(int,input().split())
E=[[] for i in range(N+1)]
for i in range(M):
    u,v,a,b=map(int,input().split())
    E[u].append((v,a,b))
    E[v].append((u,a,b))

C=[(0,0)]+[tuple(map(int,input().split())) for i in range(N)]
DP=[[1<<60]*5001 for i in range(51)]

import heapq

Q=[(0,min(S,5000),1)]
DP[1][min(S,5000)]=0

while Q:
    time,money,town = heapq.heappop(Q)

    for to,pmoney,ptime in E[town]:
        if money>=pmoney and DP[to][money-pmoney]>time+ptime:
            DP[to][money-pmoney]=time+ptime
            heapq.heappush(Q,(time+ptime,money-pmoney,to))
            
    if DP[town][min(money+C[town][0],5000)]>time+C[town][1]:
        DP[town][min(money+C[town][0],5000)]=time+C[town][1]
        heapq.heappush(Q,(time+C[town][1],min(money+C[town][0],5000),town))
        
for i in range(2,N+1):
    print(min(DP[i]))
### BUGGY CODE ###

n = int(input())
a = list(input().split())

a_dict = dict()
for x in a:
    if x not in a_dict:
        a_dict[x] = 1
    else:
        a_dict[x] += 1

"""for k, v in a_dict.items():
    if v < 2:   # 1個しかないボールは削除
        del a_dict[k]
    a_dict[k] = v*(v-1)//2  # valueにコンビネーション数を設定"""

a_dict = {k: v for k, v in a_dict.items() if v != 1}

sum = 0
for i in a:
    for k, v in a_dict.items():
        if k == i:
            sum += (v-2)*(v-1)//2
        else:
            sum += v*(v-1)//2
    print(sum)
    sum = 0


### FIXED CODE ###

n = int(input())
a = list(input().split())

a_dict = dict()
for x in a:
    if x not in a_dict:
        a_dict[x] = 1
    else:
        a_dict[x] += 1

sum = 0
for k, v in a_dict.items():
    sum += v*(v-1)//2
    a_dict[k] = (v*(v-1)//2)-((v-1)*(v-2)//2)

for i in a:
    print(int(sum-a_dict[i]))
### BUGGY CODE ###

a, b, x = map(int, input().split())
num_list = [i for i in range(a, b + 1)]
count = len(list(filter(lambda t: t % x == 0, num_list)))
print(count)

### FIXED CODE ###

a, b, x = map(int, input().split())
br = b//x
ar = (a-1)//x
print(br-ar)
### BUGGY CODE ###

#??????????????????
import heapq
def SME(start,end):
    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        if None not in ANS[a[1]:a[1]+L] : continue
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] : continue
                else :
                    ANS[idx] = a[0]
                    D.add(idx)
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in C.difference(D):
        if i < L:
            ANS[i] = min(Whole[:i+1])
        else :
            ANS[i] = min(Whole[i+1-L:i+1])
    return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
C = set([i for i in range(N)])
D = set([])
parameter = 0.9997
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]

M = max(A)
m = M
a = 1
while m // 2 != 0:
  m = m//2
  a += 1
#aはMの桁数

b = 0
for i in range(a):
  c = 0
  for j in range(N):
    c += (A[j] & 2**i)//(2**i)  #A[j]の2**iの位の値をcに加えている
  b = (b + c*(N-c)*pow(2,i,10**9+7)) % (10**9+7)
  
print(b)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]

M = max(A)
m = M
a = 1
while m // 2 != 0:
  m = m//2
  a += 1
#aはMの桁数

b = 0
for i in range(a):
  c = 0
  for j in range(N):
    c += (A[j] & 2**i)//(2**i)  #A[j]の2**iの位の値をcに加えている
  b = (b + c*(N-c)*pow(2,i,10**9+7)) % (10**9+7)
  
print(b)
### BUGGY CODE ###

N,A,B = [int(x) for x in input().split()]
n = 0
blue = 0
for i in range(10**100):
    if A == 0:
        break
    n = n + A
    blue = blue + A
    if n >= N:
        blue = blue - (n-N)
        break
    else:
        n = n + B
        if n >= N:
            break
print(blue)

### FIXED CODE ###

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

a = N//(A+B)*A

if N%(A+B) <= A:
    print(a + N%(A+B))
else:
    print(a + A)
### BUGGY CODE ###

from collections import deque
h, w = map(int, input().split())
que = deque()
data = []

for ln in range(h):
    line = list(input().rstrip())
    lineN = [0] * w
    for r, letter in enumerate(line):
        if letter == '#':
            lineN[r] = 1
            que.append((ln, r, 0b1100))
            que.append((ln, r, 0b0011))
    data.append(lineN)

def lt(row, col, dir):
    if dir & 0b0100:
        yield (row - 1, col, 0b0110)
    if dir & 0b0001:
        yield (row + 1, col, 0b1001)
    if dir & 0b0010:
        yield (row, col - 1, 0b0011)
    if dir & 0b1000:
        yield (row, col + 1, 0b1100)

count = 0
while len(que) > 0:
    count += 1
    next = deque()
    while len(que) > 0:
        for r, c, d in lt(*que.popleft()):
            if 0 <= r < h and 0 <= c < w and data[r][c] == 0:
                next.append((r, c, d))
                data[r][c] = 1
    que = next

print(count - 1)

### FIXED CODE ###

from collections import deque
H,W = map(int, input().split())
A = 0
dp = [None] * H
mat = [None] * (H*W)
matS = matE = 0
for h in range(H):
    s = list(input())
    for w, x in zip(range(W), s):
        if x == "#":
            mat[matE] = (h, w, 0)
            matE+=1
    dp[h] = s

def search(dp, mat, nH, nW, cnt):
    global matE
    if dp[nH][nW] == ".":
        mat[matE] = (nH, nW, cnt+1)
        matE+=1
        dp[nH][nW] = "#"

while matS < matE:
    h, w, cnt = mat[matS]
    matS += 1

    if h > 0:
        search(dp, mat, h - 1, w, cnt)
    if h < H-1:
        search(dp, mat, h + 1, w, cnt)
    if w > 0:
        search(dp, mat, h , w - 1, cnt)
    if w < W-1:
        search(dp, mat, h , w + 1, cnt)

print(cnt)
### BUGGY CODE ###

n, k = map(int, input().split())
a_list = []
for i in range(n):
	a, b = map(int, input().split())
	a_list.extend([a] * b)
	if a_list.count(1) > k:
		break
a_list.sort()
print(a_list[k-1])

### FIXED CODE ###

n, k = map(int, input().split())
a_list = []
for i in range(n):
	a, b = map(int, input().split())
	a_list.append([a, b])
a_list.sort(key=lambda x: x[0])
for i in range(n):
	k -= a_list[i][1]
	if k <= 0:
		print(a_list[i][0])
		break
### BUGGY CODE ###

k = int(input())

count = 0

for i in range(1,10**10):
    l = len(str(i))
    if l == 1:
        count +=1
        ans = i
        if count == k:
            print(ans)
            break
        else:
            continue
    else:
        for j in range(l-1):
            if not abs(int(str(i)[j]) - int(str(i)[j+1])) <= 1:
                continue
            elif j ==l-1:
                count +=1
                ans = i
    if count == k:
        print(ans)
        break

### FIXED CODE ###

import queue
k = int(input())

q = queue.Queue()
for i in range(1,10):
    q.put(i)

for i in range(k):
    x = q.get()
    if i == k-1:
        break
    else:
        if not x % 10 == 0:
            q.put(10*x + (x % 10) -1)
        q.put(10*x + (x % 10))
        if not x % 10 == 9:
            q.put(10*x + (x % 10) +1)

print(x)
### BUGGY CODE ###

def fib(n):
  if n < 0:
    print("error")
    exit()
  if n < 2:
    return 1
  result = fib(n-1) + fib(n-2)
  return result

n = int(input())
print(fib(n))

### FIXED CODE ###

def fibr(n):
    if arr[n] != 0:
        return arr[n]
    if n < 2:
        arr[n] = 1
    else:
        arr[n] = fibr(n-1) + fibr(n-2)
    return arr[n]

n = int(input())
arr = [0 for i in range(n+1)]
print(fibr(n))
### BUGGY CODE ###

N = int(input())

def F(A, B):
  return max(len(str(A)), len(str(B)))

ans = 100
for i in range(1, N+1):
  if N % i == 0:
    ans = min(ans, F(i, N//i))

print(ans)

### FIXED CODE ###

import math

N = int(input())

def F(A, B):
  return max(len(str(A)), len(str(B)))

ans = 10**10
for i in range(1, math.ceil(math.sqrt(N+1))+1):
  if N % i == 0:
    ans = min(ans, F(i, N//i))

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

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

ans = 0
for i in range(2**N+1):
    sum_s = 0
    for j in range(N):
        if((i >> j) & 1):
            sum_s += s[j]
    if(sum_s%10==0):
        sum_s = 0
    ans = max(ans, sum_s)

print(ans)

### FIXED CODE ###

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

s.sort()
ans = sum(s)
cnt = []
Flg = False
if(ans%10 != 0):
    print(ans)
else:
    for i in range(N):
        if(s[i]%10 != 0):
            cnt.append(s[i])
            Flg = True
    if(Flg):
        cnt.sort()
        print(ans-cnt[0])
    else:
        print(0)
### BUGGY CODE ###

from collections import Counter
from itertools import combinations

N = int(input())
c = Counter(["".join(sorted(list(input()))) for i in range(N)])
res = 0
for k,i in c.most_common():
  if i == 1:
    break
  res += len(list(combinations([0 for n in range(i)],2)))

print(res)

### FIXED CODE ###

N = int(input())
l = ["".join(sorted(list(input()))) for i in range(N)]
d = {}
ans = 0

for text in l:
  if text in d.keys():
    d[text] += 1
    ans += d[text]
  else:
    d[text] = 0

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

n = int(input())
aList = list(map(int, input().split()))
for i in range(1, n+1):
    print(aList.count(i))

### FIXED CODE ###

n = int(input())
aList = list(map(int, input().split()))
t = [0 for i in range(200001)]
for a in aList:
    t[a] += 1
for i in range(1, n+1):
    print(t[i])
### BUGGY CODE ###

[n,m,q] = list(map(int,input().split(" ")))
a = []
for i in range (q):
    a.append(list(map(int,input().split(" "))))
ans = 0
for i in range (10**n):
    tmp = 0
    nlst = [1 for t in range(n)]
    for j in range (len(str(i))):
        nlst[j]=int(str(i)[j])+1
    if max(nlst)<=m:
        nlst.sort()
        for k in range(q):
            a_ = a[k][0]
            b_ = a[k][1]
            c_ = a[k][2]
            d_ = a[k][3]
            if nlst[b_-1]-nlst[a_-1]==c_:
                tmp = tmp + d_
        if ans < tmp:
            ans = tmp
    
print(ans)

### FIXED CODE ###

[n,m,q] = list(map(int,input().split(" ")))
lst = []
for i in range (q):
    lst.append(list(map(int,input().split(" "))))

y = [1 for i in range(n)]

def f(index,li):
    if index == n:
        return eva(li)
    else:
        ret = 0
        t = 1
        if index>=1:
            t = li[index-1]
        for i in range (t,m+1):
            li[index]=i
            x = f(index+1,li)
            if ret < x:
                ret = x
        return ret
    
def eva(li):
    tmp = 0
    for k in range(q):
        a = lst[k][0]
        b = lst[k][1]
        c = lst[k][2]
        d = lst[k][3]
        if li[b-1]-li[a-1]==c:
            tmp = tmp + d
    return tmp
    
print(f(0,y))
### BUGGY CODE ###

n = int(input())
A = [list(map(int, list('{:020b}'.format(a))))
     for a in map(int, input().split())]

ans = 0
for L in range(n):
    R = L+1
    tmp = A[L]
    while R < n:
        for i in range(20):
            tmp[i] += A[R][i]
        if 2 in tmp:
            break
        R += 1
    ans += R-L
print(ans)


### FIXED CODE ###

n = int(input())
A = [list(map(int, list('{:020b}'.format(a))))
     for a in map(int, input().split())]

ans = 0
R = -1
X = [0]*20
for L in range(n):
    if R < L:
        R += 1
        for i in range(20):
            X[i] += A[R][i]

    while R+1 < n and all(x+y != 2 for x, y in zip(X, A[R+1])):
        for i in range(20):
            X[i] += A[R+1][i]
        R += 1
    ans += R-L+1
    for i in range(20):
        X[i] -= A[L][i]
print(ans)
### BUGGY CODE ###

import collections

def solution():
    n = int(input().strip())
    d = collections.defaultdict(int)
    for _ in range(n):
        d[input().strip()] += 1
    res = list(d.items())
    res.sort(key=lambda x:(-x[1], x[0]))
    for x in res:
        if x[1] == res[0][1]:
            print(x[0])
        else:
            break

def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()
    

main()

### FIXED CODE ###

import collections

def solution():
    n = int(input().strip())
    d = collections.defaultdict(int)
    for _ in range(n):
        d[input().strip()] += 1
    maxValue = max(d.values())
    res = [x[0] for x in d.items() if x[1] == maxValue]
    res.sort()
    for x in res:
        print(x)

def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()
    

main()
### BUGGY CODE ###

N,K,L=map(int,input().split())
PQ=[list(map(int,input().split())) for i in range(K)]
RS=[list(map(int,input().split())) for i in range(L)]

import sys

def find_root(root,x):
    y = root[x]
    if x == y:
        return x
    z = find_root(root,y)
    root[x] = z
    return z
 
def merge(root,size,x,y):
    x = find_root(root,x)
    y = find_root(root,y)
    if x == y:
        return
    sx,sy = size[x],size[y]
    if sx < sy:
        sx,sy = sy,sx
        x,y = y,x
    root[y] = x
    size[x] += sy
    
def UF_make(graph,n):
    Root=list(range(n+1))
    Size=[1] * (n+1)
    for i in range(len(graph)):
        merge(Root,Size,graph[i][0],graph[i][1])
    for i in range(n+1):
        Root[i] = find_root(Root,i)
    Root.pop(0)  #
    return Root

PQN=UF_make(PQ,N)
RSN=UF_make(RS,N)

if K+L<=20:
    PQRS=[]
    for i in range(N):
        PQRS.append([PQN[i],RSN[i]])
    ans=[1]*N
    for i in range(N):
        ans[i]=PQRS.count(PQRS[i])
    print(*ans)
    sys.exit()

PQRS=[PQN[i]*10**6+RSN[i] for i in range(N)]
D=len(set(PQRS))
PQRS=[[PQRS[i],i,0] for i in range(N)]
PQRS.sort()

p=0
if D==1:
    PPQQ=[]
    for i in range(K):
        PPQQ.append(PQ[i][0])
        PPQQ.append(PQ[i][1])
    T=[PPQQ.count(i)+1 for i in range(1,N+1)]
    print(*T)
else:
    while p<N:
        i=1
        c=0
        if p+i>=N-1:
            break
        while PQRS[p][0]==PQRS[p+i][0]:
            c+=1
            i+=1
        for j in range(p,p+i):
            PQRS[j][2]=c
        p+=i
    PQRS.sort(key=lambda x:x[1])
    for i in range(N):
        print(PQRS[i][2]+1,end=' ')

### FIXED CODE ###

N,K,L=map(int,input().split())
PQ=[list(map(int,input().split())) for i in range(K)]
RS=[list(map(int,input().split())) for i in range(L)]

def find_root(root,x):
    y = root[x]
    if x == y:
        return x
    z = find_root(root,y)
    root[x] = z
    return z
 
def merge(root,size,x,y):
    x = find_root(root,x)
    y = find_root(root,y)
    if x == y:
        return
    sx,sy = size[x],size[y]
    if sx < sy:
        sx,sy = sy,sx
        x,y = y,x
    root[y] = x
    size[x] += sy
    
def UF_make(graph,n):
    Root=list(range(n+1))
    Size=[1] * (n+1)
    for i in range(len(graph)):
        merge(Root,Size,graph[i][0],graph[i][1])
    for i in range(n+1):
        Root[i] = find_root(Root,i)
    Root.pop(0)  #
    return Root

PQN=UF_make(PQ,N)
RSN=UF_make(RS,N)
PQRS=[PQN[i]*10**6+RSN[i] for i in range(N)]
D=len(set(PQRS))
PQRS=[[PQRS[i],i,0] for i in range(N)]
PQRS.sort()

p=0
while p<N:
    i=1
    c=0
    if p+i>N-1:
        break
    while PQRS[p][0]==PQRS[p+i][0]:
        c+=1
        i+=1
        if p+i>N-1:
            break
    for j in range(p,p+i):
        PQRS[j][2]=c
    p+=i
PQRS.sort(key=lambda x:x[1])
for i in range(N):
    print(PQRS[i][2]+1,end=' ')
### BUGGY CODE ###

n = int(input())
ans = 0
for i in range(n) :
    ans += i
print(ans)

### FIXED CODE ###

n = int(input())

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

a, b, c, d = map(int, input().split())

while (a>0) & (c>0):
  tmp1 = c-b
  tmp2 = a-d
  if tmp1<=0: 
    print('Yes')
    break
  elif tmp2<=0: 
    print('No')
    break


### FIXED CODE ###

a, b, c, d = map(int, input().split())

num1 = (a-1)//d
num2 = (c-1)//b

print('Yes' if num1>=num2 else'No')
### BUGGY CODE ###

# coding: utf-8
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

N,M,L=map(int, raw_input().split())
RG=csr_matrix((N,N))

for i in range(M):
    f,t,c = map(int, raw_input().split())
    RG[(f-1,t-1)] = c
    RG[(t-1,f-1)] = c

Rd = floyd_warshall(RG)

FG=csr_matrix((N,N))
for i in range(N):
    for j in range(N):
        if Rd[i][j] <= L:
            FG[(i,j)] = 1

Fd = floyd_warshall(FG, directed=False)

Q=int(raw_input())
Queries = []
for i in range(Q):
    s, t = map(int, raw_input().split())
    v = Fd[s-1][t-1]
    if s == t:
        print (str(0))
    elif v == float('inf'):
        print (str(-1))
    else:
        print (str(int(v-1)))


### FIXED CODE ###

# coding: utf-8
from scipy.sparse.csgraph import floyd_warshall

N,M,L=map(int, input().split())
RG=[[0 for i in range(N)] for j in range(N)]

for i in range(M):
    f,t,c = map(int, input().split())
    if c <= L:
        RG[f-1][t-1] = c
        RG[t-1][f-1] = c

Rd = floyd_warshall(RG, directed=False)

FG=[[0 for i in range(N)] for j in range(N)]
for i in range(N):
    for j in range(i+1, N):
        if Rd[i][j] <= L:
            FG[i][j] = 1
            FG[j][i] = 1

Fd = floyd_warshall(FG, directed=False)

Q=int(input())
for i in range(Q):
    s, t = map(int, input().split())
    v = Fd[s-1][t-1]
    if s == t:
        print (str(0))
    if v == float('inf'):
        print (str(-1))
    else:
        print (str(int(v-1)))
### BUGGY CODE ###

n, x, y = input().split(" ")
n, x, y = int(n), int(x), int(y)
ans = [0] * (n - 1)

for i in range(n - 1):
    for j in range(i + 1, n):
        now = 0
        if (j <= x - 1):
            ans[j - i - 1] += 1

        elif(j > x - 1 and j <= y - 1 and i <= x - 1):
            now = now + x - 1 - i
            if (j - (x - 1) >= (y - 1) - j + 1):
                now = now + (y - 1) - j + 1
            else:
                now = now + j - (x - 1)
            ans[now - 1] += 1

        elif(j > x - 1 and j <= y - 1 and i > x - 1):
            if (j - i >= (i - (x - 1)) + ((y - 1) - j) + 1):
                now = (i - (x - 1)) + ((y - 1) - j) + 1
            else:
                now = j - i
            ans[now - 1] += 1

        elif(j > y - 1 and i <= x - 1):
            now = now + x - 1 - i
            now = now + j - (y - 1) + 1
            ans[now - 1] += 1

        elif(j > y - 1 and i > x - 1 and i < y - 1):
            if((y - 1) - i >= i - (x - 1) + 1):
                now = now + i - (x - 1) + 1
            else:
                now = now + (y - 1) - i
            now = now + j - (y - 1)
            ans[now - 1] += 1

        elif(i >= y - 1):
            ans[j - i - 1] += 1

print(*ans,sep="\n")

### FIXED CODE ###

n, x, y = input().split(" ")
n, x, y = int(n), int(x), int(y)
ans = [0] * (n - 1)

for i in range(n - 1):
    for j in range(i + 1, n):
        now = 0
        if (j <= x - 1):
            ans[j - i - 1] += 1

        elif(j > x - 1 and j <= y - 1 and i <= x - 1):
            now = now + x - 1 - i
            if (j - (x - 1) >= (y - 1) - j + 1):
                now = now + (y - 1) - j + 1
            else:
                now = now + j - (x - 1)
            ans[now - 1] += 1

        elif(j > x - 1 and j <= y - 1 and i > x - 1):
            if (j - i >= (i - (x - 1)) + ((y - 1) - j) + 1):
                now = (i - (x - 1)) + ((y - 1) - j) + 1
            else:
                now = j - i
            ans[now - 1] += 1

        elif(j > y - 1 and i <= x - 1):
            now = now + x - 1 - i
            now = now + j - (y - 1) + 1
            ans[now - 1] += 1

        elif(j > y - 1 and i > x - 1 and i < y - 1):
            if((y - 1) - i >= i - (x - 1) + 1):
                now = now + i - (x - 1) + 1
            else:
                now = now + (y - 1) - i
            now = now + j - (y - 1)
            ans[now - 1] += 1

        elif(i >= y - 1):
            ans[j - i - 1] += 1
print(*ans)
### BUGGY CODE ###

n = int(input())
li = list(map(int,input().split()))
ans = 0
for i in range(1,n):
    while li[i]<li[i-1]:
        li[i] +=1
        ans+=1
print(ans)

### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))
ma = 0
ans = 0
for i in range(n):
    if li[i]>ma:
        ma = li[i]
    else:
        ans+=ma-li[i]
print(ans)