Harryxun/stf_run huggingface dataset:
import bisect
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(index):
  if index == N:
    ans.append(-1)
    return
  num = a[index]
  if len(data[num]) == 1:
    ans.append(index)
    tami(index+1)
  elif index == data[num][-1]:
    ans.append(index)
    tami(data[num][0] +1)
  else:
    tmp = bisect.bisect_right(data[num],index)
    #print(num,data[num],tmp)
    tami(data[num][tmp]+1)

def judge(x):
  d = []
  d.append(a[x])
  while True:
    x += 1
    if x == N:
      break
    if len(data[a[x]]) == 1:
      d.append(a[x])
    elif x == data[a[x]][-1]:
      d.append(a[x])
    else:
      tmp = bisect.bisect_right(data[a[x]],x)
      x = data[a[x]][tmp]
  return d

N,K = IL()
a = IL()

data = [[] for i in range(N+1)]
ans = []

for i in range(N):
  data[a[i]].append(i)

#print(data)

tami(0)
#print(ans)
#print(len(ans),K)
#print(K%len(ans))

if ans == [-1]:
  print()
else:
  print(" ".join(map(str,(judge(ans[K%len(ans)-1])))))
"""
for i in range(K):
  for j in range(N):
    if a[j] in data:
      num = data.index(a[j])
      data = data[:num]
    else:
      data.append(a[j])
  print(data)

11 10
1 2 3 0 4 5 6 0 4 5 6

11 10
3 1 4 1 5 9 2 6 5 3 5

10 10
1 4 8 3 5 4 2 3 4 6
"""

### FIXED CODE ###

import bisect
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(index):
  if index == N:
    ans.append(-1)
    return
  num = a[index]
  if len(data[num]) == 1:
    ans.append(index)
    tami(index+1)
  elif index == data[num][-1]:
    ans.append(index)
    tami(data[num][0]+1)
  else:
    tmp = bisect.bisect_left(data[num],index)
    #print(num,data[num],tmp)
    tami(data[num][tmp+1]+1)

N,K = IL()
a = IL()

data = [[] for i in range(200010)]
ans = []

for i in range(N):
  data[a[i]].append(i)

#print(data)

tami(0)

#print(ans)
#print(len(ans),K)
#print(K%len(ans))

if K%len(ans) == 0:
  print()
else:
  x = ans[K%len(ans)-1]
  d = []
  d.append(a[x])
  while x != N-1:
    x += 1
    if len(data[a[x]]) == 1:
      d.append(a[x])
    elif x == data[a[x]][-1]:
      d.append(a[x])
    else:
      tmp = bisect.bisect_left(data[a[x]],x)
      x = data[a[x]][tmp+1]

  print(" ".join(map(str,d)))

"""
for i in range(K):
  for j in range(N):
    if a[j] in data:
      num = data.index(a[j])
      data = data[:num]
    else:
      data.append(a[j])
  print(data)

11 10
1 2 3 0 4 5 6 0 4 5 6

11 10
3 1 4 1 5 9 2 6 5 3 5

10 10
1 4 8 3 5 4 2 3 4 6
"""
A,B = map(int, input().split())
if A==1:
  A=14
if B==1:
  B=14

if a>b:
  print('Alice')
elif b>a:
  print('Bob')
else:
  print('Draw')

### FIXED CODE ###

A,B = map(int, input().split())
if A==1:
  A=14
if B==1:
  B=14

if A>B:
  print('Alice')
elif B>A:
  print('Bob')
else:
  print('Draw')
= int(input())
import numpy as np

A = list(map(int, input().split()))
dp = np.zeros((N,N), dtype=np.int32)
for i in range(N):
  tmp = [0]*(A[i]-1)+[1]+[0]*(N-A[i])
  tmp = np.array(tmp, dtype=np.int32)
  dp[i] = tmp+dp[i-1]

