Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split())

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

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf = UnionFind(N)
#print(uf.parents)

for i in range(M):
    a = list(map(int, input().split()))
    uf.union(a[0], a[1])

print(uf.group_count()-1)

### FIXED CODE ###

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

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

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf = UnionFind(N)
#print(uf.parents)

for i in range(M):
    a = list(map(int, input().split()))
    uf.union(a[0]-1, a[1]-1)
#print(uf)
print(uf.group_count()-1)
#abc163c
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
 print(a.count(i+1))


### FIXED CODE ###

#abc163a
from math import pi
r=int(input())
print(r*pi*2)
a=list(map(int,input().split()))
b=a.sorted()
print(int(b[0])+int(b[1]))

### FIXED CODE ###

a=list(map(int,input().split()))
b=sorted(a)
print(int(b[0])+int(b[1]))
# -*- coding: utf-8 -*-


def main():
    h, w = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(h)]
    operations = list()

    # See:
    # https://atcoder.jp/contests/abc109/submissions/3154532
    for row in range(h):
        for col in range(w - 1):
            if a[row][col] % 2 == 1:
                operations.append((row + 1, col + 1, row + 1, col + 2))
                a[row][col] -= 1
                a[row][col + 1] += 1

    for row in range(h - 1):
        if a[row][w - 1] % 2 == 1:
            operations.append((row + 1, col + 1, row + 2, col + 1))
            a[row][col] -= 1
            a[row + 1][col] += 1

    n = len(operations)
    print(n)

    for i in range(n):
        y, x, y_dash, x_dash = operations[i]
        print(y, x, y_dash, x_dash)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-


def main():
    h, w = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(h)]
    operations = list()
    row = 0
    prev_x, prev_y = 0, 0
    odd_count = 0

    while row < h:
        if row % 2 == 0:
            for col in range(w):
                if a[row][col] % 2 == 1:
                    if odd_count == 0:
                        prev_x, prev_y = col + 1, row + 1
                        odd_count = 1
                    else:
                        cur_x, cur_y = col + 1, row + 1
                        operations.append((prev_y, prev_x, cur_y, cur_x))
                        prev_x, prev_y = cur_x, cur_y
                        odd_count = 0
                else:
                    if odd_count == 1:
                        cur_x, cur_y = col + 1, row + 1
                        operations.append((prev_y, prev_x, cur_y, cur_x))
                        prev_x, prev_y = cur_x, cur_y
        else:
            for col in range(w - 1, -1, -1):
                if a[row][col] % 2 == 1:
                    if odd_count == 0:
                        prev_x, prev_y = col + 1, row + 1
                        odd_count = 1
                    else:
                        cur_x, cur_y = col + 1, row + 1
                        operations.append((prev_y, prev_x, cur_y, cur_x))
                        prev_x, prev_y = cur_x, cur_y
                        odd_count = 0
                else:
                    if odd_count == 1:
                        cur_x, cur_y = col + 1, row + 1
                        operations.append((prev_y, prev_x, cur_y, cur_x))
                        prev_x, prev_y = cur_x, cur_y

        row += 1

    n = len(operations)
    print(n)

    for i in range(n):
        y, x, y_dash, x_dash = operations[i]
        print(y, x, y_dash, x_dash)


if __name__ == '__main__':
    main()
url = "https://atcoder.jp/contests/abc082/tasks/abc082_b"


def main():
    s1, s2 = [input() for i in range(2)]
    l1 = sorted(list(s1))
    l2 = sorted(list(s2), reverse=True)
    for i in range(len(l1)):
        if l1[i] < l2[i]:
            print('Yes')
            exit()
    if len(l1) < len(l2) and l1[-1] <= l2[-1]:
        print('Yes')
        exit()
    print('No')




if __name__ == '__main__':
    main()




### FIXED CODE ###

url = "https://atcoder.jp/contests/abc082/tasks/abc082_b"


def main():
    s1, s2 = [input() for i in range(2)]
    l1 = sorted(list(s1))
    l2 = sorted(list(s2), reverse=True)
    indx = 0
    if len(l1) > len(l2):
        indx = len(l2)
    else:
        indx = len(l1)
    for i in range(indx):
        if l1[i] < l2[i]:
            print('Yes')
            exit()
    if len(l1) < len(l2) and l1[-1] <= l2[-1]:
        print('Yes')
        exit()
    print('No')




if __name__ == '__main__':
    main()
x,y=map(int,input().split())
c=0
for i in range(0,x+1):
    if y>50:
        c+=1
        print("No")
        break
    if y==2*(x-i)+4*i:
        c+=1
        print("Yes")
        break
    elif y==2*x+4*(x-i):
        c+=1
        print("Yes")
        break
