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 <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        map<int, long long> m;
        vector<int> v;
        for(int i=0; i < n; i++){
            long long  p, q, r;
            cin >> p >> q >> r;

            if(m[p] == 0) v.pb(p);
            m[p] += q*r;
        }
        bool isExist = false;
        for(int i=0; i < v.size(); i++){
            if(1000000 <= m[v[i]]){
                isExist = true;
                cout << v[i] << endl;
            }
        }
        if(!isExist) cout << "NA" << endl;
    }
}

C++: #include <iostream>
#include <map>
#include <vector>
#define M map<int,long long>
using namespace std;
int main()
{
  int n, i, id, a, b;
  while(cin >> n,n){
    M m;
    vector<int> v;
    vector<int>::iterator p;
    for(i=0;i<n;i++){
      cin >> id >> a >> b;
      m[id] += a * b;
      for(p = v.begin(); p != v.end(); p++){
	if(*p == id) break;
      }
      if(p == v.end()) v.push_back(id);
    }
    bool f = false;
    for(vector<int>::iterator it = v.begin(); it != v.end(); it++){
      if(m[(*it)] >= 1000000){
	cout << *it << endl;
	f = true;
      }
    }
    if(!f) cout << "NA" << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;

int n,num,cost,mon;

int main(){
	while(1){
		cin>>n;
		if(n==0) break;
		bool tmp=false;
		for(int i=0;i<n;i++){
			cin>>num>>cost>>mon;
			if((long long int)cost*mon>=1000000){
				cout<<num<<endl;
				tmp=true;
			}
		}
		if(!tmp) cout<<"NA"<<endl;
	}
}

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

int main() {
    int N;
    while (cin >> N) {
        if (N == 0) { break; }
        cin.get();
        string result, i;
        map<string, long long> sales;
 	long long p, q;
        for (int n = 0; n != N; ++n) {
            cin >> i >> p >> q;
            sales[i] += p * q;
        }

        for (map<string, long long>::iterator it=sales.begin(); it!=sales.end(); ++it) {
            if (it->second >= 1000000) {
                result += it->first + '\n';
            }
        }

        if (result.size() != 0) {
            cout << result;
        }
        else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n=1;
	int flg=0;
	int bangou[4001]={0};
	int tanka[4001]={0};
	int kosuu[4001]={0};
	int goukei[4001]={0};
	int ccc=0;
	int i=0,j=0;
	while(n!=0)
	{
		flg=0;
		ccc=0;
		scanf("%d",&n);
		if (n==0)
		{
			break;
		}
		else
		{
			for (i=1;i<=n;i++)
			{
				ccc++;
				scanf("%d %d %d",&bangou[ccc],&tanka[ccc],&kosuu[ccc]);
				goukei[ccc]=tanka[ccc]*kosuu[ccc];
				for (j=1;j<ccc;j++)
				{
					if (bangou[j]==bangou[ccc])
					{
						goukei[j]+=goukei[ccc];
						ccc--;
					}
				}
			}
			for (i=1;i<=ccc;i++)
			{
				if (goukei[i]>=1000000)
				{
					printf("%d\n",bangou[i]);
					flg=1;
				}
			}
			if (flg==0)
			{
				printf("NA\n");
			}
		}
	}
	return 0;
}

C++: #include<stdio.h>

struct staff_data{
	int num;
	long unsigned int price,volume,total;
};

int main(void){

	int n,i,j,hantei;
	int num,price,volume;
	struct staff_data dt[4000]={0};
	
	while(scanf("%d",&n)!=0){
	
		if(n==0){
			break;
		}
		
		staff_data dt[4000]={0};
		
		for(i=0;i<n;i++){
			
			scanf("%d %d %d",&num,&price,&volume);
			
			for(j=i;j<=i;j++){
				
				if(dt[j].num==num || dt[j].num==0){
					
					dt[j].num=num;
					dt[j].total=(price)*(volume)+dt[j].total;
					break;
				}
				
			}
		}

		hantei=0;

		for(j=0;j<n;j++){
		
			if(dt[j].total>=1000000){
				printf("%4d\n",dt[j].num);
				hantei=1;
			}
		}
	
		if(hantei==0){
			printf("NA\n");
		}

	}

	return 0;
}

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

int main()
{
    int n, no;
    long long yen, num;
    bool update = false;
    long long total[4001];
    std::queue<int> que;
    
    for (int i = 0; i < 4001; ++i) {
        total[i] = 0;
    }

    scanf("%d", &n);
    
    while (n != 0) {
        
        /*input*/
        for (int i = 0; i < n; ++i) {
            scanf("%d %lld %lld", &no, &yen, &num);
            total[no] += yen * num;
            que.push(no);
        }
        /*output*/
        while (!que.empty()) {
            if (total[que.front()] >= 1000000) {
                std::cout << que.front() << std::endl;
                total[que.front()] = 0;
                update = true;
            }
            que.pop();
        }
        if (!update) {
            std::cout << "NA" << std::endl;
        }
        scanf("%d", &n);
    }
    
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
int main(){
  int n,sn,p,c;
  std::vector<int> v;
  while(std::cin>>n){
    if(!n)return 0;
    for(;n;n--){
      std::cin>>sn>>p>>c;
      std::vector<int>::iterator it=std::find(v.begin(),v.end(),sn);
      if(p*c>=1000000){
        if(it==v.end()){
          v.push_back(sn);
        }
      }
    }
    if(v.empty())std::cout<<"NA"<<std::endl;
    else{
    std::vector<int>::iterator it = v.begin();
    while(it!=v.end()){
      std::cout<<*it<<std::endl;
      it++;
    }
    v.clear();
    }
  }
}
/*
4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100
0
*/

C++: #include <iostream>

using namespace std;
class MAN{
public:
	long long uriage;
	int number;
};

int main(int argc, char const* argv[])
{
	MAN *person;
	int n;
	bool flag;

	while( cin >> n && n != 0 ){
		person  = new MAN[n];
		for( int i = 0;i < n;i++ ){
			int target;
			long long a,b;
			cin >> target >> a >> b;

			int j;
			for( j = 0;j < i;j++ ){
				if( person[j].number == target ){
					person[j].uriage += a*b;
					break;
				}
			}
			if( j == i ){
				person[i].number = target;
				person[i].uriage = a * b;
			}
		}
		flag = false;
		for( int i = 0;i < n;i++ ){
			if( person[i].uriage >= 1000000 ){
				cout << person[i].number << endl;
				flag = true;
			}
		}
		if( flag == false ) cout << "NA" << endl;
		delete[] person;
	}

	return 0;
}