Harryxun/stf_run huggingface dataset:
def main()
  import sys
  input=sys.stdin.readline
  sx,sy,tx,ty=map(int,input().split())
  n=int(input())
  p=[(sx,sy,0)]
  for _ in range(n):
    x,y,r=map(int,input().split())
    p.append((x,y,r))
  p.append((tx,ty,0))
  n+=2
  edge=[[]for _ in range(n)]
  for i in range(n-1):
    for j in range(i+1,n):
      sx,sy,sr=p[i]
      tx,ty,tr=p[j]
      t=(abs(sx-tx)**2+abs(sy-ty)**2)**0.5
      c=max(0,t-(sr+tr))
      edge[i].append((j,c))
      edge[j].append((i,c))
  from heapq import heappop,heappush
  def dijkstra(s,n,edge):
    inf=10**20
    ans=[inf]*n
    ans[s]=0
    root=[-1]*n
    h=[[0,s]]
    while h:
      c,v=heappop(h)
      if ans[v]<c:continue
      for u,t in edge[v]:
        if c+t<ans[u]:
          ans[u]=c+t
          root[u]=v
          heappush(h,[c+t,u])
    print(ans[n-1])
  dijkstra(0,n,edge)
if __name__ == "__main__":
  main()

### FIXED CODE ###

import sys
input=sys.stdin.readline
sx,sy,tx,ty=map(int,input().split())
n=int(input())
p=[(sx,sy,0)]
for _ in range(n):
  x,y,r=map(int,input().split())
  p.append((x,y,r))
p.append((tx,ty,0))
n+=2
edge=[[]for _ in range(n)]
for i in range(n-1):
  for j in range(i+1,n):
    sx,sy,sr=p[i]
    tx,ty,tr=p[j]
    t=(abs(sx-tx)**2+abs(sy-ty)**2)**0.5
    c=max(0,t-(sr+tr))
    edge[i].append((j,c))
    edge[j].append((i,c))
from heapq import heappop,heappush
inf=10**20
ans=[inf]*n
ans[0]=0
root=[-1]*n
h=[(0,0)]
while h:
  c,v=heappop(h)
  if ans[v]<c:continue
  for u,t in edge[v]:
    if c+t<ans[u]:
      ans[u]=c+t
      root[u]=v
      heappush(h,(c+t,u))
print(ans[n-1])
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = l()
alf = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(s)):
	alf = alf.trplace(s[i],"")
print(alf)
if alf == "":
	print("None")
else:
	print(alf[0])


### FIXED CODE ###

def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = l()
alf = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(s)):
	alf = alf.replace(s[i],"")
if alf == "":
	print("None")
else:
	print(alf[0])
# modなしの場合は，mod=1にする

class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

N, A, B = map(int, input().split())
MOD = 10**9 + 7

def calc(k):
    ret = 1
    for i in range(k):
        ret = ret * (N - i) * pow(i + 1, -1, MOD) % MOD
    return ret

ans = pow(2, N, MOD) - 1 - calc(A) - calc(B)
print(ans % MOD)

### FIXED CODE ###

# modなしの場合は，mod=1にする

class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

N, A, B = map(int, input().split())
MOD = 10**9 + 7

def calc(k):
    ret = 1
    for i in range(k):
        ret = ret * (N - i) * pow(i + 1, MOD - 2, MOD) % MOD
    return ret

ans = pow(2, N, MOD) - 1 - calc(A) - calc(B)
print(ans % MOD)
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n,q = get_nums_l()

lines = sys.stdin.readlines()
edges = list(map(lambda s:list(map(int, s.split(" "))), lines[:n-1]))
queries = list(map(lambda s:list(map(int, s.split(" "))), lines[n-1:]))

scores = [0] * (n+1)

for q in queries:
    scores[q[0]] += q[1]

queue = deque()
mark = [False] * (n+1)
mark[1] = True

for e in edges:
    queue.append(e)

for e in queue:
    a = e[0]
    b = e[1]
    if mark[a]:
        scores[b] += scores[a]
        mark[b] = True
    elif mark[b]:
        scores[a] += scores[b]
        mark[a] = True
    else:
        queue.append(e)

print(" ".join(map(str,scores[1:])))


### FIXED CODE ###

import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n,q = get_nums_l()

lines = sys.stdin.readlines()
edges = list(map(lambda s:list(map(int, s.split(" "))), lines[:n-1]))
queries = list(map(lambda s:list(map(int, s.split(" "))), lines[n-1:]))

scores = [0] * (n+1)

for q in queries:
    scores[q[0]] += q[1]

queue = deque()
mark = [False] * (n+1)
mark[1] = True


childrens = [ [] for _ in range(n+1) ]
for e in edges:
    a = e[0]
    b = e[1]
    childrens[a].append(b)
    childrens[b].append(a)


queue.append(1)

while queue:
    a = queue.popleft()
    children = childrens[a]
    for b in children:
        if not mark[b]:
            scores[b] += scores[a]
            mark[b] = True
            queue.append(b)

print(" ".join(map(str,scores[1:])))
a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())

a_syo = a//10
b_syo = b//10
c_syo = c//10
d_syo = d//10
e_syo = e//10
time1 = (a_syo + b_syo + c_syo + d_syo + e_syo) * 10

a_amari = a%10
b_amari = b%10
c_amari = c%10
d_amari = d%10
e_amari = e%10
lst = []
if a_amari == 0:
    pass
else:
    lst = lst + [a_amari]
if b_amari == 0:
    pass
else:
    lst = lst + [b_amari]
if c_amari == 0:
    pass
else:
    lst = lst + [c_amari]
if d_amari == 0:
    pass
else:
    lst = lst + [d_amari]
if e_amari == 0:
    pass
else:
    lst = lst + [e_amari]
#print (lst)
count = len(lst) - 1
#print (count)
lst.sort()
#print (lst)
time2 = (len(lst) -1)*10 + lst[0]
print (time1 + time2)

### FIXED CODE ###

a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())

a_syo = a//10
b_syo = b//10
c_syo = c//10
d_syo = d//10
e_syo = e//10
time1 = (a_syo + b_syo + c_syo + d_syo + e_syo) * 10

a_amari = a%10
b_amari = b%10
c_amari = c%10
d_amari = d%10
e_amari = e%10
lst = []
if a_amari == 0:
    pass
else:
    lst = lst + [a_amari]
if b_amari == 0:
    pass
else:
    lst = lst + [b_amari]
if c_amari == 0:
    pass
else:
    lst = lst + [c_amari]
if d_amari == 0:
    pass
else:
    lst = lst + [d_amari]
if e_amari == 0:
    pass
else:
    lst = lst + [e_amari]
if len(lst) == 0:
    print (time1)
else:
    #print (lst)
    count = len(lst) - 1
    #print (count)
    lst.sort()
    #print (lst)
    time2 = (len(lst) -1)*10 + lst[0]
    print (time1 + time2)
import numpy as np


n = int(input())
a = [2*int(_) for _ in input().split()]
s = []
for i in range(n):
    l = [0 for _ in range(n)]
    l[i] = 1
    if i+1 != n:
        l[i+1] = 1
    else:
        l[0] = 1
    s.append(l)
A = np.array(s)
b = np.array(a)
Ainv = np.linalg.inv(A)
x = np.dot(Ainv, b)
for i in range(len(x)):
    print(int(x[i]))

### FIXED CODE ###

n = int(input())
a = [2*int(_) for _ in input().split()]
t = a[-1]
x = [0 for _ in range(n)]
for i in range(-2, -n-1, -1):
    t = a[i] - t
x[0] = t // 2
for i in range(0, n-1):
    x[i+1] = a[i] - x[i]
