CHEFSHIP question

Hello, I’m Albert, a noob coder compared to most people. I was trying to do the CHEFSHIP problem for this may cookoff and kept getting runtime errors. When I looked at the working submissions, many had the same logic as I did. How can I improve my code to improve my efficiency? Thank you so much.

package MayCookOff2020;

import java.util.;
import java.io.
;
class CHEFSHIP {
public static void main(String[] args) {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(reader.readLine());
//System.out.println(t);
PrintWriter w = new PrintWriter(System.out);
String[] words = new String[t];
String out = “”;
for (int i = 0; i < t; i++) {
words[i] = reader.readLine();

			int pos = 0;

			for (int j = 2; j <= words[i].length() - 2; j += 2) {
				//System.out.println();
				//System.out.println("here");
				String front = words[i].substring(0,j);
				String end = words[i].substring(j, words[i].length());

// System.out.println(front);
// System.out.println(end);
// String front1 = front.substring(0, front.length() / 2);
// String front2 = front.substring(front.length() / 2, front.length());
// String end1 = end.substring(0, (end.length()/2));
// String end2 = end.substring(end.length() / 2, end.length());

				if (front.substring(0, front.length() / 2).equals(front.substring(front.length() / 2, front.length())) 
						&& end.substring(0, (end.length()/2)).equals(end.substring(end.length() / 2, end.length()))) {
					pos++;
				}
			}
			out += pos + "\n";
		}
		w.print(out);
		w.close();
	}
	catch (Exception e) {
		
	}
}

}