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>
#include <map>
#include <algorithm>
using ull = unsigned long long;
const unsigned bound = 1000000;
 

void solve(unsigned n);

int main()
{
	using namespace std;
	unsigned n = 0;
	cin >> n;

	while (n != 0)
	{
		solve(n);
		cin >> n;
	}

}

void solve(unsigned n)
{
	using namespace std;
	map<int, ull> records;

	for (int i = 0; i < n; i++)
	{
		int id = 0;
		unsigned price = 0, amount = 0;
		cin >> id >> price >> amount;

		records[id] += ull(price) * ull(amount);
	}

	vector<int> idList;
	for (auto man : records)
	{
		if (man.second >= bound)
			idList.push_back(man.first);
	}

	if (!idList.empty())
	{
		for (int id : idList)
			cout << id << endl;
	}
	else
	{
		cout << "NA" << endl;
	}
}

C++: #include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 

using namespace std;

int main()
{
	int n,f,b;
	long long c,d;

	while(1){
		f=1;int k=0;
		long long a[4000][2]={0};
		cin>>n; if(n==0) return 0;

		for(int i=0;i<n;i++){
			cin>>b>>c>>d;
			for(int j=0;j<k;j++){
				if(a[j][0]==b && a[j][1]>0){ a[j][1]+=c*d; f=0;}
			}
			if(f){
				a[k][0]=b; a[k++][1]=c*d;
			}
		}

		f=0;
		for(int i=0;i<k;i++){
			if(a[i][1]>=1000000) {cout<<a[i][0]<<endl; f=1;}
		}
		if(f) cout<<"NA"<<endl;
	}
}

C++: struct employee
{
		int N;
		long long int P,A,M;
};
int main(void)
{	
	struct employee person[4000];
	int a,b,c,d;
	for(b=0;;b=0)
	{
		scanf("%d",&c);
		for(a=0;a<c;a++)
		{
			scanf("%d %lld %lld",&person[a].N,&person[a].P,&person[a].A);
			person[a].M=person[a].P*person[a].A;
			for(d=0;d<a;d++)
				if(person[a].N==person[d].N)
				{
					person[a].M+=person[d].M;
					person[d].M=0;
				}
		}
		for(a=0;a<c;a++)
			if(person[a].M>=1000000 )
			{
				printf("%d\n",person[a].N);
				b++;
			}
		if(b==0)
			printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		long long no;
		long long price;
		long long deal;

		bool f = true;
		for ( int i = 0; i < n; i++ )
		{
			cin >> no >> price >> deal;
			if ( price * deal >= 1000000 )
			{
				cout << no << endl;
				f = false;
			}
		}

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

	}

	return 0;
}

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

int main(){
    int n;
    long int array[n][3];
    int count=0;

    cin>>n;

    for(int i=0;i<n;i++){
        cin>>array[i][0]>>array[i][1]>>array[i][2];
    }
    
    for(int i=0;i<n;i++){
        for(int j=1;i+j<n;j++){
            if(array[i][0]==array[i+j][0]){
                array[i][1]+=array[i+j][1];
                array[i][2]+=array[i+j][2];
                array[j][1]=0;
                array[j][2]=0;
            }
        }
    }

    for(int i=0;i<n;i++){
        if(array[i][1]*array[i][2]>=1000000){
            cout<<array[i][0]<<"\n";
            count++;
        }
    }

    if(count==0){
        cout<<"NA\n";
    }
}

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

int main(){
 int id,price,num,count,SaleResult[4000];
 bool isBe=false,sameid[4000];
 for(int i=0;i<4000;i++){
  sameid[i]=false;
 }
 while(true){
  cin>>count;
  if(count==0){
   break;
  }
  for(int i=0;i<count;i++){
   cin>>id>>price>>num;
   SaleResult[id]+=price*num;
   if(SaleResult[id]>=1000000){
   if(!sameid[id]){
    cout<<id<<'\n';
    isBe=true;
    sameid[id]=true;
   }
   }
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
  for(int i=0;i<4000;i++){
    SaleResult[i]=0;
    sameid[i]=false;
  }
  }
 return 0;
}

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

int main() {
	int n;

	while(cin >> n, n) {
		int ID, price, sale;
		int table[4096];
		bool flag = false;
		memset(table, 0, sizeof(table));
		for(int i = 0; i < n; i++) {
			cin >> ID >> price >> sale;
			table[ID] += price * sale;
		}

		for(int i = 0; i < 4096; i++) {
			if(table[i] >= 1000000) {
				cout << i << endl;
				flag = true;
			}
		}

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

	return 0;
}

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

int main()
{
    int n;
    while(1)
    {
        long long record[4000];
        for(int i=0; i<4000; i++)
        {
            record[i] = 0;
        }
        int cnt = 0;
        cin >> n;
        if(n == 0)
        {
            break;
        }
        for(int i=0; i<n; i++)
        {
            int id;
            long long p;
            long long q;
            cin >> id >> p >> q;
            record[id] += p * q;
        }
        for(int i=0; i<4000; i++)
        {
            if(record[i] >= 1000000)
            {
                cout << i << endl;
                cnt++;
            }
        }
        if(cnt == 0)
        {
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

typedef map<int,int> M;
typedef queue<int> P;

int N[4000];

int main()
{
    int count;
    while (cin >> count, count > 0) {
        M m;
        int t = 1;
        P p;
        for (int i = 0; i < count; i++) {
            int t1, t2, t3;
            cin >> t1 >> t2 >> t3;
            if (N[t1 - 1] == 0) {
                N[t1 - 1] = t;
                t++;
                p.push(t1);
                m[t1] = 0;
            }
            m[t1] += t2 * t3;
        }

        bool flag = true;
        while (p.size()) {
            t = p.front(); p.pop();
            if (m[t] >= 1000000) {
                cout << t << endl;
                flag = false;
            }
            N[t - 1] = 0;
        }
        if (flag)
            cout << "NA" << endl;
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int data[2][40000],n,i,f,id,a,b;
  while(1){
    cin>>n;
    if(n==0) break;
    for(i=0; i<10000; i++) data[0][i]=-1,data[1][i]=0;
    for(i=0;i<n;i++){
      cin>>id>>a>>b;
      for(f=0;f<i+1;f++){
	if(data[0][f]==id){
	  data[1][f]+=(a*b);
	  break;
	}else if(data[0][f]==-1){
	  data[0][f]=id;
	  data[1][f]=a*b;
	  break;
	}
      }
    }
    for(i=0,f=0;i<n;i++)
      if(data[1][i]>999999)cout<<data[0][i]<<"\n",f=1;
    if(f==0)cout<<"NA"<<"\n";
  }
}

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

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        set<string> list;
        string id;
        ll a,b,c = 1000000;
        for(int i = 0; i < n; i++) {
            cin >> id >> a >> b;
            if(list.find(id) == list.end() && a * b >= c) {
                cout << id << endl;
            }
            list.insert(id);
        }
        if(list.size() == 0) cout << "NA" << endl;
    }
}