Harryxun/stf_run huggingface dataset:
S = input()
a = ""
stock = ""
data = []

for i in S:
    a = a + i
    if a != stock:
        stock = a
        data.append(a)
        a = ""
count = len(data)


if a == stock:
    i = 1
    data.append(a)
    while True:
        word = ""
        a = ""
        stock2 = ""
        data2 = []
        for j in range(i+1):
            word = data[-(j+1)] + word
        
        for j in reversed(word):
            a = j + a
            if a != stock2:
                stock2 = a
                data2.insert(0,a)
                a = ""
        if (data2[0] != data[-(i+2)]) and (a == ""):
            count = len(data) - (i+1) + len(data2)
            break
        i += 1
        
        

print(count)

### FIXED CODE ###

S = input()
a = ""
stock = ""
data = []

for i in S:
    a = a + i
    if a != stock:
        stock = a
        data.append(a)
        a = ""
count = len(data)


if a == stock:
    i = 1
    data.append(a)
    check = 1
    c = 0
    while True:
        word = ""
        a = ""
        c = 0
        stock2 = ""
        data2 = []
        for j in range(i+1):
            word = data[-(j+1)] + word
        
        for j in reversed(word):
            c += 1
            a = j + a
            if check > c:
                continue
            if a != stock2:
                stock2 = a
                data2.insert(0,a)
                a = ""
        if len(data2)>=2:
            if (len(S)<=i+2) and (data2[0]!=data2[1]) and (a == ""):
                count = len(data2)
                break
            elif len(S)<=i+2:
                check += 1
                if check == len(S):
                    count = 1
                    break
                continue
        elif (len(data2)==1) and (a==""):
            if S==data2[0]:
                count = 1
                break
            else:
                i += 1
                continue
        elif len(data2)==1:
            check += 1
            continue
        if (data2[0] != data[-(i+2)]) and (a == ""):
            count = len(data) - (i+1) + len(data2)
            break
        i += 1
        

print(count)
blue = []
red = []
N = int(input())
for card in range(N):
    blue.append(input())
M = int(input())
for card in range(M):
    red.append(input())

prize = 0
s = input()
for n in blue:
    if s == n:
        prize +=1
for m in red:
    if s == m:
        prize -=1
print(prize)

### FIXED CODE ###

blue = []
red = []
N = int(input())
for card in range(N):
    blue.append(input())
M = int(input())
for card in range(M):
    red.append(input())

max = 0
for b in blue:
    if max < blue.count(b) - red.count(b):
        max = blue.count(b) - red.count(b)
        
print(max)
#!/usr/bin/env python3
import sys
import statistics
import collections

def solve(n: int, v: "List[int]"):
    half_length = len(v) // 2
    O = [v[i] for i in range(1, n, 2)]
    E = [v[i] for i in range(0, n, 2)]

    co = list(collections.Counter(O).most_common())
    ce = list(collections.Counter(E).most_common())
    o1 = co[0][0]
    e1 = ce[0][0]

    O_ = list(filter(lambda o: o != o1, O))
    E_ = list(filter(lambda e: e != e1, E))
    num_o_1 = len(O_) 
    num_e_1 = len(E_)

    if e1 != o1:
        num = num_o_1 + num_e_1
    else:
        if len2(co) == 1 and len2(ce) == 1:
            num = half_length
        elif len(co) == 1:
            e2 = ce[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num = num_o_1 + num_e_2
        elif len(ce) == 1:
            o2 = co[1][0]
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = num_o_2 + num_e_1
        else:
            e2 = ce[1][0]
            o2 = co[1][0]
            num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)
    print(num)
    return

def len2(l):
    n = 0
    for i in l:
        n += 1
    return n

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, v)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import statistics
import collections

