akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	int a[n];
	rep(i,0,n) cin >> a[i];
	cout << (n-2)/(k-1) +1 << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
vector<P> pa;
vector<P> pb;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) {
    int a, b;
    cin >> a >> b;
    pa.push_back(make_pair(a, b));
  }

  REP(i, n) {
    int a, b;
    cin >> a >> b;
    pb.push_back(make_pair(b, a));
  }

  sort(pa.begin(), pa.end());
  sort(pb.begin(), pb.end());

  int ans = 0;
  REP(i, n) {
    int bx = pb[i].first;
    int by = pb[i].second;

    int pos = -1;
    REP(j, pa.size()) {
      int ax = pa[j].second;
      int ay = pa[j].first;
      if(ay >= by) break;
      if(ax < bx) pos = j;
    }

    if(pos != -1){
      ans++;
      pa.erase(pa.begin() + pos);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
N,Q = map(int,input().split())
S=input()
ans_l = [0]*N
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        ans_l[i+1] = ans_l[i] + 1
    else:
        ans_l[i+1] = ans_l[i]
for _ in range(Q):
    l, r = map(int, input().split())
    ans = ans_l[r-1] - ans_l[l-1]
    print(ans)

Measured memory_bytes: 6188
#include<stdio.h>
//#include<stdlib.h>
//#include<time.h>

struct staff_data{
	int num,price,volume;
	unsigned long long int total;
};

int main(void){

	int n,i,j,hantei;
	int num,price,volume;
	struct staff_data dt[4000]={0};
	
	/*srand((unsigned)time(NULL));*/
	
	while(scanf("%d",&n)!=0){
	
		if(n==0){
			break;
		}
		
		for(i=0;i<4000;i++){
			dt[i].num=0;
			dt[i].price=0;
			dt[i].total=0;
			dt[i].volume=0;
		}
		
		for(i=0;i<n;i++){
			
			scanf("%d %d %d",&num,&price,&volume);
			/*num=rand()%4000;
			price=rand()%1000000;
			volume=rand()%100000;
			printf("%5d %5d %5d ||",num,price,volume);*/
			
			for(j=0;j<=i;j++){
				
				if(dt[j].num==num || dt[j].num==0){
					
					dt[j].num=num;
					dt[j].total=(price)*(volume)+dt[j].total;
					/*printf("num==%5d total==%d\n",dt[j].num,dt[j].total);*/
					break;
				}
				
			}
		}

		hantei=0;

		for(j=0;j<n;j++){
		
			if(dt[j].total>=1000000){
				printf("%d\n",dt[j].num);
				hantei=1;
			}
		}
	
		if(hantei==0){
			printf("NA\n");
		}

	}

	return 0;
}

	

Measured memory_bytes: 0
#include <bits/stdc++.h>
#if 1
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define stoi stoll
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define INF MAX/2
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int (i)=0; (i) < (n); ++(i))
#define FOR(i,a,b) for (int (i)=(a); (i) < (b); ++(i))
using namespace std;

int pow(int x, int n) {int res=1; while(n){if(n&1)res*=x;x*=x;n>>=1;} return res;}
int get_gcd(int a, int b) {while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b) {return a * b / get_gcd(a, b);}
bool chmin(int &a, int b) {if(a>b){a=b; return true;} else return false;}
bool chmax(int &a, int b) {if(a<b){a=b; return true;} else return false;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//-------------------------テンプレここまで-------------------------//

signed main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int N;
  cin >> N;

  vector<pair<double,double>> town(N);
  REP(i,N) {
    cin >> town[i].fi >> town[i].se;
  }

  vector<int> v(N);
  REP(i, N) {
    v[i] = i;
  }

  double sum = 0;
  double count = 0;
  do {
    count++;
    REP(i,N-1) {
      double dx = town[v[i+1]].fi - town[v[i]].fi;
      double dy = town[v[i+1]].se - town[v[i]].se;
      sum += sqrt(dx*dx + dy*dy);
    }
  } while(next_permutation(ALL(v)));

  cout << setprecision(16) << sum/count << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def yes():
    print("Yes")  # type: str


import heapq
from collections import defaultdict


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)

    def add_edge(self, s, t, w=1):
        self.E[s].append((t, w))
        self.E[t].append((s, w))


def shortestPath(g: Graph, s: int):
    # 返り値 (dist, prev)
    # dist: 始点からの距離が格納されたリスト
    # prev: 始点から最短経路で移動する場合、各頂点に至る前の頂点のリスト
    dist = [INF]*g.N
    dist[s] = 0

    prev = [None]*g.N
    Q = []
    heapq.heappush(Q, (dist[s], s))

    while len(Q) > 0:
        _, u = heapq.heappop(Q)
        for v, w in g.E[u]:
            if dist[v] > dist[u] + w:
                dist[v] = dist[u] + w
                prev[v] = u
                heapq.heappush(Q, (dist[v], v))
    return dist, prev


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):

    g = Graph(N)
    for a, b in zip(A, B):
        g.add_edge(a-1, b-1)

    dist, prev = shortestPath(g, 0)
    if dist == INF:
        print("No")
        return
    print("Yes")
    for i in range(1, N):
        print(prev[i]+1)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)


