peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
S = list(map(str, input()))
flg = 1

if S[0] != "A":
	flg = 0

ctr = 0
for i in range(2, len(S) - 1):
	if S[i] == "C":
		ctr += 1
if ctr != 1:
	flg = 0

ctr = 0	
for s in S:
	if ord(s) <= 90:
		ctr += 1
if ctr != 2:
	flg = 0
	
	
if flg:
	print("AC")
else:
	print("WA")
# Judge status: Accepted
N=int(input())
mylist=[]
j=0
n=0
for i in range(N):
  mylist.append(int(input()))
  
for i in range(N):
  if n==1:
    print(j)
    break
  j=j+1
  n=mylist[n]-1
  if i==N-1:
  	print("-1")
# Judge status: Accepted
a,b=[int(x) for x in input().split()]

ans=max(a+b,2*a-1,2*b-1)

print(ans)
# Judge status: Wrong Answer
a, b = input().split()
print(int(round(int(a)*float(b)-0.5,0)))
# Judge status: Accepted
import fractions
n=int(input())
a=1
for i in range(n):
  b=int(input())
  a=a*b//fractions.gcd(a,b)
print(a)
# Judge status: Wrong Answer
from numpy import *
N,W=map(int,input().split())
dp=zeros(W+1)
for i in range(N):
    w,v=map(int,input().split())
    dp[w:]=maximum(dp[:-w]+v,dp[w:])
print(dp[-1])
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
X = int(input())

N=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50==X:
                N+=1

print(N)
# Judge status: Accepted
def main():
    N = int(input())
    P = list(map(int, input().split()))

    ans = 0
    tmp = N + 1
    for p in P:
        if tmp > p:
            ans += 1
            tmp = p
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import math
n, m = map(int, input().split())
mod = 10 ** 9 + 7

if n == m:
  res = 2 * math.factorial(n) * math.factorial(m)
  print(res % mod)
elif abs(n - m) == 1:
  res = math.factorial(n) * math.factorial(m)
  print(res % mod)  
else:
  print(0)
# Judge status: Wrong Answer
ABC = input().split()
print('YES' if ABC.count('5') == 2 and ABC.count('7') ==1  else 'N0')
# Judge status: Accepted
n = list(input())

if n[0] != '9':
    if n.count('9') != len(n)-1:
        n[0] = str(int(n[0])-1)
        for i in range(1, len(n)):
            n[i] = '9'

else:
    for i in range(len(n)-1):
        if n[i+1] != '9':
            n[i] = str(int(n[i])-1)
            for j in range(i+1, len(n)):
                n[j] = '9'

ans = 0
for i in range(len(n)):
    ans += int(n[i])
print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = float('inf')
for l in range(K):
    r = l + K - 1
    if l>=N-1 or r>=N-1:
        continue
    tmp_1 = abs(x[l]) + abs(x[r]-x[l])
    tmp_2 = abs(x[r]) + abs(x[r]-x[l])
    tmp = min(tmp_1,tmp_2)
    ans = min(ans,tmp)
print(ans)
# Judge status: Accepted
n = int(input())
listA = list(map(int, input().split()))
count = 0
isBroken = False


while True:
    for i in range(n):
        if listA[i] % 2 == 0:
            listA[i] //= 2
        else:
          isBroken = True
          break
    if isBroken:
        break
    else:
        count += 1


print(count)
# Judge status: Accepted
from math import *
n=int(input())
l=list(map(int,input().split()))
s=ceil(sum(l)/n)
ss=s-1
c=0
x=0
for i in range(n):
    c+=(s-l[i])**2
for i in range(n):
    x+=(ss-l[i])**2
print(min(c,x))
# Judge status: Wrong Answer
a,b=map(int,input().split())

if (a+b)%3==0:
    print("Possible")
else:
    print("Imposible")
# Judge status: Wrong Answer
import collections
n = int(input())
a = list(map(int,input().split()))

c = collections.Counter(a)

comon = c.most_common()
ans = 0
for i in comon:
  if i[1] != 1:
  	ans += (i[1]*(i[1]-1)//2)
  
for i in a:
    for j in comon:
      if i == j[0]:
        co = j[1]
        break
    if co == 1:
      print(0)
    else:
      print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))
# Judge status: Accepted
a, b = map(int, input().split())

if max(a,b)<=9:
  print(a*b)
else:
  print(-1)
# Judge status: Accepted
a, b, c = map(int, input().split())

