Harryxun/stf_run huggingface dataset:
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)

comon = c.most_common()
ans = 0
for i in comon:
  if i[1] != 1:
  	ans += (i[1]*(i[1]-1)//2)
  
for i in a:
  if (ans-int(a.count(i))) < 0:
    print(0)
  else:
    co = a.count(i)
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))


      

### FIXED CODE ###

from collections import deque

s = list(input())
s = deque(s)
q = int(input())
flag = ''
count = 0
for i in range(q):
    que = list(map(str,input().split()))
    if que[0] == "1":
        count += 1
        if flag == 'one':
          flag = ''
        else:
          flag = 'one'
    else:
        if que[1] == '1':
            if flag == 'one':
                s.append(que[2])
            else:
                s.appendleft(que[2])
        elif que[1] == '2':
            if flag == 'one':
                s.appendleft(que[2])
            else:
                s.append(que[2])
if count % 2 == 0:
  for i in s:
    print(i,end="")
else:
  for i in reversed(s):
    print(i,end="")
from functools import lru_cache
N=int(input())
h=[int(i) for i in input().split()]
@lru_cache(maxsize=10**6)
def cost(n):
    if n == 0:
        return 0
    elif n == 1:
        return abs(h[1]-h[0])
    else:
        return min(cost(n-2)+abs(h[n]-h[n-2]), cost(n-1)+abs(h[n]-h[n-1]))
print(cost(N-1))

### FIXED CODE ###

N=int(input())
h=[int(i) for i in input().split()]
cost = [-1]*N
cost[0]=0
cost[1]=abs(h[1]-h[0])
for i in range(2,N):
    cost[i] = min(cost[i-2]+abs(h[i]-h[i-2]), cost[i-1]+abs(h[i]-h[i-1]))
print(cost[-1])
s=input()
if D==25:
  print('Christmas')

if D==24:
  print('Christmas Eve')
if D==25:
  print('Christmas Eve Eve')

if D==25:
  print('Christmas Eve Eve Eve')


### FIXED CODE ###

D=int(input())
if D==25:
  print('Christmas')

if D==24:
  print('Christmas Eve')
  
if D==23:
  print('Christmas Eve Eve')

if D==22:
  print('Christmas Eve Eve Eve')
import numpy as np

num_i, num_j = map(int, input().split())
inputs = [input() for i in range(num_i)]

x = []
for _ in inputs:
    for value in _:
        x.append(value)
x = np.array(x)
x = x.reshape(num_i, num_j)

count = 0
boolean = True
while (boolean):
    count += 1
    i_arr = []
    j_arr = []
    for i in range(num_i):
        for j in range(num_j):
            if (x[i][j] == "#"):
                i_arr.append(i)
                j_arr.append(j)
    for i, j in zip(i_arr, j_arr):
        if (i == 0) & (j == 0):
            x[1][0] = "#"
            x[0][1] = "#"
        elif (i == num_i - 1) & (j == num_j - 1):
            x[i - 1][j] = "#"
            x[i][j - 1] = "#"
        elif (i == num_i - 1) & (j == 0):
            x[i - 1][0] = "#"
            x[i][1] = "#"
        elif (i == 0) & (j == num_j - 1):
            x[1][j] = "#"
            x[0][j - 1] = "#"
        elif (i == 0):
            x[1][j] = "#"
            x[0][j - 1] = "#"
            x[0][j + 1] = "#"
        elif (j == 0):
            x[i - 1][0] = "#"
            x[i + 1][0] = "#"
            x[i][1] = "#"
        elif (i == num_i - 1):
            x[i - 1][j] = "#"
            x[i][j + 1] = "#"
            x[i][j - 1] = "#"
        elif (j == num_j - 1):
            x[i - 1][j] = "#"
            x[i + 1][j] = "#"
            x[i][j - 1] = "#"
        else:
            x[i - 1][j] = "#"
            x[i + 1][j] = "#"
            x[i][j - 1] = "#"
            x[i][j + 1] = "#"
    if len(set(list(x.flatten()))) == 1:
        print(str(count))
        boolean = False
    else:
        boolean = True

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())

