akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 8000008
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int calc(vector<int> a, int curr){
	int res = 0;
	rep (i, a.size()) res += (a[i] - curr) * (a[i] - curr);
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> a(N, 0);
	int lo = 100;
	int hi = -100;
	rep (i, N){
		cin >> a[i];
		lo = min(lo, a[i]);
		hi = max(hi, a[i]);
	} // end rep

	int res = (lo != hi ? INF : 0);
	int cnt = 0;
	while(lo < hi && cnt < 100){
		int mid1 = (2*lo + hi) / 3;
		int mid2 = (lo + 2*hi) / 3;
		int curr1 = calc(a, mid1);
		int curr2 = calc(a, mid2);
		if (curr1 > curr2){
			res = min(res, curr2);
			lo = mid1;
		}else{ // if (curr1 <= curr2)
			res = min(res, curr1);
			hi = mid2;
		} // end if
		++cnt;
	} // end while

	cout << res << endl;
 
	return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var m1 = long.Parse(line[0]);
        line = Console.ReadLine().Trim().Split(' ');
        var m2 = long.Parse(line[0]);
        Console.WriteLine(m1 == m2 ? 0 : 1);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 1000010;

int n, m, dis[maxn], f[maxn], id[maxn];
vector <pair <int, int> > edge[maxn];
vector <int> g[maxn];
bool vis[maxn];

int find(int x) {
	if(f[x] == x) return f[x];
		else return f[x] = find(f[x]);
}

int main()
{
	scanf("%d %d", &n, &m);
	int cnt = n;
	for(int i = 1; i <= m; i++) {
		int u, v, w;
		scanf("%d %d %d", &u, &v, &w);
		edge[w].pb(mp(u, v));
	}
	for(int col = 1; col <= 1000000; col++) {
		if(edge[col].empty()) continue;
		for(int i = 0; i < edge[col].size(); i++) {
			vis[edge[col][i].first] = vis[edge[col][i].second] = 0;
			f[edge[col][i].first] = edge[col][i].first, f[edge[col][i].second] = edge[col][i].second;
			id[edge[col][i].first] = id[edge[col][i].second] = -1;
		}
		for(int i = 0; i < edge[col].size(); i++) {
			int root1 = find(edge[col][i].first), root2 = find(edge[col][i].second);
			if(root1 != root2) f[root2] = root1;			
		}
		for(int i = 0; i < edge[col].size(); i++) {
			if(!vis[edge[col][i].first]) {
				int root1 = find(edge[col][i].first);
				vis[edge[col][i].first] = 1;
				if(id[root1] == -1) id[root1] = ++cnt;
				g[id[root1]].push_back(edge[col][i].first);
				g[edge[col][i].first].push_back(id[root1]);
			}
			if(!vis[edge[col][i].second]) {
				int root2 = find(edge[col][i].second);
				vis[edge[col][i].second] = 1;
				if(id[root2] == -1) id[root2] = ++cnt;
				g[id[root2]].push_back(edge[col][i].second);
				g[edge[col][i].second].push_back(id[root2]);
			}
		}
	}
	memset(dis, -1, sizeof(dis));
	dis[1] = 0;
	queue <int> q;
	q.push(1);
	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(int i = 0; i < g[u].size(); i++) {
			int v = g[u][i];
			if(dis[v] == -1) {
				dis[v] = dis[u] + 1;
				q.push(v);
			}
		}
	}
	if(dis[n] == -1) cout << "-1" << endl;
		else cout << dis[n] / 2 << endl;
	return 0;
}

Measured memory_bytes: 70912
/*    *** Bismillahir Rahmanir Rahim***
          *A S M Masud Parvez*
             *18ICTCSE035*
           *SHIICT(BSMRSTU)*
*/
#include<bits/stdc++.h>
using namespace std;
#define MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define        nl "\n"
#define        End return 0
#define        gt greater<int>()
#define        ll long long int
#define        mp make_pair
#define        pb push_back
#define        mod 1000000007
#define        ull unsigned long long int
int            Max = INT_MIN;
int            Min = INT_MAX;
#define        pi acos(-1)
int i,j,f=0,x,y,z,S=0,len,n,m;
/*
bool isprime(int n)
{
  if(n<2)return false;
  for(i=2;i*i<=n;i++)
  {
    if(n%i==0)
    return false;
  }
  return true;
}*/