if c==0
    print("No")

### FIXED CODE ###

x,y=map(int,input().split())
c=0
for i in range(0,x+1):
    if y==2*(x-i)+4*i:
        c+=1
        print("Yes")
        break
    elif y==2*i+4*(x-i):
        c+=1
        print("Yes")
        break
if c==0:
    print("No")
N = int(input())
if N < 1200:
  print("ABC")
elif N < 2800:
  print("ARC")
else
  print("AGC")



### FIXED CODE ###

N = int(input())
if N < 1200:
  print("ABC")
elif N < 2800:
  print("ARC")
else:
  print("AGC")
import numpy as np

N = int(input())

pow6 = [6]
pow9 = [9]

i=0
while pow6[i]*6 < N:
    pow6.append(6*pow6[i])
    i += 1

i=0
while pow9[i]*9 < N:
    pow9.append(9*pow9[i])
    i += 1

ans = 0
while N > 6:

    tmp_6 = [i for i in pow6 if i < N]
    tmp_9 = [i for i in pow9 if i < N]

    if tmp_9[-1] >= tmp_6[-1]:
        N -= tmp_9[-1]
    else:
        N -= tmp_6[-1]
    ans = ans + 1

ans = ans + N
print(ans)


### FIXED CODE ###

import numpy as np

N = int(input())

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

    if res < ans:
        ans = res



print(ans)
k = int(input())
a, b = map(int, input().split())

 
for i in range(a, b+1):
	if i % k == 0:
    	print("OK")
    	break
else:
	print("NG")

### FIXED CODE ###

k = int(input())
a, b = map(int, input().split())
 
for x in range(a, b+1):
    if x % k == 0:
        print('OK')
        break
else:
    print('NG')
N = int(input())
p = list(map(int, input().split()))
q = sorted(p)
k = 0
for i in range(1, N + 1):
    if p[i] - q[i] != 0:
        k += 1

if k > 2:
    print("NO")
else:
    print("YES")


### FIXED CODE ###

N = int(input())
p = list(map(int, input().split()))
q = sorted(p)
k = 0
for i in range(N):
    if p[i] - q[i] != 0:
        k += 1

if k > 2:
    print("NO")
else:
    print("YES")
c=input()
if c=="a" or c=="e" or c=="i" or c=="o" or c=="u" :
print("vowel")
else:
print("consonant")

### FIXED CODE ###

c = input()
if c == "a" or c == "e" or c == "i" or c == "o" or c == "u":
  print("vowel")
else:
  print("consonant")
import itertools as it
import numpy as np

def rain_volume(A, N):
    A_citer = it.cycle(A)
    X = np.array([0]*N)
    for i in range(N):
        if i%2 == 0:
            A_p = [next(A_citer) for i in range(N)]
            X += A_p
            next(A_citer)
        elif i%2 != 0:
            A_m = [-next(A_citer) for i in range(N)]
            X += A_m
            next(A_citer)
    return X

if __name__ == '__main__':
    N = int(input())
    A = np.array(list(map(int, input().split(' '))))

    #N = 10**4 - 1
    #A = [10**9]*N
    print(' '.join(map(str, rain_volume(A, N))))

### FIXED CODE ###

def rain_volume(A, N):
    X = [0]*N
    X[0] = sum(A)
    for i, a in enumerate(A):
        if i%2 != 0:
            X[0] -= 2*a
    for i in range(1, N):
        if i != 0:
            X[i] = 2*A[i-1] - X[i-1]
    return X

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split(' ')))

    print(' '.join(map(str, rain_volume(A, N))))
import itertools

dx = (0, 0, 0, 1,-1, 1, 1,-1,-1,-2, 2, 0, 0)
dy = (0, 1,-1, 0, 0, 1,-1, 1,-1, 0, 0,-2, 2)
dd = (5, 9, 13)

def drop(fab, start, used, size_list):
    for xy in range(start, 100):
        y = xy%10
        x = xy//10
        size = size_list[used]
        check = True
        for i in range(size):
            if fab[y + dy[i] + 2][x + dx[i] + 2] == 0:
                check = False
                break
        if check:
            for i in range(size):
                fab[y + dy[i] + 2][x + dx[i] + 2] -= 1
            if sum(map(sum, fab)):
                if size == size_list[used + 1]:
                    result = drop(fab, start + 2, used + 1, size_list)
                else:
                    result = drop(fab, 0, used + 1, size_list)
                if result:
                    result.append([x, y, dd.index(size) + 1])
                    return result
                for i in range(size):
                    fab[y + dy[i] + 2][x + dx[i] + 2] += 1
            else:
                return [[x, y, dd.index(size) + 1]]
    return False

