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<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<set>
#include<iomanip>
using ll=long long int;
using namespace std;


int main() {

	int m, nmin, nmax;
	

	while (cin >> m >> nmin >> nmax,m!=0||nmin!=0||nmax!=0){
		
		vector <int> p(m);

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

		int maxi = 0;
		int num;
		int ans = 0;

		for (int i = nmin; i <= nmax; i++) {

			num = p[i-1] - p[i];

			if (num == maxi) {
				ans = max(ans, i);
			}

			if (num > maxi) {
				ans = i;
				maxi = num;
			}

			

			
		}

		cout << ans << endl;

		p = { 0 };
		num = 0;
		maxi = 0;
		
}

	
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    while(1){
        int m, nmin, nmax;
        cin >> m >> nmin >> nmax;
        if(m + nmin + nmax == 0) break;
        vector<int> p(m);
        rep(i, 0, m){
            cin >> p[i];
        }
        int ans = 0, MAX = 0;
        rep(i, nmin, nmax + 1){
            int diff = p[i - 1] - p[i];
            if(diff >= MAX){
                MAX = diff;
                ans = i;
            }
        }
        cout << ans << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int M, Nmin, Nmax, P[205];

int main() {
  while(1){
    cin>>M>>Nmin>>Nmax;
    if(M==0)break;
    REP(i,0,M){
      cin>>P[i];
    }
    int ans = 0, num = -1;
    for(int i = Nmin-1; i < Nmax; i++){
      if(ans <= P[i] - P[i+1]){
        ans = P[i] - P[i+1];
        num = i+1;
      }
    }
    cout<<num<<endl;
  }
  return 0;
}

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

int main() {
    int p, n, m;
    while (cin >> p >> n >> m, n || m || p) {
        vector<int> v(p);
        for (auto& i : v) cin >> i;
        int ans, Max = -1;
        for (int i = n; i <= m; i++) {
            if (Max <= v[i-1] - v[i]) {
                ans = i;
                Max = v[i-1] - v[i];
            }
        }

        cout << ans << endl;
    }

    return 0;
}

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

int main()
{
	while (1)
	{
		priority_queue<int> GAP;
		priority_queue<int> PQ;
		int m, n_min, n_max;
		cin >> m >> n_min >> n_max;
		if (m == 0)break;
		for (int i = 0; i < m; i++)
		{
			int k;
			cin >> k;
			PQ.push(k);
		}
		int index = 0;
		for (int i = n_min; i <= n_max; i++)
		{
			priority_queue<int> tPQ = PQ;
			for (int l = 0; l < i-1; l++)
			{
				tPQ.pop();
			}
			int temp = tPQ.top();
			tPQ.pop();
			int gap = temp - tPQ.top();
			GAP.push(gap);
			if (gap == GAP.top())index = i;
		}
		cout << index << endl;
	}
	return 0;
}

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

int main(){
	while(1){
		int m,nmin,nmax;
		cin>>m>>nmin>>nmax;
		if(m==0&&nmin==0&&nmax==0)
			break;
			
		int gap=0;
		int n=0;
		int P[200];
		for(int i=0;i<m;i++){
			cin>>P[i];
		}
		for(int i=nmin;i<nmax;i++){
			if(P[i-1]-P[i]>=gap){
				gap=P[i-1]-P[i];
				n=i;
			}
		}
		cout<<n<<endl;
		
	}
	return 0;
}

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

int main(){
    for(int m, nmn, nmx; cin>>m>>nmn>>nmx, m;){
        vector<int>vec(m);
        for(int i=0;i<m;i++)cin>>vec[i];
        vector<pair<int, int> >c;
        for(int n = nmn; n <= nmx; n++){
            c.push_back(pair<int, int>(vec[n-1]-vec[n], n));
        }
        sort(c.begin(), c.end());
        cout<<c[c.size()-1].second<<endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
 
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;
using namespace std;

int main(void) {
    int m, nmin, nmax;
    while(cin >> m >> nmin >> nmax && m) {
        vector<int> p(m);
        REP(i, m) scanf("%d", &p[i]);
        sort(p.begin(), p.end(), greater<int>());
        int gap = 0;
        int ans = 0;
        for(int i=nmin-1; i<nmax; ++i) {
            if(p[i]-p[i+1] >= gap) {
                gap = p[i]-p[i+1];
                ans = i+1;
            }
        }
        printf("%d\n", ans);
    }
}

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

int main()
{
	int n,mn,mx;
	while(cin >> n >> mn >> mx and n!=0)
	{
		vector<int> p(n);
		for(int i=0;i<n;i++)
			cin >> p[i];
		sort(p.begin(),p.end());
		//reverse(p.begin(),p.end());
		int ans=0;
		int tmp=0;
		for(int i=1;i<n;i++)
		{
			if(mn<=n-i and n-i<=mx)
			{
				if(tmp<p[i]-p[i-1]) {
					ans=n-i;
					tmp = p[i] - p[i-1];
				}
			}
		}
		cout << ans << endl;
	}
}

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

bool func() {
    int m, n_min, n_max;
    scanf("%d", &m);
    scanf("%d", &n_min);
    scanf("%d", &n_max);

    if(m==0 && n_min==0 && n_max==0) return true;

    int pre = -1;
    pair<int, int> max_diff = make_pair(-1, 0);;
    vector<int> data;
    for(int i=0; i<m; i++) {
        int tmp;
        scanf("%d", &tmp);
        data.push_back(tmp);
        
        if(pre!=-1) {
            if(max_diff.first <= (pre-tmp) && i>=n_min && i<=n_max) {
                max_diff = make_pair(pre-tmp, i);
            }
        }
        pre = tmp;
    }

    printf("%d\n", max_diff.second);
    return false;
}

int main() {
    bool flag = false;
    while(!flag) {
        flag = func();
    }
}

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

int M, Nmin, Nmax, P[200];

int main(){
    while(1){
        cin >> M >> Nmin >> Nmax;
        if (M == 0 && Nmin == 0 && Nmax == 0)
            break;

        for (int i = 0; i < M; ++i)
            cin >> P[i];

        int idx = Nmin;
        for (int i = Nmin; i <= Nmax; ++i) {
            if (P[i-1]-P[i] >= P[idx-1] - P[idx]) {
                idx = i;
            }
        }

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

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int m,nmin,nmax;
string s;

int main() {
	cout << fixed << setprecision(18);
	cin>>m>>nmin>>nmax;
	while(0!=m){
		
		long long int p[210],res,gap=0;
		for(int i=1;i<=m;i++){
			cin>>p[i];
		}
		sort(p+1,p+m+1);
		for(int i=m-nmax+1;i<=m-nmin+1;i++){
			if(gap<p[i]-p[i-1]){
				gap=p[i]-p[i-1];
				res=m-i+1;
			}
		}
		cout<<res<<endl;
		cin>>m>>nmin>>nmax;
	}
	
}