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 namespace std;
int a[1000];
int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0)
      break;
    for (int i = 0; i < n; i++)
      cin >> a[i];
    sort(a, a + n);
    if (a[n - 1] + a[n - 2] < m) {
      cout << a[n - 1] + a[n - 2] << endl;
      continue;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int p = lower_bound(a, a + n, m - a[i]) - a;
      while (p >= 0 && a[i] + a[p] > m || i == p)
        p--;
      if (p > 0 && a[i] + a[p] > ans)
        ans = a[i] + a[p];
    }
    if (ans)
      cout << ans << endl;
    else
      cout << "NONE" << endl;
  }
}

C++: #include <iostream>


int main(void){
  int n,m,tmp,cnt,max;
  std::cin>>n;
  std::cin>>m;
  int a[n];
  while(n!=0 && m!=0){
    a[n]={0};
    for(int i=0;i<n;i++){
      std::cin>>a[i];
    }
    max=a[0]+a[1];
    cnt=0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	tmp=a[i]+a[j];
	if(tmp<=m && tmp>=max){
	  max=tmp;
	  cnt=1;
	}
      }
    }
    if(cnt==0 && max>>m){
      std::cout<<"NONE\n";
    }else{
      std::cout<<max<<"\n";
    }
    std::cin>>n;
    std::cin>>m;    
  }
  std::cout<<("終わり\n");
  return 0;

C++: 
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


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

C++: #include <iostream>

int main(void)
{
    int i, j, num, lim, price[1000], temp, max;

    for(;;) {
        scanf("%d %d", num, lim);
        if(num == 0 && lim == 0) {
            return 0;
        }
        for(i = 0; i < num; i++) {
            scanf("%d", price[i]);
        }
        max = 0;
        for(i=0; i < num - 1; i++) {
            for(j = i + 1; j < num; j++) {
                temp = price[i] + price[j];
                if(temp > max && temp <= lim) {
                    max = temp;
                }
            }
        }
        if(max == 0) {
            printf("NONE\n");
        }
        else {
            printf("%d\n", max);
        }
    }
    return 0;
}