for i in range(len(x)):
    print(x[i])
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	try:
		n=int(raw_input())
		if n==-1:break
		e=0
		for i in range(n):
			a=ref[int(raw_input())]
			print "{:07b}".format(a^e)
			e=a
	except SyntaxError:
		pass

### FIXED CODE ###

ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	try:
		n=input()
		if n==-1:break
		e=0
		for i in range(n):
			a=ref[input()]
			print "{:07b}".format(a^e)
			e=a
	except:
		pass
N = int(input())
for i in range(1, 10):
  if N / i == N // i:
    if N / i < 10:
      print("Yes")
      return
print("No")
      

### FIXED CODE ###

import sys
N = int(input())
for i in range(1, 10):
  if N / i == int(N / i):
    if N / i < 10:
      print("Yes")
      sys.exit()
print("No")
s=input()
a=0
r=0
for i in range(len(s)):
  if s[i]=="A":
    a=a+1
    if s[i+1]=="C":
      a=0
  elif s[i]=="B":
    if s[i+1]=="C":
      r=r+a
    else:
      a=0
print(r)

### FIXED CODE ###

s=input()
a=0
r=0
for i in range(len(s)-1):
  if s[i]=="A":
    a=a+1
    if s[i+1]=="C":
      a=0
  elif s[i]=="B":
    if s[i+1]=="C":
      r=r+a
    else:
      a=0
  elif s[i]=="C":
    if s[i+1]=="C":
      a=0
print(int(r))
a = int(input())
s = input()
if a < 3200:
    print(red)
elif a >= 3200:
    print(s)

### FIXED CODE ###

a = int(input())
s = input()
if a < 3200:
    print("red")
elif a >= 3200:
    print(s)
input_str = input().split("\n")
number = int(input_str[0])

temp = int(input_str[1].split()[0])
goal = int(input_str[1].split()[1])

Hn = list(map(int, input_str[2].split()))

avg_temp = [(temp - (Hn * 0.006)) / goal for Hn in Hn]

if goal >= 0:
    print(int((avg_temp.index(max(avg_temp))) + 1))
else:
    print(int((avg_temp.index(min(avg_temp))) + 1))

### FIXED CODE ###

def main(n, t, a, h):
    def formula(t, x): return t - x * 0.006
    res = []

    for _h in h:
        res.append(abs(a - formula(t, _h)))

    print(res.index(min(res)) + 1)


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

    main(n, t, a, h)
#count
for l in lis:
  if l in dic: dic[l] += 1
  else: dic[l] = 1

#dic_sum = dic.copy()
s = 0
#calcurate
for d in dic:
  s += int(dic[d]*(dic[d]-1)/2)
  
for i in range(inp):
  #dic_sum_n = dic_sum.copy()
  t = dic[lis[i]]
  print(s-int(t*(t-1)/2)+int((t-1)*(t-2)/2))


### FIXED CODE ###

inp = int(input())
lis = list(map(int, input().split()))

dic = {}

#count
for l in lis:
  if l in dic: dic[l] += 1
  else: dic[l] = 1

