Harryxun/stf_run huggingface dataset:
x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for i in range(x):
    for j in range(y):
        an.append(lisa[i]+lisb[j])
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for i in range(z):
    for j in range(min(3000,x*y*z)):
        ans.append(lisc[i]+an[j])
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

### FIXED CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
#! coding: UTF-8
data1 = list(map(int,input().split(" ")))
N = data1[0]
A = data1[1]
B = data1[2]
data2 = list(map(int,input().split(" ")))
data2.sort(reverse=True)
max_avr = sum(data2[:A]) / A
a_num = data2.count(data2[A-1])
a_pos = data2[:A].count(data2[A-1])
#確率統計nCr
import math
def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)
cnt = 0
if a_pos == A:
    while a_pos <= B:
        cnt += nCr(a_num,a_pos)
        a_pos += 1
else:
    cnt = nCr(a_num,a_pos)
print("{0:.10f}".format(max_avr))
print(int(cnt))


### FIXED CODE ###

#! coding: UTF-8
N,A,B = list(map(int,input().split(" ")))
V = list(map(int,input().split(" ")))
V.sort(reverse=True)
max_avr = sum(V[:A]) / A
a_num = V.count(V[A-1])
a_pos = V[:A].count(V[A-1])

#確率統計nCr
import math
def nCr(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)

if V[0] == V[A-1]:
    cnt = sum(nCr(a_num,i) for i in range(A,min(B,a_num)+1)) 
else:
    cnt = nCr(a_num,a_pos)
print("{0:.10f}".format(max_avr))
print(int(cnt))
S=input()
if S=AAA or S=BBB:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

S=input()
if S=="AAA" or S=="BBB":
  print("No")
else:
  print("Yes")
array = intpu().split()

N = array[0]
L = array[1]
strs = array[2:]
print( sorted(strs) )



### FIXED CODE ###


a, b, c = map( int, input().split() )
 
if a == 5 and b == 5 and c == 7:
	print( "YES" )
elif a == 5 and b == 7 and c == 5:
  	print( "YES" )
elif a == 7 and b == 5 and c == 5:
  	print( "YES" )
else :
	print( "NO" )
