Language: C++

using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var pmax = 1000000;
			var primes = new bool[pmax+1];
			var maxsq = (int)Math.Sqrt(pmax);
			for(var i=2;i<=pmax;i++)
				primes[i]=true;
			for(var i=2;i<=maxsq;i++)
				if(primes[i])
					for(var j=i*2;j<pmax;j+=i)
						primes[j]=false;
			List<int> num;
			while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){
				var menu = new List<int>();
				var order = new bool[num[1]+1];
				var max = 0;
				for(var i=0;i<num[0];i++)
					menu.Add(int.Parse(Console.ReadLine()));
				order[0]=true;
				for(var i=0;i<=num[1];i++)
					if(order[i]){
						menu.ForEach(x=>{if(i+x<=num[1])order[i+x]=true;});
						if(primes[i])
							max=i;
					}
				Console.WriteLine(max<1?"NA":"{0}",max);
			}
			
		}
	}
}

Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:9:23: error: expected ':' before 'static'
    9 |                 public static void Main(string[] args)
      |                       ^~~~~~~
      |                       :
a.cc:9:41: error: 'string' has not been declared
    9 |                 public static void Main(string[] args)
      |                                         ^~~~~~
a.cc:9:50: error: expected ',' or '...' before 'args'
    9 |                 public static void Main(string[] args)
      |                                                  ^~~~
a.cc:38:10: error: expected ';' after class definition
   38 |         }
      |          ^
      |          ;
a.cc: In static member function 'static void AOJ::Program::Main(int*)':
a.cc:11:25: error: 'var' was not declared in this scope
   11 |                         var pmax = 1000000;
      |                         ^~~
a.cc:12:29: error: expected ';' before 'primes'
   12 |                         var primes = new bool[pmax+1];
      |                             ^~~~~~
a.cc:13:29: error: expected ';' before 'maxsq'
   13 |                         var maxsq = (int)Math.Sqrt(pmax);
      |                             ^~~~~
a.cc:14:33: error: expected ';' before 'i'
   14 |                         for(var i=2;i<=pmax;i++)
      |                                 ^
a.cc:14:37: error: 'i' was not declared in this scope
   14 |                         for(var i=2;i<=pmax;i++)
      |                                     ^
a.cc:14:40: error: 'pmax' was not declared in this scope
   14 |                         for(var i=2;i<=pmax;i++)
      |                                        ^~~~
a.cc:15:33: error: 'primes' was not declared in this scope
   15 |                                 primes[i]=true;
      |                                 ^~~~~~
a.cc:16:33: error: expected ';' before 'i'
   16 |                         for(var i=2;i<=maxsq;i++)
      |                                 ^
a.cc:16:37: error: 'i' was not declared in this scope
   16 |                         for(var i=2;i<=maxsq;i++)
      |                                     ^
a.cc:16:40: error: 'maxsq' was not declared in this scope
   16 |                         for(var i=2;i<=maxsq;i++)
      |                                        ^~~~~
a.cc:17:36: error: 'primes' was not declared in this scope
   17 |                                 if(primes[i])
      |                                    ^~~~~~
a.cc:18:49: error: expected ';' before 'j'
   18 |                                         for(var j=i*2;j<pmax;j+=i)
      |                                                 ^
a.cc:18:55: error: 'j' was not declared in this scope
   18 |                                         for(var j=i*2;j<pmax;j+=i)
      |                                                       ^
a.cc:18:57: error: 'pmax' was not declared in this scope
   18 |                                         for(var j=i*2;j<pmax;j+=i)
      |                                                         ^~~~
a.cc:20:25: error: 'List' was not declared in this scope
   20 |                         List<int> num;
      |                         ^~~~
a.cc:20:30: error: expected primary-expression before 'int'
   20 |                         List<int> num;
      |                              ^~~
a.cc:21:32: error: 'num' was not declared in this scope; did you mean 'enum'?
   21 |                         while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){
      |                                ^~~
      |                                enum
a.cc:21:38: error: 'Console' was not declared in this scope
   21 |                         while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){
      |                                      ^~~~~~~
a.cc:21:75: error: 'x' was not declared in this scope
   21 |                         while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){
      |                                                                           ^
a.cc:21:77: error: expected primary-expression before '>' token
   21 |                         while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){
      |                                                                             ^
a.cc:21:78: error: expected primary-expression before 'int'
   21 |                         while((num = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList())[0]>0){
      |                                                                              ^~~
a.cc:22:37: error: expected ';' before 'menu'
   22 |                                 var menu = new List<int>();
      |                                     ^~~~
a.cc:23:37: error: expected ';' before 'order'
   23 |                                 var order = new bool[num[1]+1];
      |                                     ^~~~~
a.cc:24:37: error: expected ';' before 'max'
   24 |                                 var max = 0;
      |                                     ^~~
a.cc:25:41: error: expected ';' before 'i'
   25 |                                 for(var i=0;i<num[0];i++)
      |                                         ^
a.cc:25:45: error: 'i' was not declared in this scope
   25 |                                 for(var i=0;i<num[0];i++)
      |                                             ^
a.cc:26:41: error: 'menu' was not declared in this scope
   26 |                                         menu.Add(int.Parse(Console.ReadLine()));
      |                                         ^~~~
a.cc:26:50: error: expected primary-expression before 'int'
   26 |                                         menu.Add(int.Parse(Console.ReadLine()));
      |                                                  ^~~
a.cc:27:33: error: 'order' was not declared in this scope
   27 |                                 order[0]=true;
      |                                 ^~~~~
a.cc:28:41: error: expected ';' before 'i'
   28 |                                 for(var i=0;i<=num[1];i++)
      |                                         ^
a.cc:28:45: error: 'i' was not declared in this scope
   28 |                                 for(var i=0;i<=num[1];i++)
      |                                             ^
a.cc:30:49: error: 'menu' was not declared in this scope
   30 |                                                 menu.ForEach(x=>{if(i+x<=num[1])order[i+x]=true;});
      |                                                 ^~~~
a.cc:30:64: error: expected primary-expression before '>' token
   30 |                                                 menu.ForEach(x=>{if(i+x<=num[1])order[i+x]=true;});
      |                                                                ^
a.cc:30:65: error: expected primary-expression before '{' token
   30 |                                                 menu.ForEach(x=>{if(i+x<=num[1])order[i+x]=true;});
      |                                                                 ^
a.cc:31:52: error: 'primes' was not declared in this scope
   31 |                                                 if(primes[i])
      |                                                    ^~~~~~
a.cc:32:57: error: 'max' was not declared in this scope
   32 |                                                         max=i;
      |                                                         ^~~
a.cc:34:51: error: 'max' was not declared in this scope
   34 |                                 Console.WriteLine(max<1?"NA":"{0}",max);
      |                                                   ^~~