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 <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n,m;
  while(cin>>n>>m,n|m){
    vector<int> data(n);
    rep(i,n) cin>>data[i];

    int ans=0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if(data[i]+data[j]<=m)ans=max(ans,data[i]+data[j]);
      }
    }
    if(ans!=0)cout<<ans<<endl;
    else cout<<"NONE"<<endl;
  }
  return 0;
}

C++: #include <iostream>
#define N 100000

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


  while(1){
    int p=0,sum=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;i++){
      for(int j=i+1;j<n;j++){
	tmp=a[i]+a[j];
	if(tmp>=sum&&tmp<=max){
	  sum=tmp;
	  p++; 
	}
      }
    }
    if(p!=0) {
      A[k]=sum;
      k++;
    }else {
      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";
    }
  }



}

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

void solve(int n, int m){
	vector<int> a;
	vector<int> v;
	for(int i=0; i<n; ++i){
		int t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	for(int i=0; i<n; ++i)
		for(int j=i+1; j<n; ++j){
			if(a[i] + a[j] <= m){
				v.push_back(a[i] + a[j]);
			}
		}
	if(v.size() == 0) cout << "NONE\n";
	else{
		sort(v.begin(), v.end());
		cout << v[v.size()-1] << "\n";
	}
	return;
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int n, m;
		cin >> n >> m;
		if(n == 0) return 0;
		solve(n, m);
	}
}

C++: #include<iostream>

int main()
{
  int n=1,m=1;
  int x[1000];
  int cnt=0;
  int max;

  while(n>0&&m>0){
    max=0;

    std::cin>>n>>m;
    if(n==0&&m==0) max=-1;
    int a[n+1];

    for(int i=1;i<n+1;i++){
      std::cin>>a[i];
    }

    for(int i=1;i<n;i++){
      for(int j=i+1;j<n+1;j++){
	int y=a[i]+a[j];
	if(max<y&&y<=m) max=a[i]+a[j];
      }
    }

    x[cnt]=max;

    cnt++;
  }

  for(int i=0;i<cnt;i++){
    if(x[i]==0){
      std::cout<<"NONE\n";
    }else if(x[i]>0){
      std::cout<<x[i]<<"\n";
    }else{
      break;
    }
  }

  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
using vi = vector<int>;
using vvi = vector<vi>;

signed main(){
  int n,m;
  while(cin >> n >> m, n){
    vi a(n); rep(i,n) cin >> a[i];
    int ans = 0;
    rep(i,n) rep(j,n){
      if(i == j) continue;
      if(a[i] + a[j] <= m) ans = max(ans, a[i]+a[j]);
    }
    if(ans)
      cout << ans << endl;
    else
      cout << "NONE\n";
  }
}

C++: #include <iostream>
#define N 1000000

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";
    }
   
  }



}

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

int main() {
  int n, m;
  while (true) {
    scanf("%d %d", &n, &m);
    if (n==0 && m==0) {
      break;
    }
    vector<int> a(n);
    for (int i=0; i<n; i++) {
      cin >> a[i];
    }
    int ans = -INT_MAX;
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
	if (i!=j && a[i]+a[j]<=m) {
	  ans = max(ans,a[i]+a[j]);
	}
      }
    }
    if (ans<0) {
      printf("NONE\n");
    } else {
      printf("%d\n", ans);
    }
  }
  return 0;
}