akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    vector<pair<string, int>> v(N), v2(N);
    map<pair<string, int>, int> mp;
    for(int i=0; i<N; i++){
        string s; int p;
        cin >> s >> p;
        v[i].first = s;
        v[i].second = -p;
        v2[i].first = s;
        v2[i].second = -p;
    }

    sort(v.begin(), v.end());
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(v[i] == v2[j]) cout << j+1 << endl;
        }
    }

    

}

Measured memory_bytes: 256
def ctoi(c):
  return ord(c)-97

n=int(input())
s=list(input())

bits=[[0]*(n+1) for _ in range(26)]

def query(pos):
  ret=[0]*26
  for i in range(26):
    tmp=0
    p=pos
    while p>0:
      tmp+=bits[i][p]
      p-=p&(-p)
    ret[i]=tmp
  return ret

def update(pos,a,x):
  while pos<=n:
    bits[a][pos]+=x
    pos+=pos&(-pos)

for i in range(n):
  update(i+1,ctoi(s[i]),1)

q=int(input())
for _ in range(q):
  flag,a,b=map(str,input().split())
  flag=int(flag)
  a=int(a)
  if flag==1:
    if s[a-1]==b:
      continue
    else:
      update(a,ctoi(s[a-1]),-1)
      update(a,ctoi(b),1)
      s[a-1]=b
  elif flag==2:
    b=int(b)
    cnt1=query(b)
    cnt2=query(a-1)
    ans=0
    for i in range(26):
      if cnt1[i]-cnt2[i]>0:
        ans+=1
    print(ans)

Measured memory_bytes: 165020
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

x=int(input())
LISt=(make_divisors(x))
maX=max(LISt)
n=len(LISt)
flag = False

for i in range(1000):
  for j in range(n):
    b=-LISt[j]+i
    if i**5-b**5==x:
      flag=True
      print(i,b)
      break
  if flag:
    break


Measured memory_bytes: 9368
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <climits> 
//#include <iterator>

using namespace std;
using ll = long long;
using ull = unsigned long long;

string lcs(const string& s, const string& t) {
    //F[i,j] = len(LCS)
    int m = s.size(), n = t.size();
    vector<vector<int>> dp(m+1, vector<int>(n+1,0));
    for (int i = 0; i < m; ++ i) {
        for (int j = 0; j < n; ++ j) {
            if (s[i] == t[j])  dp[i+1][j+1] = dp[i][j] + 1;
            else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
        }
    }
    string str{}; 
    int sp = m, tp = n; 
    while (sp > 0 && tp > 0) {
        if (dp[sp][tp] > dp[sp-1][tp] && dp[sp][tp] > dp[sp][tp-1]) {
            str.push_back(s[sp-1]);
            sp--, tp--;
        }
        while (sp > 0 && dp[sp][tp] == dp[sp-1][tp]) {
            sp--;
        }
        while (tp > 0 && dp[sp][tp] == dp[sp][tp-1]) {
            tp--;
        }
    }
    reverse (str.begin(), str.end());
    return str;
}

int main() {
    string s, t;
    cin>>s>>t;
    cout<<lcs(s,t)<<endl;
    return 0;
}


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 100100;
int a[3 * N];
int n;

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	ll ans = 0;
	cin >> n;
	forn(i, 3 * n) {
		cin >> a[i];
	}
	sort(a, a + 3 * n);
	reverse(a, a + 3 * n);
	forn(i, n) {
		ans += a[2 * i + 1];	
	}
	debug(a, a + 3 * n);
	cout << ans << endl;

	return 0;
}


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

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

# define int(x) int x; scanf("%d",&x);
# define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
# define string(x) string x; cin >> x;

using namespace std;

namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    REP (i, mat.size()) {
      REP (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    REP (i, v.size())
      if (i >= v.size()-1)
	cout << v[i];
      else
	cout << v[i] << ' ';
    
    cout << endl;
  }

  template <typename T> pair<T, T> shape(vector<vector<T>> mat) {
    int d1, d2;

    d1 = mat.size();
    if (d1 > 0) d2 = mat[0].size();
    else int d2 = 0;
    cout << "(" << d1 << ", " << d2 << ")" << endl;
    return make_pair(0, 0);
  }

  template <typename T> vector<vector<T>> empty(int n, int m) {
    vector<vector<T>> mat(n, vector<T>(m));
    return mat;
  }
}


