Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split())
Q_n = [0] * N
C = [0] * N

Ans = 0
Pen = 0
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if (S == 'AC') and (Q_n[p] == 0):
        Q_n[p] = 1
        Ans += 1
        Pen += C[p]
    elif (S == 'WA'):
        C[p] += 1
        
print(Ans, Pen)
  


### FIXED CODE ###

C = input()
print(chr(ord(C)+1))
n, m = map(int, input().split())
queue = []
for i in range(m):
    c, y= map(int, input().split())
    queue.append([c, y, i])

queue = sorted(queue)

index = 0
keep = 1
for i in range(m):
    if keep != queue[1][0]:
        index = 0
    index += 1
    queue[i][0] = str(queue[i][0]).zfill(6)
    queue[i][1] = str(index).zfill(6)

queue.sort(key=lambda x: x[2])

for data in queue:
    cn, yn, i = data
    print(cn + yn)

### FIXED CODE ###

n, m = map(int, input().split())
queue = []
for i in range(m):
    c, y= map(int, input().split())
    queue.append([c, y, i])

queue = sorted(queue)

index = 0
keep = queue[0][0]
for i in range(m):
    if keep != queue[i][0]:
        index = 0
        keep = queue[i][0]
    index += 1
    queue[i][0] = str(queue[i][0]).zfill(6)
    queue[i][1] = str(index).zfill(6)

queue.sort(key=lambda x: x[2])

for data in queue:
    cn, yn, i = data
    print(cn + yn)
