akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) 
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) 
#define forrc(i,l,r) for (int i= (int)(r); i>= (int)(l); --i)

#define pb push_back
#define fi first
#define se second
#define mp make_pair

#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 


#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)


#define present(c,x) ((c).find(x) != (c).end())


#define cpresent(c,x) (find(all(c),x) != (c).end())

#define sz(a) int((a).size())

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
typedef long long ll;
typedef unsigned long long int ull;

int MOD=1000000007;

int main(){
  fastio; 
  
  int n;
  cin >> n;
  ll a[n];
  ll sum=0;
  for0(i,n){
    cin >> a[i];
    sum+=a[i];
  }
  ll dp[n][n];
  int l,r;
  for0(i,n){
    l=0,r=i;
    while(r<n){
      if(l==r){
        dp[l][r]=a[l];
        l++;
        r++;
        continue;
      }
      if(l+1==r){
        dp[l][r]=max(a[l],a[r]);
        l++;
        r++;
        continue;
      }
      dp[l][r]=max(a[l]+min(dp[l+1][r-1],dp[l+2][r]),a[r]+min(dp[l][r-2],dp[l+1][r-1]));
      l++;
      r++;
    }
  }
  cout << 2*dp[0][n-1]-sum;
}

Measured memory_bytes: 70144
#include<bits/stdc++.h>
using namespace std;
int main(){
        long n;
        cin>>n;
        vector<long> a(n);
        for(int i=0; i<n; i++)
                cin>>a[i];
        unsigned long min=-1;
        for(int i=-100; i<=100; i++){
                long sum=0;
                for(int j=0; j<n; j++)
                        sum+=(a[j]-i)*(a[j]-i);
                if(sum<min)
                        min=sum;
        }
        cout<<min;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(N+100);
  for(int i=0;i<M;++i){
    cin >> a[i];
  }
  
  vector<int> fib(N+100);
  int index = 0;
  fib[0] = 1;
  if(a[0]==1){
    fib[1] = 0;
    index++;
  }else{
    fib[1] = 1;
  }
    
  for(int i=0;i<=N-1;++i){
    if(a[index]==i+2 && index<M){
      fib[i+2] = 0;
      index++;
    }else{
      fib[i+2] = (fib[i] + fib[i+1])%1000000007;
    }
  }
  
  cout << fib[N] <<endl;  
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int max(int a,int b){
  if(a > b)return a;
  return b;
}
int min(long long int a,long long int b){
  if(a < b)return a;
  return b;
}
int zet(int a){
  if(a > 0)return a;
  return -a;
}
void swap(long long int *x,long long int *y) {
  long long int temp = *x;
  *x = *y;
  *y = temp;
}
int partition(long long int array[],long long int left,long long int right) {
  long long int i,j,pivot;
  i = left;
  j = right + 1;
  pivot = left;
  do{
    do{ i++; } while(array[i] < array[pivot]);
    do{ j--; } while(array[pivot] < array[j]);
    if(i < j)swap(&array[i],&array[j]);
  }while (i < j);
  swap(&array[pivot],&array[j]);
  return j;
}
void quick_sort(long long int array[],long long int left,long long int right) {
  long long int pivot;
  if(left < right) {
    pivot = partition(array,left,right);
    quick_sort(array,left,pivot-1);
    quick_sort(array,pivot+1,right);
  }
}
int main(void){
  int n;
  scanf("%d",&n);
  long long int a[n],min1 = 10000000000,min2 = 10000000000;
  for(int i = 0;i < n;i++){
    scanf("%lld",&a[i]);
    if(min2 > a[i]){
      min2 = a[i];
    }else if(min1 > a[i]){
      min1 = a[i];
    }
  }
  for(long long int i = min1;;i--){
    int cnt = 0;
    for(int j = 0;j < n;j++){
      if(a[j] % i > 0)cnt++;
      if(cnt > 1)break;
    }
    if(cnt < 2){
      printf("%lld\n",i);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}


int main() {
  int K;
  cin >> K;

  int a, b, c; cin >> a >> b >> c;

  int ab, abc;
  int sum = 0;
  
  for (int i=1;i<=K;i++){
    for (int j=1;j<=K;j++){
      for (int k=1;k<=K;k++){
  	  ab = gcd(i, j);
	  abc = gcd(ab, k);
      sum += abc; 
      }
    }
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 3676
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int MAXN=2e5+10;
int N;
int arr[MAXN];

typedef long long int ll;

ll dp[MAXN][3];

int main(){
    scanf("%d",&N);
    for(int i=1;i<=N;i++) scanf("%d",arr+i);

    dp[1][0]=0;
    dp[1][1]=arr[1];
    dp[0][0]=0;
    dp[2][0]=0;

    for(int i=0;i<=N;i++){
        for(int j=max(i/2-1,0);j<=(i+1)/2;j++){
            // printf("i=%d j=%d\n",i,j);
            if (i+2<=N) dp[i+2][(j+1)%3]=dp[i][j%3]+arr[i+2];
            if (i+1<=N) dp[i+1][j%3]=max(dp[i+1][j%3],dp[i][j%3]);
        }
    }

    printf("%lld\n",dp[N][(N/2)%3]);

    return 0;
}

Measured memory_bytes: 7172
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    ll a=power(10,n);
    ll b=power(9,n)*2;
    b%=mod;
    ll c=power(8,n);
    ll ans=a-b+c;
    ans%=mod;
    ans+=mod;
    ans%=mod;
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15524
#include <bits/stdc++.h>
#define pq priority_queue
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2;
typedef pair<int, P2> P3; typedef long long ll; typedef long double ld;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<1010> fact; constexpr Prime<10> prime;
constexpr long long comb(int a, int b){if(a < b) return 0LL;if(!a or !b) return 1LL; long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b]; return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr int sqrtN = 512, logN = 32;
constexpr ld PI = abs(acos(-1));
constexpr ll LINF=1e18;

int n, k;
vector<vector<int>> li, li2;

int main(){
	cin >> n >> k;
	li.resize(4 * k + 1, vector<int>(4 * k + 1));
	li2.resize(4 * k + 1, vector<int>(4 * k + 1));
	for(int i = 0; i < n; i++){
		int a, b; char c; cin >> a >> b >> c;
		
		if(c == 'W') li[a % (2 * k)][b % (2 * k)]++;
		else if(c == 'B') li2[a % (2 * k)][b % (2 * k)]++;
	}
	
	for(int i = 0; i < 2 * k; i++){
		for(int j = 0; j < 2 * k; j++){
			li[i + 2 * k][j] += li[i][j];
			li[i][j + 2 * k] += li[i][j];
			li[i + 2 * k][j + 2 * k] += li[i][j];
			
			li2[i + 2 * k][j] += li2[i][j];
			li2[i][j + 2 * k] += li2[i][j];
			li2[i + 2 * k][j + 2 * k] += li2[i][j];
		}
	}
	
	for(int i = 0; i < 4 * k; i++){
		for(int j = 0; j < 4 * k; j++){
			li[i + 1][j + 1] += li[i + 1][j] + li[i][j + 1] - li[i][j];
			li2[i + 1][j + 1] += li2[i + 1][j] + li2[i][j + 1] - li2[i][j];
		}
	}
	
	int ma = 0;
	for(int K = 0; K < 2; K++){
		for(int i = 0; i < k; i++){
			for(int j = 0; j < k; j++){
				int A = li[i + k][j + k] - li[i + k][j] - li[i][j + k] + li[i][j];
				int B = li[i + 2 * k][j + 2 * k] - li[i + 2 * k][j + k] - li[i + k][j + 2 * k] + li[i + k][j + k];
				int C = li2[i + 2 * k][j + k] - li2[i + 2 * k][j] - li2[i + k][j + k] + li2[i + k][j];
				int D = li2[i + k][j + 2 * k] - li2[i][j + 2 * k] - li2[i + k][j + k] + li2[i][j + k];
				
				ma = max(ma, A + B + C + D);
			}
		}
		
		swap(li, li2);
	}
	
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 125568
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC163
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            long[] nm = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = nm[0],m = nm[1];
            long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            for (long i = 0; i < m; i++)
            {
                n -= a[i];
            }
            if (n > -1)
                Console.WriteLine(n);
            else
                Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 20380
inf = float('inf')

N, K, Q = map(int, input().split())
a = tuple(map(int, input().split()))

ans = inf
for ma in sorted(set(a)):
    res = []
    seq = 0
    for i, aa in enumerate(a):
        if aa >= ma:
            # 最小値以上の要素は部分列に含めてよい
            seq += 1
        else:
            # 最小値未満の要素が来たら、
            # それまでの部分列を処理する
            if seq >= K:
                res.extend(sorted(a[i - seq:i])[:seq - K + 1])
            seq = 0
    if seq >= K:
        res.extend(list(sorted(a[-seq:]))[:seq - K + 1])
    seq = 0
    if len(res) < Q: continue
    res.sort()
    ans = min(ans, res[Q - 1] - ma)
print(ans)


Measured memory_bytes: 3316
import copy
D = int(input())
c = list(map(int, input().split()))
s = []
for _ in range(D):
  s.append(list(map(int, input().split())))

t = [0] * 26

x = 0 # 満足度
for i in range(D): # i+1日目
  l = []
  for j in range(26): # すべてのコンテストに対して満足度を計算し、maxを求める
    u = copy.deepcopy(t)
    u[j] = i+1
    x += s[i][j]
    for k in range(26): # シグマの中身
      x -= c[k] * ((i+1) - u[k])
    l.append(x)
  v = l.index(max(l))
  t[v] = i+1
  print(v+1)

Measured memory_bytes: 9504
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 2e5+9;
int n;
ll ans;

int main() {
    cin >> n;
    
    for(int i=1; i<=n; ++i) ans = ans + 1LL * i * (i + 1) / 2;
    
    for(int i=1; i<=n-1; ++i) {
        int x, y; cin >> x >> y;
        ans -= 1LL * min(x, y) * (n-max(x, y) + 1);
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 3708
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});
process.stdin.on('end', () => {
  const [a, b, c] = content
    .trim()
    .split(' ')
    .map(n => parseInt(n, 10));
  
  let count = 0;
  for (let i = a; i <= b; i++) {
    if (c % i === 0) {
      count++;
    }
  }

  console.log(count);
});


Measured memory_bytes: 19404
#include <iostream>
#include <string>
using namespace std;

int main()
{
  string s;
  cin >> s;
  string t;
  for (int i = 0; i < s.length(); ++i)
  {
    if ('B' == s[i])
    {
      if (0 < t.size())
        t.resize(t.size() - 1);
    }
    else
      t.push_back(s[i]);
  }
  cout << t;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
  int n, m, c[20];
  int dp[50001];

  scanf("%d%d", &n, &m);
  for (int i = 0;i < m;i++) {
    scanf("%d", &c[i]);
  }
  for (int i = 0;i <= n;i++) {
    dp[i] = 1000000;
  }

  dp[0] = 0;
  for (int i = 1;i <= n;i++) {
    for (int j = 0;j < m;j++) {
      if (c[j] <= i) {
        dp[i] = min(dp[i], dp[i - c[j]] + 1);
      }
    }
  }

  printf("%d\n", dp[n]);

  return 0;
}


Measured memory_bytes: 2916
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())S
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int a,b;
    cin >> a >> b;
    pr((a-1)*(b-1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i <= n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  int N,Y;
  cin >> N >> Y;
  rep(i, 0, N){
    rep(j,0,N){
      int sum = 10000*i+5000*j+1000*(N-i-j);
      if((N-i-j)>=0 && sum == Y){
        cout << i <<" "<<  j << " "<< (N-i-j) << endl;
        return 0;
      }
    }
  }
  cout << -1 <<" "<< -1 << " "<< -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	vector<int> a;
	int n;

	for(int i=0 ; i<5 ; i++){
		cin >> n;
		a.push_back(n);
	}
	sort( a.begin() , a.end() );
	for(int i=4 ; i>=0 ; i--){
		cout << a[i] ;
		(i==0)? cout << endl : cout << " ";
	}
}

Measured memory_bytes: 3072
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	ll N,A,B;
	scan(N>>A>>B);
	ll loop=N/(A+B);
	prin(loop*A+min(A,N%(A+B)));
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

//numberが素数ならば1，そうでなければ0を返す関数
int primality(int number);

int main(void){
  int N;
  int i, j, k;
  int count = 0, count2 = 0;

  scanf("%d", &N);

  for(i = 1; i <= (N+1)/2; i++){
    count = 0;
    for(j = 1; j <= 2*i-1; j++){
      if((2*i-1)%j == 0){
        count++;
      }
    }
    if(count == 8){
      count2++;
    }
  }

  printf("%d\n", count2);
  return 0;
}

int primality(int number){
  int i;

  if(number <= 1){
    return 0;
  }
  else{
    for(i = 2; i < number; i++){
      if(number%i == 0){
        return 0;
      }
    }
    return 1;
  }
}


Measured memory_bytes: 128
// 

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int R;
    double pinum = 3.14159265;
    cin >> R;
    cout << 2.0 * pinum * R << endl;
    return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;

int main(){
    ll i,j;
    ll n,m;

    cin>>n>>m;
    vector<P> v;
    ll a,b;
    for(i=0;i<n;i++){
        cin>>a>>b;
        v.pb(P(a,b));
    }
    sort(v.begin(),v.end());
    ll ans=0;
    ll tmp=0;
    while(m){
        if(m>=v[tmp].second) {
            m-=v[tmp].second;
            ans+=v[tmp].fi*v[tmp].se;
        }
        else {
            ans+=m*v[tmp].fi;
            m=0;
        }
        tmp++;
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class T>
inline void out(T a) {
	cout<<a<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


ll L,R;

void input() {
	cin>>L>>R;
}

void solve() {
	if(R/2019-(L-1)/2019>0) {
		cout<<0<<endl;
		return;
	}

	ll res=LLINF;
	for(ll l=L; l<R; l++) for(ll r=l+1; r<=R; r++) {
		chmin(res,l*r%2019);
	}
	cout<<res<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void ARC062D();

int main()
{
	ARC062D();
	fflush(stdout);
	return 0;
}

static void ARC062D()
{
	std::string orgs;
	std::cin >> orgs;

	int turnCount = orgs.length();
	int gCount = 0;
	int pCount = 0;
	int winCount = 0;
	int loseCount = 0;
	for (int i = 0; i < turnCount; i++) {
		int win = 0;
		int lose = 0;
		if (orgs[i] == 'g') {
			win = 1;
		}
		else {
			lose = 1;
		}
		if (pCount < gCount) {
			winCount += win;
			pCount++;
		}
		else {
			loseCount += lose;
			gCount++;
		}
	}
	printf("%d\n", winCount - loseCount);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, T, A;
  cin >> N >> T >> A;
  int H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  int mini = 999999;
  int ans = -1;
  int sa = 0;
  for (int i = 0; i < N; i++) {
    if (1000 * A - (1000 * T - 6 * H[i]) < 0) {
      sa = (1000 * T - 6 * H[i]) - A * 1000;
    }
    else {
      sa = A * 1000 - (1000 * T - 6 * H[i]);
    }
    
    if (sa < mini) {
      mini = sa;
      ans = i + 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main()
{
    int w,a,b;
    cin>>w>>a>>b;
    int result = -1;
    if(b> a+w)
    {
        result = b-a-w;
    }
    else if(b<=a+w && b+w>=a)
    {
        result = 0;
    }
    else if (b <= a && b+w >=a)
    {
        result = 0;
    }
    else //b+w < a
    {
        result = a-b-w;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define SORT(obj) sort(obj.begin(),obj.end())
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
ll const MOD=1e9+7;

int main(){
  ll n;
  cin>>n;
  ll count=0;
  for(ll i=1;i<n+1;i++){
    if(!(i%3==0||i%5==0)){
      count+=i;
   }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3624
A = []
b = []
for _ in range(3):
    A.append(list(map(int, input().split())))
n = int(input())
for _ in range(n):
    b.append(int(input()))
    
X = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            X[i][j] = 1

if X[0][0]*X[0][1]*X[0][2] + X[1][0]*X[1][1]*X[1][2] + X[2][0]*X[2][1]*X[2][2] + X[0][0]*X[1][0]*X[2][0] + X[0][1]*X[1][1]*X[2][1] + X[0][2]*X[1][2]*X[2][2] + X[0][0]*X[1][1]*X[2][2] + X[0][2]*X[1][1]*X[0][2] > 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9276
#include<iostream>
using namespace std;

int main(){
	int d;
	
	while (cin >> d){
		int s = 0;
		for (int i = 1; i*d < 600; i++){
			s += (i*d)*(i*d)*d;
		}
		cout << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b%a,a);
}
int findGCD(int arr[], int n)
{
    int result=arr[0];
    for (int i=1;i<n;i++)
    {
        result = gcd(arr[i], result);

        if(result == 1)
        {
           return 1;
        }
    }
    return result;
}
int main()
{
    int k;
    long long int s=0;
    cin>>k;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            for(int l=1;l<=k;l++)
            {
                int arr[]={i,j,l};
                s=s+findGCD(arr, 3);
            }
        }
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 3612
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
const ll MOD = 1000000000000000001;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a[4],sum=0;
  string s;
  cin>>s;
  rep(i,4){
    a[i]=s[i]-'0';
  }
  char op[3];
  rep(i,(1<<3)){
    sum=a[0];
    rep(j,3){
      if(i&(1<<j)){
        op[j]='+';
        sum+=a[j+1];
      }else{
        op[j]='-';
        sum-=a[j+1];
      }
    }
    if(sum==7){
      break;
    }
  }
  cout<<a[0];
  rep(i,3){
    cout<<op[i]<<a[i+1];
  }
  cout<<"=7"<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

void addstr(char *str1, char *str2)
{
    char temp[1000];
    int max;
    int i;
    
    if (strlen(str1) > strlen(str2)){
        max = strlen(str1);
    }
    else {
        max = strlen(str2);
    }
    
    memset(temp, '\0', 1000);
    strcpy(&temp[max - strlen(str1) + 1], str1);
    i = 0;
    while (temp[i] == '\0'){
         temp[i] = '0';
         i++;
    }
    strcpy(str1, temp);
    
    memset(temp, '\0', 1000);
    strcpy(&temp[max - strlen(str2) + 1], str2);
    i = 0;
    while (temp[i] == '\0'){
         temp[i] = '0';
         i++;
    }
    strcpy(str2, temp);
    
    for (i = max; i >= 0; i--){
        str1[i] += str2[i] - '0';
        if (str1[i] > '9'){
            str1[i] -= 10;
            str1[i - 1] += 1;
        }
    }
    if (str1[0] == '0'){
        memset(temp, '\0', 1000);
        strcpy(temp, &str1[1]);
        memset(str1, '\0', 1000);
        strcpy(str1, temp);
    }
}

int main(void)
{
    char str[1000], str2[1000];
    int n;
    
    scanf("%d", &n);
    
    while (n-- != 0){
        memset(str, '\0', 1000);
        memset(str2, '\0', 1000);
        
        scanf("%s", str);
        getchar();
        scanf("%s", str2);
        getchar();
        
        addstr(str, str2);
        
        if (strlen(str) < 81){
            printf("%s\n", str);
        }
        
        else {
            printf("overflow\n");
        }
    }
    
    return (0);
}

Measured memory_bytes: 600
# ATCoder
# ACGTだけ
S = input()

def getAns(S) :
    cnt = 0
    rtn = 0
    for i in S :
        if i == "A" or i == "C" or i == "G" or i == "T" :
            cnt += 1
            rtn = max(cnt, rtn)
        else :
            cnt = 0
    return rtn

print(getAns(S))


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readc(n, m, k);
	readarr(a, n);
	readarr(b, m);
	
	map <int, int> mp;
	int sum = 0;
	FOR (i, 1, m)
	{
	    sum += b[i];
	    mp[sum] = i;
	}
	
	int ans = 0;
	sum = a[0] = 0;
	FOR (i, 0, n)
	{
	    sum += a[i];
	    if (sum > k) break;
	    
	    auto it = mp.upper_bound(k - sum);
	    if (it == mp.begin()) ans = max(ans, i);
	    else ans = max(ans, (*(--it)).se + i);
	}
	
	print(ans);
}



















Measured memory_bytes: 19292
from collections import deque
N = int(input())
edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

def bfs(v0):
    dist = [-1]*N
    que = deque([v0])
    dist[v0] = 0
    while que:
        v = que.pop()
        d = dist[v]
        for nv in edges[v]:
            if dist[nv] < 0:
                que.append(nv)
                dist[nv] = d+1
    m = max(dist)
    v = dist.index(m)
    return v, m
u, _ = bfs(0)
_, dia = bfs(u)
if N == 1:
    print('First')
elif (dia+1-2)%3 == 0:
    print('Second')
else:
    print('First')


Measured memory_bytes: 94796
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int popcount(long long n) { int cnt = 0; for ( ; n; n &= n - 1) cnt++; return cnt; }

int main() {
    int n; cin >> n;
    int mask = 0;
    while (n--) {
        char c; cin >> c;
        mask |= (c == 'P') << 0;
        mask |= (c == 'W') << 1;
        mask |= (c == 'G') << 2;
        mask |= (c == 'Y') << 3;
    }
    if (popcount(mask) == 3) cout << "Three" << endl;
    if (popcount(mask) == 4) cout << "Four" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll t;
  cin >> t;
  rep(_, t) {
    ll n;
    cin >> n;
    ll ans = 0;
    vector<P> pl, pr;
    rep(i, n) {
      ll k, l, r;
      cin >> k >> l >> r;
      if(l >= r) {
        ans += r;
        pl.push_back({k, l - r});
      } else {
        ans += l;
        pr.push_back({k, r - l});
      }
    }
    sort(all(pl), greater<P>());
    sort(all(pr));
    priority_queue<ll> q1;
    ll j = 0;
    for(ll i = pl.size(); i >= 1; i--) {
      while(j < pl.size() && pl[j].first >= i) {
        q1.push(pl[j].second);
        j++;
      }
      if(q1.empty()) continue;
      ans += q1.top();
      q1.pop();
    }
    priority_queue<ll> q2;
    j = 0;
    rep2(i, n - pr.size() + 1, n + 1) {
      while(j < pr.size() && pr[j].first < i) {
        q2.push(pr[j].second);
        j++;
      }
      if(q2.empty()) continue;
      ans += q2.top();
      q2.pop();
    }
    cout << ans << '\n';
  }
}

Measured memory_bytes: 8076
/* be name khoda */

// #define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD

stringstream sss;

// -----------------------------------------------------------------------

const ll maxn = 100010;

ll n, L;
ll A[maxn];

void MAIN() {

    cin >> n >> L;
    fori (i, n) cin >> A[i];
    ll g = -1;
    fori (i, n - 1) if (A[i] + A[i + 1] >= L) g = i;
    if (g == -1) {
        cout << "Impossible\n";
    } else {
        cout << "Possible\n";
        fori (i, g) cout << i + 1 << '\n';
        forirto (i, n - 1, g) cout << i + 1 << '\n';
    }

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
5 50
10 20 30 40 50
    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>

int main(){
	int n,i;
	char s[101];
	scanf("%d%s",&n,s);
	int r=0,b=0;
	for(i=0;i<n;i++){
		if(s[i]=='R')r++;
		else b++;
	}
	if(r>b)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
now = 2
n = int(raw_input())
a = []
for i in xrange(n):
    p = int(raw_input())
    a.append(p)

res = a[0]-1
a.pop(0)

for x in a:
    if x > now:
        if x % now:
            res += x / now
        else:
            res += x / now - 1
    if x == now:
        now += 1
print res

Measured memory_bytes: 5764
#include <bits/stdc++.h>
using namespace std;

int main(void) {
  int X, cnt=0;
  cin >> X;
  
  while(true){
    if(X >= 500){
      X -= 500;
      cnt += 1000;
    }
    else
      break;
  }
  
  while(true){
    if(X >= 5){
      X -= 5;
      cnt += 5;
    }
    else
      break;
  }
 
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
<?php

$inputs = explode("\n", file_get_contents("php://stdin"));
list($meta, $postalCode) = $inputs;
list($a, $b) = array_map("intval", explode(" ", $meta));

$reg = "/^[0-9]{".$a."}-[0-9]{".$b."}$/";
if(preg_match($reg, $postalCode) === 1) {
  echo "Yes";
} else {
  echo "No";
}

Measured memory_bytes: 4340
#ifdef LOCAL_EXEC
#include "include.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define trace(...)
#endif

using LL = long long;

const LL MOD = 998244353;
LL modpow(LL a, LL n) {
	LL res = 1;
	for (a %= MOD; n > 0; n >>= 1) {
		if (n & 1) res = (res * a) % MOD;
		a = (a * a) % MOD;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int n; cin >> n;
	vector<int> f(n);
	LL ans = 1;
	for (int i = 0; i < n; i++) {
		int d; cin >> d;
		if (i == 0 && d != 0) ans = 0;
		f[d]++;
	}

	if (f[0] != 1) ans = 0;
	for (int d = 1; d < n; d++) {
		if (f[d] > 0) {
			ans *= modpow(f[d - 1], f[d]);
			ans %= MOD;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

using namespace std;

int main()
{
    int n,res=0,i;
    long long int d, x, y;
    scanf("%d %lld",&n,&d);
    d*=d;
    while(n--)
    {
        scanf("%lld %lld",&x,&y);
        if(x*x+y*y<=d)
            res++;
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 1732
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int judge;
		List<Integer> sumSet = new ArrayList<Integer>();

		Scanner sc = new Scanner(System.in);

		boolean continueFrag = false;

		while (true) {

			judge = sc.nextInt();
			if(judge==0)break;


			int[] point = new int[judge];

			for (int pointSet = 0; pointSet < judge; pointSet++) {

				point[pointSet] = sc.nextInt();

			}

			Arrays.sort(point);
			int sum = 0;

			for (int sumNum = 1; sumNum < judge - 1; sumNum++) {
				//			int sum;
				sum += point[sumNum];
			}
			sum = sum / (judge - 2);
			sumSet.add(sum);



		}
		for (int output : sumSet) {
			System.out.println(output);
		}
	}
}



Measured memory_bytes: 30060
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
//#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 1000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;


//std::vector<std::set<int>> g;
ll ggd(ll a, ll b) {//最小公倍数，最大公約数
	if(a<b)swap(a,b);
	if (b == 0) {
		return a;			
	}
	return ggd(b, a % b);
}
ll lcm(ll number1,ll number2){
	return number1/ggd(number1,number2)*number2;	
}

int main(){
    int a,b;
    std::cin >> a>>b;
    std::cout << ggd(a,b) << std::endl;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;

 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    string a,b;
    ll ans=0;
    ll l;
    if(s.length() % 2 == 0){
        l = s.length()/2;
    }else{
        l = (s.length()-1)/2;
    }
    a += s.substr(0,l);
    reverse(all(s));
    b += s.substr(0,l);
    rep(i,l){
        if(a[i] != b[i]) ans++;
    }
    
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 256
N,M,Q = map(int,input().split())
cond_list = []
for i in range(Q) :
    cond_list.append(list(map(int,input().split())))

# len(A) < 10でも、10個数えていいはず。
# 条件に出てこないだけ。

max_score = 0
# 開始値を上位ループの値にすれば単調増加にできる
for A1 in range(1,M+1) :
    for A2 in range(A1, M+1) :
        for A3 in range(A2, M+1) :
            for A4 in range(A3, M+1) :
                for A5 in range(A4, M+1) :
                    for A6 in range(A5, M+1) :
                        for A7 in range(A6, M+1) :
                            for A8 in range(A7, M+1) :
                                for A9 in range(A8, M+1) :
                                    for A10 in range(A9, M+1) :
                                        tmpA = [A1,A2,A3,A4,A5,A6,A7,A8,A9,A10]
                                        tmp_score = 0
                                        for a,b,c,d in cond_list :
                                            if (tmpA[b-1] - tmpA[a-1] == c) :
                                                tmp_score += d
                                        if (max_score < tmp_score) :
                                            max_score = tmp_score

print(max_score)

Measured memory_bytes: 9152
def gcm(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else: 
        return gcm(a%b,b) if a>=b else gcm(a,b%a)

def lcn(a,b):
    return a*b//gcm(a,b)

a,b=map(int,input().split())
print(lcn(a,b))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i > 0; i--)

int main() {
    int N;
    cin >> N;
    vector<p> A(N);
    rep(i,N){
        int x;
        cin >> x;
        A[i] = p(x,i+1);
    }
    sort(A.begin(),A.end());
    rep(i,N){
        cout << A[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();in.nextLine();
        String s = in.nextLine();
        int index = s.indexOf("ABC");
        int cnt = 0;
        while(index != -1) {
            cnt++;
            index = s.indexOf("ABC", index + 3);
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;

/// bが真なら"Yes"を返す。そうでなければ"No"を返す。
string get_yes_or_no(bool b) {
  return b ? "Yes" : "No";
}

/// xsがかわいそうなら真を返す。
bool get_is_poor(vector<int> xs) {
  if (xs.size() != 3) {
    /// 要素数が3でない場合については、かわいそうかどうかが定義されていない。
    printf("Error: xs.size() != 3\n");
    exit(0);
  }
  set<int> xs1 = set<int>(xs.begin(), xs.end());
  return xs1.size() == 2;
}

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> xs = vector<int>({A, B, C});
  bool is_poor = get_is_poor(xs);
  string s = get_yes_or_no(is_poor);
  cout << s << endl;
}

Measured memory_bytes: 256
r=0;(N,),*d=$<.map{|s|s.split.map &:to_i};N.times{|i|i.upto(N-1){|j|a=d[i][j];N.times.any?{|k|a>(b=d[i][k]+d[k][j])?(p~0;exit):a==b&&i!=k&&j!=k}||r+=a}};p r

Measured memory_bytes: 3324
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 10000;
const int MAX_K = 10;
const int MAX_Q = 200;

/* typedef */

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

/* global variables */

int n, k;
bool xs[MAX_N], used[MAX_N];

/* subroutines */

bool ask(int i0 = 0, int i1 = n) {
  putchar('?');
  for (int i = 0; i < n; i++)
    printf("%d", (i0 <= i && i < i1) ? xs[i] : 0);
  putchar('\n');

  int ans;
  cin >> ans;
  return (bool)ans;
}

void putans() {
  bool first = true;

  putchar('!');
  for (int i = 0; i < n; i++)
    if (used[i]) {
      if (i > 0) putchar(' ');
      printf("%d", i + 1);
    }
  putchar('\n');
  
}

/* main */

int main() {
  srand(time(NULL));

  cin >> n >> k;

  if (n == k) {
    for (int i = 0; i < n; i++) used[i] = true;
    putans();
    return 0;
  }
  
  memset(used, false, sizeof(used));
  int m = 0;

  while (m < k) {
    do {
      for (int i = 0; i < n; i++)
	xs[i] = used[i] ? 0 : (rand() & 1);
    } while (! ask());

    int i0 = 0, i1 = n;

    while (i0 + 1 < i1) {
      int im = (i0 + i1) / 2;
      if (ask(i0, im)) i1 = im;
      else i0 = im;
    }

    used[i0] = true;
    m++;
  }

  putans();
  
  return 0;
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;

using lint = long long;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    lint N;
    cin >> N;

    set<lint> t = {111, 222, 333, 444, 555, 666, 777, 888, 999};
    repu(i, N, 1000, 1) {
        if(t.find(i) != t.end()) {
            cout << i << endl;
            exit(0);
        }
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 3588
fn main() {
    let nk = read_vec::<usize>();
    let mut v: Vec<i32> = vec![];
    for _ in 0..nk[0] {
        v.push(read::<i32>());
    }
    v.sort();
    let mut res = 1000000000;
    for i in 0..(nk[0]-nk[1]+1) {
        let i = i as usize;
        if res > v[i+nk[1]-1] - v[i] {
            res = v[i+nk[1]-1] - v[i];
        }
    }
    println!("{}", res);

}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352