int main() {
  int(n);
  vint(A,n);

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

  int ans = A.back() - A.front();
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
 
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        
        int[] l = new int[N];
        for(int i=0; i < N; i++){
            l[i] = Integer.parseInt(sc.next());;
        }
        
        Arrays.sort(l);
        int a= 0;
        
        for(int i= N - K ; i < N ; i++){
            a += l[i];
           
        }

        System.out.print(a);

        System.out.println();
    }

}

Measured memory_bytes: 23632
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  ll memo = a[0];
  for(int i = 1;i < n-1; i++){
    memo = a[i] - memo;
  }
  ll b[n];
  b[0] = a[n-1] - memo;
  for(int i = 1; i < n; i++){
    b[i] = 2*(a[i-1] - b[i-1]/2);
  }

  rep(i,n){
    printf("%lld ", b[i]);
  }
  printf("\n");


  
  return 0;
}


Measured memory_bytes: 2816
# cf17-final
def main():
    N, *D = map(int, open(0).read().split())
    D.sort()
    D = [0] + [d if i & 1 else 24 - d for i, d in enumerate(D, 1)]
    D.sort()
    ans = min(j - i for i, j in zip(D, D[1:]))
    print(ans)


if __name__ == "__main__":
    main()

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

int main() {
  int N;
  cin >> N;

  int fx = 0;
  int num = N;

  while(num){
    int dig = num % 10;
    fx += dig;
    num /= 10;
  }

  int ck = N % fx;

  if(ck == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<complex>

using namespace std;

double area(double a, double b) {
  return sqrt((a / 2 + b) * (-a / 2 + b) * a * a / 4);
}

int main() {
  double a, l, x;
  while (cin >> a >> l >> x) {
    printf("%.12f\n", area(a, l) + area(l, (l + x) / 2) * 2);
  }
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <string>
using namespace std;
 
int main(void) {
	
	int N,K;
	cin >> N >> K;

	int ret = K;
	for(int i = 1;i < N;i++)  ret *=  (K - 1);
	
	cout << ret;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	
	int n, m;
	cin >> n >> m;
	vector<int>p;
	vector<long long int>b;
	long long int z = 0;
	//long long int c = 0;
	int w = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		p.push_back(t);
		long long int c = 0;
		z = abs(w - t);
	
		b.push_back(z);
		w = t;
	}
	long long int x = 9999999999999999;


	for (int i = 0; i  <= p.size()-m; i++) {
	
		long long int c = abs(p[i]) + abs(p[i + m - 1] - p[i]);
		long long int d= abs(p[i+m-1]) + abs(-p[i + m - 1] + p[i]);
		x = min(x, min(c, d));

	//	cout << x << endl;
	}

	cout << x << endl;

	return 0;



}

Measured memory_bytes: 1780
using System;

namespace _0025
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            while ((input = Console.ReadLine()) != null)
            {
                if (string.IsNullOrEmpty(input)) 
                {
                    break; 
                }

                int numberOfHit = 0;
                int numberOfBlow = 0;
                string[] numbersOfA= input.Split(' ');
                string[] numbersOfB = Console.ReadLine().Split(' ');

                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        if ((i != j) && (numbersOfA[i] == numbersOfB[j]))
                        {
                            numberOfBlow++;

                        }
                    }
                    if (numbersOfA[i] == numbersOfB[i])
                    {
                        numberOfHit++;
                    }
                }
                Console.WriteLine(numberOfHit + " " + numberOfBlow);
            }
        }
    }
}

Measured memory_bytes: 5584
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int jousu(int, int);
int jousu(int x, int y) {
	int z = 1;
	for (int i = 0; i < y; i++) {
		z *= x;
	}
	return z;
}
int kurai(int x, int y) {
	int z = (x%jousu(10,y)) / jousu(10, y-1);
	return z;
}
int keta(int x) {
	int z = x;
	int w = 0;
	while (z != 0) {
		z /= 10;
		w++;
	}
	return w;
}

