Harryxun/stf_run huggingface dataset:
N = int(input())
s = [input() for i in range(N)]

end_A = 0
start_B = 0
AB_count = 0
both = 0

for i in range(N):
    if 'AB' in s[i]:
        AB_count += s[i].count('AB')
    if s[i][0] == 'B':
        start_B += 1
    if s[i][len(s[i])-1] == 'A':
        end_A += 1
    if s[i][0] == 'B' and s[i][len(s[i])-1] == 'A':
        both += 1
start_B -= both
end_A -= both

if both == 0:
    print(AB_count + min(start_B, end_A))
elif end_A + start_B > 0:
    print(AB_count + both + min(start_B, end_A))
elif end_A + end_B == 0:
    print(both - 1)

### FIXED CODE ###

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

end_A = 0
start_B = 0
AB_count = 0
both = 0

for i in range(N):
    if 'AB' in s[i]:
        AB_count += s[i].count('AB')
    if s[i][0] == 'B':
        start_B += 1
    if s[i][len(s[i])-1] == 'A':
        end_A += 1
    if s[i][0] == 'B' and s[i][len(s[i])-1] == 'A':
        both += 1
start_B -= both
end_A -= both

if both == 0:
    print(AB_count + min(start_B, end_A))
elif end_A + start_B > 0:
    print(AB_count + both + min(start_B, end_A))
else:
    print(AB_count + both - 1)
S = input()
T = input()

count = 0
#iを３回数えてもらう
for i in range(3):
#数えてｓとｔが同じならカウント１とする
    if S[i]==T[i]:
    count += 1
print(count)

### FIXED CODE ###

S = input()
T = input()

count = 0
#iを３回数えてもらう
for i in range(3):
#数えてｓとｔが同じならカウント１とする
    if S[i]==T[i]:
        count += 1
print(count)
N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ
if N%2==0:
  for i in range(0,int(N/2)):
    B+=[2*i,2*i]
    C+=[2*i+1,2*i+1]
  if A==B or A==C:
    ans=int(2**(N/2))%(10**9+7)
    print(ans)
  else:
    print(0)
else:
  B+=[0]
  C+=[1]
  for i in range(0,int(N/2)):
    B+=[2*i+2,2*i+2]
    C+=[2*i+3,2*i+3]
  if A==B or A==C:
    print(int(2**((N-1)/2))%(10**9+7))
  else: 
    print(0)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ

if N%2==0:
  for i in range(0,int(N/2)):
    B+=[2*i,2*i]
    C+=[2*i+1,2*i+1]
  if A==B or A==C:
    n=int(N/2)
    ans=2**n
    print(ans%(10**9+7))
  else:
    print(0)
else:
  B+=[0]
  C+=[1]
  for i in range(0,int(N/2)):
    B+=[2*i+2,2*i+2]
    C+=[2*i+3,2*i+3]
  if A==B or A==C:
    n=int((N-1)/2)
    ans=2**n
#    ans=2**((N-1)/2)
    print(ans%(10**9+7))
  else: 
    print(0)
from collections import deque

h,w = map(int, input().split())
A = [['*']*(w+2)] + [['*']+[s for s in input()]+['*'] for _ in range(h)] + [['*']*(w+2)]

dist_to_black = [[0]*w for _ in range(h)]

def bfs(sx,sy):
    dq = deque([(sy,sx,0)])
    while dq:
        y,x,n = dq.popleft()
        if A[y][x]=='#':
            return n
        elif A[y][x]=='.':
            dq.append([y+1,x,n+1])
            dq.append([y-1,x,n+1])
            dq.append([y,x+1,n+1])
            dq.append([y,x-1,n+1])

ans = -1
for i in range(h):
    for j in range(w):
        # dist_to_black[i][j] = bfs(i+1,j+1)
        ans = max(ans, bfs(i+1, j+1))

print(ans)

### FIXED CODE ###

from collections import deque

h,w = map(int, input().split())
A = [[s for s in input()] for _ in range(h)]

visited = [[-1]*(w) for _ in range(h)]
dq = deque()
directions = [[0,1],[1,0],[0,-1],[-1,0]]

