fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  4. #define int long long
  5. #define rep(i,a,b) for(int i=a;i<b;++i)
  6.  
  7. void solve() {
  8. int n;
  9. cin>>n;
  10. vector<int> a(n);
  11. rep(i,0,n) cin>>a[i];
  12. sort(a.begin(), a.end());
  13. auto it = unique(a.begin(), a.end());
  14. int new_size = distance(a.begin(), it);
  15. cout << n - new_size << '\n';
  16. }
  17.  
  18. int32_t main() {
  19. fast_io;
  20. int t;
  21. cin >> t;
  22. while (t--) solve();
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.01s 5228KB
stdin
5
3
3 2 1
3
1 2 3
3
3 3 3
5
3 1 4 5 2
1
1
stdout
0
0
2
0
0