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>
#include<vector>
using namespace std;
int main()
{
	
	int n;
	long long sn, x, y;
	vector<long long>nm;
	long long p[4001] = { 0 };
	while (1){
		nm.clear();
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i <= 4000; i++)p[i] = 0;
		for (int i = 0; i < n; i++){
			cin >> sn >> x >> y;
			p[sn] += x*y;
		}
		long long maxn = 0;
		for (int i = 1; i <= 4000; i++){
			if (maxn < p[i]){
				nm.clear();
				swap(maxn, p[i]);
				nm.push_back(i);
			}
			else if (maxn == p[i]){
				nm.push_back(i);
			}
		}
		if (maxn >= 1000000){
			for (int i = 0; i < nm.size(); i++){
				cout << nm[i] << endl;
			}
		}
		else
			cout << "NA" << endl;
	}
}

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

int main(void)
{
    int data_num, data_num_update;
    int employee_num[4000] = {};
    long long unit_sale_num[4000] = {};
    long long sale_num[4000] = {};
    
    while ((scanf("%d", &data_num)) != EOF) {
        
        if (data_num == 0) break;
        
        data_num_update = data_num;
        for (int i = 0; i < data_num; ++i) {
            scanf("%d %lld %lld", &employee_num[i], &unit_sale_num[i],  &sale_num[i]);
        }
        
        int data_check = 0;

        while (data_check < data_num - 1) {
            for (int i = data_check + 1; i < data_num; ++i) {
                if (employee_num[data_check] == employee_num[i]) {
                    sale_num[data_check] += sale_num[i];
                    unit_sale_num[data_check] += unit_sale_num[i];
                    data_num_update--;
                }
            }
            data_check++;
        }
        
        bool result_flag = true;
        
        for (int i = 0; i < data_num; ++i) {
            if (unit_sale_num[i] * sale_num[i] >= 1000000) {
                printf("%d\n", employee_num[i]);
                result_flag = false;
            }
            
            if (result_flag) {
                printf("NA\n");
                break;
            }
        }
    }

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void shoki();
	vector<long long> num(3999,0);
	int n,ban,tanka,kazu,i,j;
int main(){
	bool y=false;
	for(j=0;j<49;j++){
		cin>>n;
		if(n==0){
			break;
		}
		int count=0;
		for(i=0;i<n;i++){
			cin>>ban>>tanka>>kazu;
			num[ban]+=tanka*kazu;
		}
		for(int k=0;k<3999;k++){
			if(num[k]==0){
				continue;
			}
			if(num[k]>=1000000){
				y=true;
				cout<<k<<endl;
			}
		}
		if(y==false){
			cout<<"NA"<<endl;
		}
		y=false;
		shoki();
	}
	return 0;
}
void shoki(){
	for(int i=0;i<3999;i++){
		num[i]=0;
	}
}

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

int main()
{
    int n;
    long long int e[4000], p[4000], q[4000], sum[4000];
    bool ej[4000];

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

        for( int i = 0; i < 4000; i++ )
        {
            sum[i] = 0;
            ej[i] = false;
        }

        for( int i = 0; i < n; i++ )
        {
            cin >> e[i] >> p[i] >> q[i];
            sum[e[i]] += p[i] * q[i];
        }
        
        bool judge = false;
        for( int i = 0; i < n; i++ )
        {
            if( sum[e[i]] >= 1000000 && ej[e[i]] == false )
            {
                cout << e[i] << endl;
                judge = true;
                ej[e[i]] = true;
            }
        }
        if( judge == false )
            cout << "NA" << endl;
    }
    return 0;
}

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

bool p[4001];

