Harryxun/stf_run huggingface dataset:
n=int(input())
S=str(input())
s=list(S)
i=1
while True:
    if n ==1:
        break
    if s[i-1]==s[i]:
        s.pop(i)
        n -= 1
    else:
        i +=1
    if i > n:
        break
print(len(s))

### FIXED CODE ###

n=int(input())
S=str(input())
s=list(S)
i=1
while True:
    if n ==1 or n==0:
        break
    if s[i-1]==s[i]:
        s.pop(i)
        n -= 1
    else:
        i +=1
    if i >= n:
        break
print(len(s))
N=int(input())
listA=list(map(int, input().split()))
Q=int(input())

listB=[] #appendのために宣言が必要
while True:
    try:
        listB.append(list(map(int,input().split())))

    except:
        break;
        
sum=sum(listA)
numlist=[0]*(10*5+1)
for i in range(10*5+1):
  numlist[i]=listA.count(i)
  
for i in range(Q):
  B=listB[i][0]
  C=listB[i][1]
  sum=sum+(C-B)*numlist[B]
  numlist[C]+=numlist[B]
  numlist[B]=0
  # print(numlist)
  print(sum)


### FIXED CODE ###

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

listB=[] #appendのために宣言が必要
while True:
    try:
        listB.append(list(map(int,input().split())))

    except:
        break;
        
sum=sum(listA)
numlist=[0]*(10**5+1)
for i in listA:
  numlist[i]+=1
  
for i in range(Q):
  B=listB[i][0]
  C=listB[i][1]
  if numlist[B]!=0:
    sum=sum+(C-B)*numlist[B]
    # print(C)
    numlist[C]+=numlist[B]
    numlist[B]=0
    # print(numlist)
  print(sum)
N = int(input())

n = 1000 - N
if N == 2000 or N == 3000 or N == 4000 or N ==5000 or N == 6000 or N == 7000 or N == 8000 or N == 9000 or N == 10000:
  print(0)
elif 1000 < N:
  m = n * (-1)
  print(1000-((int(str(m)[-3])*100) + (int(str(m)[-2])*10) + (int(str(m)[-1]))))
else:
  print(n)





### FIXED CODE ###

N = int(input())

n = 1000 - N
if N == 2000 or N == 3000 or N == 4000 or N ==5000 or N == 6000 or N == 7000 or N == 8000 or N == 9000 or N == 10000or N == 0:
  print(0)
elif 1000 < N:
  m = n * (-1)
  if m < 10:
    print(1000-m)
  elif m < 100:
    print(1000-(int(str(m)[-2])*10) + (int(str(m)[-1])))
  else:
    print(1000-((int(str(m)[-3])*100) + (int(str(m)[-2])*10) + (int(str(m)[-1]))))
else:
  print(n)
N, X, Y = map(int, input().split())

import numpy as np
from scipy.sparse.csgraph import shortest_path

M = np.zeros((N,N))

for i in range(1,N):
    M[i-1][i] = 1
    M[i][i-1] = 1
    M[X-1][Y-1] = 1
    M[Y-1][X-1] = 1

M_diff = shortest_path(M)

for i in range(1,N):
    ans = 0
    for k in range(0,N):
        for l in range(0,N):
            if int(M_diff[k][l]) == i:
                ans += 1
    print(int(ans/2))


### FIXED CODE ###

N, X, Y = map(int, input().split())

memo = [0] *(N)

for i in range(1, N):
    for j in range(i, N + 1):
        min_dis = min((j - i), abs(X - i) + 1 + abs(j - Y))
        memo[min_dis] += 1

for k in range(1,N):
    print(memo[k])
n, x = map(int, input().split())
l = list(map(int, input().split()))

count = 0
sum = 0

while sum <= x and count <= n:
  sum += l[count]
  count+=1
print(count)

### FIXED CODE ###

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

count = 0
sum = 0

