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)
}

Python: # AOJ 1587: Plants
# Python3 2018.7.13 bal4u

hi = [[0 for j in range(51)] for i in range(51)]
W, H, T = map(int, input().split())
P = int(input())
for i in range(P):
	x, y, t = map(int, input().split())
	hi[x][y] += 1
ans = 0;
for y in range(H):
	v = list(map(int, input().split()))
	for x in range(W):
		if v[x]: ans += hi[x][y]
print(ans)

Python: w, h, t = map(int, input().split())
c = [tuple(map(int, input().split())) for _ in range(int(input()))]
area = [tuple(map(int, input().split())) for _ in range(h)]
print(sum([area[i[1]][i[0]] for i in c]))

Python: w, h, t = map(int, input().split())
p = int(input())
hiryo = []
for i in range(p):
    x, y, t = list(map(int, input().split()))
    hiryo.append([x, y, t])
hatake = [[0 for i in range(w)] for j in range(h)]
hatake_boolean = []
for i in range(h):
    row = list(map(int, input().split()))
    row_boolean = []
    for j in row:
        if j: row_boolean.append(True)
        else: row_boolean.append(False)
    hatake_boolean.append(row_boolean)

for i in range(p):
    x, y, t = hiryo[i]
    if hatake_boolean[y][x]:
        hatake[y][x] += 1
ans = 0
for row in hatake:
    ans += sum(row)
print(ans)

Python: #!/usr/bin/env python3

import itertools
import math


def main():
    w, h, t = map(int, input().split())
    p = int(input())
    fert = []
    for _ in range(p):
        x, y, _ = map(int, input().split())
        fert.append((y, x))
    stage = [list(map(int, input().split())) for _ in range(h)]
    for r, c in itertools.product(range(h), range(w)):
        if stage[r][c] == 0:
            stage[r][c] = float("inf")
        elif stage[r][c] == 1:
            stage[r][c] = 0
    for r, c in fert:
        stage[r][c] += 1
    ans = sum(sum(filter(lambda x: x != float("inf"), row)) for row in stage)
    print(ans)


if __name__ == '__main__':
    main()

Python: w, h, t = map(int, input().split())
p = int(input())
c = [tuple(map(int, input().split())) for _ in range(p)]
area = [tuple(map(int, input().split())) for _ in range(h)]
print(sum([area[i[1]][i[0]] for i in c]))

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <string>
#include <complex>
#include <cstdio>
using namespace std;

int v[50][50];
int main(){
	int h,w,t;
	int p;
	cin >> w >> h >> t >> p;
	
	for(int i = 0 ; i < p ; i++){
		int x,y,z;
		cin >> x >> y >> z;
		if( z <= t ) v[y][x]++;
	}
	int sum = 0;
	for(int i = 0 ; i < h ; i++){
		for(int j = 0 ; j < w ; j++){
			int s;
			cin >> s;
			sum += s * v[i][j];
		}
	}
	cout << sum << endl;

}

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

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int s[55][55];
int x[55],y[55],t[55];

int main(void){
	int i,j;

	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int W,H,T,p;
	cin >> W >> H >> T >> p;
	for(i=0;i<p;i++) cin >> x[i] >> y[i] >> t[i];
	for(i=0;i<H;i++) for(j=0;j<W;j++) cin >> s[i][j];

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

	cout << ans << endl;

	return 0;
}

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

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
using namespace std;
int field[1000][1000];
int Hiryo[1000][1000];
int check[1000][1000]={0};
    
int main(void){
  int W,H,T;
  int p;
  int i,j,k,l;
  int a=0;
  int b=0;
  int sum=0;


  cin>>W>>H>>T;
  cin>>p;
  for(i=0;i<p;i++){
    for(j=0;j<3;j++){
      cin>>Hiryo[i][j];
    }
  }
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
    cin>>field[i][j];
  }
}

const int x = 0;
const int y = 1;
const int t = 2;
for(int i = 0 ; i < p ; i ++){
  int nx = Hiryo[i][x];
  int ny = Hiryo[i][y];
  /*
  rep(i,H){
    rep(j,W){
      if(nx==i && ny==j){
        cout<<"m";
      }else{
        cout<<field[i][j];
      }
    }
    cout<<endl;
  }cout<<endl;
//*/
  if(field[ny][nx] == 1){
    sum ++;
  }
}

/*
for(j=0;j<T;j++){
  for(i=0;i<p;i++){
    if(Hiryo[i][2]==0){
      a=Hiryo[i][0];
      b=Hiryo[i][1];
      if(field[b][a]>0 && check[b][a]==0){
        field[b][a]++;
        check[b][a]++;

      }
    }
  }

for(k=0;k<H;k++)
  for(l=0;l<W;l++)
    check[k][l]=0;
}
for(i=0;i<H;i++){
  for(j=0;j<W;j++){
    if(field[i][j]>0)
      sum+=field[i][j]-1;
  }
}
//*/
cout<<sum<<endl;
return 0;
}

C++: #include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[101][101],w,t,h,p,pp,x[101],y[101],tt[101],ans=0;
main(){
	cin>>w>>h>>t>>p;
	r(i,p)cin>>x[i]>>y[i]>>tt[i];
	r(i,h)r(j,w){
		cin>>pp;
		if(!pp)a[i][j]=-1;
	}
	r(i,p)if(a[y[i]][x[i]]!=-1)a[y[i]][x[i]]++;
	r(i,h)r(j,w)if(a[i][j]>=1)ans+=a[i][j];
	cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[55][55];

int main() {
  ll w,h,t;
  cin>>w>>h>>t;
  clr(d,0);
  ll p;
  cin>>p;
  rep(i,0,p){
    ll a,b,c;
    cin>>a>>b>>c;
    if(c<=t){
      d[b][a]++;
    }
  }
  ll ans = 0;
  rep(y,0,h){
    rep(x,0,w){
      ll a;
      cin>>a;
      if(a==1){
        ans += d[y][x];
      }
    }
  }
  cout << ans << endl;
  return 0;
}