Harryxun/stf_run huggingface dataset:
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[val]
	else:
		pass

print(score)

### FIXED CODE ###

n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val]-1]
	else:
		pass

print(score)
n, m = list(map(int, input().split()))
data = [[] for _ in range(n)]
done = [False for _ in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    data[a-1].append(b-1)


def dfs(pos, cnt):
    done[pos] = True
    if cnt >= n-1:
        return 1
    ans = 0
    for next in data[pos]:
        if not done[next]:
            ans += dfs(next, cnt+1)
    return ans


ans = dfs(0, 0)
print(ans+1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

n, m = list(map(int, input().split()))
data = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    data[a-1].append(b-1)
    data[b-1].append(a-1)

ans = 0


def dfs(pos, cnt, his):
    global ans
    his[pos] = 1
    if cnt == n:
        if sum(his) == n:
            ans += 1
        return

    for next in data[pos]:
        dfs(next, cnt+1, his[:])


dfs(0, 1, [0]*n)
print(ans)
n,m=map(int,input().split())

ans=[[] for i in range(m)]
p_list=[[] for i in range(n)]

for i in range(m):
 p,y=map(int,input().split())

 ans[i]=str(p).zfill(6)
 p_list[p].append([i,y])

for pp in p_list:
 pp=sorted(pp,key=lambda x:x[1])
 num=0
 for ppp in pp:
  num+=1
  ans[ppp[0]]+=str(num).zfill(6)
 num=0

for i in ans:
 print(i)

### FIXED CODE ###

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

ans=[[] for i in range(m)]
p_list=[[] for i in range(n+1)]

for i in range(m):
 p,y=map(int,input().split())

 ans[i]=str(p).zfill(6)

 p_list[p].append([i,y])

for pp in p_list:
 pp=sorted(pp,key=lambda x:x[1])
 num=0
 for ppp in pp:
  num+=1
  ans[ppp[0]]+=str(num).zfill(6)
 num=0

for i in ans:
 print(i)
from sys import stdin
def main()
  from builtins import int, map, range
  readline = stdin.readline
  from heapq import heappush, heappop
  n, m = map(int, readline().split())
  jobs = {}
  for _ in range(n):
    a, b = map(int, readline().split())
    if a > m:
      continue
    if a in jobs:
      jobs[a].append(b)
    else:
      jobs[a] = [b]
  result = 0
  candidates = []
  for a in range(1, m + 1):
    if a in jobs:
      for b in jobs[a]:
        heappush(candidates, -b)
    else:
      if len(candidates) == 0:
        continue
    result += -heappop(candidates)
  print(result)
main()


### FIXED CODE ###

n, m = map(int, input().split())
d1 = {}
for _ in range(n):
  a, b = map(int, input().split())
  if a in d1:
    d1[a].append(b)
  else:
    d1[a] = [b]
result = 0
d2 = {}
maxb = -1
for i in range(1, m + 1):
  if i in d1:
    for j in d1[i]:
      if j not in d2:
        d2[j] = 0
      d2[j] += 1
      if j > maxb:
        maxb = j
  else:
    if len(d2) == 0:
      continue
  result += maxb
  if d2[maxb] == 1:
    del d2[maxb]
    if len(d2) == 0:
      maxb = 0
    else:
      maxb = max(d2.keys())
  else:
    d2[maxb] -= 1
print(result)
A, B, C, D, E, F = map(int, input().split())
W = set()
S = set()
wtr = 100*A
sgr = 0

i = 1
j = 0
while(wtr <= F):
  while(wtr <= F):
    W.add(wtr)
    wtr = i*A*100 + j*B*100
    j +=1
  i +=1
  j = 0
  wtr = i*A*100 + j*B*100
  
i = 0
j = 0
while(sgr <= F):
  while(sgr <= F):
    S.add(sgr)
    sgr = i*C + j*D
    j +=1
  i +=1
  j = 0
  sgr = i*C + j*D
answtr = 100*A
anssgr = 0
  
for wtr in W:
  for sgr in S:
    if (sgr*(answtr+anssgr) > anssgr*(wtr+sgr)) and (sgr*(100+E)<=E*(wtr+sgr) and (wtr+sgr<=F)):
      answtr = wtr
      anssgr = sgr
      if (ansgr*(100+E)==E*(answtr+anssgr):
          print("{} {}".format(answtr+anssgr, anssgr))
          exit()
print("{} {}".format(answtr+anssgr, anssgr))

### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())
W = set()
S = set()
wtr = 100*A
sgr = 0

i = 1
j = 0
while(wtr <= F):
  while(wtr <= F):
    W.add(wtr)
    wtr = i*A*100 + j*B*100
    j +=1
  i +=1
  j = 0
  wtr = i*A*100 + j*B*100
  
i = 0
j = 0
while(sgr <= F):
  while(sgr <= F):
    S.add(sgr)
    sgr = i*C + j*D
    j +=1
  i +=1
  j = 0
  sgr = i*C + j*D
answtr = 100*A
anssgr = 0
  
for wtr in W:
  for sgr in S:
    if (sgr*(answtr+anssgr) > anssgr*(wtr+sgr)) and (sgr*(100+E)<=E*(wtr+sgr) and (wtr+sgr<=F)):
      answtr = wtr
      anssgr = sgr
print("{} {}".format(answtr+anssgr, anssgr))
N,K=map(int,input().split())
a=list(map(int,input().split()))
for v in range(K-1):
  if a[v]>=a[K+v]:
    print("No")
  else:
    print("Yes")


### FIXED CODE ###

N,K=map(int,input().split())
a=list(map(int,input().split()))
for v in range(N-K):
  if a[v]>=a[K+v]:
    print("No")
  else:
    print("Yes")
import math
N, K = map(int, input().split())
L = N-K
M = 1e9+7

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kai(x, mod):
    a = 1
    for wawa in range(x):
        a *= x - wawa
        a = a%mod
    return  a

for i in range(K):
    i += 1 #iは1からkまで
    B_sla = cmb(K-1, i-1)
    R = L-(i-1)
    if R == 0:
        R_ire = 1
    elif R < 0:
        R_ire = 0
    else:
        R_ire = (math.factorial(R+i)/(math.factorial(R)*math.factorial(i))) % M

    print(int(B_sla*R_ire%M))

### FIXED CODE ###

N, K = map(int, input().split())
#組み合わせ -------------------------------------------------
mod = int(1e9+7) #適宜変更
Max = 2001 #適宜変更
fac = [0]*(Max)
finv = [0]*(Max)
inv = [0]*(Max)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,Max):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
def Comb(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod

for i in range(K):
    i += 1 #iは1からkまで
    B_sla = Comb(K-1, i-1)
    R = N-K-(i-1)
    if R == 0:
        R_ire = 1
    elif R < 0:
        R_ire = 0
    else:
        R_ire = Comb(R+i, R)

    print(int(B_sla*R_ire%mod))
# -*- coding: utf-8 -*-

import re

n = int(raw_input())
a = map(int, re.split("\s", raw_input()))
left = 0
right = 0
mask = 10**9 + 7

com = [0]*(n+2)

tmp = 1
for i in range(1, n+2):
        tmp *= i
        com[i] = tmp

for i in range(0, n + 1):
        x = a.index(a[i])
        if a[i] in a[x+1:]:
                left = i  
                right = a[x+1:].index(a[i]) + x + 1
                break

for i in range(1, n + 2):
        ans = (com[n + 1] / (com[i] * com[n + 1 - i]))
        x = (com[left + n - right] / (com[i - 1] * com[left + n - right - i + 1]))
        print (ans - x) % mask


### FIXED CODE ###

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

from collections import Counter
import re

def pow(a, x):
        y = 1
        p = a % mask
        n = x
        while (n > 0):
                if ((n % 2) == 0):
                        p = (p * p) % mask
                        n /= 2
                else:   
                        y = (y * p) % mask
                        n -= 1
        return y

n = int(raw_input())
a = map(int, re.split("\s", raw_input()))
left = 0
right = 0

mask = 10**9 + 7
invm = 10**9 + 5

com = [1]*(n+2)
inv = [1]*(n+2)

tmp = 1 
for i in range(1, n+2):
        tmp = (tmp * i) % mask
        com[i] = tmp
        inv[i] = pow(tmp, invm) % mask

counter = Counter(a)
dup = counter.most_common(1)[0][0]
left = a.index(dup)
right = a[left+1:].index(dup) + left + 1

for i in range(1, n + 2):
        ans = (com[n + 1] * (inv[i] * inv[n + 1 - i]))

        if ((left + n - right - i + 1) >= 0):
                ans -= (com[left + n - right] * inv[i - 1] * inv[left + n - right - i + 1])
        print ans % mask
hitachi = input()
#type(hitachi)
flag = 0
if(len(hitachi) == 1):
    hitachi += " "
for x in range(len(hitachi)):
    if(hitachi[x] == " "):
        break
    if(x %2 == 0):
        if(hitachi[x] + hitachi[x+1] == "hi"):
            #print(hitachi[x] + hitachi[x+1])
            flag += 1
        else:
            #print(hitachi[x] + hitachi[x+1])
            print("No")
            break
if(not len(hitachi) == 0):
    if(flag == len(hitachi)//2):
        print("Yes")

### FIXED CODE ###

hitachi = input()
#type(hitachi)
flag = 0
if(len(hitachi) == 1):
    hitachi += " "
elif(len(hitachi) >= 11):
    hitachi = " "
elif(len(hitachi) % 2 ==1):
    hitachi += " "
for x in range(len(hitachi)):
    if(hitachi[x] == " "):
        break
    if(x %2 == 0):
        if(hitachi[x] + hitachi[x+1] == "hi"):
            #print(hitachi[x] + hitachi[x+1])
            flag += 1
        else:
            #print(hitachi[x] + hitachi[x+1])
            print("No")
            break
if(not len(hitachi) == 0):
    if(flag == len(hitachi)//2):
        print("Yes")
inp = [[int(x) for x in input().split()] for _ in range(int(input()))]
inpsum = sum(map(lambda ij: abs(ij[0]+ij[1]) % 2, inp))
if not (inpsum == len(inp) or inpsum == 0):
    print(-1)
    exit(0)

seeds = ([] if inpsum == len(inp) else [1]) + [1 << i for i in range(0, 32)]
# print(inp)

print(' '.join(map(str, reversed(seeds))))

for x, y in inp:
    for k in reversed(seeds):
        res = ''
        if abs(x) > abs(y):
            if x > 0:
                res = 'R'
                x -= k
            else:
                res = 'L'
                x += k
        else:
            if y > 0:
                res = 'U'
                y -= k
            else:
                res = 'D'
                y += k
        # print((x,y))
        print(res, end='')
    print('')


### FIXED CODE ###

for s in input():
    if s == '9': print('1', end='')
    else: print('9', end='')
print('')
import sys
sys.setrecursionlimit(10**9)
n, m, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(k)]
con = [1 for _ in range(n+1)]
uni = [-1 for i in range(n+1)]

def root(num, pea):
    if pea[num] < 0:
        return num
    else:
        pea[num] = root(pea[num], pea)
        return pea[num]

for i in range(m):
    a, b = ab[i]
    con[a] += 1
    con[b] += 1
    if uni[a] != uni[b] or uni[a] < 0 or uni[b] < 0:
        root_a = root(a, uni)
        root_b = root(b, uni)
        root_a, root_b = sorted([root_a, root_b])
        uni[root_a] += uni[root_b]
        uni[root_b] = root_a
        root_b = root(root_b, uni)

for i in range(k):
    c, d = cd[i]
    if root(c, uni) == root(d, uni):
        con[c] += 1
        con[d] += 1

result = []
for i in range(1, n+1):
    root_i = root(i, uni)
    result.append(-uni[root_i]-con[i])
print(*result)


### FIXED CODE ###

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


n, m, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(k)]
con = [1 for _ in range(n+1)]
uni = UnionFind(n+1)


for i in range(m):
    a, b = ab[i]
    con[a] += 1
    con[b] += 1
    uni.Unite(a, b)

for i in range(k):
    c, d = cd[i]
    if uni.isSameGroup(c,d):
        con[c] += 1
        con[d] += 1

result = []
for i in range(1, n+1):
    result.append(uni.Count(i)-con[i])
print(*result)
r=int(input())
p=3.14159
print(f'{pi*r*r} {2*p*r}')

### FIXED CODE ###

r=float(input())
p=3.141592653589
print(p*r*r,2*p*r)
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]

def G(_a, _b):
  if _a>=_b:
    a, b = _a, _b
  else:
    a, b = _b, _a
  
  while True:
    c = a%b
    if c == 0:
      break
    a,b = b,c
  
  return b

def func(L):
  unique_L = list(set(L))
  if len(unique_L)==1:
    return unique_L[0]
  elif min(unique_L)==1:
    return 1
  else:
    g = G(unique_L[0], unique_L[-1])
    unique_L[0] = g
    unique_L[-1] = g
    return func(unique_L)
print(func(A))
    

### FIXED CODE ###

from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]

def G(_a, _b):
  if _a>=_b:
    a, b = _a, _b
  else:
    a, b = _b, _a
  
  while True:
    c = a%b
    if c == 0:
      break
    a,b = b,c
  
  return b

L = np.array(list(set(A)))
mini = np.min(L)
yaku = [1]
i=2
r_mini = np.sqrt(mini)
while i<=r_mini:
  if mini%i==0:
    yaku.append(i)
  i+=1
yaku2 = list(map(lambda x: int(mini/x), yaku))
yaku = yaku[::-1]
yaku2.extend(yaku)
for y in yaku2:
  if np.sum(L%y)==0:
    ans = y
    break

print(ans)
N = int(input())
X = input()

mod0 = X.count("1") + 1
mod1 = X.count("1") - 1

full0 = 0
full1 = 0
for i in range(N):
    if X[i] == "1":
        full0 = (full0 + pow(2, N - i - 1, mod0)) % mod0
        full1 = (full1 + pow(2, N - i - 1, mod1)) % mod1

ans = [0] * N
for i in range(N):
    if X[i] == "0":
        cur = (full0 + pow(2, N - i - 1, mod0)) % mod0
    else:
        cur = (full1 - pow(2, N - i - 1, mod1)) % mod1

    res = 1
    while cur > 0:
        cur %= bin(cur).count("1")
        res += 1
    ans[i] = res

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


### FIXED CODE ###

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

cnt = X.count("1")
res0 = 0
res1 = 0
for i in range(N):
    if X[i] == "1":
        res0 = (res0 + pow(2, N - i - 1, cnt + 1)) % (cnt + 1)

        if cnt - 1 > 0:
            res1 = (res1 + pow(2, N - i - 1, cnt - 1)) % (cnt - 1)

for i in range(N):
    ans = 0
    if X[i] == "0":
        div = cnt + 1
        tmp = (res0 + pow(2, N - i - 1, div)) % div
        ans += 1
    else:
        if cnt - 1 > 0:
            div = cnt - 1
            tmp = (res1 + div - pow(2, N - i - 1, div)) % div
            ans += 1
        else:
            tmp = 0

    while tmp > 0:
        ans += 1
        div = bin(tmp).count("1")
        tmp %= div
        
    print(ans)
t=int(input())
while(t):
    t-=1
    k,n=map(int,input().split())
    a=list(map(int,input().split()))
    max_d=0
    for i in range(n):
        x=0
        if i==n-1:
           if a[0]==0:
               x=k-a[i]
           else:
               x=k-a[i]+a[0]
        else:
            x=a[i+1]-a[i]
        if x>max_d:
            max_d=x
    print(k-max_d)

### FIXED CODE ###

k,n=map(int,input().split())
a=list(map(int,input().split()))
max_d=0
for i in range(n):
    x=0
    if i==n-1:
        if a[0]==0:
            x=k-a[i]
        else:
            x=k-a[i]+a[0]
    else:
        x=a[i+1]-a[i]
    if x>max_d:
        max_d=x
print(k-max_d)
N = int(input())
if N == 1:
    print('Hello World')
else:
    A, B = map(int, input().split())
    print(A + B)

### FIXED CODE ###

N = int(input())
if N == 1:
    print('Hello World')
else:
    print(int(input()) + int(input()))
N = int(input())
d = list(map(int, input().split())) 
d.sort()

if(len(d)%2!=0):
    print(0)
else: 
    print(d[int(len(d)/2)+1]-d[int(len(d)/2)])

### FIXED CODE ###

N = int(input())
d = list(map(int, input().split())) 
d.sort()

if(len(d)%2!=0):
    print(0)
else: 
    print(d[int(len(d)/2)]-d[int(len(d)/2)-1])
def main():
    s = input()
    ans = []
    count = 0
    for char in s:
        if char in ["A", "C", "G", "T"]:
            count += 1
        else:
            ans.append(count)
            count = 0
    print(max(ans))

if __name__ == '__main__':
   main()

### FIXED CODE ###

def main():
    s = input()
    ans = [0]
    count = 0
    for char in s:
        if char in ["A", "C", "G", "T"]:
            count += 1
        else:
            ans.append(count)
            count = 0
    ans.append(count)
    print(max(ans))

if __name__ == '__main__':
   main()
def usage():
    product = 1
    N, P = map(int, input().split())

    fct = factorize(P)

    for i in range(len(fct)):
        fct[i][1] = fct[i][1]//N

        if fct[i][1] >= 1:
            product = product*(fct[i][0]**fct[i][1])
    print(product)
    
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append([b, e])
        b, e = b + 1, 0
    if n > 1:
        fct.append([n, 1])
    return fct

if __name__ == '__main__':
    usage()

### FIXED CODE ###

s = str(input())
count = 0
for i in s:
    if i == str(2):
        count = count + 1
print(count)
s = input()
h = s//3600
m = (s-h*3600)//60
sec = (s-h*3600)%60 
print(h+":"+m+":"+sec)

### FIXED CODE ###

s = int(input())
print(str(s//3600) + ":" + str((s%3600)//60) + ":" + str(s%60))
s = input()
z = int(input())
list = [chr(i) for i in range(97,97+26)]
d = []
flag = 0
for j in list:
  indexes = [i for i,x in enumerate(s) if x==j]
  if len(indexes)==0:
    continue
  for k in indexes:
    for l in range(len(s)-k):
      d.append(s[k:l+k+1])
  if len(d)==z:
    break
print(sorted(set(d))[z-1])

### FIXED CODE ###

s = input()
z = int(input())
list = [chr(i) for i in range(97,97+26)]
d = []
for j in list:
  indexes = [i for i,x in enumerate(s) if x==j]
  if len(indexes)==0:
    continue
  for k in indexes:
    for l in range(len(s)-k):
      d.append(s[k:l+k+1])
      if len(s[k:l+k+1])==z:
        break
print(sorted(set(d))[z-1])
S = list(input())

if (S[0]==S[1])or(S[1]==S[2])or(S[2]==S[3]):
  print('Bad')
else:
  print('Good')


### FIXED CODE ###

N,L = map(int,input().split())
import math
T = []
for i in range(N):
  T.append(L+i)
cnt = 0
mcnt = sum(T)
k = 1000000
for i in range(0,N):
  if abs(T[i])<k:
    mcnt = sum(T)-T[i]
    cnt = i+1
    k=abs(T[i])
print(mcnt)
s = input()
K = int(input())
n1 = list(s)
n2 = [s[i:i+2] for i in range(len(s)-1)]
n3 = [s[i:i+3] for i in range(len(s)-2)]
cat = list(set(n1 + n2 + n3))
cat.sort()
#print(cat)
print(cat[K-1])

### FIXED CODE ###

s = input()
K = int(input())
n1 = list(s)
n2 = [s[i:i+2] for i in range(len(s)-1)]
n3 = [s[i:i+3] for i in range(len(s)-2)]
n4 = [s[i:i+4] for i in range(len(s)-3)]
n5 = [s[i:i+5] for i in range(len(s)-4)]
cat = list(set(n1 + n2 + n3 + n4 + n5))
cat.sort()
#print(cat)
print(cat[K-1])
def gcd (num1,num2):#ユークリッド互除法
    tmp = max(num1,num2) % min(num1,num2)
    if tmp == 0:
        return min(num1,num2)
    return gcd(min(num1,num2),tmp)


n = int(input())
t = []
stock = [1]
for i in range(n):
    t.append(input())

for i in range(len(t)-1):#各秒数の最大公倍数を求める
    stock.append(t[i] * t[i+1] / gcd(stock[i],t[i]))

print(stock[-1])

### FIXED CODE ###

n = int(input())
ans = int(input())
 
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a
 
def lcm(x,y):
    return (x*y//gcd(x,y))
 
for i in range(n-1):
    t = int(input())
    ans = lcm(ans,t)
print(ans)
import fractions

# 入力
A,B = map(int,input().split())

print(int((A * B) // math.fractions(A, B)))

### FIXED CODE ###

import fractions

# 入力
A,B = map(int,input().split())

print(int((A * B) // fractions.gcd(A, B)))
from heapq import heappop, heappush
N, K = map(int, input().split())
KMAX = 10 ** 5 + 1
TD = []
for _ in range(N):
    t, d = map(int, input().split())
    TD.append((d, t))

TD.sort(reverse=True)

pioneer = []
successor = []
appear = [False] * KMAX
cnt = 0
nsp = 0  # num of species
base = 0
best = []

for td in TD:
    d, t = td
    if cnt < K:
        heappush(successor if appear[t] else pioneer, (d, t))
        nsp += 0 if appear[t] else 1
        appear[t] = True
        base += d
        cnt += 1
        if cnt == K-1:
            heappush(best, -(base + nsp ** 2))
        continue
    if not successor:
        break
    if appear[t]:
        continue
    cd, ct = heappop(successor)
    appear[t] = True
    heappush(pioneer, (d, t))
    base += (d-cd)
    nsp += 1
    heappush(best, -(base + nsp ** 2))

print(-heappop(best))


### FIXED CODE ###

from heapq import heappop, heappush
N, K = map(int, input().split())
KMAX = 10 ** 5 + 1
TD = []
for _ in range(N):
    t, d = map(int, input().split())
    TD.append((d, t))

TD.sort(reverse=True)

pioneer = []
successor = []
appear = [False] * KMAX
cnt = 0
nsp = 0  # num of species
base = 0
best = []

for td in TD:
    d, t = td
    if cnt < K:
        heappush(successor if appear[t] else pioneer, (d, t))
        nsp += 0 if appear[t] else 1
        appear[t] = True
        base += d
        cnt += 1
        if cnt == K:
            heappush(best, -(base + nsp ** 2))
        continue
    if not successor:
        break
    if appear[t]:
        continue
    cd, ct = heappop(successor)
    appear[t] = True
    heappush(pioneer, (d, t))
    base += (d-cd)
    nsp += 1
    heappush(best, -(base + nsp ** 2))

print(-heappop(best))