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 <algorithm>
using namespace std;

int main() {
	long long int i, j, n, no[4000], tanka[4000], num[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, cout<<no[i]<<endl;
		}
		if (flg==false) cout<<"NA"<<endl;
	}
	return 0;
}

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

typedef long long Int;

int main(){
	const int AIM = 1000000;
	int n;
	int num, per, sum;
	bool exist;
	
	while(true){
		scanf("%d", &n);
		if(n == 0) break;
		exist = false;
		for(int i = 0; i < n; i++){
			scanf("%d%d%d", &num, &per, &sum);
			if((Int)per * sum >= AIM){
				exist = true;
				printf("%d\n", num);
			}
		}
		if(!exist) printf("NA\n");
	}
	
	return 0;
}

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

int main()
{
	int n;

	while (cin >> n, n){
		long long e[5000] = {0}, p, q, a;
		bool out = false;
		for (int i = 0; i < n; i++){
			cin >> a >> p >> q;
			e[a] += p * q;
		}
		for (int i = 1; i <= 4000; i++){
			if (e[i] >= 1000000){
			 cout << i << endl;
			 out = true;
			}
		}
		if (out == false) cout << "NA" << endl;
	}
	return (0);
}

C++: #include<stdio.h>

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

C++: #include <stdio.h>
#include <string.h>

int main(void) {
int n;
int employees[4000] = {0};
while (1) {
scanf("%d", &n);
if (!n) break;

for (int i = 0; i < n; i++) {
int id, price, sales;
scanf("%d %d %d\n", &id, &price, &sales);
employees[id] += price * sales;
}

int found = 0;
for (int i = 0; i < n; i++) {
if (employees[i] >= 1000000) {
printf("%d\n", i);
found = 1;
}
}
memset(employees, 0, sizeof employees);
if (!found) {
printf("NA\n");
}

}
}

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

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

    cin>>n;
    if(n==0) goto Exit;

    for(int i=0;i<n;i++){
        cin>>array[i][0]>>array[i][1]>>array[i][2];
    }
    
    for(int i=0;i<n-1;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[i+j][1]=0;
            }
        }
    }

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

    Exit:
    ;

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

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

int main(){
	int n;

	while(true){
		int user[4000];
		int usercount = 0;
		
		cin >> n;
		if(n == 0){
			break;
		}

		long long int buf[3];
		for(int i=0;i<n;i++){
			cin >> buf[0] >> buf[1] >> buf[2];
			long long int a = buf[1] * buf[2];
			bool flag = true;
			for(int i=0;i<usercount;i++){
				if(buf[0] == user[i]){
					flag = false;
				}
			}
			if(a >= 1000000 && flag){
				user[usercount] = buf[0];
				usercount++;
			}
		}

		for(int i=0;i<usercount;i++){
			cout << user[i] << endl;
		}
		if(usercount == 0){
			cout << "NA" << endl;
		}
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main() {
	ll n;
	while (cin >> n, n) {
		map<ll, ll>mp;
		vector<ll>v;
		rep(i, n) {
			ll e, p, q; cin >> e >> p >> q;
			mp[e] += p*q;
			if (!binary_search(v.begin(), v.end(), e))
				v.push_back(e);
		}
		bool flag = false;
		for (ll i : v) {
			if (mp[i] >= 1000000) {
				cout << i << endl;
				flag = true;
			}
		}
		if (!flag)puts("NA");
	}
}

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

int main(){

	int N,Q;
	while(1){
	cin>>N;if(N==0)break;
	long long int n[4001][2]={};
	for(int i=0;i<N;i++){
		int x,y,z;
		cin>>x>>y>>z;
		if(n[x][0]+y*z<=1000000)n[x][0]+=y*z;
		else if(n[x][0]+y*z>1000000)n[x][0]=1000000;
		if(n[x][1]==0)n[x][1]=i;
	
	}
	for(int i=0;i<4001;i++){
		for(int j=i;j>i;j--){
			if(n[j][1]<n[j-1][1]){
				int t=n[j][0];n[j-1][0];n[j-1][0]=t;
				int T=n[j][1];n[j-1][1];n[j-1][1]=T;
			}
		}
	}
	bool f=false;
	for(int i=0;i<4001;i++){
		if(n[i][0]>=1000000){cout<<i<<endl;f=true;}
	}
	if(f==false)cout<<"NA"<<endl;

	}
	return 0;
}

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

int main() {
    int i[4000], p, q, sum[4000];
    for (; ; ) {
        int n, count;
        cin>>n;
        if (n) {
            count = 0;
            for (int j = 0; j < n; j++) {
                cin>>i[j]>>p>>q;
                sum[j] = p * q;
                if (j == 0 && sum[j] >= 1000000) {
                    cout<<i[j]<<endl;
                    count++;
                }
                for (int k = 0 ; k < j; k++) {
                    if (i[k] == i[j]) {
                        if (sum[k] >= 1000000) {
                            break;
                        } else {
                            sum[k] += sum[j];
                            if (sum[k] >= 1000000) {
                                cout<<i[j]<<endl;
                                count++;
                            }
                            break;
                        }
                    }
                }
            }
            if (count == 0) {
                cout<<"NA"<<endl;
            }
        } else
            break;
    }
    return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int main() {
	while (1) {
		/*for (int i = 0; i < n; i++) {
			e[i] = 0;
		}
		for (int i = 0; i < 4000; i++) {
			m[i] = 0;
			pr[i] = 0;
		}
		na = 1;*/
		int n = 0, p, q, na = 1, e[4000] = {}, pr[4000] = {};
		unsigned long long int m[4000] = {};

		cin >> n;
		if (n == 0)
			break;

		for (int i = 0; i < n; i++) {
			cin >> e[i] >> p >> q;
			m[e[i] - 1] += p * q;
		}

		for (int i = n-1; i >= 0; i--) {
			if (m[e[i] - 1] >= 1000000 && pr[e[i] - 1] == 0) {
				cout << e[i] << endl;
				pr[e[i] - 1] = 1;
				na = 0;
			}
		}

		if (na)
			cout << "NA\n";

	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
long long n,a,b,c,f,i,s[4001];
while(cin>>n){
if(n==0)break;
for(i=1;i<=4000;i++)s[i]=0;
for(i=0;i<n;i++){
cin>>a>>b>>c;
s[a]+=b*c;
}
f=0;
for(i=1;i<=4000;i++)
if(s[i]>=1000000){cout<<i<<endl;f=1;}
if(f==0)cout<<"NA"<<endl;
}
return 0;
}

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

int main()
{
	int n,t2,t3;
	while(cin >> n && n)
	{
		int total[n][2];
		bool flag=false;
		for(int i=0;i<n;i++)
		{
			cin >> total[i][1] >> t2 >> t3;
			total[i][0] = t2*t3;
		}
		
		for(int i=0;i<n;i++)
		{
			if(total[i][0]>=1000000)
			{
				cout << total[i][1] << endl;
				flag=true;
			}
		}
		if(!flag)cout << "NA" << endl;
	}
}