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 |
|---|---|---|---|---|---|---|---|---|---|---|
p02730 | u942353650 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ["s = input()\na = s[:len(s)/2 -1]\nb = s[len(s)+3/2-1:]\nflag = 0\nif s == s[::-1]:\n if a == a[::-1]:\n if b == b[::-1]:\n flag = 1\n\nif flag:\n print('Yes')\nelse:\n print('No')", "\ns = input()\na = s[:int(len(s)/2)]\nb = s[:-int(len(s)/2 + 1)]\nflag = 0\nif s == s[::-1]:\n if a == a[::-1]:\n if b == b[::-1]:\n flag = 1\n\nif flag:\n print('Yes')\nelse:\n print('No')"] | ['Runtime Error', 'Accepted'] | ['s585448259', 's861029845'] | [3060.0, 3060.0] | [18.0, 17.0] | [195, 204] |
p02730 | u942356554 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['s1=input()\nl=len(s1)\nh=(l-1)//2\nk1=s1[:h]\nk2=s1[h+1:]\nif k1==k2:\n a=(l-1)//2\n s3=s1[:a]\n if a%2!=0:\n h2=(a-1)//2\n j1=s3[:h2]\n j2=s3[h2+1:]\n if j1==j2:\n b=(l+3)/2\n b2=l-b+1\n s4=s1[:b2]\n h3=(b2-1)//2\n f1=s3[:h3]\n f2=s3[h3+1:]\n if f1==f2:\n print("Yes")\n else:\n print("No")\n else:\n print("No")\n else:\n h2=a/2\n j1=s3[:h2]\n j2=s3[h2+1:]\n if j1==j2:\n b=(l+3)/2\n b2=l-b+1\n s4=s1[:b2]\n h3=(b2-1)//2\n f1=s3[:h3]\n f2=s3[h3+1:]\n if f1==f2:\n print("Yes")\n else:\n print("No")\n else:\n print("No")\nelse:\n print("No")', 's = list(input())\nn = len(s)\nflag = 0\nfor i in range(n//2):\n if s[i] != s[n-i-1]:\n flag = 1\nif flag == 0:\n s2 = s[:(n-1)//2]\n n2 = len(s2)\n for i in range(n2//2):\n if s2[i] != s2[n2-i-1]:\n flag = 1\n#print(n, n2, s, s2)\nif flag == 0:\n if flag == 0:\n s2 = s[(n+3)//2-1:]\n n2 = len(s2)\n for i in range(n2//2):\n if s2[i] != s2[n2-i-1]:\n flag = 1\n#print(s2)\nif flag == 0:\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Accepted'] | ['s127646287', 's446026155'] | [3064.0, 9184.0] | [18.0, 27.0] | [843, 480] |
p02730 | u944886577 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['s=str(input())\nn=len(s)\nnew_n1=(n-1)/2\nnew_s1=s[:new_n]\n\nnew_n2=(n+3)/2\nnew_s2=s[new_nw:]\n\nfor i in range(new_n1):\n if new_s1[i]!=new_s1[n-i+1]:\n print("No")\n exit()\n else:\n pass\n\nfor j in range(new_n2):\n if new_s2[j]!=new_s2[n-j+1]:\n prin("No")\n else\n print("Yes")\n \n\n \n', 's=str(input())\nn=len(s)\n\nfor i in range(0,n):\n if s[i]!=s[-i-1]:\n print("No")\n exit()\n\nnew_n1=int((n-1)/2)\nnew_s1=s[:new_n1]\n\nnew_n2=int((n+3)/2)\nnew_s2=s[new_n2-1:]\nfor i in range(0,len(new_s1)):\n if new_s1[i]!=new_s1[-i-1]:\n print("No")\n exit()\nelse:\n pass\nfor i in range(0,len(new_s2)):\n if new_s2[i]!=new_s2[-i-1]:\n print("No")\n exit()\nelse:\n print("Yes") '] | ['Runtime Error', 'Accepted'] | ['s522175301', 's348016094'] | [9000.0, 9088.0] | [24.0, 29.0] | [304, 380] |
p02730 | u947327691 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['s=str(input())\n\ncnt=0\n\nnum=len(s)//2\n\na=s[:num]\nb=s[num+1:]\nprint(a)\nprint(b)\n\nnum2=len(a)//2\nc=a[:num2]\nd=a[num2+1:]\n\nprint(c)\nprint(d)\n\nnum3=int((len(s)+3)/2-1)\ns1=s[num3:]\nnum4=len(s1)//2\ne=s1[:num4]\nf=s1[num4+1:]\n\nprint(e)\nprint(f)\n\nif a==b[::-1]:\n cnt +=1\n\nif c==d[::-1]:\n cnt +=1\n\nif e==f[::-1]:\n cnt +=1\n\nif cnt==3:\n print("Yes")\nelse:\n print("No")', 's=str(input())\n\ncnt=0\n\nnum=len(s)//2\n\na=s[:num]\nb=s[num+1:]\nprint(a)\nprint(b)\n\nnum2=len(a)//2\nif len(a)%2 ==1:\n c=a[:num2]\n d=a[num2+1:]\nelse:\n c=a[:num2]\n d=a[num2:]\n\nprint(c)\nprint(d)\n\nnum3=int((len(s)+3)/2-1)\ns1=s[num3:]\nnum4=len(s1)//2\nif len(s1)%2==1:\n e=s1[:num4]\n f=s1[num4+1:]\nelse:\n e=s1[:num4]\n f=s1[num4:]\n\n\nprint(e)\nprint(f)\n\nif a==b[::-1]:\n cnt +=1\n\nif c==d[::-1]:\n cnt +=1\n\nif e==f[::-1]:\n cnt +=1\n\nif cnt==3:\n print("Yes")\nelse:\n print("No")', 's=str(input())\n\ncnt=0\n\nnum=len(s)//2\n\na=s[:num]\nb=s[num+1:]\n\nnum2=len(a)//2\nif len(a)%2 ==1:\n c=a[:num2]\n d=a[num2+1:]\nelse:\n c=a[:num2]\n d=a[num2:]\n\n\nnum3=int((len(s)+3)/2-1)\ns1=s[num3:]\nnum4=len(s1)//2\nif len(s1)%2==1:\n e=s1[:num4]\n f=s1[num4+1:]\nelse:\n e=s1[:num4]\n f=s1[num4:]\n\n\nif a==b[::-1]:\n cnt +=1\n\nif c==d[::-1]:\n cnt +=1\n\nif e==f[::-1]:\n cnt +=1\n\nif cnt==3:\n print("Yes")\nelse:\n print("No")'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s194620924', 's904571506', 's414817794'] | [3064.0, 3064.0, 3064.0] | [17.0, 17.0, 18.0] | [370, 495, 440] |
p02730 | u949234226 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['\nimport math\ncharacter = input()\nre_character = character[::-1]\n \nnum = int(len(character))\nmiddle = math.ceil(num/2.0)\nprint(middle)\n#print(character[0:middle-1], re_character[middle:num])\n#print(character[0:num], re_character[0:num])\n#print (character[middle:num], re_character[0:middle-1])\n\nif (character[middle:num] == re_character[0:middle-1]):\n if (character[0:num] == re_character[0:num]):\n print("Yes")\n else:\n print("No")\nelse:\n print("No")\n', '\nimport math\ncharacter = input()\nre_character = character[::-1]\n \nnum = int(len(character))\nmiddle = math.ceil(num/2.0)\n#print(middle)\n#print(character[0:middle-1], re_character[middle:num])\n#print(character[0:num], re_character[0:num])\n#print (character[middle:num], re_character[0:middle-1])\n\nif (character[middle:num] == re_character[0:middle-1]):\n if (character[0:num] == re_character[0:num]):\n print("Yes")\n else:\n print("No")\nelse:\n print("No")\n'] | ['Wrong Answer', 'Accepted'] | ['s048450532', 's470775995'] | [3060.0, 3060.0] | [17.0, 20.0] | [478, 479] |
p02730 | u953499988 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['def kaibun(s):\n n=len(s)\n a=True\n if n%2==0:\n for i in range(n/2):\n if s[i]!=s[n-1-i]:\n a=False\n else:\n for i in range((n-1)/2):\n if s[i]!=s[n-1-i]:\n a=False\n return a\nS=input()\nN=len(S)\nif kaibun(S)==True and kaibun(S[0:(N-1)/2])==True and kaibun(S[(N+3)/2-1:N])==True:\n print("Yes")\nelse:\n print("No")', 'def kaibun(s):\n n=len(s)\n a=True\n if n%2==0:\n for i in range(n/2):\n if s[i]!=s[n-1-i]:\n a=False\n else:\n for i in range((n-1)/2):\n if s[i]!=s[n-1-i]:\n a=False\n return a\nif kaibun(S)==True and kaibun(S[0:(len(S)-1)/2])==True and kaibun(S[(len(S)+3)/2-1:len(S)])==True:\n return "Yes"\nelse:\n return "No"', 'def kaibun(s):\n n=len(s)\n a=True\n if n%2==0:\n for i in range(n//2):\n if s[i]!=s[n-1-i]:\n a=False\n else:\n for i in range((n-1)//2):\n if s[i]!=s[n-1-i]:\n a=False\n return a\nS=input()\nN=len(S)\nif kaibun(S)==True and kaibun(S[0:(N-1)//2])==True and kaibun(S[(N+3)//2-1:N])==True:\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s269726923', 's841757035', 's220031252'] | [3064.0, 3064.0, 3064.0] | [17.0, 17.0, 17.0] | [340, 336, 344] |
p02730 | u957098479 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ["S = input()\nN = len(S)\n\nans = 'No'\nif S == S[::-1]:\n if S[:N//2] == S[N//2::-1]:\n ans = 'Yes'\n\nprint(ans)", "S = input()\nN = len(S)\n\nans = 'No'\nif S == S[::-1]:\n if S[:N//2] == S[(N//2)-1::-1]:\n ans = 'Yes'\n\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s019281494', 's825196396'] | [2940.0, 2940.0] | [17.0, 17.0] | [115, 119] |
p02730 | u958053648 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ["S=input()\na=S[:int((len(S)-1)/2)]\nb=S[int((len(S)+3)/2)-1:]\nc=''.join(list(reversed(a)))\nd=''.join(list(reversed(b)))\n\nprint(a,b,c,d)\nif a==c and b==d:\n\tprint('Yes')\nelse:\n\tprint('No')", "S=input()\ns=''.join(list(reversed(S)))\na=S[:int((len(S)-1)/2)]\nb=S[int((len(S)+3)/2)-1:]\nc=''.join(list(reversed(a)))\nd=''.join(list(reversed(b)))\nif S==s and a==c and b==d:\n\tprint('Yes')\nelse:\n\tprint('No')"] | ['Wrong Answer', 'Accepted'] | ['s024432718', 's136934173'] | [3064.0, 3064.0] | [17.0, 17.0] | [184, 206] |
p02730 | u962423738 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['s=input()\nn=s\n \nif s==reversed(s) and s[0:(n-1)//2]==reverses(s[0:(n-1)//2]) and s[((n+3)//2)-1:n]==reversed(s[((n+3)//2)-1:n]):\nprint("Yes")\n \nelse:\n\tprint("No")', 's=input()\nn=len(s)\n \nif s==reversed(s) and s[0:(n-1)//2]==reverses(s[0:(n-1)//2]) and s[((n+3)//2)-1:n]==reversed(s[((n+3)//2)-1:n]):\n\tprint("Yes")\n\nelse:\n\tprint("No")', 's=input()\nn=s\n\nif s==reversed(s) and s[0:(n-1)//2]==reverses(s[0:(n-1)//2]) and s[((n+3)//2)-1:n] and reversed(s[((n+3)//2)-1:n]):\nprint("Yes")\n\nelse:\n\tprint("No")', 's=input()\nn=len(s)\n \nif s==s[::-1] and s[0:(n-1)//2]==s[0:(n-1)//2:-1] and s[((n+3)//2)-1:n]==s[((n+3)//2)-1:n:-1]:\n\tprint("Yes")\n\nelse:\n\tprint("No")', 's=input()\nn=len(s)\n \nif s==reversed(s) and s[0:(n-1)//2]==reverses(s[0:(n-1)//2]) and s[((n+3)//2)-1:n]==reversed(s[((n+3)//2)-1:n]):\n\tprint("Yes")\n \nelse:\n\tprint("No")', 's=input()\nn=s\n \nif s==reversed(s) and s[0:(n-1)//2]==reverses(s[0:(n-1)//2]) and s[((n+3)//2)-1:n]==reversed(s[((n+3)//2)-1:n]):\n\tprint("Yes")\n \nelse:\n\tprint("No")', "s = input()\nn = len(s)\nsl = s[:n//2]\nsr = s[n//2+1:]\nif sl == sr and sr == sr[::-1]:\n print('Yes')\nelse:\n print('No')"] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s069441953', 's229471067', 's361406946', 's471633282', 's623553775', 's811539223', 's885986919'] | [8976.0, 9040.0, 8976.0, 8952.0, 9080.0, 9112.0, 8896.0] | [25.0, 30.0, 27.0, 30.0, 32.0, 28.0, 28.0] | [162, 167, 163, 149, 168, 163, 124] |
p02730 | u964521959 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['\nS = input()\n\nS_list = list(S)\n\ncounter = 0\ncounter_ = 0\ncounter__ = 0\n\n\nfor i in range(int(len(S_list)/2)):\n if(S_list[i]==S_list[i+int(len(S_list)/2)+1]):\n counter = counter + 1\n else:\n counter = counter\nif(counter != int(len(S_list)/2)):\n print("No")\n \n \nelse:\n for i in range(int(len(S_list)/4)):\n if(S_list[i]==S_list[i+int(len(S_list)/4)+1]):\n counter_ = counter_ + 1\n else:\n counter_ = counter_\n if(counter_ != int(len(S_list)/4)):\n print("No")\n \n \n else:\n for i in range(int(len(S_list)/4)):\n print(i+int(len(S_list)/2)+1,S_list[i+int(len(S_list)/2)+1],i+int(len(S_list)/2)+1+int(len(S_list)/4),S_list[i+int(len(S_list)/2)+1+int(len(S_list)/4)+1])\n if(S_list[i+int(len(S_list)/2)+1]==S_list[i+int(len(S_list)/2)+1+int(len(S_list)/4)+1]):\n counter__ = counter__ + 1\n else:\n counter__ = counter__\n if(counter__ != int(len(S_list)/4)):\n print("No")\n else:\n print("Yes")', '\nS = input()\n\nS_list = list(S)\n\ncounter = 0\nfor i in range(int(len(S_list)/2)):\n #print(S_list[i],S_list[i+int(len(S_list)/2)+1])\n if(S_list[i]==S_list[i+int(len(S_list)/2)+1]):\n counter = counter + 1\n else:\n counter = counter\n \n#print(counter,int(len(S_list)/2))\nif(counter < int(len(S_list)/2)):\n print("NO")\n \nfor i in range(int(len(S_list)/4)):\n if(S_list[i]==S_list[i+int(len(S_list)/4)+1]):\n #print(S_list[i],S_list[i+int(len(S_list)/4)+1])\n #print((S_list[i+int(len(S_list)/2)+1],S_list[i+int(len(S_list)/2)+int(len(S_list)/2)]))\n if(S_list[i+int(len(S_list)/2)+1]==S_list[i+int(len(S_list)/2)+int(len(S_list)/2)]):\n print("YES")', '\nS = input()\n\nS_list = list(S)\n\ncounter = 0\nfor i in range(int(len(S_list)/2)):\n if(S_list[i]==S_list[i+int(len(S_list)/2)+1]):\n counter = counter + 1\n else:\n counter = counter\n \nif(counter < int(len(S_list)/2)):\n print("NO")\n \ncounter_ = 0\ncounter__ = 0\nfor i in range(int(len(S_list)/4)):\n if(S_list[i]==S_list[i+int(len(S_list)/4)+1]):\n counter_ = counter_ + 1\n if(S_list[i+int(len(S_list)/2)+1]==S_list[i+int(len(S_list)/2)+int(len(S_list)/2)]):\n counter__ = counter__ + 1\n\nif((counter_ = int(len(S_list)/4))and(counter__ = int(len(S_list)/4))):\n print("Yes")', '\nS = input()\n\nS_list = list(S)\n\nS_list_reverse = list(reversed(S_list))\n\n\n#print(S_list_reverse)\n#print(S_list)\n\nif(S_list != S_list_reverse):\n print("No")\nelse:\n S_list_new = S_list\n del S_list_new[int(len(S_list)/2):]\n S_list_new_reverse = list(reversed(S_list_new))\n if(S_list_new != S_list_new_reverse):\n print("No")\n else:\n print("Yes")'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s076282887', 's761213838', 's865552339', 's351941641'] | [3064.0, 3064.0, 3064.0, 3060.0] | [18.0, 17.0, 17.0, 17.0] | [1127, 721, 645, 406] |
p02730 | u965723631 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['S = input()\nmessage = "No"\nif S == S[::-1]:\n\tindex = int((len(S)-1)/2)\n\ttest = S[:index]\n\tprint(test)\n\tif test == test[::-1]:\n\t\tindex = int((len(S)+3)/2)\n\t\ttest = S[index-1:]\n\t\tprint(test)\n\t\tif test == test[::-1]:\n\t\t\tmessage = "Yes"\nprint(message)\n', 'S = input()\nmessage = "No"\nif S == S[::-1]:\n\tindex = int(((len(S)-1)-1)/2)\n\tprint(index)\n\ttest = S[:index+1]\n\tprint(test)\n\tif test == test[::-1]:\n\t\tindex = int(((len(S)-1)+3)/2)\n\t\tprint(index)\n\t\ttest = S[index:]\n\t\tprint(test)\n\t\tif test == test[::-1]:\n\t\t\tmessage = "Yes"\nprint(message)\n', 'S = input()\nmessage = "No"\nif S == S[::-1]:\n\tindex = (len(S)-1)//2\n\ttest = S[:index]\n\tif test == test[::-1]:\n\t\tindex2 = (len(S)+3)//2\n\t\totest = S[index2-1:]\n\t\tif otest == otest[::-1]:\n\t\t\tmessage = "Yes"\nprint(message)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s157022238', 's288855508', 's496798467'] | [3060.0, 3064.0, 2940.0] | [18.0, 17.0, 17.0] | [248, 285, 218] |
p02730 | u966542724 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ["def kaibun(sl):\n for i in range(len(sl)):\n if sl[i] != sl[-1-i]:\n return 'No'\n break\n else:\n return 'Yes'\n\n\ns = input()\n\n\n\nsl = []\nout = 'Yes'\nslz = []\nslk = []\n\nfor i in range(len(s)):\n sl.append(s[i])\n\nfor i in range((len(s)-1) // 2):\n slz.append(s[i])\n\n\nfor i in range((len(s)+3)//2,len(s)):\n slk.append(s[i-1])\n\n\n\n \n \nout = kaibun(sl)\nout = kaibun(slz)\nout = kaibun(slk)\nprint(out)\n\n\n\n\n", "def kaibun(sl):\n for i in range(len(sl)):\n if sl[i] != sl[-1-i]:\n return 'No'\n break\n else:\n return 'Yes'\n\n\ns = input()\n\n\n\nsl = []\nout = 'Yes'\nslz = []\nslk = []\n\nfor i in range(len(s)):\n sl.append(s[i])\n\nfor i in range((len(s)-1) // 2):\n slz.append(s[i])\n\n\nfor i in range((len(s)+3)//2,len(s)):\n slk.append(s[i-1])\n\n\nf = 'Yes'\n \n \nif kaibun(sl) == 'No':\n\tf = 'No'\n\nif kaibun(slz) == 'No':\n\tf = 'No'\n\nif kaibun(slk) == 'No':\n\tf = 'No'\n\nprint(f)\n\n\n\n\n", "def kaibun(sl):\n\tf = 'Yes'\n\tfor i in range(len(sl)):\n\t\tif sl[i] != sl[-1-i]:\n\t\t\tf = 'No'\n\t\t\tbreak\n\treturn f\n\n\ns = input()\n\n\n\nsl = []\nslz = []\nslk = []\n\nfor i in range(len(s)):\n sl.append(s[i])\n\nfor i in range((len(s)-1) // 2):\n slz.append(s[i])\n\n\nfor i in range(((len(s)+3)//2), len(s)+1):\n slk.append(s[i-1])\n\n\nf = 'Yes'\n \n \nif kaibun(sl) == 'No':\n\tf = 'No'\n\nif kaibun(slz) == 'No':\n\tf = 'No'\n\nif kaibun(slk) == 'No':\n\tf = 'No'\n\nprint(f)\n\n\n\n\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s117064046', 's365362244', 's942996037'] | [3064.0, 3064.0, 3064.0] | [18.0, 17.0, 17.0] | [455, 513, 458] |
p02730 | u967484343 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['def palindrome(S):\n for i in range(len(S)//2):\n# print(S[i],S[-(i+1)])\n if S[i] != S[-(i+1)]:\n return 0\n return 1\nans = "No"\nS = input()\nS1 = S[:(len(S)-1)//2]\nS1 = S[(len(S)+3)//2:]\nif palindrome(S) == 1:\n if palindrome(S1) == 1:\n if palindrome(S2) == 1:\n ans == "Yes"\nprint(ans)', 'def palindrome(S):\n for i in range(len(S)//2):\n# print(S[i],S[-(i+1)])\n if S[i] != S[-(i+1)]:\n return 0\n return 1\nans = "No"\nS = input()\nS1 = S[:(len(S)-1)//2]\nS2 = S[(len(S)+3)//2:]\nif palindrome(S) == 1:\n if palindrome(S1) == 1:\n if palindrome(S2) == 1:\n ans == "Yes"\nprint(ans)', 'def palindrome(S):\n for i in range(len(S)//2):\n# print(S[i],S[-(i+1)])\n if S[i] != S[-(i+1)]:\n return 0\n return 1\nans = "No"\nS = input()\nS1 = S[:(len(S)-1)//2]\nS2 = S[(len(S)+1)//2:]\nprint(palindrome(S))\nprint(palindrome(S1))\nprint(palindrome(S2))\n\nif palindrome(S) == 1:\n if palindrome(S1) == 1:\n if palindrome(S2) == 1:\n ans = "Yes"\nprint(ans)', 'def palindrome(S):\n for i in range(len(S)//2):\n# print(S[i],S[-(i+1)])\n if S[i] != S[-(i+1)]:\n return 0\n return 1\nans = "No"\nS = input()\nS1 = S[:(len(S)-1)//2]\nS2 = S[(len(S)+1)//2:]\n\n\n\n\nif palindrome(S) == 1:\n if palindrome(S1) == 1:\n if palindrome(S2) == 1:\n ans = "Yes"\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s533982290', 's790922504', 's975710313', 's520145828'] | [8964.0, 9096.0, 8968.0, 9120.0] | [26.0, 29.0, 26.0, 28.0] | [302, 302, 367, 370] |
p02730 | u969708690 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['s=input()\nA=list(s)\nN=len(A)\nM=N-1\nk=0\nwhile k<M/2:\n if A[k]!=A[M-k]:\n print("No")\n if A[k]!=A[(M-2)/2-k]:\n print("No")\n if A[k+M/2+1]!=A[M-k]:\n print("No")\n else:\n print("Yes")\n k=k+1', 's=input()\nA=list(s)\nN=len(A)\nM=N-1\nR=M//2\nk=0\nwhile k<M/2:\n if A[k]!=A[M-k]:\n print("No")\n if A[k]!=A[R-1-k]:\n print("No")\n if A[k+R+1]!=A[M-k]:\n print("No")\n else:\n print("Yes")\n k=k+1', 'import sys\nL=list(input())\nN=len(L)\nR=N//2\nfor i in range(R):\n if L[i]!=L[N-1-i]:\n print("No")\n sys.exit()\n elif L[i]!=L[R-1-i]:\n print("No")\n sys.exit()\nprint("Yes")'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s055069636', 's689465468', 's129809768'] | [3060.0, 3060.0, 3060.0] | [18.0, 18.0, 17.0] | [201, 202, 180] |
p02730 | u969848070 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ["a = input()\nn= len(a)\nzenzen = a[0:n//2//2]\nzenkou = a[n//2//2:n//2]\nkouzen = a[n//2+1:n-1-n//2//2]\nkoukou = a[n-1-n//2//2]\nnew_zenkou = ''.join(list(reversed(zenkou)))\nnew_koukou = ''.join(list(reversed(koukou)))\nif zenzen != new_zenkou:\n print('No')\n exit()\nif kouzen != new_zenkou:\n print('No')\n exit()\nprint('Yes')", "a = input()\n\nfor i in range(int(len(a)//2)):\n if a[i] != a[-i]:\n print('No')\n exit()\nprint('Yes')", "a = input()\nn= len(a)\nif n == 3:\n print('Yes')\n exit()\nfor i in range(n//2):\n if a[i] != a[-1-i]:\n print('No')\n exit()\nfor i in range(n//2//2):\n if a[i] != a[n//2-1-i]:\n print('No')\n exit()\n if a[(n-1+3)//2+i] != a[-1-i]:\n print('No')\n exit()\nprint('Yes')"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s824306276', 's851103032', 's611207752'] | [3064.0, 2940.0, 3064.0] | [17.0, 17.0, 17.0] | [322, 104, 278] |
p02730 | u974792613 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['s = input()\nn = len(s)\ntop = s[:(n-1)//2]\nbottom = s[(n+3)//2-1:]\n\nif s==s[::-1] and top == top[::-1] and bottom = bottom[::-1]:\n print("Yes")\nelse:\n print("No")', 's = input()\nn = len(s)\ntop = s[: (n - 1) // 2]\nbottom = s[(n + 3) // 2 - 1 :]\n\nif s == s[::-1] and top == top[::-1] and bottom == bottom[::-1]:\n print("Yes")\nelse:\n print("No")\n\n'] | ['Runtime Error', 'Accepted'] | ['s279713971', 's796763944'] | [2940.0, 2940.0] | [17.0, 17.0] | [163, 184] |
p02730 | u975652044 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['def pal(t):\n return t == t[::-1];\n\n\ns = input();\nf = pal(s) and pal(s[0:(len(s)//2 - 1):]) and pal(s[(len(s)//2 + 1)::]);\n\nif f == True:\n print("Yes");\nelse:\n print("No");\n', 'def pal(s):\n f = True;\n i = 0;\n l = s.size() - 1;\n while i < l - i:\n if s[i] != s[l - i]:\n f = false;\n\ti++;\n return f;\n\ns = input();\nf = pal(s) and pal(s[0:(n//2 - 1):]) and pal(s[(n//2 + 1)::]);\nif f == True:\n print("Yes");\nelse:\n print("No");', 'def pal(t):\n return t == t[::-1];\n\n\ns = input();\nf = pal(s) and pal(s[0:len(s)//2:]) and pal(s[(len(s)//2 + 1)::]);\n\nif f == True:\n print("Yes");\nelse:\n print("No");\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s007463355', 's187607386', 's820314054'] | [3188.0, 2940.0, 2940.0] | [18.0, 17.0, 17.0] | [187, 259, 181] |
p02730 | u978494963 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['s=input()\nif s==s[::-1] and s==s[:(len(s)−1)//2] and s==s[(len(s)+3)//2-1:]:\n print("Yes")\nelse:\n print("No")', 's=input()\na=s[:(len(s)−1)//2]\nb=s[(len(s)+3)//2-1:]\nif s==s[::-1] and a==a[::-1] and b==b[::-1]:\n print("Yes")\nelse:\n print("No")', 's=input()\na=s[:(len(s)-1)//2]\nb=s[((len(s)+3)//2-1):]\nif s==s[::-1] and a==a[::-1] and b==b[::-1]:\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s156815907', 's507531224', 's695406927'] | [3192.0, 2940.0, 3060.0] | [19.0, 17.0, 18.0] | [113, 133, 133] |
p02730 | u980875259 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ["##======================================python3\nimport sys\nimport collections\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.readline\n\nclass Run:\n def build(gv):\n gv.s = input()\n \n def string_reverse_chk(gv, s:str):\n rev_s :_= ''.join(reversed(s))\n if s == rev_s:\n return True\n return False\n \n def solve(gv):\n pass\n \nif __name__ == '__main__':\n run = Run()\n run.build()\n run.solve()\n\n", '##======================================python3\nimport sys\nimport collections\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.readline\n\nclass Run:\n def build(gv):\n gv.s = input()\n \n def string_reverse_chk(gv, s:str):\n rev_s = \'\'.join(reversed(s))\n if s == rev_s:\n return True\n return False\n \n def solve(gv):\n \n ans = "No"\n \n while True:\n reversed_s = "".join(reversed(gv.s))\n slen = len(gv.s)\n \n if gv.string_reverse_chk(gv.s) is False : break\n \n if gv.string_reverse_chk(gv.s[0:int((slen -1)/2)]) is False : break\n if gv.string_reverse_chk(reversed_s[0:int((slen -1)/2)]) is False : break\n \n if gv.string_reverse_chk(gv.s[int((slen +3)/2 -1):slen]) is False : break\n if gv.string_reverse_chk(reversed_s[int((slen +3)/2 -1):slen]) is False : break\n \n \n ans = "Yes"\n break\n \n print(ans)\n \nif __name__ == \'__main__\':\n run = Run()\n run.build()\n run.solve()\n', "##======================================python3\nimport sys\nimport collections\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.readline\n\nclass Run:\n def build(gv):\n pass\n \n def string_reverse_chk(gv, s:str):\n rev_s :_= ''.join(reversed(s))\n if s == rev_s:\n return True\n return False\n \n def solve(gv):\n pass\n \nif __name__ == '__main__':\n run = Run()\n run.build()\n run.solve()\n\n\n", '##======================================python3\nimport sys\nimport collections\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.readline\n\nclass Run:\n def build(gv):\n gv.s = input()\n \n def string_reverse_chk(gv, s:str):\n rev_s :_= \'\'.join(reversed(s))\n if s == rev_s:\n return True\n return False\n \n def solve(gv):\n \n ans:_ = "No"\n \n \nif __name__ == \'__main__\':\n run = Run()\n run.build()\n run.solve()\n\n', '##======================================python3\nimport sys\nimport collections\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.readline\n\nclass Run:\n def build(gv):\n gv.s = input()\n \n def string_reverse_chk(gv, s:str):\n rev_s :_= \'\'.join(reversed(s))\n if s == rev_s:\n return True\n return False\n \n def solve(gv):\n \n ans:_ = "No"\n \n while True:\n reversed_s = "".join(reversed(gv.s))\n slen :_= len(gv.s)\n \n if gv.string_reverse_chk(gv.s) is False : break\n \n if gv.string_reverse_chk(gv.s[0:int((slen -1)/2)]) is False : break\n if gv.string_reverse_chk(reversed_s[0:int((slen -1)/2)]) is False : break\n \n if gv.string_reverse_chk(gv.s[int((slen +3)/2 -1):slen]) is False : break\n if gv.string_reverse_chk(reversed_s[int((slen +3)/2 -1):slen]) is False : break\n \n \n ans = "Yes"\n break\n \n print(ans)\n \nif __name__ == \'__main__\':\n run = Run()\n run.build()\n run.solve()\n', '##======================================python3\nimport sys\nimport collections\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.readline\n\nclass Run:\n def build(gv):\n gv.s = input()\n \n def string_reverse_chk(gv, s:str):\n rev_s = \'\'.join(reversed(s))\n if s == rev_s:\n return True\n return False\n \n def solve(gv):\n \n ans:_ = "No"\n \n while True:\n reversed_s = "".join(reversed(gv.s))\n slen = len(gv.s)\n \n if gv.string_reverse_chk(gv.s) is False : break\n \n if gv.string_reverse_chk(gv.s[0:int((slen -1)/2)]) is False : break\n if gv.string_reverse_chk(reversed_s[0:int((slen -1)/2)]) is False : break\n \n if gv.string_reverse_chk(gv.s[int((slen +3)/2 -1):slen]) is False : break\n if gv.string_reverse_chk(reversed_s[int((slen +3)/2 -1):slen]) is False : break\n \n \n ans = "Yes"\n break\n \n print(ans)\n \nif __name__ == \'__main__\':\n run = Run()\n run.build()\n run.solve()\n', "##======================================python3\nimport sys\nimport collections\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.readline\n\nclass Run:\n def build(gv):\n gv.s = input()\n \n def string_reverse_chk(gv, s:str):\n rev_s :_= ''.join(reversed(s))\n pass\n \n def solve(gv):\n pass\n \nif __name__ == '__main__':\n run = Run()\n run.build()\n run.solve()\n\n\n\n", "##======================================python3\nimport sys\nimport collections\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.readline\n\nclass Run:\n def build(gv):\n gv.s = input()\n \n def string_reverse_chk(gv, s:str):\n rev_s = ''.join(reversed(s))\n pass\n \n def solve(gv):\n pass\n \nif __name__ == '__main__':\n run = Run()\n run.build()\n run.solve()\n\n\n\n\n", "##======================================python3\nimport sys\nimport collections\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.readline\n\nclass Run:\n def build(gv):\n gv.s = input()\n \n \n \n def solve(gv):\n pass\n \nif __name__ == '__main__':\n run = Run()\n run.build()\n run.solve()\n\n\n", '##======================================python3\nimport sys\nimport collections\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.readline\n\nclass Run:\n def build(gv):\n gv.s = input().strip()\n \n def string_reverse_chk(gv, s:str):\n rev_s = "".join(list(reversed(s))[0:len(s)])\n if s == rev_s:\n return True\n return False\n \n def solve(gv):\n \n ans = "No"\n \n while True:\n slen = len(gv.s)\n reversed_s = "".join(list(reversed(gv.s))[0:slen])\n \n if gv.string_reverse_chk(gv.s) is False : break\n if gv.string_reverse_chk(gv.s[0:int((slen -1)/2)]) is False : break\n if gv.string_reverse_chk(reversed_s[0:int((slen -1)/2)]) is False : break\n \n if gv.string_reverse_chk(gv.s[int((slen +3)/2 -1):slen]) is False : break\n if gv.string_reverse_chk(reversed_s[int((slen +3)/2 -1):slen]) is False : break\n \n \n ans = "Yes"\n break\n \n print(ans)\n \nif __name__ == \'__main__\':\n run = Run()\n run.build()\n run.solve()\n'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s029958807', 's036165946', 's332852676', 's367189477', 's421797856', 's432768935', 's564593213', 's663099592', 's808345169', 's175554823'] | [2940.0, 3316.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 3316.0, 3436.0, 3316.0] | [17.0, 21.0, 17.0, 17.0, 17.0, 17.0, 17.0, 23.0, 21.0, 21.0] | [461, 1111, 452, 487, 1117, 1113, 408, 407, 321, 1144] |
p02730 | u981812192 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['my_string = input("Type your word: ")\nmy_string = my_string.casefold()\nif ((len(my_string)) < 3 or (len(my_string)) > 100):\n #print(len(my_string))\n print("no")\n quit()\n\nreversed_string = reversed(my_string)\n\nn = len(my_string)\n#defining string [0:(n-1)/2]\nfirst_chars = my_string[:int((n-1)/2)]\nreversed_first_chars = reversed(first_chars)\n\n#defining string [((n+3)/2):n-1]\nlast_chars = my_string[int((n+3)/2)-1:]\nreversed_last_chars = reversed(last_chars)\n#print(type(first_chars), first_chars)\n#print(last_chars)\n#print(n)\n\n#checking if S is a palindrome\nif list(my_string) == list(reversed_string):\n #checking if it is a strong palindrome\n if (list(first_chars) == list(reversed_first_chars)):\n if (list(last_chars) == list(reversed_last_chars)):\n print("yes")\n else:\n print("no")\n else:\n print("no")\n#if it is not a palindrome at all\nelse:\n print("no")', 'my_string = input("Type your word: ")\nmy_string = my_string.casefold()\nreversed_string = reversed(my_string)\n\nn = len(my_string)\n#defining string [0:(n-1)/2]\nfirst_chars = my_string[:int((n-1)/2)]\nreversed_first_chars = reversed(first_chars)\n\n#defining string [((n+3)/2):n-1]\nlast_chars = my_string[int((n+3)/2)-1:]\nreversed_last_chars = reversed(last_chars)\n#print(type(first_chars), first_chars)\n#print(last_chars)\n#print(n)\n\n#checking if S is a palindrome\nif list(my_string) == list(reversed_string):\n #checking if it is a strong palindrome\n if (list(first_chars) == list(reversed_first_chars)):\n if (list(last_chars) == list(reversed_last_chars)):\n print("yes")\n else:\n print("no")\n else:\n print("no")\n#if it is not a palindrome at all\nelse:\n print("no")', 'my_string = input("Type your word: ")\nmy_string = my_string.casefold()\nif ((len(my_string)) < 3 or (len(my_string)) > 100):\n #print(len(my_string))\n print("no")\n quit()\n\nreversed_string = reversed(my_string)\n\nn = len(my_string)\n#defining string [0:(n-1)/2]\nfirst_chars = my_string[:int((n-1)/2)]\nreversed_first_chars = reversed(first_chars)\n\n#defining string [((n+3)/2):n-1]\nlast_chars = my_string[int((n+3)/2)-1:]\nreversed_last_chars = reversed(last_chars)\n#print(type(first_chars), first_chars)\n#print(last_chars)\n#print(n)\n\n#checking if S is a palindrome\nif list(my_string) == list(reversed_string):\n #checking if it is a strong palindrome\n if (list(first_chars) == list(reversed_first_chars)):\n if (list(last_chars) == list(reversed_last_chars)):\n print("Yes")\n else:\n print("No")\n else:\n print("No")\n#if it is not a palindrome at all\nelse:\n print("No")', '\nmy_string = input()\nmy_string = my_string.casefold()\nif ((len(my_string)) < 3 or (len(my_string)) > 100):\n #print(len(my_string))\n print("No")\n quit()\n\nreversed_string = reversed(my_string)\n\nn = len(my_string)\n#defining string [0:(n-1)/2]\nfirst_chars = my_string[:int((n-1)/2)]\nreversed_first_chars = reversed(first_chars)\n\n#defining string [((n+3)/2):n-1]\nlast_chars = my_string[int((n+3)/2)-1:]\nreversed_last_chars = reversed(last_chars)\n#print(type(first_chars), first_chars)\n#print(last_chars)\n#print(n)\n\n#checking if S is a palindrome\nif list(my_string) == list(reversed_string):\n #checking if it is a strong palindrome\n if (list(first_chars) == list(reversed_first_chars)):\n if (list(last_chars) == list(reversed_last_chars)):\n print("Yes")\n else:\n print("No")\n else:\n print("No")\n#if it is not a palindrome at all\nelse:\n print("No")'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s245985676', 's314899551', 's670257503', 's742110899'] | [3064.0, 3064.0, 3064.0, 3064.0] | [19.0, 17.0, 17.0, 18.0] | [921, 813, 921, 942] |
p02730 | u982471399 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ["S=input()\nK1=int((len(S)-1)/2)\nK2=int((K1-1)/2)\nK3=int((len(S)+3)/2)\n\n#1\nS_K1=S[:K1]\nS_K1_r=S[:K1:-1]\n\n#2\nS_K2=S_K1[:K2]\nS_K2_r=S_K1[:K2:-1]\n#len(S_K2)>=3\n\n#3\nS_K3=S[K3-1:]\n#len(S_K3)>=3\nnum3=int((len(S_K3)-1)/2)\nS_K4=S_K3[:num3]\nS_K4_r=S_K3[:num3:-1]\n\nif S_K1==S_K1_r and (S_K2==S_K2_r and len(S_K2)>2) and (S_K4 == S_K4_r and len(S_K3)>2):\n print('Yes')\nelse:\n print('No')", 'S=input()\nN=len(S)\nr_S=S[::-1]\nc1=int((N-1)/2)\nc2=int((N+3)/2)\nS1=S[:c1]\nr_S1=S1[::-1]\nS2=S[(c2-1):]\nr_S2=S2[::-1]\n\n\n\nif S==r_S and S1==r_S1 and S2==r_S2:\n print("Yes")\nelse:\n print("No")'] | ['Wrong Answer', 'Accepted'] | ['s398527785', 's706198189'] | [3064.0, 9032.0] | [17.0, 31.0] | [377, 203] |
p02730 | u982749462 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ["s = input()\nn = len(s)\nprint(s, n)\ni = int(((n-1)/2)-1)\nj = int(((n+3)/2)-1)\n#print(i, j)\nl = s[:i+1]\nl2 = l[::-1]\nr = s[j:]\nr2 = r[::-1]\n#print(l, l2, r, r2)\nif l == l2 and r == r2 and l == r:\n print('Yes')\nelse:\n print('No')", "s = input()\nS = s[::-1]\nn = len(s)\n#print(s, n)\ni = int(((n-1)/2)-1)\nj = int(((n+3)/2)-1)\n#print(i, j)\nl = s[:i+1]\nl2 = l[::-1]\nr = s[j:]\nr2 = r[::-1]\n#print(l, l2, r, r2)\nif l == l2 and r == r2 and s == S:\n print('Yes')\nelse:\n print('No')"] | ['Wrong Answer', 'Accepted'] | ['s942550767', 's236623225'] | [3064.0, 3064.0] | [18.0, 19.0] | [228, 241] |
p02730 | u985041094 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['s = list(map(str, input()))\nn = len(s)\nres = True\nfor i in range(n//2):\n print("?")\n if (s[i] != s[n-1-i]):\n res = False\n break\ni = 0\nwhile res and i < n//4:\n print("!")\n if (s[i] != s[(n-1)//2-1-i]):\n res = False\n break\n i += 1\nprint("Yes" if res else "No")', 's = list(map(str, input()))\nn = len(s)\nres = True\nfor i in range(n//2):\n if (s[i] != s[n-1-i]):\n res = False\n break\ni = 0\nwhile res and i < n//4:\n if (s[i] != s[(n-1)//2-1-i]):\n res = False\n break\n i += 1\nprint("Yes" if res else "No")'] | ['Wrong Answer', 'Accepted'] | ['s712429970', 's890844329'] | [3064.0, 3064.0] | [17.0, 17.0] | [301, 271] |
p02730 | u985949234 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ["s = input()\nls = list(s)\nprint((len(ls)-1)/2 - 1)\nls1 = ls[:int((len(ls)-1)/2)]\nls2 = ls[int((len(ls)+3)/2) - 1:]\ndef kt(l):\n lr = list(reversed(l))\n if l == lr:\n return 1\n else:\n return 0\na = kt(ls)\nb = kt(ls1)\nc = kt(ls2)\n\n\nd = a + b + c\n\nif d >= 3:\n print('Yes')\nelse:\n print('No')\n", "s = input()\nls = list(s)\nls1 = ls[:int((len(ls)-1)/2)]\nls2 = ls[int((len(ls)+3)/2) - 1:]\ndef kt(l):\n lr = list(reversed(l))\n if l == lr:\n return 1\n else:\n return 0\na = kt(ls)\nb = kt(ls1)\nc = kt(ls2)\n\n\nd = a + b + c\n\nif d >= 3:\n print('Yes')\nelse:\n print('No')\n"] | ['Wrong Answer', 'Accepted'] | ['s992662860', 's122311698'] | [3064.0, 3064.0] | [17.0, 17.0] | [314, 289] |
p02730 | u986190948 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['S=input()\nn=len(S)\na=0\nb=0\nfor i in range((n-1)/2):\n\tif S[i]!=S[n-i]:\n \ta=1\n print("No")\n break;\np=""\nq=""\nif a==0:\n\tfor i in range((n-1)/2):\n\t\tp.append(S[i])\n \tq.append(S[i+1+(n-1)/2])\n\tfor i in range((len(p)-1)/2):\n \t\tif p[i]!=p[len(p)-i] or q[i]!=q[len(p)-i]:\n \tb=1\n print("No")\n break;\nif a==0 and b==0:\n\tprint("Yes")\n', 'S=input()\nn=len(S)\na=0\nb=0\nfor i in range(1,int(n/2)+1):\n if S[i-1]!=S[n-i]:\n a=1\n print("No")\n break;\np=[]\nq=[]\nif a==0:\n for i in range(1,int(n/2)+1):\n p.append(S[i-1])\n q.append(S[i+int(n/2)])\n #print(p,q)\n for i in range(1,int((len(p))/2)+1):\n #print(p[i-1],p[len(p)-i],q[i-1],q[len(p)-i])\n if p[i-1]!=p[len(p)-i] or q[i-1]!=q[len(p)-i]:\n b=1\n print("No")\n break;\nif a==0 and b==0:\n print("Yes")\n'] | ['Runtime Error', 'Accepted'] | ['s002967175', 's713062904'] | [2940.0, 3064.0] | [17.0, 17.0] | [372, 497] |
p02730 | u994527877 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['s = input()\n\n\ns1 = s[0:len(s)//2]\ns2 = s[len(s)//2+1:len(s)]\n\nprint(s1, s2)\ndef reverse(s): \n return s[::-1]\n\ndef isPalindrome(s): \n rev = reverse(s) \n \n if (s == rev): \n return True\n return False\n\nif isPalindrome(s1):\n if isPalindrome(s2):\n if s1==s2:\n print("Yes")\nelse:\n print("No")\n', 's = input()\nn = len(s)\ns1 = s[0:len(s)//2]\ns2 = s[len(s)//2+1:len(s)]\n\ndef reverse(s): \n return s[::-1]\n\ndef isPalindrome(s): \n rev = reverse(s) \n \n if (s == rev): \n return True\n return False\n\nif isPalindrome(s):\n if n % 2 == 0:\n print("No")\n elif isPalindrome(s1) and isPalindrome(s2):\n print("Yes")\n else:\n print("No")\nelse:\n print("No")\n'] | ['Wrong Answer', 'Accepted'] | ['s641515672', 's695431460'] | [3060.0, 3064.0] | [18.0, 17.0] | [330, 393] |
p02730 | u996731299 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['word=list(map.string().split())\ncheck=True\nfor i in range(len(word)//2)\n if word[i]==word[len(word)-1]:\n continue:\n else:\n check=False\n braek:\nif check==True:\n print("Yes")\nelse:\n print("No")', 'word=list(input())\ncheck=True\nfor i in range(len(word)//2)\n if word[i]==word[len(word)-1]:\n continue:\n else:\n check=False\n braek:\nif check==True:\n print("Yes")\nelse:\n print("No")\n', 'S=list(input())\nN=len(S)\ncheck=True\nfor i in range(N//2):\n if S[i]!=S[N-1-i]:\n check=False\n break\nif check==False:\n print("No")\nelse:\n C=False\n for i in range((N//2)//2):\n if S[i]!=S[N//2-1-i]:#0123456\n C=True\n break\n if C==True:\n print("No")\n else:\n print("Yes")\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s529613519', 's769396716', 's928670966'] | [2940.0, 2940.0, 3060.0] | [17.0, 17.0, 17.0] | [228, 216, 335] |
p02730 | u997641430 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ["S = list(input())\nN = len(S)\nS0 = S[:(N - 1) // 2]\nS1 = S[(N + 1) // 2:]\nprint(S0, S1, S)\nif S0 == S0[::-1] and S1 == S1[::-1] and S == S[::-1]:\n print('Yes')\nelse:\n print('No')\n", "S = list(input())\nN = len(S)\nS0 = S[:(N - 1) // 2]\nS1 = S[(N + 1) // 2:]\nif S0 == S0[::-1] and S1 == S1[::-1] and S == S[::-1]:\n print('Yes')\nelse:\n print('No')\n"] | ['Wrong Answer', 'Accepted'] | ['s321537859', 's278491495'] | [2940.0, 2940.0] | [17.0, 17.0] | [184, 167] |
p02730 | u997927785 | 2,000 | 1,048,576 | A string S of an odd length is said to be a _strong palindrome_ if and only if all of the following conditions are satisfied: * S is a palindrome. * Let N be the length of S. The string formed by the 1-st through ((N-1)/2)-th characters of S is a palindrome. * The string consisting of the (N+3)/2-st through N-th characters of S is a palindrome. Determine whether S is a strong palindrome. | ['S = str(input())\n\nslist = list(S)\nN = len(slist)\nprint(N)\nk = int((N-1)/2)\n\nrs = slist[::-1]\nfront = slist[0:k]\nrfront = front[::-1]\n\nif front == rfront and rs == slist:\n print("Yes")\n\nelse:\n print("No")\n', 'S = str(input())\n\nslist = list(S)\nN = len(slist)\nk = int((N-1)/2)\n\nrs = slist[::-1]\nfront = slist[0:k]\nrfront = front[::-1]\n\nif front == rfront and rs == slist:\n print("Yes")\n\nelse:\n print("No")\n'] | ['Wrong Answer', 'Accepted'] | ['s990963166', 's825190613'] | [3060.0, 3060.0] | [18.0, 17.0] | [210, 201] |
p02732 | u001024152 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['from collections import Counter\n\nN = int(input())\na = list(map(int, input().split()))\ncnts = Counter(a)\n\n_sum = 0\nfor key,value in cnts.items():\n _sum += value*(value-1)//2\n\nfor ai in a:\n ans = _sum\n c = cnts.count(ai)\n ans -= c*(c-1)//2\n ans += (c-1)*(c-2)//2\n print(ans)\n', 'from collections import Counter\n\nN = int(input())\na = list(map(int, input().split()))\ncnts = Counter(a)\n\n_sum = 0\nfor key,value in cnts.items():\n _sum += value*(value-1)//2\n\nfor ai in a:\n ans = _sum\n c = cnts[ai]\n ans -= c*(c-1)//2\n ans += (c-1)*(c-2)//2\n print(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s866912946', 's992333266'] | [25900.0, 26780.0] | [137.0, 429.0] | [292, 286] |
p02732 | u003475507 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import collections\nfrom operator import mul\nfrom functools import reduce\n\ndef combinations_count(n, r):\n r = min(r, n - r)\n numer = reduce(mul, range(n, n - r, -1), 1)\n denom = reduce(mul, range(1, r + 1), 1)\n return numer // denom\n\nm = int(input())\na = list(map(int,input().split()))[:m]\nc = collections.Counter(a)\n\nmemo = {}\nrmemo = {}\n\nfor i in a:\n if not rmemo.get(i):\n print(rmemo[i])\n continue\n\n res = 0\n for k,v in c.items():\n if i == k: v -= 1\n \n if v >= 2:\n if not memo.get(v):\n memo[v] = combinations_count(v, 2)\n\n res += memo[v]\n rmemo[i] = res\n print(res)', 'import collections\n\n\nm = int(input())\nA = list(map(int,input().split()))[:m]\nc = collections.Counter(A)\n \ndef hoge(n):\n return n * (n - 1) // 2\n\nfull = sum([ hoge(i) for i in c.values()])\n\nfor a in A:\n print(full - hoge(c[a]) + hoge(c[a]-1))\n'] | ['Runtime Error', 'Accepted'] | ['s532742333', 's105082777'] | [26636.0, 26780.0] | [104.0, 456.0] | [666, 248] |
p02732 | u003644389 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import math\n\ndef comb(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn = int(input())\na = [0]*n\na = list(map(int, input().split()))\nmap(lambda x: x-1, a)\nty=[0]*n\n\nfor i in range(0, n):\n ty[a[i]]+=1\n\ns = 0\n\nfor i in range(0, n):\n if ty[i]>=2:\n s += comb(ty[i], 2, exact=True)\n\nfor k in range(0, n):\n if ty[a[k]]==2:\n print(s-1)\n elif ty[a[k]]>2:\n print(s-comb(ty[a[k]], 2, exact=True)+comb(ty[a[k]]-1, 2,exact=True))\n else:\n print(s)', 'def cmb(n, r):\n if n - r < r: r = n - r\n if r == 0: return 1\n if r == 1: return n\n\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n\n for p in range(2,r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1,r,p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result *= int(numerator[k])\n\n return result\n\nn = int(input())\na = [0]*n\na = list(map(int, input().split()))\nmap(lambda x: x-1, a)\nty=[0]*n\n\nfor i in range(0, n):\n ty[a[i]]+=1\n\ns = 0\n\nfor i in range(0, n):\n if ty[i]>=2:\n s += comb(ty[i], 2)\n\nfor k in range(0, n):\n if ty[a[k]]==2:\n print(s-1)\n elif ty[a[k]]>2:\n print(s-comb(ty[a[k]], 2)+comb(ty[a[k]]-1, 2))\n else:\n print(s)', 'import random\n\n\ndef nC2(n):\n return int(n*(n-1)/2)\n\nn = int(input())\n\na = [0]*n\na = list(map(int, input().split()))\na = [i-1 for i in a]\n\nty=[0]*n\n\nfor i in range(0, n):\n ty[a[i]]+=1\n\ns = 0\n\nfor i in range(0, n):\n if ty[i]>=2:\n s += nC2(ty[i])\n\nfor k in range(0, n):\n if ty[a[k]]==2:\n print(s-1)\n elif ty[a[k]]>2:\n print(s-nC2(ty[a[k]])+nC2(ty[a[k]]-1))\n else:\n print(s)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s250173372', 's368339120', 's998780772'] | [27676.0, 27396.0, 28188.0] | [112.0, 111.0, 500.0] | [513, 928, 416] |
p02732 | u004271495 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['"""\n"""\nfrom math import factorial\nfrom collections import defaultdict\n\n\ndef int_as_array(num): return list(map(int, [y for y in str(num)]))\n\n\ndef array_as_int(arr): return int(\'\'.join(map(str, arr)))\n\n\ndef read_int(): return int(input())\n\n\ndef read_array(): return list(map(int, input().split(\' \')))\n\n\ndef array_to_string(arr, sep=\' \'): return sep.join(map(str, arr))\n\n\ndef matrix_to_string(arr, sep=\' \'): return \'[\\n\' + \'\\n\'.join(\n [sep.join(map(str, row)) for row in arr]) + \'\\n]\'\n\n\ncache = {}\n\n\ndef fac(x):\n if cache.get(x) is not None:\n return cache[x]\n ans = factorial(x)\n cache[x] = ans\n return ans\n\n\ndef choose_combination(n, r):\n if r > n:\n return 0\n return int((fac(n) / fac((n - r))) * (1 / fac(r)))\n\n\ndef solve(n, array):\n counts = defaultdict(int)\n for x in array:\n counts[x] += 1\n ways_cache = {}\n for k in array:\n if ways_cache.get(k) is not None:\n return ways_cache[k]\n ways = 0\n for x, count in counts.items():\n adjusted_count = counts[x]\n if x == k:\n adjusted_count -= 1\n ways += choose_combination(adjusted_count, 2)\n ways_cache[k] = ways\n print(ways)\n\n\nN = read_int()\narray = read_array()\nsolve(N, array)\n', '"""\n"""\nfrom math import factorial\nfrom collections import defaultdict\n\n\ndef int_as_array(num): return list(map(int, [y for y in str(num)]))\n\n\ndef array_as_int(arr): return int(\'\'.join(map(str, arr)))\n\n\ndef read_int(): return int(input())\n\n\ndef read_array(): return list(map(int, input().split(\' \')))\n\n\ndef array_to_string(arr, sep=\' \'): return sep.join(map(str, arr))\n\n\ndef matrix_to_string(arr, sep=\' \'): return \'[\\n\' + \'\\n\'.join(\n [sep.join(map(str, row)) for row in arr]) + \'\\n]\'\n\n\ncache = {}\n\n\ndef fac(x):\n return factorial(x)\n\n\ndef choose_combination(n, r):\n if r > n:\n return 0\n # return int((fac(n) / fac((n - r))) * (1 / fac(r)))\n # return (fac(n) // fac((n - 2)) * (1 / 2))\n # return fac((n // n - 2)) * (1 / 2))\n return (n * (n-1)) // 2\n\n\ndef solve(n, array):\n counts = defaultdict(int)\n for x in array:\n counts[x] += 1\n total_ways = 0\n for x, count in counts.items():\n total_ways += choose_combination(counts[x], 2)\n for k in array:\n ways = choose_combination(counts[k] - 1, 2)\n print(total_ways + ways - choose_combination(counts[k], 2))\n\n\nN = read_int()\narray = read_array()\nsolve(N, array)\n'] | ['Wrong Answer', 'Accepted'] | ['s240064759', 's223136604'] | [26888.0, 26888.0] | [2104.0, 399.0] | [1273, 1176] |
p02732 | u011277545 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import math\ndef comb(N, r):\n return math.factorial(N) // (math.factorial(N - r) * math.factorial(r))\n\nfor i in range(num):\n A=target.copy()\n A.pop(i)\n out=0\n for j in set(A):\n if A.count(j)>1:\n base = comb(A.count(j),2)\n out=out+base\n print(out)', 'import math\nnum=int(input())\ntarget=list(map(int, input().split()))\n\ndef comb(N, r):\n return math.factorial(N) // (math.factorial(N - r) * math.factorial(r))\n\nfor i in range(num):\n A=target.copy()\n A.pop(i)\n B=[x for x in set(A) if A.count(x) > 1]\n out=0\n if len(B)>1:\n for j in B:\n base = comb(A.count(j),2)\n out=out+base\n print(out)\n', 'import collections\nn = int(input())\narr = list(map(int, input().split()))\ncnt = collections.Counter(arr)\ntotal = 0\nfor i in cnt.keys():\n patern = cnt[i]*(cnt[i]-1)//2\n total += patern\nfor j in range(n):\n tmp = total\n total -= cnt[arr[j]]*(cnt[arr[j]]-1)//2\n total += (cnt[arr[j]]-1)*(cnt[arr[j]]-2)//2\n print(total)\n total = tmp'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s153059510', 's401087973', 's039290751'] | [3060.0, 26140.0, 25900.0] | [17.0, 2104.0, 571.0] | [292, 385, 335] |
p02732 | u022979415 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['#include<bits/stdc++.h>\nusing namespace std;\n\nint main() {\n int N;\n cin >> N;\n vector<int> A(N), count(N);\n for (int i = 0; i < N; i++) {\n cin >> A[i];\n }\n for (int i = 0; i < N; i++) {\n count[A[i]]++;\n }\n long long answer = 0;\n for (int i = 0; i < N; i++) {\n answer += count[i] * (count[i] - 1) / 2;\n }\n for (int i = 0; i < N; i++) {\n cout << answer - count[A[i]] + 1 << endl;\n }\n return 0;\n}', "def main():\n n = int(input())\n a = [int(x) for x in input().split()]\n count = {}\n for aa in a:\n if aa in count:\n count[aa] += 1\n else:\n count[aa] = 1\n all_way = 0\n for c in count.values():\n all_way += c * (c - 1) // 2\n for i in range(n):\n if a[i] in count:\n print(all_way - count[a[i]] + 1)\n else:\n print(all_way)\n\n\nif __name__ == '__main__':\n main()\n\n"] | ['Runtime Error', 'Accepted'] | ['s317084858', 's243887095'] | [2940.0, 26140.0] | [17.0, 292.0] | [460, 455] |
p02732 | u023751250 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['from functools import reduce\nn=int(input())\na=list(map(int,input().split()))\nc=list(range(1,n+1))\na.insert(0,0)\nnum=list(map(lambda t:reduce(lambda a,b:a+1 if b==t else a,a),c))\n"""\ntest=list(map(lambda t:map(lambda x,y:x if (y!=t or x==0) else x-1,num,c),c))\nfor i in range(5):\n print(list(test[i]))\n"""\nans=list(map(lambda t:reduce(lambda x,y:x+y*(y-1)/2,map(lambda x,y:x if (y!=t or x==0) else x-1,num,c),0),c))\n\nfor i in range(n):\n print(int(ans[a[i]]))', 'from functools import reduce\nn=int(input())\na=list(map(int,input().split()))\nc=list(range(1,n+1))\nnum=[0]*n\nfor i in range(n):\n num[a[i]-1]=num[a[i]-1]+1\npreans=reduce(lambda x,y:x+y*(y-1)/2,num,0)\n\nfor i in range(n):\n print(int(preans-num[a[i]-1]+1))'] | ['Wrong Answer', 'Accepted'] | ['s038157096', 's658722784'] | [27020.0, 26892.0] | [2105.0, 403.0] | [463, 257] |
p02732 | u025287757 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n = int(input())\nA = list(map(int, input().split()))\nnum = [0]*n\nimport numpy as np\nfor i in A:\n num[i-1] += 1\nnum = np.array(num)\ndef comb(n):\n if n < 2:\n return 0\n else:\n return n * (n-1) // 2\nans_sub = np.sum(np.array(num))\nfor i in A:\n if num[i-1] < 2:\n a = 0\n else:\n a = num[i-1]-1\n print(ans_sub-a)', 'n = int(input())\nA = list(map(int, input().split()))\nnum = [0]*n\nfor i in A:\n num[i-1] += 1\ndef comb(n):\n if n < 2:\n return 0\n else:\n return n * (n-1) // 2\nans_sub = 0\nfor i in num:\n ans_sub += comb(i)\nfor i in A:\n if num[i-1] < 2:\n a = 0\n else:\n a = num[i-1]-1\n print(ans_sub-a)'] | ['Wrong Answer', 'Accepted'] | ['s717544727', 's461644729'] | [26348.0, 26140.0] | [1705.0, 342.0] | [330, 306] |
p02732 | u030669569 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['#include <bits/stdc++.h>\nusing namespace std;\n\nint main() {\n\n int N; cin >> N;\n vector<int> A(N);\n for (int i = 0; i < N; i++) {\n cin >> A[i];\n }\n\n vector<int> uniqueA = A;\n sort(uniqueA.begin(), uniqueA.end());\n uniqueA.erase(unique(uniqueA.begin(), uniqueA.end()), uniqueA.end());\n\n int sum_comb_all = 0;\n for (int i = 0; i < uniqueA.size(); i++) {\n int num_A = count(A.begin(), A.end(), uniqueA[i]);\n int comb = (num_A * (num_A-1)) / 2;\n sum_comb_all += comb;\n }\n\n\n for (int i = 0; i < N; i++) {\n\n int num_A = count(A.begin(), A.end(), A[i]);\n int prev_comb = (num_A * (num_A-1)) / 2;\n int new_comb = ((num_A-1) * (num_A-2)) / 2;\n\n int sum_comb = sum_comb_all - prev_comb + new_comb;\n cout << sum_comb << endl;\n\n }\n\n}', 'from collections import Counter\n\nN = int(input())\nlst_A = list(map(int, input().split()))\n\ndef main(N, lst_A):\n\n dct_cntA = Counter(lst_A)\n sum_comb = 0\n\n for cntA in dct_cntA.values():\n comb = (cntA * (cntA - 1)) // 2\n sum_comb += comb\n\n for A in lst_A:\n print(sum_comb - (dct_cntA[A] - 1))\n\n return 0\n\nif __name__ == "__main__":\n\n main(N, lst_A)\n '] | ['Runtime Error', 'Accepted'] | ['s473018878', 's664025508'] | [2940.0, 26780.0] | [18.0, 302.0] | [826, 391] |
p02732 | u033524082 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import collections\nn=int(input())\na=list(map(int,input().split()))\nl=[0]*(n+1)\nans=0\nfor i in range(n):\n l[a[i]]+=1\nfor j in range(n):\n if l[j]>1:\n ans+=(l[j])*(l[j]-1)//2\nfor k in range(n):\n s=l[a[k]]\n if s<2:\n print(ans)\n else:\n print(ans-(s+1)*s//2+s*(s-1)//2)', 'n=int(input())\nA=list(map(int,input().split()))\na=sorted(A)\ncounter=1\nans=0\nvalue=a[0]\ndict={}\nfor i in range(1,n):\n if a[i]==value:\n counter+=1\n else:\n dict[value]=counter\n if counter<2:\n pass\n else:\n ans+=counter*(counter-1)//2\n counter=1\n value=a[i]\ndict[value]=counter\nif counter<2:\n pass\nelse:\n ans+=counter*(counter-1)//2\nfor j in range(n):\n count=dict[A[j]]-1\n if count==0:\n print(ans)\n elif count==1:\n print(ans-1)\n else:\n c=ans-(count+1)*count//2+count*(count-1)//2\n print(c)\n'] | ['Wrong Answer', 'Accepted'] | ['s256207899', 's156379253'] | [26780.0, 26072.0] | [388.0, 457.0] | [299, 601] |
p02732 | u035453792 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n = int(input())\na = list(map(int,input().split()))\ns = n*[0]\nfor i in a:\n s[i]+=1\nfor i in range(0,n):\n s[a[i]]-=1\n ans=max(s)*(max(s)-1)/2\n s[a[i]]+=1\n print(int(ans))', 'import numpy as np\nn = int(input())\na = list(map(int,input().split()))\ns = np.zeros(n+1)\nfor i in a:\n s[i]+=1\nal = sum((s*(s-1))/2)\nfor i in range(n):\n ans=al-(s[a[i]]-1)\n print(int(ans))'] | ['Runtime Error', 'Accepted'] | ['s882593097', 's448438276'] | [32152.0, 51564.0] | [2206.0, 460.0] | [184, 196] |
p02732 | u036104576 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import sys\nimport itertools\n# import numpy as np\nimport time\nimport math\n\nsys.setrecursionlimit(10 ** 7)\n\nfrom collections import defaultdict\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn = int(readline())\na = list(map(int, readline().split()))\n\ncounter = [0 for _ in range(n + 1)]\nfor i in a:\n counter[i] += 1\n\nMAX = 10 ** 5\nMOD = 10 ** 9 + 7\nfac = [0 for i in range(MAX)]\nfinv = [0 for i in range(MAX)]\ninv = [0 for i in range(MAX)]\n\ndef comInit(mod):\n fac[0], fac[1] = 1, 1\n finv[0], finv[1] = 1, 1\n inv[1] = 1\n for i in range(2, MAX):\n fac[i] = fac[i - 1] * i % mod\n inv[i] = mod - inv[mod % i] * (mod // i) % mod\n finv[i] = finv[i - 1] * inv[i] % mod\n\ndef com(n, r, mod):\n if n < r:\n return 0\n if n < 0 or r < 0:\n return 0\n return fac[n] * (finv[r] * finv[n - r] % mod) % mod\n\ncomInit(MOD)\n\n\n# diff = [0 for _ in range(n + 1)]\nfor i, c in enumerate(counter):\n x = com(c, 2, MOD)\n\n# if c - 1 <= 0:\n# diff[i] = x\n# else:\n\n# diff[i] = x - y\n\n\n# print(total - diff[a[i]])', 'import sys\nimport itertools\n# import numpy as np\nimport time\nimport math\n\nsys.setrecursionlimit(10 ** 7)\n\nfrom collections import defaultdict\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn = int(readline())\na = list(map(int, readline().split()))\n\ncounter = [0 for _ in range(n + 1)]\nfor i in a:\n counter[i] += 1\n\nMAX = 10 ** 5\nMOD = 10 ** 9 + 7\nfac = [0 for i in range(MAX)]\nfinv = [0 for i in range(MAX)]\ninv = [0 for i in range(MAX)]\n\ndef comInit(mod):\n fac[0], fac[1] = 1, 1\n finv[0], finv[1] = 1, 1\n inv[1] = 1\n for i in range(2, MAX):\n fac[i] = fac[i - 1] * i % mod\n inv[i] = mod - inv[mod % i] * (mod // i) % mod\n finv[i] = finv[i - 1] * inv[i] % mod\n\ndef com(n, r, mod):\n if n < r:\n return 0\n if n < 0 or r < 0:\n return 0\n return fac[n] * (finv[r] * finv[n - r] % mod) % mod\ncomInit(MOD)\n\ntotal = 0 \ndiff = [0 for _ in range(n + 1)]\nfor i, c in enumerate(counter):\n x = com(c, 2, MOD)\n total += x\n # if c - 1 <= 0:\n # diff[i] = x\n # else:\n \n # diff[i] = x - y\n\nfor i in range(n):\n print(total - diff[a[i]])', 'import sys\nimport itertools\n# import numpy as np\nimport time\nimport math\n\nsys.setrecursionlimit(10 ** 7)\n\nfrom collections import defaultdict\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn = int(readline())\na = list(map(int, readline().split()))\n\ncounter = [0 for _ in range(n + 1)]\nfor i in a:\n counter[i] += 1\n\ntotal = 0 \ndiff = [0 for _ in range(n + 1)]\nfor i, c in enumerate(counter):\n x = c * (c - 1) // 2\n total += x\n if c - 1 <= 0:\n diff[i] = x\n else:\n y = (c - 1) * (c - 2) // 2\n diff[i] = x - y\n\nfor i in range(n):\n print(total - diff[a[i]])'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s147971205', 's312640379', 's140028488'] | [24788.0, 27860.0, 20776.0] | [268.0, 460.0, 383.0] | [1205, 1194, 651] |
p02732 | u037098269 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['N = int(input())\nA = [a for a in map(int, input().split())]\n\n\n\ndic1 = {}\nfor i in range(N):\n dic1[i] = 0\n\n\nfor i in A:\n if i in dic1.keys():\n dic1[i] += 1\n\ndic2 = {}\n\nfor i in range(N):\n dic2[i] = dic1[i]*(dic1[i]-1)/2\n\nans1 = 0\nfor i in range(N):\n ans1 += dic2[i]\n\nfor i in range(N):\n ans2 = ans1\n ans2 -= dic2[A[i]] \n ans2 += (dic1[A[i]]-1)*(dic1[A[i]]-2)/2\n print(ans2)', 'N = int(input())\nA = [a for a in map(int, input().split())]\n\n\n\ndic1 = {}\nfor i in range(N):\n dic1[i+1] = 0\n\n\nfor i in range(N):\n if A[i] in dic1.keys():\n dic1[A[i]] += 1\n\ndic2 = {}\n\nfor i in range(N):\n dic2[i+1] = dic1[i+1]*(dic1[i+1]-1)/2\n\nans1 = 0\nfor i in range(N):\n ans1 += dic2[i+1]\n\nfor i in range(N):\n ans2 = ans1\n ans2 -= dic2[A[i]] \n ans2 += (dic1[A[i]]-1)*(dic1[A[i]]-2)/2 \n print(int(ans2))'] | ['Runtime Error', 'Accepted'] | ['s130995851', 's878031168'] | [68600.0, 68216.0] | [636.0, 694.0] | [591, 660] |
p02732 | u038021590 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['from collections import Counter\nN = int(input())\nA = tuple(map(int, input().split()))\nA_count = Counter(A)\nans = 0\nfor i, j in A_count:\n ans += j * (j - 1) // 2\nfor k in range(1, N+1):\n n = A_count[A[k-1]]\n ans_ = ans - (n - 1)\n print(ans_)\n', 'from collections import Counter\nN = int(input())\nA = tuple(map(int, input().split()))\nA_count = Counter(A)\nans = 0\nfor i, j in A_count.items():\n ans += j * (j - 1) // 2\nfor k in range(1, N+1):\n n = A_count[A[k-1]]\n ans_ = ans - (n - 1)\n print(ans_)\n'] | ['Runtime Error', 'Accepted'] | ['s069857645', 's925450778'] | [27036.0, 27028.0] | [96.0, 391.0] | [253, 261] |
p02732 | u038887660 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import itertools\nh, w, k = map(int, input().split())\nli_hw = [list(f) for f in [input() for _ in range(h)]]\nall_h = []\nscore = []\n# for l in range(2**(h-1)):\n# ind = []\n\n# cut_list=[]\n\n# for n,yn in enumerate(reversed(list(bin(l))[2:])):\n\n# cut_list.append(li_hw[pre:n+1])\n\n# cut_list.append(li_hw[pre:h])\nfor i in itertools.product([0, 1], repeat=h-1):\n cut_list=[]\n hline_num = 0\n pre = 0\n cut_list = []\n for n, i2 in enumerate(i):\n if i2 == 1:\n cut_list.append(li_hw[pre:n+1])\n pre = n+1\n cut_list.append(li_hw[pre:h])\n hline_num = i.count(1)\n pred = 0\n wline_num = 0\n #print("list is {}".format(cut_list))\n \n \n for y in range(w):\n wcounter_list = []\n for c in cut_list:\n wcounter = 0\n for c2 in c:\n wcounter += c2[pred:y+1].count("1")\n wcounter_list.append(wcounter)\n \n if max(wcounter_list) > k:\n pred = y\n wline_num += 1\n #print("line between{}and{}".format(y-1, y))\n #print("wline{}, hline{}".format(wline_num, hline_num))\n score.append(wline_num+hline_num)\nprint(min(score))', 'import collections\nn = int(input())\na = map(int, input().split())\nli = []\nfor i in a:\n li.append(i)\ncollections.Counter(li)\nm = 0\ndic = collections.Counter(li)\nfor i in dic.values():\n m += int(i*(i-1)*0.5)\nfor k in range(n):\n print(m-dic[li[k]]+1)'] | ['Runtime Error', 'Accepted'] | ['s585571731', 's225944951'] | [3064.0, 26780.0] | [18.0, 417.0] | [1314, 258] |
p02732 | u043035376 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['from collections import Counter\n\nn = int(input())\n\na_list = list(map(int, input().split()))\n\nc = Counter(a_list)\n\nall_count = 0\nfor value in c.values():\n if value == 1:\n continue\n else:\n tmp = int((value * (value - 1))/2)\n all_count += tmp\n\nif all_count == 0:\n all_count = 1\n\nfor i in range(n):\n print(all_count - c[i])\n', 'from collections import Counter\n\nn = int(input())\n\na_list = list(map(int, input().split()))\n\nc = Counter(a_list)\n\nall_count = 0\nfor value in c.values():\n if value == 1:\n continue\n else:\n tmp = int((value * (value - 1))/2)\n all_count += tmp\n\nfor i in range(n):\n print(all_count - c[i])\n', 'from collections import Counter\n\nn = int(input())\n\na_list = list(map(int, input().split()))\n\nc = Counter(a_list)\n\nall_count = 0\nfor value in c.values():\n if value == 1:\n continue\n else:\n tmp = int((value * (value - 1))/2)\n all_count += tmp\n\nif all_count == 0:\n all_count = 1\n\nfor i in a_list:\n print(all_count - c[i])\n', 'from collections import Counter\n\nn = int(input())\n\na_list = list(map(int, input().split()))\n\nc = Counter(a_list)\n\nall_count = 0\nfor value in c.values():\n if value == 1:\n continue\n else:\n tmp = int((value * (value - 1))/2)\n all_count += tmp\n\nprint(all_count)\n\nfor i in range(n):\n print(all_count - c[i])\n', 'from collections import Counter\n\nn = int(input())\n\na_list = list(map(int, input().split()))\n\nans_dict = {}\nans_keys = []\nvalue_dict = {1: 0}\nvalue_keys = [1]\nfor i in range(n):\n num = a_list[i]\n if num in ans_keys:\n print(ans_dict[num])\n else:\n buff = a_list[:i]\n buff.extend(a_list[i+1:])\n c = Counter(buff)\n\n tmp_ans = 0\n for value in c.values():\n if value in value_keys:\n tmp_ans += value_dict[value]\n else:\n tmp = (value * (value - 1))/2\n tmp_ans += tmp\n value_dict[value] = tmp\n value_keys.append(value)\n ans_dict[num] = tmp_ans\n ans_keys.append(num)\n print(int(tmp_ans))\n\n', 'from collections import Counter\n\nn = int(input())\n\na_list = list(map(int, input().split()))\n\nc = Counter(a_list)\n\nall_count = 0\nfor value in c.values():\n if value == 1:\n continue\n else:\n tmp = int((value * (value - 1))/2)\n all_count += tmp\n\nfor i in a_list:\n print(all_count - c[i] + 1)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s069769074', 's182227687', 's206901337', 's263958003', 's800710908', 's248439356'] | [26780.0, 26780.0, 26780.0, 26780.0, 34624.0, 26780.0] | [357.0, 330.0, 312.0, 330.0, 2109.0, 321.0] | [353, 315, 351, 333, 747, 317] |
p02732 | u044220565 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ["# coding: utf-8\nN = int(input())\nA = input().split()\n\n\ndict = set(A)\ntotal_count = 0\nfor val in dict:\n tmp = A.count(val)\n tmp = int(tmp*(tmp-1)/2)\n total_count += tmp\n\n# substracted count\nfor k in range(N):\n tmp = A.count(A[k])\n sub_count = int(tmp*(tmp-1)/2)\n print('{}'.format(total_count - sub_count))", '# coding: utf-8\nimport sys\n#from operator import itemgetter\nsysread = sys.stdin.buffer.readline\nread = sys.stdin.buffer.read\n#from heapq import heappop, heappush\n#from collections import defaultdict\nsys.setrecursionlimit(10**7)\n#import math\n#from itertools import product#accumulate, combinations, product\n\n#import numpy as np\n#from copy import deepcopy\n#from collections import deque\ndef run():\n N = int(sysread())\n A = list(map(int, sysread().split()))\n count = [0] * (N+1)\n for val in A:\n count[val] += 1\n base_sum = 0\n for val in count:\n if val <= 1:continue\n base_sum += val * (val-1) // 2\n for i in range(N):\n if count[A[i]] == 1:\n print(base_sum)\n else:\n print(base_sum - count[A[i]] + 1)\nif __name__ == "__main__":\n run()\n'] | ['Wrong Answer', 'Accepted'] | ['s326172124', 's086835801'] | [22824.0, 20396.0] | [2105.0, 260.0] | [324, 842] |
p02732 | u046158516 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['N=int(input())\nm=list(map(ine,input().split()))\nt=[]\nfor i in range(N):\n t.append(0)\nfor i in range(N):\n t[m[i]-1]+=1\ntotal=0\nfor i in range(N):\n total+=(t[i]*(t[i]-1))//2\nfor i in range(N):\n if t[m[i]-1]<2:\n print(total)\n else:\n print(total-(t[m[i]-1]-1))', 'N=int(input())\nm=list(map(int,input().split()))\nt=[]\nfor i in range(N):\n t.append(0)\nfor i in range(N):\n t[m[i]-1]+=1\ntotal=0\nfor i in range(N):\n total+=(t[i]*(t[i]-1))//2\nfor i in range(N):\n if t[m[i]-1]<2:\n print(total)\n else:\n print(total-(t[m[i]-1]-1))'] | ['Runtime Error', 'Accepted'] | ['s599399385', 's463682041'] | [3064.0, 24748.0] | [17.0, 382.0] | [267, 267] |
p02732 | u046187684 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['from collections import Counter\n\n\ndef solve(string):\n n, *a = map(int, string.split())\n c = Counter(a)\n b = sum(v * (v - 1) // 2 for v in c.values())\n print(c, b)\n return "\\n".join(str(b - c[_a] + 1) for _a in a)\n\n\nif __name__ == \'__main__\':\n import sys\n print(solve(sys.stdin.read().strip()))\n', 'from collections import Counter\n\n\ndef solve(string):\n n, *a = map(int, string.split())\n c = Counter(a)\n b = sum(v * (v - 1) // 2 for v in c.values())\n return "\\n".join(str(b - c[_a] + 1) for _a in a)\n\n\nif __name__ == \'__main__\':\n import sys\n print(solve(sys.stdin.read().strip()))\n'] | ['Wrong Answer', 'Accepted'] | ['s677395242', 's255666672'] | [37388.0, 33548.0] | [305.0, 219.0] | [315, 299] |
p02732 | u051684204 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['N=int(input())\nA=list(map(int,input().split()))\nls=[0 for _ in range(N)]\nfor i in range(N):\n ls[A[i]-1]+=1\ns=0\nprint(ls)\nfor i in range(len(ls)):\n m=ls[i]*(ls[i]-1)//2\n s+=m\nfor j in range(N):\n print(s-(ls[A[j]-1]-1))', 'N=int(input())\nA=list(map(int,input().split()))\nls=[0 for _ in range(N)]\nfor i in range(N):\n ls[A[i]-1]+=1\ns=0\nfor i in range(len(ls)):\n m=ls[i]*(ls[i]-1)//2\n s+=m\nfor j in range(N):\n print(s-(ls[A[j]-1]-1))'] | ['Wrong Answer', 'Accepted'] | ['s507722891', 's167248189'] | [25716.0, 25716.0] | [373.0, 355.0] | [225, 215] |
p02732 | u052221988 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n = int(input())\nnumlist = [int(_) for _ in input().split()]\nsetnum = set(numlist)\nnsum = 0\n\nfor i in setnum:\n dicnum[i] = numlist.count(i)\n if dicnum[i] >= 2:\n nsum += dicnum[i]*(dicnum[i]-1)//2\n else:\n del dicnum[i]\n\nfor j in range(n):\n ans = nsum\n if numlist[j] in dicnum:\n ans = ans - dicnum[numlist[j]] + 1\n print(ans)', 'n = int(input())\nnumlist = [int(_) for _ in input().split()]\nnumdic = {}\nnsum = 0\n\nfor i in range(n):\n if numlist[i] in numdic:\n numdic[numlist[i]] += 1\n else:\n numdic[numlist[i]] = 1\n\nfor j in numdic:\n nsum += numdic[j] * (numdic[j] - 1) // 2\n\nfor k in range(n):\n ans = nsum\n if numdic[numlist[k]] >= 2:\n ans -= (numdic[numlist[k]]-1)\n print(ans)'] | ['Runtime Error', 'Accepted'] | ['s291556030', 's903819716'] | [25644.0, 25716.0] | [93.0, 407.0] | [362, 386] |
p02732 | u060793972 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ["import math\n\ndef ABC159D(a):\n if a<2:\n return 0\n else:\n return math.factorial(a)//math.factorial(a-2)//2\n\n\nn=int(input())\na=list(map(int,input().split()))\nd1=dict()\nfor i in a:\n if i not in d1:\n d1[i]=1\n else:\n d1[i] += 1\n#print(d1)\nd2={i:ABC159D(j) for i,j in d1.items()}\nd3={i:ABC159D(j-1)-d2[i] for i,j in d1.items()}\n#print(d2,d3)\np=sum(d2.values())\nprint(''.join([p+d3[i] for i in a]))", "import math\nfrom collections import Counter\n\ndef mycounter(d,i):\n if i in d:\n d[i]+=1\n else:\n d[i]=1\n return d\n \ndef ABC159D(a):\n if a<2:\n return 0\n else:\n return (a*(a-1))//2\n\nn=int(input())\na=list(map(int,input().split()))\nd = dict()\n\n# d=mycounter(d,i)\ndd=Counter(a)\n#print(d)\np=0\nfor i in dd.values():p+=ABC159D(i)\nprint('\\n'.join(map(str,[p-dd[i]+1 for i in a])))"] | ['Runtime Error', 'Accepted'] | ['s438645853', 's428704073'] | [41888.0, 38044.0] | [2104.0, 235.0] | [430, 429] |
p02732 | u068862829 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ["N = int(input())\nA = list(map(int, input().split()))\n\n# N = 5\n# A = [1, 1, 2, 1, 2]\n\nAset = set(A)\nlst = {}\nfor i in Aset:\n lst[i] = 0\n\n# print(lst)\n \nfor i in range(N):\n lst[A[i]] += 1\n\n# print(lst)\n\n \n\nfor i in lst:\n# print('i: {}'.format(i))\n c[i] = 0\n tmp_lst = dict(lst)\n# print('tmp_lst {}'.format(tmp_lst))\n# print('tmp_lst[i]: {}'.format(tmp_lst[i]))\n tmp_lst[i] -= 1\n# print('tmp_lst[i]: {}'.format(tmp_lst[i]))\n for j in tmp_lst:\n# print(tmp_lst[j])\n c[i] += tmp_lst[j]*(tmp_lst[j]-1)//2\n# print('c[i]: {}'.format(c[i]))\n \nfor i in range(N):\n print(int(c[A[i]]))", "N = int(input())\nA = list(map(int, input().split()))\n\n# N = 5\n# A = [1, 1, 2, 1, 2]\n\nAset = set(A)\nlst = {}\nfor i in Aset:\n lst[i] = 0\n\n# print(lst)\n \nfor i in range(N):\n lst[A[i]] += 1\n\n# print(lst)\n\n \n\nfor i in lst:\n# print('i: {}'.format(i))\n c[i] = 0\n tmp_lst = dict(lst)\n# print('tmp_lst {}'.format(tmp_lst))\n# print('tmp_lst[i]: {}'.format(tmp_lst[i]))\n tmp_lst[i] -= 1\n# print('tmp_lst[i]: {}'.format(tmp_lst[i]))\n for j in tmp_lst:\n# print(tmp_lst[j])\n c[i] += tmp_lst[j]*(tmp_lst[j]-1)//2\n# print('c[i]: {}'.format(c[i]))\n \nfor i in range(N):\n print(c[A[i]])", 'N = int(input())\nA = list(map(int, input().split()))\n\nAset = set(A)\nlst = {}\nfor i in Aset:\n lst[i] = 0\n \nfor i in range(N):\n lst[A[i]] += 1\n\nc = dict(lst) \n \n \nc_all = 0\nfor j in lst:\n c_all += lst[j]*(lst[j]-1)//2\n\nfor i in lst:\n c[i] = c_all\n c[i] = c[i] - lst[i]*(lst[i]-1)//2 + (lst[i]-1)*(lst[i]-2)//2\n \nfor i in range(N):\n print(c[A[i]])'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s541301591', 's795561080', 's075750647'] | [33136.0, 33088.0, 37760.0] | [159.0, 152.0, 455.0] | [814, 809, 600] |
p02732 | u070201429 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['#TLE\nn = int(input())\na = input().split()\ndic = {}\nans = 0\nfor i in range(n):\n if a[i] in dic:\n ans += dic[a[i]]\n else:\n num = a.count(a[i]) - 1\n ans += num\n dic[a[i]] = num\nans /= 2\nfor i in range(n):\n print(int(ans - dic[a[i]]))\nprint(dic)', '#TLE\nn = int(input())\na = input().split()\nans = 0\nimport collections\ndic = collections.Counter(a)\nfor i in dic.values():\n ans += i * (i-1)\nans /= 2\nfor i in range(n):\n print(int(ans - dic[a[i]] + 1))'] | ['Wrong Answer', 'Accepted'] | ['s769399658', 's391800010'] | [20764.0, 26752.0] | [2105.0, 400.0] | [278, 205] |
p02732 | u075012704 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['N = int(input())\nA = list(map(int, input().split()))\n \nD = defaultdict(int)\nfor a in A:\n D[a] += 1\n \nans_base = 0\nfor v in D.values():\n ans_base += v * (v - 1) // 2\n \nfor a in A:\n print(ans_base - (D[a] * (D[a] - 1) // 2) + ((D[a] - 1) * (D[a] - 2) // 2))', 'from collections import defaultdict\nN = int(input())\nA = list(map(int, input().split()))\n\nD = defaultdict(int)\nfor a in A:\n D[a] += 1\n\nans_base = 0\nfor v in D.values():\n ans_base += v * (v - 1) // 2\n\nfor a in A:\n print(ans_base - (D[a] * (D[a] - 1) // 2) + ((D[a] - 1) * (D[a] - 2) // 2))\n'] | ['Runtime Error', 'Accepted'] | ['s346201973', 's166651525'] | [26140.0, 26772.0] | [65.0, 412.0] | [264, 298] |
p02732 | u075304271 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['def solve():\n n = int(input())\n a = list(map(int, input().split()))\n c = collections.Counter(a)\n s = 0\n for i in list(c.values()):\n s += i*(i-1)//2\n print(c)\n for i in a:\n print(c[i])\n print(s-(c[i]-1))\n return 0\n \nif __name__ == "__main__":\n solve()\n', 'import numpy as np\nimport functools\nimport math\nimport collections\nimport scipy\nimport fractions\nimport itertools\n\ndef solve():\n n = int(input())\n a = list(map(int, input().split()))\n c = collections.Counter(a)\n s = 0\n for i in list(c.values()):\n s += i*(i-1)//2\n print(c)\n for i in a:\n print(s-(c[i]-1))\n return 0\n \nif __name__ == "__main__":\n solve()\n', 'import functools\nimport math\nimport collections\nimport scipy\nimport fractions\nimport itertools\n\ndef solve():\n n = int(input())\n a = list(map(int, input().split()))\n c = collections.Counter(a)\n s = 0\n for i in list(c.values()):\n s += i*(i-1)//2\n print(c)\n for i in a:\n print(c[i])\n print(s-(c[i]-1))\n return 0\n \nif __name__ == "__main__":\n solve()\n', 'import numpy as np\nimport functools\nimport math\nimport collections\nimport scipy\nimport fractions\nimport itertools\n\ndef solve():\n n = int(input())\n a = list(map(int, input().split()))\n c = collections.Counter(a)\n s = 0\n for i in list(c.values()):\n s += i*(i-1)//2\n for i in a:\n print(s-(c[i]-1))\n return 0\n \nif __name__ == "__main__":\n solve()\n'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s474606503', 's635764225', 's805363070', 's895329542'] | [26268.0, 45888.0, 46016.0, 36308.0] | [67.0, 539.0, 720.0, 458.0] | [269, 368, 365, 357] |
p02732 | u078816252 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['N = int(input())\nA = list(map(int,input().split()))\nmaxim = max(A)\nselect_num = [0 for i in range(0,maxim+1)]\nselect_num2 = [0 for i in range(0,maxim+1)]\ncount_num = [0 for i in range(0,maxim+1)]\nfor i in range(1,maxim+1):\n count_num[i] = A.count(i)\n if(count_num[i] > 1):\n select_num[i] = (count_num[i] - 0)*(count_num[i] - 1)//2\n \tselect_num2[i] = count_num[i] - 1\nsumS = sum(select_num)\nfor i in range(N):\n print(sumS -select_num2[A[i]])', 'N = int(input())\nA = list(map(int,input().split()))\n\nselect_num = 0\ncount_num = [0]*(N+1)\nfor i in A:\n count_num[i] += 1\nfor i in range(1,N+1):\n select_num += (count_num[i])*(count_num[i] - 1)//2\nfor i in A:\n print(select_num -count_num[i] + 1)'] | ['Runtime Error', 'Accepted'] | ['s360159552', 's168461853'] | [3064.0, 26268.0] | [17.0, 306.0] | [447, 247] |
p02732 | u078982327 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['m = int(input())\nq_list = list(map(int, input().strip().split()))\nn = [0] * m\nk = [0] * m\n\nfor i in q_list:\n n[i - 1] += 1\nfor j, l in zip(range(m), n):\n k[j] = int(l * (l - 1)/2)\nsum_n = sum(k)\n\nfor j in q_list:\n print(sum_n - n[j - 1]-1)\n', 'm = int(input())\nq_list = list(map(int, input().strip().split()))\nn = [0] * m\nk = [0] * m\n\nfor i in q_list:\n n[i - 1] += 1\nfor j, l in zip(range(m), n):\n k[j] = int(l * (l - 1)/2)\nsum_n = sum(k)\n\nfor j in q_list:\n print(sum_n - n[j - 1] + 1)\n'] | ['Wrong Answer', 'Accepted'] | ['s966716221', 's217449968'] | [24748.0, 26012.0] | [340.0, 325.0] | [249, 251] |
p02732 | u079022116 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import collections\nn = int(input())\na_list = list(map(int,input().split()))\nc=collections.Counter(a_list)\nresult=0\nprint(c)\n\nfor i in c.values():\n result+=i * (i - 1)//2\n\nfor a in a_list:\n print(result - c[a] + 1) ', 'import collections\nn = int(input())\na_list = list(map(int,input().split()))\nc=collections.Counter(a_list)\nresult=0\n\nfor i in c.values():\n result+=i * (i - 1)//2\n\nfor a in a_list:\n minus=-(c[a]) * (c[a]-1)//2\n plus=(c[a]-1) * (c[a]-2)//2\n print(result + minus + plus) '] | ['Wrong Answer', 'Accepted'] | ['s303631681', 's453836535'] | [35996.0, 26780.0] | [435.0, 475.0] | [221, 280] |
p02732 | u079022693 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['from sys import stdin\ndef main():\n \n readline=stdin.readline\n N=int(readline())\n A=list(map(int,readline().split()))\n\n li=[[0,0] for _ in range(N+1)]\n di=dict()\n print(li)\n for i in range(N):\n if A[i] not in di:\n di[A[i]]=1\n else:\n di[A[i]]+=1\n \n for k,v in di.items():\n li[k][0]=v*(v-1)//2\n li[k][1]=(v-1)*(v-2)//2\n\n s=0\n for i in range(N):\n s+=li[i][0]\n\n for i in range(N):\n print(s-li[A[i]][0]+li[A[i]][1])\nif __name__=="__main__":\n main()', 'from sys import stdin\ndef main():\n \n readline=stdin.readline\n N=int(readline())\n A=list(map(int,readline().split()))\n\n li=[[0,0] for _ in range(N+1)]\n di=dict()\n for i in range(N):\n if A[i] not in di:\n di[A[i]]=1\n else:\n di[A[i]]+=1\n \n s=0\n for k,v in di.items():\n li[k][0]=v*(v-1)//2\n s+=v*(v-1)//2\n li[k][1]=(v-1)*(v-2)//2\n\n for i in range(N):\n print(s-li[A[i]][0]+li[A[i]][1])\n\nif __name__=="__main__":\n main()'] | ['Wrong Answer', 'Accepted'] | ['s703018926', 's829207099'] | [46328.0, 43732.0] | [497.0, 456.0] | [555, 520] |
p02732 | u086438369 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n = int(input())\nan = list(map(int, input().split()))\nn_list = [0]*n\n\nfor i in range(n):\n n_list[an[i]-1] += 1\n\nfor j in range(n):\n n_list1 = n_list[:]\n n_list1[an[j]-1] -= 1\n answer = 0\n for k in n_list1:\n answer += k*(k-1)/2\n print(answer)\n ', 'n = int(input())\nan = list(map(int, input().split()))\nn_list = [0]*n\n\nfor i in range(n):\n n_list[an[i]-1] += 1\nn_sum = int(sum([x*(x-1)/2 for x in n_list]))\n\nfor j in range(n):\n n_remove = n_list[an[j]-1] - 1\n print(n_sum - n_remove)\n'] | ['Wrong Answer', 'Accepted'] | ['s149058930', 's941172887'] | [24748.0, 25004.0] | [2104.0, 343.0] | [253, 237] |
p02732 | u088063513 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['## coding: UTF-8\n\nfrom decimal import *\nfrom itertools import permutations, combinations,combinations_with_replacement,product\n\nN = int(input())\n\ns = input().split()\np = [int(w) for w in s]\nprint(\'p:{}\'.format(p))\n\nnumber_list = []\n\'\'\'\nfor i in range(N):\n counter = 0\n for j in range(N):\n if(p[j] == i+1):\n counter +=1\n number_list.append(counter)\n\'\'\'\nfor i in range(N):\n #print(mylist.count("A"))\n number_list.append(p.count(i+1))\n#print(\'number_list:{}\'.format(number_list))\n\ndef n_C_2(n):\n if(n == -1):\n return 0\n else:\n return int(n * (n-1) / 2)\n\n\nfull_combi = []\npickup_combi = []\nprint_combi = []\n\nfor i in range(N):\n full_combi.append(n_C_2(number_list[i]))\n pickup_combi.append(n_C_2(number_list[i] - 1))\n#print(\'full_combi:{}\'.format(full_combi))\n#print(\'pickup_combi:{}\'.format(pickup_combi))\n\nfor i in range(N):\n print_combi.append(sum(full_combi) - full_combi[i] + pickup_combi[i])\n#print(\'print_combi:{}\'.format(print_combi))\n\nfor i in range(N):\n index = p[i] - 1\n print(print_combi[index])', "## coding: UTF-8\n\nfrom decimal import *\nfrom itertools import permutations, combinations,combinations_with_replacement,product\n\nN = int(input())\n\ns = input().split()\np = [int(w) for w in s]\n#print('p:{}'.format(p))\n\nnumber_list = [0 for i in range(N)]\n'''\nfor i in range(N):\n counter = 0\n for j in range(N):\n if(p[j] == i+1):\n counter +=1\n number_list.append(counter)\n'''\n#print(number_list)\n\nfor i in range(N):\n number_list[p[i] - 1] += 1\n#print(number_list)\n\n\n\ndef n_C_2(n):\n if(n == -1):\n return 0\n else:\n return int(n * (n-1) / 2)\n\n\nfull_combi = []\npickup_combi = []\nprint_combi = []\n\nfor i in range(N):\n full_combi.append(n_C_2(number_list[i]))\n pickup_combi.append(n_C_2(number_list[i] - 1))\n#print('full_combi:{}'.format(full_combi))\n#print('pickup_combi:{}'.format(pickup_combi))\n\nall_full = sum(full_combi)\nfor i in range(N):\n print_combi.append(all_full - full_combi[i] + pickup_combi[i])\n#print('print_combi:{}'.format(print_combi))\n\nfor i in range(N):\n index = p[i] - 1\n print(print_combi[index])"] | ['Wrong Answer', 'Accepted'] | ['s963266980', 's190961158'] | [31620.0, 44940.0] | [2105.0, 564.0] | [1149, 1151] |
p02732 | u089142196 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import copy\nfrom scipy.misc import comb\nfrom collections import Counter\n\nN=int(input())\nA=list(map(int,input().split() ))\nB=[-1]*N \n\nf_cnt=Counter(A)\nf_dic=dict(f_cnt)\n\nfor i,item in enumerate(A):\n if B[item-1]>-1:\n print(B[item-1])\n else:\n D=copy.deepcopy(f_dic)\n D[item] -= 1\n opt=0\n for item3 in D:\n if D[item3]>=2:\n opt += comb(D[item3],2,exact=True)\n B[item-1]=opt\n print(opt)\n', 'import copy\nfrom scipy.misc import comb\nfrom collections import Counter\n\nN=int(input())\nA=list(map(int,input().split() ))\nB=[-1]*N \n\nf_cnt=Counter(A)\nf_dic=dict(f_cnt)\n\nfor i,item in enumerate(A):\n if B[item-1]>-1:\n print(B[item-1])\n else:\n D=copy.deepcopy(f_dic)\n D[item] -= 1\n opt=0\n for item3 in D:\n if D[item3]>=2:\n opt += D[item3]*(D[item3]-1)//2\n B[item-1]=opt\n print(opt)\n', 'from scipy.misc import comb\nfrom collections import Counter\n\nN=int(input())\nA=list(map(int,input().split() ))\nB=[-1]*N \n\nfor i,item in enumerate(A):\n if B[item-1]>-1:\n \n #print(i,B[item-1],"done")\n print(B[item-1])\n else:\n C=A[0:i]+A[i+1:] \n cnt = Counter(C)\n D=dict(cnt)\n E=[]\n for item2 in D:\n if D[item2]>=2:\n E.append(D[item2])\n #print(i,E)\n opt=0\n for item3 in E:\n opt += comb(item3,2,exact=True)\n B[item-1]=opt\n #print(i,opt)\n print(opt)\n #print(i,E,opt)\n #print(C,cnt)', 'N=int(input())\nA=list(map(int,input().split() ))\nfrom collections import Counter\nd=dict(Counter(A))\nprint(d)\ncnt=0\nfor item in d:\n cnt += (d[item])*(d[item]-1)//2\n\nprint("cnt",cnt)\n \nfor num in A:\n new = max(0, (d[num]-1)*(d[num]-2)//2)\n print(cnt- d[num]*(d[num]-1)//2 + new)', 'import copy\nfrom scipy.misc import comb\nfrom collections import Counter\n\nN=int(input())\nA=list(map(int,input().split() ))\nB=[-1]*N \n\nf_cnt=Counter(A)\nf_dic=dict(f_cnt)\n#print("first",f_dic)\n#f_dic[1] += -1 \n#print(f_dic)\n\nfor i,item in enumerate(A):\n if B[item-1]>-1:\n \n #print(i,B[item-1],"done")\n print(B[item-1])\n else:\n \n #cnt = Counter(C)\n #D=dict(cnt)\n D=copy.deepcopy(f_dic)\n D[item] -= 1\n E=[]\n for item2 in D:\n if D[item2]>=2:\n E.append(D[item2])\n #print(i,f_dic,D,E)\n opt=0\n for item3 in E:\n opt += comb(item3,2,exact=True)\n B[item-1]=opt\n #print(i,opt)\n print(opt)\n #print(i,E,opt)\n #print(C,cnt)\n', 'N=int(input())\nA=list(map(int,input().split() ))\nfrom collections import Counter\nd=dict(Counter(A))\n#print(d)\ncnt=0\nfor item in d:\n cnt += (d[item])*(d[item]-1)//2\n\n#print("cnt",cnt)\n \nfor num in A:\n new = max(0, (d[num]-1)*(d[num]-2)//2)\n print(cnt- d[num]*(d[num]-1)//2 + new)'] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Wrong Answer', 'Time Limit Exceeded', 'Accepted'] | ['s038309115', 's250542297', 's678696513', 's734295965', 's774974778', 's607369479'] | [55708.0, 53676.0, 54676.0, 27040.0, 56064.0, 27732.0] | [2110.0, 2110.0, 2110.0, 467.0, 2110.0, 442.0] | [457, 454, 639, 287, 796, 289] |
p02732 | u089504174 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n=int(input())\na=list(map(int,input().split()))\nc=[0]*n\n\nall=0\nfor i in range(n):\n c[a[i]-1]+=1\nfor i in range(n):\n if c[i]>=2:\n d=c[i]*(c[i]-1)/2\n all+=d\nfor i in range(n):\n print(all-(c[a[i]-1]-1))', 'n=int(input())\na=list(map(int,input().split()))\nc=[0]*n\n\nall=0\nfor i in range(n):\n c[a[i]-1]+=1\nfor i in range(n):\n if c[i]>=2:\n d=c[i]*(c[i]-1)/2\n all+=d\nfor i in range(n):\n print(int(all-(c[a[i]-1]-1)))'] | ['Wrong Answer', 'Accepted'] | ['s437271233', 's303658178'] | [25716.0, 24996.0] | [422.0, 365.0] | [286, 291] |
p02732 | u091307273 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['from collections import Counter\n\ndef main():\n n = int(input())\n balls = [int(i) for i in input().split()]\n\n # v - value written on ball\n # b - ball index in [0, n)\n # ct - number of times a value occurs\n\n # hist[v] = ct\n hist = Counter(balls)\n\n # counts[b] = ct \n counts = [ hist[balls[b]] for b in range(n) ]\n\n diff_counts = set(hist.values())\n # combos[ct] = number of combos with ct - 1\n combos1 = { ct: 0 if ct == 1 else (ct-1) * (ct-2) // 2 for ct in\n diff_counts }\n combos = { ct: ct * (ct-1) // 2 for ct in diff_counts }\n\n for k in range(n):\n ans = sum(combos.values()) - combos[counts[k]] + combos1[counts[k]]\n print(ans)\n\n', 'from collections import Counter\n\ndef main():\n n = int(input())\n balls = [int(i) for i in input().split()]\n\n # v - value written on ball\n # b - ball index in [0, n)\n # ct - number of times a value occurs\n\n # hist[v] = ct\n hist = Counter(balls)\n diff_counts = set(hist.values())\n combos1 = { ct: 0 if ct == 1 else (ct-1) * (ct-2) // 2 for ct in\n diff_counts }\n combos = { ct: ct * (ct-1) // 2 for ct in diff_counts }\n\n tot = sum(combos[hist[v2]] for v2 in hist.keys())\n\n for b in range(n):\n v = balls[b]\n ct = hist[v]\n print(tot - combos[ct] + combos1[ct])\n\nmain()\n'] | ['Wrong Answer', 'Accepted'] | ['s363314504', 's839118127'] | [9360.0, 34028.0] | [27.0, 226.0] | [699, 632] |
p02732 | u092387689 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import collections\n\nN = int(input())\nnum_list = list(map(int,input().split()))\nmemo = [0]*(N+1)\nmemo_flg = [False]*(N+1)\ncounter = [0] * (N+1)\ncounter_ans = [0] * (N+1)\n\nfor i in range(N):\n counter_ans[i] = (counter[i]*(counter[i]-1))//2\n\nfor i in num_list:\n counter[i] += 1\n\nall_sum = sum(counter_ans)\ndef calc(k):\n num = num_list[k]\n \n if(memo_flg[num] is True):\n return memo[num]\n ans = 0\n \n wrong = counter_ans[num]\n c = counter[num]-1\n right = (c*(c-1))//2\n \n ans = all_sum - wrong + right\n memo[num] = ans\n memo_flg[num] = True\n return ans\n\n[print(calc(i)) for i in range(N)]\n', 'import collections\n\nN = int(input())\nnum_list = list(map(int,input().split()))\nmemo = [0]*(N+1)\nmemo_flg = [False]*(N+1)\ncounter = [0] * (N+1)\ncounter_ans = [0] * (N+1)\n\nfor i in num_list:\n counter[i] += 1\nfor i in range(N+1):\n counter_ans[i] = (counter[i]*(counter[i]-1))//2\n\nall_sum = sum(counter_ans)\ndef calc(k):\n num = num_list[k]\n \n if(memo_flg[num] is True):\n return memo[num]\n ans = 0\n \n wrong = counter_ans[num]\n c = counter[num]-1\n right = (c*(c-1))//2\n \n ans = all_sum - wrong + right\n memo[num] = ans\n memo_flg[num] = True\n return ans\n\n[print(calc(i)) for i in range(N)]\n'] | ['Wrong Answer', 'Accepted'] | ['s405862760', 's999198491'] | [26780.0, 26780.0] | [382.0, 423.0] | [634, 635] |
p02732 | u093861603 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n=int(input())\nal=list(map(int,input().split()))\n\ncounter=[0]*(n+1)\nfor a in al:\n nums[a]+=1\n\nsum=0\nfor c in counter:\n sum+=c*(c-1)//2\n\nfor a in al:\n print(sum-(counter[a]-1))\n', 'n=int(input())\nal=list(map(int,input().split()))\n\ncounter=[0]*n\nfor a in al:\n nums[a]+=1\n\nsum=0\nfor c in counter:\n sum+=c*(c-1)//2\n\nfor a in al:\n print(sum-(counter[a]-1))\n', 'n=int(input())\nal=list(map(int,input().split()))\n\ncounter=[0]*(n+1)\nfor a in al:\n counter[a]+=1\n\nsum=0\nfor c in counter:\n sum+=c*(c-1)//2\n\nfor a in al:\n print(sum-(counter[a]-1))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s197244731', 's629162765', 's261168735'] | [26268.0, 26268.0, 24872.0] | [67.0, 68.0, 293.0] | [185, 181, 188] |
p02732 | u094103573 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ["import math\n\n\ndef combinations_count(n, r):\n if n == 1:\n return 0\n if n == 0:\n return 0\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nif __name__ == '__main__':\n\n N= int(input())\n\n a = list(map(int, input().split()))\n\n for i in range(N):\n total = 0\n\n b = a[:i] + a[i+1:]\n\n c = collections.Counter(b)\n\n for j in set(a):\n\n total = total + combinations_count(c[j], 2)\n\n print(total)", "import collections\nimport math\n\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nif __name__ == '__main__':\n N= int(input())\n a = list(map(int, input().split()))\n c = collections.Counter(a)\n result = 0\n for i in set(a):\n result += combinations_count(c[i], 2)\n\n for i in a:\n d = c[i]\n print(result - combinations_count(d, 2) + combinations_count(d-1, 2))", "import collections\nimport math\n\n\nif __name__ == '__main__':\n N= int(input())\n a = list(map(int, input().split()))\n c = collections.Counter(a)\n result = 0\n for i in set(a):\n \n result += (c[i]*(c[i]-1))/2\n\n for i in a:\n d = c[i]\n print(int(result - (d*(d-1))/2 + ((d-1)*(d-2))/2))"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s363313880', 's403345199', 's463253917'] | [26140.0, 26780.0, 26780.0] | [72.0, 2104.0, 490.0] | [508, 475, 352] |
p02732 | u103520789 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['from collections import Counter\n\nN = int(input())\nA_array = map(int, input().split())\nAi_dict = Counter(A_array)\n\n\ndef calc_comb(Ai, dictionary):\n num = 0\n for k,v in dictionary.items():\n if k == Ai:\n N_Ai = v -1 \n else:\n N_Ai = v\n num += N_Ai*(N_Ai-1)/2\n return int(num)\n\nfor n in A_array:\n print(calc_comb(n, Ai_dict))\n', 'from collections import Counter\n\nN = int(input())\nA_array = list(map(int, input().split()))\nAi_dict = Counter(A_array)\n\n\ndef calc_comb(dct):\n num = 0\n for k,v in dct.items():\n num += v*(v-1)/2\n return int(num)\n\n\nres_dict = dict([])\nTotalComb = calc_comb(Ai_dict)\n\nfor n in A_array:\n if not n in res_dict.keys():\n res_dict[n] = TotalComb - Ai_dict[n]+1\n print(res_dict[n])\n'] | ['Wrong Answer', 'Accepted'] | ['s449556194', 's868668546'] | [29468.0, 35224.0] | [104.0, 498.0] | [395, 401] |
p02732 | u103724957 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ["import collections\n\nn = int(input())\na = [int(i) for i in input().split(' ')]\nc = collections.Counter(a)\ncounts = {}\nall_sum = 0\nfor k, v in c.items():\n val = v * (v-1) / 2\n counts[k] = val\n all_sum += val\n\nfor i in range(n):\n k = a[i]\n count = c[k] - 1\n val = counts[k]\n print(all_sum - val + count * (count - 1) / 2)\n", "import collections\n\nn = int(input())\na = [int(i) for i in input().split(' ')]\nc = collections.Counter(a)\ncounts = {}\nall_sum = 0\nfor k, v in c.items():\n val = v * (v-1) / 2\n counts[k] = val\n all_sum += val\n\nfor i in range(n):\n k = a[i]\n count = c[k] - 1\n val = counts[k]\n print(int(all_sum - val + count * (count - 1) / 2))\n"] | ['Wrong Answer', 'Accepted'] | ['s835531943', 's388254091'] | [34460.0, 31752.0] | [558.0, 512.0] | [340, 345] |
p02732 | u106342872 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n = int(input())\na = list(map(int, input().split()))\n\narr = [0]*(n+1)\nfor i in range(n):\n arr[a[i]] += 1\n\nfrom scipy.misc import comb\n\nc = [0]*(n+1)\nfor i in range(n+1):\n c[i] = int(comb(arr[i],2))\n\nd = [0]*(n+1)\nfor i in range(n+1):\n d[i] = int(comb(arr[i]-1,2))\n\n\nfor k in range(n):\n ans = sum(c[:a[k]]) + sum(c[a[k]+1:]) + d[a[k]]\n print(ans)\n', 'n = int(input())\na = list(map(int, input().split()))\n\nnums = [0] * (max(a) + 1)\nfor i in range(len(a)):\n nums[a[i]] += 1\n\nfrom scipy.special import comb\n\nall = 0\nfor i in range(len(nums)):\n all += comb(nums[i], 2, exact=True)\n\nfor k in range(n):\n print(all - (nums[a[k]] - 1))\n'] | ['Wrong Answer', 'Accepted'] | ['s103284991', 's554061111'] | [26584.0, 51356.0] | [2109.0, 592.0] | [361, 286] |
p02732 | u106778233 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n=int(input())\na=list(map(int,input().split()))\nsum=0\nm=len(a)\nc=list(set(a))\nsum1=0\n\nfor i in range(len(c)):\n k=c.count(c[i])\n sum1+=k*(k-1)//2\n \nfor j in range(m):\n g=a.count(a[i])\n t=sum1-(g*(g-1))//2+((g-1)*(g-2))//2\n print(t)', 'import collections\nfrom collections import defaultdict\n\nn = int(input())\nl = list(map(int, input().split()))\n\ndict = defaultdict(int)\nfor i in l:\n dict[i]+=1\n\nans = 0\nfor v in dict.values():\n ans += int((v*(v-1)) // 2)\n\nfor k in l:\n print(ans - (dict[k] - 1))'] | ['Wrong Answer', 'Accepted'] | ['s751536785', 's232931196'] | [26140.0, 26780.0] | [2104.0, 338.0] | [248, 268] |
p02732 | u111473084 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\nc = dict(Counter(a))\nans = 0\nfor v in c.values():\n ans += v*(v-1)//2\nfor i in range(n):\n print(ans-a[i]-1)\n', 'from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\nc = dict(Counter(a))\nans = 0\nfor v in c.values():\n ans += v*(v-1)//2\nfor i in range(n):\n print(ans-c[a[i]]+1)\n'] | ['Wrong Answer', 'Accepted'] | ['s146744732', 's610417301'] | [26780.0, 26780.0] | [293.0, 350.0] | [199, 202] |
p02732 | u111652094 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['N=int(input())\nA=list(map(int,input().split()))\nC=[]\n\nans1=0\ns=0\nfor i in range(1,N+1):\n a=A.count(i)\n C.append(a)\nfor j in range(N):\n c=C[j]\n if c>1:\n s=c*(c-1)/2\n ans1=ans1+s\nfor k in range(N):\n b=A[k]-1\n ans=ans1-(C[b]+1)\n print(ans)', 'N=int(input())\nA=list(map(int,input().split()))\nC=[0]*(N+1)\n\nans1=0\ns=0\n\nfor A_i in A:\n C[A_i]+=1\n\nfor j in range(1,N+1):\n c=C[j]\n if c>1:\n s=c*(c-1)/2\n ans1=ans1+s\n \nfor A_k in A:\n d=C[A_k]\n if d<2:\n ans=ans1\n else:\n ans=ans1-(d-1)\n print(int(ans))'] | ['Wrong Answer', 'Accepted'] | ['s632780188', 's796142661'] | [24748.0, 25716.0] | [2104.0, 341.0] | [271, 305] |
p02732 | u112007848 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import math\n\ndef comb(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn = (int)(input())\na = list(map(int, input().split(" ")))\ntemp = [0 for i in range(n + 1)]\naaa = sorted(a)\ncount = 0\nfor i in range(n - 1):\n if aaa[i] == aaa[i + 1]:\n count+= 1\n else:\n temp[aaa[i]] = count + 1\n count = 0\nelse:\n if len(a) == 1:\n temp[aaa[0]] = 1\n else:\n temp[aaa[-1]] = count + 1\nans = 0\n\nfor i in range(n + 1):\n if temp[i] >= 2:\n ans += comb(temp[i], 2)', 'import math\n\ndef comb(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn = (int)(input())\na = list(map(int, input().split(" ")))\ntemp = [0 for i in range(n + 1)]\naaa = sorted(a)\ncount = 0\nfor i in range(n - 1):\n if aaa[i] == aaa[i + 1]:\n count+= 1\n else:\n temp[aaa[i]] = count + 1\n count = 0\nelse:\n if len(a) == 1:\n temp[aaa[0]] = 1\n else:\n temp[aaa[-1]] = count + 1\nans = 0\n\n\n\n\nfor i in range(n + 1):\n if temp[i] >= 2:\n ans += temp[i] * (temp[i] - 1) / 2\n \n\n\n\n\nfor i in range(n):\n kotae = ans\n if temp[a[i]] >= 3:\n #print(ans, comb(temp[a[i]], 2), comb(temp[a[i]] - 1, 2))\n kotae = ans - (temp[i] * (temp[i] - 1) / 2) + (temp[i] - 1 * (temp[i] - 2) / 2)\n elif temp[a[i]] == 2:\n kotae = ans -1\n print((int)(kotae))', 'import math\n\ndef comb(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn = (int)(input())\na = list(map(int, input().split(" ")))\ntemp = [0 for i in range(n + 1)]\naaa = sorted(a)\ncount = 0\nfor i in range(n - 1):\n if aaa[i] == aaa[i + 1]:\n count+= 1\n else:\n temp[aaa[i]] = count + 1\n count = 0\nelse:\n if len(a) == 1:\n temp[aaa[0]] = 1\n else:\n temp[aaa[-1]] = count + 1\nans = 0\n\n', 'n = (int)(input())\na = list(map(int, input().split(" ")))\ntemp = [0 for i in range(n + 1)]\naaa = sorted(a)\ncount = 0\nfor i in range(n - 1):\n if aaa[i] == aaa[i + 1]:\n count+= 1\n else:\n temp[aaa[i]] = count + 1\n count = 0\nelse:\n if len(a) == 1:\n temp[aaa[0]] = 1\n else:\n temp[aaa[-1]] = count + 1\nans = 0\n\n\n\n\nfor i in range(n + 1):\n if temp[i] >= 2:\n ans += temp[i] * (temp[i] - 1) / 2\n \n\n\n\n\nfor i in range(n):\n kotae = ans\n if temp[a[i]] >= 3:\n #print(ans, comb(temp[a[i]], 2), comb(temp[a[i]] - 1, 2))\n #print(temp[a[i]], i)\n kotae = ans - (temp[a[i]] * (temp[a[i]] - 1) / 2) + ((temp[a[i]] - 1) * (temp[a[i]] - 2) / 2)\n elif temp[a[i]] == 2:\n kotae = ans -1\n print((int)(kotae))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s053574490', 's245939588', 's890896638', 's040185384'] | [25644.0, 26140.0, 26268.0, 26140.0] | [1553.0, 554.0, 231.0, 528.0] | [534, 935, 465, 871] |
p02732 | u113569368 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\n\ncA = Counter(A)\n\nallS = 0\nfor key in cA:\n allS += cA[key] * (cA[key] - 1) / 2\n\nfor i in range(N):\n if i in cA.keys():\n print(int(allS - (cA[i] - 1)))\n else:\n print(int(allS))', 'from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\n\ncA = Counter(A)\n\nallS = 0\nfor key in cA:\n allS += cA[key] * (cA[key] - 1) / 2\n\nfor i in range(N):\n if A[i] in cA.keys():\n print(int(allS - (cA[A[i]] - 1)))\n else:\n print(int(allS))'] | ['Wrong Answer', 'Accepted'] | ['s948153340', 's247230007'] | [34128.0, 33952.0] | [258.0, 279.0] | [284, 290] |
p02732 | u113991073 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ["def main():\n from collections import Counter\n n=int(input())\n a=list(map(int,input().split()))\n\n q = Counter(a)\n a_cn = sum(x * (x - 1) // 2 for x in q.values())\n\n ans = []\n for x in a:\n ans.append(a_cn - q[x] + 1)\n\n print(ans, sep='\\n')\n\n\nif __name__ == '__main__':\n main()", "def main():\n from collections import Counter\n n=int(input())\n a=list(map(int,input().split()))\n\n q = Counter(a)\n a_cn = sum(x * (x - 1) // 2 for x in q.values())\n\n ans = []\n for x in a:\n ans.append(a_cn - q[x] + 1)\n\n print(*ans, sep='\\n')\n\n\nif __name__ == '__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s647729444', 's576332142'] | [31100.0, 30008.0] | [185.0, 275.0] | [308, 309] |
p02732 | u116038906 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['\nN = int(input())\nk = list(map(int, input().split()))\n\n\nfrom collections import Counter\nA =Counter(k)\n\n\nfrom math import factorial\ndef kumiawase_num(n, r): \n if n<r:\n return 0\n return factorial(n) // (factorial(n - r) * factorial(r))\n\n\nfrom collections import OrderedDict\nD = OrderedDict()\nD2 = OrderedDict()\n\nfor i,v in enumerate(k):\n D[i] =[ kumiawase_num(A[ij]-1,2) for ij,vj in A.items() if v == ij ]\n D2[i] = [ kumiawase_num(A[ij] ,2) for ij,vj in A.items() if v != ij ] \n\nD3 = [ sum(i) + sum(v) for i,v in zip(D.values(),D2.values()) ] ', '\nN = int(input())\nk = list(map(int, input().split()))\n\n\nfrom collections import Counter\nA =Counter(k)\n\n\nfrom math import factorial\ndef kumiawase_num(n, r): \n if n<r:\n return 0\n return factorial(n) // (factorial(n - r) * factorial(r))\n\n\nfrom collections import OrderedDict\nD = OrderedDict()\nD2 = OrderedDict()\n\nfor i,v in enumerate(k):\n D[i] =[ kumiawase_num(A[ij]-1,2) for ij,vj in A.items() if v == ij ]\n D2[i] = [ kumiawase_num(A[ij] ,2) for ij,vj in A.items() if v != ij ] \n\nD3 = [ sum(i) + sum(v) for i,v in zip(D.values(),D2.values()) ] ', 'from collections import Counter \nN = int(input())\nA = list(map(int, input().split()))\nc_A = Counter(A)\nall =sum( [i*(i-1)//2 for i in c_A.values()] )\n\nfor i in range(N):\n ans =all -( c_A[A[i]] -1)\n print(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s113259252', 's453522408', 's039252901'] | [53536.0, 48868.0, 26780.0] | [2107.0, 2106.0, 332.0] | [737, 737, 214] |
p02732 | u118665579 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['N = int(input())\nA = [int(i) for i in input().split()]\nprint(A)\na = 0\nfor i in range(N):\n tmp = A[:i]\n tmp.extend(A[i+1:])\n for j in range(N-2):\n for k in range(N-1-j):\n if tmp[j] == tmp[k]:\n a += 1\nprint(a)', 'N = int(input())\nA = [int(i) for i in input().split()]\na = 0\nb = []\n\nfor i in range(N):\n c=0\n for j in range(N):\n if A[i] == A[j]:\n c+=1\n c-=1\n b.append(c)\n a+=c\na/2\nfor i in range(N):\n print(a-b[i])', 'n = int(input())\na = list(map(int, input().split()))\n\ncnt = [0] * n\nfor i in a:\n cnt[i-1] += 1\nt=0\nfor i in cnt:\n t += i * (i-1)\nt/=2\nfor i in a:\n print(int(t-(cnt[i-1]-1)))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s552870049', 's691788229', 's928485901'] | [26268.0, 26268.0, 26268.0] | [2105.0, 2104.0, 338.0] | [249, 235, 182] |
p02732 | u119655368 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import collections\n\ndef count_defaultdict(it):\n counter = collections.defaultdict(int)\n for x in it:\n counter[x] += 1\n return dict(counter)\n \nn = int(input())\nl = list(map(int, input().split()))\nall_sum = 0\ncount = count_defaultdict(l)\nfor k, v in count:\n all_sum += v * (v - 1) // 2\nfor i in range(len(l)):\n if count[l[i]] > 1:\n v = count[l[i]]\n print(all_sum - v * (v-1) // 2 + (v-1) * (v-2)//2)\n else:\n print(all_sum)', 'import collections\ndef count_defaultdict(it):\n counter = collections.defaultdict(int)\n for x in it:\n counter[x] += 1\n return dict(counter)\nn = int(input())\nl = list(map(int, input().split()))\nall_sum = 0\ncount = count_defaultdict(l)\nfor k, v in count:\n all_sum += v * (v - 1) // 2\nfor i in range(len(l)):\n if count[l[i]] > 1:\n v = count[l[i]]\n print(all_sum - v * (v-1) // 2 + (v-1) * (v-2)//2)\n else:\n print(all_sum)', 'import collections\n\ndef count_defaultdict(it):\n counter = collections.defaultdict(int)\n for x in it:\n counter[x] += 1\n return dict(counter)\n\n\ndef resolve():\n n = int(input())\n l = list(map(int, input().split()))\n s = list(set(l))\n all_sum = 0\n count = {}\n for i in range(len(s)):\n v = l.count(s[i])\n all_sum += v * (v - 1) // 2\n count = count_defaultdict(l)\n for i in range(len(l)):\n if count[l[i]] > 1:\n v = count[l[i]]\n print(all_sum - v * (v-1) // 2 + (v-1) * (v-2)//2)\n else:\n print(all_sum)', 'n = int(input())\nl = list(map(int, input().split()))\nd = {}\ns_sum = {}\ns = list(set(l))\nfor i in range(len(s)):\n d[s[i]] = l.count(s[i])\nfor i in range(len(l)):\n if l[i] in s_sum:\n print(s_sum[l[i]])\n else:\n ans = 0\n e = copy.deepcopy(d)\n e[l[i]] -= 1\n for v in e.values():\n if v > 1:\n ans += math.factorial(v) // math.factorial(v -\n 2) // math.factorial(2)\n s_sum[l[i]] = ans\n print(ans)', 'import collections\n\ndef count_defaultdict(it):\n counter = collections.defaultdict(int)\n for x in it:\n counter[x] += 1\n return dict(counter)\n\n_ = int(input())\nl = list(map(int, input().split()))\nall_sum = 0\ncount = count_defaultdict(l)\nfor _, v in count.items():\n all_sum += v * (v - 1) // 2\nfor i in range(len(l)):\n if count[l[i]] > 1:\n v = count[l[i]]\n print(all_sum - v * (v-1) // 2 + (v-1) * (v-2)//2)\n else:\n print(all_sum)'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s087978003', 's198582967', 's341113013', 's689843245', 's976320670'] | [26780.0, 26780.0, 3316.0, 26140.0, 26780.0] | [128.0, 126.0, 20.0, 2104.0, 435.0] | [467, 463, 596, 530, 473] |
p02732 | u121698457 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['N = int(input())\nA = list(map(int, input().split()))\nB = sorted(A)\nB.append(0)\np = B[0]\ny = dict()\nu = 0\nfor k in range(N+1):\n q = B[k]\n if p != q:\n y[p] = u\n u = 0\n u += 1\n p = q\nAll = 0\nfor l in y.values():\n All +=l*(l-1)//2\nprint(All)\nfor j in range(N):\n x = A[j]\n print(All+(y[x]-1)*(y[x]-2)//2-y[x]*(y[x]-1)//2)', 'N = int(input())\nA = list(map(int, input().split()))\nB = sorted(A)\nB.append(0)\np = B[0]\ny = dict()\nu = 0\nfor k in range(N+1):\n q = B[k]\n if p != q:\n y[p] = u\n u = 0\n u += 1\n p = q\nAll = 0\nfor l in y.values():\n All +=l*(l-1)//2\nfor j in range(N):\n x = A[j]\n print(All+(y[x]-1)*(y[x]-2)//2-y[x]*(y[x]-1)//2)'] | ['Wrong Answer', 'Accepted'] | ['s862276187', 's966722667'] | [26524.0, 25384.0] | [521.0, 518.0] | [351, 340] |
p02732 | u124605948 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['from collections import Counter\nimport math, copy\n\ndef c(n, r):\n return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))\n\ns = input()\nA = list(map(int, input().split()))\n\nd = Counter(A)\n\nc_table = Counter()\nfor v in d.values():\n if v not in c_table:\n if v >= 2:\n c_table[v] = c(v, 2)\n if v-1 >= 2:\n c_table[v-1] = c(v-1, 2)\n\nprint(c_table)\n\nfor a in A:\n x = copy.copy(d)\n x[a] -= 1\n ans = 0\n for v in x.values():\n if v >= 2:\n ans += c_table[v]\n \n print(ans)\n', 'from collections import Counter\nfrom scipy.special import comb\n\ns = input()\nA = list(map(int, input().split()))\n\nd = Counter(A)\n\nsum_c = 0\nfor v in d.values():\n if v >= 2:\n sum_c += comb(v, 2, exact=True)\n\nfor a in A:\n x = sum_c - comb(d[a], 2, exact=True) + comb(d[a]-1, 2, exact=True)\n print(x)'] | ['Wrong Answer', 'Accepted'] | ['s226263820', 's977225054'] | [41564.0, 66208.0] | [2206.0, 458.0] | [550, 312] |
p02732 | u127499732 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ["\ndef main():\n from collections import defaultdict\n from collections import Counter\n \n n = int(input())\n a = list(map(int, input().split()))\n \n d = Counter(a)\n e = defaultdict(int)\n \n \n \n func = lambda x: x*(x-1)//2 if x>=2 else 0\n \n ppp = ''\n \n for x in a:\n get = e.get(x)\n if get == None:\n tmp = d.copy()\n tmp[x] -= 1\n h = list(tmp.values())\n i = list(map(func, h))\n ans = sum(i)\n e[x] = ans\n ppp += str(ans) + '\\n'\n else:\n ppp += str(get) + '\\n'\n \n \n print(ppp)\n \n \nif __name__=='__main__':\n main()\n", "\ndef main():\n from collections import defaultdict\n \n n = int(input())\n a = list(map(int, input().split()))\n \n d = defaultdict(int)\n e = defaultdict(int)\n \n for x in a:\n d[x] += 1\n \n func = lambda x: x*(x-1)//2 if x>=2 else 0\n \n ppp = ''\n \n for x in a:\n get = e.get(x)\n if get == None:\n g = d[x] - 1\n h = [v for k,v in d.items() if (k != x and v>=2)]\n h.append(g)\n i = list(map(func, h))\n ans = sum(i)\n e[x] = ans\n ppp += str(ans) + '\\n'\n else:\n ppp += str(get) + '\\n'\n \n \n print(ppp)\n \n \nif __name__=='__main__':\n main()\n", "\ndef main():\n from collections import defaultdict\n from collections import Counter\n \n n = int(input())\n a = list(map(int, input().split()))\n \n d = Counter(a)\n e = defaultdict(int)\n \n \n \n func = lambda x: x*(x-1)//2 if x>=2 else 0\n \n ppp = ''\n \n for x in a:\n get = e.get(x)\n if get == None:\n g = d[x] - 1\n tmp = d.copy()\n tmp.pop(x)\n h = list(tmp.values())\n h.append(g)\n i = list(map(func, h))\n ans = sum(i)\n e[x] = ans\n ppp += str(ans) + '\\n'\n else:\n ppp += str(get) + '\\n'\n \n \n print(ppp)\n \n \nif __name__=='__main__':\n main()\n", "\n\ndef main():\n from collections import Counter\n import sys\n\n input()\n a = list(map(int, sys.stdin.readline().split()))\n\n b = Counter(a)\n\n c = sum(v * (v - 1) // 2 for v in b.values())\n d = [str(c - (b[v] - 1)) for v in a]\n print('\\n'.join(d))\n\n\nif __name__ == '__main__':\n main()\n"] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s072454376', 's142985106', 's615248209', 's332636812'] | [39988.0, 26772.0, 40112.0, 34152.0] | [2105.0, 2105.0, 2105.0, 202.0] | [580, 602, 616, 307] |
p02732 | u129961029 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n=int(input())\na=list(map(int,input().split()))\nans=[]\nfor i in range(n):\n for j in range(n):\n if i!=j:\n for k in range(j+1,n):\n if a[j]==a[k]:\n ans[i]+=1\nfor i in range(n):\n print(ans[n])', 'n=int(input())\na=list(map(int,input().split()))\nans=[0]*n\nfor i in range(n):\n for j in range(n):\n if i!=j:\n for k in range(j+1,n):\n if a[j]==a[k]:\n ans[i]+=1\nfor i in ans:\n print(i)', 'n=int(input())\na=list(map(int,input().split()))\ncnt=[0]*(n+1)\nans=0\nfor i in range(n):\n cnt[a[i]]+=1\nfor j in range(n+1):\n ans+=(cnt[j]*(cnt[j]-1))//2\nfor k in range(n):\n print(ans-(cnt[a[k]]-1))\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s563348188', 's572422637', 's254444264'] | [26268.0, 26140.0, 26140.0] | [120.0, 2108.0, 328.0] | [246, 239, 205] |
p02732 | u129978636 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n=int(input())\na=list(map(int,input().split()))\naset=list(set(a))\nans=0\nalist=[ 0 for i in range(n)]\nfor _ in a:\n alist[_ - 1] += 1\nfor j in aset:\n k=a.count(j) ans += (k*(k-1)) // 2 for u in a:\n print(ans - alist[u - 1]+1)', 'n=int(input())\na=list(map(int,input().split()))\ne=list(set(a)) s=0 t=[0]*200000 for i in a:\n t[i]+=1 for j in e: k=t[j] s+=(k*(k-1))//2\nfor u in a:\n print(s-t[u]+1)', 'import copy\nn=int(input())\na=list(map(int,input().split()))\na2=copy.copy(a)\nfor i in a2:\n a.append(i)\n ad=a[i+1:n+i]\n ans = 0 adset=list(set(ad))\n for j in adset:\n k = ad.count(j) if(k >= 2): ans += (k*(k-1))//2 else:\n continue\n print(ans)', 'n=int(input())\na=list(map(int,input().split()))\ne=list(set(a))\ns=0\nt=[0]*200000\nfor i in a:\n t[i]+=1\nfor j in e:\n k=t[j]\n s+=(k*(k-1))//2\nfor u in a:\n print(s-t[u]+1)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s051896091', 's185017100', 's893093786', 's710780284'] | [2940.0, 2940.0, 2940.0, 26140.0] | [17.0, 17.0, 17.0, 330.0] | [359, 609, 548, 178] |
p02732 | u135116520 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import collections \nN=int(input())\nA=list(map(int,input().split()))\ns=0\ncnt=collections.Counter(A)\nfor key in cnt.keys():\n s+=(cnt[key]*(cnt[key]-1))//2\nfor i in range(N):\n tmp=s\n tmp-=cnt(A[i])*(cnt(A[i])-1)//2\n tmp+=(cnt(A[i])-1)*(cnt(A[i])-2)//2\n print(tmp)\n \n ', 'import collections\nN=int(input())\nA=list(map(int,input().split()))\ncnt=collections.Counter(A)\ns=0\nfor key in cnt.keys():\n s+=cnt[key]*(cnt[key]-1)//2\nfor i in range(N):\n tmp=s\n tmp-=cnt[A[i]]*(cnt[A[i]]-1)//2\n tmp+=(cnt[A[i]]-1)*(cnt[A[i]]-2)//2\n print(tmp)'] | ['Runtime Error', 'Accepted'] | ['s109192045', 's977422943'] | [26780.0, 26780.0] | [156.0, 571.0] | [273, 262] |
p02732 | u136843617 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n = int(input())\nballs = list(map(int, input().split()))\nconbi = [0]*n\nresult = 0\nfor i in balls:\n conbi[i-1] +=1\nprint(conbi)\nfor j in range(n):\n result += (conbi[j]*(conbi[j]-1))//2\nfor k in range(n):\n print(result-conbi[balls[k]-1]+1)\n', 'n = int(input())\nballs = list(map(int, input().split()))\nconbi = [0]*n\nresult = 0\nfor i in balls:\n conbi[i-1] +=1\nprint(conbi)\nfor j in range(n):\n result += (conbi[j]*(conbi[j]-1))//2\nfor k in balls:\n print(result-conbi[k-1]+1, end=" ")\n', 'n = int(input())\nballs = list(map(int, input().split()))\nconbi = [0]*n\nresult = 0\nfor i in balls:\n conbi[i-1] +=1\nprint(conbi)\nfor j in range(n):\n result += (conbi[j]*(conbi[j]-1))//2\nfor k in balls:\n print(result-conbi[k-1]+1)\n', "def solve():\n N = int(input())\n A = list(map(int,input().split()))\n conb = [0]*N\n ans = 0\n for i in A:\n conb[i-1] += 1\n for j in conb:\n if j != 0:\n ans += j*(j-1)//2\n for k in range(N):\n print(ans- conb[A[k]-1]+1)\n\n\n\nif __name__ == '__main__':\n solve()"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s100781476', 's144247034', 's528224667', 's064402852'] | [24996.0, 26012.0, 24748.0, 26012.0] | [345.0, 452.0, 347.0, 280.0] | [247, 246, 237, 308] |
p02732 | u138045722 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['N=int(input())\nA=[int(x) for x in input().split()]\nnum={i:0 for i in range(N)}\nfor i in A:\n num[i-1]+=1\ndef set(k):\n if k >= 2:\n return (k)*(k-1)/2\n else:\n return 0\ndef selfset(k):\n if k >= 2:\n return (k-1)*(k-2)/2\n else:\n return 0\n\nsetnum={i:set(num[i]) for i in range(N)}\na=sum(setnum.values())\nprint(setnum,A)\n\nselfsetnum={i:selfset(num[i]) for i in range(N)}\n\n\nfor i in range(N):\n print(int(a-setnum[A[i]-1]+selfsetnum[A[i]-1]))', 'N=int(input())\nA=[int(x) for x in input().split()]\nnum={i:0 for i in range(N)}\nfor i in A:\n num[i-1]+=1\ndef set(k):\n if k >= 2:\n return (k)*(k-1)/2\n else:\n return 0\ndef selfset(k):\n if k >= 2:\n return (k-1)*(k-2)/2\n else:\n return 0\n\nsetnum={i:set(num[i]) for i in range(N)}\na=sum(setnum.values())\n\nselfsetnum={i:selfset(num[i]) for i in range(N)}\n\n\nfor i in range(N):\n print(int(a-setnum[A[i]-1]+selfsetnum[A[i]-1]))'] | ['Wrong Answer', 'Accepted'] | ['s682900363', 's468429279'] | [86500.0, 82972.0] | [613.0, 558.0] | [478, 462] |
p02732 | u143322814 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import itertools\nimport math \ndef C(n,r): return n*(n-1)/r\n\nn = int(input())\na = list(map(int, input().split()))\nd = {}\nfor i in a:\n d[i] = d.get(i, 0)+1\n\nc = 0\ncc = {}\nfor key, val in d.items():\n temp = C(val,2)\n c += temp\n if cc.get(key) is None:\n cc[key] = temp - C(val-1,2)\nfor i in a:\n print(c - cc[i])\n', 'import itertools\nimport math \ndef C(n,r):\n if n-r < 0:\n return 0 \n return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))\n\nn = int(input())\na = list(map(int, input().split()))\nd = {}\nfor i in a:\n d[i] = d.get(i, 0)+1\n\nc = 0\nfor i in d.values():\n c += C(i,2)\nprint(d)\nfor i in a:\n print(c - (C(d[i],2)-C(d[i]-1,2)))\n', 'import itertools\nimport math \ndef C(n,r): return n*(n-1)//r\n\nn = int(input())\na = list(map(int, input().split()))\nd = {}\nfor i in a:\n d[i] = d.get(i, 0)+1\n\nc = 0\ncc = {}\nfor key, val in d.items():\n temp = C(val,2)\n c += temp\n if cc.get(key) is None:\n cc[key] = temp - C(val-1,2)\nfor i in a:\n print(c - cc[i])\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s194345096', 's603857886', 's641433804'] | [34064.0, 25644.0, 31904.0] | [462.0, 2105.0, 422.0] | [330, 352, 331] |
p02732 | u148856702 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n = input()\nn = int(n)\ninput_list = list(map(int, input().split()))\nprint(input_list)\ndicts = {}\nfor i in range(n):\n if input_list[i] not in dicts.keys():\n dicts[input_list[i]] = 0\n dicts[input_list[i]] += 1\n\nsums = 0\ndicts2 = {}\nfor key, value in dicts.items():\n if dicts[key] >= 2:\n dicts2[key] = value * (value - 1) // 2\n else:\n dicts2[key] = 0\n sums += dicts2[key]\n\nprint(dicts, dicts2)\nfor j in range(n):\n if dicts[input_list[j]] >= 2:\n value1 = dicts[input_list[j]]\n res = sums - dicts2[input_list[j]] + (value1-1) * (value1 - 2) // 2\n else:\n res = sums\n print(str(res))', 'n = input()\nn = int(n)\ninput_list = list(map(int, input().split()))\n#print(input_list)\ndicts = {}\nfor i in range(n):\n if input_list[i] not in dicts.keys():\n dicts[input_list[i]] = 0\n dicts[input_list[i]] += 1\n\nsums = 0\ndicts2 = {}\nfor key, value in dicts.items():\n if dicts[key] >= 2:\n dicts2[key] = value * (value - 1) // 2\n else:\n dicts2[key] = 0\n sums += dicts2[key]\n\n\nfor j in range(n):\n if dicts[input_list[j]] >= 2:\n value1 = dicts[input_list[j]]\n res = sums - dicts2[input_list[j]] + (value1-1) * (value1 - 2) // 2\n else:\n res = sums\n print(str(res))'] | ['Wrong Answer', 'Accepted'] | ['s021648948', 's982510459'] | [36716.0, 31844.0] | [590.0, 537.0] | [642, 644] |
p02732 | u156815136 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['N_ = int(input())\n\nA_ = list(map(int,input().split()))\n#A_.remove(1)\n#print(A_)\ndef xC(num):\n return (num * (num - 1)) //2\n\ndef Re_(reA,t):\n Dup = []\n num = 0\n #print(reA)\n for i in range(len(reA)):\n if Dup.count(reA[i]) == 0:\n Dup.append(reA[i])\n else:\n pass\n for i in range(len(Dup)):\n num += xC(reA.count(Dup[i]))\n return num', "N_ = int(input())\n\nA_ = input().split()\n#print(A_)\n\n#U_ = set(A_)\n#print(U_)\n\n\n#def xC(num):\n\nimport collections\ncnt = collections.Counter(A_)\n\nnum = 0\ndict = {}\n#judge = {}\n#for u in U_:\n# judge[u] = False\n\nfor v in cnt.values():\n num += v*(v - 1)//2\nRe = []\nfor value in A_:\n Re.append(str(num - (cnt[value] - 1)))\nprint('\\n'.join(Re))\n"] | ['Wrong Answer', 'Accepted'] | ['s595360918', 's825830494'] | [24748.0, 39636.0] | [66.0, 256.0] | [392, 407] |
p02732 | u159975271 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import collections\nN = int(input())\nA = list(map(int , input().split()))\na = collections.Counter(A)\nS = len(a)\nk = 0\nfor j in range (S):\n b = a.most_common()[j][1]\n if b > 1:\n k += b * (b-1)/2\n \n\nfor i in range(N):\n s = A[i]\n p = a[s]\n print(int(k - q) \n', 'import collections\nN = int(input())\nA = list(map(int , input().split()))\na = collections.Counter(A)\nk = 0\ndef comb(n):\n return n * (n - 1) // 2\nfor j in a.values():\n k += comb(j)\n \nfor i in range(N):\n s = A[i]\n p = a[s]\n print(int(k - p + 1))'] | ['Runtime Error', 'Accepted'] | ['s675453582', 's909965723'] | [3060.0, 26772.0] | [17.0, 411.0] | [282, 260] |
p02732 | u161693347 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ["import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom functools import reduce\nfrom bisect import bisect_left, insort_left\nfrom heapq import heapify, heappush, heappop\n\nINPUT = lambda: sys.stdin.readline().rstrip()\nINT = lambda: int(INPUT())\nMAP = lambda: map(int, INPUT().split())\nS_MAP = lambda: map(str, INPUT().split())\nLIST = lambda: list(map(int, INPUT().split()))\nS_LIST = lambda: list(map(str, INPUT().split()))\n\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef main():\n N = INT()\n A = LIST()\n\n C = Counter(A)\n print(C)\n\n X = 0\n for v in C.values():\n X += factorial(v) // (factorial(2) * factorial(v-2))\n\n for i in range(N):\n print(X - C[A[i]] + 1)\n\n\nif __name__ == '__main__':\n main()\n", "import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom functools import reduce\nfrom bisect import bisect_left, insort_left\nfrom heapq import heapify, heappush, heappop\n\nINPUT = lambda: sys.stdin.readline().rstrip()\nINT = lambda: int(INPUT())\nMAP = lambda: map(int, INPUT().split())\nS_MAP = lambda: map(str, INPUT().split())\nLIST = lambda: list(map(int, INPUT().split()))\nS_LIST = lambda: list(map(str, INPUT().split()))\n\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef main():\n N = INT()\n A = LIST()\n\n C = Counter(A)\n\n X = 0\n for v in C.values():\n X += v * (v - 1) // 2\n\n for i in range(N):\n print(X - C[A[i]] + 1)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Runtime Error', 'Accepted'] | ['s178828582', 's132464792'] | [42488.0, 33304.0] | [895.0, 206.0] | [1045, 1001] |
p02732 | u163501259 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['N = int(input())\nA = list(map(int, input().split()))\nIND = list(set(A))\n# CNT = [A.count(x) for x in IND]\n# print(IND)\n# print(CNT)\nCONB = [A.count(x)*(A.count(x)-1)//2 for x in IND]\n\nSUM = sum(CONB)\nCALC = [-1]*(N+1)\nfor i in A:\n if CALC[i] != -1:\n print(CALC[i])\n else:\n # n = CNT[IND.index(i)]\n # ans = SUM - CONB[IND.index(i)] + (n-1)*(n-2)//2\n ans = SUM - CONB[IND.index(i)] + CONB[IND.index(i-1)]\n CALC[i] = ans\n print(ans)', 'N = int(input())\nA = list(map(int, input().split()))\nCNT = [0]*(N+1)\n# IND = list(set(A))\n# CNT = [A.count(x) for x in IND]\nfor i in A:\n CNT[i] += 1\n# print(IND)\n# print(CNT)\n# CONB = [A.count(x)*(A.count(x)-1)//2 for x in IND]\nCONB = [CNT[x]*(CNT[x]-1)//2 for x in range(len(CNT))]\n\nSUM = sum(CONB)\nfor i in A:\n ans = SUM - CNT[i] + 1\n print(ans)'] | ['Runtime Error', 'Accepted'] | ['s519720690', 's981166797'] | [24996.0, 24748.0] | [2104.0, 291.0] | [490, 369] |
p02732 | u163907160 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import math\nimport collections\nm=int(input())\na=list(map(int,input().split()))\nA=collections.Counter(a)\ntotal=0\nfor j in A.values():\n total = total + j*(j-1)/2\nfor k in range(m):\n s=A[a[k]]\n d=total-s+1\n print(d)\n', 'import math\nimport collections\nm=int(input())\na=list(map(int,input().split()))\nA=collections.Counter(a)\ntotal=0\nfor j in A.values():\n total = total + j*(j-1)//2\nfor k in range(m):\n s=A[a[k]]\n d=total-s+1\n print(d)\n'] | ['Wrong Answer', 'Accepted'] | ['s607970902', 's763772587'] | [26780.0, 26780.0] | [417.0, 348.0] | [225, 226] |
p02732 | u181668771 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['N = int(input())\nA = list(map(int, input().split()))\nd = defaultdict(lambda: 0)\nfor i in range(len(A)):\n d[A[i]] += 1\n\nans1 = 0\nans2 = 0\nr = 2\ncalc_dict1 = {}\ncalc_dict2 = {}\nfor k, v in zip(d.keys(), d.values()):\n if v > 1:\n ans1 = math.factorial(v) // (math.factorial(v - r) * math.factorial(r))\n else:\n ans1 = 0\n if v > 2:\n ans2 = math.factorial(v - 1) // (math.factorial(v - 1 - r) * math.factorial(r))\n else:\n ans2 = 0\n calc_dict1[k] = ans1\n calc_dict2[k] = ans1 - ans2\ntotal = sum(calc_dict1.values())\nfor i in range(N):\n print(total - calc_dict2[A[i]])', 'from collections import defaultdict\nN = int(input())\nA = list(map(int, input().split()))\nd = defaultdict(lambda: 0)\nfor i in range(len(A)):\n d[A[i]] += 1\ntotal = 0\nfor k,v in d.items():\n total += v*(v-1)//2\nfor a in A:\n print(total - (d[a]-1))'] | ['Runtime Error', 'Accepted'] | ['s036817780', 's203032142'] | [26140.0, 26780.0] | [65.0, 357.0] | [611, 252] |
p02732 | u183657342 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['from collections import Counter\n\nn = int(input())\nA = list(map(int, input().split()))\ncounter = Counter(A)\ncounter_comb = list(map(lambda y: int(y*(y-1)/2), counter.values()))\nsum_counter = sum(counter_comb)\nfor i in range(n):\n z = counter[A[i]-1]\n if z>0:\n print(ssum_counter-(z-1))\n else:\n print(sum_counter)\n ', 'from collections import Counter\n\nn = int(input())\nA = list(map(int, input().split()))\ncounter = Counter(A)\ncounter_comb = list(map(lambda y: int(y*(y-1)/2), counter.values()))\nsum_counter = sum(counter_comb)\nfor i in range(n):\n z = counter[A[i]]\n if z>0:\n print(sum_counter-(z-1))\n else:\n print(sum_counter)\n '] | ['Runtime Error', 'Accepted'] | ['s240496990', 's330264031'] | [26900.0, 26780.0] | [318.0, 371.0] | [338, 335] |
p02732 | u185297444 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import collections\n\nn = int(input())\na = [int(i) for i in input().split()]\n\ndef com(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nfor i in range(n):\n ans = 0\n b = a.copy()\n del b[i]\n bb = collections.Counter(b)\n for j in bb:\n if bb[j] > 1:\n ans += com(bb[j],2)\n print(ans)', 'import collections\nimport math\n\nn = int(input())\na = [int(i) for i in input().split()]\n\ndef com(n, r):\n if n > 1:\n ann = math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n else:\n ann = 0\n return ann\n\nb = collections.Counter(a)\nans = []\nfor i in b:\n ans.append(com(b[i],2))\nanss = sum(ans)\n\nfor i in range(n):\n t = b[a[i]]\n print(anss - (t-1))'] | ['Runtime Error', 'Accepted'] | ['s320742259', 's906411852'] | [33900.0, 34068.0] | [110.0, 996.0] | [346, 389] |
p02732 | u185405877 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['n=int(input())\nk= list(map(int, input().split()))\nz=[0]*n\ncnt=0\nfor i in range(n):\n z[k[i]-1]+=1\nfor m in range(n):\n cnt+=z[m]*(z[m]-1)//2\nfor j in range(n):\n print(cnt-z[j]+1)', 'n=int(input())\nk= list(map(int, input().split()))\nz=[0]*n\ncnt=0\nfor i in range(n):\n z[k[i]-1]+=1\nfor m in range(n):\n cnt+=z[m]*(z[m]-1)//2\nfor j in range(n):\n a=k[j]-1\n print(cnt-z[a]+1)'] | ['Wrong Answer', 'Accepted'] | ['s625680820', 's929028798'] | [26524.0, 25004.0] | [330.0, 354.0] | [185, 198] |
p02732 | u189056821 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['import numpy as np \nimport collections\n\nn = int(input())\na = tuple(map(int, input().split()))\n\nfor i in range(n):\n _a = np.delete(a, i)\n c_dict = collections.Counter(_a)\n total = 0\n for v in c_dict.values():\n if v >= 2:\n total += v * (v - 1) / 2\n \n flag[i] = 1\n print(int(total))', "import collections\n\ndef solve(N, A):\n c_dict = collections.Counter(A)\n originals = [0 for i in range(N + 1)]\n minus = [0 for i in range(N + 1)]\n \n for (k, v) in c_dict.items():\n originals[k] = v * (v - 1) // 2\n minus[k] = ((v * (v - 1)) - (v - 1) * (v - 2)) // 2\n \n total = sum(originals)\n \n ans = []\n for a in A:\n ans.append(str(total - minus[a]))\n return '\\n'.join(ans)\n \nif __name__ == '__main__':\n N = int(input())\n A = list(map(int, input().split()))\n print(solve(N, A))"] | ['Runtime Error', 'Accepted'] | ['s234602241', 's001722014'] | [34356.0, 34488.0] | [287.0, 210.0] | [326, 545] |
p02732 | u192042624 | 2,000 | 1,048,576 | We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal. | ['\n\nusing namespace std;\n\nlong long facto(long long n)\n{\nlong long i,ans;\nans=1;\nfor(i=1;i<=n;i++) {\nans=ans*i;\n}\nreturn ans;\n}\n\n\nlong long com(int n , int r){\n return ( facto(n) / ( facto(n-r) * facto(r) ) );\n}\n\nvoid comb(vector<vector <long long int> > &v){\n for(int i = 0;i <v.size(); i++){\n v[i][0]=1;\n v[i][i]=1;\n }\n for(int k = 1;k <v.size();k++){\n for(int j = 1;j<k;j++){\n v[k][j]=(v[k-1][j-1]+v[k-1][j]);\n }\n }\n}\n\nint main(){\n long long N;\n cin >> N;\n int A[N];\n for(int i = 0 ; i< N ; i++){\n cin >> A[i];\n }\n\n long long data[N+1];\n for(int i = 0 ; i<N+1 ;i++){\n data[i] = 0;\n }\n\n for(int i = 0;i<N;i++){\n data[A[i]] += 1;\n }\n\n long long total = 0;\n\n for(int i =0;i<N;i++){\n if( data[i] >=2 ){\n total += com(data[i],2 );\n }\n }\n\n \n for(int i=0 ; i<N;i++){\n if(data[A[i]]-1>0){\n cout << total - com(data[A[i]]-1,1) << endl;\n }else{\n cout << total << endl;\n }\n \n }\n\n return 0;\n}', 'import math\n \ndef permutations_count(n, r):\n if r == 2:\n return int( (n*(n-1) ) / r )\n if r == 1:\n return n\n \n \nN = int(input())\nA = list(map(int,input().split()))\n \ndata = [0] * (N+1)\n \nfor i in range(N):\n data[A[i]] += 1\n \ntotal = 0\n \nfor i in range(N+1):\n if data[i] >= 2:\n total += permutations_count(data[i],2)\n \n \n \nfor i in range(N):\n if data[A[i]] - 1 > 0 :\n print( total - permutations_count(data[A[i]]-1,1) )\n else:\n print(total)\n\nprint(permutations_count(3,1))', 'import math\n \ndef permutations_count(n, r):\n if r == 2:\n return int( (n*(n-1) ) / r )\n if r == 1:\n return n\n \n \nN = int(input())\nA = list(map(int,input().split()))\n \ndata = [0] * (N+1)\n \nfor i in range(N):\n data[A[i]] += 1\n \ntotal = 0\n \nfor i in range(N+1):\n if data[i] >= 2:\n total += permutations_count(data[i],2)\n \n \n \nfor i in range(N):\n if data[A[i]] - 1 > 0 :\n print( total - permutations_count(data[A[i]]-1,1) )\n else:\n print(total)\n\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s328256446', 's631978194', 's372807001'] | [2940.0, 26140.0, 26140.0] | [17.0, 353.0, 348.0] | [1084, 524, 494] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.