Go: // Entrance Examination(入学試験)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1600&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		m, nMin, nMax := nextInt(sc), nextInt(sc), nextInt(sc)
		if m == 0 && nMin == 0 && nMax == 0 {
			break
		}

		points := []int{}
		for i := 0; i < m; i++ {
			points = append(points, nextInt(sc))
		}

		gapMax, pass := 0, 0
		for n := nMin; n <= nMax; n++ {
			gap := points[n-1] - points[n]
			if gap >= gapMax {
				gapMax, pass = gap, n
			}
		}

		fmt.Println(pass)
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

C++: #include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

int m, nMin, nMax;
int P[210];
pair<int, int> ans[210];

signed main()
{
    while (true) {
        cin >> m >> nMin >> nMax;
        if (m == 0 && nMin == 0 && nMax == 0) break;

        REP(i,m) cin >> P[i];
        sort(P, P + m, greater<int>());

        int idx = 0;
        for (int i=nMin; i<=nMax; i++) {
            ans[idx++] = make_pair(P[i-1] - P[i], i);
        }

        sort(ans, ans + idx);
        cout << ans[idx-1].second << endl;
    }
}

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

int main(){
    int m,n1,n2,a[201];
    cin >> m >> n1 >> n2; 
    do{
        int maxg=n2;
        for (int i=1;i<=m;i++)
            cin >> a[i];
        for (int i=0;i<n2-n1+1;i++){
            if (a[maxg]-a[maxg+1]<a[n2-i]-a[n2-i+1])
                maxg=n2-i;
       }
       cout << maxg << endl;
       cin >> m >> n1 >> n2; 
    }while(!(m==0 && n1==0 && n2==0));
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)

#define vi vector<int>
#define pb push_back

typedef long long ll;
using namespace std;


int main(){
    int m,nmn,nmx;
    while(cin >> m >> nmn >> nmx,m) {
        int gmx = 0,mxn = 0;
        vi p;
        rep(i,m){
            int tmp;
            cin >> tmp;
            p.pb(tmp);
        }
        sort(p.begin(),p.end());
        REP(n,nmn,nmx + 1){
            if(gmx <= (abs(p[m - n] - p[m - n - 1]))) {
                gmx = abs(p[m - n ] - p[m - n - 1]);
                mxn = n;
            }
        }
        cout << mxn << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    int m,min,nmax;
    while(cin >> m >> nmin >> nmax){
        if(m == 0) return 0;
        int mx = 0,ans = 0,a[m+5];
        for(int i = 1;i<=m;i++) cin >> a[i];
        for(int i = nmin;i<=nmax;i++){
            if(a[i]-a[i+1] >= mx) mx = a[i]-a[i-1],ans = i;
        }
        cout << ans << endl;
    }
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int m,nmin,nmax;
    while (cin >> m >> nmin >> nmax, m) {
        vector<int> P(m);
        REP(i,m) cin >> P[i];
        int gap = 0;
        int ans = 0;

        for (int i=nmin; i<=nmax; i++) {
            if (i == 0) continue;
            int gokaku = P[i-1];
            int hugokaku = P[i];
            if (gokaku - hugokaku >= gap) {
                gap = gokaku - hugokaku;
                ans = i;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main(void){
	int m,a,b;
	while(cin >> m >> a >> b,m){
		int p[210];
		for(int i = 0; i < m;++i) cin >> p[i];
		
		int gap = 0, idx = -1;
		for(int i = a;i <= b; ++ i){
			int cur = p[i-1] - p[i];
			if(gap <= cur) gap = cur,idx = i;
		}

		cout << idx << endl;
	}
	return 0;
}

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

int main() {
	while (true) {
		int m, nmin, nmax;
		cin >> m >> nmin >> nmax;

		if (m == 0 && nmin == 0 && nmax == 0)
			break;

		int P[200];
		for (int i = 0;i < m;i++) {
			cin >> P[i];
		}

		int gap = -1;
		int n = -1;

		for (int i = nmin;i <= nmax;i++) {
			int g = P[i - 1] - P[i];

			if (gap <= g) {
				gap = g;
				n = i;
			}
		}
		cout << n << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#define REP(i,a) for(int i = 0; i < (a); i++)
using namespace std;

int main(){
	int m,nmin,nmax;
	while(cin >> m >> nmin >> nmax){
		if(m == 0 && nmin == 0 && nmax == 0)break;
		int p[m];
		REP(i, m)cin >> p[i];
		int max = 0;
		int res;
		for(int i = nmin; i < nmax + 1; i++){
			if(p[i - 1] - p[i] >= max){
				max = p[i - 1] - p[i];
				res = i;
			}
		}
		cout << res << endl;
	}
}

C++: #include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    int m, min, max;
    cin >> m >> min >> max;
    vector<int> v;
    loop(m, i) {
        int i; cin >> i;
        v.push_back(i);
    }

    int gap = 0;
    int ans = 0;
    for (int i = min; i < max; i++) {
        if (gap < v[i-1] - v[1]) {
            gap = v[i-1] - v[1];
            ans = i;
        }
    }
    cout << i << endl;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int nmin, nmax, m;
	while (cin >> m >> nmin >> nmax, m) {
		int p[210];
		for (int i = 1; i <= m; i++)cin >> p[i];
		int ans = nmin, v = p[nmin] - p[nmin + 1];
		for (int i = nmin + 1; i <= nmax; i++) {
			if (v <= p[i] - p[i + 1]) {
				ans = i;
				v = p[i] - p[i + 1];
			}
		}
		cout << ans << endl;
	}
}

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

int main()
{
  int m, nmin, nmax;
  cin >> m >> nmin >> nmax;

  while(m && nmin && nmax){

    vector<int> p(m);
    for(int i = 0; i < m; i++) cin >> p[i];

    sort(p.begin(), p.end());

    int gap = 0, cnt = 0;
    for(int i = m - nmin; i >= m - nmax; i--){

      if(gap <= p[i] - p[i-1]){
        gap = p[i] - p[i-1];
        //cout << gap << endl;                                                  
        cnt = m - i;
      }

    }

    cout << cnt << endl;
    cin >> m >> nmin >> nmax;

  }

  return 0;

}

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

int main(){
	int m,nmin,nmax,x,res,resmax;
	vector<int> v;
	while(1){
		cin >> m >> nmin >> nmax;
		if(m == 0)break;
		resmax = 0;
		v.clear();
		for(int i = 0;i < m;i++){
			cin >> x;
			v.push_back(x);
		}
		sort(v.begin(),v.end(),greater<int>());
		for(int i = nmin - 1;i < nmax;i++){
			x = v[i] - v[i+1];
			if(x >= resmax){
				res = i + 1;
				resmax = x;
			}
		}
		cout << res << endl;
	}
	return 0;
}

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

int main() {
    int m, n_min, n_max;

    while(1) {
        cin >> m >> n_min >> n_max;
        if(m + n_min + n_max == 0) break;

        vector<int> P(m);
        for(int i = 0; i < m; i++) {
            cin >> P[i];
        }

        int ans = 0;
        int gap = 0;
        for(int i = n_max; i >= n_min; i--) {
            if(gap < P[i-1] - P[i]) {
                ans = i;
                gap = P[i-1] - P[i];
            }
        }

        cout << ans << endl; 
    }

    return 0;
}