fab = [[0 for i in range(14)] for j in range(14)]

n = int(input())

for i in range(10):
    fab[i + 2][2:12] = list(map(int, input().split()))

s = sum(map(sum, fab))
d_all = list(itertools.combinations_with_replacement([5,9,13], n))
d_list = [l for l in d_all if sum(l) == s]

ans = [0 for i in range(n)]
for d in d_list:
    d_tmp = sorted(d)[::-1]
    ans = drop(fab, 0, 0, d_tmp)
    if ans:
        for a in ans:
            print(*a)
        break



### FIXED CODE ###

import itertools

dx = (0, 0, 0, 1,-1, 1, 1,-1,-1,-2, 2, 0, 0)
dy = (0, 1,-1, 0, 0, 1,-1, 1,-1, 0, 0,-2, 2)
dd = (5, 9, 13)

def drop(fab, start, used, size_list):
    for xy in range(start, 100):
        y = xy%10
        x = xy//10
        size = size_list[used]
        for i in range(size):
            if not fab[y + dy[i] + 2][x + dx[i] + 2]:
                break
        else:
            for i in range(size):
                fab[y + dy[i] + 2][x + dx[i] + 2] -= 1
            if sum(map(sum, fab)):
                if size == size_list[used + 1]:
                    result = drop(fab, xy, used + 1, size_list)
                else:
                    result = drop(fab, 0, used + 1, size_list)
                if result:
                    result.append([x, y, dd.index(size) + 1])
                    return result
                for i in range(size):
                    fab[y + dy[i] + 2][x + dx[i] + 2] += 1
            else:
                return [[x, y, dd.index(size) + 1]]
    return False

fab = [[0 for i in range(14)] for j in range(14)]

n = int(input())

for i in range(10):
    fab[i + 2][2:12] = list(map(int, input().split()))

s = sum(map(sum, fab))
d_all = list(itertools.combinations_with_replacement([5,9,13], n))
d_list = [l for l in d_all if sum(l) == s]

ans = [0 for i in range(n)]
for d in d_list:
    d_tmp = sorted(d)[::-1]
    ans = drop(fab, 0, 0, d_tmp)
    if ans:
        for a in ans:
            print(*a)
        break
x = input()
if x < 1200:
  print("ABC\n")
else:
  print("ARC\n")
  

### FIXED CODE ###

x = int(input())
if x < 1200:
  print("ABC")
else:
  print("ARC")
n = int(input())
line = input()
L = [int(x) for x in line.split()]

flags = [False] * n
loops = []

for i, x in enumerate(L):
    k = x - 1
    if flags[k]:
        continue
    if i == k:
        flags[i] = True
        continue

    loop = []
    while x not in loop:
        flags[k] = True
        loop.append(x)
        x = L[k]
        k = x - 1
    loops.append(loop)

cost = 0
for loop in loops:
    m = min(loop)
    cost += m * (len(loop)-1) + sum(loop) - m

print(cost)

### FIXED CODE ###

n = int(input())
line = input()
L = [int(x) for x in line.split()]

flags = [False] * n
loops = []

S = sorted(L)
for idx, x in enumerate(L):
    k = S.index(x)
    if flags[k]:
        continue
    if k == idx:
        flags[k] = True
        continue

    ws = []
    while x not in ws:
        flags[k] = True
        ws.append(x)
        x = L[k]
        k = S.index(x)
    loops.append(ws)

cost = 0
for ws in loops:
    n = len(ws)
    a = sum(ws) + (n - 2) * min(ws)
    b = sum(ws) + min(ws) + (n + 1) * min(L)
    cost += min(a, b)

print(cost)
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()

ans = []
x,y,h = MAP()
for i in range(101):
    for j in range(101):
        ans.append((i,j,h+abs(i-x)+abs(j-y)))

for i in range(n-1):
    tmp = []
    x,y,h = MAP()
    for j in range(101):
        for k in range(101):
            if (j,k,h+abs(j-x)+abs(k-y)) in ans:
                tmp.append((j,k,h+abs(j-x)+abs(k-y)))
    ans = tmp

print(*ans[0])

### FIXED CODE ###

import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()

x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = MAP()
    x.append(xx)
    y.append(yy)
    h.append(hh)

kk = h.index(max(h))
k = 0

