Problem:


Score : 100 points

Problem Statement

A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.

Given a string S, determine whether it is coffee-like.

Constraints

S is a string of length 6 consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If S is coffee-like, print Yes; otherwise, print No.

Sample Input 1

sippuu

Sample Output 1

Yes

In sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.

Sample Input 2

iphone

Sample Output 2

No

Sample Input 3

coffee

Sample Output 3

Yes



Sample input:
sippuu


Sample output:
Yes

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit=10**12

def modinv(a,m=10**9+7):
    if a==0: return 1
    else:
        b=m
        (x, lastx) = (0, 1)
        (y, lasty) = (1, 0)
        while b != 0:
            q = a // b
            (a, b) = (b, a % b)
            (x, lastx) = (lastx - q * x, x)
            (y, lasty) = (lasty - q * y, y)
        return lastx % m

def cur(p):
    for x in neighbor[p]:
        par[x]=p
        neighbor[x].remove(p)
        try:
            descend[p]+=cur(x)
        except: sys.exit()
    return descend[p]

def cur2(p):
    for x in neighbor[p]:
        ans[x]=ans[p]*descend[x]*modinv(n-descend[x])
        ans[x]%=mod
        cur2(x)

mod=10**9+7
n=int(input())
neighbor=[set()  for _ in range(n+1)]
descend=[1]*(n+2)
par=[-1]+[0]*n

for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].add(b)
    neighbor[b].add(a)
cur(1)


ans=[1]*(n+1)
ans1=1
for i in range(1,n+1):
    ans1=ans1*i*modinv(descend[i])
    ans1%=mod
ans[1]=ans1

cur2(1)

for i in range(1,n+1):
    print(ans[i])

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

n = int(readline())

mod = 10**9 + 7

def expo(x,n):
    var = 1
    while n>0:
        if n%2 == 1:
            var = (var*x) % mod
        x = (x*x)%mod
        n = n>>1
    return var

def conbi(*x):
    num = 1
    den = 1
    for i in range(1,sum(x)+1):
        num = (num*i)%mod
    for i in x:
        for j in range(1,i+1):
            den = (den * j)%mod
    return (num*expo(den,mod-2))%mod

path = [set() for _ in range(n)]
pathq= [0]*n

for _ in range(n-1):
    a,b = map(int,read().split())
    a -= 1
    b -= 1
    path[a].add(b)
    pathq[a] += 1
    path[b].add(a)
    pathq[b] += 1

memo = {}
def go(i,j):
    if (i,j) in memo.keys():
        return memo[(i,j)]
    else:
        memo[(i,j)] = [1,1]
        cnt = []
        meth = 1
        for k in path[j]:
            if i != k:
                [x,y] = go(j,k)
                meth *= y
                meth %= mod
                cnt.append(x)
        memo[(i,j)] = [sum(cnt)%mod + 1, meth*conbi(*cnt)%mod]
        return memo[(i,j)]

for i in range(n):
    ans = 1
    cnt = []
    meth = 1
    for j in path[i]:
        [x,y] = go(i,j)
        meth *= y
        meth %= mod
        cnt.append(x)
    print(meth*conbi(*cnt)%mod)

Submission status: Runtime Error

