Harryxun/stf_run huggingface dataset:
def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])
def solve(maze, start_r, start_c):
    
    distances = {}
    offsets = [(-1,0),(1,0),(0,-1),(0,1)]
    
    distances[start_r, start_c] = 0
    candidates = [(start_r, start_c)]
    
    while candidates:
        r, c= candidates.pop(0)
        
        for offset_r, offset_c in offsets:
            move_r, move_c = r + offset_r, c + offset_c
            if not (move_r, move_c) in distances and maze[move_r, move_c] == ".":
                distances[move_r, move_c] = distances[r, c] + 1
                candidates.append((move_r, move_c))
    
    return max(distances.values())
    

def main():
    h, w = get_next_ints()
    from collections import defaultdict
    maze = defaultdict(str)
    for r in range(h):
        line = get_next_str()
        for c in range(w):
            maze[r,c] = line[c]
    
    results = []
    for r in range(h):
        for c in range(w):
            result = solve(maze, r, c)
            results.append(result)
    
    print(max(results))
    
if __name__ == '__main__':
    main()
if __name__ == '__jupyter__':
    import doctest
    print(doctest.testmod())


### FIXED CODE ###

def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_by_types(*value_types, delim=" "):
    return tuple(
        [t(x) for t, x in zip(value_types, input().rstrip("\n").split(delim))])


def main():
    n, m = get_next_ints()
    ac_count = 0
    wa_count = 0

    from collections import defaultdict
    ac_cache = defaultdict(int)
    wa_cache = defaultdict(int)
    ac_count = 0
    wa_count = 0
    wa = 0
    for i in range(m):

        p, result = get_next_by_types(int, str)

        if ac_cache[p] == 0:
            if result == 'AC':

                ac_cache[p] = 1
                ac_count += 1
                wa_count += wa_cache[p]
                wa = 0
            else:
                wa_cache[p] += 1
    print(ac_count, wa_count)


if __name__ == '__main__':
    main()
if __name__ == '__jupyter__':
    import doctest
    print(doctest.testmod())
n,m = map(int,input().split())
s = [[0]*n for _ in range(n)]

for _ in range(m):
    a,b = map(int,input().split())
#    print(a,b)
    s[a-1][b-1] += 1
    s[b-1][a-1] += 1
#    print(s)

for i in range(n):
    print(sum(s[i]))

"""
以下の指定では、一度の値変更で、全ての要素の該当部分の数値が一斉に変わる。
http://delta114514.hatenablog.jp/entry/2018/01/02/233002
n,m = map(int,input().split())
s = [[0]*n]*n
"""


### FIXED CODE ###

a,b,c = map(int,input().split())
if a<= c <= b:
    print("Yes")
else:
    print("No")
import math
n = int(input())
prev = 0
for i in range(n):
    if(i == 0):
        prev = int(input())
    else:
        t = int(input())
        prev = int(prev * t / math.gcd(prev, t))
print(prev)


### FIXED CODE ###

def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)
n = int(input())
prev = 1
for i in range(n):
        t = int(input())
        prev = prev * t // gcd(prev, t)
print(prev)
import heapq
def makeTree(j):
    global tree
    for x in G[j]:
        if hist[x]==0:
            heapq.heappush(F[tree],(A[x],x,tree))
            hist[x] = 1
            makeTree(x)
N,M = map(int,input().split())
A = list(map(int,input().split()))
G = {i:[] for i in range(N)}
for _ in range(M):
    x,y = map(int,input().split())
    G[x].append(y)
    G[y].append(x)
if M==N-1:
    cost = 0
elif N<2*(N-M-1):
    cost = "Impossible"
