'''
Created on 20-Jan-2022

@author: bthakur
'''

import inspect
import traceback
import random
import numpy as np
import re
from sympy import (latex, Symbol, symbols,
                   sqrt, nsimplify, simplify,
                   UnevaluatedExpr as ueval,
                   )

from xv.util import toIntOrFloat, listAttr
from xv.km.storeddata import BaseStoredQuestions

# _inequality_stored_questions
# InequalityStoredQuestions

class InequalityStoredQuestions(BaseStoredQuestions):
    _QUESTION_KEYWORDS = None
    
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        pass

    def q_indexes_to_html(self, q_indexes = None):
        if not q_indexes:
            q_indexes = self.get_q_indexes()
            
        q_indexes_str = [f"<b>Q{idx+1}. </b>{item}" for idx, item in enumerate(q_indexes)]
        q_indexes_str = "\n\n".join(q_indexes_str)
        return q_indexes_str
        pass
    
    def get_q_indexes(self):
        q_indexes = []
        
        questions_unsoved = self.get_questions_unsoved()
        q_indexes.extend(questions_unsoved)
        
        prob_s = self.get_question_am_gm_inequality_type_1(soln = False)
        q_indexes.append(prob_s)
        
        prob_s = self.get_question_am_gm_inequality_type_2(soln = False)
        q_indexes.append(prob_s)
        
        prob_s = self.get_question_maximize_pos_nums(soln = False)
        q_indexes.append(prob_s)
        
        prob_s = self.get_question_numbers_with_roots(soln = False)
        q_indexes.append(prob_s)
        
        return q_indexes
        pass
    
    def get_questions_unsoved(self):
        text = f"""
        Show that
        $$\\displaystyle  a^2 \\geq 0 \\qquad \\forall a \\in \\mathbf{{R}}  $$
        
        

        
        Basic AM-GM Inequality. For positive real numbers $a, b$
        $
        \\frac{{a+b}}{{2}} \\geq \\sqrt{{a b}} .
        $
        
        
        
        Example 1.1.1. For real numbers $a, b, c$ prove that
        $
        a^2+b^2+c^2 \\geq a b+b c+c a .
        $
        
        
        
        General AM-GM Inequality. For positive real numbers $a_1, a_2, \\ldots, a_n$ the following inequality holds.
        $
        \\frac{{a_1+a_2+\\cdots+a_n}}{{n}} \\geq \\sqrt[n]{{a_1 a_2 \\cdots a_n}},
        $
        with equality if and only if $a_1=a_2=\\cdots=a_n$.
        
        
        
        Example 1.1.2. Let $a_1, a_2, \\ldots, a_n$ be positive real numbers such that $a_1 a_2 \\cdots a_n=1$. Prove that
        $
        \\left(1+a_1\\right)\\left(1+a_2\\right) \\cdots\\left(1+a_n\\right) \\geq 2^n .
        $
        
        
        
        Example 1.1.3. Let $a, b, c$ be nonnegative real numbers. Prove that
        $
        (a+b)(b+c)(c+a) \\geq 8 a b c .
        $
        
        
        
        Example 1.1.4. Let $a, b, c>0$. Prove that
        $
        \\frac{{a^3}}{{b c}}+\\frac{{b^3}}{{c a}}+\\frac{{c^3}}{{a b}} \\geq a+b+c
        $
        
        
        
        Example 1.1.5. (Samin Riasat) Let $a, b, c$ be positive real numbers. Prove that
        $
        a b(a+b)+b c(b+c)+c a(c+a) \\geq \\sum_{{c y c}} a b \\sqrt{{\\frac{{a}}{{b}}(b+c)(c+a)}} .
        $
        
        
        
        Exercise 1.1.1. Let $a, b>0$. Prove that
        $
        \\frac{{a}}{{b}}+\\frac{{b}}{{a}} \\geq 2
        $
        
        
        
        Exercise 1.1.2. For all real numbers $a, b, c$ prove the following chain inequality
        $
        3\\left(a^2+b^2+c^2\\right) \\geq(a+b+c)^2 \\geq 3(a b+b c+c a) .
        $
        
        
        
        Exercise 1.1.3. Let $a, b, c$ be positive real numbers. Prove that
        $
        a^3+b^3+c^3 \\geq a^2 b+b^2 c+c^2 a .
        $
        
        
        
        Exercise 1.1.4. Let $a, b, c$ be positive real numbers. Prove that
        $
        a^3+b^3+c^3+a b^2+b c^2+c a^2 \\geq 2\\left(a^2 b+b^2 c+c^2 a\\right) .
        $
        
        
        
        Exercise 1.1.5. Let $a, b, c$ be positive real numbers such that $a b c=1$. Prove that
        $
        a^2+b^2+c^2 \\geq a+b+c
        $
        
        
        
        Exercise 1.1.6. (a) Let $a, b, c>0$. Show that
        $
        (a+b+c)\\left(\\frac{{1}}{{a}}+\\frac{{1}}{{b}}+\\frac{{1}}{{c}}\\right) \\geq 9 .
        $
        (b) For positive real numbers $a_1, a_2, \\ldots, a_n$ prove that
        $
        \\left(a_1+a_2+\\cdots+a_n\\right)\\left(\\frac{{1}}{{a_1}}+\\frac{{1}}{{a_2}}+\\cdots+\\frac{{1}}{{a_n}}\\right) \\geq n^2 .
        $
        
        
        
        Exercise 1.1.7. Let $a, b, c$ be nonnegative real numbers such that $a+b+c=3$. Prove that
        $
        a^2+b^2+c^2+a b+b c+c a \\geq 6 .
        $
        
        
        
        Exercise 1.1.8. Let $a, b, c, d>0$. Prove that
        $
        \\frac{{a^2}}{{b}}+\\frac{{b^2}}{{c}}+\\frac{{c^2}}{{d}}+\\frac{{d^2}}{{a}} \\geq a+b+c+d .
        $
        
        
        
        Weighted AM-GM Inequality. For positive real numbers $a_1, a_2, \\ldots, a_n$ and $n$ weights $i_1, i_2, \\ldots, i_n$ such that $\\sum_{{k=1}}^n i_k=1$, we have
        $
        a_1 i_1+a_2 i_2+\\cdots+a_n i_n \\geq a_1^{{i_1}} a_2^{{i_2}} \\cdots a_n^{{i_n}}
        $
        
        
        
        
        Example 1.2.1. Let $a, b, c$ be positive real numbers such that $a+b+c=3$. Show that
        $
        a^b b^c c^a \\leq 1
        $
        
        
        
        Example 1.2.2. (Nguyen Manh Dung) Let $a, b, c>0$ such that $a+b+c=1$. Prove that
        $
        a^a b^b c^c+a^b b^c c^a+a^c b^a c^b \\leq 1 .
        $
        
        
        
        
        Exercise 1.3.1. Let $a, b, c$ be positive real numbers such that $a b c=1$. Prove that
        $
        \\frac{{a}}{{b}}+\\frac{{b}}{{c}}+\\frac{{c}}{{a}} \\geq a+b+c .
        $
        
        
        
        
        Exercise 1.3.2. (Michael Rozenberg) Let $a, b, c$ and $d$ be non-negative numbers such that $a+b+c+d=$ 4. Prove that
        $
        \\frac{{4}}{{a b c d}} \\geq \\frac{{a}}{{b}}+\\frac{{b}}{{c}}+\\frac{{c}}{{d}}+\\frac{{d}}{{a}} .
        $
        
        
        
        
        Exercise 1.3.3. (Samin Riasat) Let $a, b, c$ be positive real numbers. Prove that
        $
        \\frac{{a^3+b^3+c^3}}{{3}} \\geq \\frac{{a+b+c}}{{3}} \\cdot \\frac{{a^2+b^2+c^2}}{{3}} \\geq \\frac{{a^2 b+b^2 c+c^2 a}}{{3}} .
        $
        
        
        
        Exercise 1.3.4.(a) (Pham Kim Hung) Let $a, b, c$ be positive real numbers. Prove that
        $
        \\frac{{a}}{{b}}+\\frac{{b}}{{c}}+\\frac{{c}}{{a}}+\\frac{{3 \\sqrt[3]{{a b c}}}}{{a+b+c}} \\geq 4 .
        $
        (b) (Samin Riasat) For real numbers $a, b, c>0$ and $n \\leq 3$ prove that
        $
        \\frac{{a}}{{b}}+\\frac{{b}}{{c}}+\\frac{{c}}{{a}}+n\\left(\\frac{{3 \\sqrt[3]{{a b c}}}}{{a+b+c}}\\right) \\geq 3+n .
        $
        
        
        
        
        
        Exercise 1.3.5. (Samin Riasat) Let $a, b, c$ be positive real numbers such that $a+b+c=a b+b c+c a$ and $n \\leq 3$. Prove that
        $
        \\frac{{a^2}}{{b}}+\\frac{{b^2}}{{c}}+\\frac{{c^2}}{{a}}+\\frac{{3 n}}{{a^2+b^2+c^2}} \\geq 3+n .
        $
        
        
        

        Cauchy-Schwarz Inequality. For any real numbers $a_1, a_2, \\ldots, a_n$ and $b_1, b_2, \\ldots, b_n$ the following inequality holds.
        $
        \\left(a_1^2+a_2^2+\\cdots+a_n^2\\right)\\left(b_1^2+b_2^2+\\cdots+b_n^2\\right) \\geq\\left(a_1 b_1+a_2 b_2+\\cdots+a_n b_n\\right)^2,
        $
        with equality if the sequences are proportional. That is if $\\frac{{a_1}}{{b_1}}=\\frac{{a_2}}{{b_2}}=\\cdots=\\frac{{a_n}}{{b_n}}$.
        
        
        
        
        Cauchy-Schwarz in Engel Form. For real numbers $a_i, a_2, \\ldots, a_n$ and $b_1, b_2, \\ldots, b_n>0$ the following inequality holds:
        $
        \\frac{{a_1^2}}{{b_1}}+\\frac{{a_2^2}}{{b_2}}+\\cdots+\\frac{{a_n^2}}{{b_n}} \\geq \\frac{{\\left(a_1+a_2+\\cdots+a_n\\right)^2}}{{b_1+b_2+\\cdots+b_n}},
        $
        with equality if and only if $\\frac{{a_1}}{{b_1}}=\\frac{{a_2}}{{b_2}}=\\cdots=\\frac{{a_n}}{{b_n}}$.
        
        
        
        
        Example 2.1.1. Let $a, b, c$ be real numbers. Show that
        $
        3\\left(a^2+b^2+c^2\\right) \\geq(a+b+c)^2 .
        $
        
        
        
        
        Example 2.1.2. (Nesbitt's Inequality) For positive real numbers $a, b, c$ prove that
        $
        \\frac{{a}}{{b+c}}+\\frac{{b}}{{c+a}}+\\frac{{c}}{{a+b}} \\geq \\frac{{3}}{{2}} .
        $
        
        
        
        
        
        Example 2.1.3. For nonnegative real numbers $x, y, z$ prove that
        $
        \\sqrt{{3 x^2+x y}}+\\sqrt{{3 y^2+y z}}+\\sqrt{{3 z^2+z x}} \\leq 2(x+y+z) .
        $
        
        
        
        
        
        Example 2.1.4. (IMO 1995) Let $a, b, c$ be positive real numbers such that $a b c=1$. Prove that
        $
        \\frac{{1}}{{a^3(b+c)}}+\\frac{{1}}{{b^3(c+a)}}+\\frac{{1}}{{c^3(a+b)}} \\geq \\frac{{3}}{{2}} .
        $
        
        
        
        
        Example 2.1.5. For positive real numbers $a, b, c$ prove that
        $
        \\frac{{a}}{{2 a+b}}+\\frac{{b}}{{2 b+c}}+\\frac{{c}}{{2 c+a}} \\leq 1
        $
        
        
        
        
        Example 2.1.6. (Vasile Cirtoaje, Samin Riasat) Let $x, y, z$ be positive real numbers. Prove that
        $
        \\sqrt{{\\frac{{x}}{{x+y}}}}+\\sqrt{{\\frac{{y}}{{y+z}}}}+\\sqrt{{\\frac{{z}}{{z+x}}}} \\leq \\frac{{3}}{{\\sqrt{{2}}}} .
        $
        
        
        
        
        
        
        
        Exercise 2.1.2. Let $a, b, c, d$ be positive real numbers. Prove that
        $
        \\frac{{a}}{{b+c}}+\\frac{{b}}{{c+d}}+\\frac{{c}}{{d+a}}+\\frac{{d}}{{a+b}} \\geq 2 .
        $
        
        
        
        Exercise 2.1.3 Let $a_1, a_2, \\ldots, a_n$ be positive real numbers. Prove that
        $
        \\frac{{a_1^2}}{{a_2}}+\\frac{{a_2^2}}{{a_3}}+\\cdots+\\frac{{a_n^2}}{{a_1}} \\geq a_1+a_2+\\cdots+a_n .
        $
        
        
        
        Exercise 2.1.4. (Michael Rozenberg) Let $a, b, c, d$ be positive real numbers such that $a^2+b^2+c^2+d^2=$ 4. Show that
        $
        \\frac{{a^2}}{{b}}+\\frac{{b^2}}{{c}}+\\frac{{c^2}}{{d}}+\\frac{{d^2}}{{a}} \\geq 4 .
        $
        
        
        
        
        Exercise 2.1.5. Let $a, b, c$ be positive real numbers. Prove that
        $
        \\left(\\frac{{a}}{{a+2 b}}\\right)^2+\\left(\\frac{{b}}{{b+2 c}}\\right)^2+\\left(\\frac{{c}}{{c+2 a}}\\right)^2 \\geq \\frac{{1}}{{3}} .
        $
        
        
        
        Exercise 2.1.6. (Zhautykov Olympiad 2008) Let $a, b, c$ be positive real numbers such that $a b c=1$. Show that
        $
        \\frac{{1}}{{b(a+b)}}+\\frac{{1}}{{c(b+c)}}+\\frac{{1}}{{a(c+a)}} \\geq \\frac{{3}}{{2}} .
        $
        
        
        
        Exercise 2.1.7. If $a, b, c$ and $d$ are positive real numbers such that $a+b+c+d=4$ prove that
        $
        \\frac{{a}}{{1+b^2 c}}+\\frac{{b}}{{1+c^2 d}}+\\frac{{c}}{{1+d^2 a}}+\\frac{{d}}{{1+a^2 b}} \\geq 2 .
        $
        
        
        
        Exercise 2.1.8. Let $a_1, a_2, \\ldots, a_n$ and $b_1, b_2, \\ldots, b_n$ be real numbers. Prove that
        $
        \\sqrt{{a_1^2+b_1^2}}+\\sqrt{{a_2^2+b_2^2}}+\\cdots+\\sqrt{{a_n^2+b_n^2}} \\geq \\sqrt{{\\left(a_1+a_2+\\cdots+a_n\\right)^2+\\left(b_1+b_2+\\cdots+b_n\\right)^2}}
        $
        
        
        
        
        
        Exercise 2.1.9. (Samin Riasat) Let $a, b, c$ be the side lengths of a triangle. Prove that
        $
        \\frac{{a}}{{3 a-b+c}}+\\frac{{b}}{{3 b-c+a}}+\\frac{{c}}{{3 c-a+b}} \\geq 1 .
        $
        
        
        
        Exercise 2.1.10. (Pham Kim Hung) Let $a, b, c$ be positive real numbers such that $a+b+c=1$.
        Prove that
        $
        \\frac{{a}}{{\\sqrt{{a+2 b}}}}+\\frac{{b}}{{\\sqrt{{b+2 c}}}}+\\frac{{c}}{{\\sqrt{{c+2 a}}}}<\\sqrt{{\\frac{{3}}{{2}}}} .
        $
        
        
        
        Exercise 2.1.11. Let $a, b, c>0$. Prove that
        $
        \\sqrt{{\\frac{{2 a}}{{b+c}}}}+\\sqrt{{\\frac{{2 b}}{{c+a}}}}+\\sqrt{{\\frac{{2 c}}{{a+b}}}} \\leq \\sqrt{{3\\left(\\frac{{a}}{{b}}+\\frac{{b}}{{c}}+\\frac{{c}}{{a}}\\right)}} .
        $
        
        
        
        
        Hölder's Inequality. Let $a_{{i_j}}, 1 \\leq i \\leq m, 1 \\leq j \\leq n$ be positive real numbers. Then the following inequality holds
        $
        \\prod_{{i=1}}^m\\left(\\sum_{{j=1}}^n a_{{i_j}}\\right) \\geq\\left(\\sum_{{j=1}}^n \\sqrt[m]{{\\prod_{{i=1}}^m a_{{i_j}}}}\\right)^m
        $
        
        
        
        
        Example 2.2.1. (IMO 2001) Let $a, b, c$ be positive real numbers. Prove that
        $
        \\frac{{a}}{{\\sqrt{{a^2+8 b c}}}}+\\frac{{b}}{{\\sqrt{{b^2+8 c a}}}}+\\frac{{c}}{{\\sqrt{{c^2+8 a b}}}} \\geq 1 .
        $
        
        
        
        
        Example 2.2.2. (Vasile Cirtoaje) For $a, b, c>0$ prove that
        $
        \\sum \\frac{{a}}{{\\sqrt{{a+2 b}}}} \\geq \\sqrt{{a+b+c}} \\geq \\sum \\frac{{a}}{{\\sqrt{{2 a+b}}}}
        $
        
        
        
        
        Example 2.2.3. (Samin Riasat) Let $a, b, c$ be the side lengths of a triangle. Prove that
        $
        \\frac{{1}}{{8 a b c+(a+b-c)^3}}+\\frac{{1}}{{8 a b c+(b+c-a)^3}}+\\frac{{1}}{{8 a b c+(c+a-b)^3}} \\leq \\frac{{1}}{{3 a b c}} .
        $
        
        
        
        
        Example 2.2.4. (IMO Shortlist 2004) If $a, b, c$ are three positive real numbers such that $a b+b c+c a=$ 1 , prove that
        $
        \\sqrt[3]{{\\frac{{1}}{{a}}+6 b}}+\\sqrt[3]{{\\frac{{1}}{{b}}+6 c}}+\\sqrt[3]{{\\frac{{1}}{{c}}+6 a}} \\leq \\frac{{1}}{{a b c}}
        $
        
        
        
        Exercise 2.2.2. Let $a, b, x$ and $y$ be positive numbers such that $1 \\geq a^{{11}}+b^{{11}}$ and $1 \\geq x^{{11}}+y^{{11}}$. Prove that $1 \\geq a^5 x^6+b^5 y^6$.
        
        
        
        Exercise 2.2.3. Prove that for all positive real numbers $a, b, c, x, y, z$,
        $
        \\frac{{a^3}}{{x}}+\\frac{{b^3}}{{y}}+\\frac{{c^3}}{{z}} \\geq \\frac{{(a+b+c)^3}}{{3(x+y+z)}} .
        $
        
        
        
        Exercise 2.2.4. Let $a, b$, and $c$ be positive real numbers. Prove the inequality
        $
        \\frac{{a^6}}{{b^2+c^2}}+\\frac{{b^6}}{{a^2+c^2}}+\\frac{{c^6}}{{a^2+b^2}} \\geq \\frac{{a b c(a+b+c)}}{{2}} .
        $
        
        
        
        Exercise 2.2.5. (Kyiv 2006) Let $x, y$ and $z$ be positive numbers such that $x y+x z+y z=1$. Prove that
        $
        \\frac{{x^3}}{{1+9 y^2 x z}}+\\frac{{y^3}}{{1+9 z^2 y x}}+\\frac{{z^3}}{{1+9 x^2 y z}} \\geq \\frac{{(x+y+z)^3}}{{18}} .
        $
        
        
        
        Exercise 2.2.6. Let $a, b, c>0$. Prove that
        $
        \\frac{{a b}}{{\\sqrt{{a b+2 c^2}}}}+\\frac{{b c}}{{\\sqrt{{b c+2 a^2}}}}+\\frac{{c a}}{{\\sqrt{{c a+2 b^2}}}} \\geq \\sqrt{{a b+b c+c a}} .
        $
        
        
        

        Exercise 2.3.1. Let $a, b, c>0$ and $k \\geq 2$. Prove that
        $
        \\frac{{a}}{{k a+b}}+\\frac{{b}}{{k b+c}}+\\frac{{c}}{{k c+a}} \\leq \\frac{{3}}{{k+1}} .
        $
        
        
        
        Exercise 2.3.2. (Samin Riasat) Let $a, b, c, m, n$ be positive real numbers. Prove that
        $
        \\frac{{a^2}}{{b(m a+n b)}}+\\frac{{b^2}}{{c(m b+n c)}}+\\frac{{c^2}}{{a(m c+n a)}} \\geq \\frac{{3}}{{m+n}} .
        $
        
        
        
        
        
        Another formulation: Let $a, b, c, m, n$ be positive real numbers such that $a b c=1$ Prove that
        $
        \\frac{{1}}{{b(m a+n b)}}+\\frac{{1}}{{c(m b+n c)}}+\\frac{{1}}{{a(m c+n a)}} \\geq \\frac{{3}}{{m+n}} .
        $
        
        
        
        
        
        Exercise 2.3.3 (Michael Rozenberg, Samin Riasat) Let $x, y, z>0$. Prove that
        $
        \\sum_{{c y c}} \\sqrt{{x^2+x y+y^2}} \\geq \\sum_{{c y c}} \\sqrt{{2 x^2+x y}} .
        $
        
        
        
        
        
        Exercise 2.3.4 (Vasile Cirtoaje and Samin Riasat) Let $a, b, c, k>0$. Prove that
        $
        \\frac{{a}}{{\\sqrt{{k a+b}}}}+\\frac{{b}}{{\\sqrt{{k b+c}}}}+\\frac{{c}}{{\\sqrt{{k c+a}}}}<\\sqrt{{\\frac{{k+1}}{{k}}(a+b+c)}} .
        $
        
        
        
        
        Exercise 2.3.5. (Michael Rozenberg and Samin Riasat) Let $x, y, z$ be positive real numbers such that $x y+y z+z x \\geq 3$. Prove that
        $
        \\frac{{x}}{{\\sqrt{{4 x+5 y}}}}+\\frac{{y}}{{\\sqrt{{4 y+5 z}}}}+\\frac{{z}}{{\\sqrt{{4 z+5 x}}}} \\geq 1 .
        $
        
        
        
        
        
        Exercise 2.3.6. Let $a, b, c>0$ such that $a+b+c=1$. Prove that
        $
        \\frac{{\\sqrt{{a^2+a b c}}}}{{c+a b}}+\\frac{{\\sqrt{{b^2+a b c}}}}{{a+b c}}+\\frac{{\\sqrt{{c^2+a b c}}}}{{b+c a}} \\leq \\frac{{1}}{{2 \\sqrt{{a b c}}}} .
        $
        
        
        
        
        
        Exercise 2.3.7. (Ji Chen, Pham Van Thuan and Samin Riasat) Let $x, y, z$ be positive real numbers. Prove that
        $
        \\sqrt[4]{{\\frac{{27\\left(x^2+y^2+z^2\\right)}}{{4}}}} \\geq \\frac{{x}}{{\\sqrt{{x+y}}}}+\\frac{{y}}{{\\sqrt{{y+z}}}}+\\frac{{z}}{{\\sqrt{{z+x}}}} \\geq \\sqrt[4]{{\\frac{{27(y z+z x+x y)}}{{4}}}} .
        $
        
        
        
        
        
        Rearrangement Inequality. Let $\\left(a_i\\right)_{{i=1}}^n$ and $\\left(b_i\\right)_{{i=1}}^n$ be sequences of positive numbers increasing or decreasing in the same direction. That is, either $a_1 \\geq a_2 \\geq \\cdots \\geq a_n$ and $b_1 \\geq b_2 \\geq \\cdots \\geq b_n$ or $a_1 \\leq a_2 \\leq \\cdots \\leq a_n$ and $b_1 \\leq b_2 \\leq \\cdots \\leq b_n$. Then for any permutation $\\left(c_n\\right)$ of the numbers $\\left(b_n\\right)$ we have the following inequalities
        $
        \\sum_{{i=1}}^n a_i b_i \\geq \\sum_{{i=1}}^n a_i c_i \\geq \\sum_{{i=1}}^n a_i b_{{n-i+1}}
        $
        That is, the maximum of the sum occurs when the two sequences are similarly sorted, and the minimum occurs when they are oppositely sorted.
        
        
        
        
        Example 3.1.1. Let $a, b, c$ be real numbers. Prove that
        $
        a^2+b^2+c^2 \\geq a b+b c+c a .
        $
        
        
        
        
        Example 3.1.2. For positive real numbers $a, b, c$ prove that
        $
        a^3+b^3+c^3 \\geq a^2 b+b^2 c+c^2 a .
        $
        
        
        
        
        Example 3.1.3. (Nesbitt's inequality) For positive real numbers $a, b, c$ prove that
        $
        \\frac{{a}}{{b+c}}+\\frac{{b}}{{c+a}}+\\frac{{c}}{{a+b}} \\geq \\frac{{3}}{{2}} .
        $
        
        
        
        
        Example 3.1.4 (IMO 1975) We consider two sequences of real numbers $x_1 \\geq x_2 \\geq \\ldots \\geq x_n$ and $y_1 \\geq y_2 \\geq \\ldots \\geq y_n$. Let $z_1, z_2, \\ldots, z_n$ be a permutation of the numbers $y_1, y_2, \\ldots, y_n$. Prove that
        $
        \\sum_{{i=1}}^n\\left(x_i-y_i\\right)^2 \\leq \\sum_{{i=1}}^n\\left(x_i-z_i\\right)^2 .
        $
        
        
        
        
        
        Example 3.1.5. (Rearrangement inequality in Exponential form) Let $a, b, c \\geq 1$. Prove that
        $
        a^a b^b c^c \\geq a^b b^c c^a
        $
        
        
        
        
        Example 3.1.6. Let $a, b, c \\geq 0$. Prove that
        $
        a^3+b^3+c^3 \\geq 3 a b c .
        $
        
        
        
        
        Example 3.1.7 (Samin Riasat) Let $a, b, c$ be positive real numbers. Prove that
        $
        \\left(\\sum_{{c y c}} \\frac{{a}}{{b+c}}\\right)^2 \\leq\\left(\\sum_{{c y c}} \\frac{{a^2}}{{b^2+b c}}\\right)\\left(\\sum_{{c y c}} \\frac{{a}}{{c+a}}\\right)
        $
        
        
        
        
        
        Exercise 3.1.2. For $a, b, c>0$ prove that
        $
        \\frac{{a b}}{{c}}+\\frac{{b c}}{{a}}+\\frac{{c a}}{{b}} \\geq a+b+c .
        $
        
        
        
        
        
        Exercise 3.1.3. Let $a, b, c>0$. Prove that
        $
        \\frac{{a^8+b^8+c^8}}{{a^3 b^3 c^3}} \\geq \\frac{{1}}{{a}}+\\frac{{1}}{{b}}+\\frac{{1}}{{c}} .
        $
        
        
        
        
        
        Exercise 3.1.5. Let $a, b, c$ be positive real numbers. Prove that
        $
        \\frac{{a}}{{b(b+c)}}+\\frac{{b}}{{c(c+a)}}+\\frac{{c}}{{a(a+b)}} \\geq \\frac{{1}}{{b+c}}+\\frac{{1}}{{c+a}}+\\frac{{1}}{{a+b}} .
        $
        
        
        
        
        
        Exercise 3.1.6. (Yaroslavle 2006) Let $a>0, b>0$ and $a b=1$. Prove that
        $
        \\frac{{a}}{{a^2+3}}+\\frac{{b}}{{b^2+3}} \\leq \\frac{{1}}{{2}}
        $
        
        
        
        
        
        Exercise 3.1.7. Let $a, b, c$ be positive real numbers satisfying $a b c=1$. Prove that
        $
        a b^2+b c^2+c a^2 \\geq a+b+c .
        $
        
        
        
        
        
        Exercise 3.1.8. Let $a, b, c$ be positive real numbers such that $a+b+c=1$. Prove that
        $
        \\frac{{a b+c}}{{a+b}}+\\frac{{a c+b}}{{a+c}}+\\frac{{b c+a}}{{b+c}} \\geq 2 .
        $
        
        
        
        
        
        Exercise 3.1.9. (Novosibirsk 2007) Let $a$ and $b$ be positive numbers, and $n \\in \\mathbb{{N}}$. Prove that
        $
        (n+1)\\left(a^{{n+1}}+b^{{n+1}}\\right) \\geq(a+b)\\left(a^n+a^{{n-1}} b+\\cdots+b^n\\right) .
        $
        



    
        Chebyshev's Inequality. Let $\\left(a_i\\right)_{{i=1}}^n$ and $\\left(b_i\\right)_{{i=1}}^n$ be two sequences of positive real numbers.
        (i) If the sequences are similarly sorted, then
        $
        \\frac{{a_1 b_1+a_2 b_2+\\cdots+a_n b_n}}{{n}} \\geq \\frac{{a_1+a_2+\\cdots+a_n}}{{n}} \\cdot \\frac{{b_1+b_2+\\cdots+b_n}}{{n}} .
        $
        (ii) If the sequences are oppositely sorted, then
        $
        \\frac{{a_1 b_1+a_2 b_2+\\cdots+a_n b_n}}{{n}} \\leq \\frac{{a_1+a_2+\\cdots+a_n}}{{n}} \\cdot \\frac{{b_1+b_2+\\cdots+b_n}}{{n}} .
        $
        
        
        
        
        Example 3.2.1. For $a, b, c>0$ prove that
        $
        3\\left(a^2+b^2+c^2\\right) \\geq(a+b+c)^2 .
        $
        
        
        
        
        Example 3.2.2. Let $a, b, c>0$. Prove that
        $
        \\frac{{a^8+b^8+c^8}}{{a^3 b^3 c^3}} \\geq \\frac{{1}}{{a}}+\\frac{{1}}{{b}}+\\frac{{1}}{{c}} .
        $
        
        
        
        
        Example 3.2.3. Let $a \\geq b \\geq c \\geq 0$ and $0 \\leq x \\leq y \\leq z$. Prove that
        $
        \\frac{{a}}{{x}}+\\frac{{b}}{{y}}+\\frac{{c}}{{z}} \\geq \\frac{{a+b+c}}{{\\sqrt[3]{{x y z}}}} \\geq 3\\left(\\frac{{a+b+c}}{{x+y+z}}\\right)
        $
        
        
        
        
        Example 3.2.4. Let $a, b, c>0$. Prove that
        $
        \\frac{{a^3}}{{b c}}+\\frac{{b^3}}{{c a}}+\\frac{{c^3}}{{a b}} \\geq a+b+c .
        $
        
        
        
        
        Exercise 3.2.2. Let $a_1, a_2, \\ldots, a_n \\geq 0$ and $k \\geq 1$. Prove that
        $
        \\sqrt[k]{{\\frac{{a_1^k+a_2^k+\\cdots+a_n^k}}{{n}}}} \\geq \\frac{{a_1+a_2+\\cdots+a_n}}{{n}} .
        $
        
        
        
        Exercise 3.2.4. Let $a_1 \\geq a_2 \\geq \\cdots \\geq a_n$ and $b_1 \\leq b_2 \\leq \\cdots \\leq b_n$ be positive. Prove that
        $
        \\sum_{{i=1}}^n \\frac{{a_i}}{{b_i}} \\geq \\frac{{a_1+a_2+\\cdots+a_n}}{{\\sqrt[n]{{b_1 b_2 \\ldots b_n}}}} \\geq \\frac{{n\\left(a_1+a_2+\\cdots+a_n\\right)}}{{b_1+b_2+\\cdots+b_n}} .
        $
        
        
        
        Exercise 3.2.5. Let $a \\geq c \\geq 0$ and $b \\geq d \\geq 0$. Prove that
        $
        (a+b+c+d)^2 \\geq 8(a d+b c) .
        $
        
        
        
        Exercise 3.2.6. (Radu Titiu) Let $a, b, c>0$ such that $a^2+b^2+c^2 \\geq 3$. Show that
        $
        \\frac{{a^2}}{{b+c}}+\\frac{{b^2}}{{c+a}}+\\frac{{c^2}}{{a+b}} \\geq \\frac{{3}}{{2}} .
        $
        
        
        
        
        
        Exercise 3.2.7. Let $a, b, c>0$ such that $a b c=1$. Prove that
        $
        \\frac{{9}}{{2}} \\leq \\sum_{{c y c}} \\frac{{1}}{{c^2(a+b)}} \\cdot \\sum_{{c y c}} a b \\leq 3 \\sum_{{c y c}} \\frac{{a b}}{{c^2(a+b)}} .
        $
        
        
        
        Exercise 3.2.8. Let $a, b, c>0$. Prove that
        $
        a^a b^b c^c \\geq(a b c)^{{\\frac{{a+b+c}}{{3}}}}
        $
        
        
        
        
        
        Exercise 3.3.1. (Samin Riasat) Let $a, b, c>0$. Prove that
        $
        \\frac{{\\max \\{{a, b, c\\}}}}{{\\min \\{{a, b, c\\}}}}+\\frac{{\\min \\{{a, b, c\\}}}}{{\\max \\{{a, b, c\\}}}} \\geq \\frac{{a+b+c}}{{\\sqrt[3]{{a b c}}}}-1 .
        $
        
        
        
        Exercise 3.3.2. Let $a_1 \\geq a_2 \\cdots \\geq a_n$ and $b_1 \\geq b_2 \\geq \\cdots \\geq b_n$ be positive.
        (i) If $\\left(c_i\\right)_{{i=1}}^n$ is a permutation of $\\left(b_i\\right)_{{i=1}}^n$ prove that
        $
        a_1^{{b_1-c_1}} a_2^{{b_2-c_2}} \\cdots a_n^{{b_n-c_n}} \\geq 1 .
        $
        (ii) Let $b=\\frac{{b_1+b_2+\\cdots+b_n}}{{n}}$. Prove that
        $
        a_1^{{b_1-b}} a_2^{{b_2-b}} \\cdots a_n^{{b_n-b}} \\geq 1 .
        $
        
        
        
        Exercise 3.3.3. Let $x, y, z \\in \\mathbb{{R}}^{{+}}$. Prove that
        $
        \\frac{{x^3+y^3+z^3}}{{3 x y z}}+\\frac{{3 \\sqrt[3]{{x y z}}}}{{x+y+z}} \\geq 2 .
        $
        
        
        
        
        Exercise 3.3.4. (Samin Riasat) Let $a, b, c$ be positive real numbers. Prove that
        $
        \\frac{{a^2+b^2+c^2}}{{a b+b c+c a}} \\geq \\frac{{2}}{{3}}\\left(\\frac{{a}}{{b+c}}+\\frac{{b}}{{c+a}}+\\frac{{c}}{{a+b}}\\right) .
        $
        
        
        
        Exercise 3.3.5. (Samin Riasat) Let $a, b, c$ be positive real numbers and $n$ be a positive integer. Prove that
        $
        \\left(\\sum_{{c y c}} \\frac{{a}}{{b+c}}\\right)^n \\leq\\left(\\sum_{{c y c}} \\frac{{a^n}}{{b^n+b^{{n-1}} c}}\\right)\\left(\\sum_{{c y c}} \\frac{{a}}{{c+a}}\\right)^{{n-1}} .
        $
        
        
        
        
        4.1 Schur's Inequality
        Let $a, b, c$ be positive real numbers, and $n$ be positive. Then the following inequality holds:
        $
        a^n(a-b)(a-c)+b^n(b-c)(b-a)+c^n(c-a)(c-b) \\geq 0,
        $
        with equality if and only if $a=b=c$ or $a=b, c=0$ and permutations.
        The above inequality is known as Schur's inequality, after Issai Schur.
        
        
        
        
        $4.2$ Jensen's Inequality
        Suppose $f$ is a convex function in $[a, b]$. Then the inequality
        $
        f\\left(\\frac{{a_1+a_2+\\cdots+a_n}}{{n}}\\right) \\leq \\frac{{f\\left(a_1\\right)+f\\left(a_2\\right)+\\cdots+f\\left(a_n\\right)}}{{n}}
        $
        is true for all $a_i \\in[a, b]$. Similarly, if $f$ is concave in the interval the sign of inequality turns over. This is called Jensen's inequality.
        
        The convexity is usually determined by checking if $f^{{\\prime \\prime}}(x) \\geq 0$ holds for all $x \\in[a, b]$. Similarly for concavity one can check if $f^{{\\prime \\prime}}(x) \\leq 0$ for all $x \\in[a, b]$. Here is an example:
        
        
        
        
        Example 4.2.1. Let $a, b, c>0$. Prove that
        $
        a^a b^b c^c \\geq\\left(\\frac{{a+b+c}}{{3}}\\right)^{{a+b+c}}
        $
        
        
        
        
        4.3 Minkowski's Inequality
        Minkowski's inequality states that for positive numbers $x_i, y_i$ and $p$ the following inequality holds:
        $
        \\left(\\sum_{{i=1}}^n\\left(x_i+y_i\\right)^p\\right)^{{\\frac{{1}}{{p}}}} \\leq\\left(\\sum_{{i=1}}^n x_i^p\\right)^{{\\frac{{1}}{{p}}}}+\\left(\\sum_{{i=1}}^n y_i^p\\right)^{{\\frac{{1}}{{p}}}} .
        $
        
        
        
        
        4.4 Ravi Transformation
        Suppose that $a, b, c$ are the side lengths of a triangle. Then positive real numbers $x, y, z$ exist such that $a=x+y, b=y+z$ and $c=z+x$.
        
        
        
        
        Example 4.4.1. (IMO 1964) Let $a, b, c$ be the side lengths of a triangle. Prove that
        $
        a^2(b+c-a)+b^2(c+a-b)+c^2(a+b-c) \\leq 3 a b c .
        $
        
        
        
        
        Example 4.4.2. Let $a, b, c$ be the lengths of the sides of a triangle. Prove that
        $
        \\sqrt{{3(\\sqrt{{a b}}+\\sqrt{{b c}}+\\sqrt{{c a}})}} \\geq \\sqrt{{a+b-c}}+\\sqrt{{b+c-a}}+\\sqrt{{c+a-b}} .
        $
        
        
        
        
        Exercise 5.1.1. Let $a, b, c$ be nonnegative reals. Prove that
        $
        \\sqrt{{\\frac{{a b+b c+c a}}{{3}}}} \\leq \\sqrt[3]{{\\frac{{(a+b)(b+c)(c+a)}}{{8}}}} .
        $
        
        
        
        
        Exercise 5.1.2. For $a, b, c>0$ prove that
        $
        \\frac{{a}}{{(b+c)^4}}+\\frac{{b}}{{(c+a)^4}}+\\frac{{c}}{{(a+b)^4}} \\geq \\frac{{3}}{{2(a+b)(b+c)(c+a)}} .
        $
        
        
        
        
        Exercise 5.1.3. Let $a, b, c$ be real numbers. Prove that
        $
        2+(a b c)^2+a^2+b^2+c^2 \\geq 2(a b+b c+c a) .
        $
        
        
        
        
        Exercise 5.1.4. (Michael Rozenberg) Let $a, b, c$ be non-negative numbers such that $a+b+c=3$. Prove that
        $
        a \\sqrt{{2 b+c^2}}+b \\sqrt{{2 c+a^2}}+c \\sqrt{{2 a+b^2}} \\leq 3 \\sqrt{{3}} .
        $
        
        
        
        
        
        Exercise 5.1.5. For any acute-angled triangle $A B C$ show that
        $
        \\tan A+\\tan B+\\tan C \\geq \\frac{{s}}{{r}},
        $
        where $s$ and $r$ denote the semi-perimeter and the inraduis, respectively.
        
        
        
        
        Exercise 5.1.6. (Iran 2008) Find the smallest real $K$ such that for each $x, y, z \\in \\mathbb{{R}}^{{+}}$:
        $
        x \\sqrt{{y}}+y \\sqrt{{z}}+z \\sqrt{{x}} \\leq K \\sqrt{{(x+y)(y+z)(z+x)}} .
        $
        
        
        
        
        Exercise 5.1.7. (USA 1997) Prove the following inequality for $a, b, c>0$
        $
        \\frac{{1}}{{a^3+b^3+a b c}}+\\frac{{1}}{{b^3+c^3+a b c}}+\\frac{{1}}{{a^3+c^3+a b c}} \\leq \\frac{{1}}{{a b c}} \\text {{. }}
        $
        
        
        
        
        Exercise 5.1.8. Let $x \\geq y \\geq z>0$ be real numbers. Prove that
        $
        \\frac{{x^2 y}}{{z}}+\\frac{{y^2 z}}{{x}}+\\frac{{z^2 x}}{{y}} \\geq x^2+y^2+z^2
        $
        
        
        
        
        Exercise 5.1.9. (Greece 2007) Let $a, b, c$ be sides of a triangle. Show that
        $
        \\frac{{(c+a-b)^4}}{{a(a+b-c)}}+\\frac{{(a+b-c)^4}}{{b(b+c-a)}}+\\frac{{(b+c-a)^4}}{{c(c+a-b)}} \\geq a b+b c+c a .
        $
        
        
        
        
        Exercise 5.1.10 (Samin Riasat) Let $a, b, c$ be sides of a triangle. Show that
        $
        \\frac{{(c+a-b)^4}}{{a(a+b-c)}}+\\frac{{(a+b-c)^4}}{{b(b+c-a)}}+\\frac{{(b+c-a)^4}}{{c(c+a-b)}} \\geq a^2+b^2+c^2 .
        $
        
        
        
        
        Exercise 5.1.11. (Crux Mathematicorum) If $a, b$ and $c$ are the sidelengths of a triangle, then prove the inequality
        $
        \\frac{{(b+c)^2}}{{a^2+b c}}+\\frac{{(c+a)^2}}{{b^2+c a}}+\\frac{{(a+b)^2}}{{c^2+a b}} \\geq 6 .
        $
        
        
        
        
        Exercise 5.1.12. Let $a, b, c$ be the side-lengths of a triangle. Prove that
        $
        \\sum_{{c y c}}(a+b)(b+c) \\sqrt{{a-b+c}} \\geq 4(a+b+c) \\sqrt{{(-a+b+c)(a-b+c)(a+b-c)}}
        $
        
        
        
        Exercise 5.1.13. Prove that if $a, b, c>0$ then
        $
        \\sqrt{{a b c}}(\\sqrt{{a}}+\\sqrt{{b}}+\\sqrt{{c}})+(a+b+c)^2 \\geq 4 \\sqrt{{3 a b c(a+b+c)}} .
        $
        
        
        
        
        Exercise 5.1.14. Let $a, b, c$ be non-negative real numbers such that $a+b+c=1$. Prove that
        $
        a b+b c+c a \\leq \\frac{{1}}{{8}} \\sum_{{c y c}} \\sqrt{{(1-a b)(1-b c)}} \\leq a^2+b^2+c^2 .
        $
        
        
        
        
        Exercise 5.1.15. Let $a, b$ and $c$ be nonnegative real numbers such that
        $
        \\frac{{1}}{{a^2+1}}+\\frac{{1}}{{b^2+1}}+\\frac{{1}}{{c^2+1}}=2 .
        $
        Prove that $a b+b c+c a \\leq \\frac{{3}}{{2}}$.
        
        
        
        
        Exercise 5.1.16. (Korea 1998) Let $I$ be the incenter of triangle $A B C$. Prove that
        $
        3\\left(I A^2+I B^2+I C^2\\right) \\geq A B^2+B C^2+C A^2 .
        $
        
        
        
        
        Exercise 5.1.17. (Samin Riasat) Let $a, b, c$ be positive real numbers such that $a^6+b^6+c^6=3$. Prove that
        $
        a^7 b^2+b^7 c^2+c^7 a^2 \\leq 3 .
        $
        
        
        
        
        Exercise 5.1.18. (Samin Riasat) Let $x, y, z$ be positive real numbers. Prove that
        $
        \\frac{{x}}{{y}}+\\frac{{y}}{{z}}+\\frac{{z}}{{x}} \\geq \\sqrt{{\\frac{{x+y}}{{2 z}}}}+\\sqrt{{\\frac{{y+z}}{{2 x}}}}+\\sqrt{{\\frac{{z+x}}{{2 y}}}} .
        $
        
        
        
        
        Exercise 5.1.19. (Samin Riasat) Let $x, y, z$ be positive real numbers. Prove that
        $
        \\sqrt{{\\frac{{x y}}{{(x+y)(y+z)}}}}+\\sqrt{{\\frac{{y z}}{{(y+z)(z+x)}}}}+\\sqrt{{\\frac{{z x}}{{(z+x)(x+y)}}}} \\leq \\frac{{3}}{{2}} .
        $
        
        
        
        
        
        """
        
        questions_unsoved = self._convert_text_to_questions(text)
        return questions_unsoved
        pass
    
    def _convert_text_to_questions(self, text):
        lines = text.split("\n")
        
        questions_unsoved = []
        q_text = []
        for idx in range(len(lines)):
            line = lines[idx].strip()
            if idx > 2:
                pre_lines = [item.strip() for item in lines[idx - 3: idx] 
                             if item.strip()]
                if not pre_lines:
                    q_text = "\n".join(q_text).strip("\n")
                    if q_text:
                        questions_unsoved.append(q_text)
                    q_text = []
                    pass
                pass
            
            q_text.append(line)
            pass
        return questions_unsoved
        
    def get_question_am_gm_inequality_type_1(self, soln = True):
        
        keywords = [
            'inequality', 'AM-GM inequality', 'AM', 'GM',
            'am_gm_inequality_type_1',
            ]
        
        prob_s = rf"""
        Show that
        $$
        1 \cdot 3 \cdot 5 \cdots(2 n-1) \leq n^{{n}}
        $$
        """
        
        if not soln:
            return prob_s.strip()
        
        soln_s = rf"""
    
        By the AM-GM inequality, we have that
        
        $$\displaystyle
        \sqrt[n]{{1 \cdot 3 \cdot 5 \cdots(2 n-1)}} \leq \frac{{1+3+\cdots+(2 n-1)}}{{n}}
        $$
        
        $$
        \text {{as}}\quad 1+3+\cdots+(2 n-1)=n^{{2}}
        $$
        
        $$
        \Rightarrow \sqrt[n]{{1 \cdot 3 \cdot 5 \cdots(2 n-1)}} \leq \frac{{n^{{2}}}}{{n}}=n
        $$
        
        $$
        \Rightarrow 1 \cdot 3 \cdot 5 \cdots(2 n-1) \leq n^{{n}}
        $$
                
        """
        
        answer_s = rf"""
        $$
        1 \cdot 3 \cdot 5 \cdots(2 n-1) \leq n^{{n}}
        $$
                
        """

        result = {
            'keywords': keywords,
            'prob_s': prob_s.strip(),
            'soln_s': soln_s.strip(),
            'answer_s': answer_s.strip(),
            }
        return result
        pass
    
    
    def get_question_am_gm_inequality_type_2(self, soln = True):
        
        keywords = [
            'inequality', 'AM-GM inequality', 'AM', 'GM', 'putnam', 'abc',
            'am_gm_inequality_type_2',
            ]
        
        
        prob_s = rf"""
        Show that if $a, b, c$ are all positive, then
        $$
        (a+b)(b+c)(a+c) \geq 8 a b c
        $$
        """

        if not soln:
            return prob_s.strip()
        
        
        soln_s = rf"""
        
        Using AM-GM, we get that
        $$
        \begin{{aligned}}
        \frac{{a+b}}{{2}} & \geq \sqrt{{a b}} \\
        \\
        \Rightarrow a+b & \geq 2 \sqrt{{a b}}
        \end{{aligned}}
        $$
        Similarly,
        $$
        \begin{{aligned}}
        &b+c \geq 2 \sqrt{{b c}} \\
        &a+c \geq 2 \sqrt{{a c}}
        \end{{aligned}}
        $$
        As all numbers are positive, inequality holds for
        
        $$
        \begin{{aligned}}
        (a+b)(b+c)(a+c) & \geq(2 \sqrt{{a b}})(2 \sqrt{{b c}})(2 \sqrt{{a c}}) \\
        \\
        &=8 \sqrt{{a b \cdot b c \cdot a c}} \\
        \\
        &=8 \sqrt{{a^{{2}} b^{{2}} c^{{2}}}} \\
        \end{{aligned}}
        $$
        
        $$
        \Rightarrow (a+b)(b+c)(a+c) \geq 8 a b c
        $$
        

        """
        
        answer_s = rf"""
        $$
        (a+b)(b+c)(a+c) \geq 8 a b c
        $$
        """

        result = {
            'keywords': keywords,
            'prob_s': prob_s.strip(),
            'soln_s': soln_s.strip(),
            'answer_s': answer_s.strip(),
            }
        return result
        pass
    
    def get_question_maximize_pos_nums(self, soln = True):
        
        keywords = [
            'assorted', 'maximize', 'positive numbers',
            ]
        
        prob_s = rf"""
        Find positive numbers $n$ and $a_{{1}}, a_{{2}}, \ldots, a_{{n}}$ such that $a_{{1}}+\cdots+a_{{n}}$ $=1000$ and the product $a_{{1}} a_{{2}} \cdots a_{{n}}$ is as large as possible.
        """

        if not soln:
            return prob_s.strip()
        
        soln_s = rf"""
        Let us find simple cases with sum as smaller number and the best solution.
        At sum = 2, 1 + 1 = 2, max product 1 * 1 = 1
        At sum = 3, 2 + 1 = 2, max product 2 * 1 = 2
        At sum = 4, 2 + 2 = 4, max product 2 * 2 = 4
        At sum = 5, 3 + 2 = 5, max product 3 * 2 = 6
        At sum = 6, 3 + 3 = 6, max product 3 * 3 = 9
        At sum = 7, 3 + 2 + 2 = 7, max product 3 * 2 * 2 = 12
        At sum = 8, 3 + 3 + 2 = 8, max product 3 * 3 * 2 = 18
        At sum = 9, 3 + 3 + 3 = 9, max product 3 * 3 * 3 = 27
        At sum = 10, 3 + 3 + 2 + 2 = 10, max product 3 * 3 * 2 * 2 = 36
        At sum = 11, 3 + 3 + 3 + 2 = 11, max product 3 * 3 * 3 * 2 = 54
        At sum = 12, 3 + 3 + 3 + 3 = 12, max product 3 * 3 * 3 * 3 = 81
        At sum = 13, 3 + 3 + 3 + 2 + 2 = 13, max product 3 * 3 * 3 * 2 * 2 = 108
        At sum = 14, 3 + 3 + 3 + 3 + 2 = 10, max product 3 * 3 * 3 * 3 * 2 = 162
        ...
        
        At sum = 1000, 3 + 3 + ... + 3 + 3 + 2 + 2, max product $3^{{332}} \times 2^{{2}}$
        """
        
        answer_s = rf"""
        $3^{{332}} \times 2^{{2}}$
        """

        result = {
            'keywords': keywords,
            'prob_s': prob_s.strip(),
            'soln_s': soln_s.strip(),
            'answer_s': answer_s.strip(),
            }
        return result
        pass


    def get_question_numbers_with_roots(self, soln = True):
        
        keywords = [
            'assorted', 'compare', 'numbers_with_roots',
            ]
        
        n1 = random.randint(15, 20)
        n3 = sqrt(ueval(random.randint(5, 10) ** 2 - random.randint(1, 3) ))
        n3_eval = float(simplify(n3))
        
        n4 = int(n1 - n3_eval)
        n4 = nsimplify(n4 * random.randint(95, 105) / 100)
        
        n5 = n1 - n4
        
        n5sqr = n5 ** 2
        
        n6 = n5sqr * n5sqr.q
        n7 = simplify(n3 ** 2 * n5sqr.q)

        if n6 == n7:
            op = "="
        elif n6 > n7:
            op = ">"
        elif n6 < n7:
            op = "<"
        else:
            op = "?"
        
        prob_s = rf"""
        Find 
        
        $\displaystyle 
        {n1} - {{{latex(n3)}}} 
        \qquad ? \qquad 
        {{{latex(n4)}}}
        $
        """
        
        if not soln:
            return prob_s.strip()

        soln_s = rf"""
        
        $\displaystyle 
        {n1} - {{{latex(n3)}}} 
        \qquad ? \qquad 
        {{{latex(n4)}}}
        $
        
        $\displaystyle \implies 
        {n1} - {{{latex(n3)}}} + {{{latex(n3)}}} - {{{latex(n4)}}}
        \qquad ? \qquad 
        {{{latex(n4)}}} + {{{latex(n3)}}} - {{{latex(n4)}}}
        $
        
        $\displaystyle \implies  
        {n1} - {{{latex(n4)}}} 
        \qquad ? \qquad  
        {{{latex(n3)}}}
        $
        
        $\displaystyle \implies  
        {{{latex(n5)}}} 
        \qquad ? \qquad  
        {{{latex(n3)}}}
        $
        
        As both sides are positive, we can square them without changing inequality status:
        
        $\displaystyle \implies  
        {{{latex(n5sqr)}}} 
        \qquad ? \qquad  
        {{{latex(n3 ** 2)}}}
        $
        
        $\displaystyle \implies  
        {{{latex(n5sqr)} * {latex(n5sqr.q)}}} 
        \qquad ? \qquad  
        {{{latex(n3 ** 2)} * {latex(n5sqr.q)}}}
        $
        
        $\displaystyle \implies  
        {{{latex(n6)}}} 
        \qquad ? \qquad  
        {{{latex(n7)}}}
        $
        
        $\displaystyle \implies  
        {{{latex(n6)}}} 
        \qquad {op} \qquad  
        {{{latex(n7)}}}
        $
        
        
        $\displaystyle \implies
        {n1} - {{{latex(n3)}}} 
        \qquad {op} \qquad 
        {{{latex(n4)}}}
        $
        
        """
        
        answer_s = rf"""
        $\displaystyle 
        {n1} - {{{latex(n3)}}} 
        \qquad {op} \qquad 
        {{{latex(n4)}}}
        $
        """

        result = {
            'keywords': keywords,
            'prob_s': prob_s.strip(),
            'soln_s': soln_s.strip(),
            'answer_s': answer_s.strip(),
            }
        return result
        pass
    
    pass
#class InequalityStoredQuestions:
