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;
typedef long long LL;
int gcd(int a,int b){if (b == 0) return a; return gcd(b , a%b);}
int lcm(int a, int b){ return a/gcd(a,b)*b;}
int a[10005];
    int n,m;
int low(int val){
    int l = 0,r = n-1;
    while (l!=r) {
        int mid = (r + l) >> 1;
        if (a[mid] > val) r = mid;
        else l = mid + 1;
    }
    return l;
}
int main(){
    while (scanf("%d%d",&n,&m) == 2 && (n || m)) {
        memset(a, 0, sizeof(a));
        for (int i=0; i<n; i++)
            cin >> a[i];
        LL now = 0,ans = 0;
        sort (a, a+n);
        for (int i=0; i<n; i++) {
            if(m <= a[i]) continue;
            int x = low(m - a[i]);
            if (a[x] < m - a[i] && x != n-1) continue;
            if (x != n-1) x--;
            if (x == i) continue;
          //  if (x-1 == i || (x == n-1 && x == i)) continue;

            if (a[x] == m - a[i]) {
                now = a[i] + a[x];
            }else{
                now = a[i] + a[x-1];
            }
            if (now <= m && ans < now) {
                ans = now;
            }
        }
        if (ans == 0) printf("NONE\n");
        else printf("%lld\n",ans);
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  int m;
  int sum=0;
  int flg=0;
  cin >> n >> m;
  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)
	{
	  sum = a[i]+a[j];
	  flg = 0;
	} 
      else
	{
	  flg=1;
	}
    }
  }
  if(flg==0)
    {
      cout << sum << endl;
    }
  if(flg==1)
    {
      cout << "NONE" << endl;
    }
}

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

	static int n, m, ans;
	static int a[100000];
void input() {
	cin >> n;
	cin >> m;
	for (int i = 1; i < n + 1; i++) {
		cin >> a[i];
	}
}
void pre() {
	ans = 0;
}
void operate() {
	for (int i=1;i<n+1;i++) 
		for (int j = i + 1; j < n + 1; j++) {
			if ((a[i] + a[j] <= m)&(a[i] + a[j] > ans)) ans = a[i] + a[j];
		}
}
void output() {
	if (ans == 0) cout << "NONE";
	else cout << ans;
}
int main() {
	while (true) {
		input();
		if (n == 0)return 0;
		pre();
		operate();
		output();
	}
	return(0);
}

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

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

    for(;;) {
        cin >> num;
        cin >> lim;
        if(num == 0 && lim == 0) {
            return 0;
        }
        for(i = 0; i < num; i++) {
            cin >> 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) {
            cout << "NONE\n";
        }
        else {
            cout << max << "\n";
        }
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  vector<int> a;
  int n,m,b,max=0;
  while(n!=0 && m!=0){
    max=0;
    cin>>n>>m;
    vector<int> a(n);
    for(int i=0;i<n;i++){
      cin>>b;
      a.push_back(b);
    }
  
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
	if(j!=k){
	  if(max<a[j]+a[k] && a[j]+a[k]<=m){
	    max=a[j]+a[k];
	    cout<<max<<"\n";
	  }
	}
      }
    }
    if(max==0 && n!=0&&m!=0){
      cout<<"NONE"<<endl;
    }else if(n!=0&&m!=0){
      cout<<max<<endl;
    }
  }
}

C++: #include <stdio.h>
int max(int a, int b){
    if(a > b){
        return a;
    }
    else{
        return b;
    }
}

int main(){
    while(1 == 1){
	int n, m, i, j, k, tmp;
	int result = 0;
	scanf("%d%d", &n, &m);
	if(n == 0 && m == 0)
	    break;
	int a[n];
	for (i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 0; i < n; i++){
	    for (j = i + 1; j < n; j++){
	        tmp = a[i] + a[j];
	        if(tmp <= m){
	            result = max(result, tmp);
	        }
	    }
	}
	if(result != 0){
	    printf("%d\n", result);
	}
	else{
	printf("NONE\n");
    }
    }
	return 0;	
}

C++: #include <iostream>

using namespace std;

int main(void){
  while(1){
    int n , m;
    cin >> n;
    cin >> m;
    if(n == 0 && m == 0){
      return 0;
    }

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

    int sum[n][n];

    for(int i = 0 ; i < n ; i ++){
      for(int j = 0 ; j < n ; j++){
        if(i != j){ sum[i][j] = a[i] + a[j]; }
        else{ sum[i][j] = -1000; }
      }
    }

    int max = -1000;

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

    if(max = -1000){
      cout << "NONE" << endl;
    }else{
      cout << max;
    }
  }

}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  vector<int> a(1000);
  int n,m,b,max=0;
  while(n!=0 && m!=0){
    max=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
      cin>>b;
      a[i]=b;
    }
  
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
	if(j!=k){
	  if(max<a[j]+a[k] && a[j]+a[k]<=m){
	    max=a[j]+a[k];
	  }
	}
      }
    }
    if(max==0 && n!=0&&m!=0){
      cout<<"NONE"<<endl;
    }else if(n!=0&&m!=0){
      cout<<max<<endl;
    }
  }
}