Language: C++

#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
 

int main() {
    queue q;
    map m;
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]==1]) q.push(a[i]);
    }
    rep(i,n){
        int sum = 0;
        m[a[i]]--;
        rep(i,q.size()){
            sum += (m[q[i]]-1)*m[q[i]]/2;
        }
        m[a[i]]++;
        cout << sum << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:11: error: class template argument deduction failed:
   10 |     queue q;
      |           ^
a.cc:10:11: error: no matching function for call to 'queue()'
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:195:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> queue(std::queue<_Tp, _Seq>&&, const _Alloc&)-> std::queue<_Tp, _Sequence>'
  195 |         queue(queue&& __q, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:195:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:191:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> queue(const std::queue<_Tp, _Seq>&, const _Alloc&)-> std::queue<_Tp, _Sequence>'
  191 |         queue(const queue& __q, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:191:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:187:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> queue(_Sequence&&, const _Alloc&)-> std::queue<_Tp, _Sequence>'
  187 |         queue(_Sequence&& __c, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:187:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:183:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> queue(const _Sequence&, const _Alloc&)-> std::queue<_Tp, _Sequence>'
  183 |         queue(const _Sequence& __c, const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:183:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:179:9: note: candidate: 'template<class _Tp, class _Sequence, class _Alloc, class _Requires> queue(const _Alloc&)-> std::queue<_Tp, _Sequence>'
  179 |         queue(const _Alloc& __a)
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:179:9: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:174:7: note: candidate: 'template<class _Tp, class _Sequence> queue(_Sequence&&)-> std::queue<_Tp, _Sequence>'
  174 |       queue(_Sequence&& __c)
      |       ^~~~~
/usr/include/c++/14/bits/stl_queue.h:174:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:170:7: note: candidate: 'template<class _Tp, class _Sequence> queue(const _Sequence&)-> std::queue<_Tp, _Sequence>'
  170 |       queue(const _Sequence& __c)
      |       ^~~~~
/usr/include/c++/14/bits/stl_queue.h:170:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:166:9: note: candidate: 'template<class _Tp, class _Sequence, class _Seq, class _Requires> queue()-> std::queue<_Tp, _Sequence>'
  166 |         queue()
      |         ^~~~~
/usr/include/c++/14/bits/stl_queue.h:166:9: note:   template argument deduction/substitution failed:
a.cc:10:11: note:   couldn't deduce template parameter '_Tp'
   10 |     queue q;
      |           ^
/usr/include/c++/14/bits/stl_queue.h:96:11: note: candidate: 'template<class _Tp, class _Sequence> queue(std::queue<_Tp, _Sequence>)-> std::queue<_Tp, _Sequence>'
   96 |     class queue
      |           ^~~~~
/usr/include/c++/14/bits/stl_queue.h:96:11: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:344:5: note: candidate: 'template<class _Container, class _Allocator, class> std::queue(_Container, _Allocator)-> queue<typename _Container::value_type, _Container>'
  344 |     queue(_Container, _Allocator)
      |     ^~~~~
/usr/include/c++/14/bits/stl_queue.h:344:5: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:340:5: note: candidate: 'template<class _Container, class> std::queue(_Container)-> queue<typename _Container::value_type, _Container>'
  340 |     queue(_Container) -> queue<typename _Container::value_type, _Container>;
      |     ^~~~~
/usr/include/c++/14/bits/stl_queue.h:340:5: note:   candidate expects 1 argument, 0 provided
a.cc:11:9: error: class template argument deduction failed:
   11 |     map m;
      |         ^
a.cc:11:9: error: no matching function for call to 'map()'
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_map.h:302:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator, const _Compare&, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  302 |         map(_InputIterator __first, _InputIterator __last,
      |         ^~~
/usr/include/c++/14/bits/stl_map.h:302:9: note:   candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_map.h:285:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  285 |         map(_InputIterator __first, _InputIterator __last)
      |         ^~~
/usr/include/c++/14/bits/stl_map.h:285:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_map.h:268:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  268 |         map(_InputIterator __first, _InputIterator __last,
      |         ^~~
/usr/include/c++/14/bits/stl_map.h:268:9: note:   candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_map.h:262:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::initializer_list<std::pair<const _Key, _Val> >, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  262 |       map(initializer_list<value_type> __l, const allocator_type& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:262:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_map.h:256:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Allocator>&&, std::__type_identity_t<_Alloc>&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  256 |       map(map&& __m, const __type_identity_t<allocator_type>& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:256:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_map.h:252:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(const std::map<_Key, _Tp, _Compare, _Allocator>&, std::__type_identity_t<_Alloc>&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  252 |       map(const map& __m, const __type_identity_t<allocator_type>& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:252:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_map.h:248:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  248 |       map(const allocator_type& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:248:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_map.h:240:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::initializer_list<std::pair<const _Key, _Val> >, const _Compare&, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  240 |       map(initializer_list<value_type> __l,
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:240:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_map.h:227:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Allocator>&&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  227 |       map(map&&) = default;
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:227:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_map.h:219:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(const std::map<_Key, _Tp, _Compare, _Allocator>&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  219 |       map(const map&) = default;
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:219:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_map.h:206:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(const _Compare&, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  206 |       map(const _Compare& __comp,
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:206:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_map.h:197:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map()-> std::map<_Key, _Tp, _Compare, _Alloc>'
  197 |       map() = default;
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:197:7: note:   template argument deduction/substitution failed:
a.cc:11:9: note:   couldn't deduce template parameter '_Key'
   11 |     map m;
      |         ^
/usr/include/c++/14/bits/stl_map.h:102:11: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Alloc>)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  102 |     class map
      |           ^~~
/usr/include/c++/14/bits/stl_map.h:102:11: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_map.h:1495:5: note: candidate: 'template<class _Key, class _Tp, class _Allocator, class> std::map(initializer_list<pair<_T1, _T2> >, _Allocator)-> map<_Key, _Tp, less<_Key>, _Allocator>'
 1495 |     map(initializer_list<pair<_Key, _Tp>>, _Allocator)
      |     ^~~
/usr/include/c++/14/bits/stl_map.h:1495:5: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_map.h:1489:5: note: candidate: 'template<class _InputIterator, class _Allocator, class, class> std::map(_InputIterator, _InputIterator, _Allocator)-> map<typename rem