Go: package main

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

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

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
		}

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

		// 最低合格者数と最高合格者数の間の各得点間のギャップが最大になる合格者数を取得する
		scoreGap := 0
		scoreGapMax := 0
		qualifiedNum := 0
		for n := nMin; n <= nMax; n++ {
			scoreGap = score_list[n-1] - score_list[n]
			if scoreGap >= scoreGapMax {
				scoreGapMax = scoreGap
				qualifiedNum = n
			}
		}

		fmt.Println(qualifiedNum)
	}
}

C++: #include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
 
int main(){
    int x,y,z;
    while(1){
        cin>>x>>y>>z;
 
        if(x==0&&y==0&&z==0)break;
 
 
        int a[114514];
        int b[114514];
 
        rep(i,x){
            cin>>a[i];
        }

        rep(i,z-y+1){
            b[i]=a[i+y-1]-a[i+y];
        }

        rep(i,z-y+1){
            // cout<<i<<" "<<b[i]<<endl;
        }

        int count=0;
        int tmp=0;
        int ans=0;

        for(int i=0;i<z-y+1;i++){
            if(tmp<b[i]){
                tmp=b[i];
                ans=i+y;
            }
        }
        cout<<ans<<endl;
 
       
    //     repi(i,y-1,z){
    //         // cout<<a[i]<<endl;
    //         // cout<<a[i+1]<<endl;
             
    //         if(tmp<=a[i]-a[i+1]){
    //             tmp=max(tmp,a[i]-a[i+1]);
    //             ans=i-1+y;
    //         }
 
    //         // cout<<"tmp:"<<tmp<<endl;
    //         // cout<<"ans:"<<ans<<endl;
 
    //         count++;
    //     }
    //     // cout<<count<<endl;
    //     // cout<<"tmp:"<<tmp<<endl;
    //     // cout<<"ans:"<<ans<<endl;
    //     if(y==1){
    //         cout<<ans+1<<endl;
    //     }else{
    //         cout<<ans<<endl;
    //     }
 
    }
     
}

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

int main()
{
    int n, min, max, a[200];

    while( cin >> n >> min >> max )
    {
        if( n + min + max == 0 )
            break;

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

        int max_distance = 0, j = 0;
        for( int i = min; i <= max; i++ )
            if( a[i-1] - a[i] >= max_distance )
            {
                max_distance = a[i-1] - a[i];
                j = i;
            }

        cout << j << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main()
{
	while (1) {
		ll mi, ma;
		cin >> n >> mi >> ma;
		if (n == 0 && mi == 0 && ma == 0) {
			return 0;
		} else {
			vi v(n);
			vp vans;
			REP(i, n) cin >> v[n - i - 1];
			FOR(i, mi, ma + 1)
			{
				ll a = v[n - i] - v[n - i - 1];
				vans.push_back(make_pair(a, i));
			}
			sort(ALL(vans));
			cout << vans[vans.size() - 1].second << endl;
		}
	}
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define PI       3.1415926535897932384626433832795028841971
#define INF 1000000000
#define EPS      1e-10
#define MOD      1000000
using namespace std;
typedef long long ll;
typedef pair<double,double> P;
typedef pair<double,P> PQ;

int m, n, N;
int p[10001];

int main(){
    while(cin >> m >> n >> N){
        if(n == 0 && N == 0 && m == 0) break;
        rep(i,m) cin >> p[i];
        sort(p,p+m,greater<int>());
        int ans = 0;
        int out = 0;
        for(int i = n-1; i < N; i++){
            if(ans <= p[i]-p[i+1]){
                ans = p[i]-p[i+1];
                out = i+1;
            }
        }
        cout << out << endl;
    }
}

C++: #include<bits/stdc++.h>
#define MAX 400
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int m,a,b;
  int p[MAX];
 
  while(1){
    cin>>m>>a>>b;
    if(m+a+b==0)break;
    FOR(i,0,m)cin>>p[i];
    sort(p,p+m);
    reverse(p,p+m);
 
    int ans=0,tmp=0;
    FOR(i,a,b+1){
      if(tmp<=p[i-1]-p[i]){
        ans=i;
        tmp=p[i-1]-p[i];
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include<cstdio>

int main() {
	int m, nmin, nmax, p[100001], maxg = 0 , n;
	while (1) {
		scanf("%d %d %d", &m, &nmin, &nmax);
		for (int i = 1; i <= m; i++) {
			scanf("%d", &p[i]);
		}
		for (int j = nmin; j <= nmax; j++) {
			if (p[j+1] - p[j] > maxg) {
				maxg = p[j+1] - p[j];
				n = j;
			}
			printf("%d\n", n);
		}
		if (m == nmin == nmax == 0)return 0;
	}
}

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

using namespace std;

int main(){
	
	while(1){
		
		int m,mi,ma;
		
		cin >> m >> mi >> ma;
		if(m==0) break;
		
		int p[m];
		for(int i=0;i<m;i++) cin >> p[i];
		
		int dif;
		int k=0,md=0,mem=0;
		
		for(int i=mi-1;i<ma;i++){
			dif=p[i]-p[i+1];
			md=max(md,dif);
			if(md==dif) mem=i;
			k++;
		}
		cout << mem+1 << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i=(a); i<(n); ++i)
#define rrep(i,a,n) for(ll i=(a); i>(n); --i)
#define erep(i,a,n) for(ll i=(a); i<=(n); ++i)
#define rerep(i,a,n) for(ll i=(a); i>=(n); --i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define print(X) cout << (X) << endl
#define _ << " " <<
static const int INF = 1e+9+7;

int main(){
  while(true){
    int n, n_min, n_max;
    cin >> n >> n_min >> n_max;
    if(n == 0 && n_max == 0 && n_min == 0) break;
    int A[1010] = {};
    rep(i,0,n) cin >> A[i];

    int tmp = 0;
    int num = 0;
    rep(i,n_min-1, n_max){
      if(tmp <= A[i] - A[i+1]){
        tmp = A[i] - A[i+1];
        num = i+1;
      }
    }
    print(num);
  }
  
  return 0;
}

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


int a[10000]={};

void sw(int n){
for(int g=0;g<2*n;g++){
for(int i=0;i<n-1;i++){
if(a[i]<a[i+1]){swap(a[i],a[i+1]);}
}}}

int main(){
int m,mi,mx;
while(cin>>m){

int am,al=0;
int b[10000];
cin>>mi>>mx;

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

sw(m);
for(int i=mx;i>=mi;i--){
b[i]=a[i]-a[i-1];
}

for(int q=mx;q>=mi;q--){
if(b[q]>al){al=b[q]; am=q;}
}

cout<<am<<endl;
}

return 0;
}