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

const int N=1000005,P=998244353;
int n,m,fac[2*N],ifac[2*N];

int power(int a,int x){
	int ans=1;
	for(;x;x>>=1,a=1LL*a*a%P)if(x&1)ans=1LL*ans*a%P;
	return ans;
}
int binom(int n,int m){
	return n<m||m<0?0:1LL*fac[n]*ifac[m]%P*ifac[n-m]%P;
}

int main(){
	scanf("%d%d",&n,&m);
	int lim=3*m/2+n;
	for(int i=fac[0]=1;i<=lim;++i)fac[i]=1LL*fac[i-1]*i%P;
	ifac[lim]=power(fac[lim],P-2);
	for(int i=lim;i;--i)ifac[i-1]=1LL*ifac[i]*i%P;
	int ans=0;
	for(int i=m&1;i<=n&&i<=m;i+=2){
		int s=(3*m+2*n-i)/2;
		for(int a=0;a<=min(1,i)&&a*m<=s-n;++a)
			for(int b=0;b<=min(n-1,1)&&a*m+b*(m+1)<=s-n;++b)
				ans=(ans+((a^b)&1?-1LL:1LL)*binom(n,i)%P*binom(i,a)%P*binom(n-i,b)%P*binom(s-a*m-b*(m+1)-1,n-1))%P;
	}
	printf("%d\n",(ans+P)%P);
}


