{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\"text/css\"\u003e h1,h2,h3,h4,h5,h6 { margin-bottom:0; } div.textBG p { margin: 0 0 0.0001pt; }\u003c/style\u003e\u003cspan style\u003d\u0027float:right\u0027\u003e \u003ca target\u003d\u0027_blank\u0027 href\u003d\u0027CDN_BASE_URL/50e3250ee1d4c7ebb5003e782c321090?v\u003d1645919676\u0027\u003e \u003cimg width\u003d\u0027100\u0027 height\u003d\u002726\u0027 border\u003d\u00270\u0027 title\u003d\u0027Download as PDF\u0027 alt\u003d\u0027Download as PDF\u0027 src\u003d\u0027https://onlinejudge.org/components/com_onlinejudge/images/button_pdf.png\u0027\u003e \u003c/a\u003e\u003c/span\u003e\u003cdiv style\u003d\u0027clear:both\u0027\u003e\u003c/div\u003e\u003ciframe src\u003d\"CDN_BASE_URL/50e3250ee1d4c7ebb5003e782c321090?v\u003d1645919676#view\u003dFitH\" style\u003d\"width:100%; height:1400px;\" frameborder\u003d\"0\"\u003e\u003c/iframe\u003e"}},{"title":"","value":{"format":"HTML","content":"You are given a sequence of n integers a1, a2, . . . , an in non-decreasing order. In addition to that, you\nare given several queries consisting of indices i and j (1 ≤ i ≤ j ≤ n). For each query, determine the\nmost frequent value among the integers ai\n, . . . , aj .\nInput\nThe input consists of several test cases. Each test case starts with a line containing two integers n and\nq (1 ≤ n, q ≤ 100000). The next line contains n integers a1, . . . , an (−100000 ≤ ai ≤ 100000, for each\ni ∈ {1, ..., n}) separated by spaces. You can assume that for each i ∈ {1, . . . , n − 1}: ai ≤ ai+1. The\nfollowing q lines contain one query each, consisting of two integers i and j (1 ≤ i ≤ j ≤ n), which\nindicate the boundary indices for the query.\nThe last test case is followed by a line containing a single ‘0’.\nOutput\nFor each query, print one line with one integer: The number of occurrences of the most frequent value\nwithin the given range.\nNote: A naive algorithm may not run in time!\n"}},{"title":"Input","value":{"format":"HTML","content":"Sample Input \u003c/br\u003e\n10 3 \u003c/br\u003e\n-1 -1 1 1 1 1 3 10 10 10 \u003c/br\u003e\n2 3 \u003c/br\u003e\n1 10 \u003c/br\u003e\n5 10 \u003c/br\u003e\n0 \u003c/br\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Sample Output \u003c/br\u003e\n1 \u003c/br\u003e\n4 \u003c/br\u003e\n3 \u003c/br\u003e"}}]}