Solution code:
X,Y,A,B,C =  [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.append(0)
B.append(0)
C.append(0)
ux_1 = 0
uy_1 = 0
for i in range(X):
    ux_1 += max(max(A),max(C))
    if max(A) >= max(C):
        A.pop(A.index(max(A)))
    else:
        C.pop(C.index(max(C)))
for i in range(Y):
    uy_1 += max(max(B),max(C))
    if max(B) >= max(C):
        B.pop(B.index(max(B)))
    else:
        C.pop(C.index(max(C)))
print(ux_1+uy_1)

Submission status: Runtime Error

Solution code:
def main():
    K, N = [int(_) for _ in input().split()]
    A = list(map(int, input().split()))
    mx = 0

    for i in range(N-1):
        dis = A[i+1]-A[i]
        if dis > mx:
            mx = dis
    se = A[N-1] - A[0]
    if (K-(se)) > mx:
        mx = K - se
    print(mx)
main()

Submission status: Runtime Error

Solution code:
str=input()
if (str[2]==str[3])&&(str[4]==str[5]):
 print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

input1 = [int(x) for x in input().split()]
lake = input1[0]
homes = input1[1]
input2 = [int(x) for x in input().split()]

result = 1000000
last = homes - 1
for x in range(homes):
    forward = 0
    backward = 0
    start = input2[x]

    # forward
    if x == 0:
        forward = input2[last] - start
    else:
        forward = (lake - start) + input2[x - 1]
    
    # backward
    if x == last:
        backward = (start) - input2[0]
    else:
        backward = (start) + lake - (input2[x + 1])

    #print("forward: {}, backward: {}".format(forward, backward))
    result = min(result, forward, backward)

print(result)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit=10**12

def modinv(a,m=10**9+7):
    if a==0: return 1
    else:
        b=m
        (x, lastx) = (0, 1)
        (y, lasty) = (1, 0)
        while b != 0:
            q = a // b
            (a, b) = (b, a % b)
            (x, lastx) = (lastx - q * x, x)
            (y, lasty) = (lasty - q * y, y)
        return lastx % m

def cur(p):
        for x in neighbor[p]:
            if x==0: sys.exit()
            if x==par[p]: continue
            par[x]=p
            descend[p]+=cur(x)
        return descend[p]


def cur2(p):
    for x in neighbor[p]:
        if x==par[p]: continue
        ans[x]=ans[p]*descend[x]*modinv(n-descend[x])
        ans[x]%=mod
        cur2(x)

mod=10**9+7
n=int(input())
neighbor=[[]  for _ in range(n+1)]
descend=[1]*(n+1)
par=[1]+[0]*(n)

for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)
cur(1)

ans=[1]*(n+1)
ans1=1
for i in range(1,n+1):
    ans1=ans1*i*modinv(descend[i])
    ans1%=mod
ans[1]=ans1

cur2(1)

for i in range(1,n+1):
    print(ans[i])

Submission status: Runtime Error

Solution code:
s = str(input())
if s[3]==s[4]  and s[5]==s[6]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
N, X, Y = map(int, input().split())
count = [0] * (N-1)
for i in range(N):
    i += 1
    for j in range(N-i):
        j += i + 1
        if i < j:
            normal = j-i
            xtoy = abs(X-i) + 1 + abs(Y-j)
            ytox = abs(Y-i) + 1 + abs(X-j)
            minRoute = min([normal, xtoy, ytox])
            count[minRoute-1] += 1
for c in count:
    print(c)

Submission status: Runtime Error