# input black cells
black_cells = []

for h in range(H):
    line = list(input())
    for w in range(W):
        if line[w] == "#":
            black_cells.append(h * W + w)


# Graph
def r(p):
    q_list = []
    h = p // W
    w = p % W
    if h != 0:
        q_list.append(p - W)
    if h != H-1:
        q_list.append(p + W)
    if w != 0:
        q_list.append(p - 1)
    if w != W-1:
        q_list.append(p + 1)
    return q_list


queue = deque(black_cells)
d = [10000] * (H * W)
for i in black_cells:
    d[i] = 0

# dijkstra
while len(queue) > 0:
    p = queue.popleft()
    for q in r(p):
        if d[q] > d[p] + 1:
            d[q] = d[p] + 1
            queue.append(q)

print(max(d))
n = int(input())
A = list(map(int,input().split()))
A_0 = A.sort(reverse=True)
swt = 0
Alice_point = 0
Bob_point = 0

for i in range(n):
    if swt == 0:
        Alice_point += A_0[i]
        swt = 1
    else:
        Bob_point += A_0[i]
        swt = 0
print(Alice_point - Bob_point)


### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
A_0 = A.sort(reverse=True)
swt = 0
Alice_point = 0
Bob_point = 0

for i in range(n):
    if swt == 0:
        Alice_point += A[i]
        swt = 1
    else:
        Bob_point += A[i]
        swt = 0
print(Alice_point - Bob_point)
import copy
from sys import exit
from math import ceil
from collections import defaultdict as dd
n = int(input())
yakusuu_dic = dd(lambda: dd(int))
f = [0] * (n+1)
f[1] = 1
f[2] = 2

if n == 1:
    print(1)
    exit()
if n == 2:
    print(5)
    exit()
sosus = [2]