for i in range(101):
    for j in range(101):
        ass = h[kk] + abs(x[kk]-i) + abs(y[kk]-j)
        for r in range(n):
            if h[r]==0:
                if ass-abs(x[r]-i)-abs(y[r]-j)>0:
                    ass = -1
                    break
            else:
                if ass != abs(x[r]-i)+abs(y[r]-j)+h[r]:
                    ass = -1
                    break
        if ass!=-1:
            print(i,j,ass)
            break
n=int(input())
a = [int(input()) for _ in range(n)]
b = max(a)
c = a.index(b)
for i in range(n):
        if i == c:
                print(max(sorted(a)[:n-1]))
        else:
                print(b)

### FIXED CODE ###

n=int(input())
print(3*n**2)
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(array[k+1])

### FIXED CODE ###

array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(array[k-1])
# Python template 
from collections import defaultdict 
import sys
import math 

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()


g = defaultdict(set)
(n,m) = get_ints()
visited = [0]*n 


def dfs(i,l,par):
    global visited
    visited[i] = True
    l.append(i)
    for j in g[i]:
        if j!=par and not visited[j]:
            dfs(j,l,i)

for i in range(m):
    (u,v) = get_ints()
    g[u-1].add(v-1)
    g[v-1].add(u-1)

ans = 0
for i in range(n):
    if not visited[i]:
        l = []
        dfs(i,l,-1)
        ans = max(ans,len(l))
        
print(ans)

### FIXED CODE ###

# Python template 
from collections import defaultdict 
import sys
import math 

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

sys.setrecursionlimit(10**6) 
g = defaultdict(set)
(n,m) = get_ints()
visited = [0]*n 


def dfs(i,l,par):
    global visited
    visited[i] = True
    l.append(i)
    for j in g[i]:
        if j!=par and not visited[j]:
            dfs(j,l,i)

for i in range(m):
    (u,v) = get_ints()
    g[u-1].add(v-1)
    g[v-1].add(u-1)

ans = 0
for i in range(n):
    if not visited[i]:
        l = []
        dfs(i,l,-1)
        ans = max(ans,len(l))
        
print(ans)
def main():
    from bisect import bisect_left
    from bisect import bisect_right

    n,q=map(int,input().split())
    stx=[list(map(int,input().split())) for _ in [0]*n]
    d=[int(input()) for _ in [0]*q]
    stx=[[s-x,t-x-1,x] for s,t,x in stx]
    stx=[[bisect_left(d,s),bisect_right(d,t),x] for s,t,x in stx]
    event=[]
    for s,t,x in stx:
        event.append([s,1,x])
        event.append([t,-1,x])
    event.sort()
    event+=[[q,1,10**9+1]]
    now=set()
    i=0
    for t,flag,x in event:
        if t>i:
            i+=1
            if len(now)==0:
                print(-1)
            else:
                print(min(now))
        if flag==1:
            now.add(x)
        else:
            now.remove(x)
main()

### FIXED CODE ###

