Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n, m := io.NextInt(), io.NextInt()
		if n == 0 {
			break
		}
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = io.NextInt()
		}
		ans := 0
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				if a[i]+a[j] <= m {
					ans = intMax(a[i]+a[j], ans)
				}
			}
		}
		if ans == 0 {
			io.Println("NONE")
		} else {
			io.Println(ans)
		}
	}
}

func intMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  int n=1;
  int m=1;
  int sum=0;
  int flg=0;
  while(n!=0&&m!=0)
    {
      cin >> n >> m;
      if(n==0&&m==0)
	{
	  break;
	}
      vector<int> a(n);
      for(int i=0;i<n;i++)
	{
	  cin >> a[i];
	}
      for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
	  if(a[i]+a[j]>sum && a[i]+a[j]<=m && i!=j)
	    {
	      sum = a[i]+a[j];
	      flg = 0;
	    } 
	  else
	    {
	      if(sum==0)
		{
		  flg=1;
		}
	    }
	}
      }
      if(flg==0)
	{
	  cout << sum << endl;
	}
      if(flg==1)
	{
	  cout << "NONE" << endl;
	}
    }
  return 0;
}

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

int main(){
	while(true){
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0){
			break;
		}
		int items[n];
		int currentMax = -1;
		for(int i = 0; i < n; i++){
			cin >> items[i];
			if(items[i] < m && i != 0){
				for(int j = 0; j < i + 1; j++){
					if(currentMax < items[i] + items[j] && m >= items[i] + items[j]){
						currentMax = items[i] + items[j];
					}
				}
			}
		}
		if(currentMax != -1){
			cout << currentMax << endl;
		}else{
			cout << "NONE" << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
int main(){
  while(1){
    int n,m,tmp=0;
    int max=-1;
    int A[1000]={0};
    std::cin>>n>>m;
    for(int i=0;i<n;i++){
      std::cin>>A[i];
    }
    if(A[0]==0&&A[1]==0){
      break;
    }
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	tmp=A[i]+A[j];
	if(tmp>max&&tmp<=m){
	  max=tmp;
	}
      }
    }
    if(max>0){
      std::cout<<max<<"\n";
    }else{
      std::cout<<"NONE\n";
    }
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n, m;
	while (cin >> n >> m) {
		if (n + m == 0)break;
		vector<int> v(n);
		for (int i = 0; i < n; i++)cin >> v[i];
		int ans = -1;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (v[i] + v[j] <= m)ans = max(ans, v[i] + v[j]);
			}

		}
		if (ans == -1)cout << "NONE" << endl;
		else cout << ans << endl;
	}

}

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

int main(void){
    
while(true){
    int n,m;
    int kakaku[1000000];
    cin >> n >> m ;
    if(n==0&&m==0)break;
    
    for(int i=0;i<n;i++){
        cin >> kakaku[i];
    }
        int ans=-1;
        for (int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if (i!= j ){
                 if(kakaku[i]+kakaku[j] <= m)
                     ans=max(ans, kakaku[i]+ kakaku[j]);
            }
         }
}
        if(ans==-1)
            cout << "NONE" << endl;
        else
            cout << ans << endl;
    
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int a[1005];

int main(){
  
  while(1){
  
    int n, m;
    cin>>n>>m;
    
    if( !n && !m ) break;
    
    for(int i=0;i<n;i++) cin>>a[i];
  
    int ans = 0;
  
    for(int i=0;i<n;i++){
    
      for(int j=i+1;j<n;j++){
      
	int sum = a[i] + a[j];
      
	if( sum <= m ) ans = max( ans, sum );
      
      }
    
    }
  
    if( ans == 0 ) cout<<"NONE"<<endl;
    else cout<<ans<<endl;

  }
  
  return 0;
}

C++: #include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int, in){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1;
	range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

using V = vector<int>;

int main() {
	for (int n, m; n = in(), m = in();) {
		V v(n);
		for (int &a: v)
			a = in();
		sort(v.begin(), v.end());
		int r{0};
		for (auto i{v.begin()}, e{v.end() - 1}; i != e && r < m; i++) {
			while (*i + *e > m && i != e)
				e--;
			if (i == e)
				break;
			r = max(r, *i + *e);
		}
		if (r)
			outl(r);
		else
			outl("NONE");
	}
}