Harryxun/stf_run huggingface dataset:
n = int(input())
a = [float(input()) for _ in range(n)]
a = [i*10**9 for i in a]
MAX = 23
p_mat = [[0 for _ in range(MAX)] for _ in range(MAX)]

for i in a:
    b_cnt = 0
    while i % 2 == 0:
        i /= 2
        b_cnt += 1
    f_cnt = 0
    while i % 5 == 0:
        i /= 5
        f_cnt += 1
    p_mat[b_cnt][f_cnt] += 1

ans = 0
for b1 in range(MAX):
    for f1 in range(MAX):
        for b2 in range(MAX):
            for f2 in range(MAX):
                if b1+b2 >= 18 and f1+f2 >= 18:
                    if b1 == b2 and f1 == f2:
                        ans += p_mat[b1][f1] * (p_mat[b2][f2] - 1)
                    else:
                        ans += p_mat[b1][f1] * p_mat[b2][f2]
print(ans//2)

### FIXED CODE ###

import collections
from decimal import Decimal

n = int(input())
a = [Decimal(input()) for _ in range(n)]
a = [int(i*10**9) for i in a]
MAX = 19
p_dict = collections.defaultdict(int)

for i in a:
    b_cnt = 0
    while i % 2 == 0 and b_cnt < 18:
        i //= 2
        b_cnt += 1
    f_cnt = 0
    while i % 5 == 0 and f_cnt < 18:
        i //= 5
        f_cnt += 1
    p_dict[(b_cnt, f_cnt)] += 1

ans = 0
for b1, f1 in p_dict:
    for b2, f2 in p_dict:
        if b1+b2 >= 18 and f1+f2 >= 18:
            if b1 == b2 and f1 == f2:
                ans += p_dict[(b1, f1)] * (p_dict[(b2, f2)] - 1)
            else:
                ans += p_dict[(b1, f1)] * p_dict[(b2, f2)]
print(ans//2)
N = int(input())
A = [input() for i in range(N)]
B = list(set(A))
C = [0]*len(B)
for i in range(len(B)):
  C[i] = A.count(B[i])
D = max(C)
for s in sorted([B[i] for i, x in enumerate(C) if x == D]):
　print(s)

### FIXED CODE ###

N = int(input())

d = {}
for _ in range(N):
    S = input()
    if S in d:
        d[S] += 1
    else:
        d[S] = 1

m = max(d.values())
for s in sorted(k for k in d if d[k] == m):
    print(s)
N = int(input())

# 約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

# 素因数分解
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def div_game(N, ans, LIST):
  if N == 1:
    print(ans)
    return ans
  
  num = make_divisors(N)
  for i in num:
    if i == 1:
      continue
    elif i in LIST:
      continue
    A = prime_decomposition(i)
    if len(set(A)) == 1:
      z = i
      LIST.append(z)
      break
    
  N = int(N/z)
  div_game(N, ans+1, LIST)

LIST = []
last = div_game(N, 0, LIST)

### FIXED CODE ###

import collections
N = int(input())
  
# 素因数分解
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

num1 = prime_decomposition(N)
num2 = collections.Counter(num1)

ans = 0

for j in set(num1):
  number = 0
  for k in range(50):
    number += k
    if number > num2[j]:
      ans += (k-1)
      break
        
print(ans)
a = int(input())
b = int(input())

if a*b%2 ==0:
  print("偶数")
else:
  print("奇数")

### FIXED CODE ###

a, b = map(int, input().split())
print("Even" if a*b % 2 == 0 else "Odd")
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]
ls = list(set(s))
temp=0
for l in ls:
    ans=0
    ans += 1 for ss in s if ss == l
    ans -= 1 for tt in t if tt == l
    temp = max(temp, ans)
print(temp)

### FIXED CODE ###

n=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
l=list(set(n))
print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))
L, N = map(int,input().split())
S = [input() for i in range(N)]

B=sorted(S)

A=''.join(B)

print(str(A))

### FIXED CODE ###

N, L = map(int,input().split())
S = [input() for i in range(N)]

S.sort()


print("".join(S))
X = int(input())
A = int(input())
B = int(input())

X -= A
print(x % B)

### FIXED CODE ###

X = int(input())
A = int(input())
B = int(input())
 
X -= A
print(X % B)
a,b,c,d = map(int,input().split())

x = min(a,b) + min(c,d)

print(x)

### FIXED CODE ###

l = [int(input()) for i in range(1, 5)]
print(min(l[0], l[1]) + min(l[2], l[3]))
n, m = map(int, input().split())