int main()
{
  MP;

cin>>n>>m;
int a[m];
for(i=0;i<m;i++){
  cin>>a[i];
  S+=a[i];
}
if(n>=S){
  cout<<n-S;
}else cout<<-1;


  End;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
 
// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
using namespace __gnu_pbds;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9 + 7;

const int maxn = 1e5 + 7;
vector<int> graph[maxn];

int dp[maxn], ans[maxn];

void dfs(int u, int p)
{
    dp[u] = 1;
    for(int &v: graph[u])
        if(v != p)
        {
            dfs(v, u);
            dp[u] *= (dp[v] + 1);
            dp[u] %= mod;
        }
}

void dfs2(int u, int p, int val)
{
    ans[u] = (val + 1);
    ans[u] %= mod;
    int cnt = 0, prf = 1;
    vector<int> pref, suff, tmp;
    for(int &v: graph[u])
        if(v != p)
        {
            ans[u] *= (dp[v] + 1);
            ans[u] %= mod;
            int t = (dp[v] + 1);
            t %= mod;
            prf *= t;
            prf %= mod;
            pref.pb(prf);
            tmp.pb(t);
            cnt++;
        }
    reverse(tmp.begin(), tmp.end());
    int s = 1;
    for(int &e: tmp)
    {
        s *= e;
        s %= mod;
        suff.pb(s);
    }
    reverse(suff.begin(), suff.end());
    int i = 0;
    for(int &v: graph[u])
        if(v != p)
        {
            int pf = (i > 0 ? pref[i-1] : 1);
            int sf = (i < cnt-1 ? suff[i+1] : 1);
            int t = pf * sf;
            t %= mod;
            t *= ((val + 1) % mod);
            t %= mod;
            dfs2(v, u, t);
            i++;
        }
}

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n;
    cin >> n >> mod;
    for(int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    dfs(1, 1);
    dfs2(1, 1, 0);
    for(int i = 1; i <= n; i++)
        cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 29952
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}



int main(){
  cout<<setprecision(1000);
  ll N,M,X;
  cin>>N>>M>>X;
  vector<ll> C(N);
  vector<vector<ll>> A(N,vector<ll>(M));
  REP(N){
    cin>>C[i];
    For(j,M){
      cin>>A[i][j];
    }
  }
  bool yn=false;
  ll ans=INF;
  REP((1<<N)){
    vector<ll> score(M);
    ll cur=0;
    For(j,N){
      if((1<<j)&i){
        cur+=C[j];
        For(k,M){
          score[k]+=A[j][k];
        }
      }
    }
    bool f=true;
    For(j,M){
      if(score[j]<X){
        f=false;
        break;
      }
    }
    if(f){
      yn=true;
      ans=min(ans,cur);
    }
  }
  if(yn){
    cout<<ans<<endl;
  }else{
    cout<<-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 3632
import bisect
n = int(input())
lis = list(map(int,input().split()))
lis.sort()
ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    k = bisect.bisect_left(lis,lis[i]+lis[j])
    ans += max(k-j-1,0)
print(ans)

Measured memory_bytes: 3316
S = input()
T = input()
Ns = len(S)
Nt = len(T)
if Ns<Nt:
   print("UNRESTORABLE")
else:
   S_merge=""
   isok = True
   for i in range(Ns-Nt,-1,-1):
      isok = True
      # print(S[i:i+Nt], T)
      for j in range(Nt):
         if not (S[i+j] == T[j] or S[i+j]=="?"):
            isok = False
            break
      if isok:
         # if i > 0:
         S_merge = S[:i]+T+S[i+Nt:]
         # else:
         #    S_merge = T
         break
   if not isok:
      print("UNRESTORABLE")
   else:
      # print(S_merge)
      S_ans =""
      for i in range(Ns):
         if S_merge[i]=="?":
            S_ans = S_ans+'a'
         else:
            S_ans = S_ans+S_merge[i]
      print(S_ans)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<int>>;


int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> C(N);
	vector<vector<int>> A(N, vector<int>(M));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M + 1; j++) {
			if (j == 0) cin >> C[i];
			else cin >> A[i][j - 1];
		}
	}

	/*for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			if (j == M - 1) cout << A[i][j] << endl;
			else cout << A[i][j] << " ";
		}
	}*/

	vector<int> num(M + 1);// num[i]はi番目のアルゴリズムの理解度
	vector<int> num2(M + 1);// num[i]はi番目のアルゴリズムの理解度

	bool flag = true;
	for (int i = 0; i < M; i++) {//横のindex
		int sum = 0;
		for (int j = 0; j < N; j++) {// 縦のindex
			sum += A[j][i];
		}
		if (sum < X) {
			flag = false; 
			break;
		}
	}
	if (flag == false) cout << -1 << endl;
	else {
		vector<int> ans;

		for (int tmp = 0; tmp < (1 << N); tmp++) {
			bitset<12> s(tmp);// Nビットのsの各位の1,0を各参考書の有無に対応させる
			int money = 0;
			
			//ビットの各桁を見て、各アルゴリズムの理解度を計算
			for (int i = 0; i < N; i++) {
				
				if (s.test(i)) {
					money += C[i];
					for (int j = 0; j < M; j++) num[j + 1] += A[i][j];
				}
			}
          
          	//for (int j = 0; j < M; j++) cout << num[j + 1] << endl;
          
			bool flag2 = true; //各アルゴリズムの理解度がX以上か
			for (int i = 1; i <= M; i++) {
				if (num[i] < X) {
					flag2 = false;
					break;
				}
			}

			if (flag2 == true) ans.push_back(money);
			num = num2;


		}
		sort(ans.begin(), ans.end());
		cout << ans[0] << endl;
	}

}

