akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define LL                  long long
#define ull                 unsigned long long LL
#define scl(n)              scanf("%lld", &n)
#define scf(n)              scanf("%lf", &n)
#define sci(n)              scanf("%d", &n)
#define scii(n,m)           scanf("%d %d",&n,&m)
#define sciii(n,m,p)        scanf("%d %d %d",&n,&m,&p)

#define MOD                 1000000007
#define MODP                99999999999973LL
#define pb                  push_back
#define mp                  make_pair
#define pp                  pair<LL,LL>
#define memo(a,b)           memset(a,b,sizeof(a))
#define INF                 1e9
#define EPS                 1e-8
#define Pi                  acos(-1.0)
LL bigmod(LL b, LL p, LL md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {LL y=bigmod(b,p/2,md);return (y*y)%md;}}
#define N 300002

LL dp[N];

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

    LL arr[n+1];

    for(int i=1;i<=n;i++)
        cin>>arr[i],dp[i]=1000000000000000000;
   \

    dp[1]=0;
    dp[0]=0;
    arr[0]=arr[1];


    for(int i=2;i<=n;i++)
    {
        dp[i]=min(dp[i],dp[i-1]+abs(arr[i]-arr[i-1])  );
        dp[i]=min(dp[i],dp[i-2]+abs(arr[i]-arr[i-2])  );
    }
    cout<<dp[n]<<endl;




    return 0;
}



