peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
a = list(map(int,input().split()))
a.extend(list(map(int,input().split())))
a.extend(list(map(int,input().split())))
n = int(input())

ins = []
for i in range(n):
    b = int(input())
    if b in a:
        ins.append(a.index(b))

okp = [(0,1,2), (3,4,5), (6,7,8) ,(0,3,6), (1,4,7), (2,5 ,8), (0,4,8), (2,4,6)]
f = "No"
for x, y, z in okp:
    if x in ins and y in ins and z in ins:
        f = "Yes"
        break

print(f)
# Judge status: Accepted
M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 == a:
    a = b
    r -= c * pow(f, M - 2, M)
print(r % M)
# Judge status: Accepted
N = int(input())
ans  = 10**5+1
for i in range(1,N//2 + 1):
    A = i
    B = N - i
    tmp = 0
    while(A > 0):
        tmp += A % 10
        A //= 10
    while(B > 0):
        tmp += B % 10
        B //= 10
    ans = min(ans,tmp)
print(str(ans))
# Judge status: Wrong Answer
a=int(input())
if -40 <= a <= 40:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
s = str(input())
r = 0
g = 0
b = 0

for i in range(n):
  if s[i] == 'R':
  	r += 1
  elif s[i] == 'G':
  	g += 1
  else:
  	b += 1

ans = r * g * b

for i in range(n):
  for j in range(n):
    if 2 * j + i < n and s[i] != s[i + j] and s[i] != s[2 * j + i] and s[i + j] != s[2 * j + i]:
      ans -= 1
print(ans)
# Judge status: Wrong Answer
m, n = map(int, input().split())
while True:
  if m < n:
    m, n = n, m
  if m%n:
    m, n = n, m%n
  else:
    break

def divisors(m):
    divisors = [1]
    for i in range(2, int(m**0.5)+1):
        if m % i == 0:
            divisors.append(i)
        while m % i == 0:
            m //= i
        if m == 1:
            break
    return divisors

print(len(divisors(n)))
# Judge status: Wrong Answer
N,M=map(int,input().split())

if N==1:
    print(M-2)
elif M==1:
    print(N-2)
else:
    print((N-2)*(M-2))
# Judge status: Accepted
def mi():
    return map(int, input().split())

def main():
    N = int(input())
    W = [input() for _ in range(N)]
    if len(set(W)) != N:
        print('No')
        return
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            print('No')
            return
    print('Yes')

if __name__ == '__main__':
    main()
# Judge status: Accepted
n="0"+input()
A,b,c=0,0,0
for i in n[::-1]:
    a=int(i)+b
    if a==5 and c==0:
        A+=5
        b=0
        c=1
    elif a<5:
        A+=a
        b=0
        c=0
    else:
        A+=10-a-c
        b=1
        c=0
print(A)
# Judge status: Accepted
import numpy as np
n, m = list(map(int,(input().split())))
a = np.array(list(map(int,(input().split()))))

all_b = sum(a)
t = 1/(4*m)*all_b
#all_t =a*t

ans = np.where(a>=t)
#print(ans)
#print(all_b[all_b >t])
#print(all_b,t)
#print(len(ans[0]))
if len(ans[0]) >= m:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n, x = map(int, input().split())
a = list(map(int, input().split()))
l = [0] * (n+1)
for i in range(n):
  l[i+1] = l[i] + a[i]
ans = 0
for i in l:
  if i <= x:
    ans += 1
print(ans)
# Judge status: Accepted
import math

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

print(math.ceil((N - 1)/(K - 1)))
# Judge status: Accepted
a, b = map(int,input().split())
if a <= b:
  print(a)
else:
  print(a-1)
# Judge status: Accepted
k,s = map(int,input().split())
cnt=0
for i in range(k+1):
    for j in range(k+1):
        if s-k<=i+j<=s:
            cnt+=1
print(cnt)
# Judge status: Wrong Answer
a = list(map(int, input().split()))

a.sort()
print(a)
print("Yes" if a[0]+a[1] == a[2] else "No")
# Judge status: Wrong Answer
n = int(input())
s = []
for i in range(n):
    s.append("".join(sorted(input())))

s.sort()
ans = 0

for i in range(n-1):
    if s[i] == s[i+1]:
            ans += 1

print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def is_prime(n):
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True


def main():
    X = int(readline())
    while not is_prime(X):
        X += 1
    print(X)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n,*a = map(int,open(0).read().split())
a.sort(reverse=True)
print(a[0]+sum(a[1:n//2])+sum(a[1:n-n//2]))
# Judge status: Accepted
n,k =map(int,input().split())
a=list(map(int,input().split()))
a = [1] + a
def next(i):
    return a[i]

z = [0] * (n+1)

place = 1
T = 0
interval = 0
if k < n:
    for i in range(k):
        place = next(place)
    print(place);exit()
place = 0
k += 1
for i in range(n):
    place = next(place)
    if z[place] != 0:
        interval = T - z[place]  + 1
        break
    z[1] = 1 
    T += 1
    z[place] = T

m = (k-z[place])%interval
for i in range(m):
    place = next(place)
print(place)
# Judge status: Wrong Answer
n, m = map(int, input().split())
lis = list(map(int, input().split()))
lis.sort()

res = []
for i in range(m - 1):
    res.append(lis[i + 1] - lis[i])
res.sort()

k = n - 1
print(sum(res[:-k]))
# Judge status: Accepted
import math

n,k = (int(x) for x in input().split())
An = [int(i) for i in input().split()]

left = 0
right = max(An)

def check(x):
    chk = 0
    for i in range(n):
        chk += math.ceil(An[i]/x)-1
    return chk

while right-left!=1:
    x = (left+right)//2
    if check(x)<=k:
        right = x
    else:
        left = x

print(right)
# Judge status: Accepted
import math
N = int(input())
ans = 1
for i in range(10**5):
    if i**2 <= N:
        ans = i**2
    if i**2 > N:
        break

print(ans)
# Judge status: Accepted
n,k = map(int,input().split())
s = list(input())
s[k-1] = s[k-1].lower()
print("".join(s))
# Judge status: Accepted
n,m = map(int, input().split())

if n*2 < m:
    c = n*2 + m
    print(c//4)
else:
    print(m//2)
# Judge status: Accepted
n = int(input())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    z = a + b
    w = a - b
    A.append(z)
    B.append(w)
    
P = abs(max(A) - min(A))
Q = abs(max(B) - min(B))
print(max(P, Q))
# Judge status: Accepted
x = int(input())

for k in range(1, 10000):
    if x*k % 360 == 0:
        print(k)
        break
# Judge status: Accepted
n,k= map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-k):
         if a[i] < a[i + k]:
                  print("Yes")
         else:
                  print("No")
# Judge status: Accepted
def main():
    N, *A = map(int, open(0).read().split())
    for i in range(N):
        A[i] -= i + 1
    A.sort()
    ans = 0
    b = A[N // 2]
    for i in range(N):
        ans += abs(A[i] - b)
    print(ans)
    return


main()
# Judge status: Accepted
a,b,c,d=map(int,input().split())

ab=abs(a-b)
bc=abs(b-c)

if abs(a-c) <= d:
    print("Yes")
elif ab <= d and bc <= d:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())

if N < 105:
    print(0)
    exit()

ans = 0
for i in range(1, N+1, 2):
    count = 0
    for j in range(1, i+1):
        if i % j == 0:
            count += 1

    if count == 8:
        ans += 1

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

array = []
cnt6 = 0
while 6**cnt6 <= N:
    array.append(6**cnt6)
    cnt6 += 1
    
cnt9 = 0
while 9**cnt9 <= N:
    array.append(9**cnt9)
    cnt9 += 1

a = sorted(list(set(array)))
# 最小
dp = [i for i in range(N+1)]
# print(a)
n = 6
for n in a:
    for i in range(N+1):
        if i+n <= N:
            dp[i+n] = min(dp[i]+1, dp[i+n])
print(dp[N])
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
import collections as col

sa=set(A)
ca=col.Counter(A)
num=0
for i in sa:
    if ca[i]==1:
        continue
    else:
        num += (ca[i]*(ca[i]-1))//2
for i in A:
    ans = num - (ca[i]-1)
    print(ans)
# Judge status: Accepted
a, b, c = input()
a=int(a)
b=int(b)
c=int(c)


if a == 7:
    print('Yes')
else:
    if b == 7:
        print('Yes')
    else:
        if c == 7:
            print('Yes')
        else:
            print('No')
# Judge status: Accepted
k, x = map(int, input().split())
print("YNeos"[k*500<x::2])
# Judge status: Accepted
a,b,c = map(int, input().split())
original = [a,b,c]
flag = 0
i = 0
while a%2 == b%2 == c%2 == 0:
    a_ = (b+c)//2
    b_ = (c+a)//2
    c_ = (a+b)//2
    a = a_
    b = b_
    c = c_
    if [a,b,c] == original:
        flag = 1
        break
    i += 1
if flag:
    print(-1)
else:
    print(i)
# Judge status: Accepted
d,n = map(int, input().split())

if n == 100: print(100**d*101)
else: print(100**d*n)
# Judge status: Accepted
X = int(input())
money = 100
cnt = 0
while money < X:
    money = int(money * 1.01)
    cnt += 1

print(cnt)
# Judge status: Wrong Answer
import sys

if (int(input()) % 500) <= int(input()):
  print('YES')
else:
  print('NO')
# Judge status: Accepted
from bisect import bisect_right
def main():
    N = int(input())
    min_a = 10**9 + 1
    values = []
    ans = 0
    for i in range(N):
        tmp = -int(input())
        idx = bisect_right(values, tmp)
        if idx != len(values):
            values[idx] = tmp
        else:
            values.append(tmp)
            ans += 1

    print(ans)








main()
# Judge status: Wrong Answer
def countPairs(str_arr):
	count = 0
	for i in range(N):
		for j in range(i+1,N):
			if str_arr[i] == str_arr[j]:
				count += 1
	return count


N = int(input())
str_arr = []

for i in range(N):
	str = input()
	str_arr.append(str)

print(countPairs(str_arr))
# Judge status: Accepted
from collections import deque
n,m=map(int,input().split())
neighbor=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  neighbor[a].append(b)
  neighbor[b].append(a)
def bfs(start,arrcnt):
  queue=deque([start])
  d=[None]*arrcnt
  d[start]=0
  while queue:
    l=queue.popleft()
    for i in neighbor[l]:
      if d[i]==None:
        d[i]=l+1
        queue.append(i)
  return d
d=bfs(0,n)
if None in d:
  print("No")
else:
  print("Yes")
  for i in range(1,n):
    print(d[i])
# Judge status: Wrong Answer
N=int(input())
a=[int(i) for i in input().split(" ")]

retval=0
for i,ai in enumerate(a):
    if i%2==0:
        continue
    if ai%2==1:
        retval+=1
print(retval)
# Judge status: Accepted
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

w = abs(A-B)
s = V-W

if s * T >= w:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N,K = map(int,(input().split()))
h = [0]*N

for i in range(N):
    h[i] = int(input())

h.sort()
s = []
for i in range(N-K+1):
    s.append(h[i+K-1] - h[i])

print(min(s))
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
d=[0]*(n+1)
for i in l:
    d[i]+=1
for i in range(1,n+1):
    print(d[i])
# Judge status: Accepted
n, m = map(int, input().split())

if n*m == 1:
    print(1)
elif m*n == 4:
    print(0)
else:
    print(abs((n-2)*(m-2)))
# Judge status: Wrong Answer
n = int(input())
a =  list(map(int, input().split()))

b = sorted(set(a))
len_a = len(a)
len_b = len(b)
ans = len_a - len_b

for i in range(len_b - 2):
    if b[i+1] - b[1] != 1:
        print(-1)
        break
else:
    print(ans)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))

t = sorted(p)
l = 0
for i in range(n):
  if p[i] != t[i]:
    l += 1
    if l > 2:
      print('NO')
      break
else:
  print('YES')
# Judge status: Accepted
import math
def better(l, ans):
    for i in range(2, n):
        ans[i] = min(ans[i - 1] + abs(l[i]-l[i - 1]), ans[i - 2] + abs(l[i]-l[i - 2]))
    return ans
n = int(input())
l = list(map(int, input().split()))
ans = [0] * n
ans[1] = abs(l[1]-l[0])
print(better(l, ans)[len(ans)-1])
# Judge status: Wrong Answer
N, M, K = map(int, input().split())

ans = "No"

for i in range(M+1):
    for j in range(N+1):
        sum = 0
        sum += N*i+M*j
        if sum == K:
            ans = "Yes"
            break
    if ans == "Yes":
        break

print(ans)
# Judge status: Accepted
def resolve():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    n = A[-1]
    import bisect
    idx = bisect.bisect_left(A, n//2)
    candidates = []
    if idx < N:
        candidates.append(A[idx])
    if idx > 0:
        candidates.append(A[idx-1])

    if abs(n/2 - candidates[0]) < abs(n/2 - candidates[1]):
        print(n, candidates[0])
    else:
        print(n, candidates[1])       

    
if '__main__' == __name__:
    resolve()
# Judge status: Accepted
from collections import Counter
from itertools import starmap
def main():
    N = input()
    A = list(map(int, input().split()))
    count = Counter(A)
    remove = lambda x,y: y-x if y >= x else y
    ans = sum(starmap(remove, count.items()))
    print(ans)

main()
# Judge status: Wrong Answer
A = int(input()) #500円玉
B = int(input()) #100円玉
C = int(input()) #50円玉
X = int(input()) #この値にする合計を求める

count = 0
a = -1
b = -1
c = -1
while a <= A:
    a += 1
    while b <= B:
        b +=1
        while c <= C:
            c +=1
            total = 500 * a + 100 * b + 50 * c
            if total == X:
                count += 1
print(count)
# Judge status: Accepted
h,w = map(int, input().split())

if h == 1 or w == 1:
  print(1)
elif h*w%2 == 1:
  print(1+h*w//2)
else:
  print(h*w//2)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
lis=[0]*(10**5+1)
for i in range(n):
    lis[a[i]]+=1
q=int(input())
for _ in range(q):
    b,c=map(int,input().split())
    s+=c*lis[b]-b*lis[b]
    lis[c]+=lis[b]
    lis[b]=0
    print(s)
# Judge status: Accepted
n = int(input())
tmp = 0
for i in range(1, n + 1):
    tmp += i
    if tmp >= n:
        print(i)
        break
# Judge status: Accepted
s=input()

if "RRR" in s:
    print(3)
elif "RR" in s:
    print(2)
elif "R" in s:
    print(1)
else:
    print(0)
# Judge status: Accepted
a=input()

if a.islower():
  print("a")
else:
  print("A")
# Judge status: Accepted
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))

k=0
m=100000000000000
for i in range(1,n+1):
    b=a-t+h[i-1]*0.006
    if m>abs(b):
        m=abs(b)
        k=i


print(k)
# Judge status: Accepted
N=int(input())
c=list(input())
cnt=0
res=10**30
rcum=[0]*(N+1)
wcum=[0]*(N+1)
for i in range(N):
    rcum[i+1]=rcum[i]+(c[i]=='R')
    wcum[i+1]=wcum[i]+(c[i]=='W')
for i in range(N+1):
    a=wcum[i]+(rcum[N]-rcum[i])
    res=min(res,a)
for i in range(N+1):
    b=max(wcum[i],(rcum[N]-rcum[i]))
    res=min(res,b)
    

print(res)
# Judge status: Wrong Answer
sample = input()
sample_list = sample.split(" ")
count = 0
flag = 0
for i in range(len(sample_list)):
  for j in range(1, i):
    if sample_list[i] == sample_list[j]:
      flag = 1
  if flag == 0:
    count += 1
  flag = 0
print(count)
# Judge status: Wrong Answer
x = []
x.append(int(input()))
x.append(int(input()))
x.append(int(input()))
x.append(int(input()))
x.append(int(input()))
tmp = 9
ans = 0


def a(b):
    c = str(b)
    if c[-1] == "0":
        return b
    else:
        return b - int(c[-1]) + 10


for i in x:
    ans += a(i)
    d = str(i)
    if int(d[-1]) != 0:
        tmp = min(tmp, int(d[-1]))

print(ans - (10 - tmp))
# Judge status: Accepted
#111_B
N=int(input())
print(-(-N//111)*111)
# Judge status: Accepted
S = input()
a = len(S)
A = a // 2
T = S[::-1]
B = S[0:A]
C = T[0:A]

x = 0
count = 0
for b in B:
    if b != C[x]:
        count += 1
    x += 1
    
print(count)
# Judge status: Wrong Answer
N = int(input())

ans = 0
for i in range(2, int(N**0.5)+1):
    cnt = 0
    while N%i == 0:
        N /= i
        cnt += 1
 
    a = 0
    b = 0
    for j in range(1, cnt+1):
        a += j
        if a > cnt:
            break
        b += 1
        
    ans += b

print(1 if ans==0 else ans)
# Judge status: Wrong Answer
S=[input() for i in range(3)]

flag=1
i=0

while flag==1:
  t=S[i][0]
  if t=='a':
    ni=0
  elif t=='b':
    ni=1
  elif t=='c':
    ni=2
    
  S[i]=S[i][1:]
  #print(i,S[i])
  if S[ni]=='':
    print('A' if i==0 else 'B' if i==1 else 'C')
    flag=0
  else:
    i=ni
# Judge status: Accepted
A,B = map(int,input().split())

if A < 10 and B < 10:
    answer = A * B
    print(answer)

else:
    print('-1')
# Judge status: Wrong Answer
n,m=map(int,input().split())
ans={i for i in range(1,m)}
for i in range(n):
    a=[int(i) for i in input().split()]
    a=a[1:]
    ans=ans&set(a)
print(len(list(ans)))
# Judge status: Wrong Answer
N, M = map(int,input().split())
#M 夏休み期間　M　宿題数
A = list(map(int, input().split()))
A_sum = 0
for i in range(0, M):
    A_sum += A[i]
    # A_sum 宿題全日数
x = N - A_sum
if x > N:
    print("-1")
else:
    print(x)
# Judge status: Accepted
import numpy as np

a = input()
b = input()
c = input()
d = input()
e = input()

l = np.array(list(map(int, [a[-1], b[-1], c[-1], d[-1], e[-1]])))

idx = np.argmin(np.where(l == 0, 10, l))

times = list(map(int, [a, b, c, d, e]))

ans = 0
for i, t in enumerate(times):
  if i == idx:
    ans += t
  else:
    ans += np.ceil(t/10) * 10

print(int(ans))
# Judge status: Accepted
list_N =list(map(int,list(input())))
total = 0
for i in list_N:
    total += i
if total % 9 == 0:
    print("Yes")
elif total % 9 != 0:
    print("No")
else:
    pass
# Judge status: Accepted
N = int(input())

if N % 9 == 0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a = input()
b = input()
relsa = {}
relsb = {}
possible = True
for i in range(len(a)):
  if a[i] not in relsa:
    relsa[a[i]] = b[i]
  else:
    if relsa[a[i]] != b[i]:
      possible = False
  if b[i] not in relsb:
    relsb[b[i]] = a[i]
  else:
    if relsb[b[i]] != a[i]:
      possible = False
      
if possible:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a,b = map(int, input().split())
num = 0
for i in range(a,b+1):
    i = str(i)
    if i[0] == i[4] and i[1] == i[3]:
        num += 1
print(num)
# Judge status: Accepted
n = int(input())
x=0
while(1):
  if n ==2:
    break
  for i in range (int((-(-n**0.5//1)))):
    if n%(i+1)==0:
      x=x+1
  if x==1:
    break
  else:
    x=0
    n=n+1
print(n)
# Judge status: Accepted
num = int(input())
num_list = [int(x) for x in input().split()]
cnt = 0
for i in range(num):
    if num_list[i] % 2 == 0:
        if not (num_list[i] % 3 == 0 or num_list[i] % 5 == 0):
            cnt += 1
            
if cnt != 0:
    print("DENIED")
else:
    print("APPROVED")
# Judge status: Accepted
a=input()
b=''
for i in range(len(a)):
  if a[i]=='0':
    b=b+'0'
  elif a[i]=='1':
    b=b+'1'
  else:
    if b!='':
      b=b[:-1]

print(b)
# Judge status: Accepted
A, B = map(int, input().split())

ans = -1

if 0 < A and A < 10 and 0 < B and B < 10:
    ans = A * B
print(ans)
# Judge status: Wrong Answer
n, a, b = map(int, input().split())
c = 0

while n >= 0:
    if n >= a+b:
        n -= (a+b)
        c += 1
    else:
        if n <= a:
            print(a*c + n)
        else:
            print(a*c)
        break
# Judge status: Accepted
s = input()
q = int(input())

sg = 1
fr = []
ba = []
for x in range(q):
  query = [s for s in input().split()]
  if query[0] == '1':
    sg *= -1
  else:
    if int(query[1])*2 + sg == 3:
      fr.append(query[2])
    else:
      ba.append(query[2])

if sg == 1:
  fr.reverse()
  frn = ''.join(fr)
  ban = ''.join(ba)
  print(frn + s + ban)
else:
  ba.reverse()
  frn = ''.join(fr)
  ban = ''.join(ba)
  print(ban + ''.join(list(reversed(s))) + frn)
# Judge status: Accepted
import math
 
t8,t10=map(int,input().split(" "))
 
mint8=t8/0.08
maxt8=(t8+1)/0.08
mint10=t10/0.1
maxt10=(t10+1)/0.1
 
ans=list(set(range(math.ceil(mint8),int(maxt8))) & set(range(math.ceil(mint10),int(maxt10))))
if len(ans)==0:
    print(-1)
else:
    print(min(ans))
# Judge status: Accepted
n=int(input())
li = list(map(int,input().split()))
ans=[]
i=1
while i<=101:
	for j in range(n):
		cost=[(li[j]-i)**2 for j in range(n)]
		ans.append(sum(cost))
	i+=1
print(min(ans))
# Judge status: Accepted
n, l = list(map(int, input().split(' ')))
m = 9999999999
apples = []
for i in range(n):
    if abs(m) > abs(i+l):
        m = i+l
    apples.append(i+l)
print(sum(apples) - m)
# Judge status: Accepted
MODULO = 10**9+7
n, k = map(int, input().split())


ans = 0
for num_add in range(k, n+2):
	min_res = (0 + num_add-1) * num_add // 2
	max_res = (n-num_add+1 + n) * num_add // 2
	ans += (max_res - min_res + 1) % MODULO
	ans %= MODULO
	# print("ans", ans)

print(ans)
# Judge status: Accepted
N = input()
nli = []
for i in range(len(N)):
    nli.append(N[i])
print("No" if sum(map(int, nli)) % 9 else "Yes")
# Judge status: Accepted
st, gl = map(int, input().split())
ans = 0

if gl == -st:
  ans = 1
elif st >= 0:
  if gl > st:
    ans = gl - st
  elif gl < -st:
    ans = - st - gl + 1
  elif gl > 0:
    ans = st - gl + 2
  else:
    ans = gl + st + 1
elif st < 0:
  if gl > -st:
    ans = gl + st + 1
  elif gl < st:
    ans = st - gl + 2
  elif gl > 0:
    ans = - st - gl + 1
  else:
    ans = gl - st
  
print(ans)
# Judge status: Accepted
import fractions as fr
a,b,c,d=map(int,input().split())

def div(x,y):
  return y//x

def div2(x):
  return div(x,b)-div(x,a-1)
  
print(b-a+1-div2(c)-div2(d)+div2(c*d//fr.gcd(c,d)))
# Judge status: Accepted
n = int(input())
print(-(-n//2))
# Judge status: Wrong Answer
# https://atcoder.jp/contests/abc083/tasks/arc088_a
import math

x, y = map(int, input().split())

print((int(math.log2(y / x))) + 1)
# Judge status: Wrong Answer
s = input()
a_index = 0
z_index = 0

for i in range(0, len(s)):
    if s[i] == "A":
        a_index = i
        break
        
for i in range(0, len(s)):
    if s[len(s)-i-1] == "Z":
        z_index = len(s)-i
        break
print(z_index - a_index + 1)
# Judge status: Wrong Answer
L, R, d = map(int, input().split())
if L % d == 0:
    print((R - L) // d + 1)
else:
    print((R - L) // d)
# Judge status: Accepted
n = input()
p = map(int,raw_input().split())
res = 0
for i in xrange(0,n-2):
    nl = [p[i],p[i+1],p[i+2]]
    
    if sorted(nl)[1] == nl[1]:
        res +=1
print res
# Judge status: Accepted
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)

alpha=Y[N//2-1]
beta=Y[N//2]

S=[0]*N
for k in range(N):
    x=X[k]
    if x<=alpha:
        S[k]=beta
    else:
        S[k]=alpha

print("\n".join(map(str,S)))
# Judge status: Accepted
n = int(input())
cnt = 0
p = 0
for i in range(n+1000):
    cnt += i
    if cnt >= n:
        p = i
        break
print(p)
# Judge status: Accepted
N, T = list(map(int,input().split()))
c = [0 for i in range(N)]
t = [0 for i in range(N)]
for i in range(N):
  c[i], t[i] = input().split()
  c[i] = int(c[i])
  t[i] = int(t[i])

ans = float('inf')
for i in range(N):
  if t[i] <= T and c[i] < ans:
    ans = c[i]
if ans == float('inf'):
  print('TLE')
else:
  print(ans)
# Judge status: Wrong Answer
n = int(input())
print(1000 - n % 1000)
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
ans=[]
for i in range(len(l)):
    c=abs(sum(l[:i])-sum(l[i:]))
    ans.append(c)
print(min(ans))
# Judge status: Wrong Answer
n,l = map(int,input().split())
s = sorted([i for i in range(n)])
print(*s,sep="")
# Judge status: Wrong Answer
import itertools

n,m,q=map(int,input().split())
List = [[int(j) for j in input().split()] for i in range(q)]
total = 0
d = 0
lis = list(range(1,m+1))

for pair in itertools.combinations(lis, n):
    for i in range(q):
        if pair[List[i][1]-1] - pair[List[i][0]-1] == List[i][2]:
            total += List[i][3]
    if d <= total:
        d = total
        print(d)
    total = 0

print(d)
# Judge status: Wrong Answer
n = int(input())
s = input()
t = input()
ans = s+t
for i in range(n):
    if s == t:
        ans = s
    if s[i:] == t[:n-i]:
        ans = s+t[-i:]
print(len(ans))
# Judge status: Accepted
import sys
n, *lst = map(int, sys.stdin.read().split())
copy = sorted(lst)
max1, max2 = copy[-1], copy[-2]

if max2 < max1:
  for j in lst:
    if j != max1:
      print(max1)
    else:
      print(max2)
else:
  for j in lst:
    print(max1)
# Judge status: Accepted
A=[]
B=[]
for i in range(3):
  A.extend(list(map(int,input().split())))

n=int(input())
for i in range(n):
  b=int(input())
  try:
    A[A.index(b)]=0
  except:
    continue

if A[0]==A[1]==A[2] or A[3]==A[4]==A[5] or A[6]==A[7]==A[8] or A[0]==A[3]==A[6] or A[1]==A[4]==A[7] or A[2]==A[5]==A[8] or A[0]==A[4]==A[8] or A[2]==A[4]==A[6]:
  print('Yes')
else:print('No')
# Judge status: Accepted
s = input()

if s.isupper():
  print('A')
else:
  print('a')