Go: package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1)

int main(){
  int n;
  while(cin >> n, n){
    map<int,long long int> e;
    vector<int> num;
    int cntnum[4000] = {0};
    for(int i = 1; i <= 4000; i++){
      e[i] = 0;
    }
    for(int i = 0; i < n; i++){
      int tmp[3];
      cin >> tmp[0] >> tmp[1] >> tmp[2];
      e[tmp[0]] += tmp[1] * tmp[2];
      if(cntnum[tmp[0]] == 0){
        num.push_back(tmp[0]);
        cntnum[tmp[0]]++;
      }
    }
    int cnt = 0;
    for(int i = 0; i < num.size(); i++){
      if(e[num[i]] >= 1000000){
        cout << num[i] << endl;
        cnt++;
      }
    }
    if(cnt == 0){
      cout << "NA" << endl;
    }
  }
}

C++: #include "iostream"
using namespace std;

int LinearSearch(int x, int S[], int N) {
	S[N] = x;
	for (int i = 0; ; i++) {
		if (S[i] == x)
			if (i < N) {
				return 0;
			}
			else
				return 1;
	}
}

int main()
{
	while (1) {
		int h[4000] = { 0 };
		int m[4000] = { 0 };
		int a = 0;
		int n;
		cin >> n;
		if (n == 0)
			break;
		int number, nedan, amount;
		for (int i = 0; i < n; i++) {
			cin >> number >> nedan >> amount;
			h[number] += nedan*amount;
			if (h[number] >= 1000000) {
				if (LinearSearch(number, m, a)) {
					m[a] = number;
					a++;
				}
			}
		}
		if (a == 0)
			cout << "NA"<<endl;
		for (int i = 0; i < a; i++) {
			cout << m[i] << endl;
		}
	}
		return 0;
}

C++: #include<iostream>
#include<cstring>
#include<map>
using namespace std;
int main(){
  long long money,many,ans[4000]={0};
  int n,number,over_many=0,over[4000]={0};
  while(1){
    cin >> n;
    if(n==0)break;
    over_many=0;
    memset(over,0,sizeof(over));
    memset(ans,0,sizeof(ans));
    for(int i=0;i<n;i++){
      cin >> number >> money >> many;
      ans[number]+=money*many;

      if(ans[number]>=1000000){
	if(over[number]==0){
	  over_many++;
	  over[number]=1;
	}
      }

    }
    if(over_many==0){
      cout << "NA" << endl;
    }
    else{
      for(int k=0,j=0;j<over_many;k++){
	if(over[k]==1){
	  cout << k << endl;
	  j++;
	}
      }
    }

  }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
int main() {
	int n;
	std::cin >> n;
	std::vector<int> A;
	while (n != 0) {
		std::vector<int> m(n);
		std::vector<std::vector<int>> V(n, std::vector<int>(3));
		for (int i = 0;i < n;++i) {
			for (int j = 0;j < 3;++j) {
				std::cin >> V[i][j];
			}
		}
		for (int i = 0;i < n;++i) {
			m[i] = V[i][1] * V[i][2];
		}
		sort(V.begin(), V.end());
		for (int i = 0;i < n;i++) {
			for (int j = 0;j < n;++j) {
				if (i < j) {
					if (V[i][0] == V[j][0]) {
						m[i] += m[j];
						m[j] = 0;
					}
				}
			}
		}
		for (int i = 0;i < n;++i) {
			if (m[i] >= 1000000) {
				A.push_back(V[i][0]);
			}
		}
		n = 0;
		std::cin >> n;
	}
	return 0;
}

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

int main(void)
{
	int n, num;
	string str;
	long a;
	
	while (cin >> n, n){
		map <string, long long> m;
		vector <string> data;
		for (int i = 0; i < n; i++){
			cin >> str >> num >> a;
			if (!m[str]) data.push_back(str);
			m[str] += (num * a);
		}
		bool flag = true;
		for (int i = 0; i < data.size(); i++){
			if (1000000 <= m[data[i]]){
				cout << data[i] << endl;
				flag = false;
			}
		}
		if (flag) cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include<stdio.h>

int main(void){
	unsigned long long int x[5000];
	int n,a,b,i,nan,k;
	while(0==0){
		scanf("%d",&n);
		if(n==0)break;
		k=0;
		for(i=0;i<5000;i++) x[i]=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&nan,&a,&b);
			x[nan]+=a*b;
			if(x[nan]>999999){
				printf("%d\n",nan);
				k++;
			}
		}
		if(k==0) printf("NA\n");
		k=0;
	}
	return 0;
}

C++: #include <stdio.h>
#include <queue>
using namespace std;

int main()
{
	int n,no;
	long long many,yen;
	long long total[4001];
	bool update;
	queue<int> que;

	for(int i = 0; i <= 4000; i++){
		total[i] = 0;
	}

	scanf("%d",&n);

	while(n != 0){
		
		update = false;

		for(int i = 0; i < n; i++){
			scanf("%d%lld%lld",&no,&many,&yen);
			total[no] += many*yen;
			que.push(no);
		}

		while(!que.empty()){
			if(total[que.front()] >= 1000000){
				printf("%d\n",que.front());
				update = true;
			}
			total[que.front()] = 0;
			que.pop();
		}
		if(!update){
			printf("NA\n");
		}

		scanf("%d",&n);
	}

	return 0;
}

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

int main(){
    int n;
    while(cin>>n,n){
        map<long,long long>m;
        int i,p,q,s=0;
        while(n--){
            cin>>i>>p>>q;
            m[i]+=p*q;
        }
        for (map<long,long long>::iterator it=m.begin(); it!=m.end(); ++it){
            if(it->second>999999){
                s=1;
                cout<<it->first<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf("%d", &data);
		if (data == 0)break;
		vector<pair<int,int>> company;
		pair<int, int> sells;
		bool hero = false;
		int num, sell, cnt;
		for (int i = 0; i < data; i++)
		{
			scanf("%d %d %d", &num, &sell, &cnt);
			bool search = false;
			for (int j = 0; j < company.size(); j++)
			{
				if (company[j].first == num){
					search = true;
					company[j].second += sell*cnt;
					break;
				}
			}
			if (search == false)
			{
				sells.first = num;
				sells.second = sell*cnt;
				company.push_back(sells);
			}
		}
		for (int i = 0; i < company.size(); i++)
		{
			if (company[i].second >= target)
			{
				hero = true;
				printf("%d\n", company[i].first);
			}
		}
		if (hero == false)
			printf("NA\n");
	}
	return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	int id,price,num;
	bool f=false;
	int i;
	while(scanf("%d",&n),n){

		for(i=0;i<n;i++){
			scanf("%d %d %d",&id,&price,&num);
			if(price*num>1000000){
				printf("%d\n",id);
				f=true;
			}
		}
		if(f){
			printf("NA\n");
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		bool printed = false;
		rep(i, n){
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			if(1000000 <= b*c){
				printf("%d\n", a);
				printed = true;
			}
		}
		if(!printed)
			puts("NA");
	}
	return 0;
}