CodeEff/ECCO huggingface dataset:
# Original solution
import itertools
import math
import fractions
import functools
import copy
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))

sum = 0
for i in range(n):
    if v[i] > c[i]:
        sum += v[i] - c[i]
print(sum)

# Optimized solution
import math


def main():
    n = int(eval(input()))
    # a, b, t = map(int, input().split())
    # h = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in rane(n)]

    v = list(map(int, input().split()))
    c = list(map(int, input().split()))

    sub = [v[i]-c[i] for i in range(n)]

    ans = 0
    for num in sub:
        if num >0:
            ans +=num

    print(ans)






if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans=-10*18
for i in range(1<<n):
    mask=[(i>>j)&1 for j in range(n)]
    X=0
    Y=0
    for k, m in enumerate(mask):
        if m==1:
            X+=v[k]
            Y+=c[k]
    ans=max(ans, X-Y)
    
print(ans)

# Optimized solution
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans=0
for x,y in zip(v,c):
    ans+=max(x-y, 0)
print(ans)
# Original solution
from itertools import product as p

N = int(eval(input()))
*V, = list(map(int, input().split()))
*C, = list(map(int, input().split()))
l = [(i, j) for i,j in zip(V, C)]

ans = -10**12
for i in p(list(range(2)), repeat=N):
    X, Y = 0, 0
    for j, k in enumerate(i):
        if k==1:
            X += V[j]
            Y += C[j]
    ans = max(ans, X-Y)
print(ans)

# Optimized solution
from itertools import product as p

N = int(eval(input()))
*V, = list(map(int, input().split()))
*C, = list(map(int, input().split()))

ans = -10**12
for i in p(list(range(2)), repeat=N):
    X, Y = 0, 0
    for j, k in enumerate(i):
        if k==1:
            X += V[j]
            Y += C[j]
    ans = max(ans, X-Y)
print(ans)
# Original solution
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))

gain = [0]*n

for i in range(n):
    if v[i]-c[i] > 0:
        gain[i] = v[i]-c[i]


print((sum(gain)))

# Optimized solution
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))

surplus = [v - c for v, c in zip(v, c)]
surplus = [v for v in surplus if v > 0]
print((sum(surplus)))
# Original solution
N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))

difer = [v - c for v, c in zip(V, C)]

ans = 0
for i in range(len(difer)):
    if difer[i] >= 0:
        ans += difer[i]

print(ans)


# Optimized solution
N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for v, c in zip(V, C):
    if v-c >= 0:
        ans += (v-c)

print(ans)
# Original solution
# coding: utf-8

from itertools import combinations, chain

N = int(eval(input()))
values = list(map(int, input().split()))
costs = list(map(int, input().split()))

sales = [v - c for v, c in zip(values, costs)]

print((max(chain.from_iterable(list(map(sum, combinations(sales, i))) for i in range(0, N+1)))))


# Optimized solution
n = int(input().strip())
values = list(map(int, input().split()))
costs = list(map(int, input().split()))
 
sales = [v - c for v, c in zip(values, costs) if v > c]
 
print((sum(sales)))
# Original solution
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return list(map(int, sys.stdin.readline().split()))
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
V = li()
C = li()

B = 2**N

ans = 0
for i in range(B):
    wa = 0
    for j in range(N):
        if i & 1 << j:
            wa += V[j] - C[j]
    ans = max(wa, ans)

print(ans)

# Optimized solution
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return list(map(int, sys.stdin.readline().split()))
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
V = li()
C = li()

sa = [V[i] - C[i] for i in range(N) if V[i] - C[i] > 0]

print((sum(sa)))
# Original solution
n=int(eval(input()))
v=list(map(int, input().split()))
c=list(map(int, input().split()))

ans=0
for _v,_c in zip(v,c):
    if _v < _c:
        continue
    ans+=_v-_c

print(ans)


# Optimized solution
n = int(eval(input()))
*v, = list(map(int, input().split()))
*c, = list(map(int, input().split()))

ans = 0
for _v, _c in zip(v, c):
    vc = _v - _c
    if 0 <= vc:
        ans += vc

print(ans)
# Original solution
n=int(eval(input()))
v=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
dif=[]
for i in range(n):
  if v[i]>c[i]:
    dif.append(v[i]-c[i])

ans=0
for i in range(1 << len(dif)):
    sum=0
    for j in range(len(dif)):
        if ((i>>j)&1)==1:
            sum += dif[j]
    ans = max(ans, sum)
