Problem:


Sale Result

There is data on sales of your company. Your task is to write a program which identifies good workers.

The program should read a list of data where each item includes the employee ID i, the amount of sales q and the corresponding unit price p. Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p &times; q) is greater than or equal to 1,000,000 in the order of inputting. If there is no such employees, the program should print "NA". You can suppose that n < 4000, and each employee has an unique ID. The unit price p is less than or equal to 1,000,000 and the amount of sales q is less than or equal to 100,000.

Input

The input consists of several datasets. The input ends with a line including a single 0. Each dataset consists of:

n (the number of data in the list)
i p q
i p q
 :
 :
i p q

Output

For each dataset, print a list of employee IDs or a text "NA"

Sample Input

4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100
2
2013 5000 100
2013 5000 100
0

Output for the Sample Input

1001
1003
NA
2013



Sample input:
4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100
2
2013 5000 100
2013 5000 100
0


Sample output:
1001
1003
NA
2013

Submission status: Wrong Answer

Solution code:
from collections import defaultdict as dd
while True:
    n=int(input())
    if n==0:
        break
    data=dd(int)
    for i in range(n):
        a,b,c=map(int,input().split())
        data[a]+=b*c
    f=False
    for i,j in data.items():
        if j>=1000000:
            print(i)
            f=True
    if f:
        print("NA")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict as dd
while True:
    n=int(input())
    if n==0:
        break
    data=dd(int)
    for i in range(n):
        a,b,c=map(int,input().split())
        data[a]+=b*c
    f=False
    for i,j in data.items():
        if j>=1000000:
            print(i)
            f=True
    if not f:
        print("NA")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Here your code !

from collections import defaultdict as dd
while True:
    n=int(input())
    if n==0:
        break
    data=dd(int)
    for i in range(n):
        a,b,c=map(int,input().split())
        data[a]+=b*c
    f=False
    for i,j in data.items():
        if j>=1000000:
            print(i)
            f=True
    if not f:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    ID = []
    sales = {}
    for i in range(n):
        ipq = list(map(int, input().split()))
        ID = ipq[0]
        pq = ipq[1] * ipq[2]
        if ID in sales:
            sales[ID] += pq
        else:
            sales[ID] = pq
    t = -1
    for k, v in sales.items():
        if v >= 1000000:
            print(k)
            t = 1
    if t == -1:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    ID = []
    sales = {}
    for i in range(n):
        ipq = list(map(str, input().split()))
        ID = ipq[0]
        pq = int(ipq[1]) * int(ipq[2])
        if ID in sales:
            sales[ID] += pq
        else:
            sales[ID] = pq
    t = -1
    for k, v in sales.items():
        if v >= 1000000:
            print(k)
            t = 1
    if t == -1:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    ID = []
    sales = {}
    for i in range(n):
        ipq = list(map(str, input().split()))
        ID = int(ipq[0])
        pq = int(ipq[1]) * int(ipq[2])
        if ID in sales:
            sales[ID] += pq
        else:
            sales[ID] = pq
    t = -1
    for k, v in sales.items():
        if v >= 1000000:
            print(k)
            t = 1
    if t == -1:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    ID = []
    sales = {}
    for i in range(n):
        ipq = list(map(int, input().split()))
        ID = ipq[0]
        pq = ipq[1] * ipq[2]
        if ID in sales:
            sales[ID][1] += pq
        else:
            sales[ID] = [ID, pq]
    t = -1
    for k, v in sales.items():
        if v[1] >= 1000000:
            print(k)
            t = 1
    if t == -1:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    ID = []
    sales = {}
    for i in range(n):
        ipq = list(map(int, input().split()))
        ID = ipq[0]
        pq = ipq[1] * ipq[2]
        if ID in sales:
            sales[ID][1] += pq
        else:
            sales[ID] = [ID, pq]
    t = -1
    for k, v in sorted(sales.items(), key=lambda x: x[1][0]):
        if v[1] >= 1000000:
            print(k)
            t = 1
    if t == -1:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    ID = []
    sales = {}
    for i in range(n):
        ipq = list(map(int, input().split()))
        ID = ipq[0]
        pq = ipq[1] * ipq[2]
        if ID in sales:
            sales[ID] += pq
        else:
            sales[ID] = pq
    t = True
    for k, v in sales.items():
        if v >= 1000000:
            print(k)
            t = False
    if t:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:
	time=input()

	if time==0:
		break

	worr={}
	mem=[]

	for i in range(time):
		shain=map(int, raw_input().split())
		if shain[0] not in worr:
			worr[shain[0]]=shain[1]*shain[2]
			mem.append(shain[0])
		else:
			worr[shain[0]]+=shain[1]*shain[2]

	mem.sort()

	check=1
	for i in mem:
		if worr[i]>=1000000:
			print i
			check=0
	if check==0:
		print "NA"

