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

import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
INF = 500000
mod = 10**9+7

def primes(n):
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1, int(n**0.5)//3+1):
        if sieve[i]:
            k = 3*i+1|1
            sieve[k*k//3::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2, 3] + [3*i+1|1 for i in range(1, n//3-correction) if sieve[i]]

N = int(input())
A = [int(x) for x in input().split()]
ps = primes(int(max(A)**0.5)+1)
dic = defaultdict(lambda : 0)
for a in A:
    for i in ps:
        if a < i:
            break
        if a % i == 0:
            c = 0
            while a % i == 0:
                c += 1
                a //= i
            if dic[i] < c:
                dic[i] = c
    if a > 1 and dic[a] == 0:
        dic[a] = 1
MAX = 1
for k in dic:
    MAX *= pow(k, dic[k])
ans = 0
for a in A:
    ans += MAX//a
    ans %= mod
print(ans)


### FIXED CODE ###

import sys
# sys.setrecursionlimit(1000000)
input = sys.stdin.readline
# from bisect import *
from collections import *
# from heapq import *
# INF = 500000
mod = 10**9+7

def primes(n):
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1, int(n**0.5)//3+1):
        if sieve[i]:
            k = 3*i+1|1
            sieve[k*k//3::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2, 3] + [3*i+1|1 for i in range(1, n//3-correction) if sieve[i]]

N = int(input())
A = [int(x) for x in input().split()]
ps = primes(int(max(A)**0.5)+1)
dic = defaultdict(lambda : 0)
for a in A:
    for i in ps:
        if a < i:
            break
        if a % i == 0:
            c = 0
            while a % i == 0:
                c += 1
                a //= i
            if dic[i] < c:
                dic[i] = c
    if a > 1 and dic[a] == 0:
        dic[a] = 1
MAX = 1
for k in dic:
    MAX = MAX * pow(k, dic[k], mod) % mod
ans = 0
for a in A:
    ans += MAX * pow(a, mod-2, mod)
    ans %= mod
print(ans)
### BUGGY CODE ###

nm = input().split()
n = int(nm[0])
m = int(nm[1])
X = input().split()
Y = input().split()
X = map(int, X)
X = list(X)
Y = map(int, Y)
Y = list(Y)
S = 0
for i in range(n - 1):
	x1 = X[i]
	x2 = X[i + 1]
	for j in range(m - 1):
		s = (x2 - x1) * (Y[j + 1] - Y[j])
		s = (i + 1) * (n - i - 1) * (j + 1) * (m - j - 1) * s
		S += s
ans = S % 1000000007
print(ans)

### FIXED CODE ###

#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	x = getlist()
	y = getlist()
	X = 0
	Y = 0
	for i in range(N - 1):
		X += ((x[i + 1] - x[i]) * (i + 1) * (N - i - 1)) % con
		X %= con
	for i in range(M - 1):
		Y += ((y[i + 1] - y[i]) * (i + 1) * (M - i - 1)) % con
		Y %= con
	print(X * Y % con)


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

N, X, Y = map(int, input().split())
# グラフの作成 数字が小さい方から大きい方への有向グラフ
g = [[i-1, i+1] for i in range(N)]
g[0].remove(-1)
g[N-1].remove(N)
g[X-1].append(Y-1)
g[Y-1].append(X-1)
#print(g)

ans_list = [0] * N
# 各頂点からの最短経路長を計算
for i in range(N):
    queue = g[i]
    seen = [False] * N
    length = 0
    while queue:
        length += 1
        #print("now length:", length, queue)
        add = []
        for qi in queue:
            if seen[qi] == False:
                if i < qi:
                    ans_list[length] += 1
                seen[qi] = True
                add += g[qi]
                #print("add,", g[qi])
        queue = list(set(add))
        #print(queue)

# 答えの出力
for k in range(1, N):
    print(ans_list[k])


### FIXED CODE ###

N, X, Y = map(int, input().split())
# グラフの作成 数字が小さい方から大きい方への有向グラフ
g = [[i-1, i+1] for i in range(N)]
g[0].remove(-1)
g[N-1].remove(N)
g[X-1].append(Y-1)
g[Y-1].append(X-1)

ans_list = [0] * N
# 各頂点からの最短経路長を計算
for i in range(N):
    queue = g[i]
    seen = [False] * N
    length = 0
    while queue:
        length += 1
        add = []
        for qi in queue:
            if seen[qi] == False:
                if i < qi:
                    ans_list[length] += 1
                seen[qi] = True
                add += g[qi]
        queue = list(set(add))

# 答えの出力
for k in range(1, N):
    print(ans_list[k])
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
triangle = 0
while len(l) >= 3:
  max_l = l.pop()
  for i in range(1, len(l)):
    rest_l = max_l - l[i]
    if rest_l >= l[i - 1]:
      continue
    for j in range(i):
      if l[j] > rest_l:
        triangle += i - j
        break
print(triangle)


### FIXED CODE ###

from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()
triangle = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    index = bisect_left(l, l[i] + l[j], j + 1, n) - 1
    triangle += index - j
print(triangle)
### BUGGY CODE ###

import sys
from collections import Counter
from itertools import product

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N = int(input())
    S = input().rstrip()

    c = Counter(S)
    values = list(c.values())
    ans = -1
    for comb in product(range(2), repeat=len(values)):
        res = 1
        for i, c in enumerate(comb):
            if c == 1:
                res = (res * values[i]) % P
        ans = (ans + res) % P

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import Counter

input = sys.stdin.readline
P = 10**9 + 7


def main():
    N = int(input())
    S = input().rstrip()

    # Editorial AC
    c = Counter(S)
    ans = 1
    for v in c.values():
        ans = (ans * (v + 1)) % P
    ans = (ans - 1) % P

    print(ans)


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

n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))