/* LL dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
/* LL dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
/* LL dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* LL dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


Measured memory_bytes: 1792
while True:
    n,turn,y,b = map(int,input().split())
    if [n,turn,y,b]==[0,0,0,0]:
        break
        
    yasumi=[]
    back=[]
    for _ in range(y):
        yasumi.append(int(input()))
    for _ in range(b):
        back.append(int(input()))
    
    taiki=[0]*(turn+10)
    dp=[[0.0]*(n+1) for _ in range(turn+10)]
    dp[0][0]=1
    for i in range(0,turn):
        for j in range(0,n):
            for dice in range(1,7):
                cur= j+dice
                if cur > n:
                    cur= n*2-cur
                if cur in yasumi:
                    dp[i+2][cur]+=dp[i][j]/6
                        
                elif cur in back:
                    dp[i+1][0]+=dp[i][j]/6
                else:
                    dp[i+1][cur]+=dp[i][j]/6

    print('{:.6f}'.format(sum([dp[i][n] for i in range(turn+1)])))


Measured memory_bytes: 5996
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1000000007;


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    string S;
    for (int i =0 ;i < N; i++){
        cin >> S[i];
    }

    string ans ="Three";

    for (int i =0 ;i < N; i++){
        if( S[i] == 'Y' ){
            ans = "Four";
            break;
        }

    }
    cout << ans;

    return 0;

}

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

int a[101];
int cnt[8], diff;

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < 400) cnt[0]++;
        else if (a[i] < 800) cnt[1]++;
        else if (a[i] < 1200) cnt[2]++;
        else if (a[i] < 1600) cnt[3]++;
        else if (a[i] < 2000) cnt[4]++;
        else if (a[i] < 2400) cnt[5]++;
        else if (a[i] < 2800) cnt[6]++;
        else if (a[i] < 3200) cnt[7]++;
        else diff++;
    }

    int ans = 0;
    for (int i = 0; i < 8; i++) {
        if (cnt[i]) ans++;
    }
    cout << max(ans, 1) << ' ' << ans + diff << '\n';

    return 0;
}


Measured memory_bytes: 256
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
a=gsmi

max=0
max_i=0
n.times do |i|
  abs=a[i].abs
  if abs>max
    max=abs
    max_i=i
  end
end

ans=[]
if a[max_i]>=0
  # 全部正にする
  n.times do |i|
    if a[i]<0
      a[i]+=a[max_i]
      ans<<[max_i+1,i+1]
    end
  end

  prev= -1
  n.times do |i|
    if a[i]<prev
      a[i]+=prev
      ans<<[i,i+1]
    end
    prev=a[i]
  end
else
  # 全部負にする
  n.times do |i|
    if a[i]>0
      a[i]+=a[max_i]
      ans<<[max_i+1,i+1]
    end
  end

  prev= 1
  (n-1).downto(0) do |i|
    if a[i]>prev
      a[i]+=prev
      ans<<[i+2,i+1]
    end
    prev=a[i]
  end
end

putsend 0 if ans.size.zero?
puts ans.size
ans.each{|i|puts i.join(" ")}

Measured memory_bytes: 1788
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

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

using namespace std;

int N, K;
vector<int> A;

bool is_need(int idx){
    vector<int> dp(K);
    dp[0] = 1;
    REP(i, N){
        if(i==idx)continue;
        int a = A[i];
        for(int k=K-1; k>=a; k--){
            dp[k] |= dp[k-a];
        }
    }
    //cerr << idx << endl;
    //REP(k, K)cerr << dp[k];
    //cerr << endl;
    REP(k, K){
        if(dp[k] && k+A[idx]>=K)return true;
    }
    return false;
}

int solve(){
    cin >> N >> K;
    A.resize(N);
    REP(i, N)cin >> A[i];
    sort(ALL(A));

    int lb=0;
    int ub=N;
    while(lb<ub){
        int mid = (lb+ub)>>1;
        if(is_need(mid)){
            ub = mid;
        }else{
            lb = mid+1;
        }
    }
    return lb;
}

int main(){
    int res = solve();
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
#define MAX 500
 
using namespace std;

int main(void){
    while(1){
        int kami[MAX][MAX]={0};
		int w, h, t, p;
		cin >> w >> h >> t >> p;
        if(!w && !h && !t && !p) break;
        for(int i=0; i<h; i++){
			fill(kami[i], kami[i]+w, 1);
        }
 
        int origin_x = 0, origin_y =0;
        for(int k=0; k<t; k++){
			int d, c;
			cin >> d >> c;
			
			int dist = 1;
            if(d == 1){
				for(int j=origin_x+c; j<origin_x+(2*c); j++){
                     for(int i=origin_y; i<MAX; i++){
                        kami[i][j] += kami[i][j-dist];
	                }
		            dist += 2;
			    }
                origin_x += c;
            } else{
                for(int i=origin_y+c; i<origin_y+(2*c); i++){
                    for(int j=origin_x; j<MAX; j++){
                        kami[i][j] += kami[i-dist][j];
                    }
                    dist += 2;
                }
                origin_y += c;
            }
        }
         
        for(int k=0; k<p; k++){
			int x, y;
			cin >> x >> y;
			cout << kami[origin_y+y][origin_x+x] << endl;
        }
    }
 
    return 0;
}


Measured memory_bytes: 4068
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadLong;
            var end = (int)(Sqrt(N));
            long A = 0;
            long B = 0;
            for(int i = 1; i <= end; i++)
            {
                if(N % i == 0)
                {
                    A = N / i;
                    B = (long)i;
                }
            }
            var lankA = 1;
            var lankB = 1;
            while(Pow(10, lankA) <= A)
            {
                lankA++;
            }
            while(Pow(10, lankB) <= B)
            {
                lankB++;
            }
            var ans = Max(lankA, lankB);
            WriteLine(ans);
        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;
const ll MOD = 998244353;

int main() {
    int N, d = 0, ans = 1;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N - 1) {
        if (A[i] < A[i + 1]) {
            if (d == -1) {
                ans++;
                d = 0;
            } else {
                d = 1;
            }
        }
        if (A[i] > A[i + 1]) {
            if (d == 1) {
                ans++;
                d = 0;
            } else {
                d = -1;
            }
        }
        //cout << "i=" << i << ", d=" << d << ", ans=" << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long double w,h,x,y,i,j,k;
    long double a,b,c;
    cin>>w>>h>>x>>y;
    i=w*(fmin(y,(h-y)));
    j=h*(fmin(x,(w-x)));
	cout<<setprecision(17)<<w*h/2.0<<" ";
	if (x==w/2.0 && y==h/2.0)
	{
		cout<<1<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')

#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=ii()

if s<10**9:
    a,b=s,0
else:
    if s%(10**9)==0:
        a,b=0,s//(10**9)
    else:
        a,b=10**9-(s%(10**9)),s//(10**9) +1

print(0,0,10**9,1,a,b)

Measured memory_bytes: 37516
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    static final int INF = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        char[] s = nchars(1, 0);
        char[] t = nchars(1, 0);
        solve(s, t);
    }
    
    static void solve(char[] s, char[] t) {
        int ls = s.length;
        int lt = t.length;
        
        int[][] len = new int[ls][lt];
        int[][] prev = new int[ls][lt];
        final int PREV_ST = 1;
        final int PREV_S = 2;
        final int PREV_T = 3;
                    
        for (int is = 1; is < ls; is++) {
            for (int it = 1; it < lt; it++) {
                
                if (s[is] == t[it]) {
                    len[is][it] = len[is-1][it-1] + 1;
                    prev[is][it] = PREV_ST;
                    
                } else {
                    if (len[is-1][it] >= len[is][it-1]) {
                        len[is][it] = len[is-1][it];
                        prev[is][it] = PREV_S;
                    } else {
                        len[is][it] = len[is][it-1];
                        prev[is][it] = PREV_T;
                    }
                }
            }
        }
        StringBuffer sb = new StringBuffer();
        int is = ls-1;
        int it = lt-1;
        while (true) {
            if (s[is] == t[it]) {
                sb.append(s[is]);
            }
            int p = prev[is][it];
            if (p == PREV_S || p == PREV_ST) is--;
            if (p == PREV_T || p == PREV_ST) it--;
            if (is <= 0 || it <= 0) {
                break;
            }
        }
        System.out.println(sb.reverse().toString());
    }
    
    static long max(long... longs) {
        return Arrays.stream(longs).max().getAsLong();
    }
    
    static long min(long... longs) {
        return Arrays.stream(longs).min().getAsLong();
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0);
    }

    private static char[][] nchars2(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


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

template <typename T>
struct BIT{
private:
    vector<T> array;
    int n;

public:
    // 初期化
    BIT() {}
    BIT(int _n) : array(_n + 1, 0), n(_n) {}

    // 1番目から i番目までの累積和を求める
    T sum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i;      // LSB 減算
        }
        return s;
    }

    // [i, j] の要素の総和
    T sum(int i, int j) {
        T ret_i = sum(i-1);
        T ret_j = sum(j);
        return ret_j - ret_i;
    }

    // i 番目に 要素 x を追加
    void add(int i, T x) {
        while(i <= n) {
            array[i] += x;
            i += i & -i;      // LSB 加算
        }
    }
};

int main(void) {
    int N; cin >> N;
    int M; cin >> M;
    BIT<int> fenwick(M+5);
    vector<pair<int, pair<int, int>>> Q(N);
    for (int i = 0; i < N; i++) {
        int l, r; cin >> l >> r;
        r++;
        int len = r - l;
        Q[i] = {len, {l, r}};
    }
    sort(Q.begin(), Q.end());

    int added = 0;
    for (int d = 1; d <= M; d++) {
        for (int i = added; i < N && Q[i].first < d; i++) {
            int left = Q[i].second.first;
            int right = Q[i].second.second;
            fenwick.add(left, 1);
            fenwick.add(right, -1);
            added++;
        }

        int ans = N - added;
        for (int crt = 0; crt <= M; crt += d) {
            ans += fenwick.sum(crt);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  int N;
  set<int> S;
  cin>>N;
  FOR(i,0,N){
    int B;
    cin>>B;
    S.insert(B);
  }
  cout<<S.size()<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[][] aryA = new int[n][m];
		int[] aryB = new int[m];
		int[] result = new int[n];
		
		//??????A???????´????????´?
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				aryA[i][j] = in.nextInt();
			}
		}
		//?????????????????????????´????????´?
		for(int i=0; i<m; i++){
			aryB[i] = in.nextInt();
		}
		//?????????????¨????????????????n x 1???????????????
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				result[i] += aryA[i][j]*aryB[j];
			}
		}
		//????????¨???
		for(int i:result){
			System.out.println(i);
		}
	}
}

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

using namespace std;

long long kpk(long long n, long long m){
	long long a,b;
	a=n;
	b=m;
	while(a!=b&&b!=a){
		while(a<b){
			a+=n;
		}
		while(b<a){
			b+=m;
		}
	}
	return b;
}

long long fpb(long long n, long long m){	
	long long r;
	if (n<m){
		swap(n,m);
	}
	r=n%m;
	while(r>0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
	}
	
int main(){
	long long a,b;
	while(cin>>a>>b){
		cout<<fpb(a,b)<<' '<<kpk(a,b)<<endl;
	}
}


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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    vector<int> H(N);
    for(int i = 0; i< N; i++){
        cin >> H[i];
    }
    int count = 0;
    for(int i = 0; i < H.size()-1; i++){
        if(H[i] >= H[i+1]){
            count++;
        }else{
            if(count >= ans){
                ans = count;
            }
            count = 0;
        }
    }
    if(count > ans) ans = count;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

// 5min
int main(void){
  long long int h[100001];
  long long int n, k;
  long long int min = 0;
  
  scanf("%lld%lld", &n, &k);
  for(int i = 0; i < n; i++){
    scanf("%lld", &h[i]);
  }

  qsort(h, n, sizeof(long long int), compare_int);

  min = h[0] - h[k - 1];

  for(long long int i = 1; i < n - k + 1; i++){
    //    printf("i = %lld  h[i] = %lld h[i+k-1] = %lld\n", i, h[i], h[i + k - 1]);
    if(h[i] - h[i + k - 1] < min){
      min = h[i] - h[i + k - 1];
      //      printf("minmin\n");
    }
}

  printf("%lld\n", min);
  
  return 0;
}


Measured memory_bytes: 1788
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	var l = a + b
	var r = c + d

	if l < r {
		fmt.Println("Right")
	} else if l == r {
		fmt.Println("Balanced")
	} else {
		fmt.Println("Left")
	}
}


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

const int N=1e5+5;
int n;
char s[N];

int main()
{
	int i,nowz=0,nowo=0,ans=0;
	scanf("%s",s+1);n=strlen(s+1);
	for(i=1;i<=n;++i)
	{
		if(s[i]=='0') ++nowo;
		else ++nowz;
	}
	printf("%d\n",min(nowo,nowz)*2);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int top=0;
int stack[1000];

void push(int n){
  stack[++top]=n;
}

int pop(void){
  top--;
  return stack[top+1];
}

void calc(char op){
  int n1=pop(), n2=pop();
  if(op=='+') push(n1+n2);
  if(op=='-') push(n2-n1);
  if(op=='*') push(n2*n1);
}

int main(void){
  char a[1000];
  int t,s;
    while(scanf("%s",a)!=EOF){
      if(a[0]=='+' || a[0]=='-' || a[0]=='*') calc(a[0]);
      else push(atoi(a));
    }
  printf("%d\n",pop());
  return 0;
}

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

using namespace std;

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

	int n;
	cin >> n;

	vector<pair<long long, long long>> v(n);
	long long a, b;

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

	sort(v.begin(), v.end());

	long long cur = 0;
	bool flag = true;

	for(int i = 0; i < n; i++) {
		cur += v[i].second;
		if(cur > v[i].first) {
			flag = false;
			break;
		}
	}

	if(flag) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

map<int,int>mp;
bool isAbleToBuy(int n){
    string s;
    s = to_string(n);
    REP(i,s.length()){
        if(mp[s[i]-'0']!=0){
            return false;
        }
    }
    return true;
}
int main(){
    int n,k;
    cin >> n >> k;
    REP(i,10){
        mp[i]=0;
    }
    REP(i,k){
        int d;
        cin >> d;
        mp[d]++;
    }

    while(!isAbleToBuy(n)){
        n++;
    }
    cout << n << endl;

    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ANS(ans) cout << ans << endl;


int
main()
{
  int N, M; cin >> N >> M;
  vector<ull> flg(N);
  REP(i, N) {
    int k; cin >> k;
    flg.at(i) = 0;
    REP(j, k) {
      int no; cin >> no;
      flg.at(i) |= (1 << no);
    }
  }

  ull ans_flg = (ull)-1;
  REP(i, N) {
    ans_flg &= flg.at(i);
  }
  
  int num = 0;
  REP(i, M+1) {
    if (ans_flg % 2) num++;
    ans_flg /= 2;
  }

  ANS(num);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define MOD  (int)(1e9+7)
 
#define float long double
 
 
int ADD(int &a,int &b)
{
  return (a%MOD + b%MOD )%MOD;
}
 
 
 
int ADD(int &a,int &b,int &c)
{
  return ( ADD(a,b) + c%MOD )%MOD;
}
 
 

 
 
 
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
 
 
bool  isPalindrome(string str) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = str.size() - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            
            return false; 
        } 
    } 
  return true;
  
} 
int32_t main()
{
  FAST;

  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  // #endif
 
  int n;
  cin >> n;
  int a[n];
  map<int,int> mp;
  
  f(i,0,n) cin >> a[i],mp[a[i]]++;
  int ans=0;
  
  for(auto x:mp) 
  {
    int temp=x.second;
    ans+=(temp*(temp-1))/2;
  }
  
  for(int i=0;i<n;i++)
  {
    int frq=mp[a[i]];
    int old=(frq*(frq-1))/2,New=((frq-1)*(frq-2))/2;
    
    cout<<ans-old+New<<E;
    
  }
 
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false);
    string a ; cin >> a;
    int n = a.size();
    a = '#' + a;
    int pos = -1;
    for (int i = 2 ; i <= n ; i++){
        if (a[i] == a[i - 1]) {
            pos = i - 1;
            break;
        }
    }
    if (~pos){
        cout << pos << " " << pos + 1 << endl;
        return 0;
    }
    for (int i = 3 ; i <= n ; i++){
        if (a[i] == a[i - 2]){
            pos = i - 2;
            break;
        }
    }
    if (~pos){
        cout << pos << " " << pos + 2 << endl;
        return 0;
    }
    cout << pos << " " << pos << endl;
    return 0;
}


Measured memory_bytes: 3772
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N;
  cin >> N;

  int mx = -1;
  int ans;
  for(int i=1;i<=N;i++){
    int itmp = i;
    int cnt = 0;
    while(itmp %2 == 0){
      cnt++;
      itmp /= 2;
    }

    if(cnt > mx){
      mx = cnt;
      ans = i;
    }
  }

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

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

int main() {
    int n, q;
    std::string s;
    std::cin >> n >> q >> s;

    int counts[n];\

    for (int i = 0; i < n; i++) {
        char current = s[i];
        int count = 0;

        if (i == 0) {
            count = 0;

        } else {
            count = counts[i - 1];
        }

        if (current == 'C' && i != 0 && s[i - 1] == 'A') {
            count++;
        }

        counts[i] = count;
    }

    for (int i = 0; i < q; i++) {
        int l, r;
        std::cin >> l >> r;
        std::cout << counts[r - 1] - counts[l - 1] << std::endl;
    }
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, K;
    cin >> K >> A >> B;
    int k = K;
    while (k <= B) {
        if (A <= k) {
            cout << "OK" << endl;
            return 0;
        }
        k += K;
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll f(ll n){
  return n*n*n*n*n;
}
int main(){
  ll x;
  cin>>x;
  for(ll i=-200;i<=200;i++){
    for(ll j=-200;j<=200;j++){
      if(f(i)-f(j)==x){
        cout<<i<<" "<<j<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3628
n,m=map(int,input().split())
a = []

mod = 1000000007

dp=[0]*(n+1)

dp[0]=1
dp[1]=1
d={}
for j in range(n+1):
    d[j]=0

for _ in range(m):
    s = int(input())
    d[s]=1
    dp[s]=0

for i in range(2,n+1):
    if d[i]==1:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]

print(dp[-1]%mod) 


Measured memory_bytes: 475904
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect
import re


ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    a,b,xtmp = mi()
    x = xtmp/a
    s = a*b
    if x>s/2:
        nx = s-x
        nb = nx*2/a
        ans = math.degrees(math.atan(nb/a))
        
    else:
        na = 2*x/b
        ans = 90-math.degrees(math.atan(na/b))



    print(ans)

main()


Measured memory_bytes: 22156
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;

int main() {
  int N,M;
  cin >> N >> M;
  vector<vint> g(N);
  repeat(i,M){
    int A,B;
    cin >> A >> B;
    A--;B--;
    g[A].push_back(B);
    g[B].push_back(A);
  }
  deque<int> dq;
  dq.push_back(0);
  vector<bool> isused(N,false);
  isused[0]=true;
  bool update = true;
  while(update){
    update = false;
    for(int f:g[dq.front()]){
      if(isused[f])continue;
      dq.push_front(f);
      isused[f]=true;
      update = true;
      break;
    }
    for(int b:g[dq.back()]){
      if(isused[b])continue;
      dq.push_back(b);
      isused[b]=true;
      update = true;
      break;
    }
  }
  cout << dq.size() << endl;
  repeat(i,dq.size()){
    cout << dq[i]+1;
    cout << (i<N-1? " ":"\n");
  }
  return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  int h, a; cin >> h >> a;
  cout << h / a + (h % a != 0);
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define int int64_t
using namespace std;
main() {
  int N,M; cin>>N>>M;
  vector<pair<int,int>> xss;
  for(int i=1; i<=N; ++i) {
    int A,B; cin>>A>>B;
    xss.push_back({A,B});
  }
  sort(xss.begin(), xss.end());//安い店順に整列する
  int sum = 0;
  for(int i=0; i<xss.size(); ++i) {//全ての店について
    int A,B; A=xss[i].first; B=xss[i].second;//価格と個数
    int b= min(B,M);//この店で購入する個数
    sum+= A*b;//購入した金額
    M-= b;//必要個数を減らす
    if(M==0) break;//もういらない
  }
  cout<< sum <<endl;
}

Measured memory_bytes: 2420
import random


def nC2(n):
    return int(n*(n-1)/2)

n = int(input())

a = [0]*n
a = list(map(int, input().split()))
a = [i-1 for i in a]

ty=[0]*n

for i in range(0, n):
    ty[a[i]]+=1

s = 0

for i in range(0, n):
    if ty[i]>=2:
        s += nC2(ty[i])

for k in range(0, n):
    if ty[a[k]]==2:
        print(s-1)
    elif ty[a[k]]>2:
        print(s-nC2(ty[a[k]])+nC2(ty[a[k]]-1))
    else:
        print(s)

Measured memory_bytes: 28188
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    set<int> st;
    cin >> n;
    rep(i, 0, n){
        int a;
        cin >> a;
        st.insert(a);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    while(true){
		int n;
		cin >> n;
		if(n == 0) break;

		int max_p = 0, max_d = 0;

		for (int i = 0; i < n; i++){
			int p, d1, d2;
			cin >> p >> d1 >> d2;

			if (max_d <= d1 + d2) {
				max_d = d1+ d2;
				max_p = p;
			}

		}
		cout << max_p << " " <<  max_d << endl;

	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <sstream>

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

using namespace std;


int main() {
    int n, d; cin >> n >> d;
    int v[15][15];
    
    rep(i, n) {
        rep(j, d) {
            int x; cin >> v[i][j];
        }
    }
    int cnt = 0;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            int len = 0;
            for (int k = 0; k < d; k++) {
                len += pow(abs(v[i][k] - v[j][k]), 2);
            }

            rep(i, 1600 * 4) {
                if(i*i == len){
                    cnt++;
                    break;
                } 
            } 
        }
    }
    
    cout << cnt / 2 << endl;
    
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

typedef struct
{
    int height;
    int targetMaxHeight;
}Info;

#define ARRAYMAX 100010
Info InfoArray[ARRAYMAX];

#define DEBUG


int main()
{
    int i, j, k, m;

    //printf("size_t:%ld\n", sizeof(size_t));

    for (i = 0;i < ARRAYMAX;i++)
    {
        InfoArray[i].height = 0;
        InfoArray[i].targetMaxHeight = 0;
    }
#if 0
    char str[1000];
    fgets(str, sizeof(str), stdin);

    char* temp;
    temp = strtok(str, " \n");
    // 展望台の数
    int TenbodaiNum = atoi(temp);
 

    // 道の数
    temp = strtok(NULL, " \n");
    int PathNum = atoi(temp);

    //高さの取得

    fgets(str, sizeof(str), stdin);

    int hoge = 0;
    temp = strtok(str, " \n");

    while (temp != NULL)
    {
        //if (hoge >= ARRAYMAX) break;
        InfoArray[hoge].height = atoi(temp);
        hoge++;
        temp = strtok(NULL, " \n");
    }
#endif
    int TenbodaiNum, PathNum;
    cin >> TenbodaiNum >> PathNum;

    for (i = 0;i < TenbodaiNum;i++)
    {
        cin >> InfoArray[i].height;
    }







    //道情報取得
    for (i = 0;i < PathNum;i++)
    {
        int iPos1;
        int iPos2;
#if 0
        fgets(str, sizeof(str), stdin);
        temp = strtok(str, " \n");
        iPos1 = atoi(temp) -1;
        temp = strtok(NULL, " \n");
        iPos2 = atoi(temp) -1;
#endif
        cin >> iPos1 >> iPos2;
        iPos1--;
        iPos2--;

        //if (iPos1 >= ARRAYMAX) continue;
        //if (iPos2 >= ARRAYMAX) continue;



        if (iPos1 == iPos2) continue;

        if (InfoArray[iPos1].targetMaxHeight < InfoArray[iPos2].height)
        {
            InfoArray[iPos1].targetMaxHeight = InfoArray[iPos2].height;
        }
        if (InfoArray[iPos2].targetMaxHeight < InfoArray[iPos1].height)
        {
            InfoArray[iPos2].targetMaxHeight = InfoArray[iPos1].height;
        }
    }

    // 判定
   
    int iGoodNum = 0;

    for (i = 0;i < TenbodaiNum;i++)
    {
        //if (i >= ARRAYMAX) continue;
         if (InfoArray[i].height > InfoArray[i].targetMaxHeight) iGoodNum++;
    }



    printf("%d\n", iGoodNum);


    return 0;
}


Measured memory_bytes: 4556
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let c: char = iterator.next().unwrap().chars().nth(0).unwrap();

    return std::char::from_u32(c as u32 + 1).unwrap().to_string();
}

#[test]
fn test() {
    assert_eq!(
        solve(
            r"a"
        ),
        "b"
    );
    assert_eq!(
        solve(
            r"y"
        ),
        "z"
    );
}


Measured memory_bytes: 4352
n = gets.to_i
a = Array.new(n) { Array.new(3) }
a[0] = [0, 0, 0]
(1..n).each do |i|
  a[i] = gets.chomp.split.map(&:to_i)
end

key = 1
(1..n).each do |i|
  x = (a[i][1] - a[i-1][1]).abs
  y = (a[i][2] - a[i-1][2]).abs
  t = a[i][0] - a[i-1][0]
  if x  + y > t || (t - x - y).odd?
    key = 0
    break
  else
    next
  end
end

puts key == 1 ? "Yes" : "No"

Measured memory_bytes: 15100
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  char x=a+'0';
  char y=b+'0';
  string str1(a,y);
  string str2(b,x);
  if(str1<str2) cout<<str1<<endl;
  else cout<<str2<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll s = 0;
    rep(i, N) {
        cin >> A[i];
        s += A[i];
    }
    ll ans = 1e18, t = 0;
    rep(i, N) {
        t += A[i];
        ll u = abs(s - t - t);
        if (u < ans) ans = u;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.lang.*;
import java.util.*;

public class Main
{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[])
    {
	int N = sc.nextInt();
	for(int c=0; c<N;c++){
	    int[][] map = new int[5][5];
	    for(int j=0; j<5; j++){
		for(int k=0; k<5; k++){
		    map[j][k] = sc.nextInt();
		}
	    }
	    int max=0;
	    
	    for(int i=0; i<5; i++){
		for(int j=0; j<5; j++){
		    
		    for(int k=i; k<5; k++){
			for(int l=j;l<5;l++){
			    boolean f = true;
			    for(int n=i; n<=k; n++){
				for(int m=j; m<=l; m++){
				    if(map[n][m]==0){
					f = false;
					break;
				    }
				}
			    }
			    if(f) max = Math.max(max, (k-i+1)*(l-j+1));
			}
		    }
		}
	    }
	    System.out.println(max);
	}	
    }
}

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

int main(){
  
  long long N;
  cin >> N;
  long long Total=0;
  Total = 60*(N/15)*(N/15);
  long long G;
  G = N - N%15;
  for(int i=0;i<(N%15)+1;i++){
    if(i%3!=0 & i%5!=0){
      Total += (G+i);
    }
  }
  cout << Total << endl;
  
  
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
        int a=0,b= 0;
        a = sc.nextInt();
        b = sc.nextInt();
        
        if ((a==4 || a==6 || a==9 ) && (b==6 || b==9 || b ==11) ){
            System.out.println("Yes");
            return;
        }
        if ((a==1 || a==3 || a==5 || a==7 || a==8 || a==10 ) && (b==3 || b==5 || b ==7 || b==8 || b==10 || b==12) ){
            System.out.println("Yes");
        }
        else System.out.println("No");
    }
}


Measured memory_bytes: 21844
import scala.io.StdIn._

object Main extends App {
  val Array(n, k) = readLine.split(" ").map(_.toInt)
  val s = readLine

  def countSeq(i: Int, prev: Char, nSeq: Int): Int = {
    if (i == n) nSeq
    else s.charAt(i) match {
      case `prev` => countSeq(i + 1, prev, nSeq + 1)
      case other => countSeq(i + 1, other, nSeq)
    }
  }

  val nSeq = countSeq(1, s.charAt(0), 0)
  println(Math.min(n - 1, nSeq + k * 2))
}

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {

    int a, b, h;
    scanf("%d%d%d", &a, &b, &h);

    int mid = ((a + b) * h) / 2;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a,b) memset(a,b,sizeof(a))
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 998244353;
const double II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    ll x,i,j;
    cin >> x;
    for(i = 0;i <= 200;i++)
    {
        for(j = -200;j <= 200;j++)
        {
            if(pow(i,5) - pow(j,5) == x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4120
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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

int n;
cin >> n;
vector<int> v(n);
rep(i,n) cin >> v[i]; 

sort(all(v));
double ans = v[0];

for(int i = 1; i < n;i++){
    ans = double(ans + v[i]) / 2;
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

vector<int> prime;
void setPrime() {
    for (int i=2; i<=55555; i++) {
        bool ok = true;
        for (int e: prime) {
            if (i%e==0) {
                ok = false;
                break;
            }
            if (e*e>i) break;
        }
        if (ok) prime.push_back(i);
    }
}

int main(){
    int n;
    cin >> n;
    setPrime();
    for (int e: prime) {
        if (e%5==1) {
            cout << e << " ";
            n--;
        }
        if (n==0) break;
    }
    
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
cnt=1
if abs(n-m)>1:print(0);exit()
elif (n+m)%2==1:
    for i in range(n):
        cnt *=(i+1)
        if cnt>=10**9+7:cnt %=10**9+7
    for j in range(m):
        cnt *=(j+1)
        if cnt>=10**9+7:cnt %=10**9+7
    print(cnt)
else:
    cnt *=(n+m)
    n -=1
    for i in range(n):
        cnt *=(i+1)
        if cnt>=10**9+7:cnt %=10**9+7
    for j in range(m):
        cnt *=(j+1)
        if cnt >=10**9+7:cnt %=10**9+7
    print(cnt)

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

#define sync {ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long int
#define mod 1000000007

ll x,k,d;

void solve()
{
    cin>>x>>k>>d;
    
    x = abs(x);
    ll used = x/d;
    used = min(k,used);
    x = x-used*d;
    k = k-used;
    
    if(k%2)
    {
        cout<<abs(x-d);
    }
    else
        cout<<x;
    
}

int main()
{
    sync;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}







Measured memory_bytes: 3648
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);

	ll n;
	cin >> n;
	ll sum = 0;
	for (ll i = 1; i <= n; i++) {
		if (i % 3 > 0 && i % 5 > 0) sum += i;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long 
#define pb push_back
#define MAX 10000005
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std;
/*
vector<int> primes;
ll sumprime[MAX];
bool is_prime[MAX];
void sieve(){
	is_prime[0]=is_prime[1]=true;
	for(int i=4;i<MAX;i+=2){
		is_prime[i]=true;
	}
	for(int i=3;i*i<MAX;i+=2){
		if(!is_prime[i]){
			for(int j=i*i;j<MAX;j+=i){
				is_prime[j]=true;
			}
		}
	}
	for(int i=0;i<MAX;i++){
		if(!is_prime[i]){
			sumprime[i]=sumprime[i-1]+i;
		}else{
			sumprime[i]=sumprime[i-1];
		}
	}
}
*/