else:
    n = N-M
    F = {i:[] for i in range(n)}
    hist = [0 for _ in range(N+1)]
    tree = 0
    for j in range(N):
        if hist[j]==1:continue
        heapq.heappush(F[tree],(A[j],j,tree))
        hist[j] = 1
        makeTree(j)
        tree += 1
    cost = 0
    B = [heapq.heappop(F[0])]
    C =sorted([heapq.heappop(F[i]) for i in range(1,n)],key=lambda x:x[0],reverse=True)
    for i in range(n-1):
        b = heapq.heappop(B)
        c = C.pop()
        indb = b[2]
        indc = c[2]
        cost += b[0]+c[0]
        if i==n-2:continue
        heapq.heappush(B,heapq.heappop(F[indb]))
        heapq.heappush(B,heapq.heappop(F[indc]))
print(cost)

### FIXED CODE ###

from collections import deque
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
G = {i:[] for i in range(N)}
for _ in range(M):
    x,y = map(int,input().split())
    G[x].append(y)
    G[y].append(x)
F = []
hist = [0 for _ in range(N)]
for i in range(N):
    T = []
    if hist[i]==0:
        que = deque([i])
        hist[i]=1
        heapq.heappush(T,A[i])
        while que:
            x = que.popleft()
            for y in G[x]:
                if hist[y]==0:
                    que.append(y)
                    hist[y]=1
                    heapq.heappush(T,A[y])
        F.append(T)
K = len(F)
if K>N//2+1:        
    cnt = -1
elif K==1:
    cnt = 0
else:
    cnt = 0
    for i in range(K):
        cnt += heapq.heappop(F[i])
    F1 = []
    for T in F:
        F1 += T
    F1 = sorted(F1)
    for i in range(K-2):
        cnt += F1[i]
if cnt<0:
    print("Impossible")
else:
    print(cnt)
import time
st_time=time.time()

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
#show_flg=True

h,w,n=LI()
b=[h,w,w,h]
r,c=LI()
st=[r,c,c,r]
s=input()
t=input()
cs=[[0]for i in range(4)]
ct=[[0]for i in range(4)]
di='URLD'
di=dict(zip(list(di),range(4)))
for j,i in di.items():
    for k in range(n):
        cs[i].append(cs[i][-1]+(1 if s[k]==j else 0))
        ct[i].append(ct[i][-1]+(1 if t[k]==j else 0))