def exhaustivesearch(i, target):
    if target == 0:
        return True
    if i >= n:
        return False
    ans = exhaustivesearch(i + 1, target) or exhaustivesearch(i + 1, target-A[i])
    return ans


for j in m:
    if exhaustivesearch(0, j):
        print("yes")
    else:
        print("no")

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
memo = [[None]*2000 for i in range(2000)]


def exhaustivesearch(i, target):
    if memo[i][target] is not None:
        return memo[i][target]
    if target == 0:
        memo[i][target] = True
        return True
    if i >= n:
        memo[i][target] = False
        return False
    else:
        memo[i][target] = exhaustivesearch(i + 1, target) or exhaustivesearch(i + 1, target-A[i])
        return memo[i][target]


for j in m:
    if exhaustivesearch(0, j):
        print("yes")
    else:
        print("no")
### BUGGY CODE ###

N = int(input())
A = tuple(map(int,input().split()))
S = ''

for i in range(N):
    n = A.index(i+1)
    S += str(n+1) + ' '

print(S.lstrip(' '))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
O = [0] * N

for i , a  in enumerate(A): #リストAのインデックスiと値a
    O[a-1] = i+1

print(*O)
### BUGGY CODE ###

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

X, Y = [], []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

ans = float('INF')

for left in range(N):
    for right in range(N):
        for top in range(N):
            for bottom in range(N):
                if X[right]-X[left] <= 0:
                    continue
                if Y[top]-Y[bottom] <= 0:
                    continue
                cnt = 0
                for i in range(N):
                    if X[left] <= X[i] <= X[right] and Y[bottom] <= Y[i] <= Y[top]:
                        cnt += 1
                if cnt >= K:
                    ans = min(ans, (X[right]-X[left])*(Y[top]-Y[bottom]))

print(ans)


### FIXED CODE ###

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

X, Y = [], []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

ans = float('INF')

for left in range(N):
    for right in range(N):
        for top in range(N):
            for bottom in range(N):
                if X[right]-X[left] <= 0:
                    continue
                if Y[top]-Y[bottom] <= 0:
                    continue
                cnt = 0
                for i in range(N):
                    if X[left] <= X[i] <= X[right] and Y[bottom] <= Y[i] <= Y[top]:
                        cnt += 1
                if cnt >= K:
                    ans = min(ans, (X[right]-X[left])*(Y[top]-Y[bottom]))

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

