{"problem":{"name":"Discrete Logarithm Problems","description":{"content":"You are given $N$ integers $A_1,\\ldots,A_N$ and a prime number $P$. Find the number of pairs of integers $(i,j)$ that satisfy both of the following conditions: *   $1 \\leq i,j \\leq N$; *   There is a","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":5000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc335_g"},"statements":[{"statement_type":"Markdown","content":"You are given $N$ integers $A_1,\\ldots,A_N$ and a prime number $P$. Find the number of pairs of integers $(i,j)$ that satisfy both of the following conditions:\n\n*   $1 \\leq i,j \\leq N$;\n*   There is a positive integer $k$ such that $A_i^k \\equiv A_j \\mod P$.\n\n## Constraints\n\n*   $2 \\leq N \\leq 2 \\times 10^5$\n*   $1 \\leq A_i < P$\n*   $2 \\leq P \\leq 10^{13}$\n*   $P$ is prime.\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $P$\n$A_1$ $\\ldots$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc335_g","tags":[],"sample_group":[["3 13\n2 3 5","5\n\nFive pairs satisfy the conditions: $(1,1),(1,2),(1,3),(2,2),(3,3)$.\nFor example, for the pair $(1,3)$, if we take $k=9$, then $A_1^9 = 512 \\equiv 5 = A_3 \\mod 13$."],["5 2\n1 1 1 1 1","25"],["10 9999999999971\n141592653589 793238462643 383279502884 197169399375 105820974944 592307816406 286208998628 34825342117 67982148086 513282306647","63"]],"created_at":"2026-03-03 11:01:13"}}