# 初期配置の黒をキューに追加
for hi in range(h):
    for wi in range(w):
        if A[hi][wi] == '#':
            dq.append([hi,wi])
            visited[hi][wi] = 0

# キューが空になるまで
while dq:
    hi,wi = dq.popleft()
    for d in directions:
        nhi, nwi = hi+d[0],wi + d[1]
        # 場外ならスキップ
        if nhi<0 or nhi>=h or nwi<0 or nwi>=w: continue 
        # 「黒くしてない白マス」をキューに追加
        if visited[nhi][nwi] == -1 and A[nhi][nwi] == '.':
            dq.append([nhi,nwi])
            visited[nhi][nwi] = visited[hi][wi] + 1

ans = -1
for x in visited:
    ans = max(ans,max(x))
print(ans)
def text_match_words(text, words):
	match_words = []
	for word in words:
		if word == text[:len(word)]:
			match_words.append(word)
	return match_words

def is_match_for(text, words):
	if "" == text: 
		return True
	else:
		match_words = text_match_words(text, words)
		if [] == match_words:
			return False
		else:
			return any([is_match_for(text[len(match_word):], words) for match_word in match_words])
		
s = input()

words = ("dream", "dreamer", "erase", "eraser")

if is_match_for(s, words):
	print("YES")
else:
	print("NO")

### FIXED CODE ###

import re

if re.match("(dream|dreamer|erase|eraser)*$", input()):
    print("YES")
else:
    print("NO")
S,T=input().split()
A,B=map(int,input().split())
U=input()
if S==U:
  print(A-1 B)
else:
  print(A B-1)

### FIXED CODE ###

S,T=input().split()
A,B=map(int,input().split())
U=input()
if U==S:
  print(str(A-1),str(B))
else:
  print(str(A),str(B-1))
# -*- coding: utf-8 -*-

n, k, q =map(int, input().split())
a = []
for i in range(q):
  a.append(int(input()))

m = list([k]*n)

for i in range(len(a)):
  for j in range(n):
    m[j]-=1
    m[i-1]+=1
  
for i in range(n):
  if m[i]>0:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
 
n, k, q =map(int, input().split())
a = [int(input()) for i in range(q)]

p = [0]*(n+1)

for i in range(q):
  p[a[i]] += 1
  

for i in range(1,n+1):
  if p[i]>q-k:
    print("Yes")
  else:
    print("No")
import math
x=int(input())
for i in range(10**5):
  b=(x-i**5)**(1/5)
  if b==math.floor(b) and b==math.ceil(b):
    print(i,int(b))
    break

### FIXED CODE ###

x=int(input())
for i in range(-1000,1000):
  for j in range(-1000,1000):
    if i**5-j**5==x:
      print(i,j)
      break
  else:
    continue
  break
n = int(input())
s = input()
k = int(input())

c = s[k]
a = ""
for t in list(s):
 if t == c:
  a += c
 else:
  a += "*"
print(a) 

### FIXED CODE ###

n = int(input())
s = input()
k = int(input())

c = s[k-1]
a = ""
for t in list(s):
 if t == c:
  a += c
 else:
  a += "*"
print(a)
from sys import stdin


# 最小化問題
def chmin(a,b):
    if a > b: return b
    else: return a


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    h_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    dp = [float('inf')] * N  # 最小化問題
    dp[0] = 0                # 初期条件
    
    # 配るDP
    for i in range(0,N):
        dp[i+1] = chmin(dp[i+1],dp[i]+abs(h_arr[i]-h_arr[i+1]))
        dp[i+2] = chmin(dp[i+2],dp[i]+abs(h_arr[i]-h_arr[i+2]))
    
    cnt = dp[N-1]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


### FIXED CODE ###

from sys import stdin


# 最小化問題
def chmin(a,b):
    if a > b: return b
    else: return a


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    h_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    dp = [float('inf')] * N  # 最小化問題
    dp[0] = 0                # 初期条件
    
    for i in range(0,N):
        dp[i] = chmin(dp[i],dp[i-1]+abs(h_arr[i]-h_arr[i-1]))
        if i > 1:
            dp[i] = chmin(dp[i],dp[i-2]+abs(h_arr[i]-h_arr[i-2]))
    cnt = dp[N-1]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
