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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  ll n;
  cin >> n;
  ll sum = 0;
  rep(i,n) {
    if ((i+1) % 3 == 0 || (i+1) % 5 == 0) {
      continue;
    } else {
      sum += (i+1);
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	if n == 1 {
		fmt.Println(0)
		return
	}

	m := map[int]int{}
	for i := 2; i <= n; i++ {
		fact := getFactor(i)
		for k, e := range fact {
			m[k] += e
		}
	}

	cle := make([]int, 0)
	for _, v := range m {
		cle = append(cle, v)
	}
	sort.Ints(cle)

	cnt := 0
	end := len(cle)

	// 2-4-4
	for i := 0; i < end; i++ { //2
		if cle[i] < 2 {
			continue
		}
		for j := 0; j < end; j++ { //4-1
			if i == j || cle[j] < 4 {
				continue
			}
			for k := 0; k < end; k++ { //4-2
				if j == k || i == k || cle[k] < 4 {
					continue
				}
				cnt++
			}
		}
	}
	cnt /= 2 // 4-1と4-2 で重複して数えているため

	// 4-14
	for i := 0; i < end; i++ { //4
		if cle[i] < 4 {
			continue
		}
		for j := 0; j < end; j++ { //14
			if i == j || cle[j] < 14 {
				continue
			}
			cnt++
		}
	}

	// 2-24
	for i := 0; i < end; i++ { //2
		if cle[i] < 2 {
			continue
		}
		for j := 0; j < end; j++ { //24
			if i == j || cle[j] < 24 {
				continue
			}
			cnt++
		}
	}

	// 74
	for i := 0; i < end; i++ { //74
		if cle[i] < 74 {
			continue
		}
		cnt++
	}

	fmt.Println(cnt)

	//cnt2 := num(75, m) +
	//	num(25, m)*(num(3, m)-1) +
	//	num(15, m)*(num(5, m)-1) +
	//	num(5, m)*(num(5, m)-1)*(num(3, m)-2)/2
	//fmt.Println(cnt2)
}
func num(x int, m map[int]int) int {
	cnt := 0
	for _, v := range m {
		if v >= x-1 {
			cnt++
		}
	}
	return cnt
}

// 素因数分解列挙Map作成
func getFactor(a int) (m map[int]int) {
	m = map[int]int{}
	for k := 2; a != 1; k++ {
		for ; a%k == 0; a /= k {
			m[k]++
		}
	}
	return m
}

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


Measured memory_bytes: 1836
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;

signed main(){

    int n;
    cin >> n;
    vector<int> s;
    s.push_back(0);
    rep(i,n){
        int a;
        cin >> a;
        s.push_back(s[i]+a);
    }
    int ans = INF;
    // rep(i,n+1)cerr << s[i] << " ";
    // cerr << endl;
    for(int i = 2;i <= n-2;i++){
        int lsum = s[i];
        int rsum = s[n] - s[i];
        auto l1 = lower_bound(s.begin(),s.end(),s[i]/2);
        auto r1 = lower_bound(s.begin(),s.end(),s[i] + rsum/2);
        int a = *l1;
        int b = s[i]-*l1;
        int c = *r1-s[i];
        int d = s[n]-*r1;
        l1--;
        r1--;
        if(abs(a-b) > abs(s[i]-2*(*l1))){
            a = *l1;
            b = s[i]-*l1;
        }
        if(abs(c-d) > abs(s[n]-2*(*r1)+s[i])){
            c = *r1-s[i];
            d = s[n]-*r1;
        }
        int maxi = max({a,b,c,d});
        int mini = min({a,b,c,d});

        ans = min(ans,maxi-mini);
        //cerr << i << " " << *l1 << " " << s[i] << " " << *r1 << " " << ans << endl;
    }
    cout << ans << endl;

    

    return 0;   
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://abc102.contest.atcoder.jp/tasks/arc100_b


Measured memory_bytes: 2420
N = int(input())
list_A1 = [int(x) for x in input().split()]
list_A2 = [int(x) for x in input().split()]

ans = 0

for i in range(N) :
    total = sum(list_A1[:i+1]) + sum(list_A2[i:])
    ans = max(ans, total)

print(ans)


Measured memory_bytes: 2940
H, W = [ int(x) for x in input().split() ]
Ss = [ input().split() for _ in range(H) ]

for i in range(H):
    for j in range(W):
        if Ss[i][j] == "snuke":
            ans = "{}{}".format(chr(j + ord('A')), i + 1)

print(ans)
print()


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
using namespace std;
int main(void){
    string input;
    cin >> input;
    sort(input.begin(), input.end());
    if(input[0] == input[1] && input[2] == input[3] && input[1] != input[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        if (N % 1000 == 0) System.out.println(0);
        else System.out.println(1000 - (N % 1000));
    }
}


Measured memory_bytes: 35652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using pii = pair<i32, i32>;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
using vpii = vector<pii>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;
using vvf80 = vector<vf80>;

template<typename T, typename S> bool amax(T &x, S y) { if (x < y) { x = y; return 1; } return 0; }
template<typename T, typename S> bool amin(T &x, S y) { if (y < x) { x = y; return 1; } return 0; }

struct Sushi {
  i64 x, v;
};

bool sort_sushi(Sushi a, Sushi b) {
  return a.x < b.x;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  i64 N, C;
  cin >> N >> C;
  vector<Sushi> sushi1(N), sushi2(N);
  vi64 x(N), v(N);
  rep(i, N) {
    cin >> x[i] >> v[i];
    sushi1[i].x = x[i];
    sushi1[i].v = v[i];
  }
  sushi2 = sushi1;
  sort(all(sushi1), sort_sushi);
  sort(all(sushi2), sort_sushi);
  reverse(all(sushi2));
  i64 ans = 0;
  vvi64 sums(2, vi64(N + 1));
  {
    i64 d = 0;
    rep(i, N) {
      sums[0][i + 1] = sums[0][i] + sushi1[i].v - (sushi1[i].x - d);
      d = sushi1[i].x;
      amax(ans, sums[0][i + 1]);
    }
    d = 0;
    rep(i, N) {
      sums[1][i + 1] = sums[1][i] + sushi2[i].v - (C - sushi2[i].x - d);
      d = C - sushi2[i].x;
      amax(ans, sums[1][i + 1]);
    }
  }
  vvi64 summax(2, vi64(N + 1));
  reps(i, N) {
    summax[0][i] = max(summax[0][i - 1], sums[0][i]);
    summax[1][i] = max(summax[1][i - 1], sums[1][i]);
  }
  rep(i, N) {
    i64 s = sums[0][i + 1] - sushi1[i].x + summax[1][N - i - 1];
    amax(ans, s);
  }
  rep(i, N) {
    i64 s = sums[1][i + 1] - (C - sushi2[i].x) + summax[0][N - i - 1];
    amax(ans, s);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8816
#include <iostream>
#include <stdio.h>
#include <vector>

typedef long long ll;

#define rep(i,n) for(int i = 0; i < n; i++)
#define debug(x) cerr << #x << ": " << x << "\n";

using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

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


Measured memory_bytes: 3624
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'

    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def query(self,top_num,front_num):

        self.save_data = [i for i in range(6)]
        for i in range(len(self.number)):
            self.save_data[i] = self.number[i]

        ret = -1;

        for i in range(len(self.order)):
            self.roll(self.order[i])
            if self.number[0] == top_num and self.number[1] == front_num:
                ret = self.number[2]
                break

        for i in range(len(self.number)):
            self.number[i] = self.save_data[i]

        return ret;




dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

num_query = int(input())
for loop in range(num_query):
    top_num,front_num = map(int,input().split())
    print("%d"%(dice.query(top_num, front_num)))


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
int n, c, f, i, j;
vector<int> a(200000), vis(1000001), spf(1000001, 2);
int main()
{
    ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    for (i = 3; i < 1e6; i += 2)
        spf[i] = i;
    for (i = 3; i < 998; i += 2)
        if (spf[i] == i)
            for (j = i * i; j < 1e6; j += i)
                if (spf[j] == j)
                    spf[j] = i;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> a[i], vis[a[i]]++;
    if (vis[1])
    {
        if (vis[1] == 1)
            cout << 1 << '\n';
        else
            cout << 0 << '\n';
        return 0;
    }
    for (i = 0; i < n; i++)
        if (vis[a[i]] == 1)
        {
            if (a[i] != spf[a[i]])
                for (j = spf[a[i]]; j * j <= a[i]; j++)
                    if (a[i] % j == 0 && (vis[a[i] / j] || vis[j]))
                    {
                        c++;
                        break;
                    }
        }
        else c++;
    cout << n - c << '\n';
}

Measured memory_bytes: 11816
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n, cnt = 0;
  cin >> n;
  map<string, int> memo;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    memo[s]++;
  }
  for(const auto& x: memo){
    int v = x.second;
    if(1 <= v){
      cnt++;
    }
  }
  
  cout << cnt <<endl;
  
}



Measured memory_bytes: 19116
#include <iostream>

using namespace std;

int main()
{
   int P,Q,R,a,b,c,d,f,g;
   cin>>P>>Q>>R;
  
   
       a=P+Q;
       b=R+Q;
       c=R+P;
       d=Q+R;
       f=R+P;
       g=Q+P;
       if(a<=b&&a<=c&&a<=d&&a<=f&&a<=g)
       cout<<a;
       else if(b<=a&&b<=c&&b<=d&&b<=f&&b<=g)
       cout<<b<<endl;
       else if(c<=a&&c<=b&&c<=d&&c<=f&&c<=g)
       cout<<c<<endl;
       else if(d<=a&&d<=b&&d<=c&&d<=f&&d<=g)
       cout<<d<<endl;
       else if(f<=a&&f<=b&&f<=d&&f<=c&&f<=g)
       cout<<f<<endl;
       else if(g<=a&&g<=c&&g<=b&&g<=f&&g<=d)
       cout<<g<<endl;
       
       else 
       cout<<"erore"<<endl;
       
       
       
       
       
   

    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

def test():

	EleList = deque()
	sublist = []
	output = []
	areas_from_left = list(sys.stdin.readline())
	sum = 0
	depth = 0

	for element in areas_from_left:

		if element == '\\':
			depth += 1
			EleList.append(element)

		elif element == '_':
			if EleList:
				EleList.append(element)

		elif element == '/':
			depth -= 1
			if EleList:
				for pop_count in range(len(EleList)):
				
					pop_ele = EleList.pop()
					if pop_ele == '\\' and EleList:
						for i in range(pop_count+2):
							EleList.append('_')
						break
				lake = pop_count + 1
				sum += lake

				if len(EleList) == 0:
					if len(sublist) == 0:
						output.append(lake)
					else:
						tmp = 0
						for i in sublist:
							tmp += i[0]
						output.append(tmp + lake)
						sublist.clear()
				else:
					
					if not sublist or sublist[len(sublist)-1][1] < depth:
						sublist_element = [0,0]
						sublist_element[0] = lake
						sublist_element[1] = depth
						sublist.append(sublist_element)
					
					else:

						sublist_element = [lake,depth]

						while True:
							
							if not sublist:
								break

							tmp = sublist.pop()
							if tmp[1] > depth:
								sublist_element[0] += tmp[0]
							else:
								sublist.append(tmp)
								break

						sublist.append(sublist_element)
				#print(f"{output}{sublist}")

	output_sublist = []
	for tmp in sublist:
		output_sublist.append(tmp[0])

	output = output + output_sublist
	length = len(output)

	print(sum)
	if length != 0:
		print(f"{length} ",end='')
	else:
		print(length)
	

	for i in range(length - 1):
		print(f"{output[i]} ",end='')
	if output:
		print(output[length-1])

if __name__ == "__main__":
	test()


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

int main() {
  int n;
  long long a,b,sum=0;
  cin>>n;
  vector <pair<long long, long long>> task;
  rep(i,n){
    cin>>a>>b;
    
    task.push_back(make_pair(b,a));
  }
  
  sort(task.begin(),task.end());
  
  rep(i,n){
    sum+=task.at(i).second;
    
    if(sum>task.at(i).first){
      cout<<"No"<<endl;
      break;
    }
    if(i==n-1&&sum<=task.at(n-1).first)
      cout<<"Yes"<<endl;
  
  }
  
  
}

Measured memory_bytes: 6512
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int main(){
	int h, w;
	char box[101][101];
	cin >> h >> w;

	for (int i = 0; i < h; i++){
		cin >> box[i];
	}
	for (int i = 0; i < h; i++){
		int a = -1;
		for (int j = 0; j < w; j++){
			if (box[i][j] == 'c') a = j;
			int ans = -1;
			if (a != - 1) ans = j - a;
			printf("%d%c", ans, j == w - 1 ? '\n':' ');
		}

	}

	return 0;
}

Measured memory_bytes: 3172
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        Node nodes[] = new Node[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = new Node();
        }

        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            nodes[a - 1].childs.add(new Edge(b - 1, 1));
            nodes[b - 1].childs.add(new Edge(a - 1, 1));
        }

        long cost1[] = dijkstra(0, n, nodes);
        long costn[] = dijkstra(n - 1, n, nodes);

        int fennec = 1;
        int snuke = 1;
        for (int i = 1; i < n - 1; i++) {
            if (cost1[i] <= costn[i]) {
                fennec++;
            } else {
                snuke++;
            }
        }

        System.out.println(fennec > snuke ? "Fennec" : "Snuke");
    }

    private class Edge {
        int to;
        long cost;

        public Edge(int to, long cost) {
            this.to = to;
            this.cost = cost;
        }
    }

    private class Node {
        Long minCost = Long.MAX_VALUE;
        List<Edge> childs = new ArrayList<>();
        boolean isFix = false;

        public Node copy() {
            Node node = new Node();
            node.minCost = this.minCost;
            node.childs.addAll(this.childs);
            node.isFix = this.isFix;
            return node;
        }
    }

    public long[] dijkstra(int start, int n, Node data[]) {
        Node nodes[] = new Node[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = data[i].copy();
        }
        nodes[start].minCost = 0L;

        Queue<Node> queue = new PriorityQueue<>((n1, n2) -> Long.compare(n1.minCost, n2.minCost));
        queue.add(nodes[start]);
        while (!queue.isEmpty()) {
            Node src = queue.poll();
            src.isFix = true;
            for (Edge e : src.childs) {
                Node dst = nodes[e.to];
                if (!dst.isFix) {
                    dst.minCost = Math.min(dst.minCost, src.minCost + e.cost);
                    queue.add(dst);
                }
            }
        }

        long res[] = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nodes[i].minCost;
        }
        return res;
    }

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


Measured memory_bytes: 120144
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <queue>
#define PIE 3.14159265358979
#define N_MAX 305
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int n;
int a[N_MAX];
int dp[N_MAX][N_MAX];

int main(){
    while(cin>>n,n!=0){
        rep(i,n){
            cin>>a[i];
        }
        rep(i,n+1){
            rep(j,n+1){
                dp[i][j]=0;
            }
        }
        if(n<2){
            cout<<0<<endl;
            continue;
        }
        int num = 2;
        while(num<=n){
            int left = 0;
            while(left+num<=n){
                if(dp[left+1][left+num-1]==num-2&&abs(a[left]-a[left+num-1])<=1)
                    dp[left][left+num]=num;
                int div=1;
                while(div<num){
                    dp[left][left+num]=max(dp[left][left+num],dp[left][left+div]+dp[left+div][left+num]);
                    div++;
                }
                left++;
            }
            num++;
        }
        int ans = 0;
        rep(i,n+1){
            rep(j,n+1){
                ans=max(ans,dp[i][j]);
            }
        }
        cout<<ans<<endl;
    }
    
}

Measured memory_bytes: 3416
#include<cstdio>

const int MAX_N = 51;
char S[MAX_N];
int main(void){
    int N=0;
    scanf("%d",&N);
    scanf("%s",S);
    int count = 0;
    for(int i=0;i<=49;i++){
        if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'){
            count ++;
        }
    }
            printf("%d",count);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int WHITE = 0; // V-T
static const int BLACK = 1; // T

int n, M[MAX][MAX];

int prim()
{
    int u, minv;
    int d[MAX]; // d[u]: Tに属する頂点とV-Tに属するuから頂点を繋ぐ辺の中で重みが最小の辺の重みを記録
    int p[MAX]; // p[u]: MSTにおける頂点uの親を記録
    int color[MAX]; // 訪問状態を記録

    // initialize
    rep(i, n)
    {
        d[i] = INF;
        p[i] = -1;
        color[i] = WHITE;
    }
    d[0] = 0;

    while (1) {
        minv = INF;
        u = -1;
        rep(i, n)
        {
            // uは最小の経路がある かつ uへは未完了
            if (d[i] < minv && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }

        // 更新できる辺がないときに終了
        if (u == -1) {
            break;
        }

        color[u] = BLACK;
        rep(v, n)
        {
            // vは未完了 かつ u->vに道はある
            if (color[v] != BLACK && M[u][v] != INF) {
                // vへの経路を最小に更新
                if (M[u][v] < d[v]) {
                    d[v] = M[u][v];
                    p[v] = u;
                }
            }
        }
    }

    int sum = 0;
    rep(i, n)
    {
        if (p[i] != -1) {
            sum += M[i][p[i]];
        }
    }
    return sum;
}

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

    cin >> n;
    rep(i, n)
    {
        rep(j, n)
        {
            int e;
            cin >> e;
            M[i][j] = (e == -1) ? INF : e;
        }
    }

    cout << prim() << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A (N);
    for(int i = 0; i < N; i++) cin >> A[i];
    //
    int maxTravel = 0;
    int subTravel = 0;
    for(int i = N-1; 0 < i; --i) {
        if( A[i-1] >= A[i] ) subTravel++;
        else {
            maxTravel = max(subTravel, maxTravel);
            subTravel = 0;
        }
    }
    maxTravel = max(subTravel, maxTravel);
    cout << maxTravel;
}


Measured memory_bytes: 768
s = input()
s_list = list(s)

yes_count = 0
for i in range(0, len(s_list)):
    count = s_list.count(s_list[i])
    if count == 2:
        yes_count += 1
    
if yes_count == 4:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
def main():
    matrix = []
    for _ in range(2):
        matrix.append(list(input()))

    if matrix[0][0] == matrix[1][2] \
        and matrix[0][1] == matrix[1][1] \
        and matrix[0][2] == matrix[1][0]:
        print("YES")
    else:
        print("NO")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"sync"
)