#dic_sum = dic.copy()
s = 0
#calcurate
for d in dic:
  s += int(dic[d]*(dic[d]-1)//2)
  
for i in range(inp):
  #dic_sum_n = dic_sum.copy()
  t = dic[lis[i]]
  print(s-int(t*(t-1)//2)+int((t-1)*(t-2)//2))
import sys

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

if k==0:
    print(max(a))
    sys.exit()

def rf(mm):
    if mm==0:
        mm=1
#        return sum(a)
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(60):
#    print(ii,m)
    if um-lm<10:
        break
    elif rf(m)>(n+k):
        lm=m
        m=(um+lm)//2
    elif rf(m)<(n+k):
        um=m
        m=(lm+um)//2
    elif rf(m)==n+k and rf(m-1)==n+k:
        um=m
        m=(lm+um)//2
    else:
        continue
#        print(m)
#        break

for mi in range(um,lm-1,-1):
#    print("mi:",mi)
    if rf(mi)==(n+k) and rf(mi-1)>(n+k):
        break
print(mi)


### FIXED CODE ###

import sys

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

if k==0:
    print(max(a))
    sys.exit()

def rf(mm):
    if mm==0:
        mm=1
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(60):
    if m==1:
        break
    if rf(m)<=(n+k) and rf(m-1)>(n+k):
        break
    if um-lm<5:
        break
    if rf(m)>(n+k):
        lm=m
        m=(um+lm)//2-1
    elif rf(m)<(n+k):
        um=m
        m=(um+lm)//2-1
    else:
        um=m-1
        m=(um+lm)//2-1
#    if rf(m)==(n+k) and um-lm<5:

if um<1:
    print(1)
    sys.exit()
    
for mi in range(um,max(0,lm-1),-1):
    if rf(mi)<=(n+k) and rf(mi-1)>(n+k):
        break

print(mi)
def exec_ncr(max_step, record_dict):
    for i in range(2, max_step):
        record_dict[i] = record_dict[i-1] + record_dict[i-2]


num_stair, num_wet = map(int, input().split(' '))

last_wet = -1
num_pattern = 1
d = {0: 1, 1: 1}
exec_ncr(100000, d)

for i in range(0, num_wet):
    wet = int(input())
    dry_step = wet - last_wet - 1
    last_wet = wet

    if dry_step <= 0:
        print('0')
        exit(0)

    elif dry_step == 1 or dry_step == 2:
        continue

    else:
        num_pattern *= d[dry_step-1]

# last step
dry_step = num_stair - last_wet

num_pattern *= d[dry_step-1]

print(num_pattern % 1000000007)
exit(0)


### FIXED CODE ###

def exec_ncr(max_step, record_dict):
    for i in range(2, max_step+1):
        record_dict[i] = record_dict[i-1] + record_dict[i-2]


num_stair, num_wet = map(int, input().split(' '))

last_wet = -1
num_pattern = 1
d = {0: 1, 1: 1}
exec_ncr(num_stair, d)

for i in range(0, num_wet):
    wet = int(input())
    dry_step = wet - last_wet - 1
    last_wet = wet

    if dry_step <= 0:
        print('0')
        exit(0)

    elif dry_step == 1 or dry_step == 2:
        continue

    else:
        num_pattern *= d[dry_step-1]

# last step
dry_step = num_stair - last_wet

num_pattern *= d[dry_step-1]

print(num_pattern % 1000000007)
exit(0)
A, B, C = map(int,input().split(' '))


def calc1(A,B,C):
  if A*C <= B:
    return C
  else:
    #回数
    N = 0
    while A*N <=B:
      N += 1
    return N-1
print(calc1(A,

### FIXED CODE ###

A, B, C = map(int,input().split(' '))


def calc1(A,B,C):
  if A*C <= B:
    return C
  else:
    #回数
    N = 0
    while A*N <=B:
      N += 1
    return N-1
print(calc1(A,B,C))
N, Y = map(int, input().split())
 
#10000:a, 5000:b, 1000:c
for a in range(N+1):
    for b in range(N+1-a):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            print(a, b, c)
            break
print(-1, -1, -1)

### FIXED CODE ###

S = input()

print(S.replace('2017', '2018'))
from sys import stdin

N, L = stdin.readline().rstrip()

# N, L = 5, 2
# N, L = 3, -1
# N, L = 30, -50

min_value = L
max_value = L + N - 1

summation = L * N + sum(range(N))

if (min_value < 0) and (0 < max_value):
    pass
elif (min_value > 0):
    summation -= min_value
elif (max_value < 0):
    summation -= max_value

### FIXED CODE ###

from sys import stdin

# N, L = stdin.readline().rstrip()
N, L = map(int, input().split(' '))
# print(N, L)
# N, L = 5, 2
# N, L = 3, -1
# N, L = 30, -50

min_value = L
max_value = L + N - 1

summation = L * N + sum(range(N))

if (min_value < 0) and (0 < max_value):
    pass
elif (min_value > 0):
    summation -= min_value
elif (max_value < 0):
    summation -= max_value
    
print(summation)
def main():
    from sys import stdin
    #input = stdin.readline
    import numpy as np
    h, w, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    ab_d = {(a, b) for a, b in ab}

    ans = [set() for _ in range(9)]
    for a, b in ab:
        temp = np.full((5, 5), None, dtype=np.int64)
        for i in range(max(0, 3-a), min(5, h-a+3)):
            for j in range(max(0, 3-b), min(5, w-b+3)):
                if (a+i-2, b+j-2) in ab_d:
                    temp[i, j] = 1
                else:
                    temp[i, j] = 0
        # print(temp)
        flag_yoko = [0, 5]
        flag_tate = [0, 5]
        if np.all(temp[:, 0] == np.full((1, 5), None, dtype=np.int64)):
            if np.all(temp[:, 1] == np.full((1, 5), None, dtype=np.int64)):
                flag_yoko[0] = 2
            else:
                flag_yoko[0] = 1
        if np.all(temp[:, 4] == np.full((1, 5), None, dtype=np.int64)):
            if np.all(temp[:, 3] == np.full((1, 5), None, dtype=np.int64)):
                flag_yoko[1] = 3
            else:
                flag_yoko[1] = 4
        if np.all(temp[0, :] == np.full(5, None, dtype=np.int64)):
            if np.all(temp[1, :] == np.full(5, None, dtype=np.int64)):
                flag_tate[0] = 2
            else:
                flag_tate[0] = 1
        if np.all(temp[4, :] == np.full(5, None, dtype=np.int64)):
            if np.all(temp[3, :] == np.full(5, None, dtype=np.int64)):
                flag_tate[1] = 3
            else:
                flag_tate[1] = 4
        new_temp = temp[flag_tate[0]:flag_tate[1], flag_yoko[0]:flag_yoko[1]]
        # print(new_temp)
        for i in range(flag_tate[1]-flag_tate[0]-2):
            for j in range(flag_yoko[1]-flag_yoko[0]-2):
                cnt = [new_temp[i+k, j+l] for k in range(3) for l in range(3)]
                if None not in cnt:
                    ans[sum(cnt)-1].add((a+i-2+flag_tate[0], b+j-2+flag_yoko[0]))

    for i in range(9):
        ans[i] = len(ans[i])

    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)


main()


### FIXED CODE ###

h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*n]
ab_d={a*(10**9)+b-1 for a,b in ab}

ans=[set() for _ in range(9)]
for a,b in ab:
    temp=[None for _ in [0]*25]
    for i in range(5):
        for j in range(5):
            if 0<a+i-2<=h and 0<b+j-2<=w:
                if (a+i-2)*(10**9)+b+j-3 in ab_d:
                    temp[i*5+j]=1
                else:
                    temp[i*5+j]=0
    for i in range(3):
        for j in range(3):
            cnt=[temp[(i+k)*5+j+l] for k in range(3) for l in range(3)]
            if None not in cnt:
                ans[sum(cnt)-1].add((a+i-2)*(10**9)+b+j-3)
                
for i in range(9):
    ans[i]=len(ans[i])

print((h-2)*(w-2)-sum(ans))
for i in ans:
    print(i)
n, k = map(int, input().split())

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

city = 1
route = []
cnt = [0] * n
route.append(0)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)

if k <= len(route):
    print(route[k])

else:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])

