akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int b = a + n - 1;
    int ans = a * n + n * (n - 1) / 2;
    if(b < 0)
        ans -= b;
    else if(a > 0)
        ans -= a;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;

// std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));

std::vector<std::vector<long>> v(2019,std::vector<long>(2019, 0));

long mod = 1000000007;

long nCr(long n, long r) {
  if (v[n][r] != 0 ){
    return v[n][r];
  }

  return v[n][r] = (nCr(n-1,r-1) + nCr(n-1,r)) % mod;
}



int main(int argc, const char * argv[]) {

    int n, k;
    cin >> n >> k;

    for (int i = 0; i <= n; i++) {
      v[i][0] = 1;
      v[i][i] = 1;
    }

    repd(i,1,k+1){
      
      if ( (n-k+1) < i ){
        cout << 0 << endl;
        continue;
      }
      ll ans = nCr(n-k+1, i) * nCr(k-1, i-1);
      cout << ans % mod << endl;
    }

    return 0;
}


Measured memory_bytes: 32256
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc=new Scanner(System.in);
       while(true){
           String x=sc.next();
           if(x.equals("0"))break;
           String[] X = x.split("", 0);
           int sum=0;
           for(int i=0;i<X.length;i++){
                int num = Integer.parseInt(X[i]);
                sum+=num;
           }
           System.out.println(sum);
       }
    }
}



Measured memory_bytes: 27288
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;
int main()
{
    ll n,k,i,cnt=0;
    string t;
    cin>>n>>t;
    for(i=0;i<n-2;i++)
    {
        if(t[i]=='A'&&t[i+1]=='B'&&t[i+2]=='C') cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}





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

int main() {
	int k;
	int a;
	int b;

	cin >> k;
	cin >> a >> b;


	if ( a + k <= b) {
		cout << "OK" << endl;
	} else if( a % k == 0) {
		cout << "OK" << endl;
	} else if( a % k > b % k) {
		cout << "OK" << endl;
	} else {
		cout << "NG" << endl;
	}
	return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = n - 1; i>= 0; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;


const double pi = 3.14159265359;
const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	for(int i = 0; i < s.size(); i++){
		if(s[i]=='?')s[i] = 'D';
	}
	cout<<s;
	return 0;
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

template<class Type>
int digit(Type x){return (x==0)?1:floor(log10(x))+1;}//自然数の桁数を求める.

int main(){
	int n;
	int m;
	cin>>n>>m;
	
	vi s(m);
	vi c(m);
	REP(i,m) cin>>s[i]>>c[i];
	
	REP(i,1000){
		if(digit(i)!=n) continue;
		
		string num=to_string(i);
		bool jud=true;
		REP(j,m){
			if(num[s[j]-1]-'0'!=c[j]) jud=false;
		}
		if(jud){
			cout<<num<<endl;
			return 0;
		}
	}
	
	cout<<-1<<endl;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int cnt = 0;
  int sw = 0;
  while (sw == 0) {
    // 
    if (cnt % 2 > 0) {
      A = A - D;
    	if (A <=0) {
    	  sw = 1;
    	}
    } else {
      C = C - B;
    	if (C <=0) {
    	  sw = 1;
    	}
    }
    cnt++;
  }
  if (A > C) {
    // 
    cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    string s; cin >> s;
    int K; cin >> K;
    set<string> sub;

    for (int i = 0; i < s.size(); ++i) {
        for (int j = 1; j <= K && j + i <= s.size(); ++j) sub.insert(s.substr(i, j));
    }

    vector<string> sub_l(sub.begin(), sub.end());
    sort(sub_l.begin(), sub_l.end());
    cout << sub_l[K-1] << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    char c[2][3];
    for(int i=0;i<2;i++)for(int j=0;j<3;j++)cin >> c[i][j];
    if(c[0][2]==c[1][0] && c[1][2]==c[0][0] && c[1][1]==c[0][1])cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 3564
import sys
import numpy as np
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N = ii()
F = [[0] * 10 for _ in range(N)]
for i in range(N):
    F[i] = lmi()


P = [[-10**9 for _ in range(10)] for _ in range(N)]
for i in range(N):
    P[i] = lmi()

# print(F)
rieki = -10**18
for i in range(1, 2 ** 10):  # bit全探索
    tmprieki = 0
    for num in range(N):
        cnt = 0
        for j in range(10):
            if ((i >> j) & 1) and F[num][j] == 1:
                cnt += 1
        tmprieki += P[num][cnt]
    rieki = max(rieki, tmprieki)

print(rieki)


Measured memory_bytes: 20708
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n string
	fmt.Scan(&n)

	s := strings.Split(n, "")
	
	if (s[0] == s[1] && s[0] == s[2]) || (s[1] == s[2] && s[1] == s[3]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int N;
    cin >> N;
    vector<bool> written(1000000001, false);
    REP (i, N) {
        int a;
        cin >> a;
        written[a] = !written[a];
    }
    
    int ans = count(written.begin() + 1, written.end(), true);
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int w, a, b;
  cin >> w >> a >> b;

  if(a + w >= b && a + w <= b + w || a >= b && a <= b + w) {
    cout << 0 << endl;
    return 0;
  }

  cout << min(abs(a - (b + w)), abs((a + w) - b)) << endl;
}


Measured memory_bytes: 256
import sys
A,B,C,K=map(int,input().split())
rest = K
cnt = 0
if rest > A:
  cnt += A
  rest -= A
else:
  cnt += rest
  print(cnt)
  sys.exit()
if rest > B:
  rest -= B
else:
  print(cnt)
  sys.exit()
print(cnt-rest)

Measured memory_bytes: 9192
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        System.out.println(in.nextInt() < 1200 ? "ABC" : "ARC");
    }
}

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

int main() {
  int x,y;
  cin >> x >> y;
        if (y%2 == 0 && 2*x <= y && y <= 4*x){
      	 cout << "Yes" << endl;
        }
    	else {
   		 cout <<"No" << endl;
}

}


Measured memory_bytes: 3640
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0
for i in range(N):
    A = list(map(int, input().split()))
    sum = C
    for a, b in zip(A, B):
        sum += a * b
    if sum > 0:
        cnt += 1
print(cnt)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n)cin >> a[i];
  sort(ALL(a));
  cout << a[n-1]-a[0] << endl;


  return 0;
}


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

