Language: C++

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		String t = scan.next();
		StringIndex si = new StringIndex(t, false);

		int q = scan.nextInt();
		for (int i = 0; i < q; i++)
			if (si.isExist(scan.next(), t))
				System.out.println("1");
			else
				System.out.println("0");

		scan.close();
		System.exit(0);
	}
}

class StringIndex {
	class StIdx {
		int pos;
		char ch;

		public StIdx(int i, char c) {
			pos = i;
			ch = c;
		}
	}

	List<StIdx> idx = new ArrayList<StIdx>();
	int[] seq;
	int compLen = 1;

	class strIndexComp implements Comparator<StIdx> {

		@Override
		public int compare(StIdx o1, StIdx o2) {
			if (compLen == 1)
				if (o1.ch > o2.ch)
					return 1;
				else if (o1.ch == o2.ch)
					return 0;
				else
					return -1;

			if (seq[o1.pos] > seq[o2.pos])
				return 1;
			if (seq[o1.pos] == seq[o2.pos]) {
				int npos1 = o1.pos + compLen / 2;
				int npos2 = o2.pos + compLen / 2;
				int nseq1 = 0, nseq2 = 0;
				if (npos1 < seq.length)
					nseq1 = seq[npos1];
				if (npos2 < seq.length)
					nseq2 = seq[npos2];
				if (nseq1 > nseq2)
					return 1;
				else if (nseq1 == nseq2)
					return 0;
				else
					return -1;
			}
			return -1;
		}
	}

	boolean debug;

	public StringIndex(String t, boolean d) {
		debug = d;

		seq = new int[t.length()];
		for (int i = 0; i < t.length(); i++)
			idx.add(new StIdx(i, t.charAt(i)));

		for (compLen = 1; compLen < idx.size(); compLen *= 2) {
			Collections.sort(idx, new strIndexComp());

			seq[idx.get(0).pos] = 1;
			for (int i = 1; i < idx.size(); i++) {
				strIndexComp cmp = new strIndexComp();
				if (cmp.compare(idx.get(i - 1), idx.get(i)) == 0)
					seq[idx.get(i).pos] = seq[idx.get(i - 1).pos];
				else
					seq[idx.get(i).pos] = seq[idx.get(i - 1).pos] + 1;
			}

			if (debug) {
				System.out.println("--------------------");
				for (int i = 0; i < idx.size(); i++)
					System.out.println(i + "\t" + seq[idx.get(i).pos] + "\t" + idx.get(i).pos + "\t"
							+ t.substring(idx.get(i).pos));
			}
		}

	}

	public boolean isExist(String p, String t) {
		int low = 0, hi = idx.size() - 1;
		return (findBin(p, t, low, hi));
	}

	private boolean findBin(String p, String t, int low, int hi) {
		if (low > hi)
			return false;
		int i = low + (hi - low) / 2;
		int r = p.compareTo(t.substring(idx.get(i).pos, idx.get(i).pos + p.length()));
		System.out.println(t.substring(idx.get(i).pos, idx.get(i).pos + p.length()));
		if (r == 0)
			return true;
		else if (r < 0)
			return findBin(p, t, low, i - 1);
		else
			return findBin(p, t, i + 1, hi);
	}
}

Compiler output:
a.cc:48:17: error: stray '@' in program
   48 |                 @Override
      |                 ^
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.IOException;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.ArrayList;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Collections;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.Comparator;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.util.HashMap;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import java.util.List;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
    7 | import java.util.Map;
      | ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
    8 | import java.util.PriorityQueue;
      | ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: 'import' does not name a type
    9 | import java.util.Scanner;
      | ^~~~~~
a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:11:1: error: expected unqualified-id before 'public'
   11 | public class Main {
      | ^~~~~~
a.cc:36:23: error: expected ':' before 'StIdx'
   36 |                 public StIdx(int i, char c) {
      |                       ^~~~~~
      |                       :
a.cc:42:9: error: expected ';' at end of member declaration
   42 |         List<StIdx> idx = new ArrayList<StIdx>();
      |         ^~~~
      |             ;
a.cc:42:13: error: expected unqualified-id before '<' token
   42 |         List<StIdx> idx = new ArrayList<StIdx>();
      |             ^
a.cc:43:12: error: expected unqualified-id before '[' token
   43 |         int[] seq;
      |            ^
a.cc:46:28: error: field 'implements' has incomplete type 'strIndexComp'
   46 |         class strIndexComp implements Comparator<StIdx> {
      |                            ^~~~~~~~~~
a.cc:46:15: note: forward declaration of 'class strIndexComp'
   46 |         class strIndexComp implements Comparator<StIdx> {
      |               ^~~~~~~~~~~~
a.cc:46:28: error: expected ';' at end of member declaration
   46 |         class strIndexComp implements Comparator<StIdx> {
      |                            ^~~~~~~~~~
      |                                      ;
a.cc:46:39: error: 'Comparator' does not name a type
   46 |         class strIndexComp implements Comparator<StIdx> {
      |                                       ^~~~~~~~~~
a.cc:79:9: error: 'boolean' does not name a type; did you mean 'bool'?
   79 |         boolean debug;
      |         ^~~~~~~
      |         bool
a.cc:81:15: error: expected ':' before 'StringIndex'
   81 |         public StringIndex(String t, boolean d) {
      |               ^~~~~~~~~~~~
      |               :
a.cc:81:34: error: expected ')' before 't'
   81 |         public StringIndex(String t, boolean d) {
      |                           ~      ^~
      |                                  )
a.cc:110:15: error: expected ':' before 'boolean'
  110 |         public boolean isExist(String p, String t) {
      |               ^~~~~~~~
      |               :
a.cc:110:16: error: 'boolean' does not name a type; did you mean 'bool'?
  110 |         public boolean isExist(String p, String t) {
      |                ^~~~~~~
      |                bool
a.cc:115:16: error: expected ':' before 'boolean'
  115 |         private boolean findBin(String p, String t, int low, int hi) {
      |                ^~~~~~~~
      |                :
a.cc:115:17: error: 'boolean' does not name a type; did you mean 'bool'?
  115 |         private boolean findBin(String p, String t, int low, int hi) {
      |                 ^~~~~~~
      |                 bool
a.cc:128:2: error: expected ';' after class definition
  128 | }
      |  ^
      |  ;