akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[300001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size);
	data tmp;
	h->obj[i] = x;
	while (i > 1) {
		if (h->obj[i].key < h->obj[i>>1].key) {
			tmp = h->obj[i>>1];
			h->obj[i>>1] = h->obj[i];
			h->obj[i] = tmp;
			i >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j = i << 1;
		} else break;
	}
	return output;
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, H, W, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, s[200002], left[200002], right[200002], BIT[200001] = {}, L, R, M, tmp;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		s[i] = i;
		left[i] = i - 1;
		right[i] = i + 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
		add_BIT(W, BIT, i, 1);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		tmp = sum_BIT(BIT, A - 1);
		if (sum_BIT(BIT, B) == tmp) {
			printf("%d\n", h.obj[1].key + i);
			continue;
		}
		
		L = A;
		R = B++;
		while (L < R) {
			M = (L + R) / 2;
			if (sum_BIT(BIT, M) > tmp) R = M;
			else L = M + 1;
		}
		
		left[B] = left[L];
		right[left[L]] = B;
		if (s[B] < 0) add_BIT(W, BIT, B, 1);
		for (j = L; j < B; j = right[j]) {
			s[B] = (s[j] > s[B])? s[j]: s[B];
			s[j] = -1;
			add_BIT(W, BIT, j, -1);
		}
		if (j != B) {
			left[j] = B;
			right[B] = j;
		}
		if (B <= W) {
			d.key = B - s[B];
			d.id = B;
			push(d, &h);
		}
		
		while (h.size > 0 && s[h.obj[1].id] < h.obj[1].id - h.obj[1].key) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else break;
	}
	for (; i <= H; i++) printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 6672
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Common Raccoon vs Monster
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int sum = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    sum += ai;
  }

  if (sum >= h) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <utility>
#include <numeric>
#include <iomanip>
#include <locale>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>
#include <cmath>

using namespace std;

pair< int, vector< vector<int> > > read();
int think(pair< int, vector< vector<int> > >);
void write(int);

vector< vector<int> > createAdjacencyMatrix(int, vector< vector<int> >);

int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  auto input = read();
  auto output = think(input);
  write(output);

  return 0;
}

pair< int, vector< vector<int> > > read() {
  int n, m, a, b;
  vector< vector<int> > edges;

  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    edges.push_back(vector<int> {a, b});
  }
  return make_pair(n, edges);
}

int think(pair< int, vector< vector<int> > > input) {
  auto n = input.first;
  auto edges = input.second;
  auto adjacencyMatrix = createAdjacencyMatrix(n, edges);

  auto perm = vector<int>();
  for (int i = 1; i <= n; i++) {
    perm.push_back(i);
  }

  int count = 0;
  do {
    bool found = true;
    for (int i = 0; i < perm.size() - 1; i++) {
      auto from = perm.at(i);
      auto to = perm.at(i + 1);
      if (adjacencyMatrix.at(from).at(to) == 0) {
        found = false;
        break;
      }
    }
    if (found) {
      count++;
    }
  } while (next_permutation(perm.begin() + 1, perm.end())); // + 1 means start vertex is "1" only.

  return count;
}

void write(int output) {
  cout << output << endl;
}

