Harryxun/stf_run huggingface dataset:
def main():
    from collections import deque
    n, q = map(int, input().split())
    t = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = map(lambda x: int(x)-1, input().split())
        t[a].append(b); t[b].append(a)
    c = [0]*n
    for i in range(q):
        p, x = map(int, input().split())
        p -= 1
        c[p] += x
    dq = deque([0])

    def dfs(node, p=-1):
        while t[node]:
            child = t[node].pop()
            if child==p:
                continue
            c[child] += c[node]
            dfs(child, node)
    dfs(0)
    print(*c)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

n, q = map(int, input().split())
g = [list() for i in range(n)]
node = [0] * n

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p, x = map(int, input().split())
    node[p-1] += x

def dfs(v, p=-1):
    for u in g[v]:
        if u == p: continue
        node[u] += node[v]
        dfs(u, v)

dfs(0)
print(*node)
def resolve():
    '''
    code here
    '''
    N, C, K = [int(item) for item in input().split()]
    Ts = [int(input()) for _ in range(N)]
    Ts.sort()

    res = 0
    temp_psg = 0
    lim = Ts[0] + K

    for i in range(N):
        temp_psg += 1
        if Ts[i] > lim:
            res += 1
            temp_psg = 1
            lim = Ts[i] + K
        else:
            if temp_psg == C:
                res += 1
                temp_psg = 0
                lim = Ts[i+1] + K
        # print(Ts[i], temp_psg, res, lim)
    
    if temp_psg > 0:
        res += 1
    print(res)


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    '''
    code here
    '''
    N, C, K = [int(item) for item in input().split()]
    Ts = [int(input()) for _ in range(N)]
    Ts.sort()

    res = 0
    temp_psg = 0
    lim = Ts[0] + K

    for i in range(N):
        temp_psg += 1
        if Ts[i] > lim:
            res += 1
            temp_psg = 1
            lim = Ts[i] + K
        else:
            if temp_psg == C and i < N-1:
                res += 1
                temp_psg = 0
                lim = Ts[i+1] + K
        # print(Ts[i], temp_psg, res, lim)
    
    if temp_psg > 0:
        res += 1
    print(res)


if __name__ == "__main__":
    resolve()
s=input()
n=len(s)
print(s[0]+str[n-2]+s[n-1])

### FIXED CODE ###

s=input()
n=len(s)
print(s[0]+str(n-2)+s[n-1])
n = [int(input()) for _ in range(5)]
minNum = 9
x = 0
for i in n:
    if i % 10 < minNum and i % 10 != 0:
        minNum = i % 10
        x = i