int main(){
	int i , n , id , price , num , cnt=0;;
	while(cin>>n){
		if (n==0) break;
		for(i=0 ; i<4001 ; i++){
			p[i]=false;
		}
		for(i=0 ; i<n ; i++){
			cin >> id >> price >> num;
			if (price*num>=1000000) {
				p[id]=true;
				cnt++;
			}
		}
		for(i=0 ; i<4001 ; i++){
			if(p[i]==true){
				cout << i << endl;
			}
		}
		if (cnt==0) {
				cout << "NA" << endl;
			}
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
    int n=0,i,j,k=0,l=0,x,y,z;
    int a[5001]={0};
    long long int b[5001]={0};
    int c[5001]={0};
    int flag[5001]={0};
    int flag2[5001]={0};
    for(;;){
        k=0;
        x=0;
        y=0;
        z=0;
        i=0;
        l=0;
        for(j=0;j<4001;j++){
            a[j]=0;
            b[j]=0;
            flag[j]=0;

            c[j]=0;
            flag2[j]=0;

            }
        scanf("%d",&n);
        if(n==0)break;
        k=1;
        for(i=0;i<n;i++){
            scanf("%d",&x);
            scanf("%d",&y);
            scanf("%d",&z);

            if(flag[x]==1);
            else {
                b[x]=b[x]+y*z;
                if(flag2[x]==0){
                    a[i] = x;
                    flag2[x]=1;
                }


                }

            if(flag[x]==0&&b[x]>=1000000){

                flag[x]=1;

                k++;
            }


        }
        if(k!=1){
            for(l=0;l<n;l++){
                if(flag[a[l]]==1){
                    printf("%d\n",a[l]);
                }
            }
        }
        else if(k==1){
                printf("NA\n");

            }
        }

return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
long long s[5000];
int main(){
	int n,a,b,c;
	while(true){
	cin>>n;
	bool t=false;
	if(n==0)
		break;
	for(int i=0;i<min(n,4000);i++)
		s[i]=0;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		s[a]+=b*c;
		if(s[a]>=1000000&&s[a]<10000000){
			cout<<a<<endl;
			s[a]=10000000;
			t=true;
		}
	}
	if(t==false)
		cout<<"NA"<<endl;
	}
    return 0;
}

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

using namespace std;

const int Target = 1000000;

struct Shain {
	int no;
	long long sum;
};

int main( void )
{
	vector<Shain> shain;
	int n;
	while(cin >> n, n) {
		shain.clear();
		for(int i=0; i < n; ++i) {
			int no, kin, num;
			cin >> no >> kin >> num;
			bool hit = false;
			vector<Shain>::iterator it = shain.begin();
			while(it != shain.end()) {
				if(it->no == no) {
					it->sum += (kin * num);
					hit = true;
					break;
				}
				++it;
			}
			if(!hit) {
				Shain tmp;
				tmp.no = no;
				tmp.sum = kin * num;
				shain.push_back(tmp);
			}
		}
		bool hit = false;
		vector<Shain>::iterator it = shain.begin();
		while(it != shain.end()) {
			if(it->sum >= Target) {
				cout << it->no << endl;
				hit = true;
			}
			++it;
		}
		if(!hit)
			cout << "NA" << endl;
	}
	return 0;
}

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

int main()
{
	int num, man, yen, ko;
	int ach;
	int c;
	int g[20][2] = { {} };
	int flag;
	
	while (1){
		c = 0;
		flag = 1;

		cin >> num;
		if (!num)	break;

		for (int i = 1; i <= num; i++){
			int j = i;
			cin >> man >> yen >> ko;
			ach = yen * ko;

			for (; j > 1; j--){
				if (g[j - 1][0] == man){
					g[j - 1][1] += ach;
					flag--;
				}

				if (g[j - 1][1] >= 1000000){
					cout << man << endl;
					c++;
				}
			}

			if (flag){
				g[i][0] = man;
				g[i][1] = ach;
			}

			if (flag || g[i][1] >= 1000000){
					cout << man << endl;
					c++;
			}
		}

		if (c == 0)
			cout << "NA" << endl;
	}

	return 0;
}