vector< vector<int> > createAdjacencyMatrix(int n, vector< vector<int> > edges) {
  // index 0 is dummy because vertex is 1-indexed.
  auto adjacencyMatrix = vector< vector<int> > (n + 1, vector<int> (n + 1, 0));

  for (auto e : edges) {
    auto from = e.at(0);
    auto to = e.at(1);
    adjacencyMatrix.at(from).at(to) = 1;
    adjacencyMatrix.at(to).at(from) = 1;
  }
  return adjacencyMatrix;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        if (i % 3 > 0 && i % 5 > 0) ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
h,w = map(int,input().split())
s = [input() for _ in range(h)]
ans = 'Yes'
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            if ((i ==0 or s[i-1][j] == '.') and (i==h-1 or s[i+1][j] == '.' )and (j==0 or s[i][j-1] == '.') and(j==w-1 or s[i][j+1] == '.')):
               ans = 'No'
print(ans)

Measured memory_bytes: 3064
N = int(input())
ans = [0] * (N + 1)
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            num = pow(x, 2) + pow(y, 2) + pow(z, 2) + \
                (x * y) + (y * z) + (z * x)
            if num <= N:
                ans[num] += 1
for i in ans[1:]:
    print(i)


Measured memory_bytes: 9156
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int A, B;
    cin >> A >> B;
    if (A <= 8 && B <= 8) {
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N=int(0)
i=int(0)
m,f,r,point=[],[],[],[]
while 1:
    point=list(map(int,input().split(' ')))
    m.append(point[0])
    f.append(point[1])
    r.append(point[2])
    if(m[i]==-1&f[i]==-1&r[i]==-1):
        break
    N=N+1
    i=i+1
i=0
while (i<N):
    if(m[i]+f[i]>=80 and m[i]!=-1 and f[i]!=-1):
        print('A')
    elif(m[i]+f[i]>=65 and m[i]+f[i]<80 and m[i]!=-1 and f[i]!=-1):
        print('B')
    elif(m[i]+f[i]>=50 and m[i]+f[i]<65 and m[i]!=-1 and f[i]!=-1):
        print('C')
    elif(m[i]+f[i]>=30 and m[i]+f[i]<50 and m[i]!=-1 and f[i]!=-1):
        if(r[i]>=50):
            print('C')
        else:
            print('D')
    elif(m[i]+f[i]<30 or m[i]==-1 or f[i]==-1):
        print('F')
    i=i+1


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

int main(int argc, char **argv)
{
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    for (int i = 0; i < n; i++) std::cin >> v[i];
    std::sort(v.begin(), v.end());

    int n2 = n / 2;

    std::cout << v[n2] - v[n2 - 1] << std::endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector<int> vec;
typedef vector<vec> mat;
typedef long long ll;
 
int N,M,T;
 
mat mul(mat &A,mat &B){
    mat C(A.size(),vec(B[0].size()));
    for(int i = 0 ; i < (int)A.size() ; i++){
	for(int k = 0 ; k < (int)B.size() ; k++){
	    for(int j = 0 ; j < (int)B[0].size() ; j++){
		C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % M;
	    }
	}
    }
    return C;
}
 
mat pow(mat A,ll n){
    mat B(A.size(),vec(A.size()));
    for(int i = 0 ; i < (int)A.size() ; i++){
	B[i][i] = 1;
    }
    while(n > 0){
	if(n & 1) B = mul(B,A);
	A = mul(A,A);
	n >>= 1;
    }
    return B;
}
 
int main(){
    int a[3];
    while(cin >> N >> M >> a[0] >> a[1] >> a[2] >> T, N){
	mat S(N,vec(1));
	for(int i = 0 ; i < N ; i++){
	    cin >> S[i][0];
	}
	mat A(N,vec(N));
	for(int i = 0 ; i < N ; i++){
	    for(int j = 0 ; j < N ; j++){
		A[i][j] = 0;
	    }
	    for(int j = i-1, k = 0 ; j < i+2 ; j++, k++){
		if(j < 0 || j >= N) continue;
		A[i][j] = a[k];
	    }
	}
	mat B = pow(A,T);
	mat C = mul(B,S);
	for(int i = 0 ; i < N ; i++){
	    if(i > 0) cout << " ";
	    cout << C[i][0];
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3048
fun main() {
    // 文字列
//    var n = readLine()!!.toInt()
//    val x: String = readLine()!!
    // 数値
    val n =readLine()!!.toInt()
    // 行
//    val list = readLine()!!.split(" ").map (String::toInt )

//    var list = readLine()!!.split("").map(String::toInt)
    var list = readLine()!!.split(" ").map(String::toLong).toMutableList()
//    val xys = List(n) {
////        readLine()!!.split(" ").map(String::toLong)
//        readLine()!!.toDouble()
//    }
    var count=0L
    for (ai in 0 until n-1){
        if (list[ai]<=list[ai+1]){
            //何もしない
        }else{
            count=count+list[ai]-list[ai+1]
            list[ai+1]=list[ai]
        }
    }
    print(count)

}


Measured memory_bytes: 65028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                double v = double.Parse(input);

                double t = v / 9.8;
                double y = 4.9 * t * t;

                double N = (y + 5) / 5;

                sb.AppendLine(Math.Ceiling(N).ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    int N;
    cin >> N;
    LL a[N],b[N];
    LL mini=LINF;
    LL sum=0;
    for(int i=0;i<N;i++){
        cin >> a[i] >> b[i];
        if(a[i]>b[i]){
            mini=min(b[i],mini);
        }
        sum+=a[i];
    }
    if(mini==LINF) cout << 0 << endl;
    else cout << sum-mini << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)


void solve(long long N, long long K, std::vector<long long> H){
    sort(H.begin(), H.end());
    ll ans = 0;
    for(ll i = 0; i < N - K; ++i){
        ans += H.at(i);
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, K, std::move(H));
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;

int i,j,k;
int h,w;
vector<vector<char>> a;
int dy[]={1,-1,0,0},dx[]={0,0,1,-1};
queue<pair<int,int>> que;

int main(){
    cin>>h>>w;
    a.assign(h,vector<char>(w,'.'));

    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>a[i][j];
        }
    }

    vector<vector<int>> d(h, vector<int>(w,INF));
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(a[i][j]=='#'){
                que.push(make_pair(i,j));
                d[i][j]=0;//はじめから黒い
            }
        }
    }

    while(que.size()!=0){//'#'の隣接を一つずつ調べる(順番に)
        pair<int,int> state=que.front();
        que.pop();
        for(i=0;i<4;i++){
            pair<int,int> next=make_pair(state.first+dy[i],state.second+dx[i]);

            if(next.first>=0 && next.first<h && next.second>=0 && next.second<w && d[next.first][next.second]==INF && a[next.first][next.second]=='.'){//未探索の時
                que.push(next);
                d[next.first][next.second]=d[state.first][state.second]+1;//はじめの黒いところから何回目で到達したか
            }
        }
    }
    
    int ans=-1;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            ans=max(ans,d[i][j]);//答え
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 13328
#include<iostream>
#define ll long long
using namespace std;
ll sum[2005];
//ll f[2005];
constexpr auto mod=1000000000+7;
int main(){
    int n;
    cin>>n;
    //f[1]=f[2]=0;
   // f[3]=f[4]=f[5]=1;
    sum[3]=1,sum[4]=2;sum[5]=3;
    for(int i=6;i<=n;i++){
        sum[i]=(sum[i-1]+sum[i-3]+1+mod)%mod;
    }
    cout<<(sum[n]+mod-sum[n-1])%mod<<endl;
    //getchar();
    //getchar();
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  int i,N;
  double ans=0;
  scanf("%d",&N);
  double A[N];
  
  for(i=0;i<N;i++){
    scanf("%lf",&A[i]);
  }
  
  for(i=0;i<N;i++){
    ans = ans + 1.0/A[i];
  }
  ans = 1.0/ans;
  
  printf("%lf",ans);
  
}

Measured memory_bytes: 128
import math
 
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
A = a % 10
B = b % 10
C = c % 10
D = d % 10
E = e % 10
L = [A,B,C,D,E]
L = [10 if i == 0 else i for i in L]
min_ = L.index(min(L))
A = math.ceil(a*0.1)*10
B = math.ceil(b*0.1)*10
C = math.ceil(c*0.1)*10
D = math.ceil(d*0.1)*10
E = math.ceil(e*0.1)*10
m = A+B+C+D+E
if min_ == 0:
  m = m - A + a
elif min_ == 1:
  m = m - B + b
elif min_ == 2:
  m = m - C + c
elif min_ == 3:
  m = m - D + d
elif min_ == 4:
  m = m - E + e
print(m)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int main(){
    int n;
    cin>>n;
    priority_queue<ll> ba;
    priority_queue<ll,vector<ll>,greater<ll>> fr;
    ll sumf=0,sumb=0;
    vector<ll> v;
    rep(i,3*n){
        ll t;cin>>t;
        if(i<n){sumf+=t;fr.push(t);}
        else if(i>=2*n){sumb+=t;ba.push(t);}
        else{v.push_back(t);}
    }
    vector<ll> ansf,ansb;
    ansf.push_back(sumf);ansb.push_back(sumb);
    rep(i,n){
        //topと比べて操作する必要がない
        sumf+=v[i];
        fr.push(v[i]);
        sumf-=fr.top();
        fr.pop();
        ansf.push_back(sumf);
    }
    for(int i=n-1;i>=0;i--){
        sumb+=v[i];
        ba.push(v[i]);
        sumb-=ba.top();
        ba.pop();
        ansb.push_back(sumb);
    }
    ll ans=-LINF;
    for(int i=0;i<=n;i++){
        ans=max(ans,ansf[i]-ansb[n-i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4852
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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




int main(){
    int N, Rcnt = 0; cin >> N;
    string s; cin >> s;
    REP(i, N)
        if(s[i] == 'R') ++Rcnt;

    cout << (2*Rcnt > N ? "Yes": "No") << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]
A2 = A.copy()

def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return (x * y) // gcd(x, y)

for i in range(n-1):
    A[i+1] = lcm(A[i], A[i+1])

f = A[-1] - 1
ans = 0
for i in range(n):
    ans += f % A2[i]

print(ans)

Measured memory_bytes: 13172
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# import collections # queue
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    s = input()
    l = 0
    r = len(s)
    for i in range(len(s)):
        if (s[i]=='A'):
            l = i
            break
    for i in range(len(s)-1,-1,-1):
        if (s[i]=='Z'):
            r = i
            break
    ans = r - l + 1
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 3516
#include<iostream>
using namespace std;
int main(){
	int kosu;
	int *p;
	int max=0;
	int sum=0;
	cin>>kosu;
	p = new int[kosu];
	for(int a=0;a<kosu;a++){
		cin>>p[a];
		sum=sum+p[a];
		if(max<p[a]){
			max=p[a];
		}
	}
	max=max/2;
	sum=sum-max;
	cout<<sum<<endl;
	delete [] p;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long [] A = new long [N];
        for(int i=0; i<N; i++){
            A[i] = sc.nextLong();
            if(i==0)continue;
            A[i] += A[i-1];
        }
        long ans = Long.MAX_VALUE;
        for(int i=0; i<N-1; i++){
            ans = Math.min(ans,Math.abs(A[N-1]-2*A[i]));
        }
        System.out.println(ans);
    }
}

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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    bool x = true;
    for (int i = 0; i < N / 2; i++)
        if (S[i] != S[i + N / 2])
            x = false;
    if (N % 2 == 1)
        x = false;
    cout << (x ? "Yes" : "No");
}

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

int main()
{
	int m,d,c = 0,d_one = 0,d_ten = 0;
	cin >> m >> d;
	for( int i = 1; i <= m; i++ )
	{
		if( d >= 22 ){
			for( int j = 1; j <= d; j++ )
			{
				d_ten = j / 10;
				d_one = j - (d_ten) * 10;

				if( ( d_ten )*( d_one ) == i
			 			&& d_ten >= 2
						&& d_one >= 2 )
				{
					c++;
				}
			}
		}
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
#define ll long long
using namespace std;

const int MAX = 10000;

enum Color {
  WHITE = 0,
  GRAY = 1,
  BLACK = 2,
};

vector<int> adj[MAX + 10];
Color color[MAX + 10];
int indeg[MAX + 10] = {};
list<int> out;

void bfs(int s) {
  queue<int> Q;
  Q.push(s);
  color[s] = GRAY;
  while (!Q.empty()) {
    int u = Q.front(); Q.pop();

    out.push_back(u);

    rep(i, adj[u].size()) {
      int v = adj[u][i];
      --indeg[v];
      if (indeg[v] == 0 && color[v] == WHITE) {
        color[v] = GRAY;
        Q.push(v);
      }
    }
  }
}

void topologicalSort(int V) {
  rep(i, V) color[i] = WHITE;

  rep(u, V) {
    if (indeg[u] == 0 && color[u] == WHITE) bfs(u);
  }
}

int main() {
  int V, E;
  cin >> V >> E;
  rep(i, E) {
    int s, t;
    cin >> s >> t;
    adj[s].push_back(t);
    ++indeg[t];
  }
  topologicalSort(V);
  for (auto i : out) cout << i << endl;
  return 0;
}



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

int main() {
  int n, l, r;
  while(cin >> n >> l >> r) {
    if(n == 0 && l == 0 && r == 0) break;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    REP(i, l, r+1) {
      bool f = n&1;
      rep(j, n) {
	if(i % a[j] == 0) {
	  f = j&1;
	  break;
	}
      }
      if(!f) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    string s,t;
    cin >> s >> t;
    int x = t.length();
    if(s==t.substr(0,x-1)){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
N = int(input())
I = list(map(int, input().split()))
minX = 10000000000
end = I.pop()
sumI = sum(I)
for i in range(len(I)):
  minX = min(minX, abs(sumI - end ) )
  popped = I.pop()
  sumI -= popped
  end += popped
  
print(minX)

Measured memory_bytes: 76880
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Data.Int
import Data.Foldable
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

solve :: Int -> VU.Vector Int16 -> Int32
solve n hs = head dp
 where
  -- dp[i]: minimal cost of moving from 1st to i-th place
  dp :: [Int32]
  dp = VU.foldl'
    (\(!dp) (!i, !v) -> if i == 0
      then 0 : dp
      else if i == 1
        then (head dp + abs (fromIntegral $ v - hs VU.! 0)) : dp
        else
          let (d1 : d2 : _) = dp
          in  (min (d1 + abs (fromIntegral $ v - hs VU.! (i - 1)))
                   (d2 + abs (fromIntegral $ v - hs VU.! (i - 2)))
              )
                : dp
    )
    []
    (VU.indexed hs)

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  hs <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n hs


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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    int res=0;
    double h;cin >> h;
    double m_gap=abs(a-(t-0.006*h));
    for(int i=1;i<n;i++){
        cin >> h;
        double gap=abs(a-(t-0.006*h));
        if(m_gap>gap){
            m_gap=gap;
            res=i;
        }
    }
    p(res+1)
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	if (abs(a - c) <= d) res = true;
	else if (abs(a - b) <= d && abs(b - c) <= d) res = true;
	else res = false;

	if (res) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int inf = 1000000000;
vector<int> a(200001, inf);
bitset<200001> b;
int main()
{
    int n, k, c;
    long long total = 0;
    scanf("%d %d", &n, &k);
    for (int i = 0, j; i < n; i++)
    {
        scanf("%d", &j);
        if (a[j] == inf)
        {
            a[j] = 1;
        }
        else
        {
            a[j]++;
        }
        b.set(j);
    }
    c = b.count();
    sort(a.begin(), a.end());
    for (int i = 0; i < c - k; i++)
    {
        total += a[i];
    }
    printf("%lld\n", total);
}


Measured memory_bytes: 1152
def is_permutation(s):
    if len(s) == 2 and s[0] != s[1]:
        return False

    mid = int((len(s) - 1) / 2)
    for i in range(mid + 1):
        if s[i] != s[len(s) - 1 - i]:
            return False
    return True

def strong_permutation(s):
    if not is_permutation(s): return False

    last = int((len(s) - 1) / 2)
    s2 = s[:last]
    if not is_permutation(s2): return False

    start = int((len(s) + 3) / 2 - 1)
    s3 = s[start:]
    if not is_permutation(s3): return False

    return True

S = input()
if strong_permutation(S):
    print("Yes")
else:
    print("No")

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

using namespace std;
const int N = 1e5 + 1, MOD = 1e9 + 7;

int parent[N], sz[N], rnk[N];

void init() {
	memset(rnk, 0, sizeof rnk);
	for (int i = 0; i < N; ++i) {
		parent[i] = i;
		sz[i] = 1;
	}
}

int root(int node) {
	while (node != parent[node]) {
		parent[node] = parent[parent[node]];
		node = parent[node];
	}
	return node;
}

bool join(int u, int v) {
	u = root(u);
	v = root(v);
	
	if (u == v)
		return false;
	
	if (rnk[u] < rnk[v])
		swap(u, v);
	
	rnk[u] += rnk[u] == rnk[v];
	sz[u] += sz[v];
	
	parent[v] = u;
	return true;
}

int find(int u, int v) {
	return root(u) == root(v);
}

struct Things {
	int cost, from, to;
	bool operator<(Things t) const {
		return cost < t.cost;
	}
};

struct Point {
	int x, y, i;
	bool operator<(Point p) const {
		if (x == p.x) {
			return y < p.y;
		}
		return x < p.x;
	}
};

Point a[N], b[N];
int main() {
//#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//#endif
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i].x >> a[i].y;
		a[i].i = i;
		b[i] = {a[i].y, a[i].x, i};
	}
	sort(a, a + n);
	sort(b, b + n);
	vector<Things> things;
	for (int i = 1; i < n; ++i) {
		things.push_back({abs(a[i].x - a[i - 1].x), a[i].i, a[i - 1].i});
		things.push_back({abs(b[i].x - b[i - 1].x), b[i].i, b[i - 1].i});
	}
	sort(things.begin(), things.end());
	long long result = 0;
	init();
	for (auto x: things) {
		if (find(x.from, x.to) == 0) {
			join(x.from, x.to);
			result += x.cost;
		}
	}
	cout << result << endl;
	return 0;
}


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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;cin>>n>>m;
  priority_queue<P> a; 
  rep(i,n){
      int s;cin>>s;
      a.push(make_pair(s,1));
  }
  rep(i,m){
      int s,t;cin>>t>>s;
      a.push(make_pair(s,t));
  }
  ll tot=0,num=0;
  while(1){
      P k=a.top();a.pop();
      if(num+k.second<=n){
          num+=k.second;
          tot+=k.first*k.second;
      }
      else{
          tot+=k.first*(n-num);
          break;
      }
  }
  cout<<tot<<endl;
  return 0;
  }


Measured memory_bytes: 6512
h, n = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(n)]
hls = [0]
for i in range(h + max(magic, key = lambda x:x[0])[0]):
    pre = []
    for j in range(n):
        hres = i + 1 - magic[j][0]
        if hres >= 0:
            pre.append(hls[hres] + magic[j][1])
        else:
            pre.append(magic[j][1])
    hls.append(min(pre))
print(min(hls[h:]))

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

int	main() {
	int N, M;
	cin >>N >>M;
	vector<vector<int>> P(M, vector<int> (2, 0));
	for (int i=0; i<M; i++) cin >>P.at(i).at(0) >>P.at(i).at(1);
	sort(P.begin(), P.end());
	int B=N+1;
	int S=0;
	for (int i=M-1; i>=0; i--) {
		if (P.at(i).at(1)>B) continue;
		B=P.at(i).at(0);
		S++;
	}
	cout <<S <<endl;
	return 0;
}


Measured memory_bytes: 5760
#include<stdio.h>   

int main(void)   

{   

int a,b,d,r;   

double f;   

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

d=a/b;   

r=a%b;   

f=(double)a/(double)b;   

printf("%d %d %lf",d,r,f);   

return 0;   

}

Measured memory_bytes: 632
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    cnt = 0
    for i in range(n):
        if b[i] >= a[i]:
            cnt += a[i]
            b[i] -= a[i]
            a[i] = 0
            if b[i] >= a[i + 1]:
                cnt += a[i + 1]
                a[i + 1] = 0
            else:
                cnt += b[i]
                a[i + 1] -= b[i]
        else:
            cnt += b[i]
            a[i] -= b[i]

    print(cnt)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 55564
// https://atcoder.jp/contests/abc143/tasks/abc143_d

#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 2000;

int N;
int L[N_MAX];

void solve() {
  sort(L, L + N);
  int ans = 0;
  FOR(j, 1, N - 2) REP(i, j) {
    int k = lower_bound(L, L + N, L[i] + L[j]) - L;
    ans += max(k - j - 1, 0);
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", L + i);
}

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


Measured memory_bytes: 128
import math

n = int(input())
def plot(x,y):
    print(f'{x:.8f} {y:.8f}')

def kock(n,x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx = (2 * x1 + x2) / 3
    sy = (2 * y1 + y2) / 3
    tx = (x1 + 2 * x2) / 3
    ty = (y1 + 2 * y2) / 3
    ux = (tx - sx)*(1/2)-(ty - sy)*(math.sqrt(3)/2)+sx
    uy = (tx - sx)*(math.sqrt(3)/2)+(ty - sy)*(1/2)+sy
    
    kock(n-1, x1, y1, sx, sy)
    kock(n-1, sx, sy, ux, uy)
    kock(n-1, ux, uy, tx, ty)
    kock(n-1, tx, ty, x2, y2)
    
kock(n,0,0,100,0) 
plot(100,0)



Measured memory_bytes: 5756
ss = raw_input()
odd = ["R", "U", "D"]
even = ["L", "U", "D"]
odds = []
evens = []

for i, s in enumerate(ss, 1):
    if i % 2 == 0:
        if s in even:
            evens.append(True)
        else:
            evens.append(False)
    else:
        if s in odd:
            odds.append(True)
        else:
            odds.append(False)
print 'Yes' if all(odds) and all(evens) else 'No'
        
    

Measured memory_bytes: 2820
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())
#define bit(i) (1LL<<i)
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N;
  while(cin >> N){
    vector<int> W(N); cin >> W;

    int ans = INT_MAX;

    FOR(i,1,N){
      int x = 0, y = 0;
      REP(j,i) x += W[j];
      FOR(j,i,N) y += W[j];
      dump(x,y);
      
      chmin(ans, abs(x-y));
    }
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,b[1<<16],f[1<<16],s;
int a[100001],o[16],ans,num[1<<16],inf;
inline bool cmp(int x,int y){return num[x]<num[y];}
int dp(int i){
	if (f[i]<inf) return f[i]; 
	for (int x=1; x<=15; x++){
		if (((1<<x)&i)==0) continue;
		for (int y=1; y<=15; y++){
			if (x==y) continue;
			if (((1<<y)&i)==0) continue;
			int z=x^y;
			int p=(((i^(1<<z))^(1<<x))^(1<<y));
			if ((1<<z)&i)
				f[i]=min(f[i],dp(p)+2);
			else
				f[i]=min(f[i],dp(p)+1);
		}
	}
	return f[i];
}
int main(){
	scanf("%d",&n);
	for (int x,y,z,i=1; i<n; i++){
		scanf("%d%d%d",&x,&y,&z);
		x++,y++;
		a[x]^=z,a[y]^=z;
	}
	for (int i=1; i<=n; i++) o[a[i]]++;
	for (int i=1; i<=15; i++){
		if (o[i]>=2){
			ans+=o[i]/2; o[i]=o[i]&1;
		}
		if (o[i]) s|=(1<<i);
	}
	memset(f,10,sizeof(f));
	int ful=(1<<16)-1; f[0]=0; inf=f[1];
	printf("%d\n",ans+dp(s));
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void)
{
	long int n, a, b, set, setNum, remainBall;

	scanf("%ld%ld%ld",&n, &a, &b);
	
	/* 青と赤のボールを1セットとし、n番目までに完全な形で並ぶセット数を数える */
	set = a + b;
	setNum = n / set;
	remainBall = n % set;

	/* n番目のボールが青のとき */
	if (remainBall <= a)
	{
		printf("%ld", a * setNum + remainBall);
	}
	/* n番目のボールが赤のとき */
	else
	{
		printf("%ld", a * setNum + a);
	}

	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	TaxIncrease()

}
func TaxIncrease() {

	var A, B int

	fmt.Scan(&A, &B)

	var Aval, Bval float64

	var i float64

	for i = 1; i < 1009; i++ {

		Aval = i * 0.08

		Bval = i * 0.1

		if int(Aval) == A && int(Bval) == B {

			fmt.Println(i)

			return
		}
	}

	fmt.Println(-1)

}


Measured memory_bytes: 512
n=int(input())
p=list(map(int,input().split()))

cnt=0

for i in range(1,n-1):
  f=p[i-1]
  s=p[i]
  t=p[i+1]

  if f<s and s<t:
    cnt+=1
  elif t<s and s<f:
    cnt+=1

print(cnt)

Measured memory_bytes: 38384
N = int(input())
A_str = input()
A = []
for s in A_str.split():
    A.append(int(s))

print(" ".join(map(str, A)))
for i in range(1, len(A)):
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = key
    print(" ".join(map(str, A)))



Measured memory_bytes: 5600
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = Math.max(a,c);
		int f = Math.min(b,d);
		if(f-e>0){
			System.out.println(f-e);
		}
		else{
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstring>
#include<algorithm>
#include<iomanip>
using namespace std;
double a[55];
int n;
int main(){
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	sort(a+1,a+n+1);
	double ans=a[1];
	for(int i=2;i<=n;++i)ans=(ans+a[i])/2.0;
	cout<<fixed<<setprecision(6)<<ans<<endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<int> heights(n);
    vector<vector<int>> roads(n);
    for (int i = 0; i < n; i++) {
        cin >> heights[i];
    }
    for (int i = 0; i < m; i++) {
        int obv1, obv2;
        cin >> obv1 >> obv2;
        roads[obv1-1].push_back(obv2-1);
        roads[obv2-1].push_back(obv1-1);
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        bool biggest = 1;
        for (int j = 0; j < roads[i].size(); j++) {
            if (heights[i] <= heights[roads[i][j]])
                biggest = 0;
        }
        if (biggest) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 8744
#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(){ 
    int n; cin>>n;
    vector<int> p(n),q(n);
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];
    vector<int> a(n);
    rep(i,n) a[i]=i+1;

    //rep(i,n) cout<<a[i]<<endl;
    map<vector<int>,int> mp;
    do{
        mp[a]=mp.size();//aという数字が何番目なのかを表している
    } while(next_permutation(a.begin(),a.end()));

    int ans=abs(mp[p]-mp[q]);
    cout<<ans<<endl;
    return 0;
    
}


Measured memory_bytes: 5248
#include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<ctype.h>
using namespace std;
int temp;
int d,n;
int t[10000];
int a[10000],b[10000],c[10000];
int dp[10000][10000];
int i,j,k;
int main(void){
	int max=0;
	scanf("%d %d",&d,&n);	//d=見る日数 n=服の種類
	for(i=0;i<d;i++){
		scanf("%d",&t[i]);	//i日目の最高温度
	}
	for(i=0;i<d;i++){
		for(j=0;j<n;j++){
			dp[i][j]=-1;	//派手さ
		}
	}
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);	//a=最低温度 b=最高温度 c=派手
	}
	for(i=0;i<n;i++){
		if(a[i]<=t[0] && b[i]>=t[0]){
			dp[0][i]=0;
		}
	}
	for(i=1;i<d;i++){
		for(j=0;j<n;j++){
			if(dp[i-1][j]!=-1){
				for(k=0;k<n;k++){
					if(a[k]<=t[i] && b[k]>=t[i]){
						if(dp[i][k]==-1) {
							dp[i][k]=0;
						}
						temp=c[k]-c[j];
						//printf("c[k]%d c[j]%d\n",c[k],c[j]);
						if(temp<0)	temp=0-temp;
						if(max<=temp){
							max=temp;
						}
						//printf("max%d\n",max);
						//printf("dpa%d i=%d k=%d\n",dp[i][k],i,k);
						if(dp[i][k]<=dp[i-1][j]+max){
							dp[i][k]=dp[i-1][j]+max;
						//printf("aa%d %d %d %d\n",dp[i][j],dp[i][k],i,j);
						}
					}
			max=0;
				}
			}
			//printf("\n");
		}
		//printf("\n");
	}
	/*for(i=0;i<d;i++){ //でバグ
		printf("%d\n",t[i]);
		for(j=0;j<n;j++){
			printf("%d ",dp[i][j]);
		}
		printf("\n");
	}*/			
	max=0;
	for(j=0;j<n;j++){
		//printf("%d ",dp[d-1][j]);
		if(dp[d-1][j]>max){
			max=dp[d-1][j];
		}
	}
	//printf("\n");
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 7448
#include<iostream>
#include<cstring>
#include<cstdio>
#include<unordered_map>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
const int N = 200 + 5;
const int M = 8 + 5;
const int INF = 0x3f3f3f3f;

unordered_map<int, int> mp;
int main(){
    int n, x;
    cin >> n;
    while(n --){
        cin >> x;
        ++ mp[x];
    }
    int cnt = 0;
    for(auto &i: mp){
        cnt += i.second%2;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4388
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
    int x=0,N,keta=1;
    cin>>N;
    for(int i=1;i<=N;i++){
         for(int j=6;j>=2;j--){
             if(i/pow(10,j-1)>=1){
                 keta=j;
                 goto lol;
             }
         }
    lol:if(keta%2==1)x++;
    }
cout<<x<<endl;
return 0;
}

Measured memory_bytes: 256
def count_bit(k, upto):
  # count total k-th bit parity from 0 to upto
  if k == 0:
    if upto % 4 in [0,3]:
      return 0
    else:
      return 1
  base = 2 ** k
  #print('base={0}'.format(base))
  upto = upto % (base * 2)
  #print('upto is now {0}'.format(upto))
  if upto  < base:
    return 0
  upto -= (base-1)
  #print(upto)
  return upto % 2

def solve(a, b):
  k = 0
  kk = 2 ** k
  val = 0
  while b >= kk:
    ak = count_bit(k, a-1)
    bk = count_bit(k, b)
    #print('k = {0}, ak = {1}, bk = {2}, ak^bk = {3}'.format(k, ak, bk, ak^bk))
    val += 2 ** k * (ak ^ bk)
    k += 1
    kk = 2 ** k
  return val

a, b = map(int, input().split())

ans = solve(a, b)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll md = 1e9+7;

const ll b = 2;//1342231LL;

const int mx = 2e5;

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

	vector<ll> pw(mx);
	pw[0] = 1;
	rep(i,1,mx) pw[i] = pw[i-1]*b % md;

	string s;
	cin >> s;
	int n = sz(s)/2;
	string a = s.substr(0, n);

	vector<ll> pre(n+1);
	rep(i,0,n) pre[i+1] = (pre[i]*b + a[i])%md;

	int len;
	for(len = n; len --> 0;){
		if((pre[n]-pre[n-len]*pw[len]%md - pre[len])%md == 0)
			break;
	}
	ll l, r;
	cin >> l >> r;

	vector<ll> fibs(200);
	fibs[0] = len, fibs[1] = n-len;
	rep(i,2,200) fibs[i] = fibs[i-1] + fibs[i-2];

	vector<vector<ll>> cnts(200, vector<ll>(26));
	rep(i,0,26) cnts[0][i] = count(a.begin(),a.begin()+len, 'a'+i);
	rep(i,0,26) cnts[1][i] = count(a.begin(),a.begin()+n-len, 'a'+i);
	rep(i,2,200) rep(j,0,26) cnts[i][j] = cnts[i-1][j]+cnts[i-2][j];

	function<ll(ll,int,int)> que = [&](ll pos, int c, int ix){
		assert(fibs[ix] >= pos);
		if(ix <= 1){
			return (ll)count(a.begin(),a.begin()+pos, 'a'+c);
		}
		if(pos <= fibs[ix-1]) return que(pos, c, ix-1);
		return cnts[ix-1][c] + que(pos-fibs[ix-1],c,ix-2);
	};

	function<ll(ll,int)> f = [&](ll pos, int c){
		int i = 0;
		while(fibs[i] < pos) ++i;
		return que(pos, c, i);
	};
	rep(c,0,26){
		cout << f(r,c) - f(l-1,c) << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 2964
def main():
    S=list(input())
    T=list(input())

    res=len(T)
    for i in range(len(S)-len(T)+1):
        res_=0
        for j in range(len(T)):
            if T[j]!=S[j+i]:
                res_+=1
        if res_<=res:
            res=res_

    print(res)

if __name__=="__main__":
    main()

Measured memory_bytes: 64960
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];
ll treasure[3030][3030];
ll dp[3030][3030][4];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	vector<ll>card(1);
	card[0] = 1;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	rep(i, n - 1) {
		if (a[i] == a[i + 1]) {
			ll k = card.size();
			card[k - 1]++;
		}
		else {
			card.push_back(1);
		}
	}
	ll odd = 0, even = 0;
	ll k = card.size();
	rep(i, k) {
		if (card[i] % 2) {
			odd++;
		}
		else {
			even++;
		}
	}
	if (even % 2) {
		even--;
	}
	ll ans = odd + even;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4908