Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n[2];
ll cnt[2][1500010];
ll h[2][1500010];

int main() {
	while (cin >> n[0] >> n[1]) {
		if (n[0] + n[1] == 0) {
			return 0;
		}
		REP(i, 2) {
			fill(cnt[i], cnt[i] + 1500010, 0);
			fill(h[i], h[i] + 1500010, 0);
		}
		REP(i, 2) {
			FOR(j, 1, n[i] + 1)cin >> h[i][j];
			REP(j, n[i])h[i][j + 1] += h[i][j];
		}
		REP(i, 2) {
			REP(j, n[i]) {
				FOR(k, j + 1, n[i] + 1) {
					cnt[i][h[i][k] - h[i][j]]++;
				}
			}
		}
		ll ans = 0;
		REP(i, #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n[2];
ll cnt[2][1500010];
ll h[2][1500010];

int main() {
	while (cin >> n[0] >> n[1]) {
		if (n[0] + n[1] == 0) {
			return 0;
		}
		REP(i, 2) {
			fill(cnt[i], cnt[i] + 1500010, 0);
			fill(h[i], h[i] + 1500010, 0);
		}
		REP(i, 2) {
			FOR(j, 1, n[i] + 1)cin >> h[i][j];
			REP(j, n[i])h[i][j + 1] += h[i][j];
		}
		REP(i, 2) {
			REP(j, n[i]) {
				FOR(k, j + 1, n[i] + 1) {
					cnt[i][h[i][k] - h[i][j]]++;
				}
			}
		}
		ll ans = 0;
		REP(i, 1500010) {
			ans += (cnt[0][i] * cnt[1][i]);
		}
		cout << ans << endl;
	}
}) {
			ans += (cnt[0][i] * cnt[1][i]);
		}
		cout << ans << endl;
	}
}

Compiler output:
In file included from a.cc:72:
/usr/include/c++/14/cmath:3911: error: unterminated argument list invoking macro "REP"
 3911 | #endif
a.cc: In function 'int main()':
a.cc:68:17: error: 'REP' was not declared in this scope
   68 |                 REP(i, #include <iostream>
      |                 ^~~
a.cc:68:17: note: the macro 'REP' had not yet been defined
a.cc:100:9: note: it was later defined here
  100 | #define REP(i,N) for(int i=0;i<(N);i++)
      |         ^~~
a.cc:114:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  114 | int main() {
      |         ^~
a.cc:114:9: note: remove parentheses to default-initialize a variable
  114 | int main() {
      |         ^~
      |         --
a.cc:114:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:114:12: error: a function-definition is not allowed here before '{' token
  114 | int main() {
      |            ^
a.cc:140:2: error: expected primary-expression before ')' token
  140 | }) {
      |  ^