Solution code:
from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*N        
for x in range(0,N):
    for y in range(x,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


for i in range(1,N):
    print(res[i])

Submission status: Runtime Error

Solution code:
if num[2] == num[3] and num[-1] == num[-2]:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
S = input()
 
if (S[2] = S[3] and S[4] = S[5]):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*N        
for x in range(0,N):
    for y in range(0,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


for i in range(1,N):
    print(res[i])

Submission status: Runtime Error

Solution code:
S = input()
 
if (S[2] = S[3] and S[4] = S[5]):
  print(Yes)
else:
  print(No)

Submission status: Runtime Error

Solution code:
a = input()

if (a[2] = a[3] and a[4] = a[5]):
  print(Yes)
else:
  print(No)

Submission status: Runtime Error

Solution code:
s=input()
if s[2]==s[3]&&s[4]==s[5]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
S = str(input())
if S[2]==S[3] & S[4]==S[5]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

n, X, Y = [int(x) for x in input().split()]

ans = [0] * (n) # 1 ~ n - 1

g = [x for x in range(1, n + 1)]
g_2 = [x for x in range(1, n + 1)]
g_2[Y - 1] = X + 1
for i in range(Y, n):
    if i < n:
        g_2[i] -= (Y - X - 1)
# print(g)
# print(g_2)

for i in range(X):
    for j in range(i + 1, n):
        # print(g_2[j], g[i])
        b = min(g_2[j] - g[i], g[X - 1] - g[i] + g_2[Y - 1] - g[X - 1] + abs(g[Y - 1] - g[j]))
        ans[b] += 1

for i in range(X, n):
    for j in range(i + 1, n):
        # print(g[j], g[i])
        a = min(g[j] - g[i], g[i] - 2 * g[X - 1] + g_2[j])
        ans[a] += 1

for i in ans[1:]:
    print(i)

Submission status: Runtime Error

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

klist = [0]*(n)
for i in range(1, n):
  for j in range(i+1, n+1):
    k = min(j-i, abs(j-y)+1+abs(x-i))
    klist[k] += 1

for _ in range(1, n):
  print(klist[_])

Submission status: Runtime Error

Solution code:
s = str(input())
if s[2]==s[3] & s[4]==s[5]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
s = str(input())
if s[2]=s[3] & s[4]=s[5]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
(n,m)=map(int,input().split())
a=input().split()
a=list(map(int,a))
l=[]
k=0
a=sorted(a)
for i in range(m-1):
    d=abs(a[i]-a[i+1])
    k=k+d
    l.append(d)
# k=k-d
c=n-k
l.append(c)
l=sorted(l)

print(n-l[-1])

Submission status: Runtime Error

Solution code:
s = input()
if s[2]=s[3] && s[4]=s[5]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort()
q.sort()
p.reverse()
q.reverse()

a=p[:]
a.extend(q)
a.extend(r)
a.sort()
a.reverse()
b=q[:]
b.extend(r)
b.sort()
b.reverse()
c=p[:]
c.extend(r)
c.sort()
c.reverse()
red=0
green=0
sum=0
sum1=0
sum2=0
d=0
for i in range((X+Y)*2):
  if(a[i] in p):
    red+=1
  elif(a[i] in q):
    green+=1
  d+=a[i]
  if(red>X and i-X-Y+1+green==Y):
    break
  if(i<X):
      sum1+=p[i]
      sum2+=c[i]
  if(i<Y):
      sum1+=b[i]
      sum2+=q[i]
  if(i==X+Y and red<=X and green<=Y):
    print(sum)
    break
  if(red>X and i-X-Y+1+green==Y):
    print(sum1)
    break
  elif(green>Y and i-X-Y+1+red==X):
    print(sum2)
    break

Submission status: Runtime Error

Solution code:
s = input()
if s[3]=s[4] && s[5]=s[6]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = input()
if (c==d) and (e==f) : print("Yes")
else print("No")

Submission status: Runtime Error

Solution code:
e = list(map(int,input().split()))
K = e[0]
N = e[1]
a = list(map(int,input().split()))
c = [a[i+1] - a[i] for i in range(N-1)]
f = a[0]+ K - a[N-1]
c.append(f)
d = max(c)
print(K - d)

Submission status: Runtime Error

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

n = inputs[0]
x = inputs[1] - 1  # 3
y = inputs[2] - 1  # 7
z = y - x - 1  # 3
c = y - x + 1
k = [0 for i in range(n-1)]

for i in range(n - 1):
    for j in range(i + 1, n):
        if i <= x and j >= y:
            d = j - i - z
        elif i <= x and not j >= y:
            d = min(j - i, c - j + x + x - i)
        elif not i <= x and j >= y:
            d = min(j - i, c - y + i + j - y)
        else:
            d = j - i
        # print(str(i+1) + " "+str(j+1)+" "+str(d))
        k[d - 1] += 1

for e in k:
    print(e)

Submission status: Runtime Error

Solution code:
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p = sorted(p)
q = sorted(q)
r = sorted(r)
P = A - X
Q = B - Y
R = C - 1
found = True
for i in range(C+1):
    if R < 0:
        break
    if P < A:
        if (r[C-i-1] >= p[P]):
            if (q[Q] >= p[P]):
                P += 1
                R -= 1
            elif Q < B:
                if r[C-i-1] > q[Q]:
                    Q += 1
                    R -= 1
                else:
                    break
            else:
                break
        elif Q < B:
            if r[C-i-1] > q[Q]:
                Q += 1
                R -= 1
            else:
                break
        else:
    elif Q < B:
        if r[C-i-1] > q[Q]:
                Q += 1
                R -= 1
        else:
            break    
    else:
        break
print(sum(p[P:])+sum(q[Q:])+sum(r[R+1:]))

Submission status: Runtime Error

Solution code:
N, X, Y = map(int, input().split(' '))

dct = {X : Y}
short = Y - X - 1

dist_list = [0] * N

for i in range(1,N):
    for j in range(i+1,N+1):
        d1 = abs(X - i) + 1 + abs(Y - j)
        d2 = j - i
        dist = min(d1,d2)
        dist_list[dist] += 1

for k in range(1,N):
    print(dist[k])

Submission status: Runtime Error

Solution code:
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(min(len(arrayR), len(arrayAns))):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))

