Problem:


Score : 300 points

Problem Statement

In a public bath, there is a shower which emits water for T seconds when the switch is pushed.

If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.
Note that it does not mean that the shower emits water for T additional seconds.

N people will push the switch while passing by the shower.
The i-th person will push the switch t_i seconds after the first person pushes it.

How long will the shower emit water in total?

Constraints

1 ≤ N ≤ 200,000

1 ≤ T ≤ 10^9

0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9

T and each t_i are integers.

Input

Input is given from Standard Input in the following format:

N T
t_1 t_2 ... t_N

Output

Assume that the shower will emit water for a total of X seconds. Print X.

Sample Input 1

2 4
0 3

Sample Output 1

7

Three seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.

Sample Input 2

2 4
0 5

Sample Output 2

8

One second after the shower stops emission of water triggered by the first person, the switch is pushed again.

Sample Input 3

4 1000000000
0 1000 1000000 1000000000

Sample Output 3

2000000000

Sample Input 4

1 1
0

Sample Output 4

1

Sample Input 5

9 10
0 3 5 7 100 110 200 300 311

Sample Output 5

67



Sample input:
2 4
0 3


Sample output:
7

Submission status: Accepted

Solution code:
n, t = map(int, input().split())
ts = map(int, input().split())
x = 0
out = False
t_sw = 0
t_last = 0
for ti in ts:
    if out and t_sw > ti:
        t_sw = ti + t
    elif out and t_sw <= ti:
        x += t_sw - t_last
        out = False
    if not out:
        t_last = ti
        t_sw = t_last + t
        out = True
if out:
    x += t_sw - t_last
print(x)

Submission status: Accepted

Solution code:
# coding: utf-8

n,t = [int(x) for x in input().rstrip().split(" ")]
push_times = [int(x) for x in input().rstrip().split(" ")]

total_duration = 0

for i in range(len(push_times)):
    if i == len(push_times) - 1:
        total_duration = total_duration + t
        break

    time_diff = (push_times[i+1] - push_times[i])
    if time_diff > t:
        total_duration = total_duration + t
    elif time_diff <= t:
        total_duration = total_duration + time_diff

print(total_duration)

Submission status: Accepted

Solution code:
n, t = map(int, input().split())
ti = list(map(int, input().split()))
ttl = t
for i in range(n-1):
    ttl += min(ti[i+1]-ti[i], t)
print(ttl)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


N,T = map(int,raw_input().split(" "))
t = map(int,raw_input().split(" "))
X = 0
sum = 0

if(N == 1):
	print T
else:
	for n in range(N-1):
		if(t[n+1]- t[n]<=T):
			X = t[n+1] + X - t[n]
		else:
			X = X + T

	X = X + T

	print X

Submission status: Accepted

Solution code:
#coding=UTF-8

mozir=input()
hyo=mozir.split(' ')
N=int(hyo[0])
T=int(hyo[1])

mozir=input()
hyo=mozir.split(' ')
t=[ int(mono) for mono in hyo]

X=0

hazimetime=None
owaritime=None
for hito in t:
    #時間清算
    if owaritime != None:
        if owaritime > hito:
            X=X+(hito-hazimetime)
        else:
            X=X+T
        
    #押す処理
    hazimetime=hito
    owaritime=hito+T


#最後の人の処理
X=X+T
print(X)

Submission status: Accepted

Solution code:
import sys

N, T = sys.stdin.readline().rstrip().split()
t_list = sys.stdin.readline().rstrip().split()

N = int(N)
T = int(T)
t_list = [int(x) for x in t_list]

t_old = t_list[0]
t_sum = T
for t in t_list:
    t_diff = t - t_old

    if t_diff >= T:
        t_sum += T
    else:
        t_sum += t_diff

    t_old = t

print(t_sum)

Submission status: Accepted

Solution code:
N, T = list(map(int, input().split()))
t =  list(map(int, input().split()))
ans = N*T
t.pop(0)   # startが0なの忘れてた
for i in range(len(t)):
    if i == len(t) - 1:
        break
    t[len(t) - 1- i] -= t[len(t) - 2 - i]
