peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
A=[int(input()) for i in range(n)]
data=collections.deque()
for i, ai in enumerate(A):
    k=bisect.bisect_left(data,ai)
    if k==0:
        data.appendleft(ai)
    else:
        data[k-1]=ai
print(len(data))
# Judge status: Accepted
try:
    N = int(input())
    min_ = 99999
    for a in range(N):
        b = N-a
        if b>0 and a>0:
            j = sum(map(int, str(a)))
            i = sum(map(int, str(b)))
            _ = i + j
            if _<min_:
                min_ = _
    print(min_)
except EOFError:
    pass
# Judge status: Accepted
S = list(map(int,list(input())))
K = int(input())
for i in range(K):
    if S[i] == 1:
        continue
    else:
        print(S[i])
        exit(0)
print(1)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = []
sb = []
for i in range(n):
    sa.append(a[i] + (0 if i==0 else sa[i-1]))
    sb.append(b[i] + (0 if i==0 else sb[i-1]))
ans = 0
for i in range(n+1):
    k = (0 if i==0 else sa[i-1] - sb[i-1] + b[i-1])
    tmp = sb[n-1] + k
    ans = max(tmp, ans)
print(ans)
# Judge status: Wrong Answer
A=list(input().split())
for i in range(110):
    if int(A[0]+A[1])==i**2:
        ans='Yes'
        break
    else:
        ans='No'
print(ans)
# Judge status: Accepted
import math
n=int(input())
if n==4:
    print(2)
elif n<=5:
    print(n-1)
else:
    ans=n-1
    for i in range(math.floor(n**0.5),1,-1):
        if n%i==0:
            ans=i+n//i-2
            break
    print(ans)
# Judge status: Accepted
A,B = sorted(map(int,input().split()))

if A==B:
  print(2*B)
else:
  print(2*B-1)
# Judge status: Wrong Answer
n = int(input())
a = list(input())
xlist = []
x = 0
for i in range(n):
  if a[i]=="D":
    x-=1
  elif a[i]=="I":
    x+=1
  xlist.append(x)
print(max(xlist))
# Judge status: Accepted
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()

def main():
    N, K = map(int, input().split())
    D = set(map(int, input().split()))
    while True:
        check = True
        for c in str(N):
            if int(c) in D:
                check = False
        if check:
            print(N)
            return
        N += 1


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n,m = map(int, input().split())
ans = [None] *n
f= 0
for i in range(m):
    s,c = map(int, input().split())
    if (ans[s-1] != None) and (ans[s-1] != c):  # 重複
        f = 1
    ans[s-1] = c

if f == 1:
    print('-1')
    exit()
elif ans[0] == None:
    ans[0] == 1
elif ans[0] == 0 and len(ans) != 1:
    print('-1')
    exit()

for i in range(n):
    if ans[i] == None:
        ans[i] = 0
print(''.join(map(str, ans)))
# Judge status: Accepted
n,a,b = map(int,input().split())

