peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
x=int(input())
#n=1
#while 1/2*(n**2+n)<x:
#  n+=1
#print(n)

left=0
right=x
while right-left>1:
  mid=(left+right)//2
  if (mid**2+mid)/2==x:
    right=mid
    break
  if (mid**2+mid)/2<x:
    left=mid
  else:
    right=mid
print(right)
# Judge status: Wrong Answer
n=int(input())
l1=[]
l2=[]
for i in range(n):
    sp=input().rstrip().split()
    l1.append(sp[0])
    l2.append(-int(sp[1]))
l=list(zip(l1,l2))

ans=sorted(l)
print(ans)
for i in range(len(ans)):
    print(l.index(ans[i])+1)
# Judge status: Wrong Answer
import sys

n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
	numa,numb=map(int,input().split())
	a.append(numa)
	b.append(numb)
bb=[]
aa=[]
if not 1 in a or not n in b:
	print("INPOSSIBLE")
	sys.exit()
for j in range(len(a)):
    if 1==a[j]:
        bb.append(b[j])
for k in range(len(b)):
    if n==b[k]:
        aa.append(a[k])
print("INPOSSIBLE" if set(aa)&set(bb)=='' else "POSSIBLE")
# Judge status: Wrong Answer
a,b = map(int, input().split())

if (a*b) % 2 == 0:
  print("Even")
else:
  print("odd")
# Judge status: Accepted
l = list(input())
n = 0
for i in l:
  if i == '1':
    n = n + 1
print (n)
# Judge status: Accepted
n,m,x=map(int,input().split())
ans=10**9
from itertools import combinations as co
l=[list(map(int,input().split())) for _ in range(n)]
for i in range(1,n+1):
  for ch in co(range(n),i):
    f=1
    t=[0]*m
    s=0
    for j in ch:
      s+=l[j][0]
      for k in range(1,m+1):
        t[k-1]+=l[j][k]
    for test in t:
      if test<x:
        f=0
        break
    if f:
      ans=min(ans,s)
if ans==10**9:
  ans=-1
print(ans)
# Judge status: Accepted
import itertools

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

A_list = list(itertools.combinations_with_replacement(range(1,m+1),n))

ans = 0
for A in A_list:
    sum = 0
    for a,b,c,d in abcd:
        if A[b-1] - A[a-1] == c:
            sum += d
    ans = max(ans, sum)

print(ans)
# Judge status: Wrong Answer
s = input()
s = s[::-1]
s = list(str(s))

for i in range(len(s)):
    if s[i] == '?':
        if s[i-1] == 'P':
            s[i] = 'D'
        elif s[i-1] == 'D':
            s[i] = 'P'
s = s[::-1]

print(''.join(s))
# Judge status: Accepted
# Enter your code here. Read input from STDIN. Print output to STDOUT

import numpy as np
from sys import stdin


def get_result(data):
    H, N = data[0]
    A = sorted(data[1])
    return 'No' if sum(A[:N]) < H else 'Yes'

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split(' ')))

import numpy as np

neg_cnt = len(list(filter(lambda x: x<0, A)))
abs_lis = np.abs(A)
sum_abs = sum(abs_lis)
if neg_cnt % 2 ==0:
    print(sum_abs)
else:
    print(sum_abs-2*min(abs_lis))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
from itertools import accumulate
ans=10**10
a=list(accumulate(a))
for i in range(n-1):
     ans=min(ans,abs(a[-1]-2*a[i]))
print(ans)
# Judge status: Accepted
N,X,T=(int(x) for x in input().split())
counter=0

while(N>X):
    counter+=1
    N=N-X

counter+=1

print(counter*T)
# Judge status: Accepted
a, b = map(int, input().split())

import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm_base(a, b))
# Judge status: Wrong Answer
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

n,m,*ab = map(int,open(0).read().split())

a = ab[::2]
b = ab[1::2]

