foo.cc: In function ‘int read()’:
foo.cc:5:14: error: ‘getchar’ was not declared in this scope
    5 |     char c = getchar(); int x = 0;
      |              ^~~~~~~
foo.cc:3:1: note: ‘getchar’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
    2 | #include <algorithm>
  +++ |+#include <cstdio>
    3 | 
foo.cc: In function ‘int main()’:
foo.cc:53:23: error: ‘printf’ was not declared in this scope
   53 |     if (m != n - 1) { printf("-1\n-1\n"); return 0; }
      |                       ^~~~~~
foo.cc:53:23: note: ‘printf’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
foo.cc:56:5: error: ‘printf’ was not declared in this scope
   56 |     printf("%d\n%d\n", f[2][1] - 1, g[2][f[2][1]][1]);
      |     ^~~~~~
foo.cc:56:5: note: ‘printf’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?