#define ll long long
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
// const int N = 1e5+9;


signed main() {  

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    vector<int> b(n+1);
    for(int i = 1; i < n; i++) {
        cin >> b[i];
    }
    ll ans = b[1];
    for(int i = 2; i < n; i++) {
        ans += min(b[i], b[i-1]);
    }
    ans += b[n-1];
    cout << ans << endl;
    

    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

vvi g;
vi d;
//vector<array<int, 3>> q;
int TIME = 0;
vi in, out, maxpath, add, ans, ret;
const int B = 18;
const int N = 200005;
int lc[N][B];
int maxlc[N][B];

int dfs0(int v, int pr, int ma) {
  lc[v][0] = pr;
  maxlc[v][0] = v;
  for (int i = 1; i < B; ++i) {
    lc[v][i] = lc[lc[v][i-1]][i-1];
    maxlc[v][i] = max(maxlc[v][i-1], maxlc[lc[v][i-1]][i-1]);
  }
  maxpath[v] = ma;
  int res = v, curma = 0;
  for (int i = B-1; i >= 0; --i) {
    int nxres = lc[res][i];
    int nxma = max(curma, maxlc[res][i]);
    if (nxma < maxpath[nxres]) {
      res = nxres;
      curma = nxma;
    }
  }
  add[v]++;
  add[lc[res][0]]--;
  in[v] = TIME++;
  int prevval = add[v];
  for (int nv : g[v]) if (nv != pr) {
    add[v] += dfs0(nv, v, max(ma, v));
    ret[nv] = add[v] - prevval;
    prevval = add[v];
  }
//  cerr << v << ' ' << res << ' ' << add[v] << endl;
  out[v] = TIME++;
  return add[v];
}

void dfs1(int v, int pr) {
  ans[v] = add[v] + ans[pr] - ret[v];
  for (int nv : g[v]) if (nv != pr) {
    dfs1(nv, v);
  }
}

/*
void dfs1(int v, int pr, int ma) {
  q.push_back({ma, in[v], out[v]});
  for (int nv : g[v]) if (nv != pr) {
    q.push_back({ma, in[nv], out[nv]});
    dfs1(nv, v, max(ma, v));
  }
}

vi fen;

void add(int i, int val) {
  for (; i < fen.size(); i |= i + 1)
    fen[i] += val;
}

int getsum(int i) {
  int s = 0;
  for (; i >= 0; i = (i & (i + 1)) - 1)
    s += fen[i];
  return s;
}
*/
int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  g.resize(n);
  d.assign(n, 0);
  in.assign(n, 0);
  out.assign(n, 0);
  add.assign(n, 0);
  ans.assign(n, 0);
  ret.assign(n, 0);
  maxpath.assign(n, 0);
  for (int i = 0; i < n-1; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs0(0, 0, 0);
  dfs1(0, 0);
  for (int i = 1; i < n; ++i) {
    cout << ans[i] << ' ';
  }
  cout << endl;
/*  dfs(0, -1, 0);
  sort(q.begin(), q.end());
  fen.assign(TIME + 1, 0);
  int it = 0;
  for (const auto& v : q) {
    while (it < v[0]) {
      add(in[it], 1);
      ++it;
    }
    ans.push_back(getsum(v[2]) - getsum(v[1] - 1));
  }*/
  return 0;
}

Measured memory_bytes: 61824
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	int room[4][3][10];
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				room[i][j][k] = 0;
			}
		}
	}
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		room[b-1][f-1][r-1] += v;
	}
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				cout << " " << room[i][j][k];
			}
			cout << "\n";
		}
		if(i < 3){
			cout << "####################" << "\n";
		}
	}
}