def main():
    from bisect import bisect_left
    from bisect import bisect_right
    from sys import stdin
    input=stdin.readline

    n,q=map(int,input().split())
    stx=[list(map(int,input().split())) for _ in [0]*n]
    d=[int(input()) for _ in [0]*q]
    stx=[[s-x,t-x-1,x] for s,t,x in stx]
    stx=[[bisect_left(d,s),bisect_right(d,t),x] for s,t,x in stx]

    #セグ木の要素数（num）および深さ（depth）を計算
    basesize=q
    num,depth=1,1
    while num<basesize:
        num*=2
        depth+=1
    num-=1
    #セグ木を構築
    treesize=num+basesize
    tree=[10**9+1]*treesize
    
    #半開区間[lower,upper)について更新の準備をする関数
    def range_update_pre(lower,upper,new_value):
        q=[[0,1]]  #インデックス、階層
        while q:
            i,f=q.pop()
            #popしたインデックスと階層から、求める下限と上限を算出する
            #幅
            width=pow(2,depth-f)
            #下限と中央と上限
            kagen=(i-pow(2,f-1)+1)*width
            chuo=kagen+width//2
            jogen=kagen+width
            k=2*i+1
            if lower<=kagen and jogen<=upper:
                tree[i]=min(new_value,tree[i])
                continue
            if k<treesize:
                if lower<=kagen and chuo<=upper:tree[k]=min(new_value,tree[k])
                elif lower<=chuo:q.append([k,f+1])
            if k+1<treesize:
                if lower<=chuo and jogen<=upper:tree[k+1]=min(new_value,tree[k+1])
                elif chuo<=upper:q.append([k+1,f+1])

    for s,t,x in stx:
        if s<t:
            range_update_pre(s,t,x)

    for i in range(1,treesize):
        tree[i]=min(tree[i],tree[(i-1)//2])

    ans=[i for i in tree[treesize-basesize:]]
    for i in ans:
        if i==10**9+1:
            print(-1)
        else:
            print(i)
main()
N = int(input())
S, T = input("Enter a two value: ").split() 
if((len(S)==N)&&(len(T)==N)):
  print(S+T)

### FIXED CODE ###

n = int(input())
s,t = input().split()
 
ans = []
 
for i in range(n):
    ans.append(s[i])
    ans.append(t[i])
    
print("".join(ans))
N = int(input())
x = 800*N
if 15 <= int(N) <30 :
    y = 200
elif  30<= int(N) <45:
    y = 400
elif 45 <= int(N) <60:
    y = 600
elif 60 <= int(N) < 75:
    y = 800
elif 75 <= int(N) < 90:
    y = 1000
elif 90 <= int(N) < 100:
    y = 1200
elif int(N) ==100:
    y = 1200
print(x - y)

### FIXED CODE ###

n = int(input())
print(800 * n - 200 * (n // 15))
# coding=utf-8
from collections import deque

def reconstruction(left, right):
    global pre_order
    global in_order
    global post_order
    global n

    if left > right:
        return None
    elif left == right:
        root = pre_order.popleft()
        post_order.append(root)
        return None
    else:
        root = pre_order.popleft()

    root_pos = in_order.index(root)
    reconstruction(left, root_pos-1)
    reconstruction(root_pos+1, right)
    post_order.append(root)

n = int(input())
pre_order = deque(map(int, input().split()))
in_order = deque(map(int, input().split()))
post_order = []

reconstruction(0, n-1)
print(*post_order)

### FIXED CODE ###

# coding=utf-8
def reconstruction(left, right):
    global pre_order
    global in_order
    global post_order
    global n

    if left > right:
        return None
    elif left == right:
        root = pre_order.pop(0)
        post_order.append(root)
        return None
    else:
        root = pre_order.pop(0)

    root_pos = in_order.index(root)
    reconstruction(left, root_pos-1)
    reconstruction(root_pos+1, right)
    post_order.append(root)

n = int(input())
pre_order = list(map(int, input().split()))
in_order = list(map(int, input().split()))
post_order = []

reconstruction(0, n-1)
print(*post_order)
N = int(input())
B = list(map(int, input().split()))

A = [0] * N


for i in range(N-1):
  A[i] = min(B[i-1],B[i])

A[0] = min(B[0],B[1])
A[N-1] = B[N-2]

print(sum(A))

### FIXED CODE ###

n = int(input())

ans = n ** 3

print(ans)
n=int(input())
if n%2==1:
  ans=(n+1)/(2*n)
else:
  ans=0.5
printa(ans)
    

### FIXED CODE ###

n=int(input())
if n%2==1:
  ans=(n+1)/(2*n)
else:
  ans=0.5
print(ans)
n = int(inpput())
if n >= 30:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

n = int(input())
if n >= 30:
    print("Yes")
else:
    print("No")
n,k = map(int,input().aplit())
print(min(n%k,abs(n%k-k)))

### FIXED CODE ###

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

print(min(n%k, abs(n%k-k)))
t=input()
p='A'+t+'A'
result=''
for i in range(len(p)-2):
    if t[i]=='?':
        if result[i-1]=='P'or t[i+1]=='P':
            result+='D'
        else:
            result+='P'
    else:
        result+=t[i]
print(result)

### FIXED CODE ###

t=input()
result=''
for i in range(len(t)-1):
    if t[i]=='?':
        try:
            if result[i-1]=='P':
                result+='D'
            else:
                if t[i+1]=='P':
                    result+='D'
                else:
                    result+='P'
        except:
            if t[i+1]=='P':
                result+='D'
            else:
                result+='P'
    else:
        result+=t[i]
if t[len(t)-1]=='?' or  t[len(t)-1]=='D':
    print(result+'D')
else:
    print(result+'P')
n, k = list(map(int, input().split(' ')))
h_arr = list(map(int, input().split(' '))).sorted(reverse=True)

if n <= k:
  print('0')
else:
  print(sum(h_arr[k:]))

### FIXED CODE ###

n, k = list(map(int, input().split(' ')))
h_arr = sorted(list(map(int, input().split(' '))),reverse=True)
 
if n <= k:
  print('0')
else:
  print(sum(h_arr[k:]))