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

#define ll long long
#define in ({ll x=0;int o=0,c=getchar();for(;!isdigit(c);c=getchar()) o=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';o?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})
#define instring ({string s;char c=getchar();while(c==' '||c=='\n') c=getchar();while(c!=' '&&c!='\n') s+=c,c=getchar();s;})

#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define ROF(i,a,b) for(auto i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "

#define bitnum(x) __builtin_popcountll(x)
#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pow2(x) (1ll<<x)

#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1

#define ifnot(x) if(!(x))
#define middle(a,b) (a+(b-(a))/2)
#define bp(x) ((x)*(x))
////////////////////////////////////////// HUX
#define int ll
const int N=2e5+5;
int n,res;
int a[N],b[N];

priority_queue<pi> h;
int LEF(int x){return x==1?n:x-1;}
int RIG(int x){return x==n?1:x+1;}
void PUSH(int x){if(a[x]<b[x]) h.push({b[x],x});}
main()
{
   // freopen("hx.inp","r",stdin);
    n=in;
    FOR(i,1,n) a[i]=in;
    FOR(i,1,n) b[i]=in;
    FOR(i,1,n) PUSH(i);
    for(;h.size();)
    {
        int v=h.top().x,x=h.top().y;h.pop();
        ll B=b[LEF(x)]+b[RIG(x)];

        if(v!=b[x]) continue;
        if(v<B||B==0) return cout<<"-1",0;

        int cnt=(v-a[x])/B;
        res+=cnt;
        v-=cnt*B;b[x]=v;

        PUSH(LEF(x));
        PUSH(RIG(x));
    }
    cout<<res;
}


Measured memory_bytes: 13420
import sys
sys.setrecursionlimit(4100000)

import logging

# logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)

import math


def resolve():
    X, Y = [int(x) for x in sys.stdin.readline().split()]

    logger.debug('{} {}'.format(X, Y))

    count = 1
    while (True):
        X = X * 2
        if X > Y:
            break
        else:
            count += 1

    print(count)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 20"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """25 100"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """314159265 358979323846264338"""
        output = """31"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """1 2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """3 3"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_6(self):
        input = """999999999999999999 1000000000000000000"""
        output = """1"""
        self.assertIO(input, output)

Measured memory_bytes: 5852
using System;

namespace ABC138A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if (3200 <= a)
                Console.WriteLine(s);
            else
                Console.WriteLine("red");
            Console.ReadKey();
            

        }
    }
}

Measured memory_bytes: 13140
def gcd(a,b):
	a,b = max(a,b),min(a,b)
	while a%b!=0:
   		a,b = b,a%b
	return b

N=int(input())
A = list(map(int,input().split()))

S1 = [A[0]]
s = A[0]
for i in range(1,N-1):
    s=gcd(s,A[i])
    S1.append(s)

S2 = [A[N-1]]
s = A[N-1]
for i in range(1,N-1):
    s=gcd(s,A[N-i-1])
    S2.append(s)

max_gcd = 1
for i in range(N):
    if i==0:
        max_gcd=max(max_gcd,S2[N-2])
    elif i==N-1:
        max_gcd=max(max_gcd,S1[N-2])
    else:
        max_gcd=max(max_gcd,gcd(S1[i-1],S2[N-2-i]))

print(max_gcd)  
    

Measured memory_bytes: 67180
#include <string>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <iostream>

#include <regex>
#include <atomic>
#include <thread>

using namespace std;

int CheckPopularNum(const vector<int>& list, const int total_vote, const int select_num) {
    int ret = 0;

    for(int vote : list) {
        if( vote >= static_cast<double>(total_vote) / (4 * select_num) ) {
            ++ret;
        }
    }
    return ret;
}

int main() {
    int product_num, popular_num;
    cin >> product_num >> popular_num;

    vector<int> vote_list(product_num);
    int total_vote = 0;
    for(int i = 0; i < product_num; ++i) {
        int vote;
        cin >> vote;
        vote_list[i] = vote;
        total_vote += vote;
    }

    const string result = (CheckPopularNum(vote_list, total_vote, popular_num) >= popular_num) ? ("Yes") : ("No");
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        int main(){
			long long n,ans=0;
			cin>>n;
			string s[n+1];
			for(int i=0;i<n;i++){
				cin>>s[i];
              	for(int j=0;j<10;j++){
                  for(int k=9;k>=j;k--){
                    if(s[i][k]<s[i][k-1]){
                      char a;
                      a=s[i][k];
                      s[i][k]=s[i][k-1];
                      s[i][k-1]=a;
                    }
                  }
                }
			}
		sort(s,s+n);
         long long c=1;
		for(int i=1;i<n;i++){
          if(s[i]==s[i-1]){
            c++;
          }
          else{
            if(c!=1)
            ans+=c*(c-1)/2;
            c=1;
        }
        }
            ans+=c*(c-1)/2;
          cout<<ans<<endl;
    		return(0);
        }

Measured memory_bytes: 7296
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
h = list(li())
INF = float('inf')

dp = [INF]*n
dp[0] = 0

for idx in range(n):
    for jdx in range(min(idx, k)):
        dp[idx] = min(dp[idx],
                      dp[idx-jdx-1] + abs(h[idx]-h[idx-jdx-1]))

print(dp[-1])


Measured memory_bytes: 55184
fn main() {
        let mut input1 = String::new();
        std::io::stdin().read_line(&mut input1).unwrap();
        let mut input2 = String::new();
        std::io::stdin().read_line(&mut input2).unwrap();
        println!("{}", input1.chars().count() - input1.chars().zip(input2.chars()).filter(|(a, b)| a == b).count());
    }

Measured memory_bytes: 2484
#include <stdio.h>

int main() {

  char r, suit;
  int num;
  int n, i, j, x;
  int cards[4][14]={};
  scanf("%d", &n);
  for (i = 0; i < n; i++){
    scanf("%c %c %d", &r, &suit, &num);
    if (suit == 'S')
      cards[0][num] = 1;
    if (suit ==  'H')
      cards[1][num] = 1;
    if (suit == 'C')
      cards[2][num] = 1;
    if (suit == 'D')
      cards[3][num] = 1;
  }
  for (i = 0; i < 4; i++){
    for (j = 1; j < 14; j++){
      if (cards[i][j] == 0){
	if (i == 0)
	  printf("S %d\n", j);
	if (i == 1)
	  printf("H %d\n", j);
	if (i == 2)
	  printf("C %d\n", j);
	if (i == 3)
	  printf("D %d\n", j);
      }
    }
  }

  return 0;

}

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

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

int main() {
	int n;
	string s;
	cin>>n>>s;
	rep(i,s.size()){
		int x=s[i]-'A';
		x=(x+n)%26;
		putchar('A'+x);
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
a, b,c  = map(int, input().split()) 
k  = int(input()) 

for i in range(k):
  if b >= c:
    c *= 2
  elif a >= b:
    b *= 2
  else:
    c *= 2

if (b > a) and (c > b):
  result = "Yes"
else:
  result = "No"
    
print(result)

Measured memory_bytes: 9176
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100100;
int i,j,k,n,m,ch,ff;
ll K;
int x[N],a[N],p[N],ans[N],tmp[N];
ll Ans[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void R(ll &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(ll x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
void work(int *A,int *B,int *C) {
	int i;
	for (i=1;i<n;i++) tmp[i]=A[B[i]];
	for (i=1;i<n;i++) C[i]=tmp[i];
}
int main() {
	R(n);
	for (i=1;i<=n;i++) R(x[i]);
	R(m);R(K);
	for (i=1;i<n;i++) ans[i]=p[i]=i;
	for (i=1;i<=m;i++) {
		R(a[i]);
		swap(p[a[i]-1],p[a[i]]);
	}
	for (;K;K>>=1,work(p,p,p))
		if (K&1) work(ans,p,ans);
	for (i=1;i<n;i++) Ans[i]=x[ans[i]+1]-x[ans[i]];
	Ans[0]=x[1];
	for (i=1;i<n;i++) Ans[i]+=Ans[i-1];
	for (i=0;i<n;i++) W(Ans[i]),puts("");
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;


int main() {
  IN(ll, K);
  IN(ll ,X);
  for(ll i = X - K + 1; i < X + K-1;i++)
    cout << i << " ";
  cout << K + X -1<< endl;
  
}

Measured memory_bytes: 256
// finish date: 2018/2/10

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int L;
    cin >> L;
    vl A(L);
    rep(i, L) cin >> A[i];

    vvl dp(5, vl(L, LONG_LONG_MAX));

    rep(i, 5) {
        rep(j, L) {
            switch (i) {
                case 0:
                    dp[i][j] = A[j];
                    if (j != 0) dp[i][j] += dp[i][j - 1];
                    break;

                case 1:
                    dp[i][j] = A[j] % 2;
                    if (A[j] == 0) dp[i][j] += 2;
                    if (j != 0) dp[i][j] += min(dp[i - 1][j - 1], dp[i][j - 1]);
                    break;

                case 2:
                    dp[i][j] = 1 - A[j] % 2;
                    if (j != 0) dp[i][j] += min({dp[0][j - 1], dp[1][j - 1], dp[2][j - 1]});
                    break;

                case 3:
                    dp[i][j] = A[j] % 2;
                    if (A[j] == 0) dp[i][j] += 2;
                    if (j != 0) dp[i][j] += min({dp[0][j - 1], dp[1][j - 1], dp[2][j - 1], dp[3][j - 1]});
                    break;

                case 4:
                    dp[i][j] = A[j];
                    if (j != 0) dp[i][j] += min({dp[0][j - 1], dp[1][j - 1], dp[2][j - 1], dp[3][j - 1], dp[4][j - 1]});

                default:
                    break;
            }
        }
    }

    ll mi = LONG_LONG_MAX;
    rep(i, 5)mi = min(mi, dp[i][L - 1]);

    cout << mi <<
         endl;
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int H1,M1,H2,M2,K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    
    int a = H1*60+M1, b = H2*60+M2;
    
    if(a > b) b += 24*60;
    cout << b-a-K << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 3652
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}


int main(void){
  ll N, A, B, W, H, C, D, Q, X, Y;
  string S, T;
  //cin >> N;
  string c[3];
  rep(i, 3) {cin>>c[i];}
  //cout << c[0] << endl;
  cout << c[0][0] << c[1][1] << c[2][2] << endl;


}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
T = [0]*N
for i in range(N):
    T[A[i]]+=1
flag = 0
if N%2==1:
    for i in range(N):
        if i==0 and T[i]!=1:
            flag = 1
        elif i%2==0 and i>=2 and T[i]!=2:
            flag = 1
elif N%2==0:
    for i in range(N):
        if i%2==1 and T[i]!=2:
            flag = 1
if flag==1:
    print(0)
else:
    if N%2==1:
        print(pow(2,(N-1)//2,10**9+7))
    else:
        print(pow(2,N//2,10**9+7))

Measured memory_bytes: 84784
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<usize>();
    if n==1{println!("Hello World")}
    else{
        let a=read::<usize>();
        let b=read::<usize>();
        println!("{}",a+b)
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N, K, a=1e9,c=0; cin >> N >> K;
	vector<int> x(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i]; 
		if (a > x[i]) a = x[i]; 
	}
	for (int i = 0; i < N; i++)if (x[i] == a)c++;
	cout << (N-c+K-2)/(K-1) << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define pq 	priority_queue<int, vector<int>, greater<int> >
ll e=  1000000007;
#define lp(n,i) for(ll i=0;i<n;i++)
using namespace std;

int main(){
	

ll n;
cin>>n;
ll a[n];
lp(n,i)
{
	cin>>a[i];
}
ll v=0;
lp(n,i)
{
	if(a[i]!=(i+1))v++;
}
	if(v==0||v==2)cout<<"YES";
	else cout<<"NO";
	
	
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int n;

int main()
{
    scanf("%d",&n);
    //printf("y");
    for (long long i=1;i<=3500;i++)
    for (long long j=i;j<=3500;j++)
    {
        //printf("%lld %lld %lld\n",i,j,(i*j*n)  );
        if ( (3*i*j>n*(i+j) ) && (i*j*n)%( 4*i*j-n*(i+j) )==0  )
        {
            printf("%lld %lld %lld\n",i,j,(i*j*n)/(4*i*j-n*(i+j) ) );
            return 0;
        }

    }
}


Measured memory_bytes: 128
x,y=map(int,input().split())

a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

for i in a:
  if x==i:
    x='a'
  if y==i:
    y='a'

for i in b:
  if x==i:
    x='b'
  if y==i:
    y='b'

for i in c:
  if x==i:
    x='c'
  if y==i:
    y='c'

if x==y:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    int n=s.size();
    reverse(al(s));
    int ans=0,cnt=0;
    rep(i,n){
        ans+=s[i]-'0';
        if(s[i]=='0') cnt++;
    }
    if(cnt==n-1 && s.back()=='1') cout<<10<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 3592
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let n: u64 = buf.trim().parse().unwrap();

    // A-E
    let mut t_s: Vec<u64> = Vec::new();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    t_s.push(buf.trim().parse().unwrap());
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    t_s.push(buf.trim().parse().unwrap());
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    t_s.push(buf.trim().parse().unwrap());
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    t_s.push(buf.trim().parse().unwrap());
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    t_s.push(buf.trim().parse().unwrap());

    let max_t = ((n as f64) / (*(t_s.iter().min().unwrap()) as f64)).ceil() as u64;

    println!("{}", max_t + 4);
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> J(100001);
  for (int a, b; cin >> a >> b;) J.at(a).push_back(b);
  priority_queue<int> Q;
  int ans = 0;
  for (int i = 1; i <= M; i++) {
    for (auto j : J.at(i)) Q.push(j);
    if (Q.size()) ans += Q.top(), Q.pop();
  }
  cout << ans << "\n";
}

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

typedef long long i64;
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, L; cin >> N >> L;
    vector<i64> a(N);
    rep(i, N) cin >> a[i];
    int aim = -1; i64 len = 0;
    rep(i, N - 1) {
        i64 tlen = a[i] + a[i + 1];
        if(tlen > len) {
            len = tlen;
            aim = i;
        }
    }
    if(len < L) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    rep(i, aim) cout << i + 1 << endl;
    for(int i = N - 2; i > aim; --i) cout << i + 1 << endl;
    cout << aim + 1 << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <stdint.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(std::string S, std::string T) {
  ll ans = 0;
  REP(i, S.size()) {
    if (S[i] != T[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}

int main() {
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(S, T);
  return 0;
}


Measured memory_bytes: 4120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();
    
    int n;
    cin >> n;
    VI in(n);
    cin >> in;

    int ans = INF;
    eFOR(i, 0, in[0]) {
        VI p = in;
        int cnt = 0;
        p[0] -= i;
        cnt += i;
        FOR(j, 0, n - 1) {
            if (p[j] <= 0)continue;
            cnt += p[j] * 2;
            p[j + 1] -= p[j];
            p[j] = 0;
        }
        if (p[n - 1] > 0)cnt += p[n - 1];
        chmin(ans, cnt);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define debug(...)
#include <complex.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;


int main( ) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifdef LOCAL
     //    freopen("input.in", "r",  stdin);
    #endif
    int n;
    cin >> n;
    bool ok = true;
    int x0(0) , y0(0) , last_t(0);
    for(int i = 0; i < n; i++){
            int tt; cin >> tt;
            int k = tt;
            tt -= last_t;
            last_t = k;
        int x , y; cin >>x >> y;
        int dist = abs(x - x0) + abs(y - y0);
        x0 = x , y0 = y;
        if(dist == tt || (dist <= tt &&  (tt - dist) % 2 == 0)){
            continue;
        }
        else{
            cout << "No" << '\n';
            return 0;
        }
    }
cout << "Yes" << '\n';
    return 0;
}













Measured memory_bytes: 384
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String a[]=line.split("",0);
        ArrayList<String> as=new ArrayList<String>();
        for(int i=0;i<a.length;i++){
            as.add(a[i]);
        }
        line = sc.nextLine();
        String b[]=line.split("",0);
        ArrayList<String> bs=new ArrayList<String>();
        for(int i=0;i<b.length;i++){
            bs.add(b[i]);
        }
        line = sc.nextLine();
        String c[]=line.split("",0);
        ArrayList<String> cs=new ArrayList<String>();
        for(int i=0;i<c.length;i++){
            cs.add(c[i]);
        }
        String turn="a";
        boolean h=true;
        while (h){
            switch(turn){
                case "a":
                    if(as.size()==0){
                        turn="A";
                        h=false;
                    }
                    else{
                        turn=as.get(0);
                        as.remove(0);
                    }
                    break;
                case "b":
                    if(bs.size()==0){
                        turn="B";
                        h=false;
                    }
                    else{
                        turn=bs.get(0);
                        bs.remove(0);
                    }
                    break;
                case "c":
                    if(cs.size()==0){
                        turn="C";
                        h=false;
                    }
                    else{
                        turn=cs.get(0);
                        cs.remove(0);
                    }
                    break;
            }
        }
        System.out.println(turn);
    }
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
#include <algorithm>
#include <vector>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

long calc(long n, long k)
{
    long sum = 0;
    while(n>0) {
        sum += (n%k);
        n/=k;
    }
    return sum;
}

int main(int argc, char* argv[])
{
    long a, b;
    scanf("%ld %ld", &a, &b);
    
    printf("%ld\n", MAX(MAX(a+b, a-b), a*b));
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007
#define endl "\n"
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



int32_t main(){
    ios::sync_with_stdio(false);
    int k, a, b;
    cin>>k>>a>>b;
    int f=0;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            f=1;
        }
    }
    if(f==1){
        cout<<"OK\n";
    }
    else{
        cout<<"NG\n";
    }

    return 0;
}

Measured memory_bytes: 3648
from collections import Counter
 
N = int(input())
l = list(map(int, input().split()))
 
o = Counter(l[::2]).most_common()
e = Counter(l[1::2]).most_common()
 
if o[0][0] == e[0][0]:
    if len(o) == 1:
        print(N//2)
    else:
        e1, e2 = o[0][1], o[1][1]
        o1, o2 = e[0][1], e[1][1]
 
        res = min(N-e1-o2, N-e2-o1)
        print(res)
else:
    print(N - o[0][1] - e[0][1])

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

using namespace std;

const int N = 1e5 + 123;
int n, a[N], mx = 0, mn = 1e5 + 123, kol[N];

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		mx = max(mx, a[i]);
		mn = min(mn, a[i]);
		kol[a[i]]++;
	}
	if(mx - mn >= 2){
		cout << "No";
		exit(0);
	}
	if(mx - mn == 0){
		if(mn <= n / 2 || mn == n - 1) cout << "Yes";
		else cout << "No";
		exit(0);
	}
	else{
		if(kol[mn] <= mn && kol[mn] >= mn - (n - (mn + 2))){
			cout << "Yes";
			exit(0);
		} 
		else cout << "No";
	}
}

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

#define int long long 

using namespace std;

void solve()
{
	int n,ans=0;
	cin>>n;
	std::vector<int> a(n);
	for(int i=0;i<n;i++)
		cin >> a[i];
	if(n<3){
		cout << 0 ;
		return;
	}
	for(int i =0;i<n;i++){
		for(int j =i+1;j<n;j++){
			if(a[i]==a[j])
				continue;
			for(int k=j+1;k<n;k++){
				if(a[i]==a[k] or a[j]==a[k])
					continue;
				if(a[i]+a[j]>a[k]){
					if(a[i]+a[k]>a[j])
					{
						if(a[j]+a[k]>a[i])
							ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;
}

int32_t main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	
	//int t;cin >> t;while(t--)
		solve();

	return 0;
}

Measured memory_bytes: 3576
N,K=[int(i) for i in input().split(" ")]
sunuke=[0 for i in range(N)]
for i in range(K):
    d=int(input())
    A=[int(j) for j in input().split(" ")]
    for a in A:
        sunuke[a-1]+=1

retval=0
for s in sunuke:
    if s==0:
        retval+=1
print(retval)


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 112345;
ll s[MAX_N];

int main2() {
  int N = nextInt();
  REP(i, N) s[i] = nextInt();
  ll ans = 0;
  for (int d = 1; d <= N-1; d++) {
    ll score = 0;
    set<int> vis;
    bool end = false;
    for (int k = 1; ; k++) {
      int x = k * d;
      int y = N-1 - k * d;
      if (vis.count(x) > 0) end = true; else vis.insert(x);
      if (vis.count(y) > 0) end = true; else vis.insert(y);
      int A = N-1-k*d;
      int B = A - d;
      if (!(1 <= A && A <= N-1 &&
            1 <= B && B <= N-1 &&
            B < A)) end = true;
      if (end) break;
      score += s[x];
      score += s[y];
      chmax(ans, score);
    }
  }

  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 7168
package main
import(
  "fmt"
)
func gcd(a int, b int)int{
	if b==0{
		return a
	}
	return gcd(b, a%b)
}
func main(){
  var a, b int
  fmt.Scan(&a, &b)
  n:=gcd(a, b)
  fmt.Println(a*b/n)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int a[2001];
int main()
{
	int n,z,w;scanf("%d%d%d",&n,&z,&w);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	int ans;
	if(n==1)
		ans=abs(a[0]-w);
	else 
		ans=max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]));
	printf("%d\n",ans);
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_g
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int N,M;
vector<int> g[112345];
int dp[112345];
int id = 0;
int ord[112345];
int vis[112345];
void topo(int v){
    if(vis[v])return;
    vis[v]=1;
    for(int u:g[v]){
        topo(u);
    }
    ord[id]=v;
    id++;
}
int main(){
    cin>>N>>M;
    for(int i:range(M)){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
    }
    for(int i:range(N))topo(i);
    reverse(ord,ord+N);
    for(int ii:range(N)){
        int v = ord[ii];
        for(int u:g[v])chmax(dp[u],dp[v]+1);
    }
    cout<<*max_element(dp,dp+N)<<endl;
    return 0;
}

Measured memory_bytes: 8576
// https://atcoder.jp/contests/abc152/tasks/abc152_a
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N, M;
    scanf("%d %d", &N, &M);
    if (M == N)
    {
        printf("Yes\n");
        return 0;
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        long[] nm = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        long N = nm[0];
        long M = nm[1];

        List<long> A = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToList();
        
        var bcList =
            Enumerable.Range(0, (int)M)
            .Select(n => Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray())
            .Select(arr => new { B = arr[0], C = arr[1] })
            .ToList();

        bcList.Sort((bc1, bc2) => -Math.Sign(bc1.C - bc2.C));
        A.Sort((num1, num2) => -Math.Sign(num1 - num2));

        int count = 0;
        int AIdx = 0;

        long ans = 0;

        foreach(var c in bcList.SelectMany(bc => Enumerable.Repeat(bc.C, (int)bc.B)))
        {
            while(A[AIdx] >= c)
            {
                ans += A[AIdx];
                AIdx++;
                count++;

                if(count == N)
                {
                    Console.WriteLine(ans);
                    return;
                }
            }

            ans += c;
            count++;

            if (count == N)
            {
                Console.WriteLine(ans);
                return;
            }
        }

        while(count < N)
        {
            ans += A[AIdx];
            AIdx++;
            count++;            
        }

        Console.WriteLine(ans);
        return;
    }

    
}


static class MathUtil
{
    public static T Max<T>(params T[] datas)
    {
        return datas.Max();
    }

    public static T Min<T>(params T[] datas)
    {
        return datas.Min();
    }

    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}






Measured memory_bytes: 30428
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    D = il()
    print(max(D)-min(D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9984
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def main():
    a, b, c = MII()
    if a == b == c:
        print(a%2-1)
        return None
    cnt = 0
    while a%2==0 and b%2==0 and c%2==0:
        a, b, c = (c+b)//2, (a+c)//2, (a+b)//2
        cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import math
MOD = 10 ** 9 + 7

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


def f(n):
    return math.factorial(n)


for i in range(K):
    if N - K - i >= 0:
        print(f(N - K + 1) // f(N - K - i) // f(i + 1)
              * (f(K - 1) // f(K - i - 1) // f(i)) % MOD)
    else:
        print(0)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
int q[N];
ll h[N],dp[N];
ll calcx(int P,int Q){return h[Q]-h[P];}
ll calcy(int P,int Q){return (dp[Q]+h[Q]*h[Q])-(dp[P]+h[P]*h[P]);}
int main()
{
	int n;ll C;scanf("%d%lld",&n,&C);
	for (register int i=1;i<=n;++i) scanf("%lld",&h[i]);
	int head=1,tail=1;q[1]=1;dp[1]=0;
	for (register int i=2;i<=n;++i)
	{
		while (head<tail&&calcy(q[head],q[head+1])<=2*h[i]*calcx(q[head],q[head+1])) head++;
		dp[i]=dp[q[head]]+(h[i]-h[q[head]])*(h[i]-h[q[head]])+C;
		while (head<tail&&calcy(q[tail],i)*calcx(q[tail-1],q[tail])<=calcy(q[tail-1],q[tail])*calcx(q[tail],i)) tail--;
		q[++tail]=i;
	}
	printf("%lld\n",dp[n]);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 


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

int N; cin >> N;
VS S(N); invec(S);

int ans = 0;
rep(B, 0, N){
    bool sym = true;
    rep(i, 0, N-1) if (sym) rep(j, i+1, N) {
        if (S[i][(j + B) % N] != S[j][(i + B) % N]){
            sym = false;
            break;
        }
    }
    if (sym) ++ans;
}

cout << ans*N << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct  edge{int to, cost;};
vector<vector<edge> > G;
int N, K;
vector<int> dist;

void dfs( int now, int ago, int depth ){
  dist[now] = depth;
  for( int i = 0; i < G[now].size(); i++ ){
    int next = G[now][i].to;
    if( next == ago ) continue;
    dfs( next, now, depth + G[now][i].cost );
  }
}

signed main(){
  cin >> N;
  G.resize(N); dist.resize(N, -1);
  for(int i = 1; i < N; i++){
    int a, b, c; scanf("%d%d%d", &a, &b, &c); --a; --b; 
    G[a].push_back(edge{b, c}); G[b].push_back(edge{a, c});
  }
  int Q; cin >> Q;
  cin >> K; --K;
  dfs(K, -1, 0);
  for( int i = 0; i < Q; i++ ){
    int x, y; scanf("%d%d", &x, &y); --x; --y;
    cout << dist[x] + dist[y] << '\n';
  }
}


Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int n, mem[100001], v[100001]={0}, max_v=0, min_v=INT_MAX;

  cin >> n;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    mem[i] = x;
    v[x] += 1;
    if(max_v < x) max_v = x;
    if(x < min_v) min_v = x;
  }

  int r1=0, r2=0;
  int m1=0, m2=0;
  for(int i = min_v; i <= max_v; i++){
    if(r2 <= v[i]){
      r2 = v[i];
      m2 = i;
      if(r1 < r2){
        int tmp = r1;
        r1 = r2;
        r2 = tmp;
        int tm = m1;
        m1 = m2;
        m2 = tm;
      }
    }
  }

  int p1=0, p2=0, ans1=0;
  for(int i = 0; i < n; i+=2){
    if(mem[i] != m1) p1++;
    if(mem[i+1] != m2) p2++;
  }
  ans1 = p1 + p2;

  int q1=0, q2=0, ans2=0;
  for(int i = 0; i < n; i+=2){
    if(mem[i] != m2) q1++;
    if(mem[i+1] != m1) q2++;
  }
  ans2 = q1 + q2;


  if(ans1 < ans2) cout << ans1 << endl;
  else cout << ans2 << endl;


	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

void solve(long long N, long long K, std::vector<long long> D)
{

    for (ll i = N; i < LLONG_MAX; i++)
    {
        ll tmp = i;
        bool flag = true;
        while(tmp != 0){
            ll dec = tmp % 10;
            tmp /= 10;
            if(find(D.begin(),D.end(),dec) != D.end()){
                flag = false;
                break;
            }
        }

        if(flag){
            cout << i << endl;
            return;
        }
    }
}

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


Measured memory_bytes: 256
#include <stdio.h>


int main(void)
{
	int i, list[31]={0}, buf;

	for(i=0; i<28; i++){
		scanf("%d", &buf);
		list[buf] = 1;
	}

	for(i=1; i<=30; i++){
		if(list[i] == 0){
			printf("%d\n", i);
		}
	}

	getchar();getchar();getchar();getchar();getchar();


	return 0;
}

Measured memory_bytes: 600