if a + b < c:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
n=int(input())
ans=10e6
for a in range(2,n+1):
    b=n-a
    ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)]))
print(ans)
# Judge status: Accepted
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

A = []
B = []

for _ in range(M):
    a,b = map(int, input().split())
    if a == 1: A.append(b)
    elif b == N: B.append(a)

B.sort()
for a in A:
    if bisect.bisect_left(B, a) < len(B) and B[bisect.bisect_left(B, a)]==a:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
# Judge status: Accepted
a, b = map(int, input().split())

if a > b:
    print(str(b)*a)
else:
    print(str(a)*b)
# Judge status: Accepted
n,q=map(int,input().split())
s=input()
cnt=[0]*n
for i in range(1,n):
  if s[i-1]=='A' and s[i]=='C':
    cnt[i]=cnt[i-1]+1
  else:
    cnt[i]=cnt[i-1]
for _ in range(q):
  l,r=map(int,input().split())
  print(cnt[r-1]-cnt[l-1])
# Judge status: Wrong Answer
N = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)

Alice = 0
Bob = 0

print(a_list)

for i in range(len(a_list)):
    if i % 2 == 0:
        Alice += a_list[i]
    else:
        Bob += a_list[i]

print(Alice-Bob)
# Judge status: Accepted
A,B,C = sorted(list(map(int,input().split())))
print(A+B+C*10)
# Judge status: Accepted
s=input();print(s[:3]+'8'+s[4:])
# Judge status: Accepted
N,K=map(int,input().split())
H=sorted(list(map(int,input().split())),reverse=True)
if N<K:K=N
for i in range(K):H[i]=0
print(sum(H))
# Judge status: Accepted
S = input()
n = S[::2].count("0") + S[1::2].count("1")
print(min(n, len(S) - n))
# Judge status: Wrong Answer
N,Y = map(int,input().split())
x = 0
y = 0
z = 0
flag = False
for i in range(N+1):
  for j in range(N+1):
    if int((Y-10000*i-5000*j)/1000) == N-i-j:
      x = i
      y = j
      z = N-i-j
      flag = True
      break
    break
if flag == False:
  print(-1,-1,-1)
else:
  print(x,y,z)
# Judge status: Accepted
import bisect
N = int(input())
A_list = sorted(list(map(int,input().split())))
B_list = sorted(list(map(int,input().split())))
C_list = sorted(list(map(int,input().split())))
ans = 0
for B in B_list:
    a_cnt = bisect.bisect_left(A_list,B)
    c_cnt = len(C_list) - bisect.bisect_right(C_list,B)
    ans += a_cnt * c_cnt
print(ans)
# Judge status: Wrong Answer
import collections
[n,m] = [int(i) for i in input().split()]
dic = collections.defaultdict(int)
for i in range(m):
  [a,b] = [int(j)-1 for j in input().split()]
  if a == 0:
    dic[b] += 1
  elif b == 0:
    dic[a] += 1
if max(dic.values()) >= 2:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
# Judge status: Wrong Answer
S=input()
Q=int(input())
A= [input().split() for i in range(Q)]

from collections import deque
ans = deque()
tmp=0
ans.append(S)

for li in A:
    if li[0]=='1':
        tmp=(tmp+1)%2
    else:
        if (tmp+int(li[1]))%2 == 1:
            ans.appendleft(li[2])
        else:
            ans.append(li[2])
if tmp == 0:
    re=map(str, list(ans))
    print(''.join(re))
else:
    re=map(str, list(ans)[::-1])
    print(''.join(re))
# Judge status: Wrong Answer
N=int(input())
if N%10==9 or N%10==9:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))
a = []

for i in range(M):
  b = list(map(int, input().split()))
  a.append(b)
  
from operator import itemgetter
A.sort()
a.sort(key = itemgetter(1))
count = 0
for i in range(N):
  if A[i] < a[-1-count][1]:
    A[i] =  a[-1-count][1]
    a[-1-count][0] -= 1
    if a[-1-count][0] == 0:
      count += 1
    if count == M:
      break
print(sum(A))
# Judge status: Wrong Answer
def main():
    a, b = input().split()
    a += b
    n = int(a)
    for i in range(1, 101):
        if i * i == n:
            print("Yes")
            exit()
    print("No")

if __name__ == "__main__":
    main()
# Judge status: Accepted
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
ans = 0
c = Counter(a)
for k,v in c.items():
    if k<v:
        ans+=v-k
    elif k>v:
        ans+=v
