Harryxun/stf_run huggingface dataset:
n=int(input())
I={"ac":0,"wa":0,"tle":0,"re":0}
for i in n:
  I[input()]+=1
print("AC x {}".format(I["ac"]))
print("WA x {}".format(I["wa"]))
print("TLE x {}".format(I["tle"]))
print("RE x {}".format(I["re"]))


### FIXED CODE ###

n=int(input())
I={"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(n):
  I[input()]+=1
print("AC x {}".format(I["AC"]))
print("WA x {}".format(I["WA"]))
print("TLE x {}".format(I["TLE"]))
print("RE x {}".format(I["RE"]))
rom fractions import gcd
n,m=map(int,input().split())
s=input()
t=input()
p=gcd(n,m)
ans=n*m//p #20ms
tt=[0 for _ in range(ans)]
# for i in range(n):
# 	tt[i*(ans//n)]=ord(s[i])
# for i in range(m):
# 	if tt[i*(ans//m)]!=ord(t[i]) and tt[i*(ans//m)]!=0:
# 		print(-1)
# 		exit()
print(ans)


### FIXED CODE ###

from fractions import gcd
n,m=map(int,input().split())
s=input()
t=input()
p=gcd(n,m)
ans=n*m//p 
for i in range(n):
	if abs((i*(ans//n)/(ans//m))-int(i*(ans//n)/(ans//m)))<=10**(-7):
		if s[i]==t[(i*(ans//n)//(ans//m))]:
			continue
		else:
			print(-1)
			exit()
print(ans)
import math

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

def lcm(a,b):
    y = a*b / math.gcd(a,b)
    return int(y)

print(lcm(A,B))

### FIXED CODE ###

import fractions

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

def lcm(a,b):
    y = a*b / fractions.gcd(a,b)
    return int(y)

print(lcm(A,B))
a=int(input())#takahashi
b=int(input())
c=int(input())#aoki
d=int(input())
flag=True
while flag:
    c-=b
    if(c<=0):
        flag=False
        print("Yes")
        break
        
    a-=d
    if(a<=0):
        falg=False
        print("No")
        break

### FIXED CODE ###

a,b,c,d=map(int,input().split())
flag=True
while flag:
    c-=b
    if(c<=0):
        flag=False
        print("Yes")
        break
        
    a-=d
    if(a<=0):
        falg=False
        print("No")
        break
mnum, gnum = map(int, input().split())
array = list(map(int, input().split())

for i in range(gnum):
	array.sort()
	array[len(array)-1] = array[len(array)-1]/2

print(sum(array))

### FIXED CODE ###

import math
import heapq

N, M = list(map(int, input().split()))
A = list(map(lambda a: -int(a), input().split()))
A.sort()
heapq.heapify(A)

for i in range(M):
  a = heapq.heappop(A)
  a /= 2.0
  heapq.heappush(A, a)

amount = 0
for a in A:
  amount += math.floor(-a)
print(amount)
import sys
f = sys.stdin


def take2(iterable):
    i = iter(iterable)
    while True:
        yield next(i), next(i)

for line in f:
    a1,a2,b1,b2 = [x + y * 1j for x, y in take2(map(float, line.split()))]
    
    if (min(a1.real, a2.real) <= b1.real <= max(a1.real, a2.real) or (min(a1.real, a2.real) <= b2.real <= max(a1.real, a2.real))) and 
    (min(a1.imag, a2.imag) <= b1.imag <= max(a1.imag, a2.imag) or (min(a1.imag, a2.imag) <= b2.imag <= max(a1.imag, a2.imag))):
        print('YES')
    else:
        print('NO')

### FIXED CODE ###

import sys
f = sys.stdin

# a1が左下、a2が右上とされている事がポイント
for line in f:
    xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = map(float, line.split())
    print('NO'  if xb2 < xa1 or xa2 < xb1 or yb2 < ya1 or ya2 < yb1 else 'YES')
N, K = map(int, input().split())
A = list(map(int, input().split()))
l=[]           
seen={}
k=1
for i in range (K):
  l.append(k)
  if not k in seen.keys():
      seen[k]=i
      k=A[k-1]
  else:
    r_start=seen[k]
    roop=i-r_start
    c=K//roop
    K=K-roop*c
    break
ans=l[K]
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
l=[1]           
seen={}
k=1
for i in range (K):
  if not k in seen.keys():
      seen[k]=i
      k=A[k-1]
      l.append(k)
  else:
    r_start=seen[k]
    roop=i-r_start
    K=(K-r_start)%roop+r_start
    break
ans=l[K]
print(ans)
n = input()
count = 0
start = 1
while start < len(n):
    count += 10**start - 10**(start -1)
    start +=2

if len(n) % 2 == 0:
    print(count)
else:
    print(count + int(n[1:]) + 1)

### FIXED CODE ###

n = int(input())

count = 0
count
for i in range(1,n+1):
    if (len(str(i)) % 2 != 0):
        count+=1

print(count)
n = int(input())
x=n
pf={}
for i in range(2,int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i,0)+1
        n//= i
if n > 1 : pf[n] = 1

for b in range(-10,10):
    a=b+int(list(pf.keys())[0])
    siki=a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4
    if siki==x/int(list(pf.keys())[0]):
        print(*(a,b))

### FIXED CODE ###


x=int(input())
A=0
B=0
for a in range(-500,500):
    for b in range(-500,500):
        if a**5-b**5==x:
            A=a
            B=b
            break
print(A,B)
from itertools import combinations
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
X, Y = list(map(list, zip(*XY)))

P = [abs(x1 - x2) for x1, x2 in combinations(X, 2)]
P = list(set(P))
Q = [abs(y1 - y2) for y1, y2 in combinations(Y, 2)]
Q = list(set(Q))
ans = 10**10
XY.sort()
for p in P:
    for q in Q:
        S = set()
        la = 0
        for x, y in XY:
            if (x, y) not in S:
                la += 1
            S.add((x+p, y+q))
        ans = min(ans, la)
        S = set()
        la = 0
        for x, y in XY:
            if (x, y) not in S:
                la += 1
            S.add((x+p, y-q))
        ans = min(ans, la)
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
if K == 1:
    print(0)
else:
    print(N-K)
from collections import defaultdict

N, Q = map(int, input().split())
edge = defaultdict(list)
for i in range(N-1):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

cnt = [0]*(N+1)
for i in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x

root_node = (1, -1) # (id, value, parent_id)
open_list = [root_node]
closed_list = []
while True:
    if len(open_list) == 0:
        break
    cur_node = open_list.pop()
    cur_id, parent_id = cur_node
    if not(parent_id == -1):
        cnt[cur_id] += cnt[parent_id]
    for child_id in edge[cur_id]:
        if child_id == parent_id:
            continue
        open_list.append((child_id, cur_id))
print(*cnt[1:])

### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print('red')
import math
n = int(input())
count = 0
while n != 0:
  max_value = 1
  for i in range(1, n+1):
    if math.log(i, 6) == int(math.log(i, 6)) or math.log(i, 9) == int(math.log(i, 9)):
    	max_value = max(max_value, i)
  n = n - max_value
  lst.add(max_value)
  count += 1
print(count)

### FIXED CODE ###

N=int(input())
ans=N
for i in range(N+1):
    cnt=0
    t=i
    while t>0:
        cnt+=t%6
        t//=6
    j=N-i
    while j>0:
        cnt+=j%9
        j//=9
    ans = min(ans,cnt)
print(ans)
import math
def beautiful:
     a,b,c = input().split()
      if fabs(b-a)) == fabs(c-b):
            print('YES')
      else:
            print('NO')

beautiful()

### FIXED CODE ###

a,b,c=map(int,input().split())
if b-a == c-b:
    print("YES")
else:
    print("NO")
data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]

# ??\?????????????????????????????§????????????????????????????????????
count = int(input(1))
for c in range(count):
    c, f, r, v = [int(1) for i in input().split]
    data[c - 1][f - 1][r - 1] += v


for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()

    if bi < 3:
        print('#' * 20)

### FIXED CODE ###

data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]
    
count = int(input())
for c in range(count):
    b,f,r,v = [int(i) for i in input().split()]
    data[b-1] [f-1] [r-1] += v
    
for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')
        print()
    if bi < 3:
        print('#' * 20)
m = list(map(int, input().split()))

hp = list(map(int, input().split()))
result = 0
checkyakusuru = []
checkodd = []
checkeven = []

if (hp.count(hp[0]) == m[0]):
    result = hp[0]

minhp = min(hp)

for p in hp:
    if (p % minhp == 0):
        checkyakusuru.append(1)
    
    if (checkyakusuru.count(1) == m[0]):
        result = p
        break
    else:
        if (p % 2 == 0):
            checkeven.append(1)
        if (checkeven.count(1) == m[0]):
            result = 2
        else:
            result = 1

### FIXED CODE ###

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

def f(a, b):
    if (b % a == 0):
        return a + b 
    else:
        return b - a 
print(f(a[0], a[1]))
a = input()
　 print('A' if a.islower() else 'a')

### FIXED CODE ###

alpha = input()
if alpha.islower():
    print('a')
else:
    print('A')
N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)

VMAX = 10**4 + 100
ans = 0
dp = [[float('inf')] * (VMAX+1) for _ in range(N+1)]
dp[0][0] = 0
for n in range(N):
    for v in range(VMAX):
        if dp[n][v] != float('inf'):
            dp[n+1][v] = min(dp[n+1][v], dp[n][v])
            dp[n+1][v+V[n]] = min(dp[n+1][v+V[n]], dp[n][v] + W[n])

            if dp[n+1][v+V[n]] <= L:
                ans = max(ans, v+V[n])
# print(*dp, sep='\n')
print(ans)


### FIXED CODE ###

N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)

VMAX = 10**5 + 100
ans = 0
dp = [[float('inf')] * (VMAX+1) for _ in range(N+1)]
dp[0][0] = 0
for n in range(N):
    for v in range(VMAX):
        if dp[n][v] != float('inf'):
            dp[n+1][v] = min(dp[n+1][v], dp[n][v])
            dp[n+1][v+V[n]] = min(dp[n+1][v+V[n]], dp[n][v] + W[n])

            if dp[n+1][v+V[n]] <= L:
                ans = max(ans, v+V[n])
# print(*dp, sep='\n')
print(ans)
import numpy as np

def main():
  n=int(input())
  s=np.array([ord(i) for i in input()])
  dp=np.zeros((n+1,n+1),dtype=int)
  ans=0
  for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
      if s[i]==s[j]:
        dp[i][j]=dp[i+1][j+1]+1
        now=dp[i][j] if dp[i][j]<j-1 else j-1
        if ans<now:
          ans=now
  print(ans)      
        

if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  n=int(input())
  s=input()
  dp=[[0]*(n+1) for i in range(n+1)]
  for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
      if s[i]==s[j]:
        dp[i][j]=dp[i+1][j+1]+1
  #for i in dp:
  #  print(i)
  
  ans=0
  for i in range(n-1):
    for j in range(i+1,n):
      ans=max(ans,min(j-i,dp[i][j]))
  print(ans)      
        

if __name__=='__main__':
  main()
n = input()
if n[0] == n[2]:
  print("Yes)
else:
  print("No")

### FIXED CODE ###

n = input()
if n[0] == n[2]:
  print("Yes")
else:
  print("No")
def gcd(x, y):
    r = 1
    for i in range(min(x, y)):
        if x % i == 0 and y % i == 0:
            r = i
    return r

x, y = map(int, re.split(' ', raw_input()))
print(gcd(x, y))

### FIXED CODE ###

import re

def gcd(x, y):
    if x == y:
        return x
    if x < y and y % x == 0:
        return x
    if x > y and x % y == 0:
        return y
    if x <= y:
        m = y % x
        return gcd(x, m)
    if x >= y:
        m = x % y
        return gcd(y, m)

    l = list(range(1, int(min(x, y) / 2) + 1))
    l.reverse()
    r = 1
    for i in l:
        if x % i == 0 and y % i == 0:
            return i
    return 1
 
x, y = map(int, re.split(' ', raw_input()))
print(gcd(x, y))
N = input()
L = list(input().split())
b=0
L.sort()
 
a = L.pop(-1)
 
for i in range(N-1):
  b+= L[i]
 
if (a < b):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
b=0
L.sort()
 
a = L.pop(-1)
 
for i in range(N-1):
  b+= L[i]
 
if (a < b):
  print("Yes")
else:
  print("No")
N = raw_input()
N = int(N)

a = []
for i in range(N):
	s_input = raw_input()
	s_input = long(s_input)
	if s_input in a:
		a.remove(s_input)
	else:
		a.append(s_input)

print(len(a))

### FIXED CODE ###

N = raw_input()
N = int(N)

num10 = N/10
num1 = N - num10*10

if num10 == 9 or num1 == 9:
	print('Yes')
else:
	print('No')
n, k = map(int, input().split())


def log(r, d):
    return np.log(d)/np.log(r)


def ceil(x):
    if x.is_integer():
        return int(x)
    return int(np.ceil(x))


print(ceil(log(k, n)))

### FIXED CODE ###

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)


n, k = map(int, input().split())
print(len(Base_10_to_n(n, k)))
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayR)):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))

### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(min(len(arrayR), len(arrayAns))):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))
a, b = map(int, input().split())

if (a % 2 == 0 ) or ( b % 2 == 0 ) :
	print('Even')
else :
	ptint('Odd')

### FIXED CODE ###

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

if (a % 2 == 0 ) or ( b % 2 == 0 ) :
	print('Even')
else :
	print('Odd')
l=[]
for i in range(1,n+1):
  l.append(abs(l-1+i))
mi=l.index(min(l))
print(n*(l-1)+sum(range(1,n+1)-l-mi)

### FIXED CODE ###

n,l=map(int,input().split())
s=0
list=[]
for i in range(1,n+1):
  s+=i
  list.append(abs(l+i-1))
sum=n*(l-1)+s
m=list.index(min(list))
print(sum-l-m)
A, B, K = map(int, input().split())


if A + B <= K:
    print(0, 0)

elif A <= K:
    C = K - A
    print(0, B-C)

else:
    print(A - K, B)


### FIXED CODE ###

S, T = input().split()
print(T+S)
N = int(input())
Y = int(input())

answer = []
comb = []
for j in range(N+1):
    for i in range(N+1):
        sum = 10000*j + 5000*i + 1000*(N-i-j)
        if(sum==Y and N-i-j>=0):
            comb = [j,i,N-i-j]
            answer = [str(x) for x in comb]
            answer = ' '.join(answer)
            print(answer)
if not(answer):
    print('-1 -1 -1')

### FIXED CODE ###

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

for j in range(N+1):
    for i in range(N+1):
        sum = 10000*j + 5000*i + 1000*(N-i-j)
        if(sum==Y and N-i-j>=0):
            print(j,i,N-i-j)
            exit()
            
print('-1 -1 -1')
n = int(input())
al = [int(input()) for _ in range(n)]
m = max(al)
s, f = 0, True
for i in range(n):
  if al[i] == m and flag:
    s += al[i] // 2
    f = False
  else:
    s += al[i]
print(s)


### FIXED CODE ###

n = int(input())
al = [int(input()) for _ in range(n)]
m = max(al)
s, f = 0, True
for i in range(n):
  if al[i] == m and f:
    s += al[i] // 2
    f = False
  else:
    s += al[i]
print(s)
import sys
sys.setrecursionlimit(2 * (10 ** 9))
lst = [[1,2], [2, 5], [3, 5], [4, 4], [5, 5], [6, 6], [7, 3], [8, 7], [9, 6]]
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse = True)
# print (A)

