Language: C++

import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;

void main() {
    int N = readln.chomp.to!int;
    auto c = readln.chomp.split.map!(to!int).array;
    int Q = readln.chomp.to!int;
    bool flag = true;

    int[] apple = new int[](N);

    for (int i = 0; i < Q; i++) {
        auto operation = readln.chomp.split.map!(to!int).array;
        int x = operation[1] - 1, d = operation[2];

        if (!flag) {
            continue;
        }

        if (operation[0] == 1) {
            if (apple[x] + d <= c[x]) {
                apple[x] += d;
            }
            else {
                writeln(x + 1);
                flag = false;
            }
        }
        else {
            if (apple[x] - d >= 0) {
                apple[x] -= d;
            }
            else {
                writeln(x + 1);
                flag = false;
            }
        }
    }

    if (flag) {
        0.writeln;
    }

    return;
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import std.stdio;
      | ^~~~~~
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 std.algorithm;
      | ^~~~~~
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 std.array;
      | ^~~~~~
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 std.conv;
      | ^~~~~~
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 std.string;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: '::main' must return 'int'
    7 | void main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:13: error: 'readln' was not declared in this scope
    8 |     int N = readln.chomp.to!int;
      |             ^~~~~~
a.cc:13:8: error: structured binding declaration cannot have type 'int'
   13 |     int[] apple = new int[](N);
      |        ^~
a.cc:13:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:13:8: error: empty structured binding declaration
a.cc:13:11: error: expected initializer before 'apple'
   13 |     int[] apple = new int[](N);
      |           ^~~~~
a.cc:24:17: error: 'apple' was not declared in this scope
   24 |             if (apple[x] + d <= c[x]) {
      |                 ^~~~~
a.cc:24:28: error: 'd' was not declared in this scope
   24 |             if (apple[x] + d <= c[x]) {
      |                            ^
a.cc:28:17: error: 'writeln' was not declared in this scope
   28 |                 writeln(x + 1);
      |                 ^~~~~~~
a.cc:33:17: error: 'apple' was not declared in this scope
   33 |             if (apple[x] - d >= 0) {
      |                 ^~~~~
a.cc:33:28: error: 'd' was not declared in this scope
   33 |             if (apple[x] - d >= 0) {
      |                            ^
a.cc:37:17: error: 'writeln' was not declared in this scope
   37 |                 writeln(x + 1);
      |                 ^~~~~~~
a.cc:44:9: error: unable to find numeric literal operator 'operator""writeln'
   44 |         0.writeln;
      |         ^~~~~~~~~
a.cc:47:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
   47 |     return;
      |     ^~~~~~