Harryxun/stf_run huggingface dataset:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod_v = 10**9 + 7
    ans = [0] * (N + 1)
    for i in range(0, N - 1):
        ai = A[0]
        aj = A[i + 1]
        ans[0] += ai * aj
    for j in range(1, N - 1):
        ans[j] = (ans[j - 1] - A[j - 1] * A[j]) // A[j - 1] * A[j]
    ret = 0
    for k in range(0, N):
        ret += ans[k]
    ret = ret % mod_v
    print(ret)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def calc(A, N, i):
    ans = 0
    ai = A[i]
    for i in range(i, N - 1):
        aj = A[i + 1]
        ans += ai * aj
    return (ans)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod_v = 10**9 + 7
    ans = [0] * (N + 1)
    for i in range(0, N - 1):
        if A[i] != 0:
            ans[i] = calc(A, N, i)
            break
    for j in range(i + 1, N - 1):
        if A[j] != 0:
            ans[j] = (ans[j - 1] - A[j - 1] * A[j]) // A[j - 1] * A[j]
        else:
            ans[j] = 0
    ret = 0
    for k in range(0, N):
        ret += ans[k]
    ret = ret % mod_v
    print(ret)


if __name__ == '__main__':
    main()
N = int(input())
a = list(map(int, input().split()))
jousi={}
for i in range(N):
    itmp=str(i)
    jousi[itmp]=0
for i in range(N-1):
    atmp=str(a[i])
    jousi[atmp]+=1
for i in range(1,N+1):
    print(jousi[str(i)])


### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
jousi={}
for i in range(N+1):
    jousi[str(i)]=0

for i in range(N-1):
    jousi[str(a[i])]+=1
    
for i in range(1,N+1):
    print(jousi[str(i)])
n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [1] * n
for i in range(m):
    ai, bi = map(int, input().split()) 
    ab[i] = ai
    ab[i+m] = bi
    if h[ai-1] >= h[bi-1]:
        ans[bi-1] = 0
    elif h[ai-1] < h[bi-1]:
        ans[ai-1] = 0
print(sum(ans))

### FIXED CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [1] * n
for i in range(m):
    ai, bi = map(int, input().split()) 
    if h[ai-1] >= h[bi-1]:
        ans[bi-1] = 0
    if h[ai-1] <= h[bi-1]:
        ans[ai-1] = 0
print(sum(ans))
(n,),*a=[[*map(int,i.split())]for i in open(0)]
ans=[]
for i in range(n-1):
    now=a[i][0]+a[i][1]
    for j in range(i+1,n-1):
        c,s,f=a[j]
        if s==now:
            d=0
        elif s>now:
            d=s-now
        else:
            d=now%f
        now+=c+d
    ans+=[now]  
ans+=[0]    
print(*ans,sep="\n")

### FIXED CODE ###

n=int(input())
a=[list(map(int,input().split())) for _ in range(n-1)]
ans=[]
for i in range(n):
    now=0
    for j in range(i,n-1):
        c,s,f=a[j]
        if s==now:
            k=0
        elif s>now:
            k=s-now
        else:
            if now%f!=0:
                k=f-now%f
            else:
                k=0
        now+=c+k
    print(now)
input()
ans = eval(input().replace(" ", "*"))
if ans > 10**18:
        print(-1)
else:
        print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1 
if 0 in a:
        print(0)
else:
        for i in range(n):
                ans = ans * a[i]
                if ans > 10**18:
                        ans = -1
                        break
        print(ans)
n = int(input()) # sを取得し、strに値を入れる
num= input()
num=list(map(int,num.split()))

from collections import defaultdict

d0=defaultdict(int)
d1=defaultdict(int)
for i in range(n):
    if i%2==0:
        d0[num[i]]+=1
    else:
        d1[num[i]]+=1

l0=[(k,d0[k]) for k in d0]
l1=[(k,d1[k]) for k in d1]
l0=sorted(l0, key=lambda d:d[1],reverse=True)
l1=sorted(l1,key=lambda d:d[1],reverse=True)

