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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;

int main(){
	setIO();
	char c; cin >> c;
	if ((int)c < 97) cout << "A\n";
	else cout << "a\n";
}

Measured memory_bytes: 3620
from heapq import heappush, heappop
#import collections
n, k = map(int, input().split())
c = []
for i in range(n):#h:高さ
    c.append([int(m) for m in input().split()])
c.sort(key=lambda x:(x[0], x[1]))
f = sorted(c, key=lambda x:(x[1], x[0]), reverse=True)
donyoku = 0
donset = set()
#pq = PriorityQueue()
notfirst =[]
for i in range(k):
    if f[i][0] not in donset:
        donset.add(f[i][0])
    else:
        heappush(notfirst, f[i][1])
    donyoku += f[i][1]
donyoku += len(donset)**2

candidate = []
candidateset = set()
donyokulength = len(donset)#len(donset)の長さが変わってしまうので予めとっておく
for i in range(k, n):
    if f[i][0] not in donset:#
        candidate.append(-f[i][1])#最小のものから取り出されるのでマイナスをつけることによって最大のものから取り出せるようにしている
        candidateset.add(f[i][0])
        donset.add(f[i][0])#donsetにも入れて二番目以降の侵入を妨げる

satili = [donyoku]
donyoku -= donyokulength**2
for i in range(len(candidateset)):
    if notfirst == []:
        break
    else:
        donyoku -= heappop(notfirst)
        donyoku += -heappop(candidate)#最小のものから取り出されるのでマイナスをつけることによって最大のものから取り出せるようにしている
        donyoku += (donyokulength + i + 1) ** 2
        satili.append(donyoku)
    donyoku -= (donyokulength + i + 1) ** 2




print(max(satili))


Measured memory_bytes: 37264
#include<iostream>
#include<cmath>
#include<vector>
int main(){
    int N;
    std::cin>>N;
    std::vector<int>h(N);
    for(int i=0;i<N;++i){
        std::cin>>h[i];
    }
    unsigned long long i_1,i_2;
    i_1=std::abs(h[1]-h[0]);
    i_2=0;
    for(int i=2;i<N;++i){
        unsigned long long buf;
        buf=std::min(i_1+std::abs(h[i]-h[i-1]),i_2+std::abs(h[i]-h[i-2]));
        i_2=i_1;
        i_1=buf;
    }
    std::cout<<i_1<<std::endl;
}

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

using namespace std;
int n;
int main()
{
    scanf("%d",&n);
    int t=n/2;
    if(n==1)
        printf("1");
    else if(n&1)
    {
        t++;
        printf("%.10f",(double)1.0*t/n);
    }
    else
        printf("%.10f",(double)1.0*t/n);
    return 0;
}


Measured memory_bytes: 256
def main():
    n, a, b = map(int, input().split())
    ans = 0
    diff = b - a
    if diff % 2 == 0:
        ans = diff // 2
    else:
        ab = [a, b]
        len_to_opp = [0] * 2
        len_to_opp[0] = n - ab[0]
        len_to_opp[1] = ab[1] - 1
        ans = min(len_to_opp)

        len_to_self = [0] * 2
        len_to_self[0] = ab[0] - 1
        len_to_self[1] = n - ab[1]
        if len_to_self[0] < len_to_self[1]:
            ab[0] = ab[0] - (len_to_self[0] + 1) * 2
        else:
            ab[1] = ab[1] + (len_to_self[1] + 1) * 2
        temp_ans = abs(ab[0] - ab[1]) // 2
        ans = min(ans, temp_ans)

    print(ans)


if __name__ == '__main__':
    main()


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t a, b;
  std::cin >> a >> b;
  const auto ans = a + b;
  if (ans % 2 == 0) {
    std::cout << ans / 2 << std::endl;
  } else {
    std::cout << "IMPOSSIBLE" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 764
import math
n = int(input())

num = int(math.log(1000000000000001, 26))
#print(num)

#余り
y, z = n, n
y_lis = []
#商
for i in range(100):
    if z >= 1:
        y_lis.append(z % 26)
        z = z // 26
    elif z == 0:
            break
#print(y_lis)


for i in range(len(y_lis) - 1):
    if y_lis[i] <= 0:
        y_lis[i] = y_lis[i] + 26
        y_lis[i + 1] -= 1

if y_lis[-1] == 0:
    y_lis.remove(y_lis[-1])
#print(y_lis)
y_lis = list(reversed(y_lis))
ans = ""
for i in range(len(y_lis)):
    y_lis[i] = chr(y_lis[i] + 96)
    ans += y_lis[i]
print(ans)


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

int exp(string&, int&);
int term(string&, int&);
int factor(string&, int&);

int exp(string& str, int& p){
  int res = term(str, p);
  while(str[p] == '+' || str[p] == '-'){
    if(str[p] == '+'){
      p++;
      res += term(str, p);
    }else{
      p++;
      res -= term(str, p);
    }
  }
  return res;
}

int term(string& str, int& p){
  int res = factor(str, p);
  while(str[p] == '*' || str[p] == '/'){
    if(str[p] == '*'){
      p++;
      res *= factor(str, p);
    }else{
      p++;
      res /= factor(str, p);
    }
  }
  return res;
}

int factor(string& str, int& p){
  int res = 0;
  int keta = 1;
  int initp = p;
  if(str[p] == '('){
    while(str[p] != ')'){
      p++;
      res = exp(str, p);
    }
    p++;
  }else{
    while(isdigit(str[p])){
      p++;
    }
    for(int i=p-1; i >= initp; i--){
      res += keta * (str[i] - '0');
      keta *= 10;
    }
  }
  return res;
}


int main(void){
  int n; cin >> n;
  while(n--){
    int p=0;
    string str;
    cin >> str;
    cout << exp(str, p) << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int h,w,a,b;
	cin >> h >> w >> a >> b;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			cout << ((i < h - b) ^ (j < w - a));
		}
		cout << endl;
	}
}

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

int main() {
    int h, w;
    std::cin >> h >> w;
    int n;
    std::cin >> n;
    std::vector<int> colored(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> colored[i];
    }

    std::vector<std::vector<int>> grid(h, std::vector<int>(w));
    int curClrd = 0, col = 0;

    for (int i = 0; i < h; ++i) {
        if (i % 2 == 0) {
            for (int j = 0; j < w; ++j) {
                if (curClrd < colored[col]) {
                    grid[i][j] = col + 1;
                    ++curClrd;
                } else {
                    ++col;
                    curClrd = 1;
                    grid[i][j] = col + 1;
                }
            }
        } else {
            for (int j = w - 1; j >= 0; --j) {
                if (curClrd < colored[col]) {
                    grid[i][j] = col + 1;
                    ++curClrd;
                } else {
                    ++col;
                    curClrd = 1;
                    grid[i][j] = col + 1;
                }
            }
        }
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            std::cout << grid[i][j] << " ";
        }
        std::cout << "\n";
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

int  main()
{
	int a,b,c; cin >> a >> b >> c;
	if (b-a == c-b)
		cout << "YES\n";
	else
		cout << "NO\n";
	return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll ar[1000];
vector<ll> adj;

bool check(ll f,ll s,ll v)
{
	f = f+(1ll<<v);
	if(f<=ar[1])
		return 1;
	else
		return 0;
}

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

	ll n,i,x = 0,s,a,f = 0;

	cin >> n;
	for(i=1;i<=n;++i)
	{
		cin >> ar[i];
		if(i>=3)
			x = x^ar[i];
	}
	
	if((ar[1]^ar[2]^x) == 0)
	{
		cout << 0 << "\n";
		return 0;
	}

	// for(i=1;i<min((ll)(1e9),ar[1]);++i)
	// {
	// 	if(((ar[1]-i)^(ar[2]+i)^x) == 0)
	// 	{
	// 		cout << i << "\n";
	// 		return 0;
	// 	}
	// }

	s = ar[1]+ar[2];
	if(s < x || (s-x)%2 == 1)
	{
		cout << -1 << "\n";
		return 0;
	}
	a = (s-x)/2;
	s = 0;
	i = 0;
	while(a>0 || x>0)
	{
		if(a%2 == 1 && x%2 == 1)
		{
			cout << -1 << "\n";
			return 0;
		}
		else if(a%2 == 1 && x%2==0)
		{
			f = f+(1ll<<i);
			s = s+(1ll<<i);
		}
		else if(a%2 == 0 && x%2 == 1)
			adj.pb(i);
		
		i++;
		a = a/2;
		x = x/2;
	}

	if(f>ar[1])
	{
		cout << -1 << "\n";
		return 0;
	}

	reverse(all(adj));
	for(auto v:adj)
	{
		if(check(f,s,v))
			f = f+(1ll<<v);
		else
			s = s+(1ll<<v);
	}

	if(f>0)
		cout << ar[1]-f << "\n";
	else
		cout << -1 << "\n";
}



	

Measured memory_bytes: 3704
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


int main(){
  int a,b;
  cin>>a>>b;
  cout<<max(max(a+b,a-b),a*b)<<endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
S=0
M=float("inf")
for i in range(N):
	s=int(input())
	S+=s
	if s%10!=0:
		M=min(M,s)
if S%10==0:
	if M!=float("inf"):
		print(S-M)
	else:
		print(0)
else:
	print(S)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define ff first
#define ss second
#define S size()
#define mod (ll)(1e9+7)
#define mset(a,k) memset(a,k,sizeof(a));
#define fr(i, x, y) for ( ll i = x; i < y;i++)
#define dr(i, x, y) for ( ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define pqueue priority_queue<ll>
#define piqueue priority_queue<ll,vll ,greater<ll>>
#define mapcl map<char,ll>
#define mapll map<ll,ll>
#define mapsl map<string,ll>
#define vi vector<ll>
#define vs vector<string>
#define vb vector<bool>
#define psi pair<string,ll>
#define pii pair<ll,ll>
#define piii pair<ll,pii>
#define vii vector<pii>
#define vvi vector<vi>
#define llu unsigned long long
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
//----------------------------------------FUNCTIONS-------------------------------------
ll gcd(ll x, ll y )						{if (y == 0) return x; return gcd(y, x % y);}
ll lcm(ll a, ll b)						{return (a * b) / gcd(a, b);}
ll logx(ll base, ll num)				{int cnt = 0; while (num != 1) {num /= base; ++cnt;} return cnt;}
vi vin(ll n)							{vi a(n); fr(i, 0, n) cin >> a[i]; return a;}
void in(ll *a, ll n)        			{for (ll i = 0; i < n; i++)cin >> a[i];}
void out(ll *a, ll n)					{fr(i, 0, n) {cout << a[i] << " ";} cout << '\n';}
void vout(vi v)							{fr(i, 0, (ll)v.S) {cout << v[i] << " ";} cout << endl;}
//----------------------------------------START-------------------------------------------
const ll maxN = (ll)(2 * 1e5 + 5 );
void solve()
{
	ll n, d;
	cin >> n >> d;
	ll cnt = 0;
	fr(i, 0, n)
	{
		ll x, y;
		cin >> x >> y;
		if (d * d >= x * x + y * y)cnt++;
	}
	cout << cnt << '\n';
}
int main()
{
	fast();
#ifndef ONLINE_JUDGE
	freopen ("inp1.txt", "r", stdin);
	freopen ("out1.txt", "w", stdout);
#endif
	ll t = 1;
	//cin >> t;
	//sieve();
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3644
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void swap_int(int *x, int *y) {int temp;temp = *x;*x = *y;*y = temp;}
void swap_char(char *x, char *y) {char temp;temp = *x;*x = *y;*y = temp;}
int max(int x, int y) { return x > y ? x : y; }
int min(int x, int y) { return x > y ? y : x; }

int main(){
    int N,T,c[200],t[200];
    int min=9999,ans;
    int i,j,k;

    scanf("%d %d",&N,&T);
    for(i=0;i<N;i++)scanf("%d %d",&c[i],&t[i]);

    for(i=0;i<N;i++){
        if(t[i]<=T){
            if(min>c[i]){
                min=c[i];
                ans=c[i];
            }
        }
    }
    if(min!=9999){
        printf("%d\n",ans);
    }else{
        printf("TLE\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  vvi p = vv(N, N, 0, int);
  for(int i=0;i<N;i++) for(int j=0;j<N;j++) scanf("%d", &p[i][j]);
  vvi dp = vv(N+1, 1<<21, 0, int);
  for(int i=0;i<N;i++) if(p[0][i]==1) dp[1][1<<i] = 1;
  for(int i=2;i<=N;i++){
    int comb = (1<<(i-1)) - 1;
    while(comb < 1 << N){
      int tmp = comb, now = 0;
      while(now<N){
        if(tmp%2==0&&p[i-1][now]==1)dp[i][comb|(1<<now)]=(dp[i][comb|(1<<now)]+dp[i-1][comb])%1000000007;
        tmp/=2,now++;
      }
      int x = comb & -comb, y = comb+x;
      comb = ((comb & ~y) / x >> 1) | y;
    }
  }
  std::cout << dp[N][(1<<N)-1] << '\n';
  return 0;
}


Measured memory_bytes: 188800
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>

using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const ll INF = 1000010000;
static const ll MOD = 1000000007;
 
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

#define all(c) (c).begin(), (c).end()

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


int main(){
  string s;
  cin >> s;
  ll k;
  cin >> k;
  ll one = -1;
  REP(i, s.length()){
    if(s[i] == '1'){
      one = ll(i);
    }else{
      break;
    }
  }
  if(k <= one + 1){
    cout << '1' << endl;
  }else{
    cout << s[one + 1] << endl;
  }
}

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

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

using namespace std;

int main(){
	int h,w,q; scanf("%d%d%d",&h,&w,&q);
	static char B[2000][2001];
	rep(i,h) scanf("%s",B[i]);

	static int sum1[2001][2001],sum2[2000][2001],sum3[2001][2000];
	rep(i,h) rep(j,w) sum1[i+1][j+1]=sum1[i+1][j]+sum1[i][j+1]-sum1[i][j]+(B[i][j]-'0');
	rep(i,h-1) rep(j,w) sum2[i+1][j+1]=sum2[i+1][j]+sum2[i][j+1]-sum2[i][j]+(B[i][j]=='1'&&B[i+1][j]=='1'?1:0);
	rep(i,h) rep(j,w-1) sum3[i+1][j+1]=sum3[i+1][j]+sum3[i][j+1]-sum3[i][j]+(B[i][j]=='1'&&B[i][j+1]=='1'?1:0);

	rep(_,q){
		int y1,x1,y2,x2; scanf("%d%d%d%d",&y1,&x1,&y2,&x2); y1--; x1--;
		int ans=0;
		ans+=sum1[y2][x2]-sum1[y1][x2]-sum1[y2][x1]+sum1[y1][x1];
		ans-=sum2[y2-1][x2]-sum2[y1][x2]-sum2[y2-1][x1]+sum2[y1][x1];
		ans-=sum3[y2][x2-1]-sum3[y1][x2-1]-sum3[y2][x1]+sum3[y1][x1];
		printf("%d\n",ans);
	}

	return 0;
}


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

int main()
{
  int m1 , d1 , m2 , d2;
  cin>>m1>>d1>>m2>>d2;
  
  if((m1+1) % 12 == (m2 % 12))
    cout<<1;
  else
    cout<<0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 1e5 + 55;//, mod = 1e9 + 7;
int n, p[maxn], rem[maxn], deg[maxn], h[maxn];
vi g[maxn], ord;
void dfs(int v, int pr = -1) {
	p[v] = pr;
	for(auto i : g[v])
		if(i!=pr) h[i] = h[v] + 1, dfs(i, v), deg[v]++;
	ord.pb(v);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	if(n==1) return cout << "First", 0;
	if(n==2) return cout << "Second", 0;
	for(int f, t, i = 1; i < n; i++) {
		cin >> f >> t;
		g[f].pb(t);
		g[t].pb(f);
	}
	int r = 0;
	for(int i = 1; i <= n; i++) if(g[i].size()==1) {dfs(i);r=i;break;};
	sort(all(ord), [&](const int &i, const int &j) {
		return h[i] > h[j];
	});
	int lft = 0;
	for(auto i : ord) {
		if(rem[i]) continue;
		if(deg[i] ==0 && deg[p[i]]==1) {
			rem[i] = rem[p[i]] = 1;
			p[p[i]]!=-1?deg[p[p[i]]]--:0;
		} else lft++;
	}
	lft += 1^rem[r];
	cout << (lft==0?"Second":"First");
}



Measured memory_bytes: 8824
#include <iostream>
#include <string>

using namespace std;

int main() {
	string S;
	cin >> S;

	int answer = 100000;
	for (int i = 0; i < S.length() - 2; ++i) {
		int tmp = stoi(S.substr(i, 3));
		if (abs(tmp - 753) < answer) {
			answer = abs(tmp - 753);
		}
	}

	cout << answer << endl;
}


Measured memory_bytes: 256
a = [4,6,9,	11]
b = [1,3,5,7,8,10,12]
x,y = list(map(int, input().split()))
if x ==2 or y ==2:
  print("No")
elif x in a and y in a:
  print("Yes")
elif x in b and y in b:
  print("Yes")
else:
  print("No")

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

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

#define val(x) (a[x.second] - a[x.first - 1])

Int a[4320];
Int p = 0;

vector<int> ans;
vector<P> nums;
int maxdp[4004];
int dp[4004][4004];
int n;
bool comp(const P &x, const P &y){
	if(val(x) == val(y)){
		return x > y;
	}
	return val(x) < val(y);
}

int main(){
	cin >> n;
	for(int i = 1;i <= n;i++)cin >> a[i];
	for(int i = 1;i <= n;i++)a[i] += a[i-1];
	for(int i = 1;i <= n;i++){
		for(int j = i;j <= n;j++){
			nums.push_back(P(i, j));
		}
	}
	sort(nums.begin(), nums.end(), comp);
	for(int i = 0;i < nums.size();i++){
		int from = nums[i].first;
		int to = nums[i].second;
		if(from == 1){
			dp[from][to] = 1;
		}
		else if(maxdp[from-1]){
			dp[from][to] = max(maxdp[from-1] + 1, dp[from][to]);
		}
		maxdp[to] = max(maxdp[to], dp[from][to]);
	}
	int m = maxdp[n];
	cout << m << endl;
	for(int x = n;x >= 1;){
		for(int j = x;j >= 0;j--){
			if(dp[j][x] == m){
				m--;
				ans.push_back(j);
				x = j - 1;
				break;
			}
		}
	}	
	for(int i = ans.size() - 2;i >= 0;i--){
		cout << ans[i]-1;
		if(i)cout << " ";
	}       cout << endl;
	return 0;
}

Measured memory_bytes: 127264
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;
#define ll long long

vector<ll> H;
int N, K;

void input() {
  cin >> N >> K;
  ll h;
  for (int i=0; i<N; i++) {
    cin >> h;
    H.push_back(h);
  }
}

void solve() {
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());
  ll total = 0;
  for (int i=K; i<N; i++) total += H.at(i);
  cout << total << endl;
}

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


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
#define maxn 100005
#define Mod 1000000007
typedef pair<int,int> PII;
typedef map<int,int> MII;
typedef vector<int> VI;
typedef vector<vector<int>> VII;
typedef vector<long long> VLL; 
#define For(i,a,b) for(int i = (a); i < (b); ++i)
#define Rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
#define __builtin_popcountll bitCountLL
#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
const int INF = 2e9;
const LL ML = 4e18;

void solve() {
    int n;
    cin >> n;
    VI a(n);
    map<int,int> mp;
    LL sum = 0;
    For(i,0,n) {
        cin >> a[i];
        mp[a[i]]++;
        sum += a[i];
    }
    int q;
    cin >> q;
    For(i,0,q) {
        int a,b;
        cin >> a >> b;
        sum += mp[a] * (b - a);
        mp[b] += mp[a];
        mp[a] = 0;
        cout << sum << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
    solve();
    
    /*clock_t start,finish;
    start = clock();
   
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  REP(i,H) cin >> S[i];

  string ret = "Yes";
  REP(i,H)REP(j,W) {
    if(S[i][j] != '#') continue;
    bool flag = false;
    REP(k,4) {
      int yi = i + dy[k];
      int xi = j + dx[k];
      if(yi < 0 || yi >= H || xi < 0 || xi >= W) continue;
      if(S[yi][xi] == '#') flag = true;
    }
    if(!flag) ret = "No";
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll a, b, c;

void solve() {
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << 0 << endl;
    else
        cout << min({-a * b * (c / 2) + a * b * (c - c / 2),
                     -(a / 2) * b * c + (a - a / 2) * b * c,
                     -a * (b / 2) * c + a * (b - b / 2) * c}) << endl;
}

int main() {
    cin >> a >> b >> c;
    solve();
    return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
MOD = 998244353
dp = [[0]*(D+1) for i in range(C+1)]
for i in range(A, C+1):
    for j in range(B, D+1):
        if (i, j) == (A, B):
            dp[i][j] = 1
        else:
            dp[i][j] = (dp[i-1][j]*j + dp[i][j-1]*i - dp[i-1][j-1]*(i-1)*(j-1)) % MOD

print(dp[-1][-1])

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

int main(){
  int A,B,C,D,count=0;
  cin>>A>>B;
  int i=A;
  while(i<=B){
    C=i%100;
    D=i/1000;
    if(C%10==D/10 && C/10==D%10)
      count++;
    i++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>
#define MOD 1000000007
#define modml(rhs,lhs) (1ll * (rhs) * (lhs) % (MOD))
#define modadd(rhs,lhs) (((rhs) + (lhs)) % (MOD))

static inline long modpow(long num,long ind){
    unsigned long u_ind = ind;
    long res = 1;
    while(u_ind){
        if(u_ind & 1ul)res = modml(res,num);
        num = modml(num,num);
        u_ind >>= 1;
    }
    return res;
}

int main(void){
    register int i,j;
    register uint64_t bitc;
    long n,tmp;
    long ans = 0;
    scanf("%ld",&n);
    uint64_t a[n];
    for(i = 0;i < n;i++)scanf("%"SCNu64,&a[i]);
    for(i = 0;i < 60;i++){
        bitc = 1ull << i;
        tmp = 0;
        for(j = 0;j < n;j++)if(a[j] & bitc)tmp++;
        ans = modadd(ans,modml(modpow(2,i),modml(tmp,n-tmp)));
    }
    printf("%ld",ans);
    return 0;
}

Measured memory_bytes: 2560
#include <cstdio>

using namespace std;

int main(){
	int N, Y;
	scanf("%d%d", &N, &Y);
	if (10000 * N < Y){
		printf("-1 -1 -1\n");
		return 0;
	}
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= N-i; j++){
			if (5000 * i + 9000 * j == 10000 * N - Y){
				printf("%d %d %d\n", N-i-j, i, j);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");

	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n;cin>>n;
  vector<ll> a(3*n);
  rep(i,3*n)cin>>a[i];
  sort(a.begin(), a.end());
  ll result=0, t=0;
//  rep(i, n)result+=a[n+i];
  rep(i,n) t += a[n+i*2];
  result = max(result, t);
//cout<<t<<' '<<result<<endl;
  cout<<result;

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int w,h,n,x[N],y[N],stx[N],sty[N],ans=0,mx[N<<2],tag[N<<2],st1[N],st2[N],tp1,tp2;
vector<int> vec[N];

#define ls (x<<1)
#define rs (x<<1|1)

void mdf(int x,int v) {
	mx[x]+=v,tag[x]+=v;
}

void pushdown(int x) {
	if(tag[x]) mdf(ls,tag[x]),mdf(rs,tag[x]),tag[x]=0;
}

void modify(int L,int R,int v,int x=1,int l=1,int r=*stx) {
	L=max(L,1);
	if(L>R) return;
	if(L<=l&&r<=R) return mdf(x,v);
	pushdown(x);
	int mid=(l+r)>>1;
	if(L<=mid) modify(L,R,v,ls,l,mid);
	if(R>mid) modify(L,R,v,rs,mid+1,r);
	mx[x]=max(mx[ls],mx[rs]);
}

void work() {
	for(int i=1;i<=*stx;i++) vec[i].clear();
	for(int i=1;i<=n;i++) vec[x[i]].push_back(i);
	int tt=n;
	for(int i=1;i<=*stx;i++) {
		x[++tt]=i,y[tt]=1;vec[i].push_back(tt);
		x[++tt]=i,y[tt]=*sty;vec[i].push_back(tt);
	}
	memset(mx,0,sizeof(mx));
	memset(tag,0,sizeof(tag));
	int lim=upper_bound(sty+1,sty+*sty+1,h/2)-sty-1;
	tp1=tp2=0;
	for(int i=1;i<=*stx;i++) {
		modify(1,i-1,stx[i]-stx[i-1]);
		modify(i-1,i-1,h);
		ans=max(ans,mx[1]);
		int _mn=*sty,_mx=1;
		for(auto p:vec[i]) {
			if(y[p]<=lim) {
				while(tp1&&y[p]>=y[st1[tp1]]) {
					modify(x[st1[tp1-1]],x[st1[tp1]]-1,-(sty[y[p]]-sty[y[st1[tp1]]]));
					--tp1;
				}
				st1[++tp1]=p;_mx=max(_mx,y[p]);
			}
			else {
				while(tp2&&y[p]<=y[st2[tp2]]) {
					modify(x[st2[tp2-1]],x[st2[tp2]]-1,-(sty[y[st2[tp2]]]-sty[y[p]]));
					--tp2;
				}
				st2[++tp2]=p;_mn=min(_mn,y[p]);
			}
		}
		modify(i-1,i-1,-h+(sty[_mn]-sty[_mx]));
	}
}

int main() {
	cin>>w>>h>>n;
	for(int i=1;i<=n;i++) {
		stx[i]=x[i]=gi();
		sty[i]=y[i]=gi();
	}
	stx[n+1]=0,stx[n+2]=w;
	sort(stx+1,stx+n+3);
	*stx=unique(stx+1,stx+n+3)-stx-1;
	sty[n+1]=0,sty[n+2]=h;
	sort(sty+1,sty+n+3);
	*sty=unique(sty+1,sty+n+3)-sty-1;
	for(int i=1;i<=n;i++) {
		x[i]=lower_bound(stx+1,stx+*stx+1,x[i])-stx;
		y[i]=lower_bound(sty+1,sty+*sty+1,y[i])-sty;
	}
	work();
	for(int i=1;i<=n;i++) swap(x[i],y[i]);
	swap(stx,sty);swap(w,h);
	work();cout<<ans*2;
	return 0;
}


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

int main(){
	int n;
	int A[100];
	int sw = 0;
	bool flag = 1;

	cin>>n;
	for(int i=0; i<n; i++) cin>>A[i];

	for(int i=0; flag; i++){
		flag = 0;
		for(int j=n-1; j>=i+1; j--){
			if(A[j]<A[j-1]){
				swap(A[j], A[j-1]);
				flag = 1;
				sw++;
			}
		}
	}

	for(int i=0; i<n; i++){
		if(i) cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
	cout<<sw<<endl;

	return 0;
}


Measured memory_bytes: 3120
from functools import reduce
def resolver(N, A):
    X = reduce(int.__xor__, A)
    ans = [str(X^a) for a in A]
    
    return ans

def test():
    pass

def main():

    #test()

    N = int(input())
    A = list(map(int, input().split()))
    ans = resolver(N, A)

    print(" ".join(ans))
    



if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
    int n,l;
    cin>>n>>l;

    int sum=0;
    vector<int> apple(n);
    for(int i=0;i<n;i++){
        apple[i]= l+i;
        sum+=apple[i];
    }

    int res=1e8;
    for(int i=0;i<n;i++){
        int tmp = sum - apple[i];
            if(abs(sum-tmp)<abs(sum-res))
                res = tmp;
    }
    cout<<res;
}


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

struct list { int b, c; };
typedef struct list *listp;

int cmp1(const void *a, const void *b) {
    int d1 = *(int*)a, d2 = *(int*)b;
    if(d1 > d2)         { return 1; }
    else if(d1 == d2)   { return 0; }
    else                { return -1; }
}

int cmp2(const void *a, const void *b) {
    listp d1 = *(listp*)a, d2 = *(listp*)b;
    if(d1->c > d2->c)       { return -1; }
    else if(d1->c == d2->c) { return 0; }
    else                    { return 1; }
}

int main(void) 
{
    int N, M, i, j, cnt;
    scanf("%d %d", &N, &M);
    int *A = (int*)malloc((N+3)*sizeof(int));
    listp *list = (listp*)malloc((M+4)*sizeof(listp));
    for(i = 0; i < M; ++i) {
        list[i] = (listp)malloc(sizeof(struct list));
    }
    for(i = 0; i < N; ++i) {
        scanf("%d", &A[i]);
    }
    for(i = 0; i < M; ++i) {
        scanf("%d %d", &list[i]->b, &list[i]->c);
    }
    qsort(A, N, sizeof(int), cmp1);
    qsort(list, M, sizeof(listp), cmp2);

    /*
    for(i = 0; i < N; ++i) {
        printf("%d ", A[i]);
    }
    printf("\n");
    for(i = 0; i < M; ++i) {
        printf("%d %d\n", list[i]->b, list[i]->c);
    }
    */
    
    cnt = 0;
    long long ans = 0;
    for(i = 0; i < M; ++i) {
        for(j = 0; j < list[i]->b; ++j) {
            if(list[i]->c <= A[cnt]) { break; }
            ans += list[i]->c;
            ++cnt;
            if(N <= cnt) { break; }
        }
        if(N <= cnt ) { break; }
    }

    for( ; cnt < N; ++cnt) {
        ans += A[cnt];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 5304
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int res=0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[i]==a[j] || a[j]==a[k])
                continue;
                if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i])
                res++;
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
int main(){
  int x;
  cin>>x;
  int y=x/500;
  x -=y*500;
  int z=x/5;
  cout << y*1000+z*5;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define CONTAINS(a, x) (a.find(x) != a.end())
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define nl cout << endl
#define F first
#define S second
 
#define what_is(x) cout << #x << " = " << x << endl
#define boost ios::sync_with_stdio(false);cin.tie(NULL)
#define CASET int ___T, case_n = 1; cin >> ___T; while (___T-- > 0) 
 
 
#define rep(it, st, en) for(ll it = st; it < en; it++)
#define rep1(it, st, en) for(ll it = st; it <= en; it++)
#define per(it, st, en) for(ll it = en - 1; it >= st; it--)
 
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<ii> vii;
typedef vector<vi> vvi;
 
ll INF = 1E9;
ll M = 1E9 + 7;
 
inline ll max_(ll a, ll b) { return (a>b)?a:b; }
inline ll min_(ll a, ll b) { return (a<b)?a:b; }
 
inline ll power (ll a,ll p){
    ll res = 1, x = a;
    while ( p ) {
        if ( p & 1 ) res = ( res * x );
        x = ( x * x ); p >>= 1;
    }
    return res;
}
 
template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}

int main() {
    boost;
    if(fopen("inp.txt", "r")){
      freopen("inp.txt", "r", stdin);
      freopen("outp.txt", "w", stdout);
    }

    ll n,a;
    cin>>n;

    set<ll> sheet;

    while (n--) { 
        cin>>a;
        if (sheet.find(a)!=sheet.end())
            sheet.erase(a);
        else
            sheet.insert(a);
    }

    cout<<(ll)sheet.size();

    return 0;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] a = new int[n];
			int[] b = new int[n];
			int[] c = new int[n];
			
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt();
				b[i] = sc.nextInt() + sc.nextInt();
			}
			
			c = Arrays.copyOf(b, n);
			Arrays.sort(b);
			
			for(int i=0;i<n;i++){
				if(c[i]==b[n-1])System.out.println(a[i] + " " + b[n-1]);
			}	
		}
	
	}	
}

Measured memory_bytes: 159948
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec(x) vector<x>
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pair<ll,ll>>
#define matrix(x) vector<vector<x>>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define ff first
#define ss second
#define mp make_pair
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main()
{
    ll n,l;
    cin>>n;
    cin>>l;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    map<ll,ll>mymap;
    ll cont=1;
    ll flag=0;
    ll k;
   for(ll i=0;i<n-1;i++)
   {
       ll total=a[i]+a[i+1];
       if(total>=l)
       {flag=1;
        k=i; break;}
        mymap.insert(pair<ll,ll>(total,cont) );
        cont++;
   }
   if(flag==1)
   {   cout<<"Possible"<<endl;
       for(ll i=0;i<k;i++)
       {cout<<i+1<<endl;}
        for(ll i=n-2;i>=k;i--)
        {cout<<i+1<<endl;}
   }
   else
    cout<<"Impossible"<<endl;
}


Measured memory_bytes: 10468
#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 << 62;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    UnionFind uf(N);
    rep(i, M){
        int a, b; cin >> a >> b;
        uf.merge(a-1, b-1);
    }
    priority_queue<int> pq;
    rep(i, N) pq.push(uf.size(i));
    cout << pq.top() << endl;
    return 0;
}

Measured memory_bytes: 4988
from collections import defaultdict
# n,m = map(int, input().split())
# b = list(map(int, input().split()))
# n = int(input())
# a = [int(input()) for _ in range(n)]
s = input()
t = input()

if s == t[0:-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9336
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
    cin>>n;
    vector<double>v(n);
    rep(i,n)cin>>v[i];
    sort(all(v));
    double ans=0;
    ans+=(v[0]+v[1])/2.0;
    rep(i,n-2){
        int ite=i+2;
        ans+=v[ite];
        ans/=2.0;
    }
    cout<<setprecision(9)<<ans<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define INF (ll)1e18
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(10);};}aaaaaaa;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){
    cin>>head;
    in(move(tail)...);
}
template <class T>
inline void out(T t) {
    cout<<t<<'\n';
}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){
    cout<<head<<' ';
    out(move(tail)...);
}
int main(){
    int n;
    in(n);
    int a,before;
    in(a);
    before=a;
    int cnt=0,ans=0;
    rep(i,1,n){
        in(a);
        if(before==a)cnt++;
        else{
            before=a;
            ans+=(cnt+1)/2;
            cnt=0;
        }
    }
    before=a;
    ans+=(cnt+1)/2;
    out(ans);
}























Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;
int n,x,y,ans,vis[maxn];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts("");}
struct Heavy_Light_Decomposition{
    struct edge{int to,nxt;}e[maxn<<1];int tot,head[maxn];
    int idx,fa[maxn],dfn[maxn],dep[maxn],son[maxn],top[maxn],size[maxn];
    void add(int u,int v){e[++tot].to=v;e[tot].nxt=head[u];head[u]=tot;}
    void insert(int u,int v){add(u,v);add(v,u);}
    void build(int x){
        dep[x]=dep[fa[x]]+1;size[x]=1;int mx=0;
        for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to){
            if(v==fa[x])continue;
            fa[v]=x;build(v);size[x]+=size[v];
            if(size[v]>mx)mx=size[v],son[x]=v;
        }
    }
    void dfs(int x){
        if(!x)return ;dfn[x]=++idx;
        top[x]=son[fa[x]]==x?top[fa[x]]:x;
        dfs(son[x]);
        for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
            if(v!=fa[x]&&v!=son[x])dfs(v);
    }
    int query(int u,int v){
        while(top[u]!=top[v]){
            if(dep[top[u]]<dep[top[v]])swap(u,v);
            u=fa[top[u]];
        }if(dep[u]>dep[v])swap(u,v);
        return u;
    }
    int get_dis(int u,int v){return dep[u]+dep[v]-2*dep[query(u,v)];}
}HLD[2];
void init(int S){
    queue<int >q;
    q.push(S);vis[S]=1;
    while(!q.empty()){
        int x=q.front();q.pop();
        for(int i=HLD[0].head[x],v=HLD[0].e[i].to;i;i=HLD[0].e[i].nxt,v=HLD[0].e[i].to)
            if(!vis[v]&&HLD[0].dep[v]<HLD[1].dep[v])vis[v]=1,q.push(v);
    }
}
void solve(){
    for(int x=1;x<=n;x++){
        if(!vis[x])continue;
        ans=max(ans,HLD[1].dep[x]-1);
        for(int i=HLD[0].head[x],v=HLD[0].e[i].to;i;i=HLD[0].e[i].nxt,v=HLD[0].e[i].to)
            if(HLD[1].get_dis(v,x)>2){puts("-1");return ;}
    }write(ans<<1);
}
int main(){
    n=read();x=read();y=read();
    if(x==y){puts("0");return 0;}
    for(int i=1;i<n;i++)HLD[0].insert(read(),read());
    for(int i=1;i<n;i++)HLD[1].insert(read(),read());
    HLD[0].build(x);HLD[0].dfs(x);HLD[1].build(y);HLD[1].dfs(y);
    init(x);solve();
    return 0;
}

Measured memory_bytes: 29440
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int a,b;
    cin >> a >> b;
    int a_leng = to_string(a).length();
    int b_leng = to_string(b).length();
    int num = a*pow(10,b_leng) + b;
    if(floor(sqrt(num))*floor(sqrt(num)) == num)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int a[10];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		a[i]=-1;	
	}
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		if(x>n){
			cout<<"-1";
			return 0;	
		}
		if(a[x]<0){
			a[x]=y;
		}
		else{
			if(a[x]!=y){
				cout<<"-1";
				return 0;
			}
		}
	}
	if(n==1&&a[1]==0){
		cout<<"0";
		return 0;	
	}
	if(n==1&&m==0){
		cout<<"0";
		return 0;	
	}
	int ok=0;
	for(int i=1;i<=n;i++){
		if(ok==0){
			if(a[i]==0){
				cout<<"-1";
				return 0;
			}
			else {
				ok=1;
				if(a[i]==-1) a[i]=1;
				cout<<a[i];	
			}
		}
		else{
			if(a[i]==-1) a[i]=0;
			cout<<a[i];	
		}
	}
	return 0;
}

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

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    ll ans = b/x - a/x;
    if(a % x == 0){
        ans++;
    }

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

Measured memory_bytes: 3636
from bisect import bisect_left