n=int(input())
a=list(map(int,input().split()))
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
from collections import defaultdict
d=defaultdict(int)
ans=0
for ai in a:
    b=make_divisors(ai)
    for bi in b:
        d[bi]+=1
        if d[bi]>=n-1:
            ans=max(ans,bi)
print(ans)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
from collections import defaultdict
d=defaultdict(int)
op=set(make_divisors(a[0])+make_divisors(a[1]))
next_op=set()
for i in range(n):
    for opi in op:
        if a[i]%opi==0:
            d[opi]+=1
        if d[opi]>=i:
            next_op.add(opi)
    op=next_op
    next_op=set()
print(max(op))
### BUGGY CODE ###

'''input
5 1
00010
'''


N, K=map(int,input().split())
Sstr=input()
# print(Sstr)
S=[]

for i in range(N):
	S.append(int(Sstr[i]))

# print(S)
# flip=0
# for i in range(N-1):
# 	flip+=abs(S[i+1]-S[i])
# print(flip)


now=1
cnt=0
Nums=[]
for i in range(N):
	if S[i]==now:
		cnt+=1
	else:
		Nums.append(cnt)
		now=1-now
		cnt=1

if cnt!=0:
	Nums.append(cnt)

if(len(Nums)%2==0):
	Nums.append(0)

Add=2*K+1
ans=0

for i in range(0, len(Nums), 2):
	tmp=0
	left=i
	right=min(i+Add, len(Nums))
	for j in range(left, right):
		tmp+=Nums[j]
	ans=max(tmp,ans)

print(ans)

### FIXED CODE ###

'''input
5 1
00010
'''


N, K=map(int,input().split())
Sstr=input()
# print(Sstr)
S=[]

for i in range(N):
	S.append(int(Sstr[i]))

# print(S)
# flip=0
# for i in range(N-1):
# 	flip+=abs(S[i+1]-S[i])
# print(flip)


now=1
cnt=0
Nums=[]
for i in range(N):
	if S[i]==now:
		cnt+=1
	else:
		Nums.append(cnt)
		now=1-now
		cnt=1

if cnt!=0:
	Nums.append(cnt)

if(len(Nums)%2==0):
	Nums.append(0)

Add=2*K+1
ans=0

left=0
right=0
tmp=0

for i in range(0, len(Nums), 2):
	# tmp=0
	Nextleft=i
	Nextright=min(i+Add, len(Nums))
	# for j in range(left, right):
	# 	tmp+=Nums[j]
	while(Nextleft>left):
		tmp-=Nums[left]
		left+=1
	while(Nextright>right):
		tmp+=Nums[right]
		right+=1
	
	ans=max(tmp,ans)

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

S = input()
N = len(S)
amari = [0 for i in range(2019)]
for i in range(N):
    amari[int(S[i : N]) % 2019] += 1
ans = amari[0]
for i in amari:
    ans += i * (i - 1) // 2
print(ans)


### FIXED CODE ###

S = input()[::-1]
N = len(S)
amari = [0 for i in range(2019)]
before = int(S[0])
amari[before] += 1
S = S[1::]
keta = 1
for i in S:
    i = int(i)
    keta = (keta * 10) % 2019
    x = (keta * i + before) % 2019
    amari[x] += 1
    before = x
ans = amari[0]
for i in amari:
    ans += i * (i - 1) // 2
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
N = len(a)
for k in range(N):
  a[k] //= 2


count = 0
foo = 1

while a[0]%2 == 0:
  foo *= 2
  a[0] // 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

def euclid(a, b):
  while b:
    a, b = b, a%b
  return a

a.sort()
lcm = a[0]
for k in range(1, N):
  lcm = lcm * a[k] // euclid(lcm, a[k])
  if lcm* foo > M:
    print(0)
    exit()
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
a = list(map(int, input().split()))
for k in range(N):
  a[k] //= 2

foo = 1
while a[0]%2 == 0:
  foo *= 2
  a[0] //= 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