if l0[0][0]!=l1[0][0]:
    print(len(num)-l0[0][1]-l1[0][1])
elif len(num)==2:
    print(1)
else:
    s=0
    if l0[0][1]>=l1[0][1]:
        s=l0[0][1]+l1[1][1]
    else:
        s=l0[1][1]+l1[0][1]
    print(len(num)-s)

### FIXED CODE ###

n = int(input()) # sを取得し、strに値を入れる
num= input()
num=list(map(int,num.split()))

from collections import defaultdict

d0=defaultdict(int)
d1=defaultdict(int)
for i in range(n):
    if i%2==0:
        d0[num[i]]+=1
    else:
        d1[num[i]]+=1

l0=[(k,d0[k]) for k in d0]
l1=[(k,d1[k]) for k in d1]

l0=sorted(l0, key=lambda d:d[1],reverse=True)
l1=sorted(l1, key=lambda d:d[1],reverse=True)

l0.append(("wild card",0))
l1.append(("wild card",0))

if l0[0][0]!=l1[0][0]: #文字が同じ場合
    print(len(num)-l0[0][1]-l1[0][1])
elif n==2:
    print(1)
else:
    print(n-max(l0[0][1]+l1[1][1],l0[1][1]+l1[0][1]))
number = input()

height = list(map(int,input().split()))

total = 1
flag = True
    
for i in range(1,len(height)):

    for j in range(i):
        if height[i] >= height[j]:
            flag = True
        else:
            flag = False
    
    if flag:
        total += 1

print(total)


### FIXED CODE ###

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

total = 0

if a >= b :
    total = a
    a -= 1
else:
    total = b
    b -=  1

if a>= b :
    total = total + a
else:
    total = total + b

print(total)
# -*- coding: utf-8 -*-
  
  
b, c = map(int, input().split())

s=0.5*(b+c)

int d = s

v=d+1

print(v)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Nov  3 09:19:07 2018