ans=False
for i in range(4):
    if max([(i-j)*(-1)**(i//2)+st[i] for i,j in zip(cs[i],[0]+ct[3-i])])>b[i]:
        ans=True
if ans:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

import time
st_time=time.time()

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
#show_flg=True

di='URLD'
mp=dict(zip(list(di),range(4)))
rv=dict(zip(list(di),list(di[::-1])))

h,w,n=LI()
b=[h,w,w,h]
r,c=LI()
st=[h-r+1,c,w-c+1,r]
s=input()
t=[rv[i] for i in input()]
ans=True
for j,i in mp.items():
    c=st[i]
    for k in range(n):
        c+=1*(s[k]==j)
        if c>b[i]:
            ans=False
        if c>1:
            c-=1*(t[k]==j)
            
show(s)
show(t)
show(mp,rv,di)
if ans:
    print('YES')
else:
    print('NO')
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""code-fes-2017-qual-c-c"""


import sys

OP_NUM = 0

def solve(s):
    """Solve."""
    global OP_NUM

    if len(s) == 0:
        return ""
    if len(s) == 1:
        return ""

    if s[0] == 'x':
        if s[-1] == 'x':
            return solve(s[1:-1])
        OP_NUM += 1
        return solve(s[1:])

    if s[0] == s[-1]:
        return solve(s[1:-1])
    if 'x' == s[-1]:
        OP_NUM += 1
        return solve(s[:-1])

    return None


def main():
    """Main function."""
    s = input()

    forward = solve(s)
    if forward is None:
        print(-1)
    else:
        print(OP_NUM)


if __name__ == '__main__':
    sys.exit(main())

### FIXED CODE ###

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

"""code-fes-2017-qual-c-c"""


import sys

OP_NUM = 0

def solve(s):
    """Solve."""
    global OP_NUM

    if len(s) == 0:
        return ""
    if len(s) == 1:
        return ""

    if s[0] == 'x':
        if s[-1] == 'x':
            return s[1:-1]
        OP_NUM += 1
        return s[1:]

    if s[0] == s[-1]:
        return s[1:-1]
    if 'x' == s[-1]:
        OP_NUM += 1
        return s[:-1]

    return None


def main():
    """Main function."""
    s = input()

    while s:
        s = solve(s)
        if s is None:
            print(-1)
            sys.exit(0)

    print(OP_NUM)

if __name__ == '__main__':
    sys.exit(main())
#500-1000, 5-5

x = int(input())
fiveHundred = x//500
x -= fiveHundred*500
fives = x//5
print(fiveHundred*1000+fives*5)


### FIXED CODE ###

s = input()

if s[2]==s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")
# Widespread
n,a,b = list(map(int, input().split()))
h = []
for i in range(n):
    h.append(int(input()))


# やり直し
import math as m

def check(ary, num, a, b):
    bommed = [(hi- b*num) for hi in h if (hi- b*num)>0]
    acnt = sum([m.ceil(hi/(a-b)) for hi in bommed])
    if acnt > num:
        return "NO"
    else:
        return "YES"

imin = 1
imax = m.ceil(max(nh)/a)

while ( imax > imin+1 ):
    imid = imin + (imax-imin)//2
    if ( check(h, imid, imin, imax)=="YES" ):
        imax = imid
    else:
        imin = imid
print(imax)

### FIXED CODE ###

n,a,b = list(map(int, input().split()))
h = []
for i in range(n):
    h.append(int(input()))

import math

sup = sum([hh // a + 1 for hh in h])
inf = 1
 
while sup - inf > 1:
    x = (sup + inf) // 2
    c = sum([math.ceil((hh - x * b)/(a-b)) for hh in h if hh > x * b])
    if c <= x:
        sup = x
    else:
        inf = x
 
print(sup)
def insertionSort(A,N):
    for i in range(1,N):
        v = A[i]
        j=i-1
        while(j>=0 and A[j] > v):
            A[j+1] = A[j]
            j-=1
        A[j+1]=v
        print(*A)

if __name__ == '__main__':
    N = int(input())
    A = [int(i) for i in input().split()]
    print(*insertionSort(A,N))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
print( *A )
for i in range(1,N):
    v = A[i]
    j = i - 1
    while j >= 0 and A [j] > v :
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print( *A )
print(a + a ** 2 + a ** 3)

### FIXED CODE ###

a = int(input())
print(a + a**2 + a**3)
n = input()
N = int(n)

m = N % 10

if (n == 3):
    print(bon)
elif (n == 0 or n == 1 or n == 6 or n == 8):
    print(pon)
else:
    print(hon)

### FIXED CODE ###

n = input()
N = int(n)

m = N % 10

if (m == 3):
    print("bon")
elif (m == 0 or m == 1 or m == 6 or m == 8):
    print("pon")
else:
    print("hon")
xs,ys,xt,yt = map(int, input().split())
n = int(input())
c = [(xs,ys, 0),(xt,yt,0)]
for i in range(n):
    x,y,r = map(int, input().split())
    c.append((x,y,r))

def circle_circle(ax,ay,ar,bx,by,br):
    d =((ax-bx)**2 + (ay-by)**2)**0.5
    return max(0, d-(ar+br))

def dijkstra(V, edges, root):
    import heapq

    visited = [False] * V
    nodes = [[] for i in range(V)]
    cost = [[] for i in range(V)]

    for e in edges:
        s, t, d = e
        nodes[s].append(t)
        cost[s].append(d)

    dist = [float('inf')] * V
    dist[root] = 0

    h = [(0, root)]
    while h:
        c, v = heapq.heappop(h)
        if visited[v]:
            continue
        visited[v] = True
        for i in range(n+1):
            t = nodes[v][i]
            nc = c + cost[v][i]
            if dist[t] > nc:
                dist[t] = nc
                heapq.heappush(h, (nc, t))
    return dist
edges = []
for i in range(n+1):
    for j in range(i+1, n+2):
        d = circle_circle(c[i][0],c[i][1],c[i][2],c[j][0],c[j][1],c[j][2])
        edges.append((i,j,d))
        edges.append((j,i,d))
dij = dijkstra(n+2, edges, 0)
print(dij[1])


### FIXED CODE ###

n,x = map(int, input().split())
a = list(map(int, input().split()))
b = a[::-1]

def solve(a):
    total = 0
    if a[0] > x:
        total += a[0]-x
        a[0] = x

    for i in range(1, n):
        if a[i-1] + a[i] > x:
            d = (a[i-1] + a[i]) - x
            total += d
            a[i] = max(0, a[i] - d)
    return total

print(min(solve(a), solve(b)))
a,b,c,d=map(int, input())
x=a+b-c-d
if x>0:
  print(Left)
elif x<0:
  print(Right)
else:
  print(Balanced)

### FIXED CODE ###

a,b,c,d=map(int, input().split())
x=a+b-c-d
if x>0:
  s="Left"
elif x<0:
  s="Right"
else:
  s="Balanced"
print(s)
K=int(input())
A=[1,2,3,4,5,6,7,8,9]
B=[]
C=[]
D=[]
E=[]
F=[]
G=[]
H=[]
I=[]

def henkan(A):
    a=len(A)
    B=[]
    for i in range(a):
        if A[i]==0:
            B.append(10*A[i])
            B.append(10*A[i]+1)
        elif A[i]==9:
            B.append(10*A[i]+9)
            B.append(10*A[i]+8)
        else:
            x=A[i]%10
            B.append(10*A[i]+x)
            B.append(10*A[i]+x+1)
            B.append(10*A[i]+x-1)
    return B

B=henkan(A)
C=henkan(B)
D=henkan(C)
E=henkan(D)
F=henkan(E)
G=henkan(F)
H=henkan(G)
I=henkan(H)
ans=A+B+C+D+E+F+G+H+I
ans=sorted(ans)

print(ans[K-1])


### FIXED CODE ###

K=int(input())
A=[1,2,3,4,5,6,7,8,9]
B=[]
C=[]
D=[]
E=[]
F=[]
G=[]
H=[]
I=[]
J=[]
def henkan(A):
    a=len(A)
    B=[]
    for i in range(a):
        if A[i]%10==0:
            B.append(10*A[i])
            B.append(10*A[i]+1)
        elif A[i]%10==9:
            B.append(10*A[i]+9)
            B.append(10*A[i]+8)
        else:
            x=A[i]%10
            B.append(10*A[i]+x)
            B.append(10*A[i]+x+1)
            B.append(10*A[i]+x-1)
    return B

B=henkan(A)
C=henkan(B)
D=henkan(C)
E=henkan(D)
F=henkan(E)
G=henkan(F)
H=henkan(G)
I=henkan(H)
J=henkan(I)
ans=A+B+C+D+E+F+G+H+I+J
ans=sorted(ans)

print(ans[K-1])
from queue import Queue

A = set()
Q = Queue()
H = W = 0
S = []
worps = set()


def main():
    global H, W, Dh, Dw, S
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    S = [input() for i in range(H)]
    Q.put(tuple([Ch, Cw, 0]))

    try:
        while item := Q.get_nowait():
            loop(item)
    except BaseException:
        pass

    print(min(worps)) if worps else print(-1)


def loop(current):
    print(current)
    ci, cj, worp = current
    if (ci, cj) == (Dh, Dw):
        worps.add(worp)

    A.add((ci, cj))
    move1 = False
    for di, dj in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
        ni = ci + di
        nj = cj + dj
        if 0 < ni and ni <= H and 0 < nj and nj <= W and \
                S[ni - 1][nj - 1] == '.' and (ni, nj) not in A:
            Q.put((ni, nj, worp))
            move1 = True
    if not move1:
        for di in range(-2, 3):
            for dj in range(-2, 3):
                if (di, dj) == (0, 0):
                    continue
                ni = ci + di
                nj = cj + dj
                if 0 < ni and ni <= H and 0 < nj and nj <= W and \
                        S[ni - 1][nj - 1] == '.' and (ni, nj) not in A:
                    Q.put((ni, nj, worp + 1))

    try:
        while item := Q.get_nowait():
            loop(item)
    except BaseException:
        pass


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque


def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    d = [[-1 for _ in range(W)] for _ in range(H)]

    q = deque([])
    q.appendleft((0, Ch - 1, Cw - 1))

    while len(q):
        worp_count, x, y = q.popleft()

        if d[x][y] != -1:
            continue
        d[x][y] = worp_count

        for i, j in ((a, b) for a in range(-2, 3) for b in range(-2, 3)):
            nx = x + i
            ny = y + j
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '.':
                if i == 0 and j == 0:
                    continue
                elif abs(i) + abs(j) == 1:
                    q.appendleft((worp_count, nx, ny))
                else:
                    q.append((worp_count + 1, nx, ny))

    print(d[Dh - 1][Dw - 1])


if __name__ == "__main__":
    main()
s=input()
ans=999
for i in range(s.len()-2):
  ans=min(abs(753-int(s[i:i+2])),ans)
print(ans)

### FIXED CODE ###

s=input()
ans=999
for i in range(len(s)-2):
  ans=min(abs(753-int(s[i:i+3])),ans)
print(ans)
n=int(input())
b=[int(i) for i in input().split()]
ans=b[-1]
for i in range(n-1):
    ans+=min(b[i],b[i+1])
print(ans)

### FIXED CODE ###

n=int(input())
b=[10000000000]+[int(i) for i in input().split()]+[100000000000000]
ans=0
for i in range(n):
    ans+=min(b[i],b[i+1])
print(ans)
N = input()
N = int(N)
l = [int(input()) for i in range(N)]
flg = 1
for i in range(0,len(l)-1):
    for j in range(i+1,len(l)):
        if(ma < l[j]-l[i] or flg ==1):
            ma = l[j] - l[i]
            flg = 0
print(ma)


### FIXED CODE ###

N = input()
N = int(N)
l = [int(input()) for i in range(N)]
flg = 1
ma = 0
mi = 0
for i in range(1,len(l)):
    if(mi > l[i-1] or flg ==1):
        mi = l[i-1]
    if(ma < l[i] - mi or flg ==1):
        ma = l[i] - mi
        flg = 0
print(ma)
def main():
  n, a, b = map(int, input().split())
  cnt = 0
  for i in range(1, n+1):
    if a <= sum(map(int, list(str(i)))) <= b:
      cnt += i
  print(cnt)
  
if __name__ == '__main__':
  main()

### FIXED CODE ###

a, b, c, d = map(int, input().split())
if a+b > c+d:
  print("Left")
elif a+b == c+d:
  print("Balanced")
else:
  print("Right")
import math

A,B,C,D = map(int, input().split())
lcm = C * D // math.gcd(C, D)
tmp = (B // C - (A - 1) // C) + (B // D - (A - 1) // D) - (B // lcm - A // lcm)
output = B - A + 1 - tmp

print(output)

### FIXED CODE ###

def gcd(a, b):
    if a < b:
        a, b = b, a

    if b == 0:
        return a

    else:
        return gcd(b, a % b)

A, B, C, D = map(int, input().split())
lcm = C * D // gcd(C, D)
tmp = (B // C - (A - 1) // C) + (B // D - (A - 1) // D) - (B // lcm - (A - 1) // lcm)
output = B - A + 1 - tmp

print(output)
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

n, m = map(int, input().split())
dp = [-1] * (n + 1)
a = []
for i in range(m):
    aa = int(input())
    a.append(aa)
    dp[aa] = 0
mod = 10 ** 9 + 7

dp[0] = 1
if a[0] != 1:
    dp[1] = 1
for i in range(1, n):
    if dp[i + 1] == -1:
        dp[i + 1] = (dp[i] + dp[i - 1]) % mod
print(dp[n])

### FIXED CODE ###

n, m = map(int, input().split())
dp = [0] * (n + 1)
a = []
for i in range(m):
    aa = int(input())
    dp[aa] = -1
    a.append(aa)
for i in range(m - 1):
    if a[i] + 1 == a[i + 1]:
        print(0)
        exit()
mod = 10 ** 9 + 7

dp[0] = 1
if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1
for i in range(1, n):
    if dp[i + 1] == -1:
        dp[i + 1] = 0
    else:
        dp[i + 1] = (dp[i] + dp[i - 1]) % mod
print(dp[n])
N=int(input())
A= list(map(int,input().split()))
B=[0 for _ in range(N)]
for a in A:
    B[a-1]+=1
for b in B:
    print(b)

### FIXED CODE ###

R=int(input())
print(2*R*3.1415926)
n = int(input())
d = {}
for i in range(n):
  a = input();k = 0
  for j in range(10):
    k+= ord(a[j]) - 95
  if k not in d:
    d[k] = 1
  else:
    d[k]+=1
if len(d) == 0:
  print(0)
else:
  print(max(d.values())

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Sep 25 08:58:11 2019

@author: avina
"""

n = int(input())
d = {}
for i in range(n):
  a = list(input())
  a.sort()
  a = ''.join(a)
  if a not in d:
    d[a] = 1
  else:
    d[a]+=1
ans = 0
for i in d:
    ans += ((d[i])*(d[i]-1))//2
print(ans)
a = []
for line in sys.stdin:
	if line="0"
    a.append(int(line))

for i in range(len(a)):
	print("Case ",i+1,": ",a[i],sep="")

### FIXED CODE ###

a = []
while True:
    n = input()
    if n == "0":
        break
    a.append(n)


for i in range(len(a)):
	print("Case ",i+1,": ",a[i],sep="")
def main():
    #入力
    n, a = map(int,input().split())
    x = [0] + list(map(int,input().split()))

    sum_max = (n)*(max(x))+1

    #dp[i][j][k]:x1-xiからj枚選んで、合計をkにする選び方の数
    dp = [[[0]*sum_max for _ in range(n+1)] for _ in range(n+1)]

    dp[0][0][0] = 1

    for i in range(n+1):
        for j in range(n+1):
            for k in range(sum_max):
                #xi>kのとき
                if x[i]>k:
                    dp[i][j][k] = dp[i-1][j][k]
                elif k>=1 and x[i-1]<=k:
                    #xi<=kのとき
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i]]

    count = 0
    for j in range(0,n+1):
        count += dp[n][j][j*a]
    
    print(count)


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    #入力
    n, a = map(int,input().split())
    x = [0] + list(map(int,input().split()))

    sum_max = (n)*(max(x))+1

    #dp[i][j][k]:x1-xiからj枚選んで、合計をkにする選び方の数
    dp = [[[0]*2501 for _ in range(n+1)] for _ in range(n+1)]

    dp[0][0][0] = 1

    for i in range(1,n+1):
        for j in range(n+1):
            for k in range(50*j+1):
                #xi>kのとき
                if x[i]>k:
                    dp[i][j][k] = dp[i-1][j][k]
                elif j>=1 and x[i]<=k:
                    #xi<=kのとき
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i]]

    count = 0
    for j in range(1,n+1):
        count += dp[n][j][j*a]
    
    print(count)