print(ans)

# Optimized solution
n=int(eval(input()))
v=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
dif=[]
for i in range(n):
  if v[i]>c[i]:
    dif.append(v[i]-c[i])
print((sum(dif)))
# Original solution
from functools import reduce
from operator import add
n=int(eval(input()))
v=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
l=[v[i]-c[i] for i in range(n) if v[i]>c[i]]
print((reduce(add,l) if l else 0))

# Optimized solution
n=int(eval(input()))
v=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
sum=0
for i in range(n):
  if v[i]>c[i]:
    sum+=v[i]-c[i]
print(sum)
# Original solution
n = int(eval(input()))
v = input().split()
c = input().split()

answer = 0
for i in range(1 << n):
  tmp = 0
  for j in range(n):
    if i & (1 << j):
      tmp += int(v[j]) - int(c[j])
  if answer < tmp:
    answer = tmp

print(answer)


# Optimized solution
n = int(eval(input()))
v = input().split()
c = input().split()

vc = []
for i in range(n):
  vc.append(int(v[i]) - int(c[i]))

answer = 0
for i in vc:
  if i > 0:
    answer += i

print(answer)
# Original solution
import itertools as it

N = int(eval(input()))
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

ans = 0
for ith_conf in it.product(list(range(2)), repeat=N):
    dif = 0
    for j_jewel in range(N):
        if ith_conf[j_jewel] == 1:
            dif += V[j_jewel] - C[j_jewel]
    ans = max(ans, dif)
print(ans)


# Optimized solution
N = int(eval(input()))
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    if V[i] > C[i]:
        ans += V[i] - C[i]
print(ans)
# Original solution
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
  k = 0
  m = 0
  for j in range(n):
    if (i >> j) & 1:
      k += v[j]
      m += c[j]
  ans = max(ans, k - m)
print(ans)


# Optimized solution
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
  if v[i] > c[i]:
    ans += v[i] - c[i]
print(ans)
# Original solution
N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0

for i in range(N):
  tmp = V[i] - C[i]
  if tmp > 0: ans += V[i] - C[i]

print(ans)



# Optimized solution
N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0

for i in range(N):
  tmp = V[i] - C[i]
  if tmp > 0: ans += tmp

print(ans)
# Original solution
n = int(eval(input()))
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0

def chr(a,l):
#    print(a,l)
    if a == n:
        x = 0
        y = 0
        for i in range(n):
            x += v[i]*l[i]
            y += c[i]*l[i]
        return(x-y)
    else:
        l[a] = 1
        ans1 = chr(a+1,l)
        l[a] = 0
        ans2 = chr(a+1,l)
    return(max(ans1,ans2))
    
l = [0 for i in range(n)]
print((chr(0,l)))

# Optimized solution
n = int(eval(input()))
v = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = []
def chr(a,l,r):
    global ans
    if a == n:
        ans.append(r-l)
    else:
        chr(a+1,l+c[a],r+v[a])
        chr(a+1,l,r)
chr(0,0,0)
print((max(ans)))
# Original solution
from itertools import combinations
N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))

maxv = 0
for i in range(1, N+1):
    for t in list(combinations(list(range(N)), i)):
        X = sum(V[k] for k in t)
        Y = sum(C[k] for k in t)
        maxv = max(maxv, X-Y)
print(maxv)


# Optimized solution
N = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))

maxv = 0
for v, c in zip(V, C):
    if v > c:
        maxv += (v-c)
print(maxv)
# Original solution
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
maxxy = -10**9
for i in range(2**n):
    s = '0'*n + format(i, 'b')
    sl = list(s)
    #print(s)
    xy = 0
    for j in range(n):
        a = sl.pop(-1)
        if a == '1':
            xy += v[j]
            xy -= c[j]
    if xy > maxxy:
        maxxy = xy
        #print(s)
print(maxxy)

# Optimized solution
import itertools as itr 

n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
maxxy = -10**9
for i2 in itr.product((0,1), repeat = n):
    xy = 0
    for j in range(n):
        if i2[j] == 1:
            xy += v[j]
            xy -= c[j]
    if xy > maxxy:
        maxxy = xy
        #print(s)
print(maxxy)
# Original solution
n = int(eval(input()))
v = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))

ans = 0
for bit in range(1 << n):
    tmp = 0
    for i in range(n):
        if bit >> i & 1:
            tmp += v[i] - c[i]
    ans = max(ans, tmp)
print(ans)


