criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
    int64_t a, ans = 0;
    string S, T;
    cin >> S >> T;

    for (int i = 0; i < T.size(); i++) {
        for (int j = 0; j < S.size(); j++){
            if (i == 0 && T.at(i) == S.at(j)) {
                    a = j;
                    break;
                }
            }
            else if (a + 1 + j < S.size()) {
                if (T.at(i) == S.at(a + 1 + j)) {
                    a += j + 1;
                    break;
                }
            }
            else {
                if (T.at(i) == S.at(a + 1 + j - S.size())) {
                    a = a + 1 + j - S.size();
                    ans++;
                    break;
                }
            }
            if (j == S.size() - 1) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans * S.size() + a + 1<< endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:13: error: 'else' without a previous 'if'
   16 |             else if (a + 1 + j < S.size()) {
      |             ^~~~
a.cc:16:30: error: 'j' was not declared in this scope
   16 |             else if (a + 1 + j < S.size()) {
      |                              ^
a.cc:29:17: error: 'j' was not declared in this scope
   29 |             if (j == S.size() - 1) {
      |                 ^
a.cc: At global scope:
a.cc:35:5: error: 'cout' does not name a type
   35 |     cout << ans * S.size() + a + 1<< endl;
      |     ^~~~
a.cc:36:1: error: expected declaration before '}' token
   36 | }
      | ^
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;

string s, t;
vector<ll> c[30];
ll x, times;
int main() {
	ll i, j, k;
	cin >> s >> t;
	for(i=0; s[i]; i++) c[s[i]-'a'].push_back(i);
	for(i=0, j=-1; t[i]; i++) {
		x = t[i] - 'a';
		if(c[x].size()==0) return puts("-1"), 0;
		k = upper_bound(c[x].begin(), c[x].end(), j) - c[x].begin();
		if(k == c[x].size()) {
			times++;
			j = c[x][0];
		} else {
			j = c[x][k];
		}
	}
	cout << times * (ll)s.size() + j + 1;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:21: error: 'upper_bound' was not declared in this scope
   17 |                 k = upper_bound(c[x].begin(), c[x].end(), j) - c[x].begin();
      |                     ^~~~~~~~~~~
Language: C++

#include "stdc++.h"
using namespace std;
typedef long long int ll;

ll ans = 0,ci=-1;
string s, t;
vector<int> lst[26];
int main() {
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++)lst[s[i] - 'a'].push_back(i);
	for (int i = 0; i < t.size(); i++) {
		if (lst[t[i] - 'a'].size() == 0) { cout << -1 << endl; return 0; }
		int ni = lower_bound(lst[t[i] - 'a'].begin(), lst[t[i] - 'a'].end(), ci + 1) - lst[t[i] - 'a'].begin();
		if (lst[t[i] - 'a'].size() != ni) {
			ans += lst[t[i] - 'a'][ni] - ci;
			ci = lst[t[i] - 'a'][ni];
		}
		else {
			ans += (ll)lst[t[i] - 'a'][0] + s.size() - ci;
			ci = lst[t[i] - 'a'][0];
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:1:10: fatal error: stdc++.h: No such file or directory
    1 | #include "stdc++.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<string>
using namespace std;
 
int main() {
	string s, t;
	cin >> s >> t;
 
	int i, j, j_memo:
    long long int counter = 0;
	while (true) {
		if (t[i] == s[j]) {
			i++;
			j_memo = j;
		}
		if (i == t.size()) {
			cout << counter + 1 << endl;
			return 0;
		}
		j++;
		if (j >= s.size())j = 0;
		counter++;
		if (j == j_memo)break;
	}
	cout << -1 << endl;
 
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:25: error: expected initializer before ':' token
    9 |         int i, j, j_memo:
      |                         ^
a.cc:14:25: error: 'j_memo' was not declared in this scope
   14 |                         j_memo = j;
      |                         ^~~~~~
a.cc:17:33: error: 'counter' was not declared in this scope
   17 |                         cout << counter + 1 << endl;
      |                                 ^~~~~~~
a.cc:22:17: error: 'counter' was not declared in this scope
   22 |                 counter++;
      |                 ^~~~~~~
a.cc:23:26: error: 'j_memo' was not declared in this scope
   23 |                 if (j == j_memo)break;
      |                          ^~~~~~
Language: Java

mport java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.nextLine().toCharArray();
		char[] t = sc.nextLine().toCharArray();

		List<List<Integer>> t_idx_list = new ArrayList<>();
		for (int i = 0; i < t.length; i++) {
			t_idx_list.add(new ArrayList<>());
			for (int j = 0; j < s.length; j++) {
				if (t[i] == s[j]) {
					t_idx_list.get(i).add(j);
				}
			}
		}
		for (List<Integer> idx_list : t_idx_list) {
			if (idx_list.isEmpty()) {
				System.out.println(-1);
				return;
			}
		}

		int s_idx = 0, t_idx = 0;
		long ans = 0;
		while (true) {
			if (s[s_idx] == t[t_idx]) {
				t_idx++;
			}
			if (t_idx == t.length) {
				break;
			}

			int next_idx = s.length;

			//s_idxより大きい値の、最初のindex
			//s_idxより大きい値がない場合
			//s_idxより小さい値の、最後のindex
			//			for (int idx : t_idx_list.get(t_idx)) {
			//				if (idx > s_idx) {
			//					next_idx = Math.min(next_idx, idx);
			//				}
			//				else {
			//					next_idx = idx;
			//				}
			//			}

			List<Integer> idx_list = t_idx_list.get(t_idx);
			if (s_idx > idx_list.get(idx_list.size() - 1)) {
				next_idx = idx_list.get(0);
			}
			else if (s_idx < idx_list.get(0)) {
				next_idx = idx_list.get(0);
			}
			else {
				next_idx = Arrays.binarySearch(idx_list.toArray(), s_idx) + 1;
			}

			if (next_idx > s_idx) {
				ans += next_idx - s_idx;
			}
			else {
				ans += s.length - s_idx + next_idx;
			}
			s_idx = next_idx;
		}

		System.out.println(ans + 1);
	}
}


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
mport java.util.ArrayList;
^
Main.java:2: error: class, interface, enum, or record expected
import java.util.Arrays;
^
Main.java:3: error: class, interface, enum, or record expected
import java.util.List;
^
Main.java:4: error: class, interface, enum, or record expected
import java.util.Scanner;
^
4 errors
Language: C++

#include<bits\stdc++.h>
using namespace std ;
const int maxx = 1e+5 ;
char m[maxx],s[maxx];
int main()
{
    vector < int > v [26];///for every alpha v[a-'a']={4,11,15}
    scanf("%s %s",m,s);
    int l=strlen(m),r=strlen(s),p=0,loop=0;
    ///lets create list for alpha in string m
    for(int i=0;i<l;i++)
    {
        int idx = m[i]-'a'; /// a->0 ,b->1 ,z -> 25
        v[idx].push_back(i+1);///a/0 -> 2,5,6,11,12
    }
    for(int i=0;i<r;i++)
    {
        int idx = s[i]-'a';
        if(v[idx].size()==0)///psb na
        {
            cout << "-1" << endl;
            return 0 ;
        }
        ///protita char ase but kto loop ghure nea lagbe
        else
        {
          int ind_of_list = upper_bound(v[idx].begin(),v[idx].end(),p)-v[idx].begin();
          if(ind_of_list==v[idx].size())
          {
              loop++;
              p=v[idx][0];///ntun loop shuru hlo
          }
          else
          {
              p=v[idx][ind_of_list];
          }
        }
    }
    cout << loop*l+p << endl;
    return 0;
}


Compiler output:
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory
    1 | #include<bits\stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

def main():
    s = input()
    t = input()
    s2 = s * 2
    sett = list(set((t)))
    settindex = {}
    for i in sett:
        settindex[i] = sett.index(i)
        if i not in s:
            print(-1)
            return
    lens = len(s)
    # index[i文字目以降][settのindex]に何文字目にあるかが格納される
    index = [[] for _ in range(lens)]
    for i in range(lens):
        for j in sett:
            index[i].append(s2[i:].index(j))
    ans = 0
    n = 0
    for i in t:
        j = settindex[i]
        ans += index[n % lens][j] + 1
        n += index[n % lens][j] + 1
    print(ans)


if __name__ == '__main__':
    main()


Compiler output:
a.cc:13:7: error: invalid preprocessing directive #index
   13 |     # index[i文字目以降][settのindex]に何文字目にあるかが格納される
      |       ^~~~~
a.cc:27:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   27 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def main():
      | ^~~
a.cc:7:5: error: expected unqualified-id before 'for'
    7 |     for i in sett:
      |     ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int main(){
	string s,t;
	cin>>s>>t;
	int n = sz(s), m=sz(t);
	vector<vector<int>> is(26);
	rep(i,n) is[[s]-'a'].push_backU(i);
	rep(i,n) is[[s]-'a'].push_backU(i+n);
	ll ans=0;
	int p = 0;
	rep(i,m){
		int c = t[i]-'a';
		if(sz(is[c])==0){
			puts("-1");
			return 0
		}
		p=*lower_bound(is[c.beign(),is[c].end(), p]);
		if(p>=n){
			p-=n;
			ans+=n;
		}
	}
	ans+=p;
	cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:20: error: two consecutive '[' shall only introduce an attribute before '[' token
   34 |         rep(i,n) is[[s]-'a'].push_backU(i);
      |                    ^
a.cc:35:20: error: two consecutive '[' shall only introduce an attribute before '[' token
   35 |         rep(i,n) is[[s]-'a'].push_backU(i+n);
      |                    ^
a.cc:42:33: error: expected ';' before '}' token
   42 |                         return 0
      |                                 ^
      |                                 ;
   43 |                 }
      |                 ~                
a.cc:44:37: error: request for member 'beign' in 'c', which is of non-class type 'int'
   44 |                 p=*lower_bound(is[c.beign(),is[c].end(), p]);
      |                                     ^~~~~
Language: Java

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int loop = 0;
		int hantei;
		int kari = 0;
		char[] c1 = scan.next().toCharArray();
		char[] c2 = scan.next().toCharArray();
		scan.close();
		for (int i = 0; i < c2.length;) {
			hantei = 0;
			for (int j = 0; j < c1.length; j++) {
				if (c2[i] == c1[j]) {
					kari = (loop * c1.length) + j;
					i++;
					hantei = 1;
					if (i == c2.length) {
						break;
					}
				}
			}
			if (hantei == 1) {
				loop++;
			} else {
				kari = -2;
				break;
			}
		}
		System.out.print(kari + 1);
	}
}

Compiler output:
Main.java:3: error: cannot find symbol
		Scanner scan = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
		Scanner scan = new Scanner(System.in);
		                   ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
    string s;
    cin>>s;
    string t;
    cin>>t;
    vector<int> arr[26];
    for(int i = 0;i<s.length();i++){
        arr[s[i] - 'a'].push_back(i);
    }
    int dp[t.length()];
    bool possible = true;
    if(arr[t[0] - 'a'].size()){
        dp[0] = arr[t[0] - 'a'][0];
    }
    else{
        dp[0] = -1;
        possible = false;
    }
    long long totlen = dp[0] + 1;
    for(int i = 1;i<t.length() && possible;i++){
        int mini = dp[i-1];
        if(arr[t[i] - 'a'].size()){
            auto it = upper_bound(arr[t[i] - 'a'].begin(), arr[t[i] - 'a'].end(), mini);
            if(it!=arr[t[i] - 'a'].end()){
                dp[i] = *it;
                totlen+=dp[i] - dp[i-1];
            }
            else{
                dp[i] = arr[t[i] - 'a'][0];
                totlen+=(s.length() - dp[i-1]) + dp[i];
            }
        }
        else{
            possible = false;
        }
    }
    if(possible){
        cout<<totlen<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:23: error: 'upper_bound' was not declared in this scope
   29 |             auto it = upper_bound(arr[t[i] - 'a'].begin(), arr[t[i] - 'a'].end(), mini);
      |                       ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MOD = 1000000007;

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

vector<int> alpha[26];

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s, t;

  cin >> s >> t;

  rep(i, s.size()) {
    alpha[s[i] - 'a'].push_back(i);
  }

  long res = 0;
  int idx = -1;

  rep(i, t.size()) {
    int next = ubv(moji, idx);
    if (next == alpha[t[i] - 'a'].size()) {
      res += s.size();
      idx = -1;
      next = ubv(alpha[t[i] - 'a'], idx);
      if (next == alpha[t[i] - 'a'].size()) {
        res = -1;
        break;
      }
    }
    idx = alpha[t[i] - 'a'][next];
  }
  cout << (res == -1 ? -1 : res+idx+1) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:94:20: error: 'moji' was not declared in this scope
   94 |     int next = ubv(moji, idx);
      |                    ^~~~
a.cc:40:32: note: in definition of macro 'ubv'
   40 | #define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
      |                                ^~
Language: Java

import java.util.*;
import java.lang.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int mod = s.length();
		long ans = 0;
		TreeSet<Integer>[] index = new TreeSet[26];
		for (int i = 0; i < 26; i++) {
			index[i] = new TreeSet<>();
		}
		for (int i = 0; i < t.length(); i++) {
			TreeSet<Integer> tmp = index[t.charAt(i) - 'a'];
			if (tmp.size() == 0) {
				if (s.indexOf(t.charAt(i)) == -1) {
					ans = -1;
					break;
				} else {
					int in = 0;
					while (s.indexOf(t.charAt(i), in) != -1) {
						tmp.add(s.indexOf(t.charAt(i), in));
						in = s.indexOf(t.charAt(i), in) + 1;
					}
				}
			}
			int num;
			if (tmp.ceiling((int) (ans % mod)) == null) {
				num = tmp.first();
			} else {
				num = tmp.ceiling((int) (ans % mod));
			}
			if (num + 1 <= ans % mod) {
				ans = mod * (ans / mod + 1) + num + 1;
			} else {
				ans = mod * (ans / mod) + num + 1;
			}
		}
		System.out.println(ans);
    }

Compiler output:
Main.java:42: error: reached end of file while parsing
    }
     ^
1 error
Language: C++

/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

////////////////////////////////////////////////////////////////////

string s, t;

int main(){
    cout << fixed << setprecision(15);

    cin >> s >> t;
    int n = s.length();
    s = s + s;

    int64 res = 0;

    vector<vector<int> > position(26);
    rep(i, 2*n) {
        position[int(s[i] - 'a')].push_back(i);
    }

    dbg(position['s' - 'a']);

    int pre = -1;
    rep(i, t.length()) {
        if (position[int(t[i] - 'a')].size() == 0) {
            cout << -1 << '\n';
            return 0;
        }
        auto it = upper_bound(all(position[int(t[i] - 'a')]), pre);
        int x = *it;
        debug(x);
        res += x - pre;
        pre = x % n;
        debug(pre); debug(res);
    }
    
    cout << res << '\n';

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:62:22: error: 'setprecision' was not declared in this scope
   62 |     cout << fixed << setprecision(15);
      |                      ^~~~~~~~~~~~
a.cc:38:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
   37 | #include <set>
  +++ |+#include <iomanip>
   38 |
Language: C++

/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <cstdio>
#include <iostream>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

////////////////////////////////////////////////////////////////////

string s, t;

int main(){
    cout << fixed << setprecision(15);

    cin >> s >> t;
    int n = s.length();
    s = s + s;

    int64 res = 0;

    vector<vector<int> > position(26);
    rep(i, 2*n) {
        position[int(s[i] - 'a')].push_back(i);
    }

    dbg(position['s' - 'a']);

    int pre = -1;
    rep(i, t.length()) {
        if (position[int(t[i] - 'a')].size() == 0) {
            cout << -1 << '\n';
            return 0;
        }
        auto it = upper_bound(all(position[int(t[i] - 'a')]), pre);
        int x = *it;
        debug(x);
        res += x - pre;
        pre = x % n;
        debug(pre); debug(res);
    }
    
    cout << res << '\n';

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:79:19: error: 'upper_bound' was not declared in this scope
   79 |         auto it = upper_bound(all(position[int(t[i] - 'a')]), pre);
      |                   ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
vector<ll> vec[27];
ll aPos[27];
int main(){
    //freopen("in.txt", "r", stdin);
    ll i;
    string s, t;
    cin >> s >> t;
    ll sLen=s.length();
    ll tLen=t.length();
    for(i=0; i<sLen; i++){
        vec[s[i]-'a'].push_back(i+1);
    }
    ll ans=0;
    ll lastPos=0;
    bool can=true;
    for(i=0; i<tLen && can; i++){
        if(vec[t[i]-'a'].size()==0){
            can=false;
            continue;
        }
    }
    for(i=0; i<tLen && can; i++){
        if(vec[t[i]-'a'][aPos[t[i]-'a']]+1<=lastPos){
            ///Si mi posisión actual es menor o igual
            //printf("%d to %d %d\n", lastPos, vec[t[i]-'a'][aPos[t[i]-'a']]+1, sLen-(lastPos-vec[t[i]-'a'][aPos[t[i]-'a']])+1);
            ans+=sLen-(lastPos-vec[t[i]-'a'][aPos[t[i]-'a']]);
        }
        else{
            ///Si la posición es mayor a la actual
            //printf("%d to %d\n", lastPos, vec[t[i]-'a'][aPos[t[i]-'a']]+1);
            printf("+%d\n", vec[t[i]-'a'][aPos[t[i]-'a']]-lastPos)
            ans+=vec[t[i]-'a'][aPos[t[i]-'a']]-lastPos;
        }
        lastPos=vec[t[i]-'a'][aPos[t[i]-'a']];
        aPos[t[i]-'a']++;
        aPos[t[i]-'a']%=vec[t[i]-'a'].size();
    }
    if(can){
        cout << ans << "\n";
    }
    else{
        cout << "-1\n";
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:67: error: expected ';' before 'ans'
   34 |             printf("+%d\n", vec[t[i]-'a'][aPos[t[i]-'a']]-lastPos)
      |                                                                   ^
      |                                                                   ;
   35 |             ans+=vec[t[i]-'a'][aPos[t[i]-'a']]-lastPos;
      |             ~~~
Language: C++

#include <stdio.h>
#include <iostream>
#include <set>
#include <vector>
#include <map>

int main(int argc, char const *argv[])
{
  // std::string s;
  // std::cin >> s;
  char s[200000];
  scanf("%s", s);

  // std::string t;
  // std::cin >> t;
  char t[100000];
  scanf("%s", t);

  int sie = strlen(s);
  int tie = strlen(t);

  bool exist = true;

  std::set<char> sts;
  for (size_t i = 0; i < sie; i++)
  {
    sts.insert(s[i]);
  }


  std::set<char> stt;
  for (int i = 0; i < tie; i++)
  {
    stt.insert(t[i]);
  }

  for (auto &&c : stt)
  {
    if (sts.count(c) == 0)
    {
      exist = false;
      break;
    }
  }

  if (exist == false)
  {
    std::cout << -1 << std::endl;
    return 0;
  }

  // std::string ss = s + s;
  int *m[26];

  for (size_t i = 0; i < 26; i++)
  {
    m[i] = new int[sie];
  }

  for (size_t i = 0; i < sie; i++)
  {
    s[i + sie] = s[i];
  }

  int pos;
  for (size_t i = 0; i < sie; i++)
  {
    for (auto &&j : stt)
    {
      pos = 0;
      for (size_t k = i; k < sie * 2; k++)
      {
        if (j == s[k])
        {
          break;
        }
        pos++;
      }
      m[j - 97][i] = pos;
    }
  }

  long si = 0;
  int ti = 0;

  for (size_t i = 0; i < tie; i++)
  {
    int sip = si % sie;
    si += m[t[i] - 97][sip] + 1;
  }

  std::cout << si;

  return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:19:13: error: 'strlen' was not declared in this scope
   19 |   int sie = strlen(s);
      |             ^~~~~~
a.cc:6:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <map>
  +++ |+#include <cstring>
    6 |
Language: C++

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); i++)

long long solve(const string &s, const string &t) {
  vector<int> pos[128];
  REP(i,s.length()) {
    pos[s[i]].push_back(i);
  }
  long long ans = -1LL;
  int idx = -1;
  for(int i = 0; i < t.length(); i++) {
    char c = t[i];
    if(pos[c].empty()) return -1;
    int nxt = upper_bound(pos[c].begin(), pos[c].end(), idx) - pos[c].begin();
    //    cout << c << " " << pos[c].size() << " " << nxt << endl;                    
    if(nxt < pos[c].size()) {
      ans += (long long)(pos[c][nxt] - idx);
      idx = pos[c][nxt];
    } else {
      while(pos[c][--nxt] > idx);
      ans += (long long)(pos[c][nxt] - idx + s.length());
      idx = pos[c][nxt];
    }
    //    cout << idx << "," << pos[c][nxt] << "," << ans << endl;                    
  }
  return ans + 1;
}


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: Java

import java.util.*;
class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      	String s = sc.nextLine();
      	String t = sc.nextLine();
      	long count = 0;
      	int zz=0,j=0;
      	for(int i=0;i<t.length();i++){
          	String tsub = t.substring(i,i+1);
          	for(;;j=(j+1)%s.length()){
              	count++;zz++;
              	if(tsub.equals(s.substring(j,j+1))){
                	j++;
                  	z=0;
                  	break;
                }
              	if(zz==s.length()){
                	count = -1;
                  	break;
                }
            }
          	if(count==-1){break;}
        }
      	System.out.println(count);
    }
}

Compiler output:
Main.java:15: error: cannot find symbol
                  	z=0;
                  	^
  symbol:   variable z
  location: class Main
1 error
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) int(x.size())
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t; cin >> s >> t;
	int n = sz(s); int m = sz(t);
	vector<vector<int>>is(26);
	rep(i, n)is[s[i] - 'a'].push_back(i);
	rep(i, n)is[s[i] - 'a'].push_back(i + n);
	int ans = 0;
	int p = 0;
	rep(i, m) {
		int c = t[i] - 'a';
		if (sz(is[c]) == 0) {
			puts("-1");
			return 0;
		}
		p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
		if (p >= n) {
			p -= n;
			ans += n;
		}
	}
	ans += p;
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:13: error: expected primary-expression before 'long'
   33 | #define int long long
      |             ^~~~
a.cc:36:15: note: in expansion of macro 'int'
   36 | #define sz(x) int(x.size())
      |               ^~~
a.cc:82:17: note: in expansion of macro 'sz'
   82 |         int n = sz(s); int m = sz(t);
      |                 ^~
a.cc:33:13: error: expected primary-expression before 'long'
   33 | #define int long long
      |             ^~~~
a.cc:36:15: note: in expansion of macro 'int'
   36 | #define sz(x) int(x.size())
      |               ^~~
a.cc:82:32: note: in expansion of macro 'sz'
   82 |         int n = sz(s); int m = sz(t);
      |                                ^~
a.cc:33:13: error: expected primary-expression before 'long'
   33 | #define int long long
      |             ^~~~
a.cc:36:15: note: in expansion of macro 'int'
   36 | #define sz(x) int(x.size())
      |               ^~~
a.cc:90:21: note: in expansion of macro 'sz'
   90 |                 if (sz(is[c]) == 0) {
      |                     ^~
a.cc:90:21: error: expected ')' before 'long'
   90 |                 if (sz(is[c]) == 0) {
      |                    ~^
      |                     )
Language: Java

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        final String s = scan.next();   
        final String t = scan.next();
        String resultStr = s;
        boolean isFind = true;
        String tempT;
        int count = 1;
        int[] findIndex = new int[t.length()];
        String[] findString = new String[t.length()];

        // tを構成する全英文字がsに含まれているか
        for(int i = 0; i < t.length(); i++){
            tempT = t.substring(i, i + 1);
            if(s.contains(tempT)){
                findIndex[i] = s.indexOf(tempT);
                findString = tempT;
            }else{
                isFind = false;
                break;
            }
        }
        if(isFind){
            for(int i = 1; i < t.length(); i++){
                if(findIndex[i - 1] > findIndex[i] && s.indexOf(findString[i], findIndex[i - 1] + 1) == -1 ){
                    resultStr = resultStr + s;
                    count++;
                }
            }
            resultStr = resultStr.substring(0, (count - 1) * s.length() + findIndex[t.length() - 1] + 1);
            System.out.println(resultStr.length());


        }else{
            System.out.println("-1");
        }
        scan.close();
    }
}

Compiler output:
Main.java:3: error: cannot find symbol
        Scanner scan = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
        Scanner scan = new Scanner(System.in);
                           ^
  symbol:   class Scanner
  location: class Main
Main.java:18: error: incompatible types: String cannot be converted to String[]
                findString = tempT;
                             ^
3 errors
Language: Java

public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        final String s = scan.next();   
        final String t = scan.next();
        String resultStr = s;
        boolean isFind = true;
        String tempT;
        int count = 1;
        int[] findIndex = new int[t.length()];
        String[] findString = new String[t.length()];

        // tを構成する全英文字がsに含まれているか
        for(int i = 0; i < t.length(); i++){
            tempT = t.substring(i, i + 1);
            if(s.contains(tempT)){
                findIndex[i] = s.indexOf(tempT);
                findString = tempT;
            }else{
                isFind = false;
                break;
            }
        }
        if(isFind){
            for(int i = 1; i < t.length(); i++){
                if(findIndex[i - 1] > findIndex[i] && !s.indexOf(findString[i], findIndex[i - 1]) + 1){
                    resultStr = resultStr + s;
                    count++;
                }
            }
            resultStr = resultStr.substring(0, (count - 1) * s.length() + findIndex[t.length() - 1] + 1);
            System.out.println(resultStr.length());


        }else{
            System.out.println("-1");
        }
        scan.close();
    }
}

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args){
              ^
  (use --enable-preview to enable unnamed classes)
Main.java:39: error: class, interface, enum, or record expected
}
^
2 errors
Language: C

