peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
s=sorted(input())
ans="abc"
flag=1
for i in range(3):
  if s[i] != ans[i]:
    print("No")
    flag=0
    break

if flag==1:
  print("Yes")
# Judge status: Wrong Answer
n = int(input())

matrix = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, n):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    matrix[a][b] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, i+1):
        if i == j:
            ans += matrix[i][i] ** 2
        else:
            ans += matrix[i][j] * matrix[j][i] * 2

print(ans)
# Judge status: Accepted
# -*- coding:utf-8 -*-

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

c_a = 1

while True:
    if a*c_a%b == 0:
        break
    c_a += 1

print(a*c_a)
# Judge status: Wrong Answer
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

a = A
b = B

for i in range(1, T + 1, 1):
    a += V
    b += W

    if a == b:
        print("YES")
        break

if (a != b):
    print("NO")
# Judge status: Wrong Answer
s = input()
t = input()

if sorted(s) < list(reversed(t)):
    print("Yes")
else:
    print("No")
# Judge status: Accepted

N, M = map(int, input().split())
Hs = list(map(int, input().split()))
ans = [1 for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    if Hs[A-1] > Hs[B-1]:
        ans[B-1] = 0
    elif Hs[A-1] == Hs[B-1]:
        ans[A-1] = 0
        ans[B-1] = 0
    else:
        ans[A-1] = 0
print(sum(ans))
# Judge status: Wrong Answer
S = input()
T = input()

tToS = {}
for s, t in zip(S, T):
    if not t in tToS:
        tToS[t] = s

    if tToS[t] != s:
        print('No')
        exit()

print('Yes')
# Judge status: Accepted
val = float(input())

print (3.14 * val * 2)
# Judge status: Accepted
def mi():
    return map(int, input().split())

def main():
    N = int(input())
    T, A = mi()
    H = list(mi())
    tmps = [abs(T-h*0.006-A) for h in H]
    print(tmps.index(min(tmps))+1)

if __name__ == '__main__':
    main()
# Judge status: Accepted
a = sorted(list(map(int, input().split())))
ans = a[0]*a[1]
for i in range(3):
    if a[i]%2==0:
        ans = 0
        break
print(ans)
# Judge status: Wrong Answer
s = input()
#print(s[2])
#print(int(s[0] + s[1]))

if int(s[0] + s[1])>12 and int(s[2] + s[3])<=12 and int(s[2] + s[3])>0:
    print("YYMM")
elif int(s[0] + s[1])<=12 and int(s[2] + s[3])<=12 and int(s[0] + s[1])>0 and int(s[2] + s[3])>0:
    print("AMBIGUOUS")
elif int(s[0] + s[1])>0 and int(s[0] + s[1])<=12 and int(s[2] + s[3])>12:
    print("MMYY")
else:
    print("NA")
# Judge status: Accepted
k = int(input())

e = k // 2
o = 0

if k%2 == 0:
    o = k//2
else:
    o = (k+1)//2
    
print(e*o)
# Judge status: Accepted
c = input()

if c == "a" or c == "i" or c == "u" or c=="e" or c =="o":
  print("vowel")
else:
  print("consonant")
# Judge status: Wrong Answer
n, m = list(map(int, input().split()))
if n==m:
    print("yes")
else:
    print("no")
# Judge status: Wrong Answer
n,m=map(int,input().split())
from math import log2
print(int(log2(m/n))+1)
# Judge status: Accepted
import heapq

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

arr.sort()
arr.reverse()

que = [0]
heapq.heapify(que)

ans = 0

for i in range(n):
    top = heapq.heappop(que)
    top = -top
    ans += top
    if i == 0:
        heapq.heappush(que, -arr[i])
    else:
        heapq.heappush(que,-arr[i])
        heapq.heappush(que,-arr[i])

    # print(que)

print(ans)
# Judge status: Wrong Answer
n = int(input())
x = n*800
y = 200*n//15
print(x-y)
# Judge status: Accepted
n,m = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(n)]