Submission status: Wrong Answer

Solution code:
while True:
	time=input()

	if time==0:
		break

	worr={}
	mem=[]

	for i in range(time):
		shain=map(int, raw_input().split())
		if shain[0] not in worr:
			worr[shain[0]]=shain[1]*shain[2]
			mem.append(shain[0])
		else:
			worr[shain[0]]+=shain[1]*shain[2]

	mem.sort()

	check=1
	for i in mem:
		if worr[i]>=1000000:
			print i
			check=0
	if check==1:
		print "NA"

Submission status: Wrong Answer

Solution code:
datasets=[]
while True:
  n = int(input())
  if n==0:
    break

  inputs=[None]*n
  for t in range(0,n):
    inputs[t] = list(map(int,input().split()))

  sale_result={}
  for t in range(0,n):
    sale_result[inputs[t][0]]=0 # inputs[t][0] means the ID in the "n"th line.

  for t in inputs:
    sale_result[t[0]]+=t[1]*t[2]

  na=True
  for k in sale_result:
    if sale_result[k]>=1000000:
      print(k)
      na=False
  if na:
    print("NA")

Submission status: Wrong Answer

Solution code:
n = int(input())
while n != 0:
    score = {}
    for i in range(n):
        e,p,q = list(map(int,input().split()))
        if e in score:
            score[e] += p*q
        else:
            score[e] = p*q
    f = True
    for e,v in score.items():
        if v >= 1000000:
            print(e)
            f = False
    if f:
        print("NA")
    n = int(input())

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    d = [0]*4000
    for i in range(n):
        e_t,p,q = map(int,input().split())
        d[e_t] += p*q
    flag = 0
    for i in range(4000):
        if d[i] >= 1000000:
            print(i)
            flag = 1
    if flag == 0:
        print('NA')

Submission status: Wrong Answer

Solution code:
x = []
while True:
    n = int(input())
    if n == 0:
        break
    d = [0]*4000
    for i in range(n):
        e_t,p,q = map(int,input().split())
        d[e_t] += p*q
    flag = 0
    for i in range(4000):
        if d[i] >= 1000000:
            x.append(i)
            flag = 1
    if flag == 0:
        x.append('NA')
for i in range(len(x)):
    print(x[i])

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    x = []
    if n == 0:
        break
    d = [0]*4000
    for i in range(n):
        e,p,q = map(int,input().split())
        d[e] += p*q
    flag = 0
    for i in range(4000):
        if d[i] >= 1000000:
            x.append(i)
            flag = 1
    if flag == 0:
        print('NA')
    else:
        for i in range(len(x)):
            print(x[i])

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    x = []
    if n == 0:
        break
    d = [0]*4000
    for i in range(n):
        e,p,q = map(int,input().split())
        d[e] += p*q
    flag = 0
    for i in range(4000):
        if d[i] >= 1000000:
            print(i)
            flag = 1
    if flag == 0:
        print('NA')

Submission status: Wrong Answer

Solution code:
while 1:
    n=int(input())
    if n==0:break
    a={}
    for _ in range(n):
        b=list(map(int,input().split()))
        if b[0] in a:a[b[0]]+=b[1]*b[2]
        else:a[b[0]]=b[1]*b[2]
    if max(a.values())<=999999:print('NA' )
    else:
        for i in a:
            if a[i]>999999:print(i)

Submission status: Wrong Answer

Solution code:
l = int(input())
while l != 0:
	k = 0
	for l in range(0,l):
		li = input().split()
		if int(li[1]) * int(li[2]) >= 10**6:
			print(li[0])
			k = 1
	
	if k == 0:
		print("NA")
	l = int(input())

