akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    int n; cin >> n;
    VI a(n);
    REP(i, n)  cin >> a[i];
    int q; cin >> q;
    REP(i, q){
        int k; cin >> k;
        cout << distance(a.begin(), lower_bound(ALL(a), k)) 
             << " " << distance(a.begin(), upper_bound(ALL(a), k)) << "\n";
    }
    return 0;
}



Measured memory_bytes: 3116
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

using ll = int_fast64_t;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<T>;
using vi = vt<int>;
using vvi = vvt<int>;
using vl = vt<ll>;
using vvl = vvt<ll>;
using pi = pair<int, int>;

constexpr int INF = 1 << 29;
// constexpr ll INFL = 1 << 58;
constexpr int dx[] = {0, 1, 0, -1};
constexpr int dy[] = {1, 0, -1, 0};

// [a, b)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (b)-1; i >= (a); i--)
// [a, b]
#define RANGE(i, a, b) for (int i = (a); i <= (b); i++)
#define RANGER(i, a, b) for (int i = (b); i >= (a); i--)
// [0, n)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) RFOR(i, 0, (n))

#define ALL(i) i.begin(), i.end()

inline int gint() {
  int a;
  cin >> a;
  return a;
}

int main() {
  int N, sum = 0, mx = 0;
  cin >> N;
  REP(i, N) {
    int tmp;
    cin >> tmp;
    sum += tmp;
    mx = max(mx, tmp);
  }
  cout << sum - mx / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
using graph = vector<vector<edge>>;
// using graph = vector<vector<int>>;


#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define delim(i, n) cout << (i == n-1 ? "\n" : " ");

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

const int maxn =  2e5;
int n, q;
graph G(maxn);
vi res(maxn);
vi seen;

int dfs(int v, int t) {
    seen[v] = true;
    for(auto next_v : G[v]) {
        if (seen[next_v.to]) continue;
        res[next_v.to] += res[v];
        t = dfs(next_v.to, t+1);
    }
    t += 1;
    return t;
}

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

    cin >> n >> q;
    REP(i, n-1) {
        edge e;
        int s; cin >> s >> e.to;
        s--; e.to--;
        G[s].push_back(e);
        swap(s, e.to);
        G[s].push_back(e);
    }
    REP(i, n) res[i] = 0;

    REP(i, q) {
        int s, c; cin >> s >> c;
        s--;
        res[s] += c;
    }

    seen.assign(n, false);

    dfs(0, 0);

    REP(i, n) {
        cout << std::fixed << std::setprecision(10) << res[i];
        delim(i, n);
    }
}

Measured memory_bytes: 27748
from collections import Counter
S = input()
MOD = 10 ** 9 + 7
ans = 0
front = [0, 0, 0, 0]
back = [0, 0, 0, 0]
m = { 'A': 0, 'B': 1, 'C': 2, '?': 3 }
for c in S:
  back[m[c]] += 1

pow3 = [1]
for i in range(max(3, back[3])):
  pow3.append((pow3[-1] * 3) % MOD)

for i in range(len(S)):
  c = S[i]
  back[m[c]] -= 1
  # Bの位置を固定
  if c == 'B' or c == '?':
    fbsum = front[3] + back[3]
    # ?を使わない
    ans += front[0] * back[2] * (pow3[fbsum])
    # Aだけ?をつかう
    ans += front[3] * back[2] * (pow3[fbsum - 1])
    # Cだけ?をつかう
    ans += front[0] * back[3] * (pow3[fbsum - 1])
    # 両方?をつかう
    ans += front[3] * back[3] * (pow3[fbsum - 2])
    ans %= MOD
  front[m[c]] += 1

print(int(ans))

Measured memory_bytes: 46576
#include<stdio.h>
char str[1005];
char p[1005];
int main(){
    int q,a,b;
    char op[10],*x,*y,c;

    scanf("%s%d",str,&q);
    while(q--){
        scanf("%s%d%d",op,&a,&b);
        if(op[2]=='i'){
            b++,c=*(str+b),*(str+b)=0,puts(str+a),*(str+b)=c;
        }else if(op[2]=='v'){
            x=str+a,y=str+b;
            while(x<y){
                c=*x,*x=*y,*y=c;
                x++,y--;
            }
        }else{
            scanf("%s",p);
            x=str+a,y=p;
            while(*y) *x++=*y++;
        }
    }
    return 0;
}


Measured memory_bytes: 2148
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll cnt1[100]={};  
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        ll a;
        cin>>a;
        for(ll j=0;j<60;j++){
            if(a & (1ll<<j)){
                cnt1[j]++;
            }
        }
    }
    ll ans=0;
    ll tmp=0;
    for(ll j=0;j<60;j++){
        ll n=cnt1[j]*(N-cnt1[j])+tmp;
        if(n%2==1){
            ans=(ans+(1ll<<j))%MOD;
        }
        tmp=n/2;
    }
    tmp%=MOD;
    tmp=((1ll<<60)%MOD)*tmp%MOD;
    ans=(ans+tmp)%MOD;
    cout<<ans<<endl;

    return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<string> s(n);
    REP(i, n) {
        cin >> s[i];
    }

    ll ans = -1;
    REP(i, n) {
        queue<ll> que;
        que.push(i);
        vec<ll> V(n, -1);
        V[i] = 1;
        bool flag = true;
        while(que.size()) {
            int v = que.front();
            que.pop();

            REP(to, n) {
                if(s[v][to] == '0')
                    continue;
                if(V[to] != -1) {
                    if(abs(V[v] - V[to]) != 1) {
                        flag = false;
                        break;
                    }
                } else {
                    V[to] = V[v] + 1;
                    que.push(to);
                }
            }
            if(!flag)
                break;
        }
        if(!flag)
            continue;
        REP(v, n) {
            chmax(ans, V[v]);
        }
    }
    cout << ans << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3692
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<unordered_set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<stack>
#include <cstring>
#include <climits>
using namespace std;
#define rep(i,n) for(int (i)=0;(i) < (n); (i)++)
#define rrep(f,i,n) for(int (i)=0;(i) < (f); (i)++)
#define FIND(v, k) find((v).begin(), (v).end(), k)
#define mset(a,x) memset(a,x,sizeof(a))

#define MAX 101
#define MAX_V 15
int a[1000000];
int main()
{
	vector<int> v;
	int n, k,t;
	cin >> n >> k;
	rep(i, n) {
		cin >> t;
		v.push_back(t);
	}
	sort(v.begin(), v.end());
	int sum = 0;
	rep(i,k){
		sum += v.back();
		v.pop_back();
	}
	cout << sum << endl;
}



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

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  printf("%lf\n", sqrt((pow((x1 - x2), 2) + pow((y1 - y2), 2))));
  return 0;
}


Measured memory_bytes: 3288
/**
 *    author:  gzhffIThh
 *    created: 19.08.2020
**/
#include <bits/stdc++.h>

using namespace std;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n,x,t;
  cin>>n>>x>>t;
 	cout<<(n/x+(n%x>0))*t;

  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "OK" << endl ; else cout << "NG" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	if(n&1){
		for(int i=1;i<=m;i++){
			cout << i << " " << n-i << endl ;
		}
	}else{
		for(int i=1;i<=m;i++){
			if(i&1){
				ll r = (m+1)/2-i/2 ;
				cout << r << " " << r+i << endl ;
			}else{
				ll r = m/2-(i-1)/2+(m+1)/2*2 ;
				cout << r << " " << r+i << endl ;
			}
		}
	}
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main (){
  
  int n;
  cin >>n;
  int h[n];
  for(int i=0; i<n; i++) cin>>h[i];
  
  int ma=h[0],count=1;
  
  for(int i=1; i<n; i++){
   if(ma<=h[i]){
     ma=h[i]; count++;
   }
  }
  
  
  cout << count << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		ex1();
		//ex2();
	}

	public static void ex1() {
		int X=0;
		int Y=0;

		Scanner sc = new Scanner(System.in);
		 X = sc.nextInt();
         Y = sc.nextInt();

        System.out.println(X+Y/2);
	}
}

