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 <bits/stdc++.h>
using Int = int64_t;

int main() {
   for(;;) {
      Int n, m;
      std::cin >> n >> m;
      if( n == 0 && m == 0 ) break;
      std::vector<Int> xs(n);
      for(Int i = 0; i < n; ++i) {
         std::cin >> xs[i];
      }
      Int res = 0;
      for(Int i = 0; i < n; ++i) {
         for(Int k = i + 1; k < n; ++k) {
            Int t = xs[i] + xs[k];
            if( t <= m && res < t ) {
               res = t;
            }
         }
      }
      if( res == 0 ) {
         std::cout << "NONE" << std::endl;
      }
      else {
         std::cout << res << std::endl;
      }
   }
}

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

typedef long long lint;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n, m;
    while(cin >> n >> m, n){
        vector<int> a(n);
        rep(i, n){
            cin >> a[i];
        }
        SORT(a);
        if(a[0] + a[1] > m){
            cout << "NONE" << endl;
            continue;
        }
        int ans = 0;
        rep(i, n){
            int k = upper_bound(a.begin(), a.end(), m - a[i]) - a.begin();
            k--;
            if(i == k){
                k--;
            }
            if(k < 0){
                continue;
            }
            ans = max(ans, a[i] + a[k]);
        }
        cout << ans << 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 a[1000];
    for(int i=0; i<n; i++){
      cin >> a[i];
    }

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

    if(sum!=-1){
      cout << sum << endl;
    }else{
      cout << "NONE" << endl;
    }
  }

  return 0;
}

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

int main() {
  int n, m;
  while (true) {
    cin >> n >> m;
    if (n==0 && m==0) {
      break;
    }
    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;
}

C++: #include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
int good;
int mx;
bool correct;
int ans;
int main() {
    while(1) {
        correct = 0;
        ans = 0;
        cin >> good >> mx;
        if(good == 0) break;
        vector<int> p(good);
        for(int i= 0; i<good;i++) cin >> p[i];
        sort(p.begin(), p.end());
        for(int i = good-1; i >= 0;i--) {
            for(int j = 1;j <= i;j++) {
                if(p[i] + p[i-j] <= mx && ans < p[i] + p[i-j]) {
                    ans = p[i] + p[i-j];
                }
            } 
        }
        if(ans == 0) cout << "NONE" << endl;
        else cout << ans << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main(){
  int n, m;

  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;

  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

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

  if(max != 0)
    cout << max << endl;
  else
    cout << "NONE" << endl;
  return 0;
}

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

int main(void){
    int n, m;
    while (cin >> n >> m) {
        if (n == 0) return 0;
        
        int a[1010];
        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++) {
                if (a[i] + a[j] <= m) ans = max(a[i] + a[j], ans);
            }
        }
        if (ans == 0) cout << "NONE" << endl;
        else cout << ans << endl;
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n,m;
int a[100010];

int main(){
  while(1){
    cin>>n>>m;
    if(n==0)break;
    rep(i,n)cin>>a[i];
    int res=-1;
    rep(i,n)rep(j,i){
      if(a[i]+a[j]<=m)maxch(res,a[i]+a[j]);
    }
    if(res==-1)cout<<"NONE"<<endl;
    else cout<<res<<endl;
  }
  return 0;
}