peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
import bisect
input = sys.stdin.readline

def main():
    N,M = map(int, input().split())
    PY_input = []
    PY_dict = {}
    for _ in range(M):
        p, y = map(int, input().split())
        PY_input.append((p, y))
        PY_dict.setdefault(p, []).append(y)

    for i in PY_dict.values():
        i.sort()

    for p, y in PY_input:
        print("{:06}{:06}".format(p, bisect.bisect_right(PY_dict[p], y)))


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
s=input()
keta=int(len(s))
n=int(s)
cnt=0
kuri=0
while n:
    n,amari=divmod(n,10)
    if kuri:
        amari+=1
    if amari<=5:
        cnt+=amari
    else:
        cnt+=10-amari
        kuri=1
print(cnt+1)
# Judge status: Accepted
N = int(input())
X = list(map(int,input().split()))
min = 1000000
for i in range(101):
    d = 0
    for j in range(N):
        d += (i-X[j])**2
    if min > d:
        min = d
print(min)
# Judge status: Wrong Answer
n, k = map(int, input().split())
li = list(input().split())

li.sort(key = int)

print(li)

j = 0
i = 0

while i <= k-1:
  
  j += int(li[i])
  i += 1

print(j)
# Judge status: Wrong Answer
A,B,C = map(int,input().split())
array = [A,B,C]
array.sort()
print(array[0]*array[1])
# Judge status: Accepted
n=int(input())
x=[[0 for i in range(26)] for j in range(n)]
for i in range(n):
    s=input()
    for j in range(len(s)):
        x[i][ord(s[j])-97]+=1
ans=[0]*26
for i in range(26):
    ans[i]=min(x[j][i] for j in range(n))
a=[]
for i in range(26):
    for j in range(ans[i]):
        a.append(chr(97+i))
print("".join(a))
# Judge status: Accepted
import sys
read = sys.stdin.read
def main():
    n = int(input())
    a = input()
    if not 'WR' in a:
        print(0)
        sys.exit()
    a = list(a)
    rnum = a.count('R')
    rl = 0
    rr = 0
    for i1 in range(rnum):
        rl += a[i1] == 'W'
    for j1 in range(n - rnum):
        rr += a[rnum + j1] == 'R'
    r = max(rl, rr)
    print(r)
