akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
using namespace std;
#define int long long
typedef pair<int, int> P;
int a[114514];
signed main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	int num = a[0], k = 0;
	for (int i = 0; i <= n; i++) {
		if (num == a[i])k++;
		else {
			if (num == k);
			else if (num < k)ans += k-num;
			else ans += k;
			num = a[i];
			k = 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define dracarys ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
 
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define dbg(x) cout << " Here => " << x 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

bool ptime;
void inline fileIO(){ 
    ptime=false;
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        ptime=true;
    #endif
        srand((unsigned)time(0));
}

const int mxW = 1e3+5,mxH = mxW;
char grid[mxW][mxH];
int n,m;

int get(int x,int y){
    return ((x-1)*m+y);
}
struct edge{
    int to;
    ld wt;
    edge(int x=0,ld y=0.0){
        to = x;wt = y;
    }
    ~edge() {}
};
vector<edge> adj[mxW*mxH];

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

void inline solve(int tc){
    memset(grid,'#',sizeof grid);

    cin >> n >> m;

    int sx,sy,ex,ey;
    cin >> sx >> sy >> ex >> ey;

    string s;
    for (int i=0;i<n;i++){
        cin >> s;
        for (int j=0;j<m;j++){
            grid[i+1][j+1] = s[j];
        }
    }

    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            if (grid[i][j] == '#')continue;
            for (int nx,ny,k=0;k<4;k++){
                nx = i+dx[k]; ny = j+dy[k];
                if (grid[nx][ny] == '#') continue;
                adj[get(i,j)].pb(edge(get(nx,ny),1e-8));
            }
            for (int nx = max(1,i-2);nx <= min(n,i+2);nx++){
                for (int ny = max(1,j-2);ny <= min(m,j+2);ny++){
                    if (nx == i and ny == j) continue;
                    if (grid[nx][ny] == '#') continue;
                    adj[get(i,j)].pb(edge(get(nx,ny),1.0));
                }
            }
        }
    }

    int src = get(sx,sy), des = get(ex,ey);

    set<pair<ld,int>> pq;
    vector<ld> dis(n*m+5,1e9);
    dis[src] = 0.0;
    pq.insert({dis[src],src});

    while(pq.size()){
        int curr = pq.begin() -> se;
        ld nd;
        pq.erase(pq.begin());
        for (edge& ed:adj[curr]){
            nd = dis[curr] + ed.wt;
            if (nd < dis[ed.to]){
                if (pq.find({dis[ed.to],ed.to})!=pq.end()){
                    pq.erase(pq.find({dis[ed.to],ed.to}));
                }
                dis[ed.to] = nd;
                pq.insert({dis[ed.to],ed.to});
            }
        }
    }

    cout << (dis[des]==1e9 ? -1:(ll)dis[des]) << "\n";
}

int main(){
    fileIO();

    dracarys

    int tt=0,t=1;
    //cin >> t;

    while(t--){solve(++tt);}

    if (ptime)
        cerr << "processor time: " << clock() / (double) CLOCKS_PER_SEC << "s    ";


    return 0;
}