ans = (n // (a + b)) * a
temp = n%(a+b)
ans += min(temp,a)
print(ans)
# Judge status: Accepted
S = input()
for i in range(2, len(S), 2):
    if S[:(len(S)-i)//2] == S[(len(S)-i)//2:len(S)-i]:
        print(len(S)-i)
        exit()
# Judge status: Accepted
S = input()
N = len(S)
left = S[:int((N-1)/2)]
right = S[int((N+3)/2)-1:]

if S != S[::-1]:
  print("No")
  exit()
if left != left[::-1]:
  print("No")
  exit()
if right != right[::-1]:
  print("No")
  exit()
print("Yes")
# Judge status: Wrong Answer
I=int(input())

print(int(I/2))
# Judge status: Wrong Answer
yes = lambda boolean: print('YES') if boolean else print('NO')
input_ints = lambda: list(map(int, input().split()))
yes(input_ints().sort() == [5,5,7])
# Judge status: Accepted
N, K = map(int, input().split())

D = N%K
print(min([abs(D-K), D]))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
aabs = [i if i>=0 else i*(-1) for i in a]
MIN = min(aabs)
ans = 0
mcount = 0

for i in range(n):
  if a[i] < 0:
    mcount += 1
    
if mcount%2 == 0:
  for i in a:
    ans += abs(i)
  print(ans)
else:
  for i in a:
    ans += abs(i)
  print(ans - 2*MIN)
# Judge status: Accepted
import sys
input = sys.stdin.readline

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

res = [0]
for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        res[-1] += 1
    else:
        res.append(0)
print(min(sum(res) + 2 * m, n - 1))
# Judge status: Accepted
N = int(input())
check = 0
for i in range(1,N+1):
  count = 0
  for j in range(1,i+1):
    if i%j == 0:
      count += 1
  if i%2 == 1 and count == 8:
    check += 1
print(check)
# Judge status: Accepted
def main():
    d,n = map(int, input().split())
    if n == 100:
        print((100**d) * (n+1)) 
    else:
        print((100**d) * n)  
if __name__ == '__main__':
    main()
# Judge status: Accepted
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-x-y<=k:
            ans+=1
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
Y = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
  ans = 10**10
  ansIndex = -1
  for j in range(M):
    tmp = abs(X[i][0]-Y[j][0])+abs(X[i][1]-Y[j][1])
    if tmp < ans:
      ans = tmp
      ansIndex = j
  print(ansIndex+1)
# Judge status: Accepted
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n, m = MII()
    food = set(MII()[1:])
    for i in range(n-1):
        a = MII()[1:]
        food &= set(a)
    print(len(food))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import itertools

s = int(input())
numbers = [i for i in range(3, s+1)]

ans = []
for i in range(len(numbers)):
    ans += [x for x in itertools.permutations(numbers, i) if sum(x) == s]

print(len(ans))
# Judge status: Accepted
h,n=map(int,input().split())
a,b=[],[]
for i in range(n):
    A,B=map(int,input().split())
    a.append(A)#ダメージ量
    b.append(B)#消費魔力

dp=[float('inf')]*(h+1)
dp[0]=0
for i in range(h):
    for j in range(n):

        next=i+a[j] if i+a[j]<=h else h
        dp[next]=min(dp[next],dp[i]+b[j])
print(dp[-1])
# Judge status: Accepted
N, A, B = map(int, input().split())

c = A + B
p, q = divmod(N, c)
ans = A * (N // c)

if q >= 1:
    if q > A:
        ans += A
    else:
        ans += q

print(ans)
# Judge status: Wrong Answer
k,x=map(int,input().split())

l=0
r=0

if x-(k-1)<-1000000:
  l=-1000000

if x-(k-1)>=-1000000:
  l=x-(k-1)

if x+(k-1)>1000000:
  r=1000000

if x+(k-1)<=1000000:
  r=x+(k-1)

print(l)
print(r)

ans=list(range(l,r+1))
s=' '.join([str(n) for n in ans])
print(s)
# Judge status: Accepted
n = int(input())
a =[0]*10001

for x in range(1,100,1):
    for y in range(1,100,1):
        for z in range(1,100,1):
            i = x*x+y*y+z*z+x*y+y*z+z*x
            if i <=10000:
                a[i]=a[i]+1
for i in range(1,n+1,1):
    print(a[i])
# Judge status: Accepted
f = lambda x, y, z: (x + y + z) ** 2 - x * y - y * z - z * x - 1

n = int(input())
a = [0] * n
z = 1
while f(1, 1, z) < n:
  y = 1
  while f(1, y, z) < n:
    x = 1
    while f(x, y, z) < n:
      a[f(x, y, z)] += 1
      x += 1
    y += 1
  z += 1
print(*a, sep='\n')
# Judge status: Accepted
N,M,Q = map(int,input().split())
ABCD = [tuple(map(int,input().split())) for i in range(Q)]
import itertools
ans = 0
for ptn in itertools.combinations_with_replacement(range(1,M+1), N):
    tmp = 0
    for a,b,c,d in ABCD:
        if ptn[b-1] - ptn[a-1] == c:
            tmp += d
    ans = max(ans,tmp)
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())

tmp=set([a,b,c])
if len(tmp)==1:
  print('No')
elif len(tmp)==2:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
answerA = int(input())
answerB = int(input())
print(6 - answerA - answerB)
# Judge status: Accepted
n = int(input())
ls = []
alphabet = [chr(i) for i in range(97, 97+26)]
alphabet_dict = {}
for i, a in enumerate(alphabet):
    alphabet_dict[a] = i
def dfs(A):
    if len(A) == n:
        ls.append(A)
        return
    Max = 0
    for i in range(len(A)):
        Max = max(Max,alphabet_dict[A[i]])
    for i in range(Max+2):
        A += alphabet[i]
        dfs(A)
        A = A[:-1]
dfs('a')
ls.sort()
for i in range(len(ls)):
    print(ls[i])
# Judge status: Wrong Answer
s = input()
L = "ACGT"
ans = ""
ss = ""
for i in range(len(s)):
  if s[i] in L:
    ans += s[i]
    #print(ans,ss)
  else:
    if len(ans)>len(ss):
      
      ss = ans
      ans = ""
print(len(ss))
# Judge status: Wrong Answer
# 二分探索で行いたい
N, M = [int(i) for i in input().split()]

low = 0
high =  M // 2

if N * 2 > M / 2:
    output = N
else :
    while abs(low-high) > 1:
        mid = (low+high) // 2
        guess_n = N + mid
        guess_m = M-(2 * mid)
        if guess_n > guess_m // 2 :
            high = mid
        else :
            low = mid

    output = low + N
    
print(output)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
M=0
P=0
for i in range(N):
  P+=max(0,M-A[i])
  M=max(M,A[i])
print(P)
# Judge status: Accepted
a,b=map(int,input().split())
if a==1 and b==13:
  print("Alice")
elif a==13 and b==1:
  print("Bob")
elif a<b:
  print("Bob")
elif a>b:
  print("Alice")
else:
  print("Draw")
# Judge status: Wrong Answer
import math

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

if n == k:
    print(1)
    exit()

idx = a.index(1)
print(math.ceil(idx / (k-1)) + math.ceil((n - idx - 1) / (k-1)))
# Judge status: Accepted
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])
ans = 1
first = T[0]
pas = 0
for t in T:
    pas += 1
    if t > first + k or pas > c:
        ans += 1
        pas = 1
        first = t
