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 <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
struct query{int x, y, t;};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int W, H, T;
    cin >> W >> H >> T;
    int p;
    cin >> p;
    vector<query> Q(p);
    rep(i, p){
        cin >> Q[i].x >> Q[i].y >> Q[i].t;
    }
    vector<vector<int>> A(H, vector<int>(W));
    int ret = 0;
    rep(i, H) rep(j, W) {
        cin >> A[i][j];
    }
    rep(i, p){
        int x = Q[i].x, y = Q[i].y, t = Q[i].t;
        if(t > T || A[y][x] == 0) continue;
        ret++;
    }
    
    cout << ret << endl;
    
    return 0;
}

C++: #include <iostream>
#include <vector>

template<class T>
using vec = std::vector<T>;

int main()
{
    int m, n, o, p, c;
    std::cin >> m >> n >> o >> p;
    int a, b;
    vec<vec<int>> cnt(n, vec<int>(m));
    for (int i = 0; i < p; i++) {
        std::cin >> a >> b >> c;
        cnt[b][a]++;
    }
    
    int s, res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            std::cin >> s;
            if (s != 0) {
                res += cnt[i][j];
            }
        }
    }
    
    std::cout << res << std::endl;
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){

  int W,H,T,P,x,y,t,s,ans = 0;
  int nae[50][50] ={{}};
  int hiryo[50][50] = {{}};

  cin >> W >> H >> T >> P;

  for(int i = 0;i < P; i++){
    cin >> x >> y >> t;
    if(t > T) continue;
    hiryo[y][x]++;
  }
    /*  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){

      cout << hiryo[i][j];
    }
    cout << endl;
  }
  cout << endl;

  }*/

  /* for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){

      cout << hiryo[i][j];
    }
    cout << endl;
    }*/

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

  /* for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){

      cout << nae[i][j];
    }
    cout << endl;
    }*/


  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
      if(hiryo[i][j] != 0 && nae[i][j] == 1){
	ans += hiryo[i][j];
      }
    }
  }

  cout << ans << endl;
}

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

int main()
{
    int w, h, t, p;

    cin >> w >> h >> t;
    cin >> p;

    int x[p], y[p], z[p], a[50][50];
    for( int i = 0; i < p; i++ )
        cin >> x[i] >> y[i] >> z[i];

    for( int i = 0; i < h; i++ )
        for( int j = 0; j < w; j++ )
            cin >> a[i][j];

    for( int i = 0; i < p; i++ )
        if( a[y[i]][x[i]] != 0 )
            a[y[i]][x[i]]++;

    int sum = 0;
    for( int i = 0; i < h; i++ )
        for( int j = 0; j < w; j++ )
            if( a[i][j] - 1 >= 0 )
                sum += a[i][j] - 1;

    cout << sum << endl;

    return 0;
}

C++: #include <iostream>

#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)

int main() {

  int m, n, t;
  cin >> m >> n >> t;
  int p;
  cin >> p;
  vector<vector<int>> sum(n, vector<int>(m));
  REP(i, p) {
    int x, y;
    cin >> x >> y;
    sum[y][x]++;
    int t;
    cin >> t;
  }
  vector<vector<int>> a(n, vector<int>(m));
  REP(i, n) REP(j, m) cin >> a[i][j];
  int ans = 0;
  REP(i, n) REP(j, m) if (a[i][j]) ans += sum[i][j];
  cout << ans << endl;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

signed main(void) {
	int i, j, k, l;
	int W, H, T;
	int p;
	int x[55] , y[55] , t[55];
	int field[55][55];
	cin >> W >> H >> T;
	cin >> p;
	rep(i, p) {
		cin >> x[i] >> y[i] >> t[i];
	}
	rep(i, H) rep(j, W) {
		cin >> field[i][j];
	}
	int cnt = 0;
	rep(i, p) {
		if (field[y[i]][x[i]]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int tall[50][50];

int main(){
    int W,H,T;
    cin>>W>>H>>T;
    int p;
    cin>>p;
    for(int i=0;i<p;i++){
        int x,y,t;
        cin>>x>>y>>t;
        tall[x][y]++;
    }
    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int s;
            cin>>s;
            ans+=tall[j][i]*s;
        }
    }
    cout<<ans<<endl;
    return 0;
}

C++: #include <iostream>
#include <cstring>

using namespace std;

int m[50][50];

int main(void){

	int W,H,T;
	int P;

	int x,y,t;
	int b;

	int ans = 0;

	cin >> W >> H >> T;
	cin >> P;

	memset(m,0,sizeof(m));

	for(int i=0;i<P;++i){
		cin >> x >> y >> t;
		if(t<=T){
			m[y][x]++;
		}
	}

	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j){
			cin >> b;

			ans += b*m[i][j];
		}
	}

	cout << ans << endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int W, H, T;
    cin >> W >> H >> T;
    int p;
    cin >> p;
    vvi a(H, vi(W));
    rep(i, p) {
        int c, r, t;
        cin >> c >> r >> t;
        a[r][c]++;
    }
    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            int b;
            cin >> b;
            ans += b * a[i][j];
        }
    }
    cout << ans << endl;
}