Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def FizzBuzz(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = FizzBuzz()
        for _ in range(n):
            p = input().strip('\n')
            # print('player {}: {}'.format(players[0], p))
            if p != fb.__next__():
                drop = players.popleft()
                # print('player {} dropped'.format(drop))
                if len(players) == 1:
                    break
            else:
                players.rotate(-1)

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def fb_gen(count=1):
    while True:
        if count % 15 == 0:
            ans = 'FizzBuzz'
        elif count % 5 == 0:
            ans = 'Buzz'
        elif count % 3 == 0:
            ans = 'Fizz'
        else:
            ans = str(count)
        yield ans
        count += 1


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        players = deque(range(1, m+1))
        fb = fb_gen()
        ok_count = 0
        for _ in range(n):
            p = input().strip()
            if p != fb.__next__():
                if len(players) > 1:
                    players.rotate(ok_count)
                    players.popleft()
                    ok_count = 0
            else:
                ok_count -= 1

        result = list(players)
        result.sort()
        print(*result)


if __name__ == '__main__':
    main(sys.argv[1:])
S = input()
if S = 'ABC':
    print("ARC")
else:
    print("ABC")


### FIXED CODE ###

S = input()
if S == 'ABC':
    print("ARC")
else:
    print("ABC")
# https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
    def __init__(self, N):
        self._root = [-1 for _ in range(N)]

    def find(self, x):
        if self._root[x] < 0: return x
        self._root[x] == self.find(self._root[x])
        return self._root[x]

    def unite(self, x, y):
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy:
            return False
        if self._root[gx] > self._root[gy]:
            gx, gy = gy, gx
        self._root[gx] += self._root[gy]
        self._root[gy] = gx
        print(self._root)
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -(self._root[self.find(x)])

    def roots(self):
        return [i for i in self._root if i < 0]


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

nodes = []
for _ in range(m):
    a, b = map(int, input().split())
    nodes.append((a,b))

cnt = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i != j: 
           uf.unite(nodes[j][0]-1, nodes[j][1]-1)
    cnt += (len(uf.roots()) != 1)
print(cnt)

### FIXED CODE ###

# https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
    def __init__(self, N):
        self._root = [-1 for _ in range(N)]

    def find(self, x):
        if self._root[x] < 0: return x
        self._root[x] = self.find(self._root[x])
        return self._root[x]

    def unite(self, x, y):
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy: return False
        if self._root[gx] > self._root[gy]:
            gx, gy = gy, gx
        self._root[gx] += self._root[gy]
        self._root[gy] = gx
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -(self._root[self.find(x)])

    def roots(self):
        return [i for i in self._root if i < 0]


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

nodes = []
for _ in range(m):
    a, b = map(int, input().split())
    nodes.append((a, b))

cnt = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i != j:
          uf.unite(nodes[j][0]-1, nodes[j][1]-1)
    cnt += (len(uf.roots()) != 1)
print(cnt)
s = list(input())

if input[0]=="9" or  input[1]=="9":
  print("Yes")
else:
  print("No")


### FIXED CODE ###

s = input()

if s[0]=="9" or  s[1]=="9":
  print("Yes")
else:
  print("No")
a = list(map(int,input().split()))
b = sorted(a)
if b = [5, 5, 7]:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a = list(map(int,input().split()))
b = sorted(a)
if b == [5, 5, 7]:
    print("YES")
else:
    print("NO")
print(len(set([int(i) in input().split()])))

### FIXED CODE ###

print(len(set([int(i) for i in input().split()])))
n=int(input())
lst=[(a,b) for a in ['S','H','C','D'] for b in range(1,14)]
for i in range(n):
    a,b = input().split()
    b = int(b)
    lst.remove(a,b)
for (a,b) in lst:
    print(a,b)


### FIXED CODE ###

n=int(input())
lst=[(a,b) for a in ['S','H','C','D'] for b in range(1,14)]
for i in range(n):
    a,b = input().split()
    b = int(b)
    lst.remove((a,b))
for (a,b) in lst:
    print(a,b)
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b
from collections import deque

n, m = getMN()
class vertex():
    def __init__(self):
        self.number = 0
        self.dst = 0

parents = [[] for i in range(n+1)]
childs = [[] for i in range(n+1)]
for i in range(m+n-1):
    m,n = getMN()
    parents[n].append(m)
    childs[m].append(n)
vtxs = [vertex() for i in range(n+2)]
d = deque()
for i ,x in enumerate(parents[1:]):
    if not x:
        n_root = i+1
        break

vtxs[n_root].dst = 0


def bfs(n_cur):
    #print(([v.dst for v in vtxs]))
    #c is pure integer
    #print("n_cur = {}".format(n_cur))
    v_cur = vtxs[n_cur]
    for c in childs[n_cur]:
        d.append(c)
        #print("c = {}".format(c))
        vtxs[c].dst = max(vtxs[c].dst, v_cur.dst+1)
    while(d):
        bfs(d.popleft())

bfs(n_root)

dsts = (([v.dst for v in vtxs]))

for plist in parents[1:]:
    if plist:
        cur = -1
        for p in plist:
            if dsts[p] > cur:
                cur = dsts[p]
                ans = p
        print(ans)
    else:
        print(0)


### FIXED CODE ###

def getN():
    return int(input())


def getNM():
    return map(int, input().split())


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

n,m = getNM()
children = [[] for i in range(n+2)]
n_in = [0] * (n+1)
par_origin = [0] * (n+1)

#入力の処理
for i in range(n+m-1):
    a,b = getNM()
    children[a].append(b)
    n_in[b] += 1

#根を見つける
for i in range(1,n+m-1):
    if n_in[i]:
        pass
    else:
        root = i
        break

#次数を減らしながら探索
import queue
def bfs(root):
    q = queue.Queue()
    q.put(root)
    while(True):
        try:
            cur = q.get(block=False)
        except:
            break
        for c in children[cur]:
            if n_in[c] == 1:
                par_origin[c] = cur
                q.put(c)
            else:
                n_in[c] -= 1

bfs(root)
for i in range(1, n+1):
    print(par_origin[i])
n,m=map(int,input().split())
lst=[]
for i in range(m):
  P,Y=map(int,input().split())
  lst.append([P,Y])
lst.sort(key=lambda x:x[0])
lst.sort(key=lambda x:x[1])
lst[0][1]=1
for j in range(m-1):
  if lst[j][0]==lst[j+1][0]:
    lst[j+1][1]=lst[j][1]+1
  else:
    lst[j+1][1]=1
def plus0(s):
  while len(s)<6:
    s='0'+s
for k in range(m):
  lst[k][0]=plus0(str(lst[k][0]))
  lst[k][1]=plus0(str(lst[k][1]))
  print(''.join(lst[k]))
  





### FIXED CODE ###

n,m=map(int,input().split())
lst=[]
for i in range(m):
  p,y=map(int,input().split())
  lst.append([i,p,y])
lst.sort(key=lambda x:(x[1],x[2]))
j=1
Lst=[]
for i in range(m):
  if lst[i][1]==lst[min(m-1,i+1)][1]:
    s=str(lst[i][1])
    t=str(j)
    u=s.zfill(6)+t.zfill(6)
    j+=1
    Lst.append([lst[i][0],u])
  else:
    s=str(lst[i][1])
    t=str(j)
    u=s.zfill(6)+t.zfill(6)
    j-=j-1
    Lst.append([lst[i][0],u])
Lst.sort(key=lambda x:x[0])
for k in range(m):
  print(Lst[k][1])
A,B=map(int,input().split())
lst=[]
i=2
while A>1 and B>1:
    if A%i==0 and B%i==0:
        flag=1
        for l in lst:
            if i%l==0:
                flag=0
                break
        if flag:
            A=A//i
            B=B//i
            lst.append(i)
    if not flag:
        i+=1

lst+=[1]
#print(lst)
print(len(lst))


### FIXED CODE ###

A,B=map(int,input().split())
lst=set()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if A==B==1:
    print(1)
else:
    print(len(set([i[0] for i in factorization(A)])&set([i[0] for i in factorization(B)]))+1)
n,m=map(int,input().split())
ans=[0]*m
ansnum=0
for i in range(n):
    list1=list(map(int,input().split()))
    for j in range(len(list1)-1):
        ans[list1[j]]+=1
for i in range(m):
    if ans[i]==n:
        ansnum+=1
print(ansnum)


### FIXED CODE ###

n,m=map(int,input().split())
ans=[0]*m
ansnum=0
for i in range(n):
    list1=list(map(int,input().split()))
    for j in range(list1[0]):
        ans[list1[j+1]-1]+=1
for i in range(m):
    if ans[i]==n:
        ansnum+=1
print(ansnum)
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

S = input()
ls = list(S)
ls = [int(x) for x in ls]
offset = 0
count = 0
while True:
    if ls[offset] == ls[offset +1]:
        del ls[offset:offset +2]
        count += 2
        offset = 0
    elif offset + 1 == len(ls):
        break
    else:
        offset += 1

print(count)

### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

S = input()
ls = list(S)
ls = [int(x) for x in ls]

ans = min(ls.count(0),ls.count(1))
print(ans*2)
#!/usr/bin/env python3


def div_pairs(n):
    for i in range(1, n):
        if i * i > n:
            break
        d, m = divmod(n, i)
        if m == 0:
            yield (i, d)


def f(a, b):
    return max(len(str(a)), len(str(b)))


def solve(n):
    return min(f(a, b) for a, b in div_pairs(n))


def main():
    print(solve(int(input())))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3


def div_pairs(n):
    for i in range(1, n + 1):
        if i * i > n:
            break
        d, m = divmod(n, i)
        if m == 0:
            yield (i, d)


def f(a, b):
    return max(len(str(a)), len(str(b)))


def solve(n):
    return min(f(a, b) for a, b in div_pairs(n))


def main():
    print(solve(int(input())))


if __name__ == '__main__':
    main()
i  = input()
if i == 'Sunny':
    print('Cloudy')
elif i == 'Cloudy':
    print('Rainy')
elif i = 'Rainy':
    print('Sunny')

### FIXED CODE ###

i  = input()
if i == 'Sunny':
    print('Cloudy')
elif i == 'Cloudy':
    print('Rainy')
elif i == 'Rainy':
    print('Sunny')
def f(h,k):
    N=len(h)
    t=0
    h.sort()
    for i in range(k-1):
        t+=h[i]
    return sum(h)-t
N,k=map(int,input().split())
h=list(map(int,input().split()))
print(f(h,k))

        

### FIXED CODE ###

def f(h,k):
    N=len(h)
    t=0
    h.sort()
    for i in range(N-k):
        t+=h[i]
    return t
N,k=map(int,input().split())
h=list(map(int,input().split()))
print(f(h,k))
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
price = 0
for i in range(k):
  price += p[i]
print(price)


### FIXED CODE ###

alpha = input()
print('A' if alpha.isupper() else 'a')
a,b = map(int(),input().split())

if a*b % 2 ==1:
  print("Odd")
else:
  print("Even")
    

### FIXED CODE ###

a,b = map(int,input().split())
 
if a*b % 2 == 1:
    print("Odd")
else:
    print("Even")
a,b,c=map(int,input().split())
if a<=c and a+b<=c
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a,b,c=map(int,input().split())
if a<=c and a+b>=c:
    print("YES")
else:
    print("NO")
n, x, t = map(int, input().split())
print(ceil(n/x)*t)


### FIXED CODE ###

from math import ceil
n, x, t = map(int, input().split())
print(ceil(n/x)*t)
from collections import deque
n,k=map(int,input().split())
s=input()
if n==1:
    print(1)
else:
	a=deque([])
	if s[0]=="1":
    	a.append([0])
	for i in range(1,n):
    	if s[i-1:i+1]=="01":
        	a.append([i])
    	elif s[i-1:i+1]=="10":
        	a[-1].append(i-1)
	if s[n-1]=="1":
    	a[-1].append(n-1)
	if a[0][0]!=0:
    	a.appendleft([0,0])
	if a[-1][1]!=n-1:
    	a.append([n-1,n-1])
        
	if len(a)-1<=k:
    	print(n)
	else:
    	t=0
    	for i in range(len(a)-k):
        	t=max(t,a[i+k][1]-a[i][0]+1)
    	print(t)

### FIXED CODE ###

#D
from collections import deque
n,k=map(int,input().split())
s=input()
if n==1:
    print(1)
elif "1" not in s:
  	print(len(s))
else:
    a=deque([])
    if s[0]=="1":
        a.append([0])
    for i in range(1,n):
        if s[i-1:i+1]=="01":
            a.append([i])
        elif s[i-1:i+1]=="10":
            a[-1].append(i-1)
    if s[n-1]=="1":
        a[-1].append(n-1)
    if a[0][0]!=0:
        a.appendleft([0,0])
    if a[-1][1]!=n-1:
        a.append([n-1,n-1])
    if len(a)-1<=k:
        print(n)
    else:
        t=0
        for i in range(len(a)-k):
            t=max(t,a[i+k][1]-a[i][0]+1)
        print(t)
import math

def combi(n ,k):
    return math.factorial(n)/(math.factorial(k)*math.factorial(n-k))

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

cnt_list = []
for i in range(1,K+1):
    if N-K+1 >= i:
        cnt = int(combi(N-K+1,i)*combi(K-1,i-1))
    else:
        cnt =0
    cnt_list.append(cnt%(10**9+7))

for i in range(len(cnt_list)):
    print(cnt_list[i])

### FIXED CODE ###

import math

def combi(n ,k):
    return math.factorial(n)//(math.factorial(k)*math.factorial(n-k))

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

cnt_list = []
for i in range(1,K+1):
    if N-K+1 >= i:
        cnt = int(combi(N-K+1,i)*combi(K-1,i-1))
    else:
        cnt =0
    cnt_list.append(cnt%(10**9+7))

for i in range(len(cnt_list)):
    print(cnt_list[i])
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N)) 
    seachList = [i for i in range(2, N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    primeNum.append(1)
    return set(primeNum)

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

divs_A = set()
for i in range(1, A+1):
    if A % i == 0:
        divs_A.add(i)
        
divs_B = set()
for i in range(1, B+1):
    if B % i == 0:
        divs_B.add(i)

divs = list(divs_A & divs_B)

print(len(set(divs) & seachPrimeNum(max(divs))))

### FIXED CODE ###

from fractions import gcd

def FindAllDivisors(x):
    divList = []
    y = 1
    while y <= x**0.5:
        if x % y == 0:
            divList.append(y)
            divList.append(int(x / y))
        y += 1
    return sorted(list(set(divList)))

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

max_divs = gcd(A, B)
divs = FindAllDivisors(max_divs)

results = []
for div in divs[1:]:
    flag = True
    for result in results:
        if div % result == 0:
            flag = False
            break
    if flag:
        results.append(div)

print(len(results) + 1)
import math
import fractions

k = input()

sum = 0
for a in range(k):
    for b in range(k):
        x = fractions.gcd(a+1, b+1)
        for c in range(k):
            y = fractions.gcd(x, c+1)
            sum += y
print(sum)


### FIXED CODE ###

import math
import fractions

k = input()

sum = 0
for a in range(int(k)):
    for b in range(int(k)):
        x = math.gcd(a+1, b+1)
        for c in range(int(k)):
            y = math.gcd(x, c+1)
            sum += y
print(sum)
A, B = map(int, input().split())
tmp = 0
if abs(A-B) > 1:
    tmp = max(A,B)
    print(tmp*2-1)
else abs(A-B) == 1:
    print(A + B)

### FIXED CODE ###

A, B = map(int, input().split())
if abs(A-B) > 1:
    tmp = max(A,B)
    print(tmp*2-1)
else:
    print(A + B)
a,b=map(int,input().split())print(('P'if a*b*(a+b)%3<0else'Imp')+'ossible')

### FIXED CODE ###

a,b=map(int,input().split());print(['P','Imp'][a*b*(a+b)%3>0]+'ossible')
a = int(input())
b = int(input())

if(a > 8 or b > 8):
    print (':(') 
else:
    print ('Yay!')


### FIXED CODE ###

l = input().split()
a = int(l[0])
b = int(l[1])

if(a > 8 or b > 8):
    print (':(') 
else:
    print ('Yay!')
N,M = map(int, input().split())
par = list(range(N))

def root(x):
    if x == par[x]:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

for i in range(M):
    x,y,_ = map(int, input().split())
    rx = root(x-1)
    ry = root(y-1)
    if rx != ry:
        par[ry] = rx

rlist = set()
for i in par:
    rlist.add(root(i))

print(len(rlist))


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

class UnionFind:
    def __init__(self, num):
        self.p = [x for x in range(num)]
    def root(self, x):
        if self.p[x] == x:
            return x
        else:
            self.p[x] = self.root(self.p[x])
            return self.p[x]
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx != ry:
            self.p[ry] = rx

def main():
    N, M = (int(x) for x in input().split())
    u = UnionFind(N)

    for i in range(M):
        x,y,_ = map(int, input().split())
        u.unite(x-1, y-1)

    rlist = set()
    for i in range(N):
        rlist.add(u.root(i))

    print(len(rlist))

if __name__ == '__main__':
    main()
a,b,c,x = map(int,[input() for i in range(4)]):
ans = 0:
  
  for i in range(a+1):
    for j in range(b+1):
      for f in range(c+1):
        if i*500 + j*100 + f*50 == x:
          ans +=1:
            
print(ans):

### FIXED CODE ###

a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)
l=int(input())
n=l/3
print(n*n*n)

### FIXED CODE ###

n,m=map(int,input().split())
print(n*(n-1)//2 + m*(m-1)//2)
import math
N = int(input())
A = list(map(int,input().split()))
b = [[0]*60 for i in range(2)]
max_a = math.ceil(math.log(max(A),2))
for i in range(N):
    x = A[i]
    j = 0
    for j in range(max_a):
        b[x % 2][j] += 1
        x //= 2

x = 0
for i in range(max_a):
    x += b[0][i] * b[1][i] * 2**i
    x %= 10 ** 9 + 7

print (x)

### FIXED CODE ###

import math
N = int(input())
A = list(map(int,input().split()))
b = [[0]*60 for i in range(2)]
#max_a = math.ceil(math.log(max(A),2))
max_a = 60
for i in range(N):
    x = A[i]
    j = 0
    for j in range(max_a):
        b[x % 2][j] += 1
        x //= 2

x = 0
for i in range(max_a):
    x += b[0][i] * b[1][i] * 2**i
    x %= 10 ** 9 + 7

print (x)
import numpy as np
N,X,Y=map(int, input().split())
ans = np.zeros(N-1)
for i in range(1,N):
  for j in range(i+1,N+1):
    root1 = j-i
    root2 = abs(X-i) + 1 + abs(Y-j)
    min_k = min(root1, root2)
    ans[min_k-1] = ans[min_k-1] + 1

for a in ans:
  print(int(a))

### FIXED CODE ###

import numpy as np
N,X,Y=map(int, input().split())
ans = [0]*(N-1)
for i in range(1,N):
  for j in range(i+1,N+1):
    root1 = j-i
    root2 = abs(X-i) + 1 + abs(Y-j)
    min_k = min(root1, root2)
    ans[min_k-1] = ans[min_k-1] + 1

for a in ans:
  print(a)
import itertools
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
for i,v in enumerate(list(itertools.permutations(range(1,N+1))), 1):
    if list(v) == P:
        A = i
    elif list(v) == Q:
        B = i
    else:
        pass
try:
    print(abs(A-B))

### FIXED CODE ###

import itertools
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
num = 0
for v in list(itertools.permutations(range(1,N+1))):
    num += 1
    if list(v) == P:
        A = num
    elif list(v) == Q:
        B = num
    else:
        pass
try:
    print(abs(A-B))
except:
    print(0)
n, k = map(int, input().split())
a = [int(input()) for _i in range(n)]

dp = [0]*300000
dp_nex = [0]*300000

for i in range(n):
    dp[a[i]] = max(dp[max(0,i-k):min(300000, i+k)])+1
print(max(dp))


### FIXED CODE ###

_N, k = map(int, input().split())
a = [int(input()) for _i in range(_N)]

n = 300002

def init_max(init_max_val):
    #set_val
    for i in range(n):
        seg_max[i+num_max-1]=init_max_val[i]    
    #built
    for i in range(num_max-2,-1,-1) :
        seg_max[i]=max(seg_max[2*i+1],seg_max[2*i+2]) 
    
def update_max(k,x):
    k += num_max-1
    seg_max[k] = x
    while k:
        k = (k-1)//2
        seg_max[k] = max(seg_max[k*2+1],seg_max[k*2+2])
    
def query_max(p,q):
    if q<=p:
        return ide_ele_max
    p += num_max-1
    q += num_max-2
    res=ide_ele_max
    while q-p>1:
        if p&1 == 0:
            res = max(res,seg_max[p])
        if q&1 == 1:
            res = max(res,seg_max[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = max(res,seg_max[p])
    else:
        res = max(max(res,seg_max[p]),seg_max[q])
    return res

#####単位元######
ide_ele_max = -1

#num_max:n以上の最小の2のべき乗
num_max =2**(n-1).bit_length()
seg_max=[ide_ele_max]*2*num_max

A = [0]*300002
init_max(A)

for i in range(_N):
    update_max(a[i], query_max(max(0, a[i]-k), min(300001, a[i]+k+1))+1)

print(query_max(0,300001))
n=int(input())

for i in n:
  
    if i %15==0:
        print('Fizz Buzz')
    elif i % 3==0:
        print('Fizz')
    elif i % 5 ==0:
        print('Buzz')
    else:
        print(i)


### FIXED CODE ###

n = int(input())
sum = 0

for i in range(1, n + 1):

    if i % 3 != 0 and i % 5 != 0:
        sum = sum + i

print(sum)
a,b,x=map(int,input().split())
i=0
while(k):
  i+=1
  if max(a%i,a%i):
    pass
  else:
    k-=1
print(i)

### FIXED CODE ###

a,b,k=map(int,input().split())
i=min(a,b)+1
while(k):
  i-=1
  if max(a%i,b%i)==0:
    k-=1
print(i)
n = int(input())
a = list(map(int, input().split()))
ca = []
cnt = 0
for i in range(len(a)-1):
  if(a[i]<a[i+1]):
    ca.append(cnt)
    cnt = 0
  else:
    cnt += 1
if(a[len(a)-2]>a[len(a)-1]):
  cnt += 1
ans = max(max(ca), cnt)
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ca = []
cnt = 0
for i in range(len(a)-1):
  if(a[i]<a[i+1]):
    ca.append(cnt)
    cnt = 0
  else:
    cnt += 1
ca.append(0)
ans = max(max(ca), cnt)
print(ans)
s=input();n=len(s)-1;print(sum(s[i]!=s[n-i]for i in range(n+1))//2)s=input();n=len(s)-1;print(sum(s[i]!=s[n-i]for i in range(n+1))//2)

### FIXED CODE ###

s=input();print(sum(s[i]!=s[len(s)-i-1] for i in range(len(s)))//2)
import bisect

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

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

for w in range(M):
    max2=A.pop(N-1)/2
    #A[N-1]=A[N-1]/2
    #max=A[N-1]
    if max2<A[N-2]:
        bisect.insort_left(A,max2)
    else:
        A[N-1]=max2
    #print(A)

B=list(map(int, A))
#print(B)
print(sum(B))

### FIXED CODE ###

import heapq

N,M=map(int,input().split())
A=list(map(int,input().split()))
#print(A)
A =[-a for a in A]
#print(A)
heapq.heapify(A)

for w in range(M):
    max=heapq.heappop(A)
    heapq.heappush(A,max/2)
   
B=list(map(int, A))
#print(B)
print(sum(B)*-1)
N=int(input())
otoshidama=0
for _ in range(N):
    x,u=input().split()
    x=int(x)
    if u=="JPY":
        otoshidama+=x
    else:
        otoshidama+=x*380000.0
print(otoshidama)
        

### FIXED CODE ###

n = int(input())
A=[]
for i in range(n):
  A.append(list(input().split()))
 
ans=0
for a in A:
    if a[1] =="JPY":
        ans += float(a[0])
    else:
        ans += float(a[0]) * 380000.0
print(ans)