Go: package main

import (
    "bufio"
    "os"
    "fmt"
    "strings"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readLineToInt() []int {
    sc.Scan()
    line := strings.Split(sc.Text(), " ")
    length := len(line)
    var intLine []int
    for i := 0; i < length; i++ {
        n, _ := strconv.Atoi(line[i])
        intLine = append(intLine, n)
    }
    return intLine
}

func readInt() int {
    sc.Scan()
    line := strings.Split(sc.Text(), " ")
    n, _ := strconv.Atoi(line[0])
    return n
}

func main() {
    wht := readLineToInt()
    _, h, _ := wht[0], wht[1], wht[2]
    p := readInt()
    var xSave []int
    var ySave []int
    for i := 0; i < p; i++ {
        xyt := readLineToInt()
        xSave = append(xSave, xyt[0])
        ySave = append(ySave, xyt[1])
    }
    var mp [][]int
    for i := 0; i < h; i++ {
        mp = append(mp, readLineToInt())
    }
    ans := 0
    for i := 0; i < p; i++ {
        x, y := xSave[i], ySave[i]
        if mp[y][x] == 1 {
            ans++
        }
    }
    fmt.Println(ans)
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
  int W, H, T, P;
  int mas[50][50] = {{}};


  cin >> W >> H >> T;
  cin >> P;
  for(int i = 0; i < P; i++) {
    int X, Y, T;
    cin >> X >> Y >> T;
    ++mas[X][Y];
  }

  int ret = 0;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      int S;
      cin >> S;
      if(S == 1) ret += mas[j][i];
    }
  }

  cout << ret << endl;
}

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,k) for (int i = 0; i < (int)(k); i++)
#define all(cnt) begin(cnt), end(cnt)

int main() {
    int w, h, t;
    int p;
    while (cin >> w >> h >> t >> p) {
        int c[50][50] = {};
        for (int i = 0; i < p; i++) {
            int x, y, t;
            cin >> x >> y >> t;
            ++c[y][x];
        }
        ll ans = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int x;
                cin >> x;
                ans += x * c[i][j];
            }
        }
        cout << ans << endl;
    }
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
ll solve(){
    ll res = 0;
    ll W,H,T; cin >> W >> H >> T;
    ll p; cin >> p;
    vector<pll> query(p);
    for(int i = 0; i < p;i++){
        cin >> query[i].first >> query[i].second;
        ll t; cin >> t;
    }
    vector<vector<ll>> s(H,vector<ll>(W));
    for(auto& vec:s) for(auto& in:vec) cin  >>in;
    
    vector<vector<ll>> plant(H,vector<ll>(W,0));
    for(int i = 0; i < p;i++){
        if(s[query[i].second][query[i].first]){
            plant[query[i].second][query[i].first]++;
        }
    }
    for(auto& vec:plant) res += accumulate(vec.begin(),vec.end(),0LL);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}

C++: /*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int w,h,T,p,x[55]={},y[55]={},t[55]={},ans=0,a[55][55]={};
  cin >> w >> h >> T >> p;
  for(int i=0; i<p; i++) {
    cin >> x[i] >> y[i] >> t[i];
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> a[i][j];
    }
  }
  int hi[55][55]={};
  for(int i=0; i<p; i++) {
    if(a[y[i]][x[i]]) {
      hi[y[i]][x[i]]++;
    }
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      ans+=hi[i][j];
    }
  }
  cout << ans << endl;
}

C++: #include<iostream>
using namespace std;

int main(){
  
  int w, h, t, p;
  int x[50], y[50];
  int s[50][50];

  cin>>w>>h>>t>>p;
  for(int i=0;i<p;i++){
    int t;
    cin>>x[i]>>y[i]>>t;
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s[i][j];
    }
  }

  int sum=0;
  for(int i=0;i<p;i++){
    if(s[y[i]][x[i]]==1) sum++;
  }

  cout<<sum<<endl;
  
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int d[55][55],n,m,k,q,ans;
int main() {
  cin >> n >> m >> k >> q;
  for(int i=0,x,y,z;i<q;i++) {
    cin >> x >> y >> z;
    d[y][x]++;
  }
  for(int i=0;i<m;i++) {
    for(int j=0,x;j<n;j++){
      cin >> x;
      ans+=d[i][j]*x;
    }
  }
  cout << ans << endl;
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,z,p,a,b,c,i,j,k,ans=0;
  cin >> x >> y >> z >> p;
  int m[x][y];
  memset(m,0,sizeof(m));
  for(i=0;i<p;i++){
    cin >> a >> b >> c;
    m[a][b]++;
  }
  for(i=0;i<y;i++){
    for(j=0;j<x;j++){
      cin >> k;
      ans+=k*m[j][i];
    }
  }
  cout << ans << endl;
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int W,H,T;
int p;
int x[50],y[50],t[50];
int mp[50][50];

int main(){
  cin>>W>>H>>T>>p;
  for(int i=0;i<p;i++){
    cin>>x[i]>>y[i]>>t[i];
  }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>mp[i][j];
    }
  }

  int ans=0;
  for(int i=0;i<p;i++){
    if( mp[ y[i] ][ x[i] ] == 1 ){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
  
}