N = int(input())
edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

def bfs(v0):
    dist = [-1]*N
    que = deque([v0])
    dist[v0] = 0
    while que:
        v = que.pop()
        d = dist[v]
        for nv in edges[v]:
            if dist[nv] < 0:
                que.append(nv)
                dist[nv] = d+1
    m = max(dist)
    v = dist.index(d)
    return v, m
u, _ = bfs(0)
_, dia = bfs(u)
if (dia+1-2)%3 == 0:
    print('Second')
else:
    print('First')


### FIXED CODE ###

from collections import deque
N = int(input())
edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

def bfs(v0):
    dist = [-1]*N
    que = deque([v0])
    dist[v0] = 0
    while que:
        v = que.pop()
        d = dist[v]
        for nv in edges[v]:
            if dist[nv] < 0:
                que.append(nv)
                dist[nv] = d+1
    m = max(dist)
    v = dist.index(m)
    return v, m
u, _ = bfs(0)
_, dia = bfs(u)
if N == 1:
    print('First')
elif (dia+1-2)%3 == 0:
    print('Second')
else:
    print('First')
import numba
r,g,b = map(int,input().split())
if (100*r+10*g+b)%4==0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

r,g,b = map(int,input().split())
if (100*r+10*g+b)%4==0:
    print("YES")
else:
    print("NO")
k = input()
yen = input()
if k*500>yen:
  print('Yes')
else:
  print('No)

### FIXED CODE ###

[k, yen] = [int(x) for x in input().split()]
print('Yes') if k*500>=yen else print('No')
S = input()

ans = 0
ACGT = set('A','C','G','T')
for i in range(1,len(S+1)):
  j = 1
  while j*i <= S:
    if set(S[j:j*i]) <= ACGT:
      ans = len(S[j:j*i])
    j += 1
print (ans)

### FIXED CODE ###

s = input()

ans=0
base = set(['A','C','G','T'])
i = 1
while i <= len(s):
    j = 0
    while j+i <= len(s):
        word = set(s[j:j+i])
        if word <= base:
            ans = len(s[j:j+i])
        j += 1
    i += 1
print (ans)
while True:
	data = raw_input().split(" ")
	a = int(data[0])
	op = data[1]
	b = int(data[2])

	if op = "?":
		break
	elif op == "+":
		ans = a + b
	elif op == "-":
		ans = a - b
	elif op == "*":
		ans = a * b
	else:
		ans = a / b

	print ans

### FIXED CODE ###

while True:
	data = raw_input().split(" ")
	a = int(data[0])
	op = data[1]
	b = int(data[2])

	if op == "?":
		break
	elif op == "+":
		ans = a + b
	elif op == "-":
		ans = a - b
	elif op == "*":
		ans = a * b
	else:
		ans = a / b

	print ans
a,b=map(int,input().split())
print("Even" if (a*b)%==0 else "Odd")

### FIXED CODE ###

a,b=map(int,input().split())
print("Even" if (a*b)%2==0 else "Odd")
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
elif x<0 and x+y>0:
    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>1])
else:
    print(hhh)

### FIXED CODE ###

T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
 
P = (A1 - B1) * T1
Q = (A2 - B2) * T2
if P > 0:
	P *= -1
	Q *= -1
 
if P + Q < 0:
	print(0)
elif P + Q == 0:
	print("infinity")
else:
	S = (-P) // (P + Q)
	T = (-P) % (P + Q)
	if T != 0:
		print(S * 2 + 1)
	else:
		print(S * 2)
A, V = map(int,input().split())
B, W = map(int,input().split())

a = A
b = B

T = int(input())
a += V * T
b += W * T

if a < b:
    print('NO')
else:
    print('YES')


### FIXED CODE ###

