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 <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 100000000
#define MAXN 4096
typedef long long ll;
bool done[MAXN];
vector<int> syain;
int main(void) {
    int n;
    while (1) {
        cin >> n;
        int flag = 0;
        if (n == 0) break;
        map<int, ll> m;
        m.clear();
        syain.clear();
        for (int i = 0; i < MAXN; i++) done[i] = false;
        for (int i = 0; i < n; i++) {
            int bango, tanka, num;
            cin >> bango >> tanka >> num;
            if (!done[bango]) {
                done[bango] = true;
                syain.push_back(bango);
            }
            m[bango] += (m[bango] >= 1000000) ? 0 : tanka * num;
        }
        for (int i = 0; i < syain.size(); i++) {
            if (m[syain[i]] >= 1000000) {
                cout << syain[i] << endl;
                flag = 1;
            }
        }
        if (flag == 0) cout << "NA" << endl;
    }
    return 0;
}

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

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	int n;
	map<int, ll> result;
	vi check(4001, 0);
	vi ans;

	int ban, tan, suu;
	while(cin >> n, n) {
		ans.clear();
		result.clear();

		REP(i, n) {
			cin >> ban >> tan >> suu;

			if(!check[ban]) {
				if(!result[ban]) {
					result[ban] = tan*suu;
				} else {
					result[ban] += tan*suu;
				}

				if(result[ban] >= 1000000) {
					ans.push_back(ban);
					check[ban] = 1;

				}
			}
		}

		if(ans.size()) {
			REP(i, ans.size()) {
				cout << ans[i] << endl;
				check[ans[i]] = 0;
			}
		} else {
			cout << "NA" << endl;
		}
	}

	return 0;
}

C++: #include<stdio.h>

int main(){
int N;
int n,m,p;
long P[4003][3]={};
long PT[4003][4]={};

while(1){
scanf("%d",&N);if(N==0)break;

for(int i=1;i<=N;i++){
scanf("%d %d %d",&n,&m,&p);
if(P[n][0]<1000000&&m*p<1000000)P[n][0]+=m*p;
if(m*p>=1000000)P[n][0]=1000000;
if(P[n][1]==0)P[n][1]=i;
}
int c=0;
for(int i=0;i<=4001;i++)
if(1000000<=P[i][0]){PT[c][0]=P[i][0];PT[c][1]=P[i][1];PT[c][2]=i;c++;}

for(int i=0;i<c;i++)
for(int j=c-1;j>i;j--)
if(PT[j][1]<PT[j-1][1])
{long TT=PT[j][1];PT[j][1]=PT[j-1][1];PT[j-1][1]=TT;
 long TTT=PT[j][2];PT[j][2]=PT[j-1][2];PT[j-1][2]=TTT;}

for(int i=0;i<c;i++)
printf("%ld\n",PT[i][2]);
if(c==0)printf("NA\n");
for(int i=0;i<=4001;i++)
{P[i][0]=0;P[i][1]=0;P[i][2]=0;
 PT[i][0]=0;PT[i][1]=0;PT[i][2]=0;PT[i][3]=0;}

}
return  0;
}

C++: #include<stdio.h>
int main()
{
	unsigned long int goukei[4001]={0},kazu,tanka;
	int n,i,j,g=0,kazuz[4001]={0};
	while(scanf("%d",&n))
	{
		if(n==0)
		{
			break;
		}
		for(i=1;i<=n;i++)
		{
			scanf("%d %d %d",&j,&tanka,&kazu);
			kazuz[i]=j;
			goukei[i]=goukei[i]+tanka*kazu;
		}
		for(i=1;i<4001;i++)
		{
			if(goukei[i]>1000000)
			{
				printf("%d\n",kazuz[i]);
				goukei[i]=0;
				g++;
			}
		}
		if(g==0)
		{
			printf("NA\n");
		}
		g=0;
	}
	
	return 0;
}

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

std::vector<int> staff;
bool search(int number);

int main()
{
	int n;
	while(1)
	{
		int number,price,amount;
		staff.clear();
		std::cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			std::cin>>number>>price>>amount;
			if(price*amount>=1000000)
			{
				if(search(number)==false)
				{
					staff.push_back(number);
				}
			}
		}
		if(staff.empty())
		{
			std::cout<<"NA"<<std::endl;
		}
		else
		{
			for(std::vector<int>::iterator p=staff.begin();p!=staff.end();p++)
			{
				std::cout<<*p<<std::endl;
			}
		}
	}
	return 0;
}

bool search(int number)
{
	for(std::vector<int>::iterator p=staff.begin();p!=staff.end();p++)
	{
		if(*p==number)return true;
	}
	return false;
}

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

int main(){
    long long n,num,mn,nm,mon;
    while(cin >> n,n){
        int c=0,sc[4001],cn=0,cc=0;
        map<int,long long> maps;
        for(int i=0;i<n;i++){
            int cnt=0,j=0;
            cin >> num >> mn >> nm;
            mon = mn*nm;
            maps[num] += mon;
            for(;j<c;j++){
                if(sc[j]==num)cn++;
            }
            if(cn==0||j==0){
                sc[c] = num;
                c++;
                //cout << sc[c] << endl;
            }
        }
        for(int i=0;i<c;i++){
            if(maps[sc[i]]>=1000000){
                cout << sc[i] << endl;
                cc++;
            }
        }
        if(cc==0) cout << "NA" << endl;
    }
    return 0;
}

C++: #include<cstdio>

int main(){
int a;
unsigned long int b,c;
while(1){
 scanf("%d",&a);
 if(a==0){
 return 0;
}
 scanf("%d",&b);
 scanf("%d",&c);
if(a*c>=1000000) printf("%d\n",a);
}
}

C++: #include<stdio.h>
int main(void)
{
	struct employee
	{
		int N,P,A;
	};
	employee person[10][4000];
	int a,b=0,c[10],d,e;
	for(d=0;;b=0,d++)
	{
		scanf("%d",&c[d]);
		if(c[d]==0)
		{
			e=d;
			break;
		}
		for(a=0;a<c[d];a++)
			scanf("%d %d %d",&person[d][a].N,&person[d][a].P,&person[d][a].A);/
	}
	for(d=0;d<=e;b=0,d++)
	{
		for(a=0;a<c[d];a++)
			if(person[d][a].P*person[d][a].A>=1000000 )
			{
				printf("%d\n",person[d][a].N);
				b++;
			}
		if(b==0)
			printf("NA\n");
	}
}