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 <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out






int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////

int n,m;
while(cin>>n){
    cin >> m;
    if(m == 0){
        break;
    }
    int b=0,ans=0;

int a[n];
int c = 0;
rep(i,n){
    cin >> a[i];
}

for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
      b = (a[i]+a[j]);
      if(m>=b){
         ans = max(b,ans);
            
          
          
          
      }
      

  }
}
       if(ans==0){
              cout << "NONE" << endl;}
       else{
           cout << ans << endl;
       }

}

///////////////////////////////////////////////////////
return 0;}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  int i,n,m,j;
  vector<int> ans;
  while(1){
    cin>>n>>m;
    if(n==0 && m==0) break;
    vector<int> item(n);
    for(i=0; i<n; i++){
      cin>>item[i];
    }
    int max=0;
    int sum;
    for(i=0; i<n; i++){
      for(j=i; j<n; j++){
	sum=0;
	sum=item[i]+item[j];
	if(sum>max && sum<=m){
	  max=sum;
	}
      }
    }
    if(max==0){
      ans.push_back(-1);
    }else{
    ans.push_back(max);
    }
  }
  for(i=0; i<ans.size(); i++){
    if(ans[i]==-1){
      cout<<"NONE";
    }else{
      cout<<ans[i];
    }
    cout<<endl;
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	while(true){
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0){
			break;
		}
		int a[2000];
		for(int i = 0; i < n; i++){
			cin >> a[i];
		}
		sort(a, a + n);
		int ans = 0;
		int j = n - 1;
		bool flag = true;
		for(int i = 0; i < n; i++){
			while(true){
				if(j <= i){
					if(i == 0){
						flag = false;
					}
					break;
				}
				if(a[i] + a[j] <= m){
					ans = max(ans, a[i] + a[j]);
					break;
				}
				j--;
			}
		}
		if(flag){
			cout << ans << endl;
		}else{
			cout << "NONE" << endl;
		}
	}
	
	
	return 0;
	
}

C++: /*Problem sennobushige 16D8104015E 18.5.16*/
#include <iostream>
#define N 100000

int main(){
  int n=1,max;
  int A[N]={0},k=0;


  while(n!=0){
    int p=0,tmp;
    std::cin>>n;
    int a[n]={0};
    std::cin>>max;
    if(n==0)break;
    for(int i=0;i<n;i++){
      std::cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	tmp=a[i]+a[j];
	if(tmp>=A[k]&&tmp<=max){
	  A[k]=tmp;
	  p++; 
	}
      }
    }
    if(p==0) A[k]=0;
    k++;
    //if(p!=0) std::cout<<sum<<"\n";
    //else std::cout<<"NONE\n";
  }
  for(int i=0;i<k;i++){
    if(A[i]!=0){
      std::cout<<A[i]<<"\n";
    }else{
      std::cout<<"NONE\n";
    }
  }



}



/*実行結果
[16D8104015E@ise6bc jisen]$ ./Problem_A
3 45 
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
40
10
99
NONE
20
*/

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

int main(){

    int n,m,price,sum,temp_sum;
    sum=0;
    std::vector<int> prices;

    n=m=1;

    while(std::cin>>n>>m,n||m){

    std::cin>>n>>m;

    for(int i=0;i<n;i++){
        std::cin>>price;
        prices.push_back(price);
    }

    for(int i=0;i<n;i++){
        for(int j=j+1;j<n;j++){
            temp_sum = prices[i]+prices[j];
            if(sum<temp_sum&&temp_sum<m) sum=temp_sum;
        }
    }

    if(sum==0){
        std::cout<<"NONE"<<std::endl;
    }
    else{
        std::cout<<sum<<std::endl;
    }

}

    return 0;

}

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

int main() {
    int n, m, a;
    int item[1000];
    while (cin >> n >> m, cin.ignore(), n||m) {
        int sum  = -1;
        for (int i = 0; i < n; ++i) {
            cin >> a;
            item[i] = a;
        }

        for (int i = 0; i < n-1; ++i) {
            for (int j = i; j < n; ++j) {
                int tmp = item[i] + item[j];
                if (tmp <= m && tmp > sum) {
                    sum = tmp;
                }
            }
        }

        if (sum < 0) cout << "NONE" << endl;
        else cout << sum << endl;
    }
    return 0;
}