Language: Java

Int();
      t = in.nextInt();
      x = new int[n];
      for (int i = 0; i < n; ++i)
        x[i] = in.nextInt();
      if (n == 1) {
        out.println(e + t);
        return;
      }
      long ans = x[0];
      int idx = 0;
      while (idx < n - 1) { 
        long cnt = 2;
        int nxt = idx;
        long temp = (x[nxt] - x[idx]) + cnt * t;
        while (nxt < n && (long) Math.max(t, 2 * (x[nxt] - x[idx])) + (x[nxt] - x[idx]) < (x[nxt] - x[idx]) + cnt * t) {
          temp = (long) Math.max(t, 2 * (x[nxt] - x[idx])) + (x[nxt] - x[idx]);
          ++nxt;
          ++cnt;
        }
        ans += temp;
        if (nxt < n)
          ans += x[nxt] - x[nxt - 1];
        if (nxt == n - 1)
          ans += t;
        idx = nxt;
      }
      ans += e - x[n - 1];
      out.println(ans);
    }
    
  }
      
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

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

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

    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
    
  }
}


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
Int();
^
Main.java:2: error: class, interface, enum, or record expected
      t = in.nextInt();
      ^
Main.java:3: error: class, interface, enum, or record expected
      x = new int[n];
      ^
Main.java:4: error: class, interface, enum, or record expected
      for (int i = 0; i < n; ++i)
      ^
Main.java:4: error: class, interface, enum, or record expected
      for (int i = 0; i < n; ++i)
                      ^
Main.java:4: error: class, interface, enum, or record expected
      for (int i = 0; i < n; ++i)
                             ^
Main.java:6: error: class, interface, enum, or record expected
      if (n == 1) {
      ^
Main.java:8: error: class, interface, enum, or record expected
        return;
        ^
Main.java:9: error: class, interface, enum, or record expected
      }
      ^
Main.java:11: error: unnamed classes are a preview feature and are disabled by default.
      int idx = 0;
      ^
  (use --enable-preview to enable unnamed classes)
Main.java:12: error: class, interface, enum, or record expected
      while (idx < n - 1) { 
      ^
Main.java:16: error: class, interface, enum, or record expected
        while (nxt < n && (long) Math.max(t, 2 * (x[nxt] - x[idx])) + (x[nxt] - x[idx]) < (x[nxt] - x[idx]) + cnt * t) {
        ^
Main.java:18: error: class, interface, enum, or record expected
          ++nxt;
          ^
Main.java:19: error: class, interface, enum, or record expected
          ++cnt;
          ^
Main.java:20: error: class, interface, enum, or record expected
        }
        ^
Main.java:22: error: class, interface, enum, or record expected
        if (nxt < n)
        ^
Main.java:24: error: class, interface, enum, or record expected
        if (nxt == n - 1)
        ^
Main.java:26: error: class, interface, enum, or record expected
        idx = nxt;
        ^
Main.java:27: error: class, interface, enum, or record expected
      }
      ^
Main.java:29: error: class, interface, enum, or record expected
      out.println(ans);
      ^
Main.java:30: error: class, interface, enum, or record expected
    }
    ^
Main.java:92: error: class, interface, enum, or record expected
}
^
22 errors