#include<stdio.h>
#include<string.h>

int main(void){
  char a[100001];
  char b[100001];
  char c[100001];
  int i;
  int j;
  int cnt = 0;
  int len1;
  int len2;
  int f = 0;
  
  scanf("%c", a);
  scnaf("%c", b);
  
  len1 = strlen(b);
  len2 = strlen(a);
  
  for(i = 0; i < 10; i++){
    strcat(a, b);
  }
  
  for(i = 0; i < len1; i++){
    for (j = 0; j < len2; j++){
      if(a[j] == b[i]){
        f = 114514;        
      }
    }
  }
  i = 0;
  j = 0;
  while(len1 == 0){
    if(a[i] == b[j]){
      len1--;
      j++;
      cnt += i + 1;
    }else{
      i++;
    }
  }
      
    
        
        
        
        
        
        
     if(f == 0){
       printf("-1");
     }else{
       prtintf("%d", &cnt);
     }
     return 0;
}
  


Compiler output:
main.c: In function 'main':
main.c:16:3: error: implicit declaration of function 'scnaf'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   16 |   scnaf("%c", b);
      |   ^~~~~
      |   scanf
main.c:54:8: error: implicit declaration of function 'prtintf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   54 |        prtintf("%d", &cnt);
      |        ^~~~~~~
      |        printf