Measured memory_bytes: 21332
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

class BSumo {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;

        int num = 0;
        REP(i, s.size()) {
            if (s[i] == 'x') num++;
        }

        cout << (num >= 8 ? "NO" : "YES") << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BSumo solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solve()
{
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
INF = 10 ** 10
n, m = gets.split.map(&:to_i)
bin_memo = [1]
1.upto(n - 1) do |i|
  bin_memo[i] = bin_memo[i - 1] * 2
end
costs = []
keys = []
m.times do
  costs << gets.to_i
  keys << gets.split.map(&:to_i).inject(0) { |res, num| res | bin_memo[num - 1] }
end
dp = Array.new(2 ** n, INF)
dp[0] = 0
keys.each_with_index do |key, i|
  dp.each_with_index do |cost, opened|
    next if cost == INF
    next_opened = (opened | key)
    dp[next_opened] = [dp[next_opened], cost + costs[i]].min
  end
end
puts dp.last == INF ? - 1 : dp.last


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int x;
    cin >> x;
    COUT(8-(x-400)/200);
}


Measured memory_bytes: 3644
#輸入字串並分隔，以list儲存
str_in = input()
num = [int(n) for n in str_in.split()]
num =list(map(int, str_in.strip().split()))  
#print(num) #D,T,S

#若T<(D/S)->遲到
if num[1] >= (num[0]/num[2]):
    print("Yes")
else:
    print("No")




Measured memory_bytes: 9100
#include <iostream>
using namespace std;
int main() {
    string S,T;
    int N,syutsuryoku;
    cin >> S;
    cin >> T;
    N = S.size();
    for (int i=0;i<(N-1);i++) {
    if (S.at(i) != T.at(i)) {
        syutsuryoku++;
    }
    }
    if (syutsuryoku != 0) cout << syutsuryoku+1 << endl;
    else cout << syutsuryoku << endl;
    
}


Measured memory_bytes: 3848
#include<iostream>
using namespace std;
int main(){
int a[100],n;
cin>>n;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=n-1;i>=0;i--){
  cout<<a[i];
  if(i==0)break;
  cout<<" ";
}
  cout<<endl;
}
  


Measured memory_bytes: 3080
#include <iostream>
using namespace std;
#define DIV 1000000007

long long int calcFactrial(int n)
{
    if(n == 0)
    {
        return 1;
    }
    long long int fac = 1;
    for(int i = 1; i <= n; ++i)
    {
        fac = fac * i % DIV;
    }

    return fac;
}

long long pow(long long a, int b, int mod)
{
    long long res = 1;
    for(int i = b; i > 0; i/=2)
    {
        if((i&1)==1)
        {
            res *= a;
            res %= mod;
        }
        a *= a;
        a %= mod;
    }
    return res;
}

int main()
{
    int x,y;
    cin >> x >> y;

    int n = 0;
    bool valid = true;
    while(x != 2*y
    && 2*x != y
    && !(x==0 && y==0))
    {
        x -= 3;
        y -= 3;
        ++n;
        if(x < 0 || y < 0)
        {
            valid = false;
            break;
        }
    }

    if(valid)
    {
        int m = min(x,y);
        long long int a = calcFactrial(2*n+m);
        long long int b = ((calcFactrial(n) * calcFactrial(n+m))%DIV);
        long long int ans = a * pow(b,DIV-2,DIV);
        cout << ans%DIV << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >>n;
  vector<pair<int,int>> v(n);
  
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    pair<int,int> p;
    p = make_pair(x,i+1);
    v.at(i)=p;
  }

  sort(v.begin(),v.end());
  
  if(n==1){
    cout << v.at(0).second <<endl;
  }
  else{
    for(int i=0;i<n-1;i++){
      cout << v.at(i).second << " ";
    }
      cout << v.at(n-1).second <<endl;
  }

  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template<typename T>
void warshall_floyd(std::vector<std::vector<T>> &distance, const T INF) {
  for(int k = 0; k < distance.size(); ++k) {
    for(int i = 0; i < distance.size(); ++i) {
      for(int j = 0; j < distance.size(); ++j) {
        if(distance[i][k] == INF || distance[k][j] == INF) continue;
        else distance[i][j] = std::min(distance[i][j], distance[i][k] + distance[k][j]);
      }
    }
  }
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, r;
  cin >> n >> m >> r;
  VI v(r);
  rep(i, r) {
    cin >> v[i];
    v[i]--;
  }
  VVI distance(n, VI(n, INF));
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    distance[a][b] = c;
    distance[b][a] = c;
  }
  rep(i, n) distance[i][i] = 0;
  warshall_floyd<int>(distance, INF);
  sort(all(v));
  int ans = INF;
  do {
    int sum = 0;
    for(int i = 0; i < r-1; ++i) sum += distance[v[i]][v[i+1]];
    ans = min(ans, sum);
  }while(next_permutation(all(v)));
  out(ans);
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
import java.util.Arrays;
public class Main{
    
    
    public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        int k = 0;
        if((a+b)%2==0){
            k = (int)((a+b)/2);
            System.out.println(k);

        }
        else{
            System.out.println("IMPOSSIBLE");
        }
        
    }
   
    
       
    
}