import math
lcm = a.pop()
for k in range(1, N):
  b = a.pop()
  lcm = lcm * b // math.gcd(lcm, b)
  if lcm* foo > M:
    print(0)
    exit()
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)
### BUGGY CODE ###

import numpy as np

N = input()


for i in range(1,int(N)+1):
    count = 0
    if i > 3:
        maxa = int(np.sqrt(i-2))
        for x in range(1,maxa):
            for y in range(1,maxa):
                for z in range(1,maxa):
                    if x*x+y*y+z*z+x*y+y*z+z*x == i:
                        count +=1

    print(count)


### FIXED CODE ###

import numpy as np

N = int(input())

ans = np.zeros(int(N))

if N<10001 and N>3:
    maxa = int(np.sqrt(N-2))
    for x in range(1,maxa):
        for y in range(1,x):
            for z in range(1,y):
                p = x*x+y*y+z*z+x*y+y*z+z*x
                if p<N+1:
                    ans[p-1] += 6


    for x in range(1,maxa):
        for y in range(1,x):
            p = x*x*3+y*y+x*y*2
            if p<N+1:
                ans[p-1] += 3
            p = y*y*3+x*x+x*y*2
            if p<N+1:
                ans[p-1] += 3

    for x in range(1,maxa):
        p = x*x*6
        if p<N+1:
            ans[p-1] += 1

for x in range(0,N):
    print(int(ans[x]))
### BUGGY CODE ###

l,r=map(int,input().split())
if l-r>=2019:
    print(0)
    exit()
ans=2020
for i in range(l,r+1):
    for j in range(i+1,r+1):
        i,j=i%2019,j%2019
        ans=min((i*j)%2019,ans)
print(ans)

### FIXED CODE ###

l,r=map(int,input().split())
if r-l>=2019:
    print(0)
    exit()
ans=2020
for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans=min((i*j)%2019,ans)
print(ans)
### BUGGY CODE ###

S = list(input())
S = [int(i) for i in S]
c = 0
while True:
    OK,flag,break_flag = 0,0,0
    LOOP = len(S)-1
    for i in range(LOOP):
        if S[i] != S[i+1] and S[i] != 9:
            S[i],S[i+1] = 9,9
            OK += 1
        else:
            flag += 1
    if flag == LOOP:
        break_flag = 1
    if OK >= 1:
        for i in range(2*OK):
            S.remove(9)
            c += 1
    if break_flag == 1 or len(S) <= 1:
        break
print(c)

### FIXED CODE ###

S = list(input())
S = [int(i) for i in S]
one = 0
zero = 0
for i in range(len(S)):
    if S[i] == 1:
      one += 1
    elif S[i] == 0:
      zero += 1
print(len(S)-abs(one-zero))
### BUGGY CODE ###

import heapq

x, y, z, k = map(int, input().split())

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

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
c = c[:k]

e = []

cnt = 0
for va in a:
    for vb in b:
        heapq.heappush(e, -(va+vb))

d = []
while len(e):
    ve = -heapq.heappop(e)
    for vc in c:
        heapq.heappush(d, -(ve+vc))

for i in range(k):
    print(-heapq.heappop(d))

### FIXED CODE ###

import heapq

x, y, z, k = map(int, input().split())

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

e = []

for va in a:
    for vb in b:
        e.append(va+vb)

e.sort(reverse=True)
e = e[:k]

d = []
for ve in e:
    for vc in c:
        heapq.heappush(d, -(ve+vc))

for i in range(k):
    print(-heapq.heappop(d))
### BUGGY CODE ###

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

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

if N > B:
    for x in range(1,B+1):
        ans = (x % B) / B * A
        if ans > z:
            z = ans
else:
    for x in range(1,N+1):
        ans = (x % B) / B * A
        if ans > z:
            z = ans

print(int(z))

### FIXED CODE ###

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

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

if N >= B:
    x  = B - 1
    z = (A * x) // B - A * (x // B)
else:
    x = N
    z = (A * x) // B - A * (x // B)

print(int(z))
### BUGGY CODE ###