dp = np.array(dp)
ans = []
for i in range(N):
  if i > 0 and i < N-1:
    tmp = dp[N-1] - dp[i] + dp[i-1]
    tmp = tmp*(tmp-1)//2
    tmp = tmp[tmp>0]
    ans.append(tmp.sum(dtype=np.int32))
  if i == 0:
    tmp = dp[N-1] - dp[i]
    tmp = tmp*(tmp-1)//2
    tmp = tmp[tmp>0]
    ans.append(tmp.sum(dtype=np.int32))
  if i == N-1:
    tmp = dp[N-2]
    tmp = tmp*(tmp-1)//2
    tmp = tmp[tmp>0]
    ans.append(tmp.sum(dtype=np.int32))
for i in ans:
  print(i)

### FIXED CODE ###

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

from collections import defaultdict
c = defaultdict(int)
cm = set()
c2 = list()
num = 0
for i in range(N):
  c[A[i]] += 1
  cm.add(A[i])
for i in list(cm):
  num += c[i]*(c[i]-1)//2
for i in range(N):
  ans = num - c[A[i]] + 1
  c2.append(ans)

for cs in c2:
  print(cs)
n=int(input())
l=[]
for _ in range(n):
  l.append(int(input()))
m=max(l)
mc=l.count(m)
s=sorted(set(l))[-2]
for i in l:
  if i==m:
    if mc>1:
      print(m)
    else:
      print(s)
  else:
    print(m)


### FIXED CODE ###

n=int(input())
l=[]
for _ in range(n):
  l.append(int(input()))
m=max(l)
mc=l.count(m)
tin=set(l)
if len(tin)==1:
  s=m
else:
  s=sorted(tin)[-2]
for i in l:
  if i==m:
    if mc>1:
      print(m)
    else:
      print(s)
  else:
    print(m)
arr = [0]*5
for i in range(5):
    arr[i] = int(input())
