Harryxun/stf_run huggingface dataset:
# coding: utf-8
# Your code here!
S=list(input())[::-1]

count=0
temp=[]
pre=[]
while len(S)>3:
    temp.append(S.pop(-1))
    if temp==pre:
        temp.append(S.pop(-1))
    pre.clear()
    pre+=temp
    temp.clear()
    count+=1

if len(S)==3:
    print(S[10])
    if pre[-1]==S[2] or S[2]==S[1] or S[1]==S[0]:
        print(count+2)
    else:
        print(count+3)
else:
    if pre[-1]==S[1] or S[1]==S[0]:
        print(count+1)
    else:
        print(count+2)


### FIXED CODE ###

# coding: utf-8
# Your code here!
S=list(input())[::-1]

count=0
temp=[]
pre=[]
while len(S)>3:
    temp.append(S.pop(-1))
    if temp==pre:
        temp.append(S.pop(-1))
    pre.clear()
    pre+=temp
    temp.clear()
    count+=1
#print(S[::-1])
if len(S)==3:
    if pre[-1]==S[2] or S[2]==S[1] or S[1]==S[0]:
        print(count+2)
    else:
        print(count+3)
else:
    if S[1]==S[0]:#aabbaが出来ればよい
        print(count+1)
    else:
        print(count+2)
n = input()
a = input().split(' ')
def doit(a):
  m = 1
  for ai in a:
  	if m > 10**18:
      return -1
    m = m*a
  
  return m

doit(a)

### FIXED CODE ###


n = int(input())
a = list(input().split(' '))
# print(n, a)
def doit(n,a):
  m = 1
  for i in range(n):
    m = m*int(a[i])
    if m > 1000000000000000000:
        for y in range(i+1, n):
            if a[y] == '0':
                return 0
        return -1
    elif m==0:
        return 0

#   if m > 1000000000000000000:
#     return -1
  return m
 
print(doit(n,a))
n, m, x = list(map(int, input().split()))
c = []
a = []

for i in range(n):
    tmp = list(map(int, input().split()))
    c.append(tmp[0])
    a.append([])
    
    for j in range(m):
        a[i].append(tmp[j])

ab = []
for i in range(m):
    sum = 0
    for j in range(n):
        sum += a[j][i]
    ab.append(bool(sum > x))

print(all[ab])

### FIXED CODE ###

from itertools import combinations

n, m, x = list(map(int, input().split()))
c = []
a = []

# c, aにデータを用意
for i in range(n):
    tmp = list(map(int, input().split()))
    c.append(tmp[0])
    a.append([])
    
    for j in range(1, m + 1):
        a[i].append(tmp[j])

money_min = -1
comb = []
# 組み合わせを用意
for l in range(n):
    tmp = combinations(range(n), l + 1)
    for i in tmp:
        comb.append(i)
    
# 組み合わせごとに考える
for el in comb:
    ables = []
    money = 0        
    scores = []

    # scoreに0をいれる
    for i in range(m):
        scores.append(0)

    # 組み合わせを足し合わせる
    for n in el:
        money += c[n] # 金
        for i in range(m):
            scores[i] += a[n][i] # 習得度

    # 判定
    for i in range(m):
        ables.append(scores[i] >= x)

    # 良ければ金額更新
    if all(ables):
        money_min = money if money_min < 0 or money_min > money else money_min

print(money_min)
N=int(input())
A=int(input)

print(N*N-A)

### FIXED CODE ###

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

print(N*N-A)
N = int(input())
s = list(map(int, input().split()))
if "Y" in s:
    print("Four")
else:
    print("Three")

### FIXED CODE ###

N = int(input())
s = list(input().split())
if "Y" in s:
    print("Four")
else:
    print("Three")
t= list()

for i in range(1,13):
    t[i] = 0

s = t
h = t
c = t
d = t

num = int(input())
for i in range(num):
    m, n = input().split()
    n = int(n)
    if m == "s":
        s[n] == 1
    if m == "h":
        h[n] == 1
    if m == "c":
        h[n] == 1
    if m == "d":
        h[n] == 1

for i in range(1,13):
    if s[i] == 0:
        print("S %d" %i)

for i in range(1,13):
    if h[i] == 0:
        print("H %d" %i)

for i in range(1,13):
    if c[i] == 0:
        print("C %d" %i)

for i in range(1,13):
    if d[i] == 0:
        print("S %d" %i)






### FIXED CODE ###

