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

H, W = map(int, raw_input().split())
a = [raw_input().strip() for _ in xrange(H)]
a = map(''.join, zip(*a))
ans = 0
def solve(a, c):
    def shift(i, j):
        ans = 0
        for pos in xrange(max(i, j), H):
            if a[pos - i] == c[pos - j]:
                ans += 1
        return ans
    dp = [[float('inf')] * (H+1) for _ in xrange(H+1)]
    shift_ = [[None] * (H+1) for _ in xrange(H+1)]
    for i in xrange(H+1):
        for j in xrange(H+1):
            shift_[i][j] = shift(i, j)
    for i in xrange(H+1):
        for j in xrange(H+1):
            b = []
            if i == j == 0:
                b.append(0)
            if i > 0:
                b.append(dp[i-1][j] + shift_[i-1][j])
            if j > 0:
                b.append(dp[i][j-1] + shift_[i][j-1])
            dp[i][j] = min(b)
    #print a, c, shift_
    return dp[H][H]
for i in xrange(W-1):
    i1 = i
    i2 = i+1
    ans += solve(a[i1], a[i2])
print ans


### FIXED CODE ###

H, W = map(int, raw_input().split())
a = [raw_input().strip() for _ in xrange(H)]
a = map(''.join, zip(*a))
ans = 0
def solve(a, c):
    shift = [[0] * (H+1) for _ in xrange(H+1)]
    for i in reversed(xrange(H)):
        for j in reversed(xrange(H)):
            shift[i][j] = shift[i+1][j+1] + int(a[H-1-i] == c[H-1-j])
    dp = [[float('inf')] * (H+1) for _ in xrange(H+1)]
    for i in xrange(H+1):
        for j in xrange(H+1):
            b = 2147483647
            if i == j == 0:
                b = 0
            if i > 0:
                b = min(b, dp[i-1][j] + shift[i-1][j])
            if j > 0:
                b = min(b, dp[i][j-1] + shift[i][j-1])
            dp[i][j] = b
    #print a, c, shift
    return dp[H][H]
for i in xrange(W-1):
    i1 = i
    i2 = i+1
    ans += solve(a[i1], a[i2])
print ans
### BUGGY CODE ###

a = input()

a = int(a)

b = input().split(' ')

from itertools import combinations

comb = combinations(b, 3)

possible_triangles = 0

for i in list(comb):
    if int(i[0]) >= int(i[1]) + int(i[2]):
        continue
    if int(i[1]) >= int(i[0]) + int(i[2]):
        continue
    if int(i[2]) >= int(i[0]) + int(i[1]):
        continue
    possible_triangles += 1

print(possible_triangles)

### FIXED CODE ###

number_of_sticks = int(input())

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

sticks.sort()

triangles = 0

import bisect

for i in range (number_of_sticks - 2):
    for j in range (i+2, number_of_sticks):
        max_range = j
        min_range = max(bisect.bisect(sticks, sticks[j] - sticks[i]), i + 1)
        triangles += max_range - min_range

print(triangles)
### BUGGY CODE ###

import math
from functools import reduce

K = int(input())

gcd_sum = 0
target_range = range(1, K + 1)

for a in target_range:
  for b in target_range:
    for c in target_range:
      gcd_sum += reduce(math.gcd, (a, b, c))

print(gcd_sum)

### FIXED CODE ###

import math
from functools import reduce
import itertools

K = int(input())

gcd_sum = 0
target_range = range(1, K + 1)
for comb in itertools.combinations_with_replacement(target_range, 3):
  a, b, c = comb[0], comb[1], comb[2]
  gcd = reduce(math.gcd, comb)
  
  if a == b == c:
    gcd_sum += gcd
  elif a != b != c:
    gcd_sum += gcd * 6
  else:
    gcd_sum += gcd * 3


print(gcd_sum)
### BUGGY CODE ###

#Biscuits

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

import numpy as np

a = np.array(A)
f = 2**N-1
cnt = 0
for i in range(2**N):
    ff = np.array(list(map(int,list(format(f,'b').zfill(N)))))
    s = np.sum(ff * a)
    if ( s%2 == P ):
        cnt+=1
    f-=1
print (cnt)


### FIXED CODE ###

