akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 


#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
long long gcd(long long a,long long b) //最大公約数
{
    if(a%b==0)
    {
        return b;
    }
    else
    {
        return (gcd(b, a % b));
    }
}

long long lcm(long long a,long long b) //最小公倍数
{
    return a * b / gcd(a, b);
}

int main() 
{
    long long a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int N,K;cin>>N>>K;
    vector<int> V(N);
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    int max = 0;
    int sum = 0;
    vector<int> minus;
    for(int i=0;i<=min(N,K);i++){
        for(int j=0;j<=min(N-i,K-i);j++){
            sum = 0;
            minus.clear();
            for(int k=0;k<i;k++){
                sum += V[k];
                if(V[k]<0){
                    minus.push_back(V[k]);
                }
            }
            for(int k=0;k<j;k++){
                sum += V[(N-1)-k];
                if(V[(N-1)-k]<0){
                    minus.push_back(V[(N-1)-k]);
                }
            }
            sort(minus.begin(),minus.end(),greater<int>());
            if(minus.size()>0){
                for(int k=0;k<K-(i+j)&&minus.size()!=0;k++){
                    sum -= minus.back();
                    minus.pop_back();
                }
            }
            if(max<sum) max = sum;
        }
    }
    cout << max << endl;
}

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

int main(){
  int n;string s;cin>>n>>s;
  string x[4]={"SS","SW","WS","WW"};
  bool f=0;
  REP(i,4){
    string ans=x[i];
    for(int k=2;k<n+1;k++){
      if((s.at(k-1)=='o'&&ans.at(k-1)=='S')||(s.at(k-1)!='o'&&ans.at(k-1)!='S')){
        ans.push_back(ans.at(k-2));
      }else{
        if(ans.at(k-2)=='S') ans.push_back('W');
        else ans.push_back('S');
      }
    }
    if(ans.at(0)==ans.at(n)){
      if(ans.at(0)=='S'&&s.at(0)=='o'&&ans.at(n-1)==ans.at(1)) f=1;
      if(ans.at(0)=='S'&&s.at(0)=='x'&&ans.at(n-1)!=ans.at(1)) f=1;
      if(ans.at(0)=='W'&&s.at(0)=='o'&&ans.at(n-1)!=ans.at(1)) f=1;
      if(ans.at(0)=='W'&&s.at(0)=='x'&&ans.at(n-1)==ans.at(1)) f=1;
    }
    if(f){
      ans.pop_back();
      cout<<ans;
      return 0;
    }
  }
  cout<<("-1");
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;
#define ll long long

int main(){
	ios_base::sync_with_stdio(0);
	int a,b,n,W,w,val,T,cas=0;
	cin>>n>>W;
	vector<ll> dp(W+1);
	// max value in total weight
	for(int i=0;i<n;++i) {
		cin>>w>>val;
		for(int weight_already=W-w;weight_already>=0;--weight_already) {
			dp[weight_already+w] = max(dp[weight_already+w], dp[weight_already]+val);
		}
	}
	cout<<dp[W]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[200005];
int b[200005];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    int i;
    for (i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    sort(b,b+n);
    for (i=0;i<n;i++)
    {
        if (a[i]<=b[n/2-1])
        {
            printf("%d\n",b[n/2]);
        }
        else
        {
            printf("%d\n",b[n/2-1]);
        }
    }
    return 0;
} 


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

namespace AtCoderBC044 {
  class AtCoderBC044 {
    static void Main(string[] args) {
      new AtCoderBC044().solveB();
    }
    private void solveB() {
      string res = Console.ReadLine();
      int cnt = 0;
      for(int i=0; i<res.Length;i++){
        cnt = 0;
        foreach(char x in res){
          if(x == res[i])
            cnt++;
        }
        if (cnt % 2 != 0) {
          Console.WriteLine("No");
          return;
        }
      }      
      Console.WriteLine("Yes");
    }//end M.
  }
}


Measured memory_bytes: 2648
#include <iostream>
#include <vector>

using namespace std;

int pow2[18];

int main(){
    int N;
    cin >> N;
    pow2[0] = 1;
    for(int i = 1; i <= 17; i++){
        pow2[i] = pow2[i-1]*2;
    }
    int m;
    for(int i = 0; i <= 17; i++){
        if(N == pow2[i]){
            cout << "No" << endl;
            return 0;
        }
        if(pow2[i] > N){
            m = i;
            break;
        }
    }
    cout << "Yes" << endl;
    if(N == 3){
        for(int i = 1; i <= 5; i++){
            cout << i << ' ' << i+1 << endl;
        }
    }else if(N%2 == 0){
        vector<int> buf;
        buf.push_back(1);
        int tmp = N-pow2[m-1]+1;
        buf.push_back(tmp);
        for(int i = 2; i < pow2[m]; i++){
            if(i != tmp) buf.push_back(i);
        }
        for(int i = 0; i < pow2[m-1]-2; i++){
            cout << buf[i] << ' ' << buf[i+1] << endl;
        }
        cout <<  buf[pow2[m-1]-2] << ' ' << buf[0]+N << endl;
        for(int i = 0; i < pow2[m-1]-2; i++){
            cout << buf[i]+N << ' ' << buf[i+1]+N << endl;
        }
        for(int i = pow2[m-1]; i <= N-2; i+=2){
            cout << 1 << ' ' << i << endl;
            cout << i << ' ' << i+1 << endl;
            cout << 1 << ' ' << i+N+1 << endl;
            cout << i+N+1 << ' ' << i+N << endl;
        }
        cout << N << ' ' << pow2[m-1] << endl;
        cout << tmp << ' ' << 2*N << endl;
    }else{
        for(int i = 1; i <= pow2[m-1]-2; i++){
            cout << i << ' ' << i+1 << endl;
        }
        cout <<  pow2[m-1]-1 << ' ' << 1+N << endl;
        for(int i = 1; i <= pow2[m-1]-2; i++){
            cout << i+N << ' ' << i+N+1 << endl;
        }
        for(int i = pow2[m-1]; i <= N-1; i+=2){
            cout << 1 << ' ' << i << endl;
            cout << i << ' ' << i+1 << endl;
            cout << 1 << ' ' << i+N+1 << endl;
            cout << i+N+1 << ' ' << i+N << endl;
        }
    }
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S, T;
    cin >> S >> T;
    ll N = (ll)S.size();

    bool ok = S == T.substr(0, N);

    cout << (ok ? "Yes\n" : "No\n");
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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


int main(){
    string S;
    cin >> N >> S;
    vector<bool> check = vector<bool>(10, true);
    ll count =0;
    for(int i = 0; i< N-2 ; i++){
        int moji = S.at(i) - '0';
        if(check.at(moji)){
            check.at(moji) = false;
            //checkする
            vector<bool> check2 = vector<bool>(10, true);
            for(int j = i+1; j<N-1; j++){
                int moji2 = S.at(j) - '0';
                if (check2.at(moji2))
                {
                    check2.at(moji2) = false;
                    vector<bool> check3 = vector<bool>(10, true);
                    for(int k = j+1; k<N; k++){
                        int moji3 = S.at(k) - '0';
                        if(check3.at(moji3)){
                            check3.at(moji3) = false;
                            count++;
                            // cout << moji << moji2 << moji3 << endl;
                        }

                    }
                }
            }
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 256
N = gets.to_i
towns = N.times.map { gets.split.map(&:to_i) }

total_dist = 0

[*1..N].permutation(N) do |order|
  dist = 0
  list = order.map { |n| towns[n - 1] }
  cy, cx = list[0]

  list[1..-1].each do |y, x|
    dist += Math.sqrt((cy - y) ** 2 + (cx - x) ** 2)
    cy = y
    cx = x
  end

  total_dist += dist
end

puts total_dist / (1..N).inject(:*).to_f


Measured memory_bytes: 1916
/// Author: Sarfaraz Alam
# include <bits/stdc++.h>
# define pb push_back
# define ll long long

# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG
typedef unsigned long long int ull;
using namespace std;
#include<string>
#include<cmath>
const int N = 1e5 + 7;
const int mod = 1e9 + 7;


int main()
{
    speed;
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG

    //Code begins
    string str;
    cin>>str;



    int n = str.size();
    cout<<str[0]<<n-2<<str[n-1]<<endl;






    return 0;
}


Measured memory_bytes: 256
class UnionFind(object):
    def __init__(self, n=1):
        self.n=n
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
    def find(self, x): # xの属する連結成分の代表元(leader)
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y): # x,yを連結(merge)
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
    def same(self, x, y): # x,yが連結かどうか
        return self.find(x) == self.find(y)
    def size(self, x): # xと同じ連結成分のサイズ（ついでにUnionFind 1周）
        cnt=0
        parx=self.find(x)
        n=self.n
        for i in range(n):
            pari=self.find(i)
            if pari==parx:
                cnt+=1
        return cnt

import sys
input = sys.stdin.readline
n,q=map(int, input().split())
uf=UnionFind(n)
for i in range(q):
    t,u,v=map(int, input().split())
    if t==0:
        uf.union(u,v)
    elif uf.same(u,v):
        print(1)
    else:
        print(0)

Measured memory_bytes: 93948
#include <stdio.h>
#define ll long long
#define MOD 1000000007
#define bit(n,m)(((n)>>(m))&1)

ll a[300010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	
	ll ans=0;
	for(int b=0;b<60;b++){
		ll c[2]={};
		for(int i=0;i<n;i++)c[bit(a[i],b)]++;
		ans+=(1LL<<b)%MOD*(c[0]*c[1]%MOD)%MOD;
	}
	printf("%lld",ans%MOD);
}

Measured memory_bytes: 4012
import sys
input = sys.stdin.readline
from operator import itemgetter
import bisect

N,M=map(int,input().split())
AB=[tuple(map(int,input().split())) for i in range(N)]
LR=[tuple(map(int,input().split())) for i in range(M)]

AB.sort(key=itemgetter(0))

A=[a for a,b in AB]
B=[0]+[b for a,b in AB]+[0]

C=[]
for i in range(1,N+2):
    C.append(B[i]^B[i-1])

XY=[]
for l,r in LR:
    XY.append((bisect.bisect_left(A,l),bisect.bisect_right(A,r)))
    
E=[[] for i in range(N+1)]

for i in range(M):
    x,y=XY[i]
    if x==y:
        continue
    E[x].append((y,i+1))
    E[y].append((x,i+1))

BACK=[-1]*(N+1)
NUM=[-1]*(N+1)
ANS=[]
for i in range(N+1):
    if BACK[i]!=-1:
        continue

    Q=[i]
    SORT=[i]
    BACK[i]=0
    
    while Q:
        x=Q.pop()

        for to ,num in E[x]:
            if BACK[to]==-1:
                SORT.append(to)
                Q.append(to)
                BACK[to]=x
                NUM[to]=num

    for x in SORT[1:][::-1]:
        if C[x]==0:
            continue
        else:
            C[x]=0
            C[BACK[x]]^=1
            ANS.append(NUM[x])

if max(C)==1:
    print(-1)
else:
    print(len(ANS))
    print(*sorted(ANS))

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;

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

	ll i = n;
	
	vector<ll>v;
	ll ans = 1;
	while(i>0)
	{
		v.pb(i);
		i = i/2;
	}

	reverse(all(v));

	forn(i,1,(ll)(v.size()))
	{
		ans=ans*2+1;
	}


	cout<<ans;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    char a,b,N;
    int n,i;
    while(scanf("%c",&a)!=EOF){
        if(a=='@'){
            scanf(" %c %c",&N,&b);
            n=N-'0';
            for(i=0;i<n;i++){
                printf("%c",b);
            }
        }else{
        printf("%c",a);
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <complex>

using namespace std;

int main() {
	int n;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		complex<double> a(x1, y1), b(x2, y2), c(x3, y3), d(x4, y4);
		complex<double> n(a - b), m(c - d);
		complex<double> r(n.real()*m.imag() - m.real()*n.imag());

		if (abs(r - 0.0) < 1e-10) {
			cout << "YES";
		}
		else {
			cout << "NO";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
struct UnionFind{
  vector<int> par;
  UnionFind(int N):par(N){
    rep(i,N) par[i]=i;
  }
  int root(int x){
    if(par[x]==x) return x;
    return par[x]=root(par[x]);
  }
  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry) return;
    par[rx]=ry;
  }
  bool same(int x, int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
};
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> X(M),Y(M),Z(M);
  rep(i,M) cin>>X[i]>>Y[i]>>Z[i];
  UnionFind tree(N+1);
  rep(i,M) tree.unite(X[i],Y[i]);
  set<int> A;
  rep(i,N+1) A.insert(tree.root(i));
  cout<<A.size()-1<<endl;
}

Measured memory_bytes: 6400
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
long double binary_search(ll n, ll k, vector<ll> a){
    long double lb = 0, ub = a.back();
    long double mid = 1;
    ll cnt = 0;
    while(cnt <= 100){
        ll lim_cut = 0;
        bool flag = true;
        mid = (lb + ub) / 2;
        if(mid != 0) {
            rep(i, n) {
                lim_cut += (ll)(a[i] / mid);
            }
        }
        if(lim_cut > k) flag = 0;
        if(flag)ub = mid;
        else lb = mid;
        cnt += 1;
    }
    //cout << lb << ub << endl;
    return lb;
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,k;
cin >> n >> k;
vector<ll> a(n);
rep(i,n){
    cin >> a[i];
}
sort(a.begin(),a.end());
long double ans = binary_search(n,k,a);

cout << (ll)ceil(ans) << endl;
}

Measured memory_bytes: 6300
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */


int main() {
    int W,a,b;
    cin >> W >> a >> b;
    int ans = 1e7;

    if ((a-b <= W) and (b <= a+W)){
        PRINTD(0);
        return 0;
    }

    if (a+W < b){
        ans = b-a-W;
    }else{
        ans = a-b-W;
    }
    cout << ans << "\n";


}


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

int main(){
    int n,k,s,i,c,res;
    while(1){
        scanf("%d",&n);
        scanf("%d",&k);
        scanf("%d",&s);
        if(!n && !k && !s){break;}
        int t[n],cd[n];
        for(i=0;i<n;i++){cd[i]=i+1;t[i]=0;}
        for(i=0;i<k;i++){t[n-i-1]=1;}    
        res=0;
        do{
            c=0;
            for(i=0;i<n;i++){c+=(t[i]*cd[i]);}
            if(c==s){res++;}
        } while(next_permutation(t,t+n));
        printf("%d\n",res);
    }
    return 0;
}



Measured memory_bytes: 2696
def change_code(moji, num):
  new_code = ord(moji) + num
  if new_code > 90:
    new_code -= 26
  return chr(new_code)

n = int(input())
s = input()
s_num = []

for _ in range(len(s)):
  s_num.append(n)

change_s = map(change_code, s, s_num)
print(''.join(list(change_s)))


Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 //   freopen("input.txt","r",stdin);
 //   freopen("output.txt","w",stdout);
    
    int n;
    cin>>n;
    int mx = 0;
    int ans =0;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        if(t>=mx)
        {
            ans++;
            mx=  max(t,mx);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int r; cin >> r;
    int ans = r*r;
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    string ans;
    if (0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h) ans = "Yes";
    else ans = "No";

    cout << ans << endl;
}



Measured memory_bytes: 3224
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::LinkedList;

fn read_list() -> LinkedList<String> {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.split(' ').map(|x| x.to_string()).collect::<LinkedList<String>>()
}

fn pop_parse<T: std::str::FromStr>(list: &mut LinkedList<String>) -> T {
    list.pop_front().expect("").trim().parse::<T>().ok().unwrap()
}


fn main() {
    let modulo = 1e9 as i64 + 7;
    let mut n = read_list();
    let n: i64 = pop_parse(&mut n);
    let mut pow:i64 = 1;
    for i in 1..n+1 {
        pow = (pow * i) % modulo;
    }
    println!("{}", pow);
}


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

#define int ll
#define pb push_back
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

void max_self(int &a,int b)
{
    a = max(a,b);
}

int32_t main()
{
    IOS;
    int n;
    string s;
    cin>>n>>s;
    int ans = 0,val = 0;
    FOR(i,0,n)
    {
        if(s[i]=='D') val-=1;
        else val+=1;
        max_self(ans,val);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int grid[2000][2000] = {};
long long memorize[2000][2000] = {};
int main() {
#define int long long
	int h, w;
	cin >> h >> w;
	REP(i, h) {
		REP(q, w) {
			cin >> grid[i][q];
		}
	}
	for (int i = 0;i < w;++i) {
		int cnt = 0;
		for (int q = 0;q < h;++q) {
			cnt++;
			if (grid[q][i] == 1) cnt = 0;
			memorize[q][i] = cnt;
		}
	}
	long long ans = 0;
	for (int i = 0;i < h;++i) {
		stack<pair<int, int>> wow;
		for (int q = 0;q <= w;++q) {
			if (wow.empty() == true || wow.top().first < memorize[i][q]) {
				wow.push(make_pair(memorize[i][q], q));
			}
			else {
				int itring = q;
				while (wow.empty() == false && wow.top().first > memorize[i][q]) {
					ans = max(ans, min((q - wow.top().second),wow.top().first)*min((q - wow.top().second), wow.top().first));
					itring = min(itring, wow.top().second);
					wow.pop();
				}
				wow.push(make_pair(memorize[i][q], itring));
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 34820
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define mp make_pair
using namespace std;
int ok[1000000];
int main()
{
    ll x;
    cin>>x;
    ok[1] = 1;
    for(int i=2;i<1000000;i++)
    {
        if(ok[i] == 0)
        for(int j=i*2;j<1000000;j+=i)
        {
            ok[j] = 1;
        }
    }
    while(ok[x] == 1)
    {
        x++;
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
 
#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)
 
int main() {
	string N;
	cin >> N;
	if (N[0] == '7' || N[1] == '7' || N[2] == '7') {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
@ExperimentalStdlibApi
fun main(args: Array<String>) = abc163d()

@ExperimentalStdlibApi
fun abc163d() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }

    val list = (0L..n).toList()
    val cSum = list.scan(0L, Long::plus)

    val map = (k..n + 1).map { (cSum.last() - cSum[cSum.lastIndex - it]) - cSum[it] + 1 }
    val answer = map.fold(0L) { acc, l -> (acc + l) % MOD }

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()


Measured memory_bytes: 59244
#include <stdio.h>
int main(void){
    // Your code here!
    int in;
    int h,m,s;
    scanf("%d",&in);
    
    h=in/3600;
    in%=3600;
    
    m=in/60;
    in%=60;
    
    s=in;
    
    printf("%d:%d:%d\n",h,m,s);
    
}



Measured memory_bytes: 2100
n = int(input())
a = list(map(int, input().split()))


def countingsort(a, k):
    c = [0 for i in range(k+1)]
    b = [0 for i in range(n)]

    for j in range(n):
        c[a[j]] += 1

    for i in range(k):
        c[i+1] += c[i]

    for j in reversed(range(n)):
        b[c[a[j]]-1] = a[j]
        c[a[j]] -= 1

    return b

b = countingsort(a, 10000)
print(*b)



Measured memory_bytes: 224388
from collections import deque
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B] = [int(input_raw[0]), int(input_raw[1])]
    

    if A <= 8 and B <= 8:
        print 'Yay!'
    else:
        print ':('


if __name__ == '__main__':
    main()


Measured memory_bytes: 2812
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            scanf("%d", &v[i][j]);
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n; ++j) {
            ans += min(v[i][j], v[j][i]);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3280
def ac(S):
    if S[0] != "A":
        return False
    C = S.find("C")
    if C <= 1 or C == len(S)-1:
        return False
    for c in (S[1:C] + S[C+1:]):
        if c.isupper():
            return False
    return True


def main():
    S = input()
    if ac(S):
        print("AC")
    else:
        print("WA")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

char a[10][5]={
	{},
	{'.',',','!','?',' '},
	{'a','b','c'},
	{'d','e','f'},
	{'g','h','i'},
	{'j','k','l'},
	{'m','n','o'},
	{'p','q','r','s'},
	{'t','u','v'},
	{'w','x','y','z'}
};
int c[10]={0,5,3,3,3,3,3,4,3,4};

char in[1100],out[99];
int main(){
	ll q;
	scanf("%lld",&q);
	while(q--){
		scanf("%s",in);
		ll n=strlen(in);
		int outlen=0;
		int cnt=0;
		rep(i,0,n){
			if(in[i]==in[i+1])cnt++;
			else{
				int ch=in[i]-'0';
				if(ch)out[outlen++]=a[ch][cnt%c[ch]];
				cnt=0;
			}
		}
		out[outlen]=0;
		puts(out);
	}
}


Measured memory_bytes: 2104
#pragma GCC optimize("O3")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define meme(a,v)    memset((a), (v), sizeof (a))
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define anal         '\n'
#define mod 1000000007
//const double PI = acos(-1.0);
typedef long long ll;


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  

int main(){
I_AM_SPEED;


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
       
     int x, y;
     cin >> x >> y;

      int minl = 2*x, maxl = 4*x;
      if(y < minl || maxl < y || (y & 1)){
        cout << "No";
        return 0;
      }
       
     if( (y/2 - x) >= 0){
         cout << "Yes";
     }
     else{
       cout << "No";
     }
  



      
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

return  0 ;      
}        





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


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

  vector<int> data(N);

  for (int i = 0;i < N ; i++){
   cin >> data.at(i); 
  }
  
  int ref=0;
  
  for(int i = 0 ;i < N-1; i++){
   for(int j = i+1 ;j < N; j++){
     ref += data.at(i)*data.at(j);
//       cout << ref << ":" << data.at(i)*data.at(j) << endl;
   }
  }
  
  cout << ref << endl;
}







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

int main() {
  int n, m;
  cin >> n >> m;
  if (n == 1) n = 14;
  if (m == 1) m = 14;
  if (n > m) cout << "Alice\n";
  else if (n < m) cout << "Bob\n";
  else cout << "Draw\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    int[] a = new int[n];
    for(int j = 0; j < n; j++)
      a[j] = sc.nextInt();
    
    for(int j= 0; j < n; j++){
        while(a[j] % 2 == 0){
          a[j] /= 2;
          count++;
        }
    }
    
    System.out.println(count);
  }
}

Measured memory_bytes: 33560
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <functional>
using namespace std;

typedef pair<int, int> P;

vector<P> edge[100000];
priority_queue<P, vector<P>, greater<P> > que;
int cost[100000];
int V, E, r;
const int INF = 999999999;


void dijkstra()
{
	for (int i = 0; i < 100000; i++)
	{
		cost[i] = INF;
	}

	cost[r] = 0;
	que.push(P(r, 0));

	while (!que.empty())
	{
		P now = que.top();
		que.pop();

		for (int i = 0; i < edge[now.first].size(); i++)
		{
			int to = edge[now.first][i].first;
			int c = now.second + edge[now.first][i].second;
			if (cost[to] > c)
			{
				cost[to] = c;
				que.push(P(to, c));
			}
		}
	}
}

int main()
{
	cin >> V >> E >> r;

	for (int i = 0; i < E; i++)
	{
		int from, to, d;
		cin >> from >> to >> d;
		edge[from].push_back(P(to, d));
	}

	dijkstra();

	for (int i = 0; i < V; i++)
	{
		if (cost[i] == INF)
		{
			cout << "INF" << endl;
			continue;
		}
		cout << cost[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 20380
import math

def main():
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        A[i] -= (i+1)
    
    A.sort()
    if N%2 == 0:
        b = (A[N//2] + A[N//2 - 1])/2
        bfl = math.floor(b)
        bce = math.ceil(b)
        ansfl = 0; ansce = 0
        for i in range(N):
            ansfl += abs(A[i] - bfl)
            ansce += abs(A[i] - bce)
        ans = min(ansfl, ansce)
    else:
        ans = 0
        b = A[N//2]
        for i in range(N):
            ans += abs(A[i] - b)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 31188
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

#define eb emplace_back
#define pb push_back
// #define mp make_pair
#define ff first
#define ss second

#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

void io(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);     
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <ext/rope>
// using namespace __gnu_pbds; 
// using namespace __gnu_cxx;
// template<typename T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
// template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T> >;
// template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}


template <typename A>
istream& operator>>(istream& input,vector<A>& x) { for(auto& i:x) input>>i; return input; }
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {  for(auto& i:x) output<<i<<' '; return output; }
template<typename T, typename U> 
istream& operator>>(istream& is, pair<T, U>& p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> 
ostream& operator<<(ostream& os, pair<T, U>& p){os << p.first << ' ' << p.second; return os;}

const int mod = 1e9 + 7;
const int N = 1e6 + 5;
//Beggar - C(n+r-1,r-1)
int fac[N],invf[N];
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x - y >= 0 ? x - y : x - y + mod; }
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}
void initcombi(int n) {
    for (int i = fac[0] = 1; i <= n; i++) { fac[i] = 1ll * fac[i - 1] * i % mod; }
    invf[n] = power(fac[n], mod - 2);
    for (int i = n; i; i--) { invf[i - 1] = 1ll * invf[i] * i % mod; }
}
 
inline int NCR(int n, int m) {
    if (n < m) { return 0; }
    return 1ll * fac[n] * invf[m] % mod * invf[n - m] % mod;
}


int main () {
    io();
    initcombi(500000);
    int n, m;
    cin >> n >> m;
    ll ans = fac[n];
    ans *= NCR(m, n);
    ans %= mod;
    debug(ans);
    ll ans2 = 0;
    for(int i = 0; i <= n; i++) {
        if(i % 2 == 0) {
            ll x = 1LL * NCR(n, i) * NCR(m - i, n - i);
            x %= mod;
            x *= fac[n - i];
            x %= mod;
            ans2 += x;
            ans2 %= mod;
            if(ans2 < 0)
                ans2 += mod;        
        
        }
        else {
            ll x = 1LL * NCR(n, i) * NCR(m - i, n - i);
            x %= mod;
            x *= fac[n - i];
            x %= mod;
            ans2 -= x;
            ans2 %= mod;
            if(ans2 < 0)
                ans2 += mod;        
        }
    }
    cout << (ans * ans2) % mod;
}

Measured memory_bytes: 7576
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,l=mp()
x=0
if l>0:
    x=l
elif l+n-1<0:
    x=l+n-1
print((l-1)*n+n*(n+1)//2-x)

Measured memory_bytes: 77460
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    vector<char>v(3);
    REP(i,3)cin>>v[i];
    sort(v.begin(),v.end());
    if(v[0]=='a'&&v[1]=='b'&&v[2]=='c')cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
ll n,k,ans;
vll a,b;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);

    cin >> n;
    a.resize(n);
    rep(i,n) cin >> a[i];

    ans = 0;
    bool before = false;
    rep(i,n) {
        if(!before && i+1==a[i]) {
            ans++;
            before = true;
        }else{
            before = false;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int n;
  	long long k;
	cin >> n >> k;
  	vector<long long> a(n);
  	rep(i, n) {
      	cin >> a[i];
    }
  	long long t = 0, now = 0;
  	if(k <= n*2) {
    	rep(i, k) {
       		now = a[now]-1;
        }
      	cout << now+1 << endl;
      	return 0;
    }
  	vector<bool> check(n);
  	vector<int> check2(n);
  	check[0] = true;
  	check2[0] = 0;
  	for(int i=1; i < n+4; i++) {
    	now = a[now]-1;
      	if(check[now] == true) {
        	t = i;
        	break; 
        }
      	check[now] = true;
      	check2[now] = i;
    }
  	k -= check2[now];
  	k %= max((int)(t - check2[now]), 1);
	rep(i, k) {
    	now = a[now]-1;
    }
  	cout << now+1 <<endl;
}


Measured memory_bytes: 5632
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Robot[] robots = input();
        Arrays.sort(robots);
        Robot pre = robots[0];
        int result = 1;
        for (int i = 1; i < robots.length; i++) {
            if (pre.rpos <= robots[i].lpos) {
                pre = robots[i];
                result++;
            } else if (pre.lpos <= robots[i].lpos && robots[i].rpos <= pre.rpos) {
                pre = robots[i];
            }
        }
        System.out.println(result);
    }

    static Robot[] input() {
        Scanner s = new Scanner(System.in);
        Robot[] robots = new Robot[Integer.parseInt(s.nextLine())];
        for (int i = 0; i < robots.length; i++) {
            robots[i] = new Robot(s.nextLine());
        }
        return robots;
    }

    static class Robot implements Comparable<Robot> {
        int x, lpos, rpos;
        Robot(String input) {
            String[] split = input.split(" ");
            x = Integer.parseInt(split[0]);
            int length = Integer.parseInt(split[1]);
            lpos = x - length;
            rpos = x + length;
        }
        public int compareTo(Robot robot) {
            if (x > robot.x) {
                return 1;
            } else if (x < robot.x) {
                return -1;
            }
            return 0;
        }
    }
}

Measured memory_bytes: 126264
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  ll ans = K * pow(K - 1, N - 1);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
      int a,b;
      cin>>a>>b;
      if(a-1>b) cout<<a*2-1<<endl;
      else if(b-1>a) cout<<b*2-1<<endl;
      else cout<<a+b<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll ans, n, a, b;
ll vv[111111];
ll cc[111111];

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>a>>b; int i;
	for(i=1 ; i<=n ; i++) cin>>vv[i];
	for(i=1 ; i<=n-1 ; i++) cc[i]=(vv[i+1]-vv[i])*a;
	ans=(vv[n]-vv[1])*a;
	for(i=1 ; i<=n-1 ; i++) if(cc[i]>b) ans+=b-cc[i];
	cout<<ans; return 0;
}


// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 1920
N, M = map(int, input().split())
A = list(map(int, input().split()))

B = set([a & (-a) for a in A])
if len(B) > 1:
    print(0)
    exit()

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

def lcm(x, y):
    return x * y // gcd(x, y)

A = [a // 2 for a in A]
LCM = A[0]
for a in A:
    LCM = lcm(LCM, a)

ans = ((M // LCM) + 1) // 2
print(ans)


Measured memory_bytes: 14244
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        int K = scanner.nextInt();
        SortedSet<String> ss = new TreeSet<>();
        int len = s.length();
        for(int i = 0; i < len; i++ ) {
            for(int j = i + 1; j <= i + 5 && j <= len; j++){
                String x = s.substring(i,j);
                ss.add(x);
            }
        }

        String[] result = ss.toArray(new String[ss.size()]);
        System.out.println(result[K - 1]);
    }
}


Measured memory_bytes: 24272
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MODD 1000000007
#define ll long long
using namespace std;


int main() {
    int N;
    cin>>N;
    
    
    
    // given x, (x*(x-1))/2
    
    ll x;
    for(x=1;;x++) {
        if ((x*(x-1))/2 >= N-x) {
            break;
        }
    }

    
    
    vector<int> ans;
    ans.push_back(x);
    
    N -= x;
    int prev = x;
    while(N > 0) {
        // min(prev-1,N);
        int next = min(prev-1,N);
        ans.push_back(next);
        N-=next;
        prev=next;
    }
    
    for(int j=ans.size()-1;j>=0;j--)
        printf("%d\n",ans[j]);
    
    
    
}

Measured memory_bytes: 384
//Resisotrs in Parallel
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    double data[]=new double[1000];

    for (int i=0;i<n;i++) {
      data[i]=sc.nextDouble();
    }

    /*for (int i=0;i<n;i++) {
      System.out.println(data[i]);
    }*/

    double oki=0;

    for (int i=0;i<n;i++) {
      oki=oki+(1.0/data[i]);
    }

    System.out.println(1.0/oki);

  }
}


Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
#include<string>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll v;cin>>v;vec.push_back(v);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
ll inv(ll a)
{
    ll p=mod2;
    ll b=p-2,ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll ncr(ll n,ll m)
{
    ll p=mod2;
    if(m > n)return 0;
    ll up=1,down=1;
    for(int i=n-m+1;i<n+1;i++)up*=i,up%=p;
    for(int i=1;i<m+1;i++)down*=i,down%=p;
    return up*inv(down)%p;
}

ll countDigit(ll n)
{   
    return floor(log10(n) + 1); 
}  
ll a_pow_b(ll a,ll b)
{
    ll p=1000000007;
    ll ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll gcd(ll a,ll b) 
{ 
    if (b==0) 
        return a; 
    return gcd(b,a%b);      
} 
ll lcm(ll a, ll b)  
{  
    return (a*b)/gcd(a, b);  
}
bool isPerfectSquare(ll x) 
{   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
}
ll ncr123(ll n, ll k){
    if (k == 1) {
        return n;
    }
    if (k == 2) {
        return n * (n - 1) / 2;
    }
    if (k == 3) {
        return n * (n - 1) * (n - 2) / 6;
    }
}
bool com(const pi &a,const pi &b)   //acc to second element sort for vec of pi
{ 
    if(a.second==b.second)
        return a.first<b.first;
    return a.second<b.second;
}



void solve(){

    ll n,k;
    cin>>n>>k;
    
    map<ll,ll> m;

    while(k--){
        ll d; cin>>d;
        while(d--){
            ll a; cin>>a;
            m[a]++;
        }
    }

    ll asn=0;
    loop(i,1,n+1){
        if(m.count(i)==0)
            asn++;
    }   

    cout<<asn;
        
    return ;
}
 
 
int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3664