#
# 6b
#

def main():
    n = int(input())
    c = []
    for i in range(n):
        m, r = input().split()
        r = int(r)
        c.append([m, r])
    for M in ["S", "H", "C", "D"]:
        for R in range(1, 14):
            for i in range(n):
                if c[i] == [M, R]:
                    break
            else:
                print(*[M, R])


if __name__ == '__main__':
    main()
n, k = map(int, input().split())
a = list(map(int, input().split()))

ruiseki = [0] * (n+1)
for i in range(n):
    ruiseki[i+1] = ruiseki[i] + a[i]

for i in range(n+1):
    ruiseki[i] -= i
    ruiseki[i] %= k
memo = {}
for i in range(min(k, n)):
    if ruiseki[i] not in memo:
        memo[ruiseki[i]] = 1
    else:
        memo[ruiseki[i]] += 1

ans = 0
for i in range(n+1):
    tmp = memo[ruiseki[i]]
    ans += tmp - 1
    memo[ruiseki[i]] -= 1
    if i+k < n+1:
        if ruiseki[i+k] not in memo:
            memo[ruiseki[i+k]] = 1
        else:
            memo[ruiseki[i+k]] += 1
print(ans)

### FIXED CODE ###

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

ruiseki = [0] * (n+1)
for i in range(n):
    ruiseki[i+1] = ruiseki[i] + a[i]

for i in range(n + 1):
    ruiseki[i] -= i
    ruiseki [i] %= k

memo = {}
cnt = 0
ans = 0
for i in range(n+1):
    if ruiseki[i] in memo:
        ans += memo[ruiseki[i]]

    if ruiseki[i] in memo:
        memo[ruiseki[i]] += 1
    else:
        memo[ruiseki[i]] = 1

    if cnt < k - 1:
        cnt += 1
    else:
        memo[ruiseki[i-cnt]] -= 1 

print(ans)
import numpy as np
H, W = map(int, input().split())
map_lis = [input() for i in range(H)]
ans = 0

def prob(x,y,h,w):
  if 0<=x<h and 0<=y<w:
    return True
  else:
    return False

def count(x,y,lis):
  if not lis[x][y]:
    return True
  else:
    return False

def maze(x,y,lis):
  if lis[x][y] == ".":
    return True
  else:
    return False

for i in range(H):
  for j in range(W):
    k = 0
    count_lis = np.zeros((H,W))
    num_lis = [[] for i in range(H*W)]
    num_lis[0].append([i,j])
    while True:
      for l in num_lis[k]:
        if prob(l[0]-1,l[1],H,W) and count(l[0]-1,l[1],count_lis) and maze(l[0]-1,l[1],map_lis):
          num_lis[k+1].append([l[0]-1,l[1]])
          count_lis[l[0]-1][l[1]] = 1
        if prob(l[0],l[1]-1,H,W) and count(l[0],l[1]-1,count_lis) and maze(l[0],l[1]-1,map_lis):
          num_lis[k+1].append([l[0],l[1]-1])
          count_lis[l[0]][l[1]-1] = 1
        if prob(l[0]+1,l[1],H,W) and count(l[0]+1,l[1],count_lis) and maze(l[0]+1,l[1],map_lis):
          num_lis[k+1].append([l[0]+1,l[1]])
          count_lis[l[0]+1][l[1]] = 1
        if prob(l[0],l[1]+1,H,W) and count(l[0],l[1]+1,count_lis) and maze(l[0],l[1]+1,map_lis):
          num_lis[k+1].append([l[0],l[1]+1])
          count_lis[l[0]][l[1]+1] = 1
      if num_lis[k+1] == []:
        break
      new_ans = 0
      for m in num_lis[1:]:
        if m != []:
          new_ans += 1
        if m == []:
          break
      ans = max(ans, new_ans)
      k += 1
    
                                           
print(ans)

### FIXED CODE ###

import numpy as np
H, W = map(int, input().split())
map_lis = [input() for i in range(H)]
ans = 0

def prob(x,y,h,w):
  if 0<=x<h and 0<=y<w:
    return True
  else:
    return False

def count(x,y,lis):
  if not lis[x][y]:
    return True
  else:
    return False

def maze(x,y,lis):
  if lis[x][y] == ".":
    return True
  else:
    return False