print(ans)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

if max(b-a,c-d) > d or (c-a) > d:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
from collections import defaultdict


N = int(input())
counter = defaultdict(int)
for a in map(int, input().split()):
    if a % 4 == 0:
        counter[2] += 1
    elif a % 2 == 0:
        counter[1] += 1
    else:
        counter[0] += 1
if counter[1] == 0:
    print('Yes') if counter[0] <= counter[2] + 1 else print('No')
else:
    print('Yes') if counter[0] <= counter[2] else print('No')
# Judge status: Accepted
H = int(input())

ans = 0
cnt = 0
while 0 != H:
    H = H // 2
    ans += 2**cnt
    cnt += 1

print(ans)
# Judge status: Wrong Answer
import sys
n = int(input())
s = sys.stdin.readlines()
s[n-1] += "\n"
print(len(set(s)))
# Judge status: Accepted
a, b = list(map(int, input().split()))

if a * b <= 0:
    print('Zero')

elif a > 0:
    print('Positive')

elif (a-b) % 2 == 0:
    print('Negative')

elif (a-b) % 2 == 1:
    print('Positive')
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

cnt = 1
ans = a[0]

for i in range(1, n):
    cnt += 1
    ans += a[i]
    if cnt == n - 1:
        break
    else:
        cnt += 1
        ans += a[i]
    if cnt == n - 1:
        break

print(ans)
# Judge status: Wrong Answer
N = int(input())

print("ABC{:03}".format(N)) if N//1000!=1 else print("ABD{:03}".format(N%1000 + N//1000))
# Judge status: Wrong Answer
n,k = map(int,input().split())
h = list(map(int,input().split()))
if n <= k:
    print(0)
else:
    h.sort()
    print(sum(h[:-k]))
# Judge status: Accepted
import math
N = int(input())
print(math.factorial(N)%(10**9+7))
# Judge status: Accepted
N = int(input())
dp = [0] * 100500

import math
dp[1] = 1
for i in range(2, N+1):
    dp[i] = dp[i-1] + 1
    for j in range(math.floor(math.log(i, 6)) + 1):
        dp[i] = min(dp[i], dp[i - 6 ** j] + 1)
    for k in range(math.floor(math.log(i, 9) + 0.00000001) + 1):
        dp[i] = min(dp[i], dp[i - 9 ** k] + 1)


print(dp[N])
# Judge status: Accepted
if int(input())>=30:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s=input()
for i in range(97,123):
  if not chr(i) in s:
    print(chr(i))
    break
else:
  print('NONE')
# Judge status: Accepted
def main():
    n, max_t = map(int, input().split())
    max_val = 10 ** 9 + 7
    answer = max_val
    for _ in range(n):
        c, t = map(int, input().split())
        if t <= max_t:
            answer = min(answer, c)
    print(answer if answer != max_val else "TLE")


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
t, a = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

