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<stdio.h>

int main()
{
	int n=1,m=1;
	int obj[1000],max,min,temp=0;
	while(1)
	{
		max=0;
		min=1000000;
		
		scanf("%d",&n);
		scanf("%d",&m);
		
		if(n==0 && m==0) break;
		
		for(int i=0;i<n;i++)
		{
			scanf("%d",&obj[i]);
		}
		for(int i=0;i<n;i++)
		{
			for(int t=i+1;t<n;t++)
			{
				temp=obj[i]+obj[t];
				if(temp>max && temp<=m) max=temp;
				if(temp<min) min=temp;
			}
		}
		if(min>m) printf("NONE\n");
		else printf("%d\n",max);
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int n,m;
int a[1005];
bool compare(int a,int b)
{
  return a<b; //升序排列，如果改为return a>b，则为降序
}
int main()
{
    cin>>n>>m;
    while(n!=0||m!=0)
    {
        int mi = 1000000000;
        for(int i = 0;i<n;i++)
            scanf("%d",a+i);
        sort(a,a+n,compare);
        for(int i = 0;i<n;i++)
        {
            if(a[i]>=m)
                break;
            int pos = lower_bound(a, a +n, m-a[i]) - a;

            if(a[i]+a[pos]==m)
            {
                if(i != pos||pos==n-1||a[pos+1]==a[pos])
                {mi=0;
                break;}

            }
            if(pos==0)
                continue;
            int tmp = m-a[i]-a[pos-1];
            mi=tmp<mi?tmp:mi;
        }
        if(mi == 1000000000)
            cout<<"NONE"<<endl;
        else
            cout<<m-mi<<endl;
        cin>>n>>m;
    }

    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m,b,max=0;
  while(n!=0 && m!=0){
    vector<int> a;
    max=0;
    int a[1000]={};
    cin>>n>>m;
    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";
	  }
	}
      }
    }
    a.clear();
    if(max==0 && n!=0&&m!=0){
      cout<<"NONE"<<endl;
    }else if(n!=0&&m!=0){
      cout<<max<<endl;
    }
  }
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;

int main() {
	while (1) {
		int a, b, ans = 0;
		cin >> a >> b;
		if (a == 0) { break; }
		int k[1005];
		for (int i = 0; i < a; ++i) { cin >> k[i]; }
		for (int i = 0; i < a; ++i) {
			for (int j = i + 1; j < a; ++j) {
				if (k[i] + k[j] <= b) { ans = max(ans, k[i] + k[j]); }
			}
		}
		if (ans == 0) { cout << "NONE" << endl; }
		else { cout << ans << endl; }
	}
}

C++: #include<cstdio>

int a[1005];

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

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

int main(){
  int n,m;
    while(1){
  cin >> n >> m;
  if(n == 0)return 0;
  int kakaku[n];
  for(int i=0; i<n; i++) cin >> kakaku[i];
  int buffer=0;
  for(int i=0; i<(n-1); i++){
    for(int j=(i+1); j<n; j++){
      if(kakaku[i]+kakaku[j] <= m && kakaku[i] + kakaku[j] > buffer) buffer = kakaku[i]+kakaku[j];
    }
  }
  if(buffer == 0){cout << "NONE" << endl;
  }else{
    cout << buffer << endl;
  }
  }
  return 0;
}

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

int main() {
    int n, m;
    while (cin >> n >> m) {
        if (n == 0) break;
        vector<int> a(n);
        for (int i=0; i<n; ++i) cin >> a[i];

        int mx = 0;
        for (int i=0; i<n; ++i) {
            for (int j=i+1; j<n; ++j) {
                if (a[i] + a[j] > mx && a[i] + a[j] <= m) {
                    mx = a[i] + a[j];
                }
            }
        }
        if (mx == 0) {
            cout << "NONE" << endl;
        } else {
            cout << mx << endl;
        }
    }
    return 0;
}

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

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

int main()
{
  int n, m, MAX = 0, SUM;
  int a, size;
  vector<int> v;
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }

  for (int i = 0; i < v.size(); i++) {
    for (int j = i+1; j < v.size(); j++) {
      SUM = v[i] + v[j];
      if (SUM < m) {
	MAX = max(MAX, SUM);
	//cout << MAX << endl;
      }
    }
  }

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