Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
 
using namespace std;
 
 
int main() {
    map<char, vector<int>> AA;
    string s, t;
 
    cin >> s >> t;
 
    int tmps_prev = 0;
    for(int i = 0; i < s.size(); i++){
        char s_c = s[i];
        int tmp_s = i + 1;
        
        AA[s_c].push_back(i + 1);
        
    }
        
    long long prev_t = 0;
    long long NOM = 0;
    for(const auto & t_c : t){
        
        if(AA[t_c].empty()) {
            cout << -1 << endl;
            return 0;
        }
        
        long long f2 = lower_bound(AA[t_c].begin(), AA[t_c].end(), prev_t);
        long long index = f2 - AA[t_c].begin();
        if (index >= AA[t_c].size()){
            NOM += s.size() - prev_t + AA[t_c].front();
            prev_t = AA[t_c].front();
        }else{
            
            long long f3 = AA[t_c][index];
            NOM += f3 - prev_t; 
            prev_t = f3;
        }
 
       
  
                
    }
    

    
    
    cout << NOM << endl;  
    
    
    
    
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:35: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'long long int' in initialization
   34 |         long long f2 = lower_bound(AA[t_c].begin(), AA[t_c].end(), prev_t);
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                   |
      |                                   __gnu_cxx::__normal_iterator<int*, std::vector<int> >
a.cc:35:30: error: no match for 'operator-' (operand types are 'long long int' and 'std::vector<int>::iterator')
   35 |         long long index = f2 - AA[t_c].begin();
      |                           ~~ ^ ~~~~~~~~~~~~~~~
      |                           |                 |
      |                           long long int     std::vector<int>::iterator
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:35:46: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'long long int'
   35 |         long long index = f2 - AA[t_c].begin();
      |                                              ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:35:46: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'long long int'
   35 |         long long index = f2 - AA[t_c].begin();
      |                                              ^
/usr/include/c++/14/bits/stl_iterator.h:1312:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> decltype ((__lhs.base() - __rhs.base())) __gnu_cxx::operator-(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
 1312 |     operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1312:5: note:   template argument deduction/substitution failed:
a.cc:35:46: note:   mismatched types 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' and 'long long int'
   35 |         long long index = f2 - AA[t_c].begin();
      |                                              ^
/usr/include/c++/14/bits/stl_iterator.h:1325:5: note: candidate: 'template<class _Iterator, class _Container> typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type __gnu_cxx::operator-(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
 1325 |     operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1325:5: note:   template argument deduction/substitution failed:
a.cc:35:46: note:   mismatched types 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' and 'long long int'
   35 |         long long index = f2 - AA[t_c].begin();
      |                                              ^