Harryxun/stf_run huggingface dataset:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


def main():
    num, start = map(int, input().split())
    data = list(map(int, input().split()))
    kyori = [0 for i in range(num)]

    for i in range(num):
        kyori[i] = abs(data[i] - start)

    ans = gcd(*kyori)

    print(ans)





if __name__ == '__main__':
    main()

### FIXED CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


def kouyakusuu(kyori, num):
    ans = kyori[0]
    pre = kyori[0]
    for i in range(num - 1):
        now_point = kyori[i + 1]
        while now_point:
            pre, now_point = now_point, pre % now_point
        if pre < ans:
            ans = pre
        pre = kyori[i + 1]
    return ans


def main():
    num, start = map(int, input().split())
    data = list(map(int, input().split()))
    kyori = [0 for i in range(num)]

    for i in range(num):
        kyori[i] = abs(data[i] - start)

    ans = kouyakusuu(kyori, num)

    print(ans)





if __name__ == '__main__':
    main()
s=input()
t=input()
ss=sorted(s)
tt=sorted(t,reversed)
if ss<tt:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

s=input()
t=input()
ss="".join(sorted(s))
tt="".join(sorted(t,reverse=True))
if ss<tt:
    print("Yes")
else:
    print("No")
N, Q = map(int, input().split())
query = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    query[a-1].append(b-1)

count = [0]*N

def dfs(v):
    global x
    if checked[v]:
        return
    checked[v] = 1
    count[v] += x
    for i in query[v]:
        if not checked[i]:
            dfs(i)

for i in range(Q):
    p, x = map(int, input().split())
    checked = [0]*N
    dfs(p-1)

print(*count)

### FIXED CODE ###

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

query = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    query[a-1].append(b-1)
    query[b-1].append(a-1)

from collections import deque

count = [0]*N

for i in range(Q):
    p, x = map(int, input().split())
    count[p-1] += x

queue = deque([0])
checked  = [0]*N
while queue:
    v = queue.pop()
    checked[v] = 1
    x = count[v]
    Vs = query[v]
    for i in Vs:
        if checked[i]:
            continue
        count[i] += x
        queue.append(i)
    
print(*count)
n = int(input())
s = input()
cnt = s.count('R')*s.count('G')*s.count('B')
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i] != s[j]:
            if 2*j-i <= n-1:
                if s[2*j-i] not in(s[i],s[j]):
                    cnt -= 1
print(cnt)


### FIXED CODE ###

n = input()
output = 'No'
if n[0] == '7' or n[1] == '7' or n[2] == '7':
    output = 'Yes'
print(output)
n = int(input())
d = map(int, input().split())
d = sorted(d)
l = []
now = 0
ans = 0
for i in range(n-1):
    if d[i] != d[i+1]:
        a = d.index(d[i])
        b = d.count(d[i])
        index = a+b-1
        #print(index)
        if index+1 == n/2:
            #print(d[i+1], d[i])
            ans = d[i+1]-d[i]
print(ans)

### FIXED CODE ###

s = input()
if s[0] == s[1] == s[2] == s[3]:
    print('No')
elif s[0] == s[1] and s[2] == s[3]:
    print('Yes')
elif s[0] == s[2] and s[1] == s[3]:
    print('Yes')
elif s[0] == s[3] and s[1] == s[2]:
    print('Yes')
else:
    print('No')
X,N = map(int,input().split())
P = list(map(int,input().split()))

P_n = [i for i in range(1,101,1) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]
min_abs = min(abs_value)