def num(k):
    return lst[k-1][1]

# for i in A:
    # print (num(i), end = ', ')
# print ()

INF = 10 ** 5
dp_lst = [-INF] * (N + 1)
dp_lst[0] = 0
def dp(i):
    if dp_lst[i] != -INF:
        return dp_lst[i]
    tmp = -INF
    for j in A:
        if i >= num(j):
            tmp = max(tmp, dp(i - num(j)) + 1)
    dp_lst[i] = tmp
    return dp_lst[i]

a = dp(N)
# print (a)
# print (dp_lst)   
# print ([0] * 10 +[i+1 for i in range(20)])

# print (len(str(71111111111111111111111111111111111111111111111111)))

def check(A):
    if dp_lst[N-num(A)] == dp_lst[N] - 1:
        return True
    else:
        return False

# print (a)
while a > 0:
    for i in A:
        if check(i):
            print (i, end = '')
            N -= num(i)
            a -= 1
            break
        else:
            pass
            # print ('B')
print ()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 5)
lst = [[1,2], [2, 5], [3, 5], [4, 4], [5, 5], [6, 6], [7, 3], [8, 7], [9, 6]]
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse = True)
# print (A)

def num(k):
    return lst[k-1][1]

# for i in A:
    # print (num(i), end = ', ')
