Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n,m;
char s[100005],t[100005];
int nxt[100005][26];
int main(){
	ios::sync_with_stdio(false);
	cin>>s+1>>t+1;n=strlen(s+1);m=strlen(t+1);
	for (int c=0;c<26;++c){
		int lst=0;
		for (int i=n;i>=0;--i){
			nxt[i][c]=lst;
			if (s[i]=='a'+c) lst=i;
		}
	}
	int p=0;ll cnt=0;
	for (int i=1;i<=m;++i){
		int c=t[i]-'a';
		if (nxt[0][c]==0){
			cout<<-1<<endl;return 0;
		}
		if (nxt[p][c]) p=nxt[p][c];
		else p=nxt[0][c],cnt+=n;
	}
	cout<<(ll)cnt+(ll)p<<endl;
	return 0; 
}#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n,m;
char s[100005],t[100005];
int nxt[100005][26];
int main(){
	ios::sync_with_stdio(false);
	cin>>s+1>>t+1;n=strlen(s+1);m=strlen(t+1);
	for (int c=0;c<26;++c){
		int lst=0;
		for (int i=n;i>=0;--i){
			nxt[i][c]=lst;
			if (s[i]=='a'+c) lst=i;
		}
	}
	int p=0;ll cnt=0;
	for (int i=1;i<=m;++i){
		int c=t[i]-'a';
		if (nxt[0][c]==0){
			cout<<-1<<endl;return 0;
		}
		if (nxt[p][c]) p=nxt[p][c];
		else p=nxt[0][c],cnt+=n;
	}
	cout<<(ll)cnt+(ll)p<<endl;
	return 0; 
}

Compiler output:
a.cc:55:2: error: stray '#' in program
   55 | }#include <iostream>
      |  ^
a.cc:55:3: error: 'include' does not name a type
   55 | }#include <iostream>
      |   ^~~~~~~
a.cc:85:5: error: redefinition of 'int n'
   85 | int n,m;
      |     ^
a.cc:31:5: note: 'int n' previously declared here
   31 | int n,m;
      |     ^
a.cc:85:7: error: redefinition of 'int m'
   85 | int n,m;
      |       ^
a.cc:31:7: note: 'int m' previously declared here
   31 | int n,m;
      |       ^
a.cc:86:6: error: redefinition of 'char s [100005]'
   86 | char s[100005],t[100005];
      |      ^
a.cc:32:6: note: 'char s [100005]' previously declared here
   32 | char s[100005],t[100005];
      |      ^
a.cc:86:16: error: redefinition of 'char t [100005]'
   86 | char s[100005],t[100005];
      |                ^
a.cc:32:16: note: 'char t [100005]' previously declared here
   32 | char s[100005],t[100005];
      |                ^
a.cc:87:5: error: redefinition of 'int nxt [100005][26]'
   87 | int nxt[100005][26];
      |     ^~~
a.cc:33:5: note: 'int nxt [100005][26]' previously declared here
   33 | int nxt[100005][26];
      |     ^~~
a.cc:88:5: error: redefinition of 'int main()'
   88 | int main(){
      |     ^~~~
a.cc:34:5: note: 'int main()' previously defined here
   34 | int main(){
      |     ^~~~