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
p02571
u918770092
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['s = str(input())\nt = str(input())\nans = 10000\nfor i in range(len(s) - len(t) + 1) : \n cnt = 0\n for j in range(len(t)) : \n if s[i + j] != t[j] : \n cnt += 1\n ans = min(ans, cnt)\n', 's = str(input())\nt = str(input())\nans = 10000\nfor i in range(len(s) - len(t) + 1) : \n cnt = 0\n for j in range(len(t)) : \n if s[i + j] != t[j] : \n cnt += 1\n ans = min(ans, cnt)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s729573756', 's834992089']
[9084.0, 9008.0]
[61.0, 55.0]
[187, 197]
p02571
u918845030
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['\ndef input_from_console():\n s = input()\n t = input()\n return s, t\n\n\ndef solve(s, t):\n min_count = len(t)\n for i in range(len(s)-len(t)):\n temp_count = 0\n for j in range(len(t)):\n if s[j+i] != t[j]:\n temp_count += 1\n min_count = min(min_count, temp_count)\n return min_count\n\n\ndef main():\n s, t = input_from_console()\n print(s,t)\n print(solve(s, t))\n\n\nif __name__ == "__main__":\n import sys\n\n if sys.gettrace(): # Check if the python interpreter is in debug mode or not.\n check_cases()\n else:\n main()', 'def input_from_console():\n s = input()\n t = input()\n return s, t\n\n\ndef solve(s, t):\n min_count = len(t)\n for i in range(len(s)-len(t) + 1):\n temp_count = 0\n for j in range(len(t)):\n if s[j+i] != t[j]:\n temp_count += 1\n min_count = min(min_count, temp_count)\n return min_count\n\n\ndef main():\n s, t = input_from_console()\n print(solve(s, t))\n\n\nif __name__ == "__main__":\n import sys\n\n if sys.gettrace(): # Check if the python interpreter is in debug mode or not.\n check_cases()\n else:\n main()\n']
['Wrong Answer', 'Accepted']
['s217890931', 's062471698']
[8944.0, 9124.0]
[50.0, 57.0]
[596, 585]
p02571
u919519672
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
["def probB():\n S = input()\n T = input()\n\n maxdiff = 0\n for i in range(len(S) - len(T)):\n count = 0\n for j in range(len(T)):\n if S[i + j] != T[j]:\n count += 1\n if (count > maxdiff):\n maxdiff = count\n print(maxdiff)\n\n\ndef main():\n probB()\n\n\nif __name__ == '__main__':\n main()\n", "def probB():\n S = input()\n T = input()\n\n if T in S:\n print(0)\n return\n if len(T) == len(S):\n count = 0\n for t, s in zip(S, T):\n if t != s:\n count += 1\n print(count)\n return\n\n maxdiff = 0\n for i in range(len(S) - len(T)):\n count = 0\n for j, c in enumerate(T):\n if S[i + j] != c:\n count += 1\n if (count > maxdiff):\n maxdiff = count\n print(maxdiff)\n\n\ndef main():\n probB()\n\n\nif __name__ == '__main__':\n main()\n", "def probB():\n S = input()\n T = input()\n\n if T in S:\n print(0)\n return\n if len(T) == len(S):\n count = 0\n for i, _ in enumerate(T):\n if T[i] != S[i]:\n count += 1\n print(count)\n return\n\n maxdiff = 0\n for i in range(len(S) - len(T)):\n count = 0\n for j, c in enumerate(T):\n if S[i + j] != c:\n count += 1\n if (count > maxdiff):\n maxdiff = count\n print(maxdiff)\n\n\ndef main():\n probB()\n\n\nif __name__ == '__main__':\n main()\n", "def probB():\n S = input()\n T = input()\n\n if T in S:\n print(0)\n\n maxdiff = 0\n for i in range(len(S) - len(T)):\n count = 0\n for j in range(len(T)):\n if S[i + j] != T[j]:\n count += 1\n if (count > maxdiff):\n maxdiff = count\n print(maxdiff)\n\n\ndef main():\n probB()\n\n\nif __name__ == '__main__':\n main()\n", "def probB():\n S = input()\n T = input()\n\n if T in S:\n print(0)\n return\n if len(T) == len(S):\n count = 0\n for t, s in zip(S, T):\n if t != s:\n count += 1\n print(count)\n return\n\n maxequal = 0\n for i in range(len(S) - len(T)):\n count = 0\n for j in range(len(T)):\n if S[i + j] == T[j]:\n count += 1\n if (count > maxequal):\n maxequal = count\n print(len(T) - maxequal)\n\n\ndef main():\n probB()\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s100193565', 's488857220', 's561653602', 's642228965', 's442256211']
[9040.0, 9068.0, 9036.0, 9056.0, 8964.0]
[54.0, 54.0, 50.0, 53.0, 60.0]
[360, 567, 576, 393, 581]
p02571
u923824033
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['a = input()\nb = input()\n\nl = []\nfor i in range(len(a) - len(b) + 1):\n cnt = 0\n for j in range(len(b)):\n if b[j] == a[i + j]:\n cnt += 1\n l.append(cnt)\n\nprint(l)\nprint(len(b) - max(l))', 'a = input()\nb = input()\n\nl = []\nfor i in range(len(a) - len(b) + 1):\n cnt = 0\n for j in range(len(b)):\n if b[j] == a[i + j]:\n cnt += 1\n l.append(cnt)\n\n#print(l)\nprint(len(b) - max(l))']
['Wrong Answer', 'Accepted']
['s482700422', 's041645950']
[8928.0, 9028.0]
[77.0, 73.0]
[209, 210]
p02571
u924852499
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['S = input()\nT = input()\n\nlen_S = len(S)\nlen_T = len(T)\n\nans = 10*5\nfor i in range(len_S - len_T+1):\n num = 0\n tmp = S[i:i+len_T]\n print(tmp)\n for j in range(len(tmp)):\n print(tmp[j])\n if tmp[j] != T[j]:\n num+=1\n ans = min(ans, num)\n\nprint(ans)', 'S = input()\nT = input()\n\nlen_S = len(S)\nlen_T = len(T)\n\nans = 10**10\nfor i in range(len_S - len_T+1):\n num = 0\n for j in range(len_T):\n if S[i+j] != T[j]:\n num+=1\n ans = min(ans, num)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s006880657', 's880515871']
[9160.0, 9124.0]
[119.0, 62.0]
[283, 222]
p02571
u935254309
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['S = str(input())\nT = str(input())\n\n\nresult =0\ncnt = len(T)\ntemp = S[:cnt]\nMin = len(T)\n\nwhile True:\n sum = 0\n \n for i in range (len(T)):\n if temp[i] != T[i]:\n sum+=1\n \n result = min(Min,sum)\n \n if cnt+len(T) <= len(S):\n temp = S[cnt:cnt+len(T)]\n print(temp)\n cnt = cnt+len(T)\n else:\n break\n \n \nprint(result)\n \n \n ', 'S = str(input())\nT = str(input())\n\nresult =0\nindex = 0\nMin = len(T)\n\nwhile True:\n sum = 0\n temp = S[index : index + len(T)]\n \n for i in range (len(T)):\n if temp[i] != T[i]:\n sum+=1\n \n Min = min(Min,sum)\n \n index +=1\n \n if index + len(T) > len(S):\n break\n \nprint(Min)\n \n \n ']
['Wrong Answer', 'Accepted']
['s117594309', 's811945064']
[9064.0, 9060.0]
[32.0, 56.0]
[399, 340]
p02571
u939790872
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['S = input()\nT = input()\n\nss = len(S)\ntt = len(T)\n\ncount = 0\nres = []\n\n\nfor i in range(ss-tt+1):\n for j in range(tt):\n if S[i+j] != T[j]:\n count += 1\n res.append(count)\n count = 0\n\nprint(res)\nprint(min(res))', 'S = input()\nT = input()\n\nss = len(S)\ntt = len(T)\n\ncount = 0\nres = []\n\n\nfor i in range(ss-tt+1):\n for j in range(tt):\n if S[i+j] != T[j]:\n count += 1\n res.append(count)\n count = 0\n\nprint(min(res))']
['Wrong Answer', 'Accepted']
['s762635109', 's172825986']
[9032.0, 9040.0]
[63.0, 63.0]
[233, 222]
p02571
u939847032
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['def main():\n S = input()\n T = input()\n print(S)\n print(T)\n min = len(T)\n for i in range(len(S) - len(T) + 1):\n temp = 0\n for j in range(len(T)):\n if S[i + j] != T[j]:\n temp += 1\n if temp < min:\n min = temp\n print(min)\nmain()', 'def main():\n S = input()\n T = input()\n min = len(T)\n for i in range(len(S) - len(T) + 1):\n temp = 0\n for j in range(len(T)):\n if S[i + j] != T[j]:\n temp += 1\n if temp < min:\n min = temp\n print(min)\nmain()']
['Wrong Answer', 'Accepted']
['s555986468', 's428910076']
[9020.0, 9052.0]
[48.0, 47.0]
[303, 277]
p02571
u941047297
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
["def main():\n s = input()\n t = input()\n n = len(t)\n ans = 0\n\n for i in range(len(s) - n + 1):\n cnt = 0\n for a, b in zip(s[i:i + n], t):\n if a == b: cnt += 1\n ans = max(ans, cnt)\n print(s[i:i + n])\n print(n - ans)\n\nif __name__ == '__main__':\n main()\n\n", "def main():\n s = input()\n t = input()\n n = len(t)\n ans = 0\n\n for i in range(len(s) - n + 1):\n cnt = 0\n for a, b in zip(s[i:i + n], t):\n if a == b: cnt += 1\n ans = max(ans, cnt)\n print(n - ans)\n\nif __name__ == '__main__':\n main()\n\n"]
['Wrong Answer', 'Accepted']
['s168817547', 's332989540']
[9056.0, 9052.0]
[40.0, 45.0]
[309, 283]
p02571
u941438707
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['s=input()\nt=input()\nans=0\nfor i in range(len(s)-len(t)):\n u=0\n for a,b in zip(t,s[i:len(t)+i]):\n if a==b:u+=1\n print(t,s[i:len(t)+i],u) \n ans=max(ans,u) \nif len(s)==len(t):\n for a,b in zip(t,s):\n if a==b:ans+=1 \nprint(len(t)-ans)', 's=input()\nt=input()\nans=0\nfor i in range(len(s)-len(t)):\n u=0\n for a,b in zip(t,s[i:len(t)+i]):\n if a==b:u+=1\n ans=max(ans,u) \nif len(s)==len(t):\n for a,b in zip(t,s):\n if a==b:ans+=1 \nprint(len(t)-ans)']
['Wrong Answer', 'Accepted']
['s643757519', 's402455802']
[9072.0, 9068.0]
[63.0, 57.0]
[265, 232]
p02571
u942033906
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['S = list(input())\nT = list(input())\nls = len(S)\nlt = len(T)\nans = lt\nfor offset in range(ls - lt + 1):\n\tprint(offset)\n\tcnt = 0\n\tfor i in range(lt):\n\t\tprint(S[offset+i], T[i])\n\t\tif S[offset + i] != T[i]:\n\t\t\tcnt += 1\n\tans = min(ans, cnt)\nprint(ans)', 'S = list(input())\nT = list(input())\nls = len(S)\nlt = len(T)\nans = lt\nfor offset in range(ls - lt + 1):\n\tcnt = 0\n\tfor i in range(lt):\n\t\tif S[offset + i] != T[i]:\n\t\t\tcnt += 1\n\tans = min(ans, cnt)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s224466144', 's992185210']
[9172.0, 9120.0]
[177.0, 59.0]
[246, 204]
p02571
u945065638
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['S =input()\nT =input()\nmint=10000\n\nfor i in range(len(S)-len(T)+1):\n con = 0\n for j in range(len(T)):\n if S[i+j] != T[j]:\n con += 1\n \n mint =min(con,mint)\n \n if min_count == 0:\n break\n\n\nprint(mint)', 's = input()\nt = input()\nmini =10000000\n\nfor i in range(len(s)-len(t)+1):\n count = 0\n for z in range(len(t)):\n if s[i+z] != t[z]:\n count += 1\n \n if count < mini :\n mini = count\n\nprint(mini) ']
['Runtime Error', 'Accepted']
['s585336318', 's691263987']
[9056.0, 8904.0]
[23.0, 59.0]
[247, 238]
p02571
u949115942
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['s = input()\nt = input()\nans = len(t)\nfor i in range(0, (len(s)-len(t)+1)):\n diff = 0\n for j in range(i, len(t)):\n if t[j] == s[i+j]:\n diff += 1\n ans = min(ans, len(t)-diff)\nprint(ans)', 's = input()\nt = input()\nans = len(t)\nfor i in range(0, (len(s)-len(t))):\n diff = 0\n for j in range(i, len(t)):\n if t[j] == s[i+j]:\n diff += 1\n ans = min(ans, len(t)-diff)\nprint(ans)\n', 's = input()\nt = input()\nans = len(t)\nfor i in range(0, (len(s)-len(t)+1)):\n diff = 0\n for j in range(0, len(t)):\n if t[j] == s[i+j]:\n diff += 1\n ans = min(ans, len(t)-diff)\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s346646412', 's514776411', 's905257938']
[9020.0, 9008.0, 9128.0]
[50.0, 47.0, 72.0]
[210, 209, 210]
p02571
u956318161
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['S=input()\nT=input()\n\nfor i in range(0,len(S)-len(T)+1):\n score=0\n for j in range(0,len(T)):\n if(S[i] != T[i+j]):\n score += 1\n score = min(score, len(T))\nprint(score)', 'S=input("codefoces")\nT=input("atcoder")\ntlen = len(T)\n \n \nfor i in range(tlen, 1):\n for k in range(0, tlen+1-i):\n Tinclude = T[k:i]\n print(tlen-i)\n break', 's=input()\nt=input()\nscorelist=[]\nfor i in range(len(s)-len(t)+1):\n S=s[i:i+len(t)]\n score=0\n for j in range(len(t)):\n if S[j]!=t[j]:\n score+=1\n scorelist.append(str(score))\npoint=min(scorelist)\nprint(point)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s548148754', 's994613786', 's453852698']
[9056.0, 9084.0, 9052.0]
[28.0, 25.0, 49.0]
[176, 177, 219]
p02571
u957799665
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['S = list(str(input()))\nT = list(str(input()))\ni = 0\nt = 0\nans = 0\nstart = 0\n\nwhile i <= len(T)-1:\n if S[i] == T[i]:\n t = i\n while t <= len(T)-1:\n print(S[t])\n if T[t] == S[t]:\n ans += 1\n t += 1\n break\n i += 1\n\nif ans > 0:\n print(len(T)-ans)\nelse:\n print(len(T))', 'S = list(str(input()))\nT = list(str(input()))\ns = 0\nt = 0\nlen_s = len(S)\nlen_t = len(T)\ni = 0\nans = []\n\nwhile i < len_s-len_t+1:\n cnt = 0\n #print(S[i:i+len_t])\n for ss, tt in zip(S[i:i+len_t], T):\n #print(ss,tt)\n if ss != tt:\n cnt +=1\n ans.append(cnt)\n i += 1\n\n#print(ans)\nprint(min(ans))']
['Wrong Answer', 'Accepted']
['s849486728', 's495400940']
[9168.0, 9124.0]
[28.0, 45.0]
[342, 328]
p02571
u959682393
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['S = list(input())\nT = list(input())\nans = 1e9\n\nfor i in range(len(S) - len(T) + 1):\n print(S[i:len(T)+i],T)\n tmp = 0\n for j in range(len(T)):\n if S[i:len(T)+i][j] == T[j]: continue\n tmp += 1\n ans = min (ans,tmp)\n\nprint(ans)', 'S = list(input())\nT = list(input())\nans = 1e9\n\nfor i in range(len(S) - len(T) + 1):\n tmp = 0\n for j in range(len(T)):\n if S[i:len(T)+i][j] == T[j]: continue\n tmp += 1\n ans = min (ans,tmp)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s458830379', 's408809333']
[9036.0, 9064.0]
[499.0, 501.0]
[249, 222]
p02571
u970348538
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['s = input()\nt = input()\n\nans = len(t)\nfor i in range(len(s) - len(t) + 1):\n ans_tmp = 0\n for j in range(len(t)):\n if s[i+j] != t[j]:\n ans_tmp += 1\n print(s[i+j])\n ans = min(ans, ans_tmp)\nprint(ans)', 's = input()\nt = input()\n\nans = len(t)\nfor i in range(len(s) - len(t) + 1):\n ans_tmp = 0\n for j in range(len(t)):\n if s[i+j] != t[j]:\n ans_tmp += 1\n ans = min(ans, ans_tmp)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s810941103', 's244112567']
[8988.0, 9012.0]
[59.0, 61.0]
[227, 209]
p02571
u972036293
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['S = input()\nT = input()\nans = len(T)\nfor start in range(len(S) - len(T)):\n dif = 0\n for i in range(len(T)):\n if T[i] == S[start + i]:\n dif += 1\n ans = min(ans, dif) \nprint(ans)', 'S = input()\nT = input()\nans = len(T)\nfor start in range(len(S) - len(T)):\n dif = 0\n for i in range(len(T)):\n if T[i] == S[start + i]:\n dif += 1\n ans = min(ans, dif) \n ', 'S=input()\nT=input()\nANS=[]\nfor start in range(len(S)-len(T)):\n ans = 0\n for j in range(len(T)):\n if S[start] != T[j]:\n ans += 1\n ANS.append(ans)\nprint(min(ANS))\n ', 'S = input()\nT = input()\nans = len(T)\nfor start in range(len(S) - len(T)):\n dif = 0\n for i in range(len(T)):\n if T[i] == S[start + i]:\n dif += 1\n ans = min(ans, dif) \nprint(ans)', 'S=input()\nT=input()\nANS=[]\nfor start in range(len(S)):\n ans = 0\n for j in range(len(T)):\n if S[start] != T[j]:\n ans += 1\n ANS.append(ans)\nprint(min(ANS))\n ', 'S=input()\nT=input()\nANS=[]\nfor start in range(len(S)-len(T)):\n ans = 0\n for j in range(len(T)):\n if S[start] != T[j]:\n ans += 1\n ANS.append(ans)\nprint(min(ANS))\n ', 'S=input()\nT=input()\nANS=[]\nfor start in range(len(S)):\n ans = 0\n for j in range(len(T)):\n if S[start] != T[j]:\n ans += 1\n ANS.append(ans)\nprint(min(ANS))\n ', 'S = input()\nT = input()\nans = len(T)\nfor start in range(len(S) - len(T) + 1):\n dif = 0\n for i in range(len(T)):\n if T[i] != S[start + i]:\n dif += 1\n ans = min(ans, dif) \nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s119717610', 's355375561', 's373229046', 's584543430', 's697000882', 's704191784', 's810754078', 's624455224']
[8996.0, 9092.0, 8992.0, 8976.0, 40280.0, 9060.0, 9040.0, 9044.0]
[68.0, 71.0, 45.0, 68.0, 266.0, 51.0, 179.0, 62.0]
[187, 179, 174, 187, 169, 174, 167, 192]
p02571
u973972117
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['S = input()\nT = input()\nAnswer = len(T)\nfor i in range(0,len(S)-len(T)):\n String = S[i:i+len(T)]\n for j in range(len(String)):\n B = len(T)\n if String[j] == T[j]:\n B -= 1\n Answer = min(Answer,B)\nprint(Answer)', 'S = input()\nT = input()\nAnswer = len(T)\nfor i in range(0,len(S)-len(T)):\n String = S[i:i+len(T)]\n B = len(T)\n for j in range(len(String)):\n if String[j] == T[j]:\n B -= 1\n Answer = min(Answer,B)\nif len(S) == len(T):\n B = len(S)\n for j in range(len(S)):\n if T[j] == S[j]:\n B -=1\n Answer = min(Answer,B)\nprint(Answer)']
['Wrong Answer', 'Accepted']
['s835158071', 's232109249']
[9020.0, 9080.0]
[133.0, 62.0]
[245, 371]
p02571
u974402118
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['S = input()\nt = input()\nneq = len(t)\nfor i in range(len(S)-len(t)+1):\n if S[i]==t[0]:\n neq_temp = 0\n for j in range(1,len(t)):\n if S[i+j]!=t[j]:\n neq += 1\n neq = min(neq,neq_temp)\nprint(neq)', 'S = input()\nt = input()\nneq = len(t)\nfor i in range(len(S)-len(t)+1):\n neq_temp = 0\n for j in range(len(t)):\n if S[i+j]!=t[j]:\n neq_temp += 1\n neq = min(neq,neq_temp)\nprint(neq)']
['Wrong Answer', 'Accepted']
['s397287782', 's579332169']
[9000.0, 9068.0]
[59.0, 55.0]
[212, 188]
p02571
u987637902
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['s = input()\nt = input()\nls = len(s)\nlt = len(t)\nans = 10000\n\n\nfor i in range(ls-lt+1): \n score = 0\n U = s[i:i + lt] \n for j in range(lt): \n \n if U[j] != t[j]:\n score += 1 \n ans = min(ans, score) \n\nprint(ans)', '# ABC177\n# B Substring\n\n\n\ns = input()\nt = input()\nls = len(s)\nlt = len(t)\nans = 10000\n\n\nfor i in range(ls - lt + 1):\n score = 0\n U = s[i:i + lt] \n for j in range(lt): \n \n if U[j] != t[j]:\n score += 1 \n ans = min(ans, score) \n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s403067655', 's901347710']
[9060.0, 9116.0]
[95.0, 59.0]
[623, 839]
p02571
u989364230
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['s = input()\nt = input()\nx = len(t)\nmx= 0\n\nres= 0\nfor i in range(len(s) - x+1):\n print(i)\n tmp = s[i:i+x]\n cntmp = 0\n for j in range(x):\n if t[j] == tmp[j]:\n cntmp += 1\n # print(tmp, i)\n res = max(res, cntmp)\nprint(x-res)', 's = input()\nt = input()\nx = len(t)\nres= 0\nfor i in range(len(s) - x):\n tmp = s[i:x]\n cntmp = 0\n for j in range(x):\n if t[j] == s[j]:\n cntmp += 1\n res = max(res, cntmp)\nprint(x-res)\n', 's = input()\nt = input()\nx = len(t)\nmx= 0\n\nres= 0\nfor i in range(len(s) - x+1):\n # print(i)\n tmp = s[i:i+x]\n cntmp = 0\n for j in range(x):\n if t[j] == tmp[j]:\n cntmp += 1\n # print(tmp, i)\n res = max(res, cntmp)\nprint(x-res)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s661717510', 's707776948', 's717281277']
[9032.0, 8948.0, 9024.0]
[62.0, 66.0, 72.0]
[256, 211, 258]
p02571
u989892335
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['s=input()\nt=input()\nans=0\ntsize=len(t)\nfor i in range(tsize):\n if t[:i] in s:\n ans=tsize-(i+1)\n \nprint(ans)', 's,t=input(),input()\nans=len(t)\n\nfor x in range(len(s)-len(t)+1):\n tmp=0\n for y in range(len(t)):\n if s[x+y]!=t[y]:\n tmp+=1\n ans=min(ans,tmp) \nprint(ans)']
['Wrong Answer', 'Accepted']
['s810603013', 's684186835']
[9028.0, 9092.0]
[29.0, 55.0]
[136, 405]
p02571
u990641144
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['import numpy as np\nS = input()\nT = input()\n\ntmp = np.zeros(len(T))\n\ni=0\nflg=True\n\nwhile flg:\n for j in range(i, len(T)):\n print(i,j)\n print(T[i:j+1])\n print(T[i:j+1] in S)\n if T[i:j+1] in S:\n tmp[i] = j+1-i\n i = max(i + int(tmp[i]),i+1)\n if i >= len(T)-1:\n flg=False\n\nprint(len(T)-int(np.max(tmp)))', '#inp = list(map(int, input().split()))\nS = input()\nT = input()\n\ntmp = []*len(T)\n\ni=0\nwhile i < len(T):\n for j in range(i, len(T)-i):\n if T[i:i+j+1] in S:\n tmp[i] = j\n i = tmp[i]\n \nprint(max(tmp))', 'S = input()\nT = input()\n\ntmp = np.zeros(len(T))\n\ni=0\nflg=True\n\nwhile flg:\n for j in range(i, len(T)):\n if T[i:j+1] in S:\n tmp[i] = j\n i = i + int(tmp[i])\n if i >= len(T)-1:\n flg=False\n\nprint(int(np.max(tmp)))', 'import numpy as np\nS = input()\nT = input()\n\ntmp = np.zeros(len(T))\n\ni=0\nflg=True\n\nwhile flg:\n for j in range(i, len(T)):\n print(i,j)\n print(T[i:j+1])\n print(T[i:j+1] in S)\n if T[i:j+1] in S:\n tmp[i] = j+1\n i = i + int(tmp[i])\n if i >= len(T)-1:\n flg=False\n\nprint(len(T)-int(np.max(tmp)))', 'S=input()\nT=input()\nls=len(S)\nlt=len(T)\nans=lt\nfor i in range(0,ls-lt+1):\n a=0\n for j in range(lt):\n if S[i+j]==T[j]:\n a+=1\n ans=min(ans,lt-a)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s024113656', 's024772340', 's211399432', 's537955267', 's958433397']
[148204.0, 9104.0, 9056.0, 148152.0, 8972.0]
[1286.0, 28.0, 29.0, 2735.0, 68.0]
[353, 210, 242, 342, 180]
p02571
u992455162
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['s = input()\nt = input()\ncnt = 0\nmin = 0\nfor i in range(len(s)-len(t)):\n cnt = 0\n for j in range(len(t)):\n if s[i+j] == t[j]:\n cnt += 1\n print(i,j,cnt)\n if min < cnt:\n min = cnt\nprint(len(t)-min)', 's = input()\nt = input()\ncnt = 0\nmin = 0\nfor i in range(len(s)-len(t)+1):\n cnt = 0\n for j in range(len(t)):\n if s[i+j] == t[j]:\n cnt += 1\n if min < cnt:\n min = cnt\nans = len(t)-min\n\ns = s[::-1]\nt = t[::-1]\ncnt=0\nmin=0\nfor i in range(len(s)-len(t)+1):\n cnt = 0\n for j in range(len(t)):\n if s[i+j] == t[j]:\n cnt += 1\n if min < cnt:\n min = cnt\nif ans > len(t)-min:\n ans = len(t)-min\nf = s.find(t)\nif f < ans and f != -1:\n ans = f\nprint(ans)']
['Wrong Answer', 'Accepted']
['s416263786', 's796117073']
[9228.0, 9088.0]
[254.0, 117.0]
[251, 526]
p02571
u995062424
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['S = input()\nT = input()\n\nnum = 10**10\n\nfor i in range(len(S)-len(T)+1):\n U = S[i:(i+len(T))]\n for j in range(len(T)):\n if(T[j] != S[j]):\n tmp += 1\n num = min(num, tmp)\n \nprint(num)', 'S = input()\nT = input()\n\nnum = 10**10\n\nfor i in range(len(S)-len(T)+1):\n U = S[i:(i+len(T))]\n tmp = 0\n for j in range(len(T)):\n if(T[j] != U[j]):\n tmp += 1\n num = min(num, tmp)\n \nprint(num)']
['Runtime Error', 'Accepted']
['s195852490', 's126051741']
[9060.0, 8952.0]
[29.0, 57.0]
[210, 222]
p02571
u995400612
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['def minimumChar(S,T): \n n, m = len(S), len(T) \n ans = sys.maxsize \n for i in range(m - n + 1): \n minRemovedChar = 0\n for j in range(n): \n if (S[j] != T[i + j]): \n minRemovedChar += 1\n ans = min(minRemovedChar, ans) \n return ans \n \nS=input()\nT=input()\n\nprint(minimumChar(S, T)) ', 'import sys\ndef minimumChar(T,S): \n n, m = len(T), len(S) \n ans = sys.maxsize \n for i in range(m - n + 1): \n minRemovedChar = 0\n for j in range(n): \n if (T[j] != S[i + j]): \n minRemovedChar += 1\n ans = min(minRemovedChar, ans) \n return ans \n \nS=input()\nT=input()\n\nprint(minimumChar(T,S)) ']
['Runtime Error', 'Accepted']
['s888852484', 's708409285']
[8728.0, 9116.0]
[22.0, 44.0]
[341, 351]
p02571
u998741086
2,000
1,048,576
Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
['#!/usr/bin/env python3\n\ns = input()\nt = input()\n\nerrors = []\nfor i in range(len(s)-len(t)+1):\n error = 0 \n for j in range(len(t)):\n if s[i+j] != t[j]:\n error += 1\n errors.append(error)\nprint(min(errors)', '#!/usr/bin/env python\n\ns = input()\nt = input()\n\nerrors = []\nfor i in range(len(s)-len(t)+1):\n error = 0 \n for j in range(len(t)):\n if s[i+j] != t[j]:\n error += 1\n errors.append(error)\nprint(min(errors))']
['Runtime Error', 'Accepted']
['s899126789', 's707183364']
[8912.0, 9048.0]
[25.0, 55.0]
[229, 229]
p02572
u005569385
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()))\nt = [];s = 0\nfor i in range(N):\n for j in range(N):\n if i != j:\n if a[i]*a[j]<10**9+7:\n t.append(a[i]*a[j])\n else:\n t.append(a[i]%7*a%[j]%7)\nfor i in t:\n s += i\ns = s//2\nprint(s%10**9+7)', 'import itertools\nN = int(input())\na = list(map(int,input().split()))\na2 = itertools.accumulate(a)\nb = [0]\nb += list(a2)\ns = 0\nfor i in range(N):\n s += (a[i] * (b[-1] - b[i+1]))\nprint(s % (10**9+7))']
['Runtime Error', 'Accepted']
['s864793843', 's461876807']
[72304.0, 31124.0]
[2208.0, 139.0]
[303, 200]
p02572
u006728642
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\nS = sum(A)\nS2 = sum(map(lambda x: x*x,A))\n\nprint((S*S - S2) / 2 % 1000000007)', 'N = int(input())\nA = list(map(int,input().split()))\nmod = 1000000000 + 7\nS = sum(A)\nS2 = sum(map(lambda x: x*x,A))\nans = (S*S - S2)// 2 % mod\nprint(ans)']
['Wrong Answer', 'Accepted']
['s281461607', 's577534870']
[31544.0, 31468.0]
[95.0, 93.0]
[130, 152]
p02572
u009885900
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 = numpy.array(list(map(int, input().split())))\n\nans = 0\n\nfor i in range(N):\n\tans = (ans + A[i] * numpy.sum(A[i+1:N])) % (10**9+7)\n\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\n\nDIV = 10**9+7\nans = 0\nAsum = sum(A)\nAsum_sq = Asum**2\n\nfor i in range(N):\n\tans += A[i]**2\n\nres = (Asum_sq-ans)//2\nprint(res%DIV)']
['Runtime Error', 'Accepted']
['s934187629', 's121560322']
[27132.0, 31652.0]
[109.0, 142.0]
[181, 182]
p02572
u013617325
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\nnumber = 0\nfor i in range(N-1):\n for j in range(i+1, N):\n print(A[i], A[j])\n number += A[i]*A[j]\n\nprint(number)\n', 'N = int(input())\nA = list(map(int, input().split()))\n\nnumber = 0\nMOD = 1000000007\n\nfor i in range(N-1):\n for j in range(i+1, N):\n print(A[i], A[j])\n number += A[i]*A[j]\n\n\nif number > MOD:\n print(number%MOD)\nelse:\n print(number)\n', 'N = int(input())\nA = list(map(int, input().split()))\n\nnumber = 0\nMOD = 1000000007\n\nfor i in range(N-1):\n for j in range(i+1, N):\n print(A[i], A[j])\n number += A[i]*A[j]\n\n\nif number > MOD:\n print(number%MOD)\nelse:\n print(number)\n', '#!/usr/bin/env python3\nimport sys\nfrom itertools import accumulate\nMOD = 1000000007 # type: int\n\n\ndef solve(N: int, A: "List[int]"):\n aa = list(accumulate(A))\n #print(aa)\n x = sum(A)\n #print(x)\n\n ans = 0\n\n for i in range(N):\n ans += A[i]*(aa[N-1]-aa[i])%MOD\n ans %= MOD\n return print(ans)\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n A = [int(next(tokens)) for _ in range(N)] # type: "List[int]"\n solve(N, A)\n\nif __name__ == \'__main__\':\n main()\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s209440138', 's496944342', 's891637150', 's525902443']
[78960.0, 71800.0, 72020.0, 44472.0]
[2338.0, 2315.0, 3051.0, 161.0]
[183, 251, 251, 820]
p02572
u013864607
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()\nAs = list(map(int, input().split()))\n\nresult = 0\nfor i in range(N-1):\n result+=As[i]*sum(As[i+1:])\nprint(result%(1*10**9+7))\n', 'N = int(input())\nAs = list(map(int, input().split()))\n\nresult = 0\nbefore_sum = sum(As)\nfor i in range(N-1):\n before_sum-=As[i]\n result+=As[i]*(before_sum)\nprint(result%(1*10**9+7))\n']
['Runtime Error', 'Accepted']
['s492393192', 's453652079']
[31736.0, 31388.0]
[72.0, 131.0]
[140, 187]
p02572
u014386369
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).
['sum_all=[]\nfor i in range(N-1):\n for j in range(i+1,N):\n A[i]=A[i]%mod\n A[j]=A[j]%mod\n sum_all.append((A[i])*(A[j]))\n\nsum=0\nfor n in sum_all:\n sum+=n\nprint(sum%mod)', 'N=int(input())\nA=list(map(int,input().split()))\n\nmod=10**9+7\n\nB=[0]\nfor i in range(1,N+1):\n B.append(A[i-1]+B[i-1])\n\nans=0\nfor i in range(N-1):\n ans+=A[i]*(B[N]-B[i+1])\n ans%=mod\n\nprint(int(ans))']
['Runtime Error', 'Accepted']
['s052803494', 's094877915']
[9028.0, 31440.0]
[27.0, 197.0]
[191, 204]
p02572
u018538342
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())\nlis = list(map(int, input().split())\nsum = 0\nfor i in lis:\n for j in lis:\n sum += i * j\nprint(sum % 1000000009) ', 'n = int(input())\nlis = list(map(int, input().split()))\ns = 0\nfor ind, i in enumerate(lis):\n for j in lis[ind+1:]:\n print(i, j)\nprint(s % 1000000009) ', 'n = int(input())\nlis = list(map(int, input().split()))\n\ns = sum(lis) ** 2\nss = sum([i ** 2 for i in lis])\n\nprint(((s - ss)//2)%(10**9+7))\n \n ']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s388345397', 's530237835', 's869606128']
[8900.0, 102044.0, 31576.0]
[25.0, 2613.0, 129.0]
[148, 159, 147]
p02572
u036340997
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 = sum(a)\nans = 0\nmod = 10**9 + 7\nfor i in range(n):\n ans = (ans + a[i] * (s - a[i])) % mod\nprint(ans)', 'n = int(input())\na = list(map(int, input().split()))\ns = 0\nans = 0\nmod = 10**9 + 7\nfor i in range(n):\n ans = (ans + a[i] * s) % mod\n s = (s + a[i]) % mod\nprint(ans)']
['Wrong Answer', 'Accepted']
['s358585835', 's353149354']
[31560.0, 31672.0]
[134.0, 141.0]
[157, 166]
p02572
u037098269
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).
['s = input()\nt = input()\n\nres = 0\nfor i in range(len(s)-len(t)+1):\n tmp = 0\n for j in range(len(t)):\n if s[j+i] == t[j]:\n tmp += 1\n res = max(res, tmp)\n\nprint(len(t)-res)', 'n = int(input())\na = list(map(int, input().split()))\nmod = 10**9+7\n\ncur = 0\nres = 0\nfor i in range(n-1):\n cur = (cur + a[n-1-i]) % mod\n tmp = (a[n-2-i] * cur) % mod\n res = (res + tmp) % mod\n\nprint(res)']
['Wrong Answer', 'Accepted']
['s111698519', 's106360110']
[13128.0, 31652.0]
[34.0, 180.0]
[196, 210]
p02572
u048004795
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\ndef main():\n input = sys.stdin.readline\n n = int(input())\n a_list = list(map(int, input().split()))\n b_list = [0]*(n+1)\n MOD = 10**9 + 7\n\n for i in range(n):\n b_list[i+1] = b_list[i] + a_list[i]\n \n ans = 0\n for i in range(n):\n ai_sum = b_list[n] - b_list[i+1]\n ans += ai_sum * a_list[i]\n ans %= MOD\n print(ans)', "import sys\n\ndef main():\n input = sys.stdin.readline\n n = int(input())\n a_list = list(map(int, input().split()))\n b_list = [0]*(n+1)\n MOD = 10**9 + 7\n\n for i in range(n):\n b_list[i+1] = b_list[i] + a_list[i]\n \n ans = 0\n for i in range(n):\n ai_sum = b_list[n] - b_list[i+1]\n ans += ai_sum * a_list[i]\n ans %= MOD\n print(ans)\n\n\n\n\n \n\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s324667887', 's063267142']
[9120.0, 31460.0]
[30.0, 159.0]
[380, 429]
p02572
u051376899
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=int(input())\na=list(map(int,input().split()))\n\narray_sum = 0\nfor i in range(0, n, 1): \n array_sum += a[i]\n array_sum%=MOD\n\narray_sum_square = pow(array_sum,2,MOD)\n\nindividual_square_sum = 0\nfor i in range(0, n, 1): \n individual_square_sum+= pow(a[i],2,MOD)\n individual_square_sum%=MOD\n\nans=(array_sum_square - individual_square_sum+MOD) / 2\nprint(int(ans%MOD))', 'MOD = 1000000007\n\nn=int(input())\na=list(map(int,input().split()))\n\narray_sum = 0\nfor i in range(0, n, 1): \n array_sum = (array_sum % MOD + a[i]%MOD)%MOD \n\narray_sum_square = pow(array_sum,2,MOD)\n\nindividual_square_sum = 0\nfor i in range(0, n, 1): \n individual_square_sum+= pow(a[i],2,MOD)\n individual_square_sum%MOD\n\nans=(array_sum_square - individual_square_sum+MOD) / 2\nprint(int(ans%MOD))', 'MOD = 1000000007\n\nn=int(input())\na=list(map(int,input().split()))\n\narray_sum = 0\nfor i in range(0, n, 1): \n array_sum += a[i]\n #array_sum%=MOD\n\narray_sum_square = pow(array_sum,2)\n\nindividual_square_sum = 0\nfor i in range(0, n, 1): \n individual_square_sum+= pow(a[i],2)\n #individual_square_sum%=MOD\n\nans=(array_sum_square - individual_square_sum) //2\nprint(ans%MOD)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s213299826', 's221188631', 's398343109']
[31552.0, 31504.0, 31716.0]
[295.0, 304.0, 170.0]
[392, 400, 377]
p02572
u056358163
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\nQ = 1e9 + 7\n\nfor i in range(N-1):\n for j in range(i+1, N):\n print(A[i], A[j])\n ans += (A[i] * A[j])\n ans %= Q\n\nprint(int(ans))', 'N = int(input())\nA = list(map(int, input().split()))\n \nans = 0\nQ = int(1e9 + 7)\n \nsumA = sum(A)\n \nfor i in range(N-1):\n sumA -= A[i]\n ans += sumA * A[i]\n ans %= Q\n \nprint(ans)']
['Wrong Answer', 'Accepted']
['s887749279', 's969126126']
[66984.0, 31528.0]
[2260.0, 156.0]
[212, 184]
p02572
u065099501
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\ninput = sys.stdin.readline\nn = int(input())\ntmp = list(map(int, input().split()))\nA = [a % M for a in tmp]\nM = 1000000007\nans = 0\nfor i in range(1,n):\n ans += (A[i-1] * ((sum(A[i::])%M)))%M\nprint(ans%M)', 'import sys\ninput = sys.stdin.readline\nM = 1000000007\nn = int(input())\nA = list(map(int, input().split()))\nans = 0\ns = 0\nfor i in range(n):\n s += A[i]\n s %= M\n\nfor i in range(n):\n s = s - A[i]\n if s < 0:\n s += M\n ans += A[i] * s\n ans %= M\nprint(ans)']
['Runtime Error', 'Accepted']
['s357409029', 's392835021']
[31576.0, 31224.0]
[74.0, 190.0]
[216, 273]
p02572
u077296371
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()))\nsu=l[0]\nans=0\nfor i in range(1,n):\n ans+=su*l[i]\n ans%=mod\n su+=l[i]\n su%=mod\nprint(ans)', '\nimport math\nimport random\nimport heapq, bisect\nimport sys\nfrom collections import deque, defaultdict\nfrom fractions import Fraction\nimport sys\n#import threading\nfrom collections import defaultdict\n#threading.stack_size(10**8)\nmod = 10 ** 9 + 7\nmod1 = 998244353\n\n# ------------------------------warmup----------------------------\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nsys.setrecursionlimit(300000)\n\nBUFSIZE = 8192\n\n\nclass FastIO(IOBase):\n newlines = 0\n\n def __init__(self, file):\n self._fd = file.fileno()\n self.buffer = BytesIO()\n self.writable = "x" in file.mode or "r" not in file.mode\n self.write = self.buffer.write if self.writable else None\n\n def read(self):\n while True:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n if not b:\n break\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines = 0\n return self.buffer.read()\n\n def readline(self):\n while self.newlines == 0:\n b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n self.newlines = b.count(b"\\n") + (not b)\n ptr = self.buffer.tell()\n self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\n self.newlines -= 1\n return self.buffer.readline()\n\n def flush(self):\n if self.writable:\n os.write(self._fd, self.buffer.getvalue())\n self.buffer.truncate(0), self.buffer.seek(0)\n\n\nclass IOWrapper(IOBase):\n def __init__(self, file):\n self.buffer = FastIO(file)\n self.flush = self.buffer.flush\n self.writable = self.buffer.writable\n self.write = lambda s: self.buffer.write(s.encode("ascii"))\n self.read = lambda: self.buffer.read().decode("ascii")\n self.readline = lambda: self.buffer.readline().decode("ascii")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip("\\r\\n")\n\n\n# -------------------game starts now----------------------------------------------------import math\nclass TreeNode:\n def __init__(self, k, v):\n self.key = k\n self.value = v\n self.left = None\n self.right = None\n self.parent = None\n self.height = 1\n self.num_left = 1\n self.num_total = 1\n\n\nclass AvlTree:\n\n def __init__(self):\n self._tree = None\n\n def add(self, k, v):\n if not self._tree:\n self._tree = TreeNode(k, v)\n return\n node = self._add(k, v)\n if node:\n self._rebalance(node)\n\n def _add(self, k, v):\n node = self._tree\n while node:\n if k < node.key:\n if node.left:\n node = node.left\n else:\n node.left = TreeNode(k, v)\n node.left.parent = node\n return node.left\n elif node.key < k:\n if node.right:\n node = node.right\n else:\n node.right = TreeNode(k, v)\n node.right.parent = node\n return node.right\n else:\n node.value = v\n return\n\n @staticmethod\n def get_height(x):\n return x.height if x else 0\n\n @staticmethod\n def get_num_total(x):\n return x.num_total if x else 0\n\n def _rebalance(self, node):\n\n n = node\n while n:\n lh = self.get_height(n.left)\n rh = self.get_height(n.right)\n n.height = max(lh, rh) + 1\n balance_factor = lh - rh\n n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)\n n.num_left = 1 + self.get_num_total(n.left)\n\n if balance_factor > 1:\n if self.get_height(n.left.left) < self.get_height(n.left.right):\n self._rotate_left(n.left)\n self._rotate_right(n)\n elif balance_factor < -1:\n if self.get_height(n.right.right) < self.get_height(n.right.left):\n self._rotate_right(n.right)\n self._rotate_left(n)\n else:\n n = n.parent\n\n def _remove_one(self, node):\n """\n Side effect!!! Changes node. Node should have exactly one child\n """\n replacement = node.left or node.right\n if node.parent:\n if AvlTree._is_left(node):\n node.parent.left = replacement\n else:\n node.parent.right = replacement\n replacement.parent = node.parent\n node.parent = None\n else:\n self._tree = replacement\n replacement.parent = None\n node.left = None\n node.right = None\n node.parent = None\n self._rebalance(replacement)\n\n def _remove_leaf(self, node):\n if node.parent:\n if AvlTree._is_left(node):\n node.parent.left = None\n else:\n node.parent.right = None\n self._rebalance(node.parent)\n else:\n self._tree = None\n node.parent = None\n node.left = None\n node.right = None\n\n def remove(self, k):\n node = self._get_node(k)\n if not node:\n return\n if AvlTree._is_leaf(node):\n self._remove_leaf(node)\n return\n if node.left and node.right:\n nxt = AvlTree._get_next(node)\n node.key = nxt.key\n node.value = nxt.value\n if self._is_leaf(nxt):\n self._remove_leaf(nxt)\n else:\n self._remove_one(nxt)\n self._rebalance(node)\n else:\n self._remove_one(node)\n\n def get(self, k):\n node = self._get_node(k)\n return node.value if node else -1\n\n def _get_node(self, k):\n if not self._tree:\n return None\n node = self._tree\n while node:\n if k < node.key:\n node = node.left\n elif node.key < k:\n node = node.right\n else:\n return node\n return None\n\n def get_at(self, pos):\n x = pos + 1\n node = self._tree\n while node:\n if x < node.num_left:\n node = node.left\n elif node.num_left < x:\n x -= node.num_left\n node = node.right\n else:\n return (node.key, node.value)\n raise IndexError("Out of ranges")\n\n @staticmethod\n def _is_left(node):\n return node.parent.left and node.parent.left == node\n\n @staticmethod\n def _is_leaf(node):\n return node.left is None and node.right is None\n\n def _rotate_right(self, node):\n if not node.parent:\n self._tree = node.left\n node.left.parent = None\n elif AvlTree._is_left(node):\n node.parent.left = node.left\n node.left.parent = node.parent\n else:\n node.parent.right = node.left\n node.left.parent = node.parent\n bk = node.left.right\n node.left.right = node\n node.parent = node.left\n node.left = bk\n if bk:\n bk.parent = node\n node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1\n node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)\n node.num_left = 1 + self.get_num_total(node.left)\n\n def _rotate_left(self, node):\n if not node.parent:\n self._tree = node.right\n node.right.parent = None\n elif AvlTree._is_left(node):\n node.parent.left = node.right\n node.right.parent = node.parent\n else:\n node.parent.right = node.right\n node.right.parent = node.parent\n bk = node.right.left\n node.right.left = node\n node.parent = node.right\n node.right = bk\n if bk:\n bk.parent = node\n node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1\n node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)\n node.num_left = 1 + self.get_num_total(node.left)\n\n @staticmethod\n def _get_next(node):\n if not node.right:\n return node.parent\n n = node.right\n while n.left:\n n = n.left\n return n\n\n\n# -----------------------------------------------binary seacrh tree---------------------------------------\nclass SegmentTree:\n def __init__(self, data, default=0, func=lambda a, b: a+b):\n """initialize the segment tree with data"""\n self._default = default\n self._func = func\n self._len = len(data)\n self._size = _size = 1 << (self._len - 1).bit_length()\n\n self.data = [default] * (2 * _size)\n self.data[_size:_size + self._len] = data\n for i in reversed(range(_size)):\n self.data[i] = func(self.data[i + i], self.data[i + i + 1])\n\n def __delitem__(self, idx):\n self[idx] = self._default\n\n def __getitem__(self, idx):\n return self.data[idx + self._size]\n\n def __setitem__(self, idx, value):\n idx += self._size\n self.data[idx] = value\n idx >>= 1\n while idx:\n self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])\n idx >>= 1\n\n def __len__(self):\n return self._len\n\n def query(self, start, stop):\n if start == stop:\n return self.__getitem__(start)\n stop += 1\n start += self._size\n stop += self._size\n\n res = self._default\n while start < stop:\n if start & 1:\n res = self._func(res, self.data[start])\n start += 1\n if stop & 1:\n stop -= 1\n res = self._func(res, self.data[stop])\n start >>= 1\n stop >>= 1\n return res\n\n def __repr__(self):\n return "SegmentTree({0})".format(self.data)\n\n\nclass Factorial:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorials = [1, 1]\n self.invModulos = [0, 1]\n self.invFactorial_ = [1, 1]\n\n def calc(self, n):\n if n <= -1:\n print("Invalid argument to calculate n!")\n print("n must be non-negative value. But the argument was " + str(n))\n exit()\n if n < len(self.factorials):\n return self.factorials[n]\n nextArr = [0] * (n + 1 - len(self.factorials))\n initialI = len(self.factorials)\n prev = self.factorials[-1]\n m = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = prev * i % m\n self.factorials += nextArr\n return self.factorials[n]\n\n def inv(self, n):\n if n <= -1:\n print("Invalid argument to calculate n^(-1)")\n print("n must be non-negative value. But the argument was " + str(n))\n exit()\n p = self.MOD\n pi = n % p\n if pi < len(self.invModulos):\n return self.invModulos[pi]\n nextArr = [0] * (n + 1 - len(self.invModulos))\n initialI = len(self.invModulos)\n for i in range(initialI, min(p, n + 1)):\n next = -self.invModulos[p % i] * (p // i) % p\n self.invModulos.append(next)\n return self.invModulos[pi]\n\n def invFactorial(self, n):\n if n <= -1:\n print("Invalid argument to calculate (n^(-1))!")\n print("n must be non-negative value. But the argument was " + str(n))\n exit()\n if n < len(self.invFactorial_):\n return self.invFactorial_[n]\n self.inv(n) # To make sure already calculated n^-1\n nextArr = [0] * (n + 1 - len(self.invFactorial_))\n initialI = len(self.invFactorial_)\n prev = self.invFactorial_[-1]\n p = self.MOD\n for i in range(initialI, n + 1):\n prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p\n self.invFactorial_ += nextArr\n return self.invFactorial_[n]\n\n\nclass Combination:\n def __init__(self, MOD):\n self.MOD = MOD\n self.factorial = Factorial(MOD)\n\n def ncr(self, n, k):\n if k < 0 or n < k:\n return 0\n k = min(k, n - k)\n f = self.factorial\n return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD\n\n\n\ndef powm(a, n, m):\n if a == 1 or n == 0:\n return 1\n if n % 2 == 0:\n s = powm(a, n // 2, m)\n return s * s % m\n else:\n return a * powm(a, n - 1, m) % m\n\n\n\ndef sort_list(list1, list2):\n zipped_pairs = zip(list2, list1)\n\n z = [x for _, x in sorted(zipped_pairs)]\n\n return z\n\n\n# --------------------------------------------------product----------------------------------------\ndef product(l):\n por = 1\n for i in range(len(l)):\n por *= l[i]\n return por\n\n\n# --------------------------------------------------binary----------------------------------------\ndef binarySearchCount(arr, n, key):\n left = 0\n right = n - 1\n\n count = 0\n\n while (left <= right):\n mid = int((right + left) / 2)\n\n # Check if middle element is\n # less than or equal to key\n if (arr[mid] <= key):\n count = mid + 1\n left = mid + 1\n\n # If key is smaller, ignore right half\n else:\n right = mid - 1\n\n return count\n\n\n# --------------------------------------------------binary----------------------------------------\ndef countdig(n):\n c = 0\n while (n > 0):\n n //= 10\n c += 1\n return c\ndef binary(x, length):\n y = bin(x)[2:]\n return y if len(y) >= length else "0" * (length - len(y)) + y\n\ndef countGreater(arr, n, k):\n l = 0\n r = n - 1\n\n # Stores the index of the left most element\n # from the array which is greater than k\n leftGreater = n\n\n # Finds number of elements greater than k\n while (l <= r):\n m = int(l + (r - l) / 2)\n if (arr[m] >= k):\n leftGreater = m\n r = m - 1\n\n # If mid element is less than\n # or equal to k update l\n else:\n l = m + 1\n\n # Return the count of elements\n # greater than k\n return (n - leftGreater)\n\n\n# --------------------------------------------------binary------------------------------------\nn=int(input())\nl=list(map(int,input().split()))\nsu=l[0]\nans=0\nfor i in range(1,n):\n ans+=su*l[i]\n ans%=mod\n su+=l[i]\n su%=mod\nprint(ans)']
['Runtime Error', 'Accepted']
['s820871280', 's589755218']
[31564.0, 35284.0]
[71.0, 169.0]
[148, 15062]
p02572
u080885857
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 itertools import accumulate\nmod = 1e9 +7\ndef main():\n n = int(input())\n a = list(map(int,input().split()))\n ans =0\n ac = list(accumulate(a))\n \n for i in range(n):\n ans += a[i]* (ac[-1]-ac[i])\n ans %=mod\n print(ans)\n\nif __name__ == '__main__':\n main()", 'mod = 1e9 + 7\n\nn = int(input())\na = list(map(int, input().split()))\npref = [0 for x in range(n)]\npref[0] = a[0]\nfor i in range(1, n):\n pref[i] += ((pref[i - 1] + a[i]))\n\nans = 0\nfor i in range(n - 1, 0, -1):\n ans = (ans + a[i] * pref[i - 1]) % mod\n\nprint(ans)', "from itertools import accumulate\nmod = 10**9 +7\n\ndef main():\n n = int(input())\n a = list(map(int,input().split()))\n ans =0\n ac = list(accumulate(a))\n\n for i in range(n):\n ans += a[i]* (ac[-1]-ac[i])\n ans %=mod\n print(ans)\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s069358880', 's897229120', 's287737689']
[31636.0, 31360.0, 31624.0]
[155.0, 218.0, 130.0]
[293, 265, 292]
p02572
u094213642
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 \n# required function \ndef findProductSum(A, n): \n \n # calculating array sum (a1 + a2 ... + an) \n array_sum = 0\n for i in range(0, n, 1): \n array_sum = array_sum + A[i] \n \n # calcualting square of array sum \n # (a1 + a2 + ... + an)^2 \n array_sum_square = array_sum * array_sum \n \n # calcualting a1^2 + a2^2 + ... + an^2 \n individual_square_sum = 0\n for i in range(0, n, 1): \n individual_square_sum += A[i] * A[i] \n \n # required sum is (array_sum_square - \n # individual_square_sum) / 2 \n return (array_sum_square - \n individual_square_sum) / 2\n \nprint(int(findProductSum(a, n))%10**9+7) ', 'n = int(input())\na = list(map(int, input().split()))\n \n# required function \ndef findProductSum(A, n): \n \n # calculating array sum (a1 + a2 ... + an) \n array_sum = 0\n for i in range(0, n, 1): \n array_sum = array_sum + A[i] \n \n # calcualting square of array sum \n # (a1 + a2 + ... + an)^2 \n array_sum_square = array_sum * array_sum \n \n # calcualting a1^2 + a2^2 + ... + an^2 \n individual_square_sum = 0\n for i in range(0, n, 1): \n individual_square_sum += A[i] * A[i] \n \n # required sum is (array_sum_square - \n # individual_square_sum) / 2 \n return (array_sum_square - \n individual_square_sum)\nmod = 10**9+7\n \ndef modinv(a, mod=10**9+7):\n return pow(a, mod-2, mod)\n \nprint(modinv(2)*int(findProductSum(a, n))%mod)']
['Wrong Answer', 'Accepted']
['s168496865', 's361544031']
[31392.0, 31444.0]
[111.0, 104.0]
[709, 786]
p02572
u097319437
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\nfrom itertools import combinations\n\nmod = 1000000007 \ns = 0\nfor c in combinations(A, 2):\n s += c[0] * c[1]\n\nprint(s % mod)', 'N = int(input())\nA = [int(x) for x in input().split(" ")]\n\nfrom itertools import combinations\n\nmod = 1000000007 \n\ns = 0\nans = 0\nfor n in A:\n s += n\n s %= mod\n\nfor i in range(N):\n s -= A[i]\n ans += A[i] * s\n ans %= mod\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s472858563', 's698362695']
[8656.0, 31564.0]
[30.0, 194.0]
[248, 310]
p02572
u100792505
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())\nalist = list(map(int, input().split()))\nSum_a = 0\nfor i in range(N):\n for j in range(i+1, N):\n Sum_a += alist[i]*alist[j]\nprint(Sum_a%(1e9+7))', 'N = int(input())\nalist = list(map(int, input().split()))\nimport numpy as np\nSum_a = 0\nSum_j_list = np.cumsum(alist)\nfor i in range(N-1):\n Sum_j = int((Sum_j_list[N-1] - Sum_j_list[i]) % int(1e9+7))\n Sum_a += (alist[i] * Sum_j) % int(1e9+7)\nprint(int(Sum_a % int(1e9+7)))']
['Wrong Answer', 'Accepted']
['s438297592', 's300933576']
[31428.0, 37828.0]
[2206.0, 420.0]
[163, 272]
p02572
u108072608
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 \ns = 0\nfor i in a_list:\n for j in a_list:\n s += i*j\n\ns_2 = 0\nfor i in a_list:\n s_2 += i**2\n \nans = int((s - s_2)/2)\nans %(10**9+7)', 'n = int(input())\na_list = list(map(int, input().split()))\n\ns_2 = 0\nfor i in a_list:\n s_2 += i**2\n\nans = (sum(a_list)**2 - s_2)/2 \n\nans = ans%(10**9+7)\nprint(ans)', 'n = int(input())\na_list = list(map(int, input().split()))\n\ns_2 = 0\nfor i in a_list:\n s_2 += i**2\n\nans = (sum(a_list)**2 - s_2)//2 \n\nans = ans%(10**9+7)\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s149336409', 's159189297', 's797614610']
[31524.0, 31588.0, 31544.0]
[2206.0, 125.0, 125.0]
[205, 165, 166]
p02572
u111471511
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\nmod = 1e9+7\n\nN = int(input())\nA = [int(num)%mod for num in input().split()]\n\nA_sum = sum(A)\nA_squared = sum([num**2 for num in A])\n\nans = (A_sum**2 - A_squared)/2\nans = int(ans%mod)\nprint(ans-1)\n', 'N = int(input())\nA = [int(num) for num in input().split()]\nA_sum = sum(A)\n\nans = 0\nfor i in range(N-1):\n ans += A[i]*(A_sum-A[i])\n A_sum = A_sum - A[i]\n\nprint(ans%(1e9+7))', 'n = int(input())\na = list(map(int, input().split()))\nb = sum(a)\nans = 0\nfor i in range(n-1):\n ans += a[i] *(b-a[i])\n b = b - a[i]\nprint(ans % (10**9 + 7))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s309521341', 's950946714', 's348618116']
[31544.0, 31436.0, 31644.0]
[111.0, 148.0, 142.0]
[203, 177, 160]
p02572
u123745130
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).
['s=input()\nt=input()\nlen_s=len(s)\nlen_t=len(t)\nlen_n=len_s-len_t\nans=100000\nfor i in range(0,len_n+1):\n cnt=0\n for j in range(len_t):\n if s[i+j]!=t[j]:\n cnt+=1\n\n ans=min(ans,cnt)\nprint(ans)\n', 'n=int(input())\nlst=list(map(int,input().split()))\naa=sum(lst) % (10**9+7)\n# print(sum(lst) % (10**9+7) )\nnew_lst=[]\ntemp_1=aa\nfor i in range(n-1):\n temp_1-=lst[i]\n new_lst.append(temp_1)\n# print(new_lst)\n\ntem=0\nfor i in range(n-1):\n tem+=(lst[i] )*new_lst[i]\n # print(tem)\nprint(tem % (10**9 +7))\n']
['Wrong Answer', 'Accepted']
['s290340864', 's700316378']
[13196.0, 31320.0]
[34.0, 150.0]
[216, 313]
p02572
u124445903
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()))\ns = sum(a)\nnum = 0\nfor i in range(n):\n num = num - a[i]\n num = a[i]*num\nelse:\n print(num)', 'n=int(input())\n\nl = 1000000007\na=list(map(int,input().split()))\ns = sum(a)\nnum = 0\nfor i in range(n):\n s = s- a[i]\n num =num+a[i]*s\nelse:\n print(num%l)\n\n']
['Wrong Answer', 'Accepted']
['s733097298', 's463600274']
[31524.0, 31408.0]
[2206.0, 136.0]
[142, 156]
p02572
u128282559
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 = 0\nt = n-1\nfor i in a:\n for j in range(t):\n sum += i * a[-(j+1)]\n t -= 1\nans = sum % (10**9 + 7)', 'n = int(input())\na = list(map(int, input().split()))\nmod = 10**9 + 7\nans = 0\ns = sum(a)\nfor i in a:\n s -= i\n ans = (ans + (i * s))\nans = ans % mod\nprint(ans)']
['Wrong Answer', 'Accepted']
['s599640482', 's131736057']
[31540.0, 31624.0]
[2206.0, 115.0]
[167, 163]
p02572
u133936772
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,*l=map(int,open(0).read().split())\nprint((sum(l)**2-sum(i**2 for i in l)//2)%(10**9+7))', 'n,*l=map(int,open(0).read().split())\nprint((sum(l)**2-sum(i**2 for i in l))//2%(10**9+7))']
['Wrong Answer', 'Accepted']
['s825870467', 's814737831']
[31508.0, 31732.0]
[124.0, 119.0]
[89, 89]
p02572
u135642682
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\nres = 1\nfor j in range(n):\n for i in range(j+1):\n res = res * a[j] * a[i] % ((10**9) + 7)\nprint(res)\n ', 'n = int(input())\na = list(map(int, input().split(" ")))\n\nres = 0\nruiseki = 0\nfor j in range(n):\n if j == 0:\n continue\n ruiseki += a[j-1]\n res = res + a[j]*ruiseki\nprint(res % ((10 **9)+7))']
['Wrong Answer', 'Accepted']
['s104906964', 's076433640']
[31600.0, 31580.0]
[2206.0, 131.0]
[176, 204]
p02572
u141786930
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 - Sum of product of pairs\nimport numpy as np\n\nN = int(input())\nA = list(int(a) for a in input().split())\nMOD = 10**9 + 7\nA = np.array(A)\ncsA = np.zeros((N+1), np.object)\nfor i in range(N):\n csA[i+1] = csA[i] + A[i]\n \nans = 0\nfor i in range(N-1):\n ans += (A[i] * (csA[N] - csA[i+1])) % MOD\nprint(ans%MOD)', '# C - Sum of product of pairs\nimport numpy as np\n\nN = int(input())\nA = list(int(a) for a in input().split())\nMOD = 10**9 + 7\nA = np.array(A)\ncsA = np.zeros((N+1), np.int64)\nfor i in range(N):\n csA[i+1] = (csA[i] + A[i]) % MOD\n \nans = 0\nfor i in range(N-1):\n ans += (A[i] * (csA[N] - csA[i+1])) % MOD\nprint(ans%MOD)']
['Wrong Answer', 'Accepted']
['s152233777', 's338025234']
[49580.0, 50248.0]
[557.0, 472.0]
[316, 323]
p02572
u146057001
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\nc = sum(a)\n\nfor i in range(n - 1):\n ans += a[i] * (c - a[i])\n\nprint(ans % (10 ** 9 + 7)) \n', 'n = int(input())\na = list(map(int, input().split()))\nans = 0\nc = sum(a)\n\nfor i in range(n - 1):\n c = c - a[i]\n ans += a[i] * c\n\nprint(ans % (10 ** 9 + 7)) ']
['Wrong Answer', 'Accepted']
['s445564139', 's034159805']
[31648.0, 31532.0]
[122.0, 130.0]
[161, 164]
p02572
u153047519
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()))\nfor i in range(n):\n for j in range(i + 1, n):\n result += (a[i] % (10**9 + 7)) * (a[i] % (10**9 + 7))\nresult = result % (10**9 + 7)\nprint(result)', 'n = int(input())\na = list(map(int, input().split()))\nresult = 0\nd = 0\nfor i in range(n):\n d += a[i] ** 2\nresult = (sum(a) ** 2 - d) / 2\nresult = result % (10**9 + 7)\nprint(result)\n', 'n = int(input())\na = list(map(int, input().split()))\nsum_a = 0\nresult = 0\nfor i in range(n):\n sum_a += a[i]\nfor j in range(n):\n sum_a -= a[j]\n result += sum_a * a[j]\nprint(result % (10**9 + 7))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s469326461', 's655250971', 's494065024']
[31752.0, 31588.0, 31228.0]
[68.0, 139.0, 149.0]
[201, 181, 196]
p02572
u155659281
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 solve():\n N = int(input())\n AA = list(map(int,input().split()))\n \n ans = 0\n for a in AA:\n ans += a\n ans = ans**2\n for a in AA:\n ans -= a**2\n ans = (ans+(10**9+7)**2//2) % (10**9+7)\n print(ans)\nsolve()', 'def solve():\n N = int(input())\n AA = list(map(int,input().split()))\n \n ans = 0\n for a in AA:\n ans += a\n ans = ans**2\n for a in AA:\n ans -= a**2\n ans = ans//2\n print(ans%(10**9+7)\nsolve()', 'def solve():\n N = int(input())\n AA = list(map(int,input().split()))\n \n ans = 0\n for a in AA:\n ans += a\n ans = ans**2\n for a in AA:\n ans -= a**2\n ans = ans//2\n print(ans%(10**9+7))\nsolve()']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s015608126', 's650483893', 's607851013']
[31520.0, 8880.0, 31408.0]
[121.0, 26.0, 132.0]
[218, 200, 201]
p02572
u156815136
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 statistics import median\n#import collections\n\nfrom fractions import gcd\nfrom itertools import combinations,permutations,accumulate, product \n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\nimport math\nimport bisect\n#\n#\n#\n\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n\n#\n\n\n\n#\n#\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n#mod = 9982443453\n#mod = 998244353\nfrom sys import stdin\nreadline = stdin.readline\ndef readInts():\n return list(map(int,readline().split()))\ndef readTuples():\n return tuple(map(int,readline().split()))\ndef I():\n return int(readline())\nn = I()\nA = readInts()\na = 0\nfor i in range(n):\n a += A[i]\n a %= mod\na = pow(a,2,mod)\nnya = 0\nfor i in range(n):\n nya += A[i] * A[i]\n nya %= mod\nif nya > a:\n a += mod\nans = (a-nya)//2\nans %= mod\nprint(ans)\n', '#from statistics import median\n#import collections\n\nfrom fractions import gcd\nfrom itertools import combinations,permutations,accumulate, product \n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\nimport math\nimport bisect\n#\n#\n#\n\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n\n#\n\n\n\n#\n#\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n#mod = 9982443453\n#mod = 998244353\nfrom sys import stdin\nreadline = stdin.readline\ndef readInts():\n return list(map(int,readline().split()))\ndef readTuples():\n return tuple(map(int,readline().split()))\ndef I():\n return int(readline())\nn = I()\nA = readInts()\na = 0\nfor i in range(n):\n a += A[i]\n a %= mod\na = pow(a,2,mod)\nnya = 0\nfor i in range(n):\n nya += A[i] * A[i]\n nya %= mod\nans = ((a-nya + mod)//2)%mod\nprint(ans)\n', "#from statistics import median\n#import collections\n\nfrom math import gcd\nfrom itertools import combinations,permutations,accumulate, product \n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\nimport math\nimport bisect\nimport heapq\n#\n#\n#\n\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n\n#\n\n\n\n#\n#\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n#mod = 9982443453\n#mod = 998244353\nINF = float('inf')\nfrom sys import stdin\nreadline = stdin.readline\ndef readInts():\n return list(map(int,readline().split()))\ndef readTuples():\n return tuple(map(int,readline().split()))\ndef I():\n return int(readline())\nn = I()\nA = readInts()\ncum = list(accumulate(A))\nans = 0\nfor i in range(n-1):\n ans += A[i] * (cum[n-1]-cum[i])\n ans%=mod\nprint(ans%mod)\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s347572240', 's504633059', 's415632329']
[34356.0, 34584.0, 32860.0]
[182.0, 185.0, 172.0]
[1210, 1186, 1160]
p02572
u157232135
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 itertools import accumulate\ndef main():\n n=int(input())\n a=list(map(int,input().split()))\n aa=list(accumulate(a))\n mod=10**9+7\n ans=0\n print(aa)\n for i in range(n):\n ans += a[i]*(aa[-1]-aa[i])%mod\n print(ans%mod)\n \nif __name__ == "__main__":\n main()', 'from itertools import accumulate\ndef main():\n n=int(input())\n a=list(map(int,input().split()))\n aa=list(accumulate(a))\n mod=10**9+7\n ans=0\n for i in range(n):\n ans += a[i]*(aa[-1]-aa[i])%mod\n print(ans%mod)\n \nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s630794489', 's390523711']
[35808.0, 31564.0]
[151.0, 131.0]
[291, 277]
p02572
u167993508
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(1,n):\n l[i] += l[i-1]\ni = 0\nwhile i<n-1:\n ans += l[i]*(l[n] - l[i])\n i += 1\nprint(ans)', 'n = int(input())\nl = list(map(int,input().split()))\nx = [*l]\nans = 0\nmod = 1000000007\nfor i in range(1,n):\n l[i] += l[i-1]\ni = 0\nwhile i<n-1:\n ans += (x[i])*(l[n-1] - l[i])\n i += 1\nprint(ans%mod)\n']
['Runtime Error', 'Accepted']
['s612205843', 's308083926']
[31388.0, 31444.0]
[104.0, 171.0]
[164, 199]
p02572
u170913092
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)%(1e9+7) for x in input().split()]\n\n# calculating array sum (a1 + a2 ... + an) \narray_sum = 0\nfor i in range(0, n, 1): \n array_sum = (array_sum + A[i])%(1e9+7)\n\n # calcualting square of array sum \n # (a1 + a2 + ... + an)^2 \n array_sum_square = (array_sum * array_sum)%(1e9+7)\n\n# calcualting a1^2 + a2^2 + ... + an^2 \nindividual_square_sum = 0\nfor i in range(0, n, 1): \n individual_square_sum += (A[i] * A[i])%(1e9+7)\n individual_square_sum = individual_square_sum%(1e9+7)\n\n# required sum is (array_sum_square - individual_square_sum) / 2 \nprint (array_sum_square - individual_square_sum) / 2\n', 'N = int(input())\nA = list(map(int,input().split()))\nmod = 10**9+7\n\npartial_sum = copy.deepcopy(A)\nsum_now = A[N-1]\nfor j in range(N-2,-1,-1):\n sum_now = int((sum_now+A[j])%mod)\n partial_sum[j] = sum_now\nres = 0\nfor i in range(N-1):\n res = (res + (A[i]*partial_sum[i+1])%mod) %mod\nprint(int(res))\n', 'N = int(input())\nA = [int(x) for x in input().split()]\n \npartial_sum = A.copy()\nsum_now = A[N-1]\nfor j in range(N-2,-1,-1):\n sum_now = int((sum_now+A[j])%(10**9+7))\n partial_sum[j] = sum_now\nres = 0\nfor i in range(N-1):\n res = (res + (A[i]*partial_sum[i+1])%(10**9+7)) %(10**9+7)\nprint(int(res))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s477334869', 's904744296', 's533040808']
[31552.0, 31836.0, 31840.0]
[234.0, 70.0, 195.0]
[638, 305, 304]
p02572
u185042816
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\nsum = 0\n\nfor i in range(n-1):\n sum_i = 0\n for j in range(n-i-1):\n sum_i += a[-(j+1)]\n print(sum_i)\n sum += (sum_i * a[i])\n\nprint(sum%((10 ** 9)+7))', 'n = int(input())\na = list(map(int, input().split()))\n\nsum_a = 0\nsum_i = sum(a)\n\nfor i in range(n-1):\n sum_i -= a[i]\n sum_a += (a[i] * sum_i)\n\nprint(sum_a%((10 **9)+7))']
['Wrong Answer', 'Accepted']
['s624433015', 's373998886']
[31600.0, 31748.0]
[2206.0, 140.0]
[220, 173]
p02572
u185405877
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())\ni = list(map(int, input().split())) \n\nm=sum(i)\n\nans=0\nfor k in range(n-1):\n ans+=(i[k]+(m-i[k]))\nans=ans//2\nans=ans%(10**9+7)\nprint(ans)', 'n=int(input())\ni = list(map(int, input().split())) \n\nans=0\nfor k in range(n-1):\n for j in range(i+1,n):\n ans+=(i[k]*i[j])%(10**9+7)\n\nans=ans%(10**9+7)\nprint(ans)\n', 'n=int(input())\ni = list(map(int, input().split())) \n\nm=sum(i)\n\nans=0\nfor k in range(n-1):\n ans+=(i[k]*(m-i[k]))\nans=ans//2\nans=ans%(10**9+7)\nprint(ans)\n', 'n=int(input())\ni = list(map(int, input().split())) \n\nm=sum(i)\n\nans=0\nfor k in range(n):\n ans+=(i[k]*(m-i[k]))\nans=ans//2\nans=ans%(10**9+7)\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s444558378', 's509991605', 's671803211', 's055000196']
[31556.0, 31628.0, 31196.0, 31452.0]
[119.0, 75.0, 125.0, 120.0]
[154, 172, 155, 152]
p02572
u186820109
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).
['i = 0\nj = i+1\nans = 0\nwhile i != n - 1:\n ans = (ans+(a[i] * a[j])) % 1000000007\n j += 1\n if j == n:\n i += 1\n j = i + 1\nprint(ans)\n', 'i = 0\nj = i+1\nans = 0\nwhile i != n - 1:\n ans += a[i] * a[j]\n j += 1\n if j == n:\n i += 1\n j = i + 1\nprint(ans % 1000000007)', 'n = int(input())\na = list(map(int, input().split()))\n\nsum = [0 for i in range(n+1)]\nfor i in range(n - 1, -1, -1):\n sum[i] = sum[i + 1] + a[i]\nans = 0\nfor i in range(n):\n ans = (ans+(a[i]*sum[i+1])) % 1000000007\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s559546543', 's930348420', 's202910977']
[9100.0, 8996.0, 31520.0]
[23.0, 24.0, 177.0]
[153, 131, 229]
p02572
u191491133
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()))\ns2=int(sum(a)*sum(a))\na2=[int(i*i) for i in a]\nans1=int((s2-sum(a2))/2)\nprint(int(ans1%10**9+7))\n', 'n=int (input())\na= list(map(int,input().split()))\ns2=int(sum(a)*sum(a))\na2=[int(i*i) for i in a]\nans1=(s2-sum(a2))//2\n\nprint(int(ans1%((10**9)+7)))\n']
['Wrong Answer', 'Accepted']
['s631704168', 's494223950']
[31704.0, 31532.0]
[104.0, 101.0]
[147, 148]
p02572
u193690465
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()\nvals = list(map(int, input().split()))\ns = sum(vals)\nret = 0\nfor i, val in enumerate(vals):\n ret += val * (s - val)\n\nmod = 10 ** 9 + 7\nprint(int(ret/2) % mod))', 'n = input()\nvals = list(map(int, input().split()))\ns = sum(vals)\nret = 0\nfor i, val in enumerate(vals):\n ret += val * (s - val)\n\nmod = 10 ** 9 + 7\nprint(int(ret/2) % mod))', 'n = input()\nvals = list(map(int, input().split()))\ns = sum(vals)\nret = 0\nfor i, val in enumerate(vals):\n ret += val * (s - val)\n\nmod = 10 ** 9 + 7\nprint(int(ret//2) % mod)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s525464401', 's953157020', 's962639240']
[9068.0, 9032.0, 31648.0]
[26.0, 23.0, 116.0]
[174, 174, 174]
p02572
u198336369
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 = 0\nb = [i % (10**9+7) for i in a if i % (10**9+7) != 0]\nprint(b)\nfor j in range(0,len(b)-1):\n for k in range(j+1,len(b)):\n c = b[j]*b[k]\n sum = sum + c\nprint(sum%(10**9+7))', 'n = int(input())\na = list(map(int, input().split()))\nA = sum(a)\nprint(A)\ns = 0\nfor i in range(n-1):\n A = A - a[i]\n b = (a[i]*A)%(10**9+7)\n s = s + b\nprint(s%(10**9+7))', 'n = int(input())\na = list(map(int, input().split()))\nA = sum(a)\ns = 0\nfor i in range(n-1):\n A = A - a[i]\n b = (a[i]*A)%(10**9+7)\n s = s + b\nprint(s%(10**9+7))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s187113381', 's885955846', 's157453944']
[31748.0, 31512.0, 31496.0]
[2210.0, 151.0, 146.0]
[247, 176, 167]
p02572
u207582576
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())\ns = list(map(int, input().split()))\n \nadd = 0\nj = 0\n \nfor i in range(N):\n for j in range(i+1, N):\n a = s[i] * s[j]\n add += a\n \na = add % (10**9 + 7) \nprint(sum)', 'n=int(input())\na=list(map(int,input().split()))\nmod = 10**9 + 7\n\nsum = 0\nf = 0\n\nfor i in range(n-1):\n f = f + a[i]\n sum += f * a[i+1]\n \nprint(sum % mod)']
['Wrong Answer', 'Accepted']
['s754642705', 's095242980']
[31400.0, 31704.0]
[2206.0, 125.0]
[187, 158]
p02572
u208588434
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())\nX = list(map(int, input().split()))\np = 0\nfor n in range(N):\n for m in range(n+1, N):\n p += X[n]*X[m]\n if p >= 10**9 + 7:\n while p >= 10**9 + 7:\n p -= 10**9 + 7\n \nprint(p)', 'N = int(input())\nX = list(map(int, input().split()))\np = 0\ns = sum(X)\nfor n in range(N):\n s -= X[n] \n s = s % (10**9 + 7)\n p += s * X[n]\n p = p % (10**9 + 7)\n\nprint(p)']
['Runtime Error', 'Accepted']
['s958144177', 's103812390']
[9004.0, 31448.0]
[27.0, 143.0]
[204, 171]
p02572
u213497190
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).
['sum_ = 0\ntemp = 0\nfor i in range(len(a)-1):\n temp += a[-i-1]\n sum_ += temp * a[-i-2]\n\nprint(sum_%(10**9 + 7))', 'n = int(input())\na = list(map(int, input().split()))\n\nsum_ = 0\ntemp = 0\nfor i in range(len(a)-1):\n temp += a[-i-1]\n sum_ += temp * a[-i-2]\n\nprint(sum_%(10**9 + 7))']
['Runtime Error', 'Accepted']
['s585087564', 's754771391']
[9084.0, 31388.0]
[29.0, 145.0]
[115, 169]
p02572
u219831209
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 = 0\nSum = 0\nfor i in range(n):\n s = (s+a[i]) % mod\nfor i in range(n):\n Sum = (Sum+a[i]*(mod+s-a[i])) % mod\nprint(int(Sum/2)+1)\n', 'n = int(input())\na = list(map(int, input().split()))\nmod = 10 ** 9 + 7\ns = 0\nSum = 0\nfor i in range(n):\n s = s+a[i]\nfor i in range(n):\n Sum = Sum+a[i]*(s-a[i])\nprint(int(Sum/2) % 10**9+7)\n', 'n = int(input())\na = list(map(int, input().split()))\nmod = 10 ** 9 + 7\ns = 0\nSum = 0\nfor i in range(n):\n s = s+a[i]\nfor i in range(n):\n Sum = Sum+a[i]*(s-a[i])\nprint(int(Sum/2) % 10**9+7)\n', 'n = int(input())\na = list(map(int, input().split()))\nmod = 10 ** 9 + 7\ns = 0\nSum = 0\nfor i in range(n):\n s = (s+a[i]) % mod\nfor i in range(n):\n Sum = (Sum+a[i]*(mod+s-a[i])) % mod\nprint(Sum/2)\n', 'n = int(input())\na = list(map(int, input().split()))\nmod = 10 ** 9 + 7\ns = sum(a)\nans = 0\nfor i in a[:n - 1]:\n s -= i\n ans += s * i\n ans %= 10 ** 9 + 7\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s150420533', 's377262190', 's665734532', 's959238333', 's286329177']
[31484.0, 31336.0, 31552.0, 31544.0, 31600.0]
[178.0, 138.0, 138.0, 173.0, 131.0]
[206, 194, 194, 199, 172]
p02572
u221149873
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())\nAs = list(map(int,input().split()))\n\nout = (sum(As)**2 - sum([a**2 for a in As]))/2\nprint(out % (10**9+7))', 'N = int(input())\nAs = list(map(int,input().split()))\n\nout = (sum(As)**2 - sum([a**2 for a in As]))//2\nprint(out % (10**9+7))']
['Wrong Answer', 'Accepted']
['s013037649', 's367247105']
[31444.0, 31484.0]
[134.0, 124.0]
[123, 124]
p02572
u224392054
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 math\nfrom fractions import Fraction as frac\n\nMOD = 1e9 + 7\n\ndef solve(case_no):\n n = int(input())\n a = list(map(int, input().split()))\n ps = [a[0]]\n for i in range(1, n):\n ps.append(ps[i - 1] + a[i])\n ans = 0\n for i in range(n - 2, -1, -1):\n ans += a[i + 1] * ps[i]\n ans %= MOD\n print(ans)\n\nt = 1\n# t = int(input())\nfor i in range(1, t + 1):\n solve(i)\n', 'import math\nfrom fractions import Fraction as frac\n\nMOD = 1000000007\n\ndef solve(case_no):\n n = int(input())\n a = list(map(int, input().split()))\n ps = [a[0]]\n for i in range(1, n):\n ps.append(ps[i - 1] + a[i])\n ans = 0\n for i in range(n - 2, -1, -1):\n ans += a[i + 1] * ps[i]\n ans %= MOD\n print(int(ans))\n\nt = 1\n# t = int(input())\nfor i in range(1, t + 1):\n solve(i)\n']
['Wrong Answer', 'Accepted']
['s657356941', 's421744563']
[32968.0, 32816.0]
[190.0, 167.0]
[404, 412]
p02572
u239091426
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()))\nleft = 0\nright = 0\nfor i in range(n):\n left += a[i]\n left %= (10**9+7)\nfor j in range(n):\n right += a[j]\n right %= (10**9+7)\nc = (left*right)%(10**9+7)\nl = [(k**2)%(10**9+7) for k in a]\nprint(((c+(10**9+7)-sum(l))**(10**9+5))%(10**9+7))', 'n = int(input())\na = list(map(int, input().split()))\nleft = 0\nright = 0\nfor i in range(n):\n left += a[i]\n left %= (10**9+7)\nfor j in range(n):\n right += a[j]\n right %= (10**9+7)\nc = (left*right)%(10**9+7)\nl = [(k**2)%(10**9+7) for k in a]\nprint(((c+(10**9+7)-sum(l)%(10**9+7))*pow(2, 10**9+5, 10**9+7))%(10**9+7))']
['Time Limit Exceeded', 'Accepted']
['s935402289', 's764390949']
[36384.0, 31448.0]
[2207.0, 194.0]
[293, 317]
p02572
u239368018
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\nmod = 1000000007\n\nans = 0\ntmp1, tmp2 = 0, 0\n\nfor m in A:\n tmp1 = (tmp1+m) %mod\n tmp2 = (tmp2+m*m%mod)%mod\n \nans = ((tmp1*tmp1)%mod-tmp2)%mod\n\nif ans%2 ==0:\n ans = ans/2\nelse:\n ans =(ans+mod)/2\n\nprint(float(ans))', 'n = int(input())\nA = map(int,input().split())\n\nmod = 1000000007\n\nans = 0\ntmp1, tmp2 = 0, 0\n\nfor m in A:\n tmp1 = (tmp1+m) %mod\n tmp2 = (tmp2+m*m%mod)%mod\n \nans = ((tmp1*tmp1)%mod-tmp2)%mod\n\nif ans%2 ==0:\n ans = ans/2\nelse:\n ans =(ans+mod)/2\n\nprint(int(ans))']
['Wrong Answer', 'Accepted']
['s198327670', 's684827594']
[25216.0, 25056.0]
[140.0, 143.0]
[263, 261]
p02572
u240630407
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\n# import math\n# import sys\n\nimport numpy as np\n\nN = int(input())\n# S = input()\n# n, *a = map(int, open(0))\n# N, M = map(int, input().split())\nA = list(map(int, input().split()))\n# B = list(map(int, input().split()))\n# tree = [[] for _ in range(N + 1)]\n# B_C = [list(map(int,input().split())) for _ in range(M)]\n# S = input()\n\n\n# all_cases = list(itertools.permutations(P))\n# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))\n# itertools.product((0,1), repeat=n)\n\nA = np.array(A)\ncum_A = np.cumsum(A)\n# cum_A = np.insert(cum_A, 0, 0)\n\n\n# for l in tree[s]:\n\n\n# dfs(tree, l[0])\n# dfs(tree, 1)\n\n\n# arr = []\n# temp = n\n\n# if temp%i==0:\n# cnt=0\n# while temp%i==0:\n# cnt+=1\n# temp //= i\n# arr.append([i, cnt])\n# if temp!=1:\n# arr.append([temp, 1])\n# if arr==[]:\n# arr.append([n, 1])\n# return arr\n\nsum_A = sum(A)\n\ntot = 0\nfor i in range(N):\n tot += A[i] * (sum_A - A[i])\n \nprint(tot % 1000000007)', '# import itertools\n# import math\n# import sys\n\nimport numpy as np\n\nN = int(input())\n# S = input()\n# n, *a = map(int, open(0))\n# N, M = map(int, input().split())\nA = list(map(int, input().split()))\n# B = list(map(int, input().split()))\n# tree = [[] for _ in range(N + 1)]\n# B_C = [list(map(int,input().split())) for _ in range(M)]\n# S = input()\n\n\n# all_cases = list(itertools.permutations(P))\n# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))\n# itertools.product((0,1), repeat=n)\n\nsum_A = sum(A)\nA = np.array(A)\n\ncum_A = np.cumsum(A)\n# cum_A = np.insert(cum_A, 0, 0)\n\n\n# for l in tree[s]:\n\n\n# dfs(tree, l[0])\n# dfs(tree, 1)\n\n\n# arr = []\n# temp = n\n\n# if temp%i==0:\n# cnt=0\n# while temp%i==0:\n# cnt+=1\n# temp //= i\n# arr.append([i, cnt])\n# if temp!=1:\n# arr.append([temp, 1])\n# if arr==[]:\n# arr.append([n, 1])\n# return arr\n\n\n\ntot = 0\nfor i in range(N):\n tot += int(A[i]) * (sum_A - int(cum_A[i]))\n \nprint(tot % 1000000007)']
['Wrong Answer', 'Accepted']
['s769979130', 's365939057']
[49964.0, 50256.0]
[508.0, 290.0]
[1311, 1327]
p02572
u243312682
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\ndef main():\n n = int(input())\n A_ = [int(x) for x in input().split()]\n A = [a for a in A_ if a != 0]\n N = len(A)\n\n mod = 10**9+7\n PR = 2\n order = [1]\n x = PR\n while x != 1:\n order.append(x)\n x *= PR\n x %= mod\n\n order_l = len(order)\n where = np.zeros(mod, int)\n for i in range(order_l):\n where[order[i]] = i\n prevCnt = np.zeros(mod, int)\n resCnt = np.zeros(mod, int)\n for n in range(N):\n if A[n] != 0:\n prevCnt[where[A[n]]] += 1\n resCnt[(A[n] * A[n]) % mod ] -= 1\n N_=1\n while N_ < 2*len(prevCnt): N_ *= 2\n nf = np.zeros(N_,int)\n nf[:len(prevCnt)]=prevCnt\n nf=np.fft.rfft(nf)\n fftRes = np.rint( np.fft.irfft(nf*nf))\n for r in range(len(fftRes)):\n if fftRes[r] != 0:\n resCnt[order[r % order_l]] += fftRes[r]\n ans = 0\n for p in range(mod):\n if resCnt[p] != 0:\n ans += (resCnt[p] // 2) * p\n print(ans)\n\nif __name__ == '__main__':\n main()", "def main():\n n = int(input())\n A = [int(x) for x in input().split()]\n mod = 10**9+7\n \n a_cum = [0] * (n+1)\n for i in range(n):\n a_cum[i + 1] = a_cum[i] + A[i]\n ans = 0\n for i in range(len(A)-1):\n ans += A[i] * (a_cum[n] - a_cum[i+1])\n ans %= mod\n print(ans)\n\nif __name__ == '__main__':\n main()\n"]
['Time Limit Exceeded', 'Accepted']
['s964403908', 's157950679']
[592028.0, 31620.0]
[2229.0, 142.0]
[1035, 357]
p02572
u244466744
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 = 0\n\nfor i in range(N):\n sum_a += A[i] \n\nfor i in range(N):\n sum_a -= A[i]\n sum += A[i] * sum_a\n ans = sum % (10**9 + 7)\n\nprint(ans)\n', 'N = int(input())\nA = list(map(int, input().split()))\n\nsum = 0\n\nfor i in range(N - 1):\n for j in range(i , N):\n sum += A[i] * A[j]\n \nans = sum % (1.0e+9 + 7)\n\nprint(ans)\n', 'N = int(input())\nA = list(map(int, input().split()))\n\nsum = 0\n\nfor i in range(N - 1):\n for j in range(i + 1, N):\n sum += A[i] * A[j]\n \nans = sum % (1.0e+9 + 7)\n\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\nsum_a = 0\nsum = 0\n\nfor i in range(N):\n sum_a += A[i] \n\nfor i in range(N):\n sum_a -= A[i]\n sum += A[i] * sum_a\n ans = sum % (10**9 + 7)\n\nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s103789863', 's111565208', 's818369484', 's006403706']
[31420.0, 31632.0, 31680.0, 31552.0]
[67.0, 2206.0, 2206.0, 166.0]
[194, 176, 178, 204]
p02572
u245375581
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).
['#!/usr/bin/env python3\n\nn=int(input()) #->n=5\na=list(map(int,input().split())) #->nl=[1,2,-,n]\n\ntemp = 0\nfor i in range(n-1):\n for j in range(i+1,n):\n temp = temp + a[j]\n temp = temp*a[i]\n temp = temp % (10**9+7)\n\nprint(temp)\n\n', '#!/usr/bin/env python3\n\nn=int(input()) #->n=5\na=list(map(int,input().split())) #->nl=[1,2,-,n]\nmod=int(1e9+7)\n\n\npre=[0]*n\npre[0]=a[0]\nfor i in range(1,n): pre[i]=pre[i-1]+a[i]\nans=0\nfor i in range(1,n): ans=(ans+(a[i-1]*(pre[n-1]-pre[i-1]))%mod)%mod\nprint(ans)\n\n']
['Wrong Answer', 'Accepted']
['s804891572', 's556677464']
[31400.0, 31464.0]
[2206.0, 202.0]
[245, 278]
p02572
u247211039
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=7+10**9\nans=0\nfor i in range(len(A)-1):\n for j in range(i+1,len(A)):\n print(A[i],A[j])\n ai= A[i] % MOD\n aj=A[j] % MOD\n ans = ans +ai*aj % MOD\nprint(ans%MOD)', 'N=int(input())\nA=list(map(int, input().split()))\n\nMOD=7+10**9\nSUM=sum(A)\nans=0\n\nfor i in range(N-1):\n SUM-=A[i]\n ans += A[i]*SUM %MOD\nprint(ans %MOD)']
['Wrong Answer', 'Accepted']
['s164401089', 's303740604']
[63520.0, 31752.0]
[2282.0, 142.0]
[240, 155]
p02572
u250944591
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=0\nfor i in range(n-1):\n for j in range(i+1,n):\n b=(b+i*j)%(10^9+7)\nprint(b)\n', 'n=int(input())\na=list(map(int,input().split()))\nb=sum(a)%(10^9+7)\nfor i in range(len(a)):\n a[i]=(a[i]%(10^9+7))*b\nprint(sum(a))', 'n=int(input())\na=list(map(int,input().split()))\nb=sum(a)\nl=[]\nfor i in range(len(a)-1):\n b-=a[i]\n l.append(a[i]*b)\nprint(sum(l)%(1000000007))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s232325112', 's969450982', 's955767688']
[31652.0, 31400.0, 31428.0]
[2206.0, 115.0, 148.0]
[130, 128, 144]
p02572
u251075661
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\n\nn = int(input())\naaa = list(map(int, input().split()))\n\nresult = 0\nfor aa in itertools.combinations(aaa, 2):\n result += aa[0] * aa[1]\n \nprint(result % 10 ** 9 + 7)', 'n = int(input())\naaa = list(map(int, input().split()))\n\nsum_a = 0\nsum_aa = 0\nfor a in aaa:\n sum_a += a\n sum_aa += a ** 2\n \nprint(((sum_a ** 2 - sum_aa) // 2) % (10 ** 9 + 7))']
['Wrong Answer', 'Accepted']
['s186697128', 's715378882']
[31236.0, 31576.0]
[2206.0, 166.0]
[183, 177]
p02572
u260370057
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()))\ncount = 0\nsu = sum[a]\nfor i in range(n-1):\n\tsu -= a[i]\n\tcount += a[i]*su\nprint(count%(10**9+7))', 'n = int(input())\na = list(map(int,input().split()))\ncount = 0\nsu = sum(a)\nfor i in range(n-1):\n\tsu -= a[i]\n\tcount += a[i]*su\nprint(count%(10**9+7))']
['Runtime Error', 'Accepted']
['s475801125', 's609804149']
[31384.0, 31536.0]
[76.0, 130.0]
[147, 147]
p02572
u264395947
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).
['A = list(map(int, input().split()))\n\nB = [0]*N\n\nnum = 0\nfor i in reversed(range(N)):\n B[i] = A[i] + num\n num = B[i]\n \nans = 0\nfor i in range(N-1):\n ans += A[i]*B[i+1] \n\nprint(ans%1000000007)', 'N = int(input())\nA = list(map(int, input().split()))\n\nB = [0]*N\n\nnum = 0\nfor i in reversed(range(N)):\n B[i] = A[i] + num\n num = B[i]\n \nans = 0\nfor i in range(N-1):\n ans += A[i]*B[i+1] %1000000007\n\nprint(ans%1000000007)']
['Runtime Error', 'Accepted']
['s243186014', 's260573359']
[9020.0, 31488.0]
[27.0, 181.0]
[202, 230]
p02572
u282376189
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 = 1000000000 + 7\nadd = 0\nfor i in range(N):\n tmp = sum(A[i+1:N])\n add += tmp * A[i]\nprint(add%mod', 'N = int(input())\nA = list(map(int,input().split()))\nmod = 1000000000 + 7\nadd = 0\ntmp = sum(A)\nfor i in range(N):\n tmp -= A[i]\n add += tmp * A[i]\nprint(add%mod)']
['Runtime Error', 'Accepted']
['s298983589', 's206240786']
[8972.0, 31524.0]
[26.0, 130.0]
[159, 165]
p02572
u285497176
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().strip().split()))\n\nm = 10 ** 9 + 7\ndef main():\n r = 0\n for nn in range(n):\n r += a[nn]\n print(r)\n return\n\nmain()\n', 'n = int(input())\na = list(map(int,input().strip().split()))\n\n\nm = 10 ** 9 + 7\ndef main():\n s = sum(a)\n ss = 0\n r = 0\n for nn in range(n):\n ss += a[nn]\n r += a[nn] * (s - ss)\n print(r % m)\n return\n\nmain()\n']
['Wrong Answer', 'Accepted']
['s597475814', 's787951416']
[31292.0, 31488.0]
[90.0, 123.0]
[174, 236]
p02572
u290866833
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()))\nS = sum(A)\n\nfor i in range(N-1):\n S -= A[i]\n ans += A[i] * S\n \n\nans = ans % (10 ** 9 +7) \n\nprint(ans)\n', 'N = int(input())\n\nA = list(map(int, input().split()))\nS = sum(A)\nans = 0\nfor i in range(N):\n S -= A[i]\n ans += A[i] * S\n \n\nans = ans % (10 ** 9 +7) \n\nprint(ans)']
['Runtime Error', 'Accepted']
['s680594898', 's098132892']
[31544.0, 31464.0]
[72.0, 127.0]
[173, 177]
p02572
u290887281
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 = list(map(int, input().split()))\nresult = 0\na_sum = sum(a)\nfor i in a_list:\n a_sum -= i\n result += i * a_sum\nprint(result % mod)', 'mod = 10 ** 9 + 7\nn = int(input())\na_list = list(map(int, input().split()))\nresult = 0\na_sum = sum(a)\nfor i in a_list:\n a_sum -= i\n result += i * a_sum\nprint(result % mod)', 'mod = 10 ** 9 + 7\nn = int(input())\na_list = list(map(int, input().split()))\nresult = 0\na_sum = sum(a_list)\nfor i in a_list:\n a_sum -= i\n result += i * a_sum\nprint(result % mod)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s509970638', 's675948032', 's029053784']
[31556.0, 31388.0, 31472.0]
[78.0, 80.0, 117.0]
[177, 177, 182]
p02572
u303711501
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()))\ndef p(val):\n print(val)\n \nsho = 10**9 +7\na1 = sum(a)**2\nb1 = list(map(lambda y:y**2,a))\nb2=sum(b1)\nresult = ((a1-b2)/2)% sho\np(result)', 'n=int(input())\na = list(map(int,input().split()))\ndef p(val):\n print(val)\n \nsho = 10**9 +7\na1 = sum(a)**2\nb1 = list(map(lambda y:y**2,a))\nb2=sum(b1)\nresult = ((a1-b2)//2)% sho\np(result)']
['Wrong Answer', 'Accepted']
['s299809451', 's109952427']
[31628.0, 31392.0]
[138.0, 128.0]
[187, 188]
p02572
u304058693
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\nimport itertools as it\n\nn = int(input())\na = list(map(int, input().split()))\n\ncombinations_lis = list(it.combinations(a, 2))\nprint(combinations_lis)\n\nsum = 0\nfor i in range(len(combinations_lis)):\n sum += combinations_lis[i][0] * combinations_lis[i][1]\nprint(sum % (10 ** 9 + 7))\n\n\n\n\n#print(sum)\n\n# ans = int(sum * np.prod(a))\n\n', '# import numpy as np\n# import itertools as it\n\nn = int(input())\na = list(map(int, input().split()))\n\nres = 0\nfor i in range(n):\n res += a[i] * a[i]\n\nans = sum(a) * sum(a)\nprint(((ans - res)//2) % (10 ** 9 + 7))\n\n\n\n\n\n#print(sum)\n\n# ans = int(sum * np.prod(a))\n\n']
['Wrong Answer', 'Accepted']
['s027907358', 's045362093']
[1943952.0, 31656.0]
[2276.0, 109.0]
[428, 341]
p02572
u304593245
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 functools\nimport operator\n\nN = int(input())\nA = list(map(int, input().split()))\nmod = 10**9+7\nans = 0\n\nfor i in range(2**len(A)):\\\n list2 = []\n for j in range(len(A)):\n if (i >> j) &1 == 1:\n list2.append(A[j])\n if len(list2) == 2:\n ans += list2[0]*list2[1]\n# print(ans)\n# print(list2)\n ans = ans%mod\nprint(ans)\n', 'import functools\nimport operator\n\nN = int(input())\nA = list(map(int, input().split()))\nmod = 10**9+7\nans = 0\nv = sum(A)\nfor i in range(N-1):\n v -= A[i]\n ans += A[i]*v\nprint(ans%mod)\n']
['Runtime Error', 'Accepted']
['s473308436', 's943322288']
[8988.0, 32216.0]
[24.0, 139.0]
[365, 188]
p02572
u309120194
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 \ns = 0\nfor i in range(N):\n s += A[i]\n s %= (10**9+7)\ns = s**2\ns %= (10**9+7)\n \nt = 0\nfor i in range(N):\n t += (A[i]**2 % (10**9+7))\nt %= (10**9+7)\n\nans = (s-t) % (10**9+7)\ntmp = (2**1000000005) % (10**9+7)\nans *= tmp\nans %= (10**9+7)\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\n\n\nmod = 10**9 + 7\ns = 0\nt = 0\nfor i in range(N):\n s += A[i]\n s %= mod\n t += (A[i]**2 % mod)\n t %= mod\ns = s**2 % mod\nans = (s - t) % mod\n\nans = (ans * 500000004) % mod\n\nprint(ans)']
['Time Limit Exceeded', 'Accepted']
['s963157052', 's135931475']
[244904.0, 31436.0]
[2213.0, 198.0]
[301, 359]
p02572
u322171361
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).
['input()\na = list(map(int, input().split()))\nc = 1000000007\nprint(((sum(a)**2-sum(map(lambda x: x**2, a)))/2)%c)', 'input()\na = list(map(int, input().split()))\nc = 1000000007\nprint(((sum(a)**2-sum(map(lambda x: x**2, a)))//2)%c)']
['Wrong Answer', 'Accepted']
['s529397129', 's065233257']
[31424.0, 31596.0]
[132.0, 119.0]
[111, 112]
p02572
u326278153
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 = 1000000007\nres = 0\n\nfor i in range(n - 1):\n for j in range(n - (i + 1)):\n print(a[i] , '*' , a[i + (j + 1)])\n res = (res + a[i] * a[i + (j + 1)] % mod) % mod\n\nprint(res)\n", 'n = int(input())\na = set(list(map(int, input().split())))\nmod = 1000000007\nres = 0\n\n\nfor i in range(n - 1):\n main = a.pop(0)\n res = (res + main * sum(a) % mod) % mod\nprint(res)', 'n = int(input())\na = list(map(int, input().split()))\nmod = 1000000007\nres = 0\na_sum = sum(a)\n\nfor i in range(n - 1):\n main = a[i]\n a_sum = a_sum - main\n res = (res + main * a_sum % mod) % mod\nprint(res)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s369540385', 's523390814', 's166995818']
[58908.0, 31612.0, 31592.0]
[2299.0, 107.0, 149.0]
[247, 183, 212]
p02572
u327498205
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()))\nsumm1 = 0\nanswer = 0\ntemp = 0\nsumm2 = 0\nsumm3 = 0\nfor i in range(N):\n summ1 += A[i]\nfor l in range(N):\n summ3 += A[l]\n summ2 += A[l]*(summ1-summ3)\n print(summ3)\n print(summ2)\nanswer = summ2 % 1000000007\nprint(answer)', 'N = int(input())\nA = list(map(int,input().split()))\nsumm1 = 0\nanswer = 0\ntemp = 0\nsumm2 = 0\nsumm3 = 0\nfor i in range(N):\n summ1 += A[i]\nfor l in range(N):\n summ3 += A[l]\n summ2 += A[l]*(summ1-summ3)\nanswer = summ2 % 1000000007\nprint(answer)']
['Wrong Answer', 'Accepted']
['s618608861', 's806314524']
[31544.0, 31624.0]
[387.0, 168.0]
[283, 249]
p02572
u329730886
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.asarray(input().split()).astype(np.int)\n\na = np.tile(A,(N, 1))\na = a * a.T\n\na_diag = np.diag(a).sum()\na = ((a.sum()-a_diag)/2)\n#print(a/10e9+7)\nprint(int(np.mod(a, 10**9+7)))', 'import numpy as np\n\nN = int(input())\nA = np.asarray(input().split()).astype(np.int)\nA_sq = np.square(A)\n\nprint(int(np.mod(((A.sum())*(A.sum())-A_sq.sum())/2, 10**9+7)))', 'import numpy as np\n\nN = int(input())\nA = np.asarray(input().split()).astype(np.int)\nA_sq = np.square(A)\nAns = np.mod(((A.sum())**2 - A_sq.sum()) / 2 ,(10**9+7)).astype(np.int)\nprint(Ans) ', 'import numpy as np\n\nN = int(input())\nA = np.asarray(input().split()).astype(np.int)\n\nans = 0\nfor i in range(N):\n pA = A[i] * A[i+1:]\n ans += pA.sum()\n\nprint(int(ans % (1e9+7)))', 'import numpy as np\n\nN = int(input())\nA = np.asarray(input().split()).astype(np.int)\nA_sq = np.square(A)\nAns = ((A.sum())**2 - A_sq.sum()) // 2 % (10**9+7)\nprint(Ans) ', 'import numpy as np\n \nN = int(input())\nA = np.asarray(input().split()).astype(np.int)\n \nans = 0\nfor i in range(N):\n pA = A[i] * A[i+1:].sum()\n ans += pA\n \nprint(int(ans % (10e9+7)))', 'N = int(input())\nA = list(map(int, input().split()))\nD = 1000000007\n\n\nans = 0\nB = [0] * (N + 1)\n\nfor i in range(N-1, -1, -1):\n print(i)\n B[i] = (B[i+1] + A[i]) % D\n\nfor i in range(0, N-1):\n ans += (A[i] * B[i+1]) % D\n\nprint(int(ans % D))', 'import numpy as np\nA = np.asarray(input().split()).astype(np.int)\n \nans = 0\nmod = 10**9 + 7\nfor i in range(N):\n pA = (A[i] % mod) * (A[i+1:].sum() % mod)\n ans += pA\n \nprint(int(ans % mod))', 'import numpy as np\nN = int(input())\nA = np.asarray(input().split()).astype(np.int)\n \nans = 0\nmod = 10**9 + 7\nfor i in range(N):\n pA = (A[i] % mod) * (A[i+1:].sum() % mod)\n ans += pA\n \nprint(int(ans % mod))', 'A = np.asarray(input().split()).astype(np.int)\n \nans = 0\nmod = 10**9 + 7\nfor i in range(N):\n pA = (A[i] % mod) * (A[i+1:].sum() % mod)\n ans += pA\n \nprint(int(ans % mod))', 'N = int(input())\nA = list(map(int, input().split()))\nD = 1000000007\n\n\nans = 0\nB = [0] * (N + 1)\n\nfor i in range(N-1, -1, -1):\n B[i] = (B[i+1] + A[i]) % D\n\nfor i in range(0, N-1):\n ans += (A[i] * B[i+1]) % D\n\nprint(int(ans % D))']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s177532843', 's213928731', 's316578428', 's334908612', 's399777292', 's573230116', 's591979657', 's648025329', 's874628154', 's979569793', 's134187642']
[1822420.0, 59104.0, 59404.0, 59504.0, 59504.0, 59236.0, 31612.0, 26952.0, 59380.0, 9060.0, 31520.0]
[1569.0, 219.0, 232.0, 2207.0, 241.0, 2206.0, 249.0, 119.0, 2207.0, 22.0, 187.0]
[323, 168, 187, 182, 166, 186, 246, 194, 211, 175, 233]
p02572
u332135290
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\n\nN = int(input())\nA = list(int(x) for x in input().split())\n\nmod = 10**9+7\nans = 0\nsumm = 0\n\nfor i in range(N):\n summ += A[i]\n summ %= mod\n\nfor i in range(N):\n summ -= A[i]\n print(summ)\n if summ < 0:\n sum += mod\n ans += A[i] * summ\n print(ans)\n ans %= mod\n print(ans)\nprint(ans)\n', 'import itertools\n\nN = int(input())\nA = list(int(x) for x in input().split())\n\nmod = 10**9+7\n\nsum_ = 0\nans = 0\n\nfor i in range(N):\n ans += sum_ * A[i]\n ans %= mod\n sum_ += A[i]\n sum_ %= mod\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s881907730', 's889004270']
[31648.0, 31628.0]
[302.0, 164.0]
[330, 213]
p02572
u337573893
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 \nc = 0\n \nfor i in range(N-2):\n for j in range(int(i)+1, N):\n d = A[i] \n e = A[j] \n c = (c + d*e) % (10**9+7)\n \n \n \nc = c % (10**9+7)\n \nprint(c)', 'N = int(input())\n\nA = list(map(int, input().split()))\n\nS = 0\nfor i in range(N):\n S += A[i]\n\nc = S\nd = 0\nfor j in range(N):\n c -= A[j]\n c = c%(10**9+7)\n d += A[j]*c\n d = d%(10**9+7)\n \nprint(d)']
['Wrong Answer', 'Accepted']
['s044212010', 's384488749']
[31616.0, 31548.0]
[2206.0, 165.0]
[215, 197]
p02572
u344813796
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()))\nAr=list(itertools.accumulate(A))\nans=0\nfor i in range(n-1):\n ans+=A[i]*(Ar[n-1]-Ar[i])\n ans%=10**9+7\nprint(ans)', 'import itertools\n#h,w=map(int,input().split())\n#S=[list(map(int,input().split())) for _ in range(h)]\nn=int(input())\nA=list(map(int,input().split()))\nAr=list(itertools.accumulate(A))\nans=0\nfor i in range(n-1):\n ans+=A[i]*(Ar[n-1]-Ar[i])\n ans%=10**9+7\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s050429401', 's198433331']
[31516.0, 31196.0]
[72.0, 156.0]
[165, 267]
p02572
u347502437
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).
['ut())\nA = list(input().split())\nB = [int(a) for a in A]\nx = 10**9+7\nsummation = sum((B[i] * (sum(B[j] for j in range(i+1,N)) % x)) % x for i in range(N-1)) % x\nprint(summation)', 'N = int(input())\nA = list(input().split())\nB = [int(a) for a in A]\nx = 10**9+7\nsummation1 = sum(B) ** 2\nsummation2 = sum(b ** 2 for b in B)\nsummation = ((summation1 - summation2) // 2) % x\nprint(summation)\n']
['Runtime Error', 'Accepted']
['s544464601', 's159466704']
[8996.0, 32588.0]
[22.0, 132.0]
[176, 206]