print(ans)
# Judge status: Accepted
S = input()

import collections

S_list = list(S)
c = collections.Counter(S_list)

if min(c.values()) == 2 and len(c.keys()) == 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        s = l[i]+l[j]
        start = j+1
        end = N
        while start != end:
            center = (start + end)//2
            if s <= l[center]:
                end = center
            else:
                start = center + 1
        ans += end-j-1
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
x=10**18
ans=1
for num in a:
    ans*=num
    if ans>x:
        ans=-1
        break
if 0 in a:
    ans=0   
print(ans)
# Judge status: Wrong Answer
n,m = map(int,input().split())
l_max=0
r_min=10**5 
for i in range(m):
  l,r = map(int,input().split())
  l_max = max(l_max,l)
  r_min = min(r_min,r)
print(r_min - l_max + 1)
# Judge status: Accepted
s = input()

#奇数が1
countA = 0
for i in range(len(s)):
    if i%2==0 and s[i]=="0":
        countA += 1
    elif i%2==1 and s[i]=="1":
        countA += 1

#偶数が1
countB = 0
for i in range(len(s)):
    if i%2==0 and s[i]=="1":
        countB += 1
    elif i%2==1 and s[i]=="0":
        countB += 1

print(min(countA,countB))
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1, n+1):
  stock = 0
  for j in range(1, n+1):
    if i % j == 0:
      stock += 1
  if stock == 8 and i % 2:
    ans += 1
print(ans)
# Judge status: Accepted
def main():
    S=input()
    if S=="AAA" or S=="BBB":
        print("No")
    else:
        print("Yes")
if __name__ == '__main__':
    main()
# Judge status: Accepted
import numpy as np


card = np.array([list(map(int, input().split())) for _ in range(3)], dtype=np.int64)
n = int(input())
for _ in range(n):
    num = int(input())
    card[card == num] = 0
card = card == 0


def check_vertical(card):
    return np.all(card, axis=0).sum() >= 1


def check_horizon(card):
    return np.all(card, axis=1).sum() >= 1


def check_diagonal(card):
    check1 = np.diag(card).sum()
    check2 = np.diag(np.fliplr(card)).sum()
    return check1 == 3 or check2 == 3


if check_vertical(card) or check_horizon(card) or check_diagonal(card):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
s = input()
ans =''
for i in s:
    ans += chr((ord(i)-65+n)%26+65)
print(ans)
# Judge status: Accepted
N=int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
  if (i+1) % 2 and a[i] % 2: ans += 1
print(ans)
# Judge status: Accepted
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
cnt=0
for i in range(n):
  for j in range(i+1,n):
    dist=0
    for k in range(d):
      dist+=(abs(x[i][k]-x[j][k])**2)
    for l in range(int(dist**.5)+1):
      if dist==l**2:
        cnt+=1
print(cnt)
# Judge status: Wrong Answer
n = int(input())
l = list(map(int,input().split()))

from itertools import accumulate

tot=sum(l)
ans=10**9+7
for i in list(accumulate(l)):
    ans=min(ans, abs(tot-(i*2)))


for i in list(accumulate(l[::-1])):
    ans=min(ans, abs(tot--(i*2)))

print(ans)
# Judge status: Accepted
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
tmp=x
ans=0
for i in a[:-1]:
    tmp=tmp-i
    if tmp>=0:
        ans+=1
if tmp==a[-1]:
    ans+=1
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
pss = [input().split() for _ in range(m)]

import array; ### print(array.typecodes) ###
wacounts = array.array("l", [0] * (n+1))
acflags = array.array("b", [0] * (n+1))

for pi, si in pss:
    pi = int(pi)
    if acflags[pi] == 0:
        if si == "WA": wacounts[pi] += 1
        if si == "AC": acflags[pi] = 1
    ### print(pi, si, wacounts, acflags) ###

print(acflags.count(1), end=" ")
print(sum(x*y for x,y in zip(wacounts, acflags)))
# Judge status: Accepted
A,B=map(int,input().split())
if A <= B:
  print("unsafe")
else:
  print("safe")
# Judge status: Accepted
A,B,C = map(int,input().split())
print('Yes' if A <= C <= B else 'No')
# Judge status: Accepted
A, B = map(int,input().split())

if A == B :
    print("Draw")
elif A == 1 and B != 1:
    print("Alice")
elif A != 1 and B == 1:
    print("Bob")