Language: C

#include<stdio.h>
#include<string.h>

int main(void){
  char a[100001];
  char b[100001];
  char c[100001];
  int i;
  int j;
  int cnt = 0;
  int len1;
  int f = 0;
  
  scanf("%c", a);
  scnaf("%c", b);
  
  len1 = strlen(b);
  len2 = strlen(a);
  
  for(i = 0; i < 10; i++){
    strcat(a, b);
  }
  
  for(i = 0; i < len1; i++){
    for (j = 0; j < len2; j++){
      if(a[j] == b[i]){
        f = 114514;        
      }
    }
  }
  i = 0;
  j = 0;
  while(len1 == 0){
    if(a[i] == b[j]){
      len1--;
      j++;
      cnt += i + 1;
    }else{
      i++;
    }
  }
      
    
        
        
        
        
        
        
     if(f == 0){
       printf("-1");
     }else{
       prtintf("%d", &cnt);
     }
     return 0;
}
  


Compiler output:
main.c: In function 'main':
main.c:15:3: error: implicit declaration of function 'scnaf'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   15 |   scnaf("%c", b);
      |   ^~~~~
      |   scanf
main.c:18:3: error: 'len2' undeclared (first use in this function); did you mean 'len1'?
   18 |   len2 = strlen(a);
      |   ^~~~
      |   len1