Measured memory_bytes: 3112
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = []
y = []
c = []
for i in range(M):
    p,q,r = map(int, input().split())
    x.append(p)
    y.append(q)
    c.append(r)

ans = min(a) + min(b)

for i in range(M):
    ans = min(a[x[i]-1] + b[y[i]-1] - c[i], ans)

print(ans)

Measured memory_bytes: 85484
input = gets.chomp.split("")
ans = ""

[0, 1].repeated_permutation(3) do |bits|
    # 0 -> +, 1 -> -
    formula = []
    bits.each_with_index do |bit, idx|
        if bit == 0 then
            formula << input[idx] + "+"
        else
            formula << input[idx] + "-"
        end
    end
    formula << input[3]
    ans = formula.join("")
    break if eval(ans) == 7
end

puts ans + "=7"

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;string S,T;bool f(char a,char b,int c,int d){int l=1,g=d;int N=S.size();for(int i=N-1;i>=0;--i){if(T[i]==a)g=min(d,g+1);else if(T[i]==b)l=max(1,l-1);if(S[i] == a)++l;else if(S[i]==b)--g;if(l>g)return false;}if(c<l||c>g)return false;else return true;}int main(){int H,W,N;cin>>H>>W>>N;int a,b;cin>>a>>b;cin>>S>>T;bool r=f('L','R',b,W)&&f('U','D',a,H);cout<<(r?"YES":"NO")<<endl;}


Measured memory_bytes: 776
#include <stdio.h>
#include <stdlib.h>
#include<string.h>

int main()
{
    int a,b,d,n,m,i,j,l;
    char s[100][1000],c[100][1000];
    scanf("%d",&n);
    getchar();
    for(i=0;i<n;i++)
        //gets(s[i]);
        scanf("%s",s[i]);
    scanf("%d",&m);
    getchar();
    for(i=0;i<m;i++)
        //gets(c[i]);
        scanf("%s",c[i]);
    for(i=0,d=0;i<n;i++)
    {
        for(j=0,b=1;j<n;j++)
        {
            if(j==i)
                continue;
            else
            {
                a=strcmp(s[i],s[j]);
                if(a==0)
                    b++;
            }
        }
        for(l=0;l<m;l++)
        {
            a=strcmp(s[i],c[l]);
            if(a==0)
                b--;
        }
        if(b>d)
            d=b;
    }
    printf("%d\n",d);
    return 0;
}


Measured memory_bytes: 256
import queue
n = int(input())
q = queue.Queue()
for i in range(9):
    q.put(i+1)
for i in range(n):
  x = q.get()
  mod_x, mul_x = x%10, 10*x
  if mod_x != 0: q.put(mul_x+mod_x-1)
  q.put(mul_x+mod_x)
  if mod_x != 9: q.put(mul_x+mod_x+1)
print(x)


Measured memory_bytes: 12512
my%h;
$_={
	%h{$^a~$^b}//=$^a*$^b>0??$_($^a div 10,$^b)+$^a%10*$_($^a div 10,$^b-1)+ +^$^a%10*$_($^a div 10-1,$^b-1)!!$^a>=$^b
}
say $_(+get,+get)

Measured memory_bytes: 66428
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef pair<int,int> P;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

struct edg{
	int from, to, d;
};

int n, m, c, s, g;
vector<edg> ed[20];
int dist[100][100];
int di[100][100];
int p[20];
int q[20][50];
int r[20][50];
int cost[20][100000];

