Language: C++

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template <class T> using Trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;

template <class T> T read() {
  int w = 1, ch = ' ';
  T q;
  for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') w = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) q = (q<<3)+(q<<1)  + ch - 48;
  return q * w;
}

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int,int> pii;
typedef pair<int,pair<int,int> > ppi;
typedef pair<ld,ld> pdd;

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ld> vd;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef vector<pdd> vdd;
typedef vector<cd> vcd;
typedef vector<ppi> vppi;

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x)  beg(x), en(x)
#define resz(x,a)  x.resize(a)
#define pb push_back
#define as(x,a) x.assign(a)

#define F0R(i,a) for(int i=0;i<(a);++i)
#define FOR(i,a,b) for(int i=a;i<(b);++i)
#define FORD(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define F0RD(i,a) for(int i=(a)-1;i>=0;--i)
#define trav(a,x) for(auto& a : x)

#define fi first
#define se second
#define mp make_pair


#define lb lower_bound
#define ub upper_bound

const int mod = 1000000007;
const ll oo = 1e18;
const ld pi= acos(-1);

template<class T> void chmax(T&a, T b)  {a=max(a,b);}
template<class T> void chmin(T&a, T b)  {a=min(a,b);}
template<class T> T gcd(T a, T b)  {return b==0 ? a : gcd(b,a%b);}
template<class T> T lcm(T a, T b)  {return a*(b/gcd(a,b));}


int n;
ll c;
typedef complex<ll> point;
class lc_tree
{
private:
    struct node
    {
        node *l,*r;
        point line;
        node() : l(nullptr), r(nullptr), line({0,oo}) { }
    }*rt;
    ll dot(point a, point b) {  return (conj(a)*b).real();}
    ll f_val(point a, int b) {  return dot(a,{b,1});}
    void ins(node *cur, int l, int r, point nw)
    {
        int mid=(l+r)>>1;
        bool M= f_val(nw,mid) < f_val(cur->line,mid);
        bool L= f_val(nw,l)   < f_val(cur->line,l);
        if(M)  swap(cur->line,nw);
        if(r-l==1)  return ;
        if(M!=L)
        {
            if(cur->l==nullptr)  cur->l= new node();
            ins(cur->l,l,mid,nw);
        }
        else
        {
            if(cur->r==nullptr)  cur->r= new node();
            ins(cur->r,mid,r,nw);
        }
    }
    ll query(node *cur, int l, int r, int val)
    {
        ll t=f_val(cur->line,val);
        if(r-l==1)  return t;
        int mid=(l+r)>>1;
        if(cur->l!=nullptr&&val<=mid)  return min(t,query(cur->l,l,mid,val));
        if(cur->r!=nullptr)  return min(t,query(cur->r,mid,r,val));
        return t;
    }
public:
    lc_tree() { rt=new node();}
    void ins(point nw) { ins(rt,0,1e6+10,nw);}
    ll query (int val) { return query(rt,0,1e6+10,val);}
};
vi v;
int main()
{
    //freopen("inp","r",stdin);
    //scanf("%d%lld",&n,&c);
  	n=read();c=read();
    v.resize(n);
    for(int i=0;i<n;++i)  v[i]=read();//scanf("%d",&v[i]);
    lc_tree lc;
    ll tmp=0ll;
    for(int i=1;i<n;++i)
    {
        lc.ins((point){-2*v[i-1],0ll+tmp+1ll*v[i-1]*v[i-1]});
        tmp=0ll+c+1ll*v[i]*v[i]+lc.query(v[i]);
    }
    cout<<tmp;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:124:15: error: no matching function for call to 'read()'
  124 |         n=read();c=read();
      |           ~~~~^~
a.cc:16:22: note: candidate: 'template<class T> T read()'
   16 | template <class T> T read() {
      |                      ^~~~
a.cc:16:22: note:   template argument deduction/substitution failed:
a.cc:124:15: note:   couldn't deduce template parameter 'T'
  124 |         n=read();c=read();
      |           ~~~~^~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:4:
/usr/include/unistd.h:371:16: note: candidate: 'ssize_t read(int, void*, size_t)'
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                ^~~~
/usr/include/unistd.h:371:16: note:   candidate expects 3 arguments, 0 provided
a.cc:124:24: error: no matching function for call to 'read()'
  124 |         n=read();c=read();
      |                    ~~~~^~
a.cc:16:22: note: candidate: 'template<class T> T read()'
   16 | template <class T> T read() {
      |                      ^~~~
a.cc:16:22: note:   template argument deduction/substitution failed:
a.cc:124:24: note:   couldn't deduce template parameter 'T'
  124 |         n=read();c=read();
      |                    ~~~~^~
/usr/include/unistd.h:371:16: note: candidate: 'ssize_t read(int, void*, size_t)'
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                ^~~~
/usr/include/unistd.h:371:16: note:   candidate expects 3 arguments, 0 provided
a.cc:126:36: error: no matching function for call to 'read()'
  126 |     for(int i=0;i<n;++i)  v[i]=read();//scanf("%d",&v[i]);
      |                                ~~~~^~
a.cc:16:22: note: candidate: 'template<class T> T read()'
   16 | template <class T> T read() {
      |                      ^~~~
a.cc:16:22: note:   template argument deduction/substitution failed:
a.cc:126:36: note:   couldn't deduce template parameter 'T'
  126 |     for(int i=0;i<n;++i)  v[i]=read();//scanf("%d",&v[i]);
      |                                ~~~~^~
/usr/include/unistd.h:371:16: note: candidate: 'ssize_t read(int, void*, size_t)'
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                ^~~~
/usr/include/unistd.h:371:16: note:   candidate expects 3 arguments, 0 provided