main.c:18:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:53:8: error: implicit declaration of function 'prtintf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   53 |        prtintf("%d", &cnt);
      |        ^~~~~~~
      |        printf
Language: C

#include<stdio.h>
#include<string.h>

int main(void){
  char a[100001];
  char b[100001];
  char c[100001];
  int i;
  int j;
  int cnt = 0;
  int len1;
  int f = 0;
  
  scanf("%s", a);
  scnaf("%s", b);
  
  len1 = strlen(b);
  len2 = strlen(a);
  
  for(i = 0; i < 10; i++){
    strcat(a, b);
  }
  
  for(i = 0; i < len1; i++){
    for (j = 0; j < len2; j++){
      if(a[j] == b[i]){
        f = 114514;        
      }
    }
  }
  i = 0;
  j = 0;
  while(len1 == 0){
    if(a[i] == b[j]){
      len1--;
      j++;
      cnt += i + 1;
    }else{
      i++;
    }
  }
      
    
        
        
        
        
        
        
     if(f == 0){
       printf("-1");
     }else{
       prtintf("%d", &cnt);
     }
     return 0;
}
  

Compiler output:
main.c: In function 'main':
main.c:15:3: error: implicit declaration of function 'scnaf'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   15 |   scnaf("%s", b);
      |   ^~~~~
      |   scanf