N = int(input())
A = sorted(list(map(int, input().split())))

a = A[-1]
b = float(a) / 2
i = bisect_left(A, b)
if a % 2 == 0 and A[i] == a // 2:
    print(a, a // 2)
else:
    if b - A[i-1] <= A[i] - b:
        print(a, A[i-1])
    else:
        print(a ,A[i])

Measured memory_bytes: 14428
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  long long K;
  cin >> N >> K;
  int count[40] = {0};
  long long A;
  for(int i=0; i<N; i++){
    cin >> A;
    for(int j=0; j<40; j++){
      if(A == 0) break;
      if(A % 2 == 1) count[j]++;
      A /= 2;
    }
  }
  
  int twoK1[40] = {0};
  K++;
  for(int i=0; i<40; i++){
    if(K % 2 == 1) twoK1[i]++;
    K /= 2;
    if(K == 0) break;
  }
  
  long long ans = 0;
  long long tmp = 0;
  int t;
  for(int i=39; i>=0; i--){
    tmp = 0;
    if(twoK1[i] == 0) continue;
    for(int j=39; j>i; j--){
      if(twoK1[j] == 1){
        t = N - count[j];
      }else{
        t = count[j];
      }
      tmp += (1LL << j) * t;
    }
    t = count[i];
    tmp += (1LL << i) * t;
    
    for(int j=i-1; j>=0; j--){
      t = max(N-count[j], count[j]);
      tmp += (1LL << j) * t;
    }
    ans = max(ans, tmp);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
#puts "n = #{n}"
a = []
moto_a = []

a << gets.chomp.to_i
a << gets.chomp.to_i
max = 1
second_max = 0
max_index = 0
second_max_index = 0
max_count = 0

if(a[0] > a[1])
  max = a[0]
  second_max = a[1]
  max_index = 0
  second_max_index = 1
  moto_a << 1
  moto_a << -1
  max_count = 1
elsif a[0] == a[1]
  max = a[0]
  second_max = a[1]
  max_index = 0
  second_max_index = 1
  moto_a << 1
  moto_a << 1
else
  max = a[1]
  second_max = a[0]
  max_index = 1
  second_max_index = [0]
  moto_a << -1
  moto_a << 1
  max_count = 1
end
ind = 1

#puts "max = #{max}, second_max = #{second_max}"

(n-2).times do|ii|
  i = ii + 2
  t = gets.chomp.to_i
  if(max < t)
    moto_a[second_max_index] = ind
    second_max = max
    second_max_index = max_index
    max_index = i
    max = t
    ind  += 1
    moto_a << ind
  elsif (max == t)
    second_max = t
    second_max_index = i
    moto_a << ind
    
  elsif (second_max < t)
    second_max = t
    second_max_index = i 
    moto_a << ind-1
  else 
    moto_a << ind-1
  end
  #puts "now moto_a = #{moto_a}"

end
n.times do|i|
  if(moto_a[i] < ind)
    puts max
  else
    puts second_max
  end 
end
#pp moto_a


Measured memory_bytes: 4860
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define MAXN 100000
using namespace std;
int numbers;
 
 
long long results;
 
int main()
{
	cin >> numbers;
	for(int a = 1; a <= numbers; ++a)
	{
		for(int b = 1; b <= numbers; ++b)
		{
			for(int c = 1; c <= numbers; ++c)
			{
				results += __gcd(a, __gcd(b, c));
			}	
		}
 
	}
	cout << results << endl;
	return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = sorted(list(map(int, input().split())), reverse = True)

alice = 0
bob = 0

i = 0
lim = n // 2 * 2

while i < lim:
    alice += a[i]
    bob += a[i+1]
    i += 2

if n % 2 == 1:
    alice += a[n-1]

print(alice-bob)

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

int main() {
  int P, Q, R; cin >> P >> Q >> R;
  vector<int> A(3);
  A.at(0) = P;
  A.at(1) = Q;
  A.at(2) = R;
  sort(A.begin(), A.end());
  cout << A.at(0) + A.at(1) << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var w string
	fmt.Scanf("%s", &w)

	_w := strings.Split(w, "")

	ans := "Yes"
	for i := 0; i < len(_w); i++ {
		if strings.Count(w, _w[i])%2 != 0 {
			ans = "No"
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<iomanip>

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

#define P pair<int, int>

typedef long long ll;

using namespace std;


const ll MOD = 1e9 + 7;

int N, K;
int a[105];
ll dp[105][100005] = {};
int main() {
	cin >> N >> K;
	rep(i, N) cin >> a[i + 1];

	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= K; j++) {
			dp[i][j] = dp[i - 1][j];
			if(j > 0) dp[i][j] += dp[i][j - 1];
			if (j - a[i] - 1 >= 0) dp[i][j] -= dp[i - 1][j - a[i] - 1];
			dp[i][j] = (dp[i][j]+MOD)%MOD;
		}
	}
	cout << dp[N][K] << endl;

	return 0;
}


Measured memory_bytes: 79360