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<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,j,m,ni,na,mx,mi,p[200];
	while(1)	{
		scanf("%d %d %d",&m,&ni,&na);
		if(m==0 && ni==0 && na==0)	break;
		for(i=0;i<m;i++)	scanf("%d",&p[i]);
		sort(p,p+m,greater<int>() );
		mx=-1;
		for(i=ni-1;i<=na-1;i++)	{
			if(mx<=p[i]-p[i+1]){
				mx=p[i]-p[i+1];
				mi=i;
			}
		}
		printf("%d\n",mi+1);
	}
	return 0;
}

C++: #include<stdio.h>
int main(){
  int m,nmi,nma,i,a[200],g[2];
  while(1){
    g[0]=0;
    scanf("%d%d%d",&m,&nmi,&nma);
    if(m==0&&nmi==0&&nma==0)break;
    for(i=0;i<m;i++){
      scanf("%d",&a[i]);
      if(i>=nmi&&nma>=i){ 
	if(a[i-1]-a[i]>=g[0]){
	  g[0]=a[i-1]-a[i];
	  g[1]=i+1;
	}
      }
    }
    printf("%d\n",g[1]-1);
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=100005,INF=1<<28;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,L,R;cin>>N>>L>>R;
        if(N==0) break;
        vector<int> A(N);
        for(int i=0;i<N;i++) cin>>A[i];
        
        int ans=-1,point=-1;
        
        for(int i=L;i<=R;i++){
            if(ans<=A[i-1]-A[i]){
                ans=A[i-1]-A[i];
                point=i;
            }
        }
        
        cout<<point<<endl;
    }
}

C++: #include <iostream>
#include <vector>

using namespace std;

int main(void) {
	int m,max,min;
	cin >> m >> min >> max;
	while (m != 0 || min != 0 || max != 0) {
		vector<int> P(m);
		for (int i = 0; i < m; ++i) {
			cin >> P[i];
		}
		int ret;
		int gap;
		for (int n = min; n < max+1; ++n) {
			if (n == min) {
				ret = n;
				gap = P[n-1] - P[n];
			}
			else if (gap <= P[n-1] - P[n]) {
				ret = n;
				gap = P[n-1] - P[n];
			}
		}
		cout << ret << endl;
		cin >> m >> min >> max;
	}
	return 0;
}

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

int main()
{
  
  int m,min,max;
  while(scanf("%d%d%d",&m,&min,&max)==3){
      if(m==0&&min==0&max==0){
          break;
      }
      else
      {
          int a[100000];
          int count = 0;
          for(int i=0;i<m;i++){
              scanf("%d",&a[i]);
          }
          int step = 0;
          for(int i=min;i<=max;i++){
              if(a[i-1]-a[i]>=step){
                 step = a[i-1]-a[i];
                 count = i;
              }
          }
          printf("%d\n",count);
              
          
      }
      
  }
    return 0;
}

C++: #include <iostream>
#include <algorithm>

#define REP(i, n) for (int i = 0; i < n; i++)
#define debug(x) cerr << #x << " = " << (x) << endl;

using namespace std;

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

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


int a[10000]={};

void sw(int n){
for(int g=0;g<2n;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,al=0;
while(cin>>m){
int b[10000]
cin>>mi>>mx;
for(int h=0;h<m;h++){
cin>>a[i];
}
sw(m);
for(i=mx;i>=mi;i--){
b[i]=a[i]-a[i-1];}
for(q=mx;q>=mi;i--){
if(b[q]>al){al=b[q]; am=q;}
}
cout<<am<<endl;
}

return 0;
}

C++: #include<iostream>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<climits>
#include<string.h>
using namespace std;

int main(){
    int m,n1,n2;
    while(cin>>m>>n1>>n2,m){
        int p[202];
        vector<pair<int,int> >v;
        for(int i=1;i<=m;i++){
            cin>>p[i];
            if(i-1>=n1&&i-1<=n2){
                v.push_back(make_pair(p[i-1]-p[i],i-1));
            }
        }
        sort(v.begin(),v.end());
        cout<<v[v.size()-1].second<<endl;
    }
}

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

int main(){
    int m, nmin, nmax;
    while(cin >> m >> nmin >> nmax, m){
        vector<int> p(m);
        for(int i = 0 ; i < m ; i++){
            cin >> p[i];
        }
        sort(p.begin(), p.end());

        pair<int, int> ans = make_pair(-1, -1);
        for(int n = nmin ; n <= nmax ; n++){
            ans = max(ans, make_pair(p[m - n] - p[m - n - 1], n));
        }

        cout << ans.second << endl;
    }

    return 0;
}

C++: #include<stdio.h>

int p[201];
int gap = -1;
int ans = -1;
int main(){
    int m, n_min, n_max;
    for(;;){
        scanf("%d %d %d\n",&m, &n_min, &n_max);
        if(m == 0 && n_max == 0 && n_min == 0) break;
        for(int i=1; i<=m; i++){
            scanf("%d\n",&p[i]);
        }
        for(int border = n_min; border <= n_max; border++){
            if(gap <= p[border] - p[border+1]){
                gap = p[border] - p[border+1];
                ans = border;
            }
        }
        printf("%d\n",ans);
        ans = -1;
        gap = -1;
    }
    return 0;
}

C++: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (1) {
		int m,nmin,nmax; cin >> m >> nmin >> nmax;
		if (m+nmin+nmax==0) break;
		vector<int> P(m);
		rep(i,m) cin >> P[i];

		int gap = 0;
		int ans = 0;
		for (int i = nmax-1; i >= nmin-1; i--) {
			if (chmax(gap,P[i]-P[i+1])) ans = i; 
		}

		cout << ans+1 << endl;
	}
}