for k in range(len(P_n)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

### FIXED CODE ###

X, N = map(int, input().split())
 
p = list(map(int, input().split()))
 
p_none = [i for i in range(110) if i not in p]
p_none_sa = [abs(p_none[i]-X) for i in range(len(p_none))]
 
import sys
 
min_p_none = min(p_none_sa)
for i in range(len(p_none_sa)):
    if p_none_sa[i] == min_p_none:
        print(p_none[i])
        sys.exit()
s=int(input())
p=10**9+7
if s<=2:
    print(0)
    exit()
n=s//3
ans=0


for k in range(1,n+1):
    a=1
    b=1
    for j in range(k-1):
        a=a*(s-3*k+1+j)%p
        b=b*(j+1)%p
    ans=(ans+a*pow(b,-1,p))%p

print(ans%p)


### FIXED CODE ###

s=int(input())
p=10**9+7
if s<=2:
    print(0)
    exit()
n=s//3
ans=0
def f(n,k,p):
    if k==0:
        return 1
    elif k%2==0:
        return (f(n,k//2,p)**2)%p
    else:
        return (n*f(n,k-1,p))%p

for k in range(1,n+1):
    a=1
    b=1
    for j in range(k-1):
        a=(a*(s-3*k+1+j))%p
        b=(b*(j+1))%p
    ans=(ans+a*f(b,p-2,p))%p

print(ans%p)
print("Yes" if 'N' in s and 'S' in s and 'W' in s and'E' in s for s in [input()] else "No")

### FIXED CODE ###

import os
import math
import itertools
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]

def get_int():
    return int(input())

def get_int_list():
    return list(map(int, input().split()))

while(True):
    try:
        s = input()
        if ('N' in s) == ('S' in s) and ('W' in s) == ('E' in s):
            print("Yes")
        else:
            print("No")
    except EOFError:
        exit()
if yyyy < 2019:
    print('Heisei')
elif yyyy > 2019:
    print('TBD')
else:
    if mm < 5:
        print('Heisei')
    else:
        print('TBD')

### FIXED CODE ###

S = input()
if S <= '2019/04/30' :
    print('Heisei' )
else:
    print('TBD')
from sys import stdin

N = int(input())
sum = 0
for i in N:
  x,u = stdin.readline().rstrip().split()
  if u == 'JPY':
    sum += int(x)
  else:
  	sum += float(x)*38000
print(sum)


### FIXED CODE ###

N = int(input())
sum = 0
for i in range (N):
  X = input().split()
  if X[1] == 'JPY':
    sum += float(X[0])
  else:
  	sum += float(X[0])*380000
print(sum)
from collections import Counter
n=input()
A=map(int,raw_input().split())

M0=[]
M1=[]

for i in range(n):
	if i%2==0: M0.append(A[i])
	else: M1.append(A[i])

C0=Counter(M0)
C1=Counter(M1)

l0=len(C0)
l1=len(C1)

ans=0
if l0>1:
	L=sorted(C1.items(), key=lambda x:x[1])
	ans=0
	for i in range(l0-1):
		ans+=L[i][1]

if l1>1:
	L=sorted(C1.items(), key=lambda x:x[1])
	ans=0
	for i in range(l1-1):
		ans+=L[i][1]

print ans


### FIXED CODE ###

from collections import Counter
n=input()
A=map(int,raw_input().split())

M0=[]
M1=[]

for i in range(n):
	if i%2==0: M0.append(A[i])
	else: M1.append(A[i])

C0=Counter(M0)
C1=Counter(M1)

L0=sorted(C0.items(), key=lambda x:x[1], reverse=True)
L1=sorted(C1.items(), key=lambda x:x[1], reverse=True)

a0=None
a1=None

if L0[0][0]!=L1[0][0]:
	a0=L0[0][0]
	a1=L1[0][0]
	b0=L0[0][0]
	b1=L1[0][0]
elif L0[0][0]==L1[0][0]:
	a0=L0[0][0]
	if len(L1)==1:
		a1=-1
	else:
		a1=L1[1][0]

	b1=L1[0][0]
	if len(L0)==1:
		b0=-1
	else:
		b0=L0[1][0]

ans0=0
ans1=0
for x in M0:
	if x!=a0:
		ans0+=1

for x in M1:
	if x!=a1:
		ans0+=1

ans1=0
for x in M0:
	if x!=b0:
		ans1+=1

for x in M1:
	if x!=b1:
		ans1+=1

print min(ans0, ans1)
N,M = map(int,input().split())
A = list(map(int,input().split()))
counter = 0
for i in range(M):
    counter += A[i]
    
if N - conter>=0:
    print(N-counter)
else:
    print(-1)

### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
counter = 0
for i in range(M):
    counter += A[i]
    
if N - counter>=0:
    print(N-counter)
else:
    print(-1)
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

count = [0]*(10**5)
for i in range(len(A)):
  count[A[i]] += 1


for i in range(Q):
  B, C = map(int, input().split())
  if count[B] != 0:
    count[C] += count[B]
    count[B] = 0
  ans = 0
  for i in range(len(A)):
    ans += count[A[i]]*A[i]
  print(ans)
  

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
S = sum(A)
count = [0]*(10**5+1)
for i in range(len(A)):
  count[A[i]] += 1

A = list(set(A))
for i in range(Q):
  B, C = map(int, input().split())
  S = S - B*count[B] + C*count[B]
  count[C] += count[B]
  count[B] = 0
  print(S)
s = list(input())
t = list(input())

b = []

for i in range(len(s)):
    c1 = s[i]
    c2 = t[i]
    if c1 == c2:
        for i in range(len(b)):
            if b[j][0] == c1:
                print("No")
                exit()
    if c1 != c2:
        for j in range(len(b)):
            if b[j][0] == c1 and b[j][1] != c2:
                print("No")
                exit()
            if b[j][0] != c1 and b[j][1] == c2:
                print("No")
                exit()
            if b[j][0] == c1 and b[j][1] == c2:
                break
        else:
            b.append([c1, c2])
else:
    print("Yes")


### FIXED CODE ###

S = input()
T = input()

converter = dict()

for s, t in zip(S, T):
    if converter.get(s) is not None:
        if converter[s] != t:
            print("No")
            break
    else:
        converter[s] = t
else:
    if len(converter.values()) != len(set(converter.values())):
        print("No")
    else:
        print("Yes")
import heapq
from collections import deque

X, Y, A, B, C = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

r.sort()

if A < X:
  p += r[-(X - A):]
  r = r[:-(X - A)]
  A = X

if B < Y:
  q += r[-(Y - B):]
  r = r[:-(Y - B)]
  B = Y

p.sort()
q.sort()

pq = deque((heapq.merge(p[A - X:], q[B - Y:])))

while pq[0] < r[-1]:
  pq.popleft()
  pq.append(r.pop())

print(sum(pq))

### FIXED CODE ###

import heapq
from collections import deque

X, Y, A, B, C = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

r.sort()

if A < X:
  p += r[-(X - A):]
  r = r[:-(X - A)]
  A = X

if B < Y:
  q += r[-(Y - B):]
  r = r[:-(Y - B)]
  B = Y

p.sort()
q.sort()

pq = deque(heapq.merge(p[A - X:], q[B - Y:]))

while r and pq[0] < r[-1]:
  pq.popleft()
  pq.append(r.pop())

print(sum(pq))
N,M = list(map(int, input().split()))
 
s = [list(map(int,input().split())) for i in range(n)]
c = [list(map(int,input().split())) for j in range(n)]
 
for t1 in s:
    l = list(map(lambda x: abs(t1[0] - x[0]) + abs(t1[1] - x[1]), c))
    print(l.index(min(l)) + 1)

### FIXED CODE ###

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

s = []
for i in range(N):
    s.append(list(map(int, input().split())))

c = []
for j in range(M):
    c.append(list(map(int, input().split())))

for t1 in s:
    l = list(map(lambda x: abs(t1[0] - x[0]) + abs(t1[1] - x[1]), c))
    print(l.index(min(l)) + 1)
N=int(input())
xyh=[]
for i in range(N):
  xyh.append(list(map(int,input().split())))
def height(x,y,h,Cx,Cy,):
  height=h+abs(x-Cx)+abs(y-Cy)
  return height
def find(N):
  for Cx in range(101):
    for Cy in range(101):
      Height=height(xyh[0][0],xyh[0][1],xyh[0][2],Cx,Cy)
      for i in range(1,N):
        Height_=height(xyh[i][0],xyh[i][1],xyh[i][2],Cx,Cy)
        if Height==Height_:
          if i==N-1:
            return (Cx,Cy,Height)
          continue
        else:
          break
Cx,Cy,H=find(N)
print(Cx,"",Cy," ",H)

### FIXED CODE ###

N=int(input())

xyh=[]
for i in range(N):
    xi,yi,hi=map(int,input().split())
    xyh.append([xi,yi,hi])
xyh.sort(reverse=True,key=lambda x:x[2])
for Cx in range(0,101):
    for Cy in range(0,101):
        for i in range(N):
            X=xyh[i][0]
            Y=xyh[i][1]
            h=xyh[i][2]
            if i==0:
                H=h+abs(X-Cx)+abs(Y-Cy)
                continue
            H_=h+abs(X-Cx)+abs(Y-Cy)
            if h==0:
                if H_<H:
                    break
            elif H!=H_:
                break
            if i==N-1:
                print(Cx,Cy,H)
                quit()
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

T = pow(2,n)-1

for k in range(q):
    z = 0
    for i in range(T):
        B = list(format(i,"0"+str(n)+"b"))
        sum = 0
        for j in range(n):
            sum += A[j]*int(B[j])
        if sum == m[k]:
            z =1
            break
    if z==1:
        print("yes")
    else:
        print("no")


### FIXED CODE ###

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


u = set()

def agari(i):
    if X[i]==1:
        X[i]=0
        agari(i+1)
    else:
        X[i]=1

X = [0]*20
k=0
while k<(pow(2,n)-1):
    y = 0
    for l in range(n):
        y += A[l]*X[l]
    u.add(y)
    agari(0)
    k+=1

for j in range(q):
    if m[j] in u:
        print("yes")
    else:
        print("no")
a,b,c=map(int,input().split())
print(min(a+b,b+c,c+a)

### FIXED CODE ###

a,b,c=map(int,input().split())
print(min(a+b,b+c,c+a))
d, n  = map(int, input().split())

if d = 0:
    print(1 * n)
if d = 1:
    print(100 * n)
if d = 2:
    print(10000 * n)

### FIXED CODE ###

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

if d == 0:
    if n == 100:
        print(101)
    else:
        print(1 * n)
if d == 1:
    if n == 100:
        print(10100)
    else:
        print(100 * n)
if d == 2:
    if n == 100:
        print(1010000)
    else:
        print(10000 * n)
# -*- coding: utf-8 -*-

from sys import stdin
import math
from functools import reduce

n,x = [int(x) for x in stdin.readline().split()]
limit = int(math.pow(x, (1.0/n)))

def factorize(x):
    g = []

    p = 2
    if x % p == 0:
        count = 0
        while x % p == 0:
            count += 1
            x /= p
        else:
            if count >= n:
                g.append(p * (count // n))

    for p in range(3, limit, 2):
        if x % p == 0:
            count = 0
            while x % p == 0:
                count += 1
                x /= p
            else:
                if count >= n:
                    g.append(p * (count // n))
    return g

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    g = factorize(x)
    ans = reduce(lambda a,b: a*b, g)
    print(ans)

### FIXED CODE ###

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

from sys import stdin

n,x = [int(i) for i in stdin.readline().split()]
limit = int(x ** (1.0/n)) + 1

def devide_counter(x, p):
    count = 1
    x /= p
    while x % p == 0:
        count += 1
        x /= p
    return x, count

def factorize(x):
    ans = 1

    p = 2
    if x % p == 0:
        x, count = devide_counter(x, p)
        if count >= n:
            ans = ans * (p ** (count // n))

    for p in range(3, limit, 2):
        if x % p == 0:
            x, count = devide_counter(x, p)
            if count >= n:
                ans = ans * (p ** (count // n))
        if x < p * p:
            break
    return ans

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    ans = factorize(x)
    print(ans)
import numpy as np
n=int(input())
a=np.array(list(map(float,input().split())))
print(float(1/sum(1/a_array)))

### FIXED CODE ###


import numpy as np
n=int(input())
a=list(map(float,input().split()))
a_array=np.array(a)
a_inv=np.reciprocal(a_array)
print(float(1/sum(a_inv)))
#入力部分　ここまでは誰でもできる
s,t = map(str,input().split())
a,b = map(int,input().split())
u = str(input())

if u == s:
  print(a-1,b)
else
  print(a,b-1)


### FIXED CODE ###

s,t = map(str,input().split())
a,b = map(int,input().split())
u = str(input())
 
if u == s:
  print(a-1,b)
else:
  print(a,b-1)
a,b = (int(x) for x in input().split())

d = a // b
r = a % b
(float) f = a / b

print (str(d) + " " + str(r) + " " + str(f))


### FIXED CODE ###

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

d = a // b
r = a % b
f = float(a) / float(b)

print ("{0} {1} {2:.8f}".format(d,r,f))
s  = input()
n  = int(input())

is_seiichi = True
s_head_append = ''

for _ in range(n):
    ipt = input()

    if ipt[0] == '1':
        is_seiichi = not is_seiichi
    else:
        _, id_, s_ = ipt.split()
        is_head = True if id_ == '1' else False
        if is_seiichi ^ is_head:
            #s = s + s_
            s_head_append += s
        else:
            s = s_ + s_head_append + s
            s_head_append = ''

print(s + s_head_append if is_seiichi else s_head_append[::-1] + s[::-1])


### FIXED CODE ###

s  = input()
n  = int(input())

s_mae = ''
s_ato = s

for _ in range(n):
    ipt = input()

    if ipt[0] == '1':
        s_mae, s_ato = s_ato, s_mae
    else:
        _, id_, s_ = ipt.split()
        is_head = True if id_ == '1' else False
        if is_head:
            s_mae += s_
        else:
            s_ato += s_

print(s_mae[::-1] + s_ato)
N, Q = [int(item) for item in input().split()]

tree_list = [input().split() for j in range(1, N)]

query_list = [input().split() for k in range(Q)]
query_list_int = [[int(k) for k in i] for i in query_list]

val_list = [0 for _ in range(N)]

linked_node_list = [[] for _ in range(N)]

for a, b in tree_list:
    a, b = int(a)-1, int(b) -1
    linked_node_list[a].append(b)
    linked_node_list[b].append(a)


for index, val in query_list_int:
    val_list[index-1] += val


def dfs(node_index, pairent_index):
    for child in linked_node_list[node_index]:
        
        if child != pairent_index:
            val_list[child] += val_list[node_index]

        dfs(child, node_index)

    return val_list


res = dfs(0, -1)

print(*res)


### FIXED CODE ###

N, Q = [int(item) for item in input().split()]

tree_list = [input().split() for j in range(1, N)]

query_list = [input().split() for k in range(Q)]
query_list_int = [[int(k) for k in i] for i in query_list]

val_list = [0 for _ in range(N)]

linked_node_list = [[] for _ in range(N)]

for a, b in tree_list:
    a, b = int(a)-1, int(b) -1
    linked_node_list[a].append(b)
    linked_node_list[b].append(a)


for index, val in query_list_int:
    val_list[index-1] += val

stack = [0]
parent = [0] * (N+1)

while True:
    v=stack.pop()
    for child in linked_node_list[v]:
        if child != parent[v]:
            parent[child] = v
            stack.append(child)
            val_list[child] += val_list[v]
    if not stack:
        break

print(*val_list)
str = [input() for i in range(2)]
nums = list(map(int, str[1].split()))
maxCount = 0
idx = 0

for index, item in enumerate(nums):
    count = 0
    if idx > index:
        break
    for i in range(len(nums)-index-1):
        kaisuu += 1
        if nums[index+i] >= nums[index+i+1]:
            count = count + 1
            idx = index+i+1
            if count >= maxCount:
                maxCount = count
        else:
            break
        
print(maxCount)
        


### FIXED CODE ###

str = [input() for i in range(2)]
nums = list(map(int, str[1].split()))
maxCount = 0
index = -1
count = 0

for i in range(len(nums)-1):
    if nums[i] >= nums[i+1]:
        count = count + 1
        if count >= maxCount:
            maxCount = count
    else:
        count = 0
        
print(maxCount)
a,b = map(int,input().split())
def fcd(a , b):
    if a>= b:
        while b != 0:
            a,b = b,a%b
        return a
    
    else:
        while a != 0:
            b,a = a,b%a
        return b
    
    
def lcm(a,b):
    return a*b//fcd(a , b)


print(lcm(a,b))


### FIXED CODE ###

n = int(input())
num_list = list(map(int,input().split()))
cnt = 0
num = 1
for i in num_list:
    if i != num:
        cnt += 1
    else:
        num += 1

if num == 1:
    print(-1)
    
else:print(cnt)
import heapq
import itertools
from operator import itemgetter
from collections import defaultdict
class UnionFind():
    def __init__(self, num):
        self.par = [-1 for _ in range(num)]
    
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            x = self.par[x]
            return self.find(x)
    
    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx != ry:
            if self.par[rx] < self.par[ry]:
                self.par[ry] = rx
            if self.par[rx] > self.par[ry]:
                self.par[rx] = ry
            else:
                self.par[rx] -= 1
                self.par[ry] = rx
        return

def inpl(): return list(map(int, input().split()))
def cost(x, y):
    return D * abs(x - y) + A[x] + A[y]
N, D = inpl()
A = inpl()
minx = A.index(min(A))
Right = [(v - i*D, i) for i, v in enumerate(A)]
Left = [(v + i*D, i) for i, v in enumerate(A)][::-1]
Right = itertools.accumulate(Right[minx:], min)
Left = itertools.accumulate(Left[N - 1 - minx:], min)
hub = set(map(itemgetter(1), Right))
hub.update(map(itemgetter(1), Left))
hub.add(0)
hub.add(N-1)
hub = list(sorted(hub))
edge = [(cost(hub[i], k), hub[i], k) for i in range(len(hub)-1) for k in range(hub[i], hub[i+1])]\
+ [(cost(hub[i+1], k), hub[i+1], k) for i in range(len(hub)-1) for k in range(hub[i], hub[i+1])]
edge.sort(reverse = True)
Uf = UnionFind(N)
ctr = 1
ans = 0
print(edge)
while ctr < N:
    v, i, j = edge.pop()
    if Uf.find(i) != Uf.find(j):
        Uf.union(i, j)
        ctr += 1
        ans += v
print(ans)

### FIXED CODE ###

from operator import itemgetter
import itertools
def inpl(): return list(map(int, input().split()))
def cost(x, y):
    if x == y:
        return float('inf')
    return D * abs(x - y) + A[x] + A[y]
N, D = inpl()
A = inpl()
Right = [(v - i*D, i) for i, v in enumerate(A)]
Left = [(v + i*D, i) for i, v in enumerate(A)][::-1]
Right = list(map(itemgetter(1), itertools.accumulate(Right, min)))
Left = list(map(itemgetter(1), itertools.accumulate(Left, min)))[::-1]
ans = 0
hub = []
for i, (l, r) in enumerate(zip(Left, Right)) :
    if i == l == r:
        hub.append(i)
    else:
        ans += min(cost(i, r), cost(i, l))
print(ans + sum([cost(i, j) for i, j in zip(hub, hub[1:])]))
cd ../n = int(input())
s = input()

r = []
g = []
b = []

for i, c in enumerate(s):
    if c == "R":
        r.append(i)
    elif c == "G":
        g.append(i)
    else:
        b.append(i)


ans = 0
for ri in r:
    for gi in g:
        for bi in b:
            arr = [ri, gi, bi]
            arr.sort()
            if arr[0] + arr[2] == 2 * arr[1]:
                pass
            else:
                ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")


ans = r * g * b

for i in range(n):
    for j in range(i + 1, n):
        if 2 * j - i > n - 1:
            continue
        if s[i] == s[j] or s[i] == s[2 * j - i] or s[j] == s[2 * j - i]:
            pass
        else:
            ans -= 1
print(ans)
#dfs
M = int(input())
L = []
for i in range(M):
    d, c = map(int, input().split())
    L.extend([d] * c)

answer = 100

def dfs(count, l):
    global answer
    if len(l) == 1:
        #print(count)
        answer = min(answer, count)
    else:
        for i in range(len(l)-1):
            sum = l[i] + l[i+1]
            result = l[:i] + [int(x) for x in list(str(sum))] + l[i+2:]
            #print(result)
            dfs(count+1, result)

dfs(0, L)
print(answer)

### FIXED CODE ###

import sys
import numpy as np

stdin = sys.stdin
 
ni = lambda:int(ns())
na = lambda:list(map(int,stdin.readline().split()))
ns = lambda:stdin.readline().rstrip()  # ignore trailing spaces

M = ni()
D = [] ; C = []

for i in range(M):
    d, c = na()
    D.append(d)
    C.append(c)

D = np.array(D) ; C = np.array(C)
#桁数の9倍とそれぞれの数字の総和をx
x = C.sum() * 9 + (C * D).sum()
# 18以下で終了
answer = (x + 8) // 9 - 2
print(answer)