Language: C++



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 * HashMap<Integer, Integer> hm = new HashMap<>();
 * int[] s = new int[M];
 * ArrayDeque<Integer> deq = new ArrayDeque<>();
 *
 */
public class Main implements Runnable { //クラス名はMain1

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 1024 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerMain1 sc = new FastScannerMain1(System.in);

		try {
			String S = sc.nextLine().trim();
			ArrayList<String> arr = new ArrayList<String>();

			dfs(S, (String) S.subSequence(0, 1), Integer.valueOf((String) S.subSequence(0, 1)), 1, arr);
			System.out.println(arr.get(0));
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public void dfs(String os, String news, long ans, int next, ArrayList<String> arr) {
		if (next == 4) {
			//System.out.println("news:" + news + " ans:" + ans);
			if (ans == 7) {
				arr.add(news + "=7");
			}
		} else {
			String news1 = news + "+" + (String) os.subSequence(next, next + 1);
			long ans1 = ans + Long.valueOf((String) os.subSequence(next, next + 1));

			dfs(os, news1, ans1, next + 1, arr);

			long ans2 = ans - Long.valueOf((String) os.subSequence(next, next + 1));

			String news2 = news + "-" + (String) os.subSequence(next, next + 1);
			dfs(os, news2, ans2, next + 1, arr);
		}
	}
}

//高速なScanner
class FastScannerMain1 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain1(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Compiler output:
a.cc:3:1: error: 'import' does not name a type
    3 | import java.io.BufferedReader;
      | ^~~~~~
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.io.IOException;
      | ^~~~~~
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.io.InputStream;
      | ^~~~~~
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.io.InputStreamReader;
      | ^~~~~~
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.ArrayList;
      | ^~~~~~
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.StringTokenizer;
      | ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:18:1: error: expected unqualified-id before 'public'
   18 | public class Main implements Runnable { //クラス名はMain1
      | ^~~~~~
a.cc:62:16: error: expected ':' before 'BufferedReader'
   62 |         private BufferedReader reader = null;
      |                ^~~~~~~~~~~~~~~
      |                :
a.cc:62:17: error: 'BufferedReader' does not name a type
   62 |         private BufferedReader reader = null;
      |                 ^~~~~~~~~~~~~~
a.cc:63:16: error: expected ':' before 'StringTokenizer'
   63 |         private StringTokenizer tokenizer = null;
      |                ^~~~~~~~~~~~~~~~
      |                :
a.cc:63:17: error: 'StringTokenizer' does not name a type
   63 |         private StringTokenizer tokenizer = null;
      |                 ^~~~~~~~~~~~~~~
a.cc:65:15: error: expected ':' before 'FastScannerMain1'
   65 |         public FastScannerMain1(InputStream in) {
      |               ^~~~~~~~~~~~~~~~~
      |               :
a.cc:65:44: error: expected ')' before 'in'
   65 |         public FastScannerMain1(InputStream in) {
      |                                ~           ^~~
      |                                            )
a.cc:70:15: error: expected ':' before 'String'
   70 |         public String next() {
      |               ^~~~~~~
      |               :
a.cc:70:16: error: 'String' does not name a type
   70 |         public String next() {
      |                ^~~~~~
a.cc:81:15: error: expected ':' before 'String'
   81 |         public String nextLine() {
      |               ^~~~~~~
      |               :
a.cc:81:16: error: 'String' does not name a type
   81 |         public String nextLine() {
      |                ^~~~~~
a.cc:92:15: error: expected ':' before 'long'
   92 |         public long nextLong() {
      |               ^~~~~
      |               :
a.cc:96:15: error: expected ':' before 'int'
   96 |         public int nextInt() {
      |               ^~~~
      |               :
a.cc:100:15: error: expected ':' before 'double'
  100 |         public double nextDouble() {
      |               ^~~~~~~
      |               :
a.cc:104:15: error: expected ':' before 'int'
  104 |         public int[] nextIntArray(int n) {
      |               ^~~~
      |               :
a.cc:104:19: error: expected unqualified-id before '[' token
  104 |         public int[] nextIntArray(int n) {
      |                   ^
a.cc:111:15: error: expected ':' before 'long'
  111 |         public long[] nextLongArray(int n) {
      |               ^~~~~
      |               :
a.cc:111:20: error: expected unqualified-id before '[' token
  111 |         public long[] nextLongArray(int n) {
      |                    ^
a.cc:117:2: error: expected ';' after class definition
  117 | }
      |  ^
      |  ;
a.cc: In member function 'long int FastScannerMain1::nextLong()':
a.cc:93:24: error: 'Long' was not declared in this scope; did you mean 'long'?
   93 |                 return Long.parseLong(next());
      |                        ^~~~
      |                        long
a.cc:93:39: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   93 |                 return Long.parseLong(next());
      |                                       ^~~~
      |                                       nextInt
a.cc: In member function 'int FastScannerMain1::nextInt()':
a.cc:97:24: error: 'Integer' was not declared in this scope
   97 |                 return Integer.parseInt(next());
      |                        ^~~~~~~
a.cc:97:41: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   97 |                 return Integer.parseInt(next());
      |                                         ^~~~
      |                                         nextInt
a.cc: In member function 'double FastScannerMain1::nextDouble()':
a.cc:101:24: error: 'Double' was not declared in this scope; did you mean 'double'?
  101 |                 return Double.parseDouble(next());
      |                        ^~~~~~
      |                        double
a.cc:101:43: error: 'next' was not declared in this scope; did you mean 'nextInt'?
  101 |                 return Double.parseDouble(next());
      |                                           ^~~~
      |                                           nextInt