elif A > B :
    print("Alice")
else :
    print("Bob")
# Judge status: Accepted
a, b  = map(int, input().split())
count = 0
for i in range(b):
  temp = a + i
  if temp > b:
    break
  li = []
  ni = temp
  for p in range(4):
    li.append(ni // (10 ** (4 - p)))
    ni = ni % (10 ** (4 - p))
  li.append(ni % 10)
  if li == li[::-1]:
    count += 1
print(count)
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]

flag = 0
cnt = 1

for i in range(n-1):
    if a[i] < a[i+1] and flag == 0:
        flag = 1
    elif a[i] > a[i+1] and flag == 0:
        flag = 2
    elif flag == 1 and a[i] > a[i+1]:
        cnt += 1
        flag = 0
    elif flag == 2 and a[i] < a[i+1]:
        cnt += 1
        flag = 0

print(cnt)
# Judge status: Accepted
N ,K , Q = map(int,input().split())
Life = [0]*N
for i in range(Q):
    a = int(input())
    Life[a-1] += 1

for i in range(N):
    if Life[i] <= Q-K:
        print("No")
    else:
        print("Yes")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
left = 0
right = n-1
for i in range(n):
    x = a.pop()
    if i % 2 == 0:
        b[left] = x
        left += 1
    else:
        b[right] = x
        right -= 1
print(*b)
# Judge status: Accepted
def cmd(n, r, D):
    r = min(r, n-r)
    upper = 1
    lower = 1
    counter = 1
    while counter <= r:
        upper = (upper * (n - counter +1)) % D
        lower = (lower * counter) % D
        counter = counter + 1
    return (upper * pow(lower, D - 2, D)) % D

D = 10 ** 9 + 7
n, a, b = map(int, input().split())

N = pow(2, n, D)
P = cmd(n, a, D)
Q = cmd(n, b, D)
Ans = (N - 1 - P - Q) % D
print(Ans)
# Judge status: Wrong Answer
s=input()
print('YES' if (len(s)>=7 and s[:3]=='key' and s[-4:]=='ence') or s[:7]=='keyence' or s[-7:]=='keyence' else 'NO')
# Judge status: Accepted
d , t , s = map(int,input().split())

if d/s <= t:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, M= map(float, input().split())
if N > round(M/2):
	print(round(M/2))
else:
	c=N+(M-N*2)//4
	print(int(c))
# Judge status: Accepted
n, m = map(int, input().split())
like = [0] * m
for _ in range(n):
    ka = list(map(int , input().split()))
    for i in range(1, ka[0]+1):
        like[ka[i]-1] += 1

ans = 0
for li in like:
    if li == n:
        ans += 1
print(ans)
# Judge status: Wrong Answer
k,x = input().split(" ")
k = int(k)
x = int(x)

print(k,x)

text = "No"
 
if k*500>=x:
  text = "Yes"
  
print(text)
# Judge status: Accepted
import math

h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
else:
    print(math.ceil(h * w / 2))
# Judge status: Accepted
from sys import stdin
from itertools import accumulate
input = stdin.readline

n = int(input())
a = list(map(int,input().split()))
p = [0] + list(accumulate(a))
res = 0
for i in range(n-1,-1,-1):
    res += (a[i] * p[i])%(10**9 + 7)
print(res % (10**9 + 7))
# Judge status: Wrong Answer
import math
X = int(input())
n = math.floor((math.sqrt(1+8*X) - 1)/2)
ans = X - sum(range(n))
print(ans)
# Judge status: Accepted
s = input()
weather = ["Sunny","Cloudy","Rainy"]

a = weather.index(s)
if a == 2:
    print("Sunny")
else:
    print(weather[a+1])
# Judge status: Wrong Answer
N = int(input())
l = [tuple(map(int, input().split())) for i in range(N)]
d=set()
for i, j in zip(range(N),range(1,N)):
    d.add(abs(l[i][0]-l[j][0]) + abs(l[i][1]-l[j][1]))
print(max(d))
# Judge status: Wrong Answer
# 問題文
# シカのAtCoDeerくんは二つの正整数 a,bを見つけました。
# aとbの積が偶数か奇数か判定してください。

# 制約
# 1 <= a,b <= 10000
# a,bは整数

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

# 積が奇数なら、0dd と偶数なら Even と出力
if (1 <=  a <= 10000) & (1 <=  b <= 10000):
    if a * b % 2 == 0:
        print('Even')
    else:
        print('0dd')