#Biscuits

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

#奇数の数
k = 0
for a in A:
    k += a%2
if ( k ==0 ):
    ans = (3-P)%2 * 2**N
else:
    ans = 2**(N-1)
print(ans)
### BUGGY CODE ###

MOD = 10 ** 9 + 7

def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    max_bin_digits = len(bin(max(A))[2:])
    cnts = [[0, 0] for _ in range(max_bin_digits)]

    for a in A:
        bin_a = bin(a)[2:].zfill(max_bin_digits)
        for i, b in enumerate(bin_a):
            cnts[-i-1][int(b)] += 1

    ans = 0
    for i in range(max_bin_digits):
        ans += cnts[i][0] * cnts[i][1] * 2 ** i
        ans %= MOD

    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

MOD = 10 ** 9 + 7

def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    max_bin_digits = len(bin(max(A))[2:])
    cnts = [0] * max_bin_digits

    for a in A:
        for i in range(max_bin_digits):
            if 1 << i & a:
                cnts[i] += 1

    ans = 0
    for i in range(max_bin_digits):
        ans += cnts[i] * (N - cnts[i]) * 2 ** i
        ans %= MOD

    print(ans)


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

import numpy as np

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

grid = [[False] * (w + 2)]
for _ in range(h):
    grid.append([False] + [x == '#' for x in input()] + [False])
grid.append([False] * (w + 2))

grid = np.array(grid)

cnt = 0
while True:
    # for i in range(1, h + 1):
    #     for j in range(1, w + 1):
    #         print('#' if grid[i, j] else '.', end='')
    #     print()
    if np.all(grid[1:-1, 1:-1]):
        break

    new_grid = grid.copy()
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if grid[i][j] == 0:
                if grid[i + 1, j] or grid[i, j + 1] or grid[i - 1, j] or grid[i, j - 1]:
                    new_grid[i][j] = 1
    grid = new_grid
    cnt += 1

print(cnt)


### FIXED CODE ###

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

grid = [[True] * (w + 2)]
for _ in range(h):
    grid.append([True] + [x == '#' for x in input()] + [True])
grid.append([True] * (w + 2))

q = []

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if grid[i][j] is True:
            q.append((i, j))

cnt = 0
while q:
    qq = []
    for i, j in q:
        if not grid[i + 1][j]:
            grid[i + 1][j] = True
            qq.append((i + 1, j))
        if not grid[i - 1][j]:
            grid[i - 1][j] = True
            qq.append((i - 1, j))
        if not grid[i][j + 1]:
            grid[i][j + 1] = True
            qq.append((i, j + 1))
        if not grid[i][j - 1]:
            grid[i][j - 1] = True
            qq.append((i, j - 1))

    cnt += 1
    q = qq

print(cnt - 1)
### BUGGY CODE ###

import math
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res

n = readInt()
a = readInts()

c=0
for i in range(0,n):
	for j in range(1,n):
		if j-i==a[i]+a[j]:
			c+=1

print(c)

### FIXED CODE ###

import math
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def pop2(li):
	c=1
	i=li.pop(0)
	while 1:
		j=li.pop(0)
		if j==i:
			c+=1
		else:
			break
	return i,c,[j]+li

n = readInt()
a = readInts()

li = []
ri = []

d1 = defaultdict(int)
d2 = defaultdict(int)

for i in range(n):
	d1[i+a[i]]+=1
	d2[i-a[i]]+=1

ans = 0

for key in d1:
	ans+=d1[key]*d2[key]

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

n = int(input())
A = list(map(int,input().split()))
q = int(input())
for i in range(q):
  a,b = map(int,input().split())
  for j in range(n):
    if A[j] == a:
      A[j] = b
  print(sum(A))
  

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
Q = int(input())
cnt = [0]*(10**5+1)
sumA = sum(A)
for a in A:
  cnt[a] += 1
        
for query in range(Q):
  b,c = map(int,input().split())
  sumA += cnt[b]*(c-b)
  cnt[c] += cnt[b]
  cnt[b] = 0
  print(sumA)
### BUGGY CODE ###

n = int(input())
a_list = list(map(int, input().split()))
a_list.sort()
a_max = a_list[-1]

