akhauriyash/Code-Regression huggingface dataset:
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;


template<typename T>
class UnionFind {
public:
    UnionFind(size_t  size) : data_(size, -1) {}

    bool unite(T x, T y) {
        x = root(x);
        y = root(y);

        if (x != y) {
            if (data_[y] < data_[x]) {
                std::swap(x, y);
            }
            data_[x] += data_[y];
            data_[y] = x;
        }
        return x != y;
    }

    bool isSameGroup(T x, T y) {
        return root(x) == root(y);
    }

    T root(T x) {
        return data_[x] < 0 ? x : data_[x] = root(data_[x]);
    }

    // --
    size_t size(T x) {
        return -data_[root(x)];
    }

private:
    std::vector<T> data_;
};



int main()
{
    int64_t N, K, L;
    std::cin >> N >> K >> L;

    UnionFind<int64_t> road(N);

    for (int64_t i = 0; i < K; ++i) {
        int64_t p, q;
        std::cin >> p >> q;
        p--;
        q--;

        road.unite(p, q);
    }

    UnionFind<int64_t> rail(N);

    for (int64_t i = 0; i < L; ++i) {
        int64_t p, q;
        std::cin >> p >> q;
        p--;
        q--;

        rail.unite(p, q);
    }

    struct Group {
        int64_t x;
        int64_t y;
        bool operator<(const Group& d) const {
            return x == d.x ? y < d.y : x < d.x;
        }
    };

    std::map<Group, int64_t> G;
    for (int64_t i = 0; i < N; ++i) {
        G[{road.root(i), rail.root(i)}] ++;
    }

    for (int64_t i = 0; i < N; ++i) {
        std::cout << G[{road.root(i), rail.root(i)}] << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 15104
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long N, std::vector<std::string> s) {
  ll ans = 0;
  ll bStart = 0;
  ll aEnd = 0;
  ll bStartAEnd = 0;
  for (auto str : s) {
    ull last = str.size() - 1;
    if (str[0] == 'B' && str[last] == 'A') {
      bStartAEnd++;
    } else {
      if (str[0] == 'B') {
        bStart++;
      }
      if (str[last] == 'A') {
        aEnd++;
      }
    }

    rep(i, last) {
      if (str[i] == 'A' && str[i + 1] == 'B') {
        ans++;
      }
    }
  }

  if (aEnd > 0 && bStartAEnd > 0) {
    aEnd--;
    ans += bStartAEnd;

    if (bStart > 0) {
      ans++;
      bStart--;
    }

    ans += min(aEnd, bStart);
  } else if (aEnd == 0 && bStartAEnd > 0) {
    ans += bStartAEnd - 1;

    if (bStart > 0) {
      ans++;
    }
  } else {
    ans += min(aEnd, bStart);
  }

  print(ans);
}

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


Measured memory_bytes: 768
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a,T2 b){if (b>a) a=b;}
template <class T1, class T2>inline void gmin(T1 &a,T2 b){if (b<a) a=b;}
/*int a,b;
int main(){
    read(a),read(b);
    if ((a+b)%2==0) cout<<(a+b)/2<<endl;
    else cout<<(a+b+1)/2<<endl;
    return 0;
}*/
/*string s,t;
int main(){
    cin>>s>>t;
    sort(ALL(s));
    sort(ALL(t));
    reverse(ALL(t));
    if (s<t) puts("Yes");
    else puts("No");
    return 0;
}*/
const int N=1e5+5;
int n,a[N],cnt[N];
int main(){
    read(n);
    int ans=0;
    for (int i=1;i<=n;i++){
        read(a[i]);
        if (a[i]>1e5) ans++;
        else cnt[a[i]]++;
    }
    for (int i=1;i<=1e5;i++){
        if (cnt[i] && cnt[i]!=i){
            ans+=cnt[i]<i?cnt[i]:cnt[i]-i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

void solve(){
  int a,b,c;
  cin>>a>>b>>c;
  if(c>=a&&c<=b)cout<<"Yes";
  else cout<<"No";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	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 X = Integer.parseInt(sc.next());
    int Y = Integer.parseInt(sc.next());
    int total = 0;

    if(X == 3)
      total += 100000;
    if(Y == 3)
      total += 100000;
    if(X == 2)
      total += 200000;
    if(Y == 2)
      total += 200000;
    if(X == 1)
      total += 300000;
    if(Y == 1)
      total += 300000;
    if(X == 1 && Y == 1)
      total += 400000;

    System.out.println(total);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=300010,mod=998244353;
int ksm(int a,int b=mod-2,int c=mod){
	int ans=1;
	while(b){
		if(b&1)ans=(LL)ans*a%mod;
		b>>=1;a=(LL)a*a%mod;
	}
	return ans;
}
int n,a,b,c[N],ans;
LL k;
int main(){
	cin>>n>>a>>b>>k;
	c[0]=1;
	for(int i=1;i<=n;i++){
		c[i]=(LL)c[i-1]*(n-i+1)%mod*ksm(i)%mod;
	}
	for(int i=0;i<=n;i++){
		if((LL)a*i<=k&&(k-(LL)a*i)%b==0&&(k-(LL)a*i)/b<=n&&(k-(LL)a*i)>=0){
			int j=(k-(LL)a*i)/b;
			ans+=(LL)c[i]*c[j]%mod;
			if(ans>=mod)ans-=mod;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1408
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );
	final int n = stdin.nextInt();

	int d = 0;
	while ( true ) {
	    if ( isPalindrome( n - d ) ) {
		System.out.println( n - d );
		break;
	    } else if ( isPalindrome( n + d ) ) {
		System.out.println( n + d );
		break;
	    }
	    d++;
	}	
    }

    static boolean isPalindrome( final int num ) {
	final String numStr = Integer.toString( num );
	return numStr.equals( reverse( numStr ) );
    }

    static String reverse( String str ) {
	return new StringBuilder( str ).reverse().toString();
    }
}

Measured memory_bytes: 17336
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

int main(){
  string s,t;cin>>s>>t;
  ll n=s.size(),m=t.size(),ans=inf;
  rep(i,0,n-m+1){
    ll tmp=0;
    rep(j,0,m){
      if(s[i+j]!=t[j]){tmp++;}
    }
    ans=min(tmp,ans);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3604
def bomb(f,x,y):
    rf=f[:][:]
    rf[y][x]=0
    for i in [-3,-2,-1,1,2,3]:
        if 0<=x+i<=7:
            if rf[y][x+i]==1:
                rf=bomb(rf,x+i,y)
        if 0<=y+i<=7:
            if rf[y+i][x]==1:
                rf=bomb(rf,x,y+i)
    return rf

n=int(raw_input())
for data in range(1,n+1):
    raw_input()
    f=[]
    for i in range(8):
        f.append([int(x) for x in raw_input()])
    x=int(raw_input())-1
    y=int(raw_input())-1
       # map(int,raw_input().split())
    f=bomb(f,x,y)
    print "Data %d:"%(data)
    for i in range(8):
        print ''.join(map(str, f[i]))

Measured memory_bytes: 6404
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline void goodbye(const T& val) { cout << val << endl; exit(0); }

ll GCD(ll x, ll y)
{
	return (x == 0 ? y : GCD(y % x, x));
}

void solve()
{
	ll A, B;
	cin >> A >> B;

	A = GCD(A, B);
	ll sz = 1;

	for(ll i = 2; i * i <= A; ++i)
	{
		if(A % i == 0)
		{
			++sz;

			while(A % i == 0)
				A /= i;
		}
	}

	sz += (A > 1);
	cout << sz << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
n, k, c = map(int, input().split())
s = input()
idx = 0
forward = []
while idx < len(s) and len(forward) < k:
    if s[idx] == 'o':
        forward.append(idx)
        idx += c + 1
    else:
        idx += 1

idx = len(s) - 1
backward = []
while idx >= 0 and len(backward) < k:
    if s[idx] == 'o':
        backward.append(idx)
        idx -= c + 1
    else:
        idx -= 1

for f, b in zip(forward, backward[::-1]):
    if f == b:
        print(f + 1)


Measured memory_bytes: 22156
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 1e5 + 7, inf = 1e18;
int n, k, h[N], dp[N];

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < N; i++) {
        dp[i] = inf;
    }
    dp[1] = 0;
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i - j < 1) {
                break;
            }
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[n];
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	int p,q,r;cin>>p>>q>>r;
	cout<<p+q+r-max({p,q,r})<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int m = (int)Math.sqrt(N);
        int ans = 100;
        for(int i = m;i > 0;i--){
            if(N%i == 0){
                long A = i;
                long B = N/i;
                int count = 0;
                while(A > 0 || B > 0){
                    A /= 10;
                    B /= 10;
                    count++;
                }
                ans = Math.min(ans, count);
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;


int main() {
     int A,B;
     cin>>A>>B;

     if(B%A==0){
         cout<<A+B<<endl;
     }else{
         cout<<B-A<<endl;
     }
     return 0;
}



Measured memory_bytes: 256
from math import sqrt
def isprime(inlst, chk, sq):
	for i in range(3, sq, 2):
		inlst = [x for x in inlst if x%i > 0 or x == i]
		i += 2
	return inlst
n = int(input())
inlst = [input() for i in range(n)]
inlst = [int(i) for i in inlst]
inlst = [x for x in inlst if x%2 > 0 or x == 2]
inlst = isprime(inlst, 3, int(sqrt(max(inlst))) + 1)
print(len(inlst))

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

int main() {
    string n; cin >> n;
    int s = 0;
    for (int i = 0; i < n.size(); i++) s += (n[i]-'0');
    
    cout << (stoi(n)%s==0 ? "Yes" : "No") << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=MAX,n;
    cin >>n;

    for(ll i=1;i*i<=n;i++){
        ll a=0,b=0;
        if(n%i==0){
            a=i,b=n/i;
            ll keta=to_string(b).size();
            ans=min(ans,keta);
        }
    }


    cout <<ans<<endl;

    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, K, sum;
  	cin >> N >> K;
  	sum = 0;
  rep (i, N) {
  	int x;
    cin >> x;
    if (x <= K - x) {
    sum += 2*x;
    }
    else sum += 2* (K - x);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
N = input()
#A, B, C, D = list(map(int, input().strip().split()))
A = int(N[0])
B = int(N[1])
C = int(N[2])
D = int(N[3])
ans1 = A+B+C+D
ans2 = A+B+C-D
ans3 = A+B-C+D
ans4 = A+B-C-D
ans5 = A-B+C+D
ans6 = A-B+C-D
ans7 = A-B-C+D
ans8 = A-B-C-D

if ans1 == 7:
	print('%d+%d+%d+%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d+%d+%d-%d=7' % (A, B, C, D))
elif ans3 == 7:
	print('%d+%d-%d+%d=7' % (A, B, C, D))
elif ans4 == 7:
	print('%d+%d-%d-%d=7' % (A, B, C, D))
elif ans5 == 7:
	print('%d-%d+%d+%d=7' % (A, B, C, D))
elif ans6 == 7:
	print('%d-%d+%d-%d=7' % (A, B, C, D))
elif ans7 == 7:
	print('%d-%d-%d+%d=7' % (A, B, C, D))
else:
	print('%d-%d-%d-%d=7' % (A, B, C, D))


Measured memory_bytes: 3064
import sys

N, M = map(int, input().split())
if N >= M:
    print(0)
    sys.exit(0)

X = list(map(int, input().split()))
X.sort()

distance_list = [b - a for a, b in zip(X,X[1:])]
distance_list.sort()

print(sum(distance_list[:M-N]))


Measured memory_bytes: 13960
using System;

namespace ABC131 {
	class Program {
		static int CalcTaste(int L, int i) {
			// for文のindexとりんご1,2,...にはiに1のズレがあることに注意する
			return L + i;
		}
		static void Main(string[] args) {
			// 入力
			int[] array = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
			int N = array[0];
			int L = array[1];
			// 処理
			// 味の総和をforで求めながら、絶対値最小のりんごを探す
			int absMinIndex = 0;
			int absMin = Math.Abs(CalcTaste(L, absMinIndex));
			int totalTaste = 0;
			for (int i = 0; i < N; i++) {
				int taste = CalcTaste(L, i);
				totalTaste += taste;
				int abs = Math.Abs(taste);
				if (abs < absMin) {
					absMin = abs;
					absMinIndex = i;
				}
			}
			int ans = totalTaste - CalcTaste(L, absMinIndex);
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13140
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str1 = scan.nextLine();
        String str2 = scan.nextLine();
        int n = Integer.parseInt(str1.split(" ")[0]);
        int k = Integer.parseInt(str1.split(" ")[1]);
        int[] a = Arrays.stream(str2.split(" ")).mapToInt(s -> Integer.parseInt(s)).toArray();
        scan.close();

        int ret = solver(n, k, a);
        System.out.println(ret);
        return;
    }

    private static int solver(int n, int k, int[] a) {
        if (a.length == 0) {
            return 0;
        }
        if (a.length <= k) {
            return 1;
        }
        int[] newA = Arrays.copyOfRange(a, k - 1, a.length);
        return 1 + solver(n - (k - 1), k, newA);
    }
}


Measured memory_bytes: 465960
from collections import Counter
from collections import deque
import math
import bisect
import sys
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
t=input()
ls=len(s)
lt=len(t)
l=[]
ans=[]
for i in range(ls-lt+1):
    ch=True
    for k in range(lt):
        if s[i+k]!=t[k] and s[i+k]!="?":
            ch=False
    if ch:
        l.append(list(s[:i]+t+s[i+lt:]))
if len(l)==0:
    print("UNRESTORABLE")
    exit()
for i in range(len(l)):
    for k in range(ls):
        if l[i][k]=="?":
            l[i][k]="a"
ans=sorted(l)
print(*ans[0],sep="")

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

int main() {
    int N; string S;
    cin >> N >> S;
    long long r = 0, g = 0, b = 0;
    for (auto c : S) {
        if (c == 'R') ++r;
        else if (c == 'G') ++g;
        else ++b;
    }
    long long all = r * g * b;
    long long sub = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (S[i] == S[j]) continue;
            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) continue;
            ++sub;
        }
    }
    cout << all - sub << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

	ll X,Y; cin >> X >> Y;

	ll ans = 0;
	ll cur = X;
	while (true) {
		if (X <= Y) {
			ans++;
			X *= 2;
		}
		else break;
	}

	cout << ans << endl;

    return 0;
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()



struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    i64 n, k;
    cin >> n >> k;
    vector<i64> used(n, -1), a(n);
    rep(i, n) {cin >> a[i]; a[i]--;}
    i64 cur = 0, cnt = 0;
    used[0] = 0;
    rep(i, k){
        cur = a[cur];
        ++cnt;
        if(used[cur] != -1){
            i64 loop = used[cur] - cnt;
            i += ((k - i - 1) / loop) * loop;
        }else{
            used[cur] = cnt;
        }
    }
    cout << cur + 1 << endl;
}


Measured memory_bytes: 6428
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
C.sort()

ans = 0
for b in B:
    ai = bisect.bisect_left(A,b)
    ci = bisect.bisect(C,b)
    ans += ai*(N-ci)
print(ans)

Measured memory_bytes: 23232
#include <bits/stdc++.h>
using namespace std;
bool square(int n) {
	for(int i = 1; i <= 100100; i++) {
		if(i * i == n) {
			return true;
		}
	}
	return false;
}
int main()
{
	string a, b;
	cin >> a >> b;
	int sum = atoi((a + b).c_str());
	if(square(sum)) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();
		System.out.println(P+Q+R-Math.max(P, Math.max(Q, R)));

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int calcdigit(int c){
	int res=1;
	while(1){
		if(c/10==0){
			break;
		}
		++res;
		c=c/10;
	}
	return res;

}
int main() {
    clock_t cTimeStart, cTimeEnd;
    cTimeStart = clock();           // 現在時刻
    int a,b;
   	while(cin>>a>>b){
	    cout<<calcdigit(a+b)<<endl;
   	}


    cTimeEnd = clock();           // 現在時刻
//    cout<< "処理時間:" <<(cTimeEnd - cTimeStart)/1000 << "[ms]" << endl;

	return 0;
}

Measured memory_bytes: 1168
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	A := nextInt()
	count := 0
	for i := 1; i < A+1; i++ {
		l := len(strconv.Itoa(i))
		if l%2 == 1 {
			count += 1
		}
	}
	fmt.Println(count)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations

// solve
int main(){

    int m1, m2;
    cin >> m1 >> m2 >> m2;
    cout << (m1 != m2) << '\n';

}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n - 1],
    }
    let mut ans = vec![0; n];

    for i in 0..a.len() {
        ans[a[i] - 1] += 1;
    }

    for i in 0..ans.len() {
        println!("{}", ans[i]);
    }
}



Measured memory_bytes: 5568
#include <iostream>
#include <string>
using namespace std;
int H, W;
string a[100];
bool x[100], y[100];
int main(){
  cin >> H >> W;
  for(int i = 0; i < H; i++){
    cin >> a[i];
  }
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(a[i][j] == '#'){
        x[i] = true;
        y[j] = true;
      }
    }
  }
  for(int i = 0; i < H; i++){
    if(x[i]){
      for(int j = 0; j < W; j++){
        if(y[j]){
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }
  return 0;
}

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

int main() {
    std::cout<<std::fixed<<std::setprecision(99999999999999999999999999999999999999999999999);
    double r;
    cin >> r;
    double pi = M_PI;
    cout << pi * r * r << " " << 2 * pi * r << endl;
}



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

using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back



int main(){
    ll q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;
    ll ans=0;

    if(q*2<=h){
        h=q*2;
    }

    if(h*2<=s){
        s=h*2;
    }


    if(s*2<=d){
        ans=s*n;
    }else{
        ans=n/2*d;
        if(n%2==1){
            ans+=s;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;


string s[1010];
int d[1010][1010];
int dy[4] = {1, 0, -1, 0};
int dx[4] = {0, 1, 0, -1};
int h, w, sy, sx, gy, gx;

bool contain(int y, int x){
    return (0 <= y && y < h && 0 <= x && x < w);
}

int bfs(){
	queue<P> q;
	rep(i, 0, h) rep(j, 0, w) d[i][j] = INF;
	q.push(P(sy,sx));  //初期状態
	d[sy][sx] = 0;

	while(!q.empty()){
		P p = q.front(); q.pop();
		//goal?
		if(p.first == gy && p.second == gx){
			return d[gy][gx];
        } 
		rep(i, 0, 4){
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if(!contain(ny, nx)) continue;
            if(s[ny][nx]!='#' && d[ny][nx] == INF){
                q.push(P(ny,nx));
				d[ny][nx] = d[p.first][p.second] + 1;
			}
		}
    }
    return -1;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    sy = 0; sx = 0; gy = h - 1; gx = w - 1;
    rep(i, 0, h){
        cin >> s[i];
    }
    int cnt = 0;
    rep(i, 0, h){
        rep(j, 0, w){
            if(s[i][j] == '#') cnt++;
        }
    }
    int dist = bfs();
    if(dist == -1) cout << -1 << endl;
    else{
        cout << h * w - cnt - (dist + 1) << endl;
    }
}

Measured memory_bytes: 512
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    S = input()
    T = input()

    ans = []
    for i in range(len(S) - len(T) + 1):
        ok = True
        for j in range(len(T)):
            if not(S[i + j] == T[j] or S[i + j] == "?"):
                ok = False
        if ok:
            ans.append(S[:i] + T + S[i + len(T):])

    if len(ans) == 0:
        print("UNRESTORABLE")
    else:
        t = min(ans)
        print(t.replace("?", "a"))


if __name__ == '__main__':
    main()


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


long long int N,A,B,C,D,E;
vector<long long int> city;
int main(void){
  cin>>N>>A>>B>>C>>D>>E;
  city.push_back(A);
  city.push_back(B);
  city.push_back(C);
  city.push_back(D);
  city.push_back(E);
  long long int min = *min_element(city.begin(), city.end());
  cout << 5+(long long int)((N-1)/min) << endl;
  return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
#define N_MAX 100

int n, k, d, a;
vector<int> s(N_MAX);

int main(void){
    cin >> n >> k;
    rep(i, k){
        cin >> d;
        rep(j, d){
            cin >> a;
            s.at(a-1)++;
        }
    }
    cout << count(s.begin(), s.begin()+n, 0) << endl;
    return 0;
}



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

#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
int main(){
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    if((a1+a2+a3)>=22) cout << "bust" << endl;
    else cout << "win" << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_B&lang=jp

int n;
int A[100005];
int cnt;

static int par(int p, int r) {
    int i = p - 1;
    int x = A[r];
    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            swap(A[j], A[i]);
        }
    }
    swap(A[r], A[i+1]);
    return i+1;
}

int main() {
    cin >> n;
    REP(i, n) cin >> A[i];
    int q = par(0, n-1);

    REP(i, n) {
        if (i) cout << " ";
        if (i == q) cout << "[";
        cout << A[i];
        if (i == q) cout << "]";
    }
    cout << "\n";
    return 0;
}



Measured memory_bytes: 3480
#include<stdio.h>

#define N 2000

int Make(int ,int,int,int * );

int main(){
  int loop1,loop2;
  int i,check;
  int Length[N],Seisu[N];
  

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

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

  for(i=0;i<loop2;i++){
    check=0;
    check=Make(0,Seisu[i],loop1,Length);

    if(check==1){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
    
  }
  
  return 0;
}


int Make(int x,int y,int length,int *Num){
  int more;

  if(y==0){
    return 1;
  }
  else if(x>=length){
    return 0;
  }
  else{
    more=Make(x+1,y,length,Num) || Make(x+1,y-Num[x],length,Num);
    return more;
  }
}



Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading;

class Program
{

    static void Main(string[] args)
    {
        int[] arr = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        int maxVal = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).Sum();
        if (arr[0] <= maxVal) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }




}

Measured memory_bytes: 35392
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.HashMap;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			final int ope_num = Integer.parseInt(br.readLine());
			Dictionary(ope_num,br);
		} catch (NumberFormatException | IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
	
	//enum宣言
	public static enum Operate{
		insert("insert"),
		find ("find"),;
		
		private final String name;
		
		Operate(String name){
			this.name = name;
		}
		
		String getName(){
			return this.name;
		}

		public static Operate getEnumName(String str){
			for(Operate v : values()){
				if(v.getName().equals(str)){
					return v;
				}
			}
			throw new IllegalArgumentException("undefined : " + str);
		}
	}

	public static void Dictionary( int ope_num ,BufferedReader br ){
		HashMap<String,Integer> que = new HashMap<String,Integer>();
		int i;
		int count = 0;
		
		for ( i = 0; i < ope_num; i++) {
			try {
				final String[] op = br.readLine().split(" ");		//キーと命令を分割
			 
				switch( Operate.getEnumName(op[0]) ){ //命令によって処理
				case insert:
					que.put(op[1],count);
					count ++;
					break;
				case find:	
					if( que.containsKey(op[1]) ) {
						System.out.println("yes");
					}else {
						System.out.println("no");
					}
				}
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		}
	}
}


Measured memory_bytes: 193324
#include <stdio.h>
#include <stdbool.h>

int main(){
  int n,i,x,p,m;
  bool f[102]={};
  scanf("%d",&x);
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&p);
    f[p]=true;
  }
  for(i=0;i<101;i++){
    if(x-i>=0){
      if(f[x-i]==false){
        m=x-i;
        break;
      }
    }
    if(x+i<=101){
      if(f[x+i]==false){
        m=x+i;
        break;
      }
    }
  }
  printf("%d",m);
  return(0);
}

Measured memory_bytes: 1732
from math import cos, pi, sqrt


a, b, r = map(int, input().split())
c = sqrt(a**2 + b**2 - 2 * a * b * cos(pi*(r/180)))

l = round(a+b+c, 10)
s = round(l/2, 10)
S = round(sqrt(s * (s-a) * (s-b) * (s-c)), 10)
h = round(S / a * 2, 10)

print(S)
print(l)
print(h)


Measured memory_bytes: 5708
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

int N;
vector<int> A, B, C;
vector<int> DPA, DPB, DPC;

int main() {
	cin >> N;
	A.resize(N + 1);
	B.resize(N + 1);
	C.resize(N + 1);
	for (int n = 1; n <= N; n++)cin >> A[n] >> B[n] >> C[n];
	DPA.resize(N + 1,0);
	DPB.resize(N + 1,0);
	DPC.resize(N + 1,0);
	for (int n = 1; n <= N; n++) {
		DPA[n] = max(DPB[n - 1], DPC[n - 1])+A[n];
		DPB[n] = max(DPC[n - 1], DPA[n - 1]) + B[n];
		DPC[n] = max(DPA[n - 1], DPB[n - 1]) + C[n];
	}
	cout << max(max(DPA[N], DPB[N]), DPC[N]) << endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();	
	        long A = sc.nextInt();	
	        long B = sc.nextInt();	
	        long[] a = new long[N];
	        long[] d = new long[N];
	        for (int i=0 ; i<N; i++) {
	            a[i] = Long.parseLong(sc.next());
	        }
	        long ans=0;
	        for(int i=0;i<N-1;i++) {
	        	d[i]=a[i+1]-a[i];
	        	ans=ans+Math.min(d[i]*A, B);
	        }
	        
	        System.out.println(ans);
	        
	 }

}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c) {
        cout << "No" << endl;
    } else if (a == b) {
        cout << "Yes" << endl;
    } else if (a == c) {
        cout << "Yes" << endl;
    } else if (b == c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
	puts("?a"); fflush(stdout);

	bool used[128]={};
	while(1){
		char s[3]; scanf("%s",s);
		if(s[1]=='\0' || s[0]!='a' || used[s[1]]){ puts("!OUT"); break; }
		used[s[1]]=true;

		if(s[1]=='a') puts("?aaa");
		else printf("?%ca\n",s[1]);
		fflush(stdout);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>

#define N 3010
#define RG register
#define ll long long
#define MOD 1000000007
#define Iv2 500000004

using namespace std;

inline int read(){
    RG int x=0,t=1;RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=-1,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return x*t;
}

int n,Q,a[N],f[N][N],tA[N],tB[N],tC[N],tD[N];
inline int Plu(const int &x,const int &y) { return x+y>=MOD?x+y-MOD:x+y; }
inline int Pow(int x,int y){ int ans=1;
	while(y) { if(y&1) ans=1LL*ans*x%MOD; x=1LL*x*x%MOD,y>>=1; }
	return ans;
}

int main(){
	n=read(),Q=read(); int cp=Q;
	for(RG int i=1;i<=n;++i) a[i]=read();
	for(RG int i=1;i<=n;++i)
		for(RG int j=1;j<=n;++j)
			f[i][j]=a[i]>a[j];
	while(Q--){
		int x=read(),y=read();
		for(RG int i=1;i<=n;++i)
			tA[i]=f[x][i],tB[i]=f[y][i],tC[i]=f[i][x],tD[i]=f[i][y];
		for(RG int i=1;i<=n;++i){
			if(i==x||i==y) continue ;
			f[x][i]=1LL*Plu(tB[i],f[x][i])*Iv2%MOD;
			f[y][i]=1LL*Plu(tA[i],f[y][i])*Iv2%MOD;
			f[i][x]=1LL*Plu(tD[i],f[i][x])*Iv2%MOD;
			f[i][y]=1LL*Plu(tC[i],f[i][y])*Iv2%MOD;
		}
		f[x][y]=1LL*Plu(f[x][y],tB[x])*Iv2%MOD;
		f[y][x]=1LL*Plu(f[y][x],tA[y])*Iv2%MOD;
	}   int ans=0;
	for(RG int i=1;i<=n;++i)
		for(RG int j=i+1;j<=n;++j)
			ans=Plu(f[i][j],ans);
	printf("%lld\n",1LL*ans*Pow(2,cp)%MOD);
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    vector<int> adj[n+1];
    int u,v;
    for(int i=0;i<m;i++){
        cin>>u>>v;
        adj[u].pb(v);
    }
    vector<int> indeg(n+1,0);
    vector<int> dp(n+1,0);
    for(int i=1;i<=n;i++){
        for(int j=0;j<adj[i].size();j++){
            indeg[adj[i][j]]++;
        }
    }
    queue<int> pq;
    for(int i=1;i<=n;i++){
        if(indeg[i]==0){
            pq.push(i);
        }
    }

    while(!pq.empty()){
        int u = pq.front();
        pq.pop();
        for(int i=0;i<adj[u].size();i++){
            indeg[adj[u][i]]--;
            if(indeg[adj[u][i]]==0){
                pq.push(adj[u][i]);
            }
            dp[adj[u][i]] = max(dp[adj[u][i]],dp[u]+1);
        }
    }
    cout<<*max_element(dp.begin(),dp.end())<<endl;
}


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

int main() {
	// your code goes here
	int a,b;
	cin>>a>>b;
	if(a==3 || b==3){
		cout<<abs(a-b);
	}
	else{
		cout<<a+b;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	a[i] -= i + 1
a = sorted(a)

res = 10 ** 100
if n % 2 == 0:
	p = n // 2 - 1
	q = n // 2
	for cand in [p, q]:
		tmp = 0
		for i in a:
			tmp += abs(i - a[cand])
		res = min(res, tmp)
else:
	tmp = 0
	for i in a:
		tmp += abs(i - a[n // 2])
	res = min(res, tmp)
	
print(res)

Measured memory_bytes: 26180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                int n = sc.nextInt();
                int s = sc.nextInt();
                if (s == 0 && n == 0)
                    break;
                System.out.println(searchAnswer(n, s, 0));
            }
        }
    }

    private static int searchAnswer(int availableNumberCount, int rest, int number) {
        if (availableNumberCount == 0 && rest == 0) return 1;
        if (availableNumberCount <= 0 || rest < 0 || number == 10) return 0;

        return searchAnswer(availableNumberCount, rest, number + 1) +
	    searchAnswer(availableNumberCount - 1, rest - number, number + 1);
    }
}


Measured memory_bytes: 26192
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#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 REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

string ch;
vector<string> vs;
vector<bool> used;

void dfs(string s,int index){
  if(index==(int)s.size()){
    vs.pb(s);
    return ;
  }
  if(s[index]=='a'||used[s[index]-'a']){
    dfs(s,index+1);
  }
  if(s[index]!='z'&&!used[s[index]+1-'a']){
    s[index]++;
    used[s[index]-'a']=true;
    dfs(s,index+1);
    used[s[index]-'a']=false;
    s[index]--;
  }
}


void solve(string str){
  used.assign(25,false);
  dfs(str,0);
  cout<<vs.size()<<endl;
  if(vs.size()<=10){
    for(int i=0;i<vs.size();i++)cout<<vs[i]<<endl;
  }else{
    for(int i=0;i<5;i++)cout<<vs[i]<<endl;
    for(int i=vs.size()-5;i<vs.size();i++)cout<<vs[i]<<endl;
  }
}

int main(){
  string s;
  while(cin>>s){
    ch=s;
    if(s=="#")break;
    vs.clear();
    solve(s);
  }
  return 0;
}



Measured memory_bytes: 4268