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

import numpy as np

N,K = map(int,input().split())
A = np.sort(list(map(int,input().split())))
F = np.sort(list(map(int,input().split())))[::-1]

Amax = A[-1]
Fmax = F[0]

x=0
if sum(A) < K:
    x = 0
else:
    xl = 0
    xh = Amax*Fmax
    while xh-xl > 0:
        xm = int((xl+xh)//2)
        if sum(max(A[i]-xm//F[i] ,0) for i in range(0,N)) > K: 
            xl = xm + 1
        else: 
            xh = xm
    else:
        x = xl
print(x)            


### FIXED CODE ###

import numpy as np

N,K = map(int,input().split())
A = np.sort(list(map(int,input().split())))
F = np.sort(list(map(int,input().split())))[::-1]

Amax = A[-1]
Fmax = F[0]

x=0
if sum(A) < K:
    x = 0
else:
    xl = 0
    xh = Amax*Fmax
    while xh-xl > 0:
        xm = int((xl+xh)//2)
        AF = A-xm//F 
        if np.sum(AF[AF>0]) > K: 
            xl = xm + 1
        else: 
            xh = xm
    else:
        x = xl
print(x)
### BUGGY CODE ###

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

if N % 2:
    if A.count(0) != 1:
        flg = 0
    else:
        if all(j % 2 == 0 for j in A):
            if all(A.count(i) == 2 for i in range(2, N, 2)):
                flg = 1
            else:
                flg = 0
        else:
            flg = 0
else:
    if all(j % 2 for j in A):
        if all(A.count(i) == 2 for i in range(1, N, 2)):
            flg = 1
        else:
            flg = 0
    else:
        flg = 0

if flg:
    ans = 1
    for i in range(N//2):
        ans *= 2
        ans %= 10**9 + 7
else:
    ans = 0

print(ans)


### FIXED CODE ###

from collections import Counter

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

flg = 0
if N % 2:
    if c[0] != 1:
        flg = 1
    else:
        for i in range(2, N, 2):
            if c[i] != 2:
                flg = 1
                break
else:
    for i in range(1, N, 2):
        if c[i] != 2:
            flg = 1
            break

if flg:
    ans = 0
else:
    ans = 2 ** (N//2) % (10**9+7)

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

import numpy as np
import sys
input = sys.stdin.readline


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

if K >= N:
    print('0')
else:
    for i in range(K):
        H[np.argmax(H)] = 0
    print(sum(H))


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

if K >= N:
    print('0')
else:
    del(H[0:K])
    print(sum(H))
### BUGGY CODE ###

s = list(input())
s=[int(i) for i in s]

from collections import defaultdict
import copy
d=defaultdict(int)
ans=0
for i in range(len(s)):
    newd=defaultdict(int)
    now=s[i]
    for k in d.keys():
        newd[(k*10+now)%2019]+=d[k]
    newd[now]+=1
    ans+=newd[0]
    d=copy.deepcopy(newd)

print(ans)

### FIXED CODE ###

s=list(input())
s=[int(i) for i in s]
now=0
c=[0]*2019
c[0]=1
for n,i in enumerate(s[::-1]):
    now+=i*pow(10,n,2019)
    c[now%2019]+=1
ans=0
for k in range(2019):
    ans+=c[k]*(c[k]-1)//2
print(ans)
### BUGGY CODE ###

H, W = map(int, input().split())

while True:
    if (H + W == 0) : break
    
    for i in range(H):
        print('#' * W)

    print("")



### FIXED CODE ###

while True:
    H, W = map(int, input().split())

    if (H + W == 0) : break
    
    for i in range(H):
        print('#' * W)

    print()
### BUGGY CODE ###

K=int(input())
a=0
b=0
i=0
if K%2==0:
  print(-1)
else:
  while True:
    a=10**i
    b=b+7*a
    i+=1
    if b%K==0:
      print(i)
      break

### FIXED CODE ###

K=int(input())
i=1
if K%2==0 or K%5==0:
  print(-1)
elif K%7==0:
  L=9*K/7
  b=10
  while True:
    b=b%L
    if b==1:
      print(i)
      break
    b=b*10
    i+=1
else:
  L=9*K
  b=10
  while True:
    b=b%L
    if b==1:
      print(i)
      break
    b=b*10
    i+=1
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
if n >= 666:
    ans = 2
elif n >= 27:
    ans = 1
else:
    ans = 0

for i in range(1,n//2+1)[::-1]:
    if i == ans:
        print(ans)
        quit()
    d = deque([])
    for j in range(i,n-i+1):
        d.append(s[j:j+i])
    for j in range(n-2*i+1):
        tmp = s[j:j+i]
        ll = len(d)
        for k in range(ll):
            ddd = d.popleft()
            if tmp == ddd:
                print(i)
                quit()
            d.append(ddd)
        d.popleft()
print(0)



### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
s = input()
def z_algo(S):
    N = len(S)
    A = [0] * N
    i = 1; j = 0
    A[0] = l = N
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
res = 0
for i in range(n):
    c = z_algo(s[i:])
    # print(c)
    for j,t in enumerate(c):
        tmp = min(j,t)
        res = max(res, tmp)
print(res)
### BUGGY CODE ###

a, b, c, d = map(int, input().split())
if a > 0 and b > 0 and c > 0 and d > 0:
  print(max(a,b)*max(c,d))
elif a == 0 or b == 0 or c == 0 or d == 0:
  print(max([a*c, a*d, b*c, b*d]))
else:
  res = []
  for i in range(a, b+1):
    for j in range(c, d+1):
      res.append(i*j)
  print(max(res))

### FIXED CODE ###

a, b, c, d = map(int, input().split())
print(max([a*c, b*c, a*d, b*d]))
### BUGGY CODE ###

import collections
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
ans = 0
for k, v in c.items():
    if v > 1:
        ans += combinations_count(v, 2)
total_ans = ans

memo = {}
for k_ball in A:
    if k_ball in set(memo.keys()):
        print(memo[k_ball])
    elif c[k_ball] > 2:
        memo[k_ball] = total_ans - (
            combinations_count(c[k_ball], 2) - combinations_count(c[k_ball] - 1, 2)
        )
        print(memo[k_ball])
    elif c[k_ball] > 1:
        memo[k_ball] = total_ans - 1
        print(memo[k_ball])
    else:
        memo[k_ball] = total_ans
        print(memo[k_ball])

### FIXED CODE ###

# 解き直し
import collections

N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)

total = 0
for v in c.values():
    total += v * (v - 1) // 2

for k_ball in A:
    cnt = c[k_ball]
    print(total - (cnt * (cnt - 1) // 2) + ((cnt - 1) * (cnt - 2) // 2))
### BUGGY CODE ###

#!/usr/bin/env python

import sys

s= sys.stdin.readline().strip()
#
MOD=10**9+7
#
base = 1
dp= [ 0 for i in range(13) ]
dp[0] = 1
tmp= [ 0 for i in range(13) ]
for i,c in enumerate(reversed(s)):
    tmp  = dp.copy()
    #
    if c=="?":
        for b in [ base*i for i in range(1,10) ]:
            for m,num in enumerate(tmp):
                if num==0: continue
                idx= (m+b)%13
                dp[idx]= dp[idx]+num
        #
        for i in range(13): dp[i] %= MOD
    else:
        b= base*int(c)
        for m in range(13):
            idx= (m+b)%13
            dp[idx]= tmp[m]
    #
    base = base*10
#
print(dp[5])


### FIXED CODE ###

import sys
 
s= sys.stdin.readline().strip()
#
MOD=10**9+7
mmap= []
for i in range(6):
    b = 10**i % 13
    mmap.append( [ [ (b*i+j)%13 for i in range(1,10) ] for j in range(13) ] )
#
dp= [ 0 ] * 13
dp[0] = 1
j= 0
for c in reversed(s):
    tmp = dp.copy()
    #
    if c=="0": pass
    elif c=="?":
        bset = mmap[j]
        for m,num in enumerate(tmp):
            if num==0: continue
            for idx in bset[m]: dp[idx]+=num
        #
        for i in range(13): dp[i]%=MOD
    else:
        b= mmap[j][0][int(c)-1]
        for m in range(13):
            idx= (m+b)%13
            dp[idx]= tmp[m]
    #
    if j==5: j=0
    else: j+=1
#
print(dp[5])
### BUGGY CODE ###

import sys

for i in sys.stdin:
    lst = i.split(' ')
    n = 1
    while n <= lst[0]:
        lst = map(int, lst)
        if lst[0]%n == 0 and lst[1]%(lst[0]/n) == 0:
            print lst[0]/n
            break
        n = n+1
    else:
        print 1
    sys.exit(0)

### FIXED CODE ###

import sys                                               
for i in sys.stdin:
    lst = i.split(' ')
    lst = map(int, lst)
    lst.sort()

    n = 1
    maxn = 1
    while n*n <= lst[0]:
        if lst[0]%n == 0 and lst[1]%(lst[0]/n) == 0:
            print lst[0]/n
            break
        elif lst[0]%n == 0 and lst[1]%n == 0:
            maxn = n
        n = n+1
    else:
        print maxn
    sys.exit(0)
### BUGGY CODE ###

H,W,D = map(int,input().split())

pos = [0]*(H*W)
for j in range(H):
  A = list(map(int,input().split()))
  for i in range(W):
    pos[A[i]-1] = (i,j)
#print(link)

memo = [0]*(H*W)
for x0 in range(H*W):
  for x in range(x0+D,H*W,D):
    i,j = pos[x-D][0],pos[x-D][1]
    u,v = pos[x  ][0],pos[x  ][1]
    memo[x] = memo[x-D]+abs(i-u)+abs(j-v)

Q = int(input())
for _ in range(Q):
  L,R = map(int,input().split())
  print(memo[R-1]-memo[L-1])


### FIXED CODE ###

H,W,D = map(int,input().split())

pos = [0]*(H*W)
for j in range(H):
  A = list(map(int,input().split()))
  for i in range(W):
    pos[A[i]-1] = (i,j)
#print(link)

memo = [0]*(H*W)
for x in range(H*W):
  if x<D:
    continue
  i,j = pos[x-D][0],pos[x-D][1]
  u,v = pos[x  ][0],pos[x  ][1]
  memo[x] = memo[x-D]+abs(i-u)+abs(j-v)

Q = int(input())
for _ in range(Q):
  L,R = map(int,input().split())
  print(memo[R-1]-memo[L-1])
### BUGGY CODE ###

a,b=map(int,input().split())
i=1
small = min(a,b)
ab=[]
j=0
while i <= small :
    if b%i==0 and a%i==0 :
        flag = 0
        j=0
        while j < len(ab):
            if ab[j]!=1 and i % ab[j] == 0:
                flag=1
                break
            j+=1
        if flag == 0:
            ab.append(i)

    i+=1


print(len(ab))

### FIXED CODE ###

def main():
    x,y = map(int,input().split())
    tmp = [1]
    i = 2
    ans = 0
    # if x == y:
    #     ans += 1
    # a = factorization(x)
    # print(a)
    tempx = x

    for i in range(2, int(-(-x**0.5//1))+1):
        if tempx % i == 0:
            tmp.append(i)
            while tempx % i == 0:

                tempx //= i
    if tempx!=1:
        tmp.append(tempx)
    # print(tmp)

    for i,a in enumerate(tmp):
        if y % a == 0:
            tmp[i] = 1
        else:
            tmp[i] = 0
    print(sum(tmp))


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

def resolve():
    a, b = map(int, input().split())
    d = []
    for i in range(2, min(a, b) + 1):
        if any([i % di == 0 for di in d]):
            continue
        elif a % i == 0 and b % i == 0:
            d.append(i)
    d.append(1)
    print(len(d))


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    a, b = map(int, input().split())
    div_a = set(prime_factorize(a))
    div_b = set(prime_factorize(b))
    print(len(div_a & div_b) + 1)
    # print(div_a)
    # print(div_b)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


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

N, M = list(map(int, input().split()))
start = []
end = []
for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1 or b == 1:
        start.append(a*b)
    if a == N or b == N:
        end.append(a * b / N)
flag = 0
for i in start:
    if i in end:
        flag = 1

if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


### FIXED CODE ###

N, M = list(map(int, input().split()))
start = set([])
end = set([])
for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1 or b == 1:
        start.add(a*b)
    if a == N or b == N:
        end.add(a * b / N)
flag = 0
for i in start:
    if i in end:
        print("POSSIBLE")
        flag = 1
        break
if not(flag):
    print("IMPOSSIBLE")
### BUGGY CODE ###

import sys

s = input()
if len(s) < 4:
    print('0')
    sys.exit()
cnt = 0

for h in range(len(s)-4):
    for e in range(h+4, len(s)+1):
        if int(s[h:e]) % 2019 == 0:
            cnt += 1

print(cnt)

### FIXED CODE ###

s = input()[::-1] # 右からn桁の数についてループを回していきたいので、文字列を反転させる

sum_of_digits = 0 # 余りの値
cnts = [0] * 2019 # 余りの値ごとに余りが同じ値の数を格納する変数。2019で割る場合、余りは0~2018までの2019通りあるので、リストの長さは2019
cnts[0] = 1 # ※1
d = 1 # sum_of_digitsの計算に使う10の累乗値

# まず余りの値ごとに余りが同じ値の数を数える
for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019 # ※2
    cnts[sum_of_digits] += 1

# 次に余りの値ごとにその組み合わせを計算し、足し合わせる
ans = 0
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

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

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

#n,k,*a = map(int,read().split())
n, = map(int,readline().split())
vw = [[0,0]]+[list(map(int,readline().split())) for _ in range(n)]

#print(vw)
A = 9
N = min(1<<A,n+1)

memo = [None for _ in range(N)]
L = 10**5+1
memo[0] = [0]*L

from itertools import accumulate

for i in range(1,N):
    m = memo[i>>1][:]
    v,w = vw[i]    
    for j in range(L-1,w-1,-1):
        if m[j] < m[j-w]+v:
            m[j] = m[j-w]+v
    memo[i] = list(accumulate(m,max))


q, = map(int,readline().split())
for _ in range(q):
    u,l = map(int,readline().split())

    dic = [(0,0)]
    while u >= N:
        dic += [(vw[u][1]+w1,vw[u][0]+v1) for w1,v1 in dic]
        u >>= 1
    
    ans = 0
    for w,v in dic:
        if w <= l:
            ans = max(ans,memo[u][l-w]+v)
    print(ans)

        


### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

#n,k,*a = map(int,read().split())

n, = map(int,readline().split())
vw = [[0,0]]+[list(map(int,readline().split())) for _ in range(n)]

def merge(av,aw,bv,bw):
    la,lb = len(aw),len(bw)
    rv = [0]*(la+lb)
    rw = [0]*(la+lb)
    ia = ib = 0
    for i in range(la+lb):
        if ib==lb or (ia < la and aw[ia] < bw[ib]):
            rv[i] = av[ia]
            rw[i] = aw[ia]
            ia += 1
        else:
            rv[i] = bv[ib]
            rw[i] = bw[ib]
            ib += 1
    return rv,rw

A = 10
N = min(1<<A,n+1)
memov = [[] for _ in range(N)]
memow = [[] for _ in range(N)]

memov[0] = [0]
memow[0] = [0]

#from itertools import acumulate
for i in range(1,N):
    v,w = vw[i]
    m2v = [v+v1 for v1 in memov[i>>1]]
    m2w = [w+w1 for w1 in memow[i>>1]]
    memov[i],memow[i] = merge(memov[i>>1],memow[i>>1],m2v,m2w)

    #memov[i] = list(accumulate(memov[i],max))
    for j in range(1,len(memov[i])):
        memov[i][j] = max(memov[i][j-1],memov[i][j])
    
def solve(lstv,lstw,dv,dw,l):
    ans = 0
    idx = len(lstw)-1
    #print(lstv,lstw,dv,dw,l)
    for v,w in zip(dv,dw):
        while idx >= 0 and lstw[idx] + w > l:
            idx -= 1
        if idx >= 0 and v+lstv[idx] > ans:
            ans = v+lstv[idx]
    print(ans)        
 
 

q, = map(int,readline().split())
for _ in range(q):
    u,l = map(int,readline().split())

    dv = [0]
    dw = [0]
    while u >= N:
        v,w = vw[u]
        m2v = [v+v1 for v1 in dv]
        m2w = [w+w1 for w1 in dw]
        dv,dw = merge(dv,dw,m2v,m2w)
        u >>= 1
    
    #for j in range(1,len(dv)):
    #    dv[j] = max(dv[j-1],dv[j])
    
    solve(memov[u],memow[u],dv,dw,l)

#print(memov)
#print(memow)
### BUGGY CODE ###

h, w, d = map(int, input().split())
A = []
for _ in range(h):
    a = list(map(int, input().split()))
    A.append(a)

q = int(input())
LR = []
for _ in range(q):
    l, r = map(int, input().split())
    LR.append([l,r])

Inds = []
for i in range(h*w):
    for j in range(h):
        for k in range(w):
            if A[j][k] == i+1:
                Inds.append([j,k])
# print(Inds)

for lr in LR:
    l = lr[0]
    r = lr[1]
    now = l
    ans = 0
    while now < r:
        # print('y is' + str(Inds[now-1][0]))
        # print('x is' + str(Inds[now-1][1]))
        ans += abs(Inds[now-1][0]-Inds[now+d-1][0]) + abs(Inds[now-1][1]-Inds[now+d-1][1])
        now += d
    print(ans)

### FIXED CODE ###

h, w, d = map(int, input().split())
A = []
for _ in range(h):
    a = list(map(int, input().split()))
    A.append(a)

q = int(input())
LR = []
for _ in range(q):
    l, r = map(int, input().split())
    LR.append([l,r])

Inds = {x:[] for x in range(1, h*w+1)}
for j in range(h):
    for k in range(w):
        Inds[A[j][k]].append(j)
        Inds[A[j][k]].append(k)

Dist = [-1 for _ in range(h*w+1)]
for i in range(1,h*w+1):
    if i <= d:
        Dist[i] = 0
    else:
        Dist[i] = Dist[i-d] + abs(Inds[i][0]-Inds[i-d][0]) + abs(Inds[i][1]-Inds[i-d][1])

for lr in LR:
    ans = Dist[lr[1]] - Dist[lr[0]]
    print(ans)
### BUGGY CODE ###

n = int(input())
s = [1 if x == 'W' else 0 for x in list(input())]
print(min([sum(s[:i]) + (n-i-1) - sum(s[i+1:]) for i in range(n)]))


### FIXED CODE ###

n = int(input())
ls = [(0, 0) for _ in range(n)]
s = list(input())
sum_ls = {}

for i in range(n):
    if i == 0:
        w = 0
        e = s[i+1:].count('E')
        sum_ls[i] = (w, e)
    else:
        _w, _e = sum_ls[i - 1]
        if s[i] == 'W':
            if s[i-1] == 'W':
                sum_ls[i] = (_w+1, _e)
            else:
                sum_ls[i] = (_w+1, _e-1)
        else:
            if s[i-1] == 'W':
                sum_ls[i] = (_w, _e)
            else:
                sum_ls[i] = (_w, _e-1)

print(min([sum(v) for v in sum_ls.values()]))
### BUGGY CODE ###

#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h,w = LI()
    a = LIR(h)
    b = LIR(h)
    for i in range(h):
        for j in range(w):
            a[i][j] -= b[i][j]
            if a[i][j] < 0:
                a[i][j] *= -1
    f = defaultdict(lambda : set({}))
    f[(0,0)].add(a[0][0])
    d = [(0,1),(1,0)]
    for y in range(h):
        for x in range(w):
            for t in f[(y,x)]:
                for dy,dx in d:
                    ny = y+dy
                    nx = x+dx
                    if 0 <= ny < h and 0 <= nx < w:
                        nt = t-a[ny][nx]
                        f[(ny,nx)].add(nt)
                        nt = t+a[ny][nx]
                        f[(ny,nx)].add(nt)
    ans = min([abs(i) for i in f[(h-1,w-1)]])
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h,w = LI()
    a = LIR(h)
    b = LIR(h)
    for i in range(h):
        for j in range(w):
            a[i][j] -= b[i][j]
            if a[i][j] < 0:
                a[i][j] *= -1
    d = [(0,1),(1,0)]
    f = [0 for x in range(w)]
    M = (1<<25600)-1
    b = 12800
    f[0] = (1<<(b+a[0][0]))|(1<<(b-a[0][0]))
    for y in range(h):
        ny = y+1
        nf = [0 for x in range(w)]
        for x in range(w):
            nx = x+1
            if nx < w:
                f[nx] |= ((f[x]<<a[y][nx])|(f[x]>>a[y][nx]))
            if ny < h:
                nf[x] |= ((f[x]<<a[ny][x])|(f[x]>>a[ny][x]))
        if ny < h:
            f = [i for i in nf]
    ans = bin(f[w-1])[2:]
    ans = [abs(i-b) for i in range(len(ans)) if ans[len(ans)-i-1] == "1"]
    print(min(ans))
    return

#Solve
if __name__ == "__main__":
    solve()
### BUGGY CODE ###

from collections import defaultdict
N = int(input())
S = input()
d = defaultdict(lambda:[0,0])

for i in range(N):
    s = S[i]
    d[s][0] += 1
    d[s][1] = i
    for j in range(i+1,N):
        s = s+S[j]
        if i>d[s][1]:
            d[s][0] += 1
            d[s][1] = j

ans = 0
for s in d:
    if d[s][0]>=2:
        ans = max(ans,len(s))

print(ans)

### FIXED CODE ###

def Z(S):
    res = [0]*len(S)
    res[0] = len(S)
    i = 1
    j = 0
    while i < len(S):
        while i+j < len(S) and S[j] == S[i+j]:
            j += 1
        res[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < len(S) and k+res[k] < j:
            res[i+k] = res[k]
            k += 1
        i += k
        j -= k
    return res

from collections import defaultdict
N = int(input())
S = input()
ans = 0
for i in range(N):
    s = S[i:]
    z = Z(s)
    for j in range(len(z)):
        z[j] = min(j,z[j])
    ans = max(ans,max(z))

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

from scipy.misc import comb

N = int(input())
num_list = list(map(int, input().split()))
num_set = set(num_list)
num_dict = {}

for i in num_set:
  num_dict[i] = num_list.count(i)

# 全数あるときの組み合わせ
ans_dict_1 = {}
# 1個抜いたときの組み合わせ
ans_dict_2 = {}

for k, v in num_dict.items():
  ans_dict_1[k] = comb(v,2,exact=True)
  ans_dict_2[k] = comb(v-1,2,exact=True)

total = sum(ans_dict_1.values())

for i in num_list:
  print(total - ans_dict_1[i] + ans_dict_2[i])

### FIXED CODE ###

from scipy.misc import comb
from collections import Counter
import datetime

N = int(input())
num_list = list(map(int, input().split()))
# num_set = set(num_list)
num_dict = {}

num_counter = Counter(num_list)
  
# 全数あるときの組み合わせ
ans_dict_1 = {}
# 1個抜いたときの組み合わせ
ans_dict_2 = {}
rap_2 = datetime.datetime.now()
for k, v in num_counter.most_common():
  ans_dict_1[k] = comb(v,2,exact=True)
  ans_dict_2[k] = comb(v-1,2,exact=True)

total = sum(ans_dict_1.values())

for i in num_list:
  print(total - ans_dict_1[i] + ans_dict_2[i])