### FIXED CODE ###

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

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

city = 1
route = []
cnt = [0] * n
cnt[0] += 1
route.append(1)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)


if k < len(route):
    print(route[k])

else:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])
n = int(input())
p = [input() for i in range(n)]
print(sum(p) - int(max(p)/2))


### FIXED CODE ###

l = [int(input()) for _ in range(int(input()))]
print(sum(l) - max(l)//2)
h, w = map(long, input().split())

a = h * w
if a % 2 == 0:
  print(long(a / 2))
else:
  print(long((a - 1) / 2))

### FIXED CODE ###

h, w = map(int, input().split())

if h == 1 or w == 1:
  print(1)
else:
  a = h * w
  if a % 2 == 0:
    print(int(a / 2))
  else:
    print(int((a + 1) / 2))
Week=["SAT","FRI","THU","WED","TUE","MON","SUN"]
 Day=input()
 print(Week.index(Day)+1)

### FIXED CODE ###

N = input()
if N == "SUN":
    print(7)
elif N == "MON":
    print(6)
elif N == "TUE":
    print(5)
elif N == "WED":
    print(4)
elif N == "THU":
    print(3)
elif N == "FRI":
    print(2)
elif N == "SAT":
    print(1)
s = input().split('i')

h = s[:len(s)-1]
space = s[len(s)-1]


for j in h:
  if j =='h' and space == '':
    ans = 'Yes'
  else:
    ans = 'No'
    break
  
print(ans)


### FIXED CODE ###

h = input()

result = 'Yes'

if len(h)%2 != 0:
  result ='No'
  
for a in range(0,len(h)-1,2):  
  b = h[a:a+2]
  if b != 'hi':
    result = 'No'
    break
    
print(result)
while True:
	try:
		line = input()
		if line == '0 ? 0':
			break	
		else:
			a,op,b = line.split(' ')
			if op == '+':
				print(int(a)+int(b))
			if op == '-':
				print(int(a)-int(b))
			if op == '*':
				print(int(a)*int(b))
			if op == '/':
				print(int(float(a)/float(b)))
	except EOFError:
		break


### FIXED CODE ###

while True:
	try:
		line = input()
		if  '?' in line:
			break	
		else:
			a,op,b = line.split(' ')
			if op == '+':
				print(int(a)+int(b))
			if op == '-':
				print(int(a)-int(b))
			if op == '*':
				print(int(a)*int(b))
			if op == '/':
				print(int(float(a)/float(b)))
	except EOFError:
		break
count=0
while True:
    count=count+1
    a=input()
    b=len(a)
    if b==0:
        break
    else:
        print("Case "+count+": "+a)



### FIXED CODE ###

count=0
while True:
    count=count+1
    a=input()
    if int(a)==0:
        break
    else:
        print("Case "+str(count)+": "+str(a))
N=int(input())
S=input()
last = s[0]
cnt = 0
for s in S[1:]:
  if last != s:
    cnt+=1
    last = s
print(cnt)

### FIXED CODE ###

N=int(input())
S=input()
last = S[0]
cnt = 1
for s in S[1:]:
  if last != s:
    cnt+=1
    last = s
print(cnt)
def main():
  import sys
  n = int(input())
  a = list(map(int.sys.stdin.readline().split()))
  b = list(map(int.sys.stdin.readline().split()))
  
  count=0
  
  for i in range(n):
    c1 = a[i] 
    c2 = a[i+1]
    h = b[i]
    ans+=min(c1,h)  
    if h>c1:
        ans+=min(h-c1,c2)
        a[i+1]=max(0,c2-(h-c1))

  print(ans)
  
if __name__=="__main__":
  main()

### FIXED CODE ###

def main():
  import sys
  n = int(input())
  a = list(map(int,sys.stdin.readline().split()))
  b = list(map(int,sys.stdin.readline().split()))
  
  count=0
  
  for i in range(n):
    c1 = a[i] 
    c2 = a[i+1]
    h = b[i]
    count+=min(c1,h)  
    if h>c1:
        count+=min(h-c1,c2)
        a[i+1]=max(0,c2-(h-c1))
 
  print(count)
  
if __name__=="__main__":
  main()