akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

using namespace std;

#define MAX 10000
#define NIL -1

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

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
	if(u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right,d+1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if(T[u].left != NIL)
		h1 = setHeight(T[u].left)  + 1;
	if(T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
	if( T[u].parent == NIL ) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
		return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
		return T[T[u].parent].right;
	return NIL;
}

void print(int u) {
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	int deg = 0;
	if(T[u].left  != NIL) deg++;
	if(T[u].right != NIL) deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent == NIL) {
		printf("root\n");
	} else if(T[u].left == NIL && T[u].right == NIL) {
		printf("leaf\n");
	} else {
		printf("internal node\n");
	}
}

int main(void) {
	int v, l, r, root = 0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) T[i].parent = NIL;
	for(int i=0;i<n;i++) {
		scanf("%d %d %d",&v,&l,&r);
		T[v].left  = l;
		T[v].right = r;
		if(l != NIL) T[l].parent = v;
		if(r != NIL) T[r].parent = v;
	}
	
	for(int i=0; i<n; i++)
	if(T[i].parent == NIL) root = i;
	
	setDepth(root,0);
	setHeight(root);
	
	for(int i=0;i<n;i++) print(i);
	
	return 0;
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000007
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;


int main(){
int n ;
cin>>n;
vector<pair<int,int> >v(n);
for(int index = 0 ;index < n;index++)
{
    cin>>v[index].first>>v[index].second;
}
bool ans= false;
for(int index = 0;index <=n-3;index++)
{
    if((v[index].first==v[index].second)&&(v[index+1].first==v[index+1].second)&&(v[index+2].first==v[index+2].second))
    {
        ans = true;

    }
}
if(ans)
    cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
 return 0;
}


Measured memory_bytes: 3632
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N, K = map(int, input().split())
a = list(map(int, input().split()))

dp = [False]*(K+1)

dp[0] = False
for i in range(1, K+1):
    flag = False
    for e in a:
        if e <= i:
            flag = flag or (not dp[i-e])
    dp[i] = flag
if dp[K]:
    print("First")
else:
    print("Second")


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=100100100;
const int mod=(int)1e9+7;

int main(){
    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n);
    rep(i,0,n){
        cin>>a.at(i);
    }
    rep(i,0,n){
        cin>>b.at(i);
    }
    rep(i,0,n){
        cin>>c.at(i);
    }
    sort(all(a));
    sort(all(c));
    ll ans=0;
    rep(i,0,n){
        int aa=lower_bound(all(a),b.at(i))-a.begin();
        int cc=c.end()-upper_bound(all(c),b.at(i));
        ans+=(ll)aa*cc;
    }
    cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<lol, lol>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, c;
  cin >> n >> c;
  int p, ans = 0;
  n ++;
  rep(i, c){
    cin >> p;
    ans += p;
  }
  cout << UPDigit(ans, n) << '\n';
  return 0;
}



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


//-----------------------------------------------------------------------------

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

	int a,b;cin>>a>>b;
	cout<<(a+b+1)/2<<endl;

	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	ps := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &ps[i])
	}

	ans := 0
	for i := 0; i < n; i++ {
		// i = piだったらswapしてみる
		if i+1 == ps[i] {
			if i != n-1 {
				tmp := ps[i]
				ps[i] = ps[i+1]
				ps[i+1] = tmp
			} else {
				tmp := ps[i]
				ps[i] = ps[i-1]
				ps[i-1] = tmp
			}
			ans++
		}
	}

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	fmt.Fprintln(w, ans)
}


