problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 262k
1.05M
| problem_description
stringlengths 48
1.55k
| codes
stringlengths 35
98.9k
| status
stringlengths 28
1.7k
| submission_ids
stringlengths 28
1.41k
| memories
stringlengths 13
808
| cpu_times
stringlengths 11
610
| code_sizes
stringlengths 7
505
|
---|---|---|---|---|---|---|---|---|---|---|
p02572 | u818213347 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\nl = list(map(int,input().split()))\nans = 0\nfor i in range(n):\n ans += ((l[i]*sum(l[i+1:n]))%1000000007\nprint(ans%1000000007)', 'n = int(input())\nl = list(map(int,input().split()))\nans = 0\nsum_n = [0]*n\nsum_n[0] = l[0]\nsumall = sum(l)\nfor i in range(1,n):\n sum_n[i] = sum_n[i-1] + l[i]\nfor i in range(n):\n ans += ((l[i]*(sumall-sum_n[i]))%1000000007)\nprint(ans%1000000007)'] | ['Runtime Error', 'Accepted'] | ['s428341828', 's073612168'] | [9000.0, 31356.0] | [28.0, 181.0] | [144, 249] |
p02572 | u820685137 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['"""C."""\n\nimport sys\n\ninput = sys.stdin.readline \n\nn = int(input())\na = list(map(int, input()[:-1].split(\' \')))\n\nresult = 0\n\nfor i, v1 in enumerate(a):\n for j in range(i + 1, n + 1):\n result += v1 * a[j]\nprint(result)\n', '"""C."""\n\nimport sys\n\ninput = sys.stdin.readline \n\nn = int(input())\na = list(map(int, input().split(\' \')))\n\nresult = 0\n\nfor i, v1 in enumerate(a):\n for j in range(i + 1, n + 1):\n result += v1 * a[j]\nprint(result)\n', '"""C."""\n\nimport sys\n\ninput = sys.stdin.readline \n\nn = int(input())\na = list(map(int, input()[:-1].split(\' \')))\n\nMOD_VALUE = 10**9 + 7\nresult = 0\n\na_sum = sum(a)\n\nfor v in a:\n result += v * (a_sum - v)\n a_sum -= v\n\nif result < MOD_VALUE:\n print(result)\nelse:\n print(result % MOD_VALUE)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s368649406', 's646510548', 's610493383'] | [31412.0, 31352.0, 31708.0] | [102.0, 98.0, 121.0] | [241, 236, 311] |
p02572 | u825186577 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA = map(int, input().split())\n\nans = 0\nmod = 10**9+7\n\nS = sum(A)\nS2 = sum(map(lambda x: x*x, A))\n\nprint((S*S-S2)//2 % mod)\n', 'n = int(input())\nA = list(map(int, input().split()))\n\nS = sum(A)\nS2 = sum(map(lambda x: x * x, A))\n\nprint((S*S-S2)//2 % 1000000007)'] | ['Wrong Answer', 'Accepted'] | ['s254723324', 's256821859'] | [25132.0, 31268.0] | [74.0, 100.0] | [140, 131] |
p02572 | u825343780 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\na = list(map(int,input().split()))\n\nsums = 0\nfor i in range(n):\n sums += a[i]\n\nsums *= sums;\nans = sums;\n\nfor i in range(n):\n ans -= a[i]*a[i]\nans /= 2\n\nans %= 1000000007\nprint(ans)\n', '\n#include <string>\n\n#include <algorithm>\n#include <cmath>\n#include <iomanip>\n#include <set>\n#include <map>\n#include <numeric>\n\nusing namespace std;\ntypedef long long ll;\n\n\n#define all(x) x.begin(), x.end()\n#define mod 1000000007\n\n\n#include <string>\n\n#include <algorithm>\n#include <cmath>\n#include <iomanip>\n#include <set>\n#include <map>\n#include <numeric>\n\nusing namespace std;\ntypedef long long ll;\n\n\n#define all(x) x.begin(), x.end()\n#define mod 1000000007\n\nint main()\n{\n int n;\n cin >> n;\n vector<ll> a(n);\n rep(i, n)\n {\n cin >> a[i];\n }\n\n ll ans = 0;\n ll sum = 0;\n ll sums = 0;\n\n ans = 0;\n\n for (int i = 0; i < n; i++)\n {\n sums += a[i];\n }\n\n ans += (sums%mod) * (sums%mod);\n\n for (int i = 0; i < n; i++)\n {\n ans -= (a[i] * a[i]) % mod;\n }\n\n if(ans < 0) {\n ans += mod;\n }\n ans %= mod;\n\n ans *= (1.0/2);\n ans %= mod;\n\n cout << ans << endl;\n}\n\n/*\nint main()\n{\n int n;cin >> n;\n vector<ll> a(n);\n vector<ll> b(n-1);\n rep(i,n) {\n cin >> a[i];\n }\n\n ll ans = 0;\n ll sum = 0;\n for (int i = 1; i < n; i++)\n {\n sum += a[i]; \n }\n\n\n int i = 1;\n for(int j = 0; j < n - 1; j++) {\n b[j] = sum;\n sum -= a[i++];\n }\n\n for(int i = 0; i < n - 1; i++) {\n ans += (b[i]%mod)*(a[i]%mod);\n ans %= mod;\n }\n\n\n\n cout << ans << endl;\n\n}\n*/', '\n#include <string>\n\n#include <algorithm>\n#include <cmath>\n#include <iomanip>\n#include <set>\n#include <map>\n#include <numeric>\n\nusing namespace std;\ntypedef long long ll;\n\n\n#define all(x) x.begin(), x.end()\n#define mod 1000000007\n\nint main()\n{\n int n;cin >> n;\n vector<ll> a(n);\n vector<ll> b(n-1);\n rep(i,n) {\n cin >> a[i];\n }\n\n ll ans = 0;\n ll sum = 0;\n ll sums = 0;\n for (int i = 1; i < n; i++)\n {\n sum += a[i]; \n }\n\n\n int i = 1;\n for(int j = 0; j < n - 1; j++) {\n b[j] = sum;\n sum -= a[i++];\n }\n\n for(int i = 0; i < n - 1; i++) {\n ans += b[i]*a[i];\n ans %= mod;\n }\n\n\n\n cout << ans << endl;\n\n}', 'n = int(input())\na = list(map(int,input().split()))\n\nsums = 0\nfor i in range(n):\n sums += a[i]\n\nsums *= sums;\nans = sums;\n\nfor i in range(n):\n ans -= a[i]*a[i]\nans //= 2\nans %= 1000000007\nprint(int(ans))\n'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s583569381', 's680075858', 's726487358', 's792485878'] | [31428.0, 8940.0, 8936.0, 31556.0] | [140.0, 24.0, 22.0, 140.0] | [205, 1565, 770, 210] |
p02572 | u848097937 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['//g++ -std=gnu++14 a.cpp\n\n#include <algorithm>\n#include <bitset>\n#include <complex>\n#include <deque>\n\n#include <istream>\n#include <iterator>\n#include <map>\n\n#include <set>\n#include <stack>\n#include <string>\n\n#include <tuple>\n#include <iomanip>\n#include <random>\n#include <math.h>\n#include <stdio.h>\n\nusing namespace std;\n\n\n\nll MOD = 1e9 + 7;\nint INF = 1 << 30;\nll INFL = 1LL << 60;\nll MODP = 998244353;\n\nvoid dfs(int x,vector<vector<int>> &v,vector<int> &g, int &num){\n int x_size = v[x].size();\n if(x > 0){\n rep(i,x_size){\n if(g[v[x][i]] == 0){\n g[v[x][i]] = num;\n dfs(v[x][i],v,g,num);\n }\n }\n }\n}\n\nint main(){\n int N,M;\n cin >> N >> M;\n vector<int> A(M),B(M),group(N+10,0);\n rep(i,M)cin >> A[i] >> B[i];\n vector<vector<int>> G(N+10);\n rep(i,M){\n G[A[i]].push_back(B[i]);\n G[B[i]].push_back(A[i]);\n }\n int num = 1;\n for(int i = 1;i <= N;i++){\n if(group[i] == 0){\n group[i] = num;\n dfs(i,G,group,num);\n num++;\n }\n }\n vector<int> cnt(N+10,0);\n for(int i = 1;i <= N;i++){\n cnt[group[i]]++;\n }\n int ans = -1;\n for(int i = 1;i <= N;i++){\n if(ans < cnt[i])ans = cnt[i];\n }\n cout << ans << endl;\n/*\n for(int i = 1;i <= N;i++){\n cout << group[i] << " ";\n }\n cout << endl;\n for(int i = 1;i <= N;i++){\n cout << G[i].size() << " ";\n }\n cout << endl;\n*/\n return 0;\n}\n', '//g++ -std=gnu++14 a.cpp\n\n#include <algorithm>\n#include <bitset>\n#include <complex>\n#include <deque>\n\n#include <istream>\n#include <iterator>\n#include <map>\n\n#include <set>\n#include <stack>\n#include <string>\n\n#include <tuple>\n#include <iomanip>\n#include <random>\n#include <math.h>\n#include <stdio.h>\n\nusing namespace std;\n\n\n\nll MOD = 1e9 + 7;\nint INF = 1 << 30;\nll INFL = 1LL << 60;\nll MODP = 998244353;\n\nvoid dfs(int x,vector<vector<int>> &v,vector<int> &g, int &num){\n int x_size = v[x].size();\n if(x > 0){\n rep(i,x_size){\n if(g[v[x][i]] == 0){\n g[v[x][i]] = num;\n dfs(v[x][i],v,g,num);\n }\n }\n }\n}\n\nint main(){\n int N,M;\n cin >> N >> M;\n vector<int> A(M),B(M),group(N+10,0);\n rep(i,M)cin >> A[i] >> B[i];\n vector<vector<int>> G(N+10);\n rep(i,M){\n G[A[i]].push_back(B[i]);\n G[B[i]].push_back(A[i]);\n }\n int num = 1;\n for(int i = 1;i <= N;i++){\n if(group[i] == 0){\n group[i] = num;\n dfs(i,G,group,num);\n num++;\n }\n }\n vector<int> cnt(N+10,0);\n for(int i = 1;i <= N;i++){\n cnt[group[i]]++;\n }\n int ans = -1;\n for(int i = 1;i <= N;i++){\n if(ans < cnt[i])ans = cnt[i];\n }\n cout << ans << endl;\n/*\n for(int i = 1;i <= N;i++){\n cout << group[i] << " ";\n }\n cout << endl;\n for(int i = 1;i <= N;i++){\n cout << G[i].size() << " ";\n }\n cout << endl;\n*/\n return 0;\n}\n', 'n = int(input())\n\ns = input().split(" ")\n\nsumup = 0\nfor i in s:\n sumup += int(i) \n\nans = 0\nfor i in s:\n r = int(i)\n \n sumup -= r\n \n ans += r*sumup\n \nprint(ans%(10**9+7))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s196641244', 's990227349', 's728699439'] | [8768.0, 8896.0, 25056.0] | [25.0, 26.0, 160.0] | [1469, 1469, 179] |
p02572 | u848312584 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA = list(map(int, input().split()))\nans = 0\nmod = 1e9 + 7\ns = sum(A) % mod\n\nfor i in range(N):\n s -= A[i]\n ans += (A[i] * s) % mod\n ans = ans % mod\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nmod = int(1e9 + 7)\ns = sum(A) % mod\n\nfor a in A:\n s -= a\n ans += (a * s) % mod\n ans %= mod\n\nprint(int(ans))'] | ['Wrong Answer', 'Accepted'] | ['s268974614', 's063216514'] | [31412.0, 31536.0] | [172.0, 149.0] | [184, 178] |
p02572 | u849559474 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\nmod = 10 ** 9 + 7\nimport numpy as np\na = np.array(map(int, input().split())\ns=0\nss=0\nfor i in range(n):\n ss += a[i]%mod\n s += ss * a[i] % mod\nprint(s)', 'n = int(input())\nmod = 10 ** 9 + 7\nimport numpy as np\na = np.array(map(int, input().split())\ns=0\nss=0\nfor i in range(n):\n ss += a[i]%mod\n s += ss * a[i] % mod\nprint(s)', 'n = int(input())\nmod = 10 ** 9 + 7\nimport numpy as np\na = list(map(int, input().split())\ns=0\nss=0\nfor i in range(n):\n ss += a[i]%mod\n s += ss * a[i] % mod\nprint(s)\n', 'n = int(input())\nmod = 10 ** 9 + 7\nimport numpy as np\na = list(map(int, input().split()))\ns=0\nss=0\nfor i in range(n):\n ss += a[i]%mod\n s += ss * a[i] % mod\nprint(s)\n', 'n = int(input())\nmod = 10 ** 9 + 7\nimport numpy as np\na = list(map(int, input().split()))\ns=0\nss=0\nfor i in range(n):\n if i > 0:\n ss += a[i-1]%mod\n s += ss * a[i] % mod\nprint(s%mod)\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s291732569', 's298496334', 's379822705', 's617450151', 's999542040'] | [8908.0, 9000.0, 8916.0, 49992.0, 49812.0] | [21.0, 27.0, 26.0, 235.0, 249.0] | [169, 173, 170, 171, 195] |
p02572 | u852790844 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['import sys\nimport numpy as np\n\nreadline = sys.stdin.readline\nread = sys.stdin.read\nMOD = 10**9 + 7\n\nn = int(input())\na = np.array(readline().split(), dtype=np.uint64)\nr = np.cumsum(a[::-1])[::-1]\nr &= MOD\nx = a[:-1] * r[1:]\nx %= MOD\nans = np.sum(x) % MOD\nprint(ans)', 'import sys\nimport numpy as np\n\nreadline = sys.stdin.readline\nread = sys.stdin.read\nMOD = 10**9 + 7\n\nn = int(input())\na = np.array(readline().split(), dtype=np.uint64)\nr = np.cumsum(a[::-1])[::-1]\nr %= MOD\nx = a[:-1] * r[1:]\nx %= MOD\nans = np.sum(x) % MOD\nprint(int(ans))'] | ['Wrong Answer', 'Accepted'] | ['s040278510', 's163561847'] | [52632.0, 52772.0] | [169.0, 184.0] | [265, 270] |
p02572 | u854931881 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n=int(input())\na=list(map(int,input().split()))\nx=0\nfor i in range(0,n-1):\n x+=a[i]\ny=0\nfor j in range(1,n):\n y+=a[j]\nz=x+y\nprint(z%(10**9+7))', 'n=int(input())\na=list(map(int,input().split()))\nx=0\nfor i in range(n):\n x+=a[i]\nx=x**2\ny=0\nfor j in range(n):\n y=a[j]**2\nz=(x-y)//2\nprint(z%(10**9+7))', 'n=int(input())\na=list(map(int,input().split()))\nx=0\nfor i in range(n):\n x+=a[i]\nx=x**2\ny=0\nfor j in range(n):\n y=a[j]**2\nz=x-y\nprint(z%(10**9+7))\n \n ', 'n=int(input())\na=list(map(int,input().split()))\nx=(sum(a)-a[n-1])*(sum(a)-a[0])\nprint(x%(10**9+7))', 'n=int(input())\na=list(map(int,input().split()))\ntotal=0\nfor i in range(0,n-1):\n for j in range(1,n):\n total+=a[i]*a[j]\nprint(total%(10**9+7))', 'n=int(input())\na=list(map(int,input().split()))\nx=0\nfor i in range(0,n-1):\n x+=a[i]\ny=0\nfor j in range(1,n):\n y+=a[j]\nw=0\nfor k in range(1,n-1):\n w+=a[k]**2\nz=(x+y-w)//2\nprint(z%(10**9+7))', 'n=int(input())\na=list(map(int,input().split()))\ntotal=0\nfor i in range(0,n-1):\n for j in range(1,n):\n total+=a[i]*a[j]\n if total>=10**9+7:\n total-=10**9+7\nprint(total)', 'n=int(inoput())\na=list(map(int,input()))\ntotal=0\nfor i in range(0,n-1):\n for j in range(1,n):\n total+=a[i]*a[j]\nprint(total%(10**9+7))\n ', 'n=int(input())\na=list(map(int,input().split()))\nx=sum(a)**2\ntotal=0\nfor i in range(n):\n total+=a[i]**2\ny=int((x-total)//2)\nprint(y%(10**9+7))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s028332297', 's035092210', 's040693642', 's355715748', 's755061576', 's882687054', 's891634191', 's911034543', 's605629606'] | [31392.0, 31600.0, 31304.0, 31512.0, 31488.0, 31716.0, 31488.0, 9112.0, 31544.0] | [124.0, 152.0, 157.0, 76.0, 2206.0, 184.0, 2206.0, 22.0, 134.0] | [144, 152, 153, 98, 145, 191, 179, 143, 144] |
p02572 | u856636328 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\nl = list(map(int,input().split()))\ns = 0\ns1 = sum(l)\nfor x in range(n-1):\n s+=l[x]*(s1-l[x])\nprint(s%1000000007)\n', 'n = int(input())\nl = list(map(int,input().split()))\ns = 0\ns1 = sum(l)\na = 0\nfor x in range(n-1):\n s+=(l[x]*(s1-l[x]-a))\n a+=l[x]\nprint(s%1000000007)\n'] | ['Wrong Answer', 'Accepted'] | ['s923419282', 's710168281'] | [31368.0, 31588.0] | [124.0, 147.0] | [131, 151] |
p02572 | u857605629 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\na = map(int,input().split())\ntemp = sum(a)**2\nfor x in a:\n temp -= x**2\nprint(temp//2)', 'n = int(input())\na = map(int,input().split())\nmod = 10**9 + 7\ntemp = sum(a)**2\nfor x in a:\n temp -= x**2\nprint((temp//2)%mod)', 'n = int(input())\na = list(map(int,input().split()))\nmod = 10**9 + 7\ntemp = sum(a)**2\nfor x in a:\n\ttemp -= x**2\nprint((temp//2)%mod)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s317763096', 's611016872', 's055863240'] | [25140.0, 25316.0, 31500.0] | [72.0, 69.0, 142.0] | [104, 126, 131] |
p02572 | u857673087 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\na = list(map(int,input().split()))\n\nmod= 10**9+7\n\nA = sum(a)\n\nans=0\n\nfor i in a:\n A -= i\n A%=mod\n ans += A*x\n ans%=mod\nprint(ans)\n \n', 'n = int(input())\na = list(map(int,input().split()))\n\nmod= 10**9+7\n\nA = sum(a)\n\nans=0\n\nfor i in a:\n A -= i\n A%=mod\n ans += A*i\n ans%=mod\nprint(ans)\n \n'] | ['Runtime Error', 'Accepted'] | ['s363870643', 's043084410'] | [31436.0, 31616.0] | [74.0, 142.0] | [154, 154] |
p02572 | u860002137 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\narr = list(map(int, input().split()))\n\nans = 0\nsum_arr = sum(arr)\n\nfor x in arr:\n ans += x * (sum_arr - x) // 2\n ans %= MOD\n\nprint(ans)', 'n = int(input())\narr = list(map(int, input().split()))\n\nMOD = 10**9 + 7\n\nans = 0\nsum_arr = sum(arr)\n\nfor x in arr:\n ans += x * (sum_arr - x) // 2\n ans %= MOD\n\nprint(ans)', 'n = int(input())\narr = list(map(int, input().split()))\n\nMOD = 10**9 + 7\n\nans = 0\nsum_arr = sum(arr)\n\nfor x in arr:\n sum_arr -= x\n ans += x * sum_arr\n ans %= MOD\n\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s386924365', 's789613022', 's313866111'] | [31440.0, 31620.0, 31616.0] | [80.0, 146.0, 148.0] | [158, 175, 181] |
p02572 | u861886710 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA = list(map(int, input().split()))\nsum_A = sum(A)\nans = 0\n\nfor i in range(N):\n sum_A = sum_A - A[i]\n ans += A[i] * sum_A\n \nprint(ans//(10^9 + 7))\n ', 'import numpy as np\n\nN = int(input())\nA = list(map(int, input().split()))\n\nB = np.array(A)\n\na = 0\nfor i in range(N):\n a += A[i]*A[i]\n\ndot = np.dot(B,B.T)\nprint((dot - a)/2)', 'N = int(input())\nA = list(map(int, input().split()))\nsum_A = sum(A)\nans = 0\n \nfor i in range(N):\n sum_A = (sum_A - A[i])%(10**9 + 7)\n ans += A[i] * sum_A\n \nprint(ans%(10**9 + 7))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s257324538', 's394409251', 's577727020'] | [31524.0, 49996.0, 31664.0] | [129.0, 219.0, 125.0] | [169, 174, 181] |
p02572 | u864090097 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA = list(map(int ,input().split()))\nMOD = 1e9+7\n\nsum = 0\nfor i in range (N):\n sum += A[i]\n\nans = 0\nfor i in range(N):\n sum -= A[i]\n ans += (A[i] * sum) % MOD\n\nans = ans % MOD\nprint(ans)', 'import math\n\nN = int(input())\nA = list(map(int ,input().split()))\nMOD = math.floor(1e9+7)\n\nsum = 0\nfor i in range (N):\n sum += A[i] % MOD\n\nans = 0\nfor i in range(N):\n sum -= A[i]\n ans += (A[i] * sum) % MOD\n\nans = ans % MOD\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s034449639', 's193047893'] | [31472.0, 32848.0] | [188.0, 168.0] | [211, 242] |
p02572 | u865343871 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['from numpy.core import double\n\nN = int(input())\nA = list(map(int,input().split()))\nMOD = 1000000007\nSUM = 0\nfor i in range(N-1):\n j=i+1\n for j in range(N):\n SUM += A[i] * A[j] % MOD\nprint(SUM)', 'N = int(input())\nA = list(map(int,input().split()))\nMOD = 1000000007\nSUM = 0\nfor i in range(N-1):\n j=i+1\n for j in range(N):\n SUM += A[i] * A[j] % MOD\nprint(SUM)', 'N = int(input())\nA = list(map(int,input().split()))\nMOD = 1000000007\nS = sum(A) % MOD\nans = 0\n\nfor x in A:\n S -= x\n S %= MOD\n ans += S * x\n ans %= MOD\nans %= MOD\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s718994630', 's751313225', 's825609252'] | [49744.0, 31588.0, 31520.0] | [2207.0, 2206.0, 138.0] | [205, 174, 184] |
p02572 | u866949333 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ["def main():\n N = int(input())\n A = list(map(int, input().split()))\n\n mod = 10**9 + 7\n\n tmp = [0] * N\n\n s = 0\n for i in range(N):\n tmp[- i - 1] = s\n s += A[-i - 1]\n\n print(tmp)\n\n ans = 0\n for i in range(N):\n ans += A[i] * tmp[i]\n\n print(ans % mod)\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n N = int(input())\n A = list(map(int, input().split()))\n\n mod = 10**9 + 7\n\n tmp = [0] * N\n\n s = 0\n for i in range(N):\n tmp[- i - 1] = s\n s += A[-i - 1]\n\n # print(tmp)\n\n ans = 0\n for i in range(N):\n ans += A[i] * tmp[i]\n\n print(ans % mod)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s391158779', 's499132369'] | [35888.0, 31688.0] | [159.0, 131.0] | [338, 340] |
p02572 | u869820398 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\na = [int(i) for i in input().split()]\n\nsum1 = 0\nsum2 = 0\n\nfor _ in a:\n sum1 += _\n sum2 += (_*_)\nsum1 = (sum1 * sum1)\nprint(sum1 - sum2)\n', 'n = int(input())\na = [int(i) for i in input().split()]\n\nsum1 = 0\nsum2 = 0\n\nfor _ in a:\n sum1 += _\n sum2 += (a*a)\nsum1 = (sum1 * sum1)\nprint(sum1 - sum2)', 'n = int(input())\na = [int(i) for i in input().split()]\n\nsum1 = 0\nsum2 = 0\n\nfor _ in a:\n sum1 += _\n sum2 += (_*_)\nsum1 = (sum1 * sum1)\nprint(((sum1 - sum2)//2)%1000000007)\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s246269029', 's735555054', 's906123581'] | [31408.0, 31744.0, 31436.0] | [123.0, 81.0, 125.0] | [155, 154, 173] |
p02572 | u872271866 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['#include <bits/stdc++.h>\nusing namespace std;\n\nint main(){\n int N;\n long long ans = 0, sum =0;\n int mod = 1000000000+7;\n cin >> N;\n vector<int> a(N);\n for (int i = 0; i < N; i++) {\n cin >> a.at(i);\n sum += a.at(i);\n sum %= mod;\n }\n for (int i = 0; i < N; i++) {\n sum -= a.at(i);\n if(sum<0) sum += mod;\n ans += sum * a.at(i);\n ans %= mod;\n }\n cout << ans << endl;\n}\n', '#include <bits/stdc++.h>\nusing namespace std;\n\nint main(){\n int N;\n long long ans = 0, sum =0;\n int mod = 1000000000+7;\n cin >> N;\n vector<int> a(N);\n for (int i = 0; i < N; i++) {\n cin >> a.at(i);\n sum += a.at(i);\n }\n for (int i = 0; i < N-1; i++) {\n sum -= a.at(i);\n if(sum<0) sum += mod;\n ans += sum * a.at(i);\n ans %= mod;\n }\n cout << ans << endl;\n}\n/*\n\n*/\n', 'def main():\n n = int(input())\n a = []\n sum = 0 \n ans = 0 \n mod = 1_000_000_000 + 7\n x = list(map(int, input().split()))\n for i in range(n):\n sum += x[i] \n a.append(x[i])\n \n sum % mod\n \n for i in range(n):\n sum -= a[i]\n if sum < 0:\n sum += mod\n ans += sum * a[i]\n ans %= mod\n print(ans)\n\nif __name__ == "__main__":\n main()\n\n '] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s451075963', 's725881041', 's098389602'] | [9008.0, 8932.0, 30956.0] | [28.0, 23.0, 137.0] | [444, 433, 493] |
p02572 | u887152994 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N=int(input())\nList = list(map(int, input().split()))\nS=0\nfor i in range(len(List)):\n S+=List[i]\nmod=10**9+7\nS=S%mod\nT=0\nfor i in range(len(List)):\n T+=List[i]*(S-List[i])\n T=T%mod\nprint(T/2)', 'N=int(input())\nList = list(map(int, input().split()))\nS=0\nfor i in range(len(List)):\n S+=List[i]\nmod=10**9+7\nS=S%mod\nT=0\ns=0\nfor i in range(len(List)):\n s+=List[i]\n s=s%mod\n T+=List[i]*(S-s)\n T=T%mod\nprint(T)'] | ['Wrong Answer', 'Accepted'] | ['s432991820', 's684485142'] | [31532.0, 31600.0] | [161.0, 191.0] | [200, 223] |
p02572 | u893962649 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nx = 0\n\nfor a in A:\n ans = (ans + a * x) % (1e9+7)\n x = (x + a) % (10e9+7)\n\nprint(ans)\n', 'N = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nx = 0\n\nfor a in A:\n ans = (ans + a * x) % (1e9+7)\n x = (x + a) % (1e9+7)\n\nprint(ans)\n', 'N = int(input())\nA = list(map(int, input().split()))\n\n\nsum_a = sum(A)\nans = 0\nmod = int(1e9+7)\n\nfor a in A:\n sum_a -= a\n ans += (sum_a * a)\n\nans %= 1000000007\n\nprint(int(ans))\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s394102708', 's743826292', 's693859715'] | [31420.0, 31744.0, 31632.0] | [143.0, 148.0, 118.0] | [154, 153, 182] |
p02572 | u903005414 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['import sys\n\ninput = sys.stdin.buffer.readline\n\nN = int(input())\nA = list(map(int, input().split()))\nMOD = 10**9 + 7\n\ncumsum = [0]\nfor i in range(1, N):\n v = (A[0] * A[i]) % MOD\n cumsum.append((cumsum[-1] + v) % MOD)\nprint(cumsum)\n\nans = 0\nfor i in range(N):\n ans += (A[i] * (cumsum[-1] - cumsum[i])) % MOD\n ans %= MOD\nprint(ans)\n', 'import sys\nfrom collections import defaultdict\n\ninput = sys.stdin.buffer.readline\nN = int(input())\nA = list(map(int, input().split()))\nMOD = 10**9 + 7\n\nD = defaultdict(int)\nans = 0\nfor i in range(N - 1):\n for j in range(i + 1, N):\n v = A[i] * A[j] % MOD\n D[v] += 1\nprint(D)\n', 'import sys\ninput = sys.stdin.buffer.readline\nfrom itertools import accumulate\n\nMOD = 10**9 + 7\n\nN = int(input())\nA = [0] + list(map(int, input().split()))\nC = list(accumulate(A))\n\nans = 0\nfor i in range(1, N):\n ans += A[i] * (C[-1] - C[i])\n\nans %= MOD\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s668045797', 's704646704', 's663995793'] | [30292.0, 354296.0, 29312.0] | [241.0, 2214.0, 129.0] | [341, 291, 266] |
p02572 | u904537833 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['import sys\nfrom itertools import combinations\n\ninput = sys.stdin.readline\n\nN = int(input())\nA = list(map(int,input().split()))\nB = list(combinations(A,2))\nsum = 0\nfor i in range(len(B)):\n sum += B[i][0]*B[i][1]\n\n\n\n', 'import sys\ninput = sys.stdin.readline\n\ndef multipleSum(A, n):\n sum = 0\n for i in range(n):\n sum += A[i]\n mulsum = sum*sum\n insum = 0\n for i in range(n):\n insum+=A[i]*A[i]\n return (mulsum-insum)//2\n\nN = int(input())\nA = list(map(int,input().split()))\nn = len(A)\nprint(multipleSum(A,n)%1000000007)\n\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s875046264', 's738173585'] | [2002936.0, 31304.0] | [2278.0, 109.0] | [217, 331] |
p02572 | u904811150 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['ans = 0\n\nfor i in range(N-1):\n for j in range(i+1, N):\n print(i, j)\n ans += ((A[i]% (10**9 + 7))*(A[j]% (10**9 + 7))) % (10**9 + 7)\n \nprint(ans % (10**9 + 7))', 'N = int(input())\nA = [int(i) for i in input().split()]\nS = []\ne = 0\nfor i in A:\n e += i\n S.append(e)\n \nans = 0\nfor i in range(N-1):\n ans += A[i]%(10**9+7)*((S[N-1] - S[i])%(10**9+7))\n \nprint(ans%(10**9+7))'] | ['Runtime Error', 'Accepted'] | ['s966061756', 's162849634'] | [9116.0, 31492.0] | [26.0, 179.0] | [182, 220] |
p02572 | u907865484 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['MOD = 1000000007\n\nN = input()\nn_list = list(map(int,input().split()))\n\nprint(n_list)\n\nresult = 0\n\nfor i in range(n):\n for j in range(n-i-1)\n result += n_list[i] * n_list[j+1] % MOD\n result = result % MOD\n\nprint(result)\n', '\nN = int(input())\nn_list = list(map(int,input().split()))\n\nresult = 0\n\ns = sum(n_list)\nm = 10**9+7\n\nfor num in n_list:\n s -= num\n result += num * s % m\n result %= m\n\nprint(result)\n'] | ['Runtime Error', 'Accepted'] | ['s222152804', 's452329977'] | [8644.0, 31548.0] | [24.0, 143.0] | [236, 189] |
p02572 | u909224749 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['import numpy as np\n \nN = int(input())\nA = np.array(map(int, input().split()))\n \nA %= (1000000000+7)\n_sum = 0\n \nfor n in range(N-1):\n for i in range(n+1):\n _sum += A[n+1] * A[i]\n _sum %= (1000000000+7)\n \nprint(_sum)', '\nN = int(input())\nA = list(map(int, input().split()))\n \n\nS = [0]*N\nfor n in range(N):\n S[n] = S[n-1] + A[n]\n \n_sum = 0\nfor i in range(N-1):\n _sum = _sum + (A[i] * (S[N] - S[i+1]))\n\n#modulo\n_sum = _sum % (1000000000+7)\n \nprint(_sum)', '\nN = int(input())\nA = list(map(int, input().split()))\n \n\nS = [0]*N\nfor n in range(N):\n S[n] = S[n-1] + A[n]\n \n_sum = 0\nfor i in range(N-1):\n _sum = _sum + (A[i] * (S[N] - S[i+1]))\n _sum = _sum % (1000000000+7)\n \nprint(_sum)', 'import numpy as np\n\nN = int(input())\nA = np.array(map(int, input().split()))\n\nA %= (1000000000+7)\n_sum = 0\n\nfor n in range(N-1):\n for i in range(n+1):\n _sum += A[n+1] * A[i]\n _sum = %= (1000000000+7)\n \nprint(_sum)', '\nN = int(input())\nA = list(map(int, input().split()))\n\n\nS = [0]*N\nfor n in range(N):\n\tS[n] = S[n-1] + A[n]\n\n_sum = 0\nfor i in range(N-1):\n _sum = _sum + (A[i] * (S[N] - S[i+1]))\n _sum = _sum % (1000000000+7)\n \nprint(_sum)\n', '\nN = int(input())\nA = list(map(int, input().split()))\n \n\nS = [0]*N\nfor n in range(N):\n S[n] = S[n-1] + A[n]\n \n_sum = int(0)\nfor i in range(N-1):\n _sum = _sum + int((A[i] * (S[N] - S[i])))\n\n#modulo\n_sum = _sum % (1000000000+7)\n \nprint(_sum)', '\nN = int(input())\nA = list(map(int, input().split()))\n\n\nS = [0]*N\nfor n in range(N):\n S[n] = S[n-1] + A[n]\n\n_sum = int(0)\nfor i in range(N-1):\n _sum = _sum + (A[i] * (S[-1] - S[i]))\n\n#modulo\n_sum = _sum % (1000000000+7)\n \nprint(_sum)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s105677981', 's381277308', 's444512003', 's549552930', 's803683852', 's916522971', 's010024338'] | [44008.0, 31576.0, 31384.0, 8960.0, 31600.0, 31644.0, 31760.0] | [130.0, 110.0, 117.0, 22.0, 114.0, 117.0, 168.0] | [224, 258, 251, 223, 248, 266, 259] |
p02572 | u910358825 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['import numpy\nn=input()\nl=list(map(int, input().split()))\nres=0\n#print(f"le{len(l)}")\nl.append(0)\nl.reverse()\nfor i in range(len(l)): \n print(l[len(l)-1-i],numpy.cumsum(l)[len(l)-i-2])\n res+=l[len(l)-1-i]*numpy.cumsum(l)[len(l)-i-2]\n print(f"{res}レス")\nprint(res%(10**9+7))\n#print(res)', 'import numpy\nn=input()\nl=list(map(int, input().split()))\nres=0\n#print(f"le{len(l)}")\nl.append(0)\nl.reverse()\nfor i in range(len(l)): \n print(l[len(l)-1-i],numpy.cumsum(l)[len(l)-i-2])\n res+=l[len(l)-1-i]*numpy.cumsum(l)[len(l)-i-2]\n \nprint(res%(10**9+7))\n#print(res)', 'import numpy\nn=int(input())\nl=list(map(int, input().split()))\nres=0\nmod=10**9+7\nl.append(0)\nl.reverse()\ncum=numpy.cumsum(l)%mod\nfor i in range(n):\n res+=((l[n-i]%mod)*cum[n-i-1])%mod\nprint(res%mod)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s309051117', 's664897348', 's146024294'] | [49752.0, 50244.0, 49820.0] | [2207.0, 2207.0, 328.0] | [296, 297, 200] |
p02572 | u910536093 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\n\na = (list(map(int, input().split())))\n\nans = 0\n\nfor i in range(n):\n for j in range(i+1, n):\n ans += a[i] * a[j]\n print("i, j, a[i], a[j] = {}, {}, {}, {}".format(i, j, a[i], a[j]))\n\nprint(ans % (10 ** 9 + 7))\n', 'n = int(input())\n\na = list(map(int, input().split()))\n\nS = sum(a)\n\nS2 = sum(map(lambda x: x * x, a ))\n\nans = (S * S - S2) // 2 % 1000000007\nprint(ans)\n\n'] | ['Wrong Answer', 'Accepted'] | ['s973506402', 's053419177'] | [129340.0, 31464.0] | [5910.0, 89.0] | [244, 152] |
p02572 | u914693053 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n=int(input())\na=list(map(int,input().split()))\nl=list(map(lambda z:z**2,a))\nx=sum(a)\ny=sum(l)\nt=(x-y)//2\nprint(t)\n', 'n=int(input())\na=list(map(int,input().split()))\nif n==1:\nprint(a[0])\nelse:\nl=list(map(lambda z:z**2,a)\nx=sum(a)\ny=sum(l)\nt=(x-y)//2\nprint(t)', 'n=int(input())\na=list(map(int,input().split()))\nl=list(map(lambda z:z**2,a)\nx=sum(a)\ny=sum(l)\nt=(x-y)//2\nprint(t)\n', 'n=int(input())\na=list(map(int,input().split()))\nif n==1:\n print(a[0])\nelse:\n l=list(map(lambda z:z**2,a))\n x=sum(a)\n y=sum(l)\n t=(x-y)//2\n print(t)\n', 'n=int(input())\na=list(map(int,input().split()))\nif n==1:\nprint(a[0])\nelse:\nl=list(map(lambda z:z**2,a)\nx=sum(a)\ny=sum(l)\nt=(x-y)//2\nif t>(10**9+7):\n print(t%(10**9+7))\nelse:\n print(t)\n', 'n=int(input())\na=list(map(int,input().split()))\nl=list(map(lambda z:z**2,a))\nx=sum(a)\ny=sum(l)\nt=(x-y)//2\nif t>(10**9+7):\n print(t%(10**9+7))\nelse:\n print(t)\n', 'n=int(input())\na=list(map(int,input().split()))\nl=list(map(lambda z:z**2,a))\nx=sum(a)**2\ny=sum(l)\nt=(x-y)//2\nif t>(10**9+7):\n print(t%(10**9+7))\nelse:\n print(t)\n'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s057984226', 's553906763', 's634282369', 's646523687', 's753347907', 's922011393', 's254831510'] | [31764.0, 8896.0, 8956.0, 31648.0, 9016.0, 31596.0, 31520.0] | [129.0, 27.0, 25.0, 129.0, 29.0, 137.0, 128.0] | [115, 140, 114, 154, 196, 170, 173] |
p02572 | u917678406 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nNUM = 1000000007\nA = [list(map(int, input().split())) for _ in range(N)]\nMASS = 0\nfor i in range (N):\n I = A[i] % NUM\n I = (I * (N - 1)) % NUM\n MASS += I\nprint(MASS % NUM)', 'N = int(input())\nNUM = 1000000007\nA = [int(input()) for _ in range(N)]\nMASS = 0\nfor i in range (N):\n I = A[i] % NUM\n I = (I * (N - 1)) % NUM\n MASS += I\nprint(MASS % NUM)', 'for i in range (N):\n A = (int(input())\nMASS = 0\nfor i in range (N - 1):\n T = 0\n for j in range (i + 1, N):\n T += (A[j] % NUM)\n MASS += ((A[i]%NUM) * (T%NUM))%NUM\nprint(MASS % NUM)', 'n = int(input())\na = list(map(int, input().split()))\ntotal = 0\nsub = 0\nfor i in a:\n total += i\n sub += i * i\nprint((((total * total) - sub) // 2) % (10 ** 9 + 7))'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s131677751', 's311152729', 's415298548', 's440047873'] | [31384.0, 13228.0, 8976.0, 31588.0] | [75.0, 42.0, 25.0, 112.0] | [197, 178, 198, 168] |
p02572 | u917872021 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\na_list = list(map(int, input().split()))\n\nMOD = (10**9)+7\na_sum = 0\nans = 0\nfor i in range(n-1):\n a_sum += a_list[n-i-1]\n print(a_sum)\n ans += a_sum * a_list[n-i-2]\n ans = ans % MOD\n\nprint(ans)\n', 'n = int(input())\na_list = list(map(int, input().split()))\n\nMOD = (10**9)+7\na_sum = 0\nans = 0\nfor i in range(n-1):\n a_sum += a_list[n-i-1]\n ans += a_sum * a_list[n-i-2]\n ans = ans % MOD\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s133117243', 's632472189'] | [31744.0, 31552.0] | [235.0, 172.0] | [223, 206] |
p02572 | u922299074 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N=input()\nA=list(map(int,input().split()))\ncount1=0\ncount2=0\nfor a in A[0:]:\n count1=count1+a\n count2=count2+a**2\n\nB=(count1**2-count2)/2\nC=B%(10**9+7)\nprint(C)', 'N=input()\nA=list(map(int,input().split()))\ncount1=0\ncount2=0\nfor a in A[0:]:\n count1=count1+a\n count2=count2+a**2\n\nB=(count1**2-count2)//2\nC=B%(10**9+7)\nprint(C)'] | ['Wrong Answer', 'Accepted'] | ['s547795021', 's325836653'] | [31756.0, 31540.0] | [149.0, 140.0] | [166, 167] |
p02572 | u923279197 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\nmod = 10**9+ 7\na = list(map(int,input().split()))\nans = (sum(a)%mod)**2 - (sum[x**2 for x in a]%mod)\nans *= 5*10**8+4\nans %= mod\nprint(ans)', 'n = int(input())\nmod = 10**9+ 7\na = list(map(int,input().split()))\nans = (sum(a)%mod)**2 - sum([x**2%mod for x in a])\nans *= 5*10**8+4\nans %= mod\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s802456829', 's797192279'] | [9028.0, 31628.0] | [24.0, 134.0] | [156, 156] |
p02572 | u924828749 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\na = [int(x) for x in input().split()]\n\nb = [0]\nfor i in range(1,n+1):\n b.append((a[i-1] + b[i-1]) % ((10 ** 9) + 7))\nprint(b)\n\nans = 0\nfor i in range(n):\n p = b[n] - b[i+1]\n p = a[i] * p % (10**9 + 7)\n ans += p\n print(ans,p)\nprint(ans)', 'n = int(input())\na = [int(x) for x in input().split()]\nm = 1000000007\nans = 0\n\nb = [0]\nfor i in range(1,n+1):\n b.append((a[i-1] + b[i-1]) % m)\n#print(a,b)\n \nfor i in range(n):\n\tp = b[n] - b[i+1]\n\tp *= a[i]\n\tp = p % m\n\tans += p\n\tans = ans % m\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s828493745', 's837769571'] | [31360.0, 31492.0] | [350.0, 248.0] | [257, 263] |
p02572 | u926266624 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA = list(map(int, input().split()))\n\nM = 0\nsum = 0\nfor i in range(N):\n sum += A[i]\n\nfor i in range(N-1):\n JM =0\n for j in range(i+1,N):\n sum = sum - A[i]\n M += A[i] * sum\n if M > 10 ** 9 + 7:\n M = M % (10 ** 9 + 7)\nprint(M)', 'N = int(input())\nA = list(map(int, input().split()))\n\nM = 0\n\nfor i in range(1,N-1):\n for j in range(i+1,N):\n M += A[i] * A[j]\n if M > 10**9 + 7:\n M = M %(10**9 +7)\nprint(M)', 'N = int(input())\nA = list(map(int, input().split()))\n\nM = 0\nsum = 0\nfor i in range(N):\n sum += A[i]\n\nfor i in range(N-1):\n sum = sum - A[i]\n M += A[i] * sum\n if M > 10 ** 9 + 7:\n M = M % (10 ** 9 + 7)\nprint(M)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s365659040', 's824272022', 's142752644'] | [31432.0, 31544.0, 31612.0] | [2206.0, 2206.0, 174.0] | [257, 186, 216] |
p02572 | u928758473 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['import os\nimport sys\nfrom collections import defaultdict, Counter\nfrom itertools import product, permutations,combinations, accumulate\nfrom operator import itemgetter\nfrom bisect import bisect_left,bisect\nfrom heapq import heappop,heappush,heapify\nfrom math import ceil, floor, sqrt\nfrom copy import deepcopy\nimport numpy \n \ndef main():\n n = int(input())\n alist = list(map(int, input().split()))\n max_num = 10**9 + 7\n ans = 0\n for i in range(n):\n ans += numpy.cumsum(alist[:i+1])\n\n print(ans%max_num)\n\nif __name__ == "__main__":\n main()', 'import os\nimport sys\nfrom collections import defaultdict, Counter\nfrom itertools import product, permutations,combinations, accumulate\nfrom operator import itemgetter\nfrom bisect import bisect_left,bisect\nfrom heapq import heappop,heappush,heapify\nfrom math import ceil, floor, sqrt\nfrom copy import deepcopy\n \n\ndef cumsum(xs):\n pass\n\ndef main():\n n = int(input())\n alist = list(map(int, input().split()))\n max_num = 10**9 + 7\n ans = 0\n sum_num = sum(alist)\n\n for i in range(n-1):\n sum_num -= alist[i]\n ans += alist[i] * sum_num\n \n\n print(ans%max_num)\n\nif __name__ == "__main__":\n main()'] | ['Runtime Error', 'Accepted'] | ['s800057376', 's939728093'] | [50068.0, 32052.0] | [158.0, 111.0] | [564, 635] |
p02572 | u934868410 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\na = list(map(int,input().split()))\nmod = 10**9 + 7\ns = sum(a)\nans = 0\nfor x in a:\n ans += (s-x) * x\n ans %= mod\nprint(ans)', 'n = int(input())\na = list(map(int,input().split()))\nmod = 10**9 * 7\ns = sum(a)\nans = 0\nfor x in a:\n ans += (s-x) * x\n ans %= mod\nprint(ans)', 'n = int(input())\na = list(map(int,input().split()))\nmod = 10**9 + 7\ninvtwo = pow(2, mod-2, mod)\ns = sum(a) % mod\nans = 0\nfor x in a:\n ans += (s-x) * x\n ans %= mod\nprint((ans * invtwo) % mod)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s363514438', 's645341142', 's852977570'] | [31420.0, 31588.0, 31444.0] | [125.0, 140.0, 122.0] | [141, 141, 192] |
p02572 | u938785734 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['import numpy as np\nans=0\nn=int(input())\nli=list(map(int,input().split()))\nfor i in range(1,n):\n L=li\n k=np.cumsum(L[:i])\n ans+=k*li[i]\nprint(ans%(10**9+7))', 'import itertools\nans=0\nn=int(input())\nli=list(map(int,input().split()))\nL=list(itertools.accumulate(li))\nfor i in range(1,n):\n ans+=L[i-1]*li[i]\nprint(ans%(10**9+7))'] | ['Runtime Error', 'Accepted'] | ['s707745598', 's264415715'] | [50024.0, 31096.0] | [163.0, 131.0] | [164, 168] |
p02572 | u939790872 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA = list(map(int, input().split()))\nans=0\nfor i in range(N):\n ans+=(sum(A)-A[i])*A[i]\nprint((ans/2)%(10**9+7))', 'N = int(input())\nA = list(map(int, input().split()))\n\nmod = 10 ** 9 + 7\nans = 0\n\nA_sum = [A[0] for i in range(N)]\nfor i in range(1, N):\n A_sum[i] = A_sum[i-1] + A[i]\n\nfor i in range(1, N):\n ans += A[i] * A_sum[i-1]\n ans %= mod\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s867800165', 's687544941'] | [31412.0, 31756.0] | [2206.0, 180.0] | [130, 248] |
p02572 | u942388574 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['# -*- coding: utf-8 -*-\n"""\nCreated on Sat Aug 29 22:19:15 2020\n\n@author: naoki\n"""\n\nN = int(input())\n\nA = list(map(int,input().split()))\n\ncount1 = 0\ncount2 = 0\ncount = 10**9 +7\nfor i in A:\n count1+=i\n\tcount1=count1%count\nfor j in A:\n count2 = j*(count1-j)%count + count2\n count1 = count1 -j \n \nprint(count2%count)\n \n \n ', '# -*- coding: utf-8 -*-\n"""\nCreated on Sat Aug 29 22:19:15 2020\n\n@author: naoki\n"""\n\nN = int(input())\n\nA = list(map(int,input().split()))\n\ncount1 = 0\ncount2 = 0\ncount = 10**9 +7\nfor i in A:\n count1+=i\n\nfor j in A:\n count2 = (j*(count1-j) + count2)%count\n count1 = count1 -j \n \nprint(count2%count)\n \n \n '] | ['Runtime Error', 'Accepted'] | ['s856722163', 's913413663'] | [8884.0, 31452.0] | [24.0, 157.0] | [341, 323] |
p02572 | u944396627 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['def main():\n N=input()\n A=list(map(float, input().split()))\n\n mod_value = 10**9 + 7\n sum = 0\n for i in range(len(A)-1):\n for j in range(i+1,len(A)):\n sum = sum + A[i]*A[j] % mod_value\n print(sum % mod_value)\nmain()\n', '4\n141421356 17320508 22360679 244949', 'def main():\n N=input()\n A=list(map(int, input().split()))\n\n mod_value = 10**9 + 7\n sum_ = 0\n b_sum = 0\n for i in range(len(A)-1):\n b_sum = b_sum + A[len(A)-i-1]\n sum_ = sum_ + (A[len(A)- i - 2]*b_sum) % mod_value\n print(sum_%mod_value)\nmain()'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s536653443', 's785415477', 's737950772'] | [31440.0, 9004.0, 31464.0] | [2206.0, 26.0, 162.0] | [250, 36, 277] |
p02572 | u945065638 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['import itertools\nimport numpy as np\n\nMOD = 1000000007\nn = int(input())\nai = list(map(int,input().split()))\nans = 0\n\nfor v in itertools.permutations(ai, 2):\n print(v)\n ans += np.prod(v)\n \nprint(ans % MOD)', 'n = int(input())\na = list(map(int,input().split()))\n\nMOD = 10 ** 9 + 7\ns =sum(a) % MOD\nans = 0\n\nfor i in a :\n s -= i\n s %= MOD\n ans += i * s\n ans %= MOD\n \nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s637840213', 's636254150'] | [49840.0, 31368.0] | [2222.0, 141.0] | [212, 180] |
p02572 | u947664173 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n=int(input())\na=list(map(int,input().split()))\nans=0\nfor i in range(n):\n b=a[i]*sum(a[i+1:n])\n print(b)\n ans=ans+b\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nans=0\nfor i in range(n):\n b=a[i]*sum(a[i+1:n])\n print(b)\n ans=ans+b\nd=ans%(10**9+7)\nprint(d)', 'n=int(input())\na=list(map(int,input().split()))\nans=0\nc=sum(a)\nfor i in range(n):\n c=c-a[i]\n b=(a[i]*c)\n ans=ans+b\nd=ans%(1000000007)\nprint(d)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s270672011', 's343794923', 's475964720'] | [31404.0, 31432.0, 31508.0] | [2206.0, 2206.0, 137.0] | [135, 149, 152] |
p02572 | u949327459 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA = list(map(int,input().split()))\n\nA = A % (1*10**9 + 7)\nvalue = 0\nplus = 0\nans = 0\n\nfor i in range(N-1):\n for j in range(N-i-1):\n value = (A[i]*A[i+j+1]+value) % (1*10**9 + 7)\n \n\nprint(value)\n', 'N = int(input())\nA = list(map(int,input().split()))\n\nA_sum = sum(A)\n\nvalue = 0\nans = 0\n\nfor i in range(N-1):\n A_sum -= A[i]\n value += A[i]*A_sum\n\nans = value % (1*10**9+7)\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s716046544', 's001764970'] | [31652.0, 31552.0] | [70.0, 131.0] | [228, 189] |
p02572 | u952708174 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ["def c_sum_of_product_of_pairs(MOD=10**9 + 7):\n import numpy\n N = int(input())\n A = [int(i) for i in input().split()]\n\n total = sum(A)\n cumsum = [0] + list(numpy.cumsum(A, dtype='int64'))\n return sum([(total - cumsum[i]) * A[i] for i in range(N)]) % MOD\n\nprint(c_sum_of_product_of_pairs())", 'def c_sum_of_product_of_pairs(MOD=10**9 + 7):\n N = int(input())\n A = [int(i) for i in input().split()]\n\n cumsum = [0]\n for a in A:\n cumsum.append(cumsum[-1] + a)\n return sum([(cumsum[N] - cumsum[i + 1]) * A[i] for i in range(N)]) % MOD\n\nprint(c_sum_of_product_of_pairs())'] | ['Wrong Answer', 'Accepted'] | ['s828217284', 's502204689'] | [51932.0, 39440.0] | [918.0, 140.0] | [306, 293] |
p02572 | u953020348 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['for i in range(N-1):\n tmp+=A[i]\n ans+=tmp*A[i+1]\nprint(ans%((10**9)+7))', 'import math\n\nN=int(input())\nA=list(map(int,input().split()))\nans=0\ntmp=0\n\nfor i in range(N-1):\n tmp+=A[i]\n ans+=tmp*A[i+1]\nprint(ans%((10**9)+7))'] | ['Runtime Error', 'Accepted'] | ['s424451849', 's734804504'] | [9068.0, 32744.0] | [28.0, 135.0] | [77, 151] |
p02572 | u953655640 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA=list(map(int, input().split()))\nB=[A[N-1]]\n#print(B[0])\nfor i in range(len(A)-2):\n #print(i)\n b=B[i]+A[N-2-i]\n B.append(b)\nprint(B)\ntotal=0\nfor i in range(len(B)):\n total += A[i]*B[len(B)-1-i]\n\nprint(total%(10**9+7))\n #print(v)', 'N = int(input())\nA=list(map(int, input().split()))\nB=[A[N-1]]\n#print(B[0])\nfor i in range(len(A)-2):\n #print(i)\n b=B[i]+A[N-2-i]\n B.append(b)\n\ntotal=0\nfor i in range(len(B)):\n total += A[i]*B[len(B)-1-i]\n\nprint(total%(10**9+7))'] | ['Wrong Answer', 'Accepted'] | ['s593573479', 's526340547'] | [35864.0, 31440.0] | [216.0, 193.0] | [261, 248] |
p02572 | u956318161 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n = int(input())\na = list(map(int,input().split()))\nb=sum(a)\nscore=0\nfor i in range(len(a)):\n b -= a[i]\n score=a[i]*b\n \nprint(score%(10**9+7))', 'n = int(input())\na = list(map(int,input().split()))\nb=sum(a)\nscore=0\nfor i in range(len(a)):\n b -= a[i]\n score=a[i]*b\n \nprint(score)', 'n=int(input())\na=list(map(int,input().split()))\nscore=0\nmod=10**9+7\nb=sum(a)\nfor i in range(0,n-1):\n b-=a[i]\n score+=a[i]*b\n\nprint(score%mod)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s418161054', 's636022516', 's009861706'] | [31372.0, 31296.0, 31684.0] | [119.0, 117.0, 129.0] | [145, 135, 143] |
p02572 | u958103790 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['def square(list):\n return [i ** 2 for i in list]\nm = 1000000007\nn = int(input())\nA = list(map(int, input().split()))\nsq = square(A)\ns1 = sum(A)\ns2 = sum(sq)\n\nresult = (s1**2-s2)/2\nprint(result%m)', 'def square(list):\n return [i ** 2 for i in list]\nm = 1000000007\nn = int(input())\nA = list(map(int, input().split()))\nsq = square(A)\ns1 = sum(A)\ns2 = sum(sq)\n \nresult = (s1**2-s2)//2\nprint(result%m)'] | ['Wrong Answer', 'Accepted'] | ['s455089729', 's437755983'] | [31740.0, 31580.0] | [122.0, 121.0] | [198, 200] |
p02572 | u960080897 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ["# Date [ 2020-08-29 21:10:46 ]\n\n# Author Koki_tkg\n\nimport sys\n# import math\n\n# import numpy as np\n# from decimal import Decimal\n# from numba import njit, i8, u1, b1 #JIT compiler\n# from itertools import combinations, product\n# from collections import Counter, deque, defaultdict\n\n\nMOD = 10 ** 9 + 7\nINF = 10 ** 9\nPI = 3.14159265358979323846\n\ndef read_str(): return sys.stdin.readline().strip()\ndef read_int(): return int(sys.stdin.readline().strip())\ndef read_ints(): return map(int, sys.stdin.readline().strip().split())\ndef read_ints2(x): return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())\ndef read_str_list(): return list(sys.stdin.readline().strip().split())\ndef read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))\ndef GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)\ndef LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)\n\ndef Main():\n n = read_int()\n a = read_int_list()\n \n ans = 0\n\n total = sum(a)\n for i in range(n):\n ans += (a[i] * (total - a[i])) / 2\n ans %= MOD\n\n print(ans % MOD)\n\nif __name__ == '__main__':\n Main()", "# Date [ 2020-08-29 21:10:46 ]\n\n# Author Koki_tkg\n\nimport sys\n# import math\n\n# import numpy as np\n# from decimal import Decimal\n# from numba import njit, i8, u1, b1 #JIT compiler\n# from itertools import combinations, product\n# from collections import Counter, deque, defaultdict\n\n\nMOD = 10 ** 9 + 7\nINF = 10 ** 9\nPI = 3.14159265358979323846\n\ndef read_str(): return sys.stdin.readline().strip()\ndef read_int(): return int(sys.stdin.readline().strip())\ndef read_ints(): return map(int, sys.stdin.readline().strip().split())\ndef read_ints2(x): return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())\ndef read_str_list(): return list(sys.stdin.readline().strip().split())\ndef read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))\ndef GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)\ndef LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)\n\ndef Main():\n n = read_int()\n a = read_int_list()\n \n ans = 0\n\n total = sum(a)\n floatcnt = 0\n for i in range(n):\n ans += a[i] * (total - a[i])\n ans %= MOD\n total -= a[i]\n\n print(int(ans % MOD))\n\nif __name__ == '__main__':\n Main()"] | ['Wrong Answer', 'Accepted'] | ['s953456398', 's769242804'] | [31300.0, 33036.0] | [162.0, 132.0] | [1215, 1253] |
p02572 | u961945062 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nS = sum(A)\nfor i in range(N):\n S -= A[i]\n ans += A[i] * S\n\nans = ans % 10**9+7\n\nprint(int(ans))', 'N = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nS = sum(A)\nfor i in range(N):\n S -= A[i]\n ans += A[i] * S\n\nans = ans % (10**9+7)\n\nprint(int(ans))'] | ['Wrong Answer', 'Accepted'] | ['s932747743', 's929660857'] | [31512.0, 31536.0] | [141.0, 127.0] | [163, 165] |
p02572 | u966207392 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA = list(map(int, input().split()))\ncnt=0\nfor i in range(1,N):\n cnt += i*(sum(A[i-1:]))\nprint(cnt%((10**9)+7))', 'N = int(input())\nA = list(map(int, input().split()))\nsum = sum(A)\ncnt = 0\nfor i in range(N-1):\n sum -= A[i]\n cnt += A[i]*sum\nprint(cnt%((10**9)+7))'] | ['Wrong Answer', 'Accepted'] | ['s563560332', 's415656176'] | [31668.0, 31612.0] | [2206.0, 131.0] | [130, 153] |
p02572 | u969081133 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['MOD = 10**9+7\nn = int(input())\na = list(map(int, input().split()))\n \nans = sum(a)**2\nfor i in range(n):\n ans -= a[i]*a[i]\nans /= 2\nans %= MOD\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nans=sum(a)*sum(a)\nfor i in range(n):\n ans-=a[i]*a[i]\nans/=2\nmod=10**9+7\nans//=mod\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nans=sum(a)*sum(a)\nfor i in range(n):\n ans-=a[i]*a[i]\nans/=2\nmod=10**9+7\nans//=mod\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nans=sum(a)*sum(a)\nfor i in range(n):\n ans=ans-(a[i]*a[i])\nans=ans/2\nmod=10**9+7\nans=ans%mod\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nans=sum(a)*sum(a)\nfor i in range(n):\n ans-=a[i]*a[i]\nans/=2\nmod=10**9+7\nans%=mod\nprint(ans)', 'n=int(input())\narray=list(map(int,input().split()))\nlist2=[]\nfor i in range(n):\n for j in range(i+1,n):\n list2.append(array[i]*array[j])\na=n*(n-1)/2\nans=0\nfor m in range(a):\n ans=ans+list2[m]\n if ans>=10**9+7:\n ans=ans-(10**9+7)\nprint(ans)', 'n=int(input())\narray=list(map(int,input().split()))\nans=0\nfor i in range(n-1):\n for j in range(i+1,n):\n ans+=array[i]*array[j]\nmod=10**9+7\nans//=mod\nprint(ans)', 'n=int(input())\narray=list(map(int,input().split()))\nans=0\nfor i in range(n-1):\n for j in range(i+1,n):\n ans+=array[i]*array[j]\nmod=10*9+7\nans//=mod\nprint(ans)', 'n=int(input())\narray=list(map(int,input().split()))\nlist2=[]\nfor i in range(n):\n for j in range(i+1,n):\n list2.append(array[i]*array[j])\na=n*(n-1)\nans=0\nfor m in range(a):\n ans=ans+list2[m]\n if ans>10**9+7:\n ans=ans-10**9+7\nprint(ans//10**9+7)', 'n=int(input())\narray=list(map(int,input().split()))\nlist2=[]\nfor i in range(n-1):\n for j in range(i+1,n):\n list2.append(array[i]*array[j])\na=n*(n-1)/2\nans=0\nfor m in range(a):\n ans=ans+list2[m]\n if ans>=10**9+7:\n ans=ans-(10**9+7)\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nans=sum(a)*sum(a)\nfor i in range(n):\n ans-=a[i]*a[i]\nans//=2\nmod=10**9+7\nans%=mod\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s322782460', 's366518322', 's464924017', 's512917672', 's537174039', 's581122215', 's726470895', 's787146100', 's839760183', 's978343792', 's297498019'] | [31444.0, 31424.0, 31608.0, 31388.0, 31340.0, 549156.0, 31616.0, 31752.0, 550972.0, 550192.0, 31612.0] | [108.0, 110.0, 113.0, 113.0, 113.0, 2223.0, 2206.0, 2206.0, 2227.0, 2223.0, 111.0] | [155, 141, 141, 151, 140, 248, 163, 162, 252, 250, 141] |
p02572 | u970082363 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['n,m = (int(x) for x in input().split())\nfriendlist = [0]*n\nclasses = 1\nfor i in range(m):\n a,b = (int(x)-1 for x in input().split())\n if friendlist[a]!=0 and friendlist[b]!=0:\n continue\n elif friendlist[a]!=0:\n friendlist[b] = friendlist[a]\n elif friendlist[b]!=0:\n friendlist[a] = friendlist[b]\n else:\n friendlist[a] = classes\n friendlist[b] = classes\n classes += 1\n\ncount = [0]*classes\nmaxa = 0\nfor i in range(n):\n count[friendlist[i]] += 1\n maxa = max([count[friendlist[i]],maxa])\n\nprint(maxa)', 'n = int(input())\n\nAn = [int(i) for i in input().split()]\nS = sum(An)\nSn = S**2\nSn2 = 0\nfor a in An:\n Sn2 += a**2\n\nans = ((Sn - Sn2)//2)%(10**9+7)\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s565546941', 's846163202'] | [9220.0, 31364.0] | [22.0, 133.0] | [559, 160] |
p02572 | u974918235 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA = list(map(int, input().split()))\nS = [A[0]]\nfor i in range(1, N):\n S.append(S[i-1] + A[i])\nprint(S)\nx = 0\nfor i in range(N):\n x += (A[i] * (S[-1] - S[i])) % 1000000007\nx = x % 1000000007\nprint(x)', 'N = int(input())\nA = list(map(int, input().split()))\nS = [A[0]]\nfor i in range(1, N):\n S.append(S[i-1] + A[i])\nx = 0\nfor i in range(N):\n x += (A[i] * (S[-1] - S[i])) % 1000000007\nx = x % 1000000007\nprint(x)'] | ['Wrong Answer', 'Accepted'] | ['s463287951', 's209432753'] | [35788.0, 31576.0] | [206.0, 189.0] | [217, 208] |
p02572 | u981931040 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\n# N = 2 * 10 ** 5\nA = tuple(map(int, input().split()))\n# A = [10 ** 9] * N\nMOD = 10 ** 9 + 7\nrev_sum_list = [0] * N\nrev_sum_list[-1] = A[-1]\nfor i in range(N - 2, -1, -1):\n rev_sum_list[i] = (rev_sum_list[i + 1] + A[i]) % MOD\nprint(rev_sum_list)\nans = 0\nfor i in range(1, N):\n ans += A[i - 1] * rev_sum_list[i]\n ans %= MOD\nprint(ans)', 'N = int(input())\n# N = 2 * 10 ** 5\nA = tuple(map(int, input().split()))\n# A = [10 ** 9] * N\nMOD = 10 ** 9 + 7\nrev_sum_list = [0] * N\nrev_sum_list[-1] = A[-1]\nfor i in range(N - 2, -1, -1):\n rev_sum_list[i] = (rev_sum_list[i + 1] + A[i]) % MOD\n# print(rev_sum_list)\nans = 0\nfor i in range(1, N):\n ans += A[i - 1] * rev_sum_list[i]\n ans %= MOD\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s793061662', 's750277912'] | [31952.0, 31904.0] | [212.0, 194.0] | [359, 361] |
p02572 | u987637902 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['N = int(input())\nA = list(map(int, input().split()))\nmod = 10 ** 9 + 7\nct = 0\nn = N - 1\nfor i in range(n):\n for j in range(i+1, N):\n print(A[i])\n print(A[j])\n x = A[i] * A[j]\n ct += x\nprint((ct % mod))\n', '# C\u3000Sum of product of pairs\nN = int(input())\nA = list(map(int, input().split()))\nt = sum(A)\nx = t - A[0]\nmod = 10 ** 9 + 7\nct = 0\nfor i in range(N-1):\n ct += A[i] * x\n x = x - A[i+1]\n\nprint((ct % mod))\nint((ct % mod))\n'] | ['Wrong Answer', 'Accepted'] | ['s486136064', 's977261245'] | [68516.0, 31692.0] | [2293.0, 134.0] | [233, 226] |
p02572 | u999327182 | 2,000 | 1,048,576 | Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). | ['ans = 0\nN = int(input())\narray = list(map(int, input().split()))\nx = sum(array)\nfor i in range(N):\n ans += array[i] * (x -arrau[i])\nprint(int(ans/2)%(10**9+7))', 'N = int(input())\nA = list(map(int, input().split()))\n \nans = 0\nx = sum(A)\n \nfor i in range(N - 1):\n x -= A[i]\n ans += A[i] * x\n \nans = ans % (10 ** 9 + 7)\n \nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s705268501', 's966728076'] | [31476.0, 31596.0] | [78.0, 127.0] | [162, 176] |
p02573 | u015767468 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['N,M=list(map(int,input().split()))\nX=[]\nfor i in range(M):\n X.append(list(map(int,input().split())))\ndic={i:[i] for i in range(1,N+1)}\nfor i in range(M):\n if X[i][1] not in dic[X[i][0]]:\n dic[X[i][0]].append(X[i][1])\n if X[i][0] not in dic[X[i][1]]:\n dic[X[i][1]].append(X[i][0])\nc=1\nfor i in range(1,N+1):\n c=max(c,len(dic[i]))\nprint(c)\nprint(dic)', 'class UnionFind():\n def __init__(self,n):\n self.n=n\n self.parents=[-1]*n\n def find(self,x):\n if self.parents[x]<0:\n return x\n else:\n self.parents[x]=self.find(self.parents[x])\n return self.parents[x]\n def union(self,x,y):\n x=self.find(x)\n y=self.find(y)\n if x==y:\n return\n if self.parents[x]>self.parents[y]:\n x,y=y,x\n self.parents[x]+=self.parents[y]\n self.parents[y]=x\n def size(self,x):\n return -self.parents[self.find(x)]\n\nN,M=map(int,input().split())\nX=[]\nfor i in range(M):\n X.append(list(map(int,input().split())))\nUF=UnionFind(N)\nfor i in range(M):\n UF.union(X[i][0]-1,X[i][1]-1)\nprint(max(UF.size(i) for i in range(N))) '] | ['Wrong Answer', 'Accepted'] | ['s348280196', 's650187312'] | [104680.0, 50060.0] | [2208.0, 876.0] | [374, 780] |
p02573 | u061140245 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['import sys\nn, m = map(int, input().split())\ninfo = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]\n\npars = [-1]*n\n\ndef get_root(x):\n if pars[x] < 0:\n return x\n else:\n pars[x] = get_root(pars[x])\n return pars[x]\n\ndef combine(x, y):\n if x == y:\n return\n r_x = get_root(x)\n r_y = get_root(y)\n if r_x > r_y:\n r_x, r_y = r_y, r_x\n if r_x != r_y:\n pars[r_x] += pars[r_y] \n pars[r_y] = r_x\n\ndef size(x):\n return -pars[get_root(x)]\n\nfor x, y in info:\n combine(x, y)\n\nprint(-min(pars))\n', 'n, m = map(int, input().split())\ninfo = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]\n\npars = [-1]*n\n\ndef get_root(x):\n if pars[x] < 0:\n return x\n else:\n return get_root(pars[x])\n\n\ndef combine(x, y):\n if x == y:\n return\n r_x = get_root(x)\n r_y = get_root(y)\n if r_x > r_y:\n r_x, r_y = r_y, r_x\n if r_x != r_y:\n pars[r_x] += pars[r_y] \n pars[r_y] = r_x\n\ndef size(x):\n return -pars[get_root(x)]\n\nfor x, y in info:\n combine(x, y)\n\nprint(-min(pars))\n', 'import sys\n\n\nclass UnionFind():\n def __init__(self, n):\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n\nN, M = map(int, input().split())\ninfo = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]\n\nuf = UnionFind(N)\nfor a, b in info:\n a -= 1; b -= 1\n uf.union(a, b)\n\nans = min(uf.parents)\n\nprint(-ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s024194035', 's374973957', 's550106561'] | [50156.0, 9096.0, 50264.0] | [322.0, 26.0, 429.0] | [609, 573, 746] |
p02573 | u085717502 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['#!/usr/bin/env python\n# coding: utf-8\n\n# In[140]:\n\n\ndef find(x):\n if par[x] < 0:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n\ndef unite(x,y):\n x = find(x)\n y = find(y)\n if x == y:\n return False\n if par[x] > par[y]:\n x,y = y,x\n par[x] += par[y]\n par[y] = x\n return True\n\ndef size(x):\n return -par[find(x)]\n\n\n# In[144]:\n\n\npar = [-1]*N\nN,M = map(int, input().split())\nfor _ in range(M):\n A,B = map(int, input().split())\n A -= 1; B -= 1\n unite(A,B)\nans = 0\nfor i in range(N):\n ans = max(ans, size(i))\nprint(ans)\n\n\n# In[ ]:\n\n\n\n\n', '#!/usr/bin/env python\n# coding: utf-8\n\n# In[1]:\n\n\ndef find(x):\n if par[x] < 0:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n\ndef unite(x,y):\n x = find(x)\n y = find(y)\n if x == y:\n return False\n if par[x] > par[y]:\n x,y = y,x\n par[x] += par[y]\n par[y] = x\n return True\n\ndef size(x):\n return -par[find(x)]\n\n\n# In[3]:\n\n\nN,M = map(int, input().split())\npar = [-1]*N\nfor _ in range(M):\n A,B = map(int, input().split())\n A -= 1; B -= 1\n unite(A,B)\nans = 0\nfor i in range(N):\n ans = max(ans, size(i))\nprint(ans)\n\n\n# In[ ]:\n\n\n\n\n'] | ['Runtime Error', 'Accepted'] | ['s488708981', 's032147402'] | [9088.0, 14628.0] | [24.0, 741.0] | [611, 607] |
p02573 | u092650292 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['\nn, m = map(int, input().split()) \npar = [i for i in range(1, n + 1)] \n\n\n\n\ndef find(x):\n if par[x - 1] == x:\n return x\n else:\n par[x - 1] = find(par[x - 1])\n return par[x - 1]\n\n\n\ndef union(x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return 0\n par[x - 1] = y\n\n\n\nfor j in range(m):\n a, b = map(int, input().split())\n union(a, b)\n\n\n\ns = [find(i) for i in range(1, n + 1)]\nprint(1)\n#import collections\n#c = collections.Counter(s)\n#print(max(c.values()))\n', '\nn, m = map(int, input().split()) \npar = [i for i in range(1, n + 1)] \n\n\n\n\ndef find(x):\n if par[x - 1] == x:\n return x\n else:\n par[x - 1] = find(par[x - 1])\n return par[x - 1]\n\n\n\ndef union(x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return 0\n par[x - 1] = y\n\n\n\nfor j in range(m):\n a, b = map(int, input().split())\n union(a, b)\n\n\n\nimport collections\nc = collections.Counter(s)\nprint(max(c.values()))\n', '\nn, m = map(int, input().split()) \npar = [i for i in range(1, n + 1)] \n\n\n\n\ndef find(x):\n if par[x - 1] == x:\n return x\n else:\n par[x - 1] = find(par[x - 1])\n return par[x - 1]\n\n\n\ndef union(x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return 0\n par[x - 1] = y\n\n\n\nfor j in range(m):\n a, b = map(int, input().split())\n union(a, b)\nprint(1)\n\n\n\n#import collections\n#c = collections.Counter(s)\n#print(max(c.values()))\n', 'import collections\nn, m = map(int, input().split())\npar = [i for i in range(n)]\n# print(par)\ns = list()\n\n\n\ndef find(x):\n\n while par[x] != x:\n tmp = par[x]\n par[x] = par[par[x]]\n x = par[x]\n\n return x\n\n\ndef union(x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return 0\n else:\n par[x] = y\n\n\n\nfor j in range(m):\n a, b = map(int, input().split())\n union(a - 1, b - 1)\n\n\nfor k in range(n):\n s.append(find(k))\n# print(s)\nc = collections.Counter(s)\nprint(max(c.values()))\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s465245585', 's800387414', 's903383791', 's613363660'] | [24900.0, 17140.0, 17064.0, 40200.0] | [824.0, 735.0, 719.0, 653.0] | [1039, 1027, 1039, 819] |
p02573 | u100858029 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ["'''\n \tWe can show that if u and v belong to the same connected component, then they are friends w/ each other\n \tSo everyone in a given connected component is friends with one another\n \tSo everyone in a given connected component must be separated into different groups\n\n \tIf we have a CC of with sz nodes in it, then we need at least sz different groups\n\n \tSo, the minimum number of groups needed is max sz(CC)\n '''\nimport sys\nsys.setrecursionlimit(4*10**5)\n\nn, m = map(int,input().split())\nadj = [[] for u in range(n+1)]\nfor i in range(m):\n u, v = map(int,input().split())\n adj[u].append(v)\n adj[v].append(u)\n\n vis = [False for u in range(n+1)]\n def dfs(u):\n if vis[u]:\n return 0\n vis[u] = True\n\n sz = 1\n for v in adj[u]:\n sz += dfs(v)\n return sz\n\n CCs = []\n for u in range(1,n+1):\n if not vis[u]:\n CCs.append(dfs(u))\n\n print(max(CCs))", "'''\n\tWe can show that if u and v belong to the same connected component, then they are friends w/ each other\n\tSo everyone in a given connected component is friends with one another\n\tSo everyone in a given connected component must be separated into different groups\n\n\tIf we have a CC of with sz nodes in it, then we need at least sz different groups\n\n\tSo, the minimum number of groups needed is max sz(CC)\n'''\nimport sys\nsys.setrecursionlimit(4e5)\n\nn, m = map(int,input().split())\nadj = [[] for u in range(n+1)]\nfor i in range(m):\n\tu, v = map(int,input().split())\n\tadj[u].append(v)\n\tadj[v].append(u)\n\nvis = [False for u in range(n+1)]\ndef dfs(u):\n\tif vis[u]:\n\t\treturn 0\n\tvis[u] = True\n\n\tsz = 1\n\tfor v in adj[u]:\n\t\tsz += dfs(v)\n\treturn sz\n\nCCs = []\nfor u in range(1,n+1):\n\tif not vis[u]:\n\t\tCCs.append(dfs(u))\n\nprint(max(CCs))", "'''\n\tWe can show that if u and v belong to the same connected component, then they are friends w/ each other\n\tSo everyone in a given connected component is friends with one another\n\tSo everyone in a given connected component must be separated into different groups\n\n\tIf we have a CC of with sz nodes in it, then we need at least sz different groups\n\n\tSo, the minimum number of groups needed is max sz(CC)\n'''\nimport sys\nsys.setrecursionlimit(2*10**5+5)\n\nn, m = map(int,input().split())\nadj = [[] for u in range(n+1)]\nfor i in range(m):\n\tu, v = map(int,input().split())\n\tadj[u].append(v)\n\tadj[v].append(u)\n\nvis = [False for u in range(n+1)]\ndef dfs(u):\n\tif vis[u]:\n\t\treturn 0\n\tvis[u] = True\n\n\tsz = 1\n\tfor v in adj[u]:\n\t\tsz += dfs(v)\n\treturn sz\n\nCCs = []\nfor u in range(1,n+1):\n\tif not vis[u]:\n\t\tCCs.append(dfs(u))\n\nprint(max(CCs))"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s263634011', 's637505266', 's285458456'] | [26532.0, 9012.0, 210860.0] | [2206.0, 28.0, 693.0] | [910, 823, 829] |
p02573 | u102655885 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['# from collections import defaultdict\nfrom collections import deque\nn, m = map(lambda x: int(x), input().split())\n\nuf = UnionFind(n)\n\nfor _ in range(m):\n a, b = map(lambda x: int(x), input().split())\n uf.union(a-1, b-1)\n \nprint(-min(uf.parent_indexes))', "# UnionFind\n\n\n\nclass UnionFind:\n def __init__(self, size):\n self.parent_indexes = [-1] * size\n \n def find_parent(self, n):\n# print(self.parent_indexes[n])\n if self.parent_indexes[n] < 0:\n return n\n# print('hewe')\n \n \n self.parent_indexes[n] = self.find_parent(self.parent_indexes[n])\n return self.parent_indexes[n] \n \n def union(self, n1, n2):\n if self.same_group(n1, n2):\n return False\n \n \n if self.size(n1) >= self.size(n2):\n tmp = self.size(n2)\n self.parent_indexes[self.find_parent(n2)] = self.find_parent(n1)\n self.parent_indexes[self.find_parent(n1)] -= tmp\n return True\n \n tmp = self.size(n1)\n self.parent_indexes[self.find_parent(n1)] = self.find_parent(n2)\n self.parent_indexes[self.find_parent(n2)] -= tmp\n return True\n \n \n def size(self, n):\n return -self.parent_indexes[self.find_parent(n)]\n \n def same_group(self, n1, n2):\n# UnionFind\n\n\n\nclass UnionFind:\n def __init__(self, size):\n self.parent_indexes = [-1] * size\n \n def find_parent(self, n):\n# print(self.parent_indexes[n])\n if self.parent_indexes[n] < 0:\n return n\n# print('hewe')\n \n \n self.parent_indexes[n] = self.find_parent(self.parent_indexes[n])\n return self.parent_indexes[n] \n \n def union(self, n1, n2):\n if self.same_group(n1, n2):\n return False\n \n \n if self.size(n1) >= self.size(n2):\n tmp = self.size(n2)\n self.parent_indexes[self.find_parent(n2)] = self.find_parent(n1)\n self.parent_indexes[self.find_parent(n1)] -= tmp\n return True\n \n tmp = self.size(n1)\n self.parent_indexes[self.find_parent(n1)] = self.find_parent(n2)\n self.parent_indexes[self.find_parent(n2)] -= tmp\n return True\n \n \n def size(self, n):\n return -self.parent_indexes[self.find_parent(n)]\n \n def same_group(self, n1, n2):\n return self.find_parent(n1) == self.find_parent(n2) return self.find_parent(n1) == self.find_parent(n2)", "# UnionFind\n\n\n\nclass UnionFind:\n def __init__(self, size):\n self.parent_indexes = [-1] * size\n \n def find_parent(self, n):\n# print(self.parent_indexes[n])\n if self.parent_indexes[n] < 0:\n return n\n# print('hewe')\n \n \n self.parent_indexes[n] = self.find_parent(self.parent_indexes[n])\n return self.parent_indexes[n] \n \n def union(self, n1, n2):\n if self.same_group(n1, n2):\n return False\n \n \n if self.size(n1) >= self.size(n2):\n tmp = self.size(n2)\n self.parent_indexes[self.find_parent(n2)] = self.find_parent(n1)\n self.parent_indexes[self.find_parent(n1)] -= tmp\n return True\n \n tmp = self.size(n1)\n self.parent_indexes[self.find_parent(n1)] = self.find_parent(n2)\n self.parent_indexes[self.find_parent(n2)] -= tmp\n return True\n \n \n def size(self, n):\n return -self.parent_indexes[self.find_parent(n)]\n \n def same_group(self, n1, n2):\n return self.find_parent(n1) == self.find_parent(n2)\n\n\nn, m = map(lambda x: int(x), input().split())\nuf = UnionFind(n)\n\nn, m = map(lambda x: int(x), input().split())\n\nuf = UnionFind(n)\n\nfor _ in range(m):\n a, b = map(lambda x: int(x), input().split())\n uf.union(a-1, b-1)\n \nprint(-min(uf.parent_indexes))", "# UnionFind\n\n\n\nclass UnionFind:\n def __init__(self, size):\n self.parent_indexes = [-1] * size\n \n def find_parent(self, n):\n# print(self.parent_indexes[n])\n if self.parent_indexes[n] < 0:\n return n\n# print('hewe')\n \n \n self.parent_indexes[n] = self.find_parent(self.parent_indexes[n])\n return self.parent_indexes[n] \n \n def union(self, n1, n2):\n if self.same_group(n1, n2):\n return False\n \n \n if self.size(n1) >= self.size(n2):\n tmp = self.size(n2)\n self.parent_indexes[self.find_parent(n2)] = self.find_parent(n1)\n self.parent_indexes[self.find_parent(n1)] -= tmp\n return True\n \n tmp = self.size(n1)\n self.parent_indexes[self.find_parent(n1)] = self.find_parent(n2)\n self.parent_indexes[self.find_parent(n2)] -= tmp\n return True\n \n \n def size(self, n):\n return -self.parent_indexes[self.find_parent(n)]\n \n def same_group(self, n1, n2):\n return self.find_parent(n1) == self.find_parent(n2)\n\n\n\nn, m = map(lambda x: int(x), input().split())\nuf = UnionFind(n)\n\nfor _ in range(m):\n a, b = map(lambda x: int(x), input().split())\n uf.union(a-1, b-1)\n \nprint(-min(uf.parent_indexes))"] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s094214977', 's224088982', 's907064176', 's175121785'] | [9416.0, 9076.0, 12216.0, 14872.0] | [27.0, 30.0, 885.0, 898.0] | [261, 2842, 1682, 1617] |
p02573 | u112007848 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['def root(x):\n if par[x] == x:\n return x\n par[x] = 1\n return par[x]\n\ndef union(x, y):\n rx = root(x)\n ry = root(y)\n if rx != ry:\n par[rx] = ry\n return 0\n \nn, m=map(int, input().split(" "))\npar = list(range(n + 1))\nfor i in range(m):\n a, b = map(int, input().split(" "))\n union(a, b)\n#print(par)\nmaxi = 0\ncount = 1\n#print(par)\ncountpar = [0 for i in range(n + 1)]\nfor i in range(1, n + 1):\n countpar[root(par[i])] += 1\nprint(max(countpar))\n', 'def root(i):\n if par[i] == i:\n return i\n par[i] = root(par[i])\n return par[i]\n\ndef union(x, y):\n rx = root(x)\n ry = root(y)\n if rx != ry:\n par[ry] = rx\n\ndef same(x, y):\n return par[x] == par[y]\n\nn,m = map(int, input().split(" "))\np = [0] + list(map(int, input().split(" ")))\na = [(list(map(int, input().split(" ")))) for i in range(m)]\npar = list(range(n + 1))\ncount = 0\nfor i, j in a:\n union(i, j)\n #print(par)\n#print(p)\nfor i in range(1, n):\n if same(root(par[p[i]]), root(par[i])):\n count += 1\nprint(count)', 'def root(x):\n if par[x] == x:\n return x\n par[x] = root(par[x])\n return 1\n\ndef union(x, y):\n rx = root(x)\n ry = root(y)\n if rx != ry:\n par[rx] = ry\n return 0\n \nn, m=map(int, input().split(" "))\npar = list(range(n + 1))\nfor i in range(m):\n a, b = map(int, input().split(" "))\n union(a, b)\n#print(par)\nmaxi = 0\ncount = 1\n#print(par)\ncountpar = [0 for i in range(n + 1)]\nfor i in range(1, n + 1):\n countpar[root(par[i])] += 1\nprint(max(countpar))\n', 'def root(i):\n if par[i] == i:\n return i\n par[i] = root(par[i])\n return par[i]\n\ndef union(x, y):\n rx = root(x)\n ry = root(y)\n if rx != ry:\n par[ry] = rx\n\ndef same(x, y):\n return par[x] == par[y]\n\nn,m = map(int, input().split(" "))\np = [0] + list(map(int, input().split(" ")))\na = [(list(map(int, input().split(" ")))) for i in range(m)]\npar = list(range(n + 1))\ncount = 0\nfor i, j in a:\n union(i, j)\n #print(par)\n#print(p)\nfor i in range(1, n + 1):\n if same(root(par[p[i]]), root(par[i])):\n count += 1\nprint(count)', 'def root(x):\n if par[x] == x:\n return x\n par[x] = root(par[x])\n return par[x]\n\ndef union(x, y):\n rx = root(x)\n ry = root(y)\n if rx != ry:\n par[rx] = ry\n return 0\n \nn, m=map(int, input().split(" "))\npar = list(range(n + 1))\nfor i in range(m):\n a, b = map(int, input().split(" "))\n union(a, b)\n#print(par)\nmaxi = 0\ncount = 1\n#print(par)\ncountpar = [0 for i in range(n + 3)]\nfor i in range(1, n + 1):\n countpar[i] += 1\nprint(max(countpar))\n', 'def root(x):\n if par[x] == x:\n return x\n par[x] = root(par[x])\n return par[x]\n\ndef union(x, y):\n rx = root(x)\n ry = root(y)\n if rx != ry:\n par[rx] = ry\n return 0\n \nn, m=map(int, input().split(" "))\npar = list(range(n + 1))\nfor i in range(m):\n a, b = map(int, input().split(" "))\n union(a, b)\n#print(par)\nmaxi = 0\ncount = 1\n#print(par)\ncountpar = [0 for i in range(n + 1)]\nfor i in range(1, n + 1):\n print(i)\nprint(max(countpar))\n', 'def root(x):\n return 1\n if par[x] == x:\n return x\n par[x] = root(par[x])\n return par[x]\n\ndef union(x, y):\n rx = root(x)\n ry = root(y)\n if rx != ry:\n par[rx] = ry\n return 0\n \nn, m=map(int, input().split(" "))\npar = list(range(n + 1))\nfor i in range(m):\n a, b = map(int, input().split(" "))\n union(a, b)\n#print(par)\nmaxi = 0\ncount = 1\n#print(par)\ncountpar = [0 for i in range(n + 1)]\nfor i in range(1, n + 1):\n countpar[root(par[i])] += 1\nprint(max(countpar))\n', 'def root(i):\n if par[i] == i:\n return i\n par[i] = root(par[i])\n return par[i]\n\ndef union(x, y):\n rx = root(x)\n ry = root(y)\n if rx != ry:\n par[ry] = rx\n\ndef same(x, y):\n return par[x] == par[y]\n\nn,m = map(int, input().split(" "))\np = [0] + list(map(int, input().split(" ")))\na = [(list(map(int, input().split(" ")))) for i in range(m)]\npar = list(range(n + 1))\ncount = 0\nfor i, j in a:\n union(i, j)\n #print(par)\n#print(p)\nfor i in range(1, n + 5):\n if same(root(par[p[i]]), root(par[i])):\n count += 1\nprint(count)', 'import sys\nimport resource\n\ndef root(x):\n if par[x] == x:\n return x\n par[x] = root(par[x])\n return par[x]\n\ndef union(x, y):\n rx = root(x)\n ry = root(y)\n if rx != ry:\n par[rx] = ry\n return 0\n\nsys.setrecursionlimit(10 ** 6)\nn, m=map(int, input().split(" "))\npar = list(range(n + 1))\nfor i in range(m):\n a, b = map(int, input().split(" "))\n union(a, b)\n#print(par)\nmaxi = 0\ncount = 1\n#print(par)\ncountpar = [0 for i in range(n + 1)]\n\nfor i in range(1, n + 1):\n countpar[root(par[i])] += 1\nprint(max(countpar))\n#print(countpar, par)\n'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s043037704', 's087318715', 's091102342', 's218253999', 's359847025', 's555917095', 's616826728', 's704293034', 's326980072'] | [18508.0, 45420.0, 19084.0, 45336.0, 18520.0, 18692.0, 18492.0, 45180.0, 176024.0] | [550.0, 399.0, 585.0, 396.0, 632.0, 666.0, 449.0, 397.0, 706.0] | [456, 528, 462, 532, 456, 448, 478, 532, 576] |
p02573 | u113255362 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ["N,M=map(int,input().split())\nList = []\nfor i in range (M):\n List.append(list(map(int, input().split())))\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n \nuni = UnionFind(N)\nfor i in range(M):\n uni.union(List[i][0],List[i][1])\nres = 0\nfor i in range(N):\n res = max(res,uni.size(i))\nprint(res)", "N,M=map(int,input().split())\nList = []\nfor i in range (M):\n List.append(list(map(int, input().split())))\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n \nuni = UnionFind(N)\nfor i in range(M):\n uni.union(List[i][0]-1,List[i][1]-1)\nres = 0\nfor i in range(N):\n res = max(res,uni.size(i))\nprint(res)"] | ['Runtime Error', 'Accepted'] | ['s953123381', 's687592857'] | [46968.0, 49972.0] | [628.0, 878.0] | [1267, 1403] |
p02573 | u124864167 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['from networkx import*;_,*n=map(str.split,open(0));print(max(map(len,[*connected_components(Graph(n))]),1,1))', 'from networkx import*;_,*n=map(str.split,open(0));print(max(map(len,[*connected_components(Graph(n))]),1,1))', 'l=lambda:map(int, input().split())\nn,m=l()\np=[-1]*n\ndef root(x):\n if p[x]<0:return x\n p[x]=root(p[x]);return p[x]\ndef union(x,y):\n x,y=root(x),root(y)\n if x==y: return\n p[x]+=p[y]\n p[y]=x\ndef same(x,y):\n return root(x)==root(y)\ndef size(x):\n return -p[r(x)]\nfor _ in range(m):\n a,b=l()\n union(a-1,b-1)\nprint(-min(p))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s121363456', 's277352767', 's879596687'] | [309624.0, 309708.0, 13276.0] | [1705.0, 1726.0, 612.0] | [108, 108, 327] |
p02573 | u127499732 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ["def main():\n from collections import defaultdict\n n, m, *ab, = map(int, open(0).read().split())\n f = defaultdict(lambda: set())\n for i, j in zip(ab[::2], ab[1::2]):\n f[i].add(j)\n f[j].add(i)\n\n group = []\n i = 1\n g = {i}\n nx = {i}\n checked = set()\n ans = 0\n while i <= n:\n if i in checked:\n i += 1\n continue\n \n tmp = set()\n for j in list(nx):\n tmp |= f[j]\n tmp -= nx\n\n if len(tmp) == 0:\n checked |= g\n group.append(g)\n l = len(g)\n r = n - len(checked)\n ans = max(ans, l)\n if l >= r:\n break\n i += 1\n g = {i}\n continue\n else:\n g |= tmp\n nx = tmp\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "class UnionFind:\n def __init__(self, size):\n self.parents = [-1] * size\n\n def find(self, x):\n while self.parents[x] > 0:\n x = self.parents[x]\n return x\n\n def union(self, i, j):\n pi, pj = self.find(i), self.find(j)\n if pi == pj:\n return\n if self.parents[pi] < self.parents[pj]:\n pi, pj = pj, pi\n i, j = j, i\n self.parents[pi] += self.parents[pj]\n self.parents[pj] = pi\n self.reconnect(j, pi)\n\n def reconnect(self, i, j):\n while self.parents[i] > 0:\n t = self.parents[i]\n self.parents[i] = j\n i = t\n\n\ndef main():\n n, m, *ab, = map(int, open(0).read().split())\n uf = UnionFind(n + 1)\n\n for i, j in zip(ab[::2], ab[1::2]):\n uf.union(i, j)\n\n print(-min(uf.parents))\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s236332124', 's381280531'] | [108668.0, 57256.0] | [2209.0, 495.0] | [864, 879] |
p02573 | u137226361 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ["import sys\n\ndef main():\n stdin = sys.stdin\n n, m = map(int, stdin.readline().split())\n\n par = [i for i in range(i)]\n size = [1] * n\n rank = [1] * n\n\n def find(x, par):\n if par[x] == x:\n return x\n else:\n return find(par[x], par)\n\n def unite(x, y):\n x = find(x)\n y = find(y)\n\n if x != y:\n \n if rank[x] < rank[y]:\n par[x] = y\n size[y] += size[x]\n else:\n par[y] = x\n size[x] += size[y]\n if rank[x] == rank[y]:\n rank[x] += 1\n\n for _ in range(m):\n a, b = map(int, stdin.readline().split())\n unite(a, b)\n\n\n print(max(size))\n\nif __name__ == '__main__':", "import sys\n\ndef main():\n stdin = sys.stdin\n n, m = map(int, stdin.readline().split())\n\n par = [i for i in range(i)]\n size = [1] * n\n rank = [1] * n\n\n def find(x, par):\n if par[x] == x:\n return x\n else:\n return find(par[x], par)\n\n def unite(x, y):\n x = find(x)\n y = find(y)\n\n if x != y:\n \n if rank[x] < rank[y]:\n par[x] = y\n size[y] += size[x]\n else:\n par[y] = x\n size[x] += size[y]\n if rank[x] == rank[y]:\n rank[x] += 1\n\n for _ in range(m):\n a, b = map(int, stdin.readline().split())\n unite(a, b, par, rank)\n\n\n print(max(size))\n\nif __name__ == '__main__':\n main()", "import sys\n\ndef main():\n stdin = sys.stdin\n n, m = map(int, stdin.readline().split())\n\n par = [i for i in range(n)]\n size = [1] * n\n rank = [1] * n\n\n def find(x, par):\n if par[x] == x:\n return x\n else:\n return find(par[x], par)\n\n def unite(x, y):\n x = find(x, par)\n y = find(y, par)\n\n if x != y:\n \n if rank[x] < rank[y]:\n par[x] = y\n size[y] += size[x]\n else:\n par[y] = x\n size[x] += size[y]\n if rank[x] == rank[y]:\n rank[x] += 1\n\n for _ in range(m):\n a, b = map(int, stdin.readline().split())\n unite(a-1, b-1)\n\n\n print(max(size))\n\nif __name__ == '__main__':\n main()"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s509849890', 's968375264', 's253640398'] | [8864.0, 9192.0, 20192.0] | [31.0, 25.0, 354.0] | [815, 837, 840] |
p02573 | u153047519 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['class union:\n def __init__(self, box):\n self.r = []\n for i in range(box):\n self.r.append(-1)\n \n def root(self, x):\n if self.r[x] < 0:\n return x\n return self.r[x] = root(self.r[x])\n\n def add(self, a, b):\n a = root(a)\n b = root(b)\n if a == b:\n return False\n if self.r[a] > self.r[b]:\n a, b = b, a\n self.r[a] += self.r[b]\n self.r[b] = a\n return True\n \n def size(self, x):\n return self.r[x]\n\nn, m = map(int, input().split())\nuf = union(m)\nans = 0\nfor i in range(m):\n uf.add(map(int, input().split()))\n\nfor i in range(n):\n ans = max(ans, uf.size(i))\nprint(ans)', 'class union:\n def __init__(self, box):\n self.r = []\n for i in range(box):\n self.r.append(-1)\n \n def root(self, x):\n if self.r[x] < 0:\n return x\n self.r[x] = self.root(self.r[x])\n return self.r[x]\n\n def add(self, a):\n a[0] -= 1\n a[1] -= 1\n a[0] = self.root(a[0])\n a[1] = self.root(a[1])\n if a[0] == a[1]:\n return False\n if self.r[a[0]] > self.r[a[1]]:\n a[0], a[1] = a[1], a[0]\n self.r[a[0]] += self.r[a[1]]\n self.r[a[1]] = a[0]\n return True\n \n def size(self, x):\n return -self.r[x]\n\nn, m = map(int, input().split())\nuf = union(n)\nans = 0\nfor i in range(m):\n uf.add(list(map(int, input().split())))\n\nfor i in range(n):\n ans = max(ans, uf.size(i))\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s881904823', 's902792316'] | [9024.0, 14908.0] | [26.0, 740.0] | [621, 731] |
p02573 | u157232135 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['def main():\n n,m=map(int,input().split())\n uf=UnionFind(n)\n for a,b in (map(lambda x: int(x)-1, input().split()) for _ in range(m)):\n uf.union(a,b)\n print(max((uf.size(x) for x in uf.roots())))\n \nif __name__ == "__main__":\n main()', 'def main():\n n,m=map(int,input().split())\n uf=UnionFind(n)\n for a,b in (map(lambda x: int(x)-1, input().split()) for _ in range(m)):\n uf.union(a,b)\n print(max((uf.size(x) for x in uf.roots())))\n\nclass UnionFind():\n \'\'\'Union-Find\'\'\'\n \n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def is_same(self, x, y) -> bool:\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return \'\\n\'.join(\'{}: {}\'.format(r, self.members(r)) for r in self.roots())\nif __name__ == "__main__":\n main()'] | ['Runtime Error', 'Accepted'] | ['s460853859', 's550134633'] | [9020.0, 18420.0] | [27.0, 620.0] | [255, 1434] |
p02573 | u161693347 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ["import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom functools import reduce\nfrom bisect import bisect_left, insort_left\nfrom heapq import heapify, heappush, heappop\n\nINPUT = lambda: sys.stdin.readline().rstrip()\nINT = lambda: int(INPUT())\nMAP = lambda: map(int, INPUT().split())\nS_MAP = lambda: map(str, INPUT().split())\nLIST = lambda: list(map(int, INPUT().split()))\nS_LIST = lambda: list(map(str, INPUT().split()))\n\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n \n \n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n \n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n \n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n \n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n \n def group_count(self):\n return len(self.roots())\n\n \n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n \n \n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\n\ndef main():\n N, M = MAP()\n\n tree = UnionFind(N)\n for _ in range(M):\n \ta, b = MAP()\n tree.union(a - 1, b - 1)\n\n ans = 0\n for l in tree.all_group_members().values():\n ans = max(ans, len(l))\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom functools import reduce\nfrom bisect import bisect_left, insort_left\nfrom heapq import heapify, heappush, heappop\n\nINPUT = lambda: sys.stdin.readline().rstrip()\nINT = lambda: int(INPUT())\nMAP = lambda: map(int, INPUT().split())\nS_MAP = lambda: map(str, INPUT().split())\nLIST = lambda: list(map(int, INPUT().split()))\nS_LIST = lambda: list(map(str, INPUT().split()))\n\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n \n \n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n \n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n \n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n \n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n \n def group_count(self):\n return len(self.roots())\n\n \n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n \n \n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\n\ndef main():\n N, M = MAP()\n \n tree = UnionFind(N)\n for _ in range(M):\n a, b = MAP()\n tree.union(a - 1, b - 1)\n\n ans = 0\n for i in range(N):\n ans = max(ans, tree.size(i))\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Runtime Error', 'Accepted'] | ['s346585620', 's561982916'] | [9096.0, 15540.0] | [24.0, 564.0] | [2719, 2705] |
p02573 | u170839742 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['from collections import Counter\n\n\nN, M = map(int, input().split())\nparent = [-1] * N\n\n\ndef union(x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return\n parent[x] = y\n\n\ndef find(x):\n if parent[x] == -1:\n return x\n res = parent[x] = find(parent[x])\n return res\n\nfor _ in range(M):\n a, b = map(int, input().split())\n union(a - 1, b - 1)\n\n\nprint(N + 1)\n', 'N, M = map(int, input().split())\nparent = [-1] * N\n\n\ndef union(x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return\n parent[x] = y\n\n\ndef find(x):\n if parent[x] == -1:\n return x\n res = parent[x] = find(parent[x])\n return res\n\nfor _ in range(M):\n a, b = map(int, input().split())\n union(a - 1, b - 1)\n\n\ncount = {}\nfor i in range(N):\n if (g := find(i)) in count:\n count[g] += 1\n else:\n count[g] = 1\n# res = 0\n# for value in count.values():\n# res = max(res, value)\nprint(N + 1)\n', 'N, M = map(int, input().split())\nparent = [-1] * N\n\n\ndef union(x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return\n parent[x] = y\n\n\ndef find(x):\n if parent[x] == -1:\n return x\n res = parent[x] = find(parent[x])\n return res\n\nfor _ in range(M):\n a, b = map(int, input().split())\n union(a - 1, b - 1)\n\n\ncount = [0] * N\nfor i in range(N - 1):\n find(i)\nprint(0)\n', 'from collections import Counter\nimport sys\n\nsys.setrecursionlimit(10 ** 6)\n\n\nN, M = map(int, input().split())\nparent = [-1] * N\n\n\ndef union(x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return\n parent[x] = y\n\n\ndef find(x):\n if parent[x] == -1:\n return x\n res = parent[x] = find(parent[x])\n return res\n\nfor _ in range(M):\n a, b = map(int, input().split())\n union(a - 1, b - 1)\n\n\ncount = Counter(find(i) for i in range(N))\nprint(count.most_common(1)[0][1])\n'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s005150677', 's523458846', 's760636120', 's957865222'] | [17096.0, 31364.0, 19024.0, 174328.0] | [580.0, 647.0, 628.0, 691.0] | [389, 539, 402, 496] |
p02573 | u183509493 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['n,m=map(int,input().split())\n# Union-Find\na=list(range(n))\ndef find(x):\n while a[x] != x:\n a[x] = a[a[x]]\n return a[x]\n\nfor _ in range(m):\n x,y=map(int,input().split())\n x,y=find(x-1),find(y-1)\n if x == y: continue\n a[y]=x\n\ncount=[0]*n\nfor i in range(n):\n count[find(i)] += 1\nprint(max(count))\n', 'n,m=map(int,input().split())\n# Union-Find\na=list(range(n))\ndef find(x):\n g = x\n while g != a[g]: g = a[g]\n a[x] = g\n return g\n\nfor _ in range(m):\n x,y=map(int,input().split())\n x,y=find(x-1),find(y-1)\n if x == y: continue\n a[y]=x\n\ncount=[0]*n\nfor i in range(n):\n count[find(i)] += 1\nprint(max(count))\n'] | ['Time Limit Exceeded', 'Accepted'] | ['s384171662', 's097889959'] | [18400.0, 18476.0] | [2206.0, 1833.0] | [304, 310] |
p02573 | u196455939 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['#D - Friends\nN,M = map(int,input().split())\npar = [i for i in range(N+1)]\n\ndef find(x):\n if par[x] == x:\n return x\n else:\n par[x] = find(par[x]) \n return par[x]\n\ndef size(x):\n return par.count(find(x))\n\ndef unite(x,y):\n x = find(x)\n y = find(y)\n if x == y:\n return 0\n if par[x] > par[y]:\n x,y = y,x\n #par[x] += par[y]\n par[y] = x\n# par[x] = y\n\nprint(par)\nfor i in range(M):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n unite(a,b)\n print(par)\n\ngroup_count = 0\n\nfor i in range(N):\n group_count = max(group_count,size(i))\n\n\nprint(group_count)\n', '#D - Friends\nN,M = map(int,input().split())\npar = [i for i in range(N)]\nrank = [1] * (N)\n\ndef find(x):\n if par[x] == x:\n return x\n else:\n par[x] = find(par[x]) \n return par[x]\n\ndef size(x):\n return par.count(find(x))\n\ndef unite(x,y):\n x = find(x)\n y = find(y)\n if x == y : return 0\n if par[x] > par[y]:\n x,y = y,x\n par[y] = x\n# par[x] = x\n if par[x] == par[y]:\n rank[x] += rank[y]\n# rank[y] += rank[x]\n#print(par)\n#print(rank)\nfor i in range(M):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n unite(a,b)\n# print(par)\n# print(rank)\ngroup_count = 0\n\ngroup_count = max(rank)\n\n\nprint(group_count)\n'] | ['Runtime Error', 'Accepted'] | ['s077447492', 's257253037'] | [149472.0, 24588.0] | [2365.0, 638.0] | [648, 706] |
p02573 | u199830845 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['\ndef resolve():\n import sys\n sys.setrecursionlimit(10 ** 6) \n to_index = lambda x: int(x) - 1 \n print_list_in_2D = lambda x: print(*x, sep="\\n") \n\n \n def input_int():\n return int(input())\n\n def map_int_input():\n return map(int, input())\n\n MII = map_int_input\n\n def MII_split():\n return map(int, input().split())\n\n def MII_to_index():\n return map(to_index, input())\n\n def MII_split_to_index():\n return map(to_index, input().split())\n\n \n def list_int_inputs():\n return list(map(int, input()))\n\n LII = list_int_inputs\n\n def LII_split():\n return list(map(int, input().split()))\n\n \n def LII_2D(rows_number):\n return [LII() for _ in range(rows_number)]\n\n def LII_split_2D(rows_number):\n return [LII_split() for _ in range(rows_number)]\n\n N, M = MII_split()\n groups = []\n for _ in range(M):\n A, B = MII_split()\n is_in_groups = False\n for group in groups:\n if A in group and B not in group:\n group.append(B)\n break\n elif B in group and A not in group:\n group.append(A)\n break\n elif A in group and B in group:\n is_in_groups = True\n break\n if not is_in_groups:\n groups.append([A, B])\n\n print(max([len(x) for x in groups]) if len(groups) > 0 else 1)\n \n resolve()', 'def resolve():\n import sys\n sys.setrecursionlimit(10 ** 6) \n to_index = lambda x: int(x) - 1 \n print_list_in_2D = lambda x: print(*x, sep="\\n") \n\n\n\n \n def input_int():\n return int(input())\n\n def map_int_input():\n return map(int, input())\n\n MII = map_int_input\n\n def MII_split():\n return map(int, input().split())\n\n def MII_to_index():\n return map(to_index, input())\n\n def MII_split_to_index():\n return map(to_index, input().split())\n\n \n def list_int_inputs():\n return list(map(int, input()))\n\n LII = list_int_inputs\n\n def LII_split():\n return list(map(int, input().split()))\n\n \n def LII_2D(rows_number):\n return [LII() for _ in range(rows_number)]\n\n def LII_split_2D(rows_number):\n return [LII_split() for _ in range(rows_number)]\n\n class UnionFind:\n def __init__(self, n):\n \n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return \'\\n\'.join(\'{}: {}\'.format(r, self.members(r)) for r in self.roots())\n\n N, M = MII_split()\n\n\n # groups = []\n uf = UnionFind(N)\n\n for _ in range(M):\n A, B = MII_split()\n uf.union(A-1, B-1) \n # is_in_groups = False\n # for group in groups:\n # if A in group and B not in group:\n \n # break\n # elif B in group and A not in group:\n # group.append(A)\n # break\n # elif A in group and B in group:\n # is_in_groups = True\n # break\n # if not is_in_groups:\n # groups.append([A, B])\n\n print(max(uf.size(x) for x in range(uf.group_count())))\n \nresolve()\n'] | ['Runtime Error', 'Accepted'] | ['s843614089', 's010020269'] | [9036.0, 18424.0] | [30.0, 580.0] | [1733, 3228] |
p02573 | u200243669 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['class UnionFind():\n def __init__(self,n):\n self.parents = [-1]*n\n\n def find(self,x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n \n def union(self,x,y):\n x = self.find(x)\n y = self.find(y)\n \n if x == y:\n return\n if self.parents[x] > self.parents[y]:\n x,y = y,x\n \n self.parents[x] += self.parents[y]\n self.parents[y] = x\n \nN,M = map(int,input().split()) \nuf = UnionFind(N)\n\nfor i in range(M):\n A,B = map(int,input().split())\n uf.union(A,B)\n \n\nprint(abs(min(uf.parents)))', 'class UnionFind():\n def __init__(self,n):\n self.parents = [-1]*n\n\n def find(self,x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n \n def union(self,x,y):\n x = self.find(x)\n y = self.find(y)\n \n if x == y:\n return\n if self.parents[x] > self.parents[y]:\n x,y = y,x\n \n self.parents[x] += self.parents[y]\n self.parents[y] = x\n \nN,M = map(int,input().split()) \nuf = UnionFind(N)\n\nfor i in range(M):\n A,B = map(lambda x:int(x)-1,input().split())\n uf.union(A,B)\n \n\nprint(abs(min(uf.parents)))'] | ['Runtime Error', 'Accepted'] | ['s954933300', 's860668428'] | [14444.0, 14524.0] | [537.0, 618.0] | [722, 736] |
p02573 | u201387466 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['import sys\ninput=sys.stdin.readline\nsys.setrecursionlimit(10 ** 8)\nfrom itertools import accumulate\nfrom itertools import permutations\nfrom itertools import combinations\nfrom collections import defaultdict\nfrom collections import Counter\nimport fractions\nimport math\nfrom collections import deque\nfrom bisect import bisect_left\nfrom bisect import bisect_right\nfrom bisect import insort_left\nimport itertools\nfrom heapq import heapify\nfrom heapq import heappop\nfrom heapq import heappush\nimport heapq\nfrom copy import deepcopy\nfrom decimal import Decimal\nalf = list("abcdefghijklmnopqrstuvwxyz")\nALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")\n#import numpy as np\nINF = float("inf")\n\n\nN,M = map(int,input().split())\ncount = [[0]*N for _ in range(N)]\nprint(1)\n\n\n\n \n\n\n\n\n\n\n', 'import sys\ninput=sys.stdin.readline\nsys.setrecursionlimit(10 ** 8)\nfrom itertools import accumulate\nfrom itertools import permutations\nfrom itertools import combinations\nfrom collections import defaultdict\nfrom collections import Counter\nimport fractions\nimport math\nfrom collections import deque\nfrom bisect import bisect_left\nfrom bisect import bisect_right\nfrom bisect import insort_left\nimport itertools\nfrom heapq import heapify\nfrom heapq import heappop\nfrom heapq import heappush\nimport heapq\nfrom copy import deepcopy\nfrom decimal import Decimal\nalf = list("abcdefghijklmnopqrstuvwxyz")\nALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")\n#import numpy as np\nINF = float("inf")\n\n\nN,M = map(int,input().split())\ncount = [[0]*N for _ in range(N)]\nfr = [[] for _ in range(N)]\nfor _ in range(M):\n a,b = map(int,input().split())\n a,b = a-1,b-1\n if count[a][b] == 1:\n continue\n count[a][b] = 1\n count[b][a] = 1\nprint(1)\n\n\n\n \n\n\n\n\n\n\n', 'import sys\nsys.setrecursionlimit(99999999)\n\n\n[n,m]=list(map(int,input().split()))\nfriends=[]\nfor i in range(m):\n friends.append(list(map(int,input().split())))\n\ntomodachi=[[]for i in range(n)]\n\nfor i in range(m):\n tomodachi[friends[i][0]-1].append(friends[i][1]-1)\n tomodachi[friends[i][1]-1].append(friends[i][0]-1)\n\nfor i in range(n):\n tomodachi[i]=list(set(tomodachi[i]))\n\nnamelist=[1 for i in range(n)]\nteams=[]\n\ndef haba(x,kari,tomodachi,namelist):\n for i in range(len(tomodachi[x])):\n if namelist[tomodachi[x][i]]==1:\n kari.append(tomodachi[x][i])\n namelist[tomodachi[x][i]]=0\n haba(tomodachi[x][i],kari,tomodachi,namelist)\n return(kari)\n \n\n\nfor i in range(n):\n if namelist[i]==1:\n teams.append(list(set(haba(i,[i],tomodachi,namelist))))\n\nsaidai=0\n\nfor i in range(len(teams)):\n if saidai<len(teams[i]):\n saidai=len(teams[i])\n\nans=saidai\n\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s347762031', 's813390547', 's018614465'] | [2691004.0, 2691472.0, 262892.0] | [2279.0, 2287.0, 1261.0] | [816, 998, 979] |
p02573 | u216015528 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ["#!/usr/bin/env python3\ndef main():\n from collections import deque\n\n N, M = map(int, input().split())\n friends_input = [set() for _ in range(N)]\n for _ in range(M):\n a, b = map(int, input().split())\n friends_input[a - 1].add(b - 1)\n friends_input[b - 1].add(a - 1)\n\n seen = [False] * N\n friends_group = []\n for i in range(N):\n if seen[i]:\n continue\n q = deque([i])\n tmp_group = [i]\n while q:\n now = q.popleft()\n if seen[now]:\n continue\n seen[now] = True\n for j in friends_input[now]:\n if not seen[j]:\n q.append(j)\n tmp_group.append(j)\n friends_group.append(tmp_group)\n ans = 0\n for i in friends_group:\n ans = max(ans, len(i))\n print(ans)\n print(friends_group)\n\n\nif __name__ == '__main__':\n main()\n", '#!/usr/bin/env python3\nclass unionfind:\n """Union-Find"""\n def __init__(self, n: int):\n """\n Constructer(Initialize parameter in this class)\n\n Parameters\n ----------\n n : int\n Number of node\n \n Yields\n -----\n root : list\n When value is postive, express root of the node.\n When it is negative, express this node is root and size of set.\n """\n\n self.root = [-1] * n\n\n def find(self, x: int):\n """\n Search root of node x\n\n Parameters\n ----------\n x : int\n node x\n\n Returns\n -------\n x : int\n Root of node x\n """\n\n if self.root[x] < 0:\n return x\n self.root[x] = self.find(self.root[x])\n return self.root[x]\n \n def unite(self, x: int, y: int):\n """\n Unite two set including node x and node y into one set.\n\n Parameters\n ----------\n x, y : int\n Node number\n\n Returns\n -------\n unite_result : bool\n False : Already two node include same set.\n True : United\n """\n\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return False\n if self.root[x] > self.root[y]:\n x, y = y, x\n self.root[x] += self.root[y]\n self.root[y] = x\n return True\n\n def same(self, x: int, y: int):\n """\n Determine if x and y are in same set.\n\n Parameters\n ----------\n x, y : int\n Node number\n\n Returns\n -------\n result : bool\n Determining result\n """\n\n return self.find(x) == self.find(y)\n \n def size(self, x: int) -> bool:\n """\n Return size of set including node x.\n\n Parameters\n ----------\n x : int\n Node number\n\n Returns\n -------\n Size of set : int\n """\n\n return self.root[self.find(x)] * -1\n\n\ndef main():\n N, M = map(int, input().split())\n uf = unionfind(N)\n for _ in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n uf.unite(a, b)\n\n ans = 0\n for i in range(N):\n ans = max(ans, uf.size(i))\n print(ans)\n\n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s714116787', 's936209069'] | [84472.0, 14904.0] | [706.0, 686.0] | [918, 2364] |
p02573 | u229950162 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['n, m = list(map(int, input().rstrip().split(" ")))\nmembers = [1 for i in range(n)]\nmax_idx = 0\nfor mm in range(m):\n print(members)\n a0, b0 = list(map(int, input().rstrip().split(" ")))\n a = a0\n b = b0\n while members[a-1] < 0:\n a = -members[a-1]\n members[a0-1] = -a\n while members[b-1] < 0:\n b = -members[b-1]\n members[b0-1] = -b\n if a != b:\n print(a, b, members[a-1], members[b-1])\n members[a-1] += members[b-1]\n members[b-1] = -a\n if members[a-1] > members[max_idx]:\n max_idx = a-1\nprint(members[max_idx])\n', 'n, m = list(map(int, input().rstrip().split(" ")))\nmembers = [1 for i in range(n)]\nmax_idx = 0\nfor mm in range(m):\n a0, b0 = list(map(int, input().rstrip().split(" ")))\n a = a0\n b = b0\n while members[a-1] < 0:\n a = -members[a-1]\n while members[b-1] < 0:\n b = -members[b-1]\n members[a0-1] = -a\n members[b0-1] = -b\n if a != b:\n members[a-1] += members[b-1]\n members[b-1] = -a\n if members[a-1] > members[max_idx]:\n max_idx = a-1\nprint(members[max_idx])\n', 'def root(x, root_ls):\n if root_ls[x] < 0:\n return x\n else:\n root_ls[x] = root(root_ls[x], root_ls)\n return root_ls[x]\n\ndef unite(a, b, root_ls):\n a = root(a, root_ls)\n b = root(b, root_ls)\n if a != b:\n root_ls[a] += root_ls[b]\n root_ls[b] = a\n \nn, m = list(map(int, input().rstrip().split(" ")))\nmembers = [-1 for i in range(n)]\nmax_idx = 0\nfor mm in range(m):\n a, b = list(map(int, input().rstrip().split(" ")))\n unite(a-1, b-1, members)\nprint(max([-m for m in members]))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s153169054', 's271805546', 's123183707'] | [147528.0, 10828.0, 21196.0] | [2373.0, 2206.0, 634.0] | [543, 478, 496] |
p02573 | u238786149 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['import networkx as nx\nimport sys\n\nG = nx.Graph()\n\nn, m = map(int, input().split())\nif m == 0:\n print(1)\n sys.exit()\nfor i in range(m):\n a, b = map(int, input().split())\n G.add_edge(a, b)\n\nlargest_cc = max(nx.connected_components(G), key=len)\nprint(largest_cc)\nprint(len(largest_cc))\n', 'import networkx as nx\nimport sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nG = nx.Graph()\n\nn, m = map(int, readline().split())\nif m == 0:\n print(1)\n sys.exit()\nfor i in range(m):\n a, b = map(int, readline().split())\n G.add_edge(a, b)\n\nlargest_cc = max(nx.connected_components(G), key=len)\nprint(len(largest_cc))\n\n'] | ['Wrong Answer', 'Accepted'] | ['s763456834', 's330090347'] | [263436.0, 255092.0] | [1925.0, 1651.0] | [295, 390] |
p02573 | u243312682 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ["\ndef main():\n from itertools import chain\n import sys\n input = sys.stdin.readline\n\n def gcd(x, y):\n if y == 0:\n return x\n return gcd(y, x % y)\n \n def prime_set(N):\n \n if N < 4:\n return ({}, {}, {2}, {2, 3})[N]\n Nsq = int(N ** 0.5 + 0.5) + 1\n primes = {2, 3} | set(chain(range(5, N + 1, 6), range(7, N + 1, 6)))\n for i in range(5, Nsq, 2):\n if i in primes:\n primes -= set(range(i * i, N + 1, i * 2))\n return list(primes)\n\n def factorization(n, prime_set):\n l = []\n tmp = n\n nsq = int(n ** 0.5 + 0.5) + 1\n for i in prime_set:\n if i > nsq: \n break \n if tmp%i == 0:\n while tmp%i == 0:\n tmp //= i\n l.append(i)\n if tmp != 1:\n l.append(tmp)\n if l == []:\n if n != 1:\n l.append(n)\n return l\n n = int(input())\n A = [int(x) for x in input().split()]\n len_A = len(A)\n \n g = 0\n for a in A:\n g = gcd(g, a)\n \n num = 10**6+1\n primes = prime_set(num)\n \n prime_list = [0] * (num+1)\n pairwise_f = True\n ll = list()\n for a in A:\n l = []\n tmp = a\n \n for i in primes:\n if i*i > a:\n break \n if tmp%i == 0:\n while tmp%i == 0:\n tmp //= i\n prime_list[i] += 1\n l.append(i)\n if tmp != 1:\n prime_list[tmp] += 1\n l.append(tmp)\n if l == []:\n if a != 1:\n prime_list[n] += 1\n l.append(a)\n set_prime_list = set(prime_list)\n if len_A > 10**5:\n if set_prime_list != set([0]) and set_prime_list != set([0, 1]):\n pairwise_f = False\n break\n \n if set_prime_list != set([0]) and set_prime_list != set([0, 1]):\n pairwise_f = False\n if pairwise_f:\n print('pairwise coprime')\n elif g == 1:\n print('setwise coprime')\n else:\n print('not coprime')\n\nif __name__ == '__main__':\n main()", 'def main():\n n, m = map(int, input().split())\n g = [[] for i in [0]*(n+1)]\n for _ in range(m):\n a, b = map(int, input().split())\n g[a].append(b)\n g[b].append(a)\n\n def bfs(n, m, adj):\n visited = [0 for i in [0]*(n+1)]\n ans = 1\n for i in range(n+1):\n if visited[i]:\n continue\n Q = deque([i])\n temp = 1\n while Q:\n q = Q.popleft()\n visited[q] = 1\n link = adj[q]\n for j in link:\n if visited[j]:\n continue\n visited[j] = 1\n temp += 1\n Q.append(j)\n ans = max(ans, temp)\n print(ans) \n bfs(n, m, g)\n \nif __name__=="__main__":\n main()', "from collections import deque\nfrom copy import deepcopy\n\ndef main():\n \n n, m = map(int, input().split())\n adj = [[] for _ in range(n)]\n for i in range(m):\n a, b = map(lambda x: int(x) - 1, input().split())\n print(a, b)\n adj[a].append(b)\n adj[b].append(a)\n print(adj)\n\n dist = [-1] * n\n q = deque([0])\n dist[0] = 0\n dl = 0\n while q:\n v = q.popleft()\n d = dist[v]\n for w in adj[v]:\n if dist[w] > -1:\n continue\n dist[w] = d + 1\n q.append(w)\n dl = sum([1 for i in dist if i >= 0])\n print(dl)\n def search_index(l, x, default=False):\n return l.index(x) if x in l else default\n print(search_index(dist, -1))\n\n dist_0 = deepcopy(dist)\n next = 1\n while next:\n next = search_index(dist_0, -1)\n print('next', next)\n if next == False:\n break\n q = deque([next])\n dist = [-1] * n\n dist[next] = 0\n while q:\n v = q.popleft()\n d = dist[v]\n for w in adj[v]:\n if dist[w] > -1:\n continue\n dist[w] = d + 1\n q.append(w)\n sum_d = sum([1 for i in dist if i >= 0])\n if dl[0] < sum_d:\n dl = sum_d\n dist_0[next] = 0\n print('dl', dl)\n\nif __name__ == '__main__':\n main()", 'def find(target):\n if parent[target] < 0:\n return target\n else:\n parent[target] = find(parent[target])\n return parent[target]\n\ndef is_same(x, y):\n return find(x) == find(y)\n\ndef union(x, y):\n root_x = find(x)\n root_y = find(y)\n if root_x == root_y:\n return\n if parent[root_x] > parent[root_y]:\n root_x, root_y = root_y, root_x\n parent[root_x] += parent[root_y]\n parent[root_y] = root_x\ndef members(n, x):\n root = find(x)\n return [i for i in range(n) if find(i) == root]\n\ndef get_size(x):\n return -parent[find(x)]\n\ndef get_root():\n return [i for i, root in enumerate(parent) if root < 0]\nn, m = map(int, input().split())\nparent = [-1 for _ in range(n)]\nfor _ in range(m):\n a, b = map(lambda x: int(x) - 1, input().split())\n union(a, b)\n # print(parent)\nans = 0\nfor i in range(n):\n ans = max(ans, get_size(i))\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s115042610', 's698935508', 's955633778', 's631201950'] | [9364.0, 46144.0, 52304.0, 14412.0] | [24.0, 555.0, 2214.0, 689.0] | [2445, 820, 1396, 904] |
p02573 | u248670337 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['from networkx import *\nprint(max(*map(len,connected_components(Graph([*map(str,open(0))][1:])))))', 'from networkx import *\nprint(max(*map(len,connected_components(Graph([input().split()][1:])))))', 'from networkx import *\nprint(max(*map(len,connected_components(Graph([*map(str.split,open(0))][1:]))),1,0))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s381482904', 's767289675', 's095428974'] | [70096.0, 53160.0, 300004.0] | [352.0, 332.0, 1635.0] | [97, 95, 107] |
p02573 | u250734103 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['N, M = map(int, input().split())\nA = [0] * M\nB = [0] * M\nfor i in range(M):\n A[i], B[i] = map(int, input().split())\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n \nu = UnionFind(N)\nfor i in range(M):\n u.union(A[i], B[i])\n \nans = 1\nfor i in range(1, N+1):\n print("{}の属するグループは{}人です。".format(i, u.size(i)))\n ans = max(ans, u.size(i))\nprint(ans)', 'N, M = map(int, input().split())\nA = [0] * (M-1)\nB = [0] * (M-1)\nfor i in range(M):\n A[i], B[i] = map(int, input().split())\n\nclass UnionFind:\n def __init__(self, n):\n \n self.par = [-1 for i in range(n + 1)]\n \n """self.rank = [0] * (n + 1)"""\n\n \n \n def find(self, x):\n if self.par[x] < 0:\n return x\n else:\n \n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n \n def union(self, x, y):\n \n x = self.find(x)\n y = self.find(y)\n \n if x != y:\n if self.par[x] < self.par[y]: \n self.par[y] += self.par[x]\n self.par[x] = y\n else:\n self.par[x] += self.par[y]\n self.par[y] = x\n \n """if self.rank[x] == self.rank[y]:\n self.rank[x] += 1"""\n\n \n def same_check(self, x, y):\n return self.find(x) == self.find(y)\n\n def size(self, x):\n return -self.par[self.find(x)]\n \n \nu = UnionFind(N)\nfor i in range(M):\n u.union(A[i], B[i])\n \nans = 1\nfor i in range(1, N+1):\n ans = max(ans, u.size(i))\nprint(ans)', 'N, M = map(int, input().split())\nA = [0] * M\nB = [0] * M\nfor i in range(M):\n A[i], B[i] = map(int, input().split())\n\nclass UnionFind:\n def __init__(self, n):\n \n self.par = [-1 for i in range(n + 1)]\n \n """self.rank = [0] * (n + 1)"""\n\n \n \n def find(self, x):\n if self.par[x] < 0:\n return x\n else:\n \n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n \n def union(self, x, y):\n \n x = self.find(x)\n y = self.find(y)\n \n if x != y:\n if self.par[x] < self.par[y]: \n self.par[y] += self.par[x]\n self.par[x] = y\n else:\n self.par[x] += self.par[y]\n self.par[y] = x\n \n """if self.rank[x] == self.rank[y]:\n self.rank[x] += 1"""\n\n def size(self, x):\n return -self.par[self.find(x)]\n \n \nu = UnionFind(N)\nfor i in range(M):\n u.union(A[i], B[i])\n \nans = 1\nfor i in range(1, N+1):\n print("{}の属するグループは{}人です。".format(i, u.size(i)))\n ans = max(ans, u.size(i))\nprint(ans)', 'N, M = map(int, input().split())\nA = [0] * M\nB = [0] * M\nfor i in range(M):\n A[i], B[i] = map(int, input().split())\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * (n+1)\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n \nu = UnionFind(N)\nfor i in range(M):\n u.union(A[i], B[i])\n \nans = 1\nfor i in range(1, N+1):\n ans = max(ans, u.size(i))\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s035566843', 's328472282', 's658125962', 's699364705'] | [26328.0, 24496.0, 31016.0, 26264.0] | [738.0, 352.0, 1099.0, 744.0] | [947, 1639, 1592, 873] |
p02573 | u260204064 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['n, m = map(int,input().split())\n\nclass unionfind():\n def __init__(self,n):\n self.li = [i for i in range(n+1)]\n self.group = [1]*(n+1)\n\n def find(self, x):\n while self.li[x]!=x:\n x = self.li[x]\n return x\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return;\n else:\n self.li[y] = x\n self.group[x] += self.group[y]\n self.group[y] = 1\nx = unionfind(n)\nans = 0\nfor _ in range(m):\n a,b = map(int,input().split())\n x.union(a,b)\nprint(max(x.group))\nprint(x.group)', 'from collections import Counter\nn, m = map(int, input().split())\nli = [0]*n\nflag = 1\nfor _ in range(m):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n if li[a] and li[b]:\n continue\n elif li[a] or li[b]:\n s = max(li[a], li[b])\n li[a] = s\n li[b] = s\n else:\n li[a] = flag\n li[b] = flag\n flag += 1\nfor i in range(len(li)):\n if li[i] == 0:\n li[i] = -i\nresult = Counter(li)\nprint(li)\nprint(result.most_common()[0][1])\n', 'n, m = map(int,input().split())\n\nclass unionfind():\n def __init__(self,n):\n self.li = [-1]*(n+1)\n\n def find(self, x):\n if self.li[x]<0:\n return x\n else:\n self.li[x] = self.find(self.li[x])\n return self.li[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return;\n if x>y:\n x, y = y, x\n self.li[x]+=self.li[y]\n self.li[y] = x\n\nx = unionfind(n)\nans = 0\nfor _ in range(m):\n a,b = map(int,input().split())\n x.union(a,b)\nprint(-min(x.li))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s130507200', 's608220831', 's831712916'] | [19624.0, 43184.0, 16680.0] | [2206.0, 522.0, 547.0] | [609, 491, 593] |
p02573 | u285265363 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['n, m = map(int, input().split())\nA = []*m\nB = []*m\nfor i in range(m):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\nS = [set([i+1]) for i in range(n)]\n#print(S)\nfor i in range(m):\n S[A[i]-1] = S[A[i]-1].union(S[B[i]-1])\n S[B[i]-1] = S[B[i]-1].union(S[A[i]-1])\n print(S)\n\nans = 1\nfor i in range(n):\n ans = max(ans, len(S[i]))\n\nprint(str(ans))\n', 'class UnionFind():\n def __init__(self, N):\n self.N = N\n self.parents = [-1] * N\n\n def root(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.root(self.parents[x])\n return self.parents[x]\n\n def unite(self, x, y):\n x = self.root(x)\n y = self.root(y)\n\n if x == y:\n return False\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.root(x)]\n\nn, m = map(int, input().split())\n\nuf = UnionFind(n)\n\nfor i in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n uf.unite(a, b)\n\nans = 0\nfor i in range(n):\n ans = max(ans, uf.size(i))\n\nprint(str(ans))'] | ['Wrong Answer', 'Accepted'] | ['s322321610', 's597222008'] | [109172.0, 14472.0] | [2352.0, 785.0] | [377, 837] |
p02573 | u295585689 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['import numpy as np\n\nn,M = [int(i) for i in input().split()]\n\nN = np.ones(n)*-1\nn_group = 0\n\nfor i in range(M):\n a,b = [int(i) for i in input().split()]\n \n if N[a]==-1 and N[b]==-1:\n N[a] = n_group\n N[b] = n_group\n n_group += 1\n \n elif N[a]>-1 and N[b]>-1:\n new = min(N[a],N[b])\n old = max(N[a],N[b])\n for i in range(n):\n if N[i] == old:\n N[i] = new\n else:\n if N[a]>-1:\n N[b] = N[a]\n else:\n N[a] = N[b]\nY = 0\nfor i in range(n_group):\n Y = max(sum(N==i),Y)\nprint(Y)', 'N,M = [int(i) for i in input().split()]\n\nrelations = []\nfor i in range(M):\n relations.append({int(i) for i in input().split()})\n \n\ndef search(node,stock):\n \n n_member = 0\n \n while(len(node)>0):\n n_member += len(node)\n go_list = []\n ng_list = []\n \n for s in stock:\n if len(s & node)>0:\n go_list = np.append(go_list,list(s))\n else:\n ng_list.append(s)\n node = set(np.unique(go_list)) - node\n stock = ng_list\n \n return n_member,stock\n \n \nMaxMember = 1 \nwhile(len(relations)>1):\n l_member,relations = search(relations[0],relations[1:])\n MaxMember = max(MaxMember,l_member)\n\nprint(MaxMember)', 'N,M = [int(i) for i in input().split()]\n\ngroups = []\n\nfor i in range(M):\n a,b = [int(i) for i in input().split()]\n flag = True\n for j,g in enumerate(groups):\n if a in g or b in g:\n groups[j] = np.unique(np.append(g,[a,b]))\n flag = False\n if flag:\n groups.append([a,b])\n \n\nmaxMember = 0\nfor g in groups:\n maxMember = max(maxMember,len(g))\n\nprint(maxMember)', 'import numpy as np\n\nn,M = [int(i) for i in input().split()]\n\nN = np.ones(n)*-1\nn_group = 0\n\nfor i in range(M):\n a,b = [int(i) for i in input().split()]\n \n if N[a]==-1 and N[b]==-1:\n N[a] = n_group\n N[b] = n_group\n n_group += 1\n \n elif N[a]>-1 and N[b]>-1:\n new = min(N[a],N[b])\n old = max(N[a],N[b])\n for i in range(n):\n if N[i] == old:\n N[i] = new\n else:\n if N[a]>-1:\n N[b] = N[a]\n else:\n N[a] = N[b]\nY = 0\nfor i in range(n_group):\n Y = max(sum(N==i+1),Y)\nprint(Y)', 'import numpy as np\n\nclass union_find:\n def __init__(self,N):\n self.r = np.ones(N)*-1\n \n def root(self,x):\n if self.r[x]<0:\n return int(x)\n else:\n self.r[x] = self.root(int(self.r[x]))\n return int(self.r[x])\n \n def unite(self,x,y):\n x = self.root(x)\n y = self.root(y)\n if x == y:\n return False\n else:\n self.r[x] += self.r[y]\n self.r[y] = int(x)\n return True\n \n def size(self,x):\n return -self.r[self.root(x)]\n\n\nN,M = [int(i) for i in input().split()]\n\nUnion = union_find(N)\nfor i in range(M):\n x,y = [int(i) for i in input().split()]\n Union.unite(x,y)\n\nY = 0\nfor i in range(N):\n Y = max(Y,Union.size(i))\nprint(int(Y))', 'import numpy as np\n\nclass union_find:\n def __init__(self,N):\n self.r = np.ones(N)*-1\n \n def root(self,x):\n if self.r[x]<0:\n return int(x)\n else:\n self.r[x] = self.root(int(self.r[x]))\n return int(self.r[x])\n \n def unite(self,x,y):\n x = self.root(x)\n y = self.root(y)\n if x == y:\n return False\n else:\n self.r[x] += self.r[y]\n self.r[y] = int(x)\n return True\n \n def size(self,x):\n return -self.r[self.root(x)]\n\n\nN,M = [int(i) for i in input().split()]\n\nUnion = union_find(N)\nfor i in range(M):\n x,y = [int(i) for i in input().split()]\n Union.unite(x-1,y-1)\n\nY = - min(Union.r)\nprint(int(Y))'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s188560904', 's252254859', 's533195565', 's899674498', 's900201041', 's221651247'] | [29000.0, 69792.0, 9184.0, 28732.0, 28508.0, 28496.0] | [2206.0, 631.0, 47.0, 2206.0, 1440.0, 1612.0] | [588, 733, 413, 590, 787, 756] |
p02573 | u314089899 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['N,M = map(int, input().split())\n\nparent_dict = dict() \n\n\ndef add_connect(A,B):\n A_parent = get_parent(A)\n B_parent = get_parent(B)\n \n if A_parent != B_parent:\n parent_dict[B_parent] = A_parent\n\n\ndef judge_connection(A,B):\n A_parent = get_parent(A) \n B_parent = get_parent(B)\n \n if A_parent != B_parent:\n return False\n else:\n return True\n\n\ndef get_parent(child):\n if child not in parent_dict: \n parent_dict[child] = child\n \n parent = parent_dict[child]\n \n if parent == child: \n return parent\n else: \n parent_dict[child] = get_parent(parent) \n return parent_dict[child]\n\n\n\n\nfor i in range(M):\n A,B = map(int, input().split())\n add_connect(A,B)\n\nfor i in range(1,N+1):\n get_parent(i)\n\n#print(parent_dict)\n\n\n\n\n\n# if parent_dict[i] not in child_dict:\n# child_dict[parent_dict[i]] = set()\n# child_dict[parent_dict[i]].add(i)\n\n\n\n#for parent in child_dict:\n# if len(child_dict[parent]) > ans:\n# ans = len(child_dict[parent])\n\n#print(ans)', '\nimport sys\nsys.setrecursionlimit(1000000)\nN,M = map(int, input().split())\n\nparent_dict = dict() \n\n\ndef add_connect(A,B):\n A_parent = get_parent(A)\n B_parent = get_parent(B)\n \n if A_parent != B_parent:\n parent_dict[B_parent] = A_parent\n\n\ndef judge_connection(A,B):\n A_parent = get_parent(A) \n B_parent = get_parent(B)\n \n if A_parent != B_parent:\n return False\n else:\n return True\n\n\ndef get_parent(child):\n if child not in parent_dict: \n parent_dict[child] = child\n \n parent = parent_dict[child]\n \n if parent == child: \n return parent\n else: \n parent_dict[child] = get_parent(parent) \n return parent_dict[child]\n\n\n\n\nfor i in range(M):\n A,B = map(int, input().split())\n add_connect(A,B)\n\nfor i in range(1,N+1):\n get_parent(i)\n\n#print(parent_dict)\n\n\nchild_dict = dict() \n\nfor i in range(1,N+1):\n if parent_dict[i] not in child_dict:\n child_dict[parent_dict[i]] = set()\n child_dict[parent_dict[i]].add(i)\n\n\nans = 1\nfor parent in child_dict:\n if len(child_dict[parent]) > ans:\n ans = len(child_dict[parent])\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s294513598', 's650097426'] | [30028.0, 96620.0] | [780.0, 1013.0] | [1615, 1673] |
p02573 | u314188085 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['from sys import setrecursionlimit\n\ndef find(par,i):\n if par[i]<0:\n return i\n par[i] = find(par,par[i])\n return par[i]\n\ndef unite(par,i,j):\n ri = find(par,i)\n rj = find(par, j)\n if ri==rj:\n return\n par[rj] += par[ri]\n par[ri] = rj\n \nsetrecursionlimit(10**6)\nn,m = map(int,input().split())\n\nparent = [-1]*n\nfor _ in range(m):\n a,b = map(lambda x:int(x)-1,input().split())\n unite(parent,a,b)\n print(parent)\n \n\nprint(-min(parent))', 'from sys import setrecursionlimit\n\ndef find(par,i):\n if par[i]<0:\n return i\n par[i] = find(par,par[i])\n return par[i]\n\ndef unite(par,i,j):\n ri = find(par,i)\n rj = find(par, j)\n if ri==rj:\n return\n par[rj] += par[ri]\n par[ri] = rj\n \nsetrecursionlimit(10**6)\nn,m = map(int,input().split())\n\nparent = [-1]*n\nfor _ in range(m):\n a,b = map(lambda x:int(x)-1,input().split())\n unite(parent,a,b)\n \nprint(-min(parent))'] | ['Runtime Error', 'Accepted'] | ['s233520410', 's697521751'] | [149196.0, 16704.0] | [2345.0, 616.0] | [479, 460] |
p02573 | u319245933 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['from collections import Counter\n\nclass UnionFindBasic():\n """via https://note.nkmk.me/python-union-find/#_3\n """\n def __init__(self, n):\n self.parents = list(range(n))\n\n def find(self, x: int) -> int:\n if self.parents[x] == x: return x\n return self.find(self.parents[x])\n\n def union(self, x: int, y: int):\n x = self.find(x)\n y = self.find(y)\n if x == y: return\n if x > y: x,y = y,x\n self.parents[y] = x\n\nif __name__ == \'__main__\':\n N, M = map(int, input().split())\n\n if M == 0:\n print(0)\n return\n\n uf = UnionFindBasic(N)\n\n for _ in range(M):\n a,b = list(map(lambda x: int(x)-1, input().split()))\n uf.union(a,b)\n\n print(Counter(uf.parents).most_common()[0][1])', '# from pprint import pprint\n#\n# N, M = map(int, input().split())\n#\n# G = [[0 for _ in range(N)] for _ in range(N)]\n#\n# for _ in range(M):\n# a, b = list(map(int, input().split()))\n# G[a-1][b-1] = G[b-1][a-1] = 1\n#\n# pprint(sum(sum(g) for g in G) // 2)\n\nfrom collections import Counter\n\nclass UnionFindBasic():\n """via https://note.nkmk.me/python-union-find/\n """\n def __init__(self, n: int):\n \n self.n = n\n self.parents = [-1] * n\n\n def find(self, x: int) -> int:\n if self.parents[x] < 0:\n return x\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x: int, y: int):\n x = self.find(x)\n y = self.find(y)\n if x == y: return\n if self.parents[x] > self.parents[y]:\n x,y = y,x\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\ndef main():\n N, M = map(int, input().split())\n\n if M == 0:\n print(1)\n return\n\n uf = UnionFindBasic(N)\n\n for _ in range(M):\n a,b = list(map(lambda x: int(x)-1, input().split()))\n uf.union(a,b)\n\n ans = 0\n for i in range(N):\n ans = max(ans, uf.size(i))\n print(ans)\n\nif __name__ == \'__main__\':\n main()'] | ['Runtime Error', 'Accepted'] | ['s914405836', 's067989371'] | [9120.0, 14880.0] | [24.0, 767.0] | [773, 1330] |
p02573 | u335599768 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['import sys\nsys.setrecursionlimit(10 ** 9)\n\nN, M = map(int, input().split())\nroot = [-1] * N\n\ndef parent(x):\n if root[x] < 0:\n return x\n return parent(root[x])\n\n\ndef union(x, y):\n x_parent = parent(x)\n y_parent = parent(y)\n if x_parent == y_parent:\n return\n root[x_parent] += root[y_parent]\n root[y_parent] = x\n\n\ndef size(x):\n return -root[x]\n \n\nfor i in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n union(a, b)\n print(root)\n\n\nmax_size = 0\nfor i in range(N):\n max_size = max(size(i), max_size)\n\nprint(max_size)', 'import sys\nsys.setrecursionlimit(10 ** 9)\n\nN, M = map(int, input().split())\nroot = [-1] * N\n\ndef parent(x):\n if root[x] < 0:\n return x\n return parent(root[x])\n\n\ndef union(x, y):\n x_parent = parent(x)\n y_parent = parent(y)\n if x_parent == y_parent:\n return\n root[x_parent] += root[y_parent]\n root[y_parent] = x\n\n\ndef size(x):\n return -root[x]\n \n\nfor i in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n union(a, b)\n print(root)\n\n\nmax_size = 0\nfor i in range(N):\n max_size = max(size(i), max_size)\n\nprint(max_size)', 'import sys\nsys.setrecursionlimit(10 ** 9)\n\nN, M = map(int, input().split())\nroot = [-1] * N\n\ndef parent(x):\n if root[x] < 0:\n return x\n root[x] = parent(root[x])\n return root[x]\n\n\ndef union(x, y):\n x_parent = parent(x)\n y_parent = parent(y)\n if x_parent == y_parent:\n return\n root[x_parent] += root[y_parent]\n root[y_parent] = x\n\n\ndef size(x):\n return -root[x]\n \n\nfor i in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n union(a, b)\n\n\nmax_size = 0\nfor i in range(N):\n max_size = max(size(i), max_size)\n\nprint(max_size)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s208652288', 's636001513', 's699930892'] | [149328.0, 149336.0, 16452.0] | [2313.0, 2335.0, 670.0] | [584, 584, 590] |
p02573 | u337626942 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['class Union_Find:\n def __init__(self, n):\n self.root = [-1]*n\n \n def find(self, x):\n if self.root[x] < -1:\n return x\n else:\n self.root[x] = self.find(self.root[x])\n return root[x]\n\n def unite(self, x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return\n else:\n self.root[x] += self.root[y]\n self.root[y] = x\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n\nn, m = map(int, input().split())\nuf = Union_Find(n)\n\nfor i in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n uf.unite(a, b)\n\nans = 0\nfor i in range(n):\n size = uf.root[i]*(-1)\n ans = max(ans, size)\n\nprint(ans)', 'n, m = map(int, input().split())\n\nroot = [-1]*n\ndef r(x):\n if root[x] < 0: \n return x\n else:\n root[x] = r(root[x])\n return root[x]\n\ndef unite(x, y):\n x = r(x)\n y = r(y)\n if x == y:\n return\n root[x] += root[y]\n root[y] = x \n\nfor i in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n unite(a, b)\n\nans = 0\nfor i in range(n):\n ans = max(ans, -root[i])\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s466351377', 's061950862'] | [10656.0, 13380.0] | [82.0, 649.0] | [747, 618] |
p02573 | u339199690 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['from collections import deque\nfrom numba import jit\n \nN, M = map(int, input().split())\nS = [set() for i in range(N)]\nvisited = [-1] * N\ncolorcount = [-1] * N\n \nfor i in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n S[a].add(b)\n S[b].add(a)\n\n@jit\ndef solve():\n q = deque()\n for i in range(N):\n q.append(i)\n color = i\n cnt = 1\n while len(q):\n nt = q.popleft()\n if visited[nt] != -1:\n continue\n visited[nt] = color\n q.extend(S[nt])\n cnt += 1\n colorcount[color] = cnt - 1\n \nprint(max(colorcount))\n', 'from collections import deque\n\nN, M = map(int, input().split())\nS = [set() for i in range(N)]\nvisited = [-1] * N\ncolorcount = [-1] * N\n\nfor i in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n S[a].add(b)\n S[b].add(a)\n\nq = deque()\nfor i in range(N):\n q.append(i)\n color = i\n cnt = 1\n while len(q):\n nt = q.popleft()\n if visited[nt] != -1:\n continue\n visited[nt] = color\n q.extend(S[nt])\n cnt += 1\n colorcount[color] = cnt - 1\n\nprint(max(colorcount))\n'] | ['Wrong Answer', 'Accepted'] | ['s576704631', 's676377197'] | [156940.0, 74352.0] | [1220.0, 1037.0] | [634, 539] |
p02573 | u345621867 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['class UnionFind:\n def __init__(self, n):\n self.par = [i for i in range(n+1)]\n self.rank = [0] * (n+1)\n self.sum = [1] * (n+1)\n\n \n def find(self, x):\n if self.par[x] == x:\n return x\n else:\n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n \n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.rank[x] < self.rank[y]:\n self.par[x] = y\n self.sum[y] += self.sum[x]\n else:\n self.par[y] = x\n self.sum[x] += self.sum[y]\n if self.rank[x] == self.rank[y]:\n self.rank[x] += 1\n\n \n def same_check(self, x, y):\n return self.find(x) == self.find(y)\n\n\nN, M = map(int,input().split())\nA = [0] * M\nB = [0] * M\n\nuni = UnionFind(N)\n\nfor i in range(M):\n A[i], B[i] = map(int,input().split())\n uni.union(A[i],B[i])\n\nprint(uni.par)\nprint(uni.rank)\nprint(uni.sum)\n\nprint(max(uni.sum))', 'class UnionFind:\n def __init__(self, n):\n self.par = [i for i in range(n+1)]\n self.rank = [0] * (n+1)\n self.sum = [1] * (n+1)\n\n \n def find(self, x):\n if self.par[x] == x:\n return x\n else:\n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n \n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.rank[x] < self.rank[y]:\n self.par[x] = y\n self.sum[y] += self.sum[x]\n else:\n self.par[y] = x\n self.sum[x] += self.sum[y]\n if self.rank[x] == self.rank[y]:\n self.rank[x] += 1\n\n \n def same_check(self, x, y):\n return self.find(x) == self.find(y)\n\n\nN, M = map(int,input().split())\nA = [0] * M\nB = [0] * M\n\nuni = UnionFind(N)\n\nfor i in range(M):\n A[i], B[i] = map(int,input().split())\n uni.union(A[i],B[i])\n\n\nprint(max(uni.sum))\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s709081401', 's821848360'] | [32420.0, 29684.0] | [768.0, 733.0] | [1076, 1548] |
p02573 | u347064383 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ["\n\nN, M = [int(x) for x in input().split(' ')]\n\nfrom collections import defaultdict\nd = defaultdict(set)\n\nfor i in range(M):\n a, b = [int(x) for x in input().split(' ')]\n d[a].add(b)\n d[b].add(a)\n\ndef bfs(i):\n obs = {i}\n passed = {i}\n\n \n before = {i}\n while True:\n after = set()\n for i in before:\n after |= d[i]\n before = after - passed\n passed |= after\n if len(after) == 0:\n return passed\n return len(passed)\n\nprint(max([bfs(i) for i in range(1, N+1)]))\n", "\n\nN, M = [int(x) for x in input().split(' ')]\n\n# from collections import defaultdict\n\n\n\n# a, b = [int(x) for x in input().split(' ')]\n# d[a].add(b)\n# d[b].add(a)\n\nclass UF:\n def __init__(self):\n self.r = [-1] * N\n\n def root(self, i):\n r = self.r\n if r[i] < 0:\n return i\n else:\n r[i] = self.root(r[i])\n return r[i]\n\n def union(self, i, j):\n ri = self.root(i)\n rj = self.root(j)\n if ri == rj:\n return\n else:\n if not self.r[ri] < self.r[rj]:\n ri, rj = rj, ri\n self.r[ri] += self.r[rj]\n self.r[rj] = ri\n return\n\n def max_size(self):\n return -min(self.r)\n\nuf = UF()\nfor i in range(M):\n uf.union(*[int(x) for x in input().split(' ')])\nprint(uf.max_size())\n \n \n\n", "\n\nN, M = [int(x) for x in input().split(' ')]\n\n# from collections import defaultdict\n\n\n\n# a, b = [int(x) for x in input().split(' ')]\n# d[a].add(b)\n# d[b].add(a)\n\nclass UF:\n def __init__(self):\n self.r = [-1] * N\n\n def root(self, i):\n r = self.r\n if r[i] < 0:\n return i\n else:\n r[i] = self.root(r[i])\n return r[i]\n\n def union(self, i, j):\n i -= 1\n j -= 1\n ri = self.root(i)\n rj = self.root(j)\n if ri == rj:\n return\n else:\n if not self.r[ri] < self.r[rj]:\n ri, rj = rj, ri\n self.r[ri] += self.r[rj]\n self.r[rj] = ri\n return\n\n def max_size(self):\n return -min(self.r)\n\nuf = UF()\nfor i in range(M):\n uf.union(*[int(x) for x in input().split(' ')])\nprint(uf.max_size())\n \n \n\n"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s189733379', 's417105055', 's621755716'] | [313244.0, 12784.0, 13468.0] | [2214.0, 524.0, 591.0] | [602, 954, 984] |
p02573 | u351480677 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['import sys\nclass UnionFind():\n def __init__(self, n):\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n\nN, M = map(int, input().split())\ninfo = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]\n#print(info)\n\nuf = UnionFind(N)\n\nfor a, b in info:\n a -= 1; b -= 1\n uf.union(a, b)\n\n\n\nprint(-ans)', 'import sys\nclass UnionFind():\n def __init__(self, n):\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n\nN, M = map(int, input().split())\ninfo = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]\n#print(info)\n\nuf = UnionFind(N)\n\nfor a, b in info:\n a -= 1; b -= 1\n uf.union(a, b)\n\nans = min(uf.parents)\n\nprint(-ans)'] | ['Runtime Error', 'Accepted'] | ['s888148773', 's381760979'] | [50208.0, 50232.0] | [441.0, 430.0] | [759, 758] |
p02573 | u356983865 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['N,M = map(int,input().split())\nhint_list = [list(map(int,input().split())) for i in range(M)]\nfriend_list = []\n\ndef get_unique_list(seq):\n seen = []\n return [x for x in seq if x not in seen and not seen.append(x)]\n\nhint_list = get_unique_list(hint_list)\n\nif M == 0:\n print(N)\nelse:\n friend_list.append(hint_list[0])\n for i in range(1,len(hint_list)):\n for j in range(len(friend_list)):\n if hint_list[i][0] in friend_list[j]:\n if hint_list[i][1] in friend_list[j]:\n pass\n else:\n frined_list[j].append(hint_list[i][1])\n elif hint_list[i][1] in friend_list[j]:\n if hint_list[i][0] in friend_list[j]:\n pass\n else:\n frined_list[j].append(hint_list[i][0])\n else:\n pass\n\n friend_length = []\n\n for i in range(len(friend_list)):\n friend_length.append(len(friend_list[i]))\n\n print(max(friend_length))', 'from collections import deque\n\nN,M = map(int,input().split())\nhint_list = [list(map(int,input().split())) for i in range(M)]\nfriend_list = []\n\ndef get_unique_list(seq):\n seen = []\n return [x for x in seq if x not in seen and not seen.append(x)]\n\nhint_list = get_unique_list(hint_list)\n\nif M == 0:\n print(N)\nelse:\n for i in range(1,N+1):\n i_list = []\n j_list = []\n for j in range(len(hint_list)):\n if i in hint_list[j]:\n i_list.append(hint_list[j])\n j_list.append(j)\n else:\n pass\n \n i_list = list(set(sum(i_list,[])))\n if i_list != []:\n new_j_list = []\n for i in range(len(j_list)):\n new_j_list.append(j_list[i]-i)\n for i in range(len(new_j_list)):\n del hint_list[new_j_list[i]]\n hint_list.append(i_list)\n else:\n pass\n print(hint_list)\n \n friend_len = []\n for i in range(len(hint_list)):\n friend_len.append(len(hint_list[i]))\n \n print(max(friend_len))', 'from collections import deque\n\nN,M = map(int,input().split())\nhint_list = [list(map(int,input().split())) for i in range(M)]\nfriend_list = []\n\ndef get_unique_list(seq):\n seen = []\n return [x for x in seq if x not in seen and not seen.append(x)]\n\nhint_list = get_unique_list(hint_list)\n\nif M == 0:\n print(0)\nelse:\n for i in range(1,N+1):\n i_list = []\n j_list = []\n for j in range(len(hint_list)):\n if i in hint_list[j]:\n i_list.append(hint_list[j])\n j_list.append(j)\n else:\n pass\n \n i_list = list(set(sum(i_list,[])))\n if i_list != []:\n new_j_list = []\n for i in range(len(j_list)):\n new_j_list.append(j_list[i]-i)\n for i in range(len(new_j_list)):\n del hint_list[new_j_list[i]]\n hint_list.append(i_list)\n else:\n pass\n \n friend_len = []\n print(hint_list)\n for i in range(len(hint_list)):\n friend_len.append(len(hint_list[i]))\n \n print(max(friend_len))', 'N,M = map(int,input().split())\nhint_list = [list(map(int,input().split())) for i in range(M)]\nfriend_list = []\n\ndef get_unique_list(seq):\n seen = []\n return [x for x in seq if x not in seen and not seen.append(x)]\n\nhint_list = get_unique_list(hint_list)\n\nif M == 0:\n print(N)\nelse:\n friend_list.append(hint_list[0])\n for i in range(1,len(hint_list)):\n for j in range(len(friend_list)):\n if hint_list[i][0] in friend_list[j]:\n if hint_list[i][1] in friend_list[j]:\n pass\n else:\n frined_list[j].append(hint_list[i][1])\n elif hint_list[i][1] in friend_list[j]:\n if hint_list[i][0] in friend_list[j]:\n pass\n else:\n frined_list[j].append(hint_list[i][0])\n else:\n pass\n\n friend_length = []\n\n for i in range(len(friend_list)):\n friend_length.append(len(friend_list[i]))\n\nprint(max(friend_length))', 'from collections import deque\n \nN,M = map(int,input().split())\nhint_list = [list(map(int,input().split())) for i in range(M)]\n\nr = [-1] * N\n\ndef find(a):\n if r[a] < 0:\n return a\n else:\n if r[r[a]] < 0:\n return r[a]\n else:\n r[a] =r[r[a]]\n return r[a]\n \ndef union(a,b):\n a -= 1\n b -= 1\n ar = find(a)\n br = find(b)\n if ar == br:\n return\n else:\n if r[ar] > r[br]:\n ar,br = br,ar\n r[ar] += r[br]\n r[br] = ar\n return\n \nfor i in range(len(hint_list)):\n union(hint_list[i][0],hint_list[i][1])\n print(r)\n \nprint(-min(r))', 'from collections import deque\n \nN,M = map(int,input().split())\nhint_list = [list(map(int,input().split())) for i in range(M)]\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x -= 1\n y -= 1\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\nuf = UnionFind(N)\nfor i in range(len(hint_list)):\n uf.union(hint_list[i][0],hint_list[i][1])\n \nprint(-min(uf.parents))'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s076211246', 's129619084', 's361194206', 's362649597', 's999449321', 's071614108'] | [45728.0, 92056.0, 46040.0, 45880.0, 172944.0, 50444.0] | [2207.0, 2354.0, 2207.0, 2207.0, 2358.0, 694.0] | [1012, 1096, 1092, 1008, 654, 822] |
p02573 | u358859892 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n\nn, m = map(int, input().split())\n\nuf = UnionFind(n+1)\n\nfor i in range(m):\n a, b = map(int, input().split())\n uf.union(a, b)\n\nans = 1\nfor i in range(1, n+1):\n ans = max(ans, uf.size(i))\n\nprint(ans)\n', 'class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n\nn, m = map(int, input().split())\n\nuf = UnionFind(n+1)\n\nfor i in range(m):\n a, b = map(int, input().split())\n uf.union(a, b)\n\nans = 1\nfor i in range(1, n+1):\n ans = max(ans, uf.size(i))\n\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s432156833', 's002626106'] | [10420.0, 14792.0] | [30.0, 723.0] | [632, 815] |
p02573 | u392441504 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['n,m=input().split()\nab = [map(int, input().split()) for _ in range(m)]\na, b = [list(i) for i in zip(*xy)]\nfriendnum = [0]*n\nfor i in range(n):\n for k in range(m):\n if a[k] == i:\n friendnum[i].append(b[i])\n if b[k] == i:\n friendnum[i].append(a[i])\nans = max(ans,len(frindnum[i]))\nprint(ans)', '# Union Find\n\n\ndef find(x):\n if par[x] < 0:\n return x\n else:\n tank = []\n while par[x] >= 0:\n tank.append(x)\n x = par[x]\n for elt in tank:\n par[elt] = x\n return x\n\n\n\ndef unite(x, y):\n x = find(x)\n y = find(y)\n\n if x == y:\n return False\n else:\n \n if par[x] > par[y]:\n x, y = y, x\n par[x] += par[y]\n par[y] = x\n return True\n\n\n\ndef same(x, y):\n return find(x) == find(y)\n\n\n\ndef size(x):\n return -par[find(x)]\n\n\n\n\nn,m = map(int,input().split())\npar = [-1] * n\nans = 0\nfor i in range(m):\n X,Y = map(int,input().split())\n unite(X-1,Y-1)\n\nfor i in range(n):\n ans = max(size(i),ans)\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s853285269', 's026490921'] | [9140.0, 14500.0] | [26.0, 678.0] | [328, 946] |
p02573 | u395816772 | 2,000 | 1,048,576 | There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group. At least how many groups does he need to make? | ['n,m = map(int,input().split())\ncon = []\nans = 0\nfor i in range(m):\n check = True\n b,c = map(int,input().split())\n if i == 0:\n con.append([b,c])\n else:\n for i in range(len(con)):\n if b in con[i]:\n check = False\n if c in con[i]:\n break\n else:\n con[i].append(c)\n break\n elif c in con[i]:\n check = False\n con[i].append(b)\n break\n if check:\n con.append([b,c])\n ans = max(ans,len(con[i]))\nprint(ans)\n', "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n \nn,m = map(int, input().split())\n\nuf = UnionFind(n)\n\nfor i in range(m):\n a,b = map(int, input().split())\n uf.union(a-1, b-1)\nans = 0\nroots = uf.roots()\ncnt = []\nfor r in roots:\n cnt.append(uf.size(r))\ncnt.sort(reverse=True)\nans = cnt[0]\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s885216645', 's798750372'] | [9592.0, 20056.0] | [2206.0, 599.0] | [618, 1406] |
Subsets and Splits