# Optimized solution
n = int(eval(input()))
v = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))

ans = 0
for i in range(n):
    ans += max(0, v[i] - c[i])
print(ans)
# Original solution
n = int(eval(input()))
value = list(map(int, input().split()))
cost = list(map(int, input().split()))
tmp = 0
for p in range(2**n):
    profit = 0
    for j in range(n):
        if((p >> j) & 1):
            profit += (value[j] - cost[j])
    if profit > tmp:
        tmp = profit
print(tmp)

# Optimized solution
n = int(eval(input()))
value = list(map(int, input().split()))
cost = list(map(int, input().split()))
tmp = 0

for i in range(len(value)):
    profit = value[i] - cost[i]
    if profit > 0:
        tmp += profit

print(tmp)
# Original solution
N = int(eval(input()))
V = list(map(int,input().split()))
C = list(map(int,input().split()))

res = []
for i in range(1 << N):
  X = Y = 0
  for j in range(N):
    if ((i >> j) & 1):
      X += V[j]
      Y += C[j]
  res.append(X-Y)
print((max(res)))

# Optimized solution
def ans():
  N = int(eval(input()))
  V = list(map(int,input().split()))
  C = list(map(int,input().split()))
  ans = 0
  for i in range(N):
    if V[i] > C[i]:
      ans += V[i] - C[i]
  print(ans)

ans()
# Original solution
n = int(eval(input()))

v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0

for i in range(1 << n):
	tmp = 0
	for j in range(n):
		if(i >> j & 1):
			tmp += v[j] - c[j]
	ans = max(ans, tmp)

print(ans)

# Optimized solution
n = int(eval(input()))

v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0

for i in range(n):
	if v[i] - c[i] > 0:
		ans += v[i] - c[i]

print(ans)
# Original solution
def main():
    N = int(eval(input()))
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))
    maxi = 0
    for i in range(2 ** N):
        binary = list(map(int, format(i, 'b').zfill(N)))
        ans = 0
        for j, k in enumerate(binary):
            if k == 1:
                ans += V[j] - C[j]
        if ans > maxi:
            maxi = ans

    print(maxi)


if __name__ == "__main__":
    main()


# Optimized solution
def main():
    N = int(eval(input()))
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))
    K = [V[i] - C[i] for i in range(N)]
    ans = 0
    for k in K:
        if k > 0:
            ans += k
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
N = int(eval(input()))
V = [int(n) for n in input().split()]
C = [int(n) for n in input().split()]
B = []
for i in range(N):
    B.append(V[i] - C[i])
#print(B)

max_profit = 0
for i in range(2**N):
    
    profit = 0
    for j in range(N):
        if i & (1 << j):
            profit += B[j]
    
    max_profit = max(max_profit, profit)

print(max_profit)



# Optimized solution
N = int(eval(input()))
V = [int(n) for n in input().split()]
C = [int(n) for n in input().split()]

profit = 0
for i in range(N):
    if V[i] - C[i] >= 0:
        profit += V[i] - C[i]

print(profit)
# Original solution
n=int(eval(input()))
v=list(map(int, input().split()))
c=list(map(int, input().split()))
ans=0

for i in range(2 ** n):
    total = 0
    for j in range(n):  
        if ((i >> j) & 1):  
            total+=v[j]-c[j]        
    ans=max(ans,total)    
print(ans)

# Optimized solution
n=int(eval(input()))
v=list(map(int, input().split()))
c=list(map(int, input().split()))
ans=0

for i in range(n):
    if (v[i]>c[i]):  
        ans+=v[i]-c[i]        
 
print(ans)
# Original solution
n = int(eval(input()))
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += max(v[i]-c[i],0)

print(ans)

# Optimized solution
n = int(eval(input()))
v = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0
for i in range(n):
    if v[i]-c[i] >0:
        ans += v[i]-c[i]

print(ans)
# Original solution
N = int(eval(input()))
v_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

max_diff = -10000000
for selection in range(1 << N):
    v_tmp = 0
    c_tmp = 0
    for idx in range(N):
        if (selection >> idx) & 1:
            v_tmp += v_list[idx]
            c_tmp += c_list[idx]
    max_diff = max(max_diff, v_tmp - c_tmp)

print(max_diff)

# Optimized solution
from itertools import combinations

N = int(eval(input()))
v_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

