akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cctype>
using namespace std;

typedef string::const_iterator State;
class ParseError{};

int expr(State &begin);
int term(State &begin);
int number(State &begin);

int expr(State &begin){
    int ret = term(begin);

    while(*begin == '+'){
        begin++;
        ret += term(begin);
    }

    return ret;
}

int term(State &begin){
    int ret = number(begin);

    while(*begin == '*'){
        begin++;
        ret *= number(begin);
    }

    return ret;
}

int number(State &begin){
    int ret = *begin - '0';
    begin++;
    return ret;
}

int main(){
    string s;
    int n;

    cin >> s >> n;
    
    State it = s.begin();
    int evala = expr(it);

    int evalb = s[0]-'0';
    for(int i = 1; i < s.length(); i+=2){
        int bin = s[i+1]-'0';
        if(s[i] == '+') evalb += bin;
        if(s[i] == '*') evalb *= bin;
    }

    bool x = (evala == n);
    bool y = (evalb == n);

    if(x&&y)    cout << "U" << endl;
    else if(x)  cout << "M" << endl;
    else if(y)  cout << "L" << endl;
    else        cout << "I" << endl;

    return 0;
}


Measured memory_bytes: 3224
#include<stdio.h>
int main()
{
    int n,i,j,t,flag=0,c;
    scanf("%d",&n);
    for(c=1,i=4,j=7;c<3;c++,i=7,j=4)
    {
        t=n;
        if(t%i==0) {flag=1;break;}
        for(;t>i;)
        {
           t=t-i;
           if(t%j==0) {flag=1;break;}
        }
    }
    if(flag==1) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 500005
const long double PI = acos(-1);

int n,m,k,x,y,L,R,U,D;
string A,B;

int main(){
    ios::sync_with_stdio(false);
    cin >> n >> m >> k;
    cin >> x >> y;
    cin >> A >> B;

    for (int i=k-1;i>=0;i--){
        if (B[i]=='U') D = max(D-1,0);
        if (B[i]=='D') U = max(U-1,0);
        if (B[i]=='L') R = max(R-1,0);
        if (B[i] == 'R') L = max(L-1,0);
    
        if (A[i] == 'U') U++;
        if (A[i] == 'D') D++;
        if (A[i] == 'R') R++;
        if (A[i] == 'L') L++;

        if (L + R >= m || U + D >= n){
            cout << "NO\n";
            return 0;
        }
    }

    if (U >= x || x + D > n){
        cout << "NO\n";
        return 0;
    }
    if (L >= y || y + R > m){
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";
    return 0;
}

Measured memory_bytes: 920
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;
int mod_add(int A, int B) { return (A + B) % MOD; }
int mod_sub(int A, int B) { return (A + MOD - B) % MOD; }
int mod_mul(int A, int B) { return ((A % MOD) * (B % MOD)) % MOD; }
int mod_bipow(int X, int Y) {
    if (Y == 0) return 1;
    else if (Y == 1) return X % MOD;
    else if (Y % 2 == 0) {
        int Z = mod_bipow(X, (int)(Y / 2));
        return mod_mul(Z, Z);
    } else {
        int Z = mod_bipow(X, (int)(Y / 2));
        return mod_mul(mod_mul(Z, Z), X);
    }
}
int mod_inv(int X) { return mod_bipow(X, MOD - 2); }
int mod_div(int A, int B) { return mod_mul(A, mod_inv(B)); }

int ceil_div(int X, int Y) {
  return (X - 1) / Y + 1;
}

struct vertex {
  vector<int> adj = vi(0);
};

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int a, b, x;
  int ans = 0;

  cin >> a >> b >> x;
  // vi a(n);
  // REP(i, n) {
  //   cin >> a[i];
  // }

  cout << (a > x || x > a + b ? "NO" : "YES") << endl;
  // REP(i, n) {
  //   cout << a[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
typedef long long ll;

int main(){
	int n;
	int tmp;
	ll ans=0;
	vector <int> L;
	cin >> n;
	rep(i,0,n*2){
		cin >> tmp;
		L.PB(tmp);
	}
	sort(L.begin(),L.end());

	rep(i,0,n){
		ans+=L[i*2];
	}
	cout << ans <<endl;


	return 0;
}


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


using namespace std;


class Dice{
	private:
		int dice_bk[6];

	public:
		// コンストラクタ
		Dice();
		// サイコロころころシュミレート
		int corocoro();
};


// コンストラクタ
Dice::Dice()
{
	for(int i = 0; i < 6; i++)
		cin >> dice_bk[i];
}
// サイコロころころシュミレート
int Dice::corocoro()
{
	int dice[6];
	int top, front;
	int mem, tmp;

	// 初期のダイスの状態をロード
	for(int i = 0; i < 6; i++)
		dice[i] = dice_bk[i];

	// 上面、正面の入力
	cin >> top >> front;
	for(int i = 0; i < 6; i++){
		if(front == dice[i]){
			mem = i;
			break;
		}
	}

	// test[0]にfrontを持ってくる
	string code;
	switch(mem){
		case 4:
			code = "S";
			break;
		case 1:
			code = "N";
			break;
		case 3:
			code = "E";
			break;
		case 2:
			code = "W";
			break;
		case 5:
			code = "WW";
			break;
		default:
			code = "";
			break;
	}

	for(int i = 0; i < code.length(); i++){
		switch(code[i]){
			case 'N':
				tmp = dice[5];
				dice[5] = dice[4];
				dice[4] = dice[0];
				dice[0] = dice[1];
				dice[1] = tmp;
				break;
			case 'S':
				tmp = dice[5];
				dice[5] = dice[1];
				dice[1] = dice[0];
				dice[0] = dice[4];
				dice[4] = tmp;
				break;
			case 'W':
				tmp = dice[5];
				dice[5] = dice[3];
				dice[3] = dice[0];
				dice[0] = dice[2];
				dice[2] = tmp;
				break;
			case 'E':
				tmp = dice[5];
				dice[5] = dice[2];
				dice[2] = dice[0];
				dice[0] = dice[3];
				dice[3] = tmp;
				break;
		}
	}

	// 正面を固定してサイコロをくるくる回す
	while(dice[4] != top){
		tmp = dice[4];
		dice[4] = dice[2];
		dice[2] = dice[1];
		dice[1] = dice[3];
		dice[3] = tmp;
	}

	// 右側の面を返す
	return dice[2];
}


int main()
{
	Dice *x = new Dice();
	int n;

	cin >> n;
	for(int i = 0; i < n; i++)
		cout << x->corocoro() << endl;

	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int dp[40 + 1][10 * 40 + 1][10 * 40 + 1];

int main() {
  int N, M_a, M_b;
  int a[40], b[40], c[40];

  cin >> N >> M_a >> M_b;
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }

  fill(dp[0][0], dp[41][0], 5000);
  dp[0][0][0] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 40 * 10; j++) {
      for (int k = 0; k <= 40 * 10; k++) {
        if (dp[i][j][k] == 5000) continue;
        dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
        dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
      }
    }
  }

  int ans = 5000;
  for (int i = 1; i <= 40 * 10; i++) {
    for (int j = 1; j <= 40 * 10; j++) {
      if(M_a * j == M_b * i) ans = min(ans, dp[N][i][j]); 
    }
  }
  if(ans == 5000) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 25984
#include <iostream>
#include <string>
#include <cmath>
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long int ll;


int main(){
	  int N,ans;
		cin>>N;
    int d[N];
    for(int i=0;i<N;i++){
      cin>>d[i];
    }
    sort(d, d + N, greater<int>());

    ans=d[N/2-1]-d[N/2];

	  cout<<ans<<endl;
}


Measured memory_bytes: 640
package main

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

func main() {
	M := nextInt()
	D := nextInt()

	c := 0

	for m := 1; m <= M; m++ {
		for d := 20; d <= D; d++ {
			d10 := d / 10
			d1 := d % 10
			if d1 >= 2 && d10 >= 2 && d10*d1 == m {
				c++
			}
		}
	}

	fmt.Println(c)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int q = sc.nextInt();
		long[] shr = new long[a];
		long[] tem = new long[b];
		long[] que = new long[q];
		for (int i = 0; i < a; i++) {
			shr[i] = sc.nextLong();
		}
		for (int i = 0; i < b; i++) {
			tem[i] = sc.nextLong();
		}
		for (int i = 0; i < q; i++) {
			que[i] = sc.nextLong();
		}
		sc.close();

		for (int i = 0; i < q; i++) {
			long x = que[i];
			int sIdx = binarySearch(shr, x);
			int tIdx = binarySearch(tem, x);

			long sS = shr[Math.max(0, sIdx - 1)];
			long sL = shr[Math.min(sIdx, a - 1)];
			long tS = tem[Math.max(0, tIdx - 1)];
			long tL = tem[Math.min(tIdx, b - 1)];

			long r1 = 0L;
			if (Math.abs(x - tS) < Math.abs(x - sS)) {
				r1 += Math.abs(x - tS);
				if (tS - sS < sL - tS) {
					r1 += Math.abs(tS - sS);
				} else {
					r1 += Math.abs(sL - tS);
				}
			} else {
				r1 += Math.abs(x - sS);
				if (sS - tS < tL - sS) {
					r1 += Math.abs(sS - tS);
				} else {
					r1 += Math.abs(tL - sS);
				}
			}

			long r2 = 0L;
			if (Math.abs(sL - x) < Math.abs(tL - x)) {
				r2 += Math.abs(sL - x);
				if (tL - sL < sL - tS) {
					r2 += Math.abs(tL - sL);
				} else {
					r2 += Math.abs(sL - tS);
				}
			} else {
				r2 += Math.abs(tL - x);
				if (sL - tL < tL - sS) {
					r2 += Math.abs(sL - tL);
				} else {
					r2 += Math.abs(tL - sS);
				}
			}
			System.out.println(Math.min(r1, r2));
		}
	}

	private static int binarySearch(long[] array, long val) {
		int ng = -1;
		int ok = array.length;

		while (Math.abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;
			if (isOK(array, mid, val)) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		return ok;
	}

	private static boolean isOK(long[] array, int index, long val) {
		if (array[index] >= val) {
			return true;
		} else {
			return false;
		}
	}
}


Measured memory_bytes: 96932
/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define int ll
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int32_t main()
{
	prep();
	ll n;
	cin>>n;
	vl v(n);
	ll sum=0;
	for(auto &x:v){ cin>>x;
	sum+=x;
	}
	vvl dp(n,vl(n));
 
	for(ll L=n-1;L>=0;L--)
	{
		for(ll R=L;R<n;R++)
		{
			if(L==R)
				dp[L][R]=v[L];
			else
			dp[L][R]=max(v[L]-dp[L+1][R],v[R]-dp[L][R-1]);
		}
	}
	cout<<(dp[0][n-1]);
	return 0;
}

Measured memory_bytes: 70784
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String x = sc.next();
        String y = sc.next();
        if (x.compareTo(y) < 0) {
            System.out.println("<");
        } else if (x.compareTo(y) > 0) {
            System.out.println(">");
        } else {
            System.out.println("=");
        }
    }
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int q;
    cin>>q;
    set<int> st;
    rep(i, q) {
        int m, x;
        cin>>m>>x;
        if (m == 0) {
            st.insert(x);
            cout<<st.size()<<endl;
        }
        else if (m == 1) {
            if (st.find(x) != st.end()) cout<<1<<endl;
            else cout<<0<<endl;
        }
        else {
            if (st.find(x) != st.end())
                st.erase(st.find(x));
        }
    }
}


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
bool f(int a){
    if((a)>5000){
        return false;
    }else{
        return true;
    }
}
bool z[5001][5001];
vi xz,yz;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(1){
    cin >> n;if(n==0)break;
    xz.clear();
    yz.clear();
    rep(i,0,5001){
        rep(j,0,5001){
            z[i][j]=false;
        }
    }
    rep(i,0,n){
        int x,y;
        cin >> x >> y;
        z[x][y]=1;
        xz.pb(x);
        yz.pb(y);
    }
    int ans=0;
    rep(i,0,n){
        rep(j,0,n){
            if(i==j)continue;
            int X=abs(xz[i]-xz[j]);
            int Y=abs(yz[i]-yz[j]);
            int an=X*X+Y*Y;
            if(ans>an)continue;
            if(f(xz[i]+Y)&&f(yz[i]+X)&&f(xz[j]+Y)&&f(yz[j]+X)){
                if((z[xz[i]+Y][yz[i]+X]&&z[xz[j]+Y][yz[j]+X])){
                    ans=max(ans,an);
                }
            }
        }
    }
    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 27560
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<queue>
#include<set>

using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

int main(){
  int len[10],l1,l2,pos;
	while(scanf("%d",&len[0])+1){
		for(int i=1;i<10;i++){
			scanf(",%d",&len[i]);
			len[i] += len[i-1];		
		}
		scanf(",%d,%d",&l1,&l2);
		pos = len[9] * l1;
		int ans;
		for(int i=0;i<10;i++){
			if(len[i] * ( l1 + l2 )  < pos)
				ans = i;
			else
				break;
		}
		ans += 2;
		cout<<ans<<endl;
	}
	
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0}; 
int H,W;
char data[55][55];

bool check_around(int y, int x){
  for(int i=0;i<4;i++){
    int nx = x+dx[i];
    int ny = y+dy[i];
    if(nx<0||nx>=W||ny<0||ny>=H) continue;
    if(data[ny][nx]=='#') return true;
  }
  return false;
}
       
  
int main(){
  cin >> H>>W;
  
  int num_sharp=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
    	cin >> data[i][j];
      	if(data[i][j]=='#') num_sharp++;
    }
  }
  
  bool result=true;
  int cnt=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(data[i][j]=='#'){
        bool OK = check_around(i, j);
        if(OK) cnt++;
        if(!OK) {
          result=false;
        }
      }
    }
  }
  if(cnt==0) result=false;
  //cout<<"#:"<<num_sharp<<" cnt:"<<cnt<<endl;
  
  
  if(num_sharp==cnt) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define fs first
