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 <bits/stdc++.h>
using namespace std;

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int main() {

  int n;
  while (cin >> n, n) {
    int xs[4002];
    calloc(sizeof(xs), sizeof(int));
    vector<int> order;
    rep (i, n) {
      int a,b,c; cin >> a >> b >> c;
      xs[a] = min(1000000, xs[a] + b * c);
      order.push_back(a);
    }
    bool bl = true;
    for (int id : order) {
      if (xs[id] >= 1000000) {
        cout << id << endl;
        bl = false;
        xs[id] = 0;
      }
    }
    if (bl) {
      cout << "NA" << endl;
    }
  }

  return 0;
}

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

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

C++: #include <iostream>

int main(void)
{
    int n, e, p, q;
    int employee[4000] = {0};

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

        while(n--)
        {
            std::cin >> e >> p >> q;
            employee[e - 1] += (p * q);
        }

        int cnt = 0;
        for(int i = 0; i < 4000; ++i)
        {
            cnt += (employee[i] >= 1000000);
        }

        if(cnt == 0)
        {
            std::cout << "NA" << std::endl;
        }

        else
        {
            for(int i = 0; i < 4000; ++i)
            {
                if(employee[i] >= 1000000)
                {
                    employee[i] = 0;
                    std::cout << i + 1 << std::endl;
                }
            }
        }
    }

    return 0;
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main() {
	int n;
	while (scanf("%d",&n)&&n!=0) {
		map<int, long long> sales;
		vector<int> log;
		long long int prc, mnt;
		int num;
		for (int i=0; i<n; i++) {
			scanf("%d%d%d",&num,&prc,&mnt);
			if (!sales[num]) {
				log.push_back(num);
			}
			sales[num] += prc * mnt;
		}
		bool flag = true;
		for (int i=0; i<log.size(); i++) {
			if (sales[log[i]]>=1000000) {
				flag = false;
				printf("%d\n", log[i]);
			}
		}
		if (flag) printf("NA\n");
	}
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    map<int, int> t;
    while (n--) {
      int i, p, q;
      cin >> i >> p >> q;
      t[i] += p * q;
    }
    vi v;
    for (auto x : t) {
      if (x.se >= 1000000) v.pb(x.fi);
    }
    if (v.size()) {
      rep(i, v.size()) cout << v[i] << endl;
    } else {
      cout << "NA" << endl;
    }
  }
}

C++: #include <cstdio>

int main() {
  int n;
  scanf("%d", &n);

  int e, p, q;
  for(int i = 0; i < n; i++) {
    scanf("%d %d %d", &e, &p, &q);
    if(p * q >  1e6) printf("%d", e);
  }
}

C++: #include<iostream>

int main()
{
	int n;

	while(1)
	{
		bool isNA=true;
		std::cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			int number,price,amount;
			std::cin>>number>>price>>amount;
			if(price*amount>=1000000)
			{
				std::cout<<number<<std::endl;
				isNA=false;
			}
		}
		if(isNA)std::cout<<"NA"<<std::endl;
	}
	return 0;
}

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

typedef struct{
	int sum;
	int pr;
} data;

int main(int argc, char **argv)
{
	int i, p, q, n, size = 0, flag, pri = 1, max;
	data *sarray = (data *)calloc(4000, sizeof(int));
	int *id = (int *)calloc(1000, sizeof(int));
	while(1){
		cin >> n;
		
		if(n == 0){
			cout << "NA" << endl;
			break;
		}
		
		while(n > 0){
			n--;
			cin >> i >> p >> q;
			flag = 0;
			for(int j = 0; j < size; j++){
				if(id[j] == i){
					if(p*q > sarray[i].sum || pri != sarray[i]->pr){
						sarray[i]->sum = p*q;
						sarray[i]->pr = pri;
					}
					flag = 1;
					break;
				}
			}
		
			if(flag == 0){
				id[size] = i;
				sarray[i]->sum = p*q;
				sarray[i]->pr = pri;
				size++;
			}
		}

		max = id[0];
		for(int j = 1; j < size; j++){
			if(sarray[max]->sum < sarray[id[j]]->sum){
				max = id[j];
			}
		}
		
		cout << max << endl;
		
		pri++;
	}
	
	free(sarray);
	return 0;
}

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

class meb{
public:
	int num;
	int tanka;
	int count;
	int sum;
};

int main(){
	int n;
	while(1){
		int cc=0;
		cin>>n;
		meb st[n];
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			cin>>st[i].num>>st[i].tanka>>st[i].count;
		}
		for(int k=0;k<n;k++){
			st[k].sum=st[k].tanka*st[k].count;
		}
		for(int j=0;j<n;j++){
			for(int l=j+1;l<n;l++){
				if(st[j].num==st[l].num){
					(st[j].sum)=(st[j].sum)+(st[l].sum);
					st[l].sum=0;
				}
			}
		}
		for(int a=0;a<n;a++){
			if(st[a].sum>=1000000)cout<<st[a].num<<endl;
			else cc++;
		}
		if(cc==n)cout<<"NA"<<endl;
	}
	return 0;
}