void solve(){
	s--; g--;
	rep(i,100) rep(j,100) dist[i][j] = INF;
	rep(i,100) dist[i][i] = 0;
	rep(i,20) rep(j,100000) cost[i][j] = 0;
	rep(i,20) ed[i].clear();
	rep(i,m){
		int x, y, d, cc;
		cin >> x >> y >> d >> cc;
		x--; y--; cc--;
		ed[cc].push_back((edg){x,y,d});
	}
	rep(i,c) cin >> p[i];
	rep(i,c){
		rep(j,p[i]-1) cin >> q[i][j];
		q[i][p[i]-1] = INF;
		rep(j,p[i]) cin >> r[i][j];
		int x = 0;
		for(int j = 1; j < 100000; j++){
			cost[i][j] = cost[i][j-1]+r[i][x];
			if(q[i][x] == j) x++;
		}
	}
	rep(i,c){
		rep(j,100) rep(k,100) di[j][k] = INF;
		rep(j,100) di[j][j] = 0;
		rep(j,ed[i].size()){
			edg e = ed[i][j];
			di[e.from][e.to] = min(di[e.from][e.to],e.d);
			di[e.to][e.from] = min(di[e.from][e.to],e.d);
		}
		rep(j,n) rep(k,n) rep(l,n) di[k][l] = min(di[k][l],di[k][j]+di[j][l]);
		rep(j,n) rep(k,n){
			if(di[j][k] == INF) continue;
			dist[j][k] = min(dist[j][k],cost[i][di[j][k]]);
		}
	}
	rep(i,n) rep(j,n) rep(k,n) dist[j][k] = min(dist[j][k],dist[j][i]+dist[i][k]);
	if(dist[s][g] == INF) dist[s][g] = -1;
	cout << dist[s][g] << endl;
}

int main(){
	while(cin >> n >> m >> c >> s >> g){
		if(n == 0 && m == 0 && c == 0 && s == 0 && g == 0) break;
		solve();
	}
}

Measured memory_bytes: 9416
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<string> A(2*N);
	for(int i = 0; i < 2*N; i++) cin >> A[i];
	cat dp_subt[40][40][40];
	memset(dp_subt, 0, 40*40*40*sizeof(cat));
	for(int i = 0; i < 2*N; i++) dp_subt[i][i][i] = 1;
	for(int d = 3; d <= 2*N; d += 2) for(int l = 0; l <= 2*N-d; l++) {
		int r = l+d-1;
		for(int c = l+1; c < r; c++)
			for(int a = l; a < c; a++) for(int b = c+1; b <= r; b++) if(A[a][b] == '1')
				for(int i = a; i < c; i++) for(int j = c+1; j <= b; j++)
					// l..i (a), j..r (b), i+1..j-1 (c)
					dp_subt[l][r][c] += dp_subt[l][i][a] * dp_subt[j][r][b] * dp_subt[i+1][j-1][c];
	}
	cat ans = 0;
	for(int c = 1; c < 2*N; c++) if(A[0][c] == '1')
		ans += dp_subt[1][2*N-1][c];
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 768
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