#define sc second
#define mp make_pair
#define L(x) (1<<x)
#define next Next
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=1e5+10;
const int maxm=1e3+10;
const int mod=1e9+7;
ll n;
int main()
{
    //freopen("in.txt","r",stdin);
    int a,b,c,d;
    while(~scanf("%d %d %d %d",&a,&b,&c,&d))
    {
        scanf("%lld",&n);
        b=min(b,a*2);
        c=min(c,b*2);
        d=min(d,c*2);
        ll ans=0;
        ans=(n/2)*d+(n%2)*c;
        printf("%lld\n",ans);
    }
    return 0;
}


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

int main(){
    int ans = 0, cnt = 0;
    int n; cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    for(int i = 0; i < n-1; i++){
        if(h[i] >= h[i+1]){
            cnt++;
        }else{
            cnt = 0;
        }
        ans = max(ans,cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
if __name__=="__main__":
    a = list(input().split())
    b = []
    for i in range(len(a)):
        if a[i] == "+":
            y = b.pop()
            x = b.pop()
            z = x + y
            b.append(z)
        elif a[i] == "-":
            y = b.pop()
            x = b.pop()
            z = x - y
            b.append(z)
        elif a[i] == "*":
            y = b.pop()
            x = b.pop()
            z = x * y
            b.append(z)
        else:
            b.append(int(a[i]))
    print(b[0])

Measured memory_bytes: 7692
#coding:utf-8
import sys,os
from collections import defaultdict
from bisect import bisect_left
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    s = input()
    t = input()
    # 各アルファベットについてsの何文字目に現れたかを保持するリストの辞書
    alphabets = defaultdict(list)
    for i,c in enumerate(s):
        alphabets[c].append(i)
    # sの繰り返した数,周期,0-indexed
    period = 0
    # sの何文字目までを使ったか
    looking = -1
    # 各アルファベットをその周期で何回使ったかを保持する辞書
    alphabet_index = defaultdict(int)
    for i,c in enumerate(t):
        index = bisect_left(alphabets[c],looking+1, alphabet_index[c])
        # その周期で使えるアルファベットがない場合
        if index == len(alphabets[c]):
            # そのアルファベットが存在しない場合は解なし
            if len(alphabets[c]) == 0:
                print(-1)
                return
            
            # 次の周期に移る
            period += 1
            alphabet_index = defaultdict(int)
            looking = alphabets[c][0]

        else:
            looking = alphabets[c][index]

        alphabet_index[c] += 1
    print(period * len(s) + looking + 1)






    

if __name__ == '__main__':
    main()

Measured memory_bytes: 79520
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}

namespace ndifix{
template<class T>void sort(T &v){std::sort(v.begin(),v.end());}
}

int main(){
  int n,k;cin>>n>>k;
  vector<int> v(n);for(int i=0;i<n;i++)cin>>v[i];
  vector<int> list;
  int sum=0,buf;
  for(int left=0;left<=k && left<n;left++){
  for(int right=0;right+left<=k && right+left<=n;right++){
    list.clear();
    for(int i=0;i<left;i++)list.push_back(v[i]);
    for(int i=0;i<right;i++)list.push_back(v[n-1-i]);
    ndifix::sort(list);buf=0;
    for(int i=0;i<k-left-right && list.size() && list[0]<0;i++){list.erase(list.begin());}
    for(int i=0;i<list.size();i++)buf+=list[i];
    sum = max(sum,buf);
  }
  }
  cout<<sum<<endl;
  return 0;
}

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

int main()
{
  int n;
  multiset<int> st;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    {
      int x; scanf("%d", &x);
      x = -x;
      auto it = st.upper_bound(x);
      if (it != st.end()) st.erase(it);
      st.insert(x);
    }
  printf("%d\n", (int) st.size());
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <climits>
#include <iomanip>

using namespace std;

const int N = 2e6 + 9;
const int INF = 2e9 + 2;
const int mod = 1e9 + 7;
const int K = 25;
const int P = 51;
const long long LONG_INF = LONG_MAX;
const int SZ = (1 << 18) - 1;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define mkp make_pair
#define all(s) s.begin(), s.end()

#define ll long long

#define int ll

void solve() {
	string s;
	cin >> s;
	string t = s;
	reverse(all(t));
	string a, b;
	for (int i = 0; i < (sz(s) - 1) / 2; ++ i)
		a += s[i];
	for (int i = (sz(s) + 3) / 2 - 1; i < sz(s); ++ i)
		b += s[i];
	string a1 = a;
	string b1 = b;
	reverse(all(a));
	reverse(all(b));
	if (a1 == a and b == b1 and s == t)
		cout << "Yes";
	else
		cout << "No";
}

signed main() {
	ios_base::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;


int main(){
  string t;
  cin >> t;
  ull len = t.size();
  rep(i,len){
    if(t[i] == '?'){
      t[i] = 'D';
    }
  }
  cout << t << endl;
}

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

int main() {
  int x, a, b, c, d;
  cin >> x >> a >> b;
  c=max((a-x),(x-a));
  d=max((b-x),(x-b));
  if (c>d) {
    cout << 'B' << endl;
  }
  else {
    cout << 'A' << endl;
  }
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int p[10];
	int goukei = 0;
	rep(i, N) {
		cin >> p[i];
		goukei += p[i];
	}
	goukei -= (*max_element(p, p + N)) / 2;

	co(goukei);

	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

const ll int MOD=1000000007;
ll int fact[1000001];
ll int modInv[1000001];

ll int power(ll int base,ll int p)
{
    ll ans=1;
    base=base%MOD;
    while(p>0)
    {
        if(p & 1)
            ans=(ans*base)%MOD;
            
        p=p>>1;
        base=(base*base)%MOD;
    }
    return ans;
}

void factInit()
{
    fact[0]=1;
    modInv[0]=1;
    for(ll int i=1;i<1000001;i++)
    {
        fact[i]=(fact[i-1]*i)%MOD;
        modInv[i]=power(fact[i],MOD-2)%MOD;
    }
}


void solve()
{
   float r;
   cin>>r;
   cout<<(2*22*r)/7;
}

int main()
{
    FAST;
    ll int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3804
#define _CRT_SECURE_NO_WARNINGS
#define MOD 1000000007
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
#include <random>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> P;
struct edge { ll to, cost; };

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n-1,-1)

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

/*
ll fact[100001], fact_inv[100001];
void calc_fact{
	fact[0]=1;
	REP(i,100000){
		fact[i+1]=mmul(fact[i],i+1);
		fact_inv[i+1]=minv(fact[i+1]);
	}
}
ll combi(int a, int b) {
	return mmul(fact[a], mmul(fact_inv[b], fact_inv[a - b]));
}
*/

double s(ll l) {
	double d = l;
	ll su = 0;
	while (l > 0) {
		su += l % 10;
		l /= 10;
	}
	return d / su;
}

int main(void) {
	ll now = 999999999999999;
	double nowval = s(now);
	//ll tosubs[] = { 100000000000000,10000000000000,1000000000000,100000000000,10000000000,1000000000,100000000,10000000,1000000,100000,10000,1000,100,10,1 };
	ll tosubs[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000 };
	vector<ll> result;
	result.push_back(now);
	while (now > 1) {
		for (ll tosub : tosubs) {
			if (tosub > now) continue;
			if (s(now - tosub) <= nowval) {
				now = now - tosub;
				break;
			}
		}
		result.push_back(now);
		nowval = s(now);
	}
	reverse(result.begin(), result.end());
	int k;
	cin >> k;
	REP(i, k) {
		cout << result[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import Control.Monad (replicateM)

main = do
  n <- getLine
  s <- getContents
  putStr $ sUnlines $ map judge $ mReadSD $ linesWords s

linesWords s = map words $ lines s
mReadSD    s = map (map (read :: String -> Double)) s
sUnlines   s = unlines $ map show s

judge [xa,ya,ra,xb,yb,rb]
  | x_b >  (ra + rb)      =  0
  | x_b >= abs (ra - rb)  =  1
  | ra > rb               =  2
  | otherwise             = (-2)
  where
    x_b = sqrt ((xa-xb)^2 + (ya-yb)^2)

Measured memory_bytes: 4372
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
struct node
{
	int x,y,next;
}a[200010];int len,last[100010];
inline void ins(int x,int y)
{
	len++;
	a[len].x=x;a[len].y=y;
	a[len].next=last[x];last[x]=len;
}
int fa[100010],f[100010],dep[100010];
inline void dfs(int x)
{
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(y==fa[x])continue;
		fa[y]=x,dep[y]=dep[x]+1;
		dfs(y);
		f[x]=max(f[x],f[y]+1);
	}
}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),p=read(),rt=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		ins(x,y),ins(y,x);
	}dfs(rt);
	int uf=dep[p]/2,ans=0,cnt=0,ul=dep[p];
	while(cnt<=uf)
	{
		ans=max(ans,f[p]+ul-cnt-1);
		cnt++,p=fa[p];
	}pr2(ans);
	return 0;
}

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

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

	int dp[n + 10];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	dp[2] = min(dp[i - 2] + abs(h[i] - h[i - 2]), h[i] - h[i - 1]);

	for (i = 2; i < n; i++) {
		dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    string s;
    cin >> s;
    bool f = true;
    for(int i = 0; i < s.size(); i++){
        if(i%2==0){
            if(s.at(i) == 'L') f = false;
        }else{
            if(s.at(i) == 'R') f = false;
        }
    }
    if(f == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    string s;
    cin >> s;
    int ans = 0;
    if (s[0] != 'C') {
        ans++;
    }
    if (s[1] != 'O') {
        ans++;
    }
    if (s[2] != 'D') {
        ans++;
    }
    if (s[3] != 'E') {
        ans++;
    }
    if (s[4] != 'F') {
        ans++;
    }
    if (s[5] != 'E') {
        ans++;
    }
    if (s[6] != 'S') {
        ans++;
    }
    if (s[7] != 'T') {
        ans++;
    }
    if (s[8] != 'I') {
        ans++;
    }
    if (s[9] != 'V') {
        ans++;
    }
    if (s[10] != 'A') {
        ans++;
    }
    if (s[11] != 'L') {
        ans++;
    }
    if (s[12] != '2') {
        ans++;
    }
    if (s[13] != '0') {
        ans++;
    }
    if (s[14] != '1') {
        ans++;
    }
    if (s[15] != '6') {
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int climb_dp(int* h, int n, int k)
{
    int dp[n];
    
    // Initialise states
    dp[0] = 0;
    for(int j=1; j<=k; j++)
        dp[j] = abs(h[j] - h[0]);

    // Calculate the most optimal state for i
    // building upon previous optimal states
    for(int i=2; i<n; i++)
    {   
        int min = dp[i-1]+abs(h[i] - h[i-1]);
        for(int j=2; j<=k; j++)
            if(i-j >= 0 && dp[i-j]+abs(h[i] - h[i-j]) < min)
                min = dp[i-j]+abs(h[i] - h[i-j]);
        dp[i] = min;
    }

    return dp[n-1];

}

int main()
{
    int n, k;
    cin >> n >> k;

    if(k > n)
        k = n;

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

    cout << climb_dp(h, n, k);
    return 0;
}

Measured memory_bytes: 1024
def main():
    length = int(input())
    words = [input() for _ in range(3)]
    answer = 0
    for i in range(length):
        l = [words[0][i], words[1][i], words[2][i]]
        answer += len(set(l)) - 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <atcoder/all>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int, int>;

void solve(ll K) {
  REP(i, K)
    cout << "ACL";
  cout << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll K;
  cin >> K;

  solve(K);

  return 0;
}


Measured memory_bytes: 3676
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A+B+C>=22) cout<<"bust";
  else cout<<"win";
return 0;}

Measured memory_bytes: 3608
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n, m = list(map(int, input().strip().split()))
    if n == m:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
using namespace std;
int main(){
	int x,y,z,t,mn;
	while(cin>>z,z){
		mn=1111*1111*1111;
		for(y=z-1;y>0;y--)for(x=1;(t=z*z*z-x*x*x-y*y*y)>0;x++)if(mn>t)mn=t;
		cout<<mn<<endl;
	}
	return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll n, k;
    cin >> n >> k;

    double ans = 0;
    FOR(i, 1, n+1){
        double a = (double)k/i;
        double p = log2(a);
        int x;
        if(p < 0) x = 0;
        else x = ceil(p);        
        ans += (double) pow(2, -x) / n;
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <deque>
#include <cmath>
#include <complex>
#include <cassert>
#include <cstring>
#include <functional>
#include <bitset>
#include <climits>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define cmn(x,y) x=min(x,y)
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template<typename T> class segtree {
private:
    int n,sz;
    vector<pair<T, int> > node;
public:
    segtree(vector<T>& v) : sz((int)v.size()){
        n = 1;
        while(n < sz){
            n *= 2;
        }
        node.resize(2*n, make_pair(numeric_limits<T>::max(), sz));
        for(int i = 0; i < sz; i++){
            node[i+n] = make_pair(v[i], i);
        }
        for(int i=n-1; i>=1; i--){
            node[i] = min(node[2*i], node[2*i+1]);
        }
    }
    void update(int k, T a)
    {
    	node[k+n] = make_pair(a, k);
        k += n;
    	while(k>>=1){
            node[k] = min(node[2*k], node[2*k+1]);
    	}
    }
    pair<T, int> query(int a,int b,int k=0,int l=0,int r=-1)
    {
        pair<T, int> res1 = make_pair(numeric_limits<T>::max(), sz);
        pair<T, int> res2 = make_pair(numeric_limits<T>::max(), sz);
        a += n, b += n;
        while(a != b){
            if(a % 2) cmn(res1, node[a++]);
            if(b % 2) cmn(res2, node[--b]);
            a >>= 1, b>>= 1;
        }
        return min(res1, res2);
    }
    void print()
    {
        for(int i = 0; i < sz; i++){
            pair<T, int> p;
            p = query(i,i+1);
            cout << "st[" << i << "]: " << p.first << " " << p.second << endl;
        }
    }
};


int n;
ll d;
ll saiki(segtree<ll>& sg, int a,int b){
    //cerr << a << " " << b << endl;
    if(b==a+1)return 0;
    auto p = sg.query(a,b);
    ll s = p.first;
    ll ans = 0;
    int ind = p.second;
    if(ind-1>=a){
        ll xx = sg.query(ind-1,ind).first;
        ans += s+d+xx;
        sg.update(ind-1,min(xx,s+d));
        ans += saiki(sg,a,ind);
    }
    if(ind+1<b){
        ll xx = sg.query(ind+1,ind+2).first;
        ans += s+d+xx;
        sg.update(ind+1,min(xx,s+d));
        ans += saiki(sg,ind+1,b);
    }
    return ans;
}


int main(){
    cin >> n >> d;
    vector<ll>v(n+1);
    rep(i,n)cin >> v[i];
    segtree<ll> sg(v);
    ll ans = saiki(sg,0,n);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 25600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;
//西暦⇒時代の歴
ll a[100010];
int main()
{
    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    if (2 * N >= M)
    {
        cout << M / 2 << endl;
    }
    else
    {
        ans += N;
        M -= 2 * N;
        ans += M / 4;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
 long long n,m,k; cin >> n >> m >> k;
 cout << max((long long)0, (n-2)*(k-m)+1) << "\n";
}

Measured memory_bytes: 256
#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 };


// 素因数が何乗かをmapで返却する
map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


void solve() {
    int N; cin >> N;
    int res=0;
    for(int i=0; 2*i+1 <= N; i++){
        auto tmap = prime_factor(2*i+1);
        ll tmp = 1;
        for(auto a: tmap){
            tmp *= (a.second+1);
        }
        if(tmp == 8) res++;
    }

    cout << res << 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: 4352
#[derive(Default)]
//NOTE
//declare variables to reduce the number of parameters for dp and dfs etc.
struct Solver {}

impl Solver {
    fn solve(&mut self) {
        let stdin = std::io::stdin();
        let mut scn = Scanner {
            stdin: stdin.lock(),
        };
        let n: usize = scn.read();
        let mut a: Vec<usize> = scn.vec(n);
        let mut result = 0;
        a.sort();
        a.reverse();
        result += a[0];
        let mut cnt = 2;
        for x in a.iter().skip(1) {
            if cnt + 2 <= n {
                result += 2 * x;
                cnt += 2;
            } else if cnt + 1 <= n {
                result += x;
                cnt += 1;
            }
            if cnt == n {
                break;
            }
        }
        println!("{}", result);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| {
            let mut solver = Solver::default();
            solver.solve()
        })
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 3232