def solve(n: int, v: "List[int]"):
    half_length = len(v) // 2
    O = [v[i] for i in range(1, n, 2)]
    E = [v[i] for i in range(0, n, 2)]

    co = list(collections.Counter(O).most_common())
    ce = list(collections.Counter(E).most_common())
    o1 = co[0][0]
    e1 = ce[0][0]

    O_ = list(filter(lambda o: o != o1, O))
    E_ = list(filter(lambda e: e != e1, E))
    num_o_1 = len(O_) 
    num_e_1 = len(E_)

    num = 0
    if e1 != o1:
        num = num_o_1 + num_e_1
    else:
        if len(co) == 1 and len(ce) == 1:
            num = half_length
        elif len(co) == 1:
            e2 = ce[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num = num_o_1 + num_e_2
        elif len(ce) == 1:
            o2 = co[1][0]
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = num_o_2 + num_e_1
        else:
            e2 = ce[1][0]
            o2 = co[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)
    print(num)
    return

def len2(l):
    n = 0
    for i in l:
        n += 1
    return n

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, v)

if __name__ == '__main__':
    main()
n, t = map(int, input().split())
d0, d1 = [0] * (t+1), [0] * (t+1)
for i in range(n):
  a, b = map(int, input().split())
  for l in range(t,a-1,-1):
    d0[l] = max(d0[l], b+d0[l-a])
    d1[l] = max(d1[l], b+d1[l-a], b+d0[l-1])
  for l in range(a-1,0,-1):
    d1[l] = max(d1[l], b+d0[l-1])
print(d1[t])

### FIXED CODE ###

n, t = map(int, input().split())
a, b = [0] * n, [0] * n
for i in range(n):
  a[i], b[i] = map(int, input().split())

dp = [[[0] * (t+1) for i in range(n+1)] for j in range(2)]
for i in range(n):
  for d in range(2):
    for l in range(1,t+1):
      if(l < a[i]):
        dp[d][i+1][l] = max(dp[d][i][l], d*(b[i]+dp[0][i][l-1]))
      else:
        dp[d][i+1][l] = max(dp[d][i][l], b[i]+dp[d][i][l-a[i]], d*(b[i]+dp[0][i][l-1]))

print(dp[1][n][t])
if "7" in input()
 print("Yes")
else print("No")

### FIXED CODE ###

N = input()
if "7" in N:
  print("Yes")
else:
  print("No")
a, b, c =  list(map(int, input().split()))

ans = (a!=b) + (b!=c) + (c!=a)

ans = 1 if ans == 0

print(ans) 


### FIXED CODE ###

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

ans = (a!=b) + (b!=c) + (c!=a)

ans = 1 if ans == 0 else ans