for i in range(H):
  for j in range(W):
    k = 0
    count_lis = np.zeros((H,W))
    num_lis = [[] for i in range(1000)]
    if maze(i,j,map_lis):
      count_lis[i][j] = 1
      num_lis[0].append([i,j])
    while True:
      for l in num_lis[k]:
        if prob(l[0]-1,l[1],H,W) and count(l[0]-1,l[1],count_lis) and maze(l[0]-1,l[1],map_lis):
          num_lis[k+1].append([l[0]-1,l[1]])
          count_lis[l[0]-1][l[1]] = 1
        if prob(l[0],l[1]-1,H,W) and count(l[0],l[1]-1,count_lis) and maze(l[0],l[1]-1,map_lis):
          num_lis[k+1].append([l[0],l[1]-1])
          count_lis[l[0]][l[1]-1] = 1
        if prob(l[0]+1,l[1],H,W) and count(l[0]+1,l[1],count_lis) and maze(l[0]+1,l[1],map_lis):
          num_lis[k+1].append([l[0]+1,l[1]])
          count_lis[l[0]+1][l[1]] = 1
        if prob(l[0],l[1]+1,H,W) and count(l[0],l[1]+1,count_lis) and maze(l[0],l[1]+1,map_lis):
          num_lis[k+1].append([l[0],l[1]+1])
          count_lis[l[0]][l[1]+1] = 1
      new_ans = 0
      for m in num_lis[1:]:
        if m != []:
          new_ans += 1
        if m == []:
          break
      ans = max(ans, new_ans)
      k += 1
      if num_lis[k] == []:
        break
                                     
print(ans)
n = int(input(n))
a = list(map(int,input().split()))
ball = []
s = 0

for i in range(n-1, (n-1)//2, -1):
    ball.insert(0, a[i])
for i in range((n-1)//2, -1, -1):
    for j in range(len(ball)):
        if (j+1) % (i+1) == 0:
            s += ball[j]

    s = s % 2
    if a[i] == s:
        ball.insert(0, 0)
    else:
        ball.insert(0, 1)
ans = ""
for i in range(n):
    if ball[i] == 1:
        ans += " " + str(i)
    elif i == 1 and ans == "":
        print("0")

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0 #ボールが入ってる箱の数
index = [] #ボールが入ってる番号

for i in range(n-1, -1, -1):
    balls = 0
    j = i
    while j +(i+1) < n:
        j += i + 1
        balls += ball[j]
    
    if a[i] != balls%2:
        ball[i] = 1
        count += 1
        index.append(i+1)
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)
a,b = map(int.input().split())

if a > b:
 print('a > b')
elif a < b:
 print('a < b')
else:
 print('a == b')

### FIXED CODE ###

a, b = map(int, input().split())
if a < b:
    print('a < b')
elif a > b:
    print('a > b')
else:
    print('a == b')
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=A+B+C
n=int(input())
for i in range (n):
    y=int(input())
    if j==y:
        x='x'
    else:
        x=[j for j in x]
if X[0]==X[3]==X[6]=='X':
    print('Yes')
elif X[1]==X[4]==X[7]=='X':
    print('Yes')
elif X[2]==X[5]==X[8]=='X':
    print('Yes')
elif X[0]==X[1]==X[2]=='X':
    print('Yes')
elif X[3]==X[4]==X[5]=='X':
    print('Yes')
elif X[6]==X[7]==X[8]=='X':
    print('Yes')
elif X[0]==X[4]==X[8]=='X':
    print('Yes')
elif X[2]==X[4]==X[6]=='X':
    print('Yes')
else:
    print('No')

### FIXED CODE ###

A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
X=A+B+C
n=int(input())
for i in range (n):
    y=int(input())
    X=['X' if j==y else j for j in X]
if X[0]==X[3]==X[6]=='X':
    print('Yes')
elif X[1]==X[4]==X[7]=='X':
    print('Yes')
elif X[2]==X[5]==X[8]=='X':
    print('Yes')
elif X[0]==X[1]==X[2]=='X':
    print('Yes')
elif X[3]==X[4]==X[5]=='X':
    print('Yes')
elif X[6]==X[7]==X[8]=='X':
    print('Yes')
elif X[0]==X[4]==X[8]=='X':
    print('Yes')
elif X[2]==X[4]==X[6]=='X':
    print('Yes')
else:
    print('No')
N=int(input())
flag=0
for i in range(9):
    for j in range(9):
        if (i+1)*(j+1)==N:
            flag=1

if flag==1:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

a = list(map(int,input().split()))
A=a[0]
B=a[1]

if 1<=A<=9 and 1<=B<=9:
    print(A*B)
else:
    print(-1)
N,K = list(map(int, input().split()))
S = str(input())
s = [S[i] for i in range(len(S))]
ans = (s[K-1].lower)
print(join(ans))

### FIXED CODE ###

N,K = list(map(int, input().split()))
S = str(input())
s = [S[i] for i in range(len(S))]
s[K-1] = chr(ord(s[K-1])+32)
print(''.join(s))
from collections import deque

n = int(input())
aa = list(map(int, input().split()))
bb = deque()
left = True
for a in aa:
    if left:
        bb.append(a)
    else:
        bb.appendleft(a)
    left = not left

if left:
    print(*list(bb))
else:
    print(*list(bb).reverse())



### FIXED CODE ###

from collections import deque

n = int(input())
aa = list(map(int, input().split()))
bb = deque()
left = True
for a in aa:
    if left:
        bb.append(a)
    else:
        bb.appendleft(a)
    left = not left

if not left:
    bb.reverse()
print(*list(bb))
import numpy

n = int(input())
a_list = [int(a) for a in input().split()]

left = [0]
right = [0]
for a in a_list:
    left.append(numpy.gcd(left[-1], a))

a_list.reverse()
for a in a_list:
    right.append(numpy.gcd(right[-1], a))

right.reverse()

m = []
for i in range(len(a_list)):
    m.append(numpy.gcd(left[i], right[i + 1]))

print(max(m))

### FIXED CODE ###

import fractions

n = int(input())
a_list = [int(a) for a in input().split()]

left = [0]
right = [0]
for a in a_list:
    left.append(fractions.gcd(left[-1], a))
    
a_list.reverse()
for a in a_list:
    right.append(fractions.gcd(right[-1], a))

right.reverse()

m = []
for i in range(len(a_list)):
    m.append(fractions.gcd(left[i], right[i + 1]))
    
print(max(m))
N=int(input())
rissoku=10**9

for _ in range(5):
    rissoku=min(rissoku,int(input()))

if N%rissoku=0:
    print((N//rissoku)+4)
else:
    print((N//rissoku)+5)

### FIXED CODE ###

N=int(input()) 
rissoku=10**18
for _ in range(5): 
    rissoku=min(rissoku,int(input())) 

if N%rissoku==0: 
    print((N//rissoku)+4) 
else: 
    print((N//rissoku)+5)
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    x, y, z = map(int, input().split())
    print(z, x, y) 


if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    x, y, z = map(int, input().split())
    print(z, x, y) 


if __name__ == '__main__':
    main()
n,k=map(int,input().split())
s=str(input())
if s[k+1]=="A":
    s[k+1]="a"
elif s[k+1]=="B":
    s[k+1]="b"
elif s[k+1]=="C":
    s[k+1]="c"
print(s)


### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
if s[k-1]=="A":
    s[k-1]="a"
elif s[k-1]=="B":
    s[k-1]="b"
elif s[k-1]=="C":
    s[k-1]="c"
print("".join(s))
A,B = (int(i) for i in input().split())
import math
print(A * B // math.gcd (A, B))

### FIXED CODE ###

A,B = (int(i) for i in input().split())

import fractions

def lcm(a, b):
    #return a * b // math.gcd(a, b)
    return  a*b // fractions.gcd(a, b)

print(lcm(A,B))
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0] + 1
nowmax = max(a[1:])
ans = a[1]-a[0]
for i in range(n-1):
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]
  elif a[i] == nowmax:
    nowmax = max(a[i+1])
    
print(ans)



### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0]
nowmax = max(a[1:])
ans = nowmax - nowmin
for i in range(n-1):
  if a[i] == nowmax:
    nowmax = max(a[i+1:])
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]


print(ans)
a = int(input())
b = int(input())

print(a*b)

### FIXED CODE ###

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

print(a*b)
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n = int(input())
A = [int(i) for i in input().split()]
k = lcm_list(A)
r = 0
for i in range(n):
    r += k//A[i]
    if r > 10**9+7:
        r %= 10**9+7
print(r)

### FIXED CODE ###

n = int(input())
C = [[0]*10 for _ in range(10)]
for i in range(1,n+1):
    C[int(str(i)[0])][int(str(i)[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += C[i][j]*C[j][i]
print(ans)
n,k=map(int,input().split())
hashmap=dict()
for i in range(k):
  d=input()
  for i in range(d):
    key=int(input())
    hashmap[key]=d
count=0
for i in range(1,n+1):
  if hashmap.get(key)==None:
    count+=1
print(count)

### FIXED CODE ###

n,k=map(int,input().split())
hashmap=dict()
for _ in range(k):
  d=int(input())
  arr=[int(p) for p in input().split()]
  for key in arr:
    hashmap[key]=d
count=0
for i in range(1,n+1):
  if hashmap.get(i)==None:
    count+=1
print(count)
A,B,K = [int(i) for i in input().split(" ")]

def check(A,B,K):
    if A > 0:
        if K-A >= 0:
            K = K-A
            A = 0
        else:
            A = A-K
            return (A,B)
    
    if B > 0:
        if B-K >= 0:
            return (A,B-K)
        else:
            return (A,0)

ans = check(A,B,K)
print(ans[0],ans[1])
            
        

### FIXED CODE ###


A,B,K = [int(i) for i in input().split(" ")]

def check(A,B,K):
    if A > 0:
        if A > K:
            A-=K
            K = 0
        else:
            result = K-A
            A = 0
            K = result
    if B > 0:
        if B > K:
            B-=K
        else:
            B = 0
    return "{0} {1}".format(A,B)

print(check(A,B,K))
# coding: UTF-8
s = raw_input()

if 'N' in s and 'W' in s and 'S' in s and 'E' in s:
    print "Yes"
elif 'N' in s and not 'W' in s and 'S' in s and not 'E' in s:
    print "Yes"
elif not 'N' in s and 'W' in s and not 'S' in s and 'E' in s:
else :
    print "No"


### FIXED CODE ###

# coding: UTF-8
s = raw_input()

if 'N' in s and 'W' in s and 'S' in s and 'E' in s:
    print "Yes"
elif 'N' in s and not 'W' in s and 'S' in s and not 'E' in s:
    print "Yes"
elif not 'N' in s and 'W' in s and not 'S' in s and 'E' in s:
    print "Yes"
else :
    print "No"
n,m,k = map(int,input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]

for i in range(n):
  A.append(a[i] + A[i])
for i in range(m):
  B.append(b[i] + B[i])

num = 0
x = m - 1
A.pop(0)
B.pop(0)

for i in range(n):
  if A[i] > k:
    break
  while A[i] + B[x] > k:
    x -= 1
  num = max(num, i + x + 2)
  
print(num)




### FIXED CODE ###

n,m,k = map(int,input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A,B = [0],[0]

for i in range(n):
  A.append(a[i] + A[i])
for i in range(m):
  B.append(b[i] + B[i])

num,x = 0,m

for i in range(n+1):
  if A[i] > k:
    break
  while A[i] + B[x] > k:
    x -= 1
  num = max(num, i + x)
  
print(num)
# -*- coding: <encoding name> -*-

import math
n = map(int, input().split())
print(math.ceil(n / 2)

### FIXED CODE ###

# -*- coding: <encoding name> -*-

import math
n = int(input())
print(math.ceil(n / 2))
hito=list(map(int,input()))
mini=min(hito[1:6])
retu=hito[0]//mini
print(retu+4)

### FIXED CODE ###

import math
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
miti=[a,b,c,d,e]
mini=min(miti)
retu=math.ceil(n/mini)
print(4+retu)
import sys 
sys.stdin = open('input.txt', 'r')  
sys.stdout = open('output.txt', 'w') 
t=int(input())
s=set()
for i in range(t):
    # n,m=map(int,input().split())
    n=input()
    s.add(n);
print(len(s));

    

### FIXED CODE ###

 
t=int(input())
s=set()
for i in range(t):
    # n,m=map(int,input().split())
    n=input()
    s.add(n);
print(len(s));
from sys import stdin,stdout
from collections import defaultdict
# n=int(stdin.readline())
def dfs(src):
    global sz
    vis[src]=1
    sz+=1
    for neigh in g[src]:
        if not vis[neigh]:
            dfs(neigh)

n,eg=list(map(int,stdin.readline().split()))
g=defaultdict(list)
for i in range(eg):
    A,B=map(int,stdin.readline().split())
    g[A]+=[B]
    g[B]+=[A]
vis=[0]*(n+1);ans=0
for node in range(1,n+1):
    if not vis[node]:
        sz=0
        dfs(node)
        ans=max(ans,sz)
print(ans)

### FIXED CODE ###

from sys import stdin,stdout
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
# n=int(stdin.readline())
def dfs(src):
    global sz
    vis[src]=1
    sz+=1
    for neigh in g[src]:
        if not vis[neigh]:
            dfs(neigh)

n,eg=list(map(int,stdin.readline().split()))
g=defaultdict(list)
for i in range(eg):
    A,B=map(int,stdin.readline().split())
    g[A]+=[B]
    g[B]+=[A]
vis=[0]*(n+1);ans=0
for node in range(1,n+1):
    if not vis[node]:
        sz=0
        dfs(node)
        ans=max(ans,sz)
print(ans)
s=input()
s=s.replace(s[-1],'')
while True:
    s=s.replace(s[-1],'')
    if len(s)%2==0 and s[:len(s)//2]==s[len(s)//2:]:
      print(len(s))
      break


### FIXED CODE ###

s=input()
s=s[:-1]
while True:
  if len(s)%2==0 and s[len(s)//2:]==s[:len(s)//2]:
    print(len(s))
    break
  else:
    s=s[:-1]
    continue
while True:
    a = raw_input()
    print 'a'

### FIXED CODE ###

while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass
from math import ceil
n = int(input())
a = list(map(int, input().split()))

ans = 10**10

m1 = a[ceil(n/2)]
m2 = int(sum(a) / n)
m3 = ceil(sum(a) / n)

for v in [m1, m2, m3]:
    cost = 0
    for i in range(n):
        cost += (a[i] - v) ** 2
    ans = min(cost, ans)
print(ans)

### FIXED CODE ###

from math import ceil
n = int(input())
a = list(map(int, input().split()))

ans = 10**10

m1 = a[int(n/2)]
m2 = int(sum(a) / n)
m3 = ceil(sum(a) / n)

for v in [m1, m2, m3]:
    cost = 0
    for i in range(n):
        cost += (a[i] - v) ** 2
    ans = min(cost, ans)
print(ans)
N = int(input())
l = []
for i in range(N):
    l.append(list(map(int, input().split())))
    
l = sp.array(sorted(l, key=lambda x: x[1]))

a = sp.cumsum(l[:,0])
b = l[:,1]

c = b-a
t = True
for i in c:
    if i < 0:
        t = False
        print("No")

if t:
    print("Yes")

### FIXED CODE ###

import scipy as sp
N = int(input())
l = []
for i in range(N):
    l.append(list(map(int, input().split())))

l = sp.array(sorted(l, key=lambda x: x[1]))

a = sp.cumsum(l[:,0])
b = l[:,1]

c = b-a
t = True
for i in c:
    if i < 0:
        t = False
        print("No")
        break

if t:
    print("Yes")
x, y = map(int, input().split())
for i in range(0, x+1):
  a.append(2 * i + 4 * (3 - i))
print("Yes" if y in a else "No")

### FIXED CODE ###

x, y = map(int, input().split())
a = []
for i in range(0, x+1):
  a.append(2 * i + 4 * (x - i))
print("Yes" if y in a else "No")
a,b,x = int(input().split())

if (a <= x) and (a + b >= x):
  print("YES")
else:
  print("NO")

### FIXED CODE ###

a,b,x = map(int,input().split())
 
if (a <= x) and (a + b >= x):
  print("YES")
else:
  print("NO")
s = input()
l = []
count = 0
for i in range(len(s)):
  if s[i] in ['A','T','C','G']:
    count += 1
  else:
    l.append(count)
    count = 0
print(max(l))

### FIXED CODE ###

s = input()
l = []
count = 0
for i in range(len(s)):
  if s[i] in ['A','T','C','G']:
    count += 1
  else:
    l.append(count)
    count = 0
l.append(count)
print(max(l))
# -*- coding: utf-8 -*-

_sum_list = []
_avg_list = []

while 1:
    try:
        _sum, _avg = [int(e) for e in input().split()]
        _sum_list.append(_sum)
        _avg_list.append(_avg)
    except:
        break


_sum, _avg = sum(_sum_list), sum(_avg_list) / len(_avg_list)
print(round(_sum, 1), round(_avg, 1))

### FIXED CODE ###

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

_sum = 0
_avg = 0
n = 0


while 1:
    try:
        _s, _a = [int(e) for e in input().split(',')]
        _sum += _s * _a
        _avg += _a
        n += 1
    except:
        print(_sum)
        print(int(_avg / n + 0.5))
        break