Language: C++

#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<queue>

using namespace std;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<pis,int> tri;
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

int main(){
	int n,m,p;
	string s;
	tri t,*po;
	pis pi;
	vector< tri > v;
	scanf("%d",&n);
	rep(i,n){
		cin >> s;
		cin >> m;
		pi = pis(s.length(),s);
		po = lower_bound(v.begin(),v.end(),tri(pi,0));
		if(po != v.end() && po->first.second == s){
			po->second += m;
		}else{
			if(v.size()==0)v.push_back(tri(pi,m));
			else v.insert(po,tri(pi,m));
		}
	}
	rep(i,v.size())printf("%s %d\n",v[i].first.second.c_str(),v[i].second);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:33: error: cannot convert '__gnu_cxx::__normal_iterator<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*, std::vector<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int> > >' to 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} in assignment
   31 |                 po = lower_bound(v.begin(),v.end(),tri(pi,0));
      |                      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                 |
      |                                 __gnu_cxx::__normal_iterator<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*, std::vector<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int> > >
a.cc:32:23: error: no match for 'operator!=' (operand types are 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} and 'std::vector<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int> >::iterator')
   32 |                 if(po != v.end() && po->first.second == s){
      |                    ~~ ^~ ~~~~~~~
      |                    |          |
      |                    |          std::vector<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int> >::iterator
      |                    tri* {aka std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*}
In file included from /usr/include/c++/14/bits/char_traits.h:42,
                 from /usr/include/c++/14/string:42,
                 from a.cc:2:
/usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)'
  197 |     operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:197:5: note:   template argument deduction/substitution failed:
a.cc:32:32: note:   mismatched types 'const std::fpos<_StateT>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'}
   32 |                 if(po != v.end() && po->first.second == s){
      |                                ^
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)'
  243 |     operator!=(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:243:5: note:   template argument deduction/substitution failed:
a.cc:32:32: note:   mismatched types 'const std::allocator<_CharT>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'}
   32 |                 if(po != v.end() && po->first.second == s){
      |                                ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  455 |     operator!=(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note:   template argument deduction/substitution failed:
a.cc:32:32: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'}
   32 |                 if(po != v.end() && po->first.second == s){
      |                                ^
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  500 |     operator!=(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note:   template argument deduction/substitution failed:
a.cc:32:32: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'}
   32 |                 if(po != v.end() && po->first.second == s){
      |                                ^
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1686 |     operator!=(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note:   template argument deduction/substitution failed:
a.cc:32:32: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'}
   32 |                 if(po != v.end() && po->first.second == s){
      |                                ^
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1753 |     operator!=(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note:   template argument deduction/substitution failed:
a.cc:32:32: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'}
   32 |                 if(po != v.end() && po->first.second == s){
      |                                ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1052 |     operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note:   template argument deduction/substitution failed:
a.cc:32:32: note:   mismatched types 'const std::pair<_T1, _T2>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'}
   32 |                 if(po != v.end() && po->first.second == s){
      |                                ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
  651 |     operator!=(basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:651:5: note:   template argument deduction/substitution failed:
a.cc:32:32: note:   mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'}
   32 |                 if(po != v.end() && po->first.second == s){
      |                                ^
/usr/include/c++/14/string_view:658:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
  658 |     operator!=(basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:658:5: note:   template argument deduction/substitution failed:
a.cc:32:32: note:   mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'}
   32 |                 if(po != v.end() && po->first.second == s){
      |                                ^
/usr/include/c++/14/string_view:666:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
  666 |     operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:666:5: note:   template argument deduction/substitution failed:
a.cc:32:32: note:   '__gnu_cxx::__normal_iterator<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*, std::vector<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int> > >' is not derived from 'std::basic_string_view<_CharT, _Traits>'
   32 |                 if(po != v.end() && po->first.second == s){
      |                                ^
/usr/include/c++/14/bits/basic_string.h:3833:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3833 |     operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3833:5: note:   template argument deduction/substitution failed:
a.cc:32:32: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'}
   32 |                 if(po != v.end() && po->first.second == s){
      |                                ^
/usr/include/c++/14/bits/basic_string.h:3847:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3847 |     operator!=(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3847:5: note:   template argument deduction/substitution failed:
a.cc:32:32: note:   'std::vector<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int> >::iterator' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   32 |                 if(po != v.end() && po->first.second == s){
      |                                ^
/usr/include/c++/14/bits/basic_string.h:3860:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
 3860 |     operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~