int n, b = 0;;
string a;
bool c = false;
int main(){
	cin >> n;
	vector<pair<string, int>>list(n);
	for (int i = 0; i < n; i++) {
		cin >> list[i].first >> list[i].second;
	}
	cin >> a;
	for (int i = 0; i < n; i++) {
		if (c) {
			b += list[i].second;
		}
		if (list[i].first == a) {
			c = true;
		}
	}
	cout << b << endl;
}

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

const int M = 1000005;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    vector<int> cnt(M);

    for(int x:a){
        if(cnt[x]!=0){
            cnt[x]=2;
            continue;
        }
        for(int i=x;i<M;i+=x) cnt[i]++;
    }
    int ans=0;
    for(int x:a){
        if(cnt[x]==1)ans++;
    }
    cout<<ans<<endl;
    return 0;

}



Measured memory_bytes: 7988
#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define ff first
#define sc second
#define INF 3000000000
#define SINF 2*(1e18)
#define inf -3000000000
#define pb push_back
#define forr(i,p,n) for(int i=p;i<n;i++)
#define mpk make_pair
#define upb(a,s) upper_bound(a.begin(),a.end(),s)
#define lwb(a,s) lower_bound(a.begin(),a.end(),s)
#define mem(a,val) memset(a,val,sizeof a)
#define cc continue
#define eb emplace_back
#define bb break
#define mostbit(n) 32-__builtin_clz(n)-1
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
//priority_queue<ll> pq;
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
bool pal(string s){
  ll j=s.size()-1;
  ll sw=0;
  for(ll i=0;i<s.size()/2;i++){
    if(s[i]!=s[j]){sw=1;break;}j--;}
  if(sw)return false;
  else return true;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();
    ll a,b,c,d,n,t,m,k;
    while(cin>>n){
      ll dp[100100];
      ll v[100100];
      forr(i,1,n+1){
	cin>>v[i];
      }
      dp[0]=0;
      dp[1]=0;
      v[0]=v[1];
      forr(i,2,n+1){
	dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
      }
      cout<<dp[n]<<endl;
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 5005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int a,b;
void Solve() {
    read(a);read(b);
    if(b >= 0 && a <= 0) puts("Zero");
    else if(a > 0) {
	puts("Positive");
    }
    else {
	if((b - a + 1) & 1) puts("Negative");
	else puts("Positive");
    }
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll t;
    cin>>t;
    rep(T,t){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        string ans="";
        if(a<b)ans="No";
        else if(b>d) ans="No";
        else if(c>=b-1) ans="Yes";
        else{
            ll g=gcd(b,d);
            ll m=b+a%g-g;
            if(c<m) ans="No";
            else ans="Yes";
        }
        cout<<ans<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        //int a = sc.nextInt();
        //int b = sc.nextInt();
        //String s = sc.next();
        //Long x = sc.nextLong();

        if(n>81||n==0){
            System.out.println("No");
            return;
        }
        for(int i=1;i<10;i++){
            for(int j=1;j<10;j++){
                if(i*j == n){
                    System.out.println("Yes");
                    return;
                }
            }
        }

        System.out.println("No");
    }
}


Measured memory_bytes: 21844
// Digits Sum
#include <iostream>
#include <algorithm>
using namespace std;

int findSumOfDigits(int n) {
    int sum = 0;
    while(n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int N;
    int mi_sum = 1 << 30;
    cin >> N;
    for (int A = 1; A < N; ++A) {
        int B = N - A;
        int su = findSumOfDigits(A) + findSumOfDigits(B);
        mi_sum = min(mi_sum, su);
    }
    cout << mi_sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;

int main()
{
 int N;
 scanf("%d",&N);
 int ans=0;
 for(int i=0;i<N;i++)
 {
	int a,b;
	scanf("%d %d",&a,&b);
	ans=ans+b-a+1;
 }
 printf("%d\n",ans);
} 



Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int a,b;
  cin>>a>>b;
  if(a+b==15) cout<<"+"<<endl;
  else if(a*b==15) cout<<"*"<<endl;
  else cout<<"x"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

int main(){
    ll n;
    cin >> n;
    cout << (n-1)*n/2 << endl;
    return 0;
}

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

// 階乗
long long factorial(long long n){
  if(n == 0) return 1;
  else return (n * factorial(n - 1)) % 1000000007;
}

// 階乗を利用した組合せ
long long nCr(long long n, long long r){
  return factorial(n) / (factorial(r) * factorial(n - r));
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  long long n, k, i, a, b;
  cin >> n >> k;
  
  a = n - k + 1;
  b = k - 1;
  
  COMinit();
  
  for(i = 1; i <= k; i++){
    cout << (COM(a, i) * COM(b, i - 1)) % 1000000007 << endl;
  }
}

Measured memory_bytes: 12160
abcd = input()
for i in range(1 << 3):
    total = int(abcd[0])
    ans = abcd[0]
    b = format(i, "b").zfill(3)
    # print(b)
    for j in range(len(b)):
        if b[j] == "1":
            total += int(abcd[j + 1])
            ans += "+" + abcd[j + 1]
        else:
            total -= int(abcd[j + 1])
            ans += "-" + abcd[j + 1]
    # print(total)
    # print(ans)
    if total == 7:
        ans += "=7"
        print(ans)
        break


Measured memory_bytes: 3060
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#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> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//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 mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int t,k ;
	cin >> t >> k ;
	int mx = 0 ;
	for(int i=0;i<k;i++){
		int a ; cin >> a ;
		mx = max(mx,a) ;
	}
	cout << max(mx-1-(t-mx),0) << endl ;
}


Measured memory_bytes: 256
s = input()
a = 0
b = 0

if s[2] == '0': b = int(s[3])
else: b = int(s[2:])
if s[0] == '0': a = int(s[1])
else: a = int(s[:2])

if (b>=1 and b<=12) and (a>=1 and a<=12): print("AMBIGUOUS")
elif b>=1 and b<=12: print("YYMM")
elif a>=1 and a<=12: print("MMYY")
else: print("NA") 

Measured memory_bytes: 9056
using System;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            int r = int.Parse(data[0]);
            int c = int.Parse(data[1]);

            string[,] cell = new string[r + 1, c + 1];

            for (int i = 0; i < r; i++)
            {
                string[] row = Console.ReadLine().Split(' ');

                int sum = 0;
                for (int j = 0; j < c; j++)
                {
                    cell[i, j] = row[j];
                    sum += int.Parse(row[j]);
                }

                cell[i, c] = sum.ToString();
            }

            for (int j = 0; j < c + 1; j++)
            {
                int sum = 0;
                for (int i = 0; i < r; i++)
                {
                    sum += int.Parse(cell[i, j]);
                }

                cell[r, j] = sum.ToString();
            }

            //??????
            for (int i = 0; i < r + 1; i++)
            {
                for (int j = 0; j < c; j++)
                {
                    Console.Write(cell[i, j] + " ");
                }

                Console.WriteLine(cell[i, c]);
            }
        }
    }
}

