Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

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

int loop(int h, int u);
void disp(vector<int> ve);

int main(){
    int id, h, u, n;
    while(cin >>n){
        if(n == 0) break;
        bool flg = false;
        vector<int> ve;
        for(int i = 0; i < n; i++){
            cin >>id >>h >>u;
            if(loop(h, u)){
                ve.push_back(id);
                flg = true;
            }
        }
        if(ve.size() == 0){
            cout <<"NA" <<endl;
        } else{
            disp(ve);
        }
    }
    return 0;
}

int loop(int h, int u){
    int sum = 0;
    for(int i = 0; i < u; i++){
        sum += h;
        if(sum >= 1000000){
            return 1;
        }
    }
    return 0;
}

void disp(vector<int> ve){
    for(int i = 0; i < ve.size(); i++){
        cout <<ve[i] <<endl;
    }
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    map<int, int> t;
    while (n--) {
      int i, p, q;
      cin >> i >> p >> q;
      t[i] += p * q;
    }
    bool f = true;
    for (auto &x : t) {
      if (x.se >= 1000000) {
        f = false;
        cout << x.fi << endl;
        x.se = 0;
      }
    }
    if (f) cout << "NA" << endl;
  }
}

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

int main(){
	int n;

	while(true){
		int user[4000];
		int usercount = 0;
		
		cin >> n;
		if(n == 0){
			break;
		}

		long long int buf[3];
		for(int i=0;i<n;i++){
			cin >> buf[0] >> buf[1] >> buf[2];
			long long int a = buf[1] * buf[2];
			if(a >= 1000000){
				user[usercount] = buf[0];
				usercount++;
			}
		}

		for(int i=0;i<usercount;i++){
			cout << user[i] << endl;
		}
		if(usercount == 0){
			cout << "NA" << endl;
		}
	}
}

C++: #include <iostream>
#include <map>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

void solve()
{
	int N;
	while(cin >> N, N)
	{
		set<int> Set;
		vector<int> ID(N);
		map<int, unsigned long long int> Map;
		bool Flag = false;
		unsigned long long int b, c;
		for(int i = 0; i < N; ++i)
		{
			cin >> ID[i] >> b >> c;
			Map[ID[i]] += b * c;
		}
		for(int i = 0; i < N; ++i)
		{
			if(Map[ID[i]] >= 1000000)
			{
				if(!Set.count(ID[i]))
				{
					cout << ID[i] << endl;
					Set.insert(ID[i]);
					Flag = true;
				}
			}
		}
		if(!Flag)
		{
			cout << "NA" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		map<ll,ll>in;
		rep(i,n){
			ll a,b,c;
			cin>>a>>b>>c;
			in[a]+=b*c;
		}
		bool h=false;
		for(map<ll,ll>::iterator it=in.begin();it!=in.end();it++){
			int d=it->first;
			if(in[d]>=1e6){
				h=true;
				cout<<d<<endl;
			}
		}
		if(!h)cout<<"NA"<<endl;
	}
}

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

using namespace std;

int main() {

	int n;

	while(cin >> n) {
		if(!n) {
			break;
		}
		deque<int> x;
		for(int i=0; i<n; i++) {
			int num, v, q;
			cin >> num >> v >> q;
			if(v*q>=1000000) {
				int f=0;
				for(int j=0; j<x.size(); j++) {
					if(x[j]==num) {
						f=1;
						break;
					}
				}
				if(!f) {
					x.push_back(num);
				}
			}
		}

		if(x.empty()) {
			cout << "NA" << endl;
		}
		else {
			for(int i=0; i<x.size(); i++) {
				cout << x[i] << endl;
			}
		}
		
	}

	return 0;

}

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

int main()
{
	int n;

	while (cin >> n, n){
		int e[5000] = {0}, p, q, a;
		bool out = false;
		for (int i = 0; i < n; i++){
			cin >> a >> p >> q;
			e[a] += p * q;
		}
		for (int i = 0; i < 4001; i++){
			if (e[i] >= 1000000){
			 cout << i << endl;
			 out = true;
			}
		}
		if (out == false) cout << "NA" << endl;
	}
	return (0);
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int
using namespace std;

typedef pair<int, int> P;

int main()
{
	int n, num, val, sale, c;
	P data[4000];
	int flag[4001];
	bool na;
	while(1){
		na = true;
		memset(flag, 0, sizeof(int)*4001);
		c = 1;

		cin >> n;
		if(n == 0) break;

		for(int i=0; i<n; i++){
			cin >> num >> val >> sale;
			if(!flag[num]){
				flag[num] = c;
				data[c].first = num, data[c].second = val * sale;
				c++;
			}else data[flag[num]].second += val * sale;
		}

		for(int i=1; i<c; i++){
			if(data[i].second >= 1000000){
				na = false;
				cout << data[i].first << endl;
			}
		}
		if(na) cout << "NA" << endl;
	}
	return 0;
}

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

int main() {

	while(true) {

		int n;
		cin >> n;
		if ( n == 0 ) break;

		int score[4000] = {0};
		int num_max = 0;

		for ( int i = 0; i < n; i++ ) {

			int input_number;
			int tanka;
			int kazu;
			cin >> input_number >> tanka >> kazu;

			score[input_number] += tanka * kazu;
			num_max = max( num_max,input_number );

		}

		bool f = true;
		for ( int i = 0; i <= num_max; i++ ) {
			if ( score[i] >= 1000000 ) {
				cout << i << endl;
				f = false;
			}
		}

		if ( f ) cout << "NA" << endl;

	}

	return 0;
}

C++: #include<stdio.h>
#include<string.h>


int main(void){

	int i,n;
	char *p;
	char a[1002];
	scanf("%d\n",&n);
	for(i = 0;i < n;i++){
        fgets(a,sizeof(a),stdin);
        while((p = strstr(a,"hoshino"))!=NULL){
            p[6] = 'a';
        }
                printf("%s",a);

    }


return 0;
}