Measured memory_bytes: 3632
#include<stdio.h> 
#define MAX 100001
  
typedef struct Card{
    char mark;
    int num;
    int index;
} c;
  
int n;
  
int Partition(c A[],int p,int r){
    int i, j, s;
    c t, u;

    s = A[r].num;
    i = p - 1;
    
    for(j = p; j <= r-1; j++){
        if(A[j].num <= s){
            i++;
            t = A[i];      
            A[i] = A[j];
            A[j] = t;
        }
    }
    
    u = A[i+1];        
    A[i+1] = A[r];
    A[r] = u;
    
    return i+1;
}
  
void QuickSort(c Q[], int p, int r){
    int q;
    if(p < r){
        q = Partition(Q, p, r);
        QuickSort(Q, p, q-1);
        QuickSort(Q, q+1, r);
    }
}
  
int JudgeStability(c K[], int n){
    int i;
    for(i = 1; i < n; i++){
        if((K[i-1].num == K[i].num) && (K[i-1].index > K[i].index)){
            return 0; 
        } 
    }
    
    return 1;
}
  
int main(){
    int i;
    c P[MAX];
    scanf("%d", &n);
    
    for(i = 0; i < n; i++){
        scanf(" %c %d", &P[i].mark, &P[i].num);
        P[i].index = i;
    }
  
    QuickSort(P, 0, n-1);
    if(JudgeStability(P,n) == 1) printf("Stable\n");
    else if(JudgeStability(P,n) == 0) printf("Not stable\n");
    for(i = 0; i < n; i++){
        printf("%c %d\n", P[i].mark, P[i].num);
    }
  
    return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof x)
#define copy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}

const int MAXN = 15;
const int MAXM = (1 << 15) + 5;
const int mod = 1e9 + 7;

inline void inc(int &x, int y) { x += y; if (x >= mod) x -= mod; }

int f[MAXM], table[MAXM], n, G[MAXN], m;

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = read(), m = read();
	table[0] = 1; f[0] = 1;
	for (int i = 1; i <= m; i ++) table[i] = (table[i - 1] << 1) % mod;
	for (int i = 1, x, y; i <= m; i ++) x = read() - 1, y = read() - 1, G[x] |= 1 << y;
	for (int S = 1; S < (1 << n); S ++) if ((S & 1) == (S >> 1 & 1))
		for (int T = S; T; T = T - 1 & S) if ((T & 1) == (T >> 1 & 1))
		{
			int ways = 1;
			for (int i = 0; i < n; i ++) if (S >> i & 1)
			{
				if (T >> i & 1) ways = 1LL * ways * table[__builtin_popcount(G[i] & (S ^ T))] % mod;
				else ways = 1LL * ways * (table[__builtin_popcount(G[i] & T)] - 1) % mod;
			}
			inc(f[S], 1LL * f[S ^ T] * ways % mod);
		}
	return printf("%d\n", (table[m] - f[(1 << n) - 1] + mod) % mod), 0;
}


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

#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define endl '\n'
#define exists(s, e) (s.find(e)!=s.end())
#define WHILE(n)
#define pb push_back
#define f first
#define s second
#define UNI(vec) vec.erase(std::unique(vec.begin(), vec.end()),vec.end());
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
typedef long long ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<int, pii> piii;

const int INF = 0x3f3f3f3f;
#define MAXN 100001
using namespace std;
int n,m,ans,k;
int a[MAXN];
int dp[MAXN];