for i in t:
    if i < T:
        ans -= T - i
print(ans)

Submission status: Accepted

Solution code:
N, T = map(int, raw_input().split())
t = map(int, raw_input().split())

X = T

dur = T

# durs = map(

for i in range(0, N-1):
    if t[i+1] - t[i] < T:
        X += t[i+1] - t[i]
    else:
        X += T

print(X)

Submission status: Accepted

Solution code:
f=map(int, raw_input().split())
s=map(int, raw_input().split())

total=0

for i in range(1,f[0]):
    total+=min(f[1], s[i]-s[i-1])

total+=f[1]

print total

Submission status: Accepted

Solution code:

N,T = map(int, input().split())
t = list(map(int,input().split()))


X = 0

for i in range(N):
    if i == 0:
        continue
    X = X + min(t[i]-t[i-1],T)

X = X + T 
print(X)

Submission status: Accepted

Solution code:
# coding: utf-8
# 整数の入力
#a = int(raw_input())
# スペース区切りの整数の入力
import numpy as np
import itertools

N, T = map(int, raw_input().split())
Timings = map(int, raw_input().split())

TotalTime = 0
beforeTime = 0
for i in range(N):
    if (Timings[i] - beforeTime) > T or i == 0:
        TotalTime += T
    else:
        TotalTime += Timings[i] - beforeTime
    beforeTime = Timings[i]

print TotalTime

Submission status: Accepted

Solution code:
N, T = map(int, input().split())

pushed_time = list(map(int, input().split()))
period = [pushed_time[0], pushed_time[0] + T]
# 今流れているお湯の [出始めた時刻, 止まる時刻]
duration = 0

for t_i in pushed_time[1:]:
    if t_i <= period[1]: # お湯が止まる前に次の人がボタンを押すならば
        period[1] = t_i + T # お湯が止まる時刻は {押した時} + T になる
    else:
        duration += period[1] - period[0]
        # お湯が止まる。止まるまでの時間をお湯が出ていた総時間に加算
        period = [t_i, t_i + T] # 次の区間が始まる
duration += period[1] - period[0]

print(duration)

Submission status: Accepted

Solution code:

N, T = map(int, input().split())
t = list(map(int, input().split()))


ret = T

for i in range(1, N):
    if t[i] - t[i -1] > T:
        ret += T
    else:
        ret += (t[i] - t[i - 1])

print(ret)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
(N,T) = map(int,input().split(" "))
t = list(map(int,input().split(" ")))

diffs=0
for i in range(1,N):
    diff = t[i] - t[i-1]
    if diff < T:
        diffs = diffs + T - diff

print(T*N-diffs)

Submission status: Accepted

Solution code:


def solve():
    timer = 0
    count = 0
    ans = 0
    while (count < n):
        diff = timer - ti[count]
        timer = ti[count] + t
        if 0 < (diff) < t:
            ans += t - diff
        else:
            ans += t
        count += 1
    print(ans)

if __name__ == '__main__':
    n, t = map(int, input().split())
    ti = list(map(int, input().split()))
    solve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n,T = map(int, raw_input().split())
t = map(int, raw_input().split())
total_time = 0
stop_time = 0
for i in range(n):
    if(stop_time<=t[i]):
        total_time += T
    else:
        total_time += t[i]-t[i-1]
    stop_time = t[i]+T
        
print (total_time)

Submission status: Accepted

Solution code:
N, T = map(int, raw_input().split())
TL = map(int, raw_input().split())

e = 0
ans = 0
for t in TL:
    ans += min(t + T - e, T)
    e = T + t
print ans

Submission status: Accepted

Solution code:
N, T = map(int, raw_input().split())
t = map(int, raw_input().split())

total = T
for idx in range(N-1):
    if t[idx+1] - t[idx] <= T:
        total += t[idx+1] - t[idx]
    else:
        total += T
print total

Submission status: Accepted

