akhauriyash/Code-Regression huggingface dataset:
N = int(input())
Fs = []
for _ in range(N):
    Fs.append(list(map(int, input().split())))

Ps = []
for _ in range(N):
    Ps.append(list(map(int, input().split())))


def calc(isOpen):
    global ans
    isAllClose = True
    for i in range(10):
        if isOpen[i]:
            isAllClose = False

    if isAllClose:
        return

    rieki = 0
    for i in range(N):
        count = 0
        for j in range(10):
            if Fs[i][j] and isOpen[j]:
                count += 1

        rieki += Ps[i][count]

    ans = max(ans, rieki)


def search(isOpen):
    if len(isOpen) == 10:
        calc(isOpen)
    else:
        search(isOpen + [True])
        search(isOpen + [False])


ans = -float('inf')
search([])

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

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

  for (ll i = 0; i < N - 1; i++)
  {
    if (A.at(i) == A.at(i + 1))
      FINALANS("NO");
  }
  FINALANS("YES");
}

Measured memory_bytes: 1792
while n=gets
	n=n.to_i
	count=0
	
	a=0
	
	
	if n<0 || n>36
		puts "0"
		next
	elsif n== nil 
		break
	end



	while a < 10
	b=0
		while b < 10
	c=0
			while c < 10
	d=0
				while d < 10
					if a+b+c+d == n
						count += 1
#						puts "#{a} #{b} #{c} #{d} #{count}"
					end
					d+=1
				end
				c+=1
			end
			b+=1
		end
		a+=1
	end
	puts count
end