if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
h, a = map(int, input().split())
print(math.ceil(h / a))
# Judge status: Accepted
def cal(b, e):
    return ((b + (e//b) * b) * (e//b))//2

n = int(input())
ans = 0

for i in range(1, n+1):
    ans += cal(i, n)

print(ans)
# Judge status: Wrong Answer
input()
a=list(map(int,input().split()))
b=0
for i in range(1,len(a)-1):
  b+=a[i-1]<i and i<a[i+1]
  b+=a[i-1]>i and i>a[i+1]
print(b)
# Judge status: Accepted
from collections import Counter
n,k = map(int,input().split())
L = list(map(int,input().split()))
s = len(set(L))
L1 = Counter(L)
L2 = L1.most_common()
L2 = sorted(L2,key = lambda x:x[1])

sum1 =0
if s-k <= 0:
    print(0)
    exit()
else:
    for i in range(s-k):
        sum1 += L2[i][1]
print(sum1)
# Judge status: Accepted
n,l = map(int,input().split())
azi = list()
for i in range(n):
    azi.append(l+i)
kei = sum(azi)
s = list()
for i in range(n):
    s.append(kei-azi[i])

tmp = float('inf')
ans = 0
for i in range(n):
    if tmp >= abs(kei-s[i]):
        ans = s[i]
        tmp = abs(kei-s[i])
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
ppyy = [list(map(int, input().split())) for _ in range(m)]
order = [{}] * (n + 1)
cnt = [1] * (n + 1)
for p, y in sorted(ppyy, key=lambda x: x[1]):
    order[p].update({y: cnt[p]})
    cnt[p] += 1
for p, y in ppyy:
    cnt[p] += 1
    print(str(format(p, '06')) + str(format(order[p][y], '06')))
# Judge status: Wrong Answer
w, h = map(int, input().split())
 
count = 0
 
if w == h == 1:
    count = 0
elif w == 1 or h == 1:
    count = max(w,h)-2
else:
    count = (w - 2) * (h - 2)
    
print(count)
# Judge status: Accepted
a=int(input())
#_l=list(map(int,input().split()))

print(a*(a-1)//2)
# Judge status: Accepted
import sys

A,B,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a) + min(b)

for s in sys.stdin:
    x,y,c = map(int, s.split())
    tmp = a[x-1] + b[y-1] - c
    ans = min(ans, tmp)
print(ans)
# Judge status: Accepted
N,K=map(int,input().split())
i=0
while N>0:
  N=N//K
  i+=1
print(i)
# Judge status: Accepted
A,B,N=map(int,input().split())
if N>=B:
    print(int(A*(B-1)/B))
else:
    print(int(A*N/B))
# Judge status: Accepted
import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(n-2):
     for j in range(i + 1,n-1):
          ans += bisect.bisect_left(l,l[i] + l[j]) - j - 1
print(ans)
# Judge status: Accepted
import collections
N, M = map(int, input().split())
H = [0]
H += list(map(int, input().split()))

a_l = [1] * (N + 1)
for i in range(M):
    a, b = map(int, input().split())
    if H[a] > H[b]:
        a_l[b] = 0
    elif H[a] < H[b]:
        a_l[a] = 0
    else:
        a_l[a] = a_l[b] = 0
print(a_l.count(1) - 1)
# Judge status: Wrong Answer
N = int(input())
count = 0
for n in range(N+1):
  if (n%5)*(n%3) != 0:
    count += n
print(count)
# Judge status: Wrong Answer
s = int(input())
MOD = 1000000007
dp = [0] * (s+1)
dp[0] = 1
for i in range(1, s+1):
    for j in range(0, (i-3)+1):
        dp[i] += dp[j]
        dp[i] %= MOD

print(dp)
# Judge status: Wrong Answer
a, b, k = map(int, input().split())
if a >= k:
    a -= k
else:
    b -= max(0,k - a)
    a = 0
print(a, b)
# Judge status: Wrong Answer
S = [c for c in input()]
while len(S):
    S.pop()
    if len(S) % 2 == 0 and S[:len(S)//2] == S[len(S)//2:]:
        print(len(S[:len(S)//2]))
        exit()
# Judge status: Accepted
# coding: utf-8
# Your code here!

k = int(input())
s = input()

if len(s) <= k:
    print(s)
else:
    print(s[:k] + '...')
# Judge status: Accepted
N = int(input())
ans = [0] * (N+1)
 
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n <= N:
                ans[n] += 1
print(*ans[1:], sep='\n')
# Judge status: Accepted
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
print("Yes" if len(set(S))==3 else "No")
# Judge status: Wrong Answer
a=int(input())
print(a,a*a,a**3)
# Judge status: Accepted
N=input()
ans=0
for cur in range(1,N+1):
    for i in range(cur,N+1,cur):
        ans+=i
print ans
# Judge status: Wrong Answer
N = int(input())
p = list(map(int,input().split()))
ans = 0
c = 0
for i in range(N-1):
    if p[i] == i+1:
        c += 1
    else:
        ans += (c+1)//2
        c = 0
print(ans+(c+1)//2)
# Judge status: Wrong Answer
import collections
n,k = map(int,input().split())
a = list(map(int,input().split()))
c = sorted(list(collections.Counter(a).values()))
print(sum(c[:k-1]))
# Judge status: Accepted
S = input()
T = input()
for i in range(100):
    if S == T:
        print('Yes')
        exit()
    S = S[-1] + S[:-1]
print('No')
# Judge status: Wrong Answer
k, n = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
df = [0] * (n - 1)
for i in range(n - 1):
    df[i] = abs(x[i + 1] - x[i])

df.sort()
print(sum(df[: n - k]))
# Judge status: Wrong Answer
n = int(input())
s = input()

i_cnt = s.count('I')
d_cnt = s.count('D')

ans = max(0, (i_cnt - d_cnt))
print(ans)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
k = int(input())

m = max(a,b,c)
print(m * 2 * k + a + b + c - max(a,b,c))
# Judge status: Accepted
def main():
    n = int(input())
    a = [int(v) for v in input().split()]
    m = 1000000007
    ans = 0
    ss = sum(a[1:])
    for i in range(n-1):
        ans += a[i]*ss
        ss -= a[i+1]
        ans %= m
    print(ans)

main()
# Judge status: Accepted
import sys
input = sys.stdin.readline
from collections import deque
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

d = deque()
for i in range(N):
    p = bisect.bisect_left(d, A[i])
    if p==0:
        d.appendleft(A[i])
    else:
        d[p-1] = A[i]
ans = len(d)
print(ans)
# Judge status: Accepted
def main():
    a, b = input().split(" ")
    num = int(a + b)
    i = 2
    answer = False
    while i * i <= num:
        if i * i == num:
            answer = True
        i += 1
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
Y = []
for i in range(M-1):
    Y.append(X[i+1]-X[i])
Y.sort()
print(sum(Y[:M-N]))
# Judge status: Accepted
import sys
input = sys.stdin.readline
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]
INF = 10**18
arr = deque([])
for a in A:
    l, r = -1, len(arr)
    while (r-l) > 1:
        mid = (r+l)//2
        if arr[mid] < a:
            l = mid
        else:
            r = mid
    if l == -1:
        arr.appendleft(a)
    else:
        arr[l] = a
print(len(arr))
# Judge status: Accepted

x,a,b = map(int,input().split())

if abs(a-x) >= abs(b-x):
    print("B")
else:
    print("A")
# Judge status: Accepted
n = int(input())
ns = list(map(int, input().split()))
li = 1
ans = 0
max_leafs = [1]
for i in ns:
    li = (li - i) * 2
    max_leafs.append(li)
points = ns.pop()
ans += points
for i in range(len(ns)-1, -1, -1):
    a = ns[i]
    points = min(points + a, max_leafs[i])
    ans += points
if max_leafs[-1] < 0:
    print(-1)
else:
    print(ans)
# Judge status: Accepted
Y, M, D = map(int, input().split('/'))

if Y >= 2019 and M >= 5:
  print("TBD")
else:
  print("Heisei")
# Judge status: Wrong Answer
N = int(input())
P = list(map(int, input().split()))
Q=list(map(int, input().split()))
l = [i for i in range(N)]

fac = [0] * 8
fac[1] = 1
for i in range(2, N):
    fac[i] = i * fac[i - 1]
print(fac)
a = 0
l = list(range(1, N + 1))
for i in range(N):
    a += l.index(P[i]) * fac[len(l) - 1]
    print(l.index(P[i]), fac[len(l) - 1])
    l.remove(P[i])

b = 0
l = list(range(1, N + 1))
for i in range(N):
    b += l.index(Q[i]) * fac[len(l) - 1]
    l.remove(Q[i])

print(abs(a-b))
# Judge status: Accepted
import queue
n,m=map(int,input().split())
e=[[] for _ in range(n+1)]
INF=10**18
d=[INF]*(n+1)
ans=[0]*(n+1)
for _ in range(m):
  a,b=map(int,input().split())
  e[a]+=[b]
  e[b]+=[a]
q=queue.Queue()
q.put(1)
d[1]=0
while not q.empty():
  now=q.get()
  for to in e[now]:
    if d[to]==INF:
      ans[to]=now
      d[to]=d[now]+1
      q.put(to)
print('Yes')
for i in ans[2:]:
  print(i)
# Judge status: Accepted

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

cdy=0
for i in range(n-1):
    ai=a[i]
    aip=a[i+1]
    if a[i]>x:
        a[i]=x
        cdy=cdy+ai-x
    ai=a[i]
    if a[i]+a[i+1]>x:
        a[i+1]=x-a[i]
        cdy=cdy+ai+aip-x

print(cdy)
# Judge status: Accepted
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[0,0,0] for i in range(n+1)]

for i in range(1,n+1):
    
    for j in range(3):
        for k in range(3):
            if k!=j:
                dp[i][j]=max(dp[i][j],dp[i-1][k]+l[i-1][j])
print(max(dp[-1]))
# Judge status: Wrong Answer
n = 6
a = [int(e) for e in input().split()]
count = 1
for i in range(1, len(a)-1):
    if a[i] < a[i-1] and a[i+1] < a[i]:
        count = count + 1
    elif a[i] > a[i-1] and a[i] > a[i+1] :
        count = count + 1
print(count)
# Judge status: Wrong Answer
string = input('入力して下さい')
if string.endswith('s'):
    print(string + 'es')
else:
    print(string + 's')
# Judge status: Wrong Answer
# 27

n, x = map(int, input().split())
a = list(map(int, input().split()))
num = 0
for i in range(len(a)-1):
    if x >= a[i] :
        num += 1
        x -= a[i]
if x == a[-1]:
    num += 1
print(num)
# Judge status: Accepted
x, y, z = map(int,input().split())

print((x-z)//(y+z))
# Judge status: Accepted
w, h, n = map(int, input().split())
sw = 0
sh = 0
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        sw = max(sw, x)
    elif a == 2:
        w = min(w, x)
    elif a == 3:
        sh = max(sh, y)
    elif a == 4:
        h = min(h, y)
if sw < w and sh < h:
    print((w-sw) * (h-sh))
else:
    print(0)
# Judge status: Wrong Answer
K,S = map(int,input().split())
num = 0
for i in range(K+1):
  for j in range(K+1) :
    k = S - i - j
    if k <= K :
      num += 1
print(num)
# Judge status: Accepted
N = int(input())
S = list(input())
dic = {}

for i in range(N):
  if S[i] not in dic.keys():
    dic[S[i]] = [i]
  else:
    dic[S[i]].append(i)
    
ans = 0
for j in range(1,N):
  cnt = 0
  for k in dic.values():
    check1 = False
    check2 = False
    for l in k:
      if l < j:
        check1 = True
      if j <= l:
        check2 = True
    if check1 and check2:
      cnt += 1
  ans = max(ans, cnt)
  
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=0
count=0
if a.count(1)==0:
    print(-1)
else:
    for i in range(n):
        if count+1 != a[i]:
            ans+=1
        else:
            count+=1
    print(ans)
# Judge status: Wrong Answer
import numpy as np 
n=int(input())
a=np.array(list(map(int, input().split())))
sum=0
i=0
while a.any():
  x= np.count_nonzero(a & 1)
  sum+=x*(n-x)<<i
  a>>=1
  i+=1
  
print(int(sum%(1e9+7)))
# Judge status: Accepted
N=int(input())
K=int(input())
X=int(input())
Y=int(input())

if N<=K:
  print(X*N)
else:
  print(X*K+(N-K)*Y)
# Judge status: Accepted
d, t, s = list(map(int, input().split()))
 
if t * s >= d:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a, b, c = input().split()
    
print(a[0], b[0], c[0])
# Judge status: Accepted
def f(n):
    ans=1
    for i in range(2,n+1):
        ans=ans*i
    return ans

from math import sqrt
n=int(input())
x=[]
y=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append(a)
    y.append(b)
ans=[]
for i in range(n-1):
    for j in range(i+1,n):
        ans.append(sqrt((x[i]-x[j])**2+(y[i]-y[j])**2))
res=0
for i in range(len(ans)):
    res+=ans[i]*2*f(n-1)
print(res/f(n))
# Judge status: Wrong Answer
from collections import Counter

M = 998244353
N = int(input())
D = list(map(int, input().split()))
assert len(D) == N
dcnt = Counter(D)

def solve():
    if D[0] != 0:
        return 0
    D.sort()
    if len(D) > 1 and D[1] != 1:
        return 0
    i = 1
    res = 1
    leaf = 1
    while i < N:
        k = D[i]
        c = dcnt[k] % M
        res *= pow(leaf, c, M)
        leaf = c
        i += c
    return res

if __name__ == "__main__":
    print(solve())
# Judge status: Wrong Answer
n=int(input())
for i in range(n):
  if i**2 == n:
    print(i**2)
    break
  if i**2 > n:
    print((i-1)**2)
    break
# Judge status: Accepted
N, Y = [int(x) for x in input().split()]

c10000 = -1
c5000 = -1
c1000 = -1

for a in range(N + 1):
    for b in range(N - a + 1):
        c = N - a - b
        total = 10000 * a + 5000 * b + 1000 * c
        if total == Y:
            c10000 = a
            c5000 = b
            c1000 = c
            break

print(str(c10000) + ' ' + str(c5000) + ' ' + str(c1000))
# Judge status: Accepted
import sys
readline = sys.stdin.readline

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

if H == 1 or W == 1:
  print(1)
  exit(0)
  
if (H * W) % 2 == 1:
  print((H * W) // 2 + 1)
else:
  print((H * W) // 2)
# Judge status: Accepted
S = input()
K = int(input())
for x in S:
    x = int(x)
    if x != 1:
        print(x)
        break
    else:
        if K == 1:
            print(x)
            break
        else:
            K -= 1
# Judge status: Wrong Answer
inp1 =input().split(" ")
HP,N= int(inp1[0]),int(inp1[1])

inp2 = input().split(" ")

ATK = 0
for x in range(N):
  ATK += int(inp2[x])
  
if HP <= ATK:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
n = int(input())
s = input()
t = input()
cnt = 0
for i in range(n):
    if s[i:] == t[:n-i]:
        cnt += n - i
        break
print(2 * n - cnt)
# Judge status: Accepted
dishes = []
serve = []
for i in range(5):
    dish = int(input())
    dishes.append(dish)
    if dish % 10 != 0:
        time = 10 - dish%10
        serve.append(time)
if serve == []:
    print(sum(dishes))
else:
    sort_serve = sorted(serve)
    sort_serve.remove(sort_serve[len(sort_serve)-1])
    ans = sum(dishes) + sum(sort_serve)
    print(ans)
# Judge status: Wrong Answer
def resolve():
    _, X = [int(i) for i in input().split()]
    xx = [int(i) for i in input().split()]
    ans = float("inf")
    for x in xx:
        ans = min(ans, abs(X - x))
    print(ans)


if __name__ == "__main__":
    resolve()
# Judge status: Accepted
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


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

ans = 0
prev = None
for a in A:
    if prev is None:
        prev = a
        continue
    if prev > a:
        diff = prev - a
    else:
        diff = 0
    ans += diff
    prev = a + diff

print(ans)
# Judge status: Accepted
s=list(input())
t=list(input())
s_r=["*"]
t_r=["*"]
s_ans=[]
t_ans=[]
for c in s:
  if c in s_r:
    s_ans.append(s_r.index(c))
  else:
    s_r.append(c)
    s_ans.append(len(s_r)-1)
for c in t:
  if c in t_r:
    t_ans.append(t_r.index(c))
  else:
    t_r.append(c)
    t_ans.append(len(t_r)-1)
print("Yes" if t_ans==s_ans else "No")
# Judge status: Wrong Answer
L=int(input())

if L%3==0:
    print((L/3)**3)
elif L%3==2:
    print((L+1)/3 * (L+1)/3*(L-2)/3)
elif L%3==1:
    print((L+2)/3 * (L-1)/3*(L-1)/3)
# Judge status: Accepted
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
for i in range(N):
  print(c[i+1])
# Judge status: Accepted
#!/usr/bin/env python3

N = int(input())

print(N*800 - N//15 * 200)
# Judge status: Accepted
a,b,t = map(int,input().split())
ans = t//a*b
print(ans)
# Judge status: Accepted
Si = input()
S1 = int(Si[0])
S2 = int(Si[1])
S3 = int(Si[2])
n = 0
if S1:
  n += 1
if S2:
  n += 1
if S3:
  n += 1
print(n)
# Judge status: Accepted
import itertools
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
p=P.copy()
p.sort()
p=itertools.permutations(p)
j=0
for i in p:
    j+=1
    if list(i)==P:
        pcount=j
    if list(i)==Q:
        qcount=j
print(abs(pcount-qcount))
# Judge status: Accepted
import sys

stdin = sys.stdin

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

def main():
    s = ns()
    ACGT = "AGCT"
    ans = 0
    tmp = 0
    for i in s:
        if i in ACGT:
            tmp += 1
        else:
            ans = max(ans, tmp)
            tmp = 0
    ans = max(ans, tmp)
    print(ans)
    return

if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
a = sorted([int(input()) for _ in range(n)])
ans = 0
tmp = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        tmp += 1
    else:
        if tmp % 2 == 1:
            ans += 1
        tmp = 1
if tmp % 2 == 1:
    ans += 1
print(ans)
# Judge status: Accepted
A, B, C = map(int, input().split())
print(min(B // A, C))
# Judge status: Accepted
s = input()
flag = [0] * 4
for i in range(len(s)):
    if s[i] == "N":
        flag[0] = 1
    elif s[i] == "W":
        flag[1] = 1
    elif s[i] == "S":
        flag[2] = 1
    else:
        flag[3] = 1

print("Yes" if flag[0] == flag[2] and flag[1] == flag[3] else "No")
# Judge status: Accepted
#ABC112
    
n,t = list(map(int,input().split()))
c = [list(map(int,input().split())) for _ in range(n)]
m = 1001
for i in range(n):
    if c[i][1] <= t and m > c[i][0]:
        m = c[i][0]
        
print(m) if m != 1001 else print("TLE")
# Judge status: Wrong Answer
N,K,*P = map(int,open(0).read().split())
P = [(P[i]+1)/2 for i in range(N)]
E = [sum(P[:i]) for i in range(1,N+1)]
m = 0
for i in range(N-K):
  if m < E[i+K]-E[i]:
    m= E[i+K]-E[i]
print(m)
# Judge status: Accepted
H, A = map(int, input().split())

print((H + A - 1)//A)
# Judge status: Wrong Answer
S = list(input())
S = [int(s) for s in S]
N = len(S)
print('S:', S)

count=0
i=1
while True:
    print(S,i)
    if len(S)==0 or len(S)==1 or sum(S)==len(S) or sum(S)==0 :
        break

    elif S[i-1] != S[i]:
        del S[i-1]
        del S[i-1]
        count+=1
        i=1
    else:
        i+=1

print(count*2)
# Judge status: Accepted
a,b = map(int,input().split())

if a*b % 2 == 1:
    print("Odd")
else:
    print("Even")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range (1,n):
  if a[i] -1 == a[i-1]:
    ans += c[i-1]
print(ans+sum(b))
# Judge status: Wrong Answer

def main():
 a,b = map(int,input().split())
 print(a)
main()
# Judge status: Wrong Answer
max_dis = 0
a = int(input())
for _ in range(3):
    input()
b = int(input())
k = int(input())
if b - a < k:
    print("Yay!")
else:
    print(":(")
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
c = [0]*(n-1)
s = [0]*(n-1)
f = [0]*(n-1)

for i in range(n-1):
    c[i], s[i], f[i] = map(int, input().split())

# from functools import lru_cache
# @lru_cache(None)
def dfs(eki,t):
    if eki == n-1:
        return t

    cc = c[eki]
    ss = s[eki]
    ff = f[eki]

    return dfs(eki+1, max(ss, -(-t)//ff*ff)+cc)

for i in range(n):
    print(dfs(i,0))
# Judge status: Wrong Answer
p=sum(map(int,input().split()));print("Impossible"if p%3else"Possible")
# Judge status: Accepted
print("YNeos"[len(set(input()))%2::2])
# Judge status: Accepted
from sys import stdin
import math

def dgtsum(x):
    if(x==0):
        return 0
    return x%10+dgtsum(x//10)

n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
    if(a<=dgtsum(i) and dgtsum(i)<=b):
        ans=ans+i

print(ans)
# Judge status: Wrong Answer

def solve():
    A = [0]*N
    A[-1] = B[-1]
    for i in range(N-2,-1,-1):
        A[i] = min(A[i+1], B[i-1])
#        print(i)
#    print(A)
    print(sum(A))

if __name__ == "__main__":
    N = int(input())
    B = list(map(int, input().split()))
    solve()
# Judge status: Accepted
from operator import itemgetter

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

an = [0]*n

sc = 0
er = 0

for i in range(m):
    t, s = map(str, input().split())
    p = int(t)-1
    if (an[p] != m+1 and s == "AC"):
        sc += 1
        er += an[p]
        an[p] = m+1
    elif (an[p] != m+1 and s == "WA"):
        an[p] += 1


print("{} {}".format(sc, er))
# Judge status: Accepted
from sys import stdin, stdout
r = int(stdin.readline())
import math
c = 2*math.pi*r
stdout.write("{}\n".format(c))
# Judge status: Accepted
from itertools import accumulate
INF = float('inf')
N = int(input())
A = [int(x) for x in input().split()]

cumA = list(accumulate(A))
ans = INF
for i in range(N - 1):
    x = cumA[i]
    y = cumA[N - 1] - cumA[i]
    ans = min(ans, abs(x - y))

print(ans)
# Judge status: Accepted
x = int(input())
for a in range(-5000,5001):
  for b in range(-5000,5001):
    if(a**5-b**5==x):
      print(a,b)
      break
  else:continue
  break
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
buf=0
for i in range(1,max(a,b)+1):
    if a%i==0 and b%i==0:
        buf+=1
    if buf==k:
        print(i)
        break
# Judge status: Accepted
n=int(input())
v=list(map(int,input().split()))

v.sort()
for i in range(n-1):
  v[i+1]=(v[i]+v[i+1])/2
print(v[n-1])
# Judge status: Accepted
A, B= map(int, input().split())
diff_ba = B-A
if diff_ba % 2 == 0:
  print(A + diff_ba//2)
else:
  print("IMPOSSIBLE")
# Judge status: Accepted
S = input()

if S == 'ABC':
  print( "ARC" )
else:
  print( "ABC" )
# Judge status: Accepted
N,M=map(int, input().split())
A=list(map(int, input().split()))
A = sorted(A, reverse=True)

s = sum(A)
th = s * 1/(4*M)

if A[M-1] < th: print('No')
else: print('Yes')