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 <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;
        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 <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
  int W, H, T;
  int p;
  int data[51][51];
  int used[51][51][51] = {{{0}}};
  Pip P[51];
  int sum = 0;
  
  cin >> W >> H >> T;
  cin >> p;

  Rep(i, p) {
    cin >> P[i].fr >> P[i].sc.fr >> P[i].sc.sc;
  }
  
  Rep(i, H) Rep(j, W) cin >> data[i][j], sum += data[i][j];

  Rep(i, p) {
    if ( data[P[i].sc.fr][P[i].fr] &&  !used[P[i].sc.sc][P[i].sc.fr][P[i].fr]  ) {
      used[P[i].sc.sc][P[i].sc.fr][P[i].fr] =true;
      data[P[i].sc.fr][P[i].fr]++;
    }
  }

  int ans = 0;
  Rep(i, H) Rep(j, W) ans += data[i][j];

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

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

int main(){
    int w,h,tim;
    int p;
    cin >> w >> h >> tim;
    cin >> p;
    int hei[50][50]={{}};
    for(int i=0;i<p;i++){
        int x,y,t;
        cin >> x >> y >> t;
        hei[x][y]++;
    }
    int sum=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;
            cin >> a;
            //cout << hei[j][i] << " ";
            if(a)sum+=hei[j][i];
        }
        cout << endl;
   }
    cout << sum << endl;
}

C++: #include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))

long long gcd(long long a, long long b){
    if(a<b){
        swap(a,b);
    }
    while(b){
        long long r = a%b;
        a=b;
        b=r;
    }
    return a;
}

int lcm(int a, int  b){
    return (a*b)/gcd(a,b);
}

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

long long mod_pow(long long x, long long n, long long mod){
    //x???n???????¨????????????????n??????2?????¨?¨???????????¨????
    //x^22 = x^16 + x^4 + x^2
    long long ret=1;
    while(n>0){
        if(n%2==1){
            ret=(ret*x)%mod;//???????????????
        }
        x=(x*x)%mod;//2???
        n=n/2;
    }
    return ret;
}

struct VV{
    int x;
    int y;
    int z;
};

class LessInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        if(riLeft.x == riRight.x){
            return riLeft.y > riRight.y;
        }
        return riLeft.x > riRight.x;
        
    }
};

class indInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        return riLeft.x < riRight.x;
        
    }
};

struct XX{
    long long min=0;
    long long kake=0;
};

class xxIntu {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //?¬¬1?????¶
        if(riLeft.kake != riRight.kake){
            return riLeft.kake > riRight.kake;//<:??????(?°??????????)???>:??????(??§?????????)
        }
        //?¬¬2?????¶
        return riLeft.min > riRight.min;
    }
};
bool operator< (const VV &riLeft, const VV &riRight){
    return riLeft.z < riRight.z;
};
/*bool operator> (const XX &riLeft, const XX &riRight){
    return riLeft.a > riRight.a;
};*/

int funC(int a,int b){
    int tmp=1;
    int tmp2=1;
    for(int i=0;i<b;i++){
        tmp=tmp*(a-i);
        tmp2=tmp2*(b-i);
    }
    return tmp/tmp2;
}

int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //???????????¨
    //ifstream ifs( "1_06.txt" );
    //ifs >> a;
    //????????????

    int W,H,T,p;
    cin >> W >> H >> T >>p;
    int x[125000];
    int y[125000];
    int t[125000];
    int s[50][50];
    
    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 >> s[j][i];
        }
    }
    
    for(int i=0;i<p;i++){
        if(t[i]<=T && s[x[i]][y[i]]!=0){
            s[x[i]][y[i]]++;
        }
    }
    
    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s[j][i]!=0){
                ans=ans+s[j][i]-1;
            }
        }
    }
    
    cout << ans << endl;

    
    //???????????§
    //cout << "ans" << endl;????????????
    //printf("%.0f\n",ans);//?°???°?????\?????¨?????????
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}