Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pic pair<int,char>
#define pci pair<char,int>
#define pll pair<ll,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define vic vector<pic>
#define vci vector<pci>
#define vlc vector<plc>
#define vcl vector<pcl>
#define pb push_back
const ll MOD=1e9+7;
const ll MAXN=1e5+3;
const ll MAXM=1e5+3;
#define bigint string
#define pbb pair<bigint,bigint>
bool operator<(bigint b1,bigint b2)
{
    if(b1.size()!=b2.size())return b1.size()<b2.size();
    else return b1<b2;
}
bigint sabirane(bigint s1,bigint s2)
{
    int t,p=0;
    bigint ans="";
    while(s1.size()!=s2.size())
    {
        if(s1.size()<s2.size())s1='0'+s1;
        else s2='0'+s2;
    }
    for(int i=s1.size()-1;i>=0;i--)
    {
        t=s1[i]-'0'+s2[i]-'0'+p;
        p=t/10;
        ans+=char(t%10+'0');
    }
    if(p==1)ans+='1';
    reverse(ans.begin(),ans.end());
    return ans;
}
bigint izvajdane(bigint s1,bigint s2)
{
    int t,p=0;
    bigint ans1="",ans="";
    for(int i=0;i<s1.size()-s2.size();i++)
    {
        s2='0'+s2;
    }
    for(int i=s1.size()-1;i>=0;i--)
    {
        t=s1[i]-s2[i]-p;
        p=0;
        if(t<0){p=1;t+=10;}
        ans1+=char(t+'0');
    }
    reverse(ans1.begin(),ans1.end());
    bool flag=0;
    for(int i=0;i<ans1.size();i++)
    {
        if(!(ans1[i]=='0'&&flag==0))
        {
            ans+=ans1[i];
            flag=1;
        }
    }
    return ans;
}
bigint umnojenie(bigint s,int x)
{
    int t,p=0;
    bigint ans="";
    for(int i=s.size()-1;i>=0;i--)
    {
        t=(s[i]-'0')*x+p;
        p=t/10;
        ans+=char(t%10+'0');
    }
    while(p)
    {
        ans+=char(p%10+'0');
        p/=10;
    }
    if(ans=="")ans="0";
    reverse(ans.begin(),ans.end());
    return ans;
}
bigint delenie(bigint s,int x)
{
    bigint s1="";
    int k,sum1=0;
    bool flag=0;
    for(int i=0;i<s.size();i++)
    {
        sum1=sum1*10+(s[i]-'0');
        k=sum1/x;
        sum1%=x;
        if(k>0||flag)
        {
            s1+=char('0'+k);
            flag=1;
        }
    }
    return s1;
}
pbb delenie1(bigint s1,bigint s2)
{
    bigint b[10];
    b[0]="0";
    for(int i=1;i<10;i++)
    {
        b[i]=sabirane(b[i-1],s2);
    }
    bigint ans="";
    bigint k="";
    for(int i=0;i<s1.size();i++)
    {
        k+=s1[i];
        if(ans==""&&k<b[1])continue;
        int p=0;
        while(p<9&&(b[p+1]<k||b[p+1]==k))
        {
            p++;
        }
        ans+=char('0'+p);
        k=izvajdane(k,b[p]);
    }
    return {ans,k};
}
vector<int>idxs[32];
int brt[32];
int brs[32];
string s;
string t;
int bs(vector<int>v,int val)
{
    int l=0,r=v.size()-1,m,ans=-1;
    while(l<=r)
    {
        m=(l+r)/2;
        if(v[m]>val)
        {
            ans=m;
            r=m-1;
        }
        else l=m+1;
    }
    //cout<<ans<<endl;
    return ans;
}
bool b2[32];
void solve()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>s;
    cin>>t;
    int tsize=t.size();
    ll ssize=s.size();
    for(int i=0;i<ssize;++i)
    {
        idxs[s[i]-'a'].push_back(i);
        b2[s[i]-'a']=1;
    }
    for(int i=0;i<tsize;++i)
    {
        if(b2[t[i]-'a']==0)
        {
            cout<<"-1\n";
            return;
        }
    }
    ll last=-1,l1=0;
    for(int i=0;i<tsize;++i)
    {
        if(clock()>1.98*CLOCKS_PER_SEC)
        {
            cout<<"-1\n";
            return 0;
        }
        if(idxs[t[i]-'a'][idxs[t[i]-'a'].size()-1]<=last)
        {
            last=idxs[t[i]-'a'][0];++l1;
        }
        else
        {
            int r1=bs(idxs[t[i]-'a'],last);
            last=idxs[t[i]-'a'][r1];
        }
    }
    cout<<(ll)(last+(ll)l1*ssize+1ll)<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:186:20: error: return-statement with a value, in function returning 'void' [-fpermissive]
  186 |             return 0;
      |                    ^