Measured memory_bytes: 9928
def show(lst):
    length = len(lst)
    for i in range(length-1):
        print(lst[i], end=" ")
    print(lst[-1])
        
    

n = int(input())
lst = list(map(int, input().split()))
def insertion_sort(lst, n):
    for i in range(n):
        v = lst[i]
        j = i - 1
        while j >= 0 and lst[j] > v:
            lst[j+1] = lst[j]
            j -= 1
        lst[j+1] = v
        show(lst)
insertion_sort(lst, n)


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

int main (){
	int n;
	int a[50];
	int ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)ans+=a[i]*a[j];
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  long long cnt = 0;
  for (int i = 1; i <= N; ++i) {
    int d = K - i % K;
    if ((2 * d) % K != 0) continue;
    long long c = 0;
    if (N - d >= 0) c = (N - d) / K + 1;
    cnt += c * c;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int input = int.Parse(Console.ReadLine());
        if(input <= 9)
        {
            Console.WriteLine(input);
            return;
        }
        List<double> list = new List<double>();
        for(int i = 1; i <= 9; i++)
        {
            list.Add(i);
        }
        int count = 9;
        bool countbl = true;
        double ans = 0;
        
        while(countbl)
        {
            List<double> ketaList = new List<double>();
            foreach (double ele in list) {
                double last = ele % 10;
                if (last == 0)
                {
                    ketaList.Add(ele * 10);
                    count++;
                    if(count == input)
                    {
                        countbl = false;
                        ans = ketaList[ketaList.Count() - 1];
                        break;
                    }
                    ketaList.Add(ele * 10 + 1);
                    count++;
                    if (count == input)
                    {
                        countbl = false;
                        ans = ketaList[ketaList.Count() - 1];
                        break;
                    }
                } else if(last == 9)
                {
                    ketaList.Add(ele * 10 + 8);
                    count++;
                    if (count == input)
                    {
                        countbl = false;
                        ans = ketaList[ketaList.Count() - 1];
                        break;
                    }
                    ketaList.Add(ele * 10 + 9);
                    count++;
                    if (count == input)
                    {
                        countbl = false;
                        ans = ketaList[ketaList.Count() - 1];
                        break;
                    }
                }
                else
                {
                    ketaList.Add(ele * 10 + last - 1);
                    count++;
                    if (count == input)
                    {
                        countbl = false;
                        ans = ketaList[ketaList.Count() - 1];
                        break;
                    }
                    ketaList.Add(ele * 10 + last);
                    count++;
                    if (count == input)
                    {
                        countbl = false;
                        ans = ketaList[ketaList.Count() - 1];
                        break;
                    }
                    ketaList.Add(ele * 10 + last + 1);
                    count++;
                    if (count == input)
                    {
                        countbl = false;
                        ans = ketaList[ketaList.Count() - 1];
                        break;
                    }
                }
            }
            list = new List<double>(ketaList);
            
        }
        Console.WriteLine(ans);
    }

   



}