from operator import itemgetter
def main():
    AB.sort(key = itemgetter(0))
    cnt = 0
    ans = 0
    for a,b in AB:
        if b + cnt < m:
            cnt += b 
            ans += b*a
        else:
            ans += (m - cnt)*a
            print(ans)
            return



if __name__ == "__main__":
    main()
# Judge status: Accepted
A = list(map(int, input().split()))

A_sort = sorted(A)

if A_sort[0]==5 and A_sort[1]==5 and A_sort[2]==7:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
x = A.index(1)
y = len(A[:x]) // (K - 1)
z = len(A[x+1:]) // (K - 1)
ans += y + z
if y > 0:
    A = A[y*(K-1):]
if z > 0:
    A = A[:-1*z*(K-1)]
if len(A) == 1:
    ans += 0
elif len(A) <= K:
    ans += 1
else:
    ans += 2
#print(y,z,A)
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
print(-(-(n-1)//(k-1)))
# Judge status: Accepted
n, a, b = map(int, input().split())
mod = 10**9 + 7


def C(n, k):
    a = 1
    b = 1
    for i in range(k):
        a = a * (n-i) % mod
        b = b * (i+1) % mod
    return a * pow(b, mod-2, mod) % mod


ans = (pow(2, n, mod) - 1 - C(n, a) - C(n, b)) % mod

print(ans)
# Judge status: Wrong Answer
from collections import Counter

w=input()

d=Counter(w)

ans="Yes"

for i in d.values():
  if i%2==0:
    ans="No"
    break

print(ans)
# Judge status: Accepted
n, *aa = map(int, open(0).read().split())

d = [0]*n

cur = 1

ans = 0

while 1:
    d[cur-1] = 1
    cur = aa[cur-1]
    ans += 1
    if cur == 2:
        print(ans)
        break
    if d[cur-1]:
        print(-1)
        break
# Judge status: Wrong Answer
N = int(input())
mant = [0 for _ in range(N)]
for i in range(N):
    x, y = map(int, input().split())
    mant[i] = x + y

print(max(mant)-min(mant))
# Judge status: Accepted
a, b, x = map(int,input().split())
if a%x == 0:
    print(b//x-a//x+1)
else:
    print(b//x-a//x)
# Judge status: Accepted
D, T, S = map(int, input().split())

if D > S * T:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
from math import sqrt
def gcd(a,b):
  if a<b:
    a,b=b,a
  if b==0:
    return a
  else:
    return gcd(b,a%b)
a,b=map(int,input().split())
n=gcd(a,b)
#print(n)
ans=1
r=int(sqrt(n)+1)
#print(r)
for i in range(2,r):
  # print(i)
  if n%i==0:
    cnt=0
    while n%i==0:
      #print(n,end=" inside \n")
      n//=i
      cnt=1
    if cnt:
      ans+=1

if n>1:
  ans+=1
#print(n)
print(ans)
# Judge status: Accepted
#AtCoder Grand Contest 006 a
def check(moji):
    x1=""
    x2=""
    for i in range(n):
        x1+=moji[i]
        x2+=moji[len(moji)-n+i]
    if s==x1 and t==x2:
        return True
    else:
        return False
n=int(input())
s=input()
t=input()
ans=[]
ans.append(s)
for i in range(len(t)-1,-1,-1):
    ans.append(s+t[i:])
for i in ans:
    if check(i):
        print(len(i))
        break
# Judge status: Accepted
x = int(input())
# n, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
_max = 1
for i in range(1, x+1):
    for j in range(2, x+1):
        if pow(i, j) > _max and pow(i, j) <= x:
            _max = pow(i, j)
        if pow(i, j) > x:
            break

print(_max)
# Judge status: Accepted
s = list(map(str,input()))
if s[0] != "A":
  print("WA")
elif s[2:-1].count("C") != 1:
  print("WA")
else:
  del s[0]
  s.remove("C")
  if "".join(s).islower():
    print("AC")
  else:
    print("WA")
# Judge status: Wrong Answer
import math
N = int(input())
ans = 10**12
if N%2 == 0:
  for i in range(1,10**6+1):
    j = math.ceil(N/(i+1))
    if (1+i)*j == N:
      ans = min(i+j-1,ans)
print(ans)
# Judge status: Wrong Answer
k = int(input())

i = 0
n = 0
flg = 0
while True:
  i += 1
  s = str(i)
  for j in range(len(s)-1):
    if (int(s[j]) - int(s[j+1])) not in [-1, 0, 1]:
      if flg == 0:
        i += 8 * (10**(len(s)-2)) - 1
        flg = 1
      break
  else:
    n += 1
    flg=0
    print(i)
    if n == k:
      print(i)
      break
# Judge status: Accepted
print(sum(sorted(map(int, input().split()))[:2]))
# Judge status: Wrong Answer
n = int(input())
*a, = map(int,input().split())
g = [0] * (10**5 + 1)
s = 0
for A in a:
    g[A] += 1
    s += A
q = int(input())
for loop in range(q):
    b,c = map(int,input().split())
    s += g[b] * (c - b)
    g[c] += g[b]
    g[b] == 0
    print(s)
# Judge status: Wrong Answer
n=input().split()

if n[1]>=n[0]:
    print('Yes\n')
else:
    print('No\n')
# Judge status: Accepted
import bisect
n= int(input())
a = list(map(int,input().split()))
a.sort()
b = list(map(int,input().split()))
b.sort()
c = list(map(int,input().split()))
c.sort()

ans = 0
for y in b:
    x = bisect.bisect_left(a, y)#挿入点はどの同じ値よりも左
    z = bisect.bisect_right(c, y) #挿入点はどの同じ値より右
    ans += x * (len(c) - z)#b<a * b > cの組み合わせ
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
new_a=str(a)*b
new_b=str(b)*a
if new_a < new_b:
    print(new_a)
else:
    print(new_b)
# Judge status: Accepted
print("Yes" if input().count("9") > 0 else "No")
# Judge status: Wrong Answer
for a in range (1, 100, 1):
    for b in range (1, 100, 1):
        print(a * b)
# Judge status: Wrong Answer
N, M=map(int,input().split())
if N == M or N < M:
  for x in range(0, N):
    print(N, end="")
else:
  for x in range(0, N):
    print(M, end="")
# Judge status: Accepted
s = input()
p = 999

for i in range(len(s) - 2 ):
    j = s[i:i+3]
    j = int(j)
    if p > abs(753 - j):
        p = abs(753 - j)

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

if C >= A and C <= B:
    print("Yes")

else:
    print("No")
# Judge status: Accepted
n, l = map(int, input().split())

lis = []

for i in range(1,n+1):
    lis.append(l+i-1)

lis = sorted(lis)


if 0 in lis:
    lis.remove(0)
elif lis[0] >= 0:
    lis.remove(min(lis))
else:
    lis.remove(max(lis))
    
print(sum(lis))
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
for i in range(1,max(a,b)+1):
  if a%i==0 and b%i==0:
    k-=1
    if k==0:
      break
print(i)
# Judge status: Accepted
s = input()
ss = "".join(sorted(s))
if ss == "abc":
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
A, B = map(int, input().split())

ans = A + B % 24

print(ans)
# Judge status: Accepted
x = [0]*5

for i in range(5):
  x[i] = int(input())
  
k = int(input())
#print(k,x)
for i in range(5):
  for j in range(i,5):
    if(x[j] - x[i]  > k):
      print(":(")
      exit()
print("Yay!")
# Judge status: Accepted
N = input()

if int(N) % 9 == 0:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
def resolve():
    Q, H, S, D = list(map(int, input().split()))
    N = int(input())
    ans = 0

    ls = [[0.25, Q, 8*Q, 0], [0.5, H, 4*H, 0], [1, S, 2*S, 0], [2, D, D, 0]]
    ls.sort(key=lambda x: x[2])

    for i in range(4):
        if N < ls[i][0]:
            continue

        ls[i][3] += int(N // ls[i][0])
        N -= ls[i][0] * ls[i][3]

        ans += ls[i][1] * ls[i][3]

    ans = int(ans)
    print(ans)
    return


resolve()
# Judge status: Wrong Answer
import math as m
n, k = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    ans += (1 / n) * ((1 / 2) ** m.ceil(m.log(k / i, 2)))
print(ans)
# Judge status: Wrong Answer
N = int(input())
A_high_list = list(map(int,input().split()))
Fumidai = 0
s = 0
B_list = []

for n in range(N):
    if n > 0 and A_high_list[n-1] > A_high_list[n]:
        Fumidai += max(B_list) - A_high_list[n]
        B_list.append(A_high_list[n])
    elif n == 0:
        B_list.append(A_high_list[0])
        continue  
    else:
        B_list.append(A_high_list[n])
        continue

print(Fumidai)
# Judge status: Accepted
A, B, X = map(int, input().split())
print("YES" if A <= X and X <= A+B else "NO")
# Judge status: Wrong Answer
import bisect
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    B.sort()
    ans = 0

    for b in B:
        a_idx = bisect.bisect_left(A, b)
        c_idx = bisect.bisect_right(C, b)
        ans += a_idx * (N - c_idx)

    print(ans)

if __name__ == '__main__':
    solve()
# Judge status: Accepted
x, a, b = map(int, input().split())
if abs(a - x) < abs(b - x):
    print('A')
else:
    print('B')
# Judge status: Accepted
import math
x = int(input())
ans = math.ceil(x/1.08)
if x == math.floor(ans * 1.08):
    print(ans)
else:
    print(":(")
# Judge status: Accepted
def main():
    S = input()
    if "".join(sorted(S)) == "abc":
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
a = list(map(int,input().split()))
seven = a.count(7)
five = a.count(5)
if five==2 and seven==1:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N = int(input())
x = 800 * N
y = 200 * (N // 15)
ans = x - y
print(ans)
# Judge status: Accepted
s=list(input())
t=list(input())
# print(s)
# print(t)
sd=sorted(s)
td=sorted(t,key=lambda x:x[-1], reverse=True)
# print(sd)
# print(td)
if sd < td:
    print('Yes')
else:
    print(('No'))
# Judge status: Accepted
n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
# Pythonのpowは繰り返し二乗法で実装されている
ans = pow(2, n, MOD) - 1
product = 1
div = 1
for i in range(1, b + 1):
    product = product * (n - i + 1) % MOD
    div = div * i % MOD
    if i == a or i == b:
        # 逆元を求める
        ans -= product * pow(div, MOD - 2, MOD)
print(ans % MOD)
# Judge status: Accepted
K=int(input())
import queue
q = queue.Queue()
for i in range(1,10):
  q.put(i)
for i in range(K-1):
  a=q.get()
  if a%10!=0:
    q.put(10*a+(a%10)-1)
  q.put(10*a+(a%10))
  if a%10!=9:
    q.put(10*a+(a%10)+1)
print(q.get())
# Judge status: Wrong Answer
n = input()
op_cnt = len(n) - 1  # すき間の個数
for i in range(2**op_cnt):
  op = ['-'] * op_cnt
  for j in range(op_cnt):
    if (i >> j) & 1:
      op[op_cnt-1-j] = '+'
      formula = ''
      for p_n, p_o in zip(n, op + ['']):
        formula += (p_n + p_o)
      if eval(formula) == 7:
          print(formula + '=7')
          break
# Judge status: Accepted
W, a, b = map(int, input().split())

l = min([a, b])
r = max([a, b])

if l+W <= r:
    print(r-(l+W))
else:
    print(0)
# Judge status: Wrong Answer
a = int(input())
b = list(map(int, input().split()))
count = 0

for i in range(a):
  if i % 2 != 0:
    if b[i] % 2 != 0:
      count += 1
      
print(count)
# Judge status: Accepted
import sys
from collections import Counter
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
c = Counter(S)
bool = True
if (c['N']==0) ^ (c['S']==0):
    bool = False
if (c['E']==0) ^ (c['W']==0):
    bool = False

print('Yes' if bool else 'No')
# Judge status: Accepted
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
q = int(input())
x = [list(map(int, input().split())) for _ in range(q)]

s = sum(a)
d = defaultdict(int)
for ai in a:
    d[ai] += 1

for xi in x:
    b, c = xi
    s += d[b] * (c - b)
    print(s)
    d[c] += d[b]
    d[b] = 0
# Judge status: Wrong Answer
N=str(input())
s=list(map(int,input().split()))
ans=0
for i in s:
  if i%2==0:
    ans+=1
    i//=2
print(ans)
# Judge status: Wrong Answer
T =  list(input())

for i in range(len(T)) :
    if (i == 0 or i == len(T) - 1) and T[0] == '?' :
        T[0] = 'D'
    
    if T[i] == '?' :
        if T[i - 1] == 'P' :
            T[i] = 'D'
        else :
            T[i] = 'P'
            
    print(T[i], end = '')
# Judge status: Accepted
title = input().split(" ")
name = title[1]
fst = list(name)
print("A"+fst[0]+"C")
# Judge status: Wrong Answer
a,b,c,k = map(int, input().split())
cheak = 10**18
def calc(a,b,c,k):
    if a == b == c:
        return 0
    elif a < b:
        if k % 2 == 1:
            return -(a-b)
        else:
            return a-b
    else:
        if k % 2 == 1:
            return a-b
        else:
            return -(a-b)
ans = calc(a,b,c,k)
if ans > cheak:
    print("Unfair")
else:
    print(ans)
# Judge status: Accepted
import collections
S = list(map(int, list(input())))
N = len(S)

dp = [0]*N
if N < 4:
    print(0)
    exit(0)

ans = 0

D = [0]*N
D[0] = 1
for i in range(1, N):
    D[i] = D[i-1]*10 % 2019
t = collections.defaultdict(int)
tmp = 0

t[0] += 1
for i in range(N):
    tmp += S[N-1-i]*D[i]
    tmp %= 2019
    t[tmp] += 1

for x in t:
    ans += t[x]*(t[x]-1) // 2

# print(N)
# print(*dp, sep='\n')

print(ans)
# Judge status: Accepted
s = list(input())
t = list(input())

s.sort()
t.sort(reverse=True)

ans = 'Yes' if s < t else 'No'
print(ans)
# Judge status: Wrong Answer
#A
s=input()
if s[-1]=='e':
    s=s+'s'
else:
    s=s+'es'
print(s)
# Judge status: Wrong Answer
string_data = list(input())

N = len(string_data)
match_word_lits = ['A', 'C', 'G', 'T']
count = 0
max_word = 0
for i in range(N):
    if string_data[i] in match_word_lits:
        count += 1
    else:
        if max_word < count:
            max_word = count
        count = 0

print(max_word)
# Judge status: Wrong Answer
N = int(input())
AB = [list(map(int, input().split())) for n in range(N)]

if N % 2 == 0:
  k1 = int(N/2-1)
  k2 = int(N/2)
  pattern = set()
  for i in range(AB[k1][0], AB[k1][1]+1):
    for j in range(AB[k2][0], AB[k2][1]+1):
      pattern.add(i+j)
  
  print(len(pattern))
else:
  k = int((N+1)/2)-1
  A = AB[k][0]
  B = AB[k][1]
  print(B-A+1)
# Judge status: Accepted
s = input()

if s[0]==s[1] and s[0]==s[2]:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
s = input()
if s == s.upper:
  print("A")
else:
  print("a")
# Judge status: Accepted
N = int(input())
A = [a - 1 for a in map(int, input().split())]
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
prev = 100000
for a in A:
    if prev + 1 == a:
        ans += B[a] + C[a - 1]
    else:
        ans += B[a]

    prev = a

print(ans)
# Judge status: Wrong Answer
n, t = map(int, input().split())
c = 999
for i in range(n):
    tmp = input().split()
    if int(tmp[1]) > t:
        pass
    elif int(tmp[1]) <= t:
        if int(tmp[0]) <= int(c):
            c = tmp[0]
    else:
        pass
if i == n-1 and c == 999:
    print('TLE')
    exit()
else:
    print(c)
# Judge status: Accepted
A, B =map(int,input().split())
answer = 0
if A >=13:
	answer = B
elif A >= 6:
		answer = B/2
print(int(answer))
# Judge status: Accepted
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for h in range(c + 1):
            if 500 * i + 100 * j + 50 * h == x:
                ans += 1
                #print(i, j, h)
print(ans)
# Judge status: Accepted
m, n = map(int, input().split(" "))
if n - m >= 673:
    print(0)
else:
    score = m * n % 2019
    for i in range(m, n + 1):
        for j in range(i + 1, n + 1):
            if (i * j) % 2019 < score:
                score = (i * j) % 2019
    print(score)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
x = [0 for i in range(60)]
for i in range(n):
    b = bin(a[i])
    for i in range(len(b)-2):
        x[-i-1] += int(b[-i-1])
mod = 10**9+7
ans = 0
two = 1
for i in range(1,60):
    ans = (ans + x[-i]*(n-x[-i])*two)%mod
    two = two*2%mod
print(ans)
# Judge status: Wrong Answer
import math
n, l = map(int, input().split())
a_l = [l + i for i in range(n)]

min1 = 100
min2 = 10000

for j in a_l:
    if j ** 2 <= min2:
        min2 = j **2
        min1 = j
print(sum(a_l) - j)
# Judge status: Wrong Answer
n,m = map(int,input().split())
dp = [1]*(n+2) 
dp[1] = 2
mod = 10**9 + 7
for i in range(m):
    a = int(input())
    dp[a-1] = 0
if dp[0] == 0:
    dp[1] =1

for i in range(1,n+2):
    if dp[i] == 0:
        continue
    else:
        if i == 1:
            dp[i]=dp[i-1]+1
        else:
            dp[i] = (dp[i-1] + dp[i-2])%mod
        #print(dp)
print(dp[n-1])
# Judge status: Accepted
r, g, b = map(int, input().split())
num = r * 100 + g * 10 + b * 1
if num%4 == 0:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
mod = 10**9+7
n,m = map(int,input().split())
a = set()
for i in range(m):
    a.add(int(input()))
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1) :
    dp[i] = (dp[i-1] + dp[i-2]) % mod
    if i in a :
        dp[i] = 0
print(dp[n])
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))*2
a.sort()
print(sum(a[n:-1]))
# Judge status: Accepted
# coding: utf-8
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
s=sum(l)
c=0
m=10000000000000000
for i in range(n-1):
    c+=l[i]
    d=s-c
    a=abs(d-c)
    m=min(m,a)
print(m)
# Judge status: Accepted
h , a = map(int , input().split())
ans = 0

while h > 0:
    h -= a
    ans += 1
print(ans)
# Judge status: Wrong Answer
import heapq
n, m = map(int, input().split())
work = [list(map(int, input().split())) for _ in range(n)]
work.sort(key=lambda x:x[0])

cd = []
heapq.heapify(cd)
cnt = 0
ans = 0

# aの条件
for k in range(1, m+1):
    for i in range(cnt, n):
        a, b = work[i]

        if k < a:
            cnt = i
            break
        heapq.heappush(cd, [-b, a])

    if not cd:
        continue
    ans += -heapq.heappop(cd)[0]
print(ans)
# Judge status: Accepted
import re
n,a,b,c,d = map(int,input().split())
s = input()
a,b,c,d = map(lambda x:x-1,[a,b,c,d])

if re.search(r'##',s[a:max(b,d)+1]):
    print('No')
else:
    if c>d:
        if (re.search(r'\.{3,}',s[b-1:d+2])):
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')
# Judge status: Accepted
s = input()
t = input()

if "".join(sorted(s)) < "".join(list(reversed(sorted(t)))):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
lst = list(map(int,input().split()))
c1 = 0
c2 = 0
for i in lst:
  if (i % 4 == 0):
    c1 += 1
  elif (i % 2 != 0):
    c2 += 1
    
ans = 'No'
if (len(lst) % 2 == 0):
  if (c1 >= c2):
    ans = 'Yes'
else:
  if (c1 >= c2 - 1):
    ans = 'Yes'
print(ans)
# Judge status: Accepted
# 先頭から見ていく
# A_i // 2個は自分同士でペアを作ってよい
# 1枚余ったら、A_i+1が0でなければA_i+1から1減らしてペアを作る。
# この貪欲でOK

import sys
readline = sys.stdin.readline

N = int(readline())
A = [int(readline()) for i in range(N)]

ans = 0
for i in range(N):
  pair, mod = divmod(A[i],2)
  ans += pair
  if mod == 1 and i != N - 1 and A[i + 1] > 0:
    ans += 1
    A[i + 1] -= 1
  
print(ans)
# Judge status: Accepted
s=int(input())
large=10**9
if s==10**18:
    print(0,0,10**9,1,0,10**9)
else:
    y3=s//large+1
    x3=y3*large-s
    print(0,0,10**9,1,x3,y3)
# Judge status: Wrong Answer
n = int(input())
lst = [int(input()) for i in range(5)]
mini = min(lst)
ans = n // mini + 5
print(ans)
# Judge status: Accepted
n = input()

cnt = len(n)

ans = 0
for i in range(cnt):
    ans += int(n[i])

if ans % 9 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
from collections import Counter

N = int(input())
S = [Counter(input()) for _ in range(N)]
aplhabet = 'abcdefghijeklmnopqrstuvwxyz'

ans = ''
for a in aplhabet:
  a_min = float('inf')
  for s in S:
    a_min = min(a_min, s[a])
  ans += a * a_min

print(ans)
# Judge status: Accepted
n, l = map(int, input().split())
a = []
if n == 1:
  print(input())
  exit()
for i in range(n):
  a.append(input())
a.sort()
a = ''.join(a)
print(a)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
c=0
all=sum(A)
buf=all
A1=[]
A2=[]
s1=0
s2=0
c=float("inf")
for i in range(N-1):
    buf=buf-A[i]
    if c>abs((all-buf)-buf):
        c=abs((all-buf)-buf)
    else:
        break
print(c)
# Judge status: Wrong Answer
n = int(input())
D = sorted(list(map(int, input().split())))
d_set = list(set(D))
MOD = 998244353

from collections import Counter
c = Counter(D)
res = 1
for k, v in c.items():
    if k == 0: continue
    res *= pow(k, v)
    res %= MOD

bl = True
if d_set[0] != 0:
    bl = False
for i in range(1, len(d_set)):
    if d_set[i] - d_set[i - 1] != 1:
        bl = False

print(res) if bl else print(0)
# Judge status: Accepted
import random
D = int(input())
ans = [random.randint(1,26) for i in range(D)]
print('\n'.join(map(str, ans)))
# Judge status: Accepted
import sys
range = xrange
input = raw_input

S = input()
start = []
end = []
par = 1

q = int(input())
for _ in range(q):
    quer = input()
    if quer == '1':
        par ^= 1
    else:
        _, f, c = quer.split()
        f = int(f) - 1
        if par ^ f:
            start.append(c)
        else:
            end.append(c)

T = ''.join([''.join(reversed(start)), S, ''.join(end)])

if par:
    print T
else:
    print T[::-1]