This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <limits>
#include <assert.h>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long int;
const ll mod = 998244353;
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<ll> hor(h), ver(w);
  for(auto& i : hor){
    cin >> i;
  }
  for(auto& i : ver){
    cin >> i;
  }
  map<ll, ll> m;
  for(int i = 0; i < h; ++i){
    for(int j = i + 1; j < h; ++j){
      ++m[hor[j] - hor[i]];
    }
  }
  ll answ = 0;
  for(int i = 0; i < w; ++i){
    for(int j = i + 1; j < w; ++j){
      answ += m[ver[j] - ver[i]];
    }
  }
  cout << answ << endl;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |