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

#define vc vector
#define pb push_back
#define pf push_front
#define pr pair
#define mp make_pair
#define fi first
#define se second
#define uset unordered_set
#define umap unordered_map
#define str string
#define pq priority_queue
#define forn(i, a, b) for(int i = (a); i < (b); i++)
#define forr(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a) forn(i, 0, a)
#define all(x) x.begin(), x.end()
#define rev(x) x.rbegin(), x.end()
#define len(x) (int)x.size()
#define last(x) x[len(x)-1]
#define forall(i, x) for(auto &i : x)
#define endl '\n'

#define int long long
#define pii pr<int, int>
#define vi vc<int>

const int MAX = 1E6;

inline void fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}
signed main()
{
    fastio();
    int n, m; cin >> n >> m;
    vi a(n, -1);
    rep(i, m){
        int x, y; cin >> x >> y;
        if(a[--x] != -1 && a[x] != y){
            cout << -1; return 0;
        }
        a[x] = y;
    }
    if(n != 1 && a[0] == 0) cout << -1;
    else if(n == 1)
        cout << (a[0] == -1 ? 0 : a[0]);
    else{
        if(a[0] == -1) cout << 1;
        else cout << a[0];
        if(n >= 2) cout << (a[1] == -1 ? 0 : a[1]);
        if(n >= 3) cout << (a[2] == -1 ? 0 : a[2]);
    }
}


Measured memory_bytes: 256
/*in the name of allah*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int n;
ll sum;
multiset<long long> s;

void read_input() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		sum -= (ll) y;
		s.insert((ll)(-x - y));
	}
}

void solve() {
	while (!s.empty()) {
		sum += *s.begin() * -1;
		s.erase(s.begin());
		if (!s.empty())
			s.erase(s.begin());
	}
	cout << sum << '\n';
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	read_input(), solve();
	return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL A, B; char op;
	cin >> A >> op >> B;
	LL ans = (op=='+'?A+B:A-B);

	cout << ans << endl;

	return 0;
}


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

int main(){

int ct = 0, n, k = 0;

cin >> n;
for(int i = 1; i <= n; i++){
  for(int j = 1; j <= n; j++){
    if(i % 2 ==1){
      if(i % j == 0) k++;
    }
  }
  if(k == 8) ct++;
  k = 0;
}
  cout << ct << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int A, B;
    cin >> A >> B;
    if ((A * B) % 2 != 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
	return 0;
}


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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef uint64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

vector<vector<ll>> mkcmb(const int MX){
	vector<vector<ll>> cmb(MX+2, vector<ll>(MX+2));
	rep(i,MX+1)  cmb[i][0] = 1;
	rep2(i,1,MX+1) rep2(j,1,i+1)
		cmb[i][j] = (cmb[i-1][j] + cmb[i-1][j-1]);
	return cmb;
}


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, p;
	cin >> n >>p;
	VI a(n);
	rep(i,n) cin >>a[i];
	
	auto cmb = mkcmb(60);
	
	int ks=0, gs=0;
	rep(i,n) if(a[i]%2) ks++;
	gs = n-ks;
	ll sgs = 1LL<<gs;
	//printf("%d:%d::%lld\n", gs, ks, sgs);
	ll ans =0;
	rep(j,ks+1){
		if(j%2 && p==0) continue;
		if(j%2==0 && p==1) continue;
		ans += cmb[ks][j] * sgs;
	}
	
	
	
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int N; cin >> N;
	map<string, int> mp;
	while (N--) {
		string si; cin >> si;
		++mp[si];
	}
	int mx = 0;
	for (auto& e : mp)
		mx = max(mx, e.second);
	vector<string> res;
	for (auto& e : mp)
		if (e.second == mx)
			res.push_back(e.first);
	//sort(res.begin(), res.end());
	for (auto s : res) cout << s << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int64_t x = 2;
  int64_t y = 1;
  for (int i = 2; i <= n; i++) {
    y = x + y;
    x = y - x;
  }
  cout << y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll N, X; cin >> N >> X;
  ll ans = N;
  ll h = X, w = N-X;
  while(1){
    if(w%h==0){
      ans += h*(2*w/h-1);
      break;
    }
    ans += w/h*h*2;
    ll ww = w, hh = h;
    w = hh;
    h = ww - ww/hh*hh;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 N;
  cin >> N;
  string s;
  cin >> s;
  i64 Q;
  cin >> Q;

  rep(q, 0, Q) {
    i64 K;
    cin >> K;
    i64 D = 0, M = 0;
    i64 now = 0;
    i64 ans = 0;
    rep(i,0,N) {
      if(s[i] == 'D') {
        D++;
      }
      else if(s[i] == 'M') {
        M++;
        now += D;
      }
      else if(s[i] == 'C') {
        ans += now;
      }
      if(i - K + 1 >= 0) {
        if(s[i - K + 1] == 'D') {
          D--;
          now -= M;
        }
        else if(s[i - K + 1] == 'M') {
          M--;
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 1412
#include <iostream>
#include <algorithm>
#include <array>
using namespace std;

int main() {
  array<int, 3> a;
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long N,K;cin>>N>>K;long long M=0;
  map<long long,long long>mp;
  for(int X=0;X<N;X++){
    int A,B;cin>>A>>B;
    mp[A]+=B;
  }
  for(auto p:mp){
    long long A=p.first;long long B=p.second;M+=B;
    if(M>=K){
      cout<<A<<endl;break;
    }
  }
}

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

using namespace std;
 
#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 DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    int n;
    cin >> n;
    if (n % 1000 == 0) cout << 0 << endl;
    else cout << 1000 - n % 1000 << endl;
}

Measured memory_bytes: 3656
#include <stdio.h>

main(){
  int w, data=4280, ryokin;

  while(1){
    scanf("%d", &w);
    if(w==-1) break;

    if(w<=10) ryokin=1150;
    else if(w<=20) ryokin=1150+(w-10)*125;
    else if(w<=30) ryokin=1150+1250+(w-20)*140;
    else ryokin=1150+1250+1400+(w-30)*160;

    printf("%d\n", data-ryokin);
  }
  return 0;
}

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

int main()
{
    string s[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT"}, ch;
    int i;

    cin >> ch;

    for(i = 0; i < 6; i++){
        if(ch == s[i]) break;
    }

    if(i != 6) cout << (6 - i) << endl;
    else cout << 7 << endl;

    return 0;
}


Measured memory_bytes: 256
L=[]
for i in range(5):
    a=int(input())
    L.append(a)

A=10
for i in range(5):
    if L[i]%10==0:
        pass
    else:
        if L[i]%10<A:
            A=L[i]%10
if A==10:
    print(sum(L))
else:
    ans=0
    for i in range(5):
        X=L[i]+9
        X=int(X/10)
        X*=10
        ans+=X
    ans-=10
    ans+=A
    print(ans)

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

#define rep(i,n)  for(int i=0;i<n;++i)
#define sc1(a)  scanf("%d",&a)

int main(){
    int mod=1000000007;
    int x=0,ans=mod;
    char s[100005];
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++) {
        if (i%2==0 && s[i]!='0') x++;
        if (i%2 && s[i]!='1') x++;
    }
    ans=min(ans,x);
    x=0;
    for(int i=0;i<strlen(s);i++) {
        if (i%2 && s[i]!='0') x++;
        if (i%2==0 && s[i]!='1') x++;
    }
    ans=min(ans,x);
    printf("%d\n",ans);
    return 0;
}


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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int tmp = i;
			if(tmp % 3 == 0) {
				cout << " " << i;
				continue;
			}
			while (tmp > 0) {
				if(tmp % 10 == 3) {
					cout << " " << i;
					break;
				}
				tmp  /= 10;
			}
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,gcd;cin>>n>>k;
  bool ans=false;
  lvector A(n,0);
  cin>>A[0];
  if(n==1) {
    if(A[0]==k) print("POSSIBLE");else print("IMPOSSIBLE");
    return 0;
  }
  rep(i,n-1) {
    cin>>A[i+1];
    gcd=__gcd(A[i],A[i+1]);
    if(A[i]==k) ans=true; 
  }
  if(!ans) {
    sort(A.begin(),A.end());
    if(A[n-1]>k) {
      if(gcd==1) ans=true;
      else {
        rep(i,n) {
          if(A[i]>k) {
            if((A[i]-k)%gcd==0) {ans=true;break;}
          }
          if(ans) break;
        }
      }
    }
  }
  if(ans) print("POSSIBLE");else print("IMPOSSIBLE");
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9

ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
   ll n;cin>>n;
   ld a[n];f(i,0,n)cin>>a[i];
   ld sum=0;
   f(i,0,n){
       sum+=1/a[i];
   }
   cout<<setprecision(5)<<fixed<<1/sum;
    return 0;
}   


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;
typedef pair<int, int> pint;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

constexpr int MAX = 110000;
ll 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;
    }
}

ll nCk(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;
}

int main() {
    int n, k; cin >> n >> k;
    vector<ll> a(n); rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    COMinit();

    map<int, int> mp;
    rep(i, n) mp[a[i]]++;



    int i = 0;
    ll max_x_sum = 0;

    while (i < n) {
        int cnt = mp[a[i]];
        for (int j = 1; j <= cnt; j++) {
            max_x_sum += a[i] * nCk(cnt, j) % MOD * nCk(i, k-j) % MOD;
            max_x_sum %= MOD;
        }
        i += cnt;
    }

    ll min_x_sum = 0;
    sort(a.rbegin(), a.rend());
    i = 0;
    while (i < n) {
        int cnt = mp[a[i]];
        for (int j = 1; j <= cnt; j++) {
            min_x_sum += a[i] * nCk(cnt, j) % MOD * nCk(i, k-j) % MOD;
            min_x_sum %= MOD;
        }
        i += cnt;
    }

    cout << (max_x_sum - min_x_sum + MOD) % MOD << endl;








    return 0;
}


    


Measured memory_bytes: 7936
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> l(N), r(N);
  for(int i = 0; i < N; i++){
    cin >> l.at(i) >> r.at(i);
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
    ans += r.at(i) - l.at(i) +1;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
s = input()
ans = 100
for i in s:
    dis = 0
    td = 0
    for j in s:
        if i == j:
            dis = max(dis, td)
            td = 0
        else:
            td += 1
        dis = max(dis, td)
    ans = min(ans, dis)
print(ans)

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;

int main(){
    ll a,b;     cin >> a >> b ;
    ll x=a*b;
    if(a<b){
      int tmp=a;
      a = b;
      b = tmp;
}
/* ユークリッドの互除法 */
int r = a % b;
while(r!=0){
    a = b;
    b = r;
    r = a % b;
}
    cout << x/b << endl;
}


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

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define DEB 0

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

int w,h;
char field[22][22];
int ans,sx,sy;

inline bool inside(char x, char y){
  return (!(x<0 || x>=w || y<0 || y>=h));
}

void dfs(char x, char y, char cnt){
  char tx,ty;
  if( cnt>=ans ) return;
  
#if DEB
  printf("(%d,%d)  cnt:%d\n",x,y,cnt);
  rep(i,h){
    rep(j,w){
      printf("%d ",field[i][j]);
    }
    puts("");
  }
#endif

  rep(k,4){
    tx = x;
    ty = y;
    if( !inside(tx+dx[k],ty+dy[k]) || field[ty+dy[k]][tx+dx[k]]==1 )continue;
    REP(j,1,30){
      tx += dx[k];
      ty += dy[k];
      if( !inside(tx,ty) ) break;
      if( field[ty][tx]==1 ){
	field[ty][tx] = 0;
	dfs(tx-dx[k], ty-dy[k], cnt+1);
	field[ty][tx] = 1;
	break;
      }else if( field[ty][tx]==3 ){
	ans = cnt+1;
	return;
      }
    }
  }
}

int main(){
  int t;
  while(scanf("%d%d",&w,&h),w|h){
    ans = 11;
    rep(i,h){
      rep(j,w){
	scanf("%d",&t);
	field[i][j] = (char)t;
	if( field[i][j]==2 ){
	  sx=j; sy=i;
	}
      }
    }
    dfs(sx,sy,0);
    printf("%d\n",ans==11?-1:ans);
  }
  return 0;
}

Measured memory_bytes: 880
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *h = map(int, read().split())
ans = 0
flag = False
for bf, af in zip(h, h[1:]):
    if bf <= af:
        if flag:
            ans += t - bf
        flag = False
    else:
        if not flag:
            t = bf
        flag = True
if flag:
    ans += t
else:
    ans += h[-1]
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
int* buildRMQ(int* a, int n) {
  int logn = 1;
  for (int k = 1; k < n; k *= 2)
    ++logn;
  int* r = new int[n * logn];
  int* b = r;
  copy(a, a + n, b);
  for (int k = 1; k < n; k *= 2) {
    copy(b, b + n, b + n);
    b += n;
    REP(i, n - k) b[i] = min(b[i], b[i + k]);
  }
  return r;
}
int minimum(int x, int y, int* rmq, int n) {
  int z = y - x, k = 0, e = 1, s;  // y - x >= e = 2^k なる最大 k
  s = ((z & 0xffff0000) != 0) << 4;
  z >>= s;
  e <<= s;
  k |= s;
  s = ((z & 0x0000ff00) != 0) << 3;
  z >>= s;
  e <<= s;
  k |= s;
  s = ((z & 0x000000f0) != 0) << 2;
  z >>= s;
  e <<= s;
  k |= s;
  s = ((z & 0x0000000c) != 0) << 1;
  z >>= s;
  e <<= s;
  k |= s;
  s = ((z & 0x00000002) != 0) << 0;
  z >>= s;
  e <<= s;
  k |= s;
  return min(rmq[x + n * k], rmq[y + n * k - e + 1]);
}

