akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
bool comp(P p1,P p2){
  return (p1.first == p2.first && p1.second > p2.second) || p1.first < p2.first;
}
bool comp1(P p1,P p2){
  return p1.second > p2.second;
}
int main(){
  ll n,h;
  cin >> n >> h;
  ll i;
  vector<P> p(n);
  for(i=0;i<n;i++){
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(),p.end(),comp);
  ll a=p[n-1].first,b=p[n-1].second;
  ll ans=0,sum=0,res=0;
  sort(p.begin(),p.end(),comp1);
  for(i=0;i<n;i++){
    if(sum>=h){
      break;
    }
    if(a>p[i].second){
      break;
    }
    if(res==0 && p[i].first==a && p[i].second==b){
      res=1;
      continue;
    }
    ans++,sum+=p[i].second;
  }
  if(sum>=h){
    cout << ans << endl;
    return 0;
  }
  sum+=b,ans++;
  if(sum>=h){
    cout << ans << endl;
    return 0;
  }
  ans+=(h-sum-1)/a+1;
  cout << ans << endl;
}

Measured memory_bytes: 4816
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	bool f = true;
	while(1){
	int a,b;
	cin>>a>>b;
	if(a==0)break;
	if(f){
		f = false;
	}else{
		cout<<endl;
	}
	vector<int> ans;
	for(int i=a;i<=b;i++){
		if(i%400==0){
			ans.push_back(i);
		}else if(i%100==0){

		}else if(i%4==0){
			ans.push_back(i);
		}
	}
	if(ans.size()==0){
		cout<<"NA"<<endl;	
	}else{
		for(int i=0;i<ans.size();i++)cout<<ans[i]<<endl;
	}

	}
	return 0;
}



Measured memory_bytes: 3072
N = int(input())
L = list(map(int, input().split()))

L.sort()
ans = 0
for i in range(N):
  for j in range(i):
    for k in range(j):
      if L[k]<L[j]<L[i] and L[k]+L[j]>L[i]:
        ans += 1
print(ans)


Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
using namespace std;

