akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll N,K,X,Y; cin >> N >> K >> X >> Y;
    cout << X*min(N,K) + Y*max(0LL,N-K) << endl;
    return 0;
}


Measured memory_bytes: 3648
//Vol5 588
#include<stdio.h>
#include<string.h>
int main()
{
	int n,s=0;
	char c,l='+';
	while(1){
		scanf("%d\n",&n);
		scanf("%c",&c);
		if(l=='+'){
			s+=n;
		}else if(l=='-'){
			s-=n;
		}else if(l=='*'){
			s*=n;
		}else{
			s/=n;
		}
		l=c;
		if(c=='='){
			printf("%d\n",s);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1812
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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



  ll a, b, c;
  cin >> a >> b >> c;
  cout << a + b + c - max({ a,b,c }) << endl;





  return 0;
}

Measured memory_bytes: 764
N, M = map(int, input().split())
all_favorit = list(range(1,M+1))
for i in range(N):
    asking_people= list(map(int, input().split()))
    for j in range(M):
        if all_favorit[j] not in asking_people[1:]:
            all_favorit[j] = 0
count = 0
for i in range(M):
    if all_favorit[i]!= 0:
        count +=1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a, b, c, d;

signed main() {
    cin >> a >> b >> c >> d;
    if(c * b <= 0 && c * a <= 0 && b * d <= 0 && a * d <= 0) {
		if(a * b * c * d == 0) {
	        puts("0");
		}
		else if(a > 0) {
			cout << a * d;
		}
		else {
			cout << b * c;
		}
    }
    else {
        cout << max(max(a * c, a * d), max(b * c, b * d));
    }
    return 0;
}

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

int main() {
	int A , B , C , D ;
  	cin >> A >> B >> C >> D ;
  	if((A + B) > (C + D)){
    	cout << "Left" << endl;
    }else if((A + B) == (C + D)){
    	cout << "Balanced" << endl;
    }else{
    	cout << "Right" << endl;
    }
}


Measured memory_bytes: 3612
import java.util.Scanner;
import java.math.BigInteger;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in).useDelimiter("[+=\n]");
		while (sc.hasNext())
		{
			String str[] = new String[3];
			int start = 0;
			for (int i = 0; i < 3; i++)
			{
				str[i] = sc.next();
				if (str[i].length() > 1 && str[i].indexOf("X") == 0)
				{
					start = 1;
				}
			}
			boolean flg = false;
			for (int i = start; i < 10; i++)
			{
				StringBuffer strb[] = new StringBuffer[3];
				for (int j = 0; j < 3; j++)
				{
					strb[j] = new StringBuffer(str[j].replaceAll("X", Integer.toString(i)));
				}
				BigInteger a = new BigInteger(strb[0].toString());
				BigInteger b = new BigInteger(strb[1].toString());
				BigInteger c = new BigInteger(strb[2].toString());
				if (a.add(b).equals(c))
				{
					System.out.println(i);
					flg = true;
					break;
				}
			}
			if (!flg)
			{
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		char[][] A = new char[N][N];
		char[][] B = new char[M][M];
		
		for(int i = 0; i < N; i++){
			A[i] = sc.next().toCharArray();
		}
		for(int i = 0; i < M; i++){
			B[i] = sc.next().toCharArray();
		}
		sc.close();
		System.out.println(isMatch(A, B) ? "Yes" : "No");
		
	}
	static boolean isMatch(char[][] a, char[][] b){
		for(int ly = 0; ly < a.length; ly++){
			for(int lx = 0; lx < a.length; lx++){
				if(ly+b.length > a.length || lx+b.length > a.length){
					continue;
				}
				boolean match = true;
				for(int y = 0; y < b.length; y++){
					for(int x = 0; x < b.length; x++){
						if(a[ly+y][lx+x] != b[y][x]){
							match = false;
							break;
						}
					}
					if(!match){
						break;
					}
				}
				if(match){
					return true;
				}
			}
		}
		return false;
	}
}


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

const int INF = (int)1e9;

struct Edge {
  int src, dst, cost;
  Edge(int s, int d, int c) : src(s), dst(d), cost(c) { }
};

struct State {
  int pos, cost;
  State(int p, int c) : pos(p), cost(c) { }
  bool operator >(const State &rhs) const {
    return cost > rhs.cost;
  }
};

typedef vector<vector<Edge>> Graph;

vector<int> shortest_path(const Graph &G, int r) {
  vector<int> d(G.size(), INF);
  d[r] = 0;
  priority_queue<State, vector<State>, greater<State> > Q;
  Q.push(State(r, 0));
  while(!Q.empty()) {
    State s = Q.top(); Q.pop();
    if(s.cost > d[s.pos]) continue;
    for(const Edge &e : G[s.pos]) {
      if(d[e.dst] > d[e.src] + e.cost) {
        d[e.dst] = d[e.src] + e.cost;
        Q.push(State(e.dst, d[e.dst]));
      }
    }
  }
  return d;
}

int main() {
  ios::sync_with_stdio(false);
  int V, E, r;
  cin >> V >> E >> r;
  Graph G(V);
  for(int i = 0; i < E; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    G[s].push_back(Edge(s, t, d));
  }
  vector<int> d = shortest_path(G, r);
  for(int i = 0;  i < V; i++) {
    if(d[i] == INF) cout << "INF" << endl;
    else cout << d[i] << endl;
  }
}

Measured memory_bytes: 13636
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (i * (m - j) + j * (n - i) == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	 int C=0;

	 char S[10],T[10];

	 scanf("%s%s",S,T);

	 if(S[0]==T[0]) {++C;}

	 if(S[1]==T[1]) {++C;}

	 if(S[2]==T[2]) {++C;}

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

}

Measured memory_bytes: 128
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 

const ll MOD = 1e9 + 7;
int N;
string P = "ACGT";
vector<map<string, ll>> dp;

ll dfs(int n, string res) {
    if (res.size() >= 3 && (
        (res[n - 3] == 'A' && res[n - 2] == 'G' && res[n - 1] == 'C') ||
        (res[n - 3] == 'A' && res[n - 2] == 'C' && res[n - 1] == 'G') ||
        (res[n - 3] == 'G' && res[n - 2] == 'A' && res[n - 1] == 'C'))) return 0;

    if (res.size() >= 4 && (
        (res[n - 4] == 'A' && res[n - 2] == 'G' && res[n - 1] == 'C') ||
        (res[n - 4] == 'A' && res[n - 3] == 'G' && res[n - 1] == 'C'))) return 0;

    if (n >= N) return 1;    

    assert(n == res.size());
    if (n >= 3) {
        string last3 = res.substr(n - 3, 3);
        if (dp[n].count(last3) > 0) return dp[n][last3];
    }

    ll ret = 0;
    REP(i, 4) {
        ret += dfs(n + 1, res+P[i]);
        ret %= MOD;
    }

    if (n >= 3) {
        string last3 = res.substr(n - 3, 3);
        dp[n][last3] = ret;
    }

    return ret;
}

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


    cin >> N;

    dp = vector<map<string, ll>>(N + 1);

    ll ans = dfs(0, "");

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
			if(a + b + c == 17 && a * b * c == 175){
				System.out.println("YES");
			}else
				System.out.println("NO");
	}
}


