peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
T=input()
T_len=len(T)
S=list(T)
if S[0]=="?":
    S[0]="P"

for i in range(T_len):
    if S[i]=="?":
        if S[i-1]=="P":
            S[i]="D"
        else:
            S[i]="P"
str_changed = "".join(S)
print(str_changed)
# Judge status: Accepted
S=input()
cnt=0
for i in range(len(S)):
    if i%2==int(S[i]):
        cnt+=1
print(min(cnt,len(S)-cnt))
# Judge status: Wrong Answer
ans=''
a, b = (input() for _ in range(2))

for i, j in zip(a, b):
    ans += i + j
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int , input().split()))
b = [a[i] - (i+1) for i in range(n)]
#print(b)
b.sort()

ans = 10 ** 10
for j in range(3):
    bi = b[((n-1)//2+j)%n]
    s = 0
    for i in range(n):
        s += abs(b[i] - bi)
    #print(((n-1)//2+j)%n, s)
    ans = min(ans, s)
print(ans)
# Judge status: Accepted
N = int(input())
H = list(map(int, input().split()))
ans = 0
cnt = 0

pre = H[0]
for h in H[1:]:
    if h <= pre:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
    pre = h
if cnt != 1:
    ans = max(ans, cnt)

print(ans)
# Judge status: Accepted
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
import numpy as np
n,W = mi()
a = [tuple(int(i) for i in input().split()) for _ in range(n)]
dp = np.array([0]*(W+1))
for w,v in a:
    ed = W+1-w
    dp[w:W+1] = np.maximum(dp[w:W+1], dp[0:W+1-w] + v)
print(dp[W])
# Judge status: Wrong Answer
n1 = set([1, 3, 5, 7, 8, 10, 12])
n2 = set([4, 6, 9, 11])
n3 = set([2])
nums = {map(int, input().split())}
print("Yes" if nums <= n1 or nums <= n2 or nums <= n3 else "No")
# Judge status: Wrong Answer
N = int(input())
A = [int(x) for x in input().split()]
d = []
p = 0
for i in range(N):
    d.append(A[i])
    if A[i] in d:
        p = 1
        break
if p == 0:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
d = 25 - int(input())
print("Christmas" + " Eve" * d)
# Judge status: Accepted
s = input()
q = int(input())

add_s = ['', ''] #pre, post
rev_flag = 0

for i in range(q):
    query = input()
    if query == '1':
        rev_flag = (rev_flag+1)%2
    else:
        _, f, c = query.split()
        if f == '1':
            add_s[rev_flag] += c
        else:
            add_s[(rev_flag+1)%2] += c

if rev_flag == 1:
    s = s[::-1]

print(add_s[rev_flag][::-1]+s+add_s[(rev_flag+1)%2])
# Judge status: Wrong Answer
a=int(input())
b=int(input())
c=0
if a==1:
  if b==2:
    c=3
  if b==3:
    c=2
elif a==2:
  if b==1:
    c==3
  if b==3:
    c==1
elif a==3:
  if b==1:
    c==2
  if b==2:
    c==1
print(c)
# Judge status: Accepted
from collections import Counter

N = int(input())
a = sorted(list(map(int, input().split())))

M = 10**6

table = [1] * (M + 1)

B = Counter(a)
Key = list(B.keys())

count = 0
for x in Key:
    if B[x] == 1 and table[x] == 1:
        count += 1

    for i in range(M):
        if i * x > M:
            break
        else:
            table[i * x] = 0

print(count)
# Judge status: Accepted
n=int(input())
d={chr(i):51 for i in range(97,97+26)}

for i in range(n):
    s=input()
    for key in d:
        d[key]=min(d[key],s.count(key))
ans=''
for key in d:
    ans+=key*d[key]
print(ans)
# Judge status: Accepted
# じょえチャンネルおもしろいよ～～～
# https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
print(sum(a[:k]))
# Judge status: Accepted
num=int(input().rstrip())
cases=[]
for i in range(num):
    cases.append(input().rstrip())
target=['AC','WA','TLE','RE']
result=[0,0,0,0]
for j in range(len(target)):
    for i in range(len(cases)):
        if cases[i]==target[j]:
            result[j]=result[j]+1
for i in range(len(target)):
    print(target[i]+' x '+str(result[i]))
# Judge status: Accepted
A=int(input())
B=int(input())
C=int(input())
x=int(input())
ans=0
L=[500*a+100*b+50*c for c in range(C+1) for b in range(B+1) for a in range(A+1)]
print(L.count(x))
# Judge status: Accepted
S=input()
A = ""
B = ""
if len(S)%2 == 0:
    N = len(S)//2-1
else : N = len(S)//2
while True:
    for i in range(N):
        A += S[i]
        B += S[i+N]
    if A == B:
        print(len(A)*2)
        break
    else:
        N -= 1
        A = ""
        B = ""
# Judge status: Wrong Answer
x,a,b = map(int,input().split())
print(min(abs(x-a),abs(x-b)))
# Judge status: Accepted
N = int(input())

print((int(N**(1/2)))**2)
# Judge status: Accepted
N,K=map(int,input().split())
S=input()
e=(S[0]=='L')+(S[-1]=='R')
i=S.count("RL")
c=max(i-K,0)*2+max(e-max(K-i,0),0)

print(N-max(c,1))
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))
i = 0
ans = 0
root = [-1] * n
flag = [False] * n
j = 0
while flag[a[i] - 1] == False:
    flag[a[i] - 1] = True
    root[j] = a[i]
    i = a[i] - 1
    j += 1
