Harryxun/stf_run huggingface dataset:
ball_name1,ball_name2 = input().split(" ")
ball1,ball2 = input().split(" ")
ball1 = int(ball1)
ball2 = int(ball2)
ball_chosen = input()


if (ball_chosen in ball_name1) :
    print(f'{ball1-1} {ball2}')
else:
    print(f'{ball1} {ball2-1}')

### FIXED CODE ###

ball_name1,ball_name2 = input().split(" ")
ball1,ball2 = input().split(" ")
ball1 = int(ball1)
ball2 = int(ball2)
ball_chosen = input()


if (ball_chosen in ball_name1) :
    ball1-=1
    print(str(ball1)+" "+str(ball2))
else:
    ball2-=1
    print(str(ball1)+" "+str(ball2))
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	A = MAP()

	i = 0
	cnt = 0
	while i < N:
		if A[i] == i+1:
			cnt += 1
			if A[i+1] == i+2:
				i += 2
			else:
				i += 1
		else:
			i += 1
	
	print(cnt)

if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	A = MAP()

	i = 0
	cnt = 0
	while i < N:
		if A[i] == i+1:
			cnt += 1
			if i < N-1 and A[i+1] == i+2:
				i += 2
			else:
				i += 1
		else:
			i += 1
	
	print(cnt)

if __name__ == '__main__':
	main()
n=int(input())
a=list(map(int,input().split()))
if len(set(a))==1 and a[0]==1:
  print('Yes')
elif n%3!=0:
  print('No')
elif len(set(a))!=3
  print('No')
else:
  print('Yes')

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  a[i]=format(a[i],'030b')
l=[0 for i in range(30)]
for i in range(n):
  for j in range(30):
    if a[i][j]=='1':
      l[j]+=1
for j in range(30):
  l[j]=l[j]%2
 
if 1 in l:
  print('No')
else:
  print('Yes')
from collections import Counter

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

counted_v1 = Counter(v[::2])
counted_v2 = Counter(v[1::2])

most_v1 = counted_v1.most_common()[0]
most_v2 = counted_v2.most_common()[0]

if  most_v1[0] != most_v2[0]:
    print(n - most_v1[1] - most_v2[1])


elif len(counted_v1) == 1 and len(counted_v2) == 1:
    print(n // 2)

elif most_v1[1] > most_v2[1]:
    second_v2 = counted_v2.most_common()[1] if len(counter_v2) >= 2 else most_v2[1]
    print(n - most_v1[1] - second_v2[1])

else:
    second_v1 = counted_v1.most_common()[1] if len(counter_v1) >= 2 else most_v1[1]
    print(n - second_v1[1] - most_v2[1])


### FIXED CODE ###

from collections import Counter

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

v1 = v[::2]
v2 = v[1::2]

cv1 = Counter(v1).most_common(2)
cv2 = Counter(v2).most_common(2)

if cv1[0][0] != cv2[0][0]:
    print(n - cv1[0][1] - cv2[0][1])
else:
    p1 = cv1[0][1] + cv2[1][1] if len(cv2) >= 2 else n - cv1[0][1]
    p2 = cv2[0][1] + cv1[1][1] if len(cv1) >= 2 else n - cv2[0][1]
    print(n - max(p1, p2))
import numpy as np
N,M,C = map(int,input().split())
B = [int,input().split()]
for i in range(1,N):
    Ai = [int(j) for j in input().split()]
    ai = np.array(Ai)   
b = np.array(B)
bt = b.reshape([M,1])
cnt = 0
for i in range(1,N)
    if (np.dot(ai,bt) + C >0)
         cnt += 1
print(cnt)




### FIXED CODE ###

import numpy as np
N,M,C = map(int,input().split())
B = [int(k) for k in input().split()]
A = [[int(j) for j in input().split()] for i in range(N)] 
b = np.array(B)
cnt = 0
for i in range(N):
    if (np.dot(np.array(A[i]),b) + C >0):
        cnt += 1
    else:
        cnt = cnt
        
print(cnt)
#!/mnt/c/Users/moiki/bash/env/bin/python
N,P = list(map(int, input().split()))
import math


def get_prime(n):
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i]]

primax = int(1e7) + 9 * int(1e6)
primes = get_prime(primax)




