Harryxun/stf_run huggingface dataset:
n = int(input())
a = [int(i) for i in input().split()]

# aの各数値の個数をdictで保持(数値:個数) 
a_dict = {}
for v in a:
    if v in a_dict:
        a_dict[v] += 1
    else:
        a_dict[v] = 1

# a_dictの中になければならない数値のリストを作成
possible_list = {i: True for i in range(1, n, 2)}
 
can = True
if n % 2 == 0:
    for k, v in a_dict.items():
        # 数値が2個でない、もしくはkがpossible_list内に存在しないならFalse
        if v != 2 or k not in possible_list:
            can = False
            break
else:
　　　　if a_dict[0] != 1:
        can = False
    else:
        for k, v in a_dict.items():
            if v != 2 or k not in possible_list:
                can = False
                break
 
if can:
    print(2 ** (n // 2) % (10 ** 9 + 7))
else:
    print(0)

### FIXED CODE ###

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

a_dict = {}
for v in a:
    if v in a_dict:
        a_dict[v] += 1
    else:
        a_dict[v] = 1

 
if n % 2 == 0:
    possible_list = {i: True for i in range(1, n, 2)}
    for k, v in a_dict.items():
        if v != 2 or k not in possible_list:
            print(0)
            exit()
else:
    possible_list = {i: True for i in range(0, n, 2)}
    if a_dict[0] != 1:
        print(0)
        exit()
    else:
        a_dict[0] = 2
        for k, v in a_dict.items():
            if v != 2 or k not in possible_list:
                print(0)
                exit()
 
print(2 ** (n // 2) % (10 ** 9 + 7))
def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    S = sum(A)
    l = A[0]
    I = 0
    for i in range(1, N):
        if l + A[i] < S / 2:
            l += A[i]
            I = i
    if l == S / 2:
        print(0)
        exit()
    c = A[I + 1]
    r = S - l - c
    ans1 = abs(r - (l + c))
    ans2 = abs(l - (r + c))
    print(min(ans1, ans2))

if __name__ == "__main__":
    solve()


### FIXED CODE ###

import math

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    S = sum(A)
    l = A[0]
    I = 0
    m = math.ceil(S / 2)
    for i in range(1, N):
        if (l + A[i]) <= m:
            l += A[i]
        else:
            I = i - 1
            break
    if l == S / 2:
        print(0)
        exit()
    c = A[I + 1]
    r = S - l - c
    ans1 = abs(r - (l + c))
    ans2 = abs(l - (r + c))
    print(min(ans1, ans2))

if __name__ == "__main__":
    solve()
from bisect import bisect_left,insort_left

#入力
D = int(input())
C = [int(c) for c in input().split()]
S = []
for _ in range(D):
    s = [int(x) for x in input().split()]
    S.append(s)
T = []
for _ in range(D):
    t = int(input()) - 1
    T.append(t)
    
#スコア計算
score = 0
last_day = [[-1] for _ in range(26)]
for t in range(D):
    test = T[t]
    score += S[t][test]
    last_day[test].append(t)
minus = [0] * 26
for i in range(26):
    last_day[i].append(D)
    l = last_day[i]
    for j in range(len(l)-1):
        dd = l[j+1] - l[j] - 1
        minus[i] += C[i] * (dd * (dd + 1)) // 2
    score -= minus[i]

M = int(input())
for _ in range(M):
    d,q = map(int,input().split())
    d -= 1
    q -= 1
    old = T[d]
    T[d] = q
    #日程dでの元のテストold
    l = last_day[old]
    ind_old = l.index(d)
    dd_left = l[ind_old] - l[ind_old-1] - 1
    dd_right = l[ind_old+1] - l[ind_old] - 1
    dd = l[ind_old+1] - l[ind_old-1] - 1
    dif_old = C[old] * (((dd_left * (dd_left + 1)) // 2) + ((dd_right * (dd_right + 1)) // 2) - ((dd * (dd + 1)) // 2))
    #日程dでのテストq
    ind_q = bisect_left(last_day[q],d)
    dd_left = d - l[ind_q] - 1
    dd_right = l[ind_q+1] - d - 1
    dd = l[ind_q+1] - l[ind_q] - 1
    dif_q = C[q] * (((dd * (dd + 1)) // 2) - ((dd_left * (dd_left + 1)) // 2) - ((dd_right * (dd_right + 1)) // 2))
    #新しいスコア
    score += (dif_old + dif_q - S[d][old] + S[d][q])
    #情報の更新
    minus[old] -= dif_old
    minus[q] -= dif_q
    del last_day[old][ind_old]
    last_day[q].insert(ind_q,d)
    print(score)

### FIXED CODE ###

from bisect import bisect_left,insort_left

#入力
D = int(input())
C = [int(c) for c in input().split()]
S = []
for _ in range(D):
    s = [int(x) for x in input().split()]
    S.append(s)
T = []
for _ in range(D):
    t = int(input()) - 1
    T.append(t)
    
#スコア計算
score = 0
last_day = [[-1] for _ in range(26)]
for d in range(D):
    test = T[d]
    score += S[d][test]
    last_day[test].append(d)
minus = [0] * 26
for i in range(26):
    last_day[i].append(D)
    l = last_day[i]
    for j in range(len(l)-1):
        dd = l[j+1] - l[j] - 1
        minus[i] += C[i] * (dd * (dd + 1)) // 2
    score -= minus[i]

M = int(input())
for _ in range(M):
    d,q = map(int,input().split())
    d -= 1
    q -= 1
    old = T[d]
    T[d] = q
    #日程dでの元のテストold
    l = last_day[old]
    ind_old = l.index(d)
    dd_left = l[ind_old] - l[ind_old-1] - 1
    dd_right = l[ind_old+1] - l[ind_old] - 1
    dd = l[ind_old+1] - l[ind_old-1] - 1
    dif_old = C[old] * (((dd_left * (dd_left + 1)) // 2) + ((dd_right * (dd_right + 1)) // 2) - ((dd * (dd + 1)) // 2))
    #日程dでのテストq
    l = last_day[q]
    ind_q = bisect_left(last_day[q],d)
    dd_left = d - l[ind_q-1] - 1
    dd_right = l[ind_q] - d - 1
    dd = l[ind_q] - l[ind_q-1] - 1
    dif_q = C[q] * (((dd * (dd + 1)) // 2) - ((dd_left * (dd_left + 1)) // 2) - ((dd_right * (dd_right + 1)) // 2))
    #新しいスコア
    score += (dif_old + dif_q - S[d][old] + S[d][q])
    #情報の更新
    minus[old] -= dif_old
    minus[q] -= dif_q
    del last_day[old][ind_old]
    last_day[q].insert(ind_q,d)
    print(score)
n, m, c = map(int, input.split())
b = list(map(int, input.split()))
ans = 0
code = 0

for i in range(n):
    for j in range(m):
        
        a = list(map(int, input.split()))
        code += a[i] * b[i]
    
    code -= 10
    if code >= 0:
        ans += 1
        
print(ans)

### FIXED CODE ###

n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
code = 0

for i in range(n):
    a = list(map(int, input().split()))
    
    for j in range(m):
        code += a[j] * b[j]
    
    code += c
    if code > 0:
        ans += 1
    code = 0
        
print(ans)
a, b, c, d = input()

string_set = set(a, b, c, d)

print("YES" if len(string_set) == 2 and not a ^ b ^ c ^ d else "NO")

### FIXED CODE ###

from collections import Counter

arr = list(input())
c = Counter(arr)
print("Yes" if c.most_common()[0][1] == 2 and c.most_common()[1][1] == 2 else "No")
n=int(input())
z=[list(map(int, input().split())) for i in range(n)]
v=[]
r=[]
#各頂点に対して、ピラミッドの頂点(  高さ200 )と仮定して計算 rに座標保存
for i in range(101):
    for j in range(101):
        for k in range(n):
            x=abs(j-z[k][0])
            y=abs(i-z[k][1])
            v.append(200-x-y-z[k][2])
        if v.count(v[0])==n:
            r=[j,i]
        v=[]
#中心座標の高さを求める。
h=z[0][2]+abs(z[0][0]-r[0])+abs(z[0][1]-r[1])
print(r[0],r[1],h)

### FIXED CODE ###

n=int(input())
z=[list(map(int, input().split())) for i in range(n)]
z.sort(key=lambda x:x[2])
z.reverse()

v=[]
count=0

#各頂点に対して、中心座標と仮定して検証
for i in range(101):
    for j in range(101):
        x=abs(j-z[0][0])
        y=abs(i-z[0][1])
        h=z[0][2]+abs(x)+abs(y)
                
            #候補があってるか確認
        for k in range(n):
            if z[k][2]==max(h-abs(z[k][0]-j)-abs(z[k][1]-i),0):
                count+=1
                
        if count==n:
            print(j,i,h)
            exit()
        count=0
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    output = 1
    output *= a[i]

    if output> 10**18:
        print(-1)
        quit()
print(output)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
output = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        output *= A[i]
        if output> 10**18:
            print(-1)
            quit()
    print(output)
import collections

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
K = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, K + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
n=int(input())
print(n)
nCk=n
R=list()
L=list(map(int,input().split()))
c = collections.Counter(L)
nikai=c.most_common()[0][0]#2回出てくる数
for i in range(n+1):
  if L[i]==nikai:
    R.append(i)
#Rに二個のindがある。それぞれR[0]こ、N-R[1]
k=n-R[1]+R[0]
for i in range(1,n):
  nCk=cmb(n+1,i+1,mod)
  a = cmb(k,i,mod)
  print((nCk-a)%mod)
print(1)

### FIXED CODE ###

import collections

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
K = 2*(10**5)
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, K + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
n=int(input())
print(n)
nCk=n
R=list()
L=list(map(int,input().split()))
c = collections.Counter(L)
nikai=c.most_common()[0][0]#2回出てくる数
for i in range(n+1):
  if L[i]==nikai:
    R.append(i)
#Rに二個のindがある。それぞれR[0]こ、N-R[1]
k=n-R[1]+R[0]
for i in range(1,n):
  nCk=cmb(n+1,i+1,mod)
  a = cmb(k,i,mod)
  print((nCk-a)%mod)
print(1)
import sys


S_raw = sys.stdin.readline().strip()

def check_next(S):
    S = list(S)
    before_num=S[0]
    for i in range(len(S)):
        if S[i]!=before_num:
            S.pop(i-1)
            #S = list(S)
            S.pop(i-1)
            new_S = S
            return S,1
            break
    return S,0


cnt=0
N=0

while cnt<10**5:
    S_raw, check_cnt = check_next(S_raw)
    N += check_cnt
    if check_cnt==0:
        break
    cnt+=1
    
print(N*2)

### FIXED CODE ###

S = input()

num0 = S.count("0")
num1 = len(S)-num0

print(min(num0,num1)*2)
a,b=map(int,input().split())
k = 1
s = 0
for i in map(int,input().split()):
    if s+i<=b:
        k+=1
    s+=i

### FIXED CODE ###

x,y=map(int,input().split())
if x<y:
    print(0)
else:
    print(10)
def main():
  N, K = map(lambda i: int(i), input().split(' '))
  l = list(map(lambda i: int(i), input().split(' '))
  l.sort()
  l.reverse()
  m = 0
  for i in range(K):
    m += l[i]
  print(m)

main()

### FIXED CODE ###

def main():
  N, K = map(lambda i: int(i), input().split(' '))
  l = list(map(lambda i: int(i), input().split(' ')))
  l.sort()
  l.reverse()
  m = 0
  for i in range(K):
    m += l[i]
  print(m)

main()
def nearlist(N, LIST):
    NEAR = [set() for _ in range(N)]
    for a, b in LIST:
        NEAR[a - 1].add(b - 1)
        NEAR[b - 1].add(a - 1)
    return NEAR


def dfs(NEAR, S, N):  # 深優先探索  # スタック
    dist = [n for _ in range(N)]  # 前処理
    PATH = [-1 for _ in range(N)]
    dist[S], PATH[S] = 0, 's'
    stack, frag = [S], set([S])

    while len(stack) > 0:
        q = stack.pop()
        for i in NEAR[q]:  # 移動先の候補
            if i != 0 and i in frag:
                dist[i] = dist[PATH[i]] + 1
            if dist[i] > dist[q] + 1:
                dist[i] = dist[q] + 1
                PATH[i] = q
            if i in frag:  # 処理済みか否か
                continue
            stack.append(i), frag.add(i)
        print(dist,PATH)
    return PATH


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

near = nearlist(n, ab)
path = dfs(near, 0, n)

print('Yes')
for i in range(1, n):
    print(path[i] + 1)


### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline


def bfs(NEAR, S, N):  # 幅優先探索  # キュー
    pas = [-1 for _ in range(N)]
    pas[S] = 's'
    frag = set([S])
    que = deque([S])

    while len(que) > 0:
        q = que.popleft()
        for i in NEAR[q]:
            if i in frag:  # 処理済みか否か
                continue
            pas[i]=q
            que.append(i)
            frag.add(i)
    return pas


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

near = [[] for _ in range(n)]
for a, b in ab:
    near[a - 1].append(b - 1)
    near[b - 1].append(a - 1)
pas = bfs(near, 0, n)

if all(pas[i] != -1 for i in range(n)):
    print('Yes')
    for i in range(1, n):
        print(pas[i] + 1)
else:
    print('No')
def splitter(type,input):
    return list(map(lambda x:type(x),input.split()))

s1 = splitter(int,input())
N = s1[0]
K = s1[1]
Q = s1[2]

ar = [0] * N
for i in range(Q):
    ar[int(input())] += 1
for j in range(N):
    if K-Q+ar[j] <= 0:
        print("No")
    else:
        print("Yes")

### FIXED CODE ###

def splitter(type,input):
    return list(map(lambda x:type(x),input.split()))

s1 = splitter(int,input())
N = s1[0]
K = s1[1]
Q = s1[2]

ar = [0] * N
for i in range(Q):
    ar[int(input())-1] += 1
for j in range(N):
    if K-Q+ar[j] <= 0:
        print("No")
    else:
        print("Yes")
# -*- coding: utf-8 -*-

n,m = map(int,input().split())
p = [0] * m
y = [0] * m
for i in range(m):
    p[i],y[i] = map(int,input().split())

certificate = [[] for _ in range(n)]

for i in range(m):
    certificate[p[i]-1].append(y[i])

for i in range(len(certificate)):
    certificate[i].sort()

for i in range(m):
    number = ""
    number += str(p[i]).zfill(6)
    number += str(certificate[p[i]-1].index(y[i])+1).zfill(6)
    print(number)


### FIXED CODE ###

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

x,y = map(int,input().split())
print(int(x + y / 2))
x1, op, x2 = input().split()

if op == "+":
  print(x1+x2)
else:
  print(x1-x2)

### FIXED CODE ###

x1, op, x2 = input().split()
 
if op == "+":
  print(int(x1)+int(x2))
else:
  print(int(x1)-int(x2))
from collections import deque
n = input()
A = ''.join(raw_input() for i in xrange(n))

if n > 5:
    exit(1)

ALL = "#"*(n*n)

deq = deque()

deq.append((A, 0))
memo = {}
while deq:
    state, cost = deq.popleft()
    if state == ALL:
        print cost
        break
    if state in memo:
        continue
    s = list(state)
    memo[state] = 1
    for i in xrange(n):
        C = [state[i*n+k] for k in xrange(n)]
        for j in xrange(n):
            n_state = s[:]
            for k in xrange(n):
                n_state[k*n+j] = C[k]
            deq.append((''.join(n_state), cost+1))
else:
    print -1


### FIXED CODE ###

n = input()
A = [raw_input() for i in xrange(n)]

R = [sum(e[j] == '#' for j in xrange(n)) for e in A]
C = [sum(A[j][i] == '#' for j in xrange(n)) for i in xrange(n)]

c_need = sum(e < n for e in C)

INF = 10**9+7
ans = INF
for i in xrange(n):
    if R[i] == C[i] == 0:
        continue
    if C[i] == 0:
        ans = min(ans, n-R[i] + c_need + 1)
    else:
        ans = min(ans, n-R[i] + c_need)
print -1 if ans == INF else ans
w,a,b=map(int,input().split())

if a=b:
  print(0)
elif a>b:
  if b+w>=a:
    print(0)
  else:
    print(int(a-b-w))
else:
   if a+w>=b:
    print(0)
  else:
    print(int(b-a-w))
  

### FIXED CODE ###

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

if a==b:
  print(int(0))
elif a>b:
  if b+w>=a:
    print(int(0))
  else:
    print(int(a-b-w))
else:
   if a+w>=b:
    print(int(0))
   else:
    print(int(b-a-w))
n=int(input())
t,a=map(int,input().split())
H=list(map(int,input().split()))
minn=10**10
for i in range(n):
  if minn>abs((t*(1000)-6*H[i])-a):
    ans = H[i]
    minn=t*(1000)-6*H[i]
print(ans)
  


### FIXED CODE ###

A,B=map(int,input().split())
print(A+B//2)
import sys
def Ii():return int(sys.stdin.buffer.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

n,k = Mi()
b = [1]*n
for i in range(k):
  d = Ii()
  a = Li()
  for j in a:
    b[j] = 0
    
print(sum(b)-1)

### FIXED CODE ###

import sys
def Ii():return int(sys.stdin.buffer.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))
 
n,k = Mi()
b = [1]*(n+1)
for i in range(k):
  d = Ii()
  a = Li()
  for j in a:
    b[j] = 0
    
print(sum(b)-1)
"""
07:26:30
奇数が2つで2つの偶数になる
片方どちらかが1の場合は、奇数が2つで1つの偶数になる
0でswapは分断される
H,W<=500なので全探索？O(HW)くらいか
端っこから決めていく
"""

H, W  = map(int, input().split())
right = []
ans = []
for i in range(H):
    As = list(map(int, input().split()))
    for j in range(W-1):
        if As[j]%2 == 1:
            ans.append([i+1,j+1,i+1,j+1+1])
            As[j] -= 1
            As[j+1] += 1
    right.append(As[j+1])
for i in range(H-1):
    if right[i]%2 == 1:
        ans.append([i+1,j+1,i+1+1,j+1])
        right[i] -= 1
        right[i+1] += 1
print(len(ans))
for a in ans:
    print(*a)



### FIXED CODE ###

### 予め一筆書きルートを作る
H, W = map(int,input().split())
As = []
for i in range(H):
    As.append(list(map(int,input().split())))
routes = []
for i in range(H):
    for j in range(W):
        if i%2 == 0:
            routes.append((i+1,j+1))
        else:
            routes.append((i+1,W-j))
n = len(routes)
mvs = []
cnt = 0
for i in range(n-1):
    hi,wi = routes[i]
    hi2,wi2 = routes[i+1]
    if As[hi-1][wi-1] % 2 == 1:
        As[hi2-1][wi2-1] += 1
        mvs.append([hi,wi,hi2,wi2])
        cnt += 1

print(cnt)
for h1,w1,h2,w2 in mvs:
    print(h1,w1,h2,w2)
a, b = map(int, input().split())
print(a * b, 2(a + b))


### FIXED CODE ###

a, b = map(int, input().split())
print(a * b, 2 * (a + b))
# input
S = input()

fl = True
for i in range(0, 4):
    if S[i] == S[i + 1]:
        print("Bad")
        fl = False
        break

if fl is True:
    print("Good")

### FIXED CODE ###

# input
S = input()

fl = True
for i in range(0, 3):
    if S[i] == S[i + 1]:
        print("Bad")
        fl = False
        break

if fl is True:
    print("Good")
NM = [int(i) for i in input().split()]
A = [int(i) fot i in input().split()]

N = NM[0]
M = NM[1]

if NM => sum(A):
  print(NM-sum(A))
else:
  print(-1)


### FIXED CODE ###

NM = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

N = NM[0]
M = NM[1]

if N >= sum(A):
  print(N-sum(A))
else:
  print(-1)
S=input()

if S="AAA" or S="BBB":
  print("NO")
else:
  print("Yes")

### FIXED CODE ###

S=input()
if S.count("AAA") or S.count("BBB"):
  print("No")
else:
  print("Yes")
n,m,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))

from collections import deque
a = deque([x for x in a])
b = deque([x for x in b])
a.append(10**9+1)
b.append(10**9+1)
ans = 0
def cnt(a,b,time):
  global ans
  #print(ans, time,a,b)
  if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):
      cnt(a,b,time)

cnt(a,b,0)
print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0] * (n + 1)
sb = [0] * (m + 1)
for i in range(n):
  sa[i + 1] = sa[i] + a[i]
for i in range(m):
  sb[i + 1] = sb[i] + b[i]
r = m
ans = 0
for i in range(n + 1):
  if sa[i] > k:
    break
  while sa[i] + sb[r] > k:
    r -= 1
  ans = max(ans, i + r)
print(ans)
H, W = map(int, input().split())
array = list()
header = ""
for i in range(H):
    array[i] = "#" + input() + "#"
for i in range(0, W+2):
    header += "#"
    
print(header)
for p in array:
    print(p)
print(header)



### FIXED CODE ###

H, W = map(int, input().split())
array = list()
header = ""
for i in range(0, H):
    array.append("#" + input() + "#")
for i in range(0, W + 2):
    header += "#"

print(header)
for p in array:
    print(p)
print(header)
import math
A, B = map(int, input().split())
print(math.cail((B-A)/(A-1))+1)

### FIXED CODE ###

import math
A, B = map(int,input().split())

x = math.ceil(1+(B-A)/(A-1))

print(x)
# coding: utf-8
# Your code here!

import copy

string = [*input()]

concat_string = copy.copy(string)
count = 0
while True:
    num_delete = 0
    flags_delete = [False] * len(string)
    
    i = 0
    while i < len(concat_string) - 1:
        if concat_string[i] != concat_string[i + 1]:
            flags_delete[i] = True
            flags_delete[i + 1] = True
            num_delete += 2
            i += 2
        else:
            i += 1
           
    if num_delete == 0:
        break
    
    count += num_delete
    concat_string = [concat_string[i] for i in range(len(concat_string)) if flags_delete[i] == False]

print(count)
        
        

### FIXED CODE ###

# coding: utf-8
# Your code here!

import copy

string = [x for x in input()]

concat_string = copy.copy(string)
num_delete = 0

i = 0
j = 1
not_delete_list = []
while True:
    if j >= len(concat_string) or i < 0:
        break
    if concat_string[i] != concat_string[j]:
        num_delete += 2
        
        if i == 0:
            i = j + 1
            j = i + 1
        else:
            if len(not_delete_list) > 0:
                i = not_delete_list.pop(-1)
                j = j + 1
            else:
                i = j + 1
                j = i + 1
    else:
        not_delete_list.append(i)
        i = j
        j = i + 1


print(num_delete)
s = list(input())
ls = len(s)
ss = sorted(s, reverse=True)
cnt = [0, 0]
ans = 0
w = 0
while ss[w] == "W":
    w += 1

for i in range(ls):
    if s[i] == "B":
        ans += w + cnt[0] - i
    else:
        ans += i - cnt[1]
    cnt[s[i] != "B"] += 1

print(ans//2)


### FIXED CODE ###

s = list(input())
ls = len(s)
ss = sorted(s, reverse=True)
cnt = [0, 0]
ans = 0
w = 0

while ss[w] == "W":
    w += 1
    if ls == w:
        break

for i in range(ls):
    if s[i] == "B":
        ans += w + cnt[0] - i
    else:
        ans += i - cnt[1]
    cnt[s[i] != "B"] += 1

print(ans//2)
def f(N):
    res = 0
    while N//10 > 0:
        res += N % 10
        N = N // 10
    return res


if __name__ == '__main__':
    N = int(input())

    if N % f(N) == 0:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

if __name__ == '__main__':
    N = input()

    fn = 0
    for i in range(len(N)):
        fn += int(N[i])

    if int(N) % fn == 0:
        print('Yes')
    else:
        print('No')
n,k=map(int,input().split())


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

ar=[-1 for i in range(n+1)]
p=1
h=[]
go=0


for i in range(1,k+1):
    
    
    
    

    ar[p]=i
    p=a[p-1]
    
    if ar[p]>0:
        j=ar[p]
        amari=(k-i-1)%(i-j)
        
        go=1
        break

if go==1:
    p=ar.index(j+amari)
    p=a[p-1]


print(p)


### FIXED CODE ###

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


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

ar=[-1 for i in range(n+1)]
p=1

go=0


for i in range(1,k+1):
    
    
    
    

    ar[p]=i-1
    p=a[p-1]
    
    if ar[p]>0:
        j=ar[p]
        amari=(k-i)%(i-j)
        
        go=1
        break

if go==1:
    p=ar.index(j+amari)
    
    


print(p)
s = input()
print("2017/01/"+s[-2:]

### FIXED CODE ###

s = input()
print("2018/01/"+s[-2:])
def fib(n):
    n += 1
    f = ((1 + 5**0.5) / 2)**n / 5**0.5 + 0.5
    return int(f)

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

if M == 0:
    print(fib(N))
    exit()

A = [int(input()) for _ in range(M)]
L = [0] * (M+1)

ans = 1

L[0] = fib(A[0]-1) % (10**9 + 7)
L[M] = fib(N-(A[M-1]+1)) % (10**9 + 7)

for i in range(1,M):
    if A[i]-A[i-1] == 1:
        print(0)
        exit()
    L[i] = fib((A[i]-1)-(A[i-1]+1)) % (10**9 + 7)

for j in range(M+1):
    ans = (ans * L[j]) % (10**9 + 7)

print(ans)


### FIXED CODE ###

def fib(n):
    a,b = 0,1
    for i in range(n):
        a, b = b, a+b
    return int(b)

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

if M == 0:
    print(fib(N) % (10**9 + 7))
    exit()

A = [int(input()) for _ in range(M)]
L = [0] * (M+1)

ans = 1

L[0] = fib(A[0]-1) % (10**9 + 7)
L[M] = fib(N-(A[M-1]+1)) % (10**9 + 7)

for i in range(1,M):
    if A[i]-A[i-1] == 1:
        print(0)
        exit()
    L[i] = fib((A[i]-1)-(A[i-1]+1)) % (10**9 + 7)

for j in range(M+1):
    ans = (ans * L[j]) % (10**9 + 7)

print(ans)