int32_t main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	//double	pi=3.14159265358979323846;
	//sieve();
	
	
	string s;
	cin>>s;
	string ans=s.substr(0,3);
	cout<<ans<<endl;

	return 0;
	
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> next;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    next.push_back(a - 1);
  }
  vector<bool> visit(n, 0);
  int count = 0;
  for (int i = 0; !visit[i]; i = next[i]) {
    visit[i] = 1;
    if (i == 1) {
      cout << count << endl;
      return 0;
    }
    count++;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
typedef long long ll;
/**
 * Uncomment the #define below if problem contains multiple test cases
 */
// #define MULTIPLE_TESTS 1

void solve() {
  int s, w;
  cin >> s >> w;
  if (w >= s) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
}

int main() {
  FAST_IO;
  int t = 1;
#ifdef MULTIPLE_TESTS
  cin >> t;
#endif

  while (t--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

bool solve(){
    int h,w,s,t;
    cin >>h >>w >>s >>t;

    if(h>w){
        swap(h,w);
        swap(s,t);
    }

    if(h==1) return t==1 || t==w;
    if(h%2==0 || w%2==0) return true;
    return (s+t)%2==0;
}

int main(){
    cout << (solve()?"Yes":"No") << endl;
    return 0;
}



Measured memory_bytes: 3100