int main(){
	double x=0, y=0, r=90;//初期設定
	double d, rd;//入力値　更新部分
	char c;//ごみ
	
	while(cin>> d >> c >> rd){
		if(d==0 && rd==0) break;

		x+=d*cos(r/180*M_PI);
		y+=d*sin(r/180*M_PI);
		r-=rd;
	}

	cout<< (int)x <<endl;
	cout<< (int)y <<endl;
    
	return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAX_N = 1 << 18;
typedef pair<int,int> P;
int n;
P dat[2*MAX_N-1];
void init(int n_){
  n=1;
  while(n<n_) n*=2;
  for(int i=0;i<2*n-1;i++) dat[i].first=0,dat[i].second=0;
}
int query(int k){
  k+=n-1;
  P p=dat[k];
  while(k>0){
    k=(k-1)/2;
    p=max(p,dat[k]);
  }
  return p.second;
}

void update(int a,int b,P p,int k=0,int l=0,int r=n){
  if(r<=a||b<=l) return;
  if(a<=l&&r<=b) {
    dat[k]=max(dat[k],p);
  }else{
    update(a,b,p,k*2+1,l,(l+r)/2);
    update(a,b,p,k*2+2,(l+r)/2,r);
  }
}

vector<int> G[MAX_N];
int st[MAX_N],en[MAX_N],de[MAX_N],po[MAX_N];
int pos;
void dfs(int v,int p=-1,int d=0){
  de[v]=d;
  po[v]=pos;
  st[v]=pos++;
  for(auto i:G[v]) if(i!=p) dfs(i,v,d+1);
  en[v]=pos;
}

void update(int k,P p){
  update(st[k],en[k],p);
}

signed main(){
  int _n,q;
  while(cin>>_n>>q,_n||q){
    for(int i=0;i<MAX_N;i++) G[i].clear();
    init(_n+1);
    for(int i=1;i<_n;i++) {
      int p;
      cin>>p;
      p--;
      G[p].push_back(i);
      G[i].push_back(p);
    }
    pos=0;dfs(0);
    int ans=0;
    for(int i=0;i<q;i++){
      char c;
      int u;
      cin>>c>>u;
      u--;
      if(c=='M') update(u,P(de[u],u));
      else ans+=query(po[u])+1;
      //for(int j=0;j<_n;j++) cout<<query(po[j])<<" \n"[j==_n-1];
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    int n;cin >> n;
    vl a(n),dp(n,INF),ans(n);
    vvl g(n);
    rep(i,n)cin>>a[i];

    rep(i,n-1){
        int u,v; cin >> u >> v;
        u--;v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    function<void(int,int)> dfs = [&](int node, int pre_node){
        ans[node] = lower_bound(all(dp), INF) - dp.begin();
        for(int nv:g[node]){
            if(nv == pre_node)continue;
            //LIS
            auto itr = lower_bound(all(dp), a[nv]);
            int pre_num = *itr;
            *itr = a[nv];
            dfs(nv, node);
            *itr = pre_num;
        }
    };
    dp[0] = a[0];
    dfs(0, -1);
    
    rep(i,n)out(ans[i]);

    return 0;
}

Measured memory_bytes: 35924
#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)

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

bool solve(int N) {
  int cnt[10] = {};
  bool same[10] = {};
  bool diff[10] = {};
  set<int> st;
  rep(i, N) {
    int x; cin >> x;
    cnt[x/10]++, cnt[x%10]++;
    st.insert(x/10), st.insert(x%10);
    if(x/10==x%10)same[x/10]=1;else diff[x/10]=diff[x%10]=1;
  }
  if(st.size() == 1) return true;
  int oddcnt = 0;
  rep(i, 10) oddcnt += cnt[i] % 2;
  if(oddcnt != 0 && oddcnt != 2) return false;
  rep(i, 10) if(same[i]&&!diff[i]) return false;
  return true;}int main() {for(int N; cin >> N && N;) cout << (solve(N) ? "Yes" : "No") << endl;return 0;}

Measured memory_bytes: 3068
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt64()
	a := nextInt64()
	b := nextInt64()

	if (b-a-1)%2 == 1 {
		fmt.Println((b - a + 1) / 2)
		return
	}
	fmt.Println(min(a-1, n-b) + 1 + (b-a-1)/2)

}
func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def f(A, M, V, P, m):
    N = len(A)
    a = A[m]
    i = bisect.bisect_right(A, a + M)
    C = N - i

    if C >= P:
        return False

    C = P - 1
    i = N - C

    U = 0
    for j in range(i):
        if j == m:
            continue
        U += min(a + M - A[j], M)

    return U >= (V - 1 - C) * M


def main():
    N, M, V, P = read_values()
    A = read_list()
    A.sort()
    
    l = 0
    r = N
    while l < r:
        m = (r + l) // 2
        if f(A, M, V, P, m):
            r = m
        else:
            l = m + 1

    print(N - r)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16168
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d[50];
  d[0]=d[1]=1;
  for(int i=0;i<43;i++)d[i+2]=d[i]+d[i+1];
  cin>>n;
  cout<<d[n]<<endl;
  return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int dp[1010101][10][2];

int main(){
    fastcin();
    string s;
    cin >> s;
    reverse(all(s));
    rep(i, 1010101)rep(j,10)rep(k, 2) dp[i][j][k] = INF;
    s.push_back('0');

    int n = s.size();
    s.push_back('0');

    dp[0][s[0]-'0'][0] = 0;
    rep(i, n){
        rep(j, 10){
            rep(fl, 2){
                // if(dp[i][j][fl] != INF) cout << i << " " << j << " " << fl  << " "<< dp[i][j][fl] << endl;
                if(fl == 0){
                    if(dp[i][j][fl] != INF){
                        // int now = s[i]-'0';
                        int nxt = s[i+1]-'0';
                        chmin(dp[i+1][nxt][fl], dp[i][j][fl]+j);
                        if(nxt < 9) chmin(dp[i+1][nxt+1][fl], dp[i][j][fl]+(10-j));
                        else chmin(dp[i+1][0][1], dp[i][j][fl]+(10-j));
                    }
                }else{
                    if(dp[i][j][fl] != INF){
                        int nxt = s[i+1]-'0';
                        if(nxt < 9) chmin(dp[i+1][nxt+1][0], dp[i][j][fl]);
                        else chmin(dp[i+1][0][1], dp[i][j][fl]);
                    }
                }
            }
        }
    }
    int ans = INF;
    rep(i, 10) chmin(ans, dp[n][i][0]);
    cout << ans << endl;
}

Measured memory_bytes: 80284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll PAT = (80 + 80) * 80;
    ll h, w;
    cin >> h >> w;
    vector<vector<ll>> a(h, vector<ll>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    vector<vector<ll>> b(h, vector<ll>(w));
    rep(i, h) rep(j, w) cin >> b[i][j];
    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(PAT + 1, false)));
    dp[0][0][abs(a[0][0] - b[0][0])] = true;
    rep(y, h) {
        rep(x, w) {
            ll d = abs(a[y][x] - b[y][x]);
            rep(k, PAT + 1) {
                if (y > 0) {
                    if (((k + d) <= PAT) && (dp[y - 1][x][k + d])) {
                        dp[y][x][k] = true;
                    }
                    if (dp[y - 1][x][abs(k - d)]) {
                        dp[y][x][k] = true;
                    }
                }
                if (x > 0) {
                    if (((k + d) <= PAT) && (dp[y][x - 1][k + d])) {
                        dp[y][x][k] = true;
                    }
                    if (dp[y][x - 1][abs(k - d)]) {
                        dp[y][x][k] = true;
                    }
                }
            }
        }
    }
    ll ans = LONG_LONG_MAX;
    rep(i, PAT + 1) {
        if (dp[h - 1][w - 1][i]) {
            chmin(ans, i);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14036
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;

string s,t;
int dp[3100][3100]={0};

int main() {
    cin>>s>>t;
    rep(i,s.size()){
        rep(j,t.size()){
            if(s[i]==t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i][j+1]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
        }
    }
    
    string res = "";
    int i=(int)s.size();
    int j=(int)t.size();
    while(i>0&&j>0){
        if(dp[i][j] == dp[i-1][j]){
            i--;
        }
        else if(dp[i][j] == dp[i][j-1]){
            j--;
        }else{
            res = s[i-1]+res;
            i--;
            j--;
        }
    }
    
    cout<< res<< endl;
    
    return 0;
}


Measured memory_bytes: 37120
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    vector<int> Ds(N); for (auto &Di : Ds) cin >> Di;
    sort(Ds.begin(), Ds.end());
    bool sign = true;
    vector<int> hours(N);
    for (int i = 0; i < N; ++i)
    {
        if (Ds[i] == 0)
        {
            hours[i] = 0;
        }
        else
        {
            hours[i] = sign ? Ds[i] : 24 - Ds[i];
        }
        sign = sign ? false : true;
    }
    hours.push_back(0);
    sort(hours.begin(), hours.end());
    int ans = 24;
    for (int i = 0; i < N + 1; ++i)
    {
        int diff = hours[(i + 1) % (N + 1)] - hours[i];
        if (diff < 0) diff = 24 + diff;
        ans = min(ans, diff);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# 2019-11-24 20:59:47(JST)
import sys
from string import ascii_uppercase as alphabet

alpha_num = dict((alpha, num) for num, alpha in enumerate(alphabet, 0))

def main():
    n, s = sys.stdin.read().split()
    n = int(n)

    t = ''
    for char in s:
        t += alphabet[(alpha_num[char] + n) % 26]
    
    print(t)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: usize = sc.read();
    let b: usize = sc.read();
    println!(
        "{}",
        if a >= 13 {
            b
        } else if a >= 6 {
            b / 2
        } else {
            0
        }
    );
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P complex<double>
#define Y real()
#define X imag()
const double INF = (1 << 16);
const int N = 1010;

class C{
  public:
    double dis;
    int now;
    vector<int> visited;
    C(double _d, int _n, vector<int> _v){
      dis = _d;
      now = _n;
      visited = _v;
    }
    bool operator>(const C &c) const { return dis > c.dis; }
};

int main() {
  int n;
  while(cin >>n && n){
    vector< pair<int, P> > building(n);
    REP(i, n){
      int a, b;
      cin >>building[i].first >>a >>b;
      building[i].second = P(a, b);
    }
    vector< vector<double> > v(N, vector<double>(N, INF));
    REP(i, n){
      REP(j, n){
        double d = abs(building[i].second - building[j].second);
        if(d <= 50.0) v[building[i].first][building[j].first] = d;
      }
    }

    int m; cin >>m;
    REP(z, m){
      int s, g; cin >>s >>g;
      priority_queue<C, vector<C>, greater<C> > open;
      vector<int> tmp(N, INF);
      tmp[s] = 0;
      open.push( C(0.0, s, tmp) );
      vector<double> closed(N, INF);
      C ans = C(0.0, -1, vector<int>());

      while(!open.empty()){
        C now = open.top();
        open.pop();

        //debug
        //cout <<now.dis <<", " <<now.now <<", ";
        //REP(i, N) REP(j, N) if(now.visited[j] == i) cout <<j <<" ";
        //cout <<endl <<"---------" <<endl;

        if(now.now == g){
          ans = now;
          break;
        }
        if(closed[now.now] <= now.dis) continue;
        closed[now.now] = now.dis;

        REP(i, N){
          if(now.visited[i] != INF || v[now.now][i] == INF) continue;
          now.visited[i] = now.dis + v[now.now][i];
          open.push( C(now.dis + v[now.now][i], i, now.visited) );
          now.visited[i] = INF;
        }
      }

      if(ans.now == -1) cout <<"NA" <<endl;
      else{
        vector<int> ans_v;
        REP(i, N) REP(j, N) if(ans.visited[j] == i) ans_v.push_back(j);
        cout <<ans_v[0];
        FOR(i, 1, ans_v.size()) cout <<" " <<ans_v[i];
        cout <<endl;
      }

    }
  }
  return 0;
}

Measured memory_bytes: 9384
/*
    なんか変な勘違いをしていた
 */

#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

#define INF 0x7fffffffffffffff

typedef pair<long long int, int> Data;
typedef pair<Data, long long int> Pair;
typedef pair<long long int, long long int> Dist;

struct Edge {
    int to;
    long long int len;
};

int n;
int m;
long long int x;
long long int h[100000];
vector<struct Edge> es[100000];
Dist shortest[100000];
priority_queue<Pair, vector<Pair>, greater<Pair> > q;

int main() {
    scanf("%d %d %lld", &n, &m, &x);
    for (int i=0; i<n; i++) {
        scanf("%lld", &h[i]);
    }

    for (int i=0; i<m; i++) {
        int a, b;
        struct Edge tmp;

        scanf("%d %d %lld", &a, &b, &tmp.len);
        --a;
        --b;
        tmp.to = b;
        es[a].push_back(tmp);
        tmp.to = a;
        es[b].push_back(tmp);
    }

    fill(shortest, shortest+n, Dist(INF, 0));
    shortest[0].first = 0;
    shortest[0].second = x;
    q.push(Pair(Data(0, 0), x));
    while (!q.empty()) {
        Pair p = q.top(); q.pop();
        long long int cost = p.first.first;
        int u = p.first.second;
        long long int arrived = p.second;
        
        if (shortest[u].first < cost-llabs(shortest[u].second-arrived)) continue;
        for (int i=0; i<es[u].size(); i++) {
            int v = es[u][i].to;
            long long int len = es[u][i].len;
            long long int newcost;
            long long int pos;

            //printf("%d: updating %d\n", u, v);
            if (h[u] < len) continue;

            if (arrived - len > h[v]) {
                newcost = cost + arrived-h[v];
                pos = h[v];
            } else if (arrived - len < 0) {
                newcost = cost + len*2 - arrived;
                pos = 0;
            } else {
                newcost = cost + len;
                pos = arrived - len;
            }

            if (shortest[v].first > newcost-llabs(shortest[v].second-pos)) {
                //printf("newcost: %lld pos: %lld\n", newcost, pos);
                shortest[v].first = newcost;
                shortest[v].second = pos;
                q.push(Pair(Data(newcost, v), pos));
            }

        }
    }

    /*for (int i=0; i<n; i++) {
        printf("%lld ", shortest[i].first);
    }
    puts("");
    for (int i=0; i<n; i++) {
        printf("%lld ", shortest[i].second);
    }
    puts("");*/

    if (shortest[n-1].first == INF) puts("-1");
    else printf("%lld\n", shortest[n-1].first + h[n-1]-shortest[n-1].second);
}

Measured memory_bytes: 24376
using System;

namespace ABC064_D___Insertion
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var surplus = S.Substring(0);
            for (int i = 0; i < 50; i++) surplus = surplus.Replace("()", "");

            var countLeft = 0;
            var countRight = 0;
            for (int i = 0; i < surplus.Length; i++)
            {
                if (surplus[i] == '(') countLeft += 1;
                if (surplus[i] == ')') countRight += 1;
            }
            for (int i = 0; i < countRight; i++) S = "(" + S;
            for (int i = 0; i < countLeft; i++) S = S + ")";

            Console.WriteLine(S);
        }
    }
}


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

int main(){
  int n; cin>>n;
  vector<int> v(n);
  for(int i=0; i<n; ++i)cin>>v[i];

  sort(v.begin(), v.end());
  double ans=v[0];
  for(int i=1; i<n; ++i)ans=(ans+v[i])/2;

  cout<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int n,m;
char X[100003],Y[100003];
vector<char> lcs( char *X, char *Y) 
{ 
   int L[m+1][n+1]; 
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
   
       else if (X[i] == Y[j]) 
        { L[i][j] = L[i-1][j-1] + 1; 

        }
   
       else
       {
        L[i][j] = max(L[i-1][j], L[i][j-1]); 
          
       }
     } 
   }
    vector<char> lcsi(L[m][n]);
    int i = m, j = n; 
    int index=L[m][n];
   while (i > 0 && j > 0) 
   { 
      if (X[i] == Y[j]) 
      { 

          lcsi[index-1]=X[i];  
          i--; j--; index--;    
      } 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
   return lcsi; 
} 
int main(){std::ios::sync_with_stdio(false);
string WW,WWW;
cin>>WW>>WWW;
n=WW.size();
m=WWW.size();
for(int i=1;i<=WW.size();i++){
	X[i]=WW[i-1];
}
for(int i=1;i<=WWW.size();i++){
	Y[i]=WWW[i-1];
}
vector<char>V;
V=lcs(Y,X);
for(int i=0;i<V.size();i++)
{
    cout<<V[i];
}
if(V.size()==0)cout<<" "<<endl;
cout<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 35456
using System;
 
namespace Atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
           var str = Console.ReadLine().Split(' ');
            var a = int.Parse(str[0]);
            var b = int.Parse(str[1]);
            var t = int.Parse(str[2]);
            Console.WriteLine(t / a * b);
        }
    }
}