# print ()

INF = 10 ** 5
dp_lst = [-INF] * (N + 1)
dp_lst[0] = 0
def dp(i):
    if dp_lst[i] != -INF:
        return dp_lst[i]
    tmp = -INF
    for j in A:
        if i >= num(j):
            tmp = max(tmp, dp(i - num(j)) + 1)
    dp_lst[i] = tmp
    return dp_lst[i]

a = dp(N)
# print (a)
# print (dp_lst)   
# print ([0] * 10 +[i+1 for i in range(20)])

# print (len(str(71111111111111111111111111111111111111111111111111)))

def check(A):
    if N - num(A) < 0:
        return False
    if dp_lst[N-num(A)] == dp_lst[N] - 1:
        return True
    else:
        return False

# print (a)
while a > 0:
    for i in A:
        if check(i):
            print (i, end = '')
            N -= num(i)
            a -= 1
            break
        else:
            pass
            # print ('B')
print ()
def abc170_c_1():
    """
    もうちょいコンパクトに書いてみる
    """
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

        p = list(map(int, input().split(' ')))

        search_range_min = min(min(p), x) - 1
        search_range_max = max(max(p), x) + 1
        search_values = [i for i in range(search_range_min, search_range_max + 1) if i not in p]

        # min関数のkeyにxとの差の絶対値を直接渡してその値の最小値を取得してしまう。
        ans = min(search_values, key=lambda a: (abs(a - x)), x)

        # こっちはたぶん絶対値の差が同じ時にリストの先にあるほうをとってしまうので結果バグっている気がする
        # ans = min(search_values, key=lambda a: abs(a - x))

        return ans

    print(solve())

