Language: C++

import java.awt.Point;
import java.io.InputStreamReader;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(new InputStreamReader(System.in));

		ArrayList<StringBuilder> lines = new ArrayList<StringBuilder>();
		while (true) {
			String text = sc.next();
			if (text.equals("END_OF_TEXT"))
				break;
			lines.add(new StringBuilder(text));
		}
		Point cursor = new Point();

		String buffer = null;

		commandLoop: while (true) {
			char command = sc.next().charAt(0);
			StringBuilder currentLine = lines.get(cursor.y);
			switch (command) {
			case 'a':
				cursor.x = 0;
				break;
			case 'e':
				cursor.x = currentLine.length();
				break;
			case 'p':
				if (cursor.y > 0)
					cursor.y--;
				else
					cursor.x = 0;
				break;
			case 'n':
				if (cursor.y + 1 < lines.size())
					cursor.y++;
				cursor.x = 0; // ?
				break;
			case 'f':
				if (cursor.x < currentLine.length()) {
					cursor.x++;
				}
				else if (cursor.y + 1 < lines.size()) {
					cursor.y++;
					cursor.x = 0;
				}
				break;
			case 'b':
				if (cursor.x > 0) {
					cursor.x--;
					break;
				}
				else if (cursor.y > 0) {
					cursor.y--;
					cursor.x = 0;
				}
				break;
			case 'd':
				if (cursor.x < currentLine.length()) {
					currentLine.deleteCharAt(cursor.x);
				}
				else if (cursor.y + 1 < lines.size()) {
					currentLine.append(lines.remove(cursor.y + 1));
				}
				break;
			case 'k':
				if (cursor.x == currentLine.length()) {
					if (cursor.y + 1 < lines.size()) {
						currentLine.append(lines.remove(cursor.y + 1));
						buffer = "\n";
					}
				}
				else {
					buffer = currentLine.substring(cursor.x);
					currentLine.delete(cursor.x, currentLine.length());
				}
				break;
			case 'y':
				if (buffer != null) {
					if (buffer.equals("\n")) {
						StringBuilder newLine = new StringBuilder();
						if(cursor.x != currentLine.length()) {
							newLine.append(currentLine.substring(cursor.x));
							currentLine.delete(cursor.x, currentLine.length());
							
						}
						lines.add(cursor.y, newLine);
						cursor.y++;
						cursor.x = 0;
					}
					else {
						if(cursor.x == currentLine.length())
							currentLine.append(buffer);
						else
							currentLine.insert(cursor.x, buffer);
						cursor.x += buffer.length();
					}
				}
				break;

			default:
				break commandLoop;
			}
//			System.out.println(cursor);
//			System.out.println(currentLine);
		}
		for (StringBuilder sb : lines) {
			System.out.println(sb);
		}
	}

}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.awt.Point;
      | ^~~~~~
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.io.InputStreamReader;
      | ^~~~~~
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.nio.Buffer;
      | ^~~~~~
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.ArrayList;
      | ^~~~~~
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.List;
      | ^~~~~~
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.Scanner;
      | ^~~~~~
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.regex.Pattern;
      | ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: expected unqualified-id before 'public'
    9 | public class Main {
      | ^~~~~~