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

int main()
{
	long long int n,id,sale,k,cnt,flg;
	while (1)
	{
		long long int outid[4001] = { 0 }, total[4001] = {0};
		cin >> n;
		if (n == 0)break;
		cnt = 0;
		flg = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> id >> sale >> k;
			outid[i] = id;
			total[i] = sale*k;
		}

		for (int i = 0; i < n-1; i++)
		{
			for (int j = i+1; j < n; j++)
			{
				if (outid[i]==outid[j])
				{
					total[i] += total[j];
					cnt++;
				}
			}
		}

		for (int i = 0; i < n-cnt; i++)
		{
			if (total[i] >= 1000000)
			{
				cout << outid[i] << endl;
				flg = 1;
			}
		}

		if (flg==0)
		{
			cout << "NA" << endl;
		}
		
	}
	return 0;
}

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

struct data{
	int num;
	long long pri;
	long long cun;
};

struct ret{
	int num;
	long long sales;
};

int main(){
	while (1){
		int n;
		std::cin >> n;
		if (n == 0)break;
		std::queue<data> que;
		for (int i = 0; i < n; ++i){
			data person;
			std::cin >> person.num >> person.pri >> person.cun;
			que.push(person);
		}
		std::vector<ret> lis;
		while (!que.empty()){
			data perso = que.front();
			if (!lis.empty()){
				bool f = false;
				for (auto it = lis.begin(); it != lis.end(); ++it){
					ret pers = *it;
					if (perso.num == pers.num){
						f = true;
						//std::cout << "t" << std::endl;
						//std::cout << pers.sales << std::endl;
						pers.sales += perso.cun * perso.pri;
						//std::cout << pers.sales << std::endl;
						std::swap(pers, *it);
					}
				}
				if (!f){
					ret newperson;
					newperson.num = perso.num;
					newperson.sales = perso.cun * perso.pri;
					lis.push_back(newperson);
				}
			}
			else{
				ret newperson;
				newperson.num = perso.num;
				newperson.sales = perso.cun * perso.pri;
				lis.push_back(newperson);
			}
			que.pop();
		}
		bool exist = false;
		for (auto it = lis.begin(); it != lis.end(); ++it){
			ret per = *it;
			//std::cout << per.num << " " << per.sales << std::endl;
			if (per.sales >= 1000000)std::cout << per.num << std::endl, exist = true;
		}
		if (!exist)std::cout << "NA" << std::endl;
	}
	//std::system("pause");
	return 0;
}

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

struct Saler
{
	int Number;
	int Saled;
};

int main(){
	struct Saler* sl;
	int n, a, b, c, i;
	bool isFound;
	
loop:
	scanf("%d\n", &n);		// データ個数
	if(n > 4000) goto end_scope;
	if(n == 0) goto end_scope;
	sl = (struct Saler*)malloc(sizeof(struct Saler) * n);
	memset(sl, 0, sizeof(struct Saler)*n);
	for(int j = 0; j < n; j++)
	{
		scanf("%d %d %d\n", &a, &b, &c);
		for(i = 0; i < n; i++)
		{
			if(sl[i].Number == 0)
			{
				sl[i].Number = a;
				sl[i].Saled = b * c;
				break;
			}
			else if(sl[i].Number == a)
			{
				sl[i].Saled += b * c;
				break;
			}
		}
	}
	isFound = false;
	for(int j = 0; j < n; j++)
	{
		if(sl[j].Saled >= 1000000)
		{
			cout << sl[j].Number << endl;
			isFound = true;
		}
	}
	!isFound && (cout << "NA" << endl);
	free(sl);
	goto loop;
end_scope:
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main()
{
    while (1)
    {
        int n;
        cin>>n;
        if (n==0)
            break;
        else
        {
            int ara[100000],i,sum[100000];
            for (i=0;i<=4000;i++)
            {
                sum[i]=0;
            }
            int id,b,c;
            for (i=0;i<n;i++)
            {
                cin>>id>>b>>c;
                sum[id]+=(b*c);
                ara[id]=id;
            }
            int ara2[100000],j=0;
            for (i=0;i<=4000;i++)
            {
                if (sum[i]>=1000000)
                {
                    ara2[j]=ara[i];
                    j++;
                }
            }
            if (j==0)
                cout<<"NA"<<endl;
            else
            {
                sort(ara2,ara2+j);
                for (int k=0;k<j;k++)
                {
                    cout<<ara2[k]<<endl;
                }
            }

        }
    }

}

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){
		cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,e[1010]={},p[1010]={},q[1010]={},i,count;
	while(1){
		cin>>n;
		if(n==0)break;
		count=0;
		for(i=0;i<n;i++){
			cin>>e[i]>>p[i]>>q[i];
			if(p[i]*q[i]>=100000){
				cout<<e[i]<<endl;
				count++;
			}
		}
		if(count==0){
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

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

template<typename itr, typename func>
func for_each_withindex(itr fi, itr l, func f){
	unsigned i{};
	for(; fi!=l; ++fi,++i){
		f(*fi,i);
	}
	return f;
}

int main(int argc, char const* argv[])
{
	unsigned n{};
	while (std::cin >> n,n != 0) {
		long long e{}, p{}, q{};
		bool isna{true};
		std::array<long long,4001> es{};
		for (unsigned i = 0; i < n; i++) {
			std::cin >> e >> p >> q;
				es.at(e) += p * q;
		}
		for_each_withindex(es.begin(), es.end(), [&isna](auto sell,auto e){ 
				if (sell>=1000000) {
				std::cout << e << std::endl;
				isna = false;
				}});
		if (isna) {
			std::cout << "NA" << std::endl;
		}

	}
	return 0;
}

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

int main()
{
    int n;
    while(cin >> n && n != 0)
    {
        long long int record[4000]={};
        int cnt = 0;
        for(int i=0; i<n; i++)
        {
            int id;
            int p;
            int 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<cstring>
using namespace std;
#define MAX_N 10000000
long long x[MAX_N], a, b, c, n;
int main() {
	while (1) {
		memset(x, 0, sizeof(x));
		cin >> n; if (!n) { break; }
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			x[a] += b*c;
			if (x[a] >= 1000000) { cout << a << endl; }
		}
	}
}