if __name__ == "__main__":
    main()
n=int(input())
ans=0
for i in range(n):
  a,b=map(str,input().split())
  a=int(a)
  if b=="BTC":
    ans+=a*380000
  elif b=="JPY":
    ans+=a
print(ans)

### FIXED CODE ###

n=int(input())
ans=0
for i in range(n):
  a,b=map(str,input().split())
  a=float(a)
  if b=="BTC":
    ans+=a*380000
  elif b=="JPY":
    ans+=a
print(ans)
import math

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

ans = 0


x = list(map(int, input().split()))
x.append(X)
x.sort()
a = []

for i in range(N):
    a.append(abs(x[i] - x[i+1]))
    ans = math.gcd(ans, a[i])


print(ans)



### FIXED CODE ###

def gcd(a,b):   #　ユーグリッドの互除法
    if b == 0:
        return a
    return gcd(b, a % b)


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

ans = 0


x = list(map(int, input().split()))
x.append(X)
x.sort()
a = []

for i in range(N):
    a.append(abs(x[i] - x[i+1]))
    ans = gcd(ans, a[i])


print(ans)
A, B = map(int(input()))

num = B / A

if B == 0:
  print(int(0))
elif B % A == 0:
  print(int(num))
else:
  print(int(num + 1))

### FIXED CODE ###