def df(P, p):
    if P >= p:
        cnt = 0
        while P >= p and P % p == 0:
            P = int(P//p)
            cnt += 1
        return cnt
    else:
        raise "P , p error."

gc = []
for p in primes:
    if P % p == 0:
        cnt = df(P, p)
        P = int( P // int(p**cnt))
        gc.append([p, cnt])
ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

debug = 1
for g,cnt in gc:
    debug *= g**cnt

if P > 1e9 and debug != P and N > 100:
    raise "errror"
print(ans)


### FIXED CODE ###

#!/mnt/c/Users/moiki/bash/env/bin/python
N,P = list(map(int, input().split()))
import math

if N == 1:
    print(P)
    exit(0)

def get_prime(n):
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i]]

primax = int(1e7) + 9 * int(1e6)
primes = get_prime(primax)
# print(primes)



def df(P, p):
    if P >= p:
        cnt = 0
        while P >= p and P % p == 0:
            P = int(P//p)
            cnt += 1
        return cnt
    else:
        raise "P , p error."

gc = []
for p in primes:
    if P % p == 0:
        cnt = df(P, p)
        P = int( P // int(p**cnt))
        gc.append([p, cnt])
ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

debug = 1
for g,cnt in gc:
    debug *= g**cnt

# N > 100:  why WA
# debug < P: under 3 RE
# debug*2 > P:  None
if P > 1e9 and debug != P and  debug < P and N == 1:
    raise "errror"
print(ans)
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N, Y = LI()
y = 1000 * N
for i in range(N+1):
    for j in range(n-i+1):
        if i * 10000 + 5000 * j + 1000 * (N-i-j) == Y:
            print(i, j, N-i-j)
            exit()
print("-1 -1 -1")

### FIXED CODE ###

import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N, Y = LI()
y = 1000 * N
for i in range(N+1):
    for j in range(N-i+1):
        if i * 10000 + 5000 * j + 1000 * (N-i-j) == Y:
            print(i, j, N-i-j)
            exit()
print("-1 -1 -1")
N,T = int(input())
min_cost = 1001

for i in range(N):
    l = input()
    if l[1] <= T:
        if l[0] < min_cost:
            min_cost = l[0]

if min_cost = 1001:
    print('TLE')
else:
    print(min_cost)


### FIXED CODE ###

N,T = map(int, input().split())
min_cost = 1001

for i in range(N):
    c,t = map(int, (input().split()))
    if t <= T:
        if c < min_cost:
            min_cost = c

if min_cost == 1001:
    print('TLE')
else:
    print(min_cost)
#import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

s = sinput()
q = iinput()
cnt = 0
for i in range(q):
    try: t,f,c = sarr()
    except: cnt += 1; cnt %= 2; continue
    if cnt:
        if f == "1": s = s + c
        if f == "2": s = c + s
    else:
        if f == "1": s = c + s
        if f == "2": s = s + c
    #print(s)

s = s[::-1] if cnt else s
print(s)



### FIXED CODE ###

import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

s = col.deque(sinput().split())
q = iinput()
cnt = 0
for i in range(q):
    try: t,f,c = sarr()
    except: cnt += 1; cnt %= 2; continue
    if cnt: #反転の状態
        if f == "1": s.append(c)
        if f == "2": s.appendleft(c)
    else: #ノーマル状態
        if f == "1": s.appendleft(c)
        if f == "2": s.append(c)
    #print(s)

s = "".join(s)
s = s[::-1] if cnt else s
print(s)
n = list(map(int,input().split()))
vote = list(map(int,input().split()))
a = sum(vote)/(4*n[1])
result = 0
for i in range(n[0]):
  if vote[i]=>a:
    result += 1
if result<n[1]:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

n = list(map(int,input().split()))
vote = list(map(int,input().split()))
a = sum(vote)/(4*n[1])
result = 0
for i in range(n[0]):
  if vote[i]>=a:
    result += 1
if result<n[1]:
  print('No')
else:
  print('Yes')
#! python
# shell_sort.py

import copy
import math

count = 0

def insertion_sort(A, N, g):
    global count
    A_ = copy.copy(A)
    for i in range(g, N):
        v = A_[i]
        j = i - g
        while j >= 0 and A_[j] > v:
            A_[j+g] = A_[j]
            j = j - g
            count += 1
        A_[j + g] = v
    return A_

# h_(i+1) = 3h_i + 1 が最良の間隔
def shell_sort(A, N):
    A_ = copy.copy(A)

    h = 1
    G = []
    while True:
        G.append(h)
        h = 3*h + 1
        if h > N:
            break
    G = G[::-1]
    m = len(G)

    for i in range(m):
        A_ = insertion_sort(A_, N, G[i])
    return A_, m, G

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

A, m, G = shell_sort(A, n)

print(m)
print(' '.join([str(h) for h in G]))
print(count)
for x in A:
    print(x)


### FIXED CODE ###

import math
import sys

count = 0
m = 0
G = []

def insertion_sort(A, N, g):
    global count
    for i in range(g, N):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            count += 1
        A[j + g] = v

# h_(i+1) = 3h_i + 1 が最良の間隔 (らしい)
def shell_sort(A, N):
    global m, G
    m = math.floor(math.log(2*N+1, 3))
    G = [int((pow(3, i)-1)/2) for i in range(m, 0, -1)]

    for i in range(m):
        insertion_sort(A, N, G[i])


n = int(input())
A = list(map(int, sys.stdin.readlines()))
shell_sort(A, n)

print(m)
print(' '.join([str(h) for h in G]))
print(count)
for x in A:
    print(x)
import collections

def root(X):
	if cards[X]==X:
		return X
	else:
		cards[X]=root(cards[X])
		return cards[X]
def unite(X,Y):
	x=root(X)
	y=root(Y)
	if x==y:
		return
	else:
		cards[x]=y
def same(X,Y):
	return root(X)==root(Y)
def show(x):
	print(cards[x])
		
N,M=[int(i) for i in input().split()]
cards=[i for i in range(N+1)]
for i in range(M):
	X,Y,Z=[int(i) for i in input().split()]
	if same(X,Y):
		pass
	else:
		unite(X,Y)
a=[]
for i in range(1,N+1):
	a.append(root(cards[i]))
print(len(set(a)))

### FIXED CODE ###

import collections
import sys
sys.setrecursionlimit(100000)
def root(X):
	if cards[X]==X:
		return X
	else:
		cards[X]=root(cards[X])
		return cards[X]
def unite(X,Y):
	x=root(X)
	y=root(Y)
	if x==y:
		return
	else:
		cards[x]=y
def same(X,Y):
	return root(X)==root(Y)
def show(x):
	print(cards[x])
		
N,M=[int(i) for i in input().split()]
cards=[i for i in range(N+1)]
for i in range(M):
	X,Y,Z=[int(i) for i in input().split()]
	if same(X,Y):
		pass
	else:
		unite(X,Y)
a=[]
for i in range(1,N+1):
	a.append(root(cards[i]))
print(len(set(a)))
a=list(map(int,input().split()))
b=0
count=0
for i in range(1,a[0]+1):
    if a[i]>=b:
        count=count+1
        b=a[i]
print(count)

### FIXED CODE ###

c=int(input())
a=list(map(int,input().split()))
b=0
count=0
for i in range(0,c):
    if a[i]>=b:
        count=count+1
        b=a[i]
print(count)
n,k = map(int,input().split())
a = list(map(int,input().split()))
l = [1,a[0]]
tp = a[0]-1
while True:  
  if a[tp] not in l: 
    l.append(a[tp])
    tp = a[tp] -1
  else:
    l.append(a[tp])
    break
    
last = l[-1]
first = l.index(last)
loop = len(l)-first

if len(l)>k:
  print(l[k])
  exit()
k -=first
k %=loop
if k==0:
  k+=loop
print(l[k+first])

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
l = [1]

for i in range(n):
  l.append(a[l[i]-1])
p = l.index(l[n])
#print(p,l[n])
if k<=n:
  print(l[k])
else:
  x = (k-n+1)%(n-p)
  if x ==0:
    x += (n-p)
    print(l[x-1])
  else:
    print(l[x+p-1])
n,m=map(int,input().split())
k=[]
ans=0
for i in range(m):
      a=list(map(int,input().split()))
      k.append(a)
p=list(map(int,input().split()))
for i in range(2**n):
      L=[0]*n
      for j in range(n):
            if ((i>>j)&1):
                  L[j]=1
      flag=True
      for j in range(n):
            s=0
            for e in range(k[j][0]):
                  s+=L[k[j][e+1]-1]
            if s%2!=p[j]:
                  flag=False
      if flag:
            ans+=1
print(ans)
                 

### FIXED CODE ###

n, m = map(int, input().split())
k = [[int(i) for i in input().split(" ")] for i in range(m)]
p = [int(i) for i in input().split(" ")]
c = 0
for i in range(2**n):
    t = bin(i+2**n)[2:]
    a = sum([0 if sum([1 if t[l]=="1" else 0 for l in k[j][1:]])%2 == p[j] else 1 for j in range(len(k))])
    if a == 0:
        c+=1
print(c)
S = list(input())

ans = 1000
L = len(S)
for i in range(L):
  if L - 1 < i + 2:
    break
  
  s = int(S[i:i+3])
  ans = min(ans,753-s)

print(ans)

### FIXED CODE ###

S = list(input())

ans = 1000
L = len(S)
for i in range(L):
  if L - 1 < i + 2:
    break
  
  s = int("".join(S[i:i+3]))
  ans = min(ans,abs(753-s))

print(ans)
N,M = list(map(int,input().split()))
xarray = list(map(int,input().split()))
diff = []
if len(xarray) == 1:
    print(0)
else:
    for i in range(len(xarray)-1):
        diff.append(abs(xarray[i+1]-xarray[i]))
    if len(diff) == 0:
        print(0)
    else:
        diff2 = sorted(diff, reverse = True)
        for j in range(N):
            diff2[j] = 0
        print(sum(diff2))

### FIXED CODE ###

N,M = list(map(int,input().split()))
xarray = sorted(list(map(int,input().split())))
 
diff = []
if len(xarray) == 1:
    print(0)
elif N >= M:
    print(0)
else:
    for i in range(len(xarray)-1):
        diff.append(abs(xarray[i+1]-xarray[i]))
 
    if len(diff) == 0:
        print(0)
    else:
        diff2 = sorted(diff, reverse = True)
        
 
        if N == 1:
            
            print(sum(diff2))
        else:
            for j in range(N-1):
                diff2[j] = 0
            
            print(sum(diff2))
c=input().split()
a=int(c)
b=int(c)
if a > b:
  print("a > b")
elif a < b:
   print("a < b")
else:
    print("a == b")


### FIXED CODE ###

n=input().split()
a=int(n[0])
b=int(n[1])
if a > b:
    print("a > b")
elif a < b:
    print("a < b")
else:
    print("a == b")
a, b= [int(input()) for _ in range(2)]
import math
c=a*(10**len(str(b))+b)
if int(math.sqrt(c)) == math.sqrt(c):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from math import sqrt
a, b = input().split()
n = int(a+b)
if(int(sqrt(n))**2 == n):
    print("Yes")
else:
    print("No")
N=int(input())
A=[int(input()) for _ in range(N)]
 
ans=0
#0,1,2のみにする
for i in range(N):
  a=A[i]
  if a>=2 and a%2==0:
    A[i]=2
    ans+=(a-2)//2
  elif a%2==1:
    A[i]=1
    ans+=(a-1)//2
  elif a==0:
    pass
  

for i in range(1,N-1):
  b,a,c=A[i-1:i+1]
  if a==2:
    if b%2==1 and c %2==1:
      A[i-1]-=1 
      A[i+1]-=1
      A[i]-=2
      ans+=2
    
for i in range(1,N):
  a,b=A[i-1:i+1]
  if a%2==1 and b%2==1:
    ans+=1
    A[i-1]-=1
    A[i]-=1  

ans+=len(list(filter(lambda x:x==2,A)))
print(ans)


### FIXED CODE ###

N=int(input())
A=[int(input()) for _ in range(N)]

ans=0
idx=[]
for i in range(N):
  if A[i]==0:
    idx.append(i+1)
n=0
idx.append(N)
for iidx in idx:
  ans+=sum(A[n:iidx])//2
  n=iidx
print(ans)
n = int(input())
s = list(input())

if n%2 == 0:
    s1 = set(s[:n//2:])
    s2 = set(s[n//2::])
    print(len(s1&s2))
else:
    s1 = set(s[:n//2:])
    s2 = set(s[n//2::])
    s3 = set(s[:(n//2)+1:])
    s4 = set(s[(n//2)+1::])
    print(max(len(s1&s2),len(s3,s4)))


### FIXED CODE ###

n = int(input())
s = list(input())
l = [0]*n
for i in range(n):
    s1 = set(s[:i:])
    s2 = set(s[i::])
    l[i] = len(s1&s2)
print(max(l))
N, M = map(int, input().split())

MOD = 10 ** 9 + 7
a = []
flag = True
for i in range(M):
  tmp = int(input())
  if i != 0 and tmp == a[-1] + 1:
    print(0)
    flag = False
    break
  a.append(tmp)

if flag:
  max_dis = 0
  dis = []
  for i in range(len(a)):
    if i == 0:
      dis.append(a[i])
    else:
      dis.append(a[i] - a[i - 1] - 1)
    max_dis = max(max_dis, dis[-1])
  max_dis = max(max_dis, N - a[-1])
  
  fib = [1, 1]
  for _ in range(max_dis):
    fib.append((fib[-1] + fib[-2]) % MOD)
  ans = 1
  for d in dis:
    ans = (ans * fib[d - 1]) % MOD
  ans *= fib[N - a[-1] - 1] % MOD
  
  print(ans % MOD)

### FIXED CODE ###

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

MOD = 10 ** 9 + 7
a = []
flag = True
for i in range(M):
  tmp = int(input())
  if i != 0 and tmp == a[-1] + 1:
    print(0)
    flag = False
    break
  a.append(tmp)

if flag:
  max_dis = 0
  dis = []
  for i in range(len(a)):
    if i == 0:
      dis.append(a[i])
    else:
      dis.append(a[i] - a[i - 1] - 1)
    max_dis = max(max_dis, dis[-1])
  if M == 0:
    max_dis = N
    a.append(-1)
  else:
    max_dis = max(max_dis, N - a[-1])
  
  fib = [1, 1]
  for _ in range(max_dis):
    fib.append((fib[-1] + fib[-2]) % MOD)
  ans = 1
  for d in dis:
    ans = (ans * fib[d - 1]) % MOD
  ans *= fib[N - a[-1] - 1] % MOD
  
  print(ans % MOD)
s, t = [input() for i in range(2)]
c = []
for i in range(len(s) - len(t)):
  d = 0
  for a, b in zip(s[i:i+len(t)], t):
    if a != b:
      d += 1
  c.append(d)
print(min(c))

### FIXED CODE ###

s, t = [input() for i in range(2)]
c = []
for i in range(len(s) - len(t) + 1):
  d = len(t)
  for a, b in zip(s[i:], t):
    if a == b:
      d -= 1
  c.append(d)
print(min(c))
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
dp1 = [0] * (n+1)
for i in range(n+1):
    if i>=a[0]:
        dp1[i] = max(dp1[i],dp1[i-a[0]]+b[0])
    if i>=a[1]:
        dp1[i] = max(dp1[i],dp1[i-a[1]]+b[1])
    if i>=a[2]:
        dp1[i] = max(dp1[i],dp1[i-a[1]]+b[2])
n=dp1[n]
dp2 = [0] * (n+1)
for i in range(n+1):
    if i>=b[0]:
        dp2[i] = max(dp2[i],dp2[i-b[0]]+a[0])
    if i>=b[1]:
        dp2[i] = max(dp2[i],dp2[i-b[1]]+a[1])
    if i>=b[2]:
        dp2[i] = max(dp2[i],dp2[i-b[1]]+a[2])


print(dp2[n])

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
dp1 = [n] * (n+1)
for i in range(n+1):
    if i>=a[0]:
        dp1[i] = max(dp1[i],dp1[i-a[0]]-a[0]+b[0])
    if i>=a[1]:
        dp1[i] = max(dp1[i],dp1[i-a[1]]-a[1]+b[1])
    if i>=a[2]:
        dp1[i] = max(dp1[i],dp1[i-a[2]]-a[2]+b[2])
n=dp1[n]
dp2 = [n] * (n+1)
for i in range(n+1):
    if i>=b[0]:
        dp2[i] = max(dp2[i],dp2[i-b[0]]-b[0]+a[0])
    if i>=b[1]:
        dp2[i] = max(dp2[i],dp2[i-b[1]]-b[1]+a[1])
    if i>=b[2]:
        dp2[i] = max(dp2[i],dp2[i-b[2]]-b[2]+a[2])


print(dp2[n])
n, m = map(int, input().split())

a = []
for _ in range(m):
    a.append(int(input()))
a.append(n+1)

def solve(a,n,m):
    for i in range(len(a)-1):
        if a[i+1] == a[i] + 1:
            return 0

    a_diff = [a[0]-1]
    for i in range(1, m+1):
        a_diff.append(a[i] - a[i-1] - 2)
    ans = 1
    for y in a_diff:
        ans *= count_way(y)
    return ans

def count_way(n):
    memo = [0]*(n+1)
    memo[0] = 1
    memo[1] = 1
    for j in range(n+1):
        memo[j] = memo[j-1] + memo[j-2]
    return memo[n]

print(solve(a,n,m)%1000000007)


### FIXED CODE ###

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

a = []
for _ in range(m):
    a.append(int(input()))
a.append(n+1)

def solve(a,n,m):
    for i in range(len(a)-1):
        if a[i+1] == a[i] + 1:
            return 0

    a_diff = [a[0]-1]
    for i in range(1, m+1):
        a_diff.append(a[i] - a[i-1] - 2)
    ans = 1
    for y in a_diff:
        if y == 0 or y == 1:
            continue
        ans *= count_way(y)
    return ans

def count_way(n):
    memo = [0]*(n+1)
    memo[0] = 1
    memo[1] = 1
    for j in range(n-1):
        memo[j+2] = memo[j+1] + memo[j]
    return memo[n]

print(solve(a,n,m)%1000000007)
def pcmod(n):
    if n==0:
        return 1
    return 1+pcmod(n%bin(n).count('1'))

def main():
    n = int(input())
    x = list(map(int,list(input())))

    m_1 = x.count(1)-1
    m_0 = x.count(1)+1 
    baser_1 = 0
    baser_0 = 0
    for i in range(n):
        baser_1 += x[i] * pow(2,(n-1-i),m_1)
        baser_0 += x[i] * pow(2,(n-1-i),m_0)
        baser_1 %= m_1
        baser_0 %= m_0

    ans = [0]*n

    for i in range(n):
        a = 0
        if x[i]==1:
            t = (baser_1 - pow(2,(n-1-i),m_1))%m_1
            a = pcmod(t)

        if x[i]==0:
            if m_0 ==0:
                ans[i] = 0
                continue
            t = (baser_0 + pow(2,(n-1-i),m_0))%m_0
            a = pcmod(t)
        ans[i] = a

    for a in ans:
        print(a)
if __name__ == "__main__":
    main()

### FIXED CODE ###

def pcmod(n):
    if n==0:
        return 1
    return 1+pcmod(n%bin(n).count('1'))

def main():
    n = int(input())
    x = list(map(int,list(input())))

    m_1 = x.count(1)-1
    m_0 = x.count(1)+1 
    baser_1 = 0
    baser_0 = 0
    if m_1!=0:
        for i in range(n):
            baser_1 += x[i] * pow(2,(n-1-i),m_1)
            baser_1 %= m_1
        
    for i in range(n):
        baser_0 += x[i] * pow(2,(n-1-i),m_0)
        baser_0 %= m_0

    ans = [0]*n

    for i in range(n):
        a = 0
        if x[i]==1:
            if m_1==0:
                ans[i] = 0
                continue
            t = (baser_1 - pow(2,(n-1-i),m_1))%m_1
            a = pcmod(t)

        if x[i]==0:
            t = (baser_0 + pow(2,(n-1-i),m_0))%m_0
            a = pcmod(t)
        ans[i] = a

    for a in ans:
        print(a)
if __name__ == "__main__":
    main()
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N

for i in range(M):
  p,s=input().split()
  if s=="WA" and ac(int(p)-1)==0:
    wa[int(p)-1]+=1
  elif s=="AC" and ac(int(p)-1)==0:
    ac[int(p)-1]+=1

penalty=[w(k) for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" %(sum(ac),sum(penalty)))


### FIXED CODE ###

N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N

for i in range(M):
  p,s=input().split()
  if s=="WA" and ac[int(p)-1]==0:
    wa[int(p)-1]+=1
  elif s=="AC" and ac[int(p)-1]==0:
    ac[int(p)-1]+=1

penalty=[wa[k] for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" % (sum(ac),sum(penalty)))
a = list( map(input().split()))
b = list( map(input().split()))
c = list( map(input().split()))

print(a[0],b[1],c[2])

### FIXED CODE ###

a = input()
b = input()
c = input()

print(a[0]+b[1]+c[2])