n = int(input())
arr = list(map(int, input().split()))
res = 0
for i in range(n):
    msum = 0
    if arr[i] != 0:
        for j in range(i+1, n):
            msum += arr[j]
        res += arr[i] * msum
res = res % (10**9 + 7)
print(res)
    


### FIXED CODE ###

def findProductSum(A, n): 
    array_sum = sum(A)
    array_sum_square = array_sum ** 2
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
    return (array_sum_square -
            individual_square_sum) // 2

n = input()
arr = list(map(int, input().split()))
res = findProductSum(arr, len(arr)) % (10**9 + 7)
print(res)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
def main():
    S = list(input())
    BW = {'B':[], 'W':[]}
    cnt = {'B':0, 'W':0}
    pre = S[0]
    cnt[pre] += 1
    for i in range(1, len(S)):
        now = S[i]
        if pre == now:
            cnt[pre] += 1
        else:
            BW[pre].append(cnt[pre])
            cnt[pre] = 0
            cnt[now] = 1
            pre = now
        # print(cnt)
        # print(BW)
    if cnt[pre] != 0:
        BW[pre].append(cnt[pre])

    if S[0] == 'W':
        BW['W'].pop(0)
    if S[-1] == 'B':
        BW['B'].pop(-1)
    ans = 0
    for i in range(len(BW['B'])):
        ans += sum(BW['B'][:i+1])*BW['W'][i]
    print(ans)
if __name__ == '__main__':
    main()

#PLAN1
    # S = list(input())
    # check = 0
    # cnt = 0
    # i = 0
    # while(check == 0) :
    #     check = 1
    #     for i in range(len(S)-1):
    #         if S[i] == 'B' and S[i+1] == 'W':
    #             S[i], S[i+1] = 'W', 'B'
    #             cnt += 1
    #             check = 0
    #             break
    # print(cnt)

# PLAN2
# S = list(input())
# state = 0
# CNT = 0
# while(state != 1):
# # for x in range(50):
#     first_W = 0
#     for i in range(len(S)):
#         if state == 0:
#             if S[i] == 'B':
#                 B_cnt = 1
#                 state = 1
#             else:
#                 first_W += 1
#         elif state == 1:
#             if S[i] == 'B':
#                 B_cnt += 1
#             else:
#                 W_cnt = 1
#                 state = 2
#         elif state == 2:
#             if S[i] == 'W':
#                 W_cnt += 1
#             else:
#                 state = 0
#                 break
#     # print(state)
#     if state == 2:
#         state = 0
#         S = ['W']*(W_cnt+first_W) + ['B']*B_cnt
#     else:
#         CNT += W_cnt*B_cnt
#         S = ['W']*(W_cnt+first_W) + ['B']*B_cnt + S[i:]
#     # print(S)
# print(CNT)

### FIXED CODE ###

# -*- coding: utf-8 -*-
def main():
    S = list(input())
    Bcnt = 0
    ans = 0
    for i in range(len(S)):
        if S[i] == 'B':
            Bcnt += 1
        else:
            ans += Bcnt
    print(ans)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

# 素数だったら1を返す
def prime_number(n):
    for x in range(2,n):
        if n%x==0:
            return 0
    return 1

ans=0
m=min(a,b)//2+2
for i in range(1,m):
    if a%i==0 and b%i==0:
        ans+=prime_number(i)

print(ans)


### FIXED CODE ###

import sys
read=sys.stdin.readline

A,B=map(int,read().split())

def factorization(n):
    arr=set([1])
    temp=n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.add(i)
    if temp!=1:
        arr.add(temp)
    if arr==[]:
        arr.add(n)
    return arr


print(len(factorization(A)&factorization(B)))
### BUGGY CODE ###


S = list(input())
a=[int(x) for x in S] #int型のリストに変換
a.reverse()
#print(a)
l=[0]*2019
l[0]=1
T=0
d=1

for i in a:
    T+=(int(i)*d)
    T%=2019
    l[T]+=1
    d*=10
result=0
for n in l:
    result+=n*(n-1)/2
print(int(result))


### FIXED CODE ###