Measured memory_bytes: 22868
#include <iostream>                                             
#include <climits>                                              
using namespace std;                                            
                                                                
int main() {                                                    
  int n;                                                        
  cin >> n;                                                     
  int R[n];                                                     
  for (int t=0; t<n; t++) {                                     
    cin >> R[t];                                                
  }                                                             
  int minv = R[0];                                              
  int maxv = -INT_MAX;                                          
  for (int j=1; j<n; j++) {                                     
    maxv = max(maxv,R[j]-minv);                                 
    minv = min(minv,R[j]);                                      
    }                                                           
  cout << maxv << endl;                                         
  return 0;                                                     
}                                                               
                                                                
                                                                
                      

Measured memory_bytes: 3880
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c > 21) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}

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

using namespace std;

struct element
{
	int value;
	int x;
	int y;
	bool take;

	element()
		:
			value{0},
			x{0},
			y{0},
			take{false}
	{
	}
};

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

	string A, B;
	cin >> A >> B;

	int LA = A.length();
	int LB = B.length();
	vector<vector<element> > dp(LA + 1, vector<element>(LB + 1));

	for(int i = 1; i <= LA; ++i)
	{
		for(int j = 1; j <= LB; ++j)
		{
			if(A[i - 1] == B[j - 1])
			{
				dp[i][j].value = dp[i - 1][j - 1].value + 1;
				dp[i][j].x = i - 1;
				dp[i][j].y = j - 1;
				dp[i][j].take = true;
			}
			if(dp[i][j].value < dp[i][j - 1].value)
			{
				dp[i][j].value = dp[i][j - 1].value;
				dp[i][j].x = i;
				dp[i][j].y = j - 1;
				dp[i][j].take = false;
			}
			if(dp[i][j].value < dp[i - 1][j].value)
			{
				dp[i][j].value = dp[i - 1][j].value;
				dp[i][j].x = i - 1;
				dp[i][j].y = j;
				dp[i][j].take = false;
			}
		}
	}

	string c;

	int i = LA, j = LB;
	while(i > 0 and j > 0)
	{
		if(dp[i][j].take)
		{
			c += A[i - 1];
		}
		tie(i, j) = make_pair(dp[i][j].x, dp[i][j].y);
	}

	reverse(c.begin(), c.end());

	cout << c << "\n";

	return 0;
}


Measured memory_bytes: 141312
def main():
    import sys
    input = sys.stdin.readline

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

    num = [0] * (N+1)
    for a in A:
        num[a] += 1
    S = 0
    for i in range(1, N+1):
        S += (num[i] * (num[i]-1)) // 2
    ans = [0] * (N+1)
    for i in range(1, N+1):
        if num[i]:
            ans[i] = S - (num[i] * (num[i]-1)) // 2 + ((num[i]-2) * (num[i]-1)) // 2
        else:
            ans[i] = S
    for i in range(N):
        print(ans[A[i]])


