Harryxun/stf_run huggingface dataset:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

""" どのパワー以上の組み合わせまで握手するのか二分探索で調べる
    同じパワーとなる組み合わせに注意 """
N, M = lr()
A = np.array(lr())
B = A[:, None] + A[None, :]
B = B.ravel()
B.sort() # 昇順
N = N ** 2
if M == N:
    print(B.sum()); exit()

def check(x):
    # x以上の幸福度と握手した場合、M回以下になる場合、Trueを返す
    i = B.searchsorted(x, side='l')
    return (N - i) <= M

ok = 10 ** 5 * 2 + 1; ng = 0
while abs(ng-ok) > 1:
    mid = (ok+ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

i = B.searchsorted(ok, side='l')
if i == N:
    answer = B[-1] * M
else:
    time = N - i
    answer = B[i:].sum() + B[i-1] * (M-time)
print(answer)
# 01

### FIXED CODE ###

import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = rl()
A = np.array(rl())
A.sort()

def shake_cnt(x):
    Y = np.searchsorted(A,x-A)
    return N*N - Y.sum()

right = 10 ** 6
left = 0 #握手するのがM人以上
while right > left + 1:
    mid = (left+right) // 2
    if shake_cnt(mid) >= M:
        left = mid
    else:
        right = mid

X = np.searchsorted(A, right-A) #握手しない人数
Acum = np.zeros(N+1, np.int64)
Acum[1:] = A.cumsum()

shake = N*N - X.sum()
happy = (Acum[-1] - Acum[X]).sum() + (A * (N-X)).sum()
happy += (M-shake) * left
print(happy)
A,B,C,D = list(map(int,input().split()))
import math

lcm = C*D/math.gcd(C,D)
a = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//lcm)
b = (B) - ((B)//C + (B)//D - (B)//lcm)
print(int(b-a))

### FIXED CODE ###

from fractions import gcd

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

lcm = C*D/gcd(C,D)

a = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//int(lcm))
b = (B) - ((B)//C + (B)//D - (B)//int(lcm))
print(int(b-a))
S=input()
N=len(S)
for i in range(0,N+1):
    for j in range(i,N+1):
        if "".join(S[:i] + S[j:]) == 'keyence':
            print("YES")
            exit(1)
else:
    print('NO')

### FIXED CODE ###

S=input()
N=len(S)
for i in range(0,N+1):
    for j in range(i,N+1):
        if  S[:i] + S[j:] == 'keyence':
            print("YES")
            exit(0)
else:
    print('NO')
n=int(input())
x=list(map(int,input().split()))

import numpy as np
import fractions as frc
from functools import reduce
from copy import deepcopy

x2=deepcopy(x)

def gcd_list(lst):
    return reduce(frc.gcd, lst)

while True:
	n=len(x)
	g=[]
	if n<=5:
		if n==2:
			res=max(x)
			break
		else:
			for i in range(n):
				f=[]
				for j in range(n):
					if j!=i:            
						f.append(x[i])
				g.append(gcd_list(f))
			idx=np.argmax(g)
			rm=x[idx]
			x3=[c for c in x2 if c!=rm]
			res=gcd_list(x3)
			break
	sp=n//2
	y=x[:sp]
	z=x[sp:]
	y_gcd=gcd_list(y)
	z_gcd=gcd_list(z)
	if y_gcd>z_gcd:
		x=z
	else:
		x=y

print(res)

### FIXED CODE ###

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

import fractions as frc

y=[0]*n
z=[0]*n

cd=x[0]
for i in range(n):
	cd=frc.gcd(cd,x[i])
	y[i]=cd

#print(y)

cd=x[n-1]
for i in range(n-1,-1,-1):
	cd=frc.gcd(cd,x[i])
	z[i]=cd

#print(z)

res=[0]*n
for i in range(n):
	if i==0:
		res[0]=z[1]
	else:
		if i==n-1:
			res[n-1]=y[n-2]
		else:
			res[i]=frc.gcd(y[i-1],z[i+1])

#print(res)

print(max(res))
import copy
N,K = list(map(int, input().split()))
 
A = list(map(int, input().split()))
 
count = [0]
Check = [0] * N
for i in range(K):
    count.append(A[count[-1]]-1)
    print(count)
    if(Check[count[-1]-1] == 1):
        break
 
    Check[count[-1]-1] = 1
    i += 1

saisyo = count.index(count[-1]) + 1

if(K > saisyo):
    loop_kazu = len(count) - saisyo
    K_loop = K - saisyo
 
    ans_index = K_loop % loop_kazu
    ans = count[saisyo + ans_index] + 1
 
    print(ans)

else:
    print(count[K-1]+1)
 

### FIXED CODE ###

import copy
N,K = list(map(int, input().split()))
 
A = list(map(int, input().split()))
 
count = [0]
Check = [0] * N
for i in range(K):
    count.append(A[count[-1]]-1)
#    print(count)
    if(Check[count[-1]-1] == 1):
        break
 
    Check[count[-1]-1] = 1
    i += 1
 
saisyo = count.index(count[-1]) + 1
#print(count,saisyo)
 
if(saisyo == len(count)):
    saisyo = 0
 
loop_kazu = len(count) - saisyo
 
if(K > loop_kazu):
    K_loop = K - saisyo
 
    ans_index = K_loop % loop_kazu
    ans = count[saisyo + ans_index] + 1
 
    print(ans)
 
else:
    print(count[K]+1)
N, M = input().split()
A = input().split()

N = int(N)
M = int(M)
print(N,M,A)

sum = 0
for i in A:
    sum += int(i)

print(sum)

### FIXED CODE ###

R = int(input())
ans = R * 2 * 3.1415
print(ans)
import mathmatics
r=int(input())
print(2*r*pi)

### FIXED CODE ###

r=int(input())
print(2*r*3.1415926535237)
N, X, M = map(int, input().split())
ls = [False]*M
ls_mod = []
x = X
for m in range(M+1):
  if ls[x] == False:
    ls_mod.append(x)
    ls[x] = m
    x = (x**2)%M
  else:
    last = m
    fast = ls[x]
    diff = last - fast
    break
if last - 1 > N:
  print(sum(ls_mod[:N]))
else:
  shou = (N-fast) // diff
  amari = (N-fast) % diff
  print(sum(ls_mod[:fast])+sum(ls_mod[fast:])*shou+sum(ls_mod[fast:fast+amari]))



### FIXED CODE ###

N, X, M = map(int, input().split())
ls = [False]*M
ls_mod = []
x = X
for m in range(M+1):
  if ls[x] == False:
    ls_mod.append(x)
    ls[x] = m
    x = (x**2)%M
  else:
    last = m
    fast = ls[x]
    diff = last - fast
    break
if M == 1:
  print(0)
else:
  if last > N:
    print(sum(ls_mod[:N]))
  else:
    shou = (N-fast) // diff
    amari = (N-fast) % diff
    print(sum(ls_mod[:fast])+sum(ls_mod[fast:])*shou+sum(ls_mod[fast:fast+amari]))
n=int(input())
a=[0 for i in range(n)]
for i in range(n+1): #0,1,2,3,…n-1,n+1-1:nが3でも5でも割り切れない場合range(n)ではダメ
    if i%3!=0 and i%5!=0:
        a[i]=int(i)

print(sum(a))


### FIXED CODE ###

n=int(input())
a=[0 for i in range(n+1)]
for i in range(n+1): #0,1,2,3,…n-1,n+1-1:nが3でも5でも割り切れない場合range(n)ではダメ
    if i%3!=0 and i%5!=0:
        a[i]=int(i)

print(sum(a))
n, m = input().split()
n, m = int(n), int(m)
a = input().split()
a = [int(i) for i in a]
a.sort()
a.reverse()
for i in range(n):
  if a[i] < 1/4m:
    print("No")
    break
  if i == m-1:
    print("Yes")
    break


### FIXED CODE ###

n, m = input().split()
n, m = int(n), int(m)
a = input().split()
a = [int(i) for i in a]
a.sort()
a.reverse()
s = 1/(4*m)*sum(i for i in a)
for i in range(n):
    if a[i] < s:
        print("No")
        break
    if i == m-1:
        print("Yes")
        break
n,m=map(int,input().split())
a=set(map(int,input().split()))
b=set(map(int,input().split()))
c=1;N=0;M=0
for k in range(m*n,0,-1):
  N+=1;M+=1 if k in a and k in b else c*=M;N+=1 if k in a else c*=N;M+=1 if k in b else c*=M*N-m*n+k
  c%=10**9+7
print(c)

### FIXED CODE ###

import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=10**9+7
if len(set(a))!=len(a) or len(set(b))!=len(b):
  print(0)
else:
  a.sort()
  b.sort()
  L=[]
  for i in range(n):
    l=[]
    for j in range(m):
      l.append(0)
    L.append(l)
  if m*n in a and m*n in b:
    L[a.index(m*n)][b.index(m*n)]=m*n
    ct=1
    ctn=1
    ctm=1
    A=set(a)
    B=set(b)
    for k in range(m*n-1,0,-1):
      if k in A and k in B:
        L[bisect.bisect_left(a,k)][bisect.bisect_left(b,k)]=k
        ct*=1
        ctn+=1
        ctm+=1
      elif k in A:
          ct*=ctm
          ctn+=1
      elif k in B:
          ct*=ctn
          ctm+=1
      else:
        ct*=(ctm*ctn-m*n+k)
      if ct==0:
        break
      ct=ct%x
    print(ct)
  else:
    print(0)
X,Y,A,B,C=map(int,input().split())
red=sorted(list(map(int,input().split())),reverse=True)
green=sorted(list(map(int,input().split())),reverse=True)
nocolor=sorted(list(map(int,input().split())),reverse=True)

X_cnt=0
Y_cnt=0
ans=[]

for i in range(X):
    ans.append(red[i])
    X_cnt+=1
    if X_cnt==X:
        break
    elif X_cnt<X:
        continue
for i in range(Y):
    ans.append(green[i])
    Y_cnt+=1
    if Y_cnt==Y:
        break
    elif Y_cnt<Y:
        continue

ans=sorted(ans)
ans_sum=sum(ans)    
for i in range(C):
    if ans[i]<nocolor[i]:
        ans_sum=ans_sum_nocolor[i]-ans[i]
        
print(ans_sum)



### FIXED CODE ###

X,Y,A,B,C=map(int,input().split())
R=sorted(list(map(int,input().split())),reverse=True)
G=sorted(list(map(int,input().split())),reverse=True)
RG=sorted(list(map(int,input().split())),reverse=True)


d=R[:X]+G[:Y]+RG
d.sort(reverse=True)
 
print(sum(d[:X+Y]))
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
if n%2==0:
    print(n/2)
else:
    print(math.ceil(n/2)/n)

### FIXED CODE ###

import math
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
if n%2==0:
    print(0.5)
else:
    print(math.ceil(n/2)/n)
x = input().split(" ")
a = int(x[0])
b = int(x[1])

if a > b:
    put("a > b")
elif a < b:
    put("a < b")
else:
    put("a == b")



### FIXED CODE ###

if __name__ == '__main__':
    x = input().split(' ')
    a = int(x[0])
    b = int(x[1])

    if a > b:
        print('a > b')
    elif a < b:
        print('a < b')
    else:
        print('a == b')
n, h = map(int, input().split())
A, B = [], []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)


throw_a = max(A)
B = sorted(B, reverse=True)
count = 0

while h > 0:
    count += 1
    if throw_a > max(B):
        h -= a
    else:
        h -= max(B)
        B.remove(max(B))

print(count)

### FIXED CODE ###

s = str(input())
ans = '2018' + s[4:]
print(ans)
input()
x = list(map(int, input().split()))
x.sort()
x=np.array(x)
ans=0
for i in x[:-2]:
    y = x[x>i]
    for j in y:
        z = y[y>j]
        for k in z:
            if i+j>k:
                ans+=1
print(ans)

### FIXED CODE ###

import numpy as np
input()
x = list(map(int, input().split()))
x.sort()
x=np.array(x)
ans=0
for i in x[:-2]:
    y = x[x>i]
    for j in y:
        z = y[y>j]
        for k in z:
            if i+j>k:
                ans+=1
print(ans)
import math
a,b,n = map(int,input().split())

for i in range(n,0,-1):
    if a*math.floor(i/b)<math.floor(a*i/b):
        ans=math.floor(a*i/b)-a*math.floor(i/b)
        break

print(ans)

### FIXED CODE ###

import math
a,b,n = map(int,input().split())

ans = math.floor(a*min((b-1),n)/b)
print(ans)
import numpy as np
from numba import njit
N=int(input())
a=np.array([int(i) for i in input().split()],dtype=np.int64)
a.dtype
dp=np.full((N,N),-1,dtype=np.int64)
dp.dtype
for i in range(N):
    dp[i][i]=a[i]

@njit('i8(i8,i8,i8[:,:],i8[:])', cache=True)
def calc(i,j,dp,a):
    if dp[i][j]!=-1:
        return dp[i][j]
    dp[i][j]=max(a[i]-calc(i+1,j,dp,a),a[j]-calc(i,j-1,dp,a))
    return dp[i][j]

calc(0,N-1,dp,a)
print(dp[0][N-1])


### FIXED CODE ###

import numpy as np
from numba import njit
N=int(input())
a=np.array([int(i) for i in input().split()],dtype=np.int64)
dp=np.full((N,N),-1,dtype=np.int64)
for i in range(N):
    dp[i][i]=a[i]

@njit('i8(i8,i8,i8[:,:],i8[:])', cache=True)
def calc(i,j,dp,a):
    if dp[i][j]!=-1:
        return dp[i][j]
    dp[i][j]=max(a[i]-calc(i+1,j,dp,a),a[j]-calc(i,j-1,dp,a))
    return dp[i][j]

calc(0,N-1,dp,a)
print(dp[0][N-1])
#71a
x,a,b=map(int,input().split())
print('A' if abs(x-a)<(x-c) else 'B')

### FIXED CODE ###

#71a
x,a,b = map(int,input().split())
print('A' if abs(x-a)<abs(x-b) else 'B')
import sys

# H1 = int(sys.stdin.readline())
# M1 = int(sys.stdin.readline())
# H2 = int(sys.stdin.readline())
# M2 = int(sys.stdin.readline())
# K = int(sys.stdin.readline())

H1 = 999
M1 = 999
H2 = 999
M2 = 999
K = 999


while not (0 <= H1 < 23 or 0 <= M1 < 59 or 0 <= H2 < 23 or 0 <= M2 < 59):
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())

if M2 >= M1:
    a = (H2 - H1) * 60 + M2 - M1
    print(a - K)
if M2 < M1:
    b = (H2 - H1) * 60 + M1 - M2
    print(b - K)

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline

h1, m1, h2, m2, k = map(int, readline().split())
print(60 * (h2 - h1) + m2 - m1 - k)
# input
N_lst = [int(x) for x in list(input()]

if N_lst[0] == 9 or N_lst[1] == 9:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

# input
N_lst = [int(x) for x in list(input())]

if N_lst[0] == 9 or N_lst[1] == 9:
    print('Yes')
else:
    print('No')
N, K = map(int, input().split())
height = list(map(int, input().split()))
unqualified = 0

for height in heights:
    if height < K:
        unqualified += 1

print(unqualified)


### FIXED CODE ###

N, K = map(int, input().split())
heights = list(map(int, input().split()))
qualified = 0

for height in heights:
    if height >= K:
        qualified += 1

print(qualified)
import sys

s = input()

rem = []
remrev = []

for i in s:
    if i != "x":
        rem.append(i)
        remrev.append(i)

remrev.reverse()

for i in range(len(rem)):

    if rem[i] != remrev[i]:
        print (-1)
        sys.exit()

nx = 0
xnum = []

for i in s:

    if i == "x":
        nx += 1
    else:
        xnum.append(nx)
        nx = 0

xnum.append(nx)

xnc = xnum.copy()
xnc.reverse()

ans = 0

for i in range((len(xnum) + 1) // 2):

    ans += abs(xnum[i]-xnc[i])

print (ans)

### FIXED CODE ###

import sys

s = input()

rem = []
remrev = []

for i in s:
    if i != "x":
        rem.append(i)
        remrev.append(i)

remrev.reverse()

for i in range(len(rem)):

    if rem[i] != remrev[i]:
        print (-1)
        sys.exit()

nx = 0
xnum = []

for i in s:

    if i == "x":
        nx += 1
    else:
        xnum.append(nx)
        nx = 0

xnum.append(nx)

xnc = xnum.copy()
xnc.reverse()

ans = 0

for i in range((len(xnum) + 1) // 2):

    ans += abs(xnum[i]-xnc[i])

print (ans)
l = ["a","b","c","d","e","f","g","i","j","k"]
n = int(input())
ans = [[] for i in range(n)]
ans[0].append("a")

for i in range(1,n):
    for j in ans[i-1]:
        for k in range(ord(j[-1])-ord("a")+2):
            an = j + l[k]
            ans[i].append(an)
count = ans[-1]
count.sort()
for i in count:
    print(i)

### FIXED CODE ###

l = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n"]
n = int(input())
ans = [[] for i in range(n)]
ans[0].append("a")

for i in range(1,n):
    
    for j in ans[i-1]:
        a = 0
        for k in j:
            a = max(a,ord(k)-ord("a"))
        for k in range(a+2):
            an = j + l[k]
            ans[i].append(an)
count = ans[-1]
count.sort()
for i in count:
    print(i)
N,Cut = map(int,input().split())
log_ls = list(map(int,input().split()))

Max = max(log_ls)

def max_less_K(k):
    times = 0
    for log in log_ls:
        times += log // k
    if times <= Cut:
        return True
    else:
        return False

def return_min_ind_whose_value_not_less_than():
    r = Max
    l = -1
    while True:
        next_k = (r+l) // 2
        if max_less_K(next_k):
            r = next_k
        else:
            l = next_k
        if r - l == 1:
            return r

ans = return_min_ind_whose_value_not_less_than()
print(ans)


### FIXED CODE ###

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

Max = max(log_ls)

def less_k(min_length,log_ls = log_ls,K=K):
    times = 0
    for log in log_ls:
        if log % min_length == 0:
            times += log // min_length -1
        else:
            times += log // min_length
    if times <= K:
        return True
    else:
        return False
#print(less_k(5,[10,10],2))

def return_min_length():
    r = Max
    l = -1
    while True:
        next_length = (r+l) // 2
        if next_length == 0 or not less_k(next_length):
            l = next_length
        else:
            r = next_length
        if r - l == 1:
            return r

ans = return_min_length()
print(ans)
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
A,B,C,D = map(int,input().split())

a = int(B/C) - int((A-1)/C)
b = int(B/D) - int((A-1)/D)
c = int(B/lcm(C,D)) - int((A-1)/lcm(C, D))

print ( B - (A - 1) - (a + b - c))

### FIXED CODE ###

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

A,B,C,D = map(int,input().split())

a = int(B//C) - int((A-1)//C)
b = int(B//D) - int((A-1)//D)
c = int(B//lcm(C,D)) - int((A-1)//lcm(C, D))

count = B - (A - 1) - (a + b - c)
print(count)
If S = "ABC":
	return "ARC"
else:
	return "ABC"

### FIXED CODE ###

S = input() 
if S == "ABC":
	print("ARC")
else:
	print("ABC")
K, S = map(int, input().split())

cnt = 0
for x in range(K+1):
  for y in range(K+1):
      if 0 <= S-(x+y) <= K 
        cnt += 1
print(cnt)

### FIXED CODE ###

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

cnt = 0
for x in range(K+1):
  for y in range(K+1):
      if 0 <= S-(x+y) <= K:
        cnt += 1
print(cnt)
s = input()
t = s[:(len(s)-1)/2]
u = s[(len(s)+3)/2-1:]
if s == s[::-1] and t == t[::-1] and u == u[::-1]:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

s = input()
t = s[:(len(s)-1)//2]
u = s[(len(s)+3)//2-1:]
if s == s[::-1] and t == t[::-1] and u == u[::-1]:
  print("Yes")
else:
  print("No")
n,m= input().split()
xl = list(map(int, input().split())) 
yl = list(map(int, input().split())) 

xsum = sum(xl)
ysum = sum(yl)
for i in range(n):
    xi += xsum - xl[i]*(n-i)
    xsum -= xl[i] 
    
for j in range(m):
    yi += ysum - yl[j]*(m-j)
    ysum -= yl[j]

print(xi*yi)

### FIXED CODE ###

n,m = map(int, input().split())
xl = list(map(int, input().split())) 
yl = list(map(int, input().split())) 

xl = list(map(lambda x: x-xl[0],xl))
yl = list(map(lambda x: x-yl[0],yl))

xi=0
yi=0
mod = 10**9+7
xsum = sum(xl)
ysum = sum(yl)
for i in range(n):
    xi += (xsum - xl[i]*(n-i)) % mod
    xsum -= xl[i] 
    
for j in range(m):
    yi += (ysum - yl[j]*(m-j)) % mod
    ysum -= yl[j]

print(xi*yi % mod)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)
ansList = []
for i in range(len(A),0,-1):
    if(ANS[i-1]%2!=A[i-1]):
        tList = make_divisors(i)
        for j in tList:
            ANS[j-1]+=1
        ansList.append(i)
print(len(ansList))

for i in ansList:
    print(i, end=" ")

### FIXED CODE ###

N = int(input())
print(3*N*N)
# coding: utf-8
N = int(input())
B = list(map(int, input().split()))
A = B
A.insert(0, B[0])
for i in range(1, N - 1):
    if A[i] == 0:
        A[i + 1] = A[i+2]
print(sum(A))

### FIXED CODE ###

# coding: utf-8
N = int(input())
B = list(map(int, input().split()))
A = B
A.insert(0, B[0])
for i in range(1, N - 1):
    if A[i] > A[i+1]:
        A[i] = A[i+1]
print(sum(A))
A = int(input())
B = int(input())
max_ab = max(A,B)
min_ab = min(A,B)

r = max_ab
s = min_ab

while s != 0:
  r,s = s,r % s
  if s == 0:
    break
print(int(r*(A/r)*(B/r)))

### FIXED CODE ###

[A,B] = map(int,input().split())
max_ab = max(A,B)
min_ab = min(A,B)

r = max_ab
s = min_ab

while s != 0:
  r,s = s,r % s
  if s == 0:
    break
print(int(r*(A/r)*(B/r)))
cnt_1 = 0
cnt_2 = 0
for i in range(1,n+1):
    for j in range(i,n+1):
        #対象な場合
        #(1,1),(22,22),(333,333)
        if i==j and (str(i)[0]==str(j)[-1] and str(i)[-1]==str(j)[0]):
            cnt_1 += 1
        #異なる数字の場合
        #揃っていてもnより大きい場合はNG
        elif (str(i)[0]==str(j)[-1] and str(i)[-1]==str(j)[0]):
                cnt_2 += 1
print(cnt_1 + cnt_2*2)

### FIXED CODE ###

n=int(input())
cnt=[[0]*10 for i in range(10)] #(10,10)サイズの配列
ret = 0

def hoge(m):
    #return m[-1],m[0]
    return (m%10, int(str(m)[0]))

for k in range(1,n+1):
    a,b = hoge(k)
    cnt[a][b] += 1    

for i in range(1,10):
    for j in range(1,10):
        ret += cnt[i][j] * cnt[j][i]

print(ret)
N = int(input())
d = []

for i in range(N):
    d.append(int(input()))

d = list(set(d))

print(length(d))

### FIXED CODE ###

N = int(input())
d = []

for i in range(N):
    d.append(int(input()))

d = list(set(d))

print(len(d))
¥import math
a = list(map(int,input().split()))
b = a[1]//a[0]
c = []
for i in range(1,int(math.sqrt(a[1]))+1):
    if a[1]%i==0 and i<=b:
        if a[1] // i <= b:
            c.append(a[1]//i)
        else:
            c.append(i)
c.sort(reverse=True)
print(c[0])

### FIXED CODE ###

import math
a = list(map(int,input().split()))

b = a[1]//a[0]

c = []

for i in range(1,int(math.sqrt(a[1]))+1):
    if a[1] % i == 0 and i <= b:
        if a[1] // i <= b:
            c.append(a[1] // i)
        else:
            c.append(i)
c.sort()
c.reverse()
print(c[0])
import numpy as np

N = int(input())
a = np.array([int(input()) for i in range(N)])


#回数i,インデックスn
def button(i,n):
    if i == N:
        return

    n_new = a[n-1]
    if n_new == 2:
        print(i)
        return 
    else:
        return button(i+1,n_new)

button(1,1)

### FIXED CODE ###

import numpy as np
import sys
sys.setrecursionlimit(500000)


N = int(input())
a = np.array([int(input()) for i in range(N)])


#回数i,インデックスn
def button(i,n):
    n_new = a[n-1]
    
    if i == N:
        if n != 2:
            print(-1)
            return
    if n_new == 2:
        print(i)
        return 
    else:
        return button(i+1,n_new)

button(1,1)
n=int(input())
s=[int(x) for x in input().split(' ')]
#print(s)
t1=[]
t2=[]
for i in range(n-1):
    #t1.append(s[i+1]-s[i])
    if s[i+1] > s[i]:
        t1.append(s[i+1]-s[i])
    else:
        t1.append(s[i]-s[i+1])
    print(t1)
for i in range(n-2):
    #t2.append(s[i+2]-s[i])
    if s[i+2] > s[i]:
        t2.append(s[i+2]-s[i])
    else:
        t2.append(s[i]-s[i+2])
    print(t2)
p=max(len(t1),len(t2))
ct1,ct2=len(t1),len(t2)
sum1=0
for i in range(p):
    if ct1 == 0 or ct2 == 0:
        break
    if t1[i] > t2[i]:
        sum1+=t2[i]
    else:
        sum1+=t1[i]
    ct1-=1
    ct2-=1
print(sum1)

### FIXED CODE ###

n=int(input())

s=input().split(' ')

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

dp = [10001]*100000

dp[0] = 0

dp[1] = abs(s[1] - s[0])

for i in range(2,n):
    
    dp[i] = min(dp[i-1] + abs(s[i]-s[i-1]), dp[i-2] + abs(s[i]-s[i-2]))

print(dp[n-1])
import math

a , b = (int(x) for x in input().split())

result = math.gcd(a, b)

print((a * b) // result)

### FIXED CODE ###

import fractions

a , b = (int(x) for x in input().split())

result = fractions.gcd(a, b)

print((a * b) // result)
def resolve():
    a, b, k = map(int, input().split())
    t = []
    for i in range(1, k+1):
        if a % i == 0 and b % i == 0:
            t.append(i)
    print(t[k-1])
resolve()    

### FIXED CODE ###

def resolve():
    a, b, k = map(int, input().split())
    t = []
    for i in range(1, min(a,b)+1):
        if a % i == 0 and b % i == 0:
            t.append(i)
    print(t[-k])
resolve()
import copy

n = int(input())
X = list(input())

popcount = [0]*(2*10**5)

num = int("".join(X), 2)
cnt = X.count("1")

for i in range(1,2*10**5):
    tmp_cnt = bin(i).count("1")
    popcount[i] = i%tmp_cnt

for i,x in enumerate(X):
    tmp = copy.deepcopy(X)
    ans = 1
    if x == "0":
        tmp[i] = "1"
        now = int("".join(tmp), 2)
        now = now%(cnt+1)
    else:
        tmp[i] = "0"
        now = int("".join(tmp), 2)
        now = now%(cnt-1)
    while now:
        now = popcount[now]
        ans += 1
    print(ans)

### FIXED CODE ###

n = int(input())
X = input()

cnt = [0]*(200001)
for i in range(1,200001):
    pc = bin(i).count('1')
    cnt[i] = cnt[i%pc] + 1
    
plus = X.count("1")+1
minus = X.count("1")-1

defp = int(X, 2)%plus
if minus:
    defm = int(X, 2)%minus
else:
    defm = None

pl = 1
mi = 1
ans = []
for i, x in enumerate(X[::-1]):
    if x == "0":
        ans.append(cnt[(defp+pl)%plus]+1)
    else:
        if minus:
            ans.append(cnt[(defm-mi)%minus]+1)
        else:
            ans.append(0)
    pl = 2*pl%plus
    if minus:
        mi = 2*mi%minus

print(*ans[::-1], sep="\n")
A,op,B=list(map(int, input().split()))
if op==+:
  print(A+B)
else:
  print(A-B)

### FIXED CODE ###

A,op,B=input().strip().split()
if op == '+':
  print(int(A)+int(B))
else:
  print(int(A)-int(B))