int main(){
    MEM(dp, INF);
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n>>k;
    for (int i =0; i < n; i++){
        cin>>a[i];
    }
    dp[0] = 0;
    for(int i = 0 ; i < n-1; i++){
        for(int j = 1; j <= k && i+j < n; j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(a[i] - a[i+j]));
        }
    }
    cout<<dp[n-1];



}


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


int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	long long int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				  int a=i,b=j,c=k;
					int val=__gcd(a,b);
					ans+=__gcd(val,c);
			}
		}
	}
	cout<<ans<<"\n";




	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
   int h,a;
   cin >> h >> a;
   int cnt=0;
   while(true){
      cnt++;
      h-=a;
      if(h<=0) break;
   }
   cout << cnt <<endl;
   return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int n;
    int max_height = 0;
    int sum = 0;
    int h = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h;
        if (h >= max_height) {
            max_height = h;
            sum++;
        }
    }
    cout << sum << endl;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    sort(A.begin(), A.end());

    for (int i = 0; i < N-1; i++)
    {
        if (A.at(i) == A.at(i+1))
        {
            cout << "NO";
            exit(0);
        }
        
    }

    cout << "YES";
    
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  string s,t; cin >> s >> t;
  int ok = false;

  REP(i,s.size()) {
    if (s==t) ok=true;
    s = s.back() + s; s.pop_back();
  }
  COUT(ok? "Yes":"No");
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import math

#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

#############
# Main Code #
#############

N,M = map(int, input().split())

ans = "No"
if N == M:
  ans = "Yes"
print(ans)


Measured memory_bytes: 38452
from copy import *

def init(N,node,unit,func):
  n=1
  while n<N:
    n<<=1
  for i in range(n*2-1):
    if len(node)<=i:
      node.append(deepcopy(unit))
    else:
      node[i]=deepcopy(unit)
  node.append(func)
  node.append(unit)

def upd(node,x,a):
  y=(len(node)>>1)+x-1
  node[y]=a
  while y:
    y=(y-1)>>1
    node[y]=node[-2](node[(y<<1)+1],node[(y+1)<<1])