counter = 0
yakusuu_dic[2] = {2: 1}
for num in range(3, n+1):
    #print(num)
    for divider in sosus:
        if num % divider == 0:
            yakusuu_dic[num] = copy.deepcopy(yakusuu_dic[num // divider])
            yakusuu_dic[num][divider] += 1
            if divider in yakusuu_dic[num // divider]:
                f[num] = f[num // divider] // (yakusuu_dic[num // divider][divider] + 1) * (yakusuu_dic[num // divider][divider] + 2)
            else:
                f[num] = f[num // divider] * 2
            break
    else:
        yakusuu_dic[num][num] = 1
        f[num] = 2
        sosus.append(num)

counter = 0
for i in range(1, n+1):
    counter += i * f[i]
print(counter)

### FIXED CODE ###

n = int(input())
Arr = [0] * (n + 1)
for num in range(1, n+1):
    for i in range(1, n // num + 1):
        Arr[i * num] += 1
ans = 0
for i in range(1, n+1):
    ans += Arr[i] * i
print(ans)
s = list(input())
size = len(s)
ans = []
for i in range(size) :
    if s[i] ==  "B":
        ans.pop(-1)
    else: ans.append(s[i])

b = "".join(ans)
print(b)

### FIXED CODE ###

s = list(input())
size = len(s)
ans = []
for i in range(size) :
    if len(ans) >= 1 :
        if s[i] ==  "B" :
            ans.pop(-1)
        else : ans.append(s[i])

    elif s[i] != "B" : ans.append(s[i])

b = "".join(ans)
print(b)
n=input()

if s[0]=='7' or s[1]=='7' or s[2]=='7':
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n=input()
 
if n[0]=='7' or n[1]=='7' or n[2]=='7':
  print('Yes')
else:
  print('No')
S = list(input())
T = list(input())
S = sorted(S)
T = sorted(T,reverse = True)
counter = 0
for i in range(len(S)) :
    if S[i] > T[i] :
        print("No")
        break
    elif S[i] < T[i] :
        print("Yes")
        break
    else :
        counter += 1
    if counter == len(S) :
        if len(S) >= len(T) :
            print("No")
            break
        else :
            print("Yes")
            break
            

### FIXED CODE ###

s = input()
t = input()
Alphabet = list(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
)

flag = 0
S = sorted(s)
T = sorted(t,reverse = True)
for i in range(min(len(S),len(T))) :
    if S[i] == T[i] :
        flag += 1
    else :
        for j in range(len(Alphabet)) :
            if S[i] == Alphabet[j] :
                print("Yes")
                flag += -10000
                break
            elif T[i] == Alphabet[j] :
                print("No")
                flag += -10000
                break
            else :
                continue
        break
    
if flag == min(len(S),len(T)) :
    if len(S) >= len(T) :
        print("No")
    elif s != t :
        print("Yes")
    else :
        print("No")
#print(Alphabet)
N, K = map(int, input().split())
S = input()

arr = []
cnt = 0
comp = S[0]
for s in S:
    if s==comp:
        cnt += 1
    else:
        if comp=='0':
            arr.append(-cnt)
        else:
            arr.append(cnt)
        cnt = 1
        comp = s
if comp=='0':
    arr.append(-cnt)
else:
    arr.append(cnt)

def iter(A, cnt):
    if cnt>=K or len(A)<2:
        return max(A)
    elif len(A)==2:
        return abs(A[0]) + abs(A[1])
    m = -A[0]+A[1]
    arg = -1
    for i in range(len(A)-2):
        s3 = A[i] - A[i+1] + A[i+2]
        if m<s3:
            m = s3
            args = i
    s3 = A[-2]-A[-1]
    if m<s3:
        m = s3
        arg = len(A)-1
    if arg==-1:
        B = [-A[0]+A[1]] + A[2:]
    elif arg==len(A)-1:
        B = A[:-2] + [A[-2]-A[-1]]
    else:
        B = A[:arg] + [A[arg] - A[arg+1] + A[arg+2]] + A[arg+3:]
    return iter(B, cnt+1)


print(iter(arr, 0))

### FIXED CODE ###

N, K = map(int, input().split())
S = input()

arr = []
cnt = 0
comp = S[0]
for s in S:
    if s==comp:
        cnt += 1
    else:
        arr.append(cnt)
        cnt = 1
        comp = s
arr.append(cnt)

if len(arr)<3:
    print(sum(arr))
else:
    if S[0]=='1':
        L = (len(arr)+1)//2 - K +1
        l = 0
        tmp = sum(arr[2*l:2*(l+K)+1])
        ans = tmp
        for l in range(1, L):
            tmp = tmp - (arr[2*(l-1)]+arr[2*l-1]) + sum(arr[2*(l-1+K)+1 : min(2*(l+K)+1, len(arr))])
            ans = max(tmp, ans)
    else:
        L = (len(arr)+1)//2 - K + 1
        l = 0
        tmp = sum(arr[2*l:2*(l+K)])
        ans = tmp
        for l in range(1, L):
            tmp = tmp - sum(arr[max(0,2*l-3) : 2*l-1]) + sum(arr[2*(l+K-1): min(2*(l+K), len(arr))])
            ans = max(tmp, ans)
            
    print(ans)
N,M = map(int,input().split(" "))

first = []
second = []
flag = 0
end = True

for i in range(M):
  a,b = map(int,input().split(" "))
  if b == N:
    second.append(a)
  if a == 1:
    first.append(b)

first.sort()
second.sort()
    
if len(first) == 0 or len(second) == 0:
  print("IMPOSSIBLE")
else:
  firsti = 0
  secondi = 0
  while(end == True):
    if first[firsti] == second[secondi]:
      print("POSSIBLE")
      break
    elif first[firsti] < second[secondi]:
      firsti += 1
      if firsti > len(first) - 1:
        print("IMPOSSIBLE")
        break
    else:
      second += 1
      if secondi > len(second) - 1:
        print("IMPOSSIBLE")
        break
    

### FIXED CODE ###

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

first = []
second = []
flag = 0
end = True

for i in range(M):
  a,b = map(int,input().split(" "))
  if b == N:
    second.append(a)
  if a == 1:
    first.append(b)

first.sort()
second.sort()
    
if len(first) == 0 or len(second) == 0:
  print("IMPOSSIBLE")
else:
  firsti = 0
  secondi = 0
  while(end == True):
    if first[firsti] == second[secondi]:
      print("POSSIBLE")
      break
    elif first[firsti] < second[secondi]:
      firsti += 1
      if firsti > len(first) - 1:
        print("IMPOSSIBLE")
        break
    else:
      secondi += 1
      if secondi > len(second) - 1:
        print("IMPOSSIBLE")
        break
a = [int(i) for i in input().split() if i > 0: else: break]
for i in range(0,len(a)):
    print('Case ', i+1, ': ', a[i], sep='')

### FIXED CODE ###

a =[]
x = 1
while x > 0:
    x = int(input())
    a.append(x)
for i in range(0,len(a)-1):
    print('Case ',i+1,': ',a[i],sep='')
N, M = list(map(int, input().split()))
students = list()
checkpoints = list()

for i in range(N):
	students.append(list(map(int, input().split())))

for i in range(M):
	checkpoints.append(list(map(int, input().split())))

ans = [0] * N

for i in range(N):
	mindif = 4 * 10**8 + 1
	for j in range(M):
		dif = abs(students[i][0] - checkpoints[j][0]) + abs(students[i][1] - checkpoints[j][1])
		if dif < mindif:
			mindif = dif
			ans[i] = j

for i in range(M):
	print(ans[i])


### FIXED CODE ###

N, M = list(map(int, input().split()))
students = list()
checkpoints = list()

for i in range(N):
	students.append(list(map(int, input().split())))

for i in range(M):
	checkpoints.append(list(map(int, input().split())))

ans = [0] * N

for i in range(N):
	mindif = 4 * 10**8 + 1
	for j in range(M):
		dif = abs(students[i][0] - checkpoints[j][0]) + abs(students[i][1] - checkpoints[j][1])
		if dif < mindif:
			mindif = dif
			ans[i] = j + 1

for i in range(N):
	print(ans[i])
r = map(int, input())
b = 3*r**2
print(b)

### FIXED CODE ###

r = int(input())
b = 3*r**2
print(b)
n = input()
k = int(input())
m = len(n)
if k == 1:
    print(int(n[0])+9*(m-1))
elif k == 2:
    if m<2:ans = 0
    else:
        ans = 81*(m-1)*(m-2)//2
        ans += (int(n[0])-1)*(m-1)*9+int(n[1])+(m-2)*9
    print(ans)
else:
    if m<3:ans = 0
    else:
        ans1 = (m-1)*(m-2)*(m-3)//6*9**3
        ans2=(int(n[0])-1)*(m-1)*(m-2)//2*81
        ans3 =(m-2)*(m-3)//2*81
        ans = ans1+ans2+ans3
        if int(n[1]) > 0:
            ans += (int(n[1])-1)*(m-2)*9 + (m-3)*9+int(n[3])
    print(ans)

### FIXED CODE ###

n = input()
k = int(input())
m = len(n)
if k == 1:
    print(int(n[0])+9*(m-1))
elif k == 2:
    if m<2:ans = 0
    else:
        ans = 81*(m-1)*(m-2)//2+(int(n[0])-1)*(m-1)*9
        for i in range(1,m):
            if int(n[i]) != 0:
                ans += (m-i-1)*9+int(n[i])
                break
    print(ans)
else:
    if m<3:ans = 0
    else:
        ans = (m-1)*(m-2)*(m-3)//6*9**3 + (int(n[0])-1)*(m-1)*(m-2)//2*81
        for i in range(1,m):
            if int(n[i])!=0:
                ans += (m-i-1)*(m-i-2)//2*81+(int(n[i])-1)*(m-i-1)*9
                break
        for j in range(i+1,m):
            if int(n[j]) != 0:
                ans += (m-j-1)*9+int(n[j])
                break
    print(ans)
import bisect
a = int(input())
b = [int(input()) in d in range(a)]
c = [b[1]]
for i in b[1:]:
    if c[-1] < i:
        c.append(i)
    else:
        c[bisect.bisect_left(c,i)] = i
        
print(len(c))


### FIXED CODE ###

import bisect
a = int(input())
b = [int(input()) for d in range(a)]
c = [b[0]]
for i in b[1:]:
    if c[-1] < i:
        c.append(i)
    else:
        c[bisect.bisect_left(c,i)] = i
        
print(len(c))
import sys
sys.setrecursionlimit(1500)
n=int(input())
arr=list(map(int,input().split()))
vis={}
def count(n):
    if n in vis:
        return vis[n]
    if n<2:
        return 0
    else:
      vis[n]=min(abs(arr[n-1]-arr[n-2])+count(n-1),abs(arr[n-1]-arr[n-3])+count(n-2))
    return vis[n]
print(count(n))

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
N, M = map(int, input().split())
purint(N * M)

### FIXED CODE ###

N, M = map(int, input().split())
print(N * M)
print(sum([int(x) for x in input().split()]))


### FIXED CODE ###

print(sum([int(x) for x in input()]))
import sys
input = sys.stdin.readline

S = input()
N = len(S)
mod_13 = [10 ** i % 13 for i in range(N)]

dp = [1] + [0 for _ in range(13 - 1)]

for i, char in enumerate(reversed(S)):
    next_dp = [0 for _ in range(13)]
    if char == '?':
        for j in range(13):
            for k in range(10):
                next_dp[(j + mod_13[i] * k)  % 13] += dp[j]
    else:
        offset = (int(char) * mod_13[i]) % 13
        for j in range(13):
            next_dp[(offset + j) % 13] = dp[j]
    dp = list(map(lambda x: x % (10 ** 9 + 7), next_dp))

print(dp[5])


### FIXED CODE ###

S = input()
mod = 10 ** 9 + 7
N = len(S)
table = [[0] * 13 for _ in range(N + 1)]
table[0][0] = 1

dd = 1

for i, char in enumerate(reversed(S)):
    c = char != '?'
    for j in range(13):
        for k in range(10):
            if c and int(char) != k:
                continue
            table[i+1][(j + dd * k)  % 13] += table[i][j]
            table[i+1][(j + dd * k)  % 13] %= mod
    dd = (dd * 10) % 13

print(table[N][5])
a,b,c,x,y = [int(x) for x in input().split()]

#そのまま
aprice = a*x + b*y
#組み合わせ
if x > y:
    amari = a*(x-y)
elif x < y:
    amari = b*(y-x)
else:
    amaru = 0
bprice = min(x,y)*c*2 + amari
#セットのみ
cprice = c*max(x, y)*2

#print(aprice,bprice,cprice)
print(min(aprice,bprice,cprice))

### FIXED CODE ###

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

#そのまま
aprice = a*x + b*y
#組み合わせ
if x > y:
    amari = a*(x-y)
elif x < y:
    amari = b*(y-x)
else:
    amari = 0
bprice = min(x,y)*c*2 + amari
#セットのみ
cprice = c*max(x, y)*2

#print(aprice,bprice,cprice)
print(min(aprice,bprice,cprice))
word = input().split()

x = 0

if word[1] != word[2] :
  x = x+1
  
if word[2] != word[3] :
  x = x+1
  
if word[3] != word[1] :
  x = x+1
  
if x == 0 : print("No")
  
else : print("Yes")

### FIXED CODE ###

word = input()

if word[0:1] == word[1:2] and word[0:1] == word[2:] :
    print("No")
    
else : print("Yes")
n=int(input())
s=0
l=[]
for i in　range(1,n+1):
 s+=i
 l.append(i)
 if s>=n:
  for j in l:
   if j!=s-n:
    print(j)
  break

### FIXED CODE ###

n=int(input())
s=0
l=[]
for i in range(1,n+1):
 s+=i
 l.append(i)
 if s>=n:
  for j in l:
   if j!=s-n:
    print(j)
  break
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  3 10:58:30 2018

@author: ashida
"""
N=int(input())

S1=list(input())
S2=list(input())

if S1[0]==S1[1]:
    st=2
    ans=6
    flag=1
else:
    st=1
    ans=3
    flag=-1

while st<N:
    if st+1<N:
        if S1[st]==S1[st+1]:
            if flag<0:
                ans*=2
            else:
                ans*=3
            st+=2
            flag=1
        else:
            if flag<0:
                ans*=2
            else:
                ans*=1
            st+=1
            flag=-1
    else:
        if flag<0:
            ans*=2
        else:
            ans*=1
        st+=1
        
ans=ans%1000000007
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Jul  3 10:58:30 2018

@author: ashida
"""
N=int(input())

S1=list(input())
S2=list(input())

if len(S1)>1:
    if S1[0]==S1[1]:
        st=2
        ans=6
        flag=1
    else:
        st=1
        ans=3
        flag=-1
else:
    st=1
    ans=3
    flag=-1

while st<N:
    if st+1<N:
        if S1[st]==S1[st+1]:
            if flag<0:
                ans*=2
            else:
                ans*=3
            st+=2
            flag=1
        else:
            if flag<0:
                ans*=2
            else:
                ans*=1
            st+=1
            flag=-1
    else:
        if flag<0:
            ans*=2
        else:
            ans*=1
        st+=1
        
ans=ans%1000000007
print(ans)
n,y = map(int, input().strip().split())
a_x, a_y, a_z = -1, -1, -1
for xi in range(n + 1):
  for yi in range(n - xi + 1):
    zi = n - xi - yi
    if 10000*xi + 5000*yi + 1000*zi == y:
      a_x = xi
      a_y = yi
      a_z = zi
      break
 
print(a_x, a_y, a_z)

### FIXED CODE ###

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



def main():
  n = int(input())
  tmp = {}
  for i in range(n):
    x = int(input())
    if x in tmp.keys():
      tmp[x] += 1
    else:
      tmp[x] = 0
  print(len(tmp))
    
  
if __name__ == "__main__":
  main()
x=input()
if x[-1]="s":
  print(x"es")
else:
  print(x"s")

### FIXED CODE ###

x=input()
if x[-1]=="s":
  print(f"{x}es")
else:
  print(f"{x}s")
s=input()
t=input()

x=list(s)
y=list(t)
import sys
if len(set(y)-set(x))!=0:
	print(-1)
	sys.exit()

a=[[] for _ in range(26)]
for i in range(len(s)):
	a[ord(x[i])-97].append(i)



import bisect
#t=bisect.bisect_right(res[p-1],y)

repeat=0
last=0
for i in range(len(t)):
	temp=a[ord(y[i])-97]
	if last>max(temp):
		repeat+=1
		last=min(temp)
	else:
		last=temp[bisect.bisect_right(temp,last)]
	#print(temp,repeat,last)
print(repeat*len(s)+last+1)

### FIXED CODE ###

s=input()
t=input()
x=list(s)
y=list(t)
import sys
if len(set(y)-set(x))!=0:
	print(-1)
	sys.exit()
a=[[] for _ in range(26)]
for i in range(len(s)):
	a[ord(x[i])-97].append(i)
import bisect

repeat=0
last=-1
for i in range(len(t)):
	temp=a[ord(y[i])-97]
	if last>=temp[-1]:
		repeat+=1
		last=temp[0]
	else:
		last=temp[bisect.bisect_right(temp,last)]
	#print(temp,repeat,last)
print(repeat*len(s)+last+1)
#%%
s = list(input())
ans = 0
i = 0

while True:
    if i < 0 :
        i += 1
    elif len(s)-2 <= i:
        break
    else:
        if s[i] == 'A'
            if s[i+1] == 'B' and s[i+2] == 'C':
                ans += 1
                s[i], s[i+1], s[i+2] = 'B', 'C', 'A'
                i -= 1
            else:
                i += 1
        else:
            i += 1

print(ans)


### FIXED CODE ###

#%%
s = list(input())
i = 0
ss = ''

while True:
    if i <= len(s) - 2:
        if s[i] == 'B' and s[i+1] == 'C':
            ss += 'D'
            i += 2
        else:
            ss += s[i]
            i += 1          
    else:
        ss += s[i]
        i += 1
    if i >= len(s):
        break
#print(ss)

a = 0
ans = 0
for i in range(len(ss)):
    if ss[i] == 'A':
        a += 1
    elif ss[i] == 'D':
        ans += a
    else:
        a = 0
print(ans)

#%%
while True:
    x,y = raw_input().split()
    #x,y = map(int,(x,y))
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = map(str,(x,y))
        print x + " " + y
    else:
        x,y = map(str,(x,y))
        print y + " " + x

### FIXED CODE ###


while True:
    x,y = raw_input().split()
    x,y = map(int,(x,y))
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = map(str,(x,y))
        print y + " " + x
    else:
        x,y = map(str,(x,y))
        print x + " " + y
D, N = map(int, input().split())
if D == 0:
  print(N)
elif D == 1:
  x = [100 * i for i in range(1,101)]
  print(x[N])
elif D == 2:
  x = [10000 * i for i in range(1,101)]
  print(x[N])

### FIXED CODE ###

D, N = map(int, input().split())
if N != 100:
  if D == 0:
    print(N)
  elif D == 1:
    x = [100 * i for i in range(1, 101)]
    print(x[N-1])
  elif D == 2:
    x = [10000 * i for i in range(1, 101)]
    print(x[N-1])
else:
  if D == 0:
    print(101)
  elif D == 1:
    x = [100 * i for i in range(1, 101)]
    print(x[N-1]+100)
  elif D == 2:
    x = [10000 * i for i in range(1, 101)]
    print(x[N-1]+10000)
N = int(input())

if N < 2:
    print(0)

heights = [int(x) for x in input().split()]

dp = [0] * N
dp[0] = 0
dp[1] = abs(heights[1] - heights[0])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(heights[i] - heights[i-1]),
                dp[i - 2] + abs(heights[i] - heights[i - 2]))

print(dp[-1])

### FIXED CODE ###

N = int(input())

if N < 2:
    print(0)

heights = [int(x) for x in input().split()]

dp = [0] * N
dp[0] = 0
dp[1] = abs(heights[1] - heights[0])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(heights[i] - heights[i-1]),
                dp[i - 2] + abs(heights[i] - heights[i - 2]))

print(dp[-1])
n=int(input())
if n==1
 print("Hello World")
else
 a=int(input())
 b=int(input())
 print(a+b)

### FIXED CODE ###

n=int(input())
if n==1:
 print("Hello World")
else:
 a=int(input())
 b=int(input())
 print(a+b)
import numpy as np

N, M, X = map(int, input().split())
C = np.zeros(N)
A = np.zeros((N, M))


for n in range(N):
    s = list(map(int, input().split()))
    C[n] = s[0]
    A[n] = s[1:]

C_MIN = 9999999999
for i in range(2 ** N):
    C_SUM = 0
    A_SUM = np.zeros(M)
    for j in range(N):
        if ((i >> j) & 1):
            C_SUM += C[j]
            A_SUM += A[j]
    if np.all(A_SUM >= X):
        if C_SUM < C_MIN:
            C_MIN = C_SUM
            
if C_MIN == 9999999999:
    print("-1")
else:
    print(C_MIN)

### FIXED CODE ###

S = input()
T = input()

if S == T[:-1]:
    print("Yes")
else:
    print("No")
l = list(map(int, input().split()))
l.sort()
ans = NO
if l == [5, 5, 7]:
  ans = YES
print(ans)

### FIXED CODE ###

l = list(map(int, input().split()))
l.sort()
ans = 'NO'
if l == [5, 5, 7]:
  ans = 'YES'
print(ans)
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
S = list(input())
K = int(input())
a = S[K-1]
ans = []
for k in S:
    if k != a:
        ans.append("*")
    else:
        ans.append(k)

answer = "".join(ans)
print(answer)

### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
A,B,C = [int(x) for x in input().split()]

if A<B:
    if A<C and C<B:
        print("Yes")
    else:
        print("No")
else:
    if B<C and C<A:
        print('Yes')
    else:
        print('No')