# 1個目を受け取る
l, r = map(int, input().split())


def check(i, l, r):
    if i == m:
        print(r - l + 1)
        exit()
    l_, r_ = map(int, input().split())
    nl = max(l, l_)
    nr = min(r, r_)
    i += 1
    check(i, nl, nr)


check(1, l, r)




### FIXED CODE ###

n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))
N=int(input())
A=[int(x)for x in input().split()]
B=[]
p = 10 ** 9 + 7
if N%2==0:
    B= sorted([2*i-1 for i in range(1,N//2+1)]*2)
    if sorted(A)==B:
        ans=(pow(2,int(N/2))%(10 ** 9 + 7)
    else:
        ans=0
else:
    B= [0]+sorted([2*i for i in range(1,N//2+1)]*2)
    if sorted(A)==B:
        ans=(pow(2,int(N/2))%(10 ** 9 + 7)
    else:
        ans=0
print(int(ans))
 


### FIXED CODE ###

mod = 10**9 + 7
n = int(input())
a = sorted(list(map(int,input().split())))
 
if n % 2 == 0:
  for i in range(n//2):
    if not a[2*i] == a[2*i+1] == 2*i+1:
      print(0)
      exit()
else:
  if a[0] != 0:
    print(0)
    exit()
  for i in range(n//2):
    if not a[2*i+1] == a[2*i+2] == 2*i+2:
      print(0)
      exit()
print(pow(2, n//2) % mod)
x=int(input())
from sympy import nextprime
print(nextprime(x))

### FIXED CODE ###

x=int(input())
i=2
cond="notyet"
while cond=="notyet":
    count=0
    for i in range(2,x):
        ex=x%i
        if  ex!=0:
            count+=1
    if count==x-2:
        ans=x
        cond="discovered"
    else:
        x=x+1
print(ans)
import sys
import collections


scan = sys.stdin.readline


def main():
    n, k = map(int, scan().rstrip().split())
    v = collections.deque([int(value) for value in scan().rstrip().split()])
    hands = [0] * n

    results = []

    for a in range(min(n, k) + 1):
        for b in range(min(n, k) - a + 1):
            for _ in range(a):
                hands.append(v.popleft())
            for _ in range(b):
                hands.append(v.pop())

            hands.sort()

            c_d = 0
            for c_d in range(k - a - b):
                if hands[c_d] < 0:
                    hands[c_d] = 0
                else:
                    break
            results.append(sum(hands))
            hands = [0] * n

    results.sort(reverse=True)
    print(results[0])


if __name__ == '__main__':
    main()



### FIXED CODE ###

import sys
import collections
import copy


scan = sys.stdin.readline


def main():
    n, k = map(int, scan().rstrip().split())
    values = collections.deque([int(value) for value in scan().rstrip().split()])

    results = []

    for a in range(min(n, k) + 1):
        for b in range(min(n, k) - a + 1):
            hands = [0] * n
            v = copy.deepcopy(values)

            for _ in range(a):
                hands.append(v.popleft())
            for _ in range(b):
                hands.append(v.pop())

            hands.sort()

            c_d = 0
            for c_d in range(k - a - b):
                if hands[c_d] < 0:
                    hands[c_d] = 0
                else:
                    break
            results.append(sum(hands))
            hands = [0] * n

    results.sort(reverse=True)
    print(results[0])


if __name__ == '__main__':
    main()
import sys
from heapq import *
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def main():
    def get_group(k):
        g = pd[k]
        if g < 0:
            return k
        gg = get_group(g)
        pd[k] = gg
        return gg

    def merge(j, k):
        g1 = get_group(j)
        g2 = get_group(k)
        if g1 != g2:
            d1 = -pd[g1]
            d2 = -pd[g2]
            if d2 > d1:
                g1, g2 = g2, g1
            pd[g2] = g1
            if d1 == d2:
                pd[g1] -= 1

    hp = []
    n, h, w = map(int, input().split())
    pd = [-1] * (h + w + 2)  # 親(parent)と深さ(depth)。0以上は親。負の場合、そのノードが根で絶対値が深さ。
    for _ in range(n):
        r, c, a = map(int, input().split())
        heappush(hp, [-a, r, h + c])
    cnt = h + w
    ans = 0
    while cnt and hp:
        a, r, c = heappop(hp)
        gr = get_group(r)
        gc = get_group(c)
        if gr + gc == 0:
            continue
        if gr == gc:
            pd[gr] = 0
        else:
            merge(gr, gc)
        ans -= a
        cnt -= 1
    print(ans)

main()


### FIXED CODE ###

import sys
from heapq import *

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    def get_group(k):
        g = pd[k]
        if g < 0:
            return k
        gg = get_group(g)
        pd[k] = gg
        return gg

    def merge(j, k):
        g1 = get_group(j)
        g2 = get_group(k)
        if g1 != g2:
            d1 = -pd[g1]
            d2 = -pd[g2]
            if d2 > d1:
                g1, g2 = g2, g1
            pd[g2] = g1
            if d1 == d2:
                pd[g1] -= 1

    hp = []
    n, h, w = map(int, input().split())
    pd = [-1] * (h + w + 2)  # 親(parent)と深さ(depth)。0以上は親。負の場合、そのノードが根で絶対値が深さ。
    pd[0] = -(h + w + 2)
    for _ in range(n):
        r, c, a = map(int, input().split())
        heappush(hp, [-a, r, h + c])
    cnt = h + w
    ans = 0
    while cnt and hp:
        a, r, c = heappop(hp)
        gr = get_group(r)
        gc = get_group(c)
        if gr + gc == 0: continue
        if gr == gc:
            merge(gr, 0)
        else:
            merge(gr, gc)
        ans -= a
        cnt -= 1
    print(ans)

main()
s=input()
ans=1

i=0
if s[i]=="A":
  i+=1
if s[i]=="K":
  i+=1
else:
  ans=0
if s[i]=="I":
  i+=1
else:
  ans=0
if s[i]=="H":
  i+=1
else:
  ans=0
if s[i]=="A":
  i+=1
if s[i]=="B":
  i+=1
else:
  ans=0
if s[i]=="A":
  i+=1
if s[i]=="R":
  i+=1
else:
  ans=0
if s[i]=="A":
  i+=1
if i!=len(s):
  ans=0

if ans:
  print("YES")
else:
  print("NO")

  

### FIXED CODE ###

s=input()
ans=1

i=0
if i<len(s) and s[i]=="A":
  i+=1
if i<len(s) and s[i]=="K":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="I":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="H":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="A":
  i+=1
if i<len(s) and s[i]=="B":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="A":
  i+=1
if i<len(s) and s[i]=="R":
  i+=1
else:
  ans=0
if i<len(s) and s[i]=="A":
  i+=1
if i!=len(s):
  ans=0

if ans:
  print("YES")
else:
  print("NO")
a=[]

def dfs(x):
  if x>3234566667:
    return
  a.append(x)
  for i in range(10):
    if abs(x%10-i) <= 1:
      dfs(x%10+i)
      
for i in range(1,10):
  dfs(i)
a =sorted(a)
k=int(input())
print(a[k-1])

### FIXED CODE ###

a = []

def dfs(x):
    if x > 3234566667:
        return
    a.append(x)
    for i in range(10):
        if abs(x%10-i) <= 1:
            dfs(x*10+i)

for i in range(1, 10):
    dfs(i)
a = sorted(a)
k = int(input())
print(a[k-1])
# -*- coding: utf-8 -*-

alice = int(input())
bob = int(input())

if(alice == bob):
    print("Draw)
        elif(alice == 1 and bob == 1):
            print("Draw")
    
            elif(alice == 1):
                print("Alice")
                    elif(bob == 1):
                        print("Bob")
                        elif(alice < bob):
                            print("Bob")
                            elif(alice > bob):
                                print("Alice")


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Spyderエディタ

これは一時的なスクリプトファイルです
"""
alice = input().split()
alice[0] = int(alice[0])
alice[1] = int(alice[1])
if(alice[0] == alice[1]):
    print("Draw")
elif(alice[0] == 1):
    print("Alice")
elif(alice[1] == 1):
    print("Bob")
elif(alice[0] < alice[1]):
    print("Bob")
elif(alice[0] > alice[1]):
    print("Alice")
k = input()

if k%2==0:
  s = k*k//4
  print(s)
else:
  s = k//2
  s1 = s*(s+1)
  print(s1)

### FIXED CODE ###

k = int(input())

if k%2 ==0 :
  s = k*k
  s1 = s//4
  print(s1)
else:
  s = k//2
  s1 = s*(s+1)
  print(s1)
import functools
import math

n,x=map(int,input().split())
xx=[int(t) for t in input().split()]
buf=[]

for value in xx:
    buf.append(abs(value - x))

print(functools.reduce(math.gcd, buf))


### FIXED CODE ###

import functools
import fractions

n,x=map(int,input().split())
xx=[int(t) for t in input().split()]
buf=[]

for value in xx:
    buf.append(abs(value - x))

print(functools.reduce(fractions.gcd, buf))
N = int(input())
H = list(map(int, input().split()))

best = 0
for i in range(N-1):
  a=0
  for j in range(i+1,N):
    if H[i] < H[j]: break
    else : 
      a += 1
  if a > best :
    best = a
print(best)

### FIXED CODE ###

S = input()
T = input()

count = 0
for i in range(0, 3):
  if S[i] == T[i]:
    count += 1
print(count)
N = int(input())
if N == 1:
    print('Yes')
    print('1 1')
    print('1 1)
elif N == 3:
    print('Yes')
    print('2 1 2')
    print('2 3 1')
    print('2 2 3')
else:
    print('No')

### FIXED CODE ###

N = int(input())
Nlist = [k*(k-1)//2 for k in range(10**3)]
if N not in Nlist:
    print('No')
    exit()
print('Yes')
k = Nlist.index(N)
S = [[0]*i for i in range(k)]
S[0] = [i+1 for i in range(k-1)]
for i in range(k-1):
    S[i+1] = [S[j][i] for j in range(i+1)]
    S[i+1] += [S[i][k-2]+j+1 for j in range(k-1-(i-1))]
print(k)
S = [[str(S[i][j]) for j in range(k-1)] for i in range(k)]
for i in range(k):
    print(' '.join([str(k-1)]+S[i]))
s = input()
s = s.replece(s[3], "8")
print(s)

### FIXED CODE ###

s = input()
print(s[:3]+"8"+s[4:])
N,K = map(int,input().split())
h = list(map(int,input().split()))

h.sort()
a = 0

for i in range(N):
  if h[i] >= K:
    a += i
    break
  else:
    continue
if max(a) < K:
  a += N
print(N-a)

### FIXED CODE ###

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

h.sort()
a = 0

for i in range(N):
  if h[i] >= K:
    a += i
    break
  else:
    continue
if max(h) < K:
  a += N
print(N-a)
i=input(int())
j,k=input(int())
for l in range(k+1)
  if j<=l*i<=k:
    break
    print("OK")
  else:
    print("NG")

### FIXED CODE ###

i=int(input())
j,k=(int(x) for x in input().split())
l=0
while True:
    if j<=l*i<=k:
        print("OK")
        break
    elif l*i>k:
        print("NG")
        break
    l+=1
N, K = map(int, input().split())

S = input()

#左端をLにする場合
now = ""
num_substr = 0
ex = ""
stack = []
for i in range(N):
    if (ex == "L" or ex == "") and S[i] == "R":
        start = i
    if ex == "R" and S[i] == "L":
        end = i-1
        stack.append((start, end))
        num_substr += 1
    ex = S[i]
#左からひっくり返す
tmp = min(K,num_substr)
num = stack[tmp-1][1]
ss = "L"*(num+1)+S[num+1:]
ll = num

for i in range(num+1,N):
    if i == 0:
        if (ss[i+1] == "R" and ss[i] == "R"):
            ll += 1
    elif i == N-1:
        if (ss[i-1] == "L" and ss[i] == "L"):
            ll += 1
    else:
        if (ss[i-1] == "L" and ss[i] == "L") or (ss[i+1] == "R" and ss[i] == "R"):
            ll += 1


#右からひっくり返す
tmp = min(K,num_substr)
num = stack[len(stack)-tmp][0]
ss = S[:(N-1-num)]+"L"*(N-1-num)

lr = (N-1-num)

for i in range(num):
    if i == 0:
        if (ss[i+1] == "R" and ss[i] == "R"):
            lr += 1
    elif i == N-1:
        if (ss[i-1] == "L" and ss[i] == "L"):
            lr += 1
    else:
        if (ss[i-1] == "L" and ss[i] == "L") or (ss[i+1] == "R" and ss[i] == "R"):
            lr += 1


######################################################################
#左端をRにする場合
now = ""
num_substr = 0
ex = ""
stack = []
for i in range(N):
    if (ex == "R" or ex == "") and S[i] == "L":
        start = i
    if ex == "L" and S[i] == "R":
        end = i-1
        stack.append((start, end))
        num_substr += 1
    ex = S[i]
#左からひっくり返す
tmp = min(K,num_substr)
num = stack[tmp-1][1]
ss = "R"*(num+1)+S[num+1:]
rl = num
#print(ll, tmp)
for i in range(num+1,N):
    if i == 0:
        if (ss[i+1] == "R" and ss[i] == "R"):
            rl += 1
    elif i == N-1:
        if (ss[i-1] == "L" and ss[i] == "L"):
            rl += 1
    else:
        if (ss[i-1] == "L" and ss[i] == "L") or (ss[i+1] == "R" and ss[i] == "R"):
            rl += 1


#右からひっくり返す
tmp = min(K,num_substr)
num = stack[len(stack)-tmp][0]
ss = S[:(N-1-num)]+"R"*(N-1-num)

rr = (N-1-num)
#print(ll, tmp)
for i in range(num):
    if i == 0:
        if (ss[i+1] == "R" and ss[i] == "R"):
            rr += 1
    elif i == N-1:
        if (ss[i-1] == "L" and ss[i] == "L"):
            rr += 1
    else:
        if (ss[i-1] == "L" and ss[i] == "L") or (ss[i+1] == "R" and ss[i] == "R"):
            rr += 1


print(max([ll,lr,rl,rr]))





### FIXED CODE ###


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

ans = 0
for x,y in zip(S, S[1:]):
    if x == y: #同じ方向を見ているとき
        ans += 1
#最大K回まで操作をして、そのたびに幸福な人が二人増える。全員同じ方向を向くとN-1
ans = N-1 if ans+2*K >= N-1 else ans+2*K
print(ans)
ans = [105,135,165,189]
n = input()
if n < 105:
  print(0)
elif n < 135:
  print(1)
elif n < 165:
  print(2)
elif n < 189:
  print(3)
else:
  print(4)

### FIXED CODE ###

ans = [105,135,165,189]
n = int(input())
if n < 105:
  print(0)
elif n < 135:
  print(1)
elif n < 165:
  print(2)
elif n < 189:
  print(3)
elif n < 195:
  print(4)
else:
  print(5)
N=int,input()
A=int,input()
print(N*N-A)

### FIXED CODE ###

N=int(input())
A=int(input())
print(N*N-A)
A = input()
B = input()
C = input()
K = input()
if A+B+C <= K:
    print(A-C)

elif A+B <= K:
    print(A)

elif A <= K:
    print(K)

### FIXED CODE ###

A,B,C,K = map(int,input().split())
sum = 0;
if A <= K:
	sum += A;
	K -= A
else:
	sum += K;
	K -= K
if B <= K:
	K -= B
else:
	K -= K
if C <= K:
	sum -= C
	K -= C
else:
	sum -= K
	K -= K
print(sum)
N = int(input())
str = input()
str_list=list(str)
pre_list=[]
length_list=[]
answer_list=[]
answer_first=0
answer_second=0
for i in range (N-1):
  if str_list[i] != str_list[i+1]:
    pre_list.append(i)
    if pre_list == []:
      print("0")
      sys.exit()
    lenlen=len(pre_list)
for i in range (lenlen-1):
  length_list.append(pre_list[i+1]-pre_list[i])
  if lenlen=1:
    for i in range (N):
      if str_list[i] == "E":
        seki = -1
        else:
          seki = 1
          point = (i-pre_list[0])*seki
          if point<0:
            answer_first = answer_first+1
    print(answer_first)
    sys.exit()
basyo = length_list.index(max(length_list))
basyo2_kouho1 = pre_list[basyo]
basyo2_kouho2 = pre_list[basyo+1]
for i in range (N):
  if str_list[i] == "E":
    seki = -1
  else:
    seki = 1
  point = (i-basyo2_kouho1)*seki
  if point<0:
    answer_first = answer_first+1
for i in range (N):
  if str_list[i] == "E":
    seki = -1
  else:
    seki = 1
  point = (i-basyo2_kouho2)*seki
  if point<0:
    answer_second = answer_second+1
if answer_first>=answer_second:
  print(answer_second)
else:
  print(answer_first)
    

### FIXED CODE ###

N = int(input())
str = input()
str_list=list(str)
num_list=[]
ans_list=[]
num=0
for i in range (N):
  if str_list[i]=="E":
    num=num+1
    num_list.append(num)
  else:
    num_list.append(num)
   
for i in range (N):
  if i==0:
    ans=num_list[N-1]-num_list[i]
    ans_list.append(ans)
  else:
    ans=num_list[N-1]-num_list[i]+i-num_list[i-1]
    ans_list.append(ans)

print(min(ans_list))
a = int(input())
b = int(input())

print( (a-1)*(b-1))


### FIXED CODE ###

a, b = map(int, input().split())
 
print( (a-1)*(b-1))
X = map(int,input().split())
for i in range(5):
    if X[i] != i :
        print(i+1)

### FIXED CODE ###

X = list(map(int,input().split()))
for i in range(5):
    if X[i] != i+1 :
        print(i+1)
S = input()
if len(S) >= 10:
  print("NO")
else:
  if S == "AKIHABARA":
    print("YES")
  elif S == "KIHABARA":
    print("YES")
  elif S == "AKIHBARA":
    print("YES")
  elif S == "AKIHABRA":
    print("YES")
  elif S == "AKIHABR":
    print("YES")
  elif S == "KIHBARA":
    print("YES")
  elif S == "KIHABRA":
    print("YES")
  elif S == "KIHABAR":
    print("YES")
  elif S == "AKIHBRA":
    print("YES")
  elif S == "AKIHABR":
    print("YES")
  elif S == "KIHBRA":
    print("YES")
  elif S == "KIHBAR":
    print("YES")
  elif S == "AKIHBR":
    print("YES")
  elif S == "KIHBR":
    print("YES")
  else;
  print("NO")

### FIXED CODE ###

S=input()

pos={"AKIHABARA","KIHABARA","AKIHBARA","KIHBARA","AKIHABRA","KIHABRA","AKIHBRA","KIHBRA","AKIHABAR","KIHABAR","AKIHBAR","KIHBAR","AKIHABR","KIHABR","AKIHBR","KIHBR"}
     
if S in pos:
  print("YES")
else:
  print("NO")
N = int(input())
Q = 0
for i in range(N+1):
  if(N%3 !== 0 and N%5 !== 0):
      Q += i
print(Q)

### FIXED CODE ###

N = int(input())
Q = 0
for i in range(1,N+1):
  if(i%3 != 0 and i%5 != 0):
      Q += i
print(Q)
N=int(input())
F=[list(map(int,input().split())) for _ in range(N)] #0-9
P=[list(map(int,input().split())) for _ in range(N)] #0-10
INF=10**9
ans=-INF


for i in range(1,2**10):
    tmp=[0]*10
    tmpans=0
    for j in range(0,10):
        bit=i>>j&1
        for n in range(N):
            tmp[n]+=F[n][j]*bit
    for n in range(N):
        tmpans+=P[n][tmp[n]]

    ans=max(ans,tmpans)

print(ans)

### FIXED CODE ###

N=int(input())
F=[list(map(int,input().split())) for _ in range(N)] #0-9
P=[list(map(int,input().split())) for _ in range(N)] #0-10

INF=10**9
ans=-INF

for i in range(1,2**10):
    tmpans=0
    for n in range(N):
        c=0
        for j in range(10):
            if (i>>j&1)&F[n][j]:
                c+=1
        tmpans+=P[n][c]

    ans=max(ans,tmpans)

print(ans)
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10000000)

def search(values,hp,vp,item):
	if not (0<=hp<len(values)): return
	if not (0<=vp<len(values[hp])): return
	if item!=values[hp][vp]: return
	values[hp][vp]=True
	search(values,hp-1,vp,item)
	search(values,hp+1,vp,item)
	search(values,hp,vp-1,item)
	search(values,hp,vp+1,item)

def solve(values):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(values)):
		for j in range(len(values[i])):
			if values[i][j] in valid_items:
				search(values,i,j,values[i][j])
				count+=1
	return count

def main():
	line,values=input().strip(),list()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		value = list()
		for _ in range(H):
			value.append(input().strip())
		values.append(value)
		line = input().strip()
	for value in values:
		print(solve(value))

if __name__=='__main__':
	main()

### FIXED CODE ###

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

import sys
sys.setrecursionlimit(10**6)

def search(field,hp,vp,item):
	if not (0<=hp<len(field)): return
	if not (0<=vp<len(field[hp])): return
	if item!=field[hp][vp]: return
	field[hp][vp]=True
	for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]:
		search(field,hp+dh,vp+dv,item)
#	search(field,hp-1,vp,item)
#	search(field,hp+1,vp,item)
#	search(field,hp,vp-1,item)
#	search(field,hp,vp+1,item)

def solve(field):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(field)):
		for j in range(len(field[i])):
			if field[i][j] in valid_items:
				search(field,i,j,field[i][j])
				count+=1
	return count

def main():
	line = input().strip()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		field = list()
		for _ in range(H):
			field.append(list(input().strip()))
		print(solve(field))
		line = input().strip()

if __name__=='__main__':
	main()