Measured memory_bytes: 8788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN=30;
int a[MAXN], b[MAXN];
int main(){
    int n, m, cs=1;
    while(cin>>n>>m&&n+m){
        int cnt=0;
        memset(a,0,sizeof a);
        a[0]=n;
        while(!a[m]){
            b[0]=a[0]%2;
            for(int i=0; i<=m; i++){
                if(i) b[i]=a[i]%2+a[i-1]/2;
                b[0]+=a[i]/2;
            }
            swap(a,b);
            cnt++;
        }
        printf("Case %d: %d\n",cs++,cnt);
    }
    return 0;
}

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

int main() {
  long double W, H, x, y;
  cin >> W >> H >> x >> y;
  long double ans = W * H / 2;
  if ( x == W / 2 && y == H / 2 ) {
    cout << ans << " " << 1;
  } else {
    cout << ans << " " << 0;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	unordered_map<string,int> mp;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)	
	{
		string s;
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<'\n';
	cout<<"WA x "<<mp["WA"]<<'\n';
	cout<<"TLE x "<<mp["TLE"]<<'\n';
	cout<<"RE x "<<mp["RE"]<<'\n';
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,e=0,o=0;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]&1)
            o++;
        else
            e++;
    }
    ll ans=1ll*pow(1ll*3,1ll*n)-pow(1ll*2,1ll*e);
    cout<<ans<<endl;
}
return 0;
}