func main() {
	var n, p int
	fmt.Scan(&n)
	fmt.Scan(&p)

	var max int

	reader := bufio.NewScanner(os.Stdin)

	dan := make([][]string, n, n)
	l, r, d, t := [2000][2000]int{}, [2000][2000]int{}, [2000][2000]int{}, [2000][2000]int{}
	for i := 0; i < n; i++ {
		reader.Scan()
		dan[i] = strings.Split(reader.Text(), "")
	}

	wg := &sync.WaitGroup{}

	wg.Add(1)
	go func() {
		for i := 0; i < n; i++ {
			for j := 0; j < p; j++ {
				if dan[i][j] == "#" {
					d[i][j] = 0
					l[i][j] = 0
				} else {
					if i == 0 {
						d[i][j] = 1
					} else {
						d[i][j] = d[i-1][j] + 1
					}
					if j == 0 {
						l[i][j] = 1
					} else {
						l[i][j] = l[i][j-1] + 1
					}
				}
			}
		}
		wg.Done()
	}()

	wg.Add(1)
	go func() {
		nn := n - 1
		pp := p - 1
		for i := nn; i >= 0; i-- {
			for j := pp; j >= 0; j-- {
				if dan[i][j] == "#" {
					r[i][j] = 0
					t[i][j] = 0
				} else {
					if j == pp {
						r[i][j] = 1
					} else {
						r[i][j] = r[i][j+1] + 1
					}
					if i == nn {
						t[i][j] = 1
					} else {
						t[i][j] = t[i+1][j] + 1
					}
				}
			}
		}
		wg.Done()
	}()

	wg.Wait()
	for i := 0; i < n; i++ {
		for j := 0; j < p; j++ {
			if dan[i][j] != "#" {
				v := l[i][j] + r[i][j] + t[i][j] + d[i][j] - 3
				if v > max {
					max = v
				}
			}
		}
	}

	fmt.Printf("%#v\n", max)
}


