{"problem":{"name":"Triple Index","description":{"content":"You are given a length-$N$ sequence $(A_1, A_2, \\ldots, A_N)$ of positive integers, and $Q$ queries about the sequence. For each $q = 1, 2, \\ldots, Q$, the $q$\\-th query gives you an integer pair $(l_","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":3000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc293_g"},"statements":[{"statement_type":"Markdown","content":"You are given a length-$N$ sequence $(A_1, A_2, \\ldots, A_N)$ of positive integers, and $Q$ queries about the sequence.\nFor each $q = 1, 2, \\ldots, Q$, the $q$\\-th query gives you an integer pair $(l_q, r_q)$;  \nprint the number of integer triplets $(i, j, k)$ such that\n\n*   $l_q \\leq i \\lt j \\lt k \\leq r_q$, and\n*   $A_i = A_j = A_k$.\n\n## Constraints\n\n*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $1 \\leq Q \\leq 2 \\times 10^5$\n*   $1 \\leq A_i \\leq 2 \\times 10^5$\n*   $1 \\leq l_q \\leq r_q \\leq N$\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $Q$\n$A_1$ $A_2$ $\\ldots$ $A_N$\n$l_1$ $r_1$\n$l_2$ $r_2$\n$\\vdots$\n$l_Q$ $r_Q$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc293_g","tags":[],"sample_group":[["10 4\n2 7 1 8 2 8 1 8 2 8\n1 10\n1 9\n2 10\n5 5","5\n2\n4\n0\n\nFor the first query, there are five triplets of integers that satisfy the conditions in the problem statement: $(1, 5, 9), (4, 6, 8), (4, 6, 10), (4, 8, 10)$, and $(6, 8, 10)$."],["20 10\n2 2 2 2 1 1 2 2 1 1 1 2 1 2 1 2 2 1 2 1\n12 16\n17 18\n12 18\n4 9\n13 13\n2 5\n6 13\n2 14\n7 14\n8 12","1\n0\n5\n2\n0\n1\n11\n55\n8\n1"]],"created_at":"2026-03-03 11:01:14"}}