This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Count Squares
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1507;
ll a[MAXN], b[MAXN];
map<ll, ll> m;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, v;
    cin >> h >> v;
    for(int i = 0; i < h; i++)
        cin >> a[i];
    for(int i = 0; i < v; i++)
        cin >> b[i];
    for(int i = 0; i < h; i++)
    {
        for(int j = i+1; j < h; j++)
            m[a[j]-a[i]]++;
    }
    ll ans = 0;
    for(int i = 0; i < v; i++)
    {
        for(int j = i+1; j < v; j++)
            ans += m[b[j]-b[i]];
    }
    cout << ans << endl;
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |