akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	string s; cin >> s;
	
	vl dp = {1};
	FOR(k,2,n+1) {
		ll sum = 0;
		vl ndp(k);
		if (s[k-2] == '<') {
			FORD(i,0,k) {
				ndp[i] = sum;
				if (i == 0) break;
				sum = (sum + dp[i-1]) % MOD;
			}
		} else {
			FOR(i,0,k) {
				ndp[i] = sum;
				if (i+1 == k) break;
				sum = (sum + dp[i]) % MOD;
			}
		}
		dp = ndp;
	}
	cout << accumulate(all(dp),0LL) % MOD << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}

constexpr int mxN = 5e5;
vector<int> appearance_index[mxN];

struct FenwickTree {
    vector<int> bit;  // binary indexed tree
    int n;

    FenwickTree(int n) {
        this->n = n;
        bit.assign(n, 0);
    }

    FenwickTree(vector<int> a) : FenwickTree(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    int sum(int r) {
        int ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    int sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

void solve(){
    int n, q;
    read(n, q);
    vector<int> color(n);
    for(int i = 0 ; i < n ; i++){
        int c;
        cin >> c;
        c--;
        color[i] = c;
        appearance_index[c].push_back(i);
    }
    set<array<int,3>> queries;
    for(int i = 0 ; i < q ; i++){
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        queries.insert({r, l, i});
    }
    set<pair<int,int>> ans;
    vector<int> good_ball(n);
    for(int i = 0; i < n ; i++){
        if(appearance_index[i].size() > 0){
            good_ball[appearance_index[i].back()] = 1;
        }
    }
    FenwickTree ft(good_ball);
    int current_right = n - 1;
    for(auto it = queries.rbegin() ; it != queries.rend(); it++){
        int r = (*it)[0];
        int l = (*it)[1];
        int query_index = (*it)[2];
        while(r < current_right){
            //update good bool 
            int current_color = color[current_right];
            auto it_temp = lower_bound(appearance_index[current_color].begin(),
                                     appearance_index[current_color].end(),
                                     current_right);
            if( it_temp != appearance_index[current_color].begin()){
                it_temp--;
                ft.add(*it_temp, 1);
            }
            current_right--;
        }
        int color_count;
        if( l > 0 ) {
            color_count = ft.sum(l,r);
        }else {
            color_count = ft.sum(r);
        }
        ans.insert(make_pair(query_index, color_count));
    }
    for(const auto & res : ans){
        cout << res.second << "\n";
    }
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    solve();

    return 0;
}


Measured memory_bytes: 91832
N,A,B = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(1,N):
  if (a[i] - a[i-1])*A < B:
    ans += (a[i] - a[i-1])*A
  else:
    ans += B
print(ans)

Measured memory_bytes: 14252
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

#define INF INT_MAX / 2
#define int long long
using namespace std;

signed main() {
  vector<vector<int>> G(205, vector<int>(205, INF));
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> r(R);
  for (int i = 0; i < R; i++)
    cin >> r[i];
  for (int i = 0; i <= N; i++)
    G[i][i] = 0;

  for (int i = 0; i < M; i++) {
    int A, B, C;
    cin >> A >> B >> C;
    A--;
    B--;
    G[A][B] = C;
    G[B][A] = C;
  }

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      for (int k = 0; k <= N; k++) {
        G[j][k] = min(G[j][k], G[j][i] + G[i][k]);
      }
    }
  }
  int ans = INF;
  sort(r.begin(), r.end());

  do {
    int res = 0;
    for (int i = 0; i < R - 1; i++) {
      res += G[r[i] - 1][r[i + 1] - 1];
    }
    ans = min(ans, res);
  } while (next_permutation(r.begin(), r.end()));

  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N, M; cin >> N;
	map<string, ll>m;
	string S;
	rep(i, 0, N) {
		cin >> S;
		m[S]++;
	}
	cin >> M;

	string T;
	rep(i, 0, M) {
		cin >> T;
		m[T]--;
	}

	ll maxV = 0;
	for (map<string, ll>::iterator it = m.begin(); it != m.end(); it++)
	{
		maxV = max(maxV, it->second);
	}
	cout << maxV << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
struct student 
{
	int index;
	int num;
	bool operator < (const student& p) const 
	{
		return num< p.num;
	}
};
student s[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		s[i].index=i+1;
		cin>>s[i].num;
	 } 
	sort(s,s+n);
	for(int i=0;i<n;i++)
	{
		cout<<s[i].index<<" ";
	}
	return 0;
 } 

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    int N;
    cin >> N;

    ll MOD=1e9+7;

    vector<ll> A;
    ll temp = 0;
    for(int i=0; i<N; i++){
        cin >> temp;
        A.emplace_back(temp);
    }

    ll now;
    ll ans = 0;

    REP(i,61){
        now = 0;
        REP(j,A.size()){
            if((A[j] >> i) & 1){
                now++;
            }
        }
        // cout << now;
        temp = modpow(2,i,MOD);
        temp = temp * now % (ll)MOD;
        // cout << temp << " ";
        temp = temp * (N - now) % (ll)MOD;
        ans += temp;
        ans = ans % (ll)MOD;
    }

    cout << ans << "\n";

return 0;
}

Measured memory_bytes: 6128
#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main( void )
{
	map <int,int> T;
	vector <int> P;
	vector <int> L;

	string in;
	while ( 1 )
	{
		in = "";
		getline( cin, in );
		if ( in == "" ) break;
		replace( in.begin(), in.end(), ',', ' ' );
		istringstream is( in );

		int no, d;
		is >> no >> d;
		T[no]++;

		if ( find( P.begin(), P.end(), no ) == P.end() )
		{
			P.push_back( no ) ;
		}
	}

	while ( cin >> in )
	{
		replace( in.begin(), in.end(), ',', ' ' );
		istringstream is( in );
		int no, d;
		is >> no >> d;
		T[no]++;

		if ( find( L.begin(), L.end(), no ) == L.end() && find( P.begin(), P.end(), no ) != P.end() )
		{
			L.push_back( no );
		}
	}

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

	for ( vector <int>::iterator it = L.begin(); it != L.end(); it++ )
	{
		cout << *it << " " << T[*it] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws IOException{
		//BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		Scanner reader=new Scanner(System.in);
		//int in=reader.nextInt();
		int[] tmp={31,29,31,30,31,30,31,31,30,31,30,31};
		String[] ans={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
		int a,b;
		while(true){
			a=reader.nextInt();
			b=reader.nextInt();
			if(a==0&&b==0)break;
			int h=1;
			int co=0;
			while(h!=a){
				co+=tmp[h-1];
				h++;
			}
			co+=b;
			System.out.println(ans[co%7]);
		}	
	}
}

Measured memory_bytes: 17208
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  2000007
#define md 998244353ll
///////////////////////////
///////////////////////////
///


int ar[10004];
int main(){

    for(int i = 1; i<= 100;i++){
        for(int j = 1; j <= 100; j++){
            for(int k = 1; k <= 100; k++){
                int n = i * i + j * j + k * k + i * j + j * k + k * i;
                if(n <= 10000){
                    ar[n]++;
                }
            }
        }
    }
    int n;
    I(n);
    for(int i = 1;i<= n;i++){
        PI(ar[i]), NL;
    }
    return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define ll long long


ll solve(ll n, ll k, vector<ll> heights) {
	vector<ll> dp(n + 1, INT_MAX);
	dp[1] = 0;
	for (int i = 2; i <= n; ++i) {
		for (int j = (i - 1); j >= (i - k) && j >= 1; --j) dp[i] = min(dp[j] + abs(heights[i - 1] - heights[j - 1]), dp[i]);
	}
	return dp[n];
}
int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	ll n, k;
	cin >> n >> k;
	vector<ll> heights(n, 0);
	for (int i = 0; i < n; ++i) {cin >> heights[i];}
	cout << solve(n, k, heights);
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define MAXN 100000
using namespace std;

int t;
int n,k;
int pos[MAXN];
vector<int>dis;

void solve()
{
	if(n<=k)
	{
		cout<<"0"<<endl;
		return;
	}
	for(int i=1;i<n;i++)
	{
		dis.push_back(pos[i]-pos[i-1]);
	}
	sort(dis.begin(),dis.end());
	int res=0;
	for(int i=0;i<n-k;i++)
	{
		res+=dis[i];
	}
	cout<<res<<endl;
	dis.clear();
}

void input()
{
	scanf("%d",&t);
	for(int i=0;i<t;i++)
	{
		scanf("%d%d",&n,&k);		
		for(int i=0;i<n;i++)
		{
			scanf("%d",&pos[i]);
		}
		solve();
	}
}

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


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

class Card{
    public:
    char name;
    int value;
};

void swap(Card *a, Card *b){
    Card tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void BubbleSort(Card* C, int N){
    int i,j;
    for(i=0;i<N;i++){
        for(j=N-1;j>i;j--){
            if(C[j].value < C[j-1].value){
                swap(C[j],C[j-1]);
            }
        }
    }
}

void SelectionSort(Card* C, int N){
    int i,j,minj;
    for(i=0;i<N;i++){
        minj = i;
        for(j=i;j<N;j++){
            if(C[j].value < C[minj].value){
                minj = j;
            }
        }
        swap(C[i],C[minj]);
    }
}

int main(){
    int N,i,*n,stacheck=0,befnum,connect=1;
    char *s;
    cin >> N;
    Card *C = new Card[N];
    n = new int[N];
    s = new char[N];
    for(i=0;i<N;i++){
        cin >> s[i] >> n[i];
        C[i].name = s[i];
        C[i].value = n[i];
    }
    BubbleSort(C,N);
    for(i=0;i<N;i++){
        if(i!=0){
            cout << " ";
        }
        cout << C[i].name << C[i].value;
    }
    cout << endl;
    cout << "Stable" << endl;
    for(i=0;i<N;i++){
        C[i].name = s[i];
        C[i].value = n[i];
    }
    SelectionSort(C,N);
    befnum = C[0].value;
    cout << C[0].name << C[0].value;
    for(i=1;i<N;i++){
        cout << " " << C[i].name << C[i].value;
        if(befnum==C[i].value){
            connect++;
        }else{
            if(connect != 1 && stacheck == 0){
                for(int j=0;j<N;j++){
                    if(befnum==n[j]){
                        if(C[i-connect].name!=s[j]){
                            stacheck++;
                            break;
                        }else{
                            connect--;
                            if(connect==1){
                                break;
                            }
                        }
                    }
                }
            }
            befnum = C[i].value;
        }
    }
    cout << endl;
    if(stacheck==0){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
n,m = gets.split.map(&:to_i)
a = []
b = [] 
for num in 0..m-1 do
  l ,r= gets.split.map(&:to_i)
  a << l
  b << r
end
c = a.sort.reverse[0]
d = b.sort[0]
if d-c < 0
  p 0
else
  p d - c + 1
end

Measured memory_bytes: 6524
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
/*#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <assert.h>*/

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

int n, K;
bool a[N];

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

    cin >> n >> K;
    forn(i, 1, n) {
        char x;
        cin >> x;
        a[i] = (x == 'B');
    }

    int ptr = 1, q = 0;
    forn(it, 1, min(2 * n + (K > 2 * n && (K - 2 * n) & 1), K)) {
        if (!(a[ptr] ^ q)) {
            a[ptr] ^= 1;
            continue;
        }
        q ^= 1;
        a[ptr + n] = q;
        ++ptr;
    }

    forn(i, ptr, ptr + n - 1) {
        cout << (a[i] ^ q ? "B" : "A");
    }

	return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
int main(){
    int w, h, x, y, r;

    scanf("%d %d %d %d %d",&w, &h, &x, &y, &r);

    if(x+r <= w && y+r <= h && x-r >= 0 && y-r >= 0){
        printf("Yes\n");
    }
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    int n, m;
    cin >> n >> m;
    if (n == m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
#define MOD 1000000007
#define FormulaToConvertMicrosecondsToSeconds(duration) duration / 1e+6
#define _CRT_SECURE_NO_DEPRECATE
#define ll                    long long
#define nl                    '\n'                             // NL - sign of new line

#define upperString(str)      transform(str.begin(), str.end(), str.begin(), ::toupper); // make entire string uppercase
#define lowerString(str)      transform(str.begin(), str.end(), str.begin(), ::tolower); // make entire string lowercase

#define ps(x,y)               fixed << setprecision(y) << x     // usage: t=1.1234; cout << ps(t,4); // it means it will print 4 decimal places.

#define eb                    emplace_back
#define sortv(v)              sort(v.begin(), v.end());
#define rsortv(v)             sort(v.rbegin(), v.rend());
#define rev(v)		          reverse(v.begin(), v.end())       // reverse the vector

#define si                    set<int>

#define mii			          std::map <int,int>
#define multimii		      std::multimap <int,int>
#define mss			          map <string, string>
#define w(t)                  unsigned t; cin >> t; while(t--)
mt19937                       rng(chrono::steady_clock::now().time_since_epoch().count());

//==================================

bool isPrime(int num) {
	if (num == 1) return false;
	for (int i = 2; i <= sqrt(num); i++) {
		if (num % i == 0) return false;
	}
	return true;
}

ll binarySearch(int a[], int l, int r, int x)
{
	while (l <= r)
	{
		int mid_index = l + (r - l) / 2;

		if (a[mid_index] == x)
			return mid_index;
		else if ( x > a[mid_index])
		{
			l = mid_index + 1;
		}
		else if ( x < a[mid_index])
		{
			r = mid_index - 1;
		}
	}
	return -1;
}

ll fast_power(ll base, ll power) {
	ll result = 1;
	while (power > 0) {

		// if( power % 2 == 1)
		if (power & 1) { // Can also use (power & 1) to make code even faster
			result = (result * base) % MOD;
		}
		base = (base * base) % MOD;

		// power /= 2
		power >>= 1; // Can also use power >>= 1; to make code even faster
	}
	return result;
}

ll solve(ll h);
//==================================
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//--------------------------------
	auto t1 = std::chrono::high_resolution_clock::now();

	//int t = 1;
	//cin >> t;
	//while (t--)
	//{
	unsigned ll  h; cin >> h;

	cout << solve(h);
	//}



	auto t2 = std::chrono::high_resolution_clock::now();
	auto duration = std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count();

	cerr << "\n\nTime taken : " << FormulaToConvertMicrosecondsToSeconds(duration) << " secs" << nl;
	return 0;
}

ll solve(ll h) //Task A. Double Cola!!! Two teams composing !
{

	if (h == 1) {
		return 1;
	}
	else
	{
		return 2 * solve(h / 2) + 1;
	}

} // !solve


/* TESTS:


*/

Measured memory_bytes: 3800
#include<iostream>
#include<string>
 
bool paro(std::string s) {
    for(size_t i=0; i<s.size()/2;i++){
        if(s[i] != s[s.size()-1-i])
            return false;
    }
    return true;
}
int main(){
    std::string s;
    std::cin >> s;
    int n = s.size();
    if(paro(s) && paro(s.substr(0,(n-1)/2)) && paro(s.substr((n+3)/2-1)))std::cout<<"Yes\n";
    else std::cout<<"No\n";
}

Measured memory_bytes: 256
# rubyにはbsearchがありますが、lower_boundなどに使える機能はありません。よって実装します。
class Array
    def lower_bound(x)
        left=0
        right=self.length
        30.times{
            mid=(left+right)>>1
            if self[mid]<x
                left=mid
            else
                right=mid
            end
        }
        return right
    end

    def upper_bound(x)
        left=0
        right=self.length
        30.times{
            mid=(left+right)>>1
            if self[mid]<=x
                left=mid
            else
                right=mid
            end
        }
        return right
    end
end

# 入力
n=gets.to_i
# 面倒なので全部ソートします(そうするとコピペできる)
a=gets.split(" ").map(&:to_i).sort()
b=gets.split(" ").map(&:to_i).sort()
c=gets.split(" ").map(&:to_i).sort()
# 各b[i]についてcの選び方が何通りあるか
cnum = Array.new(n)
for i in 0...n
    cnum[i]=c.length-c.upper_bound(b[i])
end
# cnumの累積和
accum = Array.new(n+1,0)
(n-1).downto(0){ |i|
    accum[i]=accum[i+1]+cnum[i]
}
# 各aについてb,cの選び方が何通りあるかを答えに足していく
ret=0
for i in 0...n
    idx=b.upper_bound(a[i])
    ret+=accum[idx]
end
puts ret

Measured memory_bytes: 27112
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();
		
		List<Integer> xmv = new ArrayList<Integer>();
		List<Integer> ymv = new ArrayList<Integer>();
		
		int cnt = 0;
		boolean goX = true;
		for(int i=0;i<s.length()+1;i++) {
			if(i!=s.length()&&s.charAt(i)=='F')cnt++;
			else {
				if(goX) {
					xmv.add(cnt);
					goX = false;
				}else {
					ymv.add(cnt);
					goX = true;
				}
				cnt = 0;
			}
		}
		
		int xmax = 0;
		for(int i=0;i<xmv.size();i++)xmax+=xmv.get(i);
		
		//xについて
		boolean dp[][] = new boolean[xmv.size()][35000];
		dp[0][xmv.get(0)+16005]=true;
		for(int i=1;i<xmv.size();i++) {
			int dist = xmv.get(i);
			for(int j=-xmax;j<=xmax;j++) {
				dp[i][j+16005] = dp[i-1][j-dist+16005]||dp[i-1][j+dist+16005];
			}
		}
		
		//yについてコピー
		int ymax = 0;
		if(ymv.size()==0)ymv.add(0);
		for(int i=0;i<ymv.size();i++)ymax+=ymv.get(i);
		
		//yについて
		boolean dpy[][] = new boolean[ymv.size()][35000];

		dpy[0][ymv.get(0)+16005]=true;
		dpy[0][-ymv.get(0)+16005]=true;
		for(int i=1;i<ymv.size();i++) {
			int dist = ymv.get(i);
			for(int j=-ymax;j<=ymax;j++) {
				dpy[i][j+16005] = dpy[i-1][j-dist+16005]||dpy[i-1][j+dist+16005];
			}
		}
		
		String ans = "No";
		if(dp[xmv.size()-1][x+16005]&&dpy[ymv.size()-1][y+16005]) ans = "Yes";
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 329504
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef long long ll;
typedef vector<int> vi;

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

	string::reverse_iterator it = str.rbegin();
	while(it != str.rend()) {
		printf("%c", *it);
		++it;
	}
	printf("\n");
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
int N=1e5+9;
void solve(){
    int n;
    cin>>n;
    vector<ll> dp(1e6,0);
    dp[0]=1;
    for(int j=0;j<=n;j++){
        for(int i=3;i<=n;i++){
            dp[i+j]+=dp[j];
            dp[i+j]%=mod;
        }
    }
    cout<<dp[n];
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	int t=1;
	//cin>>t;
	while(t--) 
	    solve();
	return 0; 
	
}


Measured memory_bytes: 11108
n=gets.to_i
a=[[0,0,0]]
n.times{a<<gets.split.map(&:to_i)}
ok=true
n.times{ |i|
  t,x,y=a[i]
  tn,xn,yn=a[i+1]
  m=tn-t-((xn-x).abs+(yn-y).abs)
  if m<0 || m%2==1
    ok=false
    break
  end
}
puts ok ? :Yes : :No


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

int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		int answer = 0;
		int right = n - 1;
		int left = right - 1;

		while ( left > 0 && right > 0 )
		{
			int sum = ( right - left + 1 ) * ( left + right ) / 2;
			if ( sum == n )
			{
				answer++;
				right--;
				while ( left >= right ) left--; 
			}
			else if ( sum > n )
			{
				right--;
				while ( left >= right ) left--; 
			}
			else if ( sum < n )
			{
				left--;
			}
		}

		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>

int main(int argc, char *argv[])
{
	int h,n;
	cin >> h>>n;
	

	for (int i=0;i<n && h>0;i++)
	{
		int a;
		cin>>a;
		h-=a;
	}

	cout<<(h<=0 ? "Yes":"No")<<endl;
	return 0;
}


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

using namespace std;

int main(void){

    int a, b, c, ans;

    cin >> a >> b >> c;

    ans = max( {10*a + b + c,
                a + 10*b + c,
                a + b + 10*c});
    
    cout << ans << endl;

    return 0;
}

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

ans = 0
for i in range(1, N+1):
    ans += i * (N+1 - i)

for _ in range(N-1):
    l, r = map(int, input().split())
    if l > r:
        l, r = r, l
    ans -= l * (N - r + 1)

print(ans)

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

P merge(P p, P q) {
  int a[4] = {p.first,p.second,q.first,q.second};
  sort(a,a+4,greater<int>());
  return P(a[0],a[1]);
}

int main(){
  int n;
  cin >> n;
  int a[1<<n];
  rep(i,1<<n) cin >> a[i];
  vector<vector<P>> dp(1<<n,vector<P>(n+1));
  rep(i,1<<n) dp[i][0] = P(a[i],-INF);
  rep(j,n) {
    rep(i,1<<n) {
      if(i & (1<<j)) dp[i][j+1] = merge(dp[i][j],dp[i^(1<<j)][j]);
      else dp[i][j+1] = dp[i][j];
    }
  }
  int ans = 0;
  for(int i = 1; i < (1<<n); i++) {
    ans = max(ans,dp[i][n].first+dp[i][n].second);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 52352
#include <stdio.h>

#define N 20
#define Q 200

int solve(int,int);

int A[N],mi[Q],n;

int main()
{
  int i,q;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&mi[i]);
  }

  for(i=0;i<q;i++){
    if(solve(0,mi[i])){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
    
  }
  return 0;
}


int solve(int i,int m)
{
  if(A[i]==m){
    return 1;
  }
  else if(i+1 == n){
    return 0;
  }

  return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

Measured memory_bytes: 580
N = int(input())
A = sorted(list(map(int,input().split())))
MOD = 10**9+7
if N == 1:
    print(1)
    exit()
if N % 2 == 0:
    for i in range(1, N//2+1):
        if A[(i-1)*2] == A[1+(i-1)*2] == 2*i-1:
            pass
        else:
            print(0)
            exit()
    print(2**(N//2)%MOD)
else:
    if A[0] == 0 and A[1] != 0:
        for i in range(1, N//2+1):
            if A[2*i-1] == A[2*i] == 2*i:
                pass
            else:
                print(0)
                exit()
        print(2**(N//2)%MOD)
    else:
        print(0)
        exit()


Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
typedef long long ll;

int main(){
    string S;cin >> S;
    int n = S.size();
    int cnt = 0;
    rep(i, 0, n){
        if(S[i] != S[n - 1 - i] && i != n -1 - i) cnt++;
    }
    cout << (cnt + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;
typedef long long ll;

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

    int a,b,c,ans=0;
    cin>>a>>b>>c;
    for(int i=a;i<=b;i++){
        if(c%i==0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3220
#include<stdio.h>
#include<math.h>
int main(){
    double n1,n2,n3,n4,x,y;
    scanf("%lf%lf%lf%lf",&n1,&n3,&n2,&n4);
    x=(n1-n2)*(n1-n2)+(n3-n4)*(n3-n4);
    y=sqrt(x);
    printf("%0.8lf\n",y);
    return 0;
}



Measured memory_bytes: 2056
import sys
#sys.exit()
#sorted( ,reverse=True)
N = int(input())
#S,T = map(int, input().split())
#A = list(map(int, input().split()))
A =0
W = 0
T = 0
R = 0

for i in range(N):
    c = str(input())
    if c == "AC":
        A+=1
    elif c == "WA":
        W += 1
    elif c == "TLE":
        T += 1
    elif c == "RE":
        R += 1

print(f'AC x {A}')
print(f'WA x {W}')
print(f'TLE x {T}')
print(f'RE x {R}')

#cnt = 0
#cnt += 1



#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
#print(cnt)

Measured memory_bytes: 9212
from heapq import *
n,m,s,t = map(int,input().split())
uvab = [list(map(int,input().split())) for _ in [0]*m]
connect = [[] for _ in [0]*n]
for u,v,a,b in uvab:
    connect[u-1].append((v-1,a,b))
    connect[v-1].append((u-1,a,b))
da = [-1]*n
db = [-1]*n
q = [(0,s-1)]
while q:
    c,i = heappop(q)
    if da[i]!=-1:continue
    da[i] = c
    for j,a,_ in connect[i]:
        if da[j]==-1:
            heappush(q,(c+a,j))
q = [(0,t-1)]
while q:
    c,i = heappop(q)
    if db[i]!=-1:continue
    db[i] = c
    for j,_,b in connect[i]:
        if db[j]==-1:
            heappush(q,(c+b,j))
ans = [10**15]
for ca,cb in zip(da[::-1],db[::-1]):
    ans.append(min(ans[-1],ca+cb))
for out in ans[:0:-1]:
    print(10**15-out)

Measured memory_bytes: 78948
K,N = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    m=a[i+1]-a[i]
    ans = max(ans,m)
h = K - a[N-1]+a[0]
ans = max(ans,h)
ans = K-ans
print(ans)

  


Measured memory_bytes: 25796
#include <iostream>
#include <stdio.h>
#include <queue>
#include <algorithm>
#include <map>
#include <memory.h>

using namespace std;

int main()
{
	int x, y;
	cin >> y >> x;
	x *= 2;
	x++;
	cout << y / x + (y % x != 0) << endl;
	return 0;
}


Measured memory_bytes: 256
ss = input()
ans = 0
cnt = 0
for s in ss:
    if s == "A" or s == "T" or s == "C" or s == "G":
        cnt += 1
    else:
        if ans < cnt:
            ans = cnt
        cnt = 0
    
if ans < cnt:
    ans = cnt

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<sstream>
#include<vector>
#include<cmath>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 100000
using namespace std;

long long pl(int i,int j){
  stringstream ss,tt;
  ss<<i;
  string s=ss.str();
  tt<<j;
  s+=tt.str();
  long long res=0;
  int cnt=0;
  for(int i=s.size()-1;i>=0;i--){
    res+=pow(10,i)*(long long)(s[cnt]-'0');
    cnt++;
  }
  return res;
}

int main(){
  int n,alt;
  cin>>n;
  int m[5];
  rep(i,5)m[i]=INF;
  rep(i,n){
    cin>>m[4];
    sort(m,m+5);
  }
  vector<long long> vec;
  rep(i,4){
    rep(j,4){
      if(i==j)continue;
      vec.push_back(pl(m[i],m[j]));
    }
  }
  sort(vec.begin(),vec.end());
  cout<<vec[2]<<endl;
  return 0;
}

Measured memory_bytes: 1288
A, B, K = map(int, input().split())
quant = A + B

if quant - K <= 0:
    print('0 0')
else:
    rnt = A - K  # RemainNumTime
    a = max(rnt, 0)
    b = min(B + rnt, B)
    print(str(a) + ' ' + str(b))


Measured memory_bytes: 2940
backet = [0]*(ord('z') - ord('a') + 1)
h,w = map(int,input().split())
for _ in range(h):
  a = list(input())
  for i in a:
    backet[ord(i) - ord('a')] += 1

mod = [0,0,0,0]
for i in backet:
  mod[i%4] += 1
ans = False
if h%2 and w%2:
  if mod[1] + mod[3] == 1 and (mod[2]+mod[3] - (h//2+w//2))%2 == 0 and mod[2]+mod[3] - (h//2+w//2) <= 0:
    ans = True
elif h%2:
  if mod[1]+mod[3] == 0 and (mod[2]+mod[3]-w//2)%2==0 and mod[2]+mod[3]-w//2<=0:
    ans = True
elif w%2:
  if mod[1]+mod[3] == 0 and (mod[2]+mod[3]-h//2)%2 == 0 and mod[2]+mod[3]-h//2 <= 0:
    ans = True
else:
  if mod[1] == mod[2] == mod[3] == 0:
    ans = True
if ans:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  string a,b;
  cin >> a >> b;
  int c = a.size(),tmp;
  for(int i = 0;i<c;i++){
    if(a.at(0)==b.at(i)){
      tmp = i;
    for(int j = 0;j<c;j++){
      if(tmp+j>=c) tmp-=c;
      if(a.at(j)!=b.at(tmp+j)) break;
      if(j==c-1){
        cout << "Yes";
        return 0;
      }
    }
    }
  }
  cout << "No";
}

Measured memory_bytes: 3592
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.Exception
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val k = sc.nextInt()
    if (k % 2 == 0 || k % 5 == 0) {
        println(-1)
    } else {
        var min = Int.MAX_VALUE
        var num = 7L
        for (i in 1..k) {
            if (num % k == 0L) {
                min = i
                break
            }
            num = (10 * num + 7) % k
        }
        println(min)
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34340
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
                )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get!($t)).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_| get!($($t),*)).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(usize);
    let mut line: String = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let v: Vec<u64> = line.split_whitespace()
        .map(|t| t.parse().unwrap())
        .collect::<Vec<_>>();

    println!("{}", v.iter().max().unwrap() - v.iter().min().unwrap());
}


Measured memory_bytes: 4352
from collections import defaultdict

s_dic = defaultdict(int)
for s in list(input()):
    s_dic[s] += 1

values_set = list(set(s_dic.values()))
if len(s_dic.keys()) == 2 and len(values_set) == 1 and values_set[0] == 2:
    print("Yes")
else:
    print("No")


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long N, long long X, std::vector<long long> L){

    lli sum=0;
    lli cnt=1;

    REP(i,0,N){
        sum += L[i];
        if(sum<=X)cnt++;
    }
    cout<<cnt<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    func(N, X, std::move(L));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

int main(){
  string S,T;cin>>S>>T;
  map<char,char> mp;
  REP(i,0,S.size()){
      if(mp.count(S.at(i))==0){
        mp[S.at(i)]=T.at(i);
      }
      else if(mp[S.at(i)]==T.at(i))continue;
      else{
        //print("here")
        print("No")
        return 0;
      }
  }
  swap(S,T);
  map<char,char> mp1;
  REP(i,0,S.size()){
      if(mp1.count(S.at(i))==0){
        mp1[S.at(i)]=T.at(i);
      }
      else if(mp1[S.at(i)]==T.at(i))continue;
      else{
        //print("here")
        print("No")
        return 0;
      }
    
  }
  print("Yes")
}


Measured memory_bytes: 776
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int N = scan.nextInt();

		for(int i = 0; i < N; i++) {
			int a;
			a = scan.nextInt();
			H -= a;
		}

		if(H <= 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  ll c;
  cin >> n >> c;

  vl h(n);
  rep(i,0,n) cin >> h[i];

  vl dp(n);
  auto f = [&](int j, int i) { return -2*h[j]*h[i] + h[j]*h[j] + c + dp[j]; };
  auto inter = [&](int a, int b) -> ld { // returns the x coordinate of intersection
    return ld(h[b]*h[b]+dp[b] - h[a]*h[a] - dp[a]) / ld(-2*h[a] + 2*h[b]);
  };

  deque<int> dq;
  dq.pb(0);
  rep(i,1,n) {
    while (sz(dq) > 1 and f(dq[0], i) > f(dq[1], i))
      dq.pop_front();

    dp[i] = h[i]*h[i] + f(dq.front(), i);

    // insert line
    while (sz(dq) > 1 and inter(dq[sz(dq)-2], dq.back()) > inter(dq.back(), i)) dq.pop_back();
    dq.pb(i);
  }

  cout << dp[n-1] << '\n';
}

Measured memory_bytes: 3968
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
using namespace std;
#define N (1000000000+7)
typedef pair<int, int> P;

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


int main(void) {
	double t, x;
	cin >> t >> x;
	printf("%lf\n", (double)t / x);
	
	return 0;
}

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

int myChe(map<long long,long long> &checked, pair<long long, long long> tmp, long long &minC){
  	  int flag = 1;
      long long n,cost,thisC;
      tie(n,cost) = tmp;
      if(minC <= cost) flag = 0;
	  if(checked.count(n)){
        thisC = checked.at(n);
        if(thisC <= cost) flag = 0;
        else checked[n] = cost;
      }
      else{
        checked[n] = cost;
      }
  	  if(n==1){
        minC = min(minC,cost);
        flag = 0;
      }
      else if(n==0) flag = 0;
  	  return flag;
}

void myTmp(map<long long,long long> &checked, long long &minC,
           pair<long long, long long> tmp, 
           queue<pair<long long, long long>> &que, 
           int p, long long costA, long long costD){
  long long n,cost;
  pair<long long, long long> tmp2;
  tie(n,cost) = tmp;
  if(n%p == 0){
    tmp2 = make_pair(n/p, cost + costA);
    if(myChe(checked,tmp2,minC)) que.push(tmp2);
  }
  else{
    tmp2 = make_pair(n/p, cost + costA + costD*(n%p));
    if(myChe(checked,tmp2,minC))que.push(tmp2);
    tmp2 = make_pair(n/p+1, cost + costA + costD*(p - n%p));
    if(myChe(checked,tmp2,minC))que.push(tmp2);
  }
}
int main(){
  int T;
  cin >> T;
  vector<long long> N(T), A(T), B(T), C(T), D(T);
  for(int i=0; i<T; i++){
 	 cin >> N[i] >> A[i] >> B[i] >> C[i] >> D[i];
  }
  for(int i=0; i<T; i++){
    queue<pair<long long, long long>> que;
    pair<long long, long long> tmp,tmp2;
    tmp = make_pair(N[i],0);  
    que.push(tmp);
    long long n,cost,minCost = 1e15, thisC;
    map<long long,long long> checked;
    checked[N[i]] = 0;

    while(que.size()){
      tmp = que.front(); que.pop();
      tie(n,cost) = tmp;
      myTmp(checked, minCost, tmp, que, 2, A[i], D[i]);
      myTmp(checked, minCost, tmp, que, 3, B[i], D[i]);
      myTmp(checked, minCost, tmp, que, 5, C[i], D[i]);
      if(D[i]*(long long)(n-1) >= 0 && D[i]*(long long)(n-1) < 1e15) 
        tmp2 = make_pair(1,cost+D[i]*(long long)(n-1));
      if(myChe(checked,tmp2,minCost))que.push(tmp2);
    }
    cout << minCost + D[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

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

    int a[q];
    ll cou[n];
    for(int i = 0; i < n; i++){
        cou[i] = 0;
    }

    for(int i = 0; i < q; i++){
        cin >> a[i];
        cou[a[i] - 1]++;
    }

    for(int i = 0; i < n; i++){
        if(k - (q - cou[i]) <= 0){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

#define mkp make_pair

int N;

int win[10];
int beat[10][10];

vector<pair<int,int>> rest;
int ans;

void dfs(int now){
    if(now==rest.size()){
        bool ok=true;
        for(int i=1;i<=N;i++) if(win[i]!=N/2) ok=false;
        if(ok) ans++;
    }else{
        int x=rest[now].first;
        int y=rest[now].second;
        
        win[x]++;
        if(win[x]<=N/2) dfs(now+1);
        win[x]--;

        win[y]++;
        if(win[y]<=N/2) dfs(now+1);
        win[y]--;
    }
}

void solve(){
    for(int i=0;i<=N;i++) win[i]=0;
    for(int i=0;i<=N;i++) for(int j=0;j<=N;j++) beat[i][j]=0;
    rest.clear();
    ans=0;

    int M;
    cin>>M;
    for(int i=0;i<M;i++){
        int x,y;
        cin>>x>>y;
        beat[x][y]=1;
        beat[y][x]=-1;
        win[x]++;
    }
    
    for(int i=1;i<=N;i++){
        for(int j=i+1;j<=N;j++){
            if(beat[i][j]==0){
                rest.push_back(mkp(i,j));
            }
        }
    }

    dfs(0);
    cout<<ans<<endl;
}

int main(){
  while(1){
      cin>>N;
      if(N==0) break;
      solve();
  }

  return 0;
}



Measured memory_bytes: 3044
def examA():
    X = I()
    if X<30:
        ans = "No"
    else:
        ans = "Yes"
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep,alphabet_convert
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 77008
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int du[100010],dv[100010];
vector<int> A[100010];

void dfs(int i,int p,int *d){
  for(int j=0;j<A[i].size();j++){
    if(A[i][j]==p) continue;
    d[A[i][j]]=d[i]+1;
    dfs(A[i][j],i,d);
  }  
}

int main(){
  int n,u,v;
  cin>>n>>u>>v;
  
  int x,y;
  rep(i,n-1){
    cin>>x>>y;
    A[x].push_back(y);
    A[y].push_back(x);
  }
  
  du[u]=0;
  dfs(u,u,du);
  dv[v]=0;
  dfs(v,v,dv);
  
  int ma=0;
  for(int i=1;i<=n;i++){
    if(du[i]>dv[i]) continue;
    chmax(ma,dv[i]);
  }
  
  cout<<ma-1<<endl;
  
  return 0;
}

Measured memory_bytes: 16000