import sys
import numpy as np
 

 
N =  input()
print(N[0:3])
N, M = map(int, input().split())
n = []
m = []
for i in range(N):
  s = str(input())
  row = []
  for j in range(N):
    if s[i] == "#":
      row.append(1)
    else:
      row.append(0)
  n.append(row)
for i in range(M):
  s = str(input())
  row = []
  for j in range(M):
    if s[i] == "#":
      row.append(1)
    else:
      row.append(0)
  m.append(row)
 
def search(a,b):
  for r in range(a, a+M-1):
    for c in range(b, b+M-1):
      #print(r,c)
      if n[r][c] != m[r][c]:
        return False
  return True
#print(n, m)
ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    if search(i,j):
      ans = 1
      break
  if ans:
    break
if ans:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N, M = map(int, input().split())
n = []
m = []
for i in range(N):
  s = str(input())
  row = []
  for j in range(N):
    if s[j] == "#":
      row.append(1)
    else:
      row.append(0)
  n.append(row)
for i in range(M):
  s = str(input())
  row = []
  for j in range(M):
    if s[j] == "#":
      row.append(1)
    else:
      row.append(0)
  m.append(row)
 
def search(a,b):
  mr = mc = 0
  for r in range(a, a+M):
    for c in range(b, b+M):
      if n[r][c] != m[mr][mc]:
        return False
      mc += 1
    mr += 1
    mc = 0
  return True

ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    if search(i,j):
      ans = 1
      break
  if ans:
    break
if ans:
  print("Yes")
else:
  print("No")
n = int(input())
a = list(map(int,input().split()))

for i in range(n):
    print(i.count(a))
    


### FIXED CODE ###

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

lis = [0] * n
for i in A:
  lis[i-1] += 1

for j in range(len(lis)):
  print(lis[j])
N = int(input())
edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int,input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
c = list(map(int,input().split()))
L = [0] * N

c.sort(reverse = True)

def dfs(x, par, index):
    L[x] = c[index]
    for u in edges[x]:
        if u != par:
            index += 1
            index = dfs(u, x, index)
    return index

dfs(0, -1, 0)

print(sum(L[1:]))
print(*L)

### FIXED CODE ###

import sys
sys.setrecursionlimit(4100000)

N = int(input())
edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int,input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
C = list(map(int,input().split()))
C.sort(reverse = True)

D = [0] * N

def dfs(x, parent, index):
    D[x] = C[index]
    index += 1
    for u in edges[x]:
        if u != parent:
            index = dfs(u, x, index)
    return index

dfs(0, -1, 0)

print(sum(C[1:]))
print(*D)
s = input()
cnt = 0
idx = 0
target = "KIHBR"
for i in range(len(s)):
    if s[i] == "A":
        cnt += 1
        if cnt >= 2:
            print("NO")
            exit()
    else:
        if target[idx] == s[i]:
            idx += 1
            cnt = 0
        else:
            print("NO")
            exit()
if idx == 5:
    print("YES")


### FIXED CODE ###

s = input()
t = "AKIHABARA"
idx = 0
ng = 0
for i in range(len(t)):
    if t[i] == s[idx]:
        idx += 1
    elif t[i] != "A":
        ng = 1
        break
    if idx == len(s):
        if i < len(t) - 2:
            ng = 1

        break

if idx != len(s):
    ng = 1

if ng:
    print("NO")
else:
    print("YES")
n,m=map(int,input().split())
s=[] #全kについて、スイッチの状態を格納する。s[][]で呼び出し
for i in range(m):
	switch=[] #各kについて、スイッチの状態を一旦格納する
	k,*switch=map(int,input().split())
	#switch[i]はswitchの番号であり[1,n]なので、インデックスを1つずつ減らす
	for i in range(k):
		switch[i]-=1
	s.append(switch)
p=list(map(int,input().split()))
'''
print(p) ->[1, 0]
print(s) ->[[0, 1, 4], [1, 2]]
'''
'''
state=format(4,'b')
state=state.zfill(n)
print(state)
print(s[1][1])
print(state[s[1][1]])
'''
count=0
for i in range(2**n):
	q=[] #各状態に対して、各電球につながっているスイッチのon数の偶奇を格納する配列
	state=format(i,'b')
	state=state.zfill(n)
	for i in range(m):
		on=0
		for j in range(k):
			on+=int(state[s[i][j]])
		on=on%2
		q.append(on)
		
	allon=1
	for i in range(m):
		if p[i]!=q[i]:
			allon=0
			break
	if allon:
		count+=1