time = 0
for ar in arr:
    time += (-(-ar//10))*10
amari = []
for i in arr:
    amari.append(i%10)
amari.sort()
while 0 in amari:
    amari.remove(0)
print(time - (10-amari[0]))


### FIXED CODE ###

arr = [0]*5
for i in range(5):
    arr[i] = int(input())
time = 0
for ar in arr:
    time += (-(-ar//10))*10
amari = []
for i in arr:
    amari.append(i%10)
amari.sort()
while 0 in amari:
    amari.remove(0)
if amari == []:
    amari.append(10)
print(time - (10-amari[0]))
import sys
input=sys.stdin.readline

def grid(y,x,mp):
    dp=[[0]*y for _ in range(x)]
    dp[0][0]=1
    for h in range(H):
        for w in range(W):
            if mp[h][w]=='.':
                if h>=1:
                    dp[h][w]+=dp[h-1][w]
                if w>=1:
                    dp[h][w]+=dp[h][w-1]
    return dp[y-1][x-1]%(10**9+7)


H,W=map(int,input().split())
mp=[]
for _ in range(H):
    mp.append(list(input()))
print(grid(H,W,mp))


### FIXED CODE ###

import sys
input=sys.stdin.readline

def grid(y,x,mp):
    mod=10**9+7
    dp=[[0]*x for _ in range(y)]
    dp[0][0]=1
    for h in range(y):
        for w in range(x):
            if mp[h][w]=='.':
                if 1<=h<y and 1<=w<x:
                    dp[h][w]=((dp[h][w-1]+dp[h-1][w])%mod)
                elif h==0 and 1<=w<x:
                    dp[h][w]=(dp[h][w-1]%mod)
                elif 1<=h<y and w==0:
                    dp[h][w]=(dp[h-1][w]%mod)
    return dp[y-1][x-1]


H,W=map(int,input().split())
mp=[list(input()) for _ in range(H)]
print(grid(H,W,mp))
# -*- coding: utf-8 -*-

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""
import math
N = int(input())
X = list(map(int, input().split()))

def calc(i):
    if i==1:
        return 1
    return calc(i-1)+(1.0/i)

result = []
for i in range(1, N):
    temp = (X[i]-X[i-1])*calc(i)
    result.append(temp)
    
print(int(sum(result)*math.factorial(N-1)))

### FIXED CODE ###

# -*- coding: utf-8 -*-

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

def solver(M,X):
    result = 0
    flag = 0
    for m in M:
        if flag == 1:
            result += int(m[1])
        if m[0]==X:
            flag = 1
    return result

print(solver(M,X))
#ABC070C
import math
from functools import reduce
N=int(input())
T=[int(input()) for i in range(N)]
#def lcm_base(x, y):
#    interium=x//math.gcd(x, y)
#    return (interium*y)
#print(reduce(lcm_base, T))
ans=1
def grcode(x, y):
    if y==0:
        return (x)
    else:
        return grcode(y, x%y)
#for i in range(N-1):
#    T[i]=T[i]//grcode(T[i],T[i+1])
#    T[i+1]=T[i]*T[i+1]
#print(T[N-1])
for i in range(N-1):
    T[i]=T[i]//math.gcd(T[i],T[i+1])
    T[i+1]=T[i]*T[i+1]
print(T[N-1])

### FIXED CODE ###

#ABC070C
import math
from functools import reduce
N=int(input())
T=[int(input()) for i in range(N)]
#def lcm_base(x, y):
#    interium=x//math.gcd(x, y)
#    return (interium*y)
#print(reduce(lcm_base, T))
ans=1
def grcode(x, y):
    if y==0:
        return (x)
    else:
        return grcode(y, x%y)
for i in range(N-1):
    T[i]=T[i]//grcode(T[i],T[i+1])
    T[i+1]=T[i]*T[i+1]
print(T[N-1])
import collections
n=int(input())
if n==1:
  print(0)
  exit()
b=int(n**0.5)
i=2
l=[]
while i<=b:
  if n%i==0:
    l.append(i)
    n=n//i
  else:
    i+=1
if n>b:
  l.append(n)
c=collections.Counter(l)
v=list(c.values())

ans=0
for vv in v:
  wa=1
  s=1 
  while True:
    if vv<wa:
      break
    s+=1
    wa+=s
  ans+=(s-1)
print(ans)

### FIXED CODE ###

from decimal import Decimal
a,b=map(Decimal,input().split())
print(int(a*b))
N = int(input())
s = []
for i in range(N):
	s.append(input())
l = list(itertools.combinations(s,len(s))
m = []
for j in range(N):
	new_s = "".join(s[i])
    num = new_s.count("AB")
    m.append(num)
print(max(m))

### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]
ans = 0
ba = b = a = 0
for s in S:
    ans += s.count('AB')
    if s[0] + s[-1] == 'BA':
        ba += 1
    if s[0] == 'B':
        b += 1
    if s[-1] == 'A':
        a += 1
ans += min(a, b)
if a == b == ba and b:
    ans -= 1
print(ans)
# -*- coding: utf-8 -*-
import itertools
H, W, M = [int(j) for j in input().split()]
Hx = [0]*H
Wx = [0]*W
dict = [[0] * W for i in range(H)]
for i in range(M):
    h, w =  [int(j) for j in input().split()]
    dict[h-1][w-1]=1
    Hx[h-1] += 1
    Wx[w-1] += 1
maxIndex_Hx = [i for i, x in enumerate(Hx) if x == max(Hx)]
maxIndex_Wx = [i for i, x in enumerate(Wx) if x == max(Wx)]
ans = max(Hx)+ max(Wx)
flag = 1
#print(dict)
for j in list(itertools.product(maxIndex_Hx, maxIndex_Wx)):
    if dict[j[0]][j[1]] == 0:
        print(ans)
        flag = 0
        break
if flag:
    print(ans-1)


### FIXED CODE ###

# -*- coding: utf-8 -*-
W,H,M=[int(_) for _ in input().split()]
HW=[[int(_) for _ in input().split()]for i in range(M)]
yoko = [0]*W
tate = [0]*H
for hw in HW:
    yoko[hw[0]-1]+=1
    tate[hw[1]-1]+=1

my=max(yoko)
mt =max(tate)
ans = mt+my

cu=yoko.count(my)*tate.count(mt)
c = 0

for hw in HW:
    if yoko[hw[0]-1]==my and tate[hw[1]-1]==mt:
        c+=1
if c== cu:
    ans-=1
print(ans)
from numpy import gcd
N = int(input())
a = np.arange(1,N+1)
b = np.gcd.outer(np.gcd.outer(a,a), a)
print(b)

### FIXED CODE ###

import numpy as np
K = int(input())
a = np.arange(1,K+1)
b = np.gcd.outer(np.gcd.outer(a, a), a)
print(np.sum(b))
N, M = map(int, input().split())
red = [False for i in range(N+1)]
red[1] = True
box = [1 for i in range(N+1)]

for i in range(M):
    x, y = map(int, input().split())
    if red[x]:
        red[y] = True
    box[x] -= 1
    box[y] += 1
    if box[i] == 0:
        red[x] = False

ans = 0
for i in range(1, N+1):
    if red[i] and box[i] > 0:
        ans += 1
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
red = [False for i in range(N+1)]
red[1] = True
box = [1 for i in range(N+1)]

for i in range(M):
    x, y = map(int, input().split())
    if red[x]:
        red[y] = True
    box[x] -= 1
    box[y] += 1
    if box[x] == 0:
        red[x] = False

ans = 0
for i in range(1, N+1):
    if red[i] and box[i] > 0:
        ans += 1
print(ans)
input(x)
a = x * x * x
print(a)


### FIXED CODE ###

x = int(input())
a = x * x * x
print(a)
a, b, k = map(int, input().split())
l = list(range(a, b+1))
for i in set(l[:k] + l[-k:]):
    print(i)

### FIXED CODE ###

a, b, k = map(int, input().split())
for i in range(a, min(b+1, a+k)):
    print(i)
for i in range(max(b-k+1, a+k), b+1):
    print(i)
a,b = map(int,input().split())
 
if a > b:
    op = '>'
elif a < b:
    op = '<'
else:
    op = '=='
 
print("a %s b"%op)


### FIXED CODE ###

x = input().split()
a, b = int(x[0]), int(x[1])
if a < b:
    print('a < b')
elif a > b:
    print('a > b')
else:
    print('a == b')
N = int(inoput())
S = input()

print('Yes' if S[N//2:] == S[:N//2] else 'No')

### FIXED CODE ###

N = int(input())
S = input()

print('Yes' if S[N//2:] == S[:N//2] else 'No')
A,B=map.(int,input().split())
c = A + B
d = A- B
e = A*B
print(max([c,d,e]))

### FIXED CODE ###

A,B=map(int,input().split())
c = A + B
d = A- B
e = A*B
print(max([c,d,e]))
R,G,B,N =map(int,input().split())

cnt =0
    
for r in range(int(N/R)+1):
    
    for g in range(int(N/G)+1):
        
        ball =  r*R+g*G  
        
        res = N-ball
        
        if  res >=0  and res%B ==0:
            cnt+=1
    
print(cnt)
            


### FIXED CODE ###

R,G,B,N =map(int,input().split())

cnt =0
    
for r in range(int(N/R)+1):
  ball = N-r*R 
  for g in range(int(ball/G)+1):
    res = N- (r*R+g*G)
    if  res >=0 and res%B ==0:
      cnt+=1
    
print(cnt)
s=str(input())
l=str(input())
count=0
if s[0]=l[0]:
    count+=1
if s[1]=l[1]:
    count+=1
if s[2]=l[2]:
    count+=1
print(count)

### FIXED CODE ###

s=str(input())
l=str(input())
count=0
if s[0]==l[0]:
    count+=1
if s[1]==l[1]:
    count+=1
if s[2]==l[2]:
    count+=1
print(count)
a, b, x = map(int,input().split())
print((b//x-a//x)

### FIXED CODE ###

a, b, x = map(int,input().split())
print(b//x-(a-1)//x)
def get_answer(ki):
    n = int(ki[0].split(" ")[0])
    q = int(ki[0].split(" ")[1])
    n_data = [[int(k[0]), int(k[1])] for k in [k.split(" ") for k in ki[1:-q]]]
    q_data = [[int(k[0]), int(k[1])] for k in [k.split(" ") for k in ki[-q:]]]
    tree = make_tree(n, n_data)
    t_index = make_index(n, tree)

    score = [0] * n

    for qq in q_data:
        index = qq[0]
        #add_score(tree, score, qq, n_data, index)
        s_index = t_index[index - 1]
        for i in s_index:
            score[i] += qq[1]

    score = [str(s) for s in score]
    s = " ".join(score)

    return s


def add_score(tree, score, qq, n_data, index):
    score[index - 1] += qq[1]
    next_index = tree[index -1]
    for n_i in next_index:
        add_score(tree, score, qq, n_data, n_i)


def make_tree(n, n_data):
    r = {}
    for i in range(n):
        r[i] = []
    for n in n_data:
        k = n[0] - 1
        if k in r.keys():
            r[k].append(n[1])
        else:
            r[k] = [n[1]]
    return r


def make_index(n, tree):
    index = {}
    r0 = [0] * n
    for i in range(n):
        r0[i] = i
    index[0] = r0

    for i in range(1, n):
        r = []
        add_index(tree, i, r)
        index[i] = r

    return index


def add_index(tree, index, r):
    r.append(index)
    next_index = tree[index]
    for n_i in next_index:
        add_index(tree, n_i - 1, r)


if __name__ == "__main__":
    input_ki = []
    while True:
        try:
            input1 = input()
            if not input1:
                break;
            if len(input1) == 0:
                break;
            input_ki.append(input1)
        except EOFError:
            break
    print(get_answer(input_ki))


### FIXED CODE ###

import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1): #木グラフの隣接リストを作成
 a,b=map(int,input().split())
 g[a].append(b)
 g[b].append(a)
for _ in range(q): #各頂点についてcount[v]を計算
 v,val=map(int,input().split())
 cnt[v]+=val
q=collections.deque()
q.append(1) #DFSのスタックによる実装、まずスタックに始点1を積む
checked=[0]*(n+1) #各頂点を見たかどうかのフラグを持っておく
while q:
 v=q.pop()
 checked[v]=1 #頂点を見たかどうかのフラグを更新する
 for u in g[v]:
   if checked[u]==1: #vの子ノードuについて、まだ見ていない頂点であればcount[u]をcount[u]+=count[v]として更新する
     continue
   cnt[u]+=cnt[v]
   q.append(u) #スタックに子ノードuを積む
print(*cnt[1:]) #各頂点のcountが答えとなる
N =int(input())
D = []
for i in range(n):
  D.append([])#配列の末尾に空の配列を追加

for i in range(N):
	for j in range(2):
      	D[i][j]=int(input())

for x in range(N-2):
  	if D[x][1]==D[x][2] and D[x+1][1]==D[x+1][2] and D[x+2][1]==D[x+2][2]:
      	print("Yes")
        break
    else:
      	print("No")


### FIXED CODE ###

n = int(input())
ans = "No"
j = 0
for i in range(n):
  d,dd = map(str,input().split())
  if(d==dd):
    j += 1
  else:
    j=0
  if(j>=3):
    ans = "Yes"
print(ans)
a,b,k=map(int,input().split())

a2=a-min(a,k)
if k > a:
    b2=b-min(b,k-a)
print(a2,b2)



### FIXED CODE ###

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

if k <= a:
    a2=a-k
    b2=b
elif k <= a+b:
    a2=0
    b2=b-(k-a)
else:
    a2=0
    b2=0
print(a2,b2)
A,B = int(input().split())
coin = 0
for i in range (2):
  if A>B:
    coin+=A
  else:
    coin+=B
    
print(coin)


### FIXED CODE ###

A,B = input().split()
A= int(A)
B= int(B)
coin = 0
for i in range (2):
  if A>B:
    coin += A
    A-=1
  else:
    coin += B
    B-=1
    
print(coin)
a,b = int(input())
#lis = list(map(int,input().split()))
if a<b:
    print(0)
else:
    print(0)


### FIXED CODE ###

a,b = map(int,input().split())
#lis = list(map(int,input().split()))
if a<b:
    print("0")
else:
    print("10")
n = int(input())
max = -10000000
min = 100000000
sum = 0
a = input().split()
for i in range(0,n):
 sum += a[i]
 if int(a[i]) >= max: max = a[i]
 if int(a[i]) <= min: min = a[i]

print(min,max,sum)


### FIXED CODE ###

n = int(input())
a = sorted([int(x) for x in input().split()])
print(a[0],a[-1],sum(a))
n = int(input())
a = list(map(int, input().split()))

print(*a[::-2], *a[n%2::2])

### FIXED CODE ###

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

print(*a[::-2], end=" ")
print(*a[n%2::2])
a, b, x = [int(i) for i in input().split()]
for i in range(1,10):
  n = (x-b*i)/float(a)
  if n<0:
    if i==9:
      print(0)
    continue
  if len(str(int(n)))==i:
    print(int(n))
    break
  elif i==9:
    print(10**9)

### FIXED CODE ###

s = str(input())
lst = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

print(7-int(lst.index(s)))
import sympy
S = int(input("入力："))

divisors = sympy.divisors(S)
#print(divisors)
n = len(divisors)

for i in range(int(n / 2+n % 2)):
    #print(divisors[i])
    if S // divisors[i] <= 9:
        result ="Yes"
    else:
        result ="No"
print(result)

### FIXED CODE ###

S = int(input())

for i in range(9) :
    i = i + 1
           
    if S % i == 0 and S // i <= 9:
        result = "Yes"
        break
    else :
        result = "No"
print(result)
from sys import stdin
X,Y,A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
Q = [int(x) for x in stdin.readline().rstrip().split()]
R = [int(x) for x in stdin.readline().rstrip().split()]

P.sort()
Q.sort()
R.sort()

P = [0]*(10**5) + P[A-X:]
Q = [0]*(10**5) + Q[B-Y:]
R = [0]*(10**5) + R

ans = 0
while True:
    if P[-1] > Q[-1]:
        if P[-1] > R[-1]:
            ans += P.pop()
        else:
            ans += R.pop()
        X -= 1
    else:
        if Q[-1] > R[-1]:
            ans += Q.pop()
        else:
            ans += R.pop()
        Y -= 1
    if X == 0 and Y == 0:
        break
print(ans)

### FIXED CODE ###

from sys import stdin
X,Y,A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
Q = [int(x) for x in stdin.readline().rstrip().split()]
R = [int(x) for x in stdin.readline().rstrip().split()]

P.sort(reverse=True)
Q.sort(reverse=True)

res = P[:X] + Q[:Y] + R
res.sort(reverse=True)

print(sum(res[:X+Y]))
n = int(input())
a = list(map(int,input().split()))
cnt = 0

def ers(a,cnt):
    if len(a) == 0:
        cnt = -1
        return cnt
    for i in range(len(a)):
        if i+1 != a[i]:
            a.pop(i)
            cnt+=1
            return ers(a,cnt)
    return cnt

res = ers(a,cnt)

print(str(res))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if A[i] != i+1-cnt:
        cnt += 1
if cnt == N:
    print(-1)
else:
    print(cnt)
n, m = map(int, input().split())
l = list(map(int, input().split()))
a = sum(l)
s = a / (4*m)
l.sort(reverse = True)
if l[m-1] < s:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

x, y, z = map(int, input().split())
print('{} {} {}'.format(z, x, y))
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
import decimal
from decimal import Decimal
decimal.getcontext().prec = 10
 
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 
 
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)
 
# ---------------------------------------
 
n = inp()
cnt = 0
mx = 0
for i in range(n):
    d1, d2 = inpl()
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    mx = max(mx, cnt)
 
if mx >= 3:
    print("Yes")
else:
    print("No")
 

### FIXED CODE ###

s = input()
if s[-1] == "s":
    s += "es"
else:
    s += "s"
print(s)
print('Odd' if eval(input().replace(' ','*') else 'Even')

### FIXED CODE ###

print('Odd' if eval(input().replace(' ','*'))%2!=0 else 'Even')
s=list(input())
k=int(input())
A,B,C=0,0,0
test=s*3
for i in range(len(s)*3-1):
    if test[i]==test[i+1]:
        test[i+1]="A"
A=test[:len(s)].count("A")
B=test[len(s):len(s)*2].count("A")
C=test[len(s)*2:len(s)*3].count("A")

flag=0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        flag=1
        break
if flag==0:print((s*k+1)//2)
if k==1:print(A)
elif k==2:print(A+B)
else:
    print(A+B*(k-2)+C)


### FIXED CODE ###

s=list(input())
k=int(input())
A,B,C=0,0,0
test=s*3
for i in range(len(s)*3-1):
    if test[i]==test[i+1]:
        test[i+1]="A"
A=test[:len(s)].count("A")
B=test[len(s):len(s)*2].count("A")
C=test[len(s)*2:len(s)*3].count("A")

if s.count(s[0])==len(s):
    print((len(s)*k)//2)
else:
    if k==1:print(A)
    elif k==2:print(A+B)
    else:print(A+B*(k-2)+C)
N = int(input())
a, b, bxxa, ab = 0, 0, 0, 0

for i in range(N):
    s = input()
    if s[-1] == 'A':
        a += 1
    if s[0] == 'B':
        b +=1
    if s[0]=='B' and s[-1]=='A'
        bxxa += 1 
    ab += s.count('AB')

if a>b :
    print(ab+b)
elif a==b and bxxa==a:
    print(ab+a-1)
else: 
    print(ab+a)

### FIXED CODE ###

N = int(input())
a, b, bxxa, ab = 0, 0, 0, 0

for i in range(N):
    s = input()
    if s[-1] == 'A':
        a += 1
    if s[0] == 'B':
        b += 1
    if s[0]=='B' and s[-1]=='A':
        bxxa += 1 
    ab += s.count('AB')

if a>b :
    print(ab+b)
elif a!=0 and a==b and bxxa==a:
    print(ab+a-1)
else: 
    print(ab+a)
def main():
    _ = int(input())
    a = tuple(map(int, input().split()))

    res = 0
    for i in a:
        res ^= i
    ans = [res ^ j for j in a]
    for k in ans:
        print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

from functools import reduce

n = int(input())
a = tuple(map(int, input().split()))

res = reduce(lambda x, y: x ^ y, a)
ans = [res ^ i for i in a]
print(*ans)
#coding: utf-8
 
s = input().split()
if s[0]>s[1]:
  for i in range(s[0]):
  	print(str(s[1]),end='')
else:
  for i in range(s[1]):
  	print(str(s[0]),end='')

### FIXED CODE ###

#coding: utf-8
 
s = input().split()
if s[0]==s[1]:
  print('Yes')
else:
  print('No')
ks = input()
count = 0
k, s = [int(x) for x in sk.split(" ")]
count = 0
for i in range(min(k+1, s + 2)):
    for j in range(i + 1, s + 2):
        x = i
        y = j - i - 1
        z = s - y - x
        if x <= k and y <= k and z <= k:
            count += 1
print(count)

### FIXED CODE ###

ks = input()
k, s = [int(x) for x in ks.split(" ")]
comb = []
for x in range(min(k,s) + 1)[::-1]:
    for y in range(min(x + 1, s - x + 1))[::-1]:
        z = s - x - y
        if (x <= k and y <= k and z <= k and y <= x and z <= y):
            comb.append([x,y,z])
count = 0
for c in comb:
    l = len(set(c))
    if l == 1:
        count += 1
    elif l == 2:
        count += 3
    else:
        count += 6
print(count)
#include <iostream>
using namespace std;

int main(){
 int a,b;
 cin >> a >> b;
 if(a <= 9 && b <= 9){
  cout << a * b << endl;
 }else{
  cout << -1 << endl;
 }
 return 0;
}



### FIXED CODE ###


a,b = map(int,input().split())
if a <=9 and b <=9:
 print(a*b)
else:
 print(-1)
# -*- coding: utf-8 -*-
N=int(input())
for i in range(N+1):
  s+=i
print(s)

### FIXED CODE ###

# -*- coding: utf-8 -*-
N=int(input())
s=0
for i in range(N+1):
    s += i
print(s)
a,b=map(float,input().split())
a=int(a)
print(math.trunc(a*b))

### FIXED CODE ###

a,b=map(float,input().split())
a=int(a)
print((round(b*100)*a)//100)