Problem p03763 (C++)

Buggy submission (status: Time Limit Exceeded):
#pragma region _head

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#pragma region _define

#define f(i, a, b) for (int i = a; i < b; i++)
#define f_vI(v, n) f(i, 0, n) cin >> v[i]
#define f_v2I(v1, v2, n) f(i, 0, n) cin >> v1[i] >> v2[i]
#define f_v3I(v1, v2, v3, n) f(i, 0, n) cin >> v1[i] >> v2[i] >> v3[i]
#define f_vO(v, n) f(i, 0, n) cout << v[i] << endl
#define all(a) a.begin(), a.end()
#define size(s) s.size()
#define check() cout << "! ! !"
#define endl "\n"
#define _y() cout << "Yes" << endl
#define _Y() cout << "YES" << endl
#define _n() cout << "No" << endl
#define _N() cout << "NO" << endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50 // グラフの最大位数　適宜変更
// bool graph[node][node]; bool visited[node] = { false };
#define link(a, b, m)                                                          \
  f(i, 0, m) {                                                                 \
    cin >> a[i] >> b[i];                                                       \
    a[i]--;                                                                    \
    b[i]--;                                                                    \
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;                              \
  }

#pragma endregion

LL gcd(LL a, LL b) {
  LL r;
  while ((r = a % b) != 0) {
    a = b;
    b = r;
  }
  return b;
}
LL lcm(LL a, LL b) { return (a / gcd(a, b) * b); }

#pragma endregion

/*****************************************************************************/
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vs s(n);
  f_vI(s, n);
  sort(all(s));
  vector<map<char, LL>> m(n);
  f(i, 0, n) {
    f(j, 0, size(s[i])) { m[i][s[i][j]]++; }
  }
  for (char a = 'a'; a <= 'z'; a++) {
    LL num = (LL)1e9;
    f(i, 1, n) {
      num = min(num, m[i][a]);
      if (num == 0) {
        break;
      }
    }
    f(i, 1, num + 1) { cout << a; }
  }
  return 0;
}

Fixed submission:
#pragma region _head

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#pragma region _define

#define f(i, a, b) for (int i = a; i < b; i++)
#define f_vI(v, n) f(i, 0, n) cin >> v[i]
#define f_v2I(v1, v2, n) f(i, 0, n) cin >> v1[i] >> v2[i]
#define f_v3I(v1, v2, v3, n) f(i, 0, n) cin >> v1[i] >> v2[i] >> v3[i]
#define f_vO(v, n) f(i, 0, n) cout << v[i] << endl
#define all(a) a.begin(), a.end()
#define size(s) s.size()
#define check() cout << "! ! !"
#define endl "\n"
#define _y() cout << "Yes" << endl
#define _Y() cout << "YES" << endl
#define _n() cout << "No" << endl
#define _N() cout << "NO" << endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50 // グラフの最大位数　適宜変更
// bool graph[node][node]; bool visited[node] = { false };
#define link(a, b, m)                                                          \
  f(i, 0, m) {                                                                 \
    cin >> a[i] >> b[i];                                                       \
    a[i]--;                                                                    \
    b[i]--;                                                                    \
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;                              \
  }

#pragma endregion

LL gcd(LL a, LL b) {
  LL r;
  while ((r = a % b) != 0) {
    a = b;
    b = r;
  }
  return b;
}
LL lcm(LL a, LL b) { return (a / gcd(a, b) * b); }

#pragma endregion

/*****************************************************************************/
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vs s(n);
  f_vI(s, n);
  sort(all(s));
  if (n == 1) {
    sort(all(s[0]));
    cout << s[0];
    return 0;
  }
  vector<map<char, LL>> m(n);
  f(i, 0, n) {
    f(j, 0, size(s[i])) { m[i][s[i][j]]++; }
  }
  for (char a = 'a'; a <= 'z'; a++) {
    LL num = (LL)1e9;
    f(i, 1, n) {
      num = min(num, m[i][a]);
      if (num == 0) {
        break;
      }
    }
    f(i, 1, num + 1) { cout << a; }
  }
  return 0;
}