Measured memory_bytes: 13140
while True:
	a, op, b = raw_input().split()
	a , b = int(a), int(b)
	if op == "?":
		break
	elif op == "+":
		print a + b
	elif op == "-":
		print a - b
	elif op == "*":
		print a * b
	elif (op == "/"):
		print a / b

Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
map<int,int> a; 
int n,m,sum[N],tmp;
long long cnt=0LL;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d",&tmp);
		sum[i]=(sum[i-1]+tmp%m)%m;
		cnt+=a[sum[i]];
		a[sum[i]]++;
	}
	printf("%lld",cnt+a[0]);
	return 0;
}

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

namespace ABC087 {
    class questionA {
        static void Main(string[] args) {
            int X = int.Parse(Console.ReadLine()); //標準入力
            int A = int.Parse(Console.ReadLine()); //標準入力
            int B = int.Parse(Console.ReadLine()); //標準入力
            // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
            Console.WriteLine(((X - A) % B).ToString());
        }
    }
}

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

int main() {
	int a,b,c,k,x;
	cin >> a >> b >> c >> k;
	for (int i = 0;i < k;i++) {
		if (a < b) { swap(a, b); };
		if (b < c) { swap(b, c); };
		if (a < b) { swap(a, b); };
		a = a * 2;
		x = a + b + c;
	}
	cout << x;
}