L = csr_matrix(([1]*m,(a,b)),shape=(n+1,n+1))
               
_, route = dijkstra(L ,directed = False, indices = 1, return_predecessors = True)

if (route[2:]>0).all():
    print("Yes")
    print("\n".join(map(str,route[2:])))
else:
    print("No")
# Judge status: Accepted
import math
number =int(input())

def judge_prime(number):
  n = math.floor(number**0.5)
  ar=list(range(n))+[n]
  ar.pop(0)
  ar.pop(0)
  for i in ar:
    if number%i==0:
      return 0
  return number

t = 0
while t == 0:
  if judge_prime(number) == number:
    t+=1
  else:
    number+=1
print(number)
# Judge status: Accepted
S = input()
T = input()

len_S = len(S)
len_T = len(T)

ans = 10**10
for i in range(len_S - len_T+1):
    num = 0
    for j in range(len_T):
        if S[i+j] != T[j]:
            num+=1
    ans = min(ans, num)

print(ans)
# Judge status: Accepted
r, g, b = map(int, input().split())

num = 100*r + 10*g + b

if num%4==0:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
n,m=map(int,input().split())
A,B,C,D=[],[],[],[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
for i in range(m):
    c,d=map(int,input().split())
    C.append(c)
    D.append(d)
for i in range(n):
    ans,x=100000000,0
    for j in range(m):
        if ans>abs(A[i]-C[j])+abs(B[i]-D[j]):
            ans=abs(A[i]-C[j])+abs(B[i]-D[j])
            x=j
    print(x+1)
# Judge status: Wrong Answer
a = list(input())
a.sort()
print(a)
a = "".join(a)
if a == "abc":
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S = str(input())
K = int(input())

N = len(S)

L = []

for i in range (0, N):
	L.append((97-ord(S[i]))%26)

W = []

for i in range (0, N-1):
	if L[i] <= K:
		W.append('a')
		K -= L[i]
	else:
		W.append(S[i])

V = (26-L[N-1]+K)%26
W.append(chr(97+V))
print(*W, sep="")
# Judge status: Accepted
W,H,N = map(int, input().split())
start = [0,0]
end = [W,H]

for _ in range(N):
    x,y,a = map(int, input().split())
    if a == 1:
        start[0] = max(x, start[0])
    elif a == 2:
        end[0] = min(x, end[0])
    elif a == 3:
        start[1] = max(y, start[1])
    else:
        end[1] = min(y, end[1])

print(max(0, end[0]-start[0])*max(0, end[1]-start[1]))
# Judge status: Wrong Answer
s, w = input().split()
if s <= w:
    print("unsafe")
else:
    print("safe")
# Judge status: Accepted
O = input()
E = input()
ans = ''
for i in range(len(E)):
    ans += O[i] + E[i]
if len(O) > len(E):
    ans += O[-1]
print(ans)
# Judge status: Wrong Answer
n = int(input())

min_v = 100000

for i in range(2, n - 1):
    b = n - i
    s = sum(list(map(int, str(i)))) + sum(list(map(int, str(b))))
    if s < min_v:
        min_v = s

print(min_v)
# Judge status: Accepted
N,Q=map(int,input().split())
S=input()
A=[list(map(int,input().split())) for i in range(Q)]

X=[0]*(N)
cnt=0
for i in range(N-1): 
  if S[i]=='A' and S[i+1]=='C':
    cnt+=1
    X[i+1]=cnt
  else:
    X[i+1]=cnt
    
for i in range(Q):
  a=A[i][0]-1
  b=A[i][1]-1
  print(X[b]-X[a])
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
ans=0
while a%2==0 and b%2==0 and c%2==0:
  d,e,f=0,0,0
  d=(b+c)//2
  e=(a+c)//2
  f=(a+b)//2
  a,b,c=d,e,f
  ans+=1
  if ans==100000:
    break
print(ans)
# Judge status: Accepted
s = input()
t = input()
ans = "No"
for x,y in zip(s,t):
    if x != y: break
else:
    ans = "Yes"
print(ans)
# Judge status: Wrong Answer
try:
  n,k=map(int,input().split())
  count=0
  l,p=[],[]
  for i in range(k):
      d=int(input())
      a=list(map(int,input().split()))
      for i in range(1,n+1):
          if i not in a:
              l.append(i)
  for i in l:
      if l.count(i)>1:
          if i not in p:
              p.append(i)
  print(len(p))
except:
  pass
# Judge status: Accepted
import re
s = input()
s = s.replace("?", ".")
t = input()
if len(t) > len(s):
  print("UNRESTORABLE")
else:
  r = []
  for i in range(len(s)-len(t)+1):
    m = re.match(s[i:i+len(t)], t)
    if m is None:
      continue
    r.append((s[:i]+t+s[i+len(t):]).replace(".","a"))
  if not r:
    print('UNRESTORABLE')
    quit()
      
  print(min(r))
# Judge status: Wrong Answer
l,r,d = map(int,input().split())
print((r-l+1)//d)
# Judge status: Accepted
n,k = map(int,input().split())
person = []
for i in range(k):
    num_d = int(input())
    d_list = input().split()
    person.extend(d_list)
person = list(set(person))
print(n-len(person))
# Judge status: Accepted
# D - Sum of Divisors

n = int(input())

# n以下の1の倍数 ... n個, それぞれk倍して加算 ... n * (n+1) // 2
# n以下のmの倍数 ... n//m個, それぞれk倍して加算 ... m * (n // m) * (n // m + 1) // 2

s = sum(m * (n // m) * (n // m + 1) // 2 for m in range(1, n + 1))
print(s)
# Judge status: Wrong Answer
import sys
x,y = map(int,input().split())

if x <= 0 or x >= 13 or y <= 0 or y >= 13:
    sys.exit()
if x >= y:
    sys.exit()

A = (1, 3, 5, 7, 8, 10, 12)
B = (4, 6, 9, 11)

if x == 2 or y == 2:
    print("No")
    sys.exit()
if x in A and y in A:
    print("Yes")
    sys.exit()
if x in B and y in B:
    print("Yes")
    sys.exit()
# Judge status: Accepted
n = int(input())
ans = 0
i = 2

while n>1 and i*i<=n:
  if n % i == 0:
    c = 0
    while n % i == 0:
      n = n / i
      c += 1
    Y=1
    U=2
    while c>=Y:
      ans=ans+1
      Y=Y+U
      U=U+1

  i = i + 1
      
    
if n > 1:
  ans = 1 + ans

print(ans)
# Judge status: Accepted
l = list(map(int,input().split()))
for i in range(len(l)):
  if l[i] == 0:
    print(i+1)
# Judge status: Accepted
N,M,X = map(int,input().split())
Book = []
for i in range(N):
  Book.append(list(map(int,input().split())))
Cost = 10**15
for i in range(2**N):
  cost = 0
  A = [0 for i in range(M)]
  num = []
  j = 0
  while i > 0:
    if i%2 == 1:
      num.append(j)
    i = i//2
    j += 1
  for k in num:
    A = [x+y for (x,y) in zip(A,Book[k][1:])]
    cost += Book[k][0]
  if min(A) >= X:
    if cost < Cost:
      Cost = cost
if Cost == 10**15:
  print(-1)
else:
  print(Cost)
# Judge status: Accepted
s = list(input())
t = list(input())
for i in range(len(s)-len(t)+1):
  dame = 0
  for j in range(len(t)):
    if s[len(s)-len(t)-i+j] != t[j] and s[len(s)-len(t)-i+j] != "?":
      dame = 1
      break
  if dame == 1:
    continue
  for j in range(len(t)):
      s[len(s)-len(t)-i+j] = t[j]
  for j in range(len(s)):
      if s[j] == "?":
        s[j] = "a"
  print("".join(s))
  exit()
print("UNRESTORABLE")
# Judge status: Accepted
n = int(input())
n %= 500
a = int(input())
if n <= a:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N, K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

l, r = sum(A)//(N+K), A[-1]
if l == 0: l = 1

while l+1 < r:
    m = (l+r) // 2

    cuts = sum([(a-1)//m for a in A])

    if cuts <= K:
        r = m
    else:
        l = m

print(r)
# Judge status: Accepted
a, b, c, k = map(int, input().split())
if k <= a:
    print(k)
elif a < k <= a + b:
    print(a)
else:
    print(a - (k - (a + b)))
# Judge status: Wrong Answer
D =int(input())
print('Christmas'+'Eve'*(25-D))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

a.sort()
now = 1e18
ans = 0
for r in a:
    d = abs(r - a[n - 1] / 2)
    if d < now:
        ans = r
        now = d
print(a[n-1], ans)
# Judge status: Accepted
def solve(str):
  ans = ""
  for s in str:
    if s == '0':
      ans += '0'
    elif s == '1':
      ans += '1'
    elif s == 'B':
      if len(ans) == 0:
        continue
      else:
        ans = ans[:-1]
    else:
      RuntimeError("input is not 0 or 1 or B.")
      return
  return ans

if __name__ == "__main__":
  s = input()
  ans = solve(s)
  print(ans)
# Judge status: Wrong Answer
n = list(input())

if n[0] != '9':
    n[0] = str(int(n[0])-1)
    if n.count('9') != len(n)-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: Accepted
S = list(input())
T = list(input())
count = 0
for i in range(len(S)):
  if S[i] != T[i]:
    count += 1
print(count)
# Judge status: Accepted
k,s=map(int,input().split())
ans=0

for x in range(k+1):
    for y in range(k+1):
        z=s-(x+y)
        if z>=0 and z<=k:
            ans+=1
print(ans)
# Judge status: Accepted
n = int(input())
a=list(map(int,input().split()))
 
kane=1000
kabu =0
 
for i in range(n-1):
    if a[i]<=a[i+1]:
        kabu+=kane//a[i]
        kane=kane%a[i]
    else:
        kane+=kabu*a[i]
        kabu=0

print(kane+kabu*a[n-1])
# Judge status: Wrong Answer
n, m = map(int, input().split())
c = [0] * m
for i in range(n):
    k, *a = map(int, input().split())
    print(a)
    for e in a:
        c[e-1] += 1

ans = 0
for i in range(m):
    if c[i] == n:
        ans += 1

print(ans)
# Judge status: Accepted
s = input()
if len(set(s)) == len(s):
    print('yes')
else:
    print('no')
# Judge status: Wrong Answer
def resolve():
	n, m = map(int, input().split())
	A = []
	B = []
	ans = "No"
	for _ in range(n):
		A.append(list(input()))
	for _ in range(m):
		B.append(list(input()))
	for i in range(n):
		for j in range(n):
			if i + m >= n or j + m >= n:
				continue
			tmp_ans = True
			for k in range(m):
				for l in range(m):
					if A[i+k][j+l] != B[k][l]:
						tmp_ans = False
						break
			ans = tmp_ans


	if ans:
		print('Yes')
	else:
		print('No')
resolve()
# Judge status: Accepted
A=list(int(input()) for _ in range(5))
B=[]
C=[]
for i in A:
    if i%10!=0:
        B.append(i%10)
        C.append((i//10+1)*10)
    else:
        C.append(i)
if len(B)>0:
    c=10-min(B)
else:
    c=0
print(sum(C)-c)
# Judge status: Accepted
import sys
a,b,c=map(int,input().split())
if a==b and b!=c:
  print("Yes")
  sys.exit()
elif c==b and b!=a:
  print("Yes")
  sys.exit()
elif a==c and b!=c:
  print("Yes")
  sys.exit()
else:
  print("No")
  sys.exit()
# Judge status: Accepted
x = int(input())

if x <= 6:
    print(1)
else:
    ans = (x//11)*2
    if x%11 == 0:
        print(int((x/11)*2))
    elif (x//11)*11 +6 >= x:
        print(ans+1)
    else:
        print(ans+2)
# Judge status: Wrong Answer
n = input()
p = input().split()

cnt = int(n)

for i in range(int(n)):
    if i == 0:
        min = p[i]
    if p[i] > min:
        cnt = cnt - 1
    else:
        if(min > p[i]):
            min = p[i]
print(cnt)
# 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,a,b = map(int, input().split())
if n == 1 and a==b:
    print(1)
elif n == 1 or a > b:
    print(0)
else:
    print((n-2)*(b-a)+1)
# Judge status: Accepted
X, Y = list(map(int, input().split()))

ans = 0

while X <= Y:
    ans += 1
    X = 2*X

print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
if (a <= 9) & (b <= 9):
    print(a * b)
else:
    print(-1)
# Judge status: Accepted
ABC=list(map(int,input().split()))
print("YES" if ABC.count(5)==2 and ABC.count(7)==1 else "NO")
# Judge status: Accepted
a = int(input())
l = list(map(int, input().split()))
cnt = 0
num = 1
if 1 in l:
  for i in range(a):
    if l[i] == num:
      num += 1
    else:
      cnt += 1
  print(cnt if cnt > 0 else 0)
else:
  print(-1)
# Judge status: Wrong Answer
X, Y = [int(x) for x in input().split()]
M = 10**9+7
if (X + Y) % 3:
  print(0)
else:
  x = X - (X+Y)//3
  y = Y - (X+Y)//3
  #print(x, y)
  #x+y c x
  #(x+y)!/x!/y!
  ans = 1
  for j in range(y):
    #print(j)
    #print(x+j+1, j+1)
    ans *= (x+j+1) * pow(j+1, -1, M)
    ans %= M
  print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
m2 = 0
m4 = 0
other=0
for i, aa in enumerate(a):
    if aa % 4 == 0:
        m4 +=1
        continue
    if aa % 2 == 0:
        m2 += 1
        continue
    other += 1
if m4 >= other or (m4 + 1 == other and m2 == 0):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

ans = set()
cnt = 0
for a in A:
    if a >= 3200:
        cnt += 1
    else:
        ans.add(a // 400)

mx = len(ans) + cnt
mi = max(1, len(ans))

print(mi, mx)
# Judge status: Accepted
N = int(input())
X = list(map(int, input().split()))

sum_list = []
for p in range(min(X), max(X)+1):
    _sum = 0
    for x in X:
        _sum += abs(p-x) ** 2

    sum_list += [_sum]

print(min(sum_list))
# Judge status: Wrong Answer
A = 20
B = 20
print(A*B)
# Judge status: Accepted
N =int(input())
W=list(map(int,input().split()))

sum=0
for i in range(0,N):
    sum=sum+W[i]

S=[0,sum]
m=sum

for i in range(0,N):
    S[0]=S[0]+W[i]
    S[1]=S[1]-W[i]
    x=abs(S[0]-S[1])
    if x<m:
        m=x

print(m)
# Judge status: Accepted
h1,m1,h2,m2,k=map(int,input().split())

hour=h2-h1
minu=m2-m1

sum=hour*60+minu

print(sum-k)
# Judge status: Accepted
N,M=map(int,input().split())
print(min(N,M//2)+max(M-N*2,0)//4)
# Judge status: Accepted
l = float(input())
ans = (l**3)/27
print(ans)
# Judge status: Accepted
import math
def jud(n):
    cnt=0
    while (True):
        if (n % 2 == 0):
            n /= 2
            cnt += 1
        else:
            break
    return cnt

n = int(input())
cnt = 0
ans=1
for i in range(n):
    tmp=jud(i+1)
    if (cnt < tmp):
        cnt = tmp
        ans = i + 1
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
S = list(input())
count = 0
f = True
for i in range(N - 1):
    if S[i] == S[i + 1]:
        count += 1
ans = count + 2 * K
if ans < N - 1:
    print(ans)
else:
    print(N - 1)
# Judge status: Wrong Answer
a,b,k = map(int,input().split())

t = set()
for i in range(a, min(a + k,b)):
    t.add(i)

for i in range(b, max(b - k,a), -1):
    t.add(i)

l = sorted(list(t))

for i in l:
    print(i)
# Judge status: Accepted
n=int(input())
ans=0
x=n//11
ans+=2*x
n-=11*x
if n>=7:
    ans+=2
elif 0<n<=6:
    ans+=1
print(ans)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
N,M=map(int,input().split())
A=list(map(int,input().split()))
import fractions
from functools import reduce
def lcd_base(X,Y):
    return (X*Y)//fractions.gcd(X,Y)
def lcd(*numbers):
    return reduce(lcd_base,numbers,1)

gcd_number=lcd(*A)//2
temp_ans=M//gcd_number
if temp_ans%2==0:
    print(temp_ans//2)
else:
    print(temp_ans//2+1)
# Judge status: Accepted
a=int(input())
b=int(input())
if a==3:
  print(3-b)
elif b==3:
  print(3-a)
else:
  print(3)
# Judge status: Accepted

def main():
    n = int(input())
    s = input()
    t = input()

    if s == t:
        print(n)
        return

    for i in reversed(range(0, n)):
        target = s + t[i:]
        if target.startswith(s) and target.endswith(t):
            print(len(target))
            return

main()
# Judge status: Wrong Answer
import sys

def input():
    return sys.stdin.readline().strip()

def main():

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

    if N == 1:
        print(0)
        exit()

    if A.count(A[0]) == 1:
        ans += 1

    for i in range(1,len(A)):
        for j in range(i):
            if A[i] % A[j] == 0:
                break
        else:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
S = input()
T= input()
count = 0

for i in range(0,len(S)):
    if S[i] != T[i]:
        count +=1

print(count)
# Judge status: Accepted
n,m,l = map(int, input().split())

count = n+m+l

if count > 21:
    print("bust")
else:
    print("win")
# Judge status: Accepted
#!/usr/bin/env python3

n = int(input())


ans = 0
for i in range(1, n+1):
    if i % 2 == 0:
        continue
    tmp = 0
    for j in range(1, i+1):
        if i % j == 0:
            tmp += 1
    if tmp == 8:
        ans += 1

print(ans)
# Judge status: Accepted
N,K = map(int,input().split())
import numpy as np
H = np.array(input().split(), dtype = int)

INF = 10 ** 9 + 1
dp = np.full(N,INF,dtype = int)
dp[0] = 0

for i in range(1, N):
  dp[i] = min(dp[max(i - K,0):i] + abs(H[max(i - K,0):i] - H[i]))

print(dp[-1])
# Judge status: Accepted
def main():
  x, k, d = map(int, input().split())
  if x < 0:
    x *= -1
  if x - d < 0:
    if k%2==0:
      print(x)
    else:
      print(d - x)
  elif x - k*d > 0:
    print(x - k*d)
  else:
    k -= x//d
    if k%2==0:
      print(x%d)
    else:
      print(-(x%d-d))

if (__name__=='__main__'):
  main()
# Judge status: Accepted
import math


#n=map(int,input().split())
a=int(input())
print(a+a*a+a*a*a)
# Judge status: Accepted
#!/usr/bin/env python3

def judge(k):
    n = str(k)
    return n[0] == n[4] and n[1] == n[3]

def solve(a,b):
    c = 0
    for i in range(a,b+1):
        if judge(i):
            c += 1
    return c 

def main():
    A,B = map(int,input().split())
    print(solve(A,B))

if __name__ == '__main__':
    main()
# Judge status: Accepted
w=input()
ans=[]
for i in range(len(w)):
    count = 0
    for j in range(len(w)):
        if w[i]==w[j]:
            count+=1
    if count%2==1:
        ans.append(count)
if ans == []:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
X = int(input())
i = 1
N = 0
while N <= X:
    N += i
    i += 1
i -= 1
N -= i
i -= 1
N -= i
X -= N
while X != i:
    i += 1
print(i)
# Judge status: Accepted
N = int(input())
A = [0]
A += list(map(int, input().split()))
B = [0] * N
for i in range(1,N):
    B[A[i]-1] += 1
for j in range(N):
    print(B[j])
# Judge status: Accepted
A, B, C, D = map(int, input().split())

if -(-A // D) >= -(-C // B):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = list(input())
for a in range(len(s)):
  if s[a] == 'A':
    break
for z in range(len(s)-1,-1,-1):
  if s[z] == 'Z':
    break
print(z-a+1)
# Judge status: Accepted
n = int(input())
b = list(map(int,input().split()))

ans = b[0]

for i in range(n-2):
  ans = ans + min(b[i],b[i+1])

ans = ans + b[n-2]
  
print(ans)
# Judge status: Wrong Answer
n = int(input())
x = 1
a = list(map(int,input().split()))
for i in range(n):
  x *= a[i]
if x >= 10**18:
  print(-1)
else:
  print(x)
# Judge status: Wrong Answer
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

cookies = np.array(lr())
if len(set(cookies)) == 1:
    print(-1)
    exit()
if any(cookies&1):
    print(0)
    exit()
count = 0
half_total = cookies.sum() // 2
while True:
    cookies = half_total - cookies//2
    print(cookies)
    count += 1
    if any(cookies&1):
        print(count)
        break
    if count == 10000:
        print(-1)
        exit()
# Judge status: Accepted
n, a, b = map(int, input().split())
M = 10**9 + 7
total = pow(2, n, M)

def comb(n, k, p):
    if k > n-k:
        return comb(n, n-k, p)
    num, den = 1, 1
    for i in range(k):
        num = num * (n-i) % p
        den = den * (i+1) % p
    return num * pow(den, p-2, p) % p

print((total - 1 + (M - comb(n,a,M)) + (M - comb(n,b,M))) % M)
# Judge status: Accepted
import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        bi = bisect.bisect_left(l, l[i]+l[j])
        cnt += bi-j-1
print(cnt)
# Judge status: Accepted
N,M=map(int,input().split())
l=[]
for i in range(M):
  l.extend(map(int,input().split()))
for i in range(N):
  print(l.count(i+1))
# Judge status: Accepted
# D - Replacing
def main():
    N, *X = map(int, open(0).read().split())
    A, BC = X[:N], X[N + 1 :]
    cnt = [0] * (10 ** 5 + 1)
    for a in A:
        cnt[a] += 1
    total = sum(A)
    res = []
    for b, c in zip(*[iter(BC)] * 2):
        total += (c - b) * cnt[b]
        res.append(total)
        cnt[c] += cnt[b]
        cnt[b] = 0
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a=input()
b=input()
if a in b:
  if a[0]==b[0]:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(min(k, 45)):
    b = [0] * n
    for j in range(n):
        mi = max(0, j-a[j])
        ma = min(n-1, j+a[j])
        b[mi] += 1
        if ma + 1 <= n -1:
            b[ma+1] -= 1
    c = [0] * n
    s = 0
    for k in range(n):
        s += b[k]
        c[k] = s
    a = c

for i in a:
    print(i, end=' ')
# Judge status: Accepted
N=int(input())
cnt = 0
ans = 0
for i in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        cnt += 1
        if cnt == 3:
            ans += 1
            print("Yes")
            break
    else:
        cnt = 0
if ans == 0:
    print("No")
# Judge status: Accepted
n, l = map(int, input().split())
s = sorted([input() for i in range(n)])
print(*s, sep = "")