Language: C++

    #include<bits/stdc++.h>
    using namespace std;
    #define ll long long int 
    int main()
    {
        string s,t;
        cin>>s>>t;
        vector<ll>v[26];
        vector<ll>::iterator it;
        ll i,n=s.size(),m=t.size(),count=0,num,flag=1,last=-1;
        for(i=0;i<n;i++)
            v[s[i]-'97'].push_back(i);

        for(i=0;i<n;i++)
        if(s[i]==t[0])
        {
            last=i;
            break;
        }
        if(last<0)
        {
            cout<<-1;
            return 0;
        }
        for(i=1;i<m;i++)
        {
            num= (t[i]-'97');
            if(v[num].size()==0)
            {
                flag=0;
                break;
            }
            else
            {
                it=lower_bound(v[num].begin(),v[num].end(),last);
                index=it-(v[num].begin());
                if(v[num][index]<=last)
                     {
                         count++;
                         last=v[num][0];
                     }
                else
                    last=v[num][index]; 
            } 
        }
        if(!flag)
        cout<<-1<<endl;
        else
        cout<<(count*n)+last<<endl;
        
    } 

Compiler output:
a.cc:12:20: warning: multi-character character constant [-Wmultichar]
   12 |             v[s[i]-'97'].push_back(i);
      |                    ^~~~
a.cc:27:24: warning: multi-character character constant [-Wmultichar]
   27 |             num= (t[i]-'97');
      |                        ^~~~
a.cc: In function 'int main()':
a.cc:36:41: error: overloaded function with no contextual type information
   36 |                 index=it-(v[num].begin());
      |                                         ^
a.cc:37:26: error: no match for 'operator[]' (operand types are 'std::vector<long long int>' and '<unresolved overloaded function type>')
   37 |                 if(v[num][index]<=last)
      |                          ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<long long int>::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = long long int; _Alloc = std::allocator<long long int>; const_reference = const long long int&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<long long int>::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:43:32: error: no match for 'operator[]' (operand types are 'std::vector<long long int>' and '<unresolved overloaded function type>')
   43 |                     last=v[num][index];
      |                                ^
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<long long int>::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = long long int; _Alloc = std::allocator<long long int>; const_reference = const long long int&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<long long int>::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~