main.c:18:3: error: 'len2' undeclared (first use in this function); did you mean 'len1'?
   18 |   len2 = strlen(a);
      |   ^~~~
      |   len1
main.c:18:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:53:8: error: implicit declaration of function 'prtintf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   53 |        prtintf("%d", &cnt);
      |        ^~~~~~~
      |        printf
Language: C++

#include <iostream>
#include <string>

using namespace std;

int main() {
    string s, t;
    cin >> s;
    cin >> t;

    long long shead = 0;
    long long time = 0;
    for (char x : t) {
        int pos = s.find(x);
        if (pos == -1) {
            cout << -1 << endl;
            return 0;
        }
        int ppos = s.substr(shead).find(x);
        if (ppos == -1) {
            time += 1;
            shead = pos + 1;
        } else {
            shead += ppos + 1;
        }
    }
    cout << (time * s.size() + shead << endl;
    return 0;
}

    
             

Compiler output:
a.cc: In function 'int main()':
a.cc:27:38: error: invalid operands of types 'long long unsigned int' and '<unresolved overloaded function type>' to binary 'operator<<'
   27 |     cout << (time * s.size() + shead << endl;
      |              ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
a.cc:27:45: error: expected ')' before ';' token
   27 |     cout << (time * s.size() + shead << endl;
      |             ~                               ^
      |                                             )
Language: C++

#include<bits/stdc++.h>
using namespace std;
int a[26][100005];
int num[26];
int main()
{
    string n,m;
    cin>>n>>m;
    memset(a,-1,sizeof(a));
    memset(num,-1,sizeof(num));
	int len=n.length();
	unsigned long long ans=len;
    for(int i=0;i<len;++i){
    	if(n[i]==m[0])	ans=min(ans,i);
		for(int j=num[n[i]-'a']+1;j<=i;++j){
			a[n[i]-'a'][j]=i;
		}
		num[n[i]-'a']=i;
	}
    for(int i=0;i<m.length();++i){
    	if(a[m[i]-'a'][0]==-1){
    		cout<<-1;return 0;
		}
		if(a[m[i]-'a'][ans%len]==-1){
			ans=(ans/len+1)*len+a[m[i]-'a'][0];
		}
		else{
			ans=a[m[i]-'a'][ans%len]+ans/len*len;
		}
	}
	cout<<ans+1;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:32: error: no matching function for call to 'min(long long unsigned int&, int&)'
   14 |         if(n[i]==m[0])  ans=min(ans,i);
      |                             ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:14:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'int')
   14 |         if(n[i]==m[0])  ans=min(ans,i);
      |                             ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:14:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   14 |         if(n[i]==m[0])  ans=min(ans,i);
      |                             ~~~^~~~~~~
Language: Java

import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        long ans = -1;
        int[] salp = new int[27];
        int[] talp = new int[27];
        char[] sr = s.toCharArray();
        char[] tr = t.toCharArray();
        HashMap<Character, ArrayList<Integer>> map = new HashMap<Character, ArrayList<Integer>>();

        for (int i = 0; i < sr.length; i++) {
            salp[sr[i] - 'a']++;
        }
        for (int i = 0; i < tr.length; i++) {
            talp[tr[i] - 'a']++;
            if (salp[tr[i] - 'a'] == 0) {
                System.out.println(ans);
                return;
            }

        }

        for (int i = 0; i < 27; i++) {
            if (talp[i] > 0) {
                map.put((char) ('a' + i), new ArrayList<Integer>());
            }
        }

        int pos = 0;
        // char[] fr = new char[100001];
        // int[] frp = new int[100001];
        for (int i = 0; i < sr.length; i++) {
            if (talp[sr[i] - 'a'] > 0) {
                map.get(sr[i]).add(i);
            }
        }
        for (int i = 0; i < sr.length; i++) {
            if (talp[sr[i] - 'a'] > 0) {
                map.get(sr[i]).add(i + sr.length);
            }
        }
        pos = 0;
        long rep = 0;

        for (int i = 0; i < tr.length; i++) {
            ArrayList<Integer> list = map.get(tr[i]);
            // System.out.println(Arrays.toString(list.toArray()));
            int ret = binary_search(pos, list);
            if (ret == -1)
                throw new Exception("not found");
            int pps = list.get(ret);
            // System.out.println(pps);
            if (pps >= sr.length) {
                rep++;
                pps -= sr.length;
            }
            pos = pps;
        }
        System.out.println(rep * sr.length + pos + 1);
    }

    // index が条件を満たすかどうか
    static boolean isOK(int index, int key, ArrayList<Integer> list) {
        if (list.get(index) >= key)
            return true;
        else
            return false;
    }

    // 汎用的な二分探索のテンプレ
    static int binary_search(int key, ArrayList<Integer> list) {
        int left = -1; // 「index = 0」が条件を満たすこともあるので、初期値は -1
        int right = (int) list.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
        /* どんな二分探索でもここの書き方を変えずにできる！ */
        while (right - left > 1) {
            int mid = left + (right - left) / 2;
            if (isOK(mid, key, list))
                right = mid;
            else
                left = mid;
        }
        /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
        return right;
    }
}