import bisect
from itertools import *
n=range(49994);a=list(n)
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(n,a))
for x in iter(input,'0'):
 x=int(x)
 y=bisect.bisect(p,x//2)
 if x%2:print(sum(1 for c in p[1:x]if 2+c==x))
 elif x-4:print(sum(1 for c in p[1:y]if a[x-c]))
 else:print(1)


### FIXED CODE ###

import bisect,sys
from itertools import *
n=range(50001);a=list(n);a[1]=0
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(n,a))
for x in map(int,sys.stdin):
 if x:print(len([1 for d in p[:bisect.bisect(p,x//2)]if a[x-d]]))
import sys
input = sys.stdin.readline

N, M = map(int,input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

class UnionFind:
    def __init__(self, N):
        self.Parent = [-1]*N

    def root(self, A):
        if self.Parent[A] < 0: return A
        self.Parent[A] = self.root(self.Parent[A])
        return self.Parent[A]
    
    def size(self, A):
        return -self.Parent[self.root(A)]
    
    def connect(self, A, B):
        if self.root(A) == self.root(B): return False
        if self.size(A) < self.size(B): A,B = B,A

        self.Parent[A] += self.Parent[B]
        self.Parent[B] = A
        return True

Uni = UnionFind(N+1)
ans = [0]*(M)
ans[M-1] = N*(N-1)//2

for i in reversed(range(1, M)):
    ans[i-1] = ans[i]
    if Uni.root(AB[i][0]) != Uni.root(AB[i][1]):
        ans[i-1] -= Uni.size(AB[i][0])*Uni.size(AB[i][1])
    Uni.connect(AB[i][0],AB[i][1])
for i in range(M):
    print(ans[i])
    

### FIXED CODE ###

import sys
input = sys.stdin.readline


class UnionFind:
    def __init__(self, N):
        self.Parent = [-1]*(N+1)
    #Aの親を探す。このときParent[A]は親の値からグループサイズに変わる。探索の最適化
    def root(self, A):
        if self.Parent[A] < 0: return A
        self.Parent[A] = self.root(self.Parent[A])
        return self.Parent[A]
    #Aが属しているグループのサイズを求める
    def size(self, A):
        return -self.Parent[self.root(A)]
    
    def connect(self,A,B):
        A = self.root(A)
        B = self.root(B)
        if A == B: return False
        
        if self.size(A) < self.size(B): A,B = B,A
        self.Parent[A] += self.Parent[B]
        self.Parent[B] = A
        return True



N,M = map(int,input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
Uni = UnionFind(N)
ans = [-1]*(M)
ans[M-1] = N*(N-1)//2 
for i in reversed(range(1,M)):
    ans[i-1] = ans[i]
    if Uni.root(AB[i][0]) != Uni.root(AB[i][1]):
        ans[i-1] -= Uni.size(AB[i][0])*Uni.size(AB[i][1])
    Uni.connect(AB[i][0], AB[i][1])
for i in range(M):
    print(ans[i])
ans=0
shogen=[]
n=int(input())
for _ in range(n):
  t=[]
  a=int(input())
  for __ in range(a):
    h=list(map(int,input().split()))
    t.append(s)
  shogen.append(t)
for i in range(2**n):
  flag=True
  for j in range(n):
    if not flag:
      break
    if ((i>>j) & 1):
      for h in shogen[j]:
        if ((i>>h[0]-1)&1) !=h[1]:
          flag=False
  if flag:
    mnt = bin(i).count("1")
    ans=max(ans,mnt)
print(ans)


### FIXED CODE ###

n=int(input())
shogen=[]
for _ in range(n):
  a=int(input())
  t=[]
  for __ in range(a):
    s=list(map(int,input().split()))
    t.append(s)
  shogen.append(t)

ans=0

for i in range(2**n):
  flag=True
  for j in range(n):
    if not flag:
      break
    if ((i>>j) & 1):
      for s in shogen[j]:
        if ((i>>s[0]-1)&1) !=s[1]:
          flag=False
  if flag:
    mnt = bin(i).count("1")
    ans=max(ans,mnt)
print(ans)
S=int(input())
S[3]='8'
print(S)

### FIXED CODE ###

S=str(input())
print('2018/'+S[5:10])
import collections
n, m = map(int, input().split())
L = []
for _ in range(m):
    a, b = map(int, input().split())
    L.append(a)
    L.append(b)

L_dict = collections.Counter(L)
L_dict_sort = sorted(L_dict.items(), key = lambda x:x[0])
for i in range(n):
    print(L_dict_sort[i][1])

### FIXED CODE ###

n, m = map(int, input().split())
L = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    L[a - 1] += 1
    L[b - 1] += 1

for i in L:
    print(i)
s = input()
len_li = []
cnt = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == "C" or s[i] == "G" or s[i] == "T":
        cnt+=1
    else:
        len_li.append(cnt)
        cnt = 0 
print(max(len_li))

### FIXED CODE ###

s = input()
len_li = [0]
cnt = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        cnt+=1
    else:
        len_li.append(cnt)
        cnt = 0 
len_li.append(cnt)
print(max(len_li))
h, w = map(int, input().split())
A = []
B = []
for i in range(h):
  row = list(map(int, input().split()))
  row.append(0)
  A.append(row)
A.append([0 for i in range(w+1)])

for i in range(h):
  row = list(map(int, input().split()))
  row.append(0)
  B.append(row)
B.append([0 for i in range(w+1)])

dp = [[set([]) for j in range(w+1)] for i in range(h+1)]
dp[0][0].add(abs(A[0][0] - B[0][0]))
for i in range(h):
  for j in range(w):
    for item in dp[i][j]:
      dif = abs(A[i][j+1] - B[i][j+1])
      dp[i][j+1].add(item+dif)
      dp[i][j+1].add(abs(item-dif))
      dif = abs(A[i+1][j] - B[i+1][j])
      dp[i+1][j].add(item+dif)
      dp[i+1][j].add(abs(item-dif))
print(min(dp[h][w]))

### FIXED CODE ###

import sys
def main():
  input = sys.stdin.readline
  h, w = map(int, input().split())
  A = []
  AB = []
  A_append = A.append
  AB_append = AB.append
  for i in range(h):
    row = list(map(int, input().split()))
    A_append(row)
  for i in range(h):
    row = [abs(A[i][j] - int(b)) for j, b in enumerate(input().split())]
    AB_append(row)
 
  dp_cur = [set([]) for _ in range(w)]
  dp_cur[0].add(AB[0][0])
  for i in range(h):
    dp_next = [set([]) for _ in range(w)]
    for j in range(w):
      if j < w - 1:
        add1 = dp_cur[j+1].add
        dif1 = AB[i][j+1]
      if i < h - 1:
        add2 = dp_next[j].add
        dif2 = AB[i+1][j]
      for item in dp_cur[j]:
        if j < w - 1:
          add1(item+dif1)
          add1(abs(item-dif1))
        if i < h - 1:
          add2(item+dif2)
          add2(abs(item-dif2))
    if i == h - 1:
      break
    dp_cur = dp_next
  print(min(dp_cur[w-1]))
if __name__ == '__main__':
  main()
N = int(input())
d = []
visited = [False for _ in range(N)]
for _ in range(N):
  d.append(int(input())-1)
  
def dfs(i,cnt):
  if visited[i]:
    return -1
  elif i == 1:
    return cnt
  else:
    visited[i] = True
    return dfs(d[i],cnt+1)

def main():
  if d[1] == 1:
    return -1
  
  return dfs(0,0)
  
print(main())

### FIXED CODE ###

N = int(input())
d = []
visited = [False for _ in range(N+1)]
for _ in range(N):
  d.append(int(input())-1)

i = 0
cnt = 0
while True:
  if i == 1:
    break
  elif cnt >= N:
    cnt = -1
    break
  elif visited[i]:
    cnt = -1
    break
  else:
    visited[i] = True
    cnt += 1
    i = d[i]
  
print(cnt)
a,b,k = map(int,input().split())

x =[a:b+1]
ans =[]

for i in range(k):
  ans.append(x[i])
  ans.append(x[-(1+i)])
  
  
ans.sort()

print("".joint(ans))

### FIXED CODE ###

A,B,K = map(int,input().split())
            
ans=[]
            
for i in range(K):
  if A+i <=B:
    ans.append(A+i)
  if B-i >= A:
    ans.append(B-i)
            
            
ans = sorted(list(set(ans)))
print(*ans,sep="\n")
N,M=map(int,input().split())

G=[[] for _ in range(N+1)]  #G[0]はダミー
for edge in range(M):
    x,y=map(int,input().split())
    G[x].append(y)

DP=[-1]*(N+1)   #DP[0]はダミー

def rec(now):
    global G

    if DP[now]!=-1:
        return DP[now]

    else:
        res=0
        for next in G[now]:
            res=max(res,rec(next)+1)
        DP[now]=res
        return DP[now]

ans=0
for v in range(1,N+1):
    ans=max(ans,rec(v))

print(ans)



### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

N,M=map(int,input().split())

G=[[] for _ in range(N+1)]  #G[0]はダミー
for edge in range(M):
    x,y=map(int,input().split())
    G[x].append(y)

DP=[-1]*(N+1)   #DP[0]はダミー

def rec(now):
    global G
    global DP

    if DP[now]!=-1:
        return DP[now]

    else:
        res=0
        for next in G[now]:
            res=max(res,rec(next)+1)
        DP[now]=res
        return DP[now]  #resは不可


ans=0
for v in range(1,N+1):
    ans=max(ans,rec(v))



print(ans)
if a < b:
  return print('a < b')
if a > b:
  return print('a > b')
if a == b:
  return print('a == b')
else:
  pass

### FIXED CODE ###

a, b = map(int, input().split())
if a < b:
  print('a < b')
elif a > b:
  print('a > b')
elif a == b:
  print('a == b')
else:
  pass
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 2 ** 31 - 1
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    cnt = collections.Counter()
    ans = 0
    C = []
    for _ in range(N):
        s = SI()
        a = []
        bit = 0
        for x in s:
            x = ord(x) - ord('a')
            bit |= 1 << x
            a.append(bit)
        for i in range(len(s),-1,-1):
            if i == len(s):
                c = 0
            else:
                c = (c * 27 + ord(s[i]) - ord('a') + 1) % MOD
            if i > 0:
                d = c * 27
                for j in range(26):
                    if a[i-1] & (1<<j) & i < 0:
                        cnt[(d+j+1)%MOD] += 1
        C.append(c)
    for c in C:
        ans += cnt[c] - 1

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

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():

    N = int(input())
    d = [[0] * 19 for _ in range(19)]
    c = []
    for _ in range(N):
        x = round(float(input()) * 10**9)
        d2 = 0
        d5 = 0
        while x % 2 == 0 and d2 < 18:
            x //= 2
            d2 += 1
        while x % 5 == 0 and d5 < 18:
            x //= 5
            d5 += 1
        d[d2][d5] += 1

    a = [[0] * 19 for _ in range(19)]
    for i in range(18,-1,-1):
        s = 0
        for j in range(18,-1,-1):
            s += d[i][j]
            a[i][j] = s
            if i < 18:
                a[i][j] += a[i+1][j]

    ans = 0
    for i in range(19):
        for j in range(19):
            ans += d[i][j] * a[18-i][18-j]
            if i >= 9 and j >=9:
                ans -= d[i][j]


    print(ans//2)


if __name__ == '__main__':
    main()
import math
from itertools import accumulate

def is_prime(n):
    if n == 1: return 0

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return 0
    return 1

Q = int(input())
L = [0]*Q
R = [0]*Q

for j in range(Q):
    L[j],R[j] = [int(i) for i in input().split()]

li = []
for i in range(min(L),max(R)+1,1):
    if i%2 == 1:
        li.append(is_prime(i) * is_prime((i+1)//2))
    else:
        li.append(0)

ans = [0]
ans += list(itertools.accumulate(li))

for i,j in zip(L,R):
    print(ans[j-min(L)+1] - ans[i-min(L)])


### FIXED CODE ###

import math
from itertools import accumulate


def is_prime(n):
    if n == 1:
        return 0

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return 0

    return 1


Q = int(input())
L = [0]*Q
R = [0]*Q

for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))

min_L = min(L)
max_R = max(R)

check = []
for i in range(min_L, max_R+1):
    if (i % 2 == 1):
        flg = (is_prime(i) and is_prime((i+1)/2))
    else:
        flg = 0
    check.append(flg)

# 累積和
check = [0] + check
check = list(accumulate(check))

for i in range(Q):
    print(check[R[i] - min_L + 1] - check[L[i] - min_L])
import itertools
n,m=map(int,input().split())
A=[]
for i in range(n):
  a,b=map(int,input().split())
  A.append([a,b])
N=[int(i+2) for i in range(n-1)]
def f(list,n):
  path=0
  if [1,list[0]] in A:
    path+=1
  for i in range(1,n-1):
    if [list[i],list[i-1]] in A or [list[i-1],list[i]] in A:
      path+=1
  if path==n-1:
    return 1
  else:
    return 0  
ans=0
for p in itertools.permutations(N,n-1):
  ans+=f(list(p),n)
print(ans)

### FIXED CODE ###

import itertools
n,m=map(int,input().split())
A=[]
for i in range(m):
  a,b=map(int,input().split())
  A.append([a,b])
N=[int(i+2) for i in range(n-1)]
def f(list,n):
  path=0
  if [1,list[0]] in A:
    path+=1
  for i in range(1,n-1):
    if [list[i],list[i-1]] in A or [list[i-1],list[i]] in A:
      path+=1
  if path==n-1:
    return 1
  else:
    return 0  
ans=0
for p in itertools.permutations(N,n-1):
  ans+=f(list(p),n)
print(ans)
# 動的計画法のテーブルを用意
# dp(n) は頂点nを始点として時の最大有効パスの長さ

def get_inputs():
    N, M = map(int, input().split())

    # グラフgを初期化
    g = [[] for _ in range(N)]

    # 辺情報を読み込みgに追加
    for _ in range(M):
        x, y = map(lambda c: int(c) - 1, (input().split()))
        g[x].append(y)

    return N, M, g


def getlp(x):
    global dp, g

    if dp[x] != -1:
        pass
    elif len(g[x]) == 0:
        dp[x] = 0
    else:
        mxp = 0
        for y in g[x]:
            yp = getlp(y)
            if yp > mxp:
                mxp = yp
        dp[x] = mxp + 1

    return dp[x]


N, M, g = get_inputs()

dp = [-1] * N
ans = 0
for x in range(N):
    dp[x] = getlp(x)
    ans = max(ans, dp[x])

print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

def get_inputs():
    N, M = map(int, input().split())
    
    # グラフgを初期化
    g = [[] for _ in range(N)]
    
    # 辺情報を読み込みgに追加
    for _ in range(M):
        x, y = map(lambda c: int(c) - 1, input().split())
        g[x].append(y)
    
    return N, M, g


def getlp(x):
    global dp, g
    
    if dp[x] != -1:
        return dp[x]
    elif len(g[x]) == 0:
        dp[x] = 0
        return dp[x]
    else:
        dp[x] = max([getlp(y) for y in g[x]]) + 1
        return dp[x]


N, M, g = get_inputs()

dp = [-1] * N
ans = 0
for x in range(N):
    ans = max(ans, getlp(x))

print(ans)
l,r,d = map(str,input.split())
l = int(l)
r = int(r)
d = int(d)
print((r-l+1)//d)



### FIXED CODE ###

l,r,d = map(int,input().split())
print(r//d - (l-1)//d)
line = False
while True:
    a,b = map(int, raw_input().split())
    if line: print ""
    line = True
    count = 0
    for i in range(a, b+1):
        if (i % 4 == 0 and i % 100 != 0) or i % 400 == 0:
            print i
            count += 1
    if count == 0: print "NA"

### FIXED CODE ###

line = False
while 1:
    a,b = map(int, raw_input().split())
    if a == b == 0: break
    if line: print
    line = True
    count = 0
    for i in range(a, b+1):
        if (i % 4 == 0 and i % 100 != 0) or (i % 400 == 0):
            print i
            count += 1
    if count == 0: print "NA"
#!/usr/bin/env python3
 
S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()

ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1

print(ans)


### FIXED CODE ###

from collections import defaultdict
from bisect import bisect_right

def sol():
    S = input()
    T = input()

    setS = set(S)
    setT = set(T)
    for t in setT:
        if not t in setS:
            print('-1')
            return

    posS = defaultdict(list)

    for i, s in enumerate(S):
        posS[s].append(i)

    for s in enumerate(S):
        posS[s].sort()

    prev = -1
    ans = 0
    N = len(S)

    for t in T:
        next = bisect_right(posS[t], prev)
        if next >= len(posS[t]):
            ans += N - prev
            ans += posS[t][0]
            prev = posS[t][0]
        else:
            ans += posS[t][next] - prev
            prev = posS[t][next]

    print(ans)

sol()
import numpy as np
n, q = map(int, input().split())
s = input()
dic = {}
g = np.ones(n).astype(int)
t_list = []
d_list = []

for i in range(q):
    t, d = input().split()
    t_list.append(t)
    if d == 'L':
        d_list.append(-1)
    else:
        d_list.append(1)


def find_pos(left, right):
    return left + (right - left - 1) // 2


def calc(sites, ts, ds):
    def check(idx):
        num = idx
        for j in range(q):
            site = sites[num]
            if ts[j] == site:
                num += ds[j]
            if num < 0:
                return -1
            if num > n - 1:
                return 1
        return 0

    def func(left, right):
        if right - left == 1:
            if check(right) > -1:
                return left
            else:
                return right
        pos = find_pos(left, right)
        if check(pos) > -1:
            return func(left, pos + 1)
        else:
            return func(pos + 1, right)
    return func


f1 = calc(s, t_list, d_list)
f2 = calc(s[::-1], t_list, [-i*1 for i in d_list])
left_out = f1(0, n)
right_out = f2(0, n)
print(n - left_out - right_out)


### FIXED CODE ###

n, q = map(int, input().split())
s = input()
dic = {}
t_list = []
d_list = []

for i in range(q):
    t, d = input().split()
    t_list.append(t)
    if d == 'L':
        d_list.append(-1)
    else:
        d_list.append(1)


def find_pos(left, right):
    return left + (right - left - 1) // 2


def calc(sites, ts, ds):
    def check(idx):
        num = idx
        for j in range(q):
            site = sites[num]
            if ts[j] == site:
                num += ds[j]
            if num < 0:
                return -1
            if num > n - 1:
                return 1
        return 0

    def func(left, right):
        assert left > -1
        assert right < n + 1
        if right - left == 1:
            if check(left) > -1:
                return left
            else:
                return right
        pos = find_pos(left, right)
        if check(pos) > -1:
            return func(left, pos + 1)
        else:
            return func(pos + 1, right)
    return func


f1 = calc(s, t_list, d_list)
f2 = calc(s[::-1], t_list, [-i*1 for i in d_list])
print(n - f1(0, n) - f2(0, n))
N = int(input())
T = list(map(int, input().split()))
S = sum(T)

M  = int(input())
PX = [int(input()) for _ in range(M)]

for px in PX:
    P, X = px
    print(S - T[P-1] + X)


### FIXED CODE ###

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

M  = int(input())

for m in range(M):
    P, X = map(int, input().split())
    print(S - T[P-1] + X)
# B
T = str(input())

def score(t):
    n = 0
    while "PD" in t:
        t = t.replace("PD","",1)
        n+=1
    n += t.count("D")
    return n

for i in range(T.count("?")):
    index = T.index("?")
    if T[index - 1] == "P":
        T = T.replace("?","D",1)
    elif T[index + 1] == "D":
        T = T.replace("?","P",1)
    elif T[index + 1] == "?":
        T = T.replace("?","P",1)
    else:
        T = T.replace("?","D",1)
print(T)

### FIXED CODE ###

# B
T = str(input())
try:
    for i in range(T.count("?")):
        index = T.index("?")
        if T[index - 1] == "P":
            T = T.replace("?","D",1)
        elif T[index + 1] == "D":
            T = T.replace("?","P",1)
        elif T[index + 1] == "?":
            T = T.replace("?","P",1)
        else:
            T = T.replace("?","D",1)
    print(T)
except:
    print(T.replace("?","D"))
N=int(input())
A=list(map(int,input().split()))
B=A.copy()
B.sort()
A_max=B[N-1]+N
sum_A=[0]*(A_max+1)
for i in range(A_max+1):
  for num in range(N):
    sum_A[i]+=abs(A[num]-i)
sum_A.sort()
print(sum_A[0])
    
  
  




### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
  B.append(A[i]-(i+1))
B.sort()
if N%2==0:
  a=N/2
  b=int((B[int(a)]+B[int(a-1)])/2)
else:
  a=(N+1)/2
  b=B[int(a-1)]
for i in range(N):
  B[i]=abs(B[i]-b)
print(sum(B))
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a_sum = [0]
b_sum = [0]
for i in range(n):
    a_sum.append(a[i]+a_sum[i])
    if a_sum[i]>1e+9:
        break
for i in range(m):
    b_sum.append(b[i]+b_sum[i])
    if b_sum[i]>1e+9:
        break
        
ans = 0
for i in range(len(b_sum)):
    if a_sum[i]>k:
        break
    time = k - a_sum[i]
    for j in range(len(b_sum)):
        if time<b_sum[j+1]:
            break
    if time>=b_sum[len(b_sum)-1]:
        j = len(b_sum)-1
    ans = max(ans,i+j)
    
print(ans)

### FIXED CODE ###

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a_sum = [0]
b_sum = [0]
for i in range(n):
    a_sum.append(a[i]+a_sum[i])
    if a_sum[i]>k:
        break
for i in range(m):
    b_sum.append(b[i]+b_sum[i])
    if b_sum[i]>k:
        break
        
ans = 0
y = len(b_sum)-1
for i in range(len(a_sum)):
    if a_sum[i]>k:
        break
    time = k - a_sum[i]
    for j in range(y,-1,-1):
        if time>=b_sum[j]:
            y = j
            break
    if time>=b_sum[len(b_sum)-1]:
        j = len(b_sum)-1
    ans = max(ans,i+j)
    
print(ans)