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<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

int ma[55][55] = {}, in[55][55];

signed main(void) {
    int w,h,tm;
    cin >> w >> h >> tm;
    int q;
    cin >> q;
    vi x(q),y(q),t(q);
    rep(i,q)cin >> x[i] >> y[i] >> t[i];
    rep(i,h)rep(j,w)cin >> in[i][j];
    rep(i,q){
        int b = x[i];
        int a = y[i];
        if(in[a][b])ma[a][b]++;
    }
    int ans = 0;
    rep(i,h)rep(j,w)ans += ma[i][j];
    cout << ans << endl;
}

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

int W, H, T, P;
int hiryou[55][55];
bool plant[55][55];
int ans = 0;
signed main()
{
  cin >> W >> H >> T >> P;
  for(int i = 0; i < P; i++){
    int x, y, t;
    cin >> x >> y >> t;
    hiryou[y][x]++;
  }
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> plant[i][j];
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      ans += hiryou[i][j] * plant[i][j];
    }
  }

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

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

using namespace std;

int main(){
  int w,h,T;
  cin >> w >> h >> T;
  int p;
  int a[h][w];
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++)
      a[i][j] = 0;
  }
  cin >> p;
  for(int i = 0;i < p;i++){
    int x,y,t;
    cin >> x >> y >>t;
    a[y][x]++;
    
  }
  char s[h][w];
  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 < h;i++){
    for(int j = 0;j < w;j++){
      if(s[i][j] == '1')
	sum += a[i][j];
    }
  }
  cout << sum << endl;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define ALL(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef int ut;
typedef pair<ut,ut> pr;
typedef vector<ut> VI;
typedef vector<pr> Vpr;
const int SIZE=100;
int maps[SIZE][SIZE];
int x[SIZE],y[SIZE],t[SIZE];
int main(){
	int H,W,T,P;
	cin >> W >> H >> T >> P;
	REP(i,P){
		cin >> x[i] >> y[i] >> t[i];
	}
	REP(i,H) REP(j,W){
		cin >> maps[i][j];
	//	cout << i << j << maps[i][j] <<endl;
	}
	int ans=0;
	
	REP(j,P){
		 ans+=maps[y[j]][x[j]];
	//	 cout << x[j] <<" " <<y[j] << " " << maps[y[j]][x[j]]<< endl;
	}
	
	cout << ans << endl;

	return 0;
}

C++: #include <iostream>
using namespace std;
int w,h,p,x[125010],y[125010],t,ans, map[60][60];
int main() {
	cin>>w>>h>>t>>p;
	for(int i=0;i<p;i++)cin>>x[i]>>y[i]>>t;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>map[j][i];
	for(int i=0;i<p;i++)if(map[x[i]][y[i]])ans++;
	cout<<ans<<endl;
	return 0;
}

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

#define H 50
#define W 50

int xyt[H][3];
int plant[H][W];
int x,y,cnt,when;

int main(void){

  int i,j,k;
  int length=0;
  
  cin >> x >> y >> when;
  cin >> cnt;

  for(i=0;i<cnt;i++) cin >> xyt[i][0] >> xyt[i][1] >> xyt[i][2];
  
  
  for(i=0;i<y;i++)
    for(j=0;j<x;j++)
      cin >> plant[i][j];

  for(i=0;i<cnt;i++){
    if(plant[xyt[i][1]][xyt[i][0]] == 1 && xyt[i][2] <= when) length++;
  }

  cout << length << endl;
  
}

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

int mat[50][50] = {};

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

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int w,h,t;
int p;
int mp[52][52];

int main(){
  scanf("%d%d%d%d",&w,&h,&t,&p);
  REP(i,p){
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    mp[x][y]+=1;
  }
  int ans = 0;
  REP(j,h)REP(i,w){
    int c;
    scanf("%d",&c);
    if(c==1)ans+=mp[i][j];
  }
  printf("%d\n",ans);
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m,gomi;
	cin>>m>>n>>gomi;
	int p;
	cin>>p;
	vp in(p);
	rep(i,p)cin>>in[i].second>>in[i].first>>gomi;
	vvi G(n,vi(m));
	rep(i,n)rep(j,m)cin>>G[i][j];
	int out=0;
	rep(i,p)if(G[in[i].first][in[i].second])out++;
	cout<<out<<endl;
}

C++: #include <iostream>
using namespace	std;
int main(){

  int w,h,t0,p,a[50][50]={},r=0;
  cin>>w>>h>>t0>>p;
  for(int i=0,x,y,t;i<p&&cin>>x>>y>>t;i++) if(t<=t0) a[y][x]++;
  for(int i=0,tmp;i<h;i++) for(int j=0;j<w&&cin>>tmp;j++) if(tmp) r+=a[i][j];
  cout<<r<<endl;
  return 0;

}