Compiler output:
Main.java:63: error: unreported exception Exception; must be caught or declared to be thrown
                throw new Exception("not found");
                ^
1 error
Language: C++

#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string s,t;
    cin >> s >> t;
    int ls = s.size();
    long long ans = 0;
    int now = -1;
    for (auto i : t) {
        auto a = s.find(i,now+1);
        if(a == std::string::npos){
            ans += ls-now;

            a = s.find(i);
            if(a == std::string::npos){
                now = -1;
                cout << now << endl;
                return 0
            }
            now = a;
            ans += a;
        }else{
            ans += a-now;
            now = a;
        }
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:25: error: expected ';' before '}' token
   20 |                 return 0
      |                         ^
      |                         ;
   21 |             }
      |             ~
Language: C++

#include <bits/stdc++.h>

using namespace std;

const long long INF = 1e9;

vector<vector<long long>> dp;

string s, t;

long long dfs(int pos, char al, int cnt = 0) {
  auto& res = dp[pos][al-'a'];
  if (res != -1) {
    return res;
  }
  if (s[pos] == al) {
    return res = 1;
  }
  if (cnt == s.length()) {
    return res = INF;
  }
  res = dfs((pos+1) % s.length(), al, start, cnt+1);
  if (res != INF) res++;
  return res;
}