l = [abs(a-(t-i*0.006)) for i in h]
print(l.index(min(l))+1)
# Judge status: Accepted
def main():
    s = str(input())
    if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
        print('Bad')
    else:
        print('Good')
            
main()
# Judge status: Wrong Answer
def main():
    N, A, B = map(int, input().split())
    if A % 2 == B % 2:
        return abs(A - B)//2
    else:
        return min(max((N-A), (N-B)), max((A-1), (B-1)))
print(main())
# Judge status: Wrong Answer
N=int(input())
for a in range(1,9):
  for b in range(1,9):
    if a*b==N:
      print('Yes')
      exit()
print('No')
# Judge status: Accepted
s = input()
ans = [0]*(len(s)+1)

for i in range(len(s)):
    if s[i] == '<':
        ans[i+1] = ans[i] + 1
for i in range(len(s)-1,-1,-1):
    if s[i] == '>':
        ans[i] = max(ans[i], ans[i+1] + 1)
print(sum(ans))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
point = b[a[0]-1]
for i in range(1, n):
    point += b[a[i]-1]
    if a[i] - a[i-1] == 1:
        point += c[a[i-1]-1]

print(point)
# Judge status: Wrong Answer
s = input()
#import sys
#s = '1222'
n = len(s)
for i in range(2**(n-1)):
  #print(i)
  f = ''
  b = format(i, 'b').ljust(n,'0')
  #print(b)
  for j in range(n):
    f += s[j]
    if b[j] == '0':
      f += '-'
    else:
      f += '+'
  f = f[:len(f)-1]
  #print(f)
  if eval(f) == 7:
    print(f+'=7')
    break
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
w = 1
s = 0
for i in range(n):
    if (a[i] == w):
        w += 1
        s = 1
if (s == 0):
    print(-1)
else:
    print(n-w+1)
# Judge status: Accepted
n,a,b = map(int,input().split())
s = input()
m = 0
b_rank = 0
for i in s:
    if i=="a" and m<a+b:
        m+=1
        print("Yes")
    elif i=="b" and m<a+b and b_rank+1<=b:
        b_rank+=1
        m+=1
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
d, t, s = map(int, input().split())
if (d/s <= t):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
import statistics
import math
n = int(input())
a = list(map(int,input().split()))
ans = 0
a_avr = math.ceil((statistics.mean(a)))
for i in range(n):
  ans += (a[i] - a_avr)**2
print(ans)
# Judge status: Wrong Answer
A, B, C = map(int, raw_input() .split())
if C >= A or C <= B:
    print "Yes"
else:
    print "No"
# Judge status: Accepted
def main():
    n = int(input())
    s = [int(input()) for _ in range(n)]
      
    ans = sum(s)
    if ans % 10 != 0:
        print(ans)
    else:
        a = 10**9
        for ss in s:
            if ss % 10 != 0:
                a = min(a, ss)
        if a!=10**9:
            print(ans - a)
        else:
            print(0)
    
if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

result = 0
for bit in range(60):
    m = 1 << bit
    c = sum(a & m for a in A) >> bit
    result += (c * (N - c)) << bit
    result %= 1000000007
print(result)
# Judge status: Accepted
import sys
n = int(input())

