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 ll long long
#define INF 1000000000
using namespace std;
int main(){
    int N,nmax,nmin;
    while(1){
        cin >> N;
        cin >> nmin >> nmax;
        if(N+nmax+nmin==0) return 0;
        nmin--; nmax--;
        int P[N];
        for(int i=0;i<N;i++) cin >> P[i];

        int ans = 0,gap=P[nmin]-P[nmin+1];
        for(int i=nmin;i<=nmax;i++){
            //cout << P[i]-P[i+1] << endl;
            if(gap <= P[i]-P[i+1]){
                ans = i+1;
                gap = P[i]-P[i+1];
            }
        }
        cout << ans << endl;

    }
}

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

int main(){

  int m, n_min, n_max, gap = 1000000, z;
  int ary[1000001];

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

    for(int i = 1 ; i <= m ; i++){
      cin >> ary[i];
    }

    for(int i = n_min ; i <= n_max ; i++){
      if(gap >= ary[i+1] - ary[i]){
	gap = ary[i+1] - ary[i];
	z = i;
      }
    }
    cout << z << endl;
    gap = 1000000;
    z = 0;
  }

  return 0;
}

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++)

int main() {
    int m,n_min,n_max;
    while (true) {
        cin >> m >> n_min >> n_max;
        if (m == 0 && n_min == 0 && n_max == 0) {
            break;
        }
        vector<int> P(m);
        rep(i, m) {
            cin >> P[i];
        }
        int diff = 0;
        int ans = 0;
        repi(i, n_min, n_max+1) {
            if ( (P[i-1] - P[i]) >=  diff) {
                diff = P[i-1] - P[i];
                ans = i;
            }
        }
        cout << ans << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int m,nmin,nmax;
int p[210];

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 gapmax=0;
		int gap=-1;
		for(int i=nmin;i<=nmax;i++){
			if(p[i-1]-p[i]>=gapmax){
				gapmax=p[i-1]-p[i];
				gap=i;
			}
		}
		cout<<gap<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int n,a,b;
int t[100000];
int main(){

  while(cin>>n>>a>>b,n||a||b){
  for(int i=0;i<n;i++)cin>>t[i];
  int ans=0;
    sort(t,t+n);
    reverse(t,t+n);
    //cout<<t[0]:
    int ans2=0;
    for(int i=a-1;i<b;i++){
      //cout<<t[i]-t[i+1]<<endl;
      if(ans<=t[i]-t[i+1]){
        ans=t[i]-t[i+1];
        ans2=i+1;
      }
    }
    cout<<ans2<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(kbrni,n)cout<<" "<<a[kbrni];cout<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define svecp(v) cout<<#v<<":";each(kbrni,v)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int m,nmax,nmin;
        int val = 1;
        cin >> m >> nmin >> nmax;
        if(m == 0){
            break;
        }
        vector<int> vec(m);
        rep(i,m){
            cin >> vec[i];
        }
        int ans = -1;
        srep(i,nmin,nmax+1){
            if(val <= vec[i-1] - vec[i]){
                val = vec[i-1]-vec[i];
                ans = i;
            }
        }
        cout << ans << "\n";
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

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

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

int p[200];
int main() {
	int m, s, g; scanf("%d%d%d", &m, &s, &g);
	rep(i, m)scanf("%d", &p[i]);
	sort(p, p + m, greater<>());
	int Max = 0, cnt;
	for (int i = s - 1; i < g; i++) {
		if (p[i + 1] - p[i] >= Max) {
			Max = p[i + 1] - p[i];
			cnt = i + 1;
		}
	}
	printf("%d\n", cnt);
}

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

using namespace std;

int main(void) {
    while (1) {
        int m, nmin, nmax;
        scanf("%d%d%d", &m, &nmin, &nmax);
        if (m == 0 && nmin == 0 && nmax == 0) break;

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

        sort(P, P + m, greater<int>());
//        for (int i = 0; i < m; ++i) {
//            cout << P[i] << endl;
//        }
        int maxgap = 0;
        int maxgapn;
        for (int i = nmin - 1; i <= nmax - 1; ++i) {
            int gap = P[i] - P[i + 1];
            if (gap >= maxgap) {
                maxgapn = i;
                maxgap = gap;
            }
        }

        cout << maxgapn + 1 << endl;
    }
    return 0;
}

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

int main(){

  int m, n_min, n_max, gap = 1000000, z;
  int ary[1000001];

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

    int j = 0;
    while(m--){
      cin >> ary[j];
      j++;
    }

    for(int i = n_min ; i <= n_max ; i++){
      if(gap >= ary[i-1] - ary[i]){
	gap = ary[i-1] - ary[i];
	z = i;
      }
    }
    cout << z;
    gap = 1000000;
    z = 0;
  }

  return 0;
}