if __name__ == '__main__':
    main()


Measured memory_bytes: 79564
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
//auto mod int
using ll = long long;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}

  mint comb(int r){//O(r)で間に合うようなrのみ使用可能
    mint x=1,y=1;
    for(int i=0;i<=r-1;i++){
      y*=*this-i;
      x*=i+1;
    }
    return y/x;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

signed _main(){
  int N; cin >> N;
  string S; cin >> S;
  map<char,int> mp;
  rep(i,S.size()){
    mp[S[i]]++;
  }
  mint ans=1;
  fore(i,mp){
    ans*=i.second+1;
  }
  ans-=1;
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 512
s=int(input())
x3,y3,x2,y2,y1=0,0,-int(-s**0.5//1),1,-int(-s**0.5//1)
x1=x2*y1-s
if x2*y1-s==0:
    x1,y2=0,0
print(x1,y1,x2,y2,x3,y3)

Measured memory_bytes: 3060
from numpy import *
A,B=map(int,input().split())
M=10**9+7
U=2001
C=zeros((U,U),int64)
C[0,0]=1
for n in range(1,U):
  C[n,1:]+=C[n-1,:-1]
  C[n,:-1]+=C[n-1,:-1]
  C[n]%=M
S=zeros_like(C)
S[0]=1
S[1:]=(C[:-1].cumsum(axis=1)%M).cumsum(axis=1)%M
print(sum(C[B-1,k]*(sum(S[k,:A-k+1])%M)%M for k in range(A+1))%M)

Measured memory_bytes: 137636
//ProblemD

//#define USE_STDIO
//#define USE_LOG
//#define FILE_ERR

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#ifndef debug
#define debug(...)
#endif // !LOG

//include
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;

//for
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define forbe(i, begin, end) for(decltype(begin) i = (begin); i != (end); ++i)
#define forbes(i, begin, end, step) for(decltype(begin) i = (begin); i != (end); i += (step))

//int
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;

//pair
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
#define fi first
#define se second

//vector
template <typename Value>
static inline void fillv(Value& x, const Value& val) { x = val; }
template <typename Vector, typename Value>
static inline void fillv(Vector& v, const Value& val) { for (auto& x : v) fillv(x, val); }

static inline void Solve();

int main(int argc, char* argv[]) {
#ifdef REDIRECT_STDIO
	REDIRECT_STDIO;
#endif // REDIRECT_STDIO

	Solve();
	return 0;
}

pll getMinMax(const vector<ll>& a, int start, int end) {
	auto sum = a[end] - a[start];
	auto half = sum / 2;
	int i = upper_bound(a.begin() + start, a.end() - 1, a[start] + half) - a.begin();
	int j = i - 1;
	if (j > start && abs(2 * a[j] - a[start] - a[end]) < abs(2 * a[i] - a[start] - a[end])) {
		return { min(a[j] - a[start], a[end] - a[j]), max(a[j] - a[start], a[end] - a[j]) };
	}
	else {
		return { min(a[i] - a[start], a[end] - a[i]), max(a[i] - a[start], a[end] - a[i]) };
	}
}

//ProblemD
void Solve() {
	int n;
	cin >> n;
	vector<ll> ps(n + 1, 0);
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		ps[i + 1] = ps[i] + a;
	}

	ll ans = ps.back();
	for (int i = 2; i <= n - 2; i++) {
		auto a = getMinMax(ps, 0, i);
		auto b = getMinMax(ps, i, n);
		auto t = max(a.second, b.second) - min(a.first, b.first);
		ans = min(ans, t);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ull unsigned long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define mod (1000*1000*1000+7)
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
template <typename T>
string NumberToString(T pNumber)
{
     ostringstream oOStrStream;
     oOStrStream << pNumber;
     return oOStrStream.str();
}
ll modPow(ll x,ll n,ll m)
{
    if(n==0)
    return 1%m;
    ll u = modPow(x,n/2,m);
    u=u*u%m;
    if(n%2==1)
    u=u*x%m;
    return u;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
ll seive[1000000];
void seiveForm()
{
    ll i,j;
    seive[0]=seive[1]=1;
    f(i,2,100000)
    {
        if(seive[i]==0)
            for(j=i*i;j<1000000;j+=i)
                seive[j]=1;
    }
}
bool isPerfectSquare(ll num)
{
    double n = sqrt(num);
    return n==(ll)n?true:false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,i,j,t,temp=0;
    string s;
    cin>>s;
    string ans;
    rep(i,s.length())
    {
        if(s[i]=='B')
        {
            if(ans.length()!=0)
            ans.resize(ans.size()-1);
        }
        else if(s[i]=='0' || s[i]=='1')
            ans.pb(s[i]);
    }
    cout<<ans;
    cout<<endl;
    return 0;
}


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

int main() {
  int N;
  cin>>N;
   vector<int> vec(N);
  for (int i = 0; i < N-1; i++) { cin >> vec.at(i);}
  vector <int> count(N);
  for (int i = 0; i < N-1; i++)
  
    count.at(vec.at(i)-1)++;
  
    
  for (int i = 0; i < N; i++)
    cout<<count.at(i)<<endl;
  
  
}  


Measured memory_bytes: 4852
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;

inline int iabs(int x) {
    return x > 0 ? x : -x;
}

int main() {
    int n, a, b, c, d;
    scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
    int i, j, diff = iabs(b - a);
    for (i=0; i<=n; ++i) {
        j = n - 1 - i;
        lli least = (lli)i * c - (lli)j * d;
        lli most = (lli)i * d - (lli)j * c;
        if (least <= diff && diff <= most) {
            return puts("YES") & 0;
        }
    }
    puts("NO");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
LL C[55][55];
void build(){
    for(int i = 0;i<55;i++){
        C[i][i]=C[i][0]=1;
        for(int j=1;j<i;j++){
            C[i][j]=C[i-1][j-1]+C[i-1][j];
        }
    }
}
vector<int> tmp;
int cnt=0;
void dfs(int i,vector<int> &q){
    if(i==q.size()){
        if(tmp.empty()||(tmp.size()&1))return ;
        int ok=1;
        for(int i = 0,j=tmp.size()/2;j<tmp.size();i++,j++){
            if(tmp[i]!=tmp[j])ok=0;
        }
        cnt+=ok;
        return ;
    }
    dfs(i+1,q);
    tmp.pb(q[i]);
    dfs(i+1,q);
    tmp.pop_back();
}
int main(){ 
    build();
    LL n;
    scanf("%lld",&n);
    vector<int> v;
    int tmp=1;
    LL val[55];
    for(int i = 1;i<55;i++){
        val[i]=(1ll<<i)-1;
    }
    for(int i = 54;i>0;i--){
      //  printf("%d %lld %lld\n",i,val[i],n);
        while(n>=val[i]){
            n-=val[i];
            //for(int _=0;_<2;_++)
            int ok=1;
            queue<int> q;
            for(int j=i/2;j<i;j++){
                int a=j,b=i+1-j;
                LL sum=0;
                for(int k=0;k<=min(a,b);k++){
                    sum+=C[a][k]*C[b][k];
                    if(sum>n)
                    break;
                }
              //  printf("?%d %d %lld\n",a,b,sum);
                while(sum<=n){
                    n-=sum;
                    q.push(a);
                }
            }
           // if(ok)
            int now=tmp+1;
            for(int j=0;j<=i;j++){
                while(!q.empty()&&q.front()==j){
                    q.pop();
                    v.pb(now++);
                }
                v.pb(tmp);
                
            }
            for(int j=now-1;j>tmp;j--){
                v.pb(j);
            }
            tmp=now;
           // printf("%d\n",tmp);
        }
    }
    printf("%d\n",v.size());
    for(auto it:v)
    printf("%d ",it);
    printf("\n");
  //  dfs(0,v);
  //  printf("%d\n",cnt);
}
/*
2 2 1
3 2 3
4 2 4 4 7

*/

Measured memory_bytes: 384
N, M = map(int, input().split())
H = list(map(int, input().split()))
flag = [True] * N
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] >= H[b]:
        flag[b] = False

    if H[b] >= H[a]:
        flag[a] = False

    if H[a] == H[b]:
        flag[b] = False
        flag[a] = False

ans = 0
for i in range(N):
    if flag[i]:
        ans += 1
print(ans)


Measured memory_bytes: 84724
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

int main()
{
    int64_t X, Y;
    std::cin >> X >> Y;

    for (size_t i = 0; i <= X; ++i)
    {
        if (i * 2 + (X - i) * 4 == Y) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    std::cout << "No" << std::endl;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

int main()
{
  int n,m;cin >> n >> m;
  vector<mint> dp(n+1);
  vector<bool> f(n+1,1);
  rep(i,m){
    int a;cin >> a;f[a] = 0;
  }
  dp[0].x=1;
  rep(i,n){
    if(!f[i]) continue;
    if(f[i+1]) dp[i+1] += dp[i];
    if(i+2<=n) if(f[i+2]) dp[i+2] += dp[i];
  }
  
  cout << dp[n].x << "\n";
  
  return 0;
}


Measured memory_bytes: 1024
# include <iostream>
# include <vector>
using namespace std;
int N;
int main(){
  int count = 0;
  cin >> N;
  vector<int> L(N);
  for (int i=0; i<N;i++){
    cin >> L.at(i);
  }
  for (int i=0; i<N;i++){
    for (int j=i+1; j<N;j++){
      for (int k=j+1; k<N;k++){
        if ((L.at(i)==L.at(j)) || (L.at(i)==L.at(k)) || (L.at(k)==L.at(j))){
          continue;
        }
        else if ((L.at(i)+L.at(j)>L.at(k)) && (L.at(k)+L.at(j)>L.at(i))&& (L.at(i)+L.at(k)>L.at(j))){
          count +=1;
        }
      }
    }     
  }  
  cout << count <<endl;
}
            
  



Measured memory_bytes: 3196
from collections import Counter

def comb(n,r):
    if n<r: return 0
    comb = 1
    r = min(r,n-r)
    for i in range(r):
        comb = comb * (n-i) // (i+1)
    return comb


n,a,b = map(int,input().split())
v = list(map(int,input().split()))

v.sort(reverse=True)

va_count = Counter(v[:a])
v_count  = Counter(v)

print(sum(v[:a])/a)

if v[0] == v[a-1]:
    print(sum(comb(v_count[v[0]],i ) for i in range(a,b+1)))
else:
    print(comb(v_count[v[a-1]], va_count[v[a-1]]))

Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int cap = a - b;
	int result = c - cap;
	if (result < 0) {
		cout << 0 << endl;
	}
	else {
		cout << result << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(all(a))
#define RSORT(a) stable_sort(rall(a))
#define rev(a) reverse(all(a))
#define uniq(a) a.erase(unique(all(a)), end(a))
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define min_of(a) *min_element(all(a))
#define max_of(a) *max_element(all(a))
#define sum(a) accumulate(all(a), 0)
#define count_of(a, i) count(all(a), i)
#define lower(a, i) (lower_bound(all(a), i) - begin(a))
#define upper(a, i) (upper_bound(all(a), i) - begin(a))
#define binary(a, i) binary_search(all(a), i)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define sz(a) (int)(a).size()
#define rep1(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define rrep1(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define rep2(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep2(i, a, b) for (auto i = b - 1; i >= a; i--)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep2, rrep1)(__VA_ARGS__)
#define each(i, a) for (auto&& i: (a))
using namespace std;

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

template<class T> bool amin(T& A, T B) {
  if (A > B) {
    A = B;
    return true;
  }
  return false;
}
template<class T> bool amax(T& A, T B) {
  if (A < B) {
    A = B;
    return true;
  }
  return false;
}

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

vi cum(vi V) {
  vi U(sz(V));
  partial_sum(all(V), begin(U));
  return U;
}

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

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


void solve() {
  int n, a, b;
  string s;
  int ans = 0;

  cin >> n>>a>>b;
  vi x(n);
  rep(i, n) {
    cin >> x[i];
  }
  rep(i, n - 1) {
    ans += min(a * (x[i + 1] - x[i]), b);
  }

  cout << ans << endl;
}


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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
#define reps(i, a, b) for(int i = (a); i < (b); i++)
#define INF 1e9
vector<int> rotate(vector<int> v) {
	vector<int> ret;
	for(int i = 1; i < v.size(); i++) {
		ret.push_back(v[i]);
	}
	ret.push_back(v[0]);
	return ret;
}
int main() {
	vector<vector<int>> data = {{4,1,4,1,2,1,2,1}};
	vector<int> b = vector<int>(8, 0);

	rep(i, 7) data.push_back(rotate(data[i]));
	sort(data.begin(), data.end());
	while(cin >> b[0] >> b[1] >> b[2] >> b[3] >> b[4] >> b[5] >> b[6] >> b[7]) {
		vector<int> s = vector<int>(8, 0);
		int mn = INF;
		rep(i, data.size()) {
			rep(j, data[i].size()) {
				s[i] += max(0, b[j] - data[i][j]);
			}
			if(mn > s[i]) mn = s[i];
		}
		rep(i, data.size()) {
			if(mn == s[i]) {
				printf("%d", data[i][0]);
				reps(j, 1, data[i].size()) printf(" %d", data[i][j]);
				puts("");
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1192
from collections import deque

h,w = map(int,input().split())
s = [list(input()) for i in range(h)]

used = [[0]*w for i in range(h)]
dx = [1,-1,0,0]
dy = [0,0,1,-1]
ans = 0

for i in range(h):
    for j in range(w):
        if used[i][j]:
            continue
        cw = 0
        cb = 0
        q = deque([])
        q.append([i,j])
        used[i][j] = 1
        while q:
            x,y = q.popleft()
            if s[x][y] == "#":
                cb += 1
            else:
                cw += 1
            for k in range(4):
                nx = x+dx[k]
                ny = y+dy[k]
                if 0 <= nx < h and 0 <= ny < w:
                    if (not used[nx][ny]) and s[x][y] != s[nx][ny]:
                        used[nx][ny] = 1
                        q.append([nx,ny])
        ans += cw*cb
print(ans)

Measured memory_bytes: 11984
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int a;
  cin>>a;
  cout<<800*a-200*(a/15)<<endl;
}

Measured memory_bytes: 256
import sys
from math import gcd
def input(): return sys.stdin.readline().strip()
sys.setrecursionlimit(10**9)

def main():
    N, Ma, Mb = map(int, input().split())
    """
    dp[i][j] = (0~iまでの薬品を使って、物質Bがjグラム余るようにするときの最小金額)
    jは整数になるとは限らないのでj=p/qと既約分数表示して(p, q)を辞書のキーとして保持する。
    """
    dp = {}
    a, b, c = map(int, input().split())
    p, q = b * Ma - a * Mb, Ma
    div = gcd(p, q)
    p, q = p // div, q // div
    dp[(p, q)] = c
    #print("i=0=>dp={}".format(dp))

    for i in range(1, N):
        dp2 = {}
        a, b, c = map(int, input().split())
        p, q = b * Ma - a * Mb, Ma
        div = gcd(p, q)
        p, q = p // div, q // div
        dp2[(p, q)] = c
        for p, q in dp:
            cost = dp[(p, q)]
            if (p, q) in dp2:
                dp2[(p, q)] = min(dp2[(p, q)], cost)
            else:
                dp2[(p, q)] = cost
            np, nq = p * Ma + b * q * Ma - a * q * Mb, q * Ma
            if np == 0:
                np, nq = 0, 1
            else:
                div = gcd(np, nq)
                np, nq = np // div, nq // div
            if (np, nq) in dp2:
                dp2[(np, nq)] = min(dp2[(np, nq)], cost + c)
            else:
                dp2[(np, nq)] = cost + c
        dp = dp2
        #print("i={}=>dp={}".format(i, dp))
    if (0, 1) in dp:
        print(dp[(0, 1)])
    else:
        print(-1)



if __name__ == "__main__":
    main()


Measured memory_bytes: 74516