Solution code:
N,T = map(int,input().split())
tau = list(map(int,input().split()))
answer = 0
cont = 0
for i in range(N):
	if tau[i] < cont:
		dif = cont - tau[i]
		answer += T - dif
	else:
		answer += T
	cont =tau[i] + T
print(answer)

Submission status: Accepted

Solution code:
N, T = map(int, raw_input().split())
t = map(int, raw_input().split())

result = T
for i in range(1, N):
    result += T
    if (t[i] - t[i - 1]) < T:
        result -= (T - (t[i] - t[i - 1]))
print(result)

Submission status: Accepted

Solution code:
import sys
import math

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

N, T = nil()

t = nil()

s = 0

for i in range(0, len(t)-1):
    f = T - (t[i+1] - t[i])
    if f > 0:
        s += f

print(N*T - s)

Submission status: Accepted

Solution code:
N,T = map(int,input().split())
times = list(map(int,input().split()))
ans = T
t1 = 0
for t2 in times:
	t = t2 - t1
	t1 = t2
	ans = ans + min(t, T)
print(ans)

Submission status: Accepted

Solution code:
N,T=list(map(int, input().split()))
t=[0]*N
t=list(map(int, input().split()))

S=T

for i in range(N-1):
    if t[i+1]-t[i]>T:
        S=S+T
    else:
        S=S+(t[i+1]-t[i])

print(S)

Submission status: Accepted

Solution code:
NT = list(map(int, input().split()))
N = NT[0]
T = NT[1]
del NT

t = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    l = t[i+1] - t[i]
    if l <= T:
        ans += l
    else:
        ans += T
ans += T
print(ans)

Submission status: Accepted

Solution code:
N, T = map(int, input().split())
t = list(map(int, input().split()))

sum = 0
start = t[0]
end = t[0] + T

for i in range(N - 1):
    if end >= t[i + 1]:
        sum += t[i + 1] - start
        start = t[i + 1]
        end = t[i + 1] + T
    else:
        sum += end -start
        start = t[i + 1]
        end = t[i + 1] + T

sum += end - start

print(sum)

Submission status: Accepted

Solution code:
n,t=map(int,input().split())
hito=list(map(int,input().split()))
ans=n*t
for i in range(len(hito)-1):
    if hito[i+1]-hito[i]<t:
        ans-=t-(hito[i+1]-hito[i])
print(ans)

Submission status: Accepted

Solution code:
N, T = map(int, input().split())
ti = input().split()

sum = T
for i in range(1, N):
    if (int(ti[i]) - int(ti[i-1])) <= T:
        sum += (int(ti[i]) - int(ti[i-1]))
    else:
        sum += T

print(sum)

Submission status: Accepted

Solution code:
# coding: utf-8
import numpy as np

if __name__ == "__main__":
	n, t = map(int, input().split())
	tn = list(map(int, input().split()))

	clusters = [[0, 0]]
	for i in range(0, len(tn)-1):
		if tn[i+1] - tn[i] <= t:
			clusters[-1][1] = i+1
		else:
			clusters.append([i+1, i+1])

	tsum = 0
	for s, e in clusters:
		tsum += tn[e] - tn[s] + t

	print(tsum)

Submission status: Accepted

Solution code:

N,T=map(int,raw_input().split(' '))
t=map(int,raw_input().split(' '))

X=0

for i in range(N):
    if i==N-1:
        X+=T
    elif t[i+1]-t[i]>T:
        X+=T
    else:
        X+=(t[i+1]-t[i])

print X

Submission status: Accepted

Solution code:
N, T = [int(x) for x in input().split()]
t = [int(x) for x in input().split()]
ans = 0

for i in range(N -1):
	if t[i + 1] -t[i] < T:
		ans += t[i + 1] -t[i]
	else:
		ans += T
ans += T
		
print(ans)

Submission status: Accepted

Solution code:
n, T = map(int,raw_input().split())
t = map(int,raw_input().split())
mt = 0
for i in range(1, n):
    if t[i] - t[i - 1] > T:
        mt += t[i] - t[i - 1] - T
print t[n-1] + T - mt

Submission status: Accepted