dup_set = set(x for x in set(a_list) if a_list.count(x) > 1)
divisible = [False] * (a_max + 1)

count = 0
i = 0
for a in a_list:
    if divisible[a]:
        continue
    if not a in dup_set:
        count += 1
    x = a
    while x <= a_max:
        divisible[x] = True
        x += a
print(count)

### FIXED CODE ###

n = int(input())
a_list = list(map(int, input().split()))
a_list.sort()
a_max = a_list[-1]

divisible = [False] * (a_max + 1)

count = 0
i = 0
for i in range(n):
    if divisible[a_list[i]]:
        continue
    if i < n - 1 and a_list[i] == a_list[i + 1]:
        while i < n - 1 and a_list[i] == a_list[i + 1]:
            i += 1
    else:
        count += 1
    x = a_list[i]
    while x <= a_max:
        divisible[x] = True
        x += a_list[i]
print(count)
### BUGGY CODE ###

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

arr=[]
for i in b:
  arr+=[[i,a.count(i)]]

arr.sort(key=lambda x: x[1])

d=len(b)-k
cnt=0
for i in range(d):
  cnt+=arr[i][1]
print(cnt)

### FIXED CODE ###

import collections

n,k=map(int,input().split())
a=list(map(int,input().split()))
now_k=len(set(a))
d=now_k-k
arr=collections.Counter(a).most_common()
#print(arr)
b=sorted([arr[i][1] for i in range(now_k)])
#print(b)
cnt=now_k
cnt2=0
flg=0
for i in b:
  cnt-=1
  cnt2+=i
  if cnt==k:
    print(cnt2)
    flg=1
    break
if flg==0:
  print(0)
### BUGGY CODE ###

from sys import stdin

n = int(stdin.readline().rstrip())
an = list(map(int, input().split()))

sum = 0
for i in range(n-1):
    for j in range(i+an[i], n):
        if j-i == (an[i]+an[j]):
            sum += 1

print(sum)


### FIXED CODE ###

from sys import stdin

n = int(stdin.readline().rstrip())
an = list(map(int, input().split()))

l = {}
r = {}

for i in range(n):
    x = i + an[i]
    if x not in l:
        l[x] = [i]
    else:
        l[x].append(i)

    x = i - an[i]
    if x not in r:
        r[x] = [i]
    else:
        r[x].append(i)

sum = 0
for k in l:
    if k in r:
        sum += len(l[k])*len(r[k])

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

n = int(input())
a = [int(input()) for _ in range(n)]

count = 0
i = 0
while count <= 10e+7:
    count += 1
    if a[i] == 2:
        print(count)
        break
    else:
        i = a[i]-1
else:
    print(-1)

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]

count = 0
i = 0
while count <= 10e+5:
    count += 1
    if a[i] == 2:
        print(count)
        break
    else:
        i = a[i]-1
else:
    print(-1)
### BUGGY CODE ###

inputt = [input() for i in range(2)]
num = inputt[0]
listt = list(map(int, inputt[1].split()))

def hoge(listt):
  new_list = []
  for i in listt:
    if i % 2 == 0:
      new_list.append(i)
    else:
      return False
  return new_list

count = 0
while True:
  listt = hoge(listt)
  if listt == False:
    break
  count += 1

print(count)


### FIXED CODE ###

num = input()
listt = input().split()

def hoge(fuga):
    new_list = []
    for i in fuga:
        if int(i) % 2 == 0:
            new_list.append(int(i)/2)
        else:
            return False
    return new_list


count = 0
while True:
    listt = hoge(listt)
    if listt == False:
        break
    count += 1

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

import itertools
given_n = int(input())
given_A = list(map(int,input().split()))
given_q = int(input())
given_m = list(map(int,input().split()))

for mi in given_m:
    partial_A = list(filter(lambda ai:ai<=mi,given_A))
    check = False
    for num in range(1,len(partial_A)+1):
        combinationPartialA = list(itertools.combinations(partial_A,num))
        for tmp_cpa in combinationPartialA:
            if sum(tmp_cpa) == mi:
                check = True
    if check:
        print("yes")
    else:
        print("no")

### FIXED CODE ###

from functools import lru_cache