Measured memory_bytes: 4040
#include <string.h>
#include <stdio.h>
#define REP(i,n) for(int i=0; i< int(n); (i)++)

int main()
{
    char a[52]={0};
    int i,len,tmp;
    scanf("%s",a);
    len = strlen(a);
    REP(i,len-8)
    {
        printf("%c",a[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
process.stdin.resume();
process.stdin.setEncoding('utf8'); 
var lines = [];
var reader = require('readline').createInterface({
	input: process.stdin,
	output: process.stdout
});
 
reader.on('line', (line) => {
	lines.push(line);
});

reader.on('close', () => {
	"use strict"
	const N = +lines[0];
	const S = lines[1];
	const K = +lines[2];
	
	let ans = "";
	for(let l of S){ans+= l==S[K-1]?l:"*"}
	console.log(ans)
});

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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vi adj[222222];
int a[222222];

// Binary search (note boundaries in the caller) 
int CeilIndex(std::vector<int>& v, int l, int r, int key) 
{ 
    while (r - l > 1) { 
        int m = l + (r - l) / 2; 
        if (v[m] >= key) 
            r = m; 
        else
            l = m; 
    } 
  
    return r; 
} 
  
     
 std::vector<int> tail(222222, 0); 
vector<ii> upd;
  
vi LEN;
int length = 1;
void add(int v)
{
	LEN.pb(length);
	if(v<tail[0])
	{
		upd.pb({0,tail[0]});
		tail[0]=v;
	}
	else if(v>tail[length-1])
	{
		upd.pb({length,tail[length]});
		tail[length++]=v;
	}
	else
	{
		int id=CeilIndex(tail,-1,length-1,v);
		upd.pb({id,tail[id]});
		tail[id]=v;
	}	
}

void pop()
{
	tail[upd.back().fi]=upd.back().se;
	upd.pop_back();
	length=LEN.back();
	LEN.pop_back();
}
  
int ans[222222];

void dfs(int u, int p=-1)
{
	ans[u]=length;
	for(int v:adj[u])
	{
		if(v==p) continue;
		add(a[v]);
		dfs(v,u);
		pop();
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	tail[0]=a[0];
	for(int i=0;i<n-1;i++)
	{
		int u,v; cin>>u>>v; u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	dfs(0);
	for(int i=0;i<n;i++)
	{
		cout<<ans[i]<<'\n';
	}
}


Measured memory_bytes: 33140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] employees = new int[N];

        for (int i = 0; i < N - 1; i++) {
            int temp = scanner.nextInt();
            employees[temp - 1]++;
        }

        scanner.close();

        for (int i : employees) {
            System.out.println(i);
        }

    }
}

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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=2e5+50, mod=1e9+7;
inline int mul(int x,int y) {return (long long)x*y%mod;}
inline int power(int a,int b,int rs=1) {for(;b;b>>=1,a=mul(a,a)) if(b&1) rs=mul(rs,a); return rs;}

int n,X,Y,cov[N];
vector <int> c[N];

struct combin {
	int fac[N],ifac[N];
	combin() {
		fac[0]=1;
		for(int i=1;i<N;i++) fac[i]=mul(fac[i-1],i);
		ifac[N-1]=power(fac[N-1],mod-2);
		for(int i=N-2;~i;i--) ifac[i]=mul(ifac[i+1],i+1);
	}
} C;

int main() {
	n=rd(), X=rd(), Y=rd();
	for(int i=1;i<=n;i++) {
		int col=rd(), w=rd();
		c[col].push_back(w);
	}
	for(int i=1;i<=n;i++) sort(c[i].begin(),c[i].end());
	int mn=2e9, id=23333, sec=2e9;
	for(int i=1;i<=n;i++) if(c[i].size() && c[i].front()<mn) mn=c[i].front(), id=i;
	for(int i=1;i<=n;i++) if(c[i].size() && (i==id || c[i].front()+mn<=Y)) {cov[i]=1; sec=min(sec,(i!=id) ? c[i].front() : sec);}
	int prd=1, sum=0;
	for(int i=1;i<=n;i++) {
		if(cov[i]) {
			int j=1;
			while(j<c[i].size() && (c[i][j]+c[i].front()<=X || (i!=id && c[i][j]+mn<=Y) || (i==id && c[i][j]+sec<=Y))) ++j;
			prd=mul(prd,C.ifac[j]); sum=sum+j;
		}
	}
	cout<<mul(C.fac[sum],prd)<<'\n';
}

Measured memory_bytes: 11904
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()


    var currentTime = 0
    var currentX = 0
    var currentY = 0
    (0 until N).forEach { i ->
        val (t, x, y) = readLine()!!.split(" ").map { it.toInt() }
        val timeDiff = t - currentTime
        val xDiff =  x - currentX
        val yDiff = y - currentY

        if (!isPossible(timeDiff, xDiff, yDiff)) {
            println("No")
            return
        }

        // Finalize
        currentTime = t
        currentX = x
        currentY = y
    }
    println("Yes")
}

fun isPossible(tDiff: Int, xDiff: Int, yDiff: Int) : Boolean {
    var commandCountShouldBeUsed = tDiff
    commandCountShouldBeUsed -= Math.abs(xDiff)
    commandCountShouldBeUsed -= Math.abs(yDiff)

    if (commandCountShouldBeUsed == 0) {
        return true
    } else if (commandCountShouldBeUsed < 0) {
        return false
    } else {
        return commandCountShouldBeUsed %2 == 0
    }
}


Measured memory_bytes: 53996
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int r;

int main() {
	cin >> r;
	cout << r * r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	priority_queue<int> pq;
	string s;
	int k;
	while(cin >> s) {
		if(s == "end") return 0;
		if(s == "insert") {
			cin >> k;
			pq.push(k);
		} else {
			P(pq.top());
			pq.pop();
		}
	}
	return 0;
}

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

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        vector<pair<int, int>> p;
        rep(i, n) {
            int st, ar;
            rep(j, 2) {
                string tmp;
                cin >> tmp;
                int hh = (tmp[0] - '0') * 10 + tmp[1] - '0';
                int mm = (tmp[3] - '0') * 10 + tmp[4] - '0';
                int ss = (tmp[6] - '0') * 10 + tmp[7] - '0';

                if (j % 2 == 0) {
                    st = hh * 60 * 60 + mm * 60 + ss;
                }   
                else {
                    ar = hh * 60 * 60 + mm * 60 + ss;
                }
            }
            p.push_back({ar, st});
        }
        sort(all(p));
        int ans = 0;
        int now = INF;
        vector<int> sk;
        rep(i, n) {
            int idx = -1;
            rep(j, sk.size()) {
                if (sk[j] <= p[i].se) {
                    idx = j;
                }
            }
            if (idx == -1) {
                ans++;
            }
            else {
                sk.erase(sk.begin() + idx);
            }
            sk.push_back(p[i].fi);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3332
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

#define MOD ((lli)(1000000007))
lli mop(lli p,lli q){
	lli res=1,bp=p,b=1;
	while(q){
		if(q&b){
			res=(res*bp)%MOD;
			q-=b;
		}
		bp=(bp*bp)%MOD;
		b*=2;
	}
	return res;
}

lli inv(lli p){
	return mop(p,MOD-2);
}

lli fdat[500005];

lli ifdat[500005];

void init(){
	{
		fdat[0]=fdat[1]=1;
		lli r=1;
		reg(i,1,500004){
			r=(r*i)%MOD;
			fdat[i] = r;
		}
	}

	{
		ifdat[0]=ifdat[1]=1;
		lli r=1;
		reg(i,1,500004){
			r=(r*inv(i))%MOD;
			ifdat[i] = r;
		}
	}
}

lli fact(int p){
	return fdat[p];
}

lli ifact(int p){
	return ifdat[p];
}


lli comb(lli p,lli q){
	lli res=(((fact(p)*ifact(q))%MOD)*ifact(p-q))%MOD;
	return res;
}


lli nk(int p,int q){ //p+q susumi q modoru
	if(q<=0)return 1;
	return (MOD + comb(p+2*q,q) - comb(p+q*2,q-1))%MOD;
	//
}

int n,m,k;
int main(void){
	init();
	//printf("%lld\n",nk(2,1));
	//printf("%lld\n",nk(3,2));
	
	scanf("%d%d%d",&n,&m,&k);
	lli ans = 0;
	reg(i,0,k){
		lli na = comb(n+m+k*2,n+i*2);
		//printf("%lld\n",na);
		na = (na * nk(n,i))%MOD;
		na = (na * nk(m,k-i))%MOD;
		ans = (ans+na)%MOD;
	}
			
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 9000
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val set = mutableSetOf<Int>()
    repeat(n) {
        val v = readLine()!!.toInt()
        if (set.contains(v)) {
            set.remove(v)
        } else {
            set.add(v)
        }
    }
    println(set.size)
}



Measured memory_bytes: 45664
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<pair<string, int>, int>a, pair<pair<string, int>, int>b) {
	if (a.first.first == b.first.first) {
		return a.first.second > b.first.second;
	}
	return a.first.first < b.first.first;
}

int main() {
	int n;
	cin >> n;
	vector < pair<pair<string, int>, int>>a(n);
	rep(i, n) {
		cin >> a[i].first.first >> a[i].first.second;
		a[i].second = i;
	}
	sort(a.begin(), a.end(), check);
	rep(i, n) {
		cout << a[i].second + 1 << endl;
	}
	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;

int main(){
	int n,k,q;
	cin >> n >> k >> q;
	vector<int> a(q);
	rep(i,q) cin >> a[i];
	
	vector<int> p(n);
	
	rep(i,q) p[a[i]-1]++;
	
	rep(i,n){
		if(k-q+p[i]>0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
a = list(map(int,input().split()))

#a = [7,17,19]

a = sorted(a)

ans = 0

if a[2] - a[1] >= 2 :
  x = int( (a[2]-a[1]) / 2 )
  ans += x
  a[1] += 2*x

if a[1] - a[0] >= 2 :
  x = int( (a[1]-a[0]) / 2 )
  ans += x
  a[0] += 2*x

b = [0] * 3
b[2] = a[2] - a[0]
b[1] = a[1] - a[0]
b[0] = 0

if b == [0,0,2]:
  ans += 2
elif b == [0,0,1]:
  ans += 1
elif b == [0,1,2]:
  ans += 3
elif b == [0,1,1]:
  ans += 2

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

int main(void)
{

    string devide[4] = {"dream", "dreamer", "erase", "eraser"};
    string S;
    bool flag1,flag2;

    cin >> S;

    reverse(S.begin(),S.end());

    rep(i, 4)
        reverse(devide[i].begin(), devide[i].end());

    flag1 = true;

    for(int i = 0;i < S.size();){
        flag2 = false;
        rep(j,4){
            string s = devide[j];

            if(S.substr(i,s.size() ) == s){
                flag2 = true;
                i += s.size();
            }
        }
        if(flag2 == false){
            flag1 = false;
            break;
        }
    }

    if(flag1)
        cout << "YES" << endl;

    else
        cout << "NO" << endl;
    

    return 0;
}

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

using namespace std;

vector<vector<int>> graph(100000),hate(100000);
int num[100001],size[100001],sub[100001];

void dfs(int a, int b){

    if(num[a]==0){
        num[a] = b;
        size[b]++;
    }

    for(int i=0;i<graph[a].size();i++){
        if(num[graph[a][i]]==0){
            size[b]++;
            num[graph[a][i]] = b;
            dfs(graph[a][i], b);
        }
    }
}

int main(){
    int N,M,K,x=1;
    cin >> N >> M >> K;

    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    for(int i=0;i<N;i++){
        dfs(i,x);
        x++;
    }

    for(int i=0;i<K;i++){
        int c,d;
        cin >> c >> d;
        c--;
        d--;
        if(num[c]==num[d]){
            sub[c]++;
            sub[d]++;
        }
    }

    for(int i=0;i<N;i++){
        cout << size[num[i]] - sub[i] - graph[i].size() - 1 << " ";
    }
}

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

int main() {
  int n;cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll ans=0,cnt=a[0];
  for(int i=1;i<n;i++){
    if(cnt>a[i])ans+=cnt-a[i];
    cnt=max(cnt,a[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4840
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 1; i <= N; i++) {
        cin >> A[i - 1];
        A[i - 1] -= i;
    }
    sort(A.begin(), A.end());
    int b = A[N / 2];
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        sum += abs(A[i] - b);
    }
    cout << sum << endl;
}


Measured memory_bytes: 4028
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String N = scanner.next();
		String[] splitArray = N.split("");
		int sum = 0;

 		for (int i = 0; i < splitArray.length; i++) {
 			//System.out.println(splitArray[i]);
 			sum += Integer.parseInt(splitArray[i]);
 		}
 		//System.out.println(sum);


		if (sum % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main(){

    int n,y;
    cin >> n;
    cin >> y;

    for(int l=0;l<=n;++l){
        for(int m=0;m<=n-l;++m){
            if(y/1000 == l*10 + m*5 + n-l-m){
                cout << l << " " << m << " " << n-l-m;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

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

        string result="";

        for(int a = 0; a < N; a++) {
            result += ST[0].Substring(a,1);
            result += ST[1].Substring(a, 1);
        }

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 11092
# collections.counter 使い方
import collections

n=int(input())
a= list(map(int, input().split()))
c = collections.Counter(a)
d = c.most_common()
ans=0

for i in range(len(d)):
    ans+=(d[i][1]*(d[i][1]-1)//2)


for i in range(n):
    if c[a[i]]>=2:
        print(ans-c[a[i]]+1)
    else:
        print(ans)

Measured memory_bytes: 98636
MOD = 10 ** 9 + 7
n, k = map(int, input().split())

def calc(a):
  smallest = a * (a-1) // 2
  largest = smallest + a * (n-a+1)
  return largest - smallest + 1

ans = 0
for a in range(k, n+2):
  ans += calc(a)
  ans %= MOD
  
print(ans)


Measured memory_bytes: 9060
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
using pii=pair<int,int>;
using vs=vector<string>;
using vpii=vector<pii>;
using si=set<int>;

#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rREP(i,a) for(int i=(a)-1;i>=0;i--)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define out(S) cout<<(S)<<endl;
#define beginend(v) (v).begin(),(v).end()
#define IfOut(condition,text) if(condition){out(text);return 0;}
#define IfOutElse(condition,if_text,else_text) if(condition){out(if_text);return 0;}else{out(else_text);return 0;}
#define mod(s) ((s)%(ll)(1e9+7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a*modpow((ll)b,(ll)(1e9+5))))
#define pb(i) push_back(i)
#define fst first
#define snd second
#define Foreach(item,collection) for(auto item:collection)
#define INF (int)1e10
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}
ll sum(vi v) {ll sum=0;Foreach(i,v){sum+=i;}return sum;}
#define ShowAll(v) Foreach(i,v) out(i);


int x,y;
vs box;
int dx[4]{0,1,0,-1};
int dy[4]{1,0,-1,0};
ll s=0;
void dfs(int px,int py){
    REP(i,4){
        int nx=px+dx[i];
        int ny=py+dy[i];
        if(nx>=0&&nx<x&&ny>=0&&ny<y&&box[ny][nx]=='.'){
            box[ny][nx]='d';
            s++;
            dfs(nx,ny);
        }
    }
    return;
}

int main(){
    vi ans;
    while (cin>>x>>y,(x||y))
    {
        box.resize(y);
        int sx=-1,sy;
        REP(i,y){cin>>box[i];if(sx==-1&&(sx=box[i].find('@'))!=-1){sy=i;}}
        s=1;
        dfs(sx,sy);
        ans.pb(s);
    }
    
    ShowAll(ans);
    return 0;
}

Measured memory_bytes: 3028
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int a, b;
	string s;
	cin >> a >> s >> b;
	if (s == "+")
		cout << a + b << endl;
	else
		cout << a - b << endl;

	return 0;
}

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

//#define int long long
using bll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 50;
constexpr ll V_I_MAX = 1000;

ll N;


void input() {
	scanf("%lld", &N);
	vector<ll> a(N,0);
	rep(i, N) cin>>a[i];
	sort(all(a));
	double ans = a[0];

	repeq(i,N-1){
		ans=(ans+a[i])/2.0;

	}


	printf("%.12f\n", ans);
}

signed main() {
	input();

	return 0;
}


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

using namespace std;
int a,b;
int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);cout.tie(0);
	cin>>a>>b;
	if(2*a>b || b>4*a){
		cout<<"No"<<endl;
	}
	else if(b%2==1){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  typedef complex<int> P;
  vector<P> p(4);
  rep(i, 2) {
    int x, y; cin >> x >> y;
    p[i] = {x, y};
  }
  p[2] = p[1] + (p[1] - p[0]) * P(0, 1);
  p[3] = p[2] + (p[0] - p[1]);
  rep(i, 2) {
    if (i) cout << " ";
    cout << p[2 + i].real() << " " << p[2 + i].imag();
  }
  cout << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define ff first
#define ss second
#define MAXN  1000005
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,d,e,f,z,x,q,w,y,u,vv;
    double v,ans;
    cin>>a>>b>>c>>d>>e>>f;
    ll a1,a2;
    ans=a1=a2=0;
    a2=100*a;
    
    for(ll i=0;i<32;i++){
        for(ll j=0;j<32;j++){
            for(ll k=0;k<3002;k++){
                //i=1;j=0;k=100;
                z=(100*a*i)+(100*b*j);
                x=k*c;
                q=(z/100)*e;
                if(x>q){
                    x=(q/c);
                    x*=c;
                }
                w=q-x;
                y=w/d;
                y*=d;
                u=z+x+y;
                //cout<<z<<" "<<x<<" "<<y<<endl;
                if(z+x<=f&&u>f){
                    vv=f-z-x;
                    y=vv/d;
                    y*=d;
                    u=z+x+y;
                }
                if(u<=f){
                    v=(100*(x+y)*1.0)/(u);
                    //cout<<v<<" "<<u<<" "<<x+y<<endl;
                    if(v-ans>0.0000000000001){
                        //cout<<v<<" "<<ans<<" "<<v-ans<<endl;
                        //cout<<i<<" "<<j<<" "<<k<<endl;
                        ans=v;
                        a1=x+y;
                        a2=u;
                    }
                }
                //else{
                    //break;
                //}
                //return 0;
            }
        }
    }
    //cout<<ans<<endl;
    cout<<a2<<" "<<a1;


    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string s;
int k,last=0;
long long ans;
int cnt1=0,cnt2=0;
char now;
int main(){
	ios::sync_with_stdio(false);
	cin>>s; cin>>k;
	int len=s.length();
	if (s[0]!=s[len-1]) {
		now=s[0]; last=0;
		for (int i=0; i<len; i++) {
			//if (s[i]==now) continue;
			if (s[i]!=now) {
				ans+=(i-last)/2;
				now=s[i];
				last=i;
			}
			else if (i==len-1) {
				ans+=(i-last+1)/2;
			}
		//cout << ans << " "<<i<<endl;
		}
		ans=ans*k;
	}
	else {
		now=s[0];
		for (int i=0; i<len; i++) {
			if (s[i]!=now) break;
			cnt1++;
		}
		for (int i=len-1; i>=0; i--) {
			if (s[i]!=now) break;
			cnt2++;
		}
		if (cnt1+cnt2>=len) {ans=(long long)len*k/2; }
		else {
			now=s[0]; last=0;
			for (int i=0; i<len; i++) {
				//if (s[i]==now) continue;
				if (s[i]!=now) {
					ans+=(i-last)/2;
					now=s[i];
					last=i;
				}
				else if (i==len-1) {
					ans+=(i-last+1)/2;
				}
		//cout << ans << " "<<i<<endl;
			}
			ans=ans*k;
			ans=ans-((k-1)*((cnt1/2)+(cnt2/2)-(cnt1+cnt2)/2));
		}
	}	
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace

#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    	
    ll n;
    cin >> n;
    ll cur = 1;
    ll b = 0;
    FOR(i, n)
    {
        ll x;
        cin >> x;
        if (x != cur) b++;
        else cur++;
    }
    if (b == n) cout << -1 << '\n';
    else cout << b << '\n';
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

const ll MOD = 1e9+7;
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    vector<ll> x(n),y(m);
    for(auto& xin:x) cin >> xin;
    for(auto& yin:y) cin >> yin;
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    ll x_sum = 0,y_sum = 0;
    for(int i = 0; i < n;i++){
        (x_sum += ((i*x[i])%MOD - (n-(i+1))*x[i])%MOD + MOD)%=MOD;
    }
    for(int i = 0; i < m;i++){
        (y_sum += ((i*y[i])%MOD - (m-(i+1))*y[i])%MOD + MOD)%=MOD;
    }
    ll res = x_sum * y_sum;
    res%=MOD;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
#define go {cout<<"Yes"<<endl;return 0;}
#define fin {cout<<"No"<<endl;return 0;}
//template

//main
signed main(){
  int N,A,B,C,D;cin>>N>>A>>B>>C>>D;A--;B--;C--;D--;
  string s;cin>>s;s+="#########";
  if(C<D){
    int now=B;
    int ok=0;
    while(true){
      if(now==D){ok++;break;}
      if(s[now+1]=='.'){now++;continue;}
      if(s[now+2]=='.'){now+=2;continue;}
      break;
    }
    if(ok==0)fin;
    now=A;
    while(true){
      if(now==C){go;}
      if(s[now+1]=='.'){now++;continue;}
      if(s[now+2]=='.'){now+=2;continue;}
      break;
    }
    fin;
    go;
  }
  int su=A;int fu=B;
  int nu=0;
  while(true){
    if(nu)break;
    //cout<<su<<" "<<fu<<endl;
    if(s[su+1]=='.'&&su+1!=fu){su++;continue;}
    if(s[su+2]=='.'){
      if(su+1==fu){
        nu++;
        su+=2;
        continue;
      }
      else if(su+2==fu){

      }
      else{
        su+=2;continue;
      }
    }
    if(s[fu+1]=='.'){fu++;continue;}
    if(s[fu+2]=='.')fu+=2;
    else fin;
  }
  swap(C,D);
  int now=su;
  int ok=0;
  while(true){
    if(now==D){ok++;break;}
    if(s[now+1]=='.'){now++;continue;}
    if(s[now+2]=='.'){now+=2;continue;}
    break;
  }
  if(ok==0)fin;
  now=fu;
  while(true){
    if(now==C){go;break;}
    if(s[now+1]=='.'){now++;continue;}
    if(s[now+2]=='.'){now+=2;continue;}
    break;
  }
  fin;
  go;
}


Measured memory_bytes: 644