Measured memory_bytes: 327680
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N=ii()
    ans = [0]*(N+1)
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                n = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if n<=N:
                    ans[n] += 1
    print(*ans[1:])




main()



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

int main(){
  int N;
  cin >> N;
  int a[N];
  int ans=0;
  for(int i=0; i<N; i++){
   cin >> a[i];
   for(int j=0; j<31; j++){
     if(a[i]%2==0){
       a[i]=a[i]/2;
       ans++;
     }
   }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sentence = sys.stdin.readlines()
a=""
for s in sentence:
  a += s.strip("\n")

a = a.lower()

data = dict()  
alpha = "abcdefghijklmnopqrstuvwxyz"
for key in alpha:
  data[key] = 0

for key in a:
  if key in alpha:
    data[key] += 1

for key in alpha:
  print("{} : {}".format(key,data[key]))


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

#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

using namespace std;


int main()
{
    //fastio;
    ll n;
    cin >> n;
    ll arr[n][3], dp[n][3];
    for (ll i = 0; i < n; i++)
    {
        for (ll j = 0; j < 3; j++)
            cin >> arr[i][j];
    }
    dp[n - 1][0] = arr[n - 1][0]; dp[n - 1][1] = arr[n - 1][1]; dp[n - 1][2] = arr[n - 1][2];
    for (ll i = n - 2; i >= 0; i--)
    {
        for (ll j = 0; j < 3; j++)
        {
            ll temp = 0;
            if (j == 0) temp = max(dp[i + 1][1], dp[i + 1][2]);
            else if (j == 1) temp = max(dp[i + 1][0], dp[i + 1][2]);
            else temp = max(dp[i + 1][1], dp[i + 1][0]);
            dp[i][j] = arr[i][j] + temp;
        }
    }
    ll m = dp[0][1];
    for (auto x : dp[0])
        if (x > m) m = x;
    cout << m;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(2e4+20)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define valsum first
#define wsum second
bool comp(tuple<ll,ll,ll> a,tuple<ll,ll,ll> b)
{
	return (get<0>(a)+get<1>(a))<(get<0>(b)+get<1>(b));
}
vll dp(MAXN,0);
int main()
{
	fastio;
	int n;cin>>n;
	vector< tuple<ll,ll,ll> >v(n+1);
	for(int i=1;i<=n;i++)
	{
		ll a,b,c;cin>>a>>b>>c;
		v[i]=make_tuple(a,b,c);
	}
	sort(v.begin()+1,v.end(),comp);//exchange arguments
	//dp[i]-max score with total weight i so far considering n items
	//when considering n+1 th item see if all weights <= its strength 
	//can increase the dp[weights + curr_weight] from its previous value
	for(int i=1;i<=n;i++)
	{
		for(ll weight=get<1>(v[i]);weight>=0;weight--)
		{
			if(weight+get<0>(v[i])<MAXN)
			dp[weight+get<0>(v[i])]=max(dp[weight+get<0>(v[i])],dp[weight]+get<2>(v[i]));
		}
	}
	 ll res=0;
	 for(int i=0;i<MAXN;i++)
	 {
	 	res=max(res,dp[i]);
	 }
	 cout<<res<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <vector>
#include <string>
using namespace std;

int main() {
	int n; cin >> n;
	vector<string> a(n);
	map<string, int> b;

	for(int i = 0; i < n; i++) {
		string inp; cin >> inp;
		a[i] = inp;
	}
	
	for(int i = 0; i < n; i++) {
		auto itr = b.find(a[i]);
		if(itr != b.end()) {
			cout << "No" << endl;
			return 0;
		} else {
			b[a[i]] = 1;
		}
	}

	for(int i = 0; i < n - 1; i++) {
		int nLast = a[i].size();
		if(a[i][nLast-1] != a[i+1][0]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}


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

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,lessl<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define double long double

#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()

#define ff first
#define ss second
#define mp make_pair

#define pb push_back
#define endl "\n"

#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)

#define bp __builtin_popcountll
#define inf 1e18

const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	int x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	int ans=inf;
	
		int pp=x%d;
		int move=(x-pp)/d;
		if(move<=k)
		{
			if(move%2==k%2)
			ans=pp;
			else if(move!=k)
			ans=min(ans,abs(pp-d));
		}
		else
		{
			ans=x-k*d;
		}
	
	
	cout<<ans<<endl;
	
}



signed main()
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


Measured memory_bytes: 3648
import bisect
N, K = [int(i) for i in input().split()]
xs = [int(i) for i in input().split()]

ans = []
bisect.insort_left(xs, 0)
for l in range(len(xs)):
    if l+K < len(xs):
        xl = xs[l]
        xr = xs[l+K]
    elif l-K > -1:
        xl = xs[l-K]
        xr = xs[l]
    else:
        continue

    tmp1 = abs(xl) + abs(xr-xl)
    tmp2 = abs(xr) + abs(xr-xl)
    ans.append(min(tmp1, tmp2))

print(min(ans))


Measured memory_bytes: 20316
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();
    if s <= w {
        println!("unsafe",);
    } else {
        println!("safe",);
    }
}


Measured memory_bytes: 2092
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

$map = array(array());
fscanf(STDIN, "%d", $R);
fscanf(STDIN, "%d", $G);

echo $G * 2 - $R;
echo PHP_EOL;

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

int n, a, b;

int main()
{
	std::cin >> n >> a >> b; if (a > b) return puts("0"), 0;
	if (n == 1) return std::cout << (a == b) << std::endl, 0;
	return std::cout << 1ll * (n - 2) * (b - a) + 1 << std::endl, 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int count = 0;
  long long int sum = 0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    if(A.at(i)<0){
      A.at(i)*=-1;
      count++;
    }
    sum+=A[i];
  }
  sort(A.begin(),A.end());
  if(count%2==0){
    cout << sum << endl;
  }else{
    cout << sum-2*A.at(0) << endl;
  }
}

Measured memory_bytes: 640
#! /usr/bin/env ruby

input = STDIN.read.split("\n").map{|l| l.split(" ").map{|i| i.to_i}}
N = input.shift[0]

items = input.map{|r| r.sort}
cnt = 0
for middle in items[1]
  tops = items[0].bsearch_index{|x| x >= middle }
  if tops == nil
    tops = N
  end
  bottoms = items[2].bsearch_index{|x| x > middle }
  if bottoms == nil
    bottoms = N
  end
  bottoms = N - bottoms
  cnt = cnt + (tops * bottoms)
end

puts cnt


Measured memory_bytes: 28656
N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())

max_index = A.index(max(A))
A.sort(reverse=True)

for i in range(N):
    if i==max_index:
        print(A[1])
    else:
        print(A[0])

Measured memory_bytes: 57048
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	// Code for B - Maximum Sum
	A := make([]int, 3)
	var K int
	fmt.Scanf("%d %d %d", &A[0], &A[1], &A[2])
	fmt.Scanf("%d", &K)

	sort.Sort(sort.IntSlice(A))
	fmt.Println(A[0] + A[1] + int(math.Pow(2, float64(K)))*A[2])
}


Measured memory_bytes: 1832
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        int n = Integer.valueOf(mylist.get(0));
        String arr_temp[] = mylist.get(1).split(" ");
        Integer arr01[] = new Integer[n + 2];

        int mysum = 0;

        arr01[0] = 0;
        for (int i = 1; i <= n; i++) {
            arr01[i] = Integer.valueOf(arr_temp[i - 1]);
        }
        arr01[n + 1] = 0;

        for (int j = 0; j < n + 1; j++) {
            int temp1 = arr01[j];
            int temp2 = arr01[j + 1];
            mysum += Math.abs(temp1 - temp2);
        }
        for (int k = 0; k < n; k++) {

            int temp1 = arr01[k];
            int temp2 = arr01[k + 1];
            int temp3 = arr01[k + 2];

            //            System.out.println(temp1 + " " + temp2 + " " + temp3);

            int minus = Math.abs(temp1 - temp2);
            minus += Math.abs(temp2 - temp3);

            int plus = Math.abs(temp1 - temp3);
            System.out.println(mysum - minus + plus);

        }

    }

}


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

