Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;

void forth(int x, int y, bool grid[2000][2000]){
  grid.at(x).at(y) == 0;
  if(int x < tx && grid.at(x+1).at(y) == 1){
    x++;
    cout << 'R' << endl;
    return next(x,y);
  }
  if(int y < ty && grid.at(x).at(y+1) == 1){
    y++;
    cout << 'U' << endl;
    return next(x,y);
  }
  if(x == tx && y == ty) return 0;
}

void back(int x, int y){
  grid.at(x).at(y) == 0;
  if(int x > sx && grid.at(x-1).at(y) == 1){
    x--;
    cout << 'L' << endl;
    return back(x,y);
  }
  if(int y > sy && grid.at(x).at(y-1) == 1){
    y--;
    cout << 'U' << endl;
    return back(x,y);
  }
    if(x == sx && y == sy) return 0;
}

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  vector<vector<bool>> grid(ty, vector<bool> (tx,1));
  
  forth(0, 0, grid);
  back(tx, ty, grid);
  
}

Compiler output:
a.cc: In function 'void forth(int, int, bool (*)[2000])':
a.cc:8:8: error: request for member 'at' in 'grid', which is of non-class type 'bool (*)[2000]'
    8 |   grid.at(x).at(y) == 0;
      |        ^~
a.cc:9:12: error: expected initializer before '<' token
    9 |   if(int x < tx && grid.at(x+1).at(y) == 1){
      |            ^
a.cc:9:11: error: expected ')' before '<' token
    9 |   if(int x < tx && grid.at(x+1).at(y) == 1){
      |     ~     ^~
      |           )
a.cc:12:16: error: no matching function for call to 'next(int&, int&)'
   12 |     return next(x,y);
      |            ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidate: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h: In substitution of 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type) [with _InputIterator = int]':
a.cc:12:16:   required from here
   12 |     return next(x,y);
      |            ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: error: no type named 'difference_type' in 'struct std::iterator_traits<int>'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:14:12: error: expected initializer before '<' token
   14 |   if(int y < ty && grid.at(x).at(y+1) == 1){
      |            ^
a.cc:14:11: error: expected ')' before '<' token
   14 |   if(int y < ty && grid.at(x).at(y+1) == 1){
      |     ~     ^~
      |           )
a.cc:17:16: error: no matching function for call to 'next(int&, int&)'
   17 |     return next(x,y);
      |            ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidate: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h: In substitution of 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type) [with _InputIterator = int]':
a.cc:17:16:   required from here
   17 |     return next(x,y);
      |            ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: error: no type named 'difference_type' in 'struct std::iterator_traits<int>'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:19:11: error: 'tx' was not declared in this scope; did you mean 'x'?
   19 |   if(x == tx && y == ty) return 0;
      |           ^~
      |           x
a.cc:19:22: error: 'ty' was not declared in this scope; did you mean 'y'?
   19 |   if(x == tx && y == ty) return 0;
      |                      ^~
      |                      y
a.cc:19:33: error: return-statement with a value, in function returning 'void' [-fpermissive]
   19 |   if(x == tx && y == ty) return 0;
      |                                 ^
a.cc: In function 'void back(int, int)':
a.cc:23:3: error: 'grid' was not declared in this scope
   23 |   grid.at(x).at(y) == 0;
      |   ^~~~
a.cc:24:12: error: expected initializer before '>' token
   24 |   if(int x > sx && grid.at(x-1).at(y) == 1){
      |            ^
a.cc:24:11: error: expected ')' before '>' token
   24 |   if(int x > sx && grid.at(x-1).at(y) == 1){
      |     ~     ^~
      |           )
a.cc:29:12: error: expected initializer before '>' token
   29 |   if(int y > sy && grid.at(x).at(y-1) == 1){
      |            ^
a.cc:29:11: error: expected ')' before '>' token
   29 |   if(int y > sy && grid.at(x).at(y-1) == 1){
      |     ~     ^~
      |           )
a.cc:34:13: error: 'sx' was not declared in this scope; did you mean 'x'?
   34 |     if(x == sx && y == sy) return 0;
      |             ^~
      |             x
a.cc:34:24: error: 'sy' was not declared in this scope; did you mean 'y'?
   34 |     if(x == sx && y == sy) return 0;
      |                        ^~
      |                        y
a.cc:34:35: error: return-statement with a value, in function returning 'void' [-fpermissive]
   34 |     if(x == sx && y == sy) return 0;
      |                                   ^
a.cc: In function 'int main()':
a.cc:42:15: error: cannot convert 'std::vector<std::vector<bool> >' to 'bool (*)[2000]'
   42 |   forth(0, 0, grid);
      |               ^~~~
      |               |
      |               std::vector<std::vector<bool> >
a.cc:7:31: note:   initializing argument 3 of 'void forth(int, int, bool (*)[2000])'
    7 | void forth(int x, int y, bool grid[2000][2000]){
      |                          ~~~~~^~~~~~~~~~~~~~~~
a.cc:43:7: error: too many arguments to function 'void back(int, int)'
   43 |   back(tx, ty, grid);
      |   ~~~~^~~~~~~~~~~~~~
a.cc:22:6: note: declared here
   22 | void back(int x, int y){
      |      ^~~~