int main() {
  cin >> s >> t;
  dp.resize(s.length(), vector<long long>(26, -1));
  long long res = 0;
  for (int i = 0; i < t.length(); i++) {
    int r = dfs(res % s.length(), t[i]);
    if (r == INF) {
      cout << -1 << endl;
      return 0;
    }
    res += r;
  }
  cout << res << endl;
}

Compiler output:
a.cc: In function 'long long int dfs(int, char, int)':
a.cc:22:39: error: 'start' was not declared in this scope
   22 |   res = dfs((pos+1) % s.length(), al, start, cnt+1);
      |                                       ^~~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<queue>
using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    int n=s.length();
    int m=t.length();
    vector<vector<int>> is(26);
    for(int i=0;i<n;i++){
        in[s[i]-'a'].push_back(i);
    }
    for(int i=0;i<n;i++){
        is[s[i]-'a'].push_back(i+n);
    }
    long long ans=0;
    int pos=0;
    for(int i=0;i<m;i++){
        int c = t[i]-'a';
        if(is[c].size() == 0){
            cout << -1 << endl;
            return 0;
        }
        pos = *lower_bound(is[c].begin(),is[c].end(),pos) + 1;
        if(pos >= n){
            pos -=n;
            ans += n;
        }
    }
    ans += pos;
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'in' was not declared in this scope; did you mean 'i'?
   14 |         in[s[i]-'a'].push_back(i);
      |         ^~
      |         i
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string s, t;
int n;
void solve(int& index, int k) {
 	char ch = t[k];
  	bool found = true;
  	for (int i = index % n; i < index % n + n;i++) {
    	if (s[i] == ch) {
        	index = i;
          	found = true;
          	break;
        }
    }
  	if (!found) {
     	ans = -1;
      	return;
    }
  	if (k + 1 < t.size()) {
      	index++;
  		solve(index, k + 1);
    }
}

int main() {
  	cin >> s >> t;
  	n = s.size();
  	int ans = 0;
  	solve(ans, 0);
  	cout << ans << endl;
}

Compiler output:
a.cc: In function 'void solve(int&, int)':
a.cc:19:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |         ans = -1;
      |         ^~~
      |         abs