@author: sk
"""

     
      
b, c = map(int, input().split())
     
s=0.5*(b+c)
     
d = int(s)
    
if s-d > 0:
    v=int(d+1)
else :
    v=int(d)
print(v)
for i in range(10000):
    H,W=input().split())
    if H=="0" and W=="0":
        break
    s = ""
    for j in range(int(W)):
        s = s + "#"
    for k in range(int(H)):
        print(s)
    print("")


### FIXED CODE ###

for i in range(10000):
    H,W=input().split()
    if H=="0" and W=="0":
        break
    s = ""
    for j in range(int(W)):
        s = s + "#"
    for k in range(int(H)):
        print(s)
    print("")
# ABC142D - Disjoint Set of Common Divisors
# from fractions import gcd
from math import gcd


def divisors(n: int) -> set:
    div = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.add(i), div.add(n // i)
    return div


def get_primes(n: int) -> set:
    # return a list of primes <= n
    n += 1
    sieve = [1] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i :: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1)
    return {2} | {i for i in range(3, n, 2) if sieve[i]}


def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    ans = len(divisors(g) & get_primes(g)) + 1
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC142D - Disjoint Set of Common Divisors
def divisors(n: int) -> set:
    div = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.add(i), div.add(n // i)
    return div


def main():
    A, B = map(int, input().split())
    divs = sorted(divisors(A) & divisors(B))
    divs.pop(0)
    groups = set()
    for i in divs:
        if all(i % x for x in groups):
            groups.add(i)
    ans = len(groups) + 1
    print(ans)


if __name__ == "__main__":
    main()
S = list(input())
cnt = len(S)
while len(S) > 0:
  i = 0
  while i < len(S)-1:
    if S[i] == "S" and S[i+1] == "T":
      S.pop(i)
      S.pop(i+1)
    i += 1
  if cnt == len(S):
    print(len(S))
    exit()
  cnt = len(S)
print(len(S))

### FIXED CODE ###

S = input()
Stack = []
for i in range(len(S)):
  if S[i] == "S":
    Stack.append("S")
  elif S[i] == "T" and len(Stack) == 0:
    Stack.append("T")
  elif S[i] == "T" and Stack[-1] == "T":
    Stack.append("T")
  elif S[i] == "T" and Stack[-1] == "S":
    Stack.pop()
print(len(Stack))
# -*- coding: utf-8 -*-

import sys

args = sys.argv

a_value = int(args[1])
b_value = int(args[2])
c_value = int(args[3])
a_number = int(args[4])
b_number = int(args[5])

value = 0

if a_value + b_value <= c_value * 2:
    value = a_value * a_number + b_value * b_number
    print (value)
else:
    if a_number >= b_number:
        value += c_value * 2 * b_number
        if (a_number - b_number) * a_value >= (a_number - b_number) * c_value * 2:
            value += (a_number - b_number) * c_value * 2
        else:
            value += (a_number - b_number) * a_value

    else:
        value += c_value * 2 * a_number
        if (b_number - a_number) * b_value >= (b_number - a_number) * c_value * 2:
            value += (b_number - a_number) * c_value * 2
        else:
            value += (b_number - a_number) * a_value
    print (value)

### FIXED CODE ###

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

import sys

lst = list(map(int, input().split()))

a_value = lst[0]
b_value = lst[1]
c_value = lst[2]
a_number = lst[3]
b_number = lst[4]

value = 0

if a_value + b_value <= c_value * 2:
    value = a_value * a_number + b_value * b_number
    print (value)
else:
    if a_number >= b_number:
        value += c_value * 2 * b_number
        if (a_number - b_number) * a_value >= (a_number - b_number) * c_value * 2:
            value += (a_number - b_number) * c_value * 2
        else:
            value += (a_number - b_number) * a_value

    else:
        value += c_value * 2 * a_number
        if (b_number - a_number) * b_value >= (b_number - a_number) * c_value * 2:
            value += (b_number - a_number) * c_value * 2
        else:
            value += (b_number - a_number) * b_value
    print (value)
from functools import lru_cache

# 入力
N, M = map(int, input().split())
A, B = zip(*(map(int, input().split()) for _ in range(N - 1 + M)))

# 各頂点の深さを求め、深さを利用して元の木を復元する
G = [set() for _ in range(N + 1)]
for a, b in zip(A, B):
    G[b].add(a)


@lru_cache(maxsize=None)
def f(v):
    return 1 + max((f(p) for p in G[v]), default=0)


ans = '\n'.join(
    str(max(G[i], key=f, default=0))
    for i in range(1, N + 1)
)

# 出力
print(ans)


### FIXED CODE ###

from collections import deque

# 入力
N, M = map(int, input().split())
A, B = zip(*(map(int, input().split()) for _ in range(N - 1 + M)))

# 各頂点の深さを求め、深さを利用して元の木を復元する
G = [set() for _ in range(N + 1)]
G_inv = [set() for _ in range(N + 1)]
for a, b in zip(A, B):
    G[a].add(b)
    G_inv[b].add(a)
deg = [len(G_inv[i]) for i in range(N + 1)]
V = [i for i in range(1, N + 1) if not G_inv[i]]
deq = deque(V)
while deq:
    i = deq.popleft()
    for j in G[i]:
        deg[j] -= 1
        if deg[j] == 0:
            deq.append(j)
            V.append(j)

R = {i: r for r, i in enumerate(V)}
ans = '\n'.join(
    str(max(G_inv[i], key=lambda j: R[j], default=0))
    for i in range(1, N + 1)
)

# 出力
print(ans)
N = int(input())
if N > 81:
  print("No")
elif N==1 or N==2 N==3 or N==4 or N==5 or N==6 or N==8 or N==9 or N==10 or N==12 or N==14 or N==15 or N==16 or N==18 or N==20 or N==21 or N==24 or N==25 or N==27 or N==28 or N==30 or N==32 or N==35 or N==36 or N==40 or N==42 or N==45 or N==48 or N==49 or N==54 or N==56 or N==63 or N==64 or N==72 or N==81:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = int(input())
if N > 81:
  print("No")
elif N>=1 and N<=10:
  print("Yes")
elif N==12 or N==14 or N==15 or N==16 or N==18 or N==20 or N==21 or N==24 or N==25 or N==27 or N==28 or N==30 or N==32 or N==35 or N==36 or N==40 or N==42 or N==45 or N==48 or N==49 or N==54 or N==56 or N==63 or N==64 or N==72 or N==81:
  print("Yes")
else:
  print("No")
n, x, t = map(int, input().split())
if n%x==0:
  print(n*t/x)
else:
  print(((math.floot(n/x))+1)*t)

### FIXED CODE ###

n, x, t = map(int, input().split())
if n%x==0:
  print((n//x)*t)
else:
  print( ((n//x)+1)*t )
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
exits = False

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(n):
            match = False
            if a[i][k: k+m] == b[j] and not exits:
                for l in range(1, m):
                    if a[i+l][k: k+m] == b[l]:
                        match = True
                    else:
                        match = False
                        break
            if match:
                exits = True

print('Yes' if exits else 'No')


### FIXED CODE ###

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
exits = False

for i in range(n-m+1):
    for j in range(n-m+1):
        p = []
        for k in range(m):
            p.append(a[i:i+m][k][j:j+m])
        if p == b:
            exits = True

print('Yes' if exits else 'No')
S=input()
l=S.split('/')
if l[0]<=2019:
    if l[1]<=4:
        if l[2]<=30:
            print('Heisei')
            exit()
    print('TBD')

### FIXED CODE ###

S=input()
l=S.split('/')
if int(l[0])<=2019:
    if int(l[1])<=4:
        if int(l[2])<=30:
            print('Heisei')
            exit()
    print('TBD')
s = input()
t = input()

if sorted(s) < sorted(t, reverse=True):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

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

if (a + b) %2 ==0:
    print(int((a+b)/2))
else:
    print(int((a+b+1)//2))
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort(reverse=True)
for i in range(K):
  H.remove(H[i])
print(sum(H[K:]))

### FIXED CODE ###

N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort(reverse=True)
print(sum(H[K:]))
A,B=map(int,input().split())
count=0
if i>=A and i<=B:
    array_i=list(map(int,str(i)))
    if array_i==reverse(array_i):
        count+=1
    print(count)

### FIXED CODE ###

A,B=map(int,input().split())
count=0
for i in range(A,B+1):
        if str(i)==str(i)[::-1]:
            count+=1
print(count)
s = input()
alpha = 'abcdefghijklmnopqrstuvwxyz'

s_set = set(s)
if len(s_set) == 26:
    print('None')
else:
    s_sorted = sorted(s_set)
    for i, a in enumerate(alpha):
        if a != s_sorted[i]:
            print(a)
            break

### FIXED CODE ###

s = input()
alpha = 'abcdefghijklmnopqrstuvwxyz'

s_set = set(s)
if len(s_set) == 26:
    print('None')
else:
    for a in alpha:
        if a not in s_set:
            print(a)
            break
N=int(input())
X=[int(i) for i in input().split()]
for i in range(N):
  x=X.copy()
  del x[i]
  x.sort()
  print(x[N//2-1])

### FIXED CODE ###

N=int(input())
X=[int(i) for i in input().split()]
x=X.copy()
x.sort()
mina=x[N//2-1]
minb=x[N//2]
for i in range(N):
  if mina<X[i]:
    print(mina)
  else :
    print(minb)
from math import factorial
class Facts(max_num=10**5, p=10**9 + 7):
    def __init__(self):
        self.p = p
        self.max_num = max_num
        self.fact = [1] * (self.max_num + 1)
        for i in range(1, self.max_num + 1):
            self.fact[i] = self.fact[i-1] * i
            self.fact[i] %= self.p

    def comb(self, n, k):
        """ nCk mod p を求める """
        """ 計算量 O(log(p)) """
        """ n! / (n-k)! / k! mod p """
        """ フェルマーの小定理 a^(-1) ≡ a^(p-2) """
        """ n! * k!^(p-2) * (n-k)!^(p-2) mod p """
        if n < 0 or k < 0 or n < k:
            return 0
        if n == 0 or k == 0:
            return 1
        a = self.fact[n]
        b = self.fact[k]
        c = self.fact[n-k]
        return (a*self.power_func(b, self.p-2) *
                self.power_func(c, self.p-2)) % self.p

    def perm(self, n, k):
        """ nPk mod p を求める """
        """ 計算量 O(b - a)? """
        """ n! / (n-k)! mod p """
        """ n! * (n-k)!^(p-2) mod p """
        if n < 0 or k < 0 or n < k:
            return 0
        if n == 0 or k == 0:
            return 1
        a = self.fact[n]
        b = self.fact[n-k]
        return (a * self.power_func(b, self.p-2)) % self.p

    def power_func(self, a, b):
        """ a^b mod p　を繰り返し二乗法で求める """
        """ 計算量 O(log(b)) """
        if b == 0:
            return 1
        if b % 2 == 0:
            d = self.power_func(a, b//2)
            return d*d % self.p
        if b % 2 == 1:
            return (a*self.power_func(a, b-1)) % self.p

MOD = 10**9 + 7

fact = Facts()
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
# pos
for i in range(n-1):
    c = fact.comb(n-1-i, k-1)
    ans += a[n-1-i] * c
    ans %= MOD
    ans -= a[i] * c
    ans %= MOD
print(ans)



### FIXED CODE ###

from math import factorial
MOD = 10**9 + 7

# 階乗を用意
fact = [1] * (10**5 + 1)
for i in range(1, 10**5 + 1):
    fact[i] = fact[i-1] * i
    fact[i] %= MOD

def comb(n, k, p):
    """power_funcを用いて(nCk) mod p を求める"""
    global fact
    if n < 0 or k < 0 or n < k:
        return 0
    if n == 0 or k == 0:
        return 1
    a = fact[n]
    b = fact[k]
    c = fact[n-k]
    return (a*power_func(b, p-2, p)*power_func(c, p-2, p)) % p

def power_func(a, b, p):
    """a^b mod p を求める"""
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power_func(a, b//2, p)
        return d*d % p
    if b % 2 == 1:
        return (a*power_func(a, b-1, p)) % p

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

ans = 0

# pos
for i in range(n-1):
    c = comb(n-1-i, k-1, MOD)
    ans += a[n-1-i] * c
    ans %= MOD
    ans -= a[i] * c
    ans %= MOD
print(ans)
A,B,K = map(int,input().split())
for i in range(A,min(A+K,b+1)):
  print(i)
for i in range(max(B-K+1,A+K),B+1):
  print(i) 

### FIXED CODE ###

A,B,K = map(int,input().split())
for i in range(A,min(A+K,B+1)):
  print(i)
for i in range(max(B-K+1,A+K),B+1):
  print(i)
h,w,k=map(int, input().split())
L=[]
for i in range(h):
	S=list(input())
	for j in range(w):
		L.append(S[j])
import itertools
import copy
t=[1,0]
cnt=0

for v in itertools.product(t, repeat=h+w):
	LL=copy.copy(L)
	#print(v)
	for i in range(h+w):
		if v[i]==1 and i<h:
			for j in range(w):
				LL[h*i+j]='r'
		elif v[i]==1 and i>=h:
			for j in range(h):
				LL[w*j+(i-h)]='r'
	#print(LL)
	s=LL.count('#')
	if s==k:
		cnt+=1
print(cnt)	

### FIXED CODE ###

h,w,k=map(int, input().split())
L=[]
for i in range(h):
	S=list(input())
	for j in range(w):
		L.append(S[j])
import itertools
import copy
t=[1,0]
cnt=0

for v in itertools.product(t, repeat=h+w):
	LL=copy.copy(L)
	for i in range(h+w):
		if v[i]==1 and i<h:
			for j in range(w):
				LL[w*i+j]='r'
		if v[i]==1 and i>=h:
			for j in range(h):
				LL[w*j+(i-h)]='r'
	s=LL.count('#')
	if s==k:
		cnt+=1
print(cnt)
import random
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
    s.append(list(map(int,input().split())))
t = [0]*D
def my_index(l,x,d,default=False):
    if x in l:
        return l.index(x)
    else:
        return d
def last(d,i):
    a= t[:d]
    a.reverse()
    day = -1*(my_index(a,i,d))+d
    return day
score = 0
score_v=0
for i in range(50):
    t_old = t
    d_change = random.randint(1,D)
    q_change = random.randint(1,26)
    t[d_change]=q_change
    for d in range(1,D+1):
        score_v += s[d-1][t[d-1]-1]
        for i in range(1,27):
            score_v -= c[i-1]*(d-last(d,i))
            if score_v>score:
                score=score_v
            else:
                t = t_old
for i in range(D):
    print(t[i])

### FIXED CODE ###

import random
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
    s.append(list(map(int,input().split())))
t = [1]*D
def my_index(l,x,d,default=False):
    if x in l:
        return l.index(x)
    else:
        return d
def last(d,i):
    a= t[:d]
    a.reverse()
    day = -1*(my_index(a,i,d))+d
    return day
score = 0
for i in range(40):
    score_v=0
    t_old = t
    d_change = random.randint(0,D-1)
    q_change = random.randint(1,26)
    t[d_change]=q_change
    for d in range(1,D+1):
        score_v += s[d-1][t[d-1]-1]
        for i in range(1,27):
            score_v -= c[i-1]*(d-last(d,i))
    if score_v>score:
        score=score_v
    else:
        t = t_old
for i in range(D):
    print(t[i])
H, W = map(int, input().split())

for i in range(H):
  s = input().split()
  if len(set(s)) == 2:
    row = i+1
    col = 65+s.index('snuke')
    break
print("{}{}".format(chr(col), row))

### FIXED CODE ###

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

for i in range(H):
  s = input().split()
  if "snuke" in s:
    row = i+1
    col = 65+s.index('snuke')
    break
print("{}{}".format(chr(col), row))
from collections import defaultdict,deque
H, W = map(int,input().split())
MAP = []
for _ in range(H):
    MAP.append(tuple(map(str,input())))

move = [[0,1],[0,-1],[1,0],[-1,0]]

def bfs(s):
    MAX = 0
    stack = deque([])
    stack.append(tuple(s))
    depth =dict()
    depth[tuple(s)] = 0
    goal = s
    while stack:
        v = stack.popleft()
        for m in move:
            a = tuple([v[0]+m[0], v[1] + m[1]])
            if a[0] < H and a[0] >=  0 and a[1] < W and a[1] >= 0:
                if MAP[a[0]][a[1]] == '.' and not a in depth:
                    stack.append(a)
                    depth[a] = depth[v] + 1

    for k,d in depth.items():
        if MAX < d:
            MAX = d
            goal = k

    return MAX, goal

for i in range(0,H):
    for j in range(0,W):
        if MAP[i][j] == '.':
            MAX, goal = bfs(tuple([i,j]))
            break
    break

MAX, goal = bfs(tuple(goal))
print(MAX)

### FIXED CODE ###

from collections import defaultdict,deque
H, W = map(int,input().split())
MAP = []
for _ in range(H):
    MAP.append(tuple(map(str,input())))

move = [[0,1],[0,-1],[1,0],[-1,0]]
MAX = 0 

def bfs(s):
    global MAX
    stack = deque([])
    stack.append(tuple(s))
    depth =dict()
    depth[tuple(s)] = 0
    while stack:
        v = stack.popleft()
        for m in move:
            a = tuple([v[0]+m[0], v[1] + m[1]])
            if a[0] < H and a[0] >=  0 and a[1] < W and a[1] >= 0:
                if MAP[a[0]][a[1]] == '.' and not a in depth:
                    stack.append(a)
                    depth[a] = depth[v] + 1

    for d in depth.values():
        MAX = max(MAX,d)


for i in range(0,H):
    for j in range(0,W):
        if MAP[i][j] == '.':
            bfs(tuple([i,j]))

for i in range(0,W):
    for j in range(0,H):
        if MAP[j][i] == '.':
            bfs(tuple([j,i]))

print(MAX)
N, M = list(map(int, input().split(" ")))
list_a = list(map(int, input().split(" ")))

##半公倍数が存在するかチェック
def check_exist(l) :
  if(len(l) == 0) :
    return True
  while(True) :
    flag = l[0] % 2
    for x in l[1:] :
      if(x % 2 != flag) :
        return False
    if(flag == 0) :
      l = list(map(lambda x: int(x/2), l))
    else :
      return True
    

##最大公約数を求める

def gcd(a, b) :
  if(b==0) :
    return a
  else :
    return gcd(b, a%b)
   
##最小公倍数を求める
def lcm(a, b) :
  cd = gcd(a, b)
  return a * b / cd
  
##複数個の整数の最小公倍数を求める
def lcm_multi(l) :
  if(len(l) < 2) :
    return l[0]
  cm = lcm(l[0], l[1])
  for i in range(2, N) :
    cm = lcm(l[i], cm)
    
  return cm

ans = 0
if(not(check_exist(list_a))) :
  print(0)
  exit()

lcm_m = lcm_multi(list_a)
if(M-lcm_m/2 < 0) :
  print(0)
else :
  print(int((M-lcm_m/2) / lcm_m) + 1)



### FIXED CODE ###

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

##半公倍数が存在するかチェック
def check_exist(l) :
  if(len(l) == 1) :
    return True
  while(True) :
    flag = l[0] % 2
    for x in l[1:] :
      if(x % 2 != flag) :
        return False
    if(flag == 0) :
      l = list(map(lambda x: int(x/2), l))
    else :
      return True
    

##最大公約数を求める

def gcd(a, b) :
  if(b==0) :
    return a
  else :
    return gcd(b, a%b)
   
##最小公倍数を求める
def lcm(a, b) :
  cd = gcd(a, b)
  return (a / cd) * b
  
##複数個の整数の最小公倍数を求める
def lcm_multi(l) :
  cm = 1
  for x in l :
    cm = lcm(x, cm)
    if(cm > 4 * M) :
      print(0)
      exit()
    
  return cm

if(not(check_exist(list_a))) :
  print(0)
  exit()

## 1/2の公倍数
lcm_m = lcm_multi(list(map(lambda x: int(x/2), list_a)))

if(M-lcm_m < 0) :
  print(0)
else :
  print(int((M-lcm_m) / (2*lcm_m)) + 1)
import sys
for i in sys.stdin:
    a,b,c,d,e,f = map(int, i.split())
    x=(c*e-b*f)/(a*e-b*d)
    y=(f-d*x)/e
    print "{0:.3f} {1:.3f}".format(x, y)

### FIXED CODE ###

import sys
for l in sys.stdin:
    a,b,c,d,e,f=map(float,l.split())
    x=a*e-b*d
    print"%0.3f %0.3f"%(c*e/x-b*f/x,a*f/x-c*d/x)
n = int(input())
s = str(input())
slist = []
for i in range(n):
  slist.append(s[i])
slime = slist[0]
fslist = [slime]
for i in range(1, n):
  if slime != slist[i]:
    fslist.append(slist[i])
    slime = slist[i]
print(len(fslist)

### FIXED CODE ###

n = int(input())
s = str(input())
slist = []
for i in range(n):
  slist.append(s[i])
slime = slist[0]
fslist = []
fslist.append(slime)
for i in range(1, n):
  if slime != slist[i]:
    fslist.append(slist[i])
    slime = slist[i]
print(len(fslist))