s_i = root.index(a[i])
x = 0
for i in range(k % (j - s_i)):
    ans = root[x]
    x = root[x] - 1

print(ans)
# Judge status: Accepted
S = str(input())
check = 1
for i in range(len(S)):
    if i%2==0 and S[i]=='L':
        check = 0
        break
    elif i%2==1 and S[i]=='R':
        check = 0
        break
if check == 1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a = int(input())
b = input()

if a < 3200 and b:
    print("red")
else:
    print(b)
# Judge status: Accepted
import collections
target = int(raw_input())
t = 0
while(target):
	target -= min(target, t + 1)
	t +=1
print t
# Judge status: Wrong Answer
P, Q, R = map(int, input().split())
List =[P+Q, Q+R, R+P]
List.sort
print(List[0])
# Judge status: Accepted
L = int(input())
y = L / 3

V = (y * ((y - L) ** 2)) / 4
print(V)
# Judge status: Accepted
S=input()

if "Sunny"==S:
    print("Cloudy")
elif "Cloudy"==S:
    print("Rainy")
elif "Rainy"==S:
    print("Sunny")
# Judge status: Accepted
N = int(input())
S = '0'
S += input()
R_count = 0
G_count = 0
B_count = 0
for i in range(1, N + 1):
  if S[i] == 'R':
    R_count += 1
  if S[i] == 'G':
    G_count += 1
  if S[i] == 'B':
    B_count += 1
res = R_count * G_count * B_count
for i in range(1, N + 1):
  for j in range(i + 1, N + 1):
    if 2 * j - i > N:
      break
    temp = []
    temp += S[i] + S[j] + S[2 * j - i]
    temp.sort()
    if temp[0] == 'B' and temp[1] == 'G' and temp[2] == 'R':
      res -= 1
print(res)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = list(set(a))

ans = 0
for i in range(len(b)):
    if a.count(b[i]) != b[i]:
        ans += min(abs(a.count(b[i]) - b[i]), a.count(b[i]))
print(ans)
# Judge status: Wrong Answer
x = int(input())
loop = 6+5
if x%loop <= 6:
    mod = 1
else:
    mod = 2
