Language: C++

/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline int ri() {int x; scanf("%d", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/

string s[200];
const int maxn = 205;
int p[maxn][maxn];

int main() {
  #ifdef _TEST_
  freopen("input.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  #endif
  int n, m; cin >> n >> m;
  rep(i, n) cin >> s[i];
  rep(i, n) 
    rep(j, m) 
      p[i + 1][j + 1] = p[i][j + 1] + p[i + 1][j] + (s[i][j] == 'o') - p[i][j];
  rep(i, n, maxn)
    rep(j, m, maxn) 
      p[i + 1][j + 1] = p[i][j + 1] + p[i + 1][j] - p[i][j];
  int dx, dy;
  rep(i, n) 
    rep(j, m)
    if (s[i][j] == 'E') {
      dx = i; dy = j;
    }
  int lx = min(dx + 1, n - dx), rx = max(dx + 1, n - dx);
  int ly = min(dy + 1, m - dy), ry = max(dy + 1, m - dy);
  int res = 0;
  rep(i, n) 
    rep(j, m) {
      smax(res, p[i + lx][j + ry] - p[i + lx][j] - p[i][j + ry] + p[i][j]);
      smax(res, p[i + rx][j + ly] - p[i + rx][j] - p[i][j + ly] + p[i][j]);
      smax(res, p[i + rx][j + ry] - p[i + rx][j] - p[i][j + ry] + p[i][j]);
    }
  cout << res << endl;
  return 0;
}
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline int ri() {int x; scanf("%d", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/

string s[200];
const int maxn = 205;
int p[maxn][maxn];

int main() {
  #ifdef _TEST_
  freopen("input.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  #endif
  int n, m; cin >> n >> m;
  rep(i, n) cin >> s[i];
  rep(i, n) 
    rep(j, m) 
      p[i + 1][j + 1] = p[i][j + 1] + p[i + 1][j] + (s[i][j] == 'o') - p[i][j];
  rep(i, n, maxn)
    rep(j, m, maxn) 
      p[i + 1][j + 1] = p[i][j + 1] + p[i + 1][j] - p[i][j];
  int dx, dy;
  rep(i, n) 
    rep(j, m)
    if (s[i][j] == 'E') {
      dx = i; dy = j;
    }
  int lx = min(dx + 1, n - dx), rx = max(dx + 1, n - dx);
  int ly = min(dy + 1, m - dy), ry = max(dy + 1, m - dy);
  int res = 0;
  rep(i, n) 
    rep(j, m) {
      smax(res, p[i + lx][j + ry] - p[i + lx][j] - p[i][j + ry] + p[i][j]);
      smax(res, p[i + rx][j + ly] - p[i + rx][j] - p[i][j + ly] + p[i][j]);
      smax(res, p[i + rx][j + ry] - p[i + rx][j] - p[i][j + ry] + p[i][j]);
    }
  cout << res << endl;
  return 0;
}


Compiler output:
a.cc:112:12: error: redefinition of 'int ri()'
  112 | inline int ri() {int x; scanf("%d", &x); return x;}
      |            ^~
a.cc:33:12: note: 'int ri()' previously defined here
   33 | inline int ri() {int x; scanf("%d", &x); return x;}
      |            ^~
a.cc:120:33: error: redefinition of 'template<class T> bool smax(T&, T)'
  120 | template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;}
      |                                 ^~~~
a.cc:41:33: note: 'template<class T> bool smax(T&, T)' previously declared here
   41 | template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;}
      |                                 ^~~~
a.cc:121:33: error: redefinition of 'template<class T> bool smin(T&, T)'
  121 | template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;}
      |                                 ^~~~
a.cc:42:33: note: 'template<class T> bool smin(T&, T)' previously declared here
   42 | template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;}
      |                                 ^~~~
a.cc:124:8: error: redefinition of 'std::string s [200]'
  124 | string s[200];
      |        ^
a.cc:45:8: note: 'std::string s [200]' previously declared here
   45 | string s[200];
      |        ^
a.cc:125:11: error: redefinition of 'const int maxn'
  125 | const int maxn = 205;
      |           ^~~~
a.cc:46:11: note: 'const int maxn' previously defined here
   46 | const int maxn = 205;
      |           ^~~~
a.cc:126:5: error: redefinition of 'int p [205][205]'
  126 | int p[maxn][maxn];
      |     ^
a.cc:47:5: note: 'int p [205][205]' previously declared here
   47 | int p[maxn][maxn];
      |     ^
a.cc:128:5: error: redefinition of 'int main()'
  128 | int main() {
      |     ^~~~
a.cc:49:5: note: 'int main()' previously defined here
   49 | int main() {
      |     ^~~~