int main() {
    string N;
    int onazi;
    cin >> N;
    onazi = 0;

    if(N.at(0)==N.at(1)&&N.at(1)==N.at(2)){
        onazi=1;
    }

    if(N.at(1)==N.at(2) &&N.at(2)==N.at(3)){
        onazi=1;
    }

    if(onazi==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main()
{
  int X, A, B;

  cin >> X >> A >> B;

  if (X < B - A) {
    cout << "dangerous" << endl;
  } else if (0 >= B - A) {
    cout << "delicious" << endl;
  } else {
    cout << "safe" << endl;
  }
}


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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int count = 0;
	int countf = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'a') {
			if (count < a + b) {
				cout << "Yes" << endl;
				count++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (s[i] == 'b') {
			if (count < a + b && countf < b) {
				cout << "Yes" << endl;
				countf++;
				count++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll h,w;
    cin>>h>>w;
    char a[h+1][w+1];
    ll dp[h+1][w+1];

    for (int i = 0; i < h+1; ++i)
    {
        for (int j = 0; j < w+1; ++j)
        {
            dp[i][j]=0;
        }
    }

    for (int i = 1; i<=h; ++i)
    {
        for (int j = 1; j<=w; ++j)
        {
            cin>>a[i][j];
            if(a[i][j]=='#'){
                dp[i][j]=-1;
            }
        }
    }

    dp[1][1]=0;
    for (int i = 2; i < h+1; ++i)
    {
        if(dp[i][1]==0){
            dp[i][1]=1;
        }
        else{
            break;
        }
    }
    for (int i = 2; i < w+1; ++i)
    {
        if(dp[1][i]==0){
            dp[1][i]=1;
        }
        else{
            break;
        }
    }

    for (int i = 2; i < h+1; ++i)
    {
        for (int j = 2; j < w+1; ++j)
        {
            if(dp[i][j]!=-1){
                if(dp[i-1][j]!=-1){
                    dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
                }
                if(dp[i][j-1]!=-1){
                    dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
                }                
            }
        }
    }

    cout<<dp[h][w];

    return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std ;

typedef pair<int,int> P ;
#define F first
#define S second

vector<P> VC ;
map<int,int> MP;

int main(){
	
	int N,M;
	char p;
	
	while( cin >> N >> p >> M ){
		if( !N && !M ) break ;
		VC.push_back( P(N,M) );
	}
	
	for( int i=0 ; i<VC.size() ; i++ ){
		for( int j=i+1 ; j<VC.size() ; j++ ){
			if( VC[i].S < VC[j].S ) swap(VC[i],VC[j]);
			else if( (VC[i].S == VC[j].S) && (VC[i].F > VC[j].F) ) swap(VC[i],VC[j]);
		}
	}
	
	int cnt = 0;
	int pnt = -1;
	for( int i=0 ; i<VC.size() ; i++ ){
		if( pnt != VC[i].S ){
			pnt = VC[i].S;
			cnt++;
		}
		MP[VC[i].F] = cnt;
	}
	
	while( cin >> N ){
		if( cin.eof() ) break ;
		cout << MP[N] << endl ;
	}
	
	return 0 ;
}

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

int main() {
    long long l, r; cin >> l >> r;
    long long ans=2018;
    for(long long  i=l; i<min(r, l+2019); i++){
        for(long long j=i+1; j<min(r+1, i+2020); j++){
            ans=min(ans, (i*j)%2019);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include"atcoder/all"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
//using namespace atcoder;
typedef long long ll;
const ll mod = 1000000007;
ll modpow(ll x,ll y){
  ll ans = 1;
  while(y){
    if(y&1) ans = ans*x%mod;
    x = x*x%mod;
    y >>= 1;
  }
  return ans;
}
int main(){
  ll N,K,i,j,ans = 0;scanf("%lld%lld",&N,&K);
  ll cnt[K+1] = {};
  for(i=K;i>=1;i--){
    cnt[i] = modpow(K/i,N);
    for(j=i+i;j<=K;j+=i){
      cnt[i] -= cnt[j];
      if(cnt[i] < 0) cnt[i] += mod;
    }
    ans = (ans+cnt[i]*i)%mod;
  }
  printf("%lld\n",ans);
}

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


int main(){
int n;
cin >> n;
vector<int>v(n);
rep(i,n) 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;


//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define rsrt(s) sort(s.rbegin(),s.rend())
#define all(x) x.begin(),x.end()

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...



int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    ll n;
    cin >> n;
    vector <ll> v(n);
    for(ll i=0;i<n;i++)
    {
        ll x;
        cin >> x;
        v[x-1]=i+1;
    }
    for(auto i : v) cout << i << ' ';
    cout << endl;

    //---------------------------------
    
    return 0;
}


Measured memory_bytes: 3956
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<stdlib.h>
#include<stack>
#include<set>
#include<string.h>
#include<map>
#include<queue>
#include<vector>
#define pb push_back
#define eb emplace_back
#define ins insert 
#define mp make_pair
#define ll long long 
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define inf 1000000000000000000
#define M 1000000007
using namespace std;
void solve(){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	bool dp[k+1];
	memset(dp,false,sizeof(dp));
	for (int i = 0; i <=k; ++i)
	{
		for (int j= 0; j<n; ++j)
		{
			if(a[j]<=i && !dp[i-a[j]])
				dp[i]=true;
		}
	}
	cout<<(dp[k]? "First" : "Second");
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 384
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
    fre("");
    ACCELERATE;
    
    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++) {
    	for(int j = 1; j <= 9; j++) {
    		if(i * j == n) return cout << "Yes", 0;
		}
	}
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
import bisect

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for x in b:
    ans+=bisect.bisect_left(a,x)*(n-bisect.bisect_right(c,x))
print(ans)

Measured memory_bytes: 23360
// B.

#include <iostream>
#include <sstream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int n, m, c, ans = 0;
	cin >> n >> m >> c;
	vector<int> b(m);
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	for (int i = 0; i < n; ++i) {
		int a, sum = c;
		for (int j = 0; j < m; ++j) {
			cin >> a;
			sum += a * b[j];
		}
		ans += sum > 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	//Problema B
	vector <int> v(5);
	for(int i=0;i<5;i++)
	{
		cin>>v[i];
		if(v[i]!=i+1)
		{
			cout<<i+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define LL long long

using namespace std;
const int N=1e5+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
LL n,a[N],z[N],f[N][3];
char cc[2];

int main()
{
	n=rd(),z[1]=1,a[1]=rd();
	for(int i=2;i<=n;++i) scanf("%s",cc),z[i]=cc[0]=='-'?-1:1,a[i]=rd();
	memset(f,-0x3f3f3f,sizeof(f));
	f[1][0]=a[1];
	for(int i=2;i<=n;++i)
	{
		f[i][0]=max(f[i][0],f[i-1][0]+z[i]*a[i]);
		f[i][0]=max(f[i][0],f[i-1][1]-z[i]*a[i]);
		f[i][1]=max(f[i][1],f[i-1][1]-z[i]*a[i]);
		f[i][0]=max(f[i][0],f[i-1][2]+z[i]*a[i]);
		f[i][1]=max(f[i][1],f[i-1][2]+z[i]*a[i]);
		f[i][2]=max(f[i][2],f[i-1][2]+z[i]*a[i]);
		if(z[i]<0)
		{
			f[i][1]=max(f[i][1],f[i-1][0]+z[i]*a[i]);
			f[i][2]=max(f[i][2],f[i-1][1]-z[i]*a[i]);
		}
	}
	printf("%lld\n",f[n][0]);
    return 0;
}



Measured memory_bytes: 4096
#include <stdio.h>
#define MAX 100000

int parent(int i ) {return i /2;}
int left(int i) {return 2*i;}
int right(int i){return 2*i+1;}

int main()
{
	int H , i , A[MAX+1];
	
	scanf("%d",&H);
	
	for( i = 1; i <= H; i++)
	{
		scanf("%d",&A[i]);
	}
	for( i = 1; i <= H; i++)
	{
		printf("node %d: key = %d, ",i,A[i]);
		if(parent(i) >= 1) printf("parent key = %d, ",A[parent(i)]);
		if(left(i) <= H) printf("left key = %d, ",A[left(i)]);
		if(right(i) <= H) printf("right key = %d, ",A[right(i)]);
		printf("\n");
	}
	return 0;
}



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

int main(){
	long long a,b;
	while(~scanf("%lld %lld",&a,&b)){
		if((a+b)%2==0){
			printf("%lld\n",(a+b)/2);
		}
		else printf("IMPOSSIBLE\n");		
	}
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int M = N;
  int i = 0;
  int sum = 0;
  
  while (M >= 1) {
    sum += (M - (M / 10) * 10);
    M = M / 10;
  }
  
  if (N % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3588