Solution code:
def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))

    total = T
    for n in range(1, N):
        if t[n] < t[n-1] + T:
            total += (t[n]+T) - (t[n-1]+T)
        else:
            total += T

    print(total)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, T = list(map(int, input().split()))
t_list = list(map(int, input().split()))
sum_time = 0
for i in range(1, N):
    t_delta = t_list[i] - t_list[i-1]
    if t_delta > T:
        sum_time += T
    else:
        sum_time += t_delta

sum_time += T

print(sum_time)

Submission status: Accepted

Solution code:
n,T=list(map(int,input().split()))
t=list(map(int,input().split()))
sum=0
for i in range(n-1):
    if t[i+1]-t[i]>=T:
        sum+=T
    else:
        sum+=t[i+1]-t[i]
sum+=T
print(sum)

Submission status: Accepted

Solution code:
#! -*- coding:utf-8 -*-
N,T = map(int,input().split())
t = input()

t = t.split()
for i in range(len(t)):
    t[i] = int(t[i])

total = 0
for i in range(len(t)-1):
    if t[i+1] - t[i] >= T:
        total += T
    else:
        total += t[i+1] - t[i]
total += T
print(total)

Submission status: Accepted

Solution code:
A = list(map(int,input().split(" ")))
B = list(map(int,input().split(" ")))
C = A[1]
for i in range(A[0]-1):
    ii = i + 1
    if B[ii] - B[i] < A[1]:
        C = C + B[ii] - B[i]
    else:
        C = C +A[1]
print(C)

Submission status: Accepted

Solution code:
N, T = map(int, input().split())
tn = map(int, input().split())

prev = 0
ans = 0
for t in tn:
    ans += min(T, t - prev + T)
    prev = t + T
    
print(ans)

Submission status: Accepted

Solution code:
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
for i in range(1, N):
  if(t[i] - t[i-1] >= T): ans += T
  else: ans += (t[i] - t[i-1])


print(ans + T)

Submission status: Accepted

Solution code:
def rren(): return list(map(int, input().split()))

N, oyu = rren()
T = rren()

Ans = 0
for i in range(N-1):
    Ans += oyu if T[i+1] - T[i] >= oyu else T[i+1] - T[i]

print(Ans + oyu)

Submission status: Runtime Error

Solution code:
N, T = map(int, input().split())
A = list(map(int, input().split()))
ans = T
for i in range(1, N):
  if A[i] - A[i-1] >= T:
    ans += T
  else:
    ans += (A[i] - A[i+1])
print(ans)

Submission status: Runtime Error

Solution code:
 N,T = map(int,input().split())
t = list(map(int,input().split()))
ans = T
for i in range(N-1):
    now = t[i+1]-t[i]
    ans += min(now,T)


print(ans)

Submission status: Runtime Error

Solution code:
a,b=input().split()
a=int(a)
b=int(b)
c=list(map(int,input().split()))
m=a*b
for i in range(a):
  if c[i+1]-c[i]<b:
    m=m-(b-(c[i+1]-c[i]))
print(m)

Submission status: Runtime Error

Solution code:
n, t = map(int, input().split())
arr = list(map(int, input().split()))
summ = t
for i in range(n-1):
  summ += min(t, arr[i+1] - arr[i])
return summ

Submission status: Runtime Error

Solution code:
N, T = map(int, input().split())
t = list(map(int, input().split()))

lst = [0]*(t[N-1]+T)

for i in range(N):
    for j in range(T):
        lst[t[i]+j] += 1

ans = len(lst) - lst.count(0)
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

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

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

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,T = IL()
t = IL()

ans = 0
for t in T[1:]:
  ans += min(t,T)