@lru_cache(maxsize = None)
def canProd(i,m):
     
    if m == 0:
        return True
    if i >= n:
        return False
 
    res = canProd(i+1,m) or canProd(i+1,m-a[i])
    return res
 
 
n = int(input())
a = [int(x) for x in input().split()]
q = int(input())
m = [int(x) for x in input().split()]

rs = [None]*2001

maxm = max(m)
minm = min(m)

for i in range(minm,maxm+1):
    if canProd(0,i):
        rs[i] = "yes"
    else:
        rs[i] = "no"

for i in m:
    print(rs[i])
### BUGGY CODE ###

from collections import deque


def BFS():
    point=0
    color=[["white" for _ in range(w)] for _ in range(h)]
    D=[[0 for _ in range(w)] for _ in range(h)]

    queue=deque([])
    for i in range(h):
        for j in range(w):
            if A[i][j]=="#":
                queue.append([i,j])
                D[i][j]=0

    while len(queue)>0:
        x,y=queue.popleft()
        for a,b in [[1,0],[-1,0],[0,1],[0,-1]]:
            X,Y=x+a,y+b
            if 0<=X<h and 0<=Y<w:
                if color[X][Y]!="black":
                    color[X][Y]="gray"
                    D[X][Y]=D[x][y]+1
                    point=max(point,D[X][Y])
                    queue.append([X,Y])
        color[x][y]="black"

    return point


h,w=map(int,input().split())
A=[list(input()) for _ in range(h)]
print(BFS())

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10**7)
inf=10**7


def BFS():
    color=[["white" for _ in range(w+2)] for _ in range(h+2)]
    D=[[inf for _ in range(w+2)] for _ in range(h+2)]

    queue=deque([])
    for i in range(1,h+1):
        for j in range(1,w+1):
            if A[i][j]=="#":
                queue.append([i,j])
                D[i][j]=0
                color[i][j]="gray"

    cnt=0
    while len(queue)!=0:
        a,b=queue.popleft()
        for c,d in ((1,0),(0,1),(-1,0),(0,-1)):
            X,Y=a+c,b+d
            if A[X][Y]=="." and color[X][Y]=="white":
                color[X][Y]="gray"
                D[X][Y]=D[a][b]+1
                cnt=max(cnt,D[X][Y])
                queue.append([X,Y])
        color[a][b]="black"

    return cnt


h,w=map(int,input().split())
A=[["#"]+list(input())+["#"] for _ in range(h)]
A.insert(0,["#"]*(w+2))
A.append(["#"]*(w+2))
print(BFS())
### BUGGY CODE ###

from collections import deque
K = int(input())
E = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] がcost 0, E[i][1]がcost 1
V = [-1] * (K)
V[1] = 1
q = deque([1])
i = 1
while V[0] == -1:
    i = q.popleft()
    if i != E[i][0]:
        q.appendleft(E[i][0])
        V[E[i][0]] = V[i]
    if V[E[i][1]] == -1:
        q.append(E[i][1])
        V[E[i][1]] = V[i]+1
print(V[0])

### FIXED CODE ###

from collections import deque
K = int(input())
E = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] がcost 0, E[i][1]がcost 1
INF = K*10
V = [INF] * (K)
V[1] = 1
q = deque([1])
i = 1
while q:
    i = q.popleft()
    if V[E[i][0]] > V[i]:
        q.appendleft(E[i][0])
        V[E[i][0]] = V[i]
    if V[E[i][1]] > V[i]+1:
        q.append(E[i][1])
        V[E[i][1]] = V[i]+1
print(V[0])
### BUGGY CODE ###

sx,sy,gx,gy=map(int,input().split())
n=int(input())
g = [[] for i in range(n+2)]
data=[(sx,sy,0)]
for i in range(n):
    data.append(tuple(map(int,input().split())))
data.append((gx,gy,0))
for i in range(n+2):
    for j in range(i,n+2):
        if i==j:
            g[i].append((0,j))
            g[j].append((0,i))
            continue
        tmp=max(0,((data[i][0]-data[j][0])**2+(data[i][1]-data[j][1])**2)**0.5-data[i][2]-data[j][2])
        g[i].append((tmp,j))
        g[j].append((tmp,i))