Submission status: Runtime Error

Solution code:
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayR)):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))

Submission status: Runtime Error

Solution code:
n, x, y = input().split(" ")
n, x, y = int(n), int(x), int(y)
ans = [0] * (n - 1)
 
for i in range(n - 1):
    for j in range(i + 1, n):
        now = 0
        if (j <= x - 1):
            ans[j - i - 1] += 1
 
        elif(j > x - 1 and j <= y - 1 and i <= x - 1):
            now = now + x - 1 - i
            if (j - (x - 1) >= (y - 1) - j + 1):
                now = now + (y - 1) - j + 1
            else:
                now = now + j - (x - 1)
            ans[now - 1] += 1
 
        elif(j > x - 1 and j <= y - 1 and i > x - 1):
            if (j - i >= (i - (x - 1)) + ((y - 1) - j) + 1):
                now = (i - (x - 1)) + ((y - 1) - j) + 1
            else:
                now = j - i
            ans[now - 1] += 1
 
        elif(j > y - 1 and i <= x - 1):
            now = now + x - 1 - i
            now = now + j - (y - 1) + 1
            ans[now - 1] += 1
 
        elif(j > y - 1 and i > x - 1 and i < y - 1):
            if((y - 1) - i >= i - (x - 1) + 1):
                now = now + i - (x - 1) + 1
            else:
                now = now + (y - 1) - i
            now = now + j - (y - 1)
            ans[now - 1] += 1
 
        elif(i >= y - 1):
            ans[j - i - 1] += 1
 