from collections import Counter
input()
scores = [min(int(i)//400, 8) for i in input().split()]
c = Counter([min(int(i)//400,8) for i in input().split()])
lt3200 = [bool(i) for i in c[:8]].count(True)
print(max(1, lt3200), lt3200+d[8])

### FIXED CODE ###

N =int(input())
scores = [min(int(i)//400, 8) for i in input().split()]
d = [0]*9
for s in scores:
    d[s] = d[s] + 1
lt3200 = [bool(i) for i in d[:8]].count(True)
m = max(1, lt3200)
M = lt3200+d[8]
print('{} {}'.format(m, M))
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()
	A = inputList()

	A.sort()
	ref = [0 for i in range(4*100000 + 1)]
	for i,val in enumerate(A):
		for j in range(val,2*100000 + 1,val):
			if ref[j] >= 2:
				break
			ref[j] += 1

	ans = 0
	for i,val in enumerate(A):
		if ref[val] < 2:
			ans += 1

	print(ans)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()
	A = inputList()

	A.sort()
	zyuufuku = {}
	for i,val in enumerate(A):
		if i == 0:
			continue
		if val == A[i-1]:
			if val in zyuufuku:
				pass
			else:
				zyuufuku[val] = 1

	refd = [0 for i in range(1000000 + 1)]
	for i,val in enumerate(A):
		if val in zyuufuku:
			if zyuufuku[val] > 2:
				continue
			else:
				zyuufuku[val] += 1
		for j in range(val,1000000 + 1,val):
			refd[j] += 1

	ans = 0
	for i,val in enumerate(A):
		if val in zyuufuku:
			continue
		if refd[val] < 2:
			ans += 1

	print(ans)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()
n=int(input().split())
dic=set()
dic|={1}
i=1
while True:
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  i+=1
  if n in dic:
    print(i)
    break
  else:
    dic|={i}


### FIXED CODE ###

s = int(input())

used = set()
used |= {s}
count = 1

while True:
    if s % 2 == 0: s//=2
    else:s=3*s+1
    if s in used:
        print(count+1)
        break
    else:
        used |= {s}
        count += 1
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(l[k+1])

### FIXED CODE ###

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(l[k-1])
import sys
input=sys.stdin.readline

def sol():
    n,m=map(int,input().split())
    d=[]
    ans=[0]*(m+1)
    t=0
    ans[0]=1
    y=m
    for i in range(n):
        a,b=map(int,input().split())
        d.append((b,a))
    d.sort(reverse=True)
    for bb,aa in d:
        if max(ans.index(0),aa)==y:
            ans[y]=1
            t+=bb
            y-=1
        else:
            for j in range(max(ans.index(0),aa),y+1):
                if ans[j]==0:
                    ans[j]=1
                    t+=bb
                    break

    print(t)

if __name__=="__main__":
    sol()


### FIXED CODE ###

#from https://atcoder.jp/contests/abc137/submissions/6808061
import heapq
import sys
input=sys.stdin.readline

def sol():
    n,m=map(int,input().split())
    d=[]
    for i in range(n):
        a,b=map(int,input().split())
        if a<=m: d.append((a,b))
    d.sort(reverse=True)
    q=[]
    ans=0
    for i in range(1,m+1):
        while d and d[-1][0]<=i:
            a,b=d.pop()
            heapq.heappush(q,-b)
        if q:
            ans += -heapq.heappop(q)
    print(ans)

if __name__=="__main__":
    sol()
import sys

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

A = []
for i in range(W):
  A.append(input())

for r in range(H):
  for l in range(W):
    if(A[r][l] != "#"):
      continue
    
    if(l == 0):
      L = True
    else:
      L = A[r][l-1] == "#"
    
    if(r == 0):
      U = True
    else:
      U = A[r-1][l] == "#"
    
    if(l == W - 1):
      R = True
    else:
      R = A[r][l+1] == "#"
    
    if(r == H -1):
      D = True
    else:
      D = A[r+1][l] == "#"
    
    if(L or U or R or D is False):
      print("No")
      sys.exit()
      
print("Yes")

### FIXED CODE ###

import sys

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

A = []
for i in range(H):
    A.append(list(input()))

# print(A)
for r in range(H):
    for line in range(W):
        # print(r, line)
        if(A[r][line] != "#"):
            continue

        # print(r, line, A[r][line])

        if(line == 0 or W == 1):
            L = False
        else:
            L = A[r][line - 1] == "#"

        if(r == 0 or H == 1):
            U = False
        else:
            U = A[r - 1][line] == "#"

        if(line == W - 1 or W == 1):
            R = False
        else:
            R = A[r][line + 1] == "#"

        if(r == H - 1 or H == 1):
            D = False
        else:
            D = A[r + 1][line] == "#"

        # print(L, U, R, D)
        # print(L or U or R or D)
        if((L or U or R or D) is False):
            print("No")
            sys.exit()

print("Yes")
sys.setrecursionlimit(10**6)

N, H, W = [int(x) for x in raw_input().split(' ')]
arr = []
for _ in xrange(N):
    r, c, a = [int(x) for x in raw_input().split(' ')]
    arr.append((a, r-1, c+H-1))
arr = sorted(arr)
ans = 0
P = [-1] * (H+W)
C = [1] * (H+W)

def find(a):
    if P[a] < 0: return a
    t = find(P[a])
    P[a] = t
    return t

def unite(r, c):
    fr, fc = find(r), find(c)
    if fr == fc:  return 0
    C[fr] = C[fc] = C[fr] + C[fc]
    if P[fr] == P[fc]:
        P[fc] = fr
        P[fr] -= 1
    elif P[fr] > P[fc]:
        P[fc] = fr
    else:
        P[fr] = fc
    
while arr:
    a, r, c = arr.pop()
    unite(r, c)
    fr = find(r)
    if C[fr]:
        ans += a
        C[fr] -= 1
print(ans)


### FIXED CODE ###

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

def par(a):
    if P[a] < 0: return a
    t = par(P[a])
    P[a] = t
    return t
def unite(a, b):
    if par(a) == par(b): return 0
    C[par(a)], C[par(b)] = C[par(a)] + C[par(b)], C[par(a)] + C[par(b)]
    if P[par(b)] == P[par(a)]:
        P[par(b)] = par(a)
        P[par(a)] -= 1
    elif P[par(b)] > P[par(a)]:
        P[par(b)] = par(a)
    else:
        P[par(a)] = par(b)
N, H, W = map(int, input().split())
P = [-1 for i in range(H+W)]
C = [1] * (H+W)
X = []
for _ in range(N):
    r, c, a = map(int, input().split())
    X.append((a, r-1, c+H-1))
X = sorted(X)
ans = 0
while X:
    a, r, c = X.pop()
    unite(r, c)
    if C[par(r)]:
        ans += a
        C[par(r)] -= 1
print(ans)
a,b = map(int,input().split())

if a > = 13:
  print(b)
elif 6 <= a <= 12:
  print(b // 2)
else:
  print(0)

### FIXED CODE ###

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

if a >= 13:
  print(b)
elif 6 <= a <= 12:
  print(b // 2)
else:
  print(0)
import sys

if sys.platform =='ios':
	sys.stdin=open('input_file.txt')
	
a, b=map(int,imput().split()))

if a/b==a//b:
	print(a//b)
	
else:
	print("IMPOSSIBLE")

### FIXED CODE ###


    
import sys

if sys.platform =='ios':
	sys.stdin=open('input_file.txt')
	
a, b=map(int,input().split())

if  (a+b)/2 == (a+b)//2:
	print((a+b)//2)
	
else:
	print("IMPOSSIBLE")
ソースコード 

Copy
Copy
X=int(input())
if X==3 or X==5 or X==7:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

X=int(input())
if X==3 or X==5 or X==7:
  print("YES")
else:
  print("NO")
MOD = 10 ** 9 + 7
from math import gcd
from collections import defaultdict

n = int(input())
plus = defaultdict(int)
minus = defaultdict(int)
zero = [0, 0, 0]
for _ in range(n):
    a, b = map(int, input().split())
    g = gcd(a, b)
    a //= g
    b //= g
    if a < 0:
        a *= -1
        b *= -1
    if a * b == 0:
        if a == b == 0:
            zero[0] += 1
        elif a == 0:
            zero[1] += 1
        else:
            zero[2] += 1
    elif b >= 0:
        s = str(a) + "-" + str(b)
        plus[s] += 1
    else:
        s = str(-b) + "-" + str(a)
        minus[s] += 1

pm = [[zero[1], zero[2]]]
cnt = sum(zero)
for key, value in plus.items():
    if minus[key] != 0:
        pm.append([value, minus[key]])
        cnt += value + minus[key]
        
ans = pow(2, n - cnt, MOD)

for p, m in pm:
    ans *= (pow(2, p, MOD) + pow(2, m, MOD) - 1)
    ans %= MOD
ans -= 1
ans %= MOD
print(ans)

### FIXED CODE ###

from collections import defaultdict
from math import gcd
mod = 1000000007

n = int(input())
plus = defaultdict(int)
minus = defaultdict(int)
a_0 = 0
b_0 = 0
a_b_0 = 0
xxx = 10 ** 10
for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 or b == 0:
        if a == 0 and b == 0:
            a_b_0 += 1
        elif a == 0:
            a_0 += 1
        else:
            b_0 += 1
        continue
    g = gcd(a, b)
    a //= g
    b //= g
    if a * b < 0:
        minus[(abs(a), abs(b))] += 1
    else:
        plus[(abs(b), abs(a))] += 1

total = 0
lst = []
for num, _ in minus.items():
    a1 = minus[num]
    a2 = plus[num]
    if a1 * a2 != 0:
        total += a1 + a2
        lst.append([a1, a2])
if a_0 > 0 and b_0 > 0:
    total += a_0 + b_0
    lst.append([a_0, b_0])
n -= a_b_0
ans = pow(2, n - total, mod)
for a, b in lst:
    ans = (ans * (pow(2, a, mod) + pow(2, b, mod) - 1)) % mod
ans = (ans - 1 + a_b_0) % mod
    
print(ans)
K = input()

print(K//2*(K-K//2))

### FIXED CODE ###

N=int(input())
if N%2==0:
  print((N//2)**2)
elif N%2!=0:
  print((N//2)*(N-(N//2)))
#!/usr/bin/env python3

def main():
    n, m, k = map(int, input().split())
    friends = [set() for i in range(n)]
    blocks = [set() for i in range(n)]
    parents = [i for i in range(n)]
    for i in range(m):
        a, b = map(int, input().split())
        friends[a - 1].add(b - 1)
        friends[b - 1].add(a - 1)
        unite(a - 1, b - 1, parents)
    for i in range(k):
        c, d = map(int, input().split())
        blocks[c - 1].add(d - 1)
        blocks[d - 1].add(c - 1)
    groups = [set() for i in range(n)]
    for i in range(n):
        p = find(i, parents)
        groups[p].add(i)
    res = []
    for i in range(n):
        p = find(i, parents)
        
        res.append(len(groups[p]) - len(friends[i]) - len(groups[p] & blocks[i]) - 1)
    print(" ".join([str(x) for x in res]))

def unite(x, y, parents):
    px = find(x, parents)
    py = find(y, parents)
    parents[py] = px

def find(x, parents):
    if parents[x] == x:
        return x
    fx = find(parents[x], parents)
    parents[x] = fx
    return fx

if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

import sys

def main():
    sys.setrecursionlimit(1000000)
    n, m, k = map(int, input().split())
    friends = [set() for i in range(n)]
    blocks = [set() for i in range(n)]
    parents = [i for i in range(n)]
    for i in range(m):
        a, b = map(int, input().split())
        friends[a - 1].add(b - 1)
        friends[b - 1].add(a - 1)
        unite(a - 1, b - 1, parents)
    for i in range(k):
        c, d = map(int, input().split())
        blocks[c - 1].add(d - 1)
        blocks[d - 1].add(c - 1)
    groups = [set() for i in range(n)]
    for i in range(n):
        p = find(i, parents)
        groups[p].add(i)
    res = []
    for i in range(n):
        p = find(i, parents)
        res.append(len(groups[p]) - len(friends[i]) - len(groups[p] & blocks[i]) - 1)
    print(" ".join([str(x) for x in res]))

def unite(x, y, parents):
    px = find(x, parents)
    py = find(y, parents)
    parents[py] = px

def find(x, parents):
    if parents[x] == x:
        return x
    fx = find(parents[x], parents)
    parents[x] = fx
    return fx

if __name__ == "__main__":
    main()
N = int(input())
flag = True
for h in range(1,3501):
    for n in range(1,3501):
        if flag and (N*n*h) % (4*h*n-N*(n+h)) == 0:
            print(str(h)+' '+str(N*n*h // (4*h*n+N*(n+h)))+' '+str(n))
            flag = False
        if not flag:
            break
    if not flag:
        break


### FIXED CODE ###

N = int(input())
flag = True
for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-N*(n+h) <= 0:
            continue
        if N*h*n < (4*h*n-N*(n+h)):
            continue
        if flag and (N*n*h) % (4*h*n-N*(n+h)) == 0:
            print(str(h)+' '+str(N*n*h //(4*h*n-N*(n+h)))+' '+str(n))
            flag = False
        if not flag:
            break
    if not flag:
        break
S = input()

length = len(S)
ans = 0

for i in range(n-1):
  if S[i] != S[i+1]:
    ans += 1

print(ans)

### FIXED CODE ###

S = input()

length = len(S)
ans = 0

for i in range(length-1):
  if S[i] != S[i+1]:
    ans += 1

print(ans)
n,q = map(int(input().split()))
s = input()
m = list(map(int,input().split for i in range(q)))
count = [0]*(N+1)

for i in range(n):
    if S[i:i+2] == 'AC':
        comu[i+1] = comu[i] + 1
    else:
        comu[i+1] = comu[i]

for l,r in list:
    print(count[r-1]-count[l-1])
~


### FIXED CODE ###

s = input()
p = s.replace('A','B')
q = p.replace('T','A')
r = q.replace('B','T')
w = r.replace('G','W')
x = w.replace('C','G')
y = x.replace('W','C')
print(y)
r = int(input())
import math
print(2*r * math.PI)

### FIXED CODE ###

r = int(input())
import math
print(2*r * math.pi)
N=int(input())
n=[]
n.append(int(input())
n.append(int(input())
n.append(int(input())
n.append(int(input())
n.append(int(input())

print(5+N//min(n))
    

### FIXED CODE ###

import math
import heapq
import sys
from collections import Counter
import numpy as np
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

#N,K=map(int, input[0].split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input[1].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
#s = [input() for i in range(3)]

N=int(input())
n=[]
n.append(int(input()))
n.append(int(input()))
n.append(int(input()))
n.append(int(input()))
n.append(int(input()))

print(4+math.ceil(N/min(n)))
k,x=map(int,input().split())
lst=[]
for i in range(1,2*k):
  lst.append(x-k+i)
lst_2=''.split(lst)
print(lst_2)


### FIXED CODE ###

k,x=map(int,input().split())
lst=[]
for i in range(1,2*k):
  lst.append(x-k+i)
for j in range(len(lst)):
  print(lst[j])
Rmax = 0
Rmin = 1000000000
Bmax = 0
Bmin = 1000000000

N = int(input())
xs = []
ys = []
arr = []
for i in range(N):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)
    arr.append((max(x, y) / min(x, y), min(x, y), max(x, y)))

arr = list(sorted(arr))
for (_, x, y) in arr:
    Rmin0 = min(Rmin, x)
    Rmax0 = max(Rmax, x)
    Bmin0 = min(Bmin, y)
    Bmax0 = max(Bmax, y)
    p0 = (Rmax0 - Rmin0) * (Bmax0 - Bmin0)
    Rmin1 = min(Rmin, y)
    Rmax1 = max(Rmax, y)
    Bmin1 = min(Bmin, x)
    Bmax1 = max(Bmax, x)
    p1 = (Rmax1 - Rmin1) * (Bmax1 - Bmin1)
    if p0 <= p1:
        Rmin = Rmin0
        Rmax = Rmax0
        Bmin = Bmin0
        Bmax = Bmax0
    else:
        Rmin = Rmin1
        Rmax = Rmax1
        Bmin = Bmin1
        Bmax = Bmax1

ans = (Rmax - Rmin) * (Bmax - Bmin)
print(ans)

### FIXED CODE ###

N, T = map(int, input().split())
ts = list(map(int, input().split()))

ans = sum([min(ts[i + 1] - ts[i], T) for i in range(N - 1)]) + T
print(ans)
import itertools 

N,M = map(int, input().split())
X = [int(i) for i in input().split()]

if M == 1:
    print(0)
    exit()

if N == 1:
    print(X[M-1]-X[0])
    exit()


X.sort()
index = range(1,M)

anslist = []
for c in itertools.combinations(index, N-1):
    ans = X[c[0]-1] - X[0]
    #print(ans)
    for n in range(N-1):
        if n == N-2:
            ans += X[M-1] - X[c[n]]
        else:
            ans += X[c[n+1]-1] - X[c[n]]
    anslist.append(ans)

print(min(anslist))


### FIXED CODE ###

N,M = map(int, input().split())
X = [int(i) for i in input().split()]

if N >= M:
    print(0)
    exit()


X.sort()
L = [X[i+1] - X[i] for i in range(len(X)-1)]
L.sort()

print(sum(L[:(M-N)]))
from heapq import heappush 
def inpl(): return list(map(int, input().split()))

Q = int(input())
L = []
R = []

B = 0
M = 0

for _ in range(Q):
    q = inpl()
    if len(q) == 3:
        B += q[2]
        if len(R) == 0:
            L.append(-q[1])
            R.append(q[1])
            continue

        M += min(abs(-L[0] - q[1]), abs(R[0] - q[1]))
        heappush(L, -q[1])
        if -L[0] > R[0]:
            L[0], R[0] = -L[0], -R[0]
        heappush(R, q[1])
        if -L[0] > R[0]:
            L[0], R[0] = -L[0], -R[0]
        assert -min(L) <= min(R)
    else:
        print(-L[0], B+M)

### FIXED CODE ###

from heapq import heappush, heappop
def inpl(): return list(map(int, input().split()))

Q = int(input())
L = []
R = []

B = 0
M = 0

for _ in range(Q):
    q = inpl()
    if len(q) == 3:
        B += q[2]
        if len(R) == 0:
            L.append(-q[1])
            R.append(q[1])
            continue

        M += min(abs(-L[0] - q[1]), abs(R[0] - q[1])) * (not (-L[0] <= q[1] <= R[0]))
        if q[1] < R[0]:
            heappush(L, -q[1])
            heappush(L, -q[1])
            heappush(R, -heappop(L))
        else:
            heappush(R, q[1])
            heappush(R, q[1])
            heappush(L, -heappop(R))
    else:
        print(-L[0], B+M)
S = input()
if len(S) == 2:
	print(type(S)
elese:
	S = S[::-1]
	print(type(S)

### FIXED CODE ###

S = input()
if len(S) == 2:
	print(S)
else:
	S = S[::-1]
	print(S)
sys.setrecursionlimit(100000)

N = int(input())

dp = [[[-1]*(N+1) for _ in range(N+1)] for _ in range(N+1)]


def rec(i, j, k):
    global dp, N

    if dp[i][j][k] >= 0.0:
        return dp[i][j][k]
    if i == 0 and j == 0 and k == 0:
        return 0.0

    res = 0.0
    if i > 0:
        res += rec(i-1, j, k) * i
    if j > 0:
        res += rec(i+1, j-1, k) * j
    if k > 0:
        res += rec(i, j+1, k-1) * k

    res += N
    res *= (1.0 / (i+j+k))

    dp[i][j][k] = res
    return dp[i][j][k]


dic = {}
dic[0] = 0
dic[1] = 0
dic[2] = 0
dic[3] = 0
for a in map(int, input().split(" ")):
    dic[a] += 1

print(rec(dic[1], dic[2], dic[3]))


### FIXED CODE ###

N = int(input())

dp = [[[0.0]*(N+1) for _ in range(N+1)] for _ in range(N+1)]

dic = {}
dic[0] = 0
dic[1] = 0
dic[2] = 0
dic[3] = 0
for a in map(int, input().split(" ")):
    dic[a] += 1


for k in range(dic[3]+1):
    for j in range(dic[2]+1+dic[3]-k):
        for i in range(dic[1]+1+dic[2]-j+dic[3]-k):
            if i == 0 and j == 0 and k == 0:
                continue
            res = 0.0
            if i > 0:
                res += dp[i-1][j][k] * i
            if j > 0:
                res += dp[i+1][j-1][k] * j
            if k > 0:
                res += dp[i][j+1][k-1] * k
            res += N
            res *= (1.0 / (i+j+k))
            dp[i][j][k] = res

print(dp[dic[1]][dic[2]][dic[3]])
n,m = map(int,input().split())
a = sorted(list(map(int,input().split())))
a_list=[]
for i in a[:m]:
  if sum(a)/(a*m) > i:
    print('No')
    exit()
  else:
    a_list.append(i)
print('Yes')

### FIXED CODE ###

n,m = map(int,input().split())
a = sorted(list(map(int,input().split())),reverse=True)
b = sum(a)/(4*m)
c=[]
for i in a[:m]:
  if i >= b:
    c.append(i)

if len(c) == m:
  print('Yes')
else:
  print('No')
A, B, C, D = map(int, input().split())

if A%C==0:
    c_num = B//C - A//C + 1
else:
    c_num = B//C - A//C

if A%D==0:
    d_num = B//D - A//D + 1
else:
    d_num = B//D - A//D

print(B - A + 1 - c_num - d_num + cd_num)

### FIXED CODE ###

#最大公約数
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

#最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)

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

A = A -1
c_num = B//C - A//C
d_num = B//D - A//D
    
lcm_num = lcm(C, D)

cd_num = B//lcm_num - A//lcm_num
    
print(B - A - c_num - d_num + cd_num)
n = int(input())
T = []
for i in range(n):
    T.append(int(input()))

def gcd(a, b):
    if b==0:
        return(a)
    return(gcd(b, a%b))

def lcm(a, b):
    return(a*b / gcd(a, b))

LCM = T[0]
for i in range(n-1):
    LCM = lcm(LCM, T[i+1])

print(int(LCM))


### FIXED CODE ###

n = int(input())
T = []
for i in range(n):
    T.append(int(input()))

T = sorted(T)
def gcd(a, b):
    while b > 0:
        t = a
        a = b
        b = t%b
    return(a)

def lcm(a, b):
    return(int(a / int(gcd(a, b))) * b)

LCM = T[0]
for i in range(n-1):
    LCM = lcm(LCM, T[i+1])

print(LCM)
n = int(input())
print((1+n)*n/2)


### FIXED CODE ###

nums = list(map(int,input().split()))
if sum(nums) == 17 and 5 in nums and 7 in nums:
    print('YES')
else:
    print('NO')
N=[int(x) for x in input().split()]
if N[0]/2=>N[1]:
    print("safe")
else:
   print("unsafe")

### FIXED CODE ###

N=[int(x) for x in input().split()]
if N[0]>N[1]:
    print("safe")
else:
   print("unsafe")
n,m,x,y=map(int(input().split()))
tmpx=x
tmpy=y
for i in range(n):
  x_i=int(input())
  tmpx=max(tmpx,x_i)
for j in range(m):
  y_i=int(input())
  tmpy=min(tmpy,y_i)
if tmpx+1<=tmpy:
  print('No War')
else:
  print('War')

### FIXED CODE ###

n,m,x,y=map(int,input().split())
tmpx=x
tmpy=y
li_x=list(map(int,input().split()))
li_y=list(map(int,input().split()))
for i in range(n):
  tmpx=max(tmpx,li_x[i])
for j in range(m):
  tmpy=min(tmpy,li_y[j])
if tmpx+1<=tmpy:
  print('No War')
else:
  print('War')
c = input()
v = [a,i,u,e,o]
if c in v:
  print('vowel')
else:
  print('consonant')

### FIXED CODE ###

c = input()
v = ['a','i','u','e','o']
if c in v:
  print('vowel')
else:
  print('consonant')
import heapq
from collections import defaultdict

N,m,s,t=map(int,input().split())

V=defaultdict(set)
V2=defaultdict(set)
for i in range(m):
  a,b,c,d=map(int,input().split())
  V[a-1].add((b-1,c))
  V[b-1].add((a-1,c))
  V2[a-1].add((b-1,d))
  V2[b-1].add((a-1,d))

def dijkstra(n,v,dedic):
  d=[float('inf')]*n
  d[v]=0
  
  hq=[(0,v)]
  
  while hq:
    u = heapq.heappop(hq)[1]
    for nv,c in dedic[u]:
      if d[nv]>d[u]+c:
        d[nv]=d[u]+c
        heapq.heappush(hq,(d[u]+c,nv))
        
  return d

ans=dijkstra(N,s-1,V)
ans2=dijkstra(N,t-1,V2)

ans3=[(ans[x]+ans2[x]) for x in range(N)]

for i in range(N):
  print(10**15-min(ans3[i:]))


### FIXED CODE ###

a,b=map(int,input().split())
if a+b==15:
  print("+")
elif a*b==15:
  print("*")
else:
  print("x")