P(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 16:15:19 2020

@author: shinba
"""

n,t = map(int,input().split())

T = list(map(int,input().split()))
T.append(10**10)
R = []
for i in range(n-1):
    R.append(T[i+1]-T[i])

ans = 0
start = T[0]

for i in range(n):
    if R[i] <= t:
        continue
    ans += t+(T[i]-start)
    start = T[i+1]
    
print(ans)

Submission status: Runtime Error

Solution code:
n,t=list(input())
ts = list(input())
print(sum([min(t, next - prev) for prev, next in zip(ts, ts[1:])], t))

Submission status: Runtime Error

Solution code:
n,t = map(int,input().split())
T = list(map(int,input().split()))
U = []
for i in range(n):
  for j in range(t):
    a = T[i] + j+1
    U.append(a)
setT = set(T)
setU = set(U)
ans = set(T) | set(U)

print(ans.count())

Submission status: Runtime Error

Solution code:
n,t = map(int,input().split())
T = list(map(int,input().split()))
U = []
for i in range(n):
  for j in range(t):
    a = T[i] + t+1
    U.append(a)
setT = set(T)
setU = set(U)
ans = set(T)|set(U)

print(ans.count())

Submission status: Runtime Error

Solution code:
N, T = map(int, input().split())
t = list(map(int, input().split()))
t += t[-1]*2

ans = 0
for i in range(N):
    ans += min(T, t[i+1] - t[i])

print(ans)

Submission status: Runtime Error

Solution code:
N,T=map(int,input().split())
t=list(map(int,input().split()))+[10**18]
x=0
for i in range(n):
  x+=min(t[i+1]-t[i],T)
print(x)

Submission status: Runtime Error

Solution code:
n,t = map(int, input().split( ))
t = tuple(map(int, input().split( )))
ans  = 0
ti = 0;
for i in range(n):
    if t[i] >= ti+t:
        ans += t 
    else:
        ans += t[i] - ti
    ti = t[i]
print(ans)

Submission status: Runtime Error

Solution code:
n,t = map(int,input().split())
a = list(map(int,input().split()))

ans = t
for i in range(0,n-1):
  ans += min(t, s[i+1] - s[i])
print(ans)

Submission status: Runtime Error

Solution code:
n,t=map(int,input().split())
a=list(map(int,input().split()))
ans=a[-1]+t
for i in range(1,n):
  if a[i]-a[i-1]>t:
    ans = ans - (t[i]-t[i-1]-t)
print(ans)

Submission status: Runtime Error

Solution code:
n,t=map(int,input().split())
x=list(map(int,input().split()))
a=t
for i in range(n-1):
  a.append(min(x[i+1]-x[i],t))
print(a)

Submission status: Runtime Error

Solution code:
N, T = map(int, input().split())
t = [int(i) for i in input().split()]
ans = T
wait = 0
start = 0
for i in range(1, N):
    if (t[i] - t[i - 1] >= T):
        ans += wait + T
        start = t[i]
        wait = 0
    else:
      wait = t[i] - start
        if (wait > T):
            ans, wait = ans + T, wait - T
print(ans + wait)

Submission status: Runtime Error

Solution code:
N, T = map(int, input().split())

t = list(map(int, input().split()))

discount = 0
for i in range(N - 1):
    if t[i + 1] - t[i] < T:
        discount += (T - (t[i + 1] - t[i]))

X = N * T - discount

print(X

Submission status: Runtime Error

Solution code:
from bitarray import bitarray
n,T=[int(i) for i in input().split()]
t=[int(i) for i in input().split()]

ans=0
for i in range(n-1):
    start=t[i]
    end=start+T
    if(end>t[i+1]):
        ans+=t[i+1]-t[i]
    else:
        ans+=T
ans+=T
print(ans)

Submission status: Runtime Error

Solution code:
from bitarray import bitarray
n,T=[int(i) for i in input().split()]
t=[int(i) for i in input().split()]

ans=0
a = bitarray(100000)
a.setall(0)
for i in range(n):
    start=t[i]
    end=start+T
    a[start:end]=1
print(a.count())

Submission status: Runtime Error

Solution code:

N, T = map(int, input().split())
t = list(map(int, input().split()))
s, e = 0, 0
ans = 0
for i in range(N):
  if t[i] <= e:
    e = t[i] + T
    else:
      ans += e - s
      s = t[i]
      e = t[i] + T
ans += e - s
print(ans)

Submission status: Runtime Error

Solution code:
N,T = map(int,input().split())
Ts = [int(i) for i in input().split()]
flow = set()
for i in range(N):
    flow = set(list(flow)+list(range(Ts[i]+1,Ts[i]+T+1)))
print(len(flow))

Submission status: Runtime Error

Solution code:
n,t=map(int,input().split())
a=list(map(int,input().split()))
j=t
for i in range(1,n+1):
  if a[i]>t:
    j+=t
  else:
    j+=a[i]
    
print(j)

Submission status: Runtime Error

Solution code:
a = list(input().split(" "))
b = list(input().split(" "))
oyu = []
for i in b:
    oyu[int(i):int(i)+int(a[1])] = [1] * int(a[1])
sum(oyu)

Submission status: Runtime Error

Solution code:
N,T=map(int,input().split())
t=list(map(int,input().split()))
diff = [t[i]-t[i-1] fossil i in range(1,N)]
ans=T*N
for i in range(N-1):
  ans-=min((T - diff[i]),0)
print(ans)

Submission status: Runtime Error

Solution code:
N,T = map(int,input().split())
T = list(map(int,input().split()))
tot = 0
for i in range(1,N):
    d = T[i]-T[i-1]
    if d>T:
        tot += T
    else:
        tot += d
print(tot+T)

Submission status: Runtime Error

Solution code:
N,T = map(int,input().split())
T = list(map(int,input().split()))
tot = 0
for i in range(1,N):
    d = T[i]-T[i-1]
    if d>T:
        tot += T
    else:
        tot += d
print(tot)

Submission status: Runtime Error

Solution code:
N,T = map(int,input().split())
t = list(map(int,input().split()))
sum = 0
for i in range(N-1):
  sum += (T,t[i+1]-t[i])
print(sum)

Submission status: Runtime Error

Solution code:
N,T = map(int,input().split())
t = list(map(int,input().split()))
sum = 0
sum += t[0]
for i in range(N-1):
  sum += (T,t[i+1]-t[i])
print(sum)

Submission status: Runtime Error

Solution code:
n,t=map(int,input().split())
T=list(map(int,input().split()))
count=0
if t>T[1]:
    count+=t-T[1]
pre=T[1]
for i in range(2,n):
    sa=T[i]-pre
    if t>sa:
        count+=t-sa
    pre=T[i]
print(n*t-count)

Submission status: Runtime Error

Solution code:
N,T = map(int, input().strip().split(' '))
t = list(map(int, input().strip().split(' ')))

imos = [0]*(t[-1]+T+1)
for i in t:
  imos[i] += 1
  imos[i+T] -= 1

for i in range(len(imos)-1):
  imos[i+1] += imos[i]
  
print(len([1 for i in imos if i > 0]))

Submission status: Runtime Error

Solution code:
_,T,*a=map(int,open(0).read().split())
print(sum([min(i-j,t) for i,j in zip(a,[0]+a)]))

Submission status: Runtime Error

Solution code:
n,t=map(int,input().split())
a=[int(i) for i in input().split()]
p=a[0]
c=0
for i a:
  c+=t-i if p+t>i else t
print(c)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
ans = 0
switches = list(map(int, input().split()))
switches.append(10**9+10)
for idx in range(N):
  ans += min(K, switches[i+1] - switches[i])
print(ans)

Submission status: Runtime Error

Solution code:
N, K = int(input())
ans = 0
switches = list(map(int, input().split()))
switches.append(10**9+10)
for idx in range(N):
  ans += min(K, switches[i+1] - switches[i])
print(ans)

Submission status: Runtime Error

Solution code:
N, T= map(int, input().split(' '))
X = [int(i) for i in input().split()]
num = T
for i in range(1, n):
  num += min(T, X[i] - X[i - 1])
print(num)

Submission status: Runtime Error

Solution code:
N, T= map(int, input().split(' '))
X = [int(i) for i in input().split()]
num = T
for i in range(1, n):
    num += min(T, X[i] - X[i - 1])
print(num)

Submission status: Runtime Error

Solution code:
N, T = list(map(int, input().split()))

t = list(map(int, input().split()))

if N == 1:
    print(T)
    exit(T)

ans = 0
buff = 0
for i in range(N):
    if T > t[i]:
        buff = t[i]
        if i == N-1:
            ans += buff
    elif T <= t[i]:
        if buff + T > t[i]:
            ans += t[i]
        elif buff + T < t[i]:
            ans += T + buff
        elif buff == t[i]:
            pass
        buff = 0

ans += T
print(ans)

Submission status: Runtime Error

Solution code:
N, T = list(map(int, input().split()))

t = list(map(int, input().split()))

if N == 1:
    print(T)
    exit(T)

ans = 0
buff = 0
for i in range(N):
    if T > t[i]:
        buff = t[i]
        if i == N-1:
            ans += buff
    elif T <= t[i]:
        if buff + T > t[i]:
            ans += t[i]
        elif buff + T <= t[i]:
            ans += T + buff
        buff = 0

ans += T
print(ans)

Submission status: Runtime Error

Solution code:
N, T = list(map(int, input().split()))

t = list(map(int, input().split()))

if N == 1:
    print(T)
    exit(T)

ans = 0
buff = 0
for i in range(N):
    if T > t[i]:
        buff = t[i]
        if i == N-1:
            ans = buff
    elif T <= t[i]:
        if buff + T > t[i]:
            ans += t[i]
        elif buff + T <= t[i]:
            ans += T + buff
        buff = 0

ans += T
print(ans)

Submission status: Runtime Error

Solution code:
N, T = list(map(int, input().split()))

t = list(map(int, input().split()))

if N == 1:
    print(T)
    exit(T)

ans = 0
buff = 0
for i in range(N):
    if T > t[i]:
        buff = t[i]

    elif T <= t[i]:
        if buff + T > t[i]:
            ans += t[i]
        elif buff + T <= t[i]:
            ans += T + buff
        buff = 0

ans += T
print(ans)

Submission status: Runtime Error

Solution code:
N, T = list(map(int, input().split()))

t = list(map(int, input().split()))

if N == 1:
    print(T)
    exit(T)

# t.pop(0)
ans = 0
buff = 0
for i in range(N):
    if t[i] <= T:
        buff = t[i] + T

        if N - 1 > i:
            if t[i+1] < buff:
                buff = t[i+1]

    elif t[i] > T:
        ans += buff + T
        buff = 0

print(max(ans, buff))

Submission status: Runtime Error

Solution code:
N, T = list(map(int, input().split()))

t = list(map(int, input().split()))

if N == 1:
    print(T)
    exit(T)

# t.pop(0)
ans = 0
buff = 0
for i in range(N):
    print(buff)
    if t[i] <= T:
        buff = t[i] + T

        if N - 1 > i:
            if t[i+1] < buff:
                buff = t[i+1]
        if i == N-1:
            print(buff)

    elif t[i] > T:
        ans += buff + T
        buff = 0

print(max(ans, buff))

Submission status: Runtime Error

Solution code:
# ABC060C - Sentou (ARC073C)
n, t = list(map(int, input().rstrip().split()))
lst = list(map(int, input().rstrip().split()))
ans, cur = 0, i[0]
for i in lst[1:]:
    ans += min(t, i - cur)
ans += t
print(ans)

Submission status: Runtime Error

Solution code:
n, time = map(int, input().split())
 
arr = list(map(int, input().split())) + [float("inf")]
 
left, temp, sum_time = 0, 0, 0
 
for t in arr[1:]:
  if t <= temp + time:
    temp = t
  else:
    sum_time += (temp + time - left)
    left, temp = t
 
print(sum_time)

Submission status: Runtime Error

Solution code:
n, time = map(int, input().split())

arr = list(map(int, input().split())) + [float("inf")]

left, temp, sum_time = 0, 0, 0

for t in arr[1:]:
  if t <= left + time:
    temp = t
  else:
    sum_time += (temp + time - left)
    left, temp = t

print(sum_time)

Submission status: Runtime Error

Solution code:
n,t=map(int,input().split())
arr=list(map(int,input()))
start=arr[0]
ans=0
for i in range(1,n):
  tmp=arr[i]
  if tmp-start<t:
    ans+=tmp-start
  else:
    ans+=t
  start=tmp
print(ans+t)

Submission status: Runtime Error

Solution code:
n,t=map(int,input().split())
arr=list(map(int,input()))
s=arr[0]
ans=0
tmp=0
for i in range(1,n):
  if arr[i]-s<=t:
    tmp=arr[i]-s
  else:
    ans+=tmp+t
    tmp=0
ans+=tmp+t
print(ans)

Submission status: Runtime Error

Solution code:
import sys
n,t=map(int,input().split())
T=[int(i) for i in sys.stdin]
endtime=0
for i in t:
  if endtime>i+t:
    endtime=endtime-(endtime-i)+t
print(endtime)

Submission status: Runtime Error

Solution code:
from itertools import accumulate
N, T = map(int, input().split())
t = [int(i) for i in input().split()]
a = [0]*(t[-1]+T+1)
for x in t:
    a[x] += 1
    a[x+T] += -1
ans = len(a)-list(accumulate(a)).count(0)
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import accumulate
N, T = map(int, input().split())
t = [int(i) for i in input().split()]
a = [0]*(t[-1]+T+1)
for x in t:
    a[x] = 1
    a[x+T] = -1
ans = len(a)-list(accumulate(a)).count(0)
print(ans)

Submission status: Runtime Error

Solution code:
N, T = map(int, input().split())
L = [int(i) for i in input().split()]
gap=[]
time=T

for i in range(N-1)
	gap.append(L[i+1]-L[i])

for i in range(N-1):
	time += min(B[i],T)

print(time)

Submission status: Runtime Error

Solution code:
from functools import reduce; from operator import add; print((lambda T, L: reduce(add, (lambda t, l: [min(i - j, t) for i, j in zip(l[1:], l[:-1])])(T, L), initializer=T))(int(input().split()[1]), list(map(int, input().split()))))

Submission status: Runtime Error

Solution code:
from functools import reduce; from operator import add; print((lambda T, L: T + reduce(add, (lambda t, l: [min(i - j, t) for i, j in zip(l[1:], l[:-1])])(T, L)))(int(input().split()[1]), list(map(int, input().split()))))

Submission status: Runtime Error

Solution code:
num,time = map(int, raw_input().split())
t = raw_input().split()
ans = time
for i in range(0,num-1):
  a = int(t[i+1])-int(t[i]) 
	if a < time:
		ans += a
	else:
		ans += time
print ans

Submission status: Runtime Error

Solution code:
num,time = map(int, raw_input().split())
t = raw_input().split()
ans = 0
for i in t:
	if i<time:
		ans += i
	else:
	ans += time
ans += time
ans -= t[len(t)]
print ans

Submission status: Runtime Error

Solution code:
num,time = map(int, raw_input().split())
t = raw_input().split()
ans = 0
for i in t:
	if i<time:
		ans += i
	else:
	ans += time
ans += time
ans -= t[len(t)-1]
print ans

Submission status: Runtime Error

Solution code:
num,time = map(int,raw_input().split())
t = map(int, raw_input().split())
ans = 0
for i in range(len(t)-1):
	if t(i)<time:
		ans += t(i)
	else:
	ans += time
ans += time
print ans

Submission status: Runtime Error

Solution code:
num,time = map(int,raw_input().split())
t = map(int, raw_input().split())
ans = 0
for i in range(len(t)-1):
	if t[i]<time:
		ans += t[i]
	else:
	ans += time
ans += time
print ans

Submission status: Runtime Error

Solution code:
N, T = list(map(int, input().split()))
push_list = list(map(int, input().split()))
print(push_list)

dabaaaaa = 0

for i in range(len(dabaaaaa)-1):
    if push_list[i + 1] - push_list[i] < 5:
        dabaaaaa += push_list[i + 1] - push_list[i]
    else:
        dabaaaaa += 5

print(dabaaaaa)