def query(node,l_q,r_q,k,l_m,r_m):
  if r_q<=l_m or r_m<=l_q:
    return node[-1]
  if l_q<=l_m and r_m<=r_q:
    return node[k]
  l_a=query(node,l_q,r_q,2*k+1,l_m,(l_m+r_m)//2)
  r_a=query(node,l_q,r_q,2*k+2,(l_m+r_m)//2,r_m)
  return node[-2](l_a,r_a)

N,Q=map(int,input().split())
node=[]
init(N,node,(1<<31)-1,lambda x,y:min(x,y))
c,x,y=0,0,0
for i in range(Q):
  c,x,y=map(int,input().split())
  if c:
    print(query(node,x,y+1,0,0,len(node)>>1))
  else:
    upd(node,x,y)


Measured memory_bytes: 9652
#include <iostream>

int main(int argc, char const *argv[]) {
  int n=0,x=0,min=10000000,max=-10000000;
  long long sum=0;
  std::cin >> n;

  for(int i=0;i<n;i++){
    std::cin >> x;
    if(x < min)min = x;
    if(x > max)max = x;
    sum += x;
  }

  std::cout << min << " " << max << " " << sum << std::endl;

  return 0;
}

Measured memory_bytes: 3104
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
ll Xor(ll a){
	if(a%4==0)return a;
	if(a%4==1)return 1;
	if(a%4==2)return a+1;
	else return 0;
}
int main() {
	ll a,b;cin>>a>>b;
	cout<<(Xor(a==0?0:a-1)^Xor(b));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    int s = 7,k,ans = 1;
    cin>>k;
    if(k%2 == 0){
        ans = -1;
    }
    else{
        while(true){
            if(s % k == 0)break;
            if(ans >= 1e7){
                ans = -1;
                break;
            }
            s = s % k;
            s = s * 10 + 7;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int a, b;

int main() {
	cin >> a >> b;
	int res = (a * (a - 1)) / 2 + (b * (b - 1)) / 2;
	cout << res << endl;
	return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
const int intinf = numeric_limits<int>::max();

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main()
{
    int N;
    cin >> N;
    vector<int> B(N + 1);
    B[0] = intinf;
    rep(i, N - 1) cin >> B[i + 1];
    B[N] = intinf;

    vector<int> A(N);
    rep(i, N)
        A[i] = min(B[i], B[i + 1]);

    int sum = accumulate(A.begin(), A.end(), 0);
    cout << sum << endl;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//これを使うときにはCOMinit();を忘れずに

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    COMinit();
    int N, K; cin >> N >> K;
    ll A[N]; rep(i, N) cin >> A[i];
    ll ans = 0;
    ll acc1 = 0, acc2 = 0;
    sort(A, A+N);
    //A[i](i >= K-1)がmaxとして採用される選び方はiC(K-1)
    //(K-1)C(K-1)*A[K-1] + (K)C(K-1)*A[K] + ... + (N-1)C(K-1)*A[N-1] ...(1)
    for(int i = K-1; i <= N-1; i++){
        acc1 = (acc1 + (COM(i, K-1)*A[i] % MOD)) % MOD;
    }

    reverse(A, A+N);
    //再度(1)を計算し,引き算 答えが負なら+MOD
    for(int i = K-1; i <= N-1; i++){
        acc2 = (acc2 + (COM(i, K-1)*A[i] % MOD)) % MOD;
    }
    ans = (acc1 - acc2) % MOD;

    if(ans < 0) ans += MOD;
    assert(ans >= 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13056
#include<stdio.h>

int main(void){
    int a,b,c,x;
    int cnt;
    int i,j,k;

    scanf("%d %d %d %d",&a,&b,&c,&x);
    for(i=0;i<=a;i++){
        for(j=0;j<=b;j++){
            for(k=0;k<=c;k++){
                if(x==i*500+j*100+k*50){
                    cnt++;
                }
            }
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[] box = new int[3];
		for(int i = 0; i < 3; i++) box[i] = in.nextInt();
		swap(box, 0, 1);
	    swap(box, 0, 2);
	    System.out.println(Arrays.toString(box).replace("[", "").replace("]", "").replace(",", ""));
	}
	public static void swap(int[] box, int a, int b) {
		int temp = box[a];
		box[a] = box[b];
		box[b] = temp;
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
using namespace std;
int main(){
   int A,B,C,K,T;
   cin >> A >> B >>C >>K;
   if(B>A){
     T=A;
     A=B;
     B=T;
   }
   if(C>A){
     T=A;
     A=C;
     C=T;
   }
   int i;
   for(i=0;i<K;i++){
     A=2*A;
   }
   cout << A+B+C;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	cout << 10 - n / 200 << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

bool used[305];
vector<int> cnt(305, 0);
vector<int> pos(305, 0);

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            cin >> a[i][j];
            --a[i][j];
        }
        ++cnt[a[i][0]];
    }
    
    int res = numeric_limits<int>::max();
    while(1){
        auto it = max_element(cnt.begin(), cnt.end());
        res = min(res, *it);
        *it = 0;
        used[it - cnt.begin()] = true;
        for(int i = 0; i < n; ++i){
            if(!used[a[i][pos[i]]]) continue;

            while((pos[i] < m) && (used[a[i][pos[i]]])){
                ++pos[i];
            }
            if(pos[i] < m)  ++cnt[a[i][pos[i]]];
        }

        if(find(pos.begin(), pos.begin() + m, m) != pos.begin() + m){
            break;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mod 100003
using namespace std;

int main()
{
    int n;
    float x;
    cin >> n;
    x = 1.0 * 100 * n / 108;
    x = ceil(x);
    float new_n = x * 1.08;
    if (new_n - n < 1 && new_n - n >= 0) cout << x;
    else cout << ":(";
    return 0;
}


Measured memory_bytes: 256
import sys
from itertools import product


def main():
    input = sys.stdin.buffer.readline
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    ans = 10 ** 12
    for p in product((0, 1), repeat=n - 1):
        max_h = a[0]
        visible = 1
        cost = 0
        for i in range(1, n):
            if a[i] > max_h:
                max_h = a[i]
                visible += 1
            elif p[i - 1]:
                cost += max_h + 1 - a[i]
                max_h += 1
                visible += 1
        if visible < k:
            continue
        ans = min(ans, cost)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9260
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

------------------------------------------------------------

最大流 最大フロー 最小カット Dinic法 ディニック法

------------------------------------------------------------

*/

void main(){
	int n = read.to!int;
	int m = read.to!int;
	
	Node[] nodes;
	foreach(i; 0 .. n) nodes ~= new Node(i);
	debug writeln("nodes:", nodes);
	
	long infty;
	foreach(j; 0 .. m){
		int a = read.to!int - 0;
		int b = read.to!int - 0;
		long c = read.to!int;
		new Edge(nodes[a], nodes[b], c);
		infty += c;
	}
	infty += 100;
	debug writeln("nodes:", nodes);
	debug writeln("infty:", infty);
	
	Node.start = nodes[0];
	Node.terminal = nodes[n - 1];
	
	long ans;
	while(1){
		foreach(nd; nodes) nd.isVisited = 0;
		Node.start.setDepth(0);
		if(! Node.terminal.isVisited) break;
		debug writeln("nodes:", nodes);
		
		while(1){
			long f = Node.start.flow(infty);
			debug writeln("f:", f, " nodes:", nodes);
			if(f > 0) ans += f;
			else break;
		}
		
	}
	
	ans.writeln;
}

class Node{
	static Node[] queue;
	static int iq;
	static Node start, terminal;
	
	long id;
	Edge[] edges;
	bool isVisited;
	int depth;
	bool isStart, isTerminal;
	
	this(long id){
		this.id = id;
	}
	
	void setDepth(int depth){
		if(this.isVisited) return;
		this.isVisited = 1;
		this.depth = depth;
		queue ~= this;
		foreach(ed; edges) if(ed.value > 0) ed.node1.setDepth(depth + 1);
	}
	
	long flow(long value){
		long flow = 0;
		foreach(ed; edges) if(ed.value > 0){
			debug writeln(this.id, "->", ed);
			Node nd = ed.node1;
			long res = min(value, ed.value);
			if(this.depth < nd.depth && nd.depth < terminal.depth){
				res = min(res, nd.flow(res));
			}
			else if(nd.id != terminal.id) continue;
			if(res > 0){
				ed.value -= res;
				ed.inv.value += res;
				flow += res;
				return flow;
			}
			debug writeln(this.id, "->", ed);
		}
		return flow;
	}
	
	override string toString(){
		return id.to!string ~ edges.to!string ~ "(" ~ depth.to!string ~ ")" ~ (isVisited?"v":"") ~ (isStart?"s":"") ~ (isTerminal?"t":"");
	}
}
class Edge{
	Node node0, node1;
	long value;
	Edge inv;
	this(Node node0, Node node1, long value){
		this.node0 = node0, node0.edges ~= this;
		this.node1 = node1;
		this.value = value;
		this.inv = new Edge(this);
		}
	this(Edge inv){
		this.node0 = inv.node1, inv.node1.edges ~= this;
		this.node1 = inv.node0;
		this.value = 0;
		this.inv = inv;
	}
	override string toString(){
		return this.node1.id.to!string ~ "(" ~ value.to!string ~ ")";
	}
}



Measured memory_bytes: 3024
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll a, b,c;
	cin >> a >> b >> c;
	vector<int>arr;
	map<int, int>mp;
	rep(i, b)mp[(a * (i + 1))%b]++;
	if (mp[c]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


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

int w, h;

void dfs(vector< vector<int> >& area, int x, int y, bool flag)
{
	if (flag) {
		area[x][y] ^= 4;
		if (x - 1 >= 0 && !(area[x - 1][y] & 2) && !(area[x - 1][y] & 4)) {
			dfs(area,x - 1,y,flag);
		}
		if (y - 1 >= 0 && !(area[x][y - 1] & 2) && !(area[x][y - 1] & 4)) {
			dfs(area, x, y - 1, flag);
		}
		if (x + 1 < w && !(area[x + 1][y] & 2) && !(area[x + 1][y] & 4)) {
			dfs(area, x + 1, y, flag);
		}
		if (y + 1 < h && !(area[x][y + 1] & 2) && !(area[x][y + 1] & 4)) {
			dfs(area, x, y + 1, flag);
		}
	}
	else {
		area[x][y] ^= 8;
		if (x - 1 >= 0 && !(area[x - 1][y] & 1) && !(area[x - 1][y] & 8)) {
			dfs(area, x - 1, y, flag);
		}
		if (y - 1 >= 0 && !(area[x][y - 1] & 1) && !(area[x][y - 1] & 8)) {
			dfs(area, x, y - 1, flag);
		}
		if (x + 1 < w && !(area[x + 1][y] & 1) && !(area[x + 1][y] & 8)) {
			dfs(area, x + 1, y, flag);
		}
		if (y + 1 < h && !(area[x][y + 1] & 1) && !(area[x][y + 1] & 8)) {
			dfs(area, x, y + 1, flag);
		}
	}
}

int main()
{
	char ch;
	while (cin >> w >> h, w || h) {
		vector< vector<int> > area(w, vector<int>(h));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> ch;
				if (ch == 'B') {
					area[j][i] = 1;
				}
				else if (ch == 'W') {
					area[j][i] = 2;
				}
			}
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (area[j][i] & 1) {
					dfs(area, j, i, true);
				}
				else if (area[j][i] & 2) {
					dfs(area, j, i, false);
				}
			}
		}
		int bn = 0, wn = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (!(area[j][i] & 3)) {
					if ((area[j][i] & 4) && !(area[j][i] & 8)) {
						bn++;
					}
					else if ((area[j][i] & 8) && !(area[j][i] & 4)) {
						wn++;
					}
				}
			}
		}
		cout << bn << " " << wn << endl;
	}
	return 0;
}

Measured memory_bytes: 3204
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 
const int INF = 1e9 + 10 ; 
int main(){
    fastio
    int n ;
    cin >> n ; 
    vector<vector<int>> cnt(n,vector<int>(26)) ;
    for(int i=0;i<n;i++){
    	string x ; 
    	cin >> x ; 
    	for(char &c : x){
    		cnt[i][c-'a']++;
    	}
    }
    vector<int> ans(26,INF) ;
    for(int i=0;i<26;i++){
    	for(int j=0;j<n;j++)
    		ans[i] = min(ans[i],cnt[j][i]);
    }
    for(int i=0;i<26;i++){
    	for(int j=0;j<ans[i];j++){
    		cout << char(i+'a') ; 
    	}
    }
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define dforr(i, a, b) for(int i = (int)(b-1); i >= (a); i--)
#define dforn(i, n) dforr(i, 0, n)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define sz(x) ((int)x.size())
#define fst first
#define snd second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int MAXN = -1;

int n, a, b, c, l1, l2;

int main(){
//	freopen("input.txt", "r", stdin);
	while(scanf("%d", &n) >= 1){
        scanf("%d %d", &l1, &l2);
        a = b = c = 0;
        forn(i, n){
            int x; scanf("%d", &x);
            if(x <= l1)a++;
            else if (x <= l2)b++;
            else c++;
        }
        printf("%d\n", min(a, min(b, c)));
	}
	return 0;
}


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

namespace ConsoleApp62 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            int type_A = 0;

            //〇×〇×〇×△型を探す
            for (int k = 1; k <= N; k += 2) {
                for (int i = 1; i * i * i <= k; i++) {
                    if (!isPrime(i)) {
                        continue;
                    }
                    if (k % i == 0 && k % (i * i) == 0 && k % (i * i * i) == 0 && k / (i * i * i) != i) {
                        if (isPrime(k / (i * i * i))) {
                            //Console.WriteLine("(k, i) = " + k + " " + i);
                            type_A++;
                        }
                    }
                }
            }

            int type_B = 0;

            //〇×△×◇型を探す
            for (int i = 1; i * (i + 1) * (i + 2) <= N; i += 2) {
                for (int j = i + 2; i * i * j <= N; j += 2) {
                    for (int k = j + 2; i * j * k <= N; k += 2) {
                        if (isPrime(i) && isPrime(j) && isPrime(k) && i * j * k <= N) {
                            //Console.WriteLine("(i, j, k) = " + i + " " + j + " " + k);
                            type_B++;
                        }
                    }
                }
            }


            Console.WriteLine(type_A + type_B);
        }

        //素数かどうかを返す
        static bool isPrime(int N) {
            if (N == 1) {
                return false;
            }

            if (N == 2 || N == 3) {
                return true;
            }

            for (int i = 2; i * i <= N; i++) {
                if (N % i == 0) {
                    return false;
                }
            }

            return true;
        }
    }
}

Measured memory_bytes: 13140
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  execute(sc.next())

  def execute(in: String): Unit = {
    in match {
      case "0" => sc.close()
      case _ =>
        println(in.toList.map(_.toString).map(_.toLong).sum)
        execute(sc.next())
    }
  }
}

Measured memory_bytes: 45664
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, m, l;
struct S{
    int now, d, e;
    //このままソートするとコストの昇順になる。priority_queueだと逆になる
    //priority_queue<S, vector<S>, greater<S> >の時はoperator>を定義しないと壊れる
    bool operator<(const S &s) const{
        return e > s.e;
    }
};
struct edge{
   int to, d, e;
};
vector<edge> G[110];
int dst[110][110];

void dijkstra(int s){
    rep(i, 0, 110) rep(j, 0, 110) dst[i][j] = INF;
    dst[s][0] = 0;

    priority_queue<S> q;
    q.push({s, 0, 0});
    while(!q.empty()){
        S p = q.top(); q.pop();
        int from = p.now;
        int dist = p.d;
        int cost = p.e;
        // cout << from << ' ' << dist << ' ' << cost << endl;
        if(dst[from][dist] < cost) continue;
        rep(i, 0, G[from].size()){
            edge e = G[from][i];
            int next = e.to;
            int newCost = e.e + cost;
            int newDist = e.d + dist;
            if(dst[next][newDist] > cost && newDist <= l){
                dst[next][newDist] = cost;
                q.push({next, newDist, cost});
            }
            if(dst[next][dist] > newCost){
                dst[next][dist] = newCost;
                q.push({next, dist, newCost});
            }
        }
    }
    int ans = INF;
    // rep(i, 0, n){
    //     rep(j, 0, l + 1){
    //         cout << dst[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    rep(i, 0, l + 1){
        chmin(ans, dst[n - 1][i]);
    }
    cout << ans << endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
        cin >> n >> m >> l;
        if(n + m + l == 0) break;
        rep(i, 0, n) G[i].clear();
        rep(i, 0, m){
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            a--; b--;
            G[a].push_back({b, d, e});
            G[b].push_back({a, d, e});
        }
        dijkstra(0);
    }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define esort(s) sort((s).begin(),(s).end())

typedef long long ll;
typedef pair<int,int> ipair;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N;
string S;
void solve(){
    cin>>N>>S;
    int ans=1;
    rep(i,N-1) if(S[i]!=S[i+1]) ans++;
    cout<<ans<<endl;
    return;
}

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

    solve();
    return 0;
}

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

#define ll long long 
#define pll pair<ll,ll> 

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll n,x, a;
	cin>>n>>x>>a;
	cout<<(a*((n+x-1)/x));

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef pair<ll, ll> PLL;

#define REP(i, j) for(int i=0;i<j;i++)
#define FOR(i, b, e) for(int i=b; i<=e; i++)
#define FORD(i, b, e) for(int i=b; i>=e; i--)
#define SIZE(x) ((int)x.size())
#define LAST(x) (x[SIZE(x)-1])
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sp ' '
#define ent '\n'

int n, h;
ll dp[100005];
VI nums;

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

    cin >> n;

    REP(i, n){
        cin >> h;
        nums.pb(h);
    }

    dp[0]=0;
    dp[1]=abs(nums[1]-nums[0]);

    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(nums[i-1] - nums[i]), dp[i-2]+abs(nums[i-2] - nums[i]));
    }

    cout << dp[n-1];

    return 0;
}