for i in range(len(l)):
  sum += l[i]
  if sum <= x:
    count+=1
print(count + 1)
import math
import sys
input = sys.stdin.readline


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


def main():
    A, B = map(int, input().split())

    print(lcm(A, B))


if __name__ == "__main__":
    main()


### FIXED CODE ###

import fractions
import sys
input = sys.stdin.readline


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


def main():
    A, B = map(int, input().split())

    print(lcm(A, B))


if __name__ == "__main__":
    main()
w,h,x,y = map(double, input().split())
if  w/2 == x and h/2 == y:
	ans = 1
else:
	ans = 0
print (w*h/2.0,ans)


### FIXED CODE ###

w,h,x,y = map(int, input().split())
if  w/2 == x and h/2 == y:
	ans = 1
else:
	ans = 0
print (w*h/2.0,ans)
d,g = map(int,input().split())
ps=[]
cs=[]
counts = []
count = 0
visited = [0 for i in range(d)]
sums=0


for i in range(d):
  p,c = map(int,input().split())
  ps.append(p)
  cs.append(c)

def dfs(i,count,visited,sums):
  if visited[i] != ps[i]:
    local_visited=visited[:]
    count += 1
    sums += (i+1)*100
    local_visited[i] += 1
    if local_visited[i] == ps[i]:
      sums += cs[i]
    if sums >= g:
      counts.append(count)
      return
    for i in range(d):
      dfs(i,count,local_visited,sums)


for i in range(d):
  dfs(i,count,visited,sums)


print(min(counts))



### FIXED CODE ###

import itertools
from collections import Counter
D, G = map(int, input().split())
P = [list(map(int, input().split())) for i in range(D)]
min_num = 10**8

judge_list = list(itertools.product([0, 1, 2], repeat=D)) #0:中途半端に解く 1:一問も解かない 2: 全部解く


for judge in judge_list:
    score = 0
    num = 0
    d = Counter() #インスタンスを生成
    d.update(judge)
    if (d[0] <= 1):
        for i in range(1, len(judge) + 1):
            if score >= G:
                break

            if judge[-i] == 1:
                pass

            if judge[-i] == 2:
                score += P[-i][0] * (D - i + 1) * 100 + P[-i][1]
                num += P[-i][0]

            if (judge[-i] == 0):
                for j in range(P[-i][0]):
                    if score >= G:
                        break
                    score += 100 * (D - i + 1)
                    num += 1

        if score >= G:
            min_num = min(num, min_num)

print(min_num)
X = int(input())
A = int(input())

if X<A:
  print(0)
else:
  print(10)


### FIXED CODE ###

X,A = map(int,input().split())

if X<A:
	print(0)
else:
	print(10)
# coding: utf-8

import sys
import math
input = sys.stdin.readline

# N = int(input())
# L = [int(x) for x in input().split()]
N, K = map(int, input().split())
# S = input()

max_pow = int(math.log2(K) + 0.9)

one_half = [0] * (max_pow + 1)
one_half[0] = 1
for i in range(1, max_pow + 1) :
    one_half[i] = one_half[i - 1] * 0.5

ans = 0
for i in range(1, N + 1) :
    pow_num = math.ceil(math.log2(K / i))
    
    if pow_num <= 0 :
        ans += 1
    else :
        ans += one_half[pow_num]
        
print(ans / N)


### FIXED CODE ###

# coding: utf-8

import sys
import math
input = sys.stdin.readline

# N = int(input())
# L = [int(x) for x in input().split()]
N, K = map(int, input().split())
# S = input()

max_pow = math.ceil(math.log2(K) + 0.9)

one_half = [0] * (max_pow + 1)
one_half[0] = 1
for i in range(1, max_pow + 1) :
    one_half[i] = one_half[i - 1] * 0.5

ans = 0
for i in range(1, N + 1) :
    pow_num = math.ceil(math.log2(K / i))
    
    if pow_num <= 0 :
        ans += 1
    else :
        ans += one_half[pow_num]