print(*ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import collections
N,X,Y = map(int,input().split())
ToltN=N*(N-1)/2
Dist=[[0 for i in range(N)] for i in range(N)]
for i in range(N):
    for j in range(i,N):    
        MyDist=abs(i-(X-1))+abs(j-(Y-1))+1
        if MyDist<j-i:
            Dist[i][j]=MyDist
        else:
            Dist[i][j] = j-i
for j in range(N-1):
    ans=[0]
    for i in range(N):
        ans+=Dist[i]
c = collections.Counter(ans)
for i in range(N-1):
    print(c[i+1])

Submission status: Runtime Error

Solution code:
import bisect
import copy

X, Y, A, B, C = map(int, input().split())
red = list(map(int, input().split()))
green = list(map(int, input().split()))
clear = list(map(int, input().split()))

red.sort()
green.sort()
clear.sort()

red = red[-X:]
green = green[-Y:]

def ins(a, x):
    insert_index = bisect.bisect_left(a,x)
    a.insert(insert_index,x)
    return a[1:]

while clear[-1] > min(red[0], green[0]):
    red_tmp = ins(copy.copy(red), clear[-1])
    green_tmp = ins(copy.copy(green), clear[-1])
    
    if (sum(red_tmp) + sum(green)) >= (sum(red) + sum(green_tmp)):
        # 赤に追加
        red = red_tmp
    else:
        # 緑に追加
        green = green_tmp
        
    if len(clear) == 1:
        break
    else:
        clear = clear[:-1] #clearを消去

print(sum(red) + sum(green))

Submission status: Runtime Error

Solution code:
X, Y, num_red_apple, num_green_apple, num_apple = map(int, input().strip().split())
red_apples = list(map(int, input().strip().split()))
green_apples = list(map(int, input().strip().split()))
apples = list(map(int, input().strip().split()))

good_apples = []
for i in range(1, X+1):
    good_apples.append(sorted(red_apples)[-i])

for i in range(1, Y+1):
    good_apples.append(sorted(green_apples)[-i])

while(1):
    if max(apples) > min(good_apples):
        good_apple = apples.pop(apples.index(max(apples)))
        good_apples.remove(min(good_apples))
        good_apples.append(good_apple)
    else:
        break
    
print(sum(good_apples))

Submission status: Runtime Error

Solution code:
import bisect

X, Y, A, B, C = map(int, input().split())
red = list(map(int, input().split()))
green = list(map(int, input().split()))
clear = list(map(int, input().split()))

red.sort()
green.sort()
clear.sort()

red = red[-X:]
green = green[-Y:]

def ins(a, x):
    insert_index = bisect.bisect_left(a,x)
    a.insert(insert_index,x)
    return a[1:]

while clear[-1] > min(red[0], green[0]):
    red_tmp = ins(red.copy(), clear[-1])
    green_tmp = ins(green.copy(), clear[-1])
    
    if (sum(red_tmp) + sum(green)) >= (sum(red) + sum(green_tmp)):
        # 赤に追加
        red = red_tmp
    else:
        # 緑に追加
        green = green_tmp
        
    if len(clear) == 1:
        break
    else:
        clear = clear[:-1] #clearを消去

print(sum(red) + sum(green))

Submission status: Runtime Error

Solution code:
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

s, = input()
ans = 'No'
if s[2] == s[3] and s[5] == s[6]:
    ans = 'Yes'
print(ans)

Submission status: Runtime Error

Solution code:
N, X, Y = map(int,input().split())
X -= 1
Y -= 1

nallpath = N*(N-1)//2
distance = [0] * nallpath

indx = 0
for j in range(N-1):
    for i in range(j+1,N):
        if i <= X:
            distance[indx] = i - j
        elif j >= Y:
            distance[indx] = i - j
        elif j <= X and Y<= i:
            distance[indx] = i - j - (Y-X-1)
        elif  X <= j < i <= Y:
            distance[indx] = min(i-j, (j-X)+(Y-i)+1)
        elif j <= X and X < i <= Y:
            distance[indx] = (X-j) + min(i-X, Y-i+1)
        else:
            distance[indx] = (i-Y) + min(Y-j, j-X+1)
        indx += 1
for i in range(N-1):print(distance.count(i+1))

Submission status: Runtime Error

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

for i in range(0, N): 
        for j in range(i + 1, N): 
            if A[i] + A[j] == K: 
                if A[i] > A[j]:
                    print(A[i] - A[j])
                else:
                    print(A[j] - A[i])

Submission status: Runtime Error

Solution code:
x = int(input())
ans = x//500 * 1000
ans += (x%500)//5*5
print(ans)

Submission status: Runtime Error

Solution code:
X, Y, num_red_apple, num_green_apple, num_apple = map(int, input().strip().split())
red_apples = list(map(int, input().strip().split()))
green_apples = list(map(int, input().strip().split()))
apples = list(map(int, input().strip().split()))

good_apples = []
for i in range(1, X+1):
    good_apples.append(sorted(red_apples)[-i])

for i in range(1, Y+1):
    good_apples.append(sorted(green_apples)[-i])

while(1):
    if max(apples) > min(good_apples):
        good_apple = apples.pop(apples.index(max(apples)))
        good_apples.remove(min(good_apples))
        good_apples.append(good_apple)
    else:
        break
    
print(good_apples)

Submission status: Runtime Error

Solution code:
from sys import stdin

x, y, a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

p = [int(x) for x in stdin.readline().rstrip().split()]
q = [int(x) for x in stdin.readline().rstrip().split()]
r = [int(x) for x in stdin.readline().rstrip().split()]


ps = sorted(p, reverse=True)
qs = sorted(q, reverse=True)

pss = ps[0:x]
pss.extend(qs[0:y])

he = 0

for i in range(x+y):
    for j in range(len(r)):
        if pss[i] < r[j]:
            pss[i] = r.pop(j)
            break
    he += pss[i]

print(he)

Submission status: Runtime Error

Solution code:
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayR)):
    if len(arrayAns) >= i
        if arrayAns[i] <= int(arrayR[i]):
           arrayAns[i] = int(arrayR[i])
        else:
            break