Measured memory_bytes: 1528
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
 
N, K = inpl()
A = sorted(inpl())
S = []
s = 0
for a in A:
    s += a
    S.append(s)

A = A[::-1]
DP = [True]+[False for _ in range(K-1)]

OK = [False for _ in range(N)]
 
for i, a in enumerate(A):
    DP1 = [False for _ in range(K)]
    if a >= K:
        OK[i] = True
        continue
    for j, d in enumerate(DP):
        if d:
            DP1[j] = True
            if j + a >= K:
                OK[i] = True
            else:
                DP1[j+a] = True
    DP = DP1

if sum(OK) == 0:
    print(N)
else:
    print(OK[::-1].index(True))

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

int main(){
  int n;
  cin>>n;
  vector<int> l(n);
  for(int i=0;i<n;++i) cin>>l[i];
  sort(l.begin(),l.end());
  int sum=0;
  for(int i=0;i<n-1;++i) sum += l[i];
  if(sum>l[n-1]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

namespace B___Trained
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var ai = Enumerable.Range(1, N).Select(_ => int.Parse(Console.ReadLine())).ToArray();
            int index = 1, count = 0;

            while (true)
            {
                index = ai[index - 1];
                count++;
                if (count == N) break;
                if (index == 2) break;
            }

            Console.WriteLine(count == N ? -1 : count);
        }
    }
}


Measured memory_bytes: 15400
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\n/);
const IN = input[0].split(' ').map(str => parseInt(str, 10));
console.log((IN[0] * IN[1]) % 2 === 0 ? 'Even' : 'Odd');

Measured memory_bytes: 7372
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n = int(input())
a = list(map(int, input().split()))
s = [0]*n
s[0] = a[0]
for i in range(n-1):
    s[i+1] = s[i] + a[i+1]

s.sort()
c = 1
x = s[0]
ans = 0

if x==0:
    ans +=1

for i in range(1,n):
    if s[i]==0:
        ans +=1

    if x==s[i]:
        c +=1
    else:
        if c>1:
            ans += cmb(c,2)
        c = 1
        x = s[i]
if c>1:
    ans += cmb(c,2)
print(ans)

Measured memory_bytes: 25724