n.pop(n.index(x))
total = x
print(total)
for j in n:
    total += ((j + 9) // 10) * 10
print(total)

### FIXED CODE ###

n =  [int(input()) for x in range(5)]
minNum = 10
array = 0
for i in range(len(n)):
    num = n[i] % 10
    if((num <= minNum) and (num != 0)):
        minNum = num
        array = i
        
numList = []
a = n[array]
n[array] = 0

for x in n:
    k = ((x + 9) // 10) * 10
    numList.append(k)  
print(sum(numList) + a)
def digit(i):
 if i > 0:
  return digit(i//10) + [i%10]
 else:
  return []
N=int(input())
lst=digit(N)
L=len(lst)
ans=[[0 for e in range(2)] for f in range(L)]
ans[0][0]=lst[L-1]
ans[0][1]=10-lst[L-1]
for i in range(1,L):
 ans[i][0]=min(ans[i-1][0]+lst[L-1-i],ans[i-1][1]+lst[L-1-i]+1)
 ans[i][1]=min(ans[i-1][0]+10-lst[L-1-i],ans[i-1][1]+10-lst[L-1-i]-1)
print(min(ans[L-1][0],ans[L-1][1]+1))


### FIXED CODE ###

N=input()
L=len(N)
ans=[[0 for e in range(2)] for f in range(L)]
k=int(N[L-1])
ans[0][0]=k
ans[0][1]=10-k
if L>1:
 for i in range(1,L):
  k=int(N[L-1-i])
  ans[i][0]=min(ans[i-1][0]+k,ans[i-1][1]+k+1)
  ans[i][1]=min(ans[i-1][0]+10-k,ans[i-1][1]+10-k-1)
print(min(ans[L-1][0],ans[L-1][1]+1))
S = input()
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
list.sort(A, reverse=True)

for _ in range(M):
    A[0] //= 2
    list.sort(A, reverse=True)

print(sum(A))

### FIXED CODE ###

import sys
import heapq

input = sys.stdin.readline
N, M = map(int, input().split())

A = []
for x in input().split():
    heapq.heappush(A, int(x) * (-1))

for _ in range(M):
    max_n = heapq.heappop(A) * (-1)
    heapq.heappush(A, (max_n // 2) * (-1))
    
print(sum(A) * (-1))
A, V = map(int, input().split())
B, W = map(int, input().split())
T = float(input())
 
if asbs(B - A)  <= abs(T * (V - W)):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

S = input()
print(S[:3])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

A, B = MAP()


print(int(A*B))

### FIXED CODE ###

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

L = input().split()
A = int(L[0])
B = int(L[1].replace(".", ""))


print(int(A*B)//100)
n,m = map(int,input().split())
l_n =list(list(map(int,input().split())) for i in range(n))
l_m =list(list(map(int,input().split())) for i in range(m))
q = 1000000
for i in range(n):
  for t in range(m):
    a,b = l_n[i]
    c,d = l_m[t]
    v= abs(a-c)+abs(b-d)
    if v<q:
      q = v
      z = t
  print(z+1)
  q = 10000000

### FIXED CODE ###

n,m = map(int,input().split())
l_n =list(list(map(int,input().split())) for i in range(n))
l_m =list(list(map(int,input().split())) for i in range(m))
for i in range(n):
  q = 10**9
  for t in range(m):
    a,b = l_n[i]
    c,d = l_m[t]
    v= abs(a-c)+abs(b-d)
    if v<q:
      q = v
      z = t
  print(z+1)
a = input()
if a == 'A':
	print('A')
elif a == 'C':
	print('T')
elif a == 'G'
	print('C')
elif a == 'T':
  	print('G')

### FIXED CODE ###

a = input()
if a == 'A':
  print('T')
elif a == 'C':
  print('G')
elif a == 'G':
  print('C')
elif a == 'T':
  print('A')
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*n
    self.rank = [0]*n
    
  def find_root(self, e):
    if self.root[e] < 0:
      return e
    else:
      r = self.find_root(self.root[e])
      self.root[e] = r
      return r
    
  def combine(self, e1, e2):
    root1 = self.find_root(e1)
    root2 = self.find_root(e2)
    if root1 == root2:
      pass
    elif self.rank[root1] < self.rank[root2]:
      self.root[root1] += self.root[root2]
      self.root[root2] = root1
      self.rank[root1] = self.rank[root2] + 1
    elif self.rank[root2] < self.rank[root1]:
      self.root[root2] += self.root[root1]
      self.root[root1] = root2
      self.rank[root2] = self.rank[root1] + 1
    else:
      self.root[root2] += self.root[root1]
      self.root[root1] = root2
      self.rank[root2] += 1
      
  def in_the_same_group(self, e1, e2):
      r1 = self.find_root(e1)
      r2 = self.find_root(e2)
      if r1 == r2:
        return True
      return False
  

NMK = input().split()
N = int(NMK[0])
M = int(NMK[1])
K = int(NMK[2])
uf = UnionFind(N)
from collections import defaultdict
friend_list = [0]*N
for _ in range(M):
  AB = input().split()
  A = int(AB[0])-1
  B = int(AB[1])-1
  uf.combine(A,B)
  friend_list[A] += 1
  friend_list[B] += 1

block_list = [0]*N
for _ in range(K):
  CD = input().split()
  C = int(CD[0])-1
  D = int(CD[1])-1
  if uf.in_the_same_group(C, D):
    block_list[C] += 1
    block_list[D] += 1

cnt = defaultdict(int)
ans = []
for i in range(N):
  cnt[i] = -uf.root[uf.find_root(i)] - 1 - friend_list[i] - block_list[i]
  ans.append(str(cnt[i]))

print(" ".join(ans))

### FIXED CODE ###

class UnionFind():
 def __init__(self,n):
   self.n=n
   self.root=[-1]*(n+1)
   self.rank=[0]*(n+1)
 def FindRoot(self,x):
   if self.root[x]<0:
     return x
   else:
     self.root[x]=self.FindRoot(self.root[x])
     return self.root[x]
 def Unite(self,x,y):
   x=self.FindRoot(x)
   y=self.FindRoot(y)
   if x==y:
     return
   else:
     if self.rank[x]>self.rank[y]:
       self.root[x]+=self.root[y]
       self.root[y]=x
     elif self.rank[x]<=self.rank[y]:
       self.root[y]+=self.root[x]
       self.root[x]=y
       if self.rank[x]==self.rank[y]:
         self.rank[y]+=1
 def isSameGroup(self,x,y):
   return self.FindRoot(x)==self.FindRoot(y)
 def Count(self,x):
   return -self.root[self.FindRoot(x)]
 
n,m,k=map(int,input().split())
t=UnionFind(n+1)
cnt=[0]*(n+1) #各iについて、iと同一の連結成分に属する友達関係の人、ブロック関係の人の数を数える
for _ in range(m):
 a,b=map(int,input().split())
 cnt[a]+=1 #各iについて、iと同一の連結成分に属する友達関係の人の数を数える
 cnt[b]+=1
 t.Unite(a,b)
for _ in range(k):
 a,b=map(int,input().split())
 if t.isSameGroup(a,b)==True:
   cnt[a]+=1 #各iについて、iと同一の連結成分に属するブロック関係の人の数を数える
   cnt[b]+=1
ans=[0]*(n+1)
for i in range(1,n+1):
 ans[i]=(t.Count(i)-1)-cnt[i] #答えは(各iが属する連結成分のサイズ)-1-((iと同一の連結成分に含まれているiと友達関係にある人の数)+(iと同一の連結成分に含まれているiとブロック関係にある人の数)となる
print(*ans[1:])
(r, c) = [int(i) for i in input().split()]
src = []
for _ in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)
    
last_row = [0 for _ in range(c)]
for rc in range(r):
    for cc in range(c):
        last_row[cc] += src[rc][cc]
src = append(last_row)


for _ in range(r+1):
    print(' '.join([str(a) for a in src[rc]]))

### FIXED CODE ###

(r, c) = [int(i) for i in input().split()]
src = []
for _ in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)
 
last_row = [0 for _ in range(c + 1)]
for rc in range(r):
    for cc in range(c+1):
        last_row[cc] += src[rc][cc]
 
src.append(last_row)
 
 
for rc in range(r + 1):
    print(' '.join([str(a) for a in src[rc]]))
import math
a,b,c,d = map(int, input().split())
lcm = (c*d)//math.gcd(c,d)
sum = b-a+1
x = (b//c) - ((a-1)//c)
y = (b//d) - ((a-1)//d)
z = (b//lcm) - ((a-1)//lcm)
n_i = x+y-z
print(int(sum-n_i))

### FIXED CODE ###

import fractions
a,b,c,d = map(int, input().split())
lcm = (c*d)//fractions.gcd(c,d)
sum = b-a+1
x = (b//c) - ((a-1)//c)
y = (b//d) - ((a-1)//d)
z = (b//lcm) - ((a-1)//lcm)
n_i = x+y-z
print(int(sum-n_i))
N, M = map(int, input().split())
list = sorted(list(map(int, input().split())))
print("Yes" if list[-1*M] >= sum(list)/4M else("No"))

### FIXED CODE ###

def resolve():
    N, M = map(int, input().split())
    vote = list(map(int, input().split()))
    bot = sorted(vote)
    print("Yes" if bot[M*-1] >= sum(vote)/(4*M) else "No")
resolve()
N,M = map(int, input().split())
edge=[[] for j in range(N+1)]
x = [0] * M
y = [0] * M

#N,M=4,5
#x=[1, 1, 3, 2, 3]
#y=[2, 3, 2, 4, 4]
#edge=[[], [2, 3], [4], [2, 4], []]  

for i in range(M):
    x[i], y[i] = map(int, input().split())
    edge[x[i]].append(y[i])
dp=[0]*(N+1)
def f(x):
    if edge[x]==[]:
        return dp[x]
    #num=0
    if edge[x]!=[]:
        num=0
        for i in edge[x]:
            num=max(num,f(i)+1)
        #del edge[x][0]
        dp[x]=max(dp[x],num)
        dp[x]=num
        return dp[x]
for i in range(N):
    f(i+1)
print(max(dp))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
 
 
N, M = map(int, input().split())
 
G = [[] for _ in range(N + 1)]
for i in range(M):
    x, y = map(int, input().split())
    G[x] += [y]
# print(G)
 
dp = [-1] * (N + 1)
 
 
def func(n):
    if dp[n] != -1:
        return dp[n]
    cnt = 0
	# 先にノードが存在する場合
	# ノードが存在しない場合は、cnt=0のままforをすっ飛ばす
    for m in G[n]:
        cnt = max(cnt, func(m) + 1)
    dp[n] = cnt
    return cnt
 
 
for i in range(1, N + 1):
    func(i)
 
# print(dp)
print(max(dp))
a, b = int(input())

print(a*b)

### FIXED CODE ###

a, b = input().split()

print(int(a)*int(b))
class LinearSystemIncidence:
    def __init__(self, N, edges, mod2=False, idx1=True):
        self.N = N
        self.M = len(edges)
        self.mod2 = mod2
        self.X = [0] * self.M
        self.seen = [False] * self.N
        self.G = [list() for _ in range(self.N)]
        for i, (u, v) in enumerate(edges):
            u -= idx1; v -= idx1
            self.G[u].append((i, v))
            self.G[v].append((i, ~u))

    def dfs(self, b, u):
        self.seen[u] = True
        res = b[u]
        for eid, v in self.G[u]:
            fwd = v >= 0
            if not fwd:
                v = ~v
            if self.seen[v]:
                continue
            tmp = self.dfs(b, v)
            self.X[eid] = tmp if fwd else -tmp
            res += tmp

            if self.mod2:
                self.X[eid] &= 1
        if self.mod2:
            res &= 1
        return res

    def solve(self, b):
        for s in range(self.N):
            if self.seen[s]:
                continue
            if self.dfs(b, s):
                return False, list()
        return True, self.X


def main():
    N, M = map(int, input().split())
    E = [tuple(map(int, input().split())) for _ in range(M)]
    C = [0] * N
    for u, v in E:
        C[u-1] += 1

    solver = LinearSystemIncidence(N, E, mod2=True)
    bo, ret = solver.solve(C)
    if bo:
        for i in range(M):
            u, v = E[i]
            if ret[i]:
                print(u, v)
            else:
                print(v, u)
    else:
        print(-1)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

int1 = lambda x: int(x) - 1
n, m = map(int, input().split())
if m % 2:
  print(-1); exit(0)

l = [tuple(map(int1, input().split())) for _ in range(m)]
G = [list() for _ in range(n)]

ps = [-1]*n
tot = [0]*n

def find(x):
  if ps[x] < 0:
    return x
  ps[x] = find(ps[x])
  return ps[x]

def unite(u, v):
  u = find(u)
  v = find(v)
  if ps[u] > ps[v]:
    u, v = v, u
  ps[u] += ps[v]
  ps[v] = u
  return

def same(u, v):
  return find(u) == find(v)

for u, v in l:
  if same(u, v):
    print(u+1, v+1)
    tot[u] += 1
  else:
    G[u].append(v)
    G[v].append(u)
    unite(u, v)

def dfs(v, p):
  for u in G[v]:
    if u == p: continue
    dfs(u, v)
  if p >= 0:
    if tot[v] % 2:
      print(v+1, p+1)
      tot[v] += 1
    else:
      print(p+1, v+1)
      tot[p] += 1
  return

dfs(0, -1)
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()

res = n
for i in range(n+1):
    cash = 0
    t = i
    while t > 0: # 0 ~ iを6で表す
        cash += t % 6
        t //= 6
    t = n - i
    while t > 0: # n-i ~ nを9で表す
        cc += t % 9
        t //= 9
    if res > cash: # cash最小値
        res = cash

print(res)

### FIXED CODE ###

import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()

res = n
for i in range(n+1):
    cc = 0
    t = i
    while t > 0:
        cc += t % 6
        t //= 6
    t = n - i
    while t > 0:
        cc += t % 9
        t //= 9
    if res > cc:
        res = cc

print(res)
def linearSearch(A, n, key):
    i = 0
    A.append(key)
    while A[i] != key:
        i += 1
    del A[n]
    return i != n


if __name__ == '__main__':
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))
    cnt = 0

    for i in q:
        if linearSearch(S, n,T[i]):
            cnt += 1

    print(cnt)

### FIXED CODE ###

def linearSearch(A, n, key):
    i = 0
    A.append(key)
    while A[i] != key:
        i += 1
    del A[n]
    return i != n


if __name__ == '__main__':
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))
    cnt = 0

    for i in range(q):
        if linearSearch(S, n,T[i]):
            cnt += 1

    print(cnt)
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
cost = [0,2,5,5,4,5,6,3,7,6]

dp = [0 for i in range(N+1)]

A = sorted(A, reverse=True)

for num in A:
    c = cost[num]
    dp[c] = max(dp[c], num)

for i in range(N+1):
    for num in A:
        c = cost[num]
        if i-c >= 0:
            prev = dp[i - c]
            cur = dp[i]
            if prev > 0:
                prev_str = str(prev)
                if int(prev_str[0]) > num:
                    nxt_str = prev_str + str(num)
                    nxt = int(nxt_str)
                else:
                    nxt_str = str(num) + prev_str
                    nxt = int(nxt_str)
                if nxt > cur:
                    dp[i] = nxt
                # if i == N:
                #     print(cur, prev, nxt)

print(dp[N])


### FIXED CODE ###

import copy

N, M = map(int, input().split())
A = [int(x) for x in input().split()]
cost = [0,2,5,5,4,5,6,3,7,6]

dp = [[0 for _ in range(10)] for i in range(N+10)]

A = sorted(A, reverse=True)

for num in A:
    c = cost[num]
    if dp[c][0] == 0:
        dp[c][0] = 1
        dp[c][num] = 1

for i in range(1, N+1):
    for num in A:
        c = cost[num]
        prev = copy.deepcopy(dp[i])
        if prev[0] != 0:
            if dp[i + c][0] > dp[i][0] + 1:
                continue
            elif dp[i + c][0] == dp[i][0] + 1:
                nxt = prev
                nxt[num] += 1
                nxt[0] += 1
                for number in range(9, 0, -1):
                    if dp[i + c][number] < nxt[number]:
                        dp[i + c] = copy.deepcopy(nxt)
                        break
                    if dp[i + c][number] > nxt[number]:
                        break
            else:
                nxt = prev
                nxt[num] += 1
                nxt[0] += 1
                dp[i + c] = copy.deepcopy(nxt)

# print(dp[N])
ans = ""
for number in range(9, 0, -1):
    for _ in range(dp[N][number]):
        ans = ans + str(number)

print(ans)
n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

Min = 0
Max = 0

comb_min = 1
comb_max = 1

a_sort = sorted(a)

def SUM(a):
    count = 0
    comb = 1
    for i, num in enumerate(a_sort):
        if i == k-1:
            count += num
        elif i >= k-1:
            comb = comb * i / (i-k+1)
            count += comb * num
    return count

Min = SUM(a_sort)
Max = SUM(a_sort.reverse())

print(int((Min - Max) % (10e08+7)))

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
 
class Combination():
    # コンストラクタ
    def __init__(self, N:int, P:int):
        self.N = N
        self.P = P
 
        # fact[i] = (i! mod P)
        self.fact = [1, 1]   
        # factinv[i] = ((i!)^(-1) mod P)
        self.factinv = [1, 1]
        # factinv 計算用
        self.inv = [0, 1]    
 
        for i in range(2, N+1):
            self.fact.append((self.fact[-1] * i) % P)
            self.inv.append((-self.inv[P % i] * (P // i)) % P)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % P)
    
    # nCk (mod P)   (ただし、n<=N)
    def getComb(self, n:int, k:int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] * self.factinv[n-k] % self.P
 
def main():
    N,K = map(int,input().split())
    A = sorted([int(i) for i in input().split()])
 
    mod = 10**9+7
 
    COMB = Combination(N,mod)
 
    cmb = [0] * (N-K+1)
    for i in range(N-K+1):
        cmb[i] = COMB.getComb(i+(K-1),K-1)
 
    sum_max = 0
    for i in range(K-1,N):
        sum_max = (sum_max + cmb[i-(K-1)] * A[i]) % mod
 
    sum_min = 0
    for i in range(N-K,-1,-1):
        sum_min = (sum_min + cmb[(N-K)-i] * A[i]) % mod
 
    answer = sum_max - sum_min
    print(answer % mod)
 
if __name__ == "__main__":
    main()
import math
lst = []
for i in range(5):
  lst.append(int(input()))
minu = 9
for j in range(5):
  if int(str(lst[j])[-1]) < minu and int(str(lst[j])[-1]) > 0:
    minu = int(str(lst[j])[-1])
    temp = lst[j]
lst.remove(temp)
time = 0
for k in range(4):
  kari = math.ceil(int(lst[k])/10)
  time += int(kari * 10)
time += temp
print(time)

### FIXED CODE ###

import math
lst = []
for i in range(5):
  lst.append(int(input()))
minu = 9
temp = 0
count = 0
for j in range(5):
  if int(str(lst[j])[-1]) < minu and int(str(lst[j])[-1]) > 0:
    minu = int(str(lst[j])[-1])
    temp = lst[j]
    count += 1
if count > 0:
  lst.remove(temp)
else:
  temp = lst[0]
  del lst[0]
time = 0
for k in range(4):
  kari = math.ceil(int(lst[k])/10)
  time += int(kari * 10)
time += temp
print(time)
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))

### FIXED CODE ###

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

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

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

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

ans += T
print(ans)
N,K = map(int,input().split())
list = list(map(int,input().split()))

def dfs(N,ans):
    if N < 0:
        return ans
    return dfs(N-(K -1),ans+1)

print(dfs(N-K,1))

### FIXED CODE ###

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

ans = 1
N = N - K

while N > 0:
    N -= K-1
    ans += 1

print(ans)
s_input =   input().split()
if(s_input[1] == '+'):
    print(int(s_input[0]+int(s_input[2]))
else:
    print(int(s_input[0]-int(s_input[2]))

### FIXED CODE ###

s_input =   input().split()
if(s_input[1] == '+'):
    print(int(s_input[0])+int(s_input[2]))
else:
    print(int(s_input[0])-int(s_input[2]))
tmp = list(input()).split()
val = [int(v) for v in tmp]
if val[0] * val[1] >= val[2]:
  ans = val[2]
  else:
    ans = val[0] * val[1]

### FIXED CODE ###

tmp = input().split()
val = [int(v) for v in tmp]
if val[0] * val[1] >= val[2]:
  ans = val[2]
else:
  ans = val[0] * val[1]
print(ans)