Measured memory_bytes: 8500
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main() {
    vector<int>a;
    string str;cin>>str;
    int n=str.size();
    for(int i=0;i<n;++i){
        if(str[i]=='1')a.push_back(1);
        if(str[i]=='0')a.push_back(0);
        if(str[i]=='B' && a.size()>0)a.pop_back();
    }
    int n2=a.size();
    for(int i=0;i<n2;++i){
        cout<<a[i];
    }
    cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(a)
#define ub(vec,a) upper_bound(a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    ll X;
    cin>>N>>X;
    ll x[N];
    rep(i,0,N) cin>>x[i];
    ll ans=1e17;
    ll s[N+1];
    s[0]=0;
    rep(i,1,N+1) s[i]=s[i-1]+x[i-1];
    rep(i,1,N+1){
        ll res=X*(N+i);
        res+=5*(s[N]-s[N-i]);
        rep(k,1,N/i){
            res+=(3+2*k)*(s[N-k*i]-s[N-(k+1)*i]);
            if(res>ans){
                res=ans;
                break;
            }
        }
        if(N%i) res+=(N/i*2+3)*s[N%i];
        ans=min(ans,res);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3328
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll cnt(n+1, 0);
    ll rn = 100; 
    for(ll x = 1;x<=rn;++x){
        for(ll y = 1;y<=rn;++y){
            for(ll z = 1;z<=rn;++z){
                ll t = x*x+y*y+z*z+x*y+y*z+z*x;
                if(t<=n){
                    cnt[t]++;
                }
            }
        }
    }
    REP(i,n){
        cout << cnt[i+1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=unsigned long long;


int keta(ll l){
  REP(i,20){
    l/=10;
    if(l==0)return i+1;
  }
  return 20;
}

ll myTen[]={0,1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,
	    10000000000,100000000000,1000000000000,10000000000000,100000000000000,
	    1000000000000000,10000000000000000,100000000000000000,1000000000000000000,
};
int main(){ _;
  ll s;cin>>s;s--;
  ll lo=1,hi=2e17;
  while(lo+1<hi){
    ll mid=(lo+hi)/2;
    ll mid_=mid-1;
    ll midIndex=0;
    int k=keta(mid_);
    midIndex+=8*(mid_/15);
    midIndex+=4*(mid_/5-mid_/15);
    midIndex+=4*(mid_/3-mid_/15);
    ll cnt=0;
    for(int i=1;i<k;i++){
      ll newCnt=(myTen[i+1]-1)-((myTen[i+1]-1)/3+(myTen[i+1]-1)/5-(myTen[i+1]-1)/15)-cnt;
      midIndex+=i*newCnt;
      cnt+=newCnt;
    }
    ll newCnt=mid_-(mid_/3+mid_/5-mid_/15)-cnt;
    midIndex+=k*newCnt;
    if(midIndex>s)hi=mid;
    else lo=mid;
  }
  ll lo_=lo-1;
  ll loIndex=0;
  int k=keta(lo_);
  loIndex+=8*(lo_/15);
  loIndex+=4*(lo_/5-lo_/15);
  loIndex+=4*(lo_/3-lo_/15);
  ll cnt=0;
  for(int i=1;i<k;i++){
    ll newCnt=(myTen[i+1]-1)-((myTen[i+1]-1)/3+(myTen[i+1]-1)/5-(myTen[i+1]-1)/15)-cnt;
    loIndex+=i*newCnt;
    cnt+=newCnt;
  }
  ll newCnt=lo_-(lo_/3+lo_/5-lo_/15)-cnt;
  loIndex+=k*newCnt;

  ll rest=s-loIndex;
  //  cout<<lo<<"+"<<rest<<endl;
  stringstream ss;
  for(;;lo++){
    if(lo%15==0)ss<<"FizzBuzz";
    else if(lo%5==0)ss<<"Buzz";
    else if(lo%3==0)ss<<"Fizz";
    else ss<<lo;
    string result=ss.str();
    if(result.size()>=20+rest){
      REP(i,20)
	cout<<result[i+rest];
      cout<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3220
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

x = ir()
if x == 0:
    print(1)
else:
    print(0)

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

typedef long long int ll;
const int MAX_N = 1002020;
const int mod = 1e9 + 7;

ll modPow(ll x, ll n){
    if(n == 0) return 1;
    ll ret = modPow(x, n/2);
    (ret *= ret) %= mod;
    if(n & 1) (ret *= x) %= mod;
    return ret;
}

ll modInv(ll a){
    return modPow(a, mod - 2);
}

ll modComb(ll n, ll r){
    static ll fact[MAX_N], invfact[MAX_N];
    if(fact[0]==0){
        fact[0] = invfact[0] = 1;
        for(int i = 1; i < MAX_N; i++) {
            fact[i] = fact[i-1] * i % mod;
            invfact[i] = modInv(fact[i]);
        }
    }
    if(r < 0 || n < r) return 0;
    return fact[n] * invfact[r] % mod * invfact[n-r] % mod;
}

int main(){
    ll h, w, a, b;
    scanf("%lld %lld %lld %lld",&h,&w,&a,&b);
    ll ans = 0;
    for(ll i=b;i<w;i++){
        ll x = modComb(i+h-a-1,i) % mod;
        ll y = modComb(w-i-1+a-1, a-1) % mod;
        (ans += (x*y)%mod) %= mod;
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
  string s;
  // a:97, b:98                                                       

  int A[27]={0};
  int x = 0;
  cin >> s;
  //cout << (int)s[0];                                                
  for(int j=0; j<s.length(); j++) {
    int d = (int)s[j];
    A[d%97]++;
    x++;
  }

  int flag = 0;
  for(int i=0; i<x; i++) {
    if(A[i]>1) flag = 1;
  }
  if(flag == 1) cout << "no" << endl;
  else cout << "yes" << endl;
}

Measured memory_bytes: 256
import itertools
N = int(input())
S = []
count = [0, 0, 0, 0, 0]
l = list('MARCH')
for _ in range(N):
    name = input()
    # print('name', name[0])
    if name[0] in list('MARCH'):
        S.append(name)
        count[l.index(name[0])] += 1
# print('S', S)
# print('count', count)

count = list(itertools.filterfalse(lambda x: x == 0, count))
# print('count', count)

ans = 0
for a, b, c in itertools.combinations(count, 3):
    ans += a * b * c
print(ans)


Measured memory_bytes: 9868
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int; 

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n;

vector<string> normal;
void bt(string s) {
  if ((int)s.size() == n) {
    normal.push_back(s);
    return;
  }

  bt(s + "a");
  if (s.size() > 2- 1- 1) {
    bt(s + "b");
  }

  
  if (s.size() > 3-1 - 1) {
    bt(s + "c");
  }

  if (s.size() > 4-1 - 1) {
    bt(s + "d");
  }
  if (s.size() > 5-1 - 1) {
    bt(s + "e");
  }
  if (s.size() > 6-1 - 1) {
    bt(s + "f");
  }
  if (s.size() > 7-1 - 1) {
    bt(s + "g");
  }
  if (s.size() > 8-1 - 1) {
    bt(s + "h");
  }
  if (s.size() > 9-1 - 1) {
    bt(s + "i");
  }
  if (s.size() > 10 -1 - 1) {
    bt(s + "j");
  }
    
}

pair<vector<pair<int, int>>, vector<pair<int, int>>> gen(string& a, string& b) {
  vector<pair<int, int>> eq, neq;
  for (int i = 0; i < (int)a.size(); ++i) {
    for (int j = i + 1; j < (int)b.size(); ++j) {
      if (a[i] == a[j] && b[i] != a[j]) {
        return {{{-1, -1}}, {{-1, -1}}};
      }
      if (a[i] == a[j]) {
        eq.push_back({i, j});
      } else {
        neq.push_back({i, j});
      }
    }
  }
  return {eq, neq};
}

char int_to_char(int i) {
  return (char)(i + 97);
}
int calc(string s) {
  set<int> x;
  for (auto c : s) {
    x.insert(c);
  }
  return (int)x.size();
}

int main() {
  cin >> n;

  vector<string> v = {"a"};
  for (int i = 2; i <= n; ++i) {
    vector<string> nowe;
    for (auto& s : v) {
      int ile = calc(s);

      for (int i = 0; i <= ile; ++i) {
        char c = i + 97;
        s.push_back(c); 
        nowe.push_back(s);
        s.pop_back();
      }
    }
    v = nowe;
  }
  sort(v.begin(), v.end());
  for (auto x : v) {
    cout << x << endl;
  }
}


Measured memory_bytes: 10652
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
using Graph = vector<vector<int>>;
Graph G;

int main() {
    int N; cin >> N;
    G.assign(N, vector(N,0));
    rep(i,N) {
        rep(j, N) {
            cin >> G[i][j];
        }
    }

    ll sum = 0;
    rep(k, N)
        rep(i, N)
            rep(j, N)
                if (G[i][j] > G[i][k] + G[k][j]) {
                    cout << -1 << endl;
                    return 0;
                }
    
    rep(i,N)
        for (int j = i + 1; j < N; j++) {
            bool found = false;
            rep(k, N) {
                if (i == k || j == k) continue;
                if (G[i][j] == G[i][k] + G[k][j]) {
                    found = true;
                    break;
                }
            }
            if (!found) sum += G[i][j];
        }
    cout << sum << endl;
}


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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 200005, M = 1e9 + 7;

int n, K;
int A[N];
int pref[N], suf[N];

int mul(int w, int u) {
    return ((long long)w * u % M + M) % M;
}

void printAll() {
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        ans = mul(ans, A[i]);
    }
    printf("%d\n", ans);
}

int main() {
    
    scanf("%d %d", &n, &K);
    
    for (int i = 1; i <= n; i++) {
        scanf("%d", &A[i]);
    }
    vector<int> pos, neg;
    for (int i = 1; i <= n; i++) {
        if (A[i] >= 0) {
            pos.push_back(A[i]);
        } else {
            neg.push_back(A[i]);
        }
    }
    
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    
    int cnt = 0;
    int ptr = pos.size();
    while (ptr - 1 >= 0 && cnt < K) {
        ptr--;
        cnt++;
    }
    
    int ptr2 = -1;
    if (cnt < K) {
        if ((K - cnt) % 2 == 1) {
            if (K - cnt == (int)neg.size()) {
                printAll();
                return 0;
            }
            if (ptr < pos.size()) {
                ptr++;
                cnt--;
            } else {
                int ans = 1;
                for (int i = 0; i < K; i++) {
                    ans = mul(ans, neg[neg.size() - 1 - i]);
                }
                printf("%d\n", ans);
                return 0;
            }
        }
        while (cnt < K) {
            ptr2++;
            cnt++;
        }
    }
    
    while (ptr2 + 2 < (int)neg.size() && ptr + 1 < (int)pos.size() && (long long)neg[ptr2 + 1] * neg[ptr2 + 2] > (long long)pos[ptr] * pos[ptr + 1]) {
        ptr2 += 2;
        ptr += 2;
    }
    
    int ans = 1;
    for (int i = 0; i <= ptr2; i++) {
        ans = mul(ans, neg[i]);
    }
    for (int i = ptr; i < (int)pos.size(); i++) {
        ans = mul(ans, pos[i]);
    }
    
    printf("%d\n", ans);

    return 0;
}


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

double a, b, h, m;
double pi=3.1415926535;

int main(){
	cin>>a>>b>>h>>m;
	cout<<setprecision(10)<<sqrt(a*a+b*b-2*a*b*cos(2*pi*((60*h+m)/720)-2*pi*(m/60)))<<endl;
}


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

namespace TYC
{
	typedef long long ll;
	const int N = 2e5 + 5;

	int n, L[N];
	struct data { int l, r, v; };
	vector<data> A;

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	inline void ins(const data &p)
	{
		if (A.size() && A.back().v == p.v)
			A.back().r = p.r;
		else
			A.push_back(p);
	}

	inline void add(const data &p)
	{
		if (p.l != p.r)
			ins((data){p.l, p.r - 1, p.v});
		ins((data){p.r, p.r, p.v + 1});
	}

	bool check(const int c)
	{
		A.clear();
		for (int i = 1; i <= n; i++)
			if (L[i] > L[i - 1])
				ins((data){L[i - 1] + 1, L[i], 1});
			else
			{
				while (A.back().l > L[i])
					A.pop_back();
				data p = A.back();
				A.pop_back();
				p.r = min(p.r, L[i]);
				if (p.v == c)
				{
					if (p.l == 1 && p.r == L[i])
						return false;
					data t = A.back();
					A.pop_back();
					add(t);
					ins((data){p.l, p.r, 1});
				}
				else
					add(p);
			}
		return true;
	}

	void work()
	{
		n = read();
		bool flag = true;
		for (int i = 1; i <= n; i++)
			flag &= (L[i] = read()) > L[i - 1];
		if (flag)
			puts("1");
		else
		{
			int l = 2, r = 1e9, mid, ans;
			while (l <= r)
			{
				mid = (l + r) >> 1;
				if (check(mid))
					ans = mid, r = mid - 1;
				else
					l = mid + 1;
			}
			printf("%d\n", ans);
		}
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwert=b; x<qwert; x++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define fst first
#define snd second
using namespace std;
typedef long long ll;
typedef pair<ll,int> O;
const int N=1e5+5;
const ll INF=1e18, MOD=1e9+7LL;
ll dp[2][N];
vector<ll> dist[2];
vector<pair<int,ll> > g[N];
int n, m, st, fn;

void dijkstra(int s, vector<ll>&dist){
	dist.assign(n,INF);dist[s]=0;
	priority_queue<O,vector<O>,greater<O> > pq;
	pq.push({0,s});
	while(!pq.empty()){
		int u=pq.top().snd;
		ll d=pq.top().fst; pq.pop();
		if(dist[u]<d)continue;
		for(auto e : g[u]){
			int v=e.fst;
			if(dist[v]>d+e.snd){
				dist[v]=d+e.snd;
				pq.push({dist[v],v});
			}
		}
	}
}

ll solve(int b, int u){
	ll &r=dp[b][u];
	if(r!=-1)return r;
	if((b==0 && u==fn) || (b==1 && u==st))return r=1;
	r=0;
	for(auto e : g[u]){
		int v=e.fst;
		if(dist[b][u]+e.snd+dist[!b][v]==dist[0][fn])
			r=(r+solve(b,v))%MOD;
	}
	return r;
}
struct Edge { int u, v; ll c; };
ll mod(ll v){return ((v%MOD)+MOD)%MOD;}
int main(){
	memset(dp,-1,sizeof(dp));
	cin >> n >> m >> st >> fn; st--; fn--;
	vector<Edge> edges;
	fore(x,0,m){
		int u, v, c; cin >> u >> v >> c; u--; v--;
		g[u].pb({v,c});g[v].pb({u,c});edges.pb(Edge{u,v,c});
	}
	dijkstra(st,dist[0]);
	dijkstra(fn,dist[1]);

	ll ans = (solve(0,st)*solve(1,fn))%MOD;
	fore(x,0,n)if(dist[0][x]==dist[1][x]){
		ll tmp=(solve(0,x)*solve(1,x))%MOD;
		tmp=(tmp*tmp)%MOD;
		ans = mod(ans-tmp);
	}
	fore(x,0,m){
		ll a1=dist[0][edges[x].u],a2=dist[0][edges[x].v];
		ll b1=dist[1][edges[x].u],b2=dist[1][edges[x].v];
		if(min(a1,a2)*2LL<dist[0][fn] && min(b1,b2)*2LL<dist[0][fn] &&min(b1,b2)+min(a1,a2)+edges[x].c==dist[0][fn]){
			if(min(a1,a2)==a1){
				ll tmp = (solve(0,edges[x].v)*solve(1,edges[x].u))%MOD;
				tmp=(tmp*tmp)%MOD;
				ans = mod(ans - tmp);
			}else{
				ll tmp = (solve(0,edges[x].u)*solve(1,edges[x].v))%MOD;
				tmp=(tmp*tmp)%MOD;
				ans = mod(ans - tmp);
			}
		}
	}
	cout << ans << "\n";	
}

Measured memory_bytes: 27884
import numpy as np

n = int(input())

a = np.zeros(n, dtype = int)

for i in range(n):
    a[i] = int(input())

a = np.sort(a)

sum = 0
for i in range(n):
    if(i == 0):
        flag = 1
    elif(a[i - 1] == a[i]):
        flag += 1
    else:
        if(flag % 2 == 1):
            sum += 1
        else:
            flag = 1

if(flag % 2 == 1):
    sum += 1

print(sum)

Measured memory_bytes: 13912
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		int N=in.nextInt();
		while(N-->0)
		{
			double x1=in.nextDouble(),y1=in.nextDouble();
			double x2=in.nextDouble(),y2=in.nextDouble();
			double x3=in.nextDouble(),y3=in.nextDouble();
			
			double A1=2*(x2-x1);
			double B1=2*(y2-y1);
			double C1=x1*x1-x2*x2+y1*y1-y2*y2;
			double A2=2*(x3-x1);
			double B2=2*(y3-y1);
			double C2=x1*x1-x3*x3+y1*y1-y3*y3;
			
			double x=(B1*C2-B2*C1)/(A1*B2-A2*B1);
			double y=(C1*A2-C2*A1)/(A1*B2-A2*B1);
			double d=Math.sqrt(Math.abs((x-x1)*(x-x1)+(y-y1)*(y-y1)));
			
			System.out.printf("%.3f ",x);
			System.out.printf("%.3f ",y);
			System.out.printf("%.3f\n",d);
			
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

typedef pair<int,int> P;

const int MAX_N=400;

const int di[]={1,0,-1,0};
const int dj[]={0,1,0,-1};

bool color[MAX_N][MAX_N];
int H,W;

char ch[MAX_N+1];

void input(){
    cin>>H>>W;
    for(int i=0;i<H;i++){
        cin>>ch;
        for(int j=0;j<W;j++){
            color[i][j]=(ch[j]=='#');
        }
    }
}

bool isin_(int i, int j){
    return i>=0 && i<H && j>=0 && j<W;
}

bool check_(int i,int j, int d){
    int ni=i+di[d];
    int nj=j+dj[d];
    if(!isin_(ni,nj)) return false;
    if(color[i][j]==color[ni][nj]) return false;
    return true;
}

bool used[MAX_N][MAX_N];

ll solve(){
    ll ans=0;
    ll b=0,w=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(used[i][j]) continue;
            b=0;
            w=0;
            queue<P> que;
            used[i][j]=true;
            que.push(P(i,j));
            while(!que.empty()){
                P p=que.front();
                que.pop();
                int ci=p.first,cj=p.second;
                if(color[ci][cj]) b++;
                else w++;
                for(int d=0;d<4;d++){
                    if(!check_(ci,cj,d)) continue;
                    int ni=ci+di[d],nj=cj+dj[d];
                    if(used[ni][nj]) continue;
                    used[ni][nj]=true;
                    que.push(P(ni,nj));
                }
            }
            ans+=b*w;
        }
    }
    return ans;
}

int main(){
    input();
    ll ans=solve();
    cout<<ans<<endl;
}

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

#define FasterIO  ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0) ;

int main() {
    long long h , n ;
    cin >> h >> n ;
    long long ar[n + 5] ;
    long long sum = 0 ;
    for(int i = 0 ; i < n ; i++) { 
        cin >> ar[i] ;
        sum += ar[i] ;
    }
    if(sum >= h) {
        cout << "Yes\n" ;
    } else {
        cout << "No\n" ;
    }
    return 0 ;
}

Measured memory_bytes: 1024
#include <iostream>
#define MAX 100100
#define WHITE 0
#define BLACK 1

int main() {
  int n;
  std::cin >> n;
  int d[110];
  int color[110];

  int G[110][110];
  for(int i=0; i<n; ++i) {
    for(int j=0; j<n; ++j) G[i][j] = MAX;
  }

  for(int i=0; i<n; ++i) {
    d[i] = MAX;
    color[i] = WHITE;
  }

  for(int i=0; i<n; ++i) {
    int u, k;
    std::cin >> u >> k;
    for(int j=0; j<k; ++j) {
      int to, w;
      std::cin >> to >> w;
      G[u][to] = w;
    }
  }

  d[0] = 0;

  // colorも変更する?

  while(true) {
    int u;
    int minicost = MAX;

    // d[s]が最小になる点を選ぶ
    for(int i=0; i<n; ++i) {
      if(d[i] < minicost && color[i] != BLACK) {
        minicost = d[i];
        u = i;
      }
    }

    if(minicost == MAX) break;
    color[u] = BLACK;

    for(int v=0; v<n; ++v) {
      if(d[u] + G[u][v] < d[v]) {
        d[v] = d[u] + G[u][v];
        //p[u] = u;
      }
    }
  }

  for(int i=0; i<n; ++i) {
    std::cout << i << " " << d[i] << std::endl;
  }
}


Measured memory_bytes: 3120
#include <stdio.h>

int main(void)
{
  int r, g, b;

  char number[10];

  fgets(number, sizeof(number), stdin);
  sscanf(number, "%d %d %d", &r, &g, &b);

  int x;

  x = (g * 10) + b;

  if (x%4 == 0) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }


  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

ll A[200005], B[200005];
ll N, M,ans=0;

bool isOK(int index, int key) {
	if (B[index] >= key)return true;//ここの配列名を適宜変えよう！
	else return false;
}


int binary_search(int key) {

	int left = -1, right = M - 1;//ここの配列名を適宜変えよう！
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key))right = mid;
		else left = mid;
	}
	return right;
}


int main() {


	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	 cin >> N >> M;
	ll K; cin >> K;
	FOR(i, 1, N+1) {
		int a; cin >> a;
		if(i==1)A[i]=a;
		else A[i] = A[i - 1] + a;
	}
	FOR(i, 1, M+1) {
		int b; cin >> b;
		if (i == 1)B[i] = b;
		else B[i] = B[i - 1] + b;
	}
	int bb = M;
	FOR(aa, 0, N+1) {
		while (bb >= 0 && A[aa] + B[bb] > K)bb--;
		if (A[aa] + B[bb] <= K)ans = max(ans, aa + bb);
	}


	

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


Measured memory_bytes: 6748
import numpy as np
# def main():
#     N=input()
#     N=int(N)
#     A=input().split(" ")
#     A=np.array([int(i) for i in A]).astype(np.uint64)
#     # A=np.random.randint(0,100000,200000)
#     l=[]
#     A=np.sort(A)
#     A=np.flip(A).astype(np.uint64)
#     sum=0
#     for i,num in enumerate(A):
#         if i%2==0:
#             l=l+[num]
#             if i!=0:
#                 sum+=min(l[-2],l[0])
#         else:
#             l=[num]+l
#             sum+=min(l[1],l[-1])
#     print(int(sum))

# def main2():
#     N=input()
#     N=int(N)
#     A=input().split(" ")
#     A=np.array([int(i) for i in A]).astype(np.uint64)
#     # A=np.random.randint(0,100000,200000)
#     A=np.sort(A)
#     A=np.flip(A).astype(np.uint64)
#     sum=0
#     for i,num in enumerate(A):
#         if i==0:
#             l=A[0]
#             r=A[0]
#             continue
#         sum+=min(l,r)
#         if l<r:
#             r=num
#         else:
#             l=num
#     print(int(sum))

def main3():
    N=input()
    N=int(N)
    A=input().split(" ")
    A=np.array([int(i) for i in A]).astype(np.uint64)
    l=[]
    A=np.sort(A)
    A=np.flip(A).astype(np.uint64)
    sum=0
    for i,num in enumerate(A):
        if i==0:
            l.append(num)
            continue
        l1=np.array(l,dtype=np.uint64)
        l2=np.roll(l1,1)
        l1=l1.reshape(-1,1)
        l2=l2.reshape(-1,1)
        l1=np.concatenate([l1,l2],1)
        l2=l1.min(1)
        arg=l2.argmax()
        l=l[:arg+1]+[num]+l[arg+1:]
        sum+=l2[arg]

    print(int(sum))


def correct():
    N=input()
    N=int(N)
    A=input().split(" ")
    A=np.array([int(i) for i in A]).astype(np.uint64)
    l=[]
    A=np.sort(A).astype(np.uint64)
    sum=0
    for i in range(N-1):
        sum+=A[N-(i+1)//2-1]
    print(int(sum))

if __name__ == "__main__":
    # main3()
    correct()

Measured memory_bytes: 51408
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

int main()
{
    map<int,int> v;
    int N,M;
    int nn;
    cin >> N >> M;
    int tmp;
    for(int i = 0;i < N;i++)
    {
        cin >> nn;
        for(int j = 0; j< nn;j++)
        {
            cin >> tmp;
            if(v.count(tmp) == 0)
            {
                v.insert(make_pair(tmp,1));
            }
            else
            {
                v[tmp]++;
            }
        }
    }
    int count = 0;
    for(auto i: v)
    {
        if(i.second == N)
            count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
N,X=map(int,input().split())
A=list(map(int,input().split()))
c=0

if A[0]>X:
    c+=A[0]-X
    A[0]=X

for i in range(1,N):
    if A[i-1]+A[i]>X:
        c+=A[i-1]+A[i]-X
        A[i]=X-A[i-1]

print(c)

Measured memory_bytes: 14592
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}

typedef long long int ll;
#define int ll
#define endl '\n'
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll inf = 1e18+123;
const int maxn = 300001;
int t[4*maxn];
 
void update(int id,int l,int r,int pos,int val){
	if(pos>r||pos<l||l>r)return;
	if(l==r&&l==pos){
		t[id]=val;
		return;
	}
	int mid=(l+r)>>1;
	update(id*2,l,mid,pos,val);
	update(id*2+1,mid+1,r,pos,val);
	t[id]=max(t[id*2],t[id*2+1]);
}

int counter(int id,int l,int r,int lq,int rq){
	if(l>r||l>rq||lq>r||lq>rq)return 0;
	if(lq<=l&&r<=rq){
		return t[id];
	}
	int mid=(l+r)>>1;
	return max(counter(id*2,l,mid,lq,rq),counter(id*2+1,mid+1,r,lq,rq));
}
int n;
int a[maxn];
int c = 1;
vector<int> g[maxn];
int answer[maxn];
void dfs(int u, int p){
  int now = counter(1,1,c,a[u],a[u]);
  int ans = counter(1,1,c,1,c);
  int shit  = counter(1,1,c,1,a[u]-1)+1;
  update(1,1,c,a[u],shit);
  ans = max(ans,shit);
  answer[u] = ans;
  for(auto v:g[u]){
    if(v!=p){
      dfs(v,u);
    }
  }
  update(1,1,c,a[u],now);
}
int32_t main()
{

   IOS
  
  cin>>n;
  map<int,int> cmpress;
  for(int i = 1;i<=n;i++)
    cin>>a[i],cmpress[a[i]];

  for(auto &i:cmpress) 
    {
      i.second = c++;
    } 
    c--;
  for(int i = 1;i<=n-1;i++){
    int u,v;
    cin>>u>>v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for(int  i =1;i<=n;i++)
    a[i] = cmpress[a[i]];
  dfs(1,0);

  for(int i = 1;i<=n;i++){
    cout<<answer[i]<<endl;
  }
} 


Measured memory_bytes: 44440
#include <iostream>
#include <iomanip>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i = 0; i < (n); ++i)
#define rng(i,l,r) for(ll i = (l); i < (r); ++i)
#define down(i,r,l) for(ll i = (r); i >= (l); --i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;

#define X first
#define Y second

const int N = 1001;
int board[N][N];
int h, w, a, b;

bool try_place(int nA, int nB) {
    vi row(h, 0);
    for (int i = 0; i < h; i++) {
        row[i] = (i < nA) ? a : (w - a);
    }
    memset(board, 0, sizeof(board));
    for (int j = 0; j < w; j++) {
        int coln = (j < nB) ? b : (h - b);
        // find max row
        int maxh = 0, pos = 0;
        for (int i = 0; i < h; i++) {
            if (row[i] > maxh) {
                maxh = row[i];
                pos = i;
            }
        }
        for (int t = 0; t < coln; t++) {
            if (row[pos] == 0) {
                return false;
            }
            board[pos][j] = 1;
            row[pos]--;
            pos = (pos + 1) % h;
        }
    }
    return true;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> h >> w >> a >> b;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int as = (i * a) + (h - i) * (w - a);
            int bs = (j * b) + (w - j) * (h - b);
            if (as == bs) {
                if (try_place(i, j)) {
                    for (int ii = 0; ii < h; ii++) {
                        for (int j1 = 0; j1 < w; j1++) {
                            cout << board[ii][j1] ;
                        }
                        cout << endl;
                    }
                    return 0;
                }
            }
        }
    }
    cout << -1 << endl;
        return 0;
}





Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
template<class T> inline void read(T &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
template<class T> inline void print(T x){
	if(!x){puts("0");return;}
	if(x<0){putchar('-');x=-x;}
	int a[20],m=0;
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');puts("");
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,m,col[N],a1,a2,a3,isok;
bool vis[N];
vi g[N];
void dfs(int x,int c){
	if(vis[x]){
		if(col[x]!=c) isok=0;
		return;
	}
	vis[x]=1;col[x]=c;
	for(int y:g[x])
		dfs(y,c^1);
}
void add(int x,int y){
	g[x].pb(y);g[y].pb(x);
}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
	srand(time(0));
#endif
	ios::sync_with_stdio(0);
	read(n);read(m);
	for(int i=1;i<=m;i++){
		int x,y;read(x);read(y);
		add(x,y);
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			if(!g[i].size()){a3++;continue;}
			isok=1;dfs(i,0);
			if(isok) a2++; else a1++;
		}
//	debug(a2);
	ans=(ll)a1*(a1+a2)+(ll)a2*(a1+2*a2)+(ll)a3*n*2-(ll)a3*a3;
	print(ans);
#ifdef rqgao2014
	time_tester(1);
#endif
	return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
const static int MAX = 1400;

int H, W;
int buffer[MAX][MAX];
int T[MAX][MAX];

struct Rectangle{
    int height;
    int pos;
};

int getLargestRectangle(int size, int buffer[]){
    std::stack<Rectangle> S;
    int maxv = 0;
    buffer[size] = 0;

    for(int i = 0; i <= size; i++){
        Rectangle rect;
        rect.height = buffer[i];
        rect.pos = i;
        if( S.empty() ){
            S.push(rect);
        }else{
            if(S.top().height < rect.height){
                S.push(rect);
            }else if(S.top().height > rect.height){
                int target = i;
                while(!S.empty() && S.top().height >= rect.height){
                    Rectangle pre = S.top(); S.pop();
                    int area = pre.height * (i - pre.pos);
                    maxv = std::max(maxv, area);
                    target = pre.pos;
                }
                rect.pos = target;
                S.push(rect);
            }
        }
    }
    return maxv;
}


int getLargestRectangle(){
    for(int j = 0; j < W; j++){
        for(int i = 0; i < H; i++){
            if(buffer[i][j]){
                T[i][j] = 0;
            }else{
                T[i][j] = (i > 0) ? T[i-1][j] + 1 : 1;
            }
        }
    }

    int maxv = 0;
    for(int i = 0; i < H; i++){
        maxv = std::max( maxv, getLargestRectangle(W, T[i]) );
    }

    return maxv;
}

int main(void){

    scanf("%d %d", &H, &W);

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            scanf("%d", &buffer[i][j]);
        }
    }
    std::cout << getLargestRectangle() << std::endl;

    return 0;
}


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

int main() {
    int n, m, a[110];

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

    int count = 0;
    float cond = sum / (4 * m);
    for (int i = 0; i < n; i++) {
        if (a[i] >= cond) count++;
    }

    if (count >= m) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3632
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    string s;
    int N;
    cin >> N;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    //vector<int> data(i, 0);
    vector<double> a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    double res = 0;
    res = (a[0]+a[1])/2.0;
    for (int i = 2; i < N; i++) {
        res = (res+a[i])/2.0;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
num_count = {}
for _ in range(N):
    num = int(input())
    if num_count.get(num):
        num_count[num] += 1
    else:
        num_count[num] = 1
        
left_num = 0
for value in num_count.values():
    left_num += value%2
    
print(left_num)

Measured memory_bytes: 15072
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll ans=0;
	ll a[n];
	rep(i,0,n){
		cin >> a[i];
		ans+=(a[i]-1);
	}
	cout << ans;
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

int main(){
	ll A, B;
	cin >> A >> B;

	ll g = gcd(A, B);
	cout << A * B / g << endl;

	return 0;
}


Measured memory_bytes: 256
from math import floor
a,b,n = map(int,input().strip().split())
ans = floor((a*n)/b)-a*floor(n/b)
if n>b:
    ans = floor((a*(b-1))/b) - a*floor((b-1)/b)
elif n==b:
    ans = floor((a*(b-1))/b) - a*floor((b-1)/b)
print(ans)


Measured memory_bytes: 9128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

const int SIZE = 1000000 + 10;
//const int SIZE = 100 + 10;

ll f(ll n) {
  ll ans = 0;
  ll cnt = 0;
  for(ll i = 1; ; i++) {
    cnt += i;
    ans++;
    if(cnt > n) {
      ans--;
      break;
    }
  }
  return ans;
}

int main() {
  ll N; cin>>N;
  vector<ll> primes;
  vector<bool> prime(SIZE, true);
  prime[0] = prime[1] = false;
  for(int i = 2; i < SIZE; i++) {
    if(prime[i]) {
      primes.push_back(i);
      for(int j = i+i; j < SIZE; j+=i) {
	prime[j] = false;
      }
    }
  }
  //pp(primes, primes.size());
  ll n = N;
  map<ll, int> cnt;
  REP(i, primes.size()) {
    while(n % primes[i] == 0) {
      cnt[primes[i]]++;
      n /= primes[i];
    }
  }
  cnt[n]++;
  ll ans = 0;
  for(auto p: cnt) {
    //    cout << p.first << " " << p.second << endl;
    if(p.first > 1) {
      ll tmp = f(p.second);
      ans += tmp;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
char ch[1111];
char ch2[1111];

int main()
{

    int n,m,a,b,i,j,x,y,sum;


    while(scanf("%s",&ch)==1)
    {
        scanf("%s",&ch2);

       n = strlen(ch);
       m = strlen(ch2);
       x = 1e9;
       for(i=0;i<=n-m;i++)
       {
           sum = 0;
            for(j=0;j<m;j++)
            {
                if(ch[i+j]!=ch2[j])
                {
                    sum++;
                }
            }

            x = min(x,sum);
       }

       printf("%d\n",x);
    }










return 0;
}


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

	ll w,h,x,y;
	cin >> w>>h>>x>>y;


	int flag = 0;
	if (w%2==0 && h%2 == 0 && x == w/2 && y == h/2) {
		flag = 1;
	}

	cout << w*h/2.0 << " " << flag << endl;
}




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

typedef long long ll;

int main() {
    string s; cin >> s;
    stack<int> st;
    for (char c : s) {
        if (c=='T') {
            if (!st.empty()&&st.top()=='S') {
                st.pop();
            } else {
                st.push(c);
            }
        } else {
            st.push(c);
        }
    }
    cout << st.size();
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  bool ans = false;
  for(int i = 0; i <= 100; i++){
    for(int j = 0; j + i <= 100; j++){
      if(i * 4 + 7 * j == n){
        ans = true;
      }
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

// 階乗、階乗逆元テーブル
int fact[1100000], fact_inv[1100000], inv[1100000];

int mod_fact(int n, int m) {
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= n; i++) {
        fact[i] = fact[i - 1] * i % m;
        inv[i] = m - inv[m % i] * (m / i) % m;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % m;
    }
}

int N;
string S;
int mod = 998244353;

signed main() {
    cin >> N >> S;
    int ans = 1;
    int r = 0, g = 0, b = 0;
    for (int i = 0; i < 3 * N; i++) {
        int cur;
        int top = max({r, g, b}), bottom = min({r, g, b});
        int mid = r + g + b - top - bottom;
        if (S[i] == 'R')cur = r, r++;
        else if (S[i] == 'G')cur = g, g++;
        else if (S[i] == 'B')cur = b, b++;
        if (cur == top);
        else if (cur == mid)(ans *= top - mid) %= mod;
        else if (cur == bottom)(ans *= mid - bottom) %= mod;
    }
    mod_fact(N, mod);
    cout << ans * fact[N] % mod << endl;

}


Measured memory_bytes: 5508