Language: C++

const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem1126 : The Secret Number **/
const int MAX_W = 70;
int W, H;
char field[MAX_W][MAX_W];
string dp[MAX_W][MAX_W];

bool big(string s1, string s2) {
	if (s1.length() > s2.length()) {
		return true;
	} else if (s2.length() > s1.length()) {
		return false;
	} else {
		return (s1>s2?true:false);
	}
}

bool big2(string s1, string s2) {
	while (s1[0]=='0') s1.erase(s1.begin());
	while (s2[0]=='0') s2.erase(s2.begin());
	return big(s1, s2);
}

string rec(int x, int y)
{
	if (!('0' <= field[y][x] && field[y][x] <= '9'))
		return dp[y][x] = "";
	
	string s1 = field[y][x] + dp[y][x+1];
	string s2 = field[y][x] + dp[y+1][x];
	
	return dp[y][x] = (big(s1, s2)?s1:s2);
}

int main()
{
	while (cin>>W>>H, W||H) {
		fill(dp[0], dp[0]+W*H, "");
		
		rep(i, H) {
			rep(j, W) {
				cin>>field[i][j];
			}
		}
		
		string ans = "0";
		rep(y, H) {
			rep(x, W) {
				string tmp = rec(W-x-1, H-y-1);
				ans = (big2(ans, tmp)?ans:tmp);
				
			}
		}
		while (ans[0]=='0') ans.erase(ans.begin());
		
		cout << (ans!=""?ans:"0") << endl;
	}
}

Compiler output:
a.cc:7:9: error: 'pair' does not name a type
    7 | typedef pair<int, int> P;
      |         ^~~~
a.cc:13:1: error: 'string' does not name a type
   13 | string dp[MAX_W][MAX_W];
      | ^~~~~~
a.cc:15:10: error: 'string' was not declared in this scope
   15 | bool big(string s1, string s2) {
      |          ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | const int INF = 100000000;
a.cc:15:21: error: 'string' was not declared in this scope
   15 | bool big(string s1, string s2) {
      |                     ^~~~~~
a.cc:15:21: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:15:30: error: expression list treated as compound expression in initializer [-fpermissive]
   15 | bool big(string s1, string s2) {
      |                              ^
a.cc:25:11: error: 'string' was not declared in this scope
   25 | bool big2(string s1, string s2) {
      |           ^~~~~~
a.cc:25:11: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:25:22: error: 'string' was not declared in this scope
   25 | bool big2(string s1, string s2) {
      |                      ^~~~~~
a.cc:25:22: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:25:31: error: expression list treated as compound expression in initializer [-fpermissive]
   25 | bool big2(string s1, string s2) {
      |                               ^
a.cc:31:1: error: 'string' does not name a type
   31 | string rec(int x, int y)
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:44:16: error: 'cin' was not declared in this scope
   44 |         while (cin>>W>>H, W||H) {
      |                ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | const int INF = 100000000;
a.cc:45:22: error: 'dp' was not declared in this scope; did you mean 'dy'?
   45 |                 fill(dp[0], dp[0]+W*H, "");
      |                      ^~
      |                      dy
a.cc:45:17: error: 'fill' was not declared in this scope
   45 |                 fill(dp[0], dp[0]+W*H, "");
      |                 ^~~~
a.cc:47:21: error: 'i' was not declared in this scope
   47 |                 rep(i, H) {
      |                     ^
a.cc:47:17: error: 'rep' was not declared in this scope
   47 |                 rep(i, H) {
      |                 ^~~
a.cc:53:17: error: 'string' was not declared in this scope
   53 |                 string ans = "0";
      |                 ^~~~~~
a.cc:53:17: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:54:21: error: 'y' was not declared in this scope; did you mean 'dy'?
   54 |                 rep(y, H) {
      |                     ^
      |                     dy
a.cc:61:24: error: 'ans' was not declared in this scope
   61 |                 while (ans[0]=='0') ans.erase(ans.begin());
      |                        ^~~
a.cc:63:17: error: 'cout' was not declared in this scope
   63 |                 cout << (ans!=""?ans:"0") << endl;
      |                 ^~~~
a.cc:63:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:63:26: error: 'ans' was not declared in this scope
   63 |                 cout << (ans!=""?ans:"0") << endl;
      |                          ^~~
a.cc:63:46: error: 'endl' was not declared in this scope
   63 |                 cout << (ans!=""?ans:"0") << endl;
      |                                              ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | const int INF = 100000000;