max_diff = -10000000
for n_selection in range(0, N+1):
    v_selected = list(combinations(v_list, n_selection))
    c_selected = list(combinations(c_list, n_selection))
    if n_selection == 0:
        max_diff = max(max_diff, 0)
    for i in range(len(v_selected)):
        X = sum(v_selected[i])
        Y = sum(c_selected[i])
        max_diff = max(max_diff, X - Y)

print(max_diff)
# Original solution
n = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
    b = [0] * n
    for j in range(n):
        if i >> j & 1:
            b[j] = 1
    X = sum([v for i, v in enumerate(V) if b[i] == 1])
    Y = sum([c for i, c in enumerate(C) if b[i] == 1])
    ans = max(ans, X - Y)
print(ans)

# Optimized solution
n = int(eval(input()))
V = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for v, c in zip(V, C):
    if v > c:
        ans += v - c
print(ans)
# Original solution
n = int(eval(input()))
value = list(map(int, input().split()))
cost = list(map(int, input().split()))
ret = 0
for state in range((1 << n) - 1):
    values = costs = 0
    for shift in range(n):
        if (state >> shift) & 1 == 1:
            values += value[shift]
            costs += cost[shift]
    ret = max(ret, values - costs)
print(ret)

# Optimized solution
n = int(eval(input()))
value = list(map(int, input().split()))
cost = list(map(int, input().split()))
ret = 0
for state in range((1 << n)):
    values = costs = 0
    for shift in range(n):
        if (state >> shift) & 1 == 1:
            values += value[shift]
            costs += cost[shift]
    ret = max(ret, values - costs)
print(ret)
# Original solution
n = int(eval(input()))
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(2**n):
  x = []
  y = []
  for j in range(n):
    if (i>>j) & 1:
      x.append(v[n - j - 1])
      y.append(c[n - j - 1])
  ans = max(ans,sum(x) - sum(y))
print(ans)

# Optimized solution
n = int(eval(input()))
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
# for i in range(2**n):
#   x = []
#   y = []
#   for j in range(n):
#     if (i>>j) & 1:
#       x.append(v[n - j - 1])
#       y.append(c[n - j - 1])
#   ans = max(ans,sum(x) - sum(y))
for i in range(n):
  if v[i] > c[i]:
    ans += v[i] - c[i]
print(ans)
# Original solution
import itertools

n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(1, n+1):
    a = itertools.combinations(list(range(n)), i)
    for j in a:
        x, y = 0, 0
        for k in j:
            x += v[k]
            y += c[k]
        ans = max(ans, x-y)
print(ans)

# Optimized solution
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))

vc = []
for i, j in zip(v, c):
    vc.append(i-j)
vc = sorted(vc, reverse=True)
ans = 0
for i in vc:
    if i <= 0:
        break
    ans += i
print(ans)
# Original solution

N = int(eval(input()))
xy = [input().split() for i in range(N)]


calculate_yen = lambda xyi: int(xyi[0]) if xyi[1] == 'JPY' else float(xyi[0]) * 380000.0
total = sum(map(calculate_yen, xy))

print(total)


# Optimized solution
N = int(eval(input()))
xy = [input().split() for i in range(N)]


calculate_yen = lambda xyi: int(xyi[0]) if xyi[1] == 'JPY' else float(xyi[0]) * 380000.0
calculate_total_yen = lambda xy : sum(map(calculate_yen, xy))

total = calculate_total_yen(xy)

print(total)
# Original solution
n = int(eval(input()))
res = 0
for i in range(n):
  x, u = input().split()
  x = float(x)
  if u == 'JPY':
    res += x
  else:
    res += (380000 * x)
print(res)

# Optimized solution
res=0
for i in range(int(eval(input()))):
  x,u=input().split()
  x=float(x)
  res+=x if u>'C'else 380000*x
print(res)
# Original solution
n = int(eval(input()))
ans = 0
for i in range(n):
    x,u = input().split()
    x = float(x)
    ans += x if u=='JPY' else x*380000
print(ans)

# Optimized solution
n = int(eval(input()))
ans = 0
for i in range(n):
    x,u = input().split()
    x = float(x)
    if u=='JPY':
        ans += x
    else:
        ans += x* 380000
print(ans)
# Original solution
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(eval(input()))

answer = 0
for _ in range(N):
    x,u = input().split()
    if u == "JPY":
        money = float(x) 
    else:
        money = float(x)*380000.0
    answer += money
print(answer)



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

N = int(eval(input()))

answer = 0
for _ in range(N):
    x,u = input().split()
    if u == "JPY":
        money = int(x) 
    else:
        money = float(x)*380000.0
    answer += money
