buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k |
|---|---|---|---|---|
from copy import deepcopy
dp = {}
N = int(input())
A = list(map(int, input().split()))
balls = {}
fact = 1
for (i, a) in enumerate(A):
count = i+1
dp[count] = count * (count-1) // 2
if a in balls:
balls[a] += 1
else:
balls[a] = 1
res = 0
for count in balls.values():
res += dp[count]
for a in A:
... | from copy import deepcopy
dp = {0: 0}
N = int(input())
A = list(map(int, input().split()))
balls = {}
fact = 1
for (i, a) in enumerate(A):
count = i+1
dp[count] = count * (count-1) // 2
if a in balls:
balls[a] += 1
else:
balls[a] = 1
res = 0
for count in balls.values():
res += dp[count]
for a in A... | [["+", 0, 1, 0, 662, 12, 680, 0, 569, 448, 612], ["+", 0, 1, 0, 662, 12, 680, 0, 569, 0, 102], ["+", 0, 1, 0, 662, 12, 680, 0, 569, 51, 612]] | 5 | 135 |
from collections import Counter
N = int(input())
An = list(map(int, input().split()))
counter = Counter(An)
cnt = 0
for c in counter.values():
cnt += c * c-1 // 2
for a in An:
print(cnt - (counter[a] - 1))
| from collections import Counter
N = int(input())
An = list(map(int, input().split()))
counter = Counter(An)
cnt = 0
for c in counter.values():
cnt += c * (c-1) // 2
for a in An:
print(cnt - (counter[a] - 1))
| [["+", 0, 677, 12, 657, 31, 657, 12, 23, 0, 24], ["+", 0, 677, 12, 657, 31, 657, 12, 23, 0, 25]] | 5 | 74 |
n=int(input())
a=list(map(int,input().split()))
cnt=[0]*(n+1)
for i in range(n):
cnt[a[i]]+=1
aa=0
ans=[]
for i in range(n):
aa+=(cnt[i]*(cnt[i]-1)//2)
for i in range(n):
print(aa-(cnt[a[i]]*(cnt[a[i]]-1))//2 +((cnt[a[i]]-1)*(cnt[a[i]]-2))//2, end ="\n")
| n=int(input())
a=list(map(int,input().split()))
cnt=[0]*(n+1)
for i in range(n):
cnt[a[i]]+=1
aa=0
ans=[]
for i in range(n+1):
aa+=(cnt[i]*(cnt[i]-1)//2)
for i in range(n):
print(aa-(cnt[a[i]]*(cnt[a[i]]-1))//2 +((cnt[a[i]]-1)*(cnt[a[i]]-2))//2, end ="\n")
| [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 157 |
N = int(input())
A = list(map(int,input().split()))
import collections
import math
dicA = collections.Counter(A)
total = 0
for x in list(dicA.values()):
total += math.factorial(x) // (math.factorial(x - 2)*2)
for i in range(N):
print(total - dicA[A[i]] +1)
| N = int(input())
A = list(map(int,input().split()))
import collections
import math
dicA = collections.Counter(A)
total = 0
for x in list(dicA.values()):
if x != 1:
total += math.factorial(x) // (math.factorial(x - 2)*2)
for i in range(N):
print(total - dicA[A[i]] +1)
| [["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 102]] | 5 | 95 |
def possibleCombos(num):
num2 = num - 1
return (num2*num2 + num2)//2
N = int(input())
A = [int(i) for i in input().split()]
data = [0] * N
total = 0
for i in A:
data[i] +=1
for i in data:
total += possibleCombos(i)
for i in A:
result = total - possibleCombos(data[i]) + possibleCombos(data[i]-1)
... | def possibleCombos(num):
num2 = num - 1
return (num2*num2 + num2)//2
N = int(input())
A = [int(i) for i in input().split()]
data = [0] * (N+1)
total = 0
for i in A:
data[i] +=1
for i in data:
total += possibleCombos(i)
for i in A:
result = total - possibleCombos(data[i]) + possibleCombos(data[i]-1... | [["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 24], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 25]] | 5 | 109 |
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <algorithm>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)
using namespace std;
typedef long long ll;
const int INF = 1e... | #include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <algorithm>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)
using namespace std;
typedef long long ll;
const int INF = 1e... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]] | 1 | 208 |
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
allCount = 0
c = Counter(A)
for i, v in c.items():
if (v == 1):
continue
else:
allCount += v * (v - 1) // 2
if (allCount == 0):
for i in range(N):
print(0)
exit()
for i in range(N):
a = ... | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
allCount = 0
c = Counter(A)
for i, v in c.items():
if (v == 1):
continue
else:
allCount += v * (v - 1) // 2
if (allCount == 0):
for i in range(N):
print(0)
exit()
for i in range(N):
a = ... | [["+", 0, 662, 12, 657, 31, 657, 31, 206, 51, 22], ["+", 0, 662, 12, 657, 31, 657, 31, 206, 0, 70], ["+", 12, 657, 31, 657, 31, 206, 206, 206, 0, 73], ["+", 31, 657, 12, 23, 0, 657, 31, 206, 51, 22], ["+", 31, 657, 12, 23, 0, 657, 31, 206, 0, 70], ["+", 12, 23, 0, 657, 31, 206, 206, 206, 0, 73]] | 5 | 168 |
n = int(input())
a = [int(i) for i in input().split()]
c = [0 for i in range(n+1)]
b = sorted(a)
cnt = 1
for i in range(n-1):
if b[i]==b[i+1]:
cnt += 1
else:
c[b[i]] = cnt
cnt = 1
if i==n-2:
c[b[n-1]] = cnt
ans = 0
for i in range(n):
ans += int(c[i]*(c[i]-1)/2)
for i in range(n):
print(ans-(c[... | n = int(input())
a = [int(i) for i in input().split()]
c = [0 for i in range(n+1)]
b = sorted(a)
cnt = 1
for i in range(n-1):
if b[i]==b[i+1]:
cnt += 1
else:
c[b[i]] = cnt
cnt = 1
if i==n-2:
c[b[n-1]] = cnt
ans = 0
for i in range(n+1):
ans += int(c[i]*(c[i]-1)/2)
for i in range(n):
print(ans-(... | [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 162 |
N=int(input())
A=list(map(int,input().split()))
total=0
A_li=[0]*(1+2*10**5)
for i in range(N):
A_li[A[i]]+=1
for i in range(1+2*10**5):
total+=A_li[i]*(A_li[i]-1)//2
for i in range(1,N+1):
if A_li[A[i-1]]>1:
print(total-(A_li[A[i-1]]-1))
else:
print(0) | N=int(input())
A=list(map(int,input().split()))
total=0
A_li=[0]*(1+2*10**5)
for i in range(N):
A_li[A[i]]+=1
for i in range(1+2*10**5):
total+=A_li[i]*(A_li[i]-1)//2
for i in range(1,N+1):
if A_li[A[i-1]]>1:
print(total-(A_li[A[i-1]]-1))
else:
print(total) | [["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 140 |
N = int(input())
K = list(map(int,input().split()))
A = [0]*N
print(A)
for i in range(N):
A[K[i]-1] += 1
r = 0
for k in range(N):
r += 0.5*(A[k]*(A[k]-1))
An =[]
for j in range(N):
D = A[K[j]-1]-1
An.append(int(r-(0.5*(D+1)*(D))+(0.5*D*(D-1))))
for i in range(len(An)):
print(An[i]) | N = int(input())
K = list(map(int,input().split()))
A = [0]*N
for i in range(N):
A[K[i]-1] += 1
r = 0
for k in range(N):
r += 0.5*(A[k]*(A[k]-1))
An =[]
for j in range(N):
D = A[K[j]-1]-1
An.append(int(r-(0.5*(D+1)*(D))+(0.5*D*(D-1))))
for i in range(len(An)):
print(An[i]) | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 163 |
n = int(input())
a = list(map(int, input().split()))
l = [0] * n
for i in a:
l[i-1] += 1
al = 0
for i in l:
al += i*(i-1)//2
for k in range(n):
print(al - (l[a[k]] - 1)) | n = int(input())
a = list(map(int, input().split()))
l = [0] * n
for i in a:
l[i-1] += 1
al = 0
for i in l:
al += i*(i-1)//2
for k in range(n):
print(al - (l[a[k]-1] - 1)) | [["+", 12, 23, 0, 657, 31, 206, 206, 657, 17, 33], ["+", 12, 23, 0, 657, 31, 206, 206, 657, 12, 612]] | 5 | 88 |
N = int(input())
A = [int(a) for a in input().split()]
cnt = {}
total = 0
for a in A:
if a not in cnt:
cnt[a] = 0
cnt[a] += 1
for i in cnt.values():
total += i * (i - 1) // 2
for i in range(N):
print(total - (cnt[i] - 1))
| N = int(input())
A = [int(a) for a in input().split()]
cnt = {}
total = 0
for a in A:
if a not in cnt:
cnt[a] = 0
cnt[a] += 1
for i in cnt.values():
total += i * (i - 1) // 2
for a in A:
print(total - (cnt[a] - 1))
| [["-", 36, 36, 36, 36, 0, 656, 0, 7, 31, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 7, 31, 22], ["-", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 25], ["+", 36, 36, 36, 36, 0, 656, 0, 7, 12, 22], ["-", 0, ... | 5 | 97 |
import itertools
N=int(input())
A=list(map(int,input().split(' ')))
gr=itertools.groupby(sorted(A))
s=0
dic={}
for x,group in gr:
l=len(list(group))
if l >= 2:
s+=l*(l-1)/2
dic[x]=l
for k in range(N):
l=dic[A[k]]
if l >= 2:
print(int(s-l*(l-1)/2+(l-1)*(l-2)/2))
else:
print(0)
| import itertools
N=int(input())
A=list(map(int,input().split(' ')))
gr=itertools.groupby(sorted(A))
s=0
dic={}
for x,group in gr:
l=len(list(group))
if l >= 2:
s+=l*(l-1)/2
dic[x]=l
for k in range(N):
l=dic[A[k]]
if l >= 2:
print(int(s-l*(l-1)/2+(l-1)*(l-2)/2))
else:
print(int(s))
| [["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 145 |
# inputを高速化する。
import sys
input = sys.stdin.readline
n = int(input())
balls = list(map(int, input().split()))
cnt = {}
for ball in balls:
if ball not in cnt:
cnt[ball] = 0
cnt[ball] += 1
def combination(nxt, num = 0):
return (cnt[nxt]-num) * (cnt[nxt]-1- num) // 2
total = 0
for nxt in cnt:
... | # inputを高速化する。
import sys
input = sys.stdin.readline
n = int(input())
balls = list(map(int, input().split()))
cnt = {}
for ball in balls:
if ball not in cnt:
cnt[ball] = 0
cnt[ball] += 1
def combination(nxt, num = 0):
return (cnt[nxt]-num) * (cnt[nxt]-1- num) // 2
total = 0
for nxt in cnt:
... | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 136 |
import copy
N = int(input())
A = list(map(int, input().split()))
count_dict = [0] * N
for each in A:
count_dict[each] += 1
all_types = 0
for value in count_dict:
all_types += value * (value - 1) // 2
# result_dict = {}
# for each in a_types:
# result_dict[each] = all_types - count_dict[each] + 1
for a i... | import copy
N = int(input())
A = list(map(int, input().split()))
count_dict = [0] * N
for each in A:
count_dict[each - 1] += 1
all_types = 0
for value in count_dict:
all_types += value * (value - 1) // 2
# result_dict = {}
# for each in a_types:
# result_dict[each] = all_types - count_dict[each] + 1
for... | [["+", 0, 1, 0, 677, 31, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 677, 31, 206, 206, 657, 12, 612], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 17, 33], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 12, 612]] | 5 | 83 |
n = int(input())
a = list(map(int, input().split()))
c = [0]*n
for i in range(n):
c[a[i]] = c[a[i]] + 1
total = 0
for x in c:
total = total + x*(x-1)//2
for i in range(n):
print(total - c[a[i]] + 1) | n = int(input())
a = list(map(int, input().split()))
c = [0]*n
for i in range(n):
c[a[i]-1] = c[a[i]-1] + 1
total = 0
for x in c:
total = total + x*(x-1)//2
for i in range(n):
print(total - c[a[i]-1] + 1)
| [["+", 0, 1, 0, 662, 31, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 662, 31, 206, 206, 657, 12, 612], ["+", 0, 662, 12, 657, 31, 206, 206, 657, 17, 33], ["+", 0, 662, 12, 657, 31, 206, 206, 657, 12, 612], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 17, 33], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 12, 612]] | 5 | 100 |
input = sys.stdin.readline
from collections import Counter
#
n = int(input().strip())
a = list(map(int, input().strip().split()))
#
C=Counter()
for i in range(n):
C[a[i]] += 1
xsum=0
for key, value in C.items():
xsum += value*(value-1)//2
#
for k in range(n):
print( xsum - (C[a[k]] - 1) ) | import sys
input = sys.stdin.readline
from collections import Counter
#
n = int(input().strip())
a = list(map(int, input().strip().split()))
#
C=Counter()
for i in range(n):
C[a[i]] += 1
xsum=0
for key, value in C.items():
xsum += value*(value-1)//2
#
for k in range(n):
print( xsum - (C[a[k]] - 1) ) | [["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]] | 5 | 118 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[1000007];
int main() {
ll i, j, k, l, test, n;
cin >> n;
for (i = 0; i < n; i++)
cin >> a[i];
map<ll, ll> m;
for (i = 0; i < n; i++) {
m[a[i]]++;
}
ll sum = 0;
for (i = 0; i <= n; i++) {
if (m[i] > 0) {
sum += (... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[1000007];
int main() {
ll i, j, k, l, test, n;
cin >> n;
for (i = 0; i < n; i++)
cin >> a[i];
map<ll, ll> m;
for (i = 0; i < n; i++) {
m[a[i]]++;
}
ll sum = 0;
for (i = 0; i <= n; i++) {
if (m[i] > 0) {
sum += (... | [["-", 0, 16, 31, 69, 341, 342, 0, 69, 28, 22], ["-", 31, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["-", 31, 69, 341, 342, 0, 69, 341, 342, 0, 73], ["-", 12, 23, 0, 16, 31, 69, 341, 342, 0, 70]] | 1 | 247 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll choose2(ll n) { return n * (n - 1) / 2; }
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> cnts(n + 1);
for (int i = 0; i < n; i++) {
cnts[a[i]] += 1;
}
ll tot = ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll choose2(ll n) { return n * (n - 1) / 2; }
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> cnts(n + 1);
for (int i = 0; i < n; i++) {
cnts[a[i]] += 1;
}
ll tot = ... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 198 |
# https://atcoder.jp/contests/abc159/tasks/abc159_d
N = int(input())
A_list = list(map(int, input().split()))
box = [0] * (N + 1)
box_2 = [0] * (N + 1)
box_3 = [0] * (N + 1)
for i in range(N):
box[A_list[i]] += 1
for i in range(N):
if box[i] > 1:
box_2[i] = (box[i] * (box[i] - 1)) / 2
box_3[... | # https://atcoder.jp/contests/abc159/tasks/abc159_d
N = int(input())
A_list = list(map(int, input().split()))
box = [0] * (N + 1)
box_2 = [0] * (N + 1)
box_3 = [0] * (N + 1)
for i in range(N):
box[A_list[i]] += 1
for i in range(N + 1):
if box[i] > 1:
box_2[i] = (box[i] * (box[i] - 1)) / 2
bo... | [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 200 |
import sys
sys.setrecursionlimit(10**6)
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(int)
for i in range(N):
d[A[i]] += 1
print(d)
a = defaultdict(int)
b = defaultdict(int)
for key, value in d.items():
a[key] = value * (value - 1) //2
b[key] = ... | import sys
sys.setrecursionlimit(10**6)
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(int)
for i in range(N):
d[A[i]] += 1
#print(d)
a = defaultdict(int)
b = defaultdict(int)
for key, value in d.items():
a[key] = value * (value - 1) //2
b[key] =... | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 174 |
M=int(input())
N=list(input().split())
print(N)
check=[0]*M
for i in range(M):
check[int(N[i])-1]+=1
num=0
for i in range(M):
num+=check[i]*(check[i]-1)//2
for i in range(M):
print(num-(check[int(N[i])-1]-1)) | M=int(input())
N=list(input().split())
check=[0]*M
for i in range(M):
check[int(N[i])-1]+=1
num=0
for i in range(M):
num+=check[i]*(check[i]-1)//2
for i in range(M):
#if check[int(N[i])-1]!=2:
print(num-(check[int(N[i])-1]-1))
#else:
# print(num-1) | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 110 |
n = int(input())
a = list(map(int, input().split()))
data = [0]*n
for aa in a:
data[aa] += 1
allans = 0
for d in data:
if d >= 2:
allans += (d*(d-1))//2
for aa in a:
if data[aa] == 2:
print(allans - (data[aa]*(data[aa]-1))//2)
elif data[aa] > 2:
print(allans - (data[aa]-1))
else:
print... | n = int(input())
a = list(map(int, input().split()))
data = [0]*(n+1)
for aa in a:
data[aa] += 1
allans = 0
for d in data:
if d >= 2:
allans += (d*(d-1))//2
for aa in a:
if data[aa] == 2:
print(allans - (data[aa]*(data[aa]-1))//2)
elif data[aa] > 2:
print(allans - (data[aa]-1))
else:
p... | [["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 24], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 25]] | 5 | 131 |
N = int(input())
Alist=list(map(int, input().split()))
numdic = {}
for i in Alist:
if i in numdic:
numdic[i] += 1
else:
numdic[i] = 1
Apple = 0
for i in numdic.values():
Apple += i*(i-1)//2
for i in Alist:
tmp = Apple
tmp -= numdic[i]+1
print(tmp) | N = int(input())
Alist=list(map(int, input().split()))
numdic = {}
for i in Alist:
if i in numdic:
numdic[i] += 1
else:
numdic[i] = 1
Apple = 0
for i in numdic.values():
Apple += i*(i-1)//2
for i in Alist:
tmp = Apple
tmp -= (numdic[i]-1)
print(tmp) | [["+", 8, 196, 0, 1, 0, 677, 12, 23, 0, 24], ["-", 8, 196, 0, 1, 0, 677, 12, 657, 17, 72], ["+", 0, 1, 0, 677, 12, 23, 0, 657, 17, 33], ["+", 8, 196, 0, 1, 0, 677, 12, 23, 0, 25]] | 5 | 96 |
n=int(input())
a=list(map(int,input().split()))
l=[0]*(n)
l1=[0]*(n)
for i in range(n):
l[a[i]-1]+=1
for i in range(n):
if l[i]>=2:
l1[i]+=(l[i]*(l[i]-1))//2
l1sum=sum(l1)
for i in range(n):
if l[a[i]-1]-1>=2:print(l1sum-l1[a[i]-1]+(l[a[i]-1]-1 * l[a[i]-1]-2)//2)
else:print(l1sum-l1[a[i]-1... | n=int(input())
a=list(map(int,input().split()))
l=[0]*(n)
l1=[0]*(n)
for i in range(n):
l[a[i]-1]+=1
for i in range(n):
if l[i]>=2:
l1[i]+=l[i]*(l[i]-1)//2
l1sum=sum(l1)
for i in range(n):
if l[a[i]-1]-1>=2:print(l1sum-l1[a[i]-1]+ (l[a[i]-1]-1)*(l[a[i]-1]-2)//2)
else:print(l1sum-l1[a[i]-1]... | [["-", 0, 1, 0, 677, 12, 657, 31, 23, 0, 24], ["-", 12, 657, 31, 23, 0, 657, 12, 23, 0, 25], ["+", 0, 657, 12, 657, 31, 657, 31, 23, 0, 25], ["+", 0, 657, 12, 657, 31, 657, 12, 23, 0, 24]] | 5 | 187 |
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
ans = {}
for k in cnt.keys():
ans[k] = (cnt[k] * cnt[k]-1) // 2
s = sum(list(ans.values()))
for ai in a:
if cnt[ai] == 1:
print(s)
else:
print(s - ans[ai] + (ans[ai] / cnt[ai]) * (cnt[ai] - ... | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
ans = {}
for k in cnt.keys():
ans[k] = (cnt[k] * (cnt[k]-1)) // 2
s = sum(list(ans.values()))
for ai in a:
if cnt[ai] == 1:
print(s)
else:
print(s - ans[ai] + int((ans[ai] / cnt[ai]) * (cnt[... | [["+", 12, 657, 31, 23, 0, 657, 12, 23, 0, 24], ["+", 12, 657, 31, 23, 0, 657, 12, 23, 0, 25], ["+", 0, 652, 3, 4, 0, 657, 12, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 12, 652, 3, 4, 0, 657, 12, 23, 0, 25]] | 5 | 130 |
from collections import Counter
N = int(input())
A = tuple(map(int, input().split()))
A_count = Counter(A)
ans = 0
for i, j in A_count:
ans += j * (j - 1) // 2
for k in range(1, N+1):
n = A_count[A[k-1]]
ans_ = ans - (n - 1)
print(ans_)
| from collections import Counter
N = int(input())
A = tuple(map(int, input().split()))
A_count = Counter(A)
ans = 0
for i, j in A_count.items():
ans += j * (j - 1) // 2
for k in range(1, N+1):
n = A_count[A[k-1]]
ans_ = ans - (n - 1)
print(ans_)
| [["+", 0, 656, 0, 7, 12, 652, 63, 319, 0, 131], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 25]] | 5 | 92 |
import bisect
n = int(input())
a = list(map(int, input().split()))
A = sorted(a)
s = [0]*(n+1)
b = [0]*(n+1)
c = []
for i in range(1, n+1):
x = a[i-1]
s[i] = bisect.bisect_right(A, x) - bisect.bisect_left(A, x)
if b[a[i-1]] == 0:
c.append(s[i]*(s[i]-1)//2)
b[a[i-1]] = 1
S = sum(c)
print(c)
... | import bisect
n = int(input())
a = list(map(int, input().split()))
A = sorted(a)
s = [0]*(n+1)
b = [0]*(n+1)
c = []
for i in range(1, n+1):
x = a[i-1]
s[i] = bisect.bisect_right(A, x) - bisect.bisect_left(A, x)
if b[a[i-1]] == 0:
c.append(s[i]*(s[i]-1)//2)
b[a[i-1]] = 1
S = sum(c)
# print(c... | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 178 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vpll = vector<pll>;
const ll LIN... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vpll = vector<pll>;
const ll LIN... | [["-", 0, 7, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 7, 8, 9, 0, 43, 49, 50, 51, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 110]] | 1 | 1,608 |
N=int(input())
m=list(map(ine,input().split()))
t=[]
for i in range(N):
t.append(0)
for i in range(N):
t[m[i]-1]+=1
total=0
for i in range(N):
total+=(t[i]*(t[i]-1))//2
for i in range(N):
if t[m[i]-1]<2:
print(total)
else:
print(total-(t[m[i]-1]-1)) | N=int(input())
m=list(map(int,input().split()))
t=[]
for i in range(N):
t.append(0)
for i in range(N):
t[m[i]-1]+=1
total=0
for i in range(N):
total+=(t[i]*(t[i]-1))//2
for i in range(N):
if t[m[i]-1]<2:
print(total)
else:
print(total-(t[m[i]-1]-1)) | [["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22]] | 5 | 137 |
N=int(input())
A=list(map(int,input().split()))
ls=[0 for _ in range(N)]
for i in range(N):
ls[A[i]-1]+=1
s=0
print(ls)
for i in range(len(ls)):
m=ls[i]*(ls[i]-1)//2
s+=m
for j in range(N):
print(s-(ls[A[j]-1]-1)) | N=int(input())
A=list(map(int,input().split()))
ls=[0 for _ in range(N)]
for i in range(N):
ls[A[i]-1]+=1
s=0
for i in range(len(ls)):
m=ls[i]*(ls[i]-1)//2
s+=m
for j in range(N):
print(s-(ls[A[j]-1]-1)) | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 120 |
n = int(input())
lis = list(map(int,input().split()))
num = [0 for i in range(n)]
for nn in lis:
num[nn-1] += 1
ans = 0
for nnn in num:
ans += (nnn*(nnn-1))//2
for i in range(n):
print(ans-(num[lis[i]]*(num[lis[i]]-1))//2+((num[lis[i]]-1)*(num[lis[i]]-2))//2) | n = int(input())
lis = list(map(int,input().split()))
num = [0 for i in range(n+1)]
for nn in lis:
num[nn] += 1
ans = 0
for nnn in num:
ans += (nnn*(nnn-1))//2
for i in range(n):
print(ans-(num[lis[i]]*(num[lis[i]]-1))//2+((num[lis[i]]-1)*(num[lis[i]]-2))//2)
| [["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 1, 0, 677, 31, 206, 206, 657, 17, 33], ["-", 0, 1, 0, 677, 31, 206, 206, 657, 12, 612]] | 5 | 135 |
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
X = [0]*n
for a in A:
X[a] += 1
s = 0
for x in X:
s += x*(x-1)//2
for a in A:
print(s-X[a]+1) | # coding: utf-8
n = int(input())
A = list(map(int, input().split()))
X = [0]*(n+1)
for a in A:
X[a] += 1
s = 0
for x in X:
s += x*(x-1)//2
for a in A:
print(s-X[a]+1) | [["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 24], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 25]] | 5 | 79 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int N;
cin >> N;
long long int A[N];
for (long long int i = 0; i < N; i++)
cin >> A[i];
map<long long int, long long int> M;
for (long long int i = 0; i < N; i++)
M[i] = 0;
for (long long int i = 0; i < N; i++) {
M[A[i]]++;
... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int N;
cin >> N;
long long int A[N];
for (long long int i = 0; i < N; i++)
cin >> A[i];
map<long long int, long long int> M;
for (long long int i = 0; i <= N; i++)
M[i] = 0;
for (long long int i = 0; i < N; i++) {
M[A[i]]++;
... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 254 |
n = int(input())
A = list(map(int,input().split()))
from collections import Counter
c = Counter(A)
# print(c)
cou = 0
for x in c:
if c[x]>1:
y = c[x]
cou+=y*(y-1)//2
else:
break
for i in A:
X = c[i]
ans = cou - X*(X-1)//2 + (X-1)*(X-2)//2
print(ans)
| n = int(input())
A = list(map(int,input().split()))
from collections import Counter
c = Counter(A)
# print(c)
cou = 0
for x in c:
# print(x,c[x])
if c[x]>1:
y = c[x]
cou+=y*(y-1)//2
for i in A:
X = c[i]
ans = cou - X*(X-1)//2 + (X-1)*(X-2)//2
print(ans)
| [["-", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102], ["-", 0, 57, 75, 76, 8, 196, 0, 93, 0, 94]] | 5 | 114 |
n=int(input())
a=list(map(int,input().split()))
l=[0]*(n+1)
for i in a:
l[i]+=1
ans=0
for i in range(n):
ans+=l[i]*(l[i]-1)//2
for i in a:
print(ans-l[i]*(l[i]-1)//2+(l[i]-1)*(l[i]-2)//2) | n=int(input())
a=list(map(int,input().split()))
l=[0]*(n+1)
for i in a:
l[i]+=1
ans=0
for i in range(n+1):
ans+=l[i]*(l[i]-1)//2
for i in a:
print(ans-l[i]*(l[i]-1)//2+(l[i]-1)*(l[i]-2)//2) | [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 120 |
from collections import Counter
n = int(input())
a = input().split()
freq = Counter(a)
print(freq)
total=0
for key,val in freq.items():
total+=(val*(val-1))//2
for k in range(n):
kth = (freq[a[k]]*(freq[a[k]]-1))//2
newkth = ((freq[a[k]]-2)*(freq[a[k]]-1))//2
total -= kth
total += newkth... | from collections import Counter
n = int(input())
a = input().split()
freq = Counter(a)
#print(freq)
total=0
for key,val in freq.items():
total+=(val*(val-1))//2
for k in range(n):
kth = (freq[a[k]]*(freq[a[k]]-1))//2
newkth = ((freq[a[k]]-2)*(freq[a[k]]-1))//2
total -= kth
total += newkt... | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 136 |
from collections import Counter
def cmb(n):
if n < 2:
return 0
else:
return (n * (n-1)) // 2
n = int(input())
ls = list(map(int,input().split()))
cs = Counter(a)
s = 0
for v in cs.values():
s += cmb(v)
for a in ls:
print(s - cmb(cs[a]) + cmb(cs[a] - 1)) | from collections import Counter
def cmb(n):
if n < 2:
return 0
else:
return (n * (n-1)) // 2
n = int(input())
ls = list(map(int,input().split()))
cs = Counter(ls)
s = 0
for v in cs.values():
s += cmb(v)
for a in ls:
print(s - cmb(cs[a]) + cmb(cs[a] - 1)) | [["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]] | 5 | 107 |
n = int(input())
data = list(map(int, input().split(" ")))
count = [0]*(n+1)
for i in range(n):
count[data[i]] = count[data[i]]+1
val = [0]*(n+1)
sumval = 0
for i in range(n):
if(count[i] >= 2):
val[i] = count[i]-1
sumval = sumval + int(count[i]*(count[i]-1)/2)
for i in range(n):
print(sum... | n = int(input())
data = list(map(int, input().split(" ")))
count = [0]*(n+1)
for i in range(n):
count[data[i]] = count[data[i]]+1
val = [0]*(n+1)
sumval = 0
for i in range(n+1):
if(count[i] >= 2):
val[i] = count[i]-1
sumval = sumval + int(count[i]*(count[i]-1)/2)
for i in range(n):
print(s... | [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 149 |
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main(void) {
long N;
cin >> N;
int i;
vector<long> data(N);
map<long, long> temp;
long all = 0;
long minus = 0;
for (i = 0; i < N; i++) {
cin >> data[i];
temp[data[i]]++;
// cout<<temp[data[i]]<<endl;
}
size... | #include <iostream>
#include <map>
#include <vector>
using namespace std;
int main(void) {
long N;
cin >> N;
int i;
vector<long> data(N);
map<long, long> temp;
long all = 0;
long minus = 0;
for (i = 0; i < N; i++) {
cin >> data[i];
temp[data[i]]++;
// cout<<temp[data[i]]<<endl;
}
size... | [["-", 31, 23, 0, 16, 31, 16, 12, 23, 0, 25], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25]] | 1 | 182 |
import collections
from collections import Counter
*l, = map(int, input().split())
c = Counter(l)
A = [int(i*(i-1)/2) for i in c.values()]
A_sum = sum(A)
for j in l:
print(A_sum - c[j] + 1) | import collections
from collections import Counter
n = input()
*l, = map(int, input().split())
c = Counter(l)
A = [int(i*(i-1)/2) for i in c.values()]
A_sum = sum(A)
for j in l:
print(A_sum - c[j] + 1) | [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 74 |
import collections
n = int(input())
a = list(map(int, input().split()))
num_count = collections.Counter(a)
total = sum([num*(num-1)//2 for num in num_count.values()])
for i in range(n):
print(total-a.count(a[i]+1)) | import collections
n = int(input())
a = list(map(int, input().split()))
num_count = collections.Counter(a)
total = sum([num*(num-1)//2 for num in num_count.values()])
for i in range(n):
print(total-num_count[a[i]]+1) | [["-", 3, 4, 0, 657, 12, 652, 63, 319, 500, 22], ["-", 3, 4, 0, 657, 12, 652, 63, 319, 0, 131], ["-", 3, 4, 0, 657, 12, 652, 63, 319, 319, 22], ["-", 3, 4, 0, 657, 12, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 657, 31, 657, 12, 206, 51, 22], ["+", 3, 4, 0, 657, 31, 657, 12, 206, 0, 70], ["+", 3, 4, 0, 657, 31, 657, 12, 206, 0,... | 5 | 83 |
import collections
N = int(input())
A = list(map(int,input().split()))
CA = collections.Counter(A)
S = 0
for i in CA.values():
S += i*(i-1)//2
for x in range(A):
print(S - count[x] + 1) | import collections
N = int(input())
A = list(map(int,input().split()))
CA = collections.Counter(A)
S = 0
for i in CA.values():
S += i*(i-1)//2
for x in A:
print(S - CA[x] + 1) | [["-", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 25], ["-", 3, 4, 0, 657, 31, 657, 12, 206, 51, 22], ["+", 3, 4, 0, 657, 31, 657, 12, 206, 51, 22]] | 5 | 77 |
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
s = 0
for i in set(a):
s += c[i] * (c[i] - 1)
dp = [-1] * n
for i in a:
if dp[i] == -1:
dp[i] = (s - c[i] * (c[i] - 1) + (c[i] - 1) * (c[i] - 2)) // 2
print(dp[i])
else:
print(dp[i]) | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
s = 0
for i in set(a):
s += c[i] * (c[i] - 1)
dp = [-1] * (n + 1)
for i in a:
if dp[i] == -1:
dp[i] = (s - c[i] * (c[i] - 1) + (c[i] - 1) * (c[i] - 2)) // 2
print(dp[i])
else:
print(dp... | [["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 24], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 25]] | 5 | 141 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n, x;
ll ans = 0;
cin >> n;
ll a[n] = {0}, cnt[20000] = {0};
for (ll i = 0; i < n; i++) {
cin >> a[i];
ans += cnt[a[i]];
cnt[a[i]]++;
}
for (int i = 0; i < n; i++)
cout << ans - (cnt[a[i]] - 1) << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n;
ll ans = 0;
cin >> n;
ll a[200000] = {0}, cnt[200000] = {0};
for (ll i = 0; i < n; i++) {
cin >> a[i];
ans += cnt[a[i]];
cnt[a[i]]++;
}
for (int i = 0; i < n; i++)
cout << ans - (cnt[a[i]] - 1) << endl;... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 22], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]] | 1 | 124 |
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979
typedef long long i64;
typedef pair<i64, i64> P;
inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return ... | #include <bits/stdc++.h>
using namespace std;
#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979
typedef long long i64;
typedef pair<i64, i64> P;
inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return ... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 297 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i, n) for (ll i = 0; i < n; i++)
#define fok(i, k, n) for (ll i = k; i < n; i++)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define co(x) cout << x << "\n"
#define co2(x, y) cout << x << " " << y << "\n"
#define pb push_back
... | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i, n) for (ll i = 0; i < n; i++)
#define fok(i, k, n) for (ll i = k; i < n; i++)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define co(x) cout << x << "\n"
#define co2(x, y) cout << x << " " << y << "\n"
#define pb push_back
... | [["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]] | 1 | 352 |
N = int(input())
A = list(map(int, input().split()))
l = [0] * 10000001
for i in A:
l[i] += 1
s = 0
for i in range(N):
i = l[i]
s += i * (i - 1) // 2
for a in A:
a = l[a]
print(s - (a * (a - 1) // 2) + ((a - 1) * (a - 2) // 2))
| N = int(input())
A = list(map(int, input().split()))
l = [0] * 10000001
for i in A:
l[i] += 1
s = 0
for i in range(N + 1):
i = l[i]
s += i * (i - 1) // 2
for a in A:
a = l[a]
print(s - (a * (a - 1) // 2) + ((a - 1) * (a - 2) // 2))
| [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 114 |
#include <iostream>
using namespace std;
const int N = 2e5 + 10;
long long a[N], b[N];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
b[a[i]]++;
}
long long sum = 0;
for (int i = 0; i < n; i++)
sum += (long long)(b[i] * (b[i] - 1)) / 2;
for (int i = 0; i < n; i++) {
... | #include <iostream>
using namespace std;
const int N = 2e5 + 10;
long long a[N], b[N];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
b[a[i]]++;
}
long long sum = 0;
for (int i = 0; i <= n; i++)
sum += (b[i] * (b[i] - 1)) / 2;
for (int i = 0; i < n; i++) {
long lo... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 8, 1, 0, 11, 12, 16, 31, 74, 0, 24], ["-", 12, 16, 31, 74, 39, 77, 39, 86, 0, 96], ["-", 8, 1, 0, 11, 12, 16, 31, 74, 0, 25]] | 1 | 196 |
import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
sum = 0
kn = [0 for i in range(n)]
for i in range(n):
kn[a[i]] += 1
for i in range(n):
sum += kn[i]*(kn[i]-1)//2
for i in range(n):
x = kn[a[i]]
print(sum-x+1)
| import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
sum = 0
kn = [0 for i in range(n+1)]
for i in range(n):
kn[a[i]] += 1
for i in range(n+1):
sum += kn[i]*(kn[i]-1)//2
for i in range(n):
x = kn[a[i]]
print(sum-x+1)
| [["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 112 |
#include <bits/stdc++.h>
#include <numeric>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pr pair<int, int>
using namespace std;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
//#define DEBUG
#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) <... | #include <bits/stdc++.h>
#include <numeric>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pr pair<int, int>
using namespace std;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
//#define DEBUG
#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) <... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["-", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]] | 1 | 336 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
long nCr(int n, int r) { //コピペ
long ans = 1;
for (int i = n; i > n - r; --i) {
ans = ans * i;
}
for (int i = 1; i < r + 1; ++i) {
ans = ans / i;
}
return ans;
}
int main() {
m... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
long nCr(int n, int r) { //コピペ
long ans = 1;
for (int i = n; i > n - r; --i) {
ans = ans * i;
}
for (int i = 1; i < r + 1; ++i) {
ans = ans / i;
}
return ans;
}
int main() {
m... | [["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78]] | 1 | 272 |
def com(n):
return n*(n-1)//2
ans=0
n=int(input())
a=list(map(int,input().split()))
coun=[0]*n
for i in range(n):
coun[a[i]]+=1
for i in range(n):
ans+=com(coun[i])
for i in range(n):
m=com(coun[a[i]]-1)
o=com(coun[a[i]])
print(ans-o+m) | def com(n):
return n*(n-1)//2
ans=0
n=int(input())
a=list(map(int,input().split()))
coun=[0]*(n+1)
for i in range(n):
coun[a[i]]+=1
for i in range(n+1):
ans+=com(coun[i])
for i in range(n):
m=com(coun[a[i]]-1)
o=com(coun[a[i]])
print(ans-o+m) | [["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 24], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 25], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 127 |
import collections
N=int(input())
lst=input().split()
s=0
dic=collections.Counter(lst)
for i in dic.values():
s+=(i*i-i)//2
for i in lst:
print(s+1-dict[i]) | import collections
N=int(input())
lst=input().split()
s=0
dic=collections.Counter(lst)
for i in dic.values():
s+=(i*i-i)//2
for i in lst:
print(s+1-dic[i]) | [["-", 0, 652, 3, 4, 0, 657, 12, 206, 51, 22], ["+", 0, 652, 3, 4, 0, 657, 12, 206, 51, 22]] | 5 | 66 |
n=int(input())
l=list(map(int,input().split()))
d={}
sum=0
for i in range(n):
if l[i] not in d:
d[l[i]]=1
else:
d[l[i]]+=1
l1=[]
for i in d:
if d[i]>1:
l.append((d[i]*(d[i]-1))//2)
sum+=((d[i]*(d[i]-1))//2)
#print(d,sum)
for i in range(n):
if d[l[i]]==2:
print(sum-1)
elif d[l[i]]>2:
... | n=int(input())
l=list(map(int,input().split()))
d={}
sum=0
for i in range(n):
if l[i] not in d:
d[l[i]]=1
else:
d[l[i]]+=1
l1=[]
for i in d:
if d[i]>1:
l.append((d[i]*(d[i]-1))//2)
sum+=((d[i]*(d[i]-1))//2)
#print(d,sum)
for i in range(n):
if d[l[i]]==2:
print(sum-1)
elif d[l[i]]>2:
... | [["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 233 |
#include <bits/stdc++.h>
using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
void solve(std::vector<long long> A, long long N, long long numbers[],
long long ans[]) {
long long tot = 0;
rep(i, N) { ... | #include <bits/stdc++.h>
using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
void solve(std::vector<long long> A, long long N, long long numbers[],
long long ans[]) {
long long tot = 0;
rep(i, 20000... | [["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]] | 1 | 289 |
import collections
N = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)
L = {key:(B[key] * (B[key] - 1) // 2) for key in B}
total = sum(L.values())
#print(f"A = {A}\nB = {B}\nL = {L}\ntotal = {total}")
[print(0 if L[i] == 0 else total - L[i] + ((B[i] - 1) * (B[i] - 2)) // 2) for i in A] | import collections
N = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)
L = {key:(B[key] * (B[key] - 1) // 2) for key in B}
total = sum(L.values())
#print(f"A = {A}\nB = {B}\nL = {L}\ntotal = {total}")
[print(total if L[i] == 0 else total - L[i] + ((B[i] - 1) * (B[i] - 2) // 2)) for i in A] | [["-", 0, 658, 8, 652, 3, 4, 0, 41, 0, 612], ["+", 0, 658, 8, 652, 3, 4, 0, 41, 0, 22], ["-", 12, 657, 31, 23, 0, 657, 12, 23, 0, 25], ["+", 3, 4, 0, 41, 0, 657, 12, 23, 0, 25]] | 5 | 119 |
n = int(input())
ball = list(map(int,input().split()))
num = [0] * (n + 1)
data = [0] * (n + 1)
for i in ball:
num[i] += 1
for i in range(n):
data[i] = num[i] * (num[i] - 1) // 2
x = sum(data)
for i in ball:
print(x - num[i] + 1)
| n = int(input())
ball = list(map(int,input().split()))
num = [0] * (n + 1)
data = [0] * (n + 1)
for i in ball:
num[i] += 1
for i in range(n+1):
data[i] = num[i] * (num[i] - 1) // 2
x = sum(data)
for i in ball:
print(x - num[i] + 1)
| [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 108 |
import collections as cl
N = int(input())
A = list(map(int,inpput().split()))
cn = cl.Counter(A)
sumC = sum([n*(n-1)//2 for n in cl.values()])
for k in range(N):
print(sumC - cn[A[k]] +1) | import collections as cl
N = int(input())
A = list(map(int,input().split()))
cn = cl.Counter(A)
sumC = sum([n*(n-1)//2 for n in cn.values()])
for k in range(N):
print(sumC - cn[A[k]] +1) | [["-", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["+", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["-", 0, 658, 0, 659, 12, 652, 63, 319, 500, 22], ["+", 0, 658, 0, 659, 12, 652, 63, 319, 500, 22]] | 5 | 83 |
N = int(input())
A = list(map(int, input().split()))
cnt = [0] * (N+1)
ans = 0
for i in range(N):
cnt[A[i]] += 1
for i in range(N):
ans += cnt[i] * (cnt[i] - 1) // 2
for i in range(N):
print(ans - cnt[A[i]] + 1) | N = int(input())
A = list(map(int, input().split()))
cnt = [0] * (N+1)
ans = 0
for i in range(N):
cnt[A[i]] +=1
for i in range(N+1):
ans += cnt[i] * (cnt[i] - 1) // 2
for i in range(N):
print(ans - cnt[A[i]] + 1) | [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 103 |
from collections import Counter
def solve(string):
n, *a = map(int, string.split())
c = Counter(a)
b = sum(v * (v - 1) // 2 for v in c.values())
print(c, b)
return "\n".join(str(b - c[_a] + 1) for _a in a)
if __name__ == '__main__':
import sys
print(solve(sys.stdin.read().strip()))
| from collections import Counter
def solve(string):
n, *a = map(int, string.split())
c = Counter(a)
b = sum(v * (v - 1) // 2 for v in c.values())
return "\n".join(str(b - c[_a] + 1) for _a in a)
if __name__ == '__main__':
import sys
print(solve(sys.stdin.read().strip()))
| [["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 108 |
#include <iostream>
int main() {
int N;
long long a[200000], res = 0;
std::cin >> N;
for (int i = 0; i < N; i++) {
std::cin >> a[i];
}
long long bucket[200000] = {0};
for (int i = 0; i < N; i++) {
bucket[a[i]]++;
}
for (int i = 0; i < N; i++) {
if (bucket[i] >= 2) {
res += bucket[... | #include <iostream>
int main() {
int N;
long long a[210000], res = 0;
std::cin >> N;
for (int i = 0; i < N; i++) {
std::cin >> a[i];
}
long long bucket[210000] = {0};
for (int i = 0; i < N; i++) {
bucket[a[i]]++;
}
for (int i = 0; i < 210000; i++) {
if (bucket[i] >= 2) {
res += bu... | [["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]] | 1 | 189 |
N = int(input())
As = list(map(int, input().split()))
# 1が3個、2が5個、、、みたいなものを管理する配列
counter = [0 for i in range(N+1)]
for i in range(N):
counter[As[i]] += 1
# kC2を求める。(2C2 ~ NC2まで)
k_C_2 = [0 for i in range(N+1)]
k_C_2[2] = 1
for i in range(3, N+1):
k_C_2[i] = k_C_2[i-1] * i / (i-2)
# 全体を求める
all_case = 0
for ... | N = int(input())
As = list(map(int, input().split()))
# 1が3個、2が5個、、、みたいなものを管理する配列
counter = [0 for i in range(N+1)]
for i in range(N):
counter[As[i]] += 1
# kC2を求める。(2C2 ~ NC2まで)
k_C_2 = [0 for i in range(N+1)]
k_C_2[2] = 1
for i in range(3, N+1):
k_C_2[i] = k_C_2[i-1] * i / (i-2)
# 全体を求める
all_case = 0
for ... | [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 218 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
vector<int> a(n);
map<int, long long> cnt;
for (int i = 0; i <= n; i++) {
cin >> a[i];
cnt[a[i]]++;
}
long long ret = 0;
map<int, long long>::iterator p;
for (p = cnt.begin(); p != cnt.end(); p++) {
ret += (... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
vector<int> a(n);
map<int, long long> cnt;
for (int i = 0; i < n; i++) {
cin >> a[i];
cnt[a[i]]++;
}
long long ret = 0;
map<int, long long>::iterator p;
for (p = cnt.begin(); p != cnt.end(); p++) {
ret += (p... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 44]] | 1 | 196 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
vector<int> a(n);
map<int, long long> cnt;
for (int i = 0; i <= n; i++) {
cin >> a[i];
cnt[a[i]]++;
}
long long ret = 0;
map<int, long long>::iterator p;
for (p = cnt.begin(); p != cnt.end(); p++) {
ret += (... | // ABC 159 D-Banned K
// https://atcoder.jp/contests/abc159/tasks/abc159_d
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
vector<int> a(n);
map<int, long long> cnt;
for (i = 0; i < n; i++) {
cin >> a[i];
cnt[a[i]]++;
}
long long ret = 0;
map<int, long long>::it... | [["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 44]] | 1 | 196 |
#include <bits/stdc++.h>
#define FAST \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using namespace std;
// long long int... | #include <bits/stdc++.h>
#define FAST \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using namespace std;
// long long int... | [["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]] | 1 | 346 |
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
values, counts = zip(*c.most_common())
values, counts = list(values), list(counts)
k = 0
for i in range(len(counts)):
k += counts[i]*(counts[i]-1)//2
output = [0]*len(a)
for i in range(len(a)):
temp = c[a[i]]
if te... | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
values, counts = zip(*c.most_common())
values, counts = list(values), list(counts)
k = 0
for i in range(len(counts)):
k += counts[i]*(counts[i]-1)//2
output = [0]*len(a)
for i in range(len(a)):
temp = c[a[i]]
if te... | [["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 206, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]] | 5 | 169 |
#include <iostream>
#include <map>
using namespace std;
#define N (int)2e5
#define int long
int n;
int a[N], ans[N], b[N], buket[N + 1];
int solved[N];
int nC2[N + 1];
int nCr(int n, int r) {
if (n < r)
return 0;
int temp = 1, temp2 = 1;
for (int i = n; i > n - r; i--) {
temp *= i;
}
for (int i = 2; i... | #include <iostream>
#include <map>
using namespace std;
#define N (int)2e5
#define int long
int n;
int a[N], ans[N], b[N], buket[N + 1];
int solved[N];
int nC2[N + 1];
int nCr(int n, int r) {
if (n < r)
return 0;
int temp = 1, temp2 = 1;
for (int i = n; i > n - r; i--) {
temp *= i;
}
for (int i = 2; i... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 390 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio \
ios_base::sync_with_stdio(false)... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio \
ios_base::sync_with_stdio(false)... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 8, 9, 0, 9, 0, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 9, 0, 43, 49, 50, 51, 22]] | 1 | 857 |
N = int(input())
A = list(map(int, input().split()))
cnt = [0 for _ in range(N)]
for i in range(N):
cnt[A[i]-1] += 1
S = 0
for i in range(N):
S += cnt[i]*(cnt[i]-1)/2
for i in range(N):
if cnt[A[i]] == 1:
print(S)
else:
print(int(S+(3-2*cnt[A[i]-1])/2))
| N = int(input())
A = list(map(int, input().split()))
cnt = [0 for _ in range(N)]
for i in range(N):
cnt[A[i]-1] += 1
S = 0
for i in range(N):
S += cnt[i]*(cnt[i]-1)/2
for i in range(N):
if cnt[A[i]-1] == 1:
print(int(S))
else:
print(int(S+(3-2*cnt[A[i]-1])/2))
| [["+", 0, 57, 15, 666, 0, 206, 206, 657, 17, 33], ["+", 0, 57, 15, 666, 0, 206, 206, 657, 12, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 134 |
import math
import sys
from collections import Counter
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
count=Counter(A)
kotae=0
for a in range(N):
b=count[a]
kotae+=b*(b-1)//2
for a in A:
print(kotae+1-count[a])
| import math
import sys
from collections import Counter
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
count=Counter(A)
kotae=0
for a in range(N+1):
b=count[a]
kotae+=b*(b-1)//2
for a in A:
print(kotae+1-count[a])
| [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 98 |
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
ans = 0
for i in counter.values():
ans = i * (i - 1) // 2
for j in A:
cnt = counter[j]
if cnt <= 1:
print(ans)
else:
print(ans - cnt + 1) | from collections import Counter
n = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
ans = 0
for i in counter.values():
ans += i * (i - 1) // 2
for j in A:
cnt = counter[j]
if cnt <= 1:
print(ans)
else:
print(ans - cnt + 1) | [["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107]] | 5 | 88 |
#!/usr/bin/env python
def main():
n = int(input())
a = list(map(int, input().split()))
a_sort = sorted(a)
ball_dict = {}
count = 1
for i in range(1, n):
if a_sort[i] == a_sort[i - 1]:
count += 1
else:
ball_dict.setdefault(a_sort[i - 1], count)
... | #!/usr/bin/env python
def main():
n = int(input())
a = list(map(int, input().split()))
a_sort = sorted(a)
ball_dict = {}
count = 1
for i in range(1, n):
if a_sort[i] == a_sort[i - 1]:
count += 1
else:
ball_dict.setdefault(a_sort[i - 1], count)
... | [["-", 0, 57, 15, 666, 0, 652, 63, 319, 0, 131], ["-", 0, 57, 15, 666, 0, 652, 63, 319, 319, 22], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25]] | 5 | 192 |
import collections
N = int(input())
num_list = list(map(int,input().split()))
memo = [0]*(N+1)
memo_flg = [False]*(N+1)
counter = [0] * (N+1)
counter_ans = [0] * (N+1)
for i in num_list:
counter[i] += 1
for i in range(N):
counter_ans[i] = (counter[i]*(counter[i]-1))//2
all_sum = sum(counter_ans)
def calc(k):... | import collections
N = int(input())
num_list = list(map(int,input().split()))
memo = [0]*(N+1)
memo_flg = [False]*(N+1)
counter = [0] * (N+1)
counter_ans = [0] * (N+1)
for i in num_list:
counter[i] += 1
for i in range(N+1):
counter_ans[i] = (counter[i]*(counter[i]-1))//2
all_sum = sum(counter_ans)
def calc(k... | [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 212 |
import collections
import math
n = int(input())
aa = list(map(int, input().split()))
ls = [0] * (n-1)
c = collections.Counter(aa)
for i, j in c.items():
ls[i] = j*(j-1)//2
total = sum(ls)
for i in aa:
before = (c[i]-1)*(c[i]-2) // 2
print(total - ls[i] + before)
| import collections
import math
n = int(input())
aa = list(map(int, input().split()))
ls = [0] * (n+1)
c = collections.Counter(aa)
for i, j in c.items():
ls[i] = j*(j-1)//2
total = sum(ls)
for i in aa:
before = (c[i]-1)*(c[i]-2) // 2
print(total - ls[i] + before)
| [["-", 0, 662, 12, 657, 12, 23, 0, 657, 17, 33], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72]] | 5 | 116 |
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
c=Counter(a)
max_c=0 # max combination
for i in c.values():
max_c+=i*(i-1)//2 # 6+1+1 = 8
for num in a:
k=c[num] # 4 2 4 2 2 4 2 4
print(ans-(k*(k-1)//2)+((k-1)*(k-2)//2)) # different from max combination
... | n=int(input())
a=list(map(int,input().split()))
from collections import Counter
c=Counter(a)
max_c=0 # max combination
for i in c.values():
max_c+=i*(i-1)//2 # 6+1+1 = 8
for num in a:
k=c[num] # 4 2 4 2 2 4 2 4
print(max_c-(k*(k-1)//2)+((k-1)*(k-2)//2)) # different from max combination
... | [["-", 0, 652, 3, 4, 0, 657, 31, 657, 31, 22], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 31, 22]] | 5 | 107 |
n=int(input())
a=list(map(int,input().split()))
ans=0
b=[0]*n
for i in range(n):
b[a[i]]+=1
for k in b:
ans+=k*(k-1)//2
for i in range(n):
print(ans-b[a[i]]+1) | n=int(input())
a=list(map(int,input().split()))
ans=0
b=[0]*(n+1)
for i in range(n):
b[a[i]]+=1
for k in b:
ans+=k*(k-1)//2
for i in range(n):
print(ans-b[a[i]]+1) | [["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 24], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 25]] | 5 | 90 |
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a[200000];
int ai, a_num[200000] = {0};
for (int i = 0; i < n; i++) {
cin >> ai;
a_num[ai]++;
a[i] = ai;
}
long long convs = 0;
for (int i = 0; i < n; i++) {
convs += (long long)(a_num[i]) * (a... | #include <cmath>
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a[200001];
int ai, a_num[200001] = {0};
for (int i = 0; i < n; i++) {
cin >> ai;
a_num[ai]++;
a[i] = ai;
}
long long convs = 0;
for (int i = 0; i <= n; i++) {
convs += (long long)(a_num[i]) * (... | [["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 152 |
import collections
def check(A):
count = 0
for j in A:
n = A[j]
if n > 1:
count += n * (n - 1) / 2
return int(count)
N = int(input())
A = list(map(int, input().split(" ")))
A2 = collections.Counter(A)
print(A2)
Nsum = check(A2)
# print(Nsum)
for i in range(0,N):
... | import collections
def check(A):
count = 0
for j in A:
n = A[j]
if n > 1:
count += n * (n - 1) / 2
return int(count)
N = int(input())
A = list(map(int, input().split(" ")))
A2 = collections.Counter(A)
# print(A2)
Nsum = check(A2)
# print(Nsum)
for i in range(0,N):... | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 125 |
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
re = [0] * (n-1)
c = Counter(a) # c: Counter({1: 3, 2: 2})など
for k, v in c.items():
re[k] = v*(v-1) // 2
total = sum(re)
for i in a:
print(total - re[i] + (c[i]-1)*(c[i]-2) // 2) | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
re = [0] * (n+1)
c = Counter(a) # c: Counter({1: 3, 2: 2})など
for k, v in c.items():
re[k] = v*(v-1) // 2
total = sum(re)
for i in a:
print(total - re[i] + (c[i]-1)*(c[i]-2) // 2) | [["-", 0, 662, 12, 657, 12, 23, 0, 657, 17, 33], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72]] | 5 | 112 |
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long in... | #pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long in... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 28, 22], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 17, 131], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 119, 120], ["+", 0, 7, 15, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 7, 15, 16, 12, 2, 3, 4, 0, 25]] | 1 | 504 |
n = int(input())
l = list(map(int, input().split()))
ans = 0
k = [0 for _ in range(n+1)]
for i in range(n):
k[l[i]] += 1
ll = len(k)
for i in range(ll):
a = k[i]
if a <= 1:
pass
else:
ans += (a * (a - 1))/2
for i in range(n):
a = k[l[i]]
b = (a * (a - 1))/2
c... | n = int(input())
l = list(map(int, input().split()))
ans = 0
k = [0 for _ in range(n+1)]
for i in range(n):
k[l[i]] += 1
ll = len(k)
for i in range(ll):
a = k[i]
if a <= 1:
pass
else:
ans += (a * (a - 1))/2
for i in range(n):
a = k[l[i]]
b = (a * (a - 1))/2
c... | [["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18]] | 5 | 179 |
import collections
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
c=defaultdict(int)
for s in a:
c[s]+=1
a1=list(set(a))
total=0
for j in range(len(a1)):
x=c[a[j]]
total+=x*(x-1)/2
for i in range(n):
ans=total-c[a[i]]+1
print(int(ans)) | import collections
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
c=defaultdict(int)
for s in a:
c[s]+=1
a1=list(set(a))
total=0
for j in range(len(a1)):
x=c[a1[j]]
total+=x*(x-1)/2
for i in range(n):
ans=total-c[a[i]]+1
print(int(ans)) | [["-", 0, 1, 0, 662, 12, 206, 206, 206, 51, 22], ["+", 0, 1, 0, 662, 12, 206, 206, 206, 51, 22]] | 5 | 119 |
m = int(input())
q_list = list(map(int, input().strip().split()))
n = [0] * m
k = [0] * m
for i in q_list:
n[i - 1] += 1
for j, l in zip(range(m), n):
k[j] = int(l * (l - 1)/2)
sum_n = sum(k)
for j in q_list:
print(sum_n - n[j - 1]-1)
| m = int(input())
q_list = list(map(int, input().strip().split()))
n = [0] * m
k = [0] * m
for i in q_list:
n[i - 1] += 1
for j, l in zip(range(m), n):
k[j] = int(l * (l - 1)/2)
sum_n = sum(k)
for j in q_list:
print(sum_n - n[j - 1] + 1)
| [["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72]] | 5 | 112 |
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string.h>
#include <string>
//#include <vector.h>
//#include <malloc.h>
#include <math.h>
using namespace std;
#include <stdio.h>
#include <stdlib.h>
int main() {
int n;
cin >> n;
int a[200009];
int cnt[200009];
for (int i = 0; i < 200002... | #include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string.h>
#include <string>
//#include <vector.h>
//#include <malloc.h>
#include <math.h>
using namespace std;
#include <stdio.h>
#include <stdlib.h>
int main() {
int n;
cin >> n;
int a[200009];
long long cnt[200009];
for (int i = 0; i < ... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]] | 1 | 225 |
#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <f... | #include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <f... | [["+", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22]] | 1 | 466 |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
var (
sc = bufio.NewScanner(os.Stdin)
)
func scanIntSplit(len int) ([]int, map[int]int) {
buf := make([]byte, 0) //ここのサイズは何でもよさそう
sc.Buffer(buf, 1000000009)
mp := make(map[int]int)
arr := make([]int, len)
sc.Scan()
for i, v := range strings.... | package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
var (
sc = bufio.NewScanner(os.Stdin)
)
func scanIntSplit(len int) ([]int, map[int]int) {
buf := make([]byte, 0) //ここのサイズは何でもよさそう
sc.Buffer(buf, 1000000009)
mp := make(map[int]int)
arr := make([]int, len)
sc.Scan()
for i, v := range strings.... | [["-", 8, 196, 0, 7, 8, 196, 0, 440, 0, 217], ["-", 0, 7, 8, 196, 0, 440, 0, 441, 39, 78], ["+", 8, 196, 0, 7, 8, 196, 0, 431, 0, 466], ["+", 0, 7, 8, 196, 0, 431, 12, 432, 0, 22]] | 7 | 323 |
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
sum=0
for i in range(N):
b[a[i]]+=1
for i in range(N):
sum+=b[i]*(b[i]-1)//2
for i in range(N):
print(sum-b[a[i]]+1) | N=int(input())
a=list(map(int,input().split()))
b=[0]*N
sum=0
for i in range(N):
b[a[i]-1]+=1
for i in range(N):
sum+=b[i]*(b[i]-1)//2
for i in range(N):
print(sum-b[a[i]-1]+1) | [["+", 0, 1, 0, 677, 31, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 677, 31, 206, 206, 657, 12, 612], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 17, 33], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 12, 612]] | 5 | 99 |
N = int(input())
A = list(map(int, input().split()))
D = defaultdict(int)
for a in A:
D[a] += 1
ans_base = 0
for v in D.values():
ans_base += v * (v - 1) // 2
for a in A:
print(ans_base - (D[a] * (D[a] - 1) // 2) + ((D[a] - 1) * (D[a] - 2) // 2)) | from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
D = defaultdict(int)
for a in A:
D[a] += 1
ans_base = 0
for v in D.values():
ans_base += v * (v - 1) // 2
for a in A:
print(ans_base - (D[a] * (D[a] - 1) // 2) + ((D[a] - 1) * (D[a] - 2) // 2))
| [["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["+", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["+", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22]] | 5 | 114 |
#include <bits/stdc++.h>
using namespace std;
long long sum;
int a[200001], cnt[200001];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
cnt[a[i]]++;
}
for (int i = 0; i < n; i++)
sum += (long long)cnt[i] * (cnt[i] - 1) / 2;
for (int i = 0; i < n; i++)
cout << sum ... | #include <bits/stdc++.h>
using namespace std;
long long sum;
int a[200001], cnt[200001];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
cnt[a[i]]++;
}
for (int i = 0; i <= n; i++)
sum += (long long)cnt[i] * (cnt[i] - 1) / 2;
for (int i = 0; i < n; i++)
cout << sum... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 135 |
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
cnts = Counter(a)
_sum = 0
for key,value in cnts.items():
_sum += value*(value-1)//2
for ai in a:
ans = _sum
c = cnts.count(ai)
ans -= c*(c-1)//2
ans += (c-1)*(c-2)//2
print(ans)
| from collections import Counter
N = int(input())
a = list(map(int, input().split()))
cnts = Counter(a)
_sum = 0
for key,value in cnts.items():
_sum += value*(value-1)//2
for ai in a:
ans = _sum
c = cnts[ai]
ans -= c*(c-1)//2
ans += (c-1)*(c-2)//2
print(ans)
| [["-", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 662, 12, 206, 0, 70], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["+", 8, 196, 0, 1, 0, 662, 12, 206, 0, 73]] | 5 | 106 |
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
ll T[200001] = {0};
int main() {
int n;
cin >> n;
vector<int> A(n);
int MAX = 0;
rep(i, n) {
// cin >> A[i];
A[i] = 1;
T[A[i]]++;
MAX = max(MA... | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
ll T[200001] = {0};
int main() {
int n;
cin >> n;
vector<int> A(n);
int MAX = 0;
rep(i, n) {
cin >> A[i];
T[A[i]]++;
MAX = max(MAX, A[i]);
}
... | [["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]] | 1 | 218 |
import collections
# input
N = int(input())
A = map(int,input().split())
# calculatioin
cnt = collections.Counter(A)
full_cnt = int(sum(cnt[key]*(cnt[key]-1)/2 for key in cnt))
for i in range(N):
print(full_cnt - cnt[A[i]]+1) | import collections
# input
N = int(input())
A = input().split()
# calculatioin
cnt = collections.Counter(A)
full_cnt = int(sum(cnt[key]*(cnt[key]-1)/2 for key in cnt))
for i in range(N):
print(full_cnt - cnt[A[i]]+1) | [["-", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 83 |
#include <bits/stdc++.h>
#define rep(i, c) for (int i = 0; i < (int)c; ++i)
using llint = long long int;
using namespace std;
int main() {
int N;
map<int, llint> mp;
vector<int> A(N);
cin >> N;
rep(i, N) {
cin >> A[i];
mp[A[i]]++;
}
llint num = 0;
for (auto itr = mp.begin(); itr != mp.end(); ... | #include <bits/stdc++.h>
#define rep(i, c) for (int i = 0; i < (int)c; ++i)
using llint = long long int;
using namespace std;
int main() {
int N;
map<int, llint> mp;
int A[300000];
cin >> N;
rep(i, N) {
cin >> A[i];
mp[A[i]]++;
}
llint num = 0;
for (auto itr = mp.begin(); itr != mp.end(); itr... | [["-", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["-", 8, 9, 0, 43, 39, 344, 3, 347, 0, 18], ["-", 8, 9, 0, 43, 39, 344, 3, 347, 0, 47], ["-", 8, 9, 0, 43, 49, 53, 54, 55, 0, 24], ["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 8, 9, 0, 43, 49, 53, 54, 55, 0, 25], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 0, 70], ["+", 0, 14, ... | 1 | 228 |
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
ll cnt[200005], c[200005];
int main() {
std::ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// ll tt; cin>>tt; while(tt--)
{
ll n, i, x, sum;
cin >> n;
ll arr[n + 1];
for (i = 0; i < n; i++... | #include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
ll cnt[200005], c[200005];
int main() {
std::ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// ll tt; cin>>tt; while(tt--)
{
ll n, i, x, sum;
cin >> n;
ll arr[n + 1];
for (i = 0; i < n; i++... | [["-", 8, 9, 0, 9, 0, 7, 15, 16, 17, 18], ["+", 8, 9, 0, 9, 0, 7, 15, 16, 17, 19]] | 1 | 215 |
import collections
MOD = 10**15+7
n = int(input())
a = list(map(int, input().split()))
b = [[0 for j in range(2)] for i in range(n)]
c = collections.Counter(a)
s = 0
def nCr(nn, r, mod):
r = min(r, nn-r)
numer = denom = 1
for i in range(1, r+1):
numer = numer * (nn+1-i) % mod
denom = denom * i % mod
return nume... | import collections
MOD = 10**18+9
n = int(input())
a = list(map(int, input().split()))
b = [[0 for j in range(2)] for i in range(n)]
c = collections.Counter(a)
s = 0
def nCr(nn, r, mod):
r = min(r, nn-r)
numer = denom = 1
for i in range(1, r+1):
numer = numer * (nn+1-i) % mod
denom = denom * i % mod
return nume... | [["-", 0, 1, 0, 662, 12, 657, 31, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 12, 612], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 274 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for (int i = (int)(m - 1); i >= (int)(n); i--)
#define rev(i, n) revi(i, n, 0)
#defi... | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for (int i = (int)(m - 1); i >= (int)(n); i--)
#define rev(i, n) revi(i, n, 0)
#defi... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 359 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
ll sum = 0, n;
ll a[maxn], b[maxn], c[maxn];
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
b[a[i]]++;
}
for (int i = 0; i < n; i++) {
c[i] = b[i] * (b[i] - 1) / 2;
sum += c[i];
}
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
ll sum = 0, n;
ll a[maxn], b[maxn], c[maxn];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[a[i]]++;
}
for (int i = 0; i <= n; i++) {
c[i] = b[i] * (b[i] - 1) / 2;
sum += c[i];
}... | [["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 163 |
/*
Charlotteまだ見てない人は見ような!!!!!!!
/ /:/ \:ヽ \
/ / \ ヽ
\__L 彡 ヽ ',
フ / / / / , ヽ ', j
レ / / / ', ヽ j
// ! /_l_/__ノ { \} ', ',/
... | /*
Charlotteまだ見てない人は見ような!!!!!!!
/ /:/ \:ヽ \
/ / \ ヽ
\__L 彡 ヽ ',
フ / / / / , ヽ ', j
レ / / / ', ヽ j
// ! /_l_/__ノ { \} ', ',/
... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 218, 49, 185, 54, 55, 0, 56, 39, 40], ["+", 0, 218, 49, 185, 54, 55, 0, 56, 39, 78], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 12, 103, 0, 104], ["+", 8, 9, 0, 1, 0, 16, 12, 103, 0, 44]] | 1 | 846 |
n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
if d.get(x) is None:
d[x]=1
continue
d[x]+=1
total=0
for v in d.values():
total+=(y-1)*y//2
for x in a:
print(total-d[x]+1) | n=int(input())
a=list(map(int,input().split()))
d={}
for x in a:
if d.get(x) is None:
d[x]=1
continue
d[x]+=1
total=0
for v in d.values():
total+=(v-1)*v//2
for x in a:
print(total-d[x]+1) | [["-", 12, 657, 31, 657, 31, 23, 0, 657, 31, 22], ["+", 12, 657, 31, 657, 31, 23, 0, 657, 31, 22], ["-", 0, 1, 0, 677, 12, 657, 31, 657, 12, 22], ["+", 0, 1, 0, 677, 12, 657, 31, 657, 12, 22]] | 5 | 96 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.