Measured memory_bytes: 347424
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <math.h>
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(ll i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(ll i=(s), i##_len=(n); i<i##_len; ++i)


using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return (a.first*a.first + a.second*a.second) > (b.first*b.first + b.second*b.second);
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (1000000007)

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

    ll N;
    cin >> N;
    ll sqrtN = sqrt(N)+1;
    ll d = 1e13;
    SREP(i, 1, sqrtN) {
        if (N%i == 0) {
            ll j = N/i;
            d = min(d, j+i-2);
        }
    }
    cout << d << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

ll cnt = 0;
ll l;
vll a(1e6);
ll n;
vll G;

void insertionSort(vll &a, ll n, ll g) {
  rep(i, g, n) {
    ll v = a.at(i);
    ll j = i - g;
    while (j >= 0 && a.at(j) > v) {
      a.at(j+g) = a.at(j);
      j -= g;
      cnt++;
    }
    a.at(j+g) = v;
  }
}

void shellSort(vll &a, ll n) {
  ll h=1;
  while (h <= n) {
    G.push_back(h);
    h = 3*h + 1;
  }
  reverse(G.begin(), G.end());
  for (ll g: G) {
    insertionSort(a, n, g);
  }
}

int main() {
  ll n; cin >> n;
  vll a(n);
  REP(i, n) cin >> a.at(i);

  shellSort(a, n);

  cout << G.size() << endl;
  REP(i, G.size()) {
    cout << G.at(i);
    if (i!=G.size()-1) cout << " ";
  }
  cout << endl;
  cout << cnt << endl;
  REP(i, n) cout << a.at(i) << endl;
  return 0;
}



Measured memory_bytes: 18324
#pragma GCC optimize("O2,unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;
using ll = long long;
int maxn = 531441, B, C;
int n, p[531441], f[531441];
int rev(int a) {
	int r = 0, c = 1;
	while(c < maxn) {
		if(a%3) r +=(3 - (a%3))*c;
		c*=3,a/=3;
	}
	return r;
}
 
int s = 0;
vector<int> small[729];
int id[531441], lup[531441], u = 0;
 
void add() {
	s = (s + B - 1)%B;
	for(auto i : small[s]) {
		if(lup[i] != u) {
			if((lup[i]^u)&1) id[i] = f[id[i]];
			lup[i] = u;
		}
		id[i] = (id[i] + 1)%C;
	}
}
 
void flip() {
	u++;
	for(int i = 0; i < B; i++) {
		if(f[i] <= i) {
			swap(small[(s+i)%B], small[(s+f[i])%B]);
		}
	}
}
 
int main() {
	cin.tie(0)->sync_with_stdio(0);
	string t;
	cin >> n >> t;
	maxn = B = 1;
	for(int i = 0; i < n; i++) maxn *= 3;
	for(int i = 0; i < n/2; i++) B *= 3;
	C = maxn/B;
	for(int i = 0; i < maxn; i++) {
		f[i] = rev(i);
		small[i%B].push_back(i);
		id[i] = i/B;
	}
	
	for(auto i : t) {
		if(i == 'R') add();
		else flip();
	}
	for(int i = 0; i < B; i++)
		for(auto j : small[i]) p[j] += (B+i-s)%B;
	for(int i = 0; i < maxn; i++) {
		if(lup[i] != u) {
			if((lup[i]^u)&1) id[i] = f[id[i]];
			lup[i] = u;
		}
		p[i] += B*id[i];
	}
	for(int i = 0; i < maxn; i++) cout << p[i] << " ";
}

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

int main() {
    int N;
    cin >> N;
    vector<int> L(2*N);
    for(int i=0; i<2*N; ++i) cin >> L[i];
    sort(L.begin(), L.end());

    int res = 0;
    for(int i=0; i<N; ++i) res += L[2*i];
    cout << res << endl;
}

Measured memory_bytes: 256
while 1:
    try:s=list(input().split())
    except:break
    a=[]
    for x in s:
        if x in ['+','-','*','/']:
            c,b=str(a.pop()),str(a.pop())
            a+=[float(eval(b+x+c))]
        else:a+=[float(x)]
    print(*a)

Measured memory_bytes: 7428
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX_N 20

int N;
int V[MAX_N], C[MAX_N];
int main(){
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> V[i];
    }
    for (int i = 0; i < N; i++){
        cin >> C[i];
    }
    int  num = 0;
    for (int i = 0; i < N; i++){
        if (V[i] > C[i]){
            num += V[i] - C[i];
        }
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    auto A = aryread();
    auto F = aryread();
    A.sort();
    F.sort!"b<a";
    long eval(long x)
    {
        long ret;
        foreach (i; 0 .. N)
        {
            ret += max(0, A[i] - (x / F[i]));
        }
        return ret;
    }

    long ok = 2_000_000_000_000;
    long ng = -1;
    while ((ok - ng) > 1)
    {
        long m = (ok + ng) / 2;
        if (eval(m) <= K)
        {
            ok = m;
        }
        else
        {
            ng = m;
        }
    }
    writeln(ok);
}


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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi64 a(n);
  cin >> a;
  auto check = [&]() {
    rep(i, n) if (a[i] >= n) return false;
    return true;
  };
  i64 ans = 0;
  while (!check()) {
    i64 ma = 0;
    int ma_i;
    rep(i, n) {
      if (a[i] > ma) {
        amax(ma, a[i]);
        ma_i = i;
      }
    }
    i64 c = (a[ma_i] + n) / n - 1;
    rep(i, n) {
      if (i != ma_i) a[i] += c;
      else a[i] -= c * n;
    }
    ans += c;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

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

  // AかBしかない場合(A,Bのどちらかが文字列内に無い)はNo
  if (s.find("A")==string::npos || s.find("B")==string::npos)
    cout<< "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
n=int(input())
h=list(map(int,input().split()))
dp=[999999999 for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 13976
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//Wrought Gold Master
public class Main {

	public static int[] price;
	public static int[] opt;
	public static Map<String, Integer> ref;
	public static int[][] list;

	public static int get(int k){
		if(opt[k]!=Integer.MAX_VALUE){
			return opt[k];
		}
		if(list[k].length==0){
			return opt[k] = price[k];
		}
		int p = 0;
		for(int i=0;i<list[k].length;i++){
			p += get(list[k][i]);
		}
		return opt[k] = Math.min(p, price[k]);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			price = new int[300];
			opt = new int[300];
			list = new int[300][0];
			Arrays.fill(opt, Integer.MAX_VALUE);
			int id = 0;
			ref = new HashMap<String, Integer>();
			for(int i=0;i<n;i++){
				ref.put(sc.next(), id);
				price[id++] = sc.nextInt();
			}
			int m = sc.nextInt();
			while(m--!=0){
				String s = sc.next();
				if(!ref.containsKey(s)){
					ref.put(s, id++);
				}
				int i = ref.get(s);
				int k = sc.nextInt();
				list[i] = new int[k];
				for(int j=0;j<k;j++){
					s = sc.next();
					if(!ref.containsKey(s)){
						ref.put(s, id++);
					}
					list[i][j] = ref.get(s);
				}
			}
			System.out.println(get(ref.get(sc.next())));
		}
	}
}

Measured memory_bytes: 32468
#include<bits/stdc++.h>
using namespace std;
inline int read(void)
{
	int x = 0,f = 1; char ch = getchar();
	while(!isdigit(ch)){f = ch == '-' ? -1 : 1; ch = getchar();}
	while(isdigit(ch)){x = (x << 3) + (x << 1) + ch - '0'; ch = getchar();}
	return x * f;
}
int main(int argc, char *argv[])
{
	int A[4] = {0,read(),read(),read()},ans = 0;
	sort(A+1,A+4);
	while(A[1] != A[3] && A[2] != A[3]) ++A[1],++A[2],++ans;
	if ((A[3] - A[1]) & 1) printf("%d\n",ans + (A[3]-A[1])/2 + 2);
	else printf("%d\n",ans + (A[3]-A[1])/2);
	return 0;
}


Measured memory_bytes: 256
//    https://youtu.be/mRHBP3xwgn4

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;	// 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shesh               "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define mest(a,b)           memset(a,b,sizeof(a))

int main(){
    fast;
    ll t,n,m,i,j,k,temp,flag,ans;
    cin>>n;
    ld a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=1,flag=0;i<n;i++){
        a[i]=(a[i]+a[i-1])/2;
    }
    cout<<a[n-1];
    return 0;
}


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

using namespace std;

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int a, b, c; cin >> a >> b >> c;
  cout << (a + b >= c ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

template <typename T, const T id>
class convex_hull_trick {
	struct line {
		T a, b;
		line(T a_ = 0, T b_ = 0) : a(a_), b(b_) {}
		T get(T x) { return a * x + b; }
	};
	struct node {
		line l;
		node *lch, *rch;
		node(line l_) : l(l_), lch(nullptr), rch(nullptr) {}
		~node() {
			if (lch) delete lch;
			if (rch) delete rch;
		}
	};

private:
	const int n;
	const vector<T> pos;
	node *root;

public:
	convex_hull_trick(const vector<T>& pos_) : n(pos_.size()), pos(pos_), root(nullptr) {}
	~convex_hull_trick() {
		if (root) delete root;
	}
	void insert(T a, T b) {
		line l(a, b);
		root = modify(root, 0, n - 1, l);
	}
	T get(T x) const {
		int t = lower_bound(pos.begin(), pos.end(), x) - pos.begin();
		assert(t < n && pos[t] == x);
		return sub(root, 0, n - 1, t);
	}

private:
	node* modify(node *p, int lb, int ub, line& l) {
		if (!p) return new node(l);
		if (p->l.get(pos[lb]) >= l.get(pos[lb]) && p->l.get(pos[ub]) >= l.get(pos[ub])) return p;
		if (p->l.get(pos[lb]) <= l.get(pos[lb]) && p->l.get(pos[ub]) <= l.get(pos[ub])) {
			p->l = l;
			return p;
		}
		int c = (lb + ub) / 2;
		if (p->l.get(pos[c]) < l.get(pos[c])) swap(p->l, l);
		if (p->l.get(pos[lb]) <= l.get(pos[lb]))
			p->lch = modify(p->lch, lb, c, l);
		else
			p->rch = modify(p->rch, c + 1, ub, l);
		return p;
	}
	T sub(node *p, int lb, int ub, int t) const {
		if (!p) return id;
		if (ub - lb == 0) return p->l.get(pos[t]);
		int c = (lb + ub) / 2;
		if (t <= c) return max(p->l.get(pos[t]), sub(p->lch, lb, c, t));
		return max(p->l.get(pos[t]), sub(p->rch, c + 1, ub, t));
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, c;
	cin >> n >> c;
	vector<ll> h(n);
	REP(i, n) cin >> h[i];
	convex_hull_trick<ll, -INF * INF> cht(h);
	vector<ll> dp(n, INF * INF);
	dp[0] = 0;
	cht.insert(-(-2 * h[0]), -(h[0] * h[0] + dp[0]));
	FOR(i, 1, n) {
		dp[i] = c + h[i] * h[i];
		ll tmp = -cht.get(h[i]);
		dp[i] += tmp;
		cht.insert(-(-2 * h[i]), -(h[i] * h[i] + dp[i]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 14336
# -*- coding: utf-8 -*-

import statistics

# 入力データ
in_cnt = int(input())
in_data = [int(i) for i in input().split()]

corrent_data = [0 for i in range(in_cnt)]
for idx in range(in_cnt):
	corrent_data[idx] = in_data[idx] - idx - 1

med_low = statistics.median_low(corrent_data)

ans=0
for idx in range(in_cnt):
	ans += abs( med_low - corrent_data[idx] )

print(ans)

Measured memory_bytes: 27264
t1 = int(input())
t2 = int(input())

x = (t2-t1)/2
a = x
for i in range(-2,3):
    t = x + i*180
    if abs(a) > abs(t):
        a = t

ans = t1+a
while ans < 0:
    ans += 360
while ans > 360:
    ans -= 360

print(ans)



Measured memory_bytes: 5608
#include<map>
#include<list>
#include<queue>
#include<iostream>
#include<unordered_set>
#include<set>
#include<vector>
#include<cmath>

#define ull unsigned long long
#define ll long long
#define mp make_pair
#define imei(...)   "[ "<< #__VA_ARGS__ <<" = "<< __VA_ARGS__ <<" ] "

using namespace std;

int main(int argc, char *argv[])
{
    int x, y;
    cin >> x >> y;
    if ((y - 2 * x)%2 == 0) {
        int b = ((y-2*x)/2);
        if (b < 0) {
            cout << "No\n";
            return 0;
        }
        int a = x - b;
        if (a < 0)
            cout << "No\n";
        else
            cout << "Yes\n";
    } else {
        cout << "No\n"; 
    }

    return 0;
}


Measured memory_bytes: 3628
n=int(input())
data=[] # data[[x1,y1,h1],...,[xn,yn,hn]]
for i in range(n):
    (xi,yi,hi)=map(int, input().split())
    data.append([xi,yi,hi])

data.sort(key=lambda x:x[2])
data.reverse()

breakflg=False
for cx in range(101):
    if(breakflg):
        break
    for cy in range(101):
        h=abs(data[0][0]-cx)+abs(data[0][1]-cy)+data[0][2]
        flag=True
        for i in range(n):
            h_est=h-abs(data[i][0]-cx)-abs(data[i][1]-cy)
            if(h_est<0):
                h_est=0
            if(data[i][2]!=h_est):
                flag=False
                break
        if(flag):
            print(cx,cy,h)
            breakflg=True;


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

int main() {
  string s; cin >>s;
  string t = "ab";
  t.at(0) = s.at(5); t.at(1) = s.at(6);
  string ans = "TBD";
  if (t=="04"||t=="03"||t=="02"||t=="01") ans = "Heisei";
  cout <<ans;
  cout <<endl;
}


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

l = []

for i in range(N):
    s, p = input().split()
    
    l.append([i + 1, s, int(p)])
    
l = sorted(l, key=lambda x: x[2], reverse=True)
l = sorted(l, key=lambda x: x[1])

for x in l:
    print(x[0])

Measured memory_bytes: 8836
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long N, long long R){
  cout << (N >= 10 ? R : R + (10-N)*100) << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  long long R;
  scanf("%lld",&R);
  solve(N, R);
}


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

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    long long ans;
    if (N != 1 && M != 1) ans = (long long)(N - 2) * (M - 2);
    else if (N == 1 && M == 1) ans = 1;
    else if (N == 1) ans = M - 2;
    else if (M == 1) ans = N - 2;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
import numpy as np
A, B, H, M = map(int, input().split())
theta_A = 30 * H + 0.5 * M
theta_B = (6 * M) % 360
theta = (theta_A - theta_B) * np.pi / 180
print(np.sqrt(A ** 2 + B ** 2 - 2 * A * B * np.cos(theta)))

Measured memory_bytes: 27072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
const ll INF = 1e18;

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    if (count(all(a), 0)) {
        cout << 0 << endl;
        return 0;
    }
    ll res = 1;
    rep(i,n) {
        if (res <= INF / a[i]) {
            res *= a[i];
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ((res <= INF) ? res : -1LL) << endl;
    return 0;
}


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

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

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
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);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll 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;
}

//逆元(Eucledean algorithm)
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];
}
using mP = pair<modint, modint>;

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


int n;

int LIS(vec a){
    ll dp[210000];
    fill(dp, dp+n, INF);
    for (int i=0; i<n; ++i) {
        *lower_bound(dp, dp+n, a[i]) = a[i];
    }
    return lower_bound(dp, dp+n, INF) - dp;
}

void solve() {
    int N; cin >> N;
    n = N;
    vec a(N);
    rep(i, N){
        cin >> a[i];
    }

    int ans=0;
    int res=0;
    rep(i, N-1){
        if(a[i] >= a[i+1]){
            res++;
        }else{
            res=0;
        }
        ans = max(ans, res);
    }

    cout << ans << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4736
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
ll dp[401][401];

ll cost(int i,int j,vector<ll> &v)
{
    if(i>=j)
    {
        return 0; // it simply means their is already a single slime....i==j
    }
    else
    {
        if(dp[i][j]!=-1)
           return dp[i][j]; // recursion+memoisation...
           
        ll ans=LLONG_MAX;
        ll sum=0;
        for(ll k=i;k<=j;k++)
        {
            sum+=v[k]; // ye current slime ko banane ka cost hai....
        }
        for(int k=i;k<=j-1;k++)
        {
            ans=min(ans,(dp[i][k]!=-1?dp[i][k]:cost(i,k,v))+(dp[k+1][j]!=-1?dp[k+1][j]:cost(k+1,j,v))+sum);
        }
        return dp[i][j]=ans;
    }
}

ll solve(int n,vector<ll> &v)
{
    memset(dp,-1,sizeof(dp));
    return cost(1,n,v);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;
    vector<ll> v(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    cout<<solve(n,v);
    return 0;
}







Measured memory_bytes: 4908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
ll D,T,S;
  cin>>D>>T>>S;

if(D/(double)(S)<=(double)(T)){cout<<"Yes"<<endl;}
else {cout<<"No"<<endl;
  }
  
  
}


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

int main () {
  int a ;
  cin >> a ;
  
  if(a==25) cout << "Christmas" << endl ;
  if(a==24) cout << "Christmas Eve" << endl ;
  if(a==23) cout << "Christmas Eve Eve" << endl ;
  if(a==22) cout << "Christmas Eve Eve Eve" << endl ;
}

Measured memory_bytes: 256
// In the name of ALLAH

#include<bits/stdc++.h>


#define sc(x) scanf("%d",&x)
#define ALL(x) x.begin(),x.end()
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define reset(x) memset(x,0,sizeof x)
#define sz(x) x.size()
#define pb push_back
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+7;
static const int INF = 0x3f3f3f3f;
static const int MOD = 1e9+7;
/*
ll power(ll x,ll y,ll mod){
    int res = 1; // Initialize result

    while (y > 0) {
        
        if (y & 1)
            res = (res * x + mod)%mod;


        y = y >> 1;
        x = (x * x)%mod;
    }
    return res;
}
*/


int main() {
    FASTIO
    int n;cin >> n;
    std::vector<int> arr(n);
    for(int &x:arr)cin >> x;
    sort(ALL(arr));
    
    cout << arr[n/2] - arr[n/2 - 1];
    return 0;
}

Measured memory_bytes: 640
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rep3(i,n,m) for(ll i=(n);i<(ll)(m);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int _stoi(string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double _stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}
template<typename T>string to_string(const T& n){
	std::ostringstream stm;
	stm << n;
	return stm.str();
}

// 降順ソート: sort(A, A+N, greater<>());
// min: *min_element(A, A+N)
// argmin: min_element(A, A+N)-A

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


int main(){	
	// ll A; cin >> A;
	// cout << "hello" << _stoi("14") << max({1,3}) << endl;
	string S;
	cin >> S;
	ll ans = 0, a=0;
	rep(i, S.length()){
		char c = S[i];
		if (c=='A' || c=='C' || c=='G' || c=='T'){
			a++;
		}else{
			chmax(ans, a);
			a=0;
		}
	}
	chmax(ans, a);
	cout << ans << endl;;

	

}








Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;


struct Node {
    int a, b, c, d;    
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, q;
    cin >> n >> m >> q;
    vector<Node> v(q);
    for (int i = 0; i < q; ++ i) {
        cin >> v[i].a >> v[i].b >> v[i].c >> v[i].d;
    }
    vector<int> foo;
    int64 ans = 0;
    function<void(int)> solve = [&] (int prev) -> void {
        if (foo.size() == n) {
            int64 cur = 0;
            for (Node& x : v) {
                if (foo[x.b - 1] - foo[x.a - 1] == x.c) {
                    cur += x.d;
                }
            }
            ans = max(ans, cur);
            return;
        }
        for (int i = prev; i <= m; ++ i) {
            foo.push_back(i);
            solve(i);
            foo.pop_back();
        }
    };
    solve(1);
    cout << ans;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()

const int N = 200010;
ll pf[N], ps[N], pi[N];
ll sf[N], ss[N], si[N];
ll n, a[N];

int main() {
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);

  pf[1] = a[0];
  ps[1] = a[1];
  pi[1] = 0;

  for (int i = 2; i < n; i++) {
    pf[i] = pf[i - 1];
    ps[i] = ps[i - 1] + a[i];
    pi[i] = pi[i - 1];
    ll diff = abs(ps[i] - pf[i]);
    while (abs(ps[i] - 2 * a[pi[i] + 1] - pf[i]) < diff) {
      diff = abs(ps[i] - 2 * a[pi[i] + 1] - pf[i]);
      pi[i]++;
      ps[i] -= a[pi[i]];
      pf[i] += a[pi[i]];
    }
  }

  sf[n - 2] = a[n - 1];
  ss[n - 2] = a[n - 2];
  si[n - 2] = n - 1;

  for (int i = n - 3; i >= 0; i--) {
    sf[i] = sf[i + 1];
    ss[i] = ss[i + 1] + a[i];
    si[i] = si[i + 1];
    ll diff = abs(ss[i] - sf[i]);
    while (abs(ss[i] - 2 * a[si[i] - 1] - sf[i]) < diff) {
      diff = abs(ss[i] - 2 * a[si[i] - 1] - sf[i]);
      si[i]--;
      ss[i] -= a[si[i]];
      sf[i] += a[si[i]];
    }
  }

  // debug
  for (int i = 1; i < n; i++) cerr << i << ": " << pf[i] << ", " << ps[i] << "(" << pi[i] << ")\n";
  cerr << "suff\n";
  for (int i = 0; i < n - 1; i++) cerr << i << ": " << sf[i] << ", " << ss[i] << "(" << si[i] << ")\n";

  ll ans = 1e18;
  for (int i = 1; i < n - 2; i++) {
    ll mx = max({ps[i], pf[i], ss[i + 1], sf[i + 1]});
    ll mn = min({ps[i], pf[i], ss[i + 1], sf[i + 1]});
    ans = min(ans, mx - mn);
  }
  printf("%lld\n", ans);
}



Measured memory_bytes: 11136
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d; cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void) {
	int n, i, a[100003], s;

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

	sort(a, a + n);

	i = 0;
	s = 0;
	while (i < n) {
		while (i < n && a[i] == a[i + 1]) {
			s++;
			i++;
		}
		i++;
	}

	cout << n - (s + (s & 1)) << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e5+7;
int a[MAXN],n,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n+1;i++) ans+=abs(a[i]-a[i-1]);
	for(int i=1;i<=n;i++){
		cout<<ans-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
	}
}

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

using namespace std;

#define PI 3.14159265359

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double n1 = h * 60 + m;
    double arat = n1 / 720;
    double brat = n1 / 60;
    int tmp1 = arat, tmp2 = brat;
    arat = arat - tmp1;
    brat = brat - tmp2;
    double arad = 2 * PI * arat;
    double brad = 2 * PI * brat;
    double c;
    double rad;
    if (abs(arad - brad) * 2 > 2 * PI) {
        if (arad * 2 > 2 * PI) rad = 2 * PI - arad + brad;
        else if (brad * 2 > 2 * PI) rad = 2 * PI - brad + arad;
        c = sqrt(a * a + b * b - 2 * a * b * cos(rad));
    } else {
        rad = abs(arad - brad);
        c = sqrt(a * a + b * b - 2 * a * b * cos(rad));
    }
    printf("%.10f\n", c);
    return 0;
}

Measured memory_bytes: 4060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int i;
	int H, W;
	char **pic;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	H = atoi(ch);
	ch = strtok(NULL, " ");
	W = atoi(ch);

	pic = (char **)calloc(H, sizeof(char *));
	for(i = 0; i < H; i += 1) {
		pic[i] = (char *)calloc(W + 8, sizeof(char));
	}
	for(i = 0; i < H; i += 1) {
		fgets(pic[i], sizeof(buf), stdin);
	}
	for(i = 0; i < H; i += 1) {
		printf("%s", pic[i]);
		printf("%s", pic[i]);
	}

	for(i = 0; i < H; i += 1) {
		free(pic[i]);
	}
	free(pic);
	return 0;
}


Measured memory_bytes: 2132
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;

int main(){
	cin >> s;
	int lb = 0,ub = s.size()-1;
	int ans = 0;
	while(lb < ub){
		if(s[lb] == s[ub]){
			lb++;
			ub--;
			continue;
		}

		if(s[lb] == 'x'){
			lb++;
			ans++;
		}
		else if(s[ub] == 'x'){
			ub--;
			ans++;
		}
		else {
			cout << -1 << endl;;
			return 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
/*
* @Author: Nazrul Islam
* @Date:   2020-09-19 12:41:17
* @Last Modified by:   Nazrul Islam
* @Last Modified time: 2020-09-19 12:45:49
*/

#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll; 
typedef double dd;
typedef vector<int> vi;
typedef vector<char> vc;
typedef list<int> li;
typedef set<int> si;
typedef map<int,int> mp;
#define pb push_back
#define pf push_front
#define mk make_pair
#define sc scanf
#define pr printf
#define pi acos(-1.0)
#define endl '\n'
// char s[200009];
// char st[200009];
// int a[600][600];
// int b[29][10];
// int a[200009];
// int c[200009];
void solve()
{
	ll n, m, i, j, k, l; 
	cin >> n; string s; cin >> s;
	if(n %2 == 0) {
		bool f = 1;
		for (i = 0; i < n/2; i++)
		{
			if(s[i] != s[n/2+i]) {f = 0; break;}
		}

		if(f) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else cout << "No" << endl;
}
int main()
{
	IO;
	int t; 
	t = 1;
	// cin >> t;
	while(t--)
		solve();
	return 0;
}

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

int judge5(char a, char b, char c, char d, char e) {
  if (a=='m' && b=='a' && c=='e' && d=='r' && e=='d') return 1;
  else if (a=='e' && b=='s' && c=='a' && d=='r' && e=='e') return 1;
  else return 0;
}

int judge6(char a, char b, char c, char d, char e, char f) {
  if (a=='r' && b=='e' && c=='s' && d=='a' && e=='r' && f=='e') return 1;
  else return 0;
}

int judge7(char a, char b, char c, char d, char e, char f, char g) {
  if (a=='r' && b=='e' && c=='m' && d=='a' && e=='e' && f=='r' && g=='d') return 1;
  else return 0;
}
  

int main() {
  
  string S;
  cin >> S;
  
  reverse(S.begin(), S.end());
  
  int s=1;
  while (s==1) {
    if (S.size()<5) s=0;
    else if (S.at(0)=='m' || S.at(0)=='e') {
      s=judge5(S.at(0),S.at(1),S.at(2),S.at(3),S.at(4));
      reverse(S.begin(), S.end());
      for (int i=0; i<5; i++) S.pop_back();
      reverse(S.begin(), S.end());
    }
    else if (S.at(0)=='r' && S.at(2)=='s') {
      s=judge6(S.at(0), S.at(1), S.at(2), S.at(3), S.at(4), S.at(5));
      reverse(S.begin(), S.end());
      for (int i=0; i<6; i++) S.pop_back();
      reverse(S.begin(), S.end());
    }
    else if (S.at(0)=='r' && S.at(2)=='m') {
      s=judge7(S.at(0), S.at(1), S.at(2), S.at(3), S.at(4), S.at(5), S.at(6));
      reverse(S.begin(), S.end());
      for (int i=0; i<7; i++) S.pop_back();
      reverse(S.begin(), S.end());
    }
    else s=0;
    if (S.size()==0) s=-1;
  }
  
  if (s!=0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<set>
#include<vector>
using namespace std;

int main(){
  int n,w;
  set<int> s;
  vector<int> f;

  cin >> n >> w;
  cout << w << (w==n?"\n":" ");
  for(int i=1;i<=w;i++)s.insert(i);

  for(int z=w+1;z<=n;z++){
    int prv = z-w;
    f.clear();
    for(int i=1;i*i<=prv;i++){
      if(prv%i==0){
	f.push_back(i);
	if(i*i!=prv)f.push_back(prv/i);
      }
    }

    for(int i=0;i<f.size();i++){
      if(s.find(f[i])==s.end())continue;
      int pre = (prv+1)/f[i];
      if((prv+1)%f[i]!=0)pre++;
      int suf = (z-1)/f[i];
      if(suf-pre<=0)s.erase(f[i]);
    }

    f.clear();
    for(int i=1;i*i<=z;i++){
      if(z%i==0){
	f.push_back(i);
	if(i*i!=z)f.push_back(z/i);
      }
    }

    s.insert(z);
    for(int i=0;i<f.size();i++){
      if(s.find(f[i])!=s.end())continue;
      int pre = (prv+1)/f[i];
      if((prv+1)%f[i]!=0)pre++;
      int suf = (z-1)/f[i];
      if(suf-pre>=0)s.insert(f[i]);
    }

    cout << s.size() << (z==n?"\n":" ");
  }
}
    

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int A, B;
    cin >> A >> B;

    if (A >= 13) {
        cout << B << endl;
    } else if (A >= 6) {
        cout << B / 2 << endl;
    } else {
        cout << 0 << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		var tmp int
		_, _ = fmt.Scan(&tmp)
		arr[i] = tmp
	}

	count := 0
	for {
		flg := false
		sum := 0
		for i := 0; i < n; i++ {
			sum += arr[i]
			if arr[i] > 0 {
				if !flg {
					count++
				}
				arr[i]--
				flg = true
			} else if flg {
				flg = false
			}
		}
		if sum <= 0 {
			break
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

int main() {
  std::string s;
  int w = 0;
  int g = 0;
  int p = 0;
  std::cin >> s;
  for (auto c : s) {
    if (c == 'p') {
      if (p < g) {
        ++p;
      } else {
        ++g;
        --w;
      }
    } else {
      if (p < g) {
        ++p;
        ++w;
      } else {
        ++g;
      }
    }
  }
  std::cout << w << std::endl;
  return 0;
}

Measured memory_bytes: 512
import java.io.*;

class Main {
	public static void main(String[] arg)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String str = br.readLine();
			if(str.equals("0"))break;
			int sum = 0;
			for(int i=0;i<str.length();i++){
				sum = sum + Integer.parseInt("" +str.charAt(i));
			}
			System.out.println(sum);
		}
	}
}	

Measured memory_bytes: 17188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <math.h>
#include <stack>
#include <tuple>
#include <cstring>
#include <chrono>
#include <bitset>
#include <list>
#include <stdlib.h>
#include <iomanip>
#include <bitset>
#include <chrono>

using namespace std;

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

bool comparator(const pair<ll, ll> &x, const pair<ll, ll> &y)
{
    return x.second - x.first < y.second - y.first;
}

ll gcd(ll x, ll y)
{
    return y == 0LL ? x : gcd(y, x % y);
}

struct dot {
    ll coordinate, tree;
    bool is_left;

    dot(ll _coordinate, ll _tree, bool _is_left)
    {
        coordinate = _coordinate;
        tree = _tree;
        is_left = _is_left;
    }

    ll dist() const
    {
        return abs(coordinate - tree);
    }

    bool operator<(const dot& other) const
    {
        return dist() > other.dist();
    }
};

bool is_free(ll x, set<ll> &used_coords)
{
    return used_coords.find(x) == used_coords.end();
}

int main()
{
    std::ios::sync_with_stdio(false);

    int x;
    cin >> x;
    
    vector<bool> is_prime(100 * 1000 + 10000, true);
    vector<int> primes;
    for (int i = 2; i < is_prime.size(); i++) {
        if (is_prime[i]) {
            primes.push_back(i);
            for (int j = i + i; j < is_prime.size(); j += i) {
                is_prime[j] = false;
            }
        }
    }
    
    vector<int>::iterator it = lower_bound(primes.begin(), primes.end(), x);
    cout << (*it) << endl;

    return 0;
}


Measured memory_bytes: 384
while True:
    try:
        n = int(input())
        num = list(range(n + 1))
        num[1] = 0
        for i in range(n):
            if num[i] > n ** 0.5:
                break
            if num[i] == 0:
                continue
            for j in range(num[i] * 2, n + 1, num[i]):
                num[j] = 0
        print(n + 1 - num.count(0))
    except:
        break


Measured memory_bytes: 57152
#include <stdio.h>
#include<string.h>

int min(int x,int y){
  if(x>y) return y;
  else return x;
}

  
int main(void){
  int n, m, x;
  int a[200];
  scanf("%d %d %d", &n,&m,&x);
  for(int i=0;i<m;i++){
    scanf("%d", a+i);
  }
  int left = 0;int right = 0;
  for(int i=0;i<m;i++){
    if(a[i]<x) left++;
    else right++;
  }
  printf("%d", min(left,right));


  return 0;
}

  

Measured memory_bytes: 1684