print(ans)
A = list(map(int, input().split()))
l = [[0,1],[1,2],[0,3]
ll = []
for i,j in l:
	ll.append(abs(A[i]-A[j]))
print(min(ll))

### FIXED CODE ###

A = list(map(int, input().split()))
b = [[0, 1], [2, 1], [2, 0]]
l = 0
n = []
for i, j in b:
	l = l + abs(A[j]-A[i])
	n.append(abs(A[j]-A[i]))
l = l - max(n)
print(l)
a = int(input)
b = int(input)
h = int(input)
print ((a+b)*h //2)

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
print ((a+b)*h //2)
def fill0(s,x,y):
	global A
	A[y][x] = 0
	if x < W-1 and A[y][x+1] == s: fill0(s,x+1,y)
	if y < H-1 and A[y+1][x] == s: fill0(s,x,y+1)
	if x > 0   and A[y][x-1] == s: fill0(s,x-1,y)
	if y > 0   and A[y-1][x] == s: fill0(s,x,y-1)

while 1:
	H,W = map(int,raw_input().split())
	if H == 0: break
	A = [list(raw_input()) for i in range(H)]
	ans = 0
	for y in range(H):
		for x in range(W):
			if A[y][x] in ["#","@","*"]:
				fill0(A[y][x],x,y)
				ans += 1
	print ans

### FIXED CODE ###

import sys
sys.setrecursionlimit(20000)
def solve(h,w,count,c):
    if 0 <= h < H and 0 <= w < W and A[h][w] == c:
        A[h][w] = count
        for dh,dw in zip([1,0,-1,0],[0,1,0,-1]):
            solve(h+dh,w+dw,count,c)
while 1:
    H,W = map(int,raw_input().split())
    if H == W == 0: break
    A = [list(raw_input()) for _ in range(H)]
    count = 0
    for h in range(H):
        for w in range(W):
            if type(A[h][w]) is not int:
                solve(h,w,count,A[h][w])
                count += 1
    print count
S = input()
w = int(input())
count=0
str = ""
while(count <= len(S)-1):
    str += S[count]
    count += w
print(str)

### FIXED CODE ###

s = raw_input()
w = int(raw_input())

ss = ''

for i in xrange(0, len(s), +w): ss += s[i]

print ss
S = list(input())
L = list('keyence')
if len(L) > len(S):
	print('NO')
else:
	while L[0] == S[0]:
    	L = L[1:]
    	S = S[1:]
	while len(L) != 0 and L[-1] == S[-1]:
    	L = L[:-1]
    	S = S[:-1]
	if L == []:
    	print('YES')
	else:
    	print('NO')


### FIXED CODE ###

S = list(input())
L = list('keyence')
while len(L)*len(S) > 0 and L[0] == S[0]:
    del L[0]
    del S[0]
while len(L)*len(S) > 0 and L[-1] == S[-1]:
    del L[-1]
    del S[-1]
if L == []:
    print('YES')
else:
    print('NO')
first_set_count = int(input());
first_set = [int(n) for n in input().split()];
second_set_count = int(input());
second_set = [int(n) for n in input().split()];

def binary_search(num, s, start, end):
    if start == end:
        if s[start] == num:
            return True;
        else:
            return False;
    else:
        mid = (start + end) // 2;
        if s[mid] == num:
            return True;
        elif num > s[mid]:
            start = mid + 1;
            return binary_search(num, s, start, end);
        else:
            end = mid - 1;
            return binary_search(num, s, start, end);

count = 0;
for num in second_set:
    if binary_search(num, first_set, 0, len(first_set) - 1):
        count += 1;
print(count);



### FIXED CODE ###

first_set_count = int(input());
first_set = [int(n) for n in input().split()];
second_set_count = int(input());
second_set = [int(n) for n in input().split()];

def binary_search(num, s, start, end):
    while start < end:
        mid = (end + start) // 2;
        if num == s[mid]:
            return True;
        elif num > s[mid]:
            start = mid + 1;
        else:
            end = mid;
    return False;

count = 0;
for num in second_set:
    if binary_search(num, first_set, 0, len(first_set)):
        count += 1;
print(count);
import math
A,B,H,M = map(int, input().split())
X = H*30+M*0.5
Y = M*6
if  -180 < X - Y < 0:
  Z = Y - X
elif X - Y <= -180:
  Z = 360 -(Y - X)
elif 180 > X - Y >= 0:
  z = X - Y
elif X - Y >= 180:
  z = 360-(X - Y)
ans = A*A+B*B-2*A*B*math.cos(math.radians(z))
ANS = math.sqrt(ans)

print(ANS)

### FIXED CODE ###

import math
A,B,H,M = map(int, input().split())
X = H*30+M*0.5
Y = M*6
if  -180 < X - Y < 0:
  z = Y - X
elif X - Y <= -180:
  z = 360 -(Y - X)
elif 180 > X - Y >= 0:
  z = X - Y
elif X - Y >= 180:
  z = 360-(X - Y)
ans = A*A+B*B-2*A*B*math.cos(math.radians(z))
ANS = math.sqrt(ans)

print(ANS)
import math
a,b,c,d=map(int,input().split())
ans=0
ans+=(b//c-a//c+(a%c==0))
ans+=(b//d-a//d+(a%d==0))
lcm=c*d//math.gcd(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)

### FIXED CODE ###

def G(x,y):
    if(x<y):
        x,y=y,x
    if(y==0):
        return x
    return G(y,x%y)


a,b,c,d=map(int,input().split())
ans=0
# print(a,b,c,d,b//c,a//c)
ans+=(b//c-a//c+(a%c==0))
# print(ans)
ans+=(b//d-a//d+(a%d==0))
# print(ans)
lcm=c*d//G(c,d)
ans-=(b//lcm-a//lcm+(a%lcm==0))
print(b-a+1-ans)
import math
def main():
	N = int(input())
	v = int(math.sqrt(N))
    print(v*v)
if __name__ == "__main__":
	main()

### FIXED CODE ###

import math
n = int(input())
v = int(math.sqrt(n))
print(v*v)
from collections import defaultdict
import heapq
from math import sqrt
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def calc(b1, b2):
    x1, y1, r1 = b1
    x2, y2, r2 = b2
    d = sqrt((x1-x2)**2+(y1-y2)**2)
    return max(d-(r1+r2), 0)


sx, sy, gx, gy = map(int, input().split())
N = int(input())
barriers = [[sx, sy, 0]] + [list(map(int, input().split()))
                            for _ in range(N)]+[[gx, gy, 0]]

mat = [[0]*(N+2) for _ in range(N+2)]

for row in range(N+2):
    for col in range(row+1, N+2):
        d = calc(barriers[row], barriers[col])
        mat[row][col] = d
        mat[col][row] = d

# 視点からの距離
dist = [float('inf')]*(N+2)
dist[0] = 0

# 最短経路での一つ前のノード
prev = defaultdict(lambda: None)

Q = []
# Q->[dist from　start,node])
heapq.heappush(Q, (0, 0))

while Q:
    dist_to_node, node = heapq.heappop(Q)
    if dist[node] < dist_to_node:
        continue
    else:
        for v in range(N+2):
            weight = mat[node][v]
            alt = dist_to_node+weight
            if dist[v] > alt:
                dist[v] = alt
                prev[v] = node
                heapq.heappush(Q, (alt, v))
print(dist[-1])


### FIXED CODE ###

N, x = map(int, input().split())
l = list(map(int, input().split()))

before = sum(l)
l[0] = min(x, l[0])
for i in range(1, N):
    s = l[i-1]+l[i]
    if s > x:
        l[i] = x-l[i-1]

print(before-sum(l))
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
i=0
while(True):
  d+=l[i]
  i+=1
  if(!(d<x or i<=n)):
    break
print(i)

### FIXED CODE ###

n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
i=1
while i<=n:
  d+=l[i-1]
  if x<d:
    break
  i+=1
print(i)
n,m=map(int,iput().split())
s=input()
ACsuu=[0 for i in range(n)]
for i in range(1,n):
  Acsuu[i]=ACsuu[i-1]+(1 if s[i-1:i+1]=="AC" else 0)
for i in range(m):
  a,b=map(int,input().split())
  print(ACsuu[b-1]-ACsuu[a-1])

### FIXED CODE ###

n,m=map(int,input().split())
s=input()
ACsuu=[0 for i in range(n)]
for i in range(1,n):
  ACsuu[i]=ACsuu[i-1]+(1 if s[i-1:i+1]=="AC" else 0)
for i in range(m):
  a,b=map(int,input().split())
  print(ACsuu[b-1]-ACsuu[a-1])
n=input()
for i in range(sqrt(n),0,-1):
  if n%i==0:
    j=n//i
    pirnt(i+j-2)
    break

### FIXED CODE ###

from math import sqrt

N = int(input())
for i in range(int(sqrt(N)), 0, -1):
    if N % i == 0:
        j = N // i
        print(i + j - 2)
        break
length, pos = input().split(' ')
length,pos = int(length), int(pos)
target = input()
if target[pos-1] == 'A':
  target[pos-1] = 'a'
if target[pos-1] == 'B':
  target[pos-1] = 'b'
if target[pos-1] == 'C':
  target[pos-1] = 'c'

print(target)


### FIXED CODE ###

length, pos = input().split(' ')
length, pos = int(length), int(pos)
target = input()
answer = ''
if pos == 1:
  answer = str(target[pos-1].lower() + target[1:])
elif pos == length:
  answer = str(target[:-1] + target[pos-1].lower())
else:
  answer = str(target[:pos-1] + target[pos-1].lower() + target[pos:])

print(answer)
s = input()
if s.endswith('2') == True or s.endswith('4') ==True or s.endswitch('5') == True or s.endswith('7') == True or s.endswith('9') == True:
  
  print('hon')
elif s.endswith('0') == True or s.endswith('1') == True or s.endswitch('6') == True or s.endswitch('8') == True:
  print('pon')
else:
  print('bon')


### FIXED CODE ###

s = input()
n = len(s)
a = s[n-1:n]
if a == '2' or a == '4' or a == '5' or a == '7' or a == '9':
  print('hon')
elif a == '0' or a == '1' or a == '6' or a == '8':
  print('pon')
else:
  print('bon')
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,K = MI()
k = K.bit_length()
AB = []
for _ in range(N):
    a,b = MI()
    if a > K:
        continue
    else:
        AB.append(([(a >> i) & 1 for i in range(k-1,-1,-1)],b))

N = len(AB)
K = [(K >> i) & 1 for i in range(k-1,-1,-1)]

A = [[] for _ in range(k+1)]
B = [0]*(k+1)
for i in range(N):
    a,b = AB[i]
    for j in range(k):
        if a[j] == K[j] == 1:
            B[j+1] -= b
        if a[j] > K[j]:
            A[j].append(b)
            break
    else:
        A[k].append(b)


for i in range(k+1):
    A[i] = sum(A[i])

for i in range(k-1,-1,-1):
    A[i] += A[i+1]

print(max(A[i]+B[i] for i in range(1,k+1)))


### FIXED CODE ###

import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,K = MI()
K += 1
k = K.bit_length()

AB = []

for _ in range(N):
    a,b = MI()
    if a >= K:
        continue
    else:
        AB.append(([(a >> i) & 1 for i in range(k-1,-1,-1)],b))

N = len(AB)
K_bit = [(K >> i) & 1 for i in range(k-1,-1,-1)]

ANS = [0]*k  # 

for i in range(N):
    a,b = AB[i]
    for j in range(k):
        if K_bit[j] == 1:
            if a[j] == 0:
                ANS[j] += b
        else:
            if a[j] == 1:
                break

print(max(ANS))
n,m=[int(n) for n in input().split()]
arr=list(map(int,input().strip().split()))
if(m==0):
    print(n)
else:
    j=n
    while(j>=1):
        flag=0
        for i in range(m):
            if(arr[i]==j):
                flag=1
        if(flag==1):
            j=j-1
        else:
            s1=j
            break
    j=n
    while(j<101):
        flag=0
        for i in range(m):
            if(arr[i]==j):
                flag=1
        if(flag==1):
            j=j+1
        else:
            s2=j
            break
    a=abs(n-s1)
    b=abs(n-s2)
    if(a<=b):
        print(s1)
    else:
        print(s2)
        

### FIXED CODE ###

x, n = (int(x) for x in input().split())
p_list = list(map(int, input().split()))
 
ans = 0
 
max_ = 0
min_ = 0

for i in range(x, 102, 1) :
 
    if i not in p_list:
        max_ = i
        break
for j in reversed(range(x + 1)) :

 
    if j not in p_list:
        min_ = j
        break
 
if abs (min_ - x) <= abs(max_ - x) :
    ans = min_
else : 
    ans = max_
 
print(ans)
n, m = map(int, input().split())

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

change = []
for i in range(m):
	b, c = map(int, input().split())
	change.append([b,c])

change = sorted(change, key=lambda x: x[1], reverse=True)

cur = 0
done = False
for vals in change:
	b, c = vals
	for i in range(b):
		if a[cur] < c:
			a[cur] = c
		else:
			done = True
			break
		cur += 1
	if done:
		break

print(sum(a))

### FIXED CODE ###

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

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

change = []
for i in range(m):
	b, c = map(int, input().split())
	change.append([b,c])

change = sorted(change, key=lambda x: x[1], reverse=True)

cur = 0
done = False
for vals in change:
	b, c = vals
	for i in range(b):
		if a[cur] < c:
			a[cur] = c
		else:
			done = True
			break
		cur = (cur+1)%len(a)
	if done:
		break

print(sum(a))
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = A % 10
b = B % 10
c = C % 10
d = D % 10
e = E % 10

if a == 0:
  a = 10
elif b == 0:
  b = 10
elif c == 0:
  c = 10
elif d == 0:
  d = 10
elif e = 10:
  e = 10
  
list1 = [a,b,c,d,e]
list1.sort(reverse = True)
key = {a:A,b:B,c:C,d:D,e:E}
i = 0
sum = 0
while i < 4:
  sum += key[list1[i]]
  while not sum % 10 == 0:
    sum += 1
  i += 1
  
sum += list1[4]
print(sum)
  

### FIXED CODE ###

B = [int(input()) for _ in range(5)]
A = [10-int(str(B[i])[-1]) for i in range(5) if str(B[i])[-1] != "0"]
if len(A) != 0:
	A.remove(max(A))
print(sum(B)+sum(A))
#!/usr/bin/env python3
def main():
    import numpy as np

    N = int(input())

    cnt = np.zeros((10, 10), dtype=np.int64)
    for n in map(str, range(1, N + 1)):
        cnt[int(n[0])][int(n[-1])] += 1

    print(np.sum(cnt * cnt.T))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
def main():
    import numpy as np

    N = int(input())

    cnt = np.zeros((10, 10), dtype=np.int64)
    for n in [str(x) for x in range(1, N + 1)]:
        cnt[int(n[0])][int(n[-1])] += 1

    print((cnt[:, :] * cnt.T[:, :]).sum())


if __name__ == '__main__':
    main()
N = int(input())
K = int(input())
P = list(map(int,input().split()))
for i in range(N):
  P[i] = (i+1)/2
now = sum(P[:K])
ans = now
for j in range(N-K):
  ans = ans - P[j] + P[j+K]
  ans = max(ans,now)
print(ans)



### FIXED CODE ###

N,K = map(int,input().split())
P = list(map(int,input().split()))
for i in range(N):
  P[i] = (P[i]+1)/2
now = sum(P[:K])
ans = now
for j in range(N-K):
  now = now - P[j] + P[j+K]
  ans = max(ans,now)
print(ans)
while True:
   a,b = map(int, raw_input().split())

   if a == 0 && b == 0:
      break
    
   else
      for i in range(a):
         print b*'#'
      print ""

### FIXED CODE ###

while True:
   a,b = map(int, raw_input().split())

   if a + b ==0:
      break
    
   else:
      for i in range(a):
         print b*'#'
      print ""
n = int(input())
A = list(map(int,input().split()))
B  =list(map(int,input().split()))
f = True
for i in range(n):
    if A[i]==B[i]:
        f = False
        break
if f:
    print('Yes')
    ans =[str(i) for i in B]
    print(' '.join(ans))
    exit()
if A[-1]<B[0]:
    print('Yes')
    ans =[str(i) for i in B]
    print(' '.join(ans))
    exit()

B=B[::-1]
f = True
for i in range(n-1,-1,-1):
    if A[i]!=B[i]:
        continue
    else:
        p = A[i]
        l = A.count(A[i])
        m = B.count(B[i])
        idx = i
        f = False
        break
l ,m=0,0
for i in range(idx+1):
    if A[i]==p:l+=1
    if B[i]==p:m+=1
if f:
    print('Yes')
    ans =[str(i) for i in B]
    print(' '.join(ans))
    exit()

if idx+1-m==0:
    if n-idx<=l:
        print('No')
        exit()
    else:
        print('Yes')
        tmp = B[:idx-l+1]+B[idx+1:] + B[idx-l+1:idx+1]
        ans =[str(i) for i in tmp]
        print(' '.join(ans))
        exit()

if idx+1-m>=l:
    print('Yes')
    tmp = B[idx+1-m:idx+1]+B[:idx+1-m]+B[idx+1:]
    ans =[str(i) for i in tmp]
    print(' '.join(ans))
    exit()
else:
    print('No')
    exit()


### FIXED CODE ###

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

n = int(input())
a = get_ints()
b = get_ints()

cnt = [0]*(n+1)
for x in a+b:
  cnt[x] += 1

q = [set() for i in range(n+1)]
for i in range(1,n+1):
  if cnt[i] > n:
    print('No')
    exit(0)
  q[cnt[i]].add(i)
print('Yes')

def make_cnt(a):
  cnt_ = {}
  for i in range(n):
    if a[i] not in cnt_:
      cnt_[a[i]] = [i]
    else:
      cnt_[a[i]].append(i)
  return cnt_

cnt_a = make_cnt(a)
cnt_b = make_cnt(b)

def get_any(cnt_, x):
  for key in cnt_.keys():
    if key != x:
      return key
  assert False

ans = [-1]*n

for i in range(n,0,-1):
  s = list(q[i])
  x,y = 0,0
  if len(s) == 0:
    x = get_any(cnt_a, -1)
    y = get_any(cnt_b, x)
  elif len(s) == 1:
    x = s[0]
    if x not in cnt_a:
      y = x
      x = get_any(cnt_a, y)
    else:
      y = get_any(cnt_b, x)
  else:
    x,y = s
    if x not in cnt_a:
      x,y = y,x

  ans[cnt_a[x][-1]] = y
  def update_cnt(cnt_, x):
    cnt_[x].pop()
    if len(cnt_[x]) == 0:
      del cnt_[x]
  def use(x):
    q[cnt[x]].remove(x)
    cnt[x] -= 1
    q[cnt[x]].add(x)
  update_cnt(cnt_a, x)
  update_cnt(cnt_b, y)
  use(x)
  use(y)

print(' '.join(map(str,ans)))
ソースコード 

Copy
Copy
B = int(input(N))
C = int(input(A))
D = B % 500
if D > C:
  print("no")
else:
  print("yes")

### FIXED CODE ###

N=int(input())
A=int(input())

if N % 500 <= A:
  print("Yes")
else:
  print("No")
import bisect
import sys

inf = sys.maxsize
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

for i in range(M):
    x = A.pop(N-1)
    if x == 0:
        break
    x = x // 2
    A.insert(bisect.bisect_left(A, x), x)
print(sum(A)

### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = [-int(x) for x in input().split()]
heapq.heapify(A)
for i in range(M):
    x = heapq.heappop(A)
    x = int(x / 2)
    heapq.heappush(A, x)  # pop minimum
print(-sum(A))
n = int(input())
d = list(map(int,input().split()))
ans = 0
for i in range(n):
  for j in range(i+1,n+1):
    ans += d[i]*d[j]
print(ans)

### FIXED CODE ###

N=int(input())
D=list(map(int,input().split()))
print((sum(D)**2-sum(d*d for d in D))//2)
n, m = map(int, input().split())
a = input().split()
a = [int(i) for i in a]
s = sum(a)
dif = (1 / (4*m)) * s
cont = 0
for i in a:
     cont += (1 if i >= dif else 0)
print ('Yes' if cont >= m else 'No')


### FIXED CODE ###

n, m = map(int, input().split())
n = n % m
if m == 1:  
    print(0)
elif n < m:
    print(min(abs(n-m), n))
else: 
    print(abs(n - m))