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 "stdio.h"
#include "string.h"
long long N[4001];
int f[4001];
int main(){
    int x,n,p,i,j,c=0;
    scanf("%d",&i);
    while(i!=0){
        c=0;
        for(j=0;j<i;j++){
            scanf("%d%d%d",&x,&n,&p);
            if(N[x]>=0){
                N[x]+=n*p;
                if(N[x]>=1000000){
                    f[c]=x;
                    c++;
                    N[x]=-1;
                }
            }
        }
        if(c==0)
            printf("NA\n");
        else 
            for(j=0;j<c;j++)printf("%d\n",f[j]);
        memset(N,0,4001);
        memset(f,0,4001);
        scanf("%d",&i);
    }
    return 0;
}

C++: #include <stdio.h>

int output[50000];
int count=0;

void input(int);
int main(void){
	int n,i;
	while(true){
		scanf("%d",&n);
		if(n>0){
			input(n);
		}else{
			break;
		}
	}
	for(i=0;i<count;i++){
		if(output[i]!=0){
			printf("%d\n",output[i]);
		}else{
			printf("NA\n");
		}
	}
	
	return 0;
}
void input(int n){
	int e[4000];
	int p[1000000];
	int q[100000];
	int c[n];
	
	int i;
	
	for(i=0;i<n;i++){
		scanf("%d",&e[i]);
		scanf("%d",&p[i]);
		scanf("%d",&q[i]);
		c[i] = p[i]*q[i];
	}
	
	int j;
	
	for(i=0;i<n-1;i++){
		for(j=1;j<n;j++){
			if(e[i]==e[j]){
				c[i]=c[i]+c[j];
				c[j]=0;
			}
		}
	}
	int ch = 0;
	
	for(i=0;i<n-1;i++){
		if(c[i]>=1000000){
			output[count]=e[i];
			count++;
			ch = 1;
		}
	}
	if(ch == 0){
		output[count]=0;
		count++;
	}
}

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

int main(){
	int n, num;
	long long price, amount;
	map<int, long long> member;
	vector<int> array;

	while(cin >> n, n){
		member.clear();
		array.clear();
		for(int i = 0; i < n; i++){
			cin >> num >> price >> amount;
			member[num] +=  price * amount;
			for(int i = 0; i < array.size(); i++){
				if(num == array[i]){
					continue;
				}
			}
			if(member[num] >= 1000000){
				array.push_back(num);
			}
		}
		if(array.empty()){
			cout << "NA" << endl;
		}
		else{
			for(int i = 0; i < array.size(); i++){
				cout << array[i] << endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

typedef long long int lli;

const lli kSum = 1000000;

lli getSum(int price, int sales)
{
  return price * sales;
}

int main()
{
  int n_employee;
  int number;
  lli price, sales;
  bool flag;
  map<int, lli> checkEmp;
  vector<int> empNumbers;

  while(cin >> n_employee){
    if(n_employee == 0){
      break;
    }

    flag = true;

    for(int i = 0; i < n_employee; ++i){
      cin >> number >> price >> sales;

      if(checkEmp.find(number) != checkEmp.end()){
	checkEmp[number] += getSum(price, sales);
      } else {
	checkEmp[number] = getSum(price, sales);
	empNumbers.push_back(number);
      }
    }

    int length = empNumbers.size();
    for(int i = 0; i < length; ++i){
      if(checkEmp[empNumbers[i]] >= kSum){
	cout << empNumbers[i] << endl;
	flag = false;
      }
    }

    if(flag){
      cout << "NA" << endl;
    }
    checkEmp.clear();
  }

  return 0;
}

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

using namespace std;

int main(void){
	vector<int> staffNumber;
	vector<int> sellingPrice;
	vector<int> qty;
	int count=0;
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int sN,sP,qt;
		cin >> sN >> sP >> qt;
		staffNumber.push_back(sN);
		sellingPrice.push_back(sP);
		qty.push_back(qt);
	}
	for(int i=0;i<n;i++){
		if(sellingPrice[i]*qty[i]>=1000000){
			cout << staffNumber[i] << endl;
			count++;
		}
	}
	if(count==0 and  n != 0){
		cout << "NA" << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
int n;

int main() {
	while(scanf("%d\n", &n) != EOF) {
		map<int, ll> m;
		vector<int> id, p, q;
		rep(i,n) {
			int x, y, z;
			cin >> x >> y >> z;
			id.push_back(x);
			p.push_back(y);
			q.push_back(z);
		}
		rep(i,n) {
			auto it = m.find(id.at(i));
			if(it == m.end()) {
				m.insert(make_pair(id.at(i), (ll)p.at(i) * q.at(i)));
			} else {
				(*it).second += p.at(i) * q.at(i);
			}
		}
		bool flag = false;
		for(auto it = m.begin(); it != m.end(); ++it) {
			if((*it).second >= 1000000) {
				flag = true;
				cout << (*it).first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

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

int main() {
	long long int i, j, n, no[4000], tanka[4000], num[4000], ans[4000];
	bool flg=false;
	while (1) {
		j=0;
		flg=false;
		cin>>n;
		if (n==0) break;
		for (i=0; i<n; i++)
			cin>>no[i]>>tanka[i]>>num[i];
		for (i=0; i<n; i++) {
			if (tanka[i]*num[i]>=1000000)
				flg=true, ans[j]=no[i], j++;
		}
		sort(ans, ans+(j+1));
		if (flg==false) cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){

  int n, id, val, num, cnt;
  long long member[4000];
  int index[4000];

  while(cin >> n){

    if(!n) break;

    cnt = 0;
    memset(member, -1, sizeof(member));
    memset(index, -1, sizeof(index));

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

      cin >> id >> val >> num;

      if(member[id - 1] == -1){
        index[cnt] = id - 1; ++cnt;
        member[id - 1] += 1 + val * num;
      } else {
        member[id - 1] += val * num;
      }

    }

    bool flag = false;

    for(int i = 0; i < cnt; ++i){
      if(member[index[i]] >= 1000000){
        cout << index[i] + 1 << endl;
        flag = true;
      }
    }

    if(!flag) cout << "NA" << endl;

  }

}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

#define INF 10000000
#define MAX_N 4001

int n;
int meibo[MAX_N];

struct kanri{

	int number;
	long long sum;

}syain[MAX_N];

void shoki();

int main(){

	while(true){
	
		scanf("%d", &n);

		if(n == 0)
			break;

		shoki();

		int num = 0;
		int kari;

		for(int i = 0; i < n; i++){
			scanf("%d", &kari);
			bool flag = false;
			for(int j = 0; j < num; j++){
				if(syain[j].number == kari){
					int kari1, kari2;
					scanf("%d%d", &kari1, &kari2);
					syain[j].sum += kari1*kari2;
					flag = true;
					break;
				}
			}

			if(!flag){
				int kari1, kari2;
				syain[num].number = kari;
				scanf("%d%d", &kari1, &kari2);
				syain[num].sum += kari1 * kari2;
				num++;
			}

		}

		bool flag2 = false;

		for(int i = 0; i < n; i++){
			if(syain[i].sum >= 1000000){
				printf("%d\n", syain[i].number);
				flag2 = true;
			}
		}

		if(!flag2){
			printf("NA\n");
		}

	
	}


	return 0;

}

void shoki(){
	for(int i = 0; i < MAX_N; i++){
		syain[i].number = 0;
		syain[i].sum = 0;
	}
}