Submission status: Wrong Answer

Solution code:
while True:
    n=int(input())
    if n==0:break
    d=dict()
    for _ in range(n):
        i,p,q=map(int, input().split())
        d[i] = d[i]+p*q if i in d else p*q
    b=True
    for k, v in d.items():
        if v >= 1000000:
            print(k)
            b=False
    else:
        if b:print("NA")

Submission status: Wrong Answer

Solution code:
while True:
    n=int(input())
    if n==0:break
    d=dict()
    for _ in range(n):
        i,p,q=map(int, input().split())
        d[i] = d[i]+p*q if i in d else p*q
    b=True
    ans=[]
    for k, v in d.items():
        if v >= 1000000:
            ans.append(k)
            b=False
    else:
        if b:print("NA")
        else:print('\n'.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math
from collections import defaultdict

for s in sys.stdin:
    n = int(s)
    if n == 0:
        break

    d = defaultdict(int)
    for i in range(n):
        e, p, q = map(int, input().split())
        d[e] += p * q

    is_exist = False
    for k, v in d.items():
        if v >= 1000000:
            print(k)
            is_exist = True

    if not is_exist:
        print('NA')

Submission status: Wrong Answer

Solution code:
import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break
    member = {}
    for i in range(n):
        e,p,q = sys.stdin.readline().rstrip().split(' ')
        if not e in member.keys():
            member[e] = 0
        member[e] += int(p) * int(q)
    ret = sorted(member.items(), key=lambda d: d[1])[::-1]
    ret = [k for k,v in ret if v >= 1000000]
    if len(ret) != 0:
        for d in ret:
            print(d)
    else:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:
    n=int(input())
    if n==0:break
    res=[0 for i in range(4000)]
    for i in range(n):
        d=[int(num) for num in input().split(' ')]
        res[d[0]-1]+=d[1]*d[2]
    flag=False
    for i in range(4000):
        if res[i]>=1000000:
            print(i+1)
            flag=True
    if flag==False:print("NA")

Submission status: Wrong Answer

Solution code:
from pip._vendor.distlib.compat import raw_input
while True:
    n = int(raw_input())
    if n == 0: break
    data = {}
    order = []
    for i in range(n):
        id,price,quant = map(int, raw_input().split())
        if id in data:
            data[id] += price * quant
        else:
            data[id] = price * quant
            order.append(id)

    if max(data.values()) < 1000000: print("NA")
    else:
        for i in order:
            if data[i] >= 1000000:
                print(id)

Submission status: Wrong Answer

Solution code:
while True :
    n = int(input())
    if n == 0 : break
    
    box = {}
    for _ in ([None]*n) :
        e, p, q = map(int, input().split())
        if e in box : box[e] += p * q
        else        : box[e]  = p * q
    
    check = 0
    for _ in box :
        if box[_] >= (10**6) :
            print(_)
            check = 1
    if check == 0 : print('NA')

Submission status: Wrong Answer

Solution code:
data_num = int(input())

nice_syatiku = 0

for data_num in range(data_num):

    a,b,c = map(int,input().split())

    Earnings = b * c
    
    if Earnings >= 1000000:
        print("a\n")
        nice_syatiku += 1

if nice_syatiku == 0:
    print("NA\n")

Submission status: Wrong Answer

Solution code:
data_num = int(input())

nice_syatiku = 0

for data_num in range(data_num):

    a,b,c = map(int,input().split())

    Earnings = b * c
    
    if Earnings >= 1000000:
        print(a)
        nice_syatiku += 1

if nice_syatiku == 0:
    print("NA\n")

Submission status: Wrong Answer

Solution code:
data_num = 1

while(data_num != 0):

    data_num = int(input())
    
    if data_num == 0:
        break

    nice_syatiku = 0

    for data_num in range(data_num):

        a,b,c = map(int,input().split())

        Earnings = b * c
        
        if Earnings >= 1000000:
            print(a)
            nice_syatiku += 1

    if nice_syatiku == 0:
        print("NA\n")

Submission status: Wrong Answer

Solution code:
while True:

    data_num = int(input())
    
    if data_num == 0:
        break

    nice_syatiku = 0

    for data_num in range(data_num):

        a,b,c = map(int,input().split())

        Earnings = b * c
        
        if Earnings >= 1000000:
            print(a)
            nice_syatiku += 1

    if nice_syatiku == 0:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:

    data_num = int(input())
    
    if data_num == 0:
        break

    nice_syatiku = 0

    for data_num in range(0,data_num,1):
        print("datanum = {0}".format(data_num))

        a,b,c = map(int,input().split())

        Earnings = b * c
        
        if Earnings >= 1000000:
            print(a)
            nice_syatiku += 1

    if nice_syatiku == 0:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:

    data_num = int(input())
    
    if data_num == 0:
        break

    nice_syatiku = 0

    for data_num in range(0,data_num,1):

        a,b,c = map(int,input().split())

        Earnings = b * c
        
        if Earnings >= 1000000:
            print(a)
            nice_syatiku += 1

    if nice_syatiku == 0:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    d = dict()
    for _ in range(n):
        i, p, q = map(int, input().split())
        d[i] = d[i]+p*q if i in d else p*q
    tmp = sorted(d.items(), key=lambda x: x[0])
    tmp = list(filter(lambda x: x[1] >= 1000000, tmp))
    if len(tmp):
        for t in tmp:
            print(t[0])
    else:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    d = dict()
    sep = []
    for _ in range(n):
        i, p, q = map(int, input().split())
        if i in d:
            d[i] += p*q
        else:
            d[i] = p*q
            sep.append(i)
    tmp = list(filter(lambda x: x[1] >= 1000000, d.items()))
    if len(tmp):
        for s in sep:
            if s in tmp:
                print(s)
    else:
        print("NA")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100&lang=jp
"""
import sys


def solve(data):
    result = []
    total_sales = [0 for _ in range(4002)]
    for id, unit_price, quantity in data:
        total_sales[id] += unit_price * quantity
    for i, sales in enumerate(total_sales):
        if sales >= 1000000:
            result.append(i)
    return result


def main(args):
    #data = []
    #data.append([1001, 2000, 520])
    #data.append([1002, 1800, 450])
    #data.append([1003, 1600, 625])
    #data.append([1001, 200, 1220])

    while True:
        num = int(input())
        if num == 0:
            break
        data = []
        for _ in range(num):
            data.append([int(x) for x in input().split(' ')])
        result = solve(data)
        if result:
            for ele in result:
                print(ele)
        else:
            print('NA')


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100&lang=jp
"""
import sys


def solve(data):
    result = []
    total_sales = [0 for _ in range(4000+1)]
    for id, unit_price, quantity in data:
        total_sales[id] += unit_price * quantity
    for i, sales in enumerate(total_sales):
        if sales >= 1000000:
            result.append(i)
    return result


def main(args):
    #data = []
    #data.append([1001, 2000, 520])
    #data.append([1002, 1800, 450])
    #data.append([1003, 1600, 625])
    #data.append([1001, 200, 1220])

    while True:
        num = int(input().strip())
        if num == 0:
            break
        data = []
        for _ in range(num):
            data.append([int(x) for x in input().strip().split(' ')])
        result = solve(data)
        if result:
            for ele in result:
                print(ele)
        else:
            print('NA')


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break

    rs = {}
    for i in range(n):
        arr = [int(x) for x in input().split(' ')]
        s = arr[1] * arr[2]
        rs[arr[0]] = (rs.get(arr[0]) or 0) + s

    top = [k for k, v in rs.items() if v > 1000000 ]
    if len(top) == 0:
        print('NA')
    else:
        for i in top:
            print(i)

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break

    rs = {}
    for i in range(n):
        cid, p, q = map(int, input().strip().split(' '))
        rs[cid] = (rs.get(cid, None) or 0) + p * q

    top = [k for k, v in rs.items() if v >= 1000000]
    if len(top) == 0:
        print('NA')
    else:
        for i in top:
            print(i)

Submission status: Wrong Answer

Solution code:
class Employee():
    def __init__(self,id,p,q):
        self.id = id
        self.total = p*q
    
    def add_total(self,total):
        self.total += total

class Manager():
    def __init__(self):
        self.employees = list()
        self.count = 0
    
    def add(self,e):
        if len(self.employees) == 0:
            self.employees.append(e)
        else:
            if self.employees[-1].id == e.id:
                self.employees[-1].add_total(e.total)
            else:
                self.employees.append(e)
            
    def pprint(self):
        for i,e in enumerate(self.employees):
            if e.total >= 1000000:
                print(e.id)
                self.count+=1
        if self.count == 0:
            print("NA")

def main():
    while(True):
        m = Manager()
        n = int(input())
        if n==0:
            break
        l = list()
        for i in range(n):
            s = list(map(int,input().split()))
            l.append(s)
        l = sorted(l)
        for x in l:
            m.add(Employee(*x))
        m.pprint()
    

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
class Employee():
    def __init__(self,id,p,q):
        self.id = id
        self.total = p*q
    
    def add_total(self,total):
        self.total += total

class Manager():
    def __init__(self):
        self.employees = list()
        self.count = 0
    
    def add(self,e):
        if len(self.employees) == 0:
            self.employees.append(e)
        else:
            if self.employees[-1].id == e.id:
                self.employees[-1].add_total(e.total)
            else:
                self.employees.append(e)
            
    def pprint(self):
        for i,e in enumerate(self.employees):
            if e.total >= 1000000:
                print(e.id)
                self.count+=1
        if self.count == 0:
            print("NA")

def main():
    while(True):
        m = Manager()
        n = int(input())
        if n==0:
            break
        l = list()
        for i in range(n):
            s = list(map(int,input().split()))
            l.append(s)
        l = sorted(l)
        for x in l:
            m.add(Employee(*x))
        m.pprint()
 
main()

Submission status: Wrong Answer

Solution code:
while(True):
    n = int(input())
    if n==0: break
    d = dict()
    s = set()
    c = 0
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in s:
            d[id_] += p*q
        else:
            s.add(id_)
            d[id_] = p*q
    for i in s:
        if d[i] >= 1000000:
            print(i)
            c+=1
    if c == 0: print("NA")

Submission status: Wrong Answer

Solution code:
while(True):
    n = int(input())
    if n==0: break
    d = dict()
    s = set()
    c = 0
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in s:
            d[id_] += p*q
        else:
            s.add(id_)
            d[id_] = p*q
    for i in s:
        if d[i] >= 1000000:
            print(i)
            c+=1
    if c == 0: print('NA')

Submission status: Wrong Answer

Solution code:
while(True):
    n = int(input())
    if n==0: break
    d = dict()
    c = 0
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in d:
            d[id_] += p*q
        else:
            d[id_] = p*q
    for i in d:
        if d[i] >= 1000000:
            print(i)
            c+=1
    if c == 0: print('NA')

Submission status: Wrong Answer

Solution code:
while(True):
    n = int(input())
    if n==0:
        break
    d = dict()
    c = 0
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in d:
            d[id_] += p*q
        else:
            d[id_] = p*q
    for i in d:
        print(d[i])
        if d[i] >= 1000000:
            print(i)
            c+=1
    if c == 0:
        print('NA')

Submission status: Wrong Answer

Solution code:
while(True):
    n = int(input())
    if n==0:
        break
    d = dict()
    c = 0
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in d:
            d[id_] = d[id_] + p*q
        else:
            d[id_] = p*q
    for i in d:
        print(d[i])
        if d[i] >= 1000000:
            print(i)
            c+=1
    if c == 0:
        print('NA')

Submission status: Wrong Answer

Solution code:
while(True):
    n = int(input())
    if n==0: break
    d = dict()
    s = set()
    l = list()
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in s:
            d[id_] += p*q
        else:
            s.add(id_)
            d[id_] = p*q
    for i in s:
        if d[i] >= 1000000:
            l.append(i)
    if len(l) == 0:
        print('NA')
    else:
        for i in sorted(l):
            print(i)

Submission status: Wrong Answer

Solution code:
while(True):
    n = int(input())
    if n==0: break
    d = {}
    c = 0
    l = list()
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in d:
            d[id_] += p*q
        else:
            d[id_] = p*q
            l.append(id_)
    for i in d:
        if d[i] >= 1000000:
            print(i)
            c += 1
    if c == 0:
        print('NA')

Submission status: Wrong Answer

Solution code:
import sys
import math

data =[0 for i in range(4000)]
p_data = []
while True:
	n = int(input())
	count = 0
	if n == 0:
		break
	for i in range(n):
		e,p,q = map(int, input().split())
		data[e] = data[e] + p * q
		if p_data.count(e) == 0:
			p_data.append(e)
		if i >= 1:
			p_data.sort()
	for i in range(len(p_data)):
		if data[p_data[i]] >= 1000000:
			print(p_data[i])
			count = count + 1
			data[p_data[i]] = 0
		elif data[p_data[i]] != 0:
			data[p_data[i]] = 0
	if count == 0:
		print('NA')
	p_data.clear()

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':

    list = []

    while (True):
        n = int(input())
        if (n == 0):
            break

        isNA = True

        for i in range(n):
            ds = input().split()
            e = ds[0]
            p = int(ds[1])
            q = int(ds[2])

            sales = p * q

            if (1000000 <= sales):
                list.append(e)
                isNA = False

        if isNA:
            list.append("NA")

    for l in list:
        print("%s" % l)

Submission status: Wrong Answer

Solution code:
list = []

while (True):
    n = int(input())
    if (n == 0):
        break

    isNA = True

    for i in range(n):
        ds = input().split()
        e = ds[0]
        p = int(ds[1])
        q = int(ds[2])

        sales = p * q

        if (1000000 <= sales):
            list.append(e)
            isNA = False

    if isNA:
        list.append("NA")

for l in list:
    print("%s" % l)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys

while True:
    n = int(input())
    salesmap = {}
    j = 0
    for i in range(1,4001):
    	salesmap[i] = 0
    if n == 0:
        break
    for i in range(n):
    	a = input().split()
    	salesmap[int(a[0])] += int(a[1])*int(a[2])
    for i in range(1,4001):
    	if salesmap[i] >= 1000000:
    		j += 1
    		print(i)
    if j == 0:
    	print('NA')
#print a # [a1, a2, a3, ..., aN]

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys

while True:
    n = int(input())
    j = 0
    if n == 0:
        break
    salesmap = [0 for i in range(0,4001)]
    for i in range(n):
    	a = input().split()
    	salesmap[int(a[0])] += int(a[1])*int(a[2])
    for i in range(1,4001):
    	if salesmap[i] >= 1000000:
    		j += 1
    		print(i)
    if j == 0:
    	print('NA')
#print a # [a1, a2, a3, ..., aN]

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys

while True:
	n = int(input())
	j = 0
	if n == 0:
		break
	salesmap = [0 for i in range(0,4001)]
	for i in range(n):
		a = input().split()
		salesmap[int(a[0])] += int(a[1])*int(a[2])
	for i in range(1,4001):
		if salesmap[i] >= 1000000:
			j += 1
			print(str(i))
	if j == 0:
		print('NA')
#print a # [a1, a2, a3, ..., aN]

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    data = [0] * 4001
    for _ in range(n):
        e, p, q = map(int, input().split())
        data[e] += p*q
        
    for i in range(1, 4001):
        if data[i] >= 1000000:
            print(i)

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    data = [0] * 4001
    for _ in range(n):
        e, p, q = map(int, input().split())
        data[e] += p*q

    flag = True
    for i in range(1, 4001):
        if data[i] >= 1000000:
            print(i)
            flag = False
    if flag:
        print("NA")

Submission status: Wrong Answer

Solution code:
import sys

l = []
temp = []
d = dict()
for input in sys.stdin:
    l.append(input)
i = 0
while(i < len(l)):
    j = i+1
    while(j <= int(l[i])+int(i)):
        temp = l[j].split()
        if(d.get(int(temp[0]),0) == 0):
            d[int(temp[0])] = int(temp[1])*int(temp[2])
        else:
            d[int(temp[0])] += int(temp[1])*int(temp[2])
        j += 1
    j = 0
    for key,value in d.items():
        if(value >= 1000000):
            print key
            j += 1
    if(j == 0 and int(l[i]) != 0):
        print 'NA'
    d.clear()
    i += (int(l[i])+1)

Submission status: Wrong Answer

Solution code:
while 1:
 a={};b=0
 n=int(input())
 if n==0:break
 for _ in[0]*n:
  e,p,q=map(int,input().split())
  a.setdefault(e,0);a[e]+=p*q
 for e in a:
  if a[e]>=1e6:print(e);b=1
 if b:print('NA')

Submission status: Wrong Answer

Solution code:
while True:
  a =int(input())
  if a ==0:break
  hito =[]
  t =0
  for i in range(a):
    hoge = map(int,raw_input().split())
    if hoge[1]*hoge[2] >= 1000000:
      print hoge[0]
      t+=1
  if t == 0: print "NA"

Submission status: Wrong Answer

Solution code:
while True:
  count = int(input())
  if count == 0: break
  ans,v = 0,0
  for i in range(count):
    a,b,c = map(str,raw_input().split())
    v = int(b)*int(c)
    v= str(v)
    if len(v) >= 7:
      print a
      ans +=1
  if ans == 0:
    print "NA"

Submission status: Wrong Answer

Solution code:
while True:
  count = int(input())
  if count == 0: break
  ans,v,t = 0,0,[]
  for i in range(count):
    a,b,c = map(str,raw_input().split())
    v = int(b)*int(c)
    v= str(v)
    if len(v) >= 7:
      if a in t:
        continue
      else:
        print a
        t.append(a)
        ans +=1
        continue
  if ans == 0:
    print "NA"
    continue
  else: continue

Submission status: Wrong Answer

Solution code:
def nz(a):
	if a is None:
		return 0
	else: return a

while 2 > 1:
	line_num = int(raw_input())
	if line_num < 1:
		break
	mydict = {}
	for n in range(line_num):
		dat = map(int, raw_input().split(" "))
		mydict[dat[0]] = nz(mydict.get(dat[0])) + dat[1] * dat[2]
	mylist = []
	flg = 0
	for n in mydict.keys():
		if mydict[n] > 999999:
			print n
			flg = 1
	if flg == 0:
		print 'NA'

Submission status: Wrong Answer

Solution code:
def nz(a):
	if a is None:
		return 0
	else: return a

disp = ''

while 2 > 1:
	line_num = int(raw_input())
	if line_num < 1:
		break
	mydict = {}
	for n in range(line_num):
		dat = map(int, raw_input().split(" "))
		mydict[dat[0]] = nz(mydict.get(dat[0])) + dat[1] * dat[2]
	mylist = []
	flg = 0
	for n in mydict.keys():
		if mydict[n] > 999999:
			disp = disp + str(n) + "\n"
			flg = 1
	if flg == 0:
		disp += 'NA'

print disp

Submission status: Wrong Answer

Solution code:
def nz(a):
	if a is None:
		return 0
	else: return a

while 2 > 1:
	line_num = int(raw_input())
	if line_num < 1:
		print 'NA'
		break
	mydict = {}
	for n in range(line_num):
		dat = map(int, raw_input().split(" "))
		mydict[dat[0]] = nz(mydict.get(dat[0])) + dat[1] * dat[2]
	mylist = []
	flg = 0
	for n in mydict.keys():
		if mydict[n] > 999999:
			print str(n)
			flg = 1
	if flg == 0:
		print 'NA'

Submission status: Wrong Answer

Solution code:
while(True):
    x = int(raw_input())
    if x==0 : break
    flag=0

    for i in range(x):
        list = [int(y) for y in (raw_input()).split()]
        if(list[1]*list[2]>=1000000):
            print list[0]
            flag=1
    if flag==0:
        print 'NA'

Submission status: Wrong Answer

Solution code:
while(True):
    x = int(raw_input())
    if x==0 : break
    flag=0

    for i in range(x):
        list = [int(y) for y in (raw_input()).split()]
        if(list[1]*list[2]>999999):
            print list[0]
            flag=1
    if flag==0:
        print 'NA'

Submission status: Wrong Answer

Solution code:
while True:
    NA = True
    n = int(raw_input())
    if n == 0: break
    for i in range(n):
        data = raw_input().split()
        if int(data[1]) * int(data[2]) >= 1000000:
            NA = False
            print data[0]
    if NA: print "NA"

Submission status: Wrong Answer

Solution code:
while True:
    NA = True
    n = int(raw_input())
    if n == 0: break
    for i in range(n):
        data = map(int, raw_input().split())
        if data[1] * data[2] >= 1000000:
            NA = False
            print data[0]
    if NA: print "NA"