int o[100001], e[100001];
int p0[200001];

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    if (i % 2) {
      o[i / 2] = p;
    } else {
      e[i / 2] = p;
    }
    p0[p] = i;
  }

  int* ot = buildRMQ(o, N / 2);
  int* et = buildRMQ(e, N / 2);
  priority_queue<pair<int, pair<int, int> >,
                 vector<pair<int, pair<int, int> > >,
                 greater<pair<int, pair<int, int> > > >
      q;
  q.push(make_pair(minimum(0, N / 2 - 1, et, N / 2), make_pair(0, N)));

  bool first = true;
  for (;;) {
    if (q.empty())
      break;

    pair<int, pair<int, int> > top = q.top();
    int l = top.second.first, r = top.second.second;
    q.pop();

    int* let = l % 2 == 0 ? et : ot;
    int* lot = l % 2 == 0 ? ot : et;
    int d = l % 2 == 0 ? 0 : 1;

    int emin = minimum(l / 2, r / 2 - 1, let, N / 2);
    int epos = p0[emin];
    int omin = minimum(epos / 2 + d, r / 2 - 1 + d, lot, N / 2);
    int opos = p0[omin];

    if (first) {
      first = false;
    } else {
      cout << " ";
    }
    cout << emin << " " << omin;

    if (epos != l) {
      q.push(make_pair(minimum(l / 2, epos / 2 - 1, let, N / 2),
                       make_pair(l, epos)));
    }
    if (opos - epos > 1) {
      q.push(make_pair(minimum(epos / 2 + d, opos / 2 - 1, lot, N / 2),
                       make_pair(epos + 1, opos)));
    }
    if (r - opos > 1) {
      q.push(make_pair(minimum((opos + 1) / 2, r / 2 - 1, let, N / 2),
                       make_pair(opos + 1, r)));
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 17784
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

using mint = modint998244353;
const mint inv9 = mint(1)/9;

struct S {
  mint x, power;
  S(mint x=0, mint power=1):x(x),power(power) {}
};
S op(S l, S r) { return S{l.x * r.power + r.x, l.power * r.power}; }
S e() { return S{0, 1}; }

struct F { int d; };
S mapping(F f, S s) {
  if(f.d == 0) return s;
  return S{(s.power-1) * inv9 * f.d, s.power};
}
F composition(F f, F g) {
  if( f.d == 0) return g;
  else return f;
}
F id() { return F{0}; }

int main() {
  int n,q; cin >> n >> q;
  lazy_segtree<S, op, e, F, mapping, composition, id> t(n);
  rep(i,n) t.set(i, S(1,10));
  rep(i,q) {
    int l, r, d;
    cin >> l >> r >> d; --l;
    t.apply(l, r, F{d});
    S ans = t.prod(0,n);
    cout << ans.x.val() << endl;
  }
}


Measured memory_bytes: 9892
nums=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(input())
print(nums[a-1])

Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
	long long x,y;

	scanf("%lld %lld",&x,&y);

	if(abs(x-y)<=1){
		printf("Brown\n");
	}else{
		printf("Alice\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string s,t;
string ans="";
void lcs(){
    int n=s.size();
    int m=t.size();
    int a[n+1][m+1];
    for(int i=0;i<=n;i++){
        int flag=0;
        for(int j=0;j<=m;j++){
            if(i==0 || j==0)a[i][j]=0;
            else if(s[i-1]==t[j-1])a[i][j]=1+a[i-1][j-1];
            else a[i][j]=max(a[i][j-1],a[i-1][j]);
        }//if(flag && i>0)ans+=s[i];
    }
    int i=n,j=m;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1])ans+=s[i-1],i--,j--;
        else if(a[i-1][j]>=a[i][j-1])i--;
        else j--;
    }
}
int main(){
    cin>>s>>t;
    lcs();
    reverse(ans.begin(),ans.end());
    cout<<ans;
}

Measured memory_bytes: 35456
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int n;
	scanf("%d",&n);
	int i,S[n];
	for(i=0; i<n; i++){
		scanf("%d",&S[i]);
	}
	int q;
	scanf("%d",&q);
	int j,T[q];
	for(j=0; j<q; j++){
		scanf("%d",&T[j]);
	}
	int cnt=0;
	int same[n];
	for(i=0; i<n; i++){
		for(j=i+1; j<n; j++){
			if(S[i]==S[j]){
				same[j]=1;
			}
		}
	}
	for(i=0; i<n; i++){
		if(same[i]!=1){
			for(j=0; j<q; j++){
				if(S[i]==T[j]){
					cnt++;
				}
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}


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

#define int long long
#define mod 1000000007

int calc(int n,int m){
	int ans = (m*(m*m - 1))/3;
	ans = (ans*n)%mod;
	ans = (ans*n)%mod;
	return ans;
}

int powmod(int base,int exponent)
{
    if(exponent<0) exponent+=mod-1;
    int ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    return ans;
}

int nCrModp(int n, int r, int p) 
{ 
    int ans =1;
    for(int i = n;i >= n-r+1;i--){
    	ans = (ans*i)%mod;
    }
    for(int i =2 ;i<= r;i++){
    	ans = (ans*powmod(i,mod-2))%mod;
    }
    return ans;
} 

signed main() {
	// your code goes here
	int n,m,k;
	cin>>n>>m>>k;
	int ans = (calc(n,m) + calc(m,n))%mod;
	ans = (ans*500000004LL)%mod;
	int f = nCrModp(n*m-2,k-2,mod);
	cout<<(ans*f)%mod<<endl;
	return 0;
}

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

int h, n, arr[100001], brr[100001], dp[100001], ans;

int main(){
	cin>>h>>n;
	
	for(int i=1; i<=n; i++){
		cin>>arr[i]>>brr[i];
	}
	
	memset(dp, 100, sizeof(dp));
	dp[h]=0;
	ans=1e9;
	
	for(int i=1; i<=n; i++){
		for(int j=h; j>0; j--){
			dp[max(0, j-arr[i])]=min(dp[max(0, j-arr[i])], dp[j]+brr[i]);
		}
		ans=min(ans, dp[0]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
 
N, M = mi()
Q = li2(M)
Q = sorted(Q, key=lambda x:x[1])
 
#table = dp2(0, N, N)
 
#for i in range(M):
    #s, t = mi()
    #for i in range(t):
    #table[s-1][t-1] = 1
 
#for i in reversed(range(N-1)):
    #for j in range(i, N):
        #table[i][j] = max(table[i+1][j], table[i][j])
 
#print(table)
'''
i = j = 0
cnt = 0
while True:
    while j < N and table[i][j] == 0:
        j += 1
    if j >= N:
        break
    cnt += 1
    i = j
 
print(cnt)
'''
 
l = [N]*N
for i in range(M):
    ind = max(0, Q[i][0]-1)
    l[ind] = min(Q[i][1]-1, l[ind])
 
for i in reversed(range(N-1)):
    l[i] = min(l[i], l[i+1])
 
cnt = 0
i = 0
#print(l)
while True:
    i = l[i]
    cnt += 1
    if l[i] == N:
        break
 
print(cnt)

Measured memory_bytes: 31000
#include<bits/stdc++.h>
const int maxn = 1e2 + 5;
using namespace std;

int n,m;
char x;
string a[maxn];


int main(){
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++){
		getchar();
		for(int j = 1; j <= m; j++){
			scanf("%c", &x);
			a[i] += x;
		}
	}
	sort(a + 1,a + n + 1);
	for(int i = 1; i <= n; i++) cout << a[i];
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX1 10000
#define MAX2 500
int main()
{
  int n,m,i,j;
  int count=0;
  int s[MAX1];
  int t[MAX2];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&s[i]);
    }

  scanf("%d",&m);
  for(i=0;i<m;i++)
    {
      scanf("%d",&t[i]);
    }

  for(i=0;i<m;i++)
    {
      for(j=0;j<n;j++)
	{
	  if(s[j]==t[i])
	    {
	      count+=1;
	      break;
	    }
	}
    }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    vi a;
    rep(i,n){
        int x; cin >> x;
        a.pb(x);
        a.pb(x);
    }
    sort(all(a));
    ll ans = 0;
    rep(i,n-1){
        ans += a[n*2-1 -i -1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5348
var cc: ansistring ;
   sum, a,b,c,d,e,f : longint ;
     g : char;
begin
 readln(cc);
 a:=length(cc);
 for b:=a downto 1 do
  if b=a then
   g:=cc[b]
  else if cc[b]<>g then
   begin
    sum:=sum+1;
    g:=cc[b];
   end;
  writeln(sum);
end.


Measured memory_bytes: 256
from itertools import permutations, combinations, combinations_with_replacement, product
import fractions
from collections import Counter

n = int(input())
listA = map(int, input().split())
Cs = list(combinations(listA, 3)) # C
ans = 0
for li in Cs:
  if (li[0]+li[1]>li[2]) and (li[1]+li[2]>li[0]) and (li[0]+li[2]>li[1]) and not li[0] == li[1] and not li[1] == li[2] and not li[2]==li[0]:
    ans+=1
print(ans)


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

int n;
int k;
int64_t p;

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

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

    vector<int64_t> s(n, 0);
    s[0] = a[0];
    for(int i=0;i<n-1;i++){
        if(a[i+1] < s[i]) {
            s[i+1] = a[i+1];
        }
        else s[i+1] = s[i];
        // cout << s[i+1] << endl;
    }

    int count=0;

    for(int i=0;i<n;i++){
        if(a[i] <= s[i]){
            count++;
        }
    }

    cout << count << endl;
}

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

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    vector<int> A0, A1;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        A0.push_back(tmp);
        A1.push_back(tmp);
    }
    
    sort(A0.begin(), A0.end(), greater<int>());
    
    for (int i = 0; i < N; i++) {
        if (A1[i] != A0[0]) {
            cout << A0[0] << endl;
        }else {
            cout << A0[1] << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3436
package main

// 某DP, 再帰でやったらTLEになる原因がメモ化再帰しか浮かばないんだけどループでやるDPってやったことないので練習のため来ました
// ループできたのでメモ化再帰やってみる
// 組み合わせの総数じゃなくて最大値や最小値を求める場合、返り値が苦手だってのがわかった
// （引数にコストやポイントを含めるとうまくいかない）
// （そういう場合は次の再帰に渡すときではなくかえってきたものに加算/減算など手を加える）
// トップダウン的に配るDPでやってみる（ボトムアップだとなんかできん）

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

var n int
var h []int

var dp []int

func rec(i int) int {
	// トップダウンでやる
	if dp[i] > -1 {
		return dp[i]
	}
	if i == 1 {
		ret := int(math.Abs(float64(h[i] - h[i-1])))
		dp[i] = ret
		return ret
	}
	epi_one := rec(i-1) + int(math.Abs(float64(h[i]-h[i-1])))
	epi_two := rec(i-2) + int(math.Abs(float64(h[i]-h[i-2])))
	ret := int(math.Min(float64(epi_one), float64(epi_two)))
	dp[i] = ret
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	n = nextInt()
	h = nextInts(n)
	dp = make([]int, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = -1
	}
	dp[0] = 0
	fmt.Fprint(out, rec(n-1))
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}


Measured memory_bytes: 10624
import * as fs from "fs";
 
let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
var bags = input[0].split(" ").map(x => parseInt(x));
var a = bags[0]
var b = bags[1]
var c = bags[2]
var result = "No"

if (a == b + c || b == c + a || c == a + b) { 
result = "Yes"
};

console.log(result);




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

int gcd(int a, int b){
    if(b == 0)  return a;
    else    return gcd(b, a%b);
}
int main(void){
    int a, b, c;
    cin >> a >> b;
    if(a < b){
        c = a;
        a = b;
        b = c;
    }
    
    cout << gcd(a,b) << endl;
    return 0;
}



Measured memory_bytes: 3068
#!/usr/bin/env python3
import sys
import collections

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    _ = int(readline())
    s_list = [''.join(sorted(s.rstrip().decode())) for s in readlines()]
    counter = collections.Counter(s_list)
    ans = 0
    for v in counter.values():
        if v != 1:
            ans += v * (v - 1) // 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21620
a,b,c,d,e,f=map(int,input().split())
s=[]
for i in range(f):
    for j in range(f):
        y=i*c+j*d
        if y<=f:
            s.append(y)
w=[]
for i in range(0,f//100+1):
    for j in range(0,f//100+1):
        x=i*a*100+j*b*100
        if x<=f:
            w.append(x)
max_con=0
ans,ans_2=0,0
for x in w:
    for y in s:
        if x==0 and y==0:
            continue
        elif e*(x//100)<y:
            continue
        elif x+y>f:
            continue
        else:
            con=(100*y)/(x+y)
            if max_con<=con:
                max_con=con
                ans=x+y
                ans_2=y
print(ans,ans_2)


Measured memory_bytes: 12440
#include<stdio.h>
int main(){
    int v, h;
    for(scanf("%d %d", &v, &h); v!=0||h!=0; scanf("%d %d", &v, &h)){
        for(int i=0; i<v; i++){
            for(int j=0; j<h; j++){
                if(i==0 || i==v-1 || j==0 || j==h-1){
                    putchar('#');
                }else{
                    putchar('.');
                }
            }
            putchar('\n');
        }
        putchar('\n');
    }
}


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

static int is_prime (int x) {
    int i;
    int sqrt_x = sqrt(x);

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

int main (void) {
    int x;
    int ans;
    scanf("%d", &x);

    ans = x;
    while ( !is_prime(ans) )
        ans++;

    printf("%d\n", ans);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
s = int(input())
sequence = [s]

for i in range(1, 1000001):
    if sequence[i - 1] % 2 == 0:
        sequence.append(sequence[i - 1] / 2)
    else:
        sequence.append(3 * sequence[i - 1] + 1)
    if sequence[i] in sequence[:i]:
        print(i+1)
        exit()



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll inv[1000000];
ll FactorialInv[1000000];
ll Factorial[1000000];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    inv[1] = 1;
    FactorialInv[1] = 1;
    Factorial[1] = 1;
    Factorial[0] = 1;
    FactorialInv[0] = 1;
    inv[0] = 1;
    for(int i = 2; i < 1000000; i++){
        inv[i] = beki(i, mod - 2);
        Factorial[i] = Factorial[i - 1] * i % mod;
        FactorialInv[i] = FactorialInv[i - 1] * inv[i] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

ll n;
string S = "#";

ll dp[205][205][205];
//dp[i][j][k]:i人目まで見たとき
//未使用のUがj人
//使用しているDがk人

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_combination();
    cin >> n;
    for(int i = 1; i <= n; i++) {
        char in;
        cin >> in;
        if(in == '-') {
            n--;
            i--;
            continue;
        }
        S.push_back(in);
    }
    dp[0][0][0] = 1;
    //cout << S << endl;
    for(ll i = 1; i <= n; i++) {
        for(ll j = 0; j <= i; j++) {
            for(ll k = 0; k <= i; k++) {
                if(S[i] == 'U') {
                    if(true) {
                        dp[i][j][k] += dp[i-1][j][k] * j;
                    }
                    if(j >= 1) {
                        dp[i][j][k] += dp[i-1][j-1][k-1];
                    }
                } else if(S[i] == 'D') {
                    if(true) {
                        dp[i][j][k] += dp[i-1][j+1][k+1] * (j+1) * (k + 1);
                    }
                    if(true) {
                        dp[i][j][k] += dp[i-1][j][k] * k;
                    }
                }
                dp[i][j][k] %= mod;
                //cerr << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
            }
        }
    }
    cout << dp[n][0][0] << endl;
    return 0;
}


Measured memory_bytes: 57972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll n;
    cin >> n;
    vector<double> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(all(v));

    double ans = v[0];
    for(int i = 1; i <= n-1; i++){
        ans = (v[i]+ans)/2.0;
    }
    printf("%.10f\n",ans);


    return 0;

}


Measured memory_bytes: 256
import itertools
N=int(input())
F=[list(input().split()) for _ in range(N)]
P=[list(input().split()) for _ in range(N)]

answer = -float('inf')
for x in itertools.product([int(0),int(1)],repeat=10):
  if x != (0, 0, 0, 0, 0, 0, 0, 0, 0, 0):#一回は開店しないといけない。
    value=0
    for i in range(N):#各店舗と調べる。
      count=0
      for j in range(10):#対象店舗iとの同時開店の回数を調べる。
        if x[j]==1 and F[i][j]=='1':
          count +=1
      value += int(P[i][count])
    answer=max(answer,value)
print(answer)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	string S;
	cin >> S;
	vector<int> num(3);
	for (auto i = 0; i < (int)S.length(); ++i)
	{
		++num[S[i] - 'a'];
	}

	auto minNum = min(num[0], min(num[1], num[2]));
	num[0] -= minNum;
	num[1] -= minNum;
	num[2] -= minNum;
	if (num[0] < 2 && num[1] < 2 && num[2] < 2)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 512
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=[]
S,ans=0,0
for a,b in zip(A,B):
    if a>=b:C.append(a-b)
    else:
        ans +=1
        S +=b-a
C.sort()
while S>0 and C:
    ans +=1
    S -=C.pop()

print(-1 if S>0 else ans)

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

int main() {
  int X, Y, ans = 0;
  cin >> X >> Y;
  ans = max(400000 - 100000 * X, 0) + max(400000 - 100000 * Y, 0);
  if (X * Y == 1) ans += 400000;
  cout << ans << endl;
}

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

int main() {
    while (true) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ((i > 0 && i < H - 1) &&
                    (j > 0 && j < W - 1)) {
                    cout << ".";
                } else {
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


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

int main() {

  
int k;
int A,B;
cin>>k;
cin>>A>>B;
int f=0;
for(int i=A;i<=B;++i)
{
	if(i%k==0)
	{
		f=1;
		break;
	}
}

if(f==0)
{
	cout<<"NG"<<endl;
}
else
{
	cout<<"OK"<<endl;
}

	return 0;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        System.out.println(Math.log10(n) % 1 == 0 ? 10 : Integer.toString(n).chars().map(c -> c - '0').sum());
    }
}

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

int main(){
  int N, T;
  cin >> N >> T;
  vector<pair<int,int>> V;
  for(int i = 0; i < N; ++i){
    int a, b;
    cin >> a >> b;
    V.emplace_back(a,b);
  }
  sort(V.begin(), V.end());
  vector<int> dp(2*T+1);
  for(auto e : V){
    for(int i = T-1; i >= 0; --i){
      dp[min(2*T,i+e.first)] = max(dp[min(2*T,i+e.first)],dp[i]+e.second);
    }
  }
  cout << *max_element(dp.begin(), dp.end()) << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

int x, a, b;
cin >> x >> a >> b;

if (a > b && x + a > b|| a == b) {
	cout << "delicious" << endl;
}
else if (a < b && a + x < b ) {
	cout << "dangerous" << endl;
}
else {
	cout << "safe" << endl;
}

return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

type Drink struct {
  ProblemIndex int
  Time int
}

func main() {
  var numberOfProblems int
  fmt.Scanf("%d", &numberOfProblems)
  solvingTimes  := make([]int, numberOfProblems)
  for i := 0; i < numberOfProblems; i++ {
    var time int
    fmt.Scanf("%d", &time)
    solvingTimes[i] = time
  }

  var numberOfDrinks int
  fmt.Scanf("%d", &numberOfDrinks)
  for i := 0; i < numberOfDrinks; i++ {
    var problemIndex, time int
    fmt.Scanf("%d %d", &problemIndex, &time)
    totalTime := 0
    for j := 0; j < numberOfProblems; j++ {
      if j == problemIndex - 1 {
        totalTime = totalTime + time
      } else {
        totalTime = totalTime + solvingTimes[j]
      }
    }
    fmt.Printf("%d\n", totalTime)
  }
}


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

int main() {
    int n[4];
    int count[4] = {};
    for (int i = 0; i < 4; i++) {
        cin >> n[i];
        if (n[i] == 1) count[0]++;
        else if (n[i] == 9) count[1]++;
        else if (n[i] == 7) count[2]++;
        else if (n[i] == 4) count[3]++;
    }
    if (count[0] == 1 && count[1] == 1 && count[2] == 1 && count[3] == 1) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl; 
}

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

int main()
{
    int n,m,a,b,i,j,ans=-1;

    cin>>n>>m;

    vector<int>v[n+5];
    bool vis[n+5]={0};
    queue<int>q;

    for(i=0;i<m;i++){
        cin>>a>>b;

        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(i=1;i<=n;i++){
        if(!vis[i]){
            ans++;
            q.push(i);
            vis[i]=1;

            while(!q.empty()){
                a=q.front();
                q.pop();

                for(j=0;j<v[a].size();j++){
                    b=v[a][j];
                    if(!vis[b]){
                        vis[b]=1;
                        q.push(b);
                    }
                }
            }
        }
    }
    cout<<ans<<"\n";

    return 0;
}




Measured memory_bytes: 8900
n=int(input())
a=list(map(int,input().split()))
ans=[]
if n%2==0:
  for i in reversed(range(1,n,2)):
    ans.append(a[i])
  for i in range(0,n,2):
    ans.append(a[i])
else:
  for i in reversed(range(0,n,2)):
    ans.append(a[i])
  for i in range(1,n,2):
    ans.append(a[i])
print(*ans)

Measured memory_bytes: 26180
import java.util.Scanner;

//Distinct or Not
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int[][] bingo = new int[3][3];
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				bingo[i][j] = sc.nextInt();

			}
		}

		int max = sc.nextInt();
		for(int x = 0; x < max; x++) {
			int num = sc.nextInt();
			for(int i = 0; i < 3; i++) {
				for(int j = 0; j < 3; j++) {
					if(bingo[i][j] == num) {
						bingo[i][j] = 0;
					}
				}
			}
		}


		//正解チェック
		int cnt = 0;
		boolean flg = false;
		//横チェック
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				if(bingo[i][j] == 0) {
					cnt++;
				}
				if(cnt == 3) {
					flg = true;
				}
			}
			cnt = 0;
		}

		//縦チェック
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				if(bingo[j][i] == 0) {
					cnt++;
				}
				if(cnt == 3) {
					flg = true;
				}
			}
			cnt = 0;
		}

		//斜めチェック
		if(bingo[0][0] == 0) cnt++;
		if(bingo[1][1] == 0) cnt++;
		if(bingo[2][2] == 0) cnt++;

		if(cnt == 3) flg = true;
		cnt = 0;

		if(bingo[0][2] == 0) cnt++;
		if(bingo[1][1] == 0) cnt++;
		if(bingo[2][0] == 0) cnt++;

		if(cnt == 3) flg = true;

		if(flg) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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; }

int main(){
    ll x;
    cin >> x;
    ll m = 100;
    int cnt = 0;
    while(true){
        if (m >= x) break;
        m = m * 1.01;
        cnt++;
    }
    cout << cnt << endl;
}

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

using namespace std;
 
//#define int long long
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=0;i<=n;i++)

ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll modm(ll val, ll m) {
  ll res = val % m;
  if (res < 0) res += m;
  return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    ll n,m,ans=0;
    cin >> n >> m;
    vector<ll> K(n,0);
    vector<vector<ll>> A(n,vector<ll>(m,0));
    vector<ll> s(m+1,0);
    rep(i,n){
      cin >> K[i];
      for(int j=0;j<K[i];j++){
        cin >> A[i][j];
        s[A[i][j]]++;
      }
    }
    rep(k,m+1){
      if(s[k]==n){
        ans++;
      }
    }

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


Measured memory_bytes: 3600
def get_neighbors(x, y):
    neighbors = []
    for i in [-1, 0, 1]:
        for j in [-1, 0, 1]:
            if i == 0 and j == 0:
                continue
            search_y = y + i
            search_x = x + j
            if search_x >= 0 and search_y >= 0 and search_x < W and search_y < H:
                neighbors.append(S[search_y][search_x])
    return neighbors
                
H, W = map(int, input().split())
S = [input() for _ in range(H)]
for y in range(H):
    for x in range(W):
        if S[y][x] == '#':
            print('#', end='')
        else:
            neighbors = get_neighbors(x, y)
            n_mines = neighbors.count('#')
            print(n_mines, end='')
    print()

Measured memory_bytes: 3444