隨便寫
#include <bits/stdc++.h> //e465
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, d, ans = 0, count = 0;
cin >> n >> d;
int a[n][3];
for(int i = 0;i < n;i++){
cin >> a[i][0] >> a[i][1] >> a[i][2];
}
for(int i = 0;i < n;i++){
if(abs(a[i][0] - a[i][1]) >= d || abs(a[i][0] - a[i][2]) >= d || abs(a[i][1] - a[i][2]) >= d){
ans += (a[i][0] + a[i][1] + a[i][2]) / 3;
count++;
}
}
cout << count << " " << ans << "\n";
}