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 <vector>

int main() {
	int n;
	std::cin >> n;
	while (n != 0) {
		bool flag{ true };
		std::vector<int> crue(4000 + 1, 0);
		for (auto i = 0; i < n; ++i) {
			int id, value, size;
			std::cin >> id >> value >> size;
			crue.at(id) += value * size;
		}
		for (auto i = 1; i <= 4000; ++i) {
			if (crue.at(i) >= 1000000) {
				std::cout << i << "\n";
				flag = false;
			}
		}
		if (flag) {
			std::cout << "NA\n";
		}
		std::cin >> n;
	}
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
??
#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
??
using namespace std;
typedef long long int lint;
??
bool AOJ0100() {
????????lint n, e, p, q;
????????cin >> n;
????????if (n == 0) return false;
??
????????lint* data = new lint[4001];
????????for (int i = 0; i <= 4000; i++) data[i] = 0;
??
????????for (lint i = 0; i < n; i++) {
????????????????cin >> e >> p >> q;
????????????????data[e] += p * q;
????????}
??
????????bool flag = false;
????????for (int i = 1; i <= 4000; i++) {
????????????????if (data[i] >= 1000000) {
????????????????????????flag = true;
????????????????????????cout << i << endl;
????????????????}
????????}
????????if (!flag) cout << "NA" << endl;
??
????????delete[] data;
????????return true;
}
??
int main()
{
????????while (AOJ0100()) {
????????}
????????return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long int lint;

bool AOJ0100() {
	lint n, e, p, q;
	cin >> n;
	if (n == 0) return false;

	lint* data = new lint[4001];
	for (int i = 0; i <= 4000; i++) data[i] = 0;

	for (lint i = 0; i < n; i++) {
		cin >> e >> p >> q;
		data[e] += p * q;
	}

	bool flag = false;
	for (int i = 1; i <= 4000; i++) {
		if (data[i] >= 1000000) {
			flag = true;
			cout << i << endl;
		}
	}
	if (!flag) cout << "NA" << endl;

	delete[] data;
	return true;
}

int main()
{
	while (AOJ0100()) {
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
 
int main()
{
    int n;
     
    while (cin >> n, n) {
        int cnt = 0;
        unsigned long long int s[4002] = {0}, gs[4002] = {0};

        int t, cost, num;

        for (int i = 0; i < n; i++) {
            cin >> num >> t >> cost;
            s[num] += t*cost;
            gs[i] = num;
        }
         
	for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                if(gs[i] == gs[j] && i < j) {
                    gs[j] = 4001;
                }
            }
        }
         
        for (int i = 0; i < n; i++) {
            if (s[gs[i]] >= 1000000) {
                cout << gs[i] << endl;
                cnt++;
            }
        }
        if (!cnt) cout << "NA" << endl;
    }
    return 0;
}

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

long long int sale[4001];

int main(){
	int p;
	while(cin >> p, p){
		for(int i=0; i < 4001; i++) sale[i] = 0;
		int id, price, num, result=0;

		for(int i=0; i < p; i++){
			cin >> id >> price >> num;
			sale[id] += price * num;
		}
		for(int i=0; i < 4001; i++){
			if(1000000 <= sale[i]){
				cout << i << endl;
				result++;
			}
		}
		if(result == 0) cout << "NA" << endl;
	}
}

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

using namespace std;
typedef long long Int;
Int n, b, c, num[4320];
Int sum[4320];
int main(){
	while(cin >> n, n){
		fill(sum, sum + 4320, 0);
		for(int i = 0;i < n;i++){
			cin >> num[i] >> b >> c;
			sum[num[i]] += b * c;
		}
		bool na = true;
		for(int i = 0;i < n;i++){
			if(sum[num[i]] >= 1000000){
				na = false;
				cout << num[i] << endl;
				sum[num[i]] = 0;
			}
		}
		if(na)cout << "NA" << endl;
	}
	return 0;
}

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;
}