ans = float("inf")
flag = 0
for i in range(2,int(n**(1/2))+1):
  if n%i == 0:
    ans = min(ans, i+(n//i)-2)
    flag = 1

if flag:
  print(ans)
else:
  print(n-1)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
  a[i] -= i + 1
a = sorted(a)
med = a[n // 2]
ans = 0
for x in a:
  ans += abs(x - med)
print(ans)
# Judge status: Wrong Answer
import sys
N,M,X=map(int,input().split())
L=[list(map(int,input().split())) for i in range(N)]
#print(L)
price=[]
list_X=[X for i in range(M-1)]
for i in range(2**N):
  A=[0 for i in range(M+1)]
  for j in range(N):
    if (i>>j) & 1:
      A = [x+y for (x,y) in zip(A,L[j])] 
  #print(A)
  if A[1:] >= list_X:
    price.append(A[0])
#print(price)
if price ==[]:
  print(-1)
else:
  print(min(price))
# Judge status: Wrong Answer
n,h=map(int,input().split())
ab=[]
ans=0
for i in range(n):
  aa,bb=map(int,input().split())
  ab.append([aa,bb])

ab.sort(key=lambda x: x[0],reverse=True)
katana=ab[0][0]
ab.sort(key=lambda x: x[1],reverse=True)
cnt=0
# print(ab)
for a,b in ab:
  if b>=katana:
    cnt+=1

for i in range(cnt):
  if h<0:break
  h-=ab[i][1]
  ans+=1
if h>0:
  from math import ceil
  ans+=ceil(h/katana)
  print(ans)
else:
  print(ans)
# Judge status: Accepted
import fractions
import math
A,B = map(int,input().split())

g = fractions.gcd(A,B)
h = math.floor(math.sqrt(g))
D = {1:1}
for i in range(2,h+1):
    while g%i == 0:
        D[i] = D.get(i,0) + 1
        g //= i
    if g == 1:
        break
if g > 1:
    D[g] = D.get(g,0) + 1

print(len(D))
# Judge status: Accepted
from collections import deque
s=deque(input())
q=int(input())
flag = True

for i in range(q):
    query=input().split()
    if query[0] == "1":
        flag = not flag
    elif query[1] == "1" and flag or query[1] == "2" and not flag :
         s.appendleft(query[2])
    else:
        s.append(query[2])

if not flag:
    s.reverse()

print("".join(s))
# Judge status: Wrong Answer
# coding: utf-8
a, b, c, k = map(int, input().split())
x = 0

x += a
k -= a
if k <= b:
    print(x)
else:
    k -= b
    x -= k
    print(x)
# Judge status: Accepted
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, c = rm()
print('Yes' if a+b >= c else 'No')
# Judge status: Accepted
data=input()
n=int(data[:2])
m=int(data[2:])
if 1<=n<=12:
    if 1<=m<=12:
        print("ambiguous".upper())
        exit()
    else:
        print("MMYY")
        exit()
if 1<=m<13:
    print("YYMM")
    exit()
print("NA")
# Judge status: Wrong Answer
# 27

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

for i in range(len(a)):
    if i != len(a) - 1:
        if x >= a[i] :
            num += 1
            x -= a[i]
    elif x == a[i]:
        num += 1

print(num)
# Judge status: Wrong Answer
n=int(input())
l,r=0,10**9
while l+1!=r:
    m=(l+r)/2
    if m*(m+1)//2==n:
        print(m)
        exit()
    elif m*(m+1)//2>n:
        r=m
    else:
        l=m
print(r)
# Judge status: Wrong Answer
N = int(input())
dp = [[0]*2 for i in range(N + 1)]


for i in range(1,N + 1):
    P = int(input())
    dp[i][False] = max(dp[i-1])
    dp[i][True] = max(dp[i-1][False] + P,dp[i-1][True] + P)

print(max(list(map(lambda x:x if x % 10 != 0 else 0,dp[-1]))))
# Judge status: Wrong Answer
lst = [input() for i in range(2)]

n = int(lst[0])
s = lst[1]

if n % 2 == 1:
    print('NO')

t = ''

for i in range(0, n//2):
    t += s[i]

if t + t == s:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
# 文字列を取得
C1 = str(input())
C2 = str(input())

# 文字列の結合
ori_str = C1 + C2

# 末尾から１文字ずつ取得して逆さま文字を生成
rev_str = ori_str[-1::-1]

# 比較結果を出力
if ori_str == rev_str:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N = int(input())
s = input()
t = input()
ans = 2*N
for i in range(N):
  ss = s[i:N]
  tt = t[0:N-i]
  if (ss == tt):
    ans = N+i
    break
print(ans)
# Judge status: Wrong Answer
i = int(input())
ans = 0
for ii in range(1,i):
	for p in range(2,i):
		if ii == (p*p):
			ans = ii
	
print(ans)
# Judge status: Accepted
#n=int(input())
n,k=map(int,input().split())
#t=int(input())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

arrived={i:False for i in range(1,n+1)}
#arrived[1]=True
city=[]
before=1
while True:
    nxt=al[before-1]
    if arrived[nxt]:
        break
    arrived[nxt]=True
    city.append(nxt)
    before=nxt
ind=city.index(nxt)
loop=city[ind:]
if k<=ind:
    ans=city[k-1]
else:
    k-=ind
    ans=loop[k%len(loop)-1]
print(ans)
# Judge status: Accepted
S, T = input().split()
u    = str(T) + str(S)
print(u)
# Judge status: Accepted
x,y=map(int,input().split())
count=1
while x*2<=y:
  count+=1
  x*=2
print(count)
# Judge status: Wrong Answer
A = int(input())
B = int(input())

if A == 1 and B == 2:
  print(3)
elif A == 2 and B == 3:
  print(1)
else:
  print(2)
# Judge status: Wrong Answer
# coding: utf-8
S = input()
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        print('no')
        exit()
else:
    print('yes')
# Judge status: Accepted
try:
    from math import gcd
except ImportError:
    from fractions import gcd

x=int(input())

print(360//gcd(x,360))
# Judge status: Accepted
k,a,b = [int(x) for x in input().split()]

l = k - (a - 1)

tmp = a + (b-a) * (l//2) + (l%2)
print(max(k+1, tmp))
# Judge status: Accepted
a,b = map(str,input().split())
if int(a+b)**0.5%1 == 0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
P = [i for i in input().split()]
Q = [i for i in input().split()]

Z = ['1','2','3','4','5','6','7','8']

X = Z[:N]

from itertools import permutations

A=[]
for l in list(permutations(X)):
  a = "".join(l)
  A.append(a)

# print(A)

p = "".join(P)
q = "".join(Q)

a = A.index(p)
b = A.index(q)

print( abs(a-b) )
# Judge status: Wrong Answer
N,M,X = map(int, input().split())
A = [list(map(int, input().split(" "))) for i in range(N)]

MOD = 10**9+7
a = [0]*M
value = [0]
ans = MOD

for i in range(2**N):
    if min(a) >= X :
        ans = min(ans,sum(value))
    a = [0]*M
    value = []
    for j in range(M+1):
        if(i >> j) & 1:
            for k in range(M):
                a[k] += A[j][k+1]
            value.append(A[j][0])
print(-1 if ans == MOD else ans)
# Judge status: Accepted
S = int(input())
import math

if S == 10**18:
    print(0,0,10**9,0,0,10**9)
else:
    Y3 = S // 10**9 + 1
    X3 = 10**9 - S % 10**9

    print(0,0,10**9,1,X3,Y3)
# Judge status: Accepted
A,B,C = map(int, input().split())
for i in range(B):
    if (i*(A%B))%B==C:
        print('YES')
        exit()
print('NO')
# Judge status: Wrong Answer
n = int(input())
min = 100
a_sum = 0
b_sum = 0

for a in range(1, n):
  b = n-a
  while a >= 1:
    a_sum += a%10
    a = a//10
  
  while b >= 1:
    b_sum += b%10
    b = b//10
  
  if a_sum + b_sum < min:
    min = a_sum + b_sum

print(min)
# Judge status: Accepted
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n):
	k -= a[i]
	if k >= 0:
		cnt += 1
	else:
		break
if k > 0:
	cnt -= 1

print(cnt)
# Judge status: Wrong Answer
_ = input()
a = [int(x) for x in input().split()]

b = sorted(set(a))
b.reverse()
ans = 1
cnt = 0
for i in b:
    c = a.count(i)
    if 4 <= c:
        print(i ** 2)
        break
    elif 2 <= c:
        if cnt == 0:
            ans *= i
            cnt += 1
        else:
            print(ans * i)
            break
else:
    print(0)
# Judge status: Wrong Answer
P,Q,R = map(int,input().split())
print(min(R+Q,Q+R,R+P))
# Judge status: Accepted
A, B, C = map(int, input().split())

rest = C - (A - B)

if rest > 0:
    print(rest)
else:
    print('0')
# Judge status: Wrong Answer
n=int(input())
dp=[float("inf")]*(n+1)
dp[0]=0
for i in range(n-1):
    for j in range(1,7):
        j=6**j
        if i+j<n:
            dp[i+j]=min(dp[i+j],dp[i]+1)
    for j in range(1,6):
        j=9**j
        if i+j<n:
            dp[i+j]=min(dp[i+j],dp[i]+1)
    dp[i+1]=min(dp[i+1],dp[i]+1)
    

print(dp[-1])
# Judge status: Accepted
a,b,x = map(int,input().split())
x /= a
import math
PI = math.pi
if x > a*b//2:
    print("{:.10}".format(math.atan2((a*b-x)*2, a*a)*180/PI))
else:
    print("{:.10}".format(math.atan2(b*b,x*2)*180/PI))
# Judge status: Wrong Answer
a,b = map(int, input().split())
if a <= 1 and a <= 9 and b <= 1 and b <= 9:
    print(a*b)
else:
    print(-1)