print(count)

### FIXED CODE ###

n,m=map(int,input().split())
s=[] #全kについて、スイッチの状態を格納する。s[][]で呼び出し
for i in range(m):
	switch=[] #各kについて、スイッチの状態を一旦格納する
	k,*switch=map(int,input().split())
	#switch[i]はswitchの番号であり[1,n]なので、インデックスを1つずつ減らす
	for i in range(k):
		switch[i]-=1
	s.append(switch)
p=list(map(int,input().split()))

ans=0
#スイッチの2**n通りの状態に対して
for state in range(2**n):
	state=list(map(int,format(state,'b').zfill(n)))
	allon=1
	for i in range(m):
		count=0
		for j in range(len(s[i])):
			count+=state[s[i][j]]
		if count%2!=p[i]:
			allon=0
			break
	if allon==1:
		ans+=1
print(ans)
s = int(input())
s[0] = A
s[1] = B
result = A - B * 2
if result < 0:
    result = 0
print(result)

### FIXED CODE ###

s = list(map(int, input().split()))
A = s[0] 
B = s[1]
result = A - B * 2
if result < 0:
    result = 0
print(result)
n = int(input()),m = int(input())
if n % 2 == 0:
  ans = n * m / 2
else:
  if m % 2==0:
    ans = ((n / 2 + 1) + n / 2) * m / 2
  else:
    ans = ((n / 2 + 1) + n / 2) * (m-1) / 2 + n / 2 + 1
print(ans)

### FIXED CODE ###

n, m = (int(x) for x in input().split())

if n == 1 or m == 1:
  ans = 1
else:
  if n % 2 == 0:
    ans = n * m // 2
  else:
    if m % 2 == 0:
      ans = n * m // 2
    else:
      ans = n * m // 2 + 1
print(ans)
S = str(input())
N = int(input())
q = (N -1) // 5
mod = N % 5

    print(S[q]+S[mod-1])


### FIXED CODE ###

S = str(input())
if S[0] == S[1] == S[2] or S[1] == S[2] == S[3]:
    print("Yes")