if __name__ == '__main__':
    main()


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    rep(i, 5) {
        ll temp;
        cin >> temp;
        if(temp == 0) cout << i + 1 << endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;

int main(){
    string s; cin >> s;
    vector<string> ss;
    ss = {"Sunny", "Cloudy", "Rainy", "Sunny"};
    rep(i, 3){
        if(ss[i] == s) cout << ss[i+1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int n, k; std::cin >> n >> k;
    int s = 0;
    for (int i = 0; i < n; i++) {
        int x; std::cin >> x;
        s += std::min(x, k -x);
    }
    std::cout << 2 * s << std::endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    let B: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    let C: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let mut ans = 0;
    let mut p = 1000;
    for &a in &A {
        let i = a - 1;
        ans += B[i];
        if p + 1 == i {
            ans += C[i - 1];
        }
        p = i;
    }

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  a--; b--; c--; d--;
  
  string s;
  cin >> s;
  
  if (c < d){
    int ok = 1;
    for (int i = a; i < c; i++){
      if (s[i] == '#' && s[i + 1] == '#')
        ok = 0;
    }
    for (int i = b; i < d; i++){
      if (s[i] == '#' && s[i + 1] == '#')
        ok = 0;
    }
    if (ok)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  else {
    int ok = 1;
    for (int i = a; i < c; i++){
      if (s[i] == '#' && s[i + 1] == '#')
        ok = 0;
    }
    for (int i = b; i < d; i++){
      if (s[i] == '#' && s[i + 1] == '#')
        ok = 0;
    }
    if (ok){
      ok = 0;
      for (int i = b - 1; i < d; i++){
        if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
          ok = 1;
      }
      if(ok)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
    }
    else 
      cout << "No" << endl;
  }

  return 0;
}


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

#define fast ios_base::sync_with_stdio(0)
#define sf scanf
#define pf printf
#define outn(x , y) pf(x, y);

typedef long long LL;
typedef vector<int>vii;
typedef map<string, int>mpsi;
typedef map<int, int>mpii;

const int high = 125;

int ar[high];

int main()
{
    fast;
    //outn("%s" , "hello");
    string s;
    cin >> s;
    sort(s.begin() , s.end());
    int len = s.length() , i;

    bool fl=false;

    for(i=0; i<len; i++)
    {
        int tmp = s[i] + '\0';
        //utn("%d", tmp);
        ar[tmp] = 1;
    }

    vector<char>vc;

    for(i=97; i<=122; i++)
    {
        if(!ar[i])
        {
            char ch = i - '\0';

            vc.push_back(ch);
            break;
        }
    }

    if(vc.size() == 0) cout << "None\n";
    else
    {
        for(i=0; i<vc.size(); i++)
        {
            cout << vc[i] << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string n;
	long long i,l,j,k,s=0;
	cin>>n;
	l=n.length();
	for(i=0;i<l;i++){
		s+=(n[i]-48);
	}
//	cout<<s<<endl;
	if(s%9==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;

int head=1,tail=0,MAX=2000000;
int a[2000000];

void insert(int x){
    head = (head+MAX-1)%MAX;
    a[head] = x;
}
void Delete(int x){
    if(head <= tail){
    for(int i=head;i<=tail;i++){
        if(a[i] == x){
            if(i != head){
            for(int j=i;j>head;j--){
                a[j] = a[j-1];
            }
            a[head] = -1;
            head = (head+1)%MAX;
            }
            else{
                a[head] = -1;
                head = (head+1)%MAX;
            }
            i=tail;
        }
    }
    }
    else{
        for(int i=head;i<=tail+MAX;i++){
            if(a[i%MAX] == x){
                if(i != head){
                for(int j=i;j>head;j--){
                    a[j%MAX] = a[(j-1)%MAX];
                }
                a[head] = -1;
                head = (head+1)%MAX;
                }
                else{
                    a[head] = -1;
                    head = (head+1)%MAX;
                }
                i=tail + MAX;
            }
        }
    }
}
void DeleteFirst(){
    a[head] = -1;
    head = (head+1)%MAX;
}
void DeleteLast(){
    a[tail] = -1;
    tail = (tail+MAX-1)%MAX;
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        if(s == "insert"){
            int x;
            scanf("%d", &x);
            insert(x);
        }
        if(s == "delete"){
            int x;
            scanf("%d", &x);
            Delete(x);
        }
        if(s == "deleteFirst"){
            DeleteFirst();
        }
        if(s == "deleteLast"){
            DeleteLast();
        }
    }
    cout << a[head];
    if(head < tail){
    for(int i=head+1;i<=tail;i++){
        cout << ' ' << a[i];
    }
    cout << endl;
    }
    else if(head > tail){
        for(int i=head+1;i<=tail+MAX;i++){
            cout << ' ' << a[i%MAX];
        }
        cout << endl;
    }
    else cout << endl;
}


Measured memory_bytes: 7128
// header {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
#define INF         1000000005

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    ll n, x;cin >> n >> x;
    vector<ll> a(n);
    ll ans = 0;
    for(auto &aa : a){
        cin >> aa;
        if(aa > x){
            ans += aa - x;
            aa = x;
        }
    }
    for(int i=0;i<n-1;i++){
        if(a[i] + a[i+1] > x){
            ans += a[i] + a[i+1] - x;
            a[i+1] -= a[i] + a[i+1] - x;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

public class Hello
{
    public static void Main()
    {
        var d = new Dictionary<int, long>();
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 2; i <= n; i++)
        {
            foreach (var x in PrimeFactors(i))
                if (d.ContainsKey(x)) d[x]++;
                else d[x] = 1;
        }
        var res = 1L;
        foreach (var x in d)
        {
            res *= x.Value + 1;
            res %= 1000000007;
        }
        Console.WriteLine(res);
    }
    public static IEnumerable<int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
        while (i * i <= n)
        {
            if (tmp % i == 0) { tmp /= i; yield return i; }
            else i++;
        }
        if (tmp != 1) yield return tmp;
    }
}


Measured memory_bytes: 13152
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  int V[N];
  REP(i,N)cin>>V[i];
  int ans=0;
  REP(k,K){
    int M=K-k;
    if(M>N)M=N;
    REP(m,M+1){
      vector<int> v;
      REP(i,m)v.push_back(V[i]);
      REP(i,M-m)v.push_back(V[N-i-1]);
      sort(ALL(v));
      int temp=0;
      int suteru=0;
      REP(i,M){
        if(suteru<k and v[i]<0){
          suteru++;
          continue;
        }
        temp+=v[i];
      }
      // REP(i,M)cerr<<v[i]<<" ";
      // cerr<<" "<<k<<endl;
      ans=max(ans,temp);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<iterator>
#include<iomanip>
#include<string>
using namespace std;

int main()
{
    long long int a;
    float b;
    cin>>a>>b;
    int c=100.05*b;
    cout<<fixed<<setprecision(0)<<a*c/100;
    return 0;
}

Measured memory_bytes: 3696
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, a;
  scanf("%lld", &n);
  ll cnt[n];
  for(i = 0; i < n; ++i) cnt[i] = 0;
  for(i = 0; i < n; ++i) scanf("%lld", &a), cnt[a]++;
  for(i = n - 1; !cnt[i]; --i);
  a = i;
  for(i = 0; i < (a + 1) / 2; ++i) if(cnt[i]) {
    printf("Impossible");
    return 0;
  }
  if(a & 1) {
    if(cnt[i] != 2) {
      printf("Impossible");
      return 0;
    }
  } else if(cnt[i] != 1) {
    printf("Impossible");
    return 0;
  }
  for(++i; i <= a; ++i) if(cnt[i] < 2) {
    printf("Impossible");
    return 0;
  }
  printf("Possible");
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();
        if (e - a <= k) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}


Measured memory_bytes: 23764
import java.util.*;

public class Main{

    int n;
    String[] a,b;
    String from,to;

    class E{
        String s;
        int cost;
        E(String s, int cost){
            this.s = s;
            this.cost = cost;
        }
    }

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt();
            if(n==0) break;

            a = new String[n];
            b = new String[n];
            for(int i=0; i<n; i++){
                a[i] = sc.next();
                b[i] = sc.next();
            }
            from = sc.next();
            to = sc.next();

            System.out.println(getMin());
        }
    }

    int getMin(){
        PriorityQueue<E> 
            q = new PriorityQueue<E>(n, new Comparator<E>(){
                    public int compare(E e1, E e2){
                        return e1.cost - e2.cost;
                    }
                });
        q.add(new E(from,0));
        HashSet<String> set = new HashSet<String>();

        while(q.size()>0){
            E e = q.poll();
            String ss = e.s;
            int cost = e.cost;

            if(ss.equals(to)) return cost;
            if(set.contains(ss)) continue;
            set.add(ss);

            for(int i=0; i<a.length; i++){
                String s = ss;
                s = s.replaceAll(a[i],b[i]);

                if(ss.equals(s)) continue;
                if(s.length()>to.length()) continue;
                q.add(new E(s,cost+1));
            }
        }

        return -1;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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

using namespace std;

struct Node
{
	int key;
	Node* parent;
	Node* left;
	Node* right;
};

Node* root;
Node* NIL;

Node* find(Node* u, int k)
{
	while (u != NIL && k != u->key)
	{
		if (k < u->key)
		{
			u = u->left;
		}
		else
		{
			u = u->right;
		}
	}
	return(u);
}

void insert(int key)
{
	Node* y = NIL;
	Node* x = root;
	Node* z;

	z = new Node;
	z->key = key;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL)
	{
		y = x;
		if (z->key < x->key)
		{
			x = x->left;
		}
		else
		{
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL)
	{
		root = z;
	}
	else
	{
		if (z->key < y->key)
		{
			y->left = z;
		}
		else
		{
			y->right = z;
		}
	}
}

void inOrder(Node* u)
{
	if (u == NIL)
	{
		return;
	}
	inOrder(u->left);
	cout << " " << u->key;
	inOrder(u->right);
}

void preOrder(Node* u)
{
	if (u == NIL)
	{
		return;
	}
	cout << " " << u->key;
	preOrder(u->left);
	preOrder(u->right);
}

void solve()
{
	int m;
	cin >> m;
	for (int i = 0; i < m; ++i)
	{
		string command;
		cin >> command;
		if (command == "insert")
		{
			int key;
			cin >> key;
			insert(key);
		}
		else if (command == "print")
		{
			inOrder(root);
			cout << endl;
			preOrder(root);
			cout << endl;
		}
		else if (command == "find")
		{
			int key;
			cin >> key;
			Node* t = find(root, key);
			if (t != NIL)
			{
				cout << "yes" << endl;
			}
			else
			{
				cout << "no" << endl;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 19964
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int x,n;
    cin>>x>>n;
    vector<int> p(101,0);
    rep(i,n){
        int a;
        cin>>a;
        p[a]=1;
    }
    
    vector<pair<int,int>> v;
    for(int i=0;i<=101;i++){
        if(p[i]==0){
            int k=abs(x-i);
            v.push_back({k,i});
        }
    }
    
    sort(v.begin(),v.end());
    cout<<v[0].second<<endl;


    
return 0;
}


Measured memory_bytes: 3636
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()

a=i()
b=i()
c=0
for i in range(3):
  if a[i]==b[i]:
    c+=1
print(c)

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll W, a, b;
    cin >> W >> a >> b;

    if(a<=b&&b<=(a+W)){
        cout << 0 << endl;
    }
    else{
        cout << min(abs(b - a - W), abs(a - b - W)) << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#define long long
using namespace std;

int main() {
	int a,b,c,d,e;
	cin>>a>>b>>c;
	if(a==5){
		d++;
	}
	if(b==5){
		d++;
	}
	if(c==5){
		d++;
	}
	if(a==7){
		e++;
	}
	if(b==7){
		e++;
	}
	if(c==7){
		e++;
	}
	if(d==2 and e==1){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}
}


Measured memory_bytes: 3556
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
const int maxn=2*300;
int n;

int a[maxn];
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }

    for(int i=1;i<=n;i++)
    {
        printf("node %d: key = %d, ",i,a[i]);
        if(i!=1) printf("parent key = %d, ",a[i/2]);
        if(2*i<=n) printf("left key = %d, ",a[2*i]);
        if(2*i+1<=n) printf("right key = %d, ",a[2*i+1]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	int n=s.size();
	int ans=0;
	for(int i=0; i<n; i++) {
		if(i==0)continue;
		if(i%2!=0) continue;
		if(s.substr(0,(n-i)/2)==s.substr((n-i)/2,(n-i)/2)) {
			ans=max(ans,n-i);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <math.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <stdlib.h>
#include <time.h> 
#include <assert.h>

#define nmax 500010
#define eps 1e-8
#define MOD 998244353

#define P1 25671
#define P2 191
#define MOD1 666013
#define MOD2 1000000007
#define B_SIZE 315

#define SZ(x) ((int)(x.size()))

#define fst first
#define snd second
#define pb push_back
#define mp make_pair

using namespace std;

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

typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int n, w;
bool b[nmax];
ll dp[nmax];
pii item[nmax];

int main()
{
	scanf("%d %d", &n, &w);

	for (int i = 1; i <= n; i++) 
		scanf("%d %d", &item[i].fst, &item[i].snd);

	// dp[i] -> minimum sum of weights, with the sum of values = i 

	for (int i = 0; i <= 100000; i++) dp[i] = 1e18;

	dp[0] = 0;

	for (int i = 1; i <= n; i++) {

		for (int j = 100000 - item[i].snd; j >= 0; j--)
			dp[j + item[i].snd] = min(dp[j + item[i].snd], dp[j] + item[i].fst);
	}

	int answer = 0;

	for (int i = 0; i <= 100000; i++)
		if (dp[i] <= w) answer = i;

	printf("%d", answer);

	return 0;
}

Measured memory_bytes: 4352
def main():
    a, b = map(int, input().split())
    c = [[(b - a) // 2 % 2 ^ b, (b - a + 1) // 2 % 2], [a ^ b ^ (b - a - 1) // 2 % 2, (b - a + 1) // 2 % 2 ^ a]]
    i, j = a % 2, b % 2
    print(c[i][j])


if __name__ == '__main__':
    main()


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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  long N;
  cin >> N;
  vector<tuple<long, long, long>> V(N);
  for (long i = 0; i < N; i++) {
    long A, B;
    cin >> A >> B;
    V.at(i) = {A + B, A, B};
  }
  sort(V.rbegin(), V.rend());
  long T = 0, A = 0;
  for (long i = 0; i < N; i++) {
    auto [a, b, c] = V.at(i);
    if (i % 2) A += c;
    else T += b;
  }
  cout << T - A << "\n";
}

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

typedef long long ll;
typedef unsigned long long ull;

class vertex{
public:
    int id;
    int parent = -1;
    int left = -1;
    int right = -1;
    int sibling = -1;
    int degree = 0;
    int depth;
    int height;
};
bool operator<(const vertex &a, const vertex &b){
    return a.id<b.id;
}

void label(vertex *v, int i){
    if(v[i].parent<0) v[i].depth=0;
    else v[i].depth=v[v[i].parent].depth+1;
    if(v[i].left>=0) label(v, v[i].left);
    if(v[i].right>=0) label(v, v[i].right);
    v[i].height=0;
    if(v[i].left>=0) v[i].height = max(v[i].height, v[v[i].left].height + 1);
    if(v[i].right>=0) v[i].height = max(v[i].height, v[v[i].right].height + 1);
}

int main(){
    int n;
    vertex v[25];
    cin >> n;
    for(int i=0;i<n;i++){
        int id, l, r;
        cin >> id >> l >> r;
        v[i].id=id;
        v[i].left=l;
        v[i].right=r;
    }
    sort(v, v+n);
    for(int i=0;i<n;i++){
        int l = v[i].left;
        int r = v[i].right;
        if(l>=0){
            v[i].degree++;
            v[l].parent=i;
            v[l].sibling=r;
        }
        if(r>=0){
            v[i].degree++;
            v[r].parent=i;
            v[r].sibling=l;
        }
    }

    int p;
    for(int i=0;i<n;i++){
        if(v[i].parent<0){
            p=i;
            break;
        }
    }
    label(v, p);

    for(int i=0;i<n;i++){
        //node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root
        cout << "node " << v[i].id << ": parent = " << v[i].parent << ", sibling = " << v[i].sibling << ", degree = " << v[i].degree
            << ", depth = " << v[i].depth << ", height = " << v[i].height << ", ";
        if(v[i].depth==0) cout << "root";
        else if(v[i].height==0) cout << "leaf";
        else cout << "internal node";
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
from sys import stdin
A, B, M = [int(_) for _ in stdin.readline().rstrip().split()]
A = [int(_) for _ in stdin.readline().rstrip().split()]
B = [int(_) for _ in stdin.readline().rstrip().split()]
XYC = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]
ans = [min(A)+min(B)]
for x, y, c in XYC:
  ans.append(A[x-1]+B[y-1]-c)
print(min(ans))

Measured memory_bytes: 81988
using System;

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine(n % digitSum(n) == 0 ? "Yes" : "No");
    }
    static int digitSum(int n) {
        int sum = 0;
        while(n>0) {
            sum += n%10;
            n /= 10;
        }
        return sum;
    }
}

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

long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {

    long long int N;
    cin >> N;
    long long int min=N;

    if(!IsPrime(N)) {
        for (int i = sqrt(N); i >= 1; i--) {
            if (N % i == 0) {
                int A = i;
                int B = N / i;
                int kA = GetDigit(A);
                int kB = GetDigit(B);

                if (max(kA, kB) < min) {
                    min = max(kA, kB);


                }

                break;
            }
        }
    }else{
        int kN=GetDigit(N);
        min = max(1,kN);
    }



    cout << min << endl;


}

Measured memory_bytes: 384
import java.io.*;
import java.util.regex.Pattern;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Pattern pattern=Pattern.compile("the|this|that");
        String str;
        try{
            while((str=br.readLine())!=null){
                char[] ch=str.toCharArray();
                for(int j=0;!pattern.matcher(str).find()&j<26;j++){
                    for(int i=0;i<ch.length;i++){
                        if('a'<=ch[i]&&ch[i]<'z'){    //a???z??§????????????????????????
                            ch[i]++;
                        }else if(ch[i]=='z'){
                            ch[i]='a';  //z????¬????a
                        }
                    }
                    if(pattern.matcher(String.valueOf(ch)).find()){
                        break;
                    }
                }
                System.out.println(ch);
            }
        }catch(Exception e){
        }
    }
}

Measured memory_bytes: 17840
package main

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

func main() {
	scanInit()

	s := nextStr()
	m := map[string]int{}
	for i := 0; i < len(s); i++ {
		m[string(s[i])]++
	}

	if m["E"] > 0 && m["W"] == 0 {
		fmt.Println("No")
		return
	}
	if m["E"] == 0 && m["W"] > 0 {
		fmt.Println("No")
		return
	}
	if m["S"] > 0 && m["N"] == 0 {
		fmt.Println("No")
		return
	}
	if m["S"] == 0 && m["N"] > 0 {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
	return
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

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, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
template<typename weight_t> using graph = vector<vector<pair<int,weight_t>>>;
template<typename weight_t> vector<weight_t> dijkstra(const graph<weight_t> &g,const int e){
    using node=pair<int,weight_t>; auto cmp=[](node &a,node &b)->bool {return (a.second>b.second);};
    priority_queue<node,vector<node>,decltype(cmp)> pq(cmp);
    vector<weight_t> w(g.size(),numeric_limits<weight_t>::max());
    vector<bool> done(g.size(),false);
    pq.push({e,0}); w[e]=0;
    while(!pq.empty()){ auto u=pq.top(); pq.pop(); 
        if(done[u.first])continue;
        for(auto &v:g[u.first]){
        if(w[u.first]+v.second<w[v.first]){
            w[v.first]=w[u.first]+v.second; pq.push({v.first,w[v.first]});
        }}
        done[u.first]=true;
    }
    return w;
}
int main(){
    double xs,ys,xt,yt;
    int n;
    cin >> xs >> ys >> xt >> yt >> n;
    vector<double> x(n+2),y(n+2),r(n+2);
    x[0]=xs;
    y[0]=ys;
    x[1]=xt;
    y[1]=yt;
    rep(i,2,n+2){
        cin >> x[i] >> y[i] >> r[i];
    }
    graph<double> g(n+2);
    auto dist = [&](double xi,double yi,double xj,double yj)->double{
        return sqrt((xi-xj)*(xi-xj)+(yi-yj)*(yi-yj));};
    loop(i,n+1)rep(j,i+1,n+2){
        double d=max(0.0,dist(x[i],y[i],x[j],y[j])-r[i]-r[j]);
        g[i].push_back({j,d});
        g[j].push_back({i,d});
    }
    auto ans=dijkstra(g,0);
    cout << setprecision(10) << ans[1] << endl;
    return 0;
}

Measured memory_bytes: 22000
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
lr = [LIST() for _ in range(N)]

ans = 0

for l, r in lr:
	ans += r-l+1

print(ans)


Measured memory_bytes: 5204
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, a[200010];

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << a[0] << endl;
		return 0;
	}
	if (n % 2 == 0) {
		for (int i = n - 1; i >= 0; i -= 2) cout << a[i] << " ";
		for (int i = 0; i <= n - 4; i += 2) cout << a[i] << " ";
		cout << a[n - 2] << endl;
	}
	else {
		for (int i = n - 1; i >= 0; i -= 2)cout << a[i] << " ";
		for (int i = 1; i <= n - 4; i += 2)cout << a[i] << " ";
		cout << a[n - 2] << endl;
	}
	getchar(); getchar();
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
using namespace std;
 
int main() {
  ll H, W;
  cin >> H >> W;
  string S;
  vector<vector<char>> c(H, vector<char>(W));
  bool judge = 1;
  for(ll i = 0; i < H; i++) {
    cin >> S;
    for(ll j = 0; j < W; j++) c.at(i).at(j) = S.at(j);
  }
  if((H != 1) && (W != 1)) {
    for(ll i = 0; i < H; i++) {
      for(ll j = 0; j < W; j++) {
        if(i == 0) {
          if(j == 0) {
            if((c.at(i).at(j) == '#') && ((c.at(i + 1).at(j) == '.') && (c.at(i).at(j + 1) == '.'))) judge = 0;
          }
          else if(j == W - 1) {
            if((c.at(i).at(j) == '#') && ((c.at(i + 1).at(j) == '.') && (c.at(i).at(j - 1) == '.'))) judge = 0;
          }
          else {
            if(((c.at(i).at(j) == '#') && (c.at(i).at(j - 1) == '.')) && ((c.at(i + 1).at(j) == '.') && (c.at(i).at(j + 1) == '.'))) judge = 0;
          }
        }
        else if(i == H - 1) {
          if(j == 0) {
            if((c.at(i).at(j) == '#') && ((c.at(i - 1).at(j) == '.') && (c.at(i).at(j + 1) == '.'))) judge = 0;
          }
          else if(j == W - 1) {
            if((c.at(i).at(j) == '#') && ((c.at(i - 1).at(j) == '.') && (c.at(i).at(j - 1) == '.'))) judge = 0;
          }
          else {
            if(((c.at(i).at(j) == '#') && (c.at(i).at(j - 1) == '.')) && ((c.at(i - 1).at(j) == '.') && (c.at(i).at(j + 1) == '.'))) judge = 0;
          }
        }
        else {
          if(j == 0) {
            if(((c.at(i).at(j) == '#') && (c.at(i - 1).at(j) == '.')) && ((c.at(i + 1).at(j) == '.') && (c.at(i).at(j + 1) == '.'))) judge = 0;
          }
          else if(j == W - 1) {
            if(((c.at(i).at(j) == '#') && (c.at(i - 1).at(j) == '.')) && ((c.at(i + 1).at(j) == '.') && (c.at(i).at(j - 1) == '.'))) judge = 0;
          }
          else {
            if((((c.at(i).at(j) == '#') && (c.at(i - 1).at(j) == '.')) && ((c.at(i + 1).at(j) == '.') && (c.at(i).at(j - 1) == '.'))) && (c.at(i).at(j + 1) == '.')) judge = 0;
          }
        }
      }
    }
  }
  else if((H == 1) && (W != 1)) {
    for(ll j = 0; j < W; j++) {
      if(j == 0) {
        if((c.at(0).at(j) == '#') && (c.at(0).at(j + 1) == '.')) judge = 0;
      }
      else if(j == W - 1) {
        if((c.at(0).at(j) == '#') && (c.at(0).at(j - 1) == '.')) judge = 0;
      }
      else {
        if((c.at(0).at(j) == '#') && ((c.at(0).at(j - 1) == '.') && (c.at(0).at(j + 1) == '.'))) judge = 0;
      }
    }
  }
  else if((H != 1) && (W == 1)) {
    for(ll i = 0; i < H; i++) {
      if(i == 0) {
        if((c.at(i).at(0) == '#') && (c.at(i + 1).at(0) == '.')) judge = 0;
      }
      else if(i == H - 1) {
        if((c.at(i).at(0) == '#') && (c.at(i - 1).at(0) == '.')) judge = 0;
      }
      else {
        if((c.at(i).at(0) == '#') && ((c.at(i - 1).at(0) == '.') && (c.at(i + 1).at(0) == '.'))) judge = 0;
      }
    }
  }
  else {
    if(c.at(0).at(0) == '.') judge = 0;
  }
  if(judge) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim();
    var expressions = inputs.split('\n');
 
    for (var i = 0; i < expressions.length; i++) {
        if (expressions[i] === '0 ? 0') {
            break;
        }
        var expression = expressions[i].split(' ');
        var left = parseFloat(expression[0]);
        var right = parseFloat(expression[2]);
        var op = expression[1];
 
        switch (op) {
            case '+':
                console.log(left + right);
                break;
            case '-':
                console.log(left - right);
                break;
            case '*':
                console.log(left * right);
                break;
            case '/':
                console.log(Math.floor(left / right));
                break;
        }
 
    }
 
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15924
# coding: utf-8
# Your code here!

def fibo(n):
    if n==0:
        return 1
    if n==1:
        return 1
    if memo[n] != 0:
        return memo[n]
    memo[n]=fibo(n-1)+fibo(n-2)
    return memo[n]
n=int(input())
memo=[0 for i in range(n+1)]

print(fibo(n))


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

int main(){
	string st;
    cin >> st;
    int ans = 700;
    rep(i, 3) if(st.at(i) == 'o') ans += 100;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# 122A
# 対の値を出力する　A と T、C と G
# 入力値　A, C, G, T

# 入力
b = str(input())

# 処理
if b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "C":
    print("G")
elif b == "G":
    print("C")


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

int main() {
  int n;
  scanf("%d", &n);
  double a[4141];
  for (int i = 0; i < n; i++)
    scanf("%lf", a + i);
  sort(a, a + n);
  double ans = (a[0] + a[1]) / 2;
  for (int i = 2; i < n; i++) {
    ans += a[i];
    ans /= 2;
  }
  printf("%.12lf\n", ans);
  return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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


int main() {
  int n;cin >> n;
  int a[n];rep(i,n)cin >> a[i];
  int c=0;
  rep(i,n){
    if(a[i]==c+1)c=c+1;
  }
  cout << (!c?-1:(n-c));
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
    int N,i;
  
    scanf("%d",&N);
   
    if(N<1000) { printf("%d\n",1000-N); return 0; }
    
    for(i=1;i<=10;i++){
      if(i*1000>=N){
        printf("%d\n",i*1000-N);
        return 0; 
      }
    }
}
  


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, int b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int al[26] = {};
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++)
        al[s[i] - 'a']++;

    int j;
    for (j = 0; j < 26; j++)
        if (al[j] == 0)
        {
            cout << (char)('a' + j) << endl;
            break;
        }
    if (j == 26)
        cout << "None" << endl;
}


Measured memory_bytes: 512
a, b, k = map(int,input().split())

ans = {i for i in range(a,min(a+k,b+1))}
ans2 = {i for i in range(b,max(b-k,a-1),-1)}

ans = ans | ans2
ans = sorted(list(ans))

for an in ans: print(an) 


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std ;
bool cmp(int a ,int b)
{
	return a < b ;
}
int main()
{
	int N;
	int a[200];
	int c[200];
	cin>>N;
	for(int i=0;i<2*N;i++)
        {
                cin>>a[i];
        }
	sort(a,a+(2*N),cmp);
	for(int i=0;i<2*N;i++)
	{
		c[i]=a[i];
	}

	int sum=0;
        for(int z=0;z<2*N;z=z+2)
        {
                sum=c[z]+sum;
        }
	cout<<sum;
	return 0 ;
}

Measured memory_bytes: 256
N = int(input()) 
total = 0

for i in range(N):
  A = input().split()
  if A[1] == "JPY":
    total = total + float(A[0])
  if A[1] == "BTC":
    total = total + (float(A[0]) * 380000)

print(total)
    
  

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

int main(void){
    vector<int> n(3);
    int inpt;
    cin >> inpt;
    for(auto &x: n) x = (inpt % 10), inpt /= 10;
    for(auto &x: n)
    {
        if ( x == 1 ) x = 9;
        else if ( x == 9 ) x = 1;
    }
    cout << n[2] << n[1] << n[0];
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

char G[55][55];

const ll dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const ll dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(ll y, ll x, ll H, ll W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll ans=1;
  reps(i,n){
    ans*=i;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

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

int main() {
  int n, c = 0;
  short int k, h;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> h;
    if (h >= k) ++c;
  }
  cout << c << '\n';
  return 0;
}

Measured memory_bytes: 256