print(2*(x//loop)+mod)
# Judge status: Wrong Answer
import numpy
N,M,X = map(int,input().split())
A = numpy.array([[int(i) for i in input().split()] for _ in range(N)])
ans = 10**6
for i in range(2**N) :
    i = format(i,'b').zfill(N)
    s = 0
    check = numpy.array([0]*(M+1))
    for j in range(N) :
        if i[j] == '0' :
            continue
        check +=  A[j][0:]
#        print('i = {},j = {},check = {}'.format(i,j,check))
    if all (check[m] >= X for m in range(1,M)) :
        ans = min(ans,check[0])

print(ans)
# Judge status: Wrong Answer
#!/usr/bin/env python3

s = input()

def dfs(i, n, ns):
    if i == 3:
        if n == 7:
            print(ns + '=7')
            return
        else:
            return

    dfs(i+1, n + int(s[i+1]), ns + '+' + s[i+1])
    dfs(i+1, n - int(s[i+1]), ns + '-' + s[i+1]) 


dfs(0, int(s[0]), s[0])
# Judge status: Wrong Answer
import sys

H,N = map(int, input().split())
D=list()
for i in range(N):
    a,b = map(int, input().split())
    D.append((a, b, a/b))
ans = 0
M = list(sorted(D, key=lambda tup: tup[2], reverse=True))

ans = (H // M[0][0]) * M[0][1]
H = H % M[0][0]
if H == 0:
    print(ans)
    sys.exit()

dp = [[H]]

mi = float("inf")
for d in M:
    mp = (H // d[0]) * d[1]
    if H % d[0] != 0:
        mp += d[1]
    if mi > mp:
        mi = mp
ans += mi

print(ans)
# Judge status: Accepted
def main():
  N,X,Y=map(int,input().split())

  C=[0]*N
  for i in range(1,N):
    for j in range(i+1,N+1):
      C[min(j-i,abs(X-i)+1+abs(j-Y))]+=1
  for i in range(1,N):
    print(C[i])

main()
# Judge status: Accepted
n, k = map(int, input().split())
D = set(list(input().split()))
for i in range(n, n*10+1):
    if set(str(i))&D == set():
        print(i)
        break
# Judge status: Accepted
n = int(input())
a, b, c = [list(map(int, input().split())) for _ in range(3)]
s = sum(b)
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        s += c[a[i] - 1]

print(s)
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
count = 0
l.sort()

for i in range(n-2):
    for j in range(i+1,n-1):
        if l[i] == l[j]:
            continue
        for k in range(j+1,n):
            if l[j] == l[k] or l[i] == l[k]:
                continue
            if l[i] + l[j] > l[k]:
                count += 1

print(count)
# Judge status: Wrong Answer
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)]
dp[0][W] = 0

for i in range(N):
  for j in range(W+1):
    if j- wv[i][0] >= 0:
      dp[i+1][j] = max(dp[i+1][j], dp[i][j-wv[i][0]] + wv[i][1])
    else:
      dp[i+1][j] = max(dp[i+1][j], dp[i][j])

ans = 0

for k in range(N+1):
  ans = max(ans, max(dp[k]))

print(ans)
# Judge status: Accepted
import math

def get_distance(x1, y1, x2, y2):
    d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return d

a, b, h, m = list(map(int, input().split()))

point_h = [
    a * math.cos(math.radians((90 - 30*h)-m/2.0)),
    a * math.sin(math.radians((90 - 30*h)-m/2.0))
]

point_m = [
    b * math.cos(math.radians(90 - 6*m)),
    b * math.sin(math.radians(90 - 6*m))
]

print(get_distance(point_h[0], point_h[1], point_m[0], point_m[1]))
# Judge status: Wrong Answer
s = int(input())
a = s
c = 0
while a != 1:
  if a%2 == 0:
    a = int(a/2)
    c += 1
  else:
    a = int(3*a+1)
    c += 1
print(c+2)
# Judge status: Accepted
n = int(input())
s = input()

white = s.count('.')
black = n - white
w = 0
b = 0
y = [white]
for i in range(n):
    if s[i] == '#':
        b += 1
    else: w += 1
    y.append(b+white-w)
    if w == white:
        break
print(min(y))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
ans = 12345678901234
cnt = 0
for i in range(n):
    cnt += a[i]
    ans = min(ans,abs(s-cnt - cnt))
print(ans)
# Judge status: Wrong Answer
n, c, k = map(int, input().split())
arr = sorted([int(input()) for _ in range(n)])

ans = 0
cnt = 0
tmp_t = 0
for t in arr:
    if cnt == 0:
        tmp_t = t
    cnt += 1
    if cnt >= c:
        ans += 1
        cnt = 0
    elif t - tmp_t > k:
        ans += 1
        cnt = 1
        tmp_t = t
if cnt:
    ans += 1

print(ans)
# Judge status: Wrong Answer
S = list(input())
N = int(input())

'''
ordの位置
#z = 122
#a = 97
左の文字からNで'a'に出来るかを確認
aに出来るならaにして使った分をNから引く
繰り返して行き一番最後にあまりをすべて使う'''
  
for i, s in enumerate(S):
  if ord(s) - 97 > 0  and 122 - ord(s) < N:
    S[i] = "a"
    N -= 123 - ord(s)
else:
  S[i] = (chr((ord(S[i]) + N) % 122 ))
  
  
print("".join(S))
# Judge status: Wrong Answer
s = input()

flg = 0

for i in range(len(s)):
    if i % 2 == 0 and (s[i] != "L" and s[i] != "U" and s[i] != "D"):
        flg = 1
    elif i % 2 == 1 and (s[i] != "R" and s[i] != "U" and s[i] != "D"):
        flg = 1
    else:
        continue

if flg == 0:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
money = 1000
stock = 0
i = 0
while i < N - 1:
    if A[i + 1] > A[i]:
        # 全額buy
        stock += money // A[i]
        money -= (money // A[i]) * A[i]
        # print('buy', i)
        # print(money, stock)
    if A[i + 1] < A[i]:
        money += stock * A[i]
        stock = 0
    if i == N - 2 and stock > 0:
        money += stock * A[-1]
        stock = 0

    # print(i, money, stock)
    i += 1
print(money)
# Judge status: Wrong Answer
N = int("0" <= "N" <= "100")
M = int("0" <= "N" <= "M")
if N == M:
  print("yes")
if N > M:
  print("No")
# Judge status: Wrong Answer
n = int(input())
count = 0
result = 0
for i in range(n+1):
  if n % 2 ==0:
    pass
  else:
    count +=1

result = count / n

print(result)
# Judge status: Wrong Answer
s = input()
if s[5] == 0 and int(s[6]) <=4:
  print('Heisei')
else:
  print('TBD')
# Judge status: Accepted
n, k = map(int, input().split())

if n % k == 0:
    ans = 0
else:
    ans = 1

print(ans)
# Judge status: Accepted
n,*a=map(int,open(0).read().split())
t,v,w=sum(a),1,1
for q in a:
  w=min(2*(w-q),t:=t-q)
  v+=w
  if w<0:print(-1);exit()
print(v)
# Judge status: Accepted
from functools import reduce

x,y=list(map(int,input().split()))
mod = 10 ** 9 + 7

if (2 * y - x) % 3 != 0 or (2 * x - y) % 3 != 0:
  print("0")
  exit()
  
a,b = (2 * y - x) // 3, (2 * x - y) // 3 

r = max(a,b)

if min(a,b) < 0:
  print("0")
else:
  numerator = reduce(lambda x, y: x * y % mod, range(a + b - r + 1, a + b + 1))
  denominator = reduce(lambda x, y: x * y % mod, range(1 , r + 1))
  print(numerator * pow(denominator, mod - 2, mod) % mod)
# Judge status: Accepted
import collections

N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)

for i in range(1, N + 1):
  print(c[i])
# Judge status: Accepted
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s)
# Judge status: Wrong Answer
a , b = (input().split(' '))
a = int(a[0])
b = int(b[0])
print(a*b)
# Judge status: Wrong Answer
n = int(input())
a = []
a = input().split()
b = 1
for num in range(n):
  b = b * num
print(b)
# Judge status: Accepted
n,l = map(int,input().split())
lst = [l+i-1 for i in range(1,n+1)]
if 0 in lst:
    print(sum(lst))
else:
    if l > 0:
        print(sum(lst)-l)
    if l < 0:
        print(sum(lst)-(l+n-1))
# Judge status: Accepted
a,b = map(int,input().split())

sa = max(a,b) - min(a,b)

if sa % 2 == 0:
  print((a + b) // 2)
else:
  print('IMPOSSIBLE')
# Judge status: Wrong Answer
k,s=map(int,input().split())
x=[0]*k
for i in range(0,k):
  x[i]=i
x.append(k)
a=int(s/3)-1
count=0
for i in range(0,len(x)):
  stemp=s-x[i]
  for j in range(0,min(k+1,stemp)):
    if stemp-x[j] in x:
      count=count+1
print(count)
# Judge status: Accepted
n, a, b = map(int, input().split())
print((b-a)//2 + min(a-1,n-b) + 1 if (b-a)%2 else (b-a)//2)
# Judge status: Accepted
w,a,b=map(int,input().split())
if a<b:
    print(b-a-w if b-a-w>0 else 0)
else:
    print(a-b-w if a-b-w>0 else 0)
# Judge status: Accepted
a,b,c,k = map(int,input().split())
if k % 2 == 0:
    ans = a - b
else:
    ans = b - a
print(ans)
# Judge status: Accepted
w = input()
w = list(w)
import collections
co = collections.Counter(w)
li = co.values()
for i in li:
    if i % 2 == 1:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i in h:
    l.append(abs(a - (t - i * 0.006)))
print(l.index(min(l)) + 1)
# Judge status: Accepted
s = input()

ans = 0
for a, b in zip(s, s[::-1]):
    if a != b:
        ans += 1

print(ans // 2)
# Judge status: Accepted
a,b = map(int,input().split())
if b<0 and (b-a+1)%2==0:
    print("Positive")
elif b<0 and (b-a+1)%2==1:
    print("Negative")
elif a<0 and b>=0:
    print("Zero")
elif a==0:
    print("Zero")
elif a>0:
    print("Positive")
# Judge status: Accepted
n,k = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

k -= 1
cnt = -(-(n-1)//k)

print(cnt)
# Judge status: Accepted
x = int(input())
a = (x // 11) * 2
if x % 11 == 0:
    b = 0
elif x % 11 <= 6:
    b = 1
else:
    b = 2
print(a + b)
# Judge status: Wrong Answer
a,b=map(int,input().split())

import math
a_min=math.ceil(a/0.08)
a_max=math.floor((a+1)/0.08)
b_min=math.ceil(b/0.1)
b_max=math.floor((b+1)/0.1)

if a_max<b_min or b_max<a_min:
    ans=-1
else:
    ans=max(a_min,b_min)
print(ans)
# Judge status: Accepted
s = list(input())
k = int(input())
for i in range(len(s)):
  if ord("z")<ord(s[i])+k and s[i]!="a":
    k =k-(ord("z")-ord(s[i])+1)
    s[i]="a"
  if i==len(s)-1 and 0<k:
    k=k%26
    s[i]=chr(ord(s[i])+k)
print("".join(s))
# Judge status: Accepted
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

w = input()
import collections
c = collections.Counter(w)
for k, v in c.items():
    if v % 2 != 0:
        print('No')
        quit()
print('Yes')
# Judge status: Accepted
x = int(input())
num = x // 3
rem = x % 3
if rem == 1:
    res = (num+1)*(num**2)
elif rem == 2:
    res = ((num + 1) ** 2) * num
else:
    res = num ** 3
res2 = (x/3)**3
if res > res2:
    print(res)
else:
    print(res2)
# Judge status: Accepted
n = int(input())
ans = float("inf")
for i in range(1, int(n**0.5)+2):
  if n%i == 0:
    a = n//i
    t = i+a-2
    ans = min(ans, t)
print(ans)
# Judge status: Wrong Answer
def main():
  N, K = map(int,input().split())
  H = list(map(int,input().split()))
  H.sort()
  print(sum(H[:-K]))
  return

main()
# Judge status: Accepted
a,b=map(int,input().split())
import math
print(math.ceil((a+b)/2))
# Judge status: Wrong Answer
s = input()
if int(s[0:3]) <= 2019 and int(s[6]) <= 4 and int(s[8:9]) <= 30:
  print("Heisei")
else:
  print("TBD")
# Judge status: Accepted
W,H,N = map(int,input().split())

L = 0
R = W
D = 0
U = H

for _ in range(N):
  x,y,a = map(int,input().split())
  if a == 1:
    L = max(L,x)
  if a == 2:
    R = min(R,x)
  if a == 3:
    D = max(D,y)
  if a == 4:
    U = min(U,y)

x = max(0,R-L)
y = max(0,U-D)
answer = x*y

print(answer)
# Judge status: Accepted
import math
a,b=map(int,input().split())
if a==1 or b==1:
  k=1
else:
	k=math.ceil((a*b)/2)
print(k)
# Judge status: Wrong Answer
N = int(input())
a = 1000 - (N % 1000)
print(a)
# Judge status: Wrong Answer
n=int(input())
s=list(str(input()))
x=0
ans=-1
for i in range(n):
  ans=max(ans,x)
  if s[i]=="I":
    x+=1
  else:
    x-=1
print(ans)
# Judge status: Accepted
n,m=list(map(int, input().split()))
check=0
if n==1 or m==1:
    if n*m!=1:
        check=max(n,m)-2
print(max((n-2)*(m-2),0)+check)
# Judge status: Accepted
def get_ints():
    return list(map(int, input().split()))

a, b, c, d = get_ints()
while True:
    c -= b
    if c <= 0:
        print('Yes')
        exit(0)
    a -= d
    if a <= 0:
        print('No')
        exit(0)
# Judge status: Accepted
S = input()
k = "keyence"

if S == k:
    print("YES")
else:
    ans = "NO"
    s = S
    for i in range(8):
        S = list(s)
        del S[i:i+(len(S)-7)]
        if "".join(S) in k:
            ans = "YES"
            break
    
    print(ans)
# Judge status: Accepted
n,k=map(int,input().split())
ab=[]
for _ in range(n):
    ab.append(list(map(int,input().split())))
ab.sort(key=lambda x:x[0])
i=0
j=0
ans=0
while j<k:
    j+=ab[i][1]
    ans=ab[i][0]
    i+=1
print(ans)
# Judge status: Accepted
n = int(input())
ryuka = [0] * (n+1)

for i in range(n+1):
    if i==0:
        ryuka[i] = 2
    elif i==1:
        ryuka[i] = 1
    else:
        ryuka[i] = ryuka[i-2] + ryuka[i-1]

print(ryuka[-1])
# Judge status: Wrong Answer
A,B = list(map(int,input().split()))
para_a = str(B)
para_b = str(A)

for i in range(A-1):
    para_a = para_a + str(B)

for i in range(B-1):
    para_b = para_b + str(A)

N = [para_a,para_b]
print(N)
sorted(N)

print(N[0])
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)

    if 0 in A:
        print('0')
        return
    prod=1
    for a in A:
        prod*=a
        if prod> 1000000000000000000:
            print('-1')
            return
    print(prod)

ans=main()
# Judge status: Accepted
n = int(input())
A = [int(input()) for _ in range(n)]
ans = 0
temp = 0
for i in range(n):
    ans += (A[i]+temp)//2
    if A[i] != 0:
        temp = (A[i]+temp)%2
    else:
        temp = 0
print(ans)
# Judge status: Wrong Answer
n = int(input())
ans = 1
dummy1,dummy2 = divmod(n,2)
for i in range(1,dummy1+1):
  ans *= i
  ans *= n+1-i
  ans = ans % (10**9+7)
if dummy2 == 1:
  ans *= (dummy2+1)
print(ans)
# Judge status: Accepted


n = int(input())
if(n >= 30):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(15)]
for some in a:
    b[some//400]+=1
ans=0
for i in range(8):
    if b[i]>0:
        ans+=1
mini=ans
for i in range(8,15):
    ans+=b[i]
if mini==0:
    mini=1
print(mini,ans)
# Judge status: Wrong Answer
n=int(input())
dic=[]
for i in range(n):
  if not i in dic:
    dic.append(i)
print(len(dic))
# Judge status: Accepted
import sys
input = sys.stdin.readline

N = int(input())
S_list = [input() for _ in range(N)]

AC_c = 0
WA_c = 0
TLE_c = 0
RE_c = 0
for S in S_list:
    if S == "AC\n":
        AC_c += 1
    elif S == "WA\n":
        WA_c += 1
    elif S == "TLE\n":
        TLE_c += 1
    else:
        RE_c += 1
print("AC x " + str(AC_c))
print("WA x " + str(WA_c))
print("TLE x " + str(TLE_c))
print("RE x " + str(RE_c))
# Judge status: Accepted
def main():
  n, mods = 0, [1]+[0]*2019
  d = 1
  for i in reversed(input()):
    n = (n+int(i)*d)%2019
    d = d*10%2019
    mods[n] += 1
  print(sum([i*(i-1)//2 for i in mods]))
main()
# Judge status: Accepted
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    S = input()[:-1]
    print("x" * len(S))


if __name__ == '__main__':
    main()
# Judge status: Accepted
n,m=map(int,input().split())
m-=2
n-=2
if m<0:
  m=1
if n<0:
  n=1
print(m*n)
# Judge status: Accepted
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15


def main():
    date = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
    print(7 - date.index(input().strip()))


if __name__ == '__main__':
    main()

"""
9999
3

2916
"""
# Judge status: Accepted
S,T = map(str,input().split())
print(T+S)
# Judge status: Accepted
x = int(input())
if x == 3 or x == 5 or x == 7:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
x=int(input())
a=x//11
b=x%11
if b==0:
  print(2*a)
elif b>0 and b<7:
  print(2*a+1)
else:
  print(2*a+2)
# Judge status: Wrong Answer
N, A, B, C, D = map(int, input().split())
N-=1
A-=1
B-=1
C-=1
D-=1
S = input()

massesExist = True
overtakeFlag = False if C > D else True
proceedableFlag = True

if max(A, B, C, D) > N:
    massesExist = False

for i in range(B, D-1):
    if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
        overtakeFlag = True

for i in range(B, max(C, D)-1):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = False

if overtakeFlag and proceedableFlag and massesExist:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
# coding: utf-8

n = input().rstrip()
count = 0
c = 0
for i in range(len(n)):
  num = int(n[-i-1])
  if c + num <= 5:
    count += c + num
    c = 0
  else:
    count += 10 - num - c
    c = 1
print(count + c)
# Judge status: Accepted
import itertools
import math
import fractions
import functools
import copy

n, k = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))

h.sort()
minimum = 10**10
for i in range(n-k+1):
    minimum = min(minimum,h[i+k-1]-h[i])

print(minimum)
# Judge status: Accepted
S = [i for i in input()]
T = [i for i in input()]
N = len(T)
ans = 10**10
for i in range(len(S)-N+1):
     X = S[i:i+N]
     a = N
     for j in range(N):
         if X[j] == T[j]:
             a -= 1
     ans = min(ans, a)
print(ans)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if (a!=b,b!=c,a!=c):
  print(3)
elif(a==b,b!=c):
  print(2)
elif(b==c,c!=a):
  print(2)
elif(c==a,a!=b):
  print(2)
else:
  print(1)