print(ans / N)
import math
r = int(input())

print("{0:5f}".format(r**2*math.pi) , end = " ")
print("{0:5f}".format(2*r*math.pi))

### FIXED CODE ###

import math
r = float(input())

print("{0:5f}".format(r**2*math.pi) , end = " ")
print("{0:5f}".format(2*r*math.pi))
from dataclasses import dataclass
    
class BIT:
    '''
    All methods use 0-based index while the implementation use 1-based index
    '''
    def __init__(self, N, val=0):
        self.data = [val] * (N + 1)
        self.N = N
    
    def add_at(self, idx, val):
        i = idx + 1
        while i <= self.N:
            self.data[i] += val
            i += i & (-i)
    
    def sum_to(self, idx):
        res = 0
        i = idx + 1
        while i > 0:
            res += self.data[i]
            i -= i & (-i)
        return res
    
    def sum_in(self, l, r): # [l, r]
        return self.sum_to(r) - self.sum_to(l - 1)
    
    
@dataclass
class Query:
    i: int
    l: int
    r: int
    
    
N, Q = map(int, input().split())
C = list(map(int, input().split()))
    
queries = [[] for _ in range(N)]
for i in range(Q):
    l, r = map(int, input().split())
    l, r = l - 1, r - 1
    queries[r].append(Query(i, l, r))
    
V = max(C)
bit = BIT(N)
last = [-1] * (max(C) + 1)
    
query_idx = 0
ans = [-1] * Q
for i, c in enumerate(C):
    if last[c] != -1:
        bit.add_at(last[c], -1)    
    bit.add_at(i, +1)
    last[c] = i
    
    for q in queries[i]:
        ans[q.i] = bit.sum_in(q.l, q.r)
    
print('\n'.join(map(str, ans)))

### FIXED CODE ###


class BIT:
    '''
    All methods use 0-based index while the implementation use 1-based index
    '''
    def __init__(self, N, val=0):
        self.data = [val] * (N + 1)
        self.N = N
    
    def add_at(self, idx, val):
        i = idx + 1
        while i <= self.N:
            self.data[i] += val
            i += i & (-i)
    
    def sum_to(self, idx):
        res = 0
        i = idx + 1
        while i > 0:
            res += self.data[i]
            i -= i & (-i)
        return res
    
    def sum_in(self, l, r): # [l, r]
        return self.sum_to(r) - self.sum_to(l - 1)
    
    
class Query:
    def __init__(self, i, l, r):
        self.i = i
        self.l = l
        self.r = r
    
    
N, Q = map(int, input().split())
C = list(map(int, input().split()))
    
queries = [[] for _ in range(N)]
for i in range(Q):
    l, r = map(int, input().split())
    l, r = l - 1, r - 1
    queries[r].append(Query(i, l, r))
    
bit = BIT(N)
last = [-1] * (max(C) + 1)
    
query_idx = 0
ans = [-1] * Q
for i, c in enumerate(C):
    if last[c] != -1:
        bit.add_at(last[c], -1)    
    bit.add_at(i, +1)
    last[c] = i
    
    for q in queries[i]:
        ans[q.i] = bit.sum_in(q.l, q.r)
    
print('\n'.join(map(str, ans)))
s = input()
if not s[1]==s[2]==s[3]:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
if s=='AAA' or s=='BBB':
    print('No')
else:
    print('Yes')
