akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, k;
  cin >> n >> k;
  if(k == 1){
    cout << 0 << endl;
  }else{
    cout << n - k << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  ll dp[n];
  fill(dp,dp+n,MAX);
  dp[0]=0;
  rep(i,n) {
    REP(j,i+1,min(i+3,n)) dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
  }
  pr(dp[n-1]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1792
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

if A + B + C + D == 7:
    print("{}+{}+{}+{}=7".format(A,B,C,D))
elif A - B + C + D == 7:
    print("{}-{}+{}+{}=7".format(A,B,C,D))
elif A + B - C + D == 7:
    print("{}+{}-{}+{}=7".format(A,B,C,D))
elif A - B - C + D == 7:
    print("{}-{}-{}+{}=7".format(A,B,C,D))
elif A + B + C - D == 7:
    print("{}+{}+{}-{}=7".format(A,B,C,D))
elif A - B + C - D == 7:
    print("{}-{}+{}-{}=7".format(A,B,C,D))
elif A + B - C - D == 7:
    print("{}+{}-{}-{}=7".format(A,B,C,D))
elif A - B - C - D == 7:
    print("{}-{}-{}-{}=7".format(A,B,C,D))

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

n = int(input())
h = tuple(map(int, input().split()))

dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 14236
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N,R;cin >> N >> R;
    if(N >= 10)cout << R << endl;
    else cout << R + (100 * (10 - N)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 // #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
// const int mod=1e9+7;
 const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void solve()
{
    int n, k;
    cin>>n>>k;
    readv(p,n);
    sort(all(p));
    cout<<accumulate(p.begin(), p.begin()+k,(int)0);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define        fast        ios_base::sync_with_stdio(false);cin.tie(NULL)
#define        ll          long long int
#define        End         return 0
#define        st          string
#define        sz(x)       (int)x.size()
#define        nl          '\n'

int main()
{
    fast;
   int d,t,s;
   cin>>d>>t>>s;
   if(d<=t*s)
    cout<<"Yes";
   else
    cout<<"No";
    End;
}



Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main()
{
  char x,y;
  cin >> x >> y;
  if(x=='H')
  {
    if(y=='H')
      cout << 'H' << endl;
    else
      cout << 'D' << endl;
  }
  else
  {
    if(y=='H')
      cout << 'D' << endl;
    else
      cout << 'H' << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    string S;
    cin >> S;

    vector<int> count(3,0);
    REP(i,(int)S.size()){
        if(S[i]=='a'){
            count[0]+=1;
        }else if(S[i]=='b'){
            count[1]+=1;
        }else{
            count[2]+=1;
        }
    }

    int var_a = count[0];
    int var_b = count[1];
    int var_c = count[2];
    if(abs(var_a-var_b)<=1 && abs(var_b-var_c)<=1 && abs(var_c-var_a)<=1){
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;

}

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

using namespace std;

int main() {
	int Q;
	string S;
	bool flip = false;
	
	cin >> S >> Q;
	deque<char> D(S.begin(), S.end());
	
	while (Q--) {
		char C;
		int q, F;
		cin >> q;
		if (q == 1)
			flip = !flip;
		else {
			cin >> F >> C;
			if (--F ^ flip)
				D.push_back(C);
			else
				D.push_front(C);
		}
	}
	
	if (flip)
		reverse(D.begin(), D.end());
	
	for (char c: D)
		cout << c;
	
	return 0;
}

Measured memory_bytes: 896
gets
array = gets.split.map(&:to_i)

num = 1
max = 10**18
if not array.filter{|i| i == 0}.empty?
  num = 0
else
  array.each do |i|
    num *= i
    if num > max
      num = -1
      break
    end
  end
end
puts num


Measured memory_bytes: 21560
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000'000'007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
    string s;
    cin >> s;
    for(int i = 0;i < s.size();i++){
        if(s[i] == ','){
            cout << " ";
        }
        else{
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}

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

int main(){
  int K,X;
  cin >> K >> X;
  vector <int> A;
  for(int i=K-1;i>-K;i--){
    A.push_back(X-i);
  }
  for(int i=0;i<A.size();i++){
    cout << A[i] << " ";
  }
  cout << endl;
  return 0;
}


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

int main()
{

    long long int n;
    scanf("%lld",&n);
    long long int s=0;
   long long int p1;
    long long int p;
    for(int i=1;;i++)
    {
        s+=i;
        if(s>=n)
        {
           printf("%d\n",i);
           break;
        }
    }

    return 0;
}


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

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;

	if (a == 0) {
		cout << 1 << endl;
	}

	if (b == 0) {
		cout << 2 << endl;
	}

	if (c == 0) {
		cout << 3 << endl;
	}

	if (d == 0) {
		cout << 4 << endl;
	}

	if (e == 0) {
		cout << 5 << endl;
	}
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] a = new Integer[n];
        for (int i=0;i<n;i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        int diff = 0;
        for (int i=0;i<n/2;i++) {
            diff += a[2*i] - a[2*i+1];
        }
        if ((n & 1) == 1)
            diff += a[n-1];
        System.out.println(diff);
    }
}

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

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

        public void Solve(ConsoleInput cin)
        {
            // Initialize
            var sCin = cin.ReadLine.Split(' ');
          	var sS = sCin[0];
          	var sT = sCin[1];
            // Process
            // Output
            WriteLine($"{sT}{sS}");
        }
    }

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


Measured memory_bytes: 26156
from operator import itemgetter
n=int(input())
li=[]
for i in range(n):
  temp=input().split()
  li.append({"city":temp[0],"point":-int(temp[1]),"ind":i+1})
ans=sorted(li,key=itemgetter("city","point"))
#print(ans)
for dic in ans:
  print(dic["ind"])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <vector>
#include <cmath>

using namespace std;

int main(){

	int n, lt, mi=9999;
	vector<int> c, t;

	cin>> n >> lt;
	c.resize(n);
	t.resize(n);

	for(int i=0;i<n;i++){
		cin>> c[i] >> t[i];
		if(t[i]<=lt) mi=min(mi, c[i]);
	}

	if(mi==9999){
		cout<< "TLE" << endl;
	}else{
		cout<< mi << endl;
	}


}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

int main(){
    std::vector<int> vec(2);
    while(1){
        std::cin >> vec.at(0) >> vec.at(1);
        if(0 == vec.at(0) + vec.at(1)){
            break;
        }else{
            std::sort(vec.begin(), vec.end());
            std::cout << vec.at(0) << " " << vec.at(1) << std::endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3036
n, k = gets.chomp.split.map(&:to_i)
x = gets.chomp.split.map(&:to_i)
x << 0
x.sort!

res = 10 ** 14
cur = x.bsearch_index {|y| y >= 0 }

k.step(n) do |i|
  if cur < i - k || cur > i
    next
  end

  dist = [res]
  '''
  if cur == i - k
    dist << x[i].abs
  elsif cur == i
    dist << x[i - k].abs
  else
    dist << x[i].abs + (x[i] - x[i - k]).abs
    dist << x[i - k].abs + (x[i] - x[i - k]).abs
  end
  '''
  dist << x[i].abs + (x[i] - x[i - k]).abs
  dist << x[i - k].abs + (x[i] - x[i - k]).abs
  res = dist.min
end
puts res

Measured memory_bytes: 22912
#include<iostream>
using namespace std;
int main(){
  int N,T,L;
  int r;
  int i;
  cin>>N>>T>>L>>L;
  int m[101],n[101];
  for(i=0;i<N;i++)cin>>m[i]>>n[i];
  i=r=0;
  while(1){
    if(m[i]+n[i]==0)break;
    bool broken=false;
    if(m[i]){
      m[i]--;
      r+=10;
      T++;
    }else{
      n[i]--;
      r+=100;
    }
    if(T>L)broken=true;
    if(r>=90){
      r-=90;
      if(r/10 > T){
        broken=true;
      }else{
        m[i]+=r;
        T-=r/10;
        r=0;
      }
    }
    if(broken)break;
    i = (i+1)%N;
  }
  cout<<i+1<<"\n";
}

Measured memory_bytes: 1168
N,M=map(int,input().split())
Lmax = 0
Rmin = 1e8
for _ in range(M):
    L,R=map(int,input().split())
    if L > Lmax:
        Lmax = L
    if R < Rmin:
        Rmin = R

print(max(0, Rmin - Lmax + 1))

Measured memory_bytes: 74464
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------
		String s = sc.next();
		int n = s.length();
		int ret = 0;
		for (int i = 0; i < n / 2; i++) {
			if (s.charAt(i) != s.charAt(n - i - 1)) {
				ret++;
			}
		}
		out.println(ret);

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
}

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

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

#define MAX 500000

Node* root;

void in(Node* node) {
	if (node == NULL)return;
	in(node->left);
	cout << " " << node->key;
	in(node->right);
}

void pre(Node* node) {
	if (node == NULL)return;
	cout << " " << node->key;
	pre(node->left);
	pre(node->right);
}

void print() {
	in(root);
	cout << endl;
	pre(root);
	cout << endl;
}

void insert(int key) {
	Node* y = NULL;
	Node* x = root;
	Node* z = new Node;
	z->key = key;
	z->parent = z->left = z->right = NULL;

	if (root == NULL) {
		root = z;
		return;
	}

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

Node* find(int key) {
	Node* p = root;
	while (p!=NULL) {
		if (key < p->key)p = p->left;
		else if (key > p->key)p = p->right;
		else return p;
	}
	return NULL;
}

int main() {
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		char buf[20];
		cin >> buf;
		if (buf[0] == 'i') {
			int k;
			cin >> k;
			insert(k);
		}
		else if (buf[0] == 'f') {
			int k;
			cin >> k;
			if (find(k) != NULL)cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else {
			print();
		}
	}
	return 0;
}


Measured memory_bytes: 21772
import java.util.Scanner;

public class Main {
 public static void main(String args[]){
	 Scanner s=new Scanner(System.in);
	 int a = s.nextInt();
	 int b = s.nextInt();
	 if((a >= -1000 && a <= 1000) && (b >= -1000 && b <= 1000)){
		 if(a < b){
			 System.out.println("a < b");
		 }else if(a > b){
			 System.out.println("a > b");
		 }else if(a == b){
			 System.out.println("a == b");
		 }
	 }
 }
 
}

Measured memory_bytes: 26408
n = int(input())
h = [int(i) for i in input().split()]
dp = [float('inf')]*(n+1)
dp[0] = 0
for i in range(1,n):
    dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])


Measured memory_bytes: 13780
h, m, h2, m2, k = map(int, input().split())


m1 = h * 60 + m
m2 = h2 * 60 + m2

if(m2 - m1):
    time = m2 - m1
else:
    time = 1440 - m1 + m2

ans = max(time - k, 0)
print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  ll A,B,x,c;cin >> A >> B >> x;
  c=(B/x)-(A==0 ? -1 :(A-1)/x);
  cout << c << endl;
}

Measured memory_bytes: 256
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

data PizzaPrice = PizzaPrice{
priceA :: Integer,
priceB :: Integer,
priceC :: Integer
}

data ReqNum = ReqNum{
quantityX :: Integer,
quantityY :: Integer
}

type Price = Integer

halfAndHalf :: PizzaPrice -> ReqNum -> Price
halfAndHalf pp rn
            | a + b < 2 * c = a * x + b * y
            | x > y = min ((y * 2 * c)  + ( (x - y) * a)) (x * 2 * c)
            | otherwise = min ((x * 2 * c)  + ( (y - x) * b)) (y * 2 * c)
            where
                a = priceA pp
                b = priceB pp
                c = priceC pp        
                x = quantityX rn
                y = quantityY rn                

                
main = do
     [a,b,c,x,y] <- getIntList
     print $ halfAndHalf (PizzaPrice a b c) (ReqNum x y)

Measured memory_bytes: 3812
sosuu = Array.new(1000001,true)
sosuu[0] = false
sosuu[1] = false
sosuu2 = []
i = 0
while i < 1000001
 if sosuu[i]
  sosuu2 << i
  s = 2
  k = s * i
  while k < 1000001
   sosuu[k] = false
   s += 1
   k = s * i
  end
 end
 i += 1
end

n = gets.to_i
until n == 0
 ans = 0
 i = 0
 while i < n
  w = sosuu2[i]
  ans += w
  i += 1
 end

 puts ans

 n = gets.to_i
end


Measured memory_bytes: 15376
n, a, b = gets.split.map(&:to_i)

if (a-b).abs.even?
  puts (a-b).abs/2
elsif (a-b).abs == 1
  puts [b-1, n-a].min
else
  x = a + (b - (a+1))/2
  # puts x
  y = (n-b+1) + (n-a - (n-b+1))/2
  # puts y
  puts [x, y].min
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int len = s.size();
    vector<pair<int,int> > vp;
    for(int i = 1;i < len;i++)
    {
        if(s[i - 1] == 'R' && s[i] == 'L')
        {
            vp.push_back(make_pair(i - 1,i));
        }
    }
    vector<tuple<int,int,int> > vt;
    for(int i = 0;i < vp.size();i++)
    {
        int j = vp[i].first;
        int R_count = 0,L_count = 0;
        while(j >= 0 && s[j] == 'R')
        {
            R_count++;
            j--;
        }
        j = vp[i].second;
        while(j < len && s[j] == 'L')
        {
            L_count++;
            j++;
        }
        int x = R_count,y = L_count;
        int sum = R_count + L_count;
        if(R_count >= L_count)
        {
            L_count = sum / 2;
            R_count = sum - L_count;
        }
        else
        {
            R_count = sum / 2;
            L_count = sum - R_count;
        }
        if(max(x,y) % 2 == 0)
        {
            swap(R_count,L_count);
        }
        vt.push_back(make_tuple(vp[i].first,R_count,L_count));
    }
    int j = 0;
    for(int i = 0;i < len;i++)
    {
        if(i != get<0>(vt[j]))
        {
            cout << "0 ";
        }
        else
        {
            cout << get<1>(vt[j]) << " " << get<2>(vt[j]) << " ";
            i++;
            j++;
        }
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 1912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll X; cin >> X;
  ll now = 0;
  ll ans = 0;
  rep(i,1000000){
    now += X;
    ans++;
    if(now%360==0) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

typedef long long LL;

int main(void) {
	LL n,x; scanf("%lld%lld",&n,&x);
	x=std:: min(x,n-x);
	LL y=std:: max(x,n-x),ans=n;
	while (x) {
		if (y%x==0) {
			ans+=(y/x)*2*x;
			ans-=x;
			break;
		} else {
			ans+=(y/x)*2*x;
			LL tmp=y; y=x;
			x=tmp%x;
		}
	} printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
const int num = 100000, INF = 2000000000;
vector<pair<int, int> > m[num];
int n, d[num];
inline void bfs(int k) {
	for (int i = 0; i < n; i++) {
		d[i] = INF;
	}
	d[k] = 0;
	queue <int> q;
	q.push(k);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (int i = 0; i < m[v].size(); i++) {
			int u = m[v][i].first;
			if (d[u] == INF) {
				q.push(u);
				d[u] = d[v] + m[v][i].second;
			}
		}
	}
}
inline void ml() {
	bfs(0);
	int maxd = -INF;
	int mi;
	for (int i = 0; i < n; i++) { 
		if (maxd < d[i]) {
			mi = i;
			maxd = d[i];
		}
	}
	bfs(mi);
	maxd = -INF;
	for (int i = 0; i < n; i++)
		maxd = max(d[i], maxd);
	cout << maxd << endl;
}
int main() {
	int s, t, w;
	cin >> n;
	for (int i = 0; i < n- 1; i++) {
		scanf("%d%d%d", &s, &t, &w);
		m[s].push_back(make_pair(t, w));
		m[t].push_back(make_pair(s, w));
	}
	ml();
	return 0;
}

Measured memory_bytes: 9988
#!/usr/bin/env python3
import sys


def solve(X: str, Y: str):
    print("<" if X < Y else ">" if X > Y else "=")


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = next(tokens)  # type: str
    Y = next(tokens)  # type: str
    solve(X, Y)


if __name__ == '__main__':
    main()


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

int main(){

  long N,M;
  uint64_t ans;
  cin >> N >> M;

  if(N==1) ans = max((long)0,M-2);
  else if(M==1) ans = max((long)0,N-2);
  else ans = (N-2)*(M-2);

  if(N==1&&M==1) ans = 1;
  cout << ans << endl;
  return 0;
}


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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1
#define all(x) (x).begin() ,(x).end()

const ll mod = 1e9 + 7;

ll binpow(ll a, long long b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}

ll dp[2005];

ll getAns(int s) {
	if (s == 0)
		return 1LL;
	if (s == 1 || s == 2)
		return 0LL;

	if (dp[s] != -1) return dp[s];

	ll tot = 0LL;

	for (int i = 3 ; i <= s ; i++)
		if (s - i >= 0)
			tot = (tot + getAns(s - i)) % mod;
	return dp[s] = tot;
}

void solve() {

	int n;
	cin >> n;
	memset(dp , -1 , sizeof(dp));

	dp[0] = 1LL;

	cout << getAns(n) << "\n";
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
		solve();
	return 0;
}





Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int X;
    cin >> X;
    if(X<600) cout << 8 << endl;
    else if(X<800) cout << 7 << endl;
    else if(X<1000) cout << 6 << endl;
    else if(X<1200) cout << 5 << endl;
    else if(X<1400) cout << 4 << endl;
    else if(X<1600) cout << 3 << endl;
    else if(X<1800) cout << 2 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3692
n, k = map(int, input().split())
v = []
for i in range(n):
  v.append(False)
for i in range(k):
  d = int(input())
  a = map(int, input().split())
  for j in a:
    v[j - 1] = True
ans = 0
for b in v:
  if not b:
    ans += 1
print(ans)


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

int main( int argc, char* argv[]) {
    int N;
    cin >> N;
    if( N==1 ){
        cout << "Hello World" << endl;
        return 0;
    }
    if( N==2 ){
        int A, B;
        cin >> A >> B;
        cout << A+B << endl;
        return 0;
}
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*---define tricks---*/
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define revsort(b,e) sort(b,e),reverse(b,e)
/*---define types---*/
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
/*---define variables---*/
int n,l;
int a[100005];
priority_queue<int> s;
/*---define function---*/

/*---main code---*/
int main()
{
	FIO;
	cin>>n>>l;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	s.push(a[n]);
	int mval=INT_MIN,msum=0;
	for(int i=n-1;i>0;--i)
	{
		int nval=s.top()-a[i];
		if(nval>mval)
		{
			mval=nval,msum=1;
		}
		else if(nval==mval)
		{
			msum++;
		}
		s.push(a[i]);
	}
	cout<<msum<<'\n';
	return 0;
}


Measured memory_bytes: 1276
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n+1) {
        if (pow(10, 0) <= i && i < pow(10, 1))ans++;
        if (pow(10, 2) <= i && i < pow(10, 3))ans++;
        if (pow(10, 4) <= i && i < pow(10, 5))ans++;
    }
    cout << ans << endl;
}



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

using namespace std;

using ll = long long;
using vi = vector <int>;
using vll = vector <ll>;
using vvi = vector <vi >;
using pii = pair <int, int>;
using pll = pair <long, long>;
using vpi = vector <pii >;

#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define dg(x) cout << #x << " = " << x << endl

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

    int n;
    cin >> n;
    vi v(n);
    for (auto &i : v)
        cin >> i;
    sort(all(v));
    int cnt = 0;
    for (int i = 0; i < (int) v.size() - 2; i++)
    {
        for (int j = i + 1; j < (int) v.size() - 1; j++)
        {
            for (int k = j + 1; k < (int) v.size(); k++)
            {
                if (v[i] + v[j] > v[k] && v[i] != v[j] && v[i] != v[k] && v[j] != v[k])
                    cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i,N) cin >> p[i];

    int count = 0;
    rep(i,N) {
        if (p[i] != i + 1) count++;
    }

    if (count <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[1000000],b[1000000];
int main()
{
	int n,h;
	cin>>n>>h;
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i];
	int x=*max_element(a,a+n);
	sort(b,b+n);
	reverse(b,b+n);
	int ans=(h+x-1)/x;
	for(int i=0;i<n;i++)
	{
		h-=b[i];
		int k;
		if(h<=0)
			k=0;
		else
			k=(h+x-1)/x;
		if(i+1+k<ans)
			ans=i+1+k;
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 4736
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    int N;
    while(cin >> N){
        vi A(N);
        rep(i, N)scanf("%d", &A[i]);
        vector<pii > B(N);
        rep(i, N){
            B[i] = mp(A[i], i & 1);
        }
        sort(all(B));
        int ans = 0;
        for(int i = 0; i < N; i += 2){
            ans += B[i].second;
        }
        cout << ans << endl;
    }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int n;
	cin >> n;
	ll a[n+10];
	rep(i,n) cin >> a[i];

	ll ans = 0;
	for(int i = 0; i < 60; i++) {
		ll cnt = 0;
		for(int j = 0; j < n; j++) {
			if((1ll<<i)&a[j]) cnt++;
		}
		ans = (ans+((cnt*(n-cnt))%MOD)*((1ll<<i)%MOD))%MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define pb push_back
#define int long long int
#define vec vector<int>
#define REP(i,a,b) for(i=a;i<b;i++)
using namespace std;
main()
{
  int n;
  cin>>n;
  int a[10001]={0},i,j,k;
  int ans;
  for(i=1;i<=100;i++)
  {
    for(j=1;j<=100;j++)
    {
      for(k=1;k<=100;k++)
      {
        ans=(i*i)+(j*j)+(k*k)+(i*j)+(i*k)+(j*k);
        if(ans<=10000)
            a[ans]++;
      }
    }
  }
  for(i=1;i<=n;i++)
    cout<<a[i]<<"\n";
}


Measured memory_bytes: 3592
#include <stdio.h>
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}


int main(void){
    char po[114][114];
    int H,W;
    scanf("%d %d",&H,&W);
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        scanf(" %c",&po[i][j]);
    }
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        if(po[i][j]!='#'){
            int count=0;
            for(int k=max(0,i-1);k<min(i+2,H);k++)for(int l=max(0,j-1);l<min(j+2,W);l++){if(po[k][l]=='#')count++;}
            po[i][j]='0'+count;
        }
    }
    for(int i=0;i<H;i++){for(int j=0;j<W;j++){
        printf("%c",po[i][j]);
    }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
typedef pair<int, int> pii;

int N, A, B;
int s[200000];

int main(void) {
  cin >> N;
  REP(i, 0, N + 2) s[i] = 0;
  REP(i, 0, N) {
    cin >> A >> B;
    s[A - 1]++;
    s[B]--;
  }
  REP(i, 1, 100001) s[i] += s[i - 1];

  int ans = 0;
  REP(i, 0, N + 2) if(i <= s[i]) ans = i;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int n,x;
ll dp[520][520],pd[520][520],fac[1520],fnv[1520],ans;
int main() {
	scanf("%d%d",&n,&x);
	dp[0][0]=1;
	fac[0]=1,fnv[0]=1;
	for (int i=1;i<=1000;i++) fac[i]=fac[i-1]*i%mod,fnv[i]=powmod(fac[i],mod-2);
	for (int i=0;i<=x;i++) {
		for (int j=0;j<=n;j++) for (int k=0;k<512;k++) pd[j][k]=dp[j][k];
		for (int j=1;j<=n;j++) for (int k=0;k<512;k++) dp[j][k]=(pd[j-1][k^i]+dp[j][k])%mod;
	}
	for (int i=n;i>=0;i-=2) {
		ll a=dp[i][x];
		a=a*fac[(n-i)/2+x]%mod*fnv[(n-i)/2]%mod*fnv[x]%mod;
		ans=(ans+a)%mod;
	}

	printf("%lld\n",ans);
}



Measured memory_bytes: 7364
import sys
input = sys.stdin.readline

N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]
AB.sort()
ans = 0
if N & 1:
    l = AB[N//2][0]
    AB.sort(key=lambda x: x[1])
    ans = AB[N // 2][1] - l + 1
else:
    l = (AB[N // 2][0], AB[N // 2 - 1][0])
    AB.sort(key=lambda x: x[1])
    r = (AB[N // 2][1], AB[N // 2 - 1][1])
    ans = sum(r) - sum(l) + 1
print(ans)

Measured memory_bytes: 109356
N = int(input())

A = [int(n) for n in input().split()]

flag = 1
num_c  = 0
while(flag):
    flag = 0
    for j in range(1, N):
        if A[j] < A[j-1]:
            v = A[j]
            A[j] = A[j-1]
            A[j-1] = v
            num_c += 1
            flag = 1

print((" ").join((str(a) for a in A)))
print(num_c)

Measured memory_bytes: 7740
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 1000000000
#define EPS 1e-10

#define MAX_N 100000
#define MAX_P 100

int N, P;

bool prime[5 * MAX_N];

vector<int> ans_list;

int main(){

	fill(prime, prime + 5 * MAX_N, true);

	prime[0] = prime[1] = false;
	for (int i = 0; i < 5 * MAX_N; i++){
		if (prime[i]){
			for (int j = 2 * i; j < MAX_N * 5; j += i){
				prime[j] = false;
			}
		}
	}

	while (true){

		cin >> N >> P;
		if (N == -1 && P == -1)
			break;

		vector<int> L;
		for (int i = N + 1, count = 0; count < 100; i++){
			if (prime[i]){
				L.push_back(i);
				count++;
			}
		}

		vector<int> ans;
		for (int i = 0; i < L.size(); i++){
			for (int j = i; j < L.size(); j++){
				ans.push_back(L[i] + L[j]);
			}
		}

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

		ans_list.push_back(ans[P - 1]);

	}

	for (int i = 0; i < ans_list.size(); i++){
		cout << ans_list[i] << endl;
	}

	return 0;

}

Measured memory_bytes: 1780
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if (s.size() > k) {
    cout << s.substr(0, k) << "..." << endl;
  } else {
    cout << s << endl;
  }

  return 0;
}


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

// ???????????§???????????§?????§??????
// int L[1024][1024] = {};

int main(){
    int N;
    cin >> N;
    for(int c=0; c<N; ++c){
        string X,Y;
        cin >> X >> Y;
        int xlen = (int)X.size();
        int ylen = (int)Y.size();

        // vector??§??????
        vector<vector<int> > L(xlen+1 ,vector<int>(ylen+1, 0));

        for(int i=0;i<=xlen;++i){
          L[i][0] = 0;
        }
        for(int i=0;i<=ylen;++i){
          L[0][i] = 0;
        }

        for(int i=1;i<=xlen;++i){
            for(int j=1;j<=ylen;++j){
                if(X[i-1] == Y[j-1]){ // X???i???????????¨Y???j?????????????????????????????????index?????????????????¨?????¨??????
                    L[i][j] = L[i-1][j-1] + 1;
                } else {
                    L[i][j] = max(L[i-1][j], L[i][j-1]);
                }
            }
        }
        cout << L[xlen][ylen] << endl;
    }
}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define setval(arr,v) memset(arr,v,sizeof(arr));
#define lli long long int
#define ll long long
#define mod 1000000007
#define v vector
#define pb push_back
#define pf pop_front;
#define fi first
#define se second
using namespace std;

int dp[100005];
int h[100005];


void solve()
{
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
        cin>>h[i];
    }
    dp[1] = 0;
    dp[2] = abs(h[1]-h[0]);
    for (int i = 3; i <= n; ++i)
    {
        dp[i] = min(dp[i-1]+abs(h[i-2]-h[i-1]),dp[i-2]+abs(h[i-3]-h[i-1]));
    }
    cout<<dp[n];










    
}


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();

    }
    return 0;

}



Measured memory_bytes: 4356
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define ppi pair< pair<int,int>,int >
#define bs binary_search
#define gcd _gcd
#define fs first
#define sc second
#define MOD 1000000007
int ABS(int a){return max(a,-a);}
ll ABS(ll a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int gif(int x,int a){return (x%a==0)?(x/a):((x/a)+1);}
ll gif(ll x,ll a){return (x%a==0LL)?(x/a):((x/a)+1LL);}
int lif(int x,int a){return (x/a);}
ll lif(ll x,ll a){return (x/a);}

void solve()
{
    int n;
    cin>>n;
    vector<int> dp(3,0);
    for(int day=0;day<n;day++)
    {
        vector<int> c(3);
        for(int i=0;i<3;i++)
            cin>>c[i];

        vector<int> prev_dp(3,0);
        for(int i=0;i<3;i++)
            for(int j=0;j<3;j++)
                if(i!=j)
                    prev_dp[j] = max(prev_dp[j],dp[i]+c[j]);
        dp = prev_dp;
    }

    cout<< max(dp[0],max(dp[1],dp[2]))<<"\n";
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

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

    solve();    

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;
long long fact(long long n)
{
	if(n<=0)
	{
		return 0;
	}
	else
	{
		return (n+1) * n /2;
	}
}
int main()
{
	int s_len = 10;
	int N;
	cin>>N;

	vector<vector<char>> s(N);

	for(int i=0; i<N; i++)
	{
		vector<char> new_s(s_len);
		for(int j=0; j<s_len; j++)
		{
			cin>>new_s[j];
		}
		sort(new_s.begin(),new_s.end());
		s[i] = new_s;
	}
	sort(s.begin(),s.end());
	vector<char> dummy(1,'0');
	s.push_back(dummy);
	int l=0;
	int r=0;
	long long cnt = 0;
	for(int i=0; i<=N; i++)
	{
		if(s[l]==s[i])
		{
			r=i;
		}
		else
		{
			cnt += fact(r-l);
			l=i;
			r=i;
		}
	}
	//cout<<r<<l<<endl;
	
	cout<<cnt<<endl;
}

Measured memory_bytes: 9984
#include <iostream>
 
using namespace std;
 
int main(){
    int X,Y,a=0;
    cin>>X>>Y;
    for(int i=0;i<=X;i++){
        if((X-i)*2+i*4==Y){
            a=1;
            break;
        }
    }
    if(a==1)printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 3600
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    // int T;cin>>T;while(T--) 
    {
        ll k,a,b;
        cin>>k>>a>>b;
        ll l = (a-1)/k;
        ll r = b/k;
        if(r-l>=1) cout<<"OK\n";
        else cout<<"NG\n";
    }
    return 0;
}

Measured memory_bytes: 3612
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength


#X = str(input()).split()
#a = [int(x) for x in input().split()]

N = int(input())
v = [int(x) for x in input().split()]

v.sort()

for i in range(N-1):
  v[i+1] = (v[i]+v[i+1])/2

print(v[N-1])



Measured memory_bytes: 12516