S = list(input())
a=[int(x) for x in S] #int型のリストに変換
a.reverse()
#print(a)
l=[0]*2019
l[0]=1
T=0
d=1

for i in a:
    T+=(int(i)*d)
    T%=2019
    l[T]+=1
    d*=10
    d%=2019
result=0
for n in l:
    result+=n*(n-1)/2
print(int(result))
### BUGGY CODE ###

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

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    if i > 1:
        al[c] += i * (i-1) / 2
    c += 1

for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sum(al)-(al[f-1]-t*(t-1)/2)))
    


### FIXED CODE ###

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

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    if i > 1:
        al[c] += i * (i-1) / 2
    c += 1

sine = sum(al)
for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sine-(al[f-1]-t*(t-1)/2)))
### BUGGY CODE ###

N = int(input())
S = list(input())
r = []
g = []
b = []
for i in range(len(S)):
    if S[i] == 'R':
        r.append(i)
    elif S[i] == 'G':
        g.append(i)
    else:
        b.append(i)
lr = len(r)
lg = len(g)
lb = len(b)
cnt = 0
for i in range(lr):
    for j in range(lg):
        for k in range(lb):
            l, m, n = r[i], g[j], b[k]
            if 2*(l+m+n) != 3*(max(l,m,n)+min(l,m,n)):
                cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
S = list(input())
r = []
g = []
b = []
s = len(S)
for i in range(s):
    if S[i] == 'R':
        r.append(i)
    elif S[i] == 'G':
        g.append(i)
    else:
        b.append(i)
lr = len(r)
lg = len(g)
lb = len(b)
cnt = lr * lg * lb
for i in range(lr):
    for j in range(lg):
        r0 = r[i]
        g0 = g[j]
        up = max(r0,g0)+abs(r0-g0)
        dw = min(r0,g0)-abs(r0-g0)
        if up < s and S[up] == 'B':
            cnt -= 1
        if dw >= 0 and S[dw] == 'B':
            cnt -= 1
        if abs(r0-g0)%2 == 0:
            half = min(r0,g0) + abs(r0-g0)//2
            if 0 <= half < s and S[half] == 'B':
                cnt -= 1
print(cnt)
### BUGGY CODE ###

def c_marks():
    N, K = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    score = 1
    for a in A[:K]:
        score *= a

    ans = []
    for i in range(N - K):
        score_before = score
        score //= A[i]
        score *= A[i + K]
        ans.append('Yes' if score > score_before else 'No')
    return ' '.join(ans)

print(c_marks())

### FIXED CODE ###

def c_marks():
    N, K = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]
    ans = ['Yes' if A[i + K] > A[i] else 'No' for i in range(N - K)]
    return '\n'.join(ans)

print(c_marks())
### BUGGY CODE ###

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
 
cost = {}#[[float('inf')]*(m+1) for i in range(n+1)]
#Aからi冊、Bからｊ冊読むときにかかる時間がcost[i][j]
              
cost[(0,0)] = 0
max_count = 0
 
i = 0
while i<=n:
  j = 0
  while j<m:
    cost[(i,j+1)] = cost[(i,j)] + b[j]
    j += 1
    if cost[(i,j)]<=k:
      max_count = max(max_count,i+j)
    else:
      break
  if i == n:
    break
  cost[(i+1,0)] = cost[(i,0)] + a[i]
  i += 1
  if cost[(i,0)]<=k:
    max_count = max(max_count,i)
  else:
    break
print(max_count)

### FIXED CODE ###

def judge(num):
  if num>n+m:
    return False
  for i in range(max(0,num-m),min(n,num)+1):
    if a_cumsum[i] + b_cumsum[num-i]<=k:
      return True
  return False
 
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
 
a_cumsum = [0]
b_cumsum = [0]
for i in a:
  a_cumsum.append(a_cumsum[-1]+i)
for i in b:
  b_cumsum.append(b_cumsum[-1]+i)
  
left = 0
right = k+1
 
while right-left>1:
  mid = (right+left)//2
  
  if judge(mid):
    left = mid
  else:
    right = mid
 
print(left)