int main()
{
	char op;
	int A, B;
	cin >> A >> op >> B;
	if (op == '+') {
		cout << A + B << endl;
	}
	else {
		cout << A - B << endl;
	}
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main() {
	int n;
	while (cin >> n, n) {
		int s[1000], p[1000], q[1000], r[1000];
		REP(i, n) scanf("%d %d %d %d", s + i, p + i, q + i, r + i);
		int P, Q, R, C;
		scanf("%d %d %d %d", &P, &Q, &R, &C);
		
		bool no = true;
		REP(i, n) {
			if (p[i] <= P && q[i] <= Q && r[i] <= R && p[i] * 4 + q[i] * 9 + r[i] * 4 <= C) {
				printf("%d\n", s[i]);
				no = false;
			}
		}
		if (no) puts("NA");
	}
	return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

int main() {
	IO;
	int n;
	cin>>n;
	int bef=-1;
	int len=0, ans=0;
	for(int i=0;i<n;++i) {
		int akt;
		cin>>akt;
		if(bef<akt) {
			bef=akt;
			len=1;
		}else {
			len++;
		}
		ans=max(ans, len);
		bef=akt;
	}
	cout<<ans-1<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int A = 0, B = 0;
  for (int i = 0; i < N; i++)
  {
  	if (i % 2 == 0) A += a.at(i);
    else B += a.at(i);
  }
  	
  cout << A - B << endl;
}

Measured memory_bytes: 256
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"--->"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    
    ll i,j,k,n,m,T; //basic variables

    cin>>n>>m>>k;
    
    ll arr[n+1],brr[m+1];
    arr[0] = brr[0] = 0;
    for(i=1;i<=n;i++){
        cin>>arr[i];
        arr[i]+=arr[i-1];
    }
    for(j=1;j<=m;j++){
        cin>>brr[j];
        brr[j]+=brr[j-1];
    }

    for(i=1;i<=n;i++){
        if(arr[i]>k) break;
    }
    ll lenA = i-1;
    ll ans = 0;
    for(i=0;i<=m;i++){
        ll check = 0;
        while(arr[lenA]+brr[i]>k){
            if(lenA==0){
                check = 1;
                break;
            }
            lenA--;
        }
        if(arr[lenA]+brr[i]>k) break;
        // cout<<arr[lenA]<<SP<<brr[i]<<NL;
        ans = max(ans,lenA+i);
    }
    cout<<ans<<NL;  
    
    /// Don't forget to set array size....
    return 0;
}




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

using namespace std;

int main()
{
    int N,D;
    cin >> N >> D;
    int x = 0;
    x = 2*D+1;
    if(N%x == 0){
    cout<<N/x<<endl;
    }else{
        cout<<N/x+1<<endl;
    }
        return 0;
    }


Measured memory_bytes: 256
#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(){
    string s; cin >> s;

    bool flg = true;

    if(s[0] != 'A') flg = false;

    int cnt = 0;
    for(int i=2; i<s.size()-1; i++) if(s[i] == 'C') cnt++;
    if(cnt != 1) flg = false;

    cnt = 0;
    for(int i=1; i<s.size(); i++) if(!islower(s[i])) cnt++;
    if(cnt > 1) flg = false;

    if(flg) cout << "AC" << endl;
    else cout << "WA" << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;

  for (int i = 0; i < W + 2; i++) cout << '#';
  cout << endl;

  for (int i = 0; i < H; i++) {
    string a;
    cin >> a;
    cout << '#' << a << '#' << endl;
  }

  for (int i = 0; i < W + 2; i++) cout << '#';
  cout << endl;
}

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 ans = 0;
		for(int i = 1;i < N+1;i += 2){
			int count = 0;
			for(int j = 1;j < i+1;j ++){
				if(i % j == 0){
					count++;
				}
			}
			if(count == 8){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

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


/*  
    
*/

void test_case(){
    int n; cin >> n;
    int x[n],y[n];
    for(int i =0; i <n;i++)
        cin >> x[i] >> y[i];
    int p[4][2];
    for(int i = 0; i < 4; i++){
        p[i][0] = x[0];
        p[i][1] = y[0];
    }
    
    
    
    for(int i = 1; i < n; i++){
        int u = x[i] , v = y[i];
        if( (-u - v)  > ( -p[0][0] - p[0][1]) ){
            p[0][0] = u;
            p[0][1] = v;
        }
        
        if( (-u + v)  > ( -p[1][0] + p[1][1] ) ){
            p[1][0] = u;
            p[1][1] = v;
        }
        
        if( (u - v)  > ( p[2][0] - p[2][1] ) ){
            p[2][0] = u;
            p[2][1] = v;
        }
        
        if( u + v > p[3][0] + p[3][1]){
            p[3][0] = u;
            p[3][1] = v;
        }
    
    
    }
    
    ll res = 0;
    for(int i = 0; i <4; i++){
        for(int j = 0; j < 4; j++){
            if(i != j)
                res = max(res, ll(abs(p[i][0]-p[j][0])) + ll(abs(p[i][1] -p[j][1] )) );
        }
    }
    
    cout << res << endl;
    
}

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

    int t; t = 1;
    //~ cin >> t;
    while(t--)
        test_case();
    return 0;
}


Measured memory_bytes: 5208
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

    int ans=10000;
    rep(i,n){
        int s1=0;
        int s2=0;
        for(int j=0;j<i;++j){
            s1+=w[j];
        }
        for(int j=i;j<n;++j){
            s2+=w[j];
        }
        ans=min(ans,abs(s1-s2));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3560
using System;

namespace ConsoleApp37
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            
            
            string[] arr = new string[n.Length];
            for (int i = 0; i < n.Length; i++)
            {
                arr[i] = n[i].ToString(); ;
            }
            int sum = 0;
            for(int i = 0; i < arr.Length; i++)
            {
                sum += int.Parse(arr[i]);
            }
            if (sum % 9 == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 34392
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int> A(N);
    rep(n,0,N) cin>>A.at(n);

    vector<char> ope;
    vector<int> price;

    int s=0,e=0;
    rep(n,1,N){
        if(A.at(n)<A.at(n-1)){
            if(n-1==s) s=n;
            else{
                e=n-1;
                ope.push_back('b');
                price.push_back(A.at(s));
                ope.push_back('s');
                price.push_back(A.at(e));
                s=n;
            }
        }
        else if(n==N-1 && A.at(n)>A.at(s)){
                e=n;
                ope.push_back('b');
                price.push_back(A.at(s));
                ope.push_back('s');
                price.push_back(A.at(e));
                s=n;
        }
    }

    int64_t ans=1000;
    int64_t kabu=0;
    rep(i,0,ope.size()){
        char o=ope.at(i);
        if(o=='s'){
            ans+=kabu*price.at(i);
            kabu=0;
        }else if(o=='b'){
            kabu+=ans/price.at(i);
            ans-=ans/price.at(i)*price.at(i);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3536
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

string nisin(ll r){
	string ret = "";
	while(r > 0){
		if(r % 2 == 0){
			ret = "0" + ret;
		}else{
			ret = "1" + ret;
		}
		r /= 2;
	}
	return ret;
}

int main(void){
	ll l_,r_;
	cin>>l_>>r_;
	string l = nisin(l_);
	string r = nisin(r_);

	int fl = r.size() - l.size();
	int fr = 0;
	while(l.size() < r.size()){
		l = "0" + l;
	}
	/*cout<<"l: "<<l<<endl;
	cout<<"r: "<<r<<endl;
	cout<<fl<<endl;*/

	ll dp[4][2];
	rep(i,4){
		rep(j,2){
			dp[i][j] = 0;
		}
	}
	rep(i,r.size()){
		rep(j,4){
			dp[j][1] = 0;
		}
		if(fl == i && fr == i){
			dp[3][1] = 1;
		}else if(fl == i && fr != i){
			dp[2][1] = 1;
		}else if(fl != i && fr == i){
			dp[1][1] = 1;
		}else if(i < fl){
			dp[0][1] = 1;
		}

		dp[0][1] += dp[0][0] * 3;
		if(r[i] == '1'){
			dp[0][1] += dp[1][0];
		}
		if(l[i] == '0'){
			dp[0][1] += dp[2][0];
		}

		if(r[i] == '0'){
			dp[1][1] += dp[1][0];
		}
		if(r[i] == '1'){
			dp[1][1] += dp[1][0] * 2;
		}
		if(l[i] == '0' && r[i] == '1'){
			dp[1][1] += dp[3][0];
		}

		if(l[i] == '0'){
			dp[2][1] += dp[2][0] * 2;
		}
		if(l[i] == '1'){
			dp[2][1] += dp[2][0];
		}
		if(l[i] == '0' && r[i] == '1'){
			dp[2][1] += dp[3][0];
		}

		if(l[i] == '0' || r[i] == '1'){
			dp[3][1] += dp[3][0];
		}

		rep(j,4){
			dp[j][0] = dp[j][1] % MOD;
			//cout<<dp[j][0]<<" ";
		}
		//cout<<endl;
	}
	ll ans = 0;
	rep(i,4){
		ans += dp[i][0];
	}
	ans %= MOD;
	cout<<ans<<endl;
	return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
  int n;
  cin >> n;
  char s[n];
  rep(i,n)
  {
    cin >> s[i];
  }
  if (n % 2 == 1)
  {
    cout << "No";
    return 0;
  }
  int u = n / 2;
  rep(i,u)
  {
    if(s[i] != s[i + u])
    {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
n = int(input())
nn = [i for i in range(1, n+1) if i%2==1]
ans = 0
for i in range(1, n+1, 2):
    cnt = []
    t = 0
    for j in nn[:-2]:
        for k in nn[1:]:
            if j*k==i: cnt.extend([j, k])
    if len(set(cnt))==8:
        ans+=1
        
print(ans)


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int n, m, x;
    cin >> n >> m >> x;

    vector< int > cs(n);
    auto as = make_vector(n, m, 0);
    range(i, 0, n) {
        cin >> cs[i];
        range(j, 0, m) {
            cin >> as[i][j];
        }
    }

    int ans = inf;
    range(bit, 0, (1 << n)) {
        vector< int > sums(m);
        int mon = 0;
        range(i, 0, n) {
            if ((bit & (1 << i)) == 0) continue;
            mon += cs[i];
            range(j, 0, m) {
                sums[j] += as[i][j];
            }
        }

        bool check = true;
        range(j, 0, m) {
            if (sums[j] < x) check = false;
        }

        if (check) chmin(ans, mon);
    }

    if (ans == inf) ans = -1;
    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3656
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	String S;
	int result;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		S = in.readLine();
	}

	void calc() {
		if (S.equals("SUN")) {
			result = 7;
		} else if (S.equals("MON")) {
			result = 6;
		} else if (S.equals("TUE")) {
			result = 5;
		} else if (S.equals("WED")) {
			result = 4;
		} else if (S.equals("THU")) {
			result = 3;
		} else if (S.equals("FRI")) {
			result = 2;
		} else if (S.equals("SAT")) {
			result = 1;
		}
	}

	void showResult() {
		System.out.println(result);
	}
}


Measured memory_bytes: 22996
from collections import deque

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

G = [[[] for j in range(N)] for i in range(2)]
check = [[0 for l in range(N)] for k in range(2)]


def bfs(s, cnt, mode):
    q = deque()
    q.append(s)
    check[mode][s] = cnt

    while len(q) != 0:
        u = q.popleft()
        for i in G[mode][u]:
            if check[mode][i] == 0:
                q.append(i)
                check[mode][i] = cnt


def main():
    for i in range(K):
        p, q = map(int, input().split())
        G[0][p-1].append(q-1)
        G[0][q-1].append(p-1)
    for i in range(L):
        r, s = map(int, input().split())
        G[1][r-1].append(s-1)
        G[1][s-1].append(r-1)

    cnt = 1
    for i in range(N):
        if check[0][i] == 0:
            bfs(i, cnt, 0)
            cnt += 1

    cnt = 1
    for i in range(N):
        if check[1][i] == 0:
            bfs(i, cnt, 1)
            cnt += 1

    groups = {}
    for i in range(N):
        a, b = check[0][i], check[1][i]
        groups[(a, b)] = groups.get((a, b), 0) + 1

    nums = []
    for i in range(N):
        a, b = check[0][i], check[1][i]
        nums.append(str(groups[(a, b)]))

    print(" ".join(nums))


if __name__ == '__main__':
    main()


Measured memory_bytes: 97056
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    long long N;
    cin >> N;
    string S;
    while(N > 0){
        N--;
        int a = N % 26;
        S += 'a' + a;
        N -= a;
        N /= 26;
    }
    reverse(S.begin(), S.end());
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<long long> A(N), B(N), C(N);
    rep (i, 0, N) cin >> A[i];
    rep (i, 0, N) cin >> B[i];
    rep (i, 0, N) cin >> C[i];

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

    long ans = 0;
    rep (i, 0, N) {  // B固定
        // 配列Aの要素において、値がB[i]未満の要素の数を計算する
        auto iter_a = lower_bound(A.begin(), A.end(), B[i]);
        long num_a = iter_a - A.begin();

        // 配列Cの要素において、値がB[i]より大きい要素の数を計算する
        auto iter_c = upper_bound(C.begin(), C.end(), B[i]);
        int num_c = C.end() - iter_c;

        ans += num_a * num_c;
    }

    cout << ans << endl;
}

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


int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    N = S.length();
    int totalWhite = 0;
    int totalBlack = 0;
    int black[N];
    int white[N];
    rep(i, N) {
        if (S[i] == '#') {
            totalBlack++;
        } else {
            totalWhite++;
        }
        black[i] = totalBlack;
        white[i] = totalWhite;
    }

    int ans = INT_MAX;
    rep(i, N) {
        if (i == N - 1 || S[i] != S[i + 1]) {
            int leftBlack = black[i];
            int leftWhite = white[i];
            int rightBlack = totalBlack - black[i];
            int rightWhite = totalWhite - white[i];
            //全部白にするときの数
            int allWhite = leftBlack + rightBlack;
            //左を白、みぎを黒にするときの数
            int turn = leftBlack + rightWhite;
            //全部黒にする
            int allBlack = leftWhite + rightWhite;
            
            ans = min(ans, allWhite);
            ans = min(ans, allBlack);
            ans = min(ans, turn);
        }
    }
    if (ans == INT_MAX) {
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2180
def resolve():
    def Dijkstra(s, n, edge, inf=float("inf")):
        import heapq
        d = [inf] * n
        used = [False] * n
        d[s] = 0
        used[s] = True
        queue = []
        path = [-9999] * n
        for e in edge[s]:
            heapq.heappush(queue, e + [s])
        while len(queue):
            dist, point, before = heapq.heappop(queue)
            if used[point]:
                continue
            d[point] = dist
            used[point] = True
            path[point] = before
            for nextdist, nextp in edge[point]:
                if not used[nextp]:
                    heapq.heappush(queue, [dist + nextdist, nextp, point])
        return d, path
    n, m = map(int, input().split())
    inf = 10 ** 10
    edge = [[] for _ in range(n)]
    for _ in range(m):
        x, y = [int(x) - 1 for x in input().split()]
        edge[x].append([1, y])
        edge[y].append([1, x])
    l, p = Dijkstra(0, n, edge, inf)
    if min(p[1:]) < -1:
        print("No")
    else:
        print("Yes")
        for i in p[1:]:
            print(i + 1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 156936
import sys

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    inp = sys.stdin.readlines()
    lis = set()
    for i in range(n):
        com = inp[i].split()
        if com[0] == "insert":
            lis.add(com[1])
        elif com[1] in lis:
            print("yes")
        else:
            print("no")

Measured memory_bytes: 108248
#include <bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

using namespace std;


int32_t main(){IOS;
	int a , b ;
	cin >> a >> b;
	cout << (a*b)/(__gcd(a,b)) << endl;
	return 0;
}


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

/*----------------------------- DEFINES ------------------------------*/

#define eps 1e-9
#define mod 1000000007
#define ump unordered_map // operations take less time compared to map
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define mp make_pair
#define ps(x) push(x) // for stack and queue
#define T top() //  for stack
#define FR front()// for queue
#define BA back()// for queue
#define PP pop()// for queue and stack
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define MAE max_element
#define MIE min_element
#define cnt(x) count(x)
#define lb(x) lower_bound(x) // returns an it ptng to the element >=x if no such returns end
#define ub(x) upper_bound(x) // returns an it ptng to the element >x if no such returns end
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define reps(i,x,y,k) for(int i=x;i<y;i+=k)
#define sper(i,x,y,k) for(int i=x;i>y;i-=k) 
#define all(x) ((x.B),(x.E))
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x) // easy method to iterate through a ds
#define sq(a) (a)*(a)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)// compute fib(n) in O(1)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}// fast i/o
#define dig(n) (int)(log10(n)+1) // num of digits
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define f(x) find(x)
#define set(x,k) memset(x,k,sizeof x)

/*------------------------------ TYPEDEFS-----------------------------*/

typedef long long ll;
typedef long double ld;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef ump<int,int> umpii;

/*-----------------------------START FROM HERE -----------------------*/

int main(){
	FIO
	
	int n,s=0;cin>>n;
	int a[n];rep(i,0,n){cin>>a[i];s+=a[i];}
	int res=1e9;
	rep(i,-100,101){
		int cur=0;
		rep(j,0,n)cur+=((a[j]-i)*(a[j]-i));
		res=min(res,cur);
	}
	cout<<res;
	return 0;
}


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

int main()
{
    int a, b;
    string op;

    while ((cin >> a >> op >> b), op != "?") {
        cout << (op == "+" ? a + b :
                 op == "-" ? a - b :
                 op == "*" ? a * b :
                 a / b) << endl;
    }

    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    ll x[n], y[n], h[n], idx;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] > 0) idx = i;
    }
  //little bit o confusing statement
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            ll t = h[idx] + abs(x[idx] - i) + abs(y[idx] - j);
            bool flag = true;
            for (int k = 0; k < n; k++) {
                int tmp = t - abs(x[k] - i) - abs(y[k] - j);
                tmp = max(tmp, 0);
                if (h[k] != tmp) flag = false;
            }
            if (flag) {
                cout << i << ' ' << j << ' ' << t << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
/*
半径 r の円の面積と円周の長さを求めるプログラムを作成して下さい。
 */

#include <stdio.h>

int main(void)
{
    double radius;
    double area, circumference, pi;

    pi = 3.141592653589;
    scanf("%lf", &radius);

    area = radius * radius * pi;
    circumference = (radius + radius) * pi;
    
    printf("%.8lf %.8lf\n", area, circumference);
    return (0);
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 2;

void solve() {
    ll k; string s;
    cin >> k >> s;
    string ans = s;
    if(s.size() > k){
        ans = s.substr(0, k) + "...";
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n;
  string w;
  char cur;
  map<string, int> mp;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> w;
    if(i == 0) cur = w[w.size()-1];
    else if(mp[w] == 1 || cur != w[0]){
      cout << "No" << endl;
      return 0;
    }
    mp[w]++; cur = w[w.size()-1];
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;

#define abs(a) ((a) < (0)? -(a):(a))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define pb push_back

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  bool same(int x, int y) {
      return find(x) == find(y);
  }
  int size(int x) {
    return -data[find(x)];
  }
};

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<pii> ab;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        ab.pb({a-1, b-1});
    }
    
    vector<ll> ans = {(ll)n*(n-1)/2};
    UnionFind uf(n);
    for(int i=ab.size()-1; i>0; i--) {
        int a = ab[i].first, b=ab[i].second;
        if(!uf.same(a, b)) {
            ans.pb(ans.back()-(ll)uf.size(a)*uf.size(b));
            uf.unite(a, b);
        } else {
            ans.pb(ans.back());
        }
    }
    
    for(int i=ans.size()-1; i>=0; i--) cout << ans[i] << endl;
}

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<vector<int>> a(n, vector<int>(n));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }

    using ll = long long;
    const ll mod = 1000000007;

    vector<vector<ll>> dp(n + 1, vector<ll>(1 << n));

    dp[0][0] = 1;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < (1 << n); j++) {
            if (dp[i][j] == 0) {
                continue;
            }

            for (int k = 0; k < n; k++) {
                if (a[i][k] && !(j >> k & 1)) {
                    dp[i + 1][j | (1 << k)] += dp[i][j];

                    if (dp[i + 1][j | (1 << k)] >= mod) {
                        dp[i + 1][j | (1 << k)] -= mod;
                    }
                }
            }
        }
    }

    cout << dp[n][(1 << n) - 1] << endl;
}


Measured memory_bytes: 377216
n = int(input())
diff_min = pow(10, 12)
for a in range(1, n + 1):
    if n % a == 0:
        b = n // a
        diff = a + b - 2
        diff_min = min(diff_min, diff)
    if a * a > n:
        break
print(diff_min)

Measured memory_bytes: 63680
#include<iostream>
#include<cstdlib>
using namespace std;

struct node{
	int num;
	node* next;
	node* prev;
};

int main(){
	 ios::sync_with_stdio(false);


	int order_num;
	char order[10];
	int val;
	node* p = (node*)malloc(sizeof(node));
	node* origin = p;
	origin->next = NULL;
	origin->prev = NULL;
	origin->num = 0;
	cin >> order_num;
	const int test = order_num;

	for(int i = 0; i < test; i++){
		cin >> order;
		//cout << i << "/" << test << ":" << order << endl;
		if(order[0] == 'i'){
			cin >> val;
			p->num = val;
			p->next = (node*)malloc(sizeof(node)); 
			p->next->prev = p;
			p->next->next = NULL;
			p->next->num = 0;
			p = p->next;
		}else if(order[6] == 'F'){
			if(p->prev == origin){
				free(origin);
				origin = p;
				p->prev = NULL;
			}else{
				p->prev = p->prev->prev;
				free(p->prev->next);
				p->prev->next = p;
			}
		}else if(order[6] == 'L'){
			origin = origin->next;
			free(origin->prev);
			origin->prev = NULL;
		}else{
			cin >> val;
			node* p2 = p;
			do{
				p2 = p2->prev;
				if(p2->num == val){
					if(p2->prev == NULL){
						origin = origin->next;
						free(origin->prev);
						origin -> prev = NULL;
					}else{
						p2->next->prev = p2->prev;
						p2->prev->next = p2->next;
						free(p2);
					}
					break;
				}
			}while(p2->prev != NULL);
		}

		
	
	}


	if(p != origin){
		p = p->prev;
		while(p->prev != NULL){
			free(p->next);
			cout << p->num << " ";
			p = p->prev;
		}
		cout << p->num << endl;
	}
	free(p);
	
	return 0;
}

Measured memory_bytes: 32460
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
#define rep(x, a, b) for(int x = (a); x <= (b); ++x)
#define rop(x, a, b) for(int x = (a); x < (b); ++x)
#define per(x, a, b) for(int x = (a); x >= (b); --x)
using namespace std;
typedef long long LL;
typedef double DB;
int a[100005], pr[100005], sf[100005];
int n;
int dfs() {
	LL K = 0;
	rep(i, 1, n) K += a[i] - 1;
	if(K & 1) return 1;
	rep(i, 1, n) pr[i] = __gcd(pr[i - 1], a[i]);
	per(i, n, 1) sf[i] = __gcd(sf[i + 1], a[i]);
	rep(i, 1, n) {
		if(a[i] == 1) continue;
		K = __gcd(__gcd(pr[i - 1], sf[i + 1]), a[i] - 1);
		if(K != 1) {
			--a[i];
			rep(j, 1, n) a[j] /= K; 
			int bj = dfs();
			rep(j, 1, n) a[j] *= K;
			++a[i];
			return bj ^ 1;
		}
	}
	return 0;
}
signed main() {
	scanf("%lld", &n);
	rep(i, 1, n) {
		scanf("%lld", &a[i]);
	}
	if(n == 1) puts(a[1] == 1 ? "Second" : "First");
	else if(n == 2) puts("First");
	else puts(dfs() ? "First" : "Second");
	return 0;
}


Measured memory_bytes: 2688
H,W = map(int,input().split())
s = ['' for i in range(H)]
white = H*W
black = 0
for i in range(H):
    s[i] = input()
    black += s[i].count('#')
white -= black
direction = [[1,0],[0,1],[-1,0],[0,-1]]
q = [[0,0,0]]

mass = [[-1 for i in range(W)] for j in range(H)]
while len(q) > 0:
    tmp = [y,x,d] = q.pop(0)
    if mass[y][x] >= 0: 
        continue
    mass[y][x] = d
    for [dy,dx] in direction:
        ny = y + dy
        nx = x + dx
        if 0 <= ny and ny < H and 0 <= nx and nx < W:
            if s[ny][nx] == '#' or mass[ny][nx] >= 0:
                continue
            q.append([ny,nx,d+1])
# for i in mass:
#     print(i)
if mass[H-1][W-1] < 0:
    print(-1)
else:
    print(white - mass[H-1][W-1] - 1)

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


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

    if(n<1000){
        //printf("ABC%03d\n", n);
        puts("ABC");
    }else{
        //printf("ABD%03d\n", n-999);
        puts("ABD");
    }

	return 0;
}


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

