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 <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int w,h,t;
int p;
int add[51][51][51];
int s[51][51];

int main(void){
	scanf("%d%d%d",&w,&h,&t);
	scanf("%d",&p);
	for(int i=0;i<p;i++){
		int x,y,t;
		scanf("%d%d%d",&x,&y,&t);
		add[t][y][x]=1;
	}
	int all=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			scanf("%d",&s[i][j]);
		}
	}
	for(int i=0;i<t;i++){
		for(int j=0;j<h;j++){
			for(int k=0;k<w;k++){
				if(s[j][k] && add[i][j][k]){
					all++;
				}
			}
		}
	}
	printf("%d\n",all);

	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int W; int H; int T;
	while(~scanf("%d%d%d", &W, &H, &T)) {
		int P;
		scanf("%d", &P);
		vector<vi> v(H, vi(W));
		rep(i, P) {
			int x; int y; int t;
			scanf("%d%d%d", &x, &y, &t);
			++ v[y][x];
		}
		vector<vector<int> > s(H, vector<int>(W));
		for(int i = 0; i < H; ++ i) for(int j = 0; j < W; ++ j)
			scanf("%d", &s[i][j]);
		int ans = 0;
		rep(i, H) rep(j, W) if(s[i][j] == 1)
			ans += v[i][j];
		printf("%d\n", ans);
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int cnt[55][55];
int a[55][55];
vpii mp[55];

signed main()
{ // #define int long long ?????????????????§scanf???????????¨???????????????????????\?????????????????????
    int W, H, T; cin >> W >> H >> T;

    int p; cin >> p;

    rep(i, p) {
        int x, y, t; cin >> x >> y >> t;
        t--;
        mp[t].PB(pii(x, y));
    }

    rep(i, H) rep(j, W) {
        int s; cin >> s;
        cnt[i][j] = s;
    }

    int ans = 0;

    rep(i, T) {
        rep(j, mp[i].size()) {
            pii p = mp[i][j];
            if (cnt[p.fst][p.scd]) cnt[p.fst][p.scd] += 1;
        }
    }

    rep(i, H) rep(j, W) if (cnt[i][j] > 0) ans += cnt[i][j] - 1;

    cout << ans << endl;
}

C++: #include <iostream>
#define rep(i,n) for(int i = 0;i<n;i++)

using namespace std;

int main ()
{
        bool check[51][51] = {false};
        int array[51][51] = {0};
        int W,H,T,n,p;
        int x[100],y[100],t[100];
        cin >> W >> H >>T;
        cin >> p;
        int answer = 0;

        rep(i,p){cin >> x[i] >> y[i] >> t[i];}
        rep(i,H){
                rep(j,W ){
                cin >> n;
                if(n)
                        check[i][j] = true;

                }
        }
        rep(i,p){
                if(check[y[i]][x[i]])
                        answer++;
        }
        cout << answer << endl;
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    vector<int> x(p), y(p);
    for(int i=0; i<p; ++i){
        int tmp;
        cin >> x[i] >> y[i] >> tmp;
    }

    vector<vector<int> > s(h, vector<int>(w));
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            cin >> s[i][j];
        }
    }

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

    return 0;
}