Measured memory_bytes: 21656
N = input()
c = 0
for i, n in enumerate(N):
    if i == 0:
        if not n == "A":
            print("WA")
            exit()
    elif n == 'C':
        if 2<= i and i < len(N) -1:
            c += 1
    else:
        if not 97 <= ord(n) or not ord(n) <= 122:
            print("WA")
            exit()
if c == 1:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
bool flag[2];
int main(void){
	int a,b;
	scanf("%2d %2d",&a,&b);
	if(b>=1 && b<=12)flag[0]=true;
	if(a>=1 && a<=12)flag[1]=true;
	if(flag[0]==true && flag[1]==true)cout << "AMBIGUOUS" <<endl;
	else if(flag[0]==true)cout << "YYMM"<<endl;
	else if(flag[1]==true)cout << "MMYY"<<endl;
	else cout <<"NA"<<endl;
}

Measured memory_bytes: 256
/**
 * A - Registration
 * https://atcoder.jp/contests/abc167/tasks/abc167_a
 */
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    // まずIDを S として登録しようとしました。しかし、このIDは既に他のユーザーによって使用されていました。
    // そこで、高橋君は S の末尾に 1 文字追加した文字列をIDとして登録することを考えました。
    string S, T;
    cin >> S >> T;

    for (int i = 0; i < T.length() - 1; i++) {
        if (S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}
 

Measured memory_bytes: 3620
import java.util.*;

class Main {
  public static final long MOD = 1000000007;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Integer A[] = new Integer[N];
    for(int i=0; i<N; i++){
      A[i] = sc.nextInt() - i;
    }
    int interm;
    Arrays.sort(A);
    if(N % 2 == 1){
      interm = A[(N-1) / 2];
    }else{
      interm = (A[N/2] + A[N/2-1]) / 2;
    }
    Long ans = 0L;
    for(int i=0; i<N; i++){
      ans += Math.abs(A[i] - interm);
    }
    System.out.println(ans);
    
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 93940
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,n,a[10000];
	cin >> n;
	for(i=0;i<n;i++) cin >> a[i];
	
	int min,max;
	long sum;
	min=a[0];
	max=a[0];
	sum=a[0];
	for(i=1;i<n;i++){
		if(min>a[i]){
			min=a[i];
		}
		if(max<a[i]){
			max=a[i];
		}
		sum=sum+a[i];
	}
	cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3128
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
int a,b;

int main(){
  cin >> a >> b;
  int s = b-a;
  int wa = 0;
  REP(i,s) wa += i;
  cout << wa - a << endl;
  return 0;
}


Measured memory_bytes: 256
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    h = list(LI())
    ans = h[0]
    for i in range(1, n):
        if h[i] > h[i-1]:
            ans += h[i] - h[i-1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27112
N = gets.to_i
As, Bs = readlines.map{|l| l.split.map(&:to_i)}

def z(s)
  l = s.length
  res = Array.new(l, 0)
  res[0] = l
  i, j = 1, 0
  while i < l
    j += 1 while i + j < l && s[j] == s[i + j]
    res[i] = j
    if j == 0
      i += 1
      next
    end
    k = 1
    while i + k < l && k + res[k] < j
      res[i + k] = res[k]
      k += 1
    end
    i += k
    j -= k
  end
  res
end

f = ->(a){a.cycle.each_cons(2).take(N).map{|x, y| x^y}}
a = z(f[Bs] + f[As]*2)
(0 ... N).each{|k| puts "#{k} #{As[k]^Bs[0]}" if a[k + N] >= N}

Measured memory_bytes: 61148
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define range(i,a,b) for(int i = (a);i <= (b);i++)
#define all(A) A.begin(),A.end()
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
#define vi vector<int>
#define vl vector<long long>
#define vd vector<double>
#define vp vector<pair<int,int> >
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define popcnt(x) __builtin_popcountll(x)
#define LSOne(x) ((x) & (-(x)))
#define xx first
#define yy second
#define PQ priority_queue
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prp(p) cerr << "(" << (p).first << " ," << (p).second << ")";
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
#define what_is(x) cerr << #x << " is " << x << endl
#define bit_lg(x) (assert(x > 0),__builtin_ffsll(x) - 1)
const double PI = acos(-1);
using namespace std;

const int MAX = 200000 + 10;
int A[MAX],n,m;
int freq[MAX];
int cnt[MAX];

int erase(int p) {
	int v = A[p];
	p = v - freq[v] + 1;
	freq[v] --;
	if(p <= 0) return 0;
	cnt[p]--;
	return cnt[p] == 0;
}

int insert(int p,int v) {
	freq[v]++;
	A[p] = v;
	p = v - freq[v] + 1;
	if(p <= 0) return 0;
	cnt[p] ++;
	return cnt[p] == 1;
}

int main(){
	scanf("%d %d",&n,&m);
	range(i,1,n) {
		scanf("%d",A + i);
		freq[A[i]]++;
	}
	range(i,1,n) if(freq[i]){
		cnt[max(1,i - freq[i] + 1)]++;
		cnt[i+1]--;
	}
	int pref = 0;
	range(i,1,n) cnt[i] = pref += cnt[i];

	int ans = 0;
	range(i,1,n) ans += cnt[i] == 0;
//	cerr << "intial answer = " << ans << endl;
	while(m--) {
		int p,v; scanf("%d %d",&p,&v);
		ans += erase(p);
		ans -= insert(p,v);
		printf("%d\n",ans);
/*

 		cerr << erase(p) << endl;
		cerr << insert(p,v) << endl;
		cerr << "===========================" << endl;
*/
	}
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=k;i<n;i++){
        if(a[i]>a[i-k]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

long long naive(long long N) {
    N *= 2;
    for (long long k = 1; k <= N; ++k) {
        if (k * (k + 1) % N == 0) return k;
    }
}


vector<long long> prime_factorize(long long n) {
    vector<long long> res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        long long val = 1;
        while (n % p == 0) { ++num; n /= p; val *= p; }
        res.push_back(val);
    }
    if (n != 1) res.push_back(n);
    return res;
}

long long solve(long long N) {
    N *= 2;
    auto pf = prime_factorize(N);
    int M = pf.size();
    long long res = N-1;
    for (int bit = 0; bit < (1<<M); ++bit) {
        long long left = 1;
        for (int i = 0; i < M; ++i) if (bit & (1LL<<i)) left *= pf[i];
        long long right = N / left;

        if (left > right) {
            // find k
            for (long long tmp = left; tmp < res; tmp += left) {
                long long k = tmp, pk = tmp + 1;
                if (pk % right == 0) chmin(res, k);
            }
        }
        else {
            // find k + 1
            for (long long tmp = right; tmp - 1 < res; tmp += right) {
                long long k = tmp - 1, pk = tmp;
                if (k % left == 0) chmin(res, k);
            }
        }
    }
    return res;
}

int main() {
    /*
    for (long long n = 1; n <= 100000000; ++n) {
        if (solve(n) != naive(n)) cout << n << endl;

        if (n % 100000 == 0) cout << "check; " << n << endl;
    }
    */
    long long N;
    while (cin >> N) cout << solve(N) << endl;
}

















Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f3f3f
#define pi 3.1415926535898
#define N 200050
using namespace std;
const ll mod=1e9+7;
ll f[200010];
ll inv[200010];
ll pows(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
        {
            ans=ans*a%mod;
        }
        a=a*a%mod;
        n>>=1;
    }
    return ans%mod;
}
ll c(ll n,ll m)
{
    return f[m]*inv[m-n]%mod*inv[n]%mod;
}
int main()
{
    ll n,k;
    cin>>n>>k;
    f[0]=1;
    for(ll i=1;i<=n;i++)
    {
        f[i]=f[i-1]*i%mod;

    }
    for(ll i=0;i<=n;i++)
    {
        inv[i]=pows(f[i],mod-2)%mod;
    }
    k=min(k,n-1);
    ll ans=0;
    for(ll i=0;i<=k;i++)
    {
        ans=(ans+c(i,n)*c(i,n-1)%mod)%mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6732
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
map<ll,ll>d;
ll n;
inline ll solve(ll x)
{
    if(d[x]!=0)
        return d[x];
    else
    	return d[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
int main()
{
    d[0]=1;
    d[1]=2; 
    scanf("%lld",&n);
    ll ans=solve(n);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N, K;
int digits[10];

bool check(int n){
 string s = to_string(n);
 int p = s.length();
 for(int i=0; i<p; ++i){
   if(digits[s[i] - '0'])
     return false;
 }
 return true;
}

int main(){
  ios_base::sync_with_stdio(false); 
  cin >> N >> K;
  for(int i=0; i<K; ++i){
   int x;
   cin >> x;
   digits[x] = 1;
  }
  while(1){
    if(check(N))
      break;
    ++N;
  }
  cout << N << "\n";
  return 0;
}

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

int main()
{
  int N, L; cin >> N >> L;
  string S[N]; rep(i,N) cin >> S[i];
  sort(S, S+N);
  string ans;
  rep(i,N)
  {
    ans += S[i];
  }
  cout << ans << endl;
}

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	string s, t;
	cin >> s >> t;
	int cnt = 0;
	if (s[0] == t[0]) cnt++;
	if (s[1] == t[1]) cnt++;
	if (s[2] == t[2]) cnt++;
	cout << cnt << '\n';

	return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))

if N ==2:
    print(abs(h[1] - h[0]))
else:
    dp = [10**4+1]*N
    dp[0] = 0
    dp[1] = abs(h[0]-h[1])
    for i in range(2,N):
        dp[i] = min(dp[i-2]+abs(h[i] - h[i-2]), dp[i-2] + abs(h[i-2]-h[i-1]) + abs(h[i-1] - h[i]), dp[i-1]+abs(h[i-1]-h[i]))
        
    print(dp[N-1])
    

Measured memory_bytes: 13784
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const int limit = 50;
int n,m;
int a[limit],b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
  visited[v] = true;
  rep(v2,n){
    if(graph[v][v2] == false) continue;
    if(visited[v2] == true) continue;
    dfs(v2);
  }
}

int main() {
  cin >> n >> m;
  
  rep(i,m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    graph[a[i]][b[i]] = true; graph[b[i]][a[i]] = true;
  }
  
  int ans = 0;
  
  rep(i,m){
    graph[a[i]][b[i]] = false; graph[b[i]][a[i]] = false; //一つ辺を消す
    rep(j,n) visited[j] = false; //visited初期化
    
    dfs(0); //dfsで探索
    
    bool bridge = false;
    
    rep(j,n){
      if(visited[j] == false) bridge = true; //全部のノードを調べて到達できていなかったらtrueにする
    }
    
    if(bridge) ans += 1;
    graph[a[i]][b[i]] = true; graph[b[i]][a[i]] = true; //元に戻す
    
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	while (true) {
		int a, b;
		char op;
		std::cin >> a >> op >> b;
		if (op == '?') break;
		
		if (op == '+') std::cout << a+b << std::endl;
		else if (op == '-') std::cout << a-b << std::endl;
		else if (op == '*') std::cout << a*b << std::endl;
		else  std::cout << a/b << std::endl;
	}
	
	return 0;
}



Measured memory_bytes: 3072
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n==0){
			System.out.println(0);
			return;
		}
		String s="";
		int a = 1;
		int m = 1;
		while (n!=0){
			int d =0;
			if (Math.abs(n)%2==1) d = 1;
			s = d + s;
			n = (n - d*m )/2;
			m*=-1;
		}
		System.out.println(s);
	}

}


Measured memory_bytes: 21844
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long DIV = (ll)1e9+7;


int main(void) {
   ll N,A,B;
   cin>>N>>A>>B;
   ll max_s = B/A;
   vector<ll> X(N,0);
   rep(i,0,N) {
      cin>>X[i];
   }
   ll ans = 0;
   rep(i,1,N) {
      if (X[i] - X[i-1] <= max_s) ans += A*(X[i] - X[i-1]);
      else ans += B; 
   }
   cout<<ans<<endl;

   return 0;
}

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

int main(){
  int N;
  cin >> N;
  int f=0;
  for(int i=0; i<9; i++){
    int z = std::pow(10, i);
    f+= N / z % 10;
  }
  if(N%f==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

def ceil(a):
    if a % 10 == 0:
        return a
    else:
        return (a//10+1)*10

gohan = [0]*5
for i in range(5):
    gohan[i] = int(input())
    
ans = 0
for i in range(5):
    ans += ceil(gohan[i])
    gohan[i] = ceil(gohan[i]) - gohan[i]
    
print(ans - max(gohan))

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const set<T> &v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T,S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T,S> &v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "TRACE ON! (Line: " << __LINE__ << ")\n"; auto _stream = istringstream{string{#args}}; d_f(_stream, args); } while(0)
	void d_f(__attribute__((unused)) istringstream& _stream) {}
	template<typename Head, typename... Tails> void d_f(istringstream& _stream, Head H, Tails... T) { string _name; _stream >> _name; if(_name.back() == ',') _name.pop_back(); cerr << "\t" << _name << " <=> [" << H << "]\n"; d_f(_stream, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	int n;
	cin >> n;

	vector<ll> divisors(n + 1, 0);

	for(int i = 1; i <= n; ++i)
		for(int j = i; j <= n; j += i)
			++divisors[j];

	ll su = 0;
	for(int i = 1; i <= n; ++i) su += i * divisors[i];
	cout << su << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


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

int main(){
    int k;
    cin>>k;
    string s;
    cin>>s;
    if (s.size()<=k){
        cout<<s;
    }
    else{
        string temp = "";
        for (int i=0;i<k;++i){
            temp+=s[i];
        }
        cout<<temp<<"...";
    }
    
    
}

Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int r; cin >> r;
	if (r < 1200)cout << "ABC" << endl;
	else if (r < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}

Measured memory_bytes: 3632
def cntBit(n):
    cnt = 0
    while n > 0:
        cnt += (n & 1)
        n >>= 1
    return cnt


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

switch = [list(map(int, input().split())) for _ in range(M)]
B = []
for K, *S in switch:
    b = 0
    for k in range(K):
        b += (1 << (S[k] - 1))
    B.append(b)
P = list(map(int, input().split()))

ans = 0
for i in range(2 ** N):
    on = True
    B1 = list(map(lambda x: x & i, B))
    B2 = list(map(cntBit, B1))
    B3 = list(map(lambda x: x % 2, B2))

    if B3 == P:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<stack>
using namespace std;
int main(){
    stack<int> s;
    int n;
    cin>>n;
    s.push(n);
    while(cin>>n){
        if(n==0){
            cout<<s.top()<<endl;
            s.pop();
        }
        else{
            s.push(n);
        }
    }
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,d;
    cin >> n >> d;
    //vector<int> v[n];
    if(n%(2*d+1)==0){
        cout << n/(2*d+1) << endl;
    } else if(n%(2*d+1)!=0){
        cout << n/(2*d+1) +1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256