else:
    print("No")
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
dic=[0 for i in range(9)]
for i in range(n):
    if lis[i]//400==8:
        dic[8]+=1
    else:
        if dic[lis[i]//400]==0:
            dic[lis[i]//400]=1
        
#print(dic)
#print(sum(dic[0:8]))
if sum(dic[0:8])==0:
    mn=1
    mx=dic[-1]
else:
    mn=sum(dic[0:8])
    mx=sum(dic[0:8])+dic[-1]
print(mn,mx)

### FIXED CODE ###

# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
dic=[0 for i in range(9)]
for i in range(n):
    if lis[i]//400>=8:
        dic[8]+=1
    else:
        if dic[lis[i]//400]==0:
            dic[lis[i]//400]=1
        
#print(dic)
#print(sum(dic[0:8]))
if sum(dic[0:8])==0:
    mn=1
    mx=dic[-1]
else:
    mn=sum(dic[0:8])
    mx=sum(dic[0:8])+dic[-1]
print(mn,mx)
N, Z, W = map(int, input().split())
cards = list(map(int, input().split()))

if N == 1:
    print(cards[0] - W)
else:
    x = abs(cards[-1] - cards[-2])
    y = abs(cards[-1] - W)
    print(max(x, y))

### FIXED CODE ###

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

n = 1
for _ in range(M):
    n *= 2

print(n * ((N - M) * 100 + M * 1900))
import collections
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
dd,tt=collections.Counter(d),collections.Counter(t)
for k,v in tt.items():
  h=dd.get(k)>=v
  if h==False or h==None:
    print("NO")
    exit()
print("YES")

### FIXED CODE ###

import collections
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
dd,tt=collections.Counter(d),collections.Counter(t)
for k,v in tt.items():
  if dd.get(k)==None:
    print("NO")
    exit()
  elif dd.get(k)<v:
    print("NO")
    exit()
print("YES")
from sys import stdin
import numpt as np

def main(args):
    r = args[0]
    d = args[1]
    x = args[2]
    ar = np.zeros([10])

    ar[0] = r*x-d
    for i in range(1,len(ar)):
        ar[i] = r*ar[i-1]-d

    for i in ar:
        print(i)

if __name__ == "__main__":
    main([int(x) for x in stdin.readline().rstrip().split()])

### FIXED CODE ###

from sys import stdin
import numpy as np

def main(args):
    r = int(args[0])
    d = int(args[1])
    x = int(args[2])
    ar = np.zeros([10], dtype=int)

    ar[0] = r*x-d
    for i in range(1,len(ar)):
        ar[i] = r*ar[i-1]-d

    for i in ar:
        print(i)

if __name__ == "__main__":
    main(stdin.readline().rstrip().split())
N = int(input())
a = list(map(int,input().split()))

color = [0]*9

for rate in a:
    if rate >= 3200:
        color[8] += 1
    else:
        color[rate//400] += 1
    
ans = 0

for i in range(8):
        if color[i] > 0:
            ans += 1
print(max(ans,1),ans + c[8])

### FIXED CODE ###

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

color = [0]*9

for rate in a:
    if rate >= 3200:
        color[8] += 1
    else:
        color[rate//400] += 1
    
ans = 0

for i in range(8):
        if color[i] > 0:
            ans += 1
print(max(ans,1),ans + color[8])
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    S = input()
    B = []
    W = []
    i = 0
    fin = None
    while i < N:
        if S[i] == '#':
            if i == N-1:
                B.append(1)
                fin = True
            else:
                tmp = 1
                while S[i+1] == '#':
                    tmp += 1
                    i += 1
                    if i == N-1:
                        break
                B.append(tmp)
        else:
            if i == N-1:
                W.append(1)
                fin = False
            else:
                tmp = 1
                while S[i+1] == '.':
                    tmp += 1
                    i += 1
                    if i == N-1:
                        break
                W.append(tmp)
        i += 1

    # print(B,W)
    ans = sum(B)
    L = len(B)+len(W)
    now = ans
    if fin:
        for i in range(L):
            if i % 2 == 0:
                now -= B[i//2]
            else:
                now += W[i//2]
            ans = min(ans,now)
    else:
        for i in range(L):
            if i % 2 == 1:
                now -= B[i//2]
            else:
                now += W[i//2]
            ans = min(ans,now)
    print(ans)



    

if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    S = input()
    B = []
    W = []
    i = 0
    fin = None
    while i < N:
        if S[i] == '#':
            if i == N-1:
                B.append(1)
                fin = True
            else:
                tmp = 1
                while S[i+1] == '#':
                    tmp += 1
                    i += 1
                    if i == N-1:
                        fin = True
                        break
                B.append(tmp)
        else:
            if i == N-1:
                W.append(1)
                fin = False
            else:
                tmp = 1
                while S[i+1] == '.':
                    tmp += 1
                    i += 1
                    if i == N-1:
                        fin = False
                        break
                W.append(tmp)
        i += 1

    ans = sum(B)
    L = len(B)+len(W)
    B = B[::-1]
    W = W[::-1]
    now = ans
    if fin:
        for i in range(L):
            if i % 2 == 0:
                now -= B[i//2]
            else:
                now += W[i//2]
            ans = min(ans,now)
    else:
        for i in range(L):
            if i % 2 == 1:
                now -= B[i//2]
            else:
                now += W[i//2]
            ans = min(ans,now)
    print(ans)



    

if __name__ == "__main__":
    main()
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;

int main() {
    int s,w; cin >> s >> w;
    if (w >= s){
        cout << "unsafe\n";
    }
    else{
        cout << "safe\n";
    }
}

### FIXED CODE ###

s,w = map(int,input().split())
if s<=w:
    print("unsafe")
else:
    print("safe")