if __name__ == '__main__':
    abc170_c_1()


### FIXED CODE ###

def abc170_c():
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

        p = list(map(int, input().split(' ')))

        search_range_min = min(min(p), x) - 1
        search_range_max = max(max(p), x) + 1
        search_values = [i for i in range(search_range_min, search_range_max + 1) if i not in p]

        check_dict = {}

        for i in search_values:
            # 絶対値が小さいものを調べるので差の絶対値を格納
            check_dict[i] = abs(x - i)

        return min(check_dict, key=check_dict.get)
    print(solve())

if __name__ == '__main__':
    abc170_c()
from itertools import product
def cnt(b,e,n_str):
  res=0
  for i in range(int(n_str)+1):
    if int(str(i)[0])==b and i%10==e:
      res+=1
  return res
def sol():
  n_str=input()
  c={i:{j:cnt(b,e,n_str) for j in range(1,10)} for i in range(1,10)}
  return sum(c[b][e]*c[e][b] 
             for b,e in product(range(1,10),repeat=2))

print(sol())  



### FIXED CODE ###

from itertools import product
from functools import reduce
import operator
def prod(iterable):
    return reduce(operator.mul, iterable, 1)
def cnt_samelen(b,e,n_str):
  n0=int(n_str[0])
  if b>n0 or len(n_str)==1:
    return 0
  if b<n0:
    return b*int(10**(len(n_str)-2))
  
  return (int(n_str[1:-1])+1 if len(n_str)>2 else 1)-(1 if e>int(n_str[-1]) else 0)
def cnt(b,e,n_str):
  res=0
  l=len(n_str)
  if b==e and int(n_str)>=b:
    res+=1
  for i in range(l-2):
    res+=10**(i)
  res+=cnt_samelen(b,e,n_str)
  return res
def sol():
  n_str=input()
  return sum(cnt(b,e,n_str)*cnt(e,b,n_str) 
             for b,e in product(range(1,10),repeat=2))

print(sol())
ソースコード 

Copy
Copy
p, q = map(int, input().split())
import fractions
 
def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)
 
print(lcm(p, q))


### FIXED CODE ###

p, q = map(int, input().split())
import fractions
 
def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)

print(lcm(p, q))
n,k=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)].sort()
cou=0
for [a,b] in l:
  cou+=b
  if cou>=k:
    print(a)
    break

### FIXED CODE ###

n,k=map(int,input().split())
l=sorted([list(map(int,input().split())) for _ in range(n)])
cou=0
for r in l:
  a,b=r[0],r[1]
  cou+=b
  if cou>=k:
    print(a)
    break
N, K = map(int, input().split())
A = list(map(int, input().split()))

binlen = len(bin(max(A))) - 2
while 2 ** binlen > K:
    binlen -= 1

if binlen < 0:
    print(sum(A))
    exit()

bitcount = [0] * (len(bin(max(A))) - 2)
for a in A:
    for i, s in enumerate(bin(a)[::-1][:-2]):
        if s == "1":
            bitcount[i] += 1

maxn = 2 ** binlen
mid = N / 2

for i in range(binlen + 1):
    if bitcount[i] < mid and i != binlen:
        maxn += 2 ** i
    elif bitcount[i] > mid and i == binlen:
        maxn -= 2 ** i
    elif i >= len(bitcount):
        maxn += 2 ** i