print(sum(arrayAns))

Submission status: Runtime Error

Solution code:
a=int(input())
if a > 500:
    print((a//500)*1000+((a%500)//5)*5)
else:
    print(a//5*5)

Submission status: Runtime Error

Solution code:
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

eat = []

# 食べる
p.sort(reverse=True)
if X > A:
    eat.extend(p)
else:
    eat.extend(p[:X])

q.sort(reverse=True)
if Y > B:
    eat.extend(q)
else:
    eat.extend(q[:Y])
loss = X+Y - len(eat)

# 足りない分を補充する
while loss > 0:
    r.sort(reverse=True)
    eat.append(r.pop(0))    
    loss -= 1

# rの方が大きいものがあれば入れ替える
eat.sort()
r.sort()
for i in range(len(eat)):
    if len(r) != 0 and eat[i] < r[-1]:
        eat[i] = r.pop(-1)
    else:
        break

print(sum(eat))

Submission status: Runtime Error

Solution code:
a=int(input())
if a > 500:
    print((a//500)*1000+((a%500)//5)*5)
else:
    print((a//5)*5)

Submission status: Runtime Error

Solution code:
X, Y, A, B, C = map(int,input().split()) 
P = [list(map(int,input().split())) for i in range(3)]
Red = sorted(P[0], reverse=True)
Green = sorted(P[1], reverse=True)
Trans = sorted(P[2], reverse=True)

pre_max = sum(Red[:X]) + sum(Green[:Y])
Red = Red[:X]
Green = Green[:Y]
for i in range (C):
  maxo = pre_max
  if (Trans[i] > Red[-1+i]):
    maxo= pre_max + Trans[i] - Red[-1+i]
for i in range (C):
  if (Trans[i] > Green[-1+i]):
    maxo = pre_max + Trans[i] - Green[-1+i]
    
print(maxo)

Submission status: Runtime Error

Solution code:
s=input()
if s[3]==s[4] and s[5]==s[6]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
K, N = map(int,input().split())
N = N-1
A = list(map(int, input().split()))
A_d = [ A[i+1]-A[i] for i in range(0, len(A)-1)]
A_d.append(K-A[-1]+A[0])
print(A_d)
A_d2 = (A_d+A_d[1:])*2
print(A_d2)
res = K
for i in range(len(A_d2)-1):
    if res > sum(A_d2[i:i+N]):
        res = sum(A_d2[i:i+N])
print(res)

Submission status: Runtime Error

Solution code:
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayR)):
    if arrayAns[0] <= int(arrayR[i]):
        arrayAns[0] = int(arrayR[i])
        arrayAns.sort()
    else:
        break
print(sum(arrayAns))

Submission status: Runtime Error

Solution code:
x, y, a, b, c = map(int, input().split())

red = sorted(list(map(int, input().split())), reverse=True)
gre = sorted(list(map(int, input().split())), reverse=True)
non = sorted(list(map(int, input().split())), reverse=True)

eat = []

for i in range(x):
    eat.append(red.pop(0))

for i in range(y):
    eat.append(gre.pop(0))

eat.sort()

for i in range(len(non)):
    n = non.pop(0)
    if eat[i] < n:
        eat[i] = n
    else:
        break

print(sum(eat))

Submission status: Runtime Error

Solution code:
cin >>> a,b,c,d,e,f;
if c=d and e=f : cout <<< "Yes"
else : cout <<< "No"

Submission status: Runtime Error

Solution code:
K, N = input().split()
i, lists = 0, []
while i < N:
    lists.append(eval(input()))
    i += 1
if 0 in lists:
   lists.remove(0) 
print(max(lists) - min(lists))

Submission status: Runtime Error

Solution code:
K, N = input().split()
A = list(map(int, input().split()))
if 0 in A:
    A.remove(0)
x = max(A) - min(A)
print(x)

Submission status: Runtime Error

Solution code:
K, N = map(int, input().split())
A = list(map(int, input().split()))
if 0 in A:
    A.remove(0)
x = max(A) - min(A)
print(x)

Submission status: Runtime Error

Solution code:
def InS(): return input()


def InL(): return list(map(int, input().split()))


def InI(): return int(input())


S = InL()

if S[2] == S[3]:
    print("Yes")
elif S[4] == S[5]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
letters = eval(input("Enter: "))
for i in letters:
	print(["Yes" if i[2]==i[3] and i[4]==i[5] else "No"])

Submission status: Runtime Error

Solution code:
K, N = map(int, input().split())
A = list(map(int, input().split()))
if 2  <= K <= 10 ** 6 and 2 <= N <= 2 * 10 ** 5:
    if 0 in A:
        A.remove(0)
    x = max(A) - min(A)
    print(x)

Submission status: Runtime Error

Solution code:
k,n=map(int,input().split())
a=list(map(int,input().split()))
b=0
s=[0]*n
#間隔を求める
for i in range(n-1):
    s[i]=a[i+1]-a[i]
#間隔を足す
for i in range(n):
  if s[i]<k/3:
    b=b+s[i]
  else:
    con=k-s[i]
    print(con)
    exit()
  
print(b)

Submission status: Runtime Error

Solution code:
S = str(input())
if(S[3]==S[4] and S[5]==S[6])
	print('Yes')
else
	print('No')

Submission status: Runtime Error

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

zero = False
if 0 in a:
    a.remove(0)
    n = n - 1
    zero = True
    #print("contain 0.")

l1 = a[n-1] - a[0]  # 0を通らない側
l2 = a[0] + k - a[n-1]  # 0を通る側
if zero == True:
    ret = l2
else:
    ret = l1 if l1 < l2 else l2
print("{}".format(ret))

Submission status: Runtime Error

Solution code:
l = eval(input("Enter: "))
for i in len(l):
  if len(l)<=6:
    if i[2]==i[3] and i[4]==i[5]:
      print("Yes")
    elif l=="coffee-like":
      print("Yes")
    else:
      print("No")
  print("No")

Submission status: Runtime Error

Solution code:
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

eat = []

# 食べる
p.sort(reverse=True)
if X > A:
    eat.extend(p)
else:
    eat.extend(p[:X])

q.sort(reverse=True)
if Y > B:
    eat.extend(q)
else:
    eat.extend(q[:Y])
loss = X+Y - len(eat)

# 足りない分を補充する
while loss > 0:
    r.sort(reverse=True)
    eat.append(r.pop(0))    
    loss -= 1

# rの方が大きいものがあれば入れ替える
eat.sort()
for i in range(len(eat)):
    if len(r) != 0 and eat[i] < r[0]:
        eat[i] = r.pop(0)
    else:
        break

print(sum(eat))

Submission status: Runtime Error

Solution code:
str = input()
S = print(str)
if  S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
coffee
str=input()
S=print(str)
if  S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
i = eval(input("Enter your words: "))
if (i[2]==i[3]) and (i[4]==i[5]:
      print("Yes")
elif i=="coffee-like":
    print("Yes")
else:
      print("No")

Submission status: Runtime Error

Solution code:
s_in = S
if s_in[2]==s_in[3] and s_in[4]==s_in[5]:
    print('yes')
else:
    print('no')

Submission status: Runtime Error

Solution code:
x = int(input())
a = int(x/500)
b = x - 500*a
c = int(b/5)

print(1000*a + 5*c)

Submission status: Runtime Error

Solution code:
S = str(input()) 
print('YES' if S[2] ==S[3] and 'NO' if S[4]==S[5]

Submission status: Runtime Error

Solution code:
str=input()
S=print(str)
if  S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s=input()
s.lower()
if(s[4]==s[3] and s[6]==s[5]):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n,x,y=map(int, raw_input().split())

tb=[[0]*(n+1) for i in xrange(n+1)]
tb[x][y]=1
for i in xrange(1, n+1):
    for j in xrange(i+1,n+1):
        # if i<=x and j==y:
        #     tb[i][j]=min(tb[i][j-1]+1-(y-x)+1, j-i)
        # elif i>x and i<y and j==y:
        #     tb[i][j]=min(j-i, j-x+1)
        # else:
        #     tb[i][j]=min(tb[i][j-1]+1, j-i)
        if i<x:
            # print i,j, x-i+1+abs(y-j)
            tb[i][j]=min(j-i, x-i+1+abs(y-j))
        elif i>=x and i<=y:
            tb[i][j]=min(j-i, i-x+1+abs(y-j))

res=[0]*(n+1)

for i in xrange(1 ,n+1):
    for j in xrange(i+1, n+1):
        res[tb[i][j]]+=1

s=''
for i in xrange(1, n):
    s+=str(res[i])+'\n' 

# for i in tb:
#     print i
print s

Submission status: Runtime Error

Solution code:
letters = eval(input("Enter: "))
for i in letters:
  print("Yes" if (i[2]==i[3] and i[4]==i[5]) "Yes" if letters=="coffee-like" else "No")

Submission status: Runtime Error

Solution code:
k , n = (int(x) for x in input().split())
a = [int(i) for i in input().split()]
b = []

for i in range(n-1):
    b.append(a[i+1] - a[i])
    
b.append(a[0] + k -a[n-1])

ans=0

b.sort()

for i in range(len(b)-1):
    ans = b[i] + ans
    
    
print(ans)

Submission status: Runtime Error

Solution code:
S=imput()
if  S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
i = eval(input("Enter: "))
print(["Yes" if (i[2]==i[3] and i[4]==i[5]) "Yes" if letters=="coffee-like" else "No"])

Submission status: Runtime Error

Solution code:
s=[]
s.lower()
if(s[4]==s[3] and s[6]==s[5]):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
X,Y,A,B,C = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
C_copy = C.copy()
for i in range(30):
    C_copy.append(0)
    C.append(0)
ux_1 = 0
uy_1 = 0
for i in range(X):
    ux_1 += max(max(A),max(C_copy))
    if max(A) >= max(C_copy):
        A.pop(A.index(max(A)))
    else:
        C_copy.pop(C_copy.index(max(C_copy)))
for i in range(Y):
    uy_1 += max(max(B),max(C_copy))
    if max(B) >= max(C_copy):
        B.pop(B.index(max(B)))
    else:
        C_copy.pop(C_copy.index(max(C_copy)))
print(ux_1 + uy_1)