N = int(input())
N_List = list(map(int,input().split()))
NR_List = [i // 400 for i in N_List]
Number_NRD = len(set([i for i in NR_List if i < 8]))
Number_NRU = len([i for i in NR_List if i >= 8])
max_p= (Number_NRD + Number_NRU,8)[Number_NRD +Number_NRU>=8]
min_P= (Number_NRD,1)[Number_NRD == 0]
print(str(min_p) + " " + str(max_p))

### FIXED CODE ###

N = int(input())
N_List = list(map(int,input().split()))
NR_List = [i // 400 for i in N_List]
Number_NRD = len(set([i for i in NR_List if i < 8]))
Number_NRU = len([i for i in NR_List if i >= 8])
max_p= Number_NRD + Number_NRU
min_p= (Number_NRD,1)[Number_NRD == 0]
print(str(min_p) + " " + str(max_p))
A, B = map(int,input().split(" "))
print(int(A * B))

### FIXED CODE ###

import math
A, B = map(str,input().split(" "))
B_ = int(B.split(".")[0])*100 + int(B.split(".")[1])

print(int(A) * B_ // 100)
import sys
input = sys.stdin.readline
#-------------
n,k = map(int,input().split())
a = list(map(int,input().split()))
#-------------
a.sort(reverse = True)
w = 10**9 + 7
ans = 1
if k%2 == 1:#kは奇数
  for i in range(k):
    ans *= a[i]
  print(ans % w)

else:#kは偶数
  if n%2 == 0:#nは偶数
    A = n//2
    a_new = [a[2*i]*a[2*i+1] for i in range(A)]
    a_new.sort(reverse = True)
    for j in range(k//2):
      ans *= a_new[j]
    print(ans % w)
      
  else:#nは奇数
    a_plus =[]
    a_minus = []
    pos = 0
    neg = 0
    for i in range(n):
      if a[i] > 0 :
        a_plus.append(a[i])
        pos += 1
      if a[i] < 0 :
        a_minus.append(a[i])
        neg += 1
    a_plus.sort(reverse = True)
    a_minus.sort()
    a_plus_new = [a_plus[2*i]*a_plus[2*i+1] for i in range(pos//2)]
    a_minus_new = [a_minus[2*i]*a_minus[2*i+1] for i in range(neg//2)]
    a_new = a_plus_new + a_minus_new
    a_new.sort(reverse = True)
    for j in range(k//2):
      ans *= a_new[j]
    print(ans % w)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
from collections import deque

def main():
    R,C= map(int,input().split())

    S = [0,0]

    mv = [[1,0],[-1,0],[0,-1],[0,1]]
    MAP = []
    flg = 0
    block = 0
    for _ in range(R):
        t = list(input())
        block += t.count('#')
        MAP.append(t)
    stack = deque([S])
    MAP_c = [[None]*C for _ in range(R)]
    MAP_c[0][0] = 1
    while stack:
        v = stack.popleft()
        for m in mv:
            u = [v[0]+m[0],v[1]+m[1]]
            if u[0] >=0 and u[0] < R and u[1] > 0 and u[1] < C and MAP[u[0]][u[1]] == '.':
                MAP[u[0]][u[1]] = '#'
                MAP_c[u[0]][u[1]] = MAP_c[v[0]][v[1]] + 1
                stack.append(u)
                if u == [R-1,C-1]:
                    flg = 1

        if flg == 1:
            break

    a = MAP_c[R-1][C-1]
    print(R*C - a - block)


main()

### FIXED CODE ###

from collections import deque

def main():
    R,C= map(int,input().split())

    S = [0,0]

    mv = [[1,0],[-1,0],[0,-1],[0,1]]
    MAP = []
    flg = 0
    block = 0
    for _ in range(R):
        t = list(input())
        block += t.count('#')
        MAP.append(t)
    stack = deque([S])
    MAP_c = [[None]*C for _ in range(R)]
    MAP_c[0][0] = 1
    while stack:
        v = stack.popleft()
        for m in mv:
            u = [v[0]+m[0],v[1]+m[1]]
            if u[0] >=0 and u[0] < R and u[1] >= 0 and u[1] < C and MAP[u[0]][u[1]] == '.':
                MAP[u[0]][u[1]] = '#'
                MAP_c[u[0]][u[1]] = MAP_c[v[0]][v[1]] + 1
                stack.append(u)
                if u == [R-1,C-1]:
                    flg = 1

        if flg == 1:
            break

    if flg == 1:
        a = MAP_c[R-1][C-1]
        print(R*C - a - block)
    else:
        print(-1)


main()
N = 0
while N<1 or N>50:
	N = int(input('N: '))
    if N<1 or N>50:
      print('1 <= N <= 50')
K = 0
while K<1 or K>N:
  K = int(input('K: '))
  if K<1 or K>N:
    print('1 <= K <= N')
S = ''
while len(S) != N:
  S = input('S: ')
  if len(S) != N:
    print("Length doesn't Match")
  for i in S:
    if i != 'A' and i != 'B' and i != 'C':
      print('Only A, B and C allowed')
      S = ''
      break

S1 = ''
for i in range (N):
  if i + 1 == K:
    if S[i] == 'A':
      S1 += 'a'
    elif S[i] == 'B':
      S1 += 'b'
    elif S[i] == 'C':
      S1 += 'c'
  else:
 	 S1 += S[i]
S = S1
print(S)

### FIXED CODE ###

n, k = map(int, input().split())
s = list(input())
s[k-1] = chr(ord(s[k-1])+ord('a')-ord('A'))
print(''.join(s))
# https://atcoder.jp/contests/abc157/tasks/abc157_e

class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

sc = iter(open(0).read().split())
ni = lambda: int(next(sc))
ns = lambda: next(sc)
nc = lambda: ord(next(sc)) - ord('a')

N, S, Q = ni(), list(ns()), ni()

B = [BIT(N) for _ in range(26)]
for i, s in enumerate(S, 1):
    B[ord(s) - ord('a')].add(i, 1)

A = []
for _ in range(Q):
    if ni() == 1:
        i, c = ni(), nc()
        B[ord(S[i - 1]) - ord('a')].add(i, -1)
        S[i - 1] = c
        B[c].add(i, 1)
    else:
        l, r = ni(), ni()
        A.append(sum(b.sum(l - 1) < b.sum(r) for b in B))

print("\n".join(map(str, A)))

### FIXED CODE ###

# https://atcoder.jp/contests/abc157/tasks/abc157_e

class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

sc = iter(open(0).read().split())
ni = lambda: int(next(sc))
ns = lambda: next(sc)

N, S, Q = ni(), list(ns()), ni()

B = [BIT(N) for _ in range(26)]
for i, s in enumerate(S, 1):
    B[ord(s) - ord('a')].add(i, 1)

A = []
for _ in range(Q):
    if ni() == 1:
        i, c = ni(), ns()
        B[ord(S[i - 1]) - ord('a')].add(i, -1)
        S[i - 1] = c
        B[ord(c) - ord('a')].add(i, 1)
    else:
        l, r = ni(), ni()
        A.append(sum(b.sum(l - 1) < b.sum(r) for b in B))

print("\n".join(map(str, A)))
s = input().split()
n = input().split()
s2 = input()

if s[0] == s2:
  n[0] = n[0] - 1
else:
  n[1] = n[1] - 1

print(str(n[0]) +' '+str(n[1]))


### FIXED CODE ###

# -*- coding: utf-8 -*-
s = input().split()
n = list(map(int,input().split()))
s2 = input()

if s[0] == s2:
  n[0] = n[0] - 1
else:
  n[1] = n[1] - 1

print(str(n[0]) +' '+str(n[1]))
c = {"1":"", "2":"k", "3":"s", "4":"t", "5":"n",
     "6":"h","7":"m", "8":"y", "9":"r", "0":"w"}
m = {"T":"a", "L":"i", "U":"u", "R":"e", "D":"o"}
s = input()
ans = ""
for i in range(0, len(s), 2):
  if com == "0U":ans += "nn"
  else:ans += c[com[0]] + m[com[1]]
print(ans)


### FIXED CODE ###

c = {"1":"", "2":"k", "3":"s", "4":"t", "5":"n",
     "6":"h","7":"m", "8":"y", "9":"r", "0":"w"}
m = {"T":"a", "L":"i", "U":"u", "R":"e", "D":"o"}
s = input()
ans = ""
for i in range(0, len(s), 2):
  com = s[i:i+2]
  if com == "0U":ans += "nn"
  else:ans += c[com[0]] + m[com[1]]
print(ans)
x=input()
count=0
x_count=0
o=None
judge=[]
string=["k","e","y","e","n","c","e"]
for i in x:
    if(i==string[count] and count<=6):
        judge.append(i)
        count=count+1

for i in judge:        
    if(i==string[x_count]):
        o=True
        x_count=x_count+1
    else:
        x_count=x_count+1
        o=False
        break

if(o==True):
    print("YES")
else:
    print("NO")


### FIXED CODE ###

S = input()
KEYENCE = "keyence"
 
 
isKeyence = False
for i in range(len(S)):
    for j in range(i, len(S)):
        s = S[:i] + S[j:]
        if s == KEYENCE:
            isKeyence = True
if isKeyence:
    print("YES")
else:
    print("NO")
a = input()
s = input()

if a >= 3200:
    print(s)
else:
    print('red')

### FIXED CODE ###

a = int(input())
s = input()

if a >= 3200:
  print(s)
else:
  print('red')
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

D = (N-K)*X + (N-(K+1))*Y 

# N泊連続で行う。最初の K 泊まで X 円.　K+1泊以降はY円

if  N <= (K+1):
    print(X*X)
elif  N >= (K+1):
    print(((N-K)*X) + ((N-(K+1))*Y)


#　10泊する　5泊目までX円　6泊目からY円　(((N-K)*X) + ()

### FIXED CODE ###

N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N <= K :
    ans = X * N
else :
    ans = X * K + Y * (N - K)
print(ans)
X,Y,Z,K = (int(i) for i in input().split())  
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ans = []
b=0
c=0
for a in range(len(A)):
	if (a+1)*(b+1)*(c+1)>K:
		break
	for b in range(len(B)):
		if (a+1)*(b+1)*(c+1)>K:
			break
		for c in range(len(C)):
			if (a+1)*(b+1)*(c+1)<=K:
				ans.append(A[a]+B[b]+C[c])
			else:
				break

ans.sort(reverse=True)
for i in range(K):
	print(ans[i])

### FIXED CODE ###

X,Y,Z,K = (int(i) for i in input().split())  
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ans = []
b=0
c=0
for a in range(len(A)):
	for b in range(len(B)):
		for c in range(len(C)):
			if (a+1)*(b+1)*(c+1)<=K:
				ans.append(A[a]+B[b]+C[c])
			else:
				break

ans.sort(reverse=True)
for i in range(K):
	print(ans[i])
# D
N, M = map(int, input().split())
A_list = list(map(int, input().split()))

mod_dict = dict()

sum_k = 0
for a in A_list:
    sum_k += a
    r = sum_k % M
    if r not in mod_dict.keys():
        mod_dict[r] = 1
    else:
        mod_dict[r] += 1

res = 0
sum_k = 0

r = 0

for a in A_list:
    res += mod_dict[r]    
    sum_k += a
    r = sum_k % M
    mod_dict[r] -= 1
    
    
print(res)

### FIXED CODE ###

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

mod_dict = dict()
mod_dict[0] = 0
sum_k = 0
for a in A_list:
    sum_k += a
    r = sum_k % M
    if r not in mod_dict.keys():
        mod_dict[r] = 1
    else:
        mod_dict[r] += 1

res = 0
sum_k = 0

r = 0

for a in A_list:
    res += mod_dict[r]    
    sum_k += a
    r = sum_k % M
    mod_dict[r] -= 1
    
    
print(res)
s = input()
t = input()

if all(s[i] == t[-i-1] for i in range(len(s)))):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import sys

s = input()
t = input()

temp = ''
for i in range(len(s)):
    temp += s[-1]
    temp += s[0:len(s)-1]
    if temp == t:
        print('Yes')
        sys.exit()
    else:
        s = temp
        temp = ''

print('No')
#coding:utf-8
#1_9_A 2015.4.10
w = input().lower()
c = 0
while True:
    t = input()
    if 'END_OF_TEXT' in t:
        break
    c += t.lower().split()lower().count(w)
print(c)

### FIXED CODE ###

#coding:utf-8
#1_9_A 2015.4.12
w = input().lower()
c = 0
while True:
    t = input()
    if 'END_OF_TEXT' in t:
        break
    c += t.lower().split().count(w)
print(c)
def main():
    S = input()
    K = int(input())
    ans = 0
    L = len(S)
    if L == 1:
        ans = K//2
        print(ans)
        exit()
    cnt = 1
    for i in range(L):
        if S[i] == S[i+1] and i+1 < L:
            cnt += 1
        else:
            ans += cnt//2
            cnt = 1
    ans += cnt//2
    ans *= K
    if S[0] == S[-1]:
        t = S[0]
        i = 0
        a = 0
        b = 0
        while S[i] == t and i < L:
            a += 1
            i += 1
            if i >= L:break
        i = L-1
        while S[i] == t and i >= 0:
            b += 1
            i -= 1
            if i < 0:break
        tmp = a//2+b//2-(a+b)//2
        tmp *= (K-1)
        ans -= tmp
    print(ans)
if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    S = input()
    K = int(input())
    ans = 0
    L = len(S)
    s = set([i for i in S])
    if len(s) == 1:
        print((L*K)//2)
        exit()
    cnt = 1
    for i in range(L):
        if i < L-1 and S[i] == S[i+1]:
            cnt += 1
        else:
            ans += cnt//2
            cnt = 1
    ans *= K
    if S[0] == S[-1]:
        t = S[0]
        i = 0
        a = 0
        b = 0
        while i < L and S[i] == t:
            a += 1
            i += 1

        i = L-1
        while i >= 0 and S[i] == t:
            b += 1
            i -= 1

        tmp = a//2+b//2-(a+b)//2
        tmp *= (K-1)
        ans -= tmp
    print(ans)
if __name__ == "__main__":
    main()
n = int(input())
ps = [int(input()) for _ in range(n)]
maxpro = 0
for i, p in enumerate(ps[:-1]):
  pro = max(ps[i + 1:]) - p
  maxpro = max(pro, maxpro)
print maxpro

### FIXED CODE ###

n = int(input())
ps = [int(input()) for _ in range(n)]
maxpro = -999999999
minp = 1000000000
for i, p in enumerate(ps[:-1]):
  if p >= minp: continue
  pro = max(ps[i + 1:]) - p
  maxpro = max(pro, maxpro)
  minp = p
print(maxpro)
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4+1
dp = [inf] * n
dp[0] = 0
for i in range(n):
    dp[i] = min([dp[i - j]  + abs(h[i - j] - h[i]) for j in range(max(0,i-k),i)])
print(dp[-1])


### FIXED CODE ###

n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])
import re
n0=input()
s=input()
ans=0

for i in range(1000):
    n = str(i).zfill(3)
#    print(n[0])
    p = f".*{n[0]}.*{n[1]}.*{n[2]}.*"
    if re.search(p,s):
        ans += 1
print(ans)


### FIXED CODE ###

n=int(input())
s=input()
ans=0

for ii in range(1000):
    v = str(ii).zfill(3)
    start=0
    f=0
    
    for j in range(3):
        idx=s.find(v[j],start)
        if idx > -1:
            start = idx + 1
            f+=1
        else:
            break

    if f == 3:
        ans += 1

print(ans)