# Judge status: Wrong Answer
import math
#import itertools
num = (int)(input())
total = 0
#for i, j, k in itertools.product(list(range(1, num + 1)), list(range(1, num + 1)), list(range(1, num + 1))):
#  total += math.gcd(math.gcd(i, j), k)
#print(total)
for i in range(2, num + 1):
  for j in range(2, num + 1):
    for k in range(2, num + 1):
      total += math.gcd(math.gcd(i, j), k)
print(total)
# Judge status: Wrong Answer
n, m = map(int, input().split())

cnt = 1
for i in range(int(m ** 0.5) + 1,0,-1):
    # print(i,m/i)
    if m % i == 0:
        if m // i >= n:
            cnt = m // i
            break
print(m//cnt)
# Judge status: Accepted
A,B= input().split(' ')
if int(A)*int(B)%2 == 0:
  print("Even")
else:
  print("Odd")
# Judge status: Wrong Answer
# Nこの商品の中からM個選ぶ
N, M = list(map(int, input().split()))
# 商品iの得票数はA_i
A = list(map(int, input().split()))

A = sorted(A, reverse=True)

if A[M-1] >= 1/(4*M):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
q = ["0"]
cnt = 0
while cnt < n - 1:
    qt = []
    for num in q:
        lastnum = num[-1]
        for i in range(int(lastnum) + 2):
            qt += [num + str(i)]
    q = qt.copy()
    cnt += 1
    
alp = "abcdefghijkl"
    
def show(num):
    ret = ""
    l = len(num)
    for i in range(l):
        ret += alp[int(num[i])]
    return ret

q.sort()

for num in q:
    print(show(num))
# Judge status: Accepted
n,k = map(int,input().split())
k -= 1
s = input()
print(s[:k] + s[k].lower() + s[k+1::])
# Judge status: Wrong Answer
n,l=map(int,input().split())
a=[l+i for i in range(n)]
print(sum(a)-min(a))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

num = [0]*n
for i in a:
    num[i-1] += 1

print(*num)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans='Yes'
a[0]-=1
for i in range(n-1):
  if a[i]>a[i+1]:
    ans='No'
  elif a[i+1]>a[i]:
    a[i+1]-=1
print(ans)
# Judge status: Wrong Answer
a = list(map(int,input().split()))
k = int(input())

tmp = max(a)
m = 0
for i in range(k):
  m = 2*max(a) + m

for i in range(3):
  if a[i] == tmp:
    a[i] = m
    break
  
print(sum(a))
# Judge status: Accepted
# 初期入力
N = int(input())
X = list(map(int, input().split()))
X_max =max(X)
X_min = min(X)

tairyoku =[]
# Pで集会を開く
for P in range(X_min,X_max + 1): #住んでいるところで端から端まで確認
    tairyoku.append([(x_j - P)**2 for x_j in X ])
tairyoku_sum = [sum(i) for i in tairyoku ]
# print(tairyoku)
#print(tairyoku_sum)
print(min(tairyoku_sum))
# Judge status: Accepted
n, k = map(int, input().split())
sets = set()

for i in range(k):
    _ = input()
    sets |= set(map(int, input().split()))

m = set(range(1,n+1))
rest = m - sets
print(len(rest))
# Judge status: Wrong Answer

n = []

n = input().split()

for i in range(5):
    n[i] = int(n[i])

print(n)
for i in range(5):
    if n[i] == 0:
        print(i+1)
# Judge status: Wrong Answer
n = int(input())

x = 7
ans = 1

for i in range(n+10):
  if x%n==0:
    break
  ans+=1
  x= x*10 + 7
  x=x%n
    
if ans < n:
  print(ans)
else:
  print(-1)
# Judge status: Accepted

def main():
    s = input()
    for i,c in enumerate(s):
        if c == "A":
            a_pointer = i+1
            break

    for i,c in enumerate(s):
        if c == "Z":
            b_pointer = i+1
            continue
    print(b_pointer - a_pointer +1)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print("Yes")
else:
    k = 0
    for i in range(N -1):
        if A[i + 1] < A[i]:
            k  += (A[i] - A[i +1])
    if k <= 1:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
def main():
    input()
    s = input()
    l, r = 0, 0
    for si in s[::-1]:
        if si == ")":
            break
        r += 1
    for si in s[:-r] if r > 0 else s:
        if si == ")":
            l += 1
        else:
            l -= 1
    print("(" * l + s + ")" * r)

if __name__ == '__main__':
    main()
# Judge status: Accepted
N, K = map(int, input().split())

def sumLR(l, r):
	return (l+r)*(r-l+1)//2

mod = 10**9 + 7
count = 0

for n in range(K, N+2):
	max = sumLR(N-n+1, N)
	min = sumLR(0, n-1)
	count += max - min + 1
	count %= mod
print(count)
# Judge status: Accepted
a,b,c = map(int,input().split())

amari = a - b

if amari >= c:
  print(0)
elif amari < c:
  print(c - amari)
# Judge status: Accepted
a,b,x = map(int,input().split())
print("YES" if a<=x and (a+b)>=x else "NO")
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
count = 0
while True:
    for i,num in enumerate(A):
        if num % 2 != 0:
            print(count)
            exit()
        else:
            A[i] = num / 2
    count += 1
# Judge status: Accepted
L = sorted(list(map(int, input().split())))
K = int(input())
print(L[0] + L[1] + L[2]*2**K)
# Judge status: Wrong Answer
s = input()
if s == "Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print( "Rainy")
elif s == " Rainy":
    print("Sunny")
# Judge status: Accepted
import math

n = int(input())
ans = [0]*n
root = n ** 0.5

for x in range(1, math.floor(root) + 1):
    for y in range(1, math.floor(root) + 1):
        for z in range(1, math.floor(root) + 1):
            result = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if result <= n:
                ans[result - 1] += 1

for num in ans:
    print(num)
# Judge status: Accepted
N = int(input())
ans = 0
g = 10

if N%2 != 0:
    print(0)
else:
    flag = True
    while flag:
        i = N//g
        if i == 0:
            break
        ans += i
        g *= 5
    
    print(ans)
# Judge status: Accepted
if int(input()[5:7]) >= 5:
	print("TBD")
else:
	print("Heisei")
# Judge status: Wrong Answer
import math
n=int(input())
def num_divisors_trial_division(n):
    num = 0
    for i in range(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1
    
    return num

ans=1
for i in range(1,n+1):
    ans+=i*num_divisors_trial_division(i)
print(ans)
# Judge status: Wrong Answer
a = int(input())
print(a + a^2 + a^3)
# Judge status: Accepted
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
asum=0
bsum=0
pointer=0
while pointer<m and bsum+b[pointer]<=k:
	bsum+=b[pointer]
	pointer+=1
ans=pointer
for i in range(n):
	asum+=a[i]
	while asum+bsum>k and pointer>=0:
		pointer-=1
		bsum-=b[pointer]
	if asum+bsum>k:
		break
	ans=max(ans,(i+1)+pointer)
print(ans)
# Judge status: Accepted
s=input()
print(max(sum(map(int,list(s))),int(s[0])-1+9*len(s)-9))
# Judge status: Accepted
x = [int(input()) for i in range(4)]
print(min(x[0], x[1])*x[2]+max(0, (x[0]-x[1]))*x[3])
# Judge status: Accepted
import sys
readline = sys.stdin.readline

def main():
    N, L = map(int, readline().rstrip().split())
    A = [L+i-1 for i in range(1, N+1)]
    A_abs = [abs(a) for a in A]
    mi_idx = A_abs.index(min(A_abs))
    print(sum(A) - A[mi_idx])

if __name__ == '__main__':
    main()
# Judge status: Accepted
s = str(input())
t = str(input())
d = {}
for k, v in zip(s, t):
    if d.get(k) != None and d.get(k) != v:
        print("No")
        exit()
    d[k] = v

if len(set(d.values())) == len(d):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = input()
for i in range(0, len(s), 2):
    if s[i:i+2] != 'hi':
        print('No')
        exit()
print('Yes')
# Judge status: Wrong Answer
import math

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


tan = ((a*a*b - x) * 2) / a**3


print(math.degrees(math.atan(tan)))
# Judge status: Accepted

h1,m1,h2,m2,k = map(int,input().split())

start = 60*h1+m1
end = 60*h2+m2
res = (end-start-k)


print(res)
# Judge status: Accepted
n=int(input())
s=input()
t=input()
actualfail=0
for i in range(n):
  fail=0
  for j in range(n-i):
    if s[i+j]!=t[j]:
      fail=1
      break
  if fail==0:
    actualfail=1
    break
if actualfail==1:
  print(n+i)
else:
  print(2*n)