int main() {
  int a, b, k;
  scanf("%d %d %d", &a, &b, &k);

  int c = 0;
  for (int i = min(a, b); i > 0; i--)
    if (a % i == 0 && b % i == 0)
      if (++c == k) {
        printf("%d\n", i);
      }

  return 0;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}


int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    
    int a, b;
    cin >> a >> b;
    if (a > b)
        swap(a, b);
    if (a == 1)
        cout << (b == 2 ? 3 : 2) << '\n';
    else if (a == 2)
        cout << (b == 1 ? 3 : 1) << '\n';
    else
        cout << (b == 3 ? 2 : 1) << '\n';


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
// #include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define RFOR(i, j, k) for(int i=j ; i>=k ; i--)
#define REP(i, j) FOR(i, 0, j)
#define RREP(i, j) RFOR(i, j, 0)
#define PI 3.1415926535897932384626433832795
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    ll N, A, B; cin >> N >> A >> B;
    vector<ll> x(N);
    REP(i, N) cin >> x[i];

    ll res = 0;
    REP(i, N-1) {
        res += min(B, (x[i+1]-x[i]) * A);
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 1024
//
// Created by yamunaku on 2019/11/26.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n, k;
    cin >> n >> k;
    vl a(n + 1, 0);
    rep(i, n) cin >> a[i + 1];
    rep(i, n) a[i + 1] += a[i];
    map<int, set<int>> mp;
    rep(i, n + 1){
        a[i] = (a[i] - i + k) % k;
        mp[a[i]].insert(i);
    }
    ll ans = 0;
    for(auto &st:mp){
        queue<int> q;
        for(auto &x:st.second){
            while(!q.empty()){
                if(x - q.front() < k) break;
                q.pop();
            }
            ans += q.size();
            q.push(x);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 32000
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin>>s;

    int t=s.size()-1;
    bool judge=true;
 
    if(s.substr(0,t/2)==s.substr(t/2+1)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
#include <functional>
#include <queue>
using namespace std;

string t;
int n;
bool incr(string& s)
{
    int i = n - 1;
    while (i > 0 && s[i] > t[i - 1])
        --i;
    if (i == 0)
        return false;
    ++s[i];
    t[i] = max(s[i], t[i]);
    for (int j = i + 1; j < n; ++j) {
        t[j] = t[j - 1];
        s[j] = 'a';
    }
    return true;
}

signed main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        std::ios_base::sync_with_stdio(false);
        std::cin.tie(NULL);
        std::cout.tie(NULL);
    }

    cin >> n;
    string s(n, 'a');
    t.resize(n, 'a');
    cout << s << '\n';
    while (incr(s)) {
        cout << s << '\n';
    }
    return 0;
}

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

vector <ll> adj[100001];
ll dp[100001];
bool visited[100001];

void dfs(ll src)
{
	visited[src]=true;
	for(auto a:adj[src])
	{
		if(visited[a]==false)
		{
			dfs(a);
		}
		dp[src] = max(dp[src],1+dp[a]);
	}
}

int main()
{
    
        
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    

    ll n,m,i,j;
    cin>>n>>m;
    char grid[n][m];
    for(i=0;i<n;i++)
    {
    	for(j=0;j<m;j++)
    	{
    		cin>>grid[i][j];
    	}
    }
    ll dp[n][m];
    dp[0][0] = 0;
    int flag=0;
    for(i=1;i<n;i++)
    {
    	if(grid[i][0] == '.' && flag==0)
    		dp[i][0]=1;
    	else
    	{
    		dp[i][0]=0;
    		flag=1;
    	}
    }
    flag=0;
    for(i=1;i<m;i++)
    {
    	if(grid[0][i] == '.' && flag==0)
    		dp[0][i]=1;
    	else
    	{
    		flag=1;
    		dp[0][i]=0;	
    	}
    }
    for(i=1;i<n;i++)
    {
    	for(j=1;j<m;j++)
    	{
    		if(grid[i][j]=='.')
    		{
    			dp[i][j] = (dp[i-1][j]%MOD + dp[i][j-1]%MOD)%MOD;
    		}
    		else
    			dp[i][j] = 0;
    	}
    }
    
    cout<<dp[n-1][m-1]<<endl;
    return 0;
}

Measured memory_bytes: 11392
// IlyM

#include <bits/stdc++.h>
#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (int a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
int n,a[4];
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if (a[0]==5 && a[1]==a[0] && a[2]==7) cout<<"YES";
	else cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [int(input()) for i in range(N)]
max = sum(S)
semi_max = max
i = 0
while True:
	if semi_max % 10 != 0:
		print(semi_max)
		exit()
	else:
		S.sort()
		semi_max = max - S[i]
		i += 1
		if i == len(S):
			print(0)
			exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<ll, ll>;

// chmin, chmax関数

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

int main(){
    ll n,k;
    cin >> n >> k;
    vector<P> arr;
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        P p(a,b);
        arr.push_back(p);
    }

    sort(arr.begin(), arr.end());
    for(auto p : arr){
        ll a = p.first, b = p.second;
        k -= b;
        if(k <= 0){
            cout << a << endl;
            break;
        }
    }

    return 0;
}

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

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

    int N, X;
    cin >> N >> X;
    vector<int> x(N + 1);
    x[N] = X;
    for (int i = 0; i < N; i++) cin >> x[i];
    sort(x.begin(), x.end());
    int res = 0;
    for (int i = 1; i < x.size(); i++) {
        res = __gcd(x[i] - x[i - 1], res);
    }
    cout << res << endl;
}

Measured memory_bytes: 640
a = input().split(" ")
temp = a[0]
if a[0] > a[1]:
    temp = a[1]
    a[1] = a[0]
    a[0] = temp
if a[1] > a[2]:
    temp = a[2]
    a[2] = a[1]
    a[1] = temp
if a[0] > a[1]:
    temp = a[1]
    a[1] = a[0]
    a[0] = temp
print(str(a[0]) +" " + str(a[1]) + " " + str(a[2]))


Measured memory_bytes: 5560