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 "stdafx.h"
#include <iostream>
using namespace std;

int main(void) {
	int n, m;
	int i, j;
	int sum = 0, max = 0;
	int price[1000];

	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0)break;

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

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

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

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    while(N){
        vector<ll> V(N);
        rep(i,0,N)cin >> V[i];
        ll maxi = 0;
        rep(i,0,N)rep(j,i+1,N){
            if(V[i] + V[j] <= M)maxi = max(maxi, V[i] + V[j]);
        }
        if(maxi == 0)cout << "NONE" << endl;
        else cout << maxi << endl;
        cin >> N >> M;
    }
}

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

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

C++: #include<stdio.h>
#include<algorithm>
using namespace std;

int main()
{
    int m, n, a[1005];
    while(1)
    {
        scanf("%d%d",&n,&m);
        if(n==0) return 0;

        for(int i=1;i<=n;i++)
        {
            scanf("%d",a+i);
        }

        int maxsum=0;
        for(int i=1;i<n;i++)
            for(int j=i+1;j<=n;j++)
        {
            int sum=a[i]+a[j];
            if(sum>maxsum&&sum<=m)
            {
                maxsum=sum;
            }
        }
        if(maxsum==0) printf("NONE\n");
        else printf("%d\n",maxsum);
    }
}

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

C++: 
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n,m,add=0,temp;
	int a[1000];
	bool judge = false;

	start:

	scanf("%d %d", &n,&m);

	if (n == 0 && m==0 ) {
		goto finish;
	}

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

	for (int i = 0; i < n-1; i++) {
		for (int j = i+1; j < n; j++) {
			if (a[i] < a[j]) {
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	}

	for (int i = 0; i < n - 1; i++) {
		//if (judge == true) break;
		for (int j = n-1; j != i; j--) {
			if (m < a[i] + a[j]) {
				break;
			}
			else {
				if(add<a[i]+a[j]) add = a[i] + a[j];
				//judge = true;
			}
		}
	}
	if (add == 0) {
		cout << "NONE" << endl;
	}
	else {
		cout << add << endl;
	}

	n = 0;
	m = 0;
	add = 0;
	judge = false;

	goto start;

	finish:

	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


int n,m;
vector<int> a;
int ans,xx;

int main(){
  scanf ("%d %d",&n,&m);
  while(n){
    ans=0;
    a.assign(n,0);
    for(int t=0;t<n;++t){
      scanf ("%d",&a[t]);
    }
    sort(a.begin(),a.end());
    for(int p=0;p<n&&a[p]<m;++p){
      for(int q=p+1;q<n&&xx<=m;++q){
        xx=a[p]+a[q];
        if(ans<xx&&xx<=m){
          ans=xx;
        }
      }
      xx=0;
    }
    if(ans==0){
      printf("NONE\n");
    }
    else{
      printf("%d\n",ans);
    }
    scanf ("%d %d",&n,&m);
  }
}

C++: #include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		ll m;cin>>m;
		ll a[1001];
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		ll ans=-1;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j)continue;
				//if(a[i]==a[j])continue;
				if(a[i]+a[j]>m)continue;
				ans=max(ans,a[i]+a[j]);
			}
		}
		if(ans==-1)cout<<"NONE";
		else cout<<ans;
		cout<<"\n";
	}
}

C++: #include <iostream>
using namespace std;
int main(){
    while(true){
    int n,m;
    cin>>n>>m;
    if(n==0&&m==0){
        return 0;
    }
    int a[1000];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int sum=-1;
    for(int i=0;i<n;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;
    }
    }
}