Language: C++

#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

template<class ...T>tuple<T...>Init(T... t) { return tuple<T...>{ t... }; }
template<class T>tuple<T> Init(T t) { return tuple<T>{ t }; }
template<int N, int...I>struct idx_seq : idx_seq<N - 1, 0, (I + 1)...> { };
template<int...I>struct idx_seq<0, I...> { };
template<class R, class T, int...I>R InitInternal(T&&a, idx_seq<0, I...>) { return R{ get<I>(a)... }; }
template<class T, class B, class...V>struct Vec {
  typedef Vec<T, V...>A; typedef vector<typename A::t>t; t nvec(B a, V...b) { return t(a, A().nvec(b...)); }
};
template<class T, class B>struct Vec<T, B> {
  using X = typename conditional<is_same<T, nullptr_t>::value, int, T>::type;
  typedef vector<X>t; t nvec(B a) { return t(a); }
};
template<class T, class ...C>struct Vec<T, tuple<C...>> {
  template<class A, class B>static pair<A, B> X(A, B);
  template<class...A>static tuple<A...> X(A...);
  using t = typename conditional < is_same<T, nullptr_t>::value, decltype(X(C{}...)), T > ::type;
  t nvec(tuple<C...> a) { return InitInternal<t>(a, idx_seq<sizeof...(C)>()); }
};
template<class T, class C>struct Vec<T, tuple<C>> {
  using X = typename conditional<is_same<T, nullptr_t>::value, C, T>::type;
  using t = X; t nvec(tuple<C> a) { return { get<0>(a) }; }
};
template<class T = nullptr_t, class...B> typename Vec<T, B...>::t nvec(B...b) { return Vec<T, B...>().nvec(b...); }



const ll mod = (ll)1e9 + 7;
template<ll MOD>struct Mint {
  typedef const Mint&T;
  ll x = 0;
  Mint() { }
  Mint(ll a) { x = a % MOD; if (x < 0) x += MOD; }
  Mint&operator+=(T a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
  Mint&operator-=(T a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; }
  Mint&operator*=(T a) { x = x * a.x % MOD; return *this; }
  Mint&operator/=(T a) { return *this *= a.Pow(MOD - 2); }
  Mint operator+(T a)const { return Mint(*this) += a; }
  Mint operator-(T a)const { return Mint(*this) -= a; }
  Mint operator*(T a)const { return Mint(*this) *= a; }
  Mint operator/(T a)const { return Mint(*this) /= a; }
  bool operator<(T a)const { return x < a.x; }
  bool operator==(T a)const { return x == a.x; }
  Mint Pow(ll k)const {
    if (k == 0) return 1;
    Mint t = Pow(k / 2);
    return t *= (k & 1) ? t * *this : t;
  }
};
template<ll MOD>istream&operator >> (istream&i, Mint<MOD>&a) { return i >> a.x; }
template<ll MOD>ostream&operator<<(ostream&o, const Mint<MOD>&a) { return o << a.x; }
typedef Mint<mod>mint;

template<ll MOD = mod>Mint<MOD> CombMod(int n, int r) {
  Mint<MOD> a = 1, b = 1;
  rep(i, r) { a *= (n - i); }
  repa(i, 2, r + 1) { b *= i; }
  err(a, b);
  return a / b;
}
void Calc() {

  var(int, n, m);
  //n = 4, m = 4;
  auto x = in.Array(n);
  auto y = in.Array(m);

  auto u = nvec(n - 1);
  auto v = nvec(m - 1);
  
  rep(i, n - 1) {
    if (i == 0 || i == n - 2) u[i] = n - 1;
    else u[i] = min(abs(0 - i), abs(n - 2 - i)) + (n - 2) * 2 - 1;
  }
  err(u);

  rep(i, m - 1) {
    if (i == 0 || i == m - 2) v[i] = m - 1;
    else v[i] = min(abs(0 - i), abs(m - 2 - i)) + (m - 2) * 2 - 1;
  }
  err(v);

  //auto c = nvec(n - 1, m - 1);
  //rep(i, n)rep(j, m)rep(k, i + 1, n)rep(l, j + 1, m)rep(o, i, k)rep(p, j, l) {
  //  c[o][p]++;
  //}
  //err(c);

  mint ans = 0;
  mint xx = 0;
  rep(i, n - 1){
    xx += mint(u[i]) * (x[i+1] - x[i]);
  }
  rep(i, m - 1){
    ans += mint(v[i]) * (y[i+1] - y[i]) * xx;
  }

  cout << (ans) << endl;
}


Compiler output:
a.cc: In function 'Mint<MOD> CombMod(int, int)':
a.cc:92:8: error: 'i' was not declared in this scope
   92 |   repa(i, 2, r + 1) { b *= i; }
      |        ^
a.cc:92:3: error: there are no arguments to 'repa' that depend on a template parameter, so a declaration of 'repa' must be available [-fpermissive]
   92 |   repa(i, 2, r + 1) { b *= i; }
      |   ^~~~
a.cc:92:3: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
a.cc:92:20: error: expected ';' before '{' token
   92 |   repa(i, 2, r + 1) { b *= i; }
      |                    ^~
      |                    ;