Measured memory_bytes: 1920
import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    S = input()
    if S == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
        return

    l = [0]*26
    for c in S:
        l[ord(c)-ord('a')] += 1

    if len(S) < 26:
        i = l.index(0)
        print(S+chr(i+ord('a')))
        return

    for i in range(len(S)-1, 0, -1):
        if S[i-1] < S[i]:
            break

    c = min(S[j] for j in range(i, len(S)) if S[j] > S[i-1])
    print(S[:i-1]+c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9808
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstdlib>
using namespace std;
typedef long long ll;
const int NN = 1100;

ll f[NN][NN];
ll mod, k, n, a[NN], b[NN], ans, x;
int vis1[30], vis2[30];
char s[NN];


int main(){
	//freopen("a.in", "r", stdin);

	scanf("%lld", &n);
	ll ans = n / 500 * 1000;
	n %= 500;
	ans += n / 5 * 5;
	cout << ans;
	
	return 0;
} 

Measured memory_bytes: 256
#include <vector>
#include <array>
#include <algorithm>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <assert.h>
#include <queue>
#include <deque>
#include <iomanip>
#include <numeric>
#include <fstream>

using namespace std;

typedef long long ll;
typedef long double ld;

#define fi first
#define se second

#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;

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

const ll A = 'z' - 'a' + 1;
void no() {
    cout << "-1" << endl;
    exit(0);
}

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    string s, t;
    cin >> s >> t;
    ll n, m;
    n = sz(s);
    m = sz(t);
    vvl nxt(n + 1, vl(A, n));
    for (int i = 0; i < A; ++i) {
        char ch = 'a' + i;
        for (int j = n - 1; j >= 0; --j) {
            nxt[j][i] = (s[j] == ch ? j : nxt[j + 1][i]);
        }
    }

    ll ans = 0;
    ll index = 0;
    ll jumps = 0;
    for (int i = 0; i < m; ++i) {
        char ch = t[i];
        ll idx = ch - 'a';
        ll new_index = nxt[index][idx];
        if (new_index == n) {
            index = 0;
            ++jumps;
            new_index = nxt[index][idx];
            if (new_index == n) no();
        }
        index = new_index + 1;
        if (index >= n) {
            ++jumps;
            index -= n;
        }
    }
    ans = jumps * n + index;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 24784
import math
S = list(input())
r_cnt = 0
l_cnt = 0
ans = [0]*len(S)
for i,s in enumerate(S):
    if s == 'R':
        if r_cnt == 0:
            r_cnt += 1
            if i == 0:
                continue
            ans[i - l_cnt] += math.ceil(l_cnt/2)
            ans[i - l_cnt - 1] +=l_cnt - math.ceil(l_cnt/2)
            l_cnt = 0
        else:
            r_cnt += 1

    if s == 'L':
        if l_cnt == 0:
            l_cnt += 1
            ans[i-1] += math.ceil(r_cnt/2)
            ans[i] += r_cnt - math.ceil(r_cnt/2)
            r_cnt = 0
        else:l_cnt += 1

    if i == len(S)-1:
        ans[i-l_cnt+1] += math.ceil(l_cnt/2)
        ans[i-l_cnt] += l_cnt - math.ceil(l_cnt/2)


print(*ans)

Measured memory_bytes: 7088
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class PointIdx{
    public:
    int ptr;
    map<pair<int,int>,int>idx;
    PointIdx(){}
    PointIdx(int start):ptr(start){}
    int getIdx(int x,int y){
        if(idx.find({x,y})==idx.end()){
            idx[{x,y}]=++ptr;
        }
        return idx[{x,y}];
    }
};
class Graph{
    public:
    class Edge{
        public:
        int t,w;
        Edge(){}
        Edge(int to,int wt):t(to),w(wt){}
    };
    typedef Edge Node;
    const static int MAXN=5e5+10;
    vector<Edge>G[MAXN];
    void insertEdge(int f,int t,int w){
        G[f].push_back(Edge(t,w));
        G[t].push_back(Edge(f,w));
    }
    int vis[MAXN];
    int dis[MAXN];
    class Cmp{
        public:
        bool operator ()(Node &n1,Node &n2){
            return n1.w>n2.w;
        }
    };
    void dijstra(){
        priority_queue<Node,vector<Node>,Cmp>pq;
        memset(vis,0,sizeof(vis));
        memset(dis,0x3f,sizeof(dis));
        pq.push(Node(1,0));
        dis[1]=0;
        while(!pq.empty()){
            auto t=pq.top();
            pq.pop();
            if(vis[t.t])continue;
            vis[t.t]=true;
            for(auto e:G[t.t]){
                if(dis[t.t]+e.w<dis[e.t]){
                    dis[e.t]=dis[t.t]+e.w;
                    pq.push(Node(e.t,dis[e.t]));
                }
            }
        }
    }
};
class Solver{
    public:
    const static int MAXN=5e5+10;
    const static int INF=0x3f3f3f3f;
    int n,m;
    Graph *graph;
    PointIdx *pidx;
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);cout.tie(0);
        cin>>n>>m;
        graph=new Graph();
        pidx=new PointIdx(n);
        for(int u=0;u<m;u++){
            int p,q,c;
            cin>>p>>q>>c;
            int pc=pidx->getIdx(p,c);
            int qc=pidx->getIdx(q,c);
            graph->insertEdge(p,pc,1);
            graph->insertEdge(q,qc,1);
            graph->insertEdge(pc,qc,0);
        }
        graph->dijstra();
        int ans=graph->dis[n];
        if(ans==INF)ans=-1;
        else ans/=2;
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

Measured memory_bytes: 60156
#include<bits/stdc++.h>
using namespace std;
  int n1,n,l,t,i,x,a,b,ans,c;
  string s;
int main()
{

  	cin>>a>>b>>c;
  	ans=0;
  	for (i=1;i<=a;i++)
  	  {
  	  	cin>>n;
  	  	if (n<b||n>=c)
  	  	  ans++;
		}
  	cout<<ans<<endl;
  	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <bitset>
#include <iostream>
#include <sstream>
using namespace std;
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define deb(x) cerr << ">>>>>>>>>>>>>>>>>>>> "#x" = " << x << " <<<<<<<<<<<<<<<<<<<<\n"
#define debd(x) fprintf(stderr, ">>>>>>>>>>>>>>>>>>>> %s = %d <<<<<<<<<<<<<<<<<<<<\n", #x, x)
#define debs(x) fprintf(stderr, ">>>>>>>>>>>>>>>>>>>> %s = %s <<<<<<<<<<<<<<<<<<<<\n", #x, x)
#define debll(x) fprint(stderr, ">>>>>>>>>>>>>>>>>>>> %s = %lld <<<<<<<<<<<<<<<<<<<<\n", #x, x)
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mems(a) memset(a, 0, sizeof(a))
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
//bitmask
int onbit(int x, int pos) {x |= (1 << pos); return x;}
int offbit(int x, int pos) {x &= ~(1 << pos); return x;}
int test(int x, int pos) {return x & (1 << pos);}
int flip(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int onbitall(int x, int pos) {x = (1 << pos)-1; return x;}
//constants
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
//moves
const int dx1[] = {0, 1, 0, -1};
const int dy1[] = {1, 0, -1, 0};
const int dx2[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy2[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int k, n;
bool disliked[123];

bool cek(int x) {
    while(x > 0) {
        int now = x % 10;
//        debd(now);
//        debd(x);
        if(disliked[now]) return false;
        x /= 10;
    }
	return true;
}

int main() {
//  freopen("input.in", "r", stdin);
	sf("%d %d", &n, &k);
	fr(i, 0, 122) disliked[i] = false;
    fr(i, 0, k) {
        int qwe;
        sf("%d", &qwe);
        disliked[qwe] = true;
    }

	fr(i, n, INT_MAX-1) {
//		deb(i);
		if(cek(i)) {
			pf("%d\n", i);
			return 0;
		}
	}

	return 0;
}


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

using namespace std;

typedef vector<double> vec;
typedef vector<vec> mat;

#define EPS (1e-9)

// ガウスの消去法で連立式をとく
vec gauss_jordan(const mat&A,const vec &b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i = 0; i < n;i++)
    for(int j=0;j<n;j++)
      B[i][j]=A[i][j];
  for(int i = 0; i < n; i++)
    B[i][n]=b[i];
  // 各変数に注目
  for(int i = 0; i < n; i++){
    // 最大の係数の絶対値をもつものをi番目に持ってくる
    int piv=-1;
    double val=-1;
    for(int j=i;j<n;j++){
      if(val<abs(B[j][i])){
	piv=j;
	val=abs(B[j][i]);
      }
    }
    // B[i][n]が0でない場合は、解は存在しない
    // 0である場合は、複数の解が存在する可能性あり
    if(piv==-1||val<EPS)return vec();
    swap(B[piv],B[i]);
    // i行目をそれぞれB[piv][i]の値で割る
    double divNum=B[i][i];
    for(int j = i; j <= n; j++)
      B[i][j]/=divNum;
    // それぞれの行から、i行目の値を引くかんじ
    for(int j = 0; j < n; j++){
      if(i==j)continue;
      double mulnum=B[j][i];
      for(int k = i; k <= n; k++)
	B[j][k]-=mulnum*B[i][k];
    }
  }
  vec res(n);
  for(int i = 0; i < n; i++)res[i]=B[i][n];
  return res;
}

const int INF=1000000000;
int n,s,g;
int qs[101];
int as[101][101];
int d[101][101];

int main(){

  while(cin>>n>>s>>g&&(n|s|g)){
    s--;g--;
    for(int i=0;i<n;i++)cin>>qs[i];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i!=j)d[i][j]=INF;
	else d[i][j]=0;
	cin>>as[i][j];
	// ルート無し
	if(as[i][j]==0)as[i][j]=INF;
	d[i][j]=min(d[i][j],as[i][j]);
      }
    }
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	for(int k=0;k<n;k++)
	  d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
    if(d[s][g]==INF){
      cout<<"impossible"<<endl;
      continue;
    }
    mat A(n,vec(n,0));
    vec b(n,0);
    for(int i=0;i<n;i++){
      if(i==g){
	A[i][i]=1;
	continue;
      }
      if(d[i][g]==INF){
	A[i][i]=1;
	continue;
      }
      int cnt=0;
      int scost=0;
      // 最短距離を構成するルートのみ考慮
      for(int j=0;j<n;j++){
	if(as[i][j]==INF)continue;
	if((qs[i]&&as[i][j]+d[j][g]==d[i][g])
	   ||!qs[i]){
	  cnt++;
	  scost+=as[i][j];
	  A[i][j]=1;
	}
      }
      if(cnt!=0)b[i]=(double)scost/cnt;
      if(cnt!=0)for(int j=0;j<n;j++)A[i][j]/=(-cnt);
      A[i][i]+=1;
    }
    vec v=gauss_jordan(A,b);
    printf("%.10f\n",v[s]);
  }

  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int m, f, r;
    while(1){
        cin >> m >> f >> r;
        if(m == -1 and f == -1 and r == -1){
            break;
        }
        else{
            if(m == -1 or f == -1){
                printf("F\n");
            }
            else if(m + f >= 80){
                printf("A\n");
            }
            else if(m + f >= 65 and m + f < 80){
                printf("B\n");
            }
            else if(m + f >= 50 and m + f < 65){
                printf("C\n");
            }
            else if(m + f >= 30 and m + f < 50){
                if(r >= 50){
                    printf("C\n");
                }
                else{
                    printf("D\n");
                }
            }
            else{
                printf("F\n");
            }

        }
    }
    return 0;
}


Measured memory_bytes: 2988
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll a[n],b[n];
  REP(i,n){
    cin >> a[i];
  }
  REP(i,n){
    cin >> b[i];
  }
  ll mx = 0;
  REP(i,n){
    ll sum = 0;
    REP(j,i+1){
      sum += a[j];
    }
    for(int k = i;k < n;k++){
      sum += b[k];
    }
    mx = max(mx,sum);
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    string a;
    cin >> a;
    reverse(a.begin(), a.end());
    a += '0';

    int n = a.size();
    vector<vector<int>> dp(n, vector<int>(2, 0));

    int ans = 0;
    for (int i = 0; i < a.size(); i++)
    {
        int curr = a[i] - '0';

        if (!i)
        {
            dp[i][0] = curr;
            dp[i][1] = 10 - curr;
        }
        else
        {
            dp[i][0] = curr + dp[i - 1][0];
            dp[i][1] = 10 - curr + dp[i - 1][0];
            curr++;

            dp[i][0] = min(dp[i][0], curr + dp[i - 1][1]);
            dp[i][1] = min(dp[i][1], 10 - curr + dp[i - 1][1]);
        }
    }
    cout << min(dp[n - 1][0], dp[n - 1][1]) << endl;
}

Measured memory_bytes: 55940
#include<stdio.h>
#include<math.h>

struct Point{double x,y;};

void koch(int n, Point a, Point b){
  if(n==0) return;

  Point s,t,u;
  double th = M_PI*60.0/180.0;

  s.x = (2.0*a.x + 1.0*b.x) / 3.0;
  s.y = (2.0*a.y + 1.0*b.y) / 3.0;
  t.x = (1.0*a.x + 2.0*b.x) / 3.0;
  t.y = (1.0*a.y + 2.0*b.y) / 3.0;
  u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
  u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  Point a,b;
  int n;

  scanf("%d",&n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}



Measured memory_bytes: 2764
n=int(input())
a=list(map(int,input().split()))
count=0
a_plus=[]
a_minu=[]
for i in range(n):
    a_plus.append(a[i]+1)
    a_minu.append(a[i]-1)
import collections
a.extend(a_plus)
a.extend(a_minu)
data=collections.Counter(a)
data=sorted(data.items(),key=lambda x:x[1],reverse=True)
print(data[0][1])


Measured memory_bytes: 31580
#include<stdio.h>

int main(){
	int n,h[105]={0},i,j,lr[102][100][2],clr[102]={0};
	long ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&h[i]);
/*	for(i=1;i<n+1;i++){
		if(a[i-1]<a[i]&&a[i]>a[i+1]){
			hh[c]=i;
			c++;
		}
		if(a[i-1]>a[i]&&a[i]<a[i+1]){
			hc[c2]=i;
			c2++;
		}
	}*/
	for(i=0;i<=101;i++){
		for(j=1;j<=n+1;j++){
			if(h[j-1]<i&&h[j]>=i)lr[i][clr[i]][0]=j;
			if(h[j+1]<i&&h[j]>=i){
				lr[i][clr[i]][1]=j;
				clr[i]++;
			}
		}
	}	
/*	for(i=0;i<=100;i++){
		for(j=0;j<clr[i];j++)printf("%d,%d,%d\n",i,lr[i][j][0],lr[i][j][1]);
	}*/
	for(i=0;i<=101;i++){
		ans+=clr[i];
	}
	printf("%ld\n",ans);
	return 0;
}

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

int main() {
  string S;
  int N, res = 0, rmax = 0;

  cin >> N >> S;

  for (int i = 0; i < N; i++) {
    if (S[i] == 'I')
      res += 1;
    if (S[i] == 'D')
      res -= 1;
    if (res > rmax)
      rmax = res;
  }

  cout << rmax << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

ll INF = 1e9 + 7;

int main() {
	ll n;
	cin >> n;
	ll ans = 1;
	for (ll i = 1; i <= n; i++) {
		ans *= i;
		ans %= INF;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  for(int i = k;i < n;i++){
    if(a[i] > a[i - k])cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 4836
import sys
import math
import bisect

def main():
    A = [1, 3, 5, 7, 8, 10, 12]
    B = [4, 6, 9, 11]
    C = [2]
    x, y = map(int, input().split())
    if x in A and y in A:
        print('Yes')
    elif x in B and y in B:
        print('Yes')
    elif x in C and y in C:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.util.*;

class Main {
    public static void main(String args[]){

        Scanner s=new Scanner(System.in);
        Integer n= s.nextInt();
        long min=Long.MAX_VALUE;
        int count=0;
        for (int i = 1; i <=n ; i++) {
            Integer p= s.nextInt();
            if(p<=min){
                count++;
            }
            min=Math.min(p,min);
        }
        System.out.println(count);




    }
}

Measured memory_bytes: 62928
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mx5 100005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int h[2*mx5], a[2*mx5];
ll BIT[2*mx5] = {};

ll qry(int h) {
    ll out = 0;
    for (int i = h; i; i ^= i & (-i)) {
        out = max(out, BIT[i]);
    }
    return out;
}

void upd(ll b, int h) {
    for (int i = h; i < 2*mx5; i += i & (-i)) {
        BIT[i] = max(BIT[i], b);
    }
}

int main() {
    nfs
    int i, j, n;
    cin >> n;
    
    for (i = 0; i < n; i++) {
        cin >> h[i];
    }

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

    for (i = 0; i < n; i++)
        upd(qry(h[i]) + a[i], h[i]);
    
    cout << qry(n);
}

Measured memory_bytes: 6768
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 998244353;
const int N = 3006;
const ll INF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    n--;
    
    while(n) {
        int cur = 0;
        for(int i = 1; i * i <= n; i++) {
            if(n % i == 0) {
                cur += 1;
                if(n / i != i) {
                    cur += 1;
                }
            }
        }
        ans += cur;
        n--;
    }
    cout << ans << '\n';
    return 0;
}

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

#define loop(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
int d,n,m;
vector<int> v;

int main(){
  while(cin>>d,d){
    cin>>n>>m;
    v.clear();
    v.push_back(0);
    v.push_back(d);
    int x;
    loop(i,n-1){
      cin>>x;
      v.push_back(x);
    }
    sort(all(v));
    int k;
    int sum=0;
    loop(j,m){
      cin>>k;
      vector<int>::iterator p=lower_bound(all(v),k);
      int a=*p;
      int b=*(p-1);
      sum+=min(abs(a-k),abs(b-k));
    }
    cout<<sum<<endl;
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int ui;
typedef string st;
typedef vector<int> vi;
typedef vector <ll> vll;
typedef pair<int, int> pii;
typedef set<int> seti;
#define all(v) ((v).begin()),((v).end())
#define allr(v) v.rbegin(),v.rend()
#define repi(n)  for(int i = 0; i < (int)(n); ++i)
#define repj(n)  for(int j = 0; j < (int)(n); ++j)
#define endl "\n"
#define sz(n) n.size()
#define RT(v) return cout<<v,0
#define watch(x) cout<<#x<<" = { "<<x<<" }\n"
ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }
void run() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
void Ahmed_Meky()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


int main()
{

	Ahmed_Meky();  		   /*█▀▀▄░░░░░░░░░░░▄▀▀█
						   ░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
						   ░░▀▄░░░▀░░░░░▀░░░▄▀
						   ░░░░▌░▄▄░░░▄▄░▐▀▀
						   ░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
						   ░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
						   ▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
						   █░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
						   ░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
						   ░░░█░░░░░░░░░░░▄▀▄░▀▄
						   ░░░█░░░░░░░░░▄▀█░░█░░█
						   ░░░█░░░░░░░░░░░█▄█░░▄▀
						   ░░░█░░░░░░░░░░░████▀
						   ░░░▀█▄▄▄▀▀▀▀▄▄▄█▀*/
	
	st s, t;  cin >> s >> t;
	t.pop_back();
	if (s == t)cout << "Yes";
	else cout << "No";
    //system("pause");
    return 0;

}
				


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[10010];string s;ll l;double d;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	double nextDouble(){scanf("%lf", &d);return d;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

double dp[(1<<12) + 10][12 + 10];

vector<string> split(string s, char c = ' '){
	vector<string> ret;
	stringstream ss(s);
	string t;
	while(getline(ss, t, c)) ret.pb(t);
	return ret;
}

int perseInt(string s){
	int ret = 0;
	for(auto& c : s){
		ret *= 10;
		ret += c - '0';
	}
	return ret;
}

double calc(int r1, int r2){
	return sqrt((r1+r2)*(r1+r2)-(r1-r2)*(r1-r2)) + r2 - r1;
}

int main(){
	string s;
	while(getline(cin, s)){
		auto u = split(s);
		int r = perseInt(u[0]);
		vector<int> v;
		for(int i = 1; i < u.size(); i++) v.pb(perseInt(u[i]));
		int n = v.size();
		for(int i = 1; i < 1<<n; i++){
			for(int j = 0; j <= 12; j++) dp[i][j] = 1e18;
		}

		for(int i = 0; i < n; i++){
			dp[1<<i][i] = v[i] * 2;
		}

		for(int i = 1; i < 1<< n; i++){
			for(int j = 0; j < n; j++){
				if(i & (1<<j)) continue;
				int nxt = i | (1<<j);
				for(int k = 0; k < n; k++) {
					if((i & (1<<k)) == 0) continue;
					dp[nxt][j] = min(dp[nxt][j], dp[i][k] + calc(v[k], v[j]));
				}
			}
		}
		double ans = 1e18;
		int goal = (1<<n) -1;
		for(int i = 0; i < n; i++) ans = min(ans, dp[goal][i]);
		cout<<(ans <= r ? "OK" : "NA")<<endl;
	}
}

Measured memory_bytes: 3656
//https://qiita.com/drken/items/dc53c683d6de8aeacf5a
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; i++) {
        for(int j = 0; j <= K; j++){
          if(i-j >= 0)chmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
lists = [list(map(int,input().split())) for i in range(m)]
Min = min(a) + min(b)
for x,y,c in lists:
    Min = min(Min,a[x-1] + b[y-1] - c)
print(Min)



Measured memory_bytes: 80324
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if(!(A%2) && !(B%2) && !(C%2) && A==B && B==C) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  while(!(A%2) && !(B%2) && !(C%2)) {
    int na = B/2+C/2, nb = A/2+C/2, nc = A/2+B/2;
    A = na;
    B = nb;
    C = nc;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

long long prime = 998244353;

long long mod(long long x) { 
    return (x % prime + prime) % prime;
}

long long pow(long long x, long long r) {
    if (r == 0) return 1LL;
    long long y = pow(x, r/2);
    long long z = (y * y) % prime;
    if (r % 2 == 0) {
        return z;
    }
    return (z * x) % prime;
}

long long inv(long long x) {
    return pow(x, prime-2);
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long long> xs(n);
    for (long long& x : xs) {
        cin >> x;
    }
    int m = *max_element(xs.begin(), xs.end());
    vector<int> smallest_prime(m+1, 0);
    for (int i = 2; i <= m; ++i) {
        if (smallest_prime[i] == 0) {
            for (int k = i; k <= m; k += i) {
                if (smallest_prime[k] == 0) {
                    smallest_prime[k] = i;
                }
            }
        }
    }
    function<vector<int> (int)> get_divisors = [&](int k) {
        vector<int> ds;
        if (k == 1) {
            ds.push_back(1);
            return ds;
        }
        vector<int> ps;
        int p = smallest_prime[k];
        int p_r = p;
        ps.push_back(1);
        while (k % p == 0) {
            ps.push_back(p_r);
            p_r *= p;
            k /= p;
        }
        vector<int> others = get_divisors(k);
        for (int a : others) {
            for (int b : ps) {
                ds.push_back(a*b);
            }
        }
        return ds;
    };
    vector<long long> divisor_sum(m+1, 0);
    for (long long x: xs) {
        for (int d : get_divisors(x)) {
            divisor_sum[d] = (divisor_sum[d] + x) % prime;
        }
    }
    vector<long long> magic(m+1, 0);
    vector<long long> mem_inv(m+1, 0);
    magic[1] = 1;
    for (int i = 2; i <= m; ++i) {
        int p = smallest_prime[i];
        if (mem_inv[p] == 0) {
            mem_inv[p] = inv(p);
        }
        long long inv_p_r = mem_inv[p];
        int p_r = p;
        while (i % (p_r * p) == 0) {
            p_r *= p;
            inv_p_r = (inv_p_r * mem_inv[p]) % prime;
        }
        magic[i] = mod(mod(inv_p_r - p * inv_p_r) * magic[i/p_r]);
    }
    long long sum = 0;
    for (int i = 1; i <= m; ++i) {
        long long a = (divisor_sum[i] * divisor_sum[i]) % prime;
        sum = (sum + a * magic[i]) % prime;
    }
    for (long long x : xs) {
        sum = mod(sum - x);
    }
    sum = mod(sum * inv(2));
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 29184
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void)
{
    int n;
    double a_i;
    double a[1000];
    double sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a_i;
        a[i] = 1 / a_i;
    }
    for (int i = 0; i < n; i++)
    {
        sum += a[i];
    }
    printf("%5lf", 1/sum);
    
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x<<"="<<x<<endl

#define fi first
#define se second

typedef long long ll;
/*
typedef vector<int> vec;
typedef vector<vec> mat;

int mod;

mat operator*(const mat& a,const mat& b){
  int n=a.size();
  mat res(n,vec(n,0));
  rep(i,n)rep(k,n)rep(j,n){
    ll add=(ll)a[i][k]*(ll)b[k][j];
    add%=mod;
    (res[i][j]+=add)%=mod;
  }
  return res;
}

mat operator+(const mat& a,const mat& b){
  int n=a.size();
  mat res(n,vec(n,0));
  rep(i,n)rep(j,n)(res[i][j]+=(a[i][j]+b[i][j]))%=mod;
  return res;
}*/

ll mod;

struct form{
  ll a,b,bc;
};

form operator+(const form& x,const form& y){
  return (form){(x.a+y.a)%mod,(x.b+y.b)%mod,(x.bc+y.bc)%mod};
}

form update(form x,char c,ll num){
  if(isdigit(c)){
    return (form){x.a,x.b,(x.b*(c-'0')%mod+x.bc*10)%mod};
    //A[0][0]=1; A[1][1]=1; A[2][1]=c-'0'; A[2][2]=10; A[3][3]=1;
  }else if(c=='+'){
    return (form){(x.a+x.bc)%mod,num,0};
    //A[0][0]=1; A[0][2]=1; A[1][3]=1; A[3][3]=1;
  }else if(c=='*'){
    return (form){x.a,x.bc,0};
    //A[0][0]=1; A[1][2]=1; A[3][3]=1;
  }
}

char S[2001][2001];
ll num[2001][2001];
form dp[2001][2001];

int main(){
  
  int H,W;

  scanf("%d%d%lld",&H,&W,&mod);

  rep(i,H){
    scanf("%s",S[i]);
  }

  dp[0][0]=(form){0,1,0};
  dp[0][0]=update(dp[0][0],S[0][0],1);
  num[0][0]=1;

  repl(i,1,H){
    dp[i][0]=update(dp[i-1][0],S[i][0],1);
    num[i][0]=(num[i][0]+num[i-1][0])%mod;
  }
  repl(j,1,W){
    dp[0][j]=update(dp[0][j-1],S[0][j],1);
    num[0][j]=(num[0][j]+num[0][j-1])%mod;
  }
  repl(i,1,H)repl(j,1,W){
    dp[i][j]=update(dp[i-1][j],S[i][j],num[i-1][j])+update(dp[i][j-1],S[i][j],num[i][j-1]);
    num[i][j]=(num[i-1][j]+num[i][j-1])%mod;
  }
  cout<<(dp[H-1][W-1].a+dp[H-1][W-1].bc)%mod<<endl;

  return 0;
}



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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    IOS;

    string S;
    cin >> S;

    int ans = 0;
    if(S[0] == 'R') {
        if(S[1] == 'S') {
            ans = 1;
        }
        else {
            if(S[2] == 'R') {
                ans = 3;
            }
            else {
                ans = 2;
            }
        }
    }
    else if(S[1] == 'R') {
        if (S[2] == 'R') {
            ans = 2;
        } else {
            ans = 1;
        }
    }
    else if(S[2] == 'R') {
        ans = 1;
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b;
    char s[2];
    
    scanf("%d%s%d", &a, s, &b);
    
    if (s[0]=='+') {
        printf("%d", a+b);
    } else {
        printf("%d", a-b);
    }
    
    return 0;
}



Measured memory_bytes: 1712
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;


// a と b の最大公約数を返す
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}


ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}



// 素数判定
bool is_prime(ll N) {
    if (N == 1) return false;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}


// 約数列挙
vector<ll> enum_divisors(ll N) {
    vector<ll> res;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}


// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll N){
    vector<pair<ll, ll>> res;
    for(ll i = 2; i * i <= N; i++){
        if(N % i != 0)  continue;
        ll ex = 0;

        while(N % i == 0){
            ex++;
            N /= i;
        }

        res.push_back({i, ex});
    }

    if(N != 1)  res.push_back({N, 1});
    return res;
};


int main(){
    ll n, k;    cin >> n >> k;
    vector<ll> a(n);
    ll su = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        su += a[i];
    }

    vector<ll> divs = enum_divisors(su);

    reverse(divs.begin(), divs.end());
    for(auto d: divs){
        ll sux = 0;
        vector<ll> b;
        for(int i = 0; i < n; i++){
            sux += a[i] % d;
            b.push_back(a[i] % d);
        }
        sort(b.begin(), b.end());
        ll num = n - sux / d;
        ll res = 0;
        for(int i = 0; i < num; i++){
            res += b[i];
        }
        if(res <= k){
            cout << d << endl;
            return 0;
        }
    }



    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    for(i=m/n;i>=1;i--)
    {
        if(m%i==0){printf("%d\n",i);break;}
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
typedef std::pair<int,int> pii;
inline bool up(int&x,const int y){return x<y?x=y,1:0;}
inline bool down(int&x,const int y){return x>y?x=y,1:0;}
const int mod=998244353;
#define N 200005
int n,q;
ll pw[N],sum[N];
inline void reduce(ll&x){
	x-=mod,x+=x>>31&mod;
}
struct node{
	int l,r; mutable int v;
	inline node(int L,int R=-1,int V=0):l(L),r(R),v(V){}
	inline bool operator<(const node&x)const{
		return l<x.l;
	}
};
#define It std::set<node>::iterator
std::set<node> s;
inline It split(int p){
	It it=s.lower_bound(node(p));
	if(it!=s.end()&&it->l==p) return it;
	--it;
	int l=it->l,r=it->r,v=it->v;
	s.erase(it);
	s.insert(node(l,p-1,v));
	return s.insert(node(p,r,v)).first;
}
ll ret=0;
inline void assign(int L,int R,int val){
	It r=split(R+1),l=split(L);
	for(It i=l;i!=r;++i){
		int v=i->v,_l=i->l,_r=i->r;
		reduce(ret+=mod-(sum[_r]-sum[_l-1]+mod)*v%mod);
//		std::cerr<<"C: "<<(i->l)<<' '<<(i->r)<<' '<<v<<'\n';
	}
	s.erase(l,r);
	reduce(ret+=(sum[R]-sum[L-1]+mod)*val%mod);
	s.insert(node(L,R,val));
}
int main(){
	std::ios::sync_with_stdio(0);
	std::cin>>n>>q;
	pw[n]=1;
	_rep(i,n-1,1) pw[i]=pw[i+1]*10%mod;
	rep(i,1,n) reduce(sum[i]=sum[i-1]+pw[i]);
	ret=sum[n];
	s.insert(node(1,n,1));
	while(q--){
		int l,r,d; std::cin>>l>>r>>d;
		assign(l,r,d);
		std::cout<<ret<<'\n';
	}
	return 0;
}

Measured memory_bytes: 19276
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

void chmin(int &a, int b) {
	a = min(a, b);
}
void chmax(int &a, int b) {
	a = max(a, b);
}
ll mod_pow(ll a, ll n, ll m = mod) {
	a %= m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };


void solve() {
	int k; string s; cin >> k >> s;
	if (s.size() <= k) {
		cout << s << "\n";
	}
	else {
		s.resize(k);
		rep(i, 3)s.push_back('.');
		cout << s << "\n";
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	solve();
	stop
		return 0;
}

Measured memory_bytes: 7708
if __name__ == '__main__':
    N = int(input())
    A_list = list(map(int, input().split()))

    A_list = sorted(A_list, reverse=True)

    odd_A_list = A_list[::2]
    even_A_list = A_list[1::2]

    print(sum(odd_A_list)-sum(even_A_list))

Measured memory_bytes: 3060
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K,X;
  cin>>K>>X;
  if(500*K>=X)
  	cout<<"Yes"<<endl;
  else
  	cout<<"No"<<endl;

}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vi v(N);
    REP(i, N) cin >> v[i];
    sort(ALL(v));

    ll ans = v[0] + v[1];
    ll c = 2;
    REP(i, N - 2) {
        ans +=  c * v[i + 2];
        c *= 2;
    }

    print((long double) ans / c);
}


Measured memory_bytes: 3792