print(sum([maxn ^ a for a in A]))


### FIXED CODE ###

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

binlen = 0
while 2 ** binlen <= K:
    binlen += 1
binlen -= 1

if binlen < 0:
    print(sum(A))
    exit()

bitcount = [0] * (len(bin(max(A))) - 2)
for a in A:
    for i, s in enumerate(bin(a)[::-1][:-2]):
        if s == "1":
            bitcount[i] += 1

maxn = 2 ** binlen
mid = N / 2

for i in range(binlen + 1):
    if i < len(bitcount):
        if bitcount[i] < mid and i != binlen:
            maxn += 2 ** i
        elif bitcount[i] > mid and i == binlen:
            maxn -= 2 ** i
    elif i != binlen:
        maxn += 2 ** i

pos = 0
while maxn > K:
    if bin(maxn)[2:][pos] == "1" and bin(K)[2:][pos] == "0":
        maxn -= 2 ** (len(bin(maxn)) - 3 - pos)
    pos += 1

print(sum([maxn ^ a for a in A]))
a,b = list(map(input().split()))
#s = [1 if i=='R' else 0 for i in S]

ans = [a+b,a-b,a*b]





print(max(ans))

### FIXED CODE ###

a,b = map(int,input().split())
#s = [1 if i=='R' else 0 for i in S]

ans = [a+b,a-b,a*b]





print(str(max(ans)))
N, M = map(int, input().split())
A = []
B = []
pt = [[] for i in range(M)]
#print(pt)
for i in range(M):
	a, b =  map(int, input().split())
	a -=1
	b -=1
	#A.append(a)
	#B.append(b)
	pt[a].append(b)
	pt[b].append(a)
#	print(pt)
#print(A)
#print(B)
print(pt)
n=M
#n=7
#pt=[[1, 2, 3], [0], [5, 0], [6, 0], [6], [2], [3, 4]]
res_list = [-1] * n
def bfs(v):
    d=[-1]*n
    d[v]=0
    q=[v]
    c=1
    while q:
        q1=[]
        for i in q:
            for j in pt[i]:
                if d[j]==-1:
                    d[j]=c
                    q1.append(j)
                    res_list[j]=i
        q=q1
        c+=1
#        print(d,q)
    return d
res = bfs(0)

no = 'No'
yes ='Yes'
if -1 in res:
	print(no)
else:
	print(yes)
	
for i,x in enumerate(res_list):
	if i==0:
		continue
	print(x+1)

### FIXED CODE ###

N, M = map(int, input().split())
A = []
B = []
pt = [[] for i in range(N)]
for i in range(M):
	a, b =  map(int, input().split())
	a -=1
	b -=1
	pt[a].append(b)
	pt[b].append(a)
n=N
res_list = [-1] * N
def bfs(v):
    d=[-1]*n
    d[v]=0
    q=[v]
    c=1
    while q:
        q1=[]
        for i in q:
            for j in pt[i]:
                if d[j]==-1:
                    d[j]=c
                    q1.append(j)
                    res_list[j]=i
        q=q1
        c+=1
    return d
res = bfs(0)

no = 'No'
yes ='Yes'
if -1 in res:
	print(no)
else:
	print(yes)
	
for i,x in enumerate(res_list):
	if i==0:
		continue
	print(x+1)
v = map(int, input().split())

if (v[0] * v[1]) % 2 == 0:
    print('Even')
else
    print('Odd')


### FIXED CODE ###

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

if (v[0] * v[1]) % 2 == 0:
    print('Even')
else:
    print('Odd')
n, m = map(int, input().split())
l = [list(input().split()) for i in range(m)]
cnt = 0
ans = [0]*n
num = 0
for i in range(0, m):
  num = int(l[i][0])
  if l[i][1] == 'AC':
    ans[num] = 1
  elif ans[num] != 1:    
    cnt += 1
print(sum(ans), cnt)

### FIXED CODE ###

n, m = map(int, input().split())
P = [0]*n
AC = [False]*n
correct = 0
penalty = 0
for i in range(m):
  ans = input().split()
  problem = int(ans[0])
  result = ans[1]
  if AC[problem-1] == False:
    if result == 'AC':
      AC[problem-1] = True
      correct += 1
      penalty += P[problem-1]
    else:
      P[problem-1] += 1
print(correct, penalty)