Measured memory_bytes: 256
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define ff first
#define ss second
#define mkp make_pair    
#define mkt make_tuple
#define all(v ) sort(v.begin(), v.end());      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define pr pair<ll,ll>
#define mps map<string ,ll>
#define mpc map<char ,char>
#define mpl map<ll,ll>
#define tpl tuple<ll,ll,ll>
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
//	   cin>>t;
	      while(t--)
{


/*
5 5 7/**/
ll a,b,c;
ll l1=0;
ll l2=0;

fo(i,3)
{
	cin>>a;
	if(a==5)
	l1++;
	if(a==7)
	l2++;
}
if(l1==2&&l2==1)
YY;
else
NN;
	ee;


}
return 0;
}



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

long long n,q;
long long a[100002];
long long b,c;

long long cnt[100012];
long long sum = 0ll;


int main(){

	// init
	for(int i=0;i<=100002;i++){
		cnt[i] = 0ll;
	}

	// input
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cnt[a[i]]++;
		sum += a[i];
	}

	cin>>q;
	for(int i=0;i<q;i++){
		cin>>b>>c;
		sum -= b*cnt[b];
		sum += c*cnt[b];
		cnt[c] += cnt[b]; 
		cnt[b]=0ll;
		cout<<sum<<endl;
	}

	return(0);
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF = 1000000000000000;

string s;
int main(){
	ll n;
	cin >> n;

	ll ans = (n-1)*n/2;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    ll n,k,ans = 0;
    cin>>n>>k;
    repi(i,k + 1,n + 1){//bを固定して考えてみる
        ans += n / i * max(0LL,i - k);
        ans += max(0LL, n % i + 1 - k);
    }
    if(k == 0)cout<<n * n<<endl;
    else cout<<ans<<endl;
}


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

int main(){
  
  long long N, K, R, S, P, i, Score = 0;
  string T;
  cin >> N >> K >> R >> S >> P;
  cin >> T;
  for (i = 0; i < N; i++){
    
    cin >> T.at(i);
    
    switch(T.at(i)){
        case 'r':
            Score += P;
            break;
        case 's':
            Score += R;
            break;
        case 'p':
            Score += S;
            break;
    }
  }
  
  for (i = 0; i < N - K; i++){
    
    if(T.at(i) == T.at(i + K)){
      
      T.at(i + K) = 'n';
        
      switch(T.at(i)){
          case 'r':
              Score -= P;
              break;
          case 's':
              Score -= R;
              break;
          case 'p':
              Score -= S;
              break;
      }
    }
  }
  cout << Score << endl;
  return 0;
}

Measured memory_bytes: 512