A, B = map(int,input().split())
num = B / A
i = 0
if B == 1:
  print(int(0))
else:
  while True:
    if B == 1:
        print(0)
        break
    if A * i - (i - 1) >= B:
        print(i)
        break
    i += 1
import sys
from fractions import Fraction

input = sys.stdin.readline

N = int(input()) # integer
A = list(map(int,input().split())) # list
M = 998244353

amax = max(A)
w = [1]*amax
for i in range(1,amax+1):
	n = 2
	j = i*n
	while j<=amax:
		w[j-1] -= w[i-1]*n
		n += 1
		j += i

count = [0]*amax
for i in range(N):
	count[A[i]-1] += 1

ans = 0
for i in range(1,amax+1):
	isum = 0
	isumr = 0
	sqsum = 0
	j = i
	while j<=amax:
		isum += j*count[j-1]
		sqsum += j*j*count[j-1]
		j += i

	ans += ((isum**2-sqsum)/2)*w[i-1]//i
	ans = ans%M

print(ans%M)

### FIXED CODE ###

import sys

input = sys.stdin.readline

H, W, A, B = list(map(int,input().split()))

out = [[0]*W for i in range(H)]

for y in range(B):
	for x in range(A):
		out[y][x] = 1

for y in range(B,H):
	for x in range(A,W):
		out[y][x] = 1

for i in out: print(*i, sep='')
import numpy as np
N, M= map(int, input().split())

if M == 0:
    print('No')
if N < M:
    print('No')

A = [int(input()) for i in range(M)]


B = []
for i in range(len(A)):
    if A[i] > sum(A)/4/M:
        B.append(0)
    else:
        B.append(1)

if sum(B) > N - M + 1:
    print('No')
else:
    print('Yes')

### FIXED CODE ###


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

C = map(int, input().split())

A = list(C)

#if N < M:
#    print('No')
#if M == 0:
#    print('No')

B = []
for i in range(len(A)):
    if A[i] >= sum(A)/4/M:
        B.append(1)
    else:
        B.append(0)

if sum(B) >= M:
    print('Yes')
else:
    print('No')
import math
A,B = map(int,input().split())
if (A+1)/0.08 > B/0.1 and (B+1)/0.1 > A/0.08:
    print(max(math.ceil(A/0.08),math.ceil(B/0.1))
else:
    print(-1)

### FIXED CODE ###

import math
A,B = map(int,input().split())
if (A+1)/0.08 > B/0.1 and (B+1)/0.1 > A/0.08:
    print(max(math.ceil(A/0.08),math.ceil(B/0.1)))
else:
    print(-1)