print(answer)
# Original solution
print((sum(0x5CC60**("B"in i)*float(i[:-4])for i in open(0).readlines()[1:])))

# Optimized solution
n=int(eval(input()))
ans=0
for i in range(n):
    a,b=input().split()
    if b=="JPY":
        ans+=int(a)
    else:
        ans+=float(a)*380000.0
print(ans)
# Original solution
N = int(eval(input()))
ans = 0
for _ in range(N):
    x, u = input().split()
    if u == 'JPY':
        ans += float(x)
    elif u == 'BTC':
        ans += float(x) * 380000.0
print(ans)

# Optimized solution
N = int(eval(input()))
ans = 0.0
for _ in range(N):
    x, u = input().split()
    if u == 'JPY':
        ans += float(x)
    elif u == 'BTC':
        ans += float(x) * 380000.0
print(ans)
# Original solution
n = int(eval(input()))
a = []
b = []
for i in range(n):
    x,u = list(map(str,input().split()))
    if u == "JPY":
        a.append(int(x))
    elif u == "BTC":
        b.append(float(x))
print((sum(a)+sum(b)*380000.0))

# Optimized solution
n = int(eval(input()))
l = []
m = []
a = 0
b = 0
for i in range(n):
    x,u = list(map(str,input().split()))
    l.append(float(x))
    m.append(u)
for i in range(n):
    if m[i] == "JPY":
        a += l[i]
    elif m[i] == "BTC":
        b += l[i]
print((a+b*380000))
# Original solution
N=int(eval(input()))
X=[]
U=[]
ans=0
for i in range(N):
	A,B=input().split()
	X.append(float(A))
	U.append(B)
for i in range(N):
	if U[i]=="JPY":
		ans+=X[i]
	elif U[i]=="BTC":
		ans+=(X[i]*380000.0)
print(ans)

# Optimized solution
N=int(eval(input()))
ans=0
for i in range (N):
	A,B=input().split()
	if B=="JPY":
		ans+=float(A)
	elif B=="BTC":
		ans+=float(A)*380000.0
print(ans)
# Original solution
N = int(eval(input()))
sum=0
for i in range(N):
    x, u = list(map(str, input().split()))
    if u == "JPY":
        sum+=int(x)
    else:
        sum+=float(x)*380000
print(sum)

# Optimized solution
N = int(eval(input()))
sum=0
for i in range(N):
    x, u = input().split()
    if u == "JPY":
        sum+=int(x)
    else:
        sum+=float(x)*380000
print(sum)
# Original solution
print((sum(float(s[:-4])*[380000,1][s[-4]>'C']for s in open(0).readlines()[1:])))

# Optimized solution
print((sum(float(s[:-4])*(s[-4]>'C'or 380000)for s in open(0).readlines()[1:])))
# Original solution
print((sum(380000**('B'in s)*float(s[:-4])for s in open(0).readlines()[1:])))

# Optimized solution
print((sum(38e4**('B'in s)*float(s[:-4])for s in open(0).readlines()[1:])))
# Original solution
N = int(eval(input()))
JPY = 0
BTC = 0
for _ in range(N):
    a = list(input().split())
    if a[1] == 'JPY': JPY += int(a[0])
    else: BTC += float(a[0])
print((float(JPY + BTC*380000.0)))

# Optimized solution
n = int(eval(input()))
money = [input().split() for _ in range(n)]
print((sum([float(x)*{"JPY":1, "BTC":380000}[u] for x,u in money])))
# Original solution
def ans():
  N = int(eval(input()))
  btc = 380000
  cnt = 0
  for _ in range(N):
    x, y = input().split()
    if(y == "JPY"):
      cnt += int(x)
    else:
      cnt += btc*float(x)
  print(cnt)
ans()

# Optimized solution
N = int(eval(input()))
btc = 380000
money = 0
for _ in range(N):
  x, y = input().split()
  if(y == "BTC"):
    money += float(x)*btc
  else:
    money += int(x)
print(money)
# Original solution
num = int(eval(input()))
sum = 0

while num > 0:
  a,b = input().split(" ")
  if b == "JPY":
    sum += int(a)
    
  else:
    c = float(a) * 380000
    sum += c
  num -= 1    
print(sum)

# Optimized solution
N = int(eval(input()))
ans = 0
for i in range(N):
  x, u = input().split()
  if u == "BTC":
    ans += float(x)*380000
  else:
    ans += int(x)
print(ans)