Measured memory_bytes: 14848
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn calc(w: usize, a: &[usize], b: &[usize]) -> usize {
    let n = a.len();
    let mut dp = vec![0; w + 1];
    for i in 0..n {
        for j in 0..w + 1 {
            if j + a[i] <= w {
                dp[j + a[i]] = max(dp[j + a[i]], dp[j] + b[i]);
            }
        }
    }
    let mut ma = 0;
    for i in 0..w + 1 {
        ma = max(ma, dp[i] + (w - i));
    }
    ma
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [usize; 3],
        b: [usize; 3],
    }
    let pa = calc(n, &a, &b);
    let ans = calc(pa, &b, &a);
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 205052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace dpsheet
{
    class Program
    {
        static void Main(string[] args)
        {
           string[] st1 = Console.ReadLine().Split(' ');
            int n = int.Parse(st1[0]);
            int kn= int.Parse(st1[1]); 
            int[] arr = new int[n];
            int[] temp = new int[n];
            string[] st = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                arr[i] = int.Parse(st[i]);
            for (int i = 0; i < n; i++)
                temp[i] = -1;
            Console.WriteLine(frog(arr, 0, n,kn, temp));

        }
        static int frog(int[] arr, int i, int n,int kn, int[] temp)

        {
            int m = int.MaxValue;
            if (temp[i] != -1)
                return temp[i];
            if (i == n - 1 || i == n)
                return temp[i] = 0;
            for (int j = i + 1; j <= i +kn && j < n; j++)
            {
                m = Math.Min(m, frog(arr, j, n,kn, temp) + Math.Abs(arr[i] - arr[j]));
            }
            temp[i] = m;
            return temp[i];
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
ll a[1<<18];
pll t2[1<<18][2];
ll ans[1<<18];

int main(){
  scanf("%d",&n);
  REP(i,1<<n)scanf("%lld",a+i);
  REP(i,1<<n)t2[i][0] = pll(a[i], i);
  REP(i,1<<n)t2[i][1] = pll(-1<<30, -1);
  FOR(i,0,1<<n){
    int id = i;
    // to parent
    REP(j,n)if(!((id>>j)&1)){
      int to = id | (1<<j);
      REP(k,2){
        pll val = t2[id][k];
        if(val.first < 0)continue;
        if(t2[to][0] == val)continue;
        if(t2[to][1] == val)continue;
        if(t2[to][0] < val){
          t2[to][1] = t2[to][0];
          t2[to][0] = val;
        }else if(t2[to][1] < val){
          t2[to][1] = val;
        }
      }
    }
  }
  ans[0] = -1<<30;
  FOR(i,1,1<<n){
    ans[i] = max(ans[i-1], t2[i][0].first + t2[i][1].first);
    printf("%lld\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int A[50];
	rep(i, N) cin >> A[i];

	int kotae = 0;
	rep(i, N) {
		for (int j = i + 1; j < N; j++) {
			swap(A[i], A[j]);

			int OK = 1;
			rep(k, N) {
				if (A[k] != k + 1) OK = 0;
			}
			if (OK) kotae = 1;

			swap(A[i], A[j]);

		}
	}

	int OK = 1;
	rep(k, N) {
		if (A[k] != k + 1) OK = 0;
	}
	if (OK) kotae = 1;

	if (kotae) co("YES");
	else co("NO");

	Would you please return 0;
}

Measured memory_bytes: 256
import sys
N, M = map(int, sys.stdin.readline().split())
a = [int(sys.stdin.readline()) for _ in range(M)]

MOD = 10 ** 9 + 7

list = [0] * N

if M > 0:
    j = 0
    for i in range(N):
        if i == 0:
            if a[j] == 1:
                list[i] = 0
            else:
                list[i] = 1
        elif i == 1:
            if a[j] == 2:
                list[i] = 0
            elif a[0] == 1:
                list[i] = 1
            else:
                list[i] = 2
        else:
            if a[j] == i + 1:
                list[i] = 0
            else:
                list[i] = (list[i - 1] + list[i - 2]) % MOD
        if i + 1 == a[j] and j < M - 1:
            j += 1

else:
    for i in range(N):
        if i == 0:
            list[i] = 1
        elif i == 1:
            list[i] = 2
        else:
            list[i] = (list[i - 1] + list[i - 2]) % MOD
            
ans = list[N - 1]
print(ans)

Measured memory_bytes: 7848
#include <stdio.h>

int main (void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if (a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else if(a==b){
		printf("a == b\n");
	}
	
	return(0);
}

Measured memory_bytes: 580
#include <set>
#include <map>
#include <iostream>
#include <cmath>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int main(){
  map<int, int> m;
  int n;
  cin >> n;
  REP(i,n){
    double tmp; cin >> tmp;
    int t = floor(tmp * 10 + 1e-10);
    m[max(1649, min(1850, t)) / 50]++;
  }
  REP(i,6){
    cout << i + 1 << ":";
    REP(j, m[(i + 1649 / 50)])
      cout << "*";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
A, B, C, X, Y = map(int, input().split())

price = 0

if A+B > 2*C:
    if X >= Y:
        price += 2*C*Y
        remain = X-Y
        if A >= 2*C:
            price += 2*C*remain
        else:
            price += A*remain
    else:
        price += 2*C*X
        remain = Y-X
        if B >= 2*C:
            price += 2*C*remain
        else:
            price += B*remain
else:
    if X >= Y:
        price += (A+B)*Y
        remain = X-Y
        if A >= 2*C:
            price += 2*C*remain
        else:
            price += A*remain
    else:
        price += (A+B)*X
        remain = Y-X
        if B >= 2*C:
            price += 2*C*remain
        else:
            price += B*remain

print(price)


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S[3];
	rep(i, 0, 3)
	{
		cin >> S[i];
		cout << S[i][i];
	}
	cout << endl;

	return 0;
}

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

int main() {
  char a, b;
  cin >> a >> b;
  if (a == 'H') {
    cout << b;
  } else {
    if (b == 'H') {
      cout << 'D';
    } else {
      cout << 'H';
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string.h>

using namespace std;

void swap(int* a, int* b)
{
	int t = *a;
	*a = *b;
	*b = t;
}

int partition(int array[], int l, int r) {
	int pivot = array[r];
	int i = (l - 1);

	for (int j = l; j <= r - 1; j++) {
		if (array[j] <= pivot) {
			i++;
			swap(&array[i], &array[j]);
		}
	}
	swap(&array[i + 1], &array[r]);
	return (i + 1);
}

void quickSort(int array[], int l, int r) {
	if (l < r) {
		int pivot = partition(array, l, r);
		quickSort(array, l, pivot - 1);
		quickSort(array, pivot + 1, r);
	}
}

int main() {
	int N, K;
	int p[1000];

	cin >> N >> K;

	for (int i = 0;i < N;i++) {
		cin >> p[i];
	}

	quickSort(p, 0, N - 1);

	int ans = 0;
	for (int i = 0;i < K;i++) {
		ans += p[i];
	}

	cout << ans << endl;

	return 0;
}

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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
#define endl "\n"

void testCase() {
	int n;
	cin >> n;
	int ans = 1;
	for (int i=0; i<n; i++) {
		int val;
		cin >> val;
		ans = (ans*val)/__gcd(ans, val);
	}
	cout << ans << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
constexpr uint64_t MOD =1000000007UL;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(void) {
    int N;
    int tmpa;
    int i;
    bool correct = true;
    int array_size;
    uint64_t ans = 1;

    cin >> N;

    if(N%2) array_size = N/2+1;
    else array_size = N/2;

    vector <int> A(array_size,0);

    for(i=0;i<N;i++){
        cin >> tmpa;
        if(N % 2) {
            if(tmpa % 2) {
                correct = false;
            } else {
                A[tmpa/2]++;
            }
        } else {
            if(tmpa%2) {
                A[tmpa/2]++;
            } else {
                correct = false;
            }
        }
    }

    if(N%2) {
        i = 1;
    } else {
        i = 0;
    }
    for(;i<array_size;i++) {
        if(A[i] != 2) {
            correct = false;
        }
    }

    if(!correct) {
        cout << "0\n";
    } else {
        if(N%2) {
            array_size -= 1;
        }

        ans = modpow(2,array_size, MOD);
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int main(void)
{
	int a, b, c;
	char op;
	while(scanf("%d %c %d", &a, &op, &b), op != '?'){
		if(op=='+'){
			c=a+b;
		}else if(op=='-'){
			c=a-b;
		}else if(op=='*'){
			c=a*b;
		}else if(op=='/'){
			c=a/b;
		}
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};

int n, q, s, t;

int get_tmp(int d) {
	if(d < 0) return -t * d;
	else return -s * d;

}

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

	cin >> n >> q >> s >> t;
	int a[n + 10];
	rep(i, n + 1) cin >> a[i];

	int d[n];
	int ans = 0;
	rep(i, n) {
		d[i] = a[i + 1] - a[i];
		ans += get_tmp(d[i]);
	}

	while(q--) {
		int l, r, x;
		cin >> l >> r >> x;
		l--;

		ans -= get_tmp(d[l]);
		d[l] += x;
		ans += get_tmp(d[l]);

		if(r != n) {
			ans -= get_tmp(d[r]);
			d[r] -= x;
			ans += get_tmp(d[r]);
		}

		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 6332
N,K=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
dic={}
for e in ls:
  if (e in dic):
    dic[e]+=1
  else:
    dic[e]=1
ls2=list(dic.items())
ls2=sorted(ls2, key=lambda x : -x[1])
ans=0
for i in range(K,len(ls2)):
  ans+=ls2[i][1]
print(ans)
  

Measured memory_bytes: 40600
import collections

N = int(input())
S = []
for i in range(N):
    S.append(input())

c = collections.Counter(S)
values, counts = zip(*c.most_common())

max_val = counts[0]
ans = []
for i in range(len(counts)):
    if counts[i] == max_val:
        ans.append(values[i])
    else:
        break
        
ans.sort()
for a in ans:
    print(a)


Measured memory_bytes: 59496
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <time.h>
#define ll long long
#define mp(a,b) make_pair(a,b)
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define ss(s) scanf("%s",&s)
#define pi(n) printf("%d\n",n)
#define pl(n) printf("%lld\n",n)
#define newline cout << endl;
using namespace std;

int main(){
  clock_t tStart = clock();
  ll ans = 0;
  string s; cin >> s;
  int n = s.length();
  for(int i=0;i<n;i++){
    if(s[i]=='+') ans++;
    else ans--;
  }
  pl(ans);
  //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  return 0;
}


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

using namespace std;

int main() {
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> lmax(n + 2, 0);
    vector<int> rmax(n + 2, 0);
    for (int i = 1; i <= n; ++i) {
        char ch = s[i - 1];
        lmax[i] = max(lmax[i], lmax[i - 1]);
        if (ch == 'o') lmax[i] = max(lmax[i] , 1);
        if (i >= c + 1 && ch == 'o') lmax[i] = max(lmax[i], lmax[i - c - 1] + 1);
    }
    for (int i = n; i > 0; --i) {
        char ch = s[i - 1];
        rmax[i] = max(rmax[i], rmax[i + 1]);
        if (ch == 'o') rmax[i] = max(rmax[i], 1);
        if (i + c + 1 <= n && ch == 'o') rmax[i] = max(rmax[i], rmax[i + c + 1] + 1);
    }
    map<pair<int, int>, vector<int>> f;
    for (int i = 1; i <= n; ++i) if (s[i - 1] == 'o') {
        int lef = (i >= c + 1 ? lmax[i - c - 1] : 0);
        int rig = (i + c + 1 <= n ? rmax[i + c + 1] : 0);
        // cout << i << ' ' << lef << ' ' << rig << endl;
        if (lef + rig + 1 == k) {
            f[make_pair(lef, rig)].push_back(i);
        }
    }
    vector<int> ans;
    for (auto it : f) if (it.second.size() == 1) {
        ans.push_back(it.second[0]);
    }
    sort(ans.begin(), ans.end());
    for (auto v : ans) cout << v << '\n';
}

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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int64_t LagrangeInterpolation(vector<int64_t> P, int64_t T){
    int N = P.size()-1;
    if(T <= N) return P[T];
    int64_t Qi = 1, QTA = 1;
    for(int i=0; i<=N; i++){
        if(i) mul(Qi, MOD-i);
        mul(QTA, T-i);
    }
    int64_t ans = 0;
    for(int i=0; i<=N; i++){
        add(ans, P[i] * inv_mod(Qi) % MOD * QTA % MOD * inv_mod(T-i));
        mul(Qi, (i+1) * inv_mod(MOD-N+i) % MOD);
    }
    return ans;
}

int main(){
    int64_t N, S;
    cin >> N >> S;
    int64_t ans = S*(S+1)/2 % MOD * power_mod(S+1, N-2) % MOD;
    for(int k=0; k<2; k++){
        vector<int64_t> P;
        int64_t v = 0;
        for(int i=0; i<=N; i++){
            add(v, power_mod(2*i+k, N-1));
            P.push_back(v);
        }
        int64_t res = LagrangeInterpolation(P, (S-k)/2);
        add(ans, S%2 == k ? res : MOD-res);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	long double a,b;
	cin>>a>>b;
	cout<<(ll)(a*b)<<endl;
	return 0;
}




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

int N;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    int ans = 0;
    rep(i, N) {
        int ai; cin >> ai;
        int cnt = 0;
        while (ai%2==0) {
            ai /= 2;
            cnt++;
        }
        ans += cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,A,B;
  cin >> n >> A >> B;
  const int nmax=40,amax=10,INF=1e9;
  int dp[nmax+1][nmax*amax+1][nmax*amax+1];
  for(int i=0;i<n+1;i++){
    for(int j=0;j<nmax*amax+1;j++){
      for(int k=0;k<nmax*amax+1;k++){
        dp[i][j][k]=INF;
      }
    }
  }
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  dp[0][0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<nmax*amax+1;j++){
      for(int k=0;k<nmax*amax+1;k++){
        if(dp[i][j][k]==INF){
          continue;
        }
        dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
        dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
      }
    }
  }
  int ans=INF;
  for(int i=1;i<nmax*amax+1;i++){
    for(int j=1;j<nmax*amax+1;j++){
      if(i*B==j*A){
        ans=min(ans,dp[n][i][j]);
      }
    }
  }
  if(ans==INF){
    cout << -1 << endl;
  }
  else{
    cout << ans << endl;
  }
}

Measured memory_bytes: 25984
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
ab.sort(key = lambda x:x[1]);check = -1;count = 0
for i in range(m):
    if check >= ab[i][0]:continue
    check = ab[i][1]-1
    count += 1
print(count)

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

const int MAXN = 10000 + 10;
const int INF = 2000000000;
struct edge
{
    int to, val, cost;
};
vector<edge> G[MAXN];
int n, m;
int dis[MAXN];
int inq[MAXN];

void SPFA()
{
    memset(inq, 0, sizeof inq);
    for(int i = 1; i <= n; i++) dis[i] = INF;
    dis[1] = 0;
    queue<int> q;
    q.push(1);
    inq[1] = 1;
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        for(int i = 0; i < G[u].size(); i++)
        {
            if(dis[G[u][i].to] > dis[u] + G[u][i].val)
            {
                dis[G[u][i].to] = dis[u] + G[u][i].val;
                if(!inq[G[u][i].to])
                {
                    q.push(G[u][i].to);
                    inq[G[u][i].to] = 1;
                }
            }
        }
        inq[u] = 0;
    }
}

int main()
{
    while(~scanf("%d%d", &n, &m), n + m)
    {
        for(int i = 0; i <= n; i++) G[i].clear();
        for(int i = 0; i < m; i++)
        {
            int a, b, c, d;
            scanf("%d%d%d%d", &a, &b, &c, &d);
            G[a].push_back((edge)
            {
                b, c, d
            });
            G[b].push_back((edge)
            {
                a, c, d
            });
        }
        SPFA();
        int total = 0;
        for(int i = 2; i <= n; i++)
        {
            int tmp = INF;
            for(int j = 0; j < G[i].size(); j++)
            {
                if(dis[i] == dis[G[i][j].to] + G[i][j].val && G[i][j].cost < tmp)
                    tmp = G[i][j].cost;
            }
            total += tmp;
        }
        cout << total << endl;
    }
    return 0;
}
/*

3 3
1 2 1 2
2 3 2 1
3 1 3 2
5 5
1 2 2 2
2 3 1 1
1 4 1 1
4 5 1 1
5 3 1 1
5 10
1 2 32 10
1 3 43 43
1 4 12 52
1 5 84 23
2 3 58 42
2 4 86 99
2 5 57 83
3 4 11 32
3 5 75 21
4 5 23 43
5 10
1 2 1 53
1 3 1 65
1 4 1 24
1 5 1 76
2 3 1 19
2 4 1 46
2 5 1 25
3 4 1 13
3 5 1 65
4 5 1 34
0 0

3
5
137
218

*/

Measured memory_bytes: 3224
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
Llist = [int(x) for x in input().split()]
Llist.sort()
Llist.reverse()
if sum(Llist) > 2*Llist[0]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
/*
    Two roads diverged in a yellow wood,
And sorry I could not travel both
And be one traveler, long I stood
And looked down one as far as I could
To where it bent in the undergrowth;

Then took the other, as just as fair,
And having perhaps the better claim,
Because it was grassy and wanted wear;
Though as for that the passing there
Had worn them really about the same,

And both that morning equally lay
In leaves no step had trodden black.
Oh, I kept the first for another day!
Yet knowing how way leads on to way,
I doubted if I should ever come back.

I shall be telling this with a sigh
Somewhere ages and ages hence:
Two roads diverged in a wood, and I—
I took the one less traveled by,
And that has made all the difference.
*/
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld long double
map<ll , ll>M;

int main()
{
   ll x , y;
   cin >> x >> y;
   ll val1 = min(x , y);
   ll val2 = max(x , y);
   x = val1;
   y = val2;
   if(x == 1 && y == 2)
   cout << 3 << "\n";
   if(x == 1 && y == 3)
   cout << 2 << "\n";
   if(x == 2 && y == 3 )
   cout << 1 << "\n";

}


Measured memory_bytes: 256
//Compiler optimization
#pragma GCC optimize("Ofast")

//include
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll pow(ll a,ll n, ll m){
    ll ret=1;
    for(;n>0;n>>=1,a=a*a%m){
        if(n%2==1){
        ret=ret*a%m;
        }
    }
    return ret;
}

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    int n,m;cin >> n >> m;
    atcoder::dsu uf(n);
    int a,b;
    int ans = n-1;
    fr(i,m){
        cin >> a >> b;
        a--;
        b--;
        if(!uf.same(a,b)){
            ans--;
            uf.merge(a,b);
        }
    }
    cout << ans << endl;
}

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

int main()
{
  int N, M, X, Y;
  std::cin >> N >> M >> X >> Y;
  std::vector<int> x(N), y(M);
  for (int i = 0; i < N; i++) std::cin >> x.at(i);
  for (int i = 0; i < M; i++) std::cin >> y.at(i);
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  int min_z = x.at(N-1), max_z = y.at(0);
  bool war = true;
  for (int i = Y; i > X; i--)
  {
    if (i <= max_z && i > min_z)
    {
      war = false;
      break;
    }
  }
  if (war) std::cout << "War" << std::endl;
  else std::cout << "No War" << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
#define MAX_M 100005
  
int n,m,ans;
int x[MAX_M],y[MAX_M],w[MAX_M];
vector<int> G[MAX_N];
vector<int> g[MAX_N];
vector<int> group[MAX_N];
int id[MAX_N];
bool visited[MAX_N];
vector<int> vd;
int dp[MAX_N];
int d[MAX_N];
  
bool dfs(int pos,int prev,int root){
  id[pos]=root;
  visited[pos]=true;
  group[root].push_back(pos);
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(i&&to==G[pos][i-1])return true;
    if(visited[to])return true;
    if(dfs(to,pos,root))return true;
  }
  return false;
}
  
bool check(){
  memset(visited,false,sizeof(visited));
  for(int i=0;i<n;i++)
    if(!visited[i]&&dfs(i,-1,i))return true;
  
  vector<int> deg(n);
  for(int pos=0;pos<n;pos++){
    for(int i=0;i<(int)g[pos].size();i++){
      int to=g[pos][i];
      deg[ id[to] ]++;
    }
  }
  
  queue<int> Q;
  for(int i=0;i<n;i++)
    if(deg[i]==0&&id[i]==i)
      Q.push(i);
    
  while(!Q.empty()){
    int root=Q.front();Q.pop();
    vd.push_back(root);
    for(int i=0;i<(int)group[root].size();i++){
      int pos=group[root][i];
      for(int j=0;j<(int)g[pos].size();j++){
        int to=g[pos][j];
        deg[ id[to] ]--;
        if(deg[ id[to] ]==0)Q.push(id[to]);
      }
    }
  }
  for(int i=0;i<n;i++)
    if(deg[i]>0)return true;
  return false;
}
  
int solve(int S){
  for(int i=0;i<(int)group[id[S]].size();i++){
    int pos=group[id[S]][i];
    d[pos]=-1;
  }
  queue<int> Q;
  Q.push(S);
  d[S]=0;
  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    for(int i=0;i<(int)G[pos].size();i++){
      int to=G[pos][i];
      if(d[to]!=-1)continue;
      d[to]=d[pos]+1;
      Q.push(to);
    }
  }
  int res=S;
  for(int i=0;i<(int)group[id[S]].size();i++){
    int pos=group[id[S]][i];
    if(d[pos]+dp[pos]>d[res]+dp[res])res=pos;
    ans=max(ans,d[pos]+dp[S]);
    for(int i=0;i<(int)g[pos].size();i++){
      int to=g[pos][i];
      dp[to]=max(dp[to],d[pos]+dp[S]+1);
    }
  }
  return res;
}
  
int main(){
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d %d %d",&x[i],&y[i],&w[i]);
    x[i]--,y[i]--;
    if(w[i]==1){
      g[x[i]].push_back(y[i]);
    }
    if(w[i]==2){
      G[x[i]].push_back(y[i]);
      G[y[i]].push_back(x[i]);
    }
  }
  if(check()){
    printf("Infinite\n");
    return 0;
  }
  for(int i=0;i<(int)vd.size();i++){
    int root=vd[i];
    if(root==id[root])
      solve(solve(solve(root)));
  }
  printf("%d\n",ans);  
  return 0;
}

Measured memory_bytes: 21424
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }
 
#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
 
// constexpr int MOD = 1e9+7;
 
int main(void){
    Cin(string, a);
    CoutYn(Contains(a, '7'));
}

Measured memory_bytes: 3632
import java.util.*;
public class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String [] args){
    int e;
    while(true){
      e = sc.nextInt();
      if(e == 0)break;
      System.out.println(solve(e));
    }
  }
  static int solve(int e){
    double x,y,z,res;
    int ans = e;
    double m;
    double Cz;
    for(z = 0; Math.pow(z, 3) <= e ;z++){
      Cz = Math.pow(z,3);
      for(y = 0; Math.pow(y, 2) <= e - Cz; y++){
        x = e - (Cz + Math.pow(y, 2));
        if(x <0)break;
        m = x + y + z;
        ans = Math.min(ans, (int)m);
      }
    }
    return ans;
  }
}

Measured memory_bytes: 25964
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] o = new char[3];
    o[0] = sc.next().charAt(0);
    o[1] = sc.next().charAt(1);
    o[2] = sc.next().charAt(2);
    String ou = new String(o);
    System.out.println(ou);
  }
}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

template <typename T>
vector<T> Dijkstra(int s, vector<vector<pair<int, T>>> & G, const T INF = 1e9){
    using P = pair<T, int>;
    int V = G.size();
    vector<T> dist(V, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.emplace(0, s);
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;
        for(int i = 0; i < G[v].size(); i++){
            int to = G[v][i].first;
            T cost = G[v][i].second;
            if(dist[to] > dist[v] + cost){
                dist[to] = dist[v] + cost;
                que.emplace(dist[to], to);
            }
        }
    }
    return dist;
}

signed main(){
    int n,m;
    cin >> n >> m;
    vector<vector<P>> G(n + m);
    REP(i,n){
        int k;
        cin >> k;
        REP(j,k){
            int l;
            cin >> l;
            l--;
            G[i].emplace_back(n + l, 1);
            G[n + l].emplace_back(i, 1);
        }
    }
    vector<int> dist = Dijkstra(0, G, INF);
    REP(i,n){
        if(dist[i] == INF){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 11124
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define ll long long
int main()
{
    ll n,i,j,k,l,m;
    cin>>n;
    cin>>m;
    ll arr[m+10];
    l=0;
    for(i=0;i<m;i++)
    {
        cin>>arr[i];
        l+=arr[i];
    }
    if(l<=n)
    {
        cout<<n-l<<endl;
    }
    else
    {
        cout<<"-1"<<endl;
    }
    return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MIN -10000000
#define MAX 10000000

int main()
{
  int n,k,c;cin>>n>>k>>c;
  string s;cin>>s;
  vector<bool> can(n);
  int i;
  rep(i,s.size())
  {
    if(s[i]=='o')can[i]=true;
    else can[i]=false;
  }
  //front,back
  vector<int> dp1(k+1,0);
  dp1[0]=MIN;
  int now=0;
  rep(i,n)
  {
    if(!can[i])continue;
    else if(now<k&&dp1[now]<i-c)
    {
      dp1[now+1]=i;
      now++;
    }
  }
  vector<int> dp2(k+1,n);
  dp2[k]=MAX;
  now=k;
  for(i=n-1;i>=0;i--)
  {
    if(!can[i])continue;
    else if(now>0&&dp2[now]>i+c)
    {
      dp2[now-1]=i;
      now--;
    }
  }
  rep(i,k)
  {
    if(dp1[i+1]==dp2[i])
    {
      cout<<dp2[i]+1<<endl;
    }
  }
}


Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int a,b;
    char s[100][100];
    int bom[100][100];
    cin>>a>>b;
    for(int i=1;i<=a;i++){
        for(int j=1;j<=b;j++){
            cin>>s[i][j];
            if(s[i][j]=='#'){
                bom[i-1][j-1]++;
                bom[i-1][j]++;
                bom[i-1][j+1]++;
                bom[i][j-1]++;
                bom[i][j+1]++;
                bom[i+1][j-1]++;
                bom[i+1][j]++;
                bom[i+1][j+1]++;
            }
        }
    }
    for(int i=1;i<a+1;i++){
        for(int j=1;j<b+1;j++){
            if(s[i][j]=='#'){
                cout<<"#";
            }else{
                cout<<bom[i][j];
            }
        }
        cout<<endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    vector<ll> L, R;

    ll idx = 0;
    while (L.size() < K && idx < N) {
        if (S[idx] == 'o') {
            L.push_back(idx);
            idx += C + 1;
        } else {
            idx++;
        }
    }
    idx = N - 1;
    while (R.size() < K && idx >= 0) {
        if (S[idx] == 'o') {
            R.push_back(idx);
            idx -= C + 1;
        } else {
            idx--;
        }
    }
    reverse(R.begin(), R.end());
    rep(i, K) {
        if (L[i] == R[i]) {
            cout << L[i] + 1 << '\n';
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 5128
using System;

class Plogram
{
    static void Main()
    {
        var array = Console.ReadLine().Split();
        int r = int.Parse(array[0]);
        int D = int.Parse(array[1]);
        int x = int.Parse(array[2]);

        int m = r * x - D;
        Console.WriteLine(m);

        for (int i = 0; i<9; i++)
        {
            m = r * m - D;
            Console.WriteLine(m);
        }
    }
}

Measured memory_bytes: 11092
n,t = map(int,input().split())
a = list(map(int,input().split()))
ans = t
for i in range(n-1, 0, -1):
    if a[i] - a[i-1] < t:
        ans += a[i] - a[i-1]
    else:
        ans += t
print(ans)


Measured memory_bytes: 85328
module Sort_Module
    implicit none
    public
    contains
    recursive subroutine mergesort(a, p, r, b)
        integer(8) a(:), b(:)
        integer(8) p, r
        integer(8) q
        if (p < r) then
            q = (p+r)/2
            call mergesort(a, p, q, b)
            call mergesort(a, q+1, r, b)
            call merge(a, p, q, r, b)
        end if
    end subroutine mergesort
    subroutine merge(a, p, q, r, b)
        integer(8) a(:), b(:)
        integer(8) p, r, q, i, j, k
        integer(8) t
        k = p;   i = p;   j = q+1
        do
            if (.not. (k <= r)) exit
            if (j > r) then
                t = a(i);   i = i+1
            else if (i > q) then
                t = a(j);   j = j+1
            else if (a(i) <= a(j)) then
                t = a(i);   i = i+1
            else
                t = a(j);   j = j+1
            end if
            b(k) = t;   k = k+1
        end do
        do i = p, r
            a(i) = b(i)  
        end do
    end subroutine merge
    subroutine sort(a)
      integer(8) a(:),b(ubound(a,1)-size(a)+1:ubound(a,1)),n,k
      n = ubound(a,1)
      k = ubound(a,1)-size(a)+1
      call mergesort(a,k,n,b)
    end subroutine sort
    function POSL(a,v) result(r)!find first i:a(i)>=v
        implicit none
        integer(8) :: a(:),l,r,idx,v
        r = ubound(a,1) + 1
        l = ubound(a,1)-size(a)
        do while(r-l>1)
            idx = l + (r-l)/2
            if(a(idx) >= v)then
                r = idx
            else
                l = idx
            endif
        enddo
    end function
    function POSU(a,v) result(r)!find first i:a(i)>v
        implicit none
        integer(8) :: a(:),l,r,idx,v
        r = ubound(a,1) + 1
        l = ubound(a,1)-size(a)
        do while(r-l>1)
            idx = l + (r-l)/2
            if(a(idx) > v)then
                r = idx
            else
                l = idx
            endif
        enddo
    end function
    function NUM(a,v) result(n)
        implicit none
        integer(8) :: a(:),v,n
        n = POSU(a,v) - POSL(a,v)
    end function
end module Sort_Module

program atcoder
    use Sort_Module
    implicit none
    integer(8) :: N,M,i,ans,k,l,x,y,z,MO
    integer(8),allocatable,dimension(:) :: A,B
    MO = 1000000007_8
    read*,N,M
    allocate(A(N),B(M))
    read(*,*)(A(i),i=1,N)
    read(*,*)(B(i),i=1,M)
    call sort(A)
    call sort(B)
    ans = 1_8
    do i = N*M,1_8,-1_8
        k = NUM(A,i)
        l = NUM(B,i)
        x = N - POSL(A,i) + 1_8
        y = M - POSL(B,i) + 1_8
        z = N*M - i
        if(k*l>=2)then
            write(*,'(I0)')0
            return
        else if(k*l==1)then
            continue
        else if(k==0.and.l==0)then
            ans = mod(ans*(x*y-z),MO)
        else if(l==1)then
            ans = mod(ans*x,MO)
        else if(k==1)then
            ans = mod(ans*y,MO)
        end if
    enddo
    write(*,'(I0)')ans
    stop 
contains
end program atcoder

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long int     ll;
typedef  vector<int>       vi;
typedef  pair<int,int>     pii;
#define  int               ll
#define  F                 first
#define  S                 second
#define  pb                push_back
#define  mp                make_pair 
#define  si(x)             (int)x.size()
#define  all(x)            x.begin(),x.end()
#define  minv(m,n)         *min_element(m,n)      
#define  maxv(m,n)         *max_element(m,n)
#define  mem(a,x)          memset(a,x,sizeof(a))
#define  deb(x)            cout<<#x<<" = "<<x<<endl
#define  rep(i,n)          for(int i=0; i<n;i++)
#define  prs(x)            fixed <<setprecision(x)
#define  w(ttz)            int ttz;cin>>ttz;while(ttz--)
#define  show(a)           for(auto x:a){cout<<x<<" ";}cout<<endl;
        void iosbase(void);

int32_t main() 
{   
  iosbase();
 int a[3];
 cin>>a[0]>>a[1]>>a[2];
 sort(a , a+3);
 if(a[0] == 5 and a[1]==5 and a[2]==7)
 cout<<"YES";
 else
 cout<<"NO";  


}


void iosbase(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif 
}

Measured memory_bytes: 3636
n = int(input())
a = [int(i) for i in input().split()]
odd, even = [],[]
for i in range(n):
  if i%2 == 1:
    odd.append(a[i])
  else:
    even.append(a[i])

if n%2 == 0:
  odd.reverse()
  b = odd+even
else:
  even.reverse()
  b = even+odd
print(" ".join(map(str,b)))

Measured memory_bytes: 31296
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	lnt a,b,c,d,t;
	std::cin >> a >> b >> c >> d >> t;
	if(std::abs(a-c)<=(b-d)*t) print("YES");
	else print("NO");
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(void)
{
	
	int S, h, m, s, x;
	
    scanf("%d",&S);
    
    h = S/3600;
    x = S%3600;
    m = x/60;
    s = x%60;
    
    printf("%d:%d:%d\n",h,m,s);

    return 0;
}

Measured memory_bytes: 592
#include <string>
#include <iostream>
using namespace std;
int main()
{
    string a;
    int j;
    cin >> a;
    if(a[0] == 'B')
    {
        a[0] = '/';
    }
    for(int i = 1;i < a.size();i++)
    {
        if(a[i] == 'B')
        {
            a[i] = '/';
            if(a[i - 1] != '/')
            {
                a[i - 1] = '/';
            }
            else
            {
                j = i - 1;
                for(;j > 0 && a[j] == '/';j--);
                a[j] = '/';
            }
        }
    }
    for(int i = 0;i < a.size();i++)
    {
        if(a[i] != '/')
        {
            cout << a[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
use std::collections::*;
use std::io::*;
use std::str::FromStr;

fn main() {
    let a:i128 = read();
    let b:i128 = read();
    let c:i128 = read();
    let d:i128 = read();
    let arr = vec![a*c,a*d,b*c,b*d];
    let at = arr.iter().max();
    match at {
        Some(max) =>println!("{:?}",max),
        None => println!("miss")
    }
}
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}



Measured memory_bytes: 2116