def dijkstra(g,st,ed):
    from heapq import heappush, heappop, heapify
    dist=[2828427127 for i in range(len(g))]
    dist[st]=0
    que=[]
    heappush(que,(0,st))
    while que:
        c,v=heappop(que)
        if dist[v]<c:
            continue
        for i in range(len(g[v])):
            if g[v][i][0]+c<dist[g[v][i][1]]:
                dist[g[v][i][1]]=g[v][i][0]+c
                heappush(que,(g[v][i][0]+c,g[v][i][1]))
    return dist[ed]

print(dijkstra(g,0,n+1))

### FIXED CODE ###

from heapq import heappush, heappop
sx,sy,gx,gy=map(int,input().split())
n=int(input())
g = [[] for i in range(n+2)]
data=[(sx+sy*1j,0)]
for i in range(n):
    a,b,c=map(int,input().split())
    data.append((a+b*1j,c))
data.append((gx+gy*1j,0))

for i in range(n+2):
    for j in range(i+1,n+2):
        tmp=abs(data[i][0]-data[j][0])-data[i][1]-data[j][1]
        g[i].append((tmp,j))
        g[j].append((tmp,i))

dist=[2828427127 for i in range(n+2)]
visited=[False for i in range(n+2)]
dist[0]=0
que=[]
heappush(que,(0,0))

while que:
    c,v=heappop(que)
    if visited[v]:
        continue
    visited[v]=True
    for x in g[v]:
        if visited[x[1]]:
            continue
        tmp=x[0]+c if not x[0]<0 else c
        if tmp<dist[x[1]]:
            dist[x[1]]=tmp
            heappush(que,(tmp,x[1]))
print(dist[n+1])
### BUGGY CODE ###

def resolve():
    n,k  = map(int,input().split())
    
    member_cost = list(map(int,input().split()))
    food_cost = list(map(int,input().split()))

    member_cost.sort()
    food_cost.sort(reverse=True)
    total_cost = []
    for i in range(len(member_cost)):
        total_cost.append(member_cost[i]*food_cost[i])

    if k >= sum(member_cost):
        print(0)
    else:
        while k > 0:
            k -= 1
            reduce_index = total_cost.index(max(total_cost))
            member_cost[reduce_index] -= 1
            total_cost[reduce_index] -= food_cost[reduce_index]
        print(max(total_cost))
        
        
            
resolve()


### FIXED CODE ###

class Contest:
    def __init__(self, member_cost,food_cost,k):
        self.member_cost = member_cost
        self.food_cost   = food_cost
        self.max_training_times = k
        
    def canAchieve(self,target):
        sum_training_times = 0
        for i in range(len(self.member_cost)):
            sum_training_times += max(0,self.member_cost[i] - target//self.food_cost[i])

        return  sum_training_times <= self.max_training_times
        


    def bisect(self,begin,end):
        if (end - begin <= 1 ):
            return end
        target = (begin + end)//2
        if self.canAchieve(target):
            return self.bisect(begin,target)

        else:
            return self.bisect(target,end)




def resolve():
    n,k  = map(int,input().split())
    
    member_cost = list(map(int,input().split()))

    food_cost = list(map(int,input().split()))
    member_cost.sort()
    food_cost.sort(reverse=True)
    total_cost = []
    for i in range(len(member_cost)):
        total_cost.append(member_cost[i]*food_cost[i])

    max_total_cost = max(total_cost)
    contest = Contest(member_cost,food_cost,k)
    print(contest.bisect(-1,max_total_cost))
    
resolve()
### BUGGY CODE ###

S = input

for i in range(10 ** 10):
  a = 1 + 1

### FIXED CODE ###

s=input()
l=len(s)
se=dict()
k=0
for i in range(l-1,-1,-1):
    k+=(pow(10,l-1-i,2019)*int(s[i]))
    k%=2019
    if k in se:
        se[k]+=1
    else:
        se[k]=1

ans=0
for j in se:
    i=se[j]
    if i>1:
        ans+=(i*(i-1)//2)
    if j==0:
        ans+=i
print(ans)
### BUGGY CODE ###

N =int(input())
keihin =[]
ans = 0
for _ in range(N):
    S = input()
    if S in keihin:
        continue
    else:
        keihin.append(S)
        ans+=1

print(ans)
    

### FIXED CODE ###

N =int(input())
keihin ={}
ans = 0
for _ in range(N):
    S = input()   
    keihin[S] = 1


print(sum(keihin.values()))
### BUGGY CODE ###

from collections import Counter

n = int(input())
cnt = Counter(input().split())
c1, c2, c3 = cnt['1'], cnt['2'], cnt['3']
total = c1 + 2 * c2 + 3 * c3
dp = [[[0] * (c3 + 1) for _ in range(c2 + c3 + 2)] for _ in range(n + 2)]

for k in range(1, n + 1):
    still = n / k
    for a1 in range(k, max(-1, 2 * k - total - 1), -1):
        dpap, dpac, dpan = dp[a1 - 1], dp[a1], dp[a1 + 1]
        for a2 in range(min(k - a1, c2 + c3), max(-1, 3 * k - 2 * a1 - total - 1), -1):
            a3 = k - a1 - a2
            if a3 > c3:
                break
            tmp = 0
            if a1:
                tmp += dpap[a2][a3] * a1
            if a2:
                tmp += dpan[a2 - 1][a3] * a2
            if a3:
                tmp += dpac[a2 + 1][a3 - 1] * a3
            dpac[a2][a3] = tmp / k + still
print(dp[c1][c2][c3])


### FIXED CODE ###

from collections import Counter

n = int(input())
cnt = Counter(input().split())
c1, c2, c3 = cnt['1'], cnt['2'], cnt['3']
total = c1 + 2 * c2 + 3 * c3
c23 = c2 + c3
dp = [[[0.0] * (c3 + 1) for _ in range(c2 + c3 + 1)] for _ in range(n + 2)]

for k in range(1, n + 1):
    still = n / k
    for a1 in range(k, max(-1, 2 * k - total - 1, k - c23 - 1), -1):
        dpap, dpac, dpan = dp[a1 - 1], dp[a1], dp[a1 + 1]
        for a2 in range(min(k - a1, c2 + c3), max(-1, 3 * k - 2 * a1 - total - 1, k - a1 - c3 - 1), -1):
            a3 = k - a1 - a2
            tmp = 0
            if a1:
                tmp += dpap[a2][a3] * a1
            if a2:
                tmp += dpan[a2 - 1][a3] * a2
            if a3:
                tmp += dpac[a2 + 1][a3 - 1] * a3
            dpac[a2][a3] = tmp / k + still
print(dp[c1][c2][c3])
### BUGGY CODE ###

import math

sum = 0
K = int(input())

for a in range(1, K+1):
	for b in range(1, K+1):
		for c in range(1, K+1):
			sum += math.gcd(math.gcd(a, b), c)

print(sum)

### FIXED CODE ###

import math

sum = 0
K = int(input())

for a in range(1, K+1):
	for b in range(1, K+1):
		x = math.gcd(a, b)
		for c in range(1, K+1):
			sum += math.gcd(x, c)

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

N = int(input())
la = list(map(int, input().split()))

ans = list()

for i in range(1, N+1):
    ans.append(la.index(i) + 1)

print(*ans)

### FIXED CODE ###

import numpy as np

N = int(input())
la = list(map(int, input().split()))

ans = np.argsort(la) + 1

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

n=int(input())
s=input()
l=[]
for i in range(n-2):
    for k in range(i+1,n-1):
        for j in range(k+1,n):
            l.append(s[i]+s[k]+s[j])
print(len(set(l)))

### FIXED CODE ###

n=int(input())
s=input()
ans=0
for i in range(1000):
    num=str(i).zfill(3)
    if s.find(num[0])==-1:
        continue
    s1=s[s.find(num[0])+1:]
    if s1.find(num[1])==-1:
        continue
    s2=s1[s1.find(num[1])+1:]
    if s2.find(num[2])==-1:
        continue
    ans+=1
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
mod = 7 + 10 ** 9
lcm = lcm(*A)
ans = 0
for i in A:
    ans += lcm // i
print(ans % mod) 


### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
mod = 7 + 10 ** 9
lcm = lcm(*A)
ans = 0
for i in A:
    ans += lcm // i
print(ans % mod)