Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from math import gcd
n=int(input())
a=list(map(int,input().split()))
x=[-1]*(10**6+5)
x[0]=0
x[1]=1
i=2
while i<=10**6+1:
    j=2*i
    if x[i]==-1:
        x[i]=i
        while j<=10**6+1:
            if x[j]==-1:x[j]=i
            j+=i
    i+=1

z=[0]*(10**6+5)

g=gcd(a[0],a[0])
for i in range(n):
    g=gcd(g,a[i])
if g!=1:
    print("not coprime")
else:
    f=0
    for i in range(n):
        p=1
        while a[i]>=2:
            if p==x[a[i]]:
                a[i]=a[i]//p
                continue
            else:
                p=x[a[i]]
                z[p]+=1
                a[i]=a[i]//p

    for i in range(10**6+1):
        if z[i]>=2:
            f=1
    print("pairwise coprime" if f==0 else "setwise coprime")


### FIXED CODE ###

from math import gcd
n=int(input())
a=list(map(int,input().split()))
x=[-1]*(10**6+5)
x[0]=0
x[1]=1
i=2
while i<=10**6+1:
    j=2*i
    if x[i]==-1:
        x[i]=i
        while j<=10**6+1:
            x[j]=i
            j+=i
    i+=1

z=[0]*(10**6+5)
def d(y):
    t=[]
    while y>=2:
        p=x[y]
        t.append(p)
        y=y//p
    t=list(set(t))
    for i in range(len(t)):
        z[t[i]]+=1
    return
g=gcd(a[0],a[0])
for i in range(n):
    g=gcd(g,a[i])
if g!=1:
    print("not coprime")
else:
    f=0
    for i in range(n):
        d(a[i])
    for i in range(10**6+1):
        if z[i]>=2:
            f=1
    print("pairwise coprime" if f==0 else "setwise coprime")
### BUGGY CODE ###

# 入力
N = int(input())
A = list(map(int,input().split()))

ans = 0
P = 10**9+7
bit = [0 for i in range(60)]

# 各bit独立に1が何個あるか数える
for i in range(N):
    S = bin(A[i])
    for j in range(1,len(S)-1):
        if S[-1*j] == '1':
            bit[j-1] += 1

# 各bitの1の個数と0の個数の積が、XOR和が1になる数字の個数と一致
for i in range(60):
    if bit[i] != 0 and bit[i] != N:
        ans += (2**i)*bit[i]*(N-bit[i])
        ans %= P

print(ans)


### FIXED CODE ###

# 入力
N = int(input())
A = list(map(int,input().split()))

ans = 0
P = 10**9+7
bit = [0 for i in range(70)]

# 各bit独立に1が何個あるか数える
for i in range(N):
    S = bin(A[i])
    for j in range(1,len(S)-1):
        if S[-1*j] == '1':
            bit[j-1] += 1

# 各bitの1の個数と0の個数の積が、XOR和が1になる数字の個数と一致
for i in range(70):
    ans += (2**i)*bit[i]*(N-bit[i])
    ans %= P

print(ans)
### BUGGY CODE ###

A,B,C=map(int,input().split())
kot=0
while C!=0:
    
    if B+A==0:
        kot+=1
        break
    else:
        C-=1
        kot+=1
        if B>0:
            B-=1
            kot+=1
        elif A>0:
            A-=1
if B>0:
    kot+=B

print(kot)


### FIXED CODE ###

A,B,C=map(int,input().split())
kot=0
"""while C!=0:

    if B+A==0:
        kot+=1
        break
    else:
        C-=1
        kot+=1
        if B>0:
            B-=1
            kot+=1
        elif A>0:
            A-=1
if B>0:
    kot+=B

print(kot)"""
if C>=B:
    kot+=B*2
    C-=B
else:
    kot+=B+C
    print(kot)
    exit()
if C-1>A:
    kot+=A+1
else:
    kot+=C
print(kot)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
D = []
for i in range(M):
  B,C = map(int, input().split())
  D.extend([C]*B)

import bisect
from collections import deque

D = sorted(D,reverse=True)
A = sorted(A)
A.extend(D[:N])
A = sorted(A,reverse=True)

print(sum(A[:N]))


### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [[] for _ in range(M)]
for i in range(M):
  BC[i] = list(map(int, input().split()))

BC.sort(key=lambda x: x[1], reverse=True)

for i in BC:
  A.extend([i[1]]*i[0])
  if len(A) > 2*N:
    break
    
A = sorted(A,reverse=True)
print(sum(A[:N]))
### BUGGY CODE ###

import sys

read = sys.stdin.read


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


N, *A = map(int, read().split())
mod = 10 ** 9 + 7

l = A[0]
g = A[0]
for i in A:
    g = gcd(l, i)
    l = l * i // g

answer = 0
for i in A:
    answer += l // i
    if answer >= mod:
        answer %= mod
print(answer)


### FIXED CODE ###

import sys
from collections import Counter

read = sys.stdin.read


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


def sieve_of_eratosthenes(n):
    sieve = [True] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i::2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
    return [2] + [i for i in range(3, n, 2) if sieve[i]]


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N, *A = map(int, read().split())
mod = 10 ** 9 + 7

primes = sieve_of_eratosthenes(max(A) + 1)
dic = {i: 0 for i in primes}

n = len(primes)
p = [0] * n
for i in A:
    tmp = Counter(prime_factorize(i))
    for key, value in tmp.items():
        #print(key, value)
        if dic[key] < value:
            dic[key] = value

lcm = 1
for i, j in dic.items():
    if j == 0:
        continue
    lcm *= pow(i, j, mod)
    lcm %= mod

answer = 0
for i in A:
    answer += lcm * pow(i, mod - 2, mod)
    answer %= mod

print(answer)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(250000)

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

nl = [[] for _ in range(N + 1)]
for a, b in [tuple(map(int, input().split())) for _ in range(N - 1)]:
    nl[a].append(b)
    nl[b].append(a)

d = [[i] for i in range(N + 1)]
seen = set()


def dfs(v, parents):
    seen.add(v)
    for p in parents:
        d[p].append(v)
    for next_v in nl[v]:
        if next_v not in seen:
            dfs(next_v, parents + [v])


dfs(1, [])
c = [0 for _ in range(N + 1)]
for p, x in [tuple(map(int, input().split())) for _ in range(Q)]:
    for v in d[p]:
        c[v] += x
print(' '.join([str(ans) for ans in c[1:]]))

### FIXED CODE ###

from collections import defaultdict

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

nl = [[] for _ in range(N + 1)]
for a, b in [tuple(map(int, input().split())) for _ in range(N - 1)]:
    nl[a].append(b)
    nl[b].append(a)
nl[0].append(1)

val = defaultdict(int)
for p, x in [tuple(map(int, input().split())) for _ in range(Q)]:
    val[p] += x

ans = [0 for _ in range(N + 1)]

stack = list()
stack.append((0, -1, 0))
while len(stack) > 0:
    v, p, cnt = stack.pop()
    cnt += val[v]
    ans[v] = cnt
    for next_v in nl[v]:
        if next_v != p:
            stack.append((next_v, v, cnt))

print(' '.join([str(a) for a in ans[1:]]))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

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

g = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

cnt = [0] * (N+1)
for i in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x

def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])

dfs(1, 0, 0)

print(' '.join(map(str, cnt[1:])))        

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
g = [[] for _ in range(N+1)]
for a,b in AB:
    g[a].append(b)
    g[b].append(a)
 
cnt = [0] * (N+1)
for p,x in PX:
    cnt[p] += x

def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])

dfs(1, 0, 0)

print(' '.join(map(str, cnt[1:])))
### BUGGY CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
mask = (1<<(k+1)) - 1
def sub(ii):
    dp = 1
    for i in range(n):
        if i==ii:
            continue
        dp |= (dp<<a[i]) & mask
#         for j in range(k-1, a[i]-1, -1):
#             dp[j] += dp[j-a[i]]
    val = max(i for i in range(k) if (dp>>i)&1)
    return val+a[ii]>=k
if sub(0):
    ans = 0
elif not sub(n-1):
    ans = n
else:
    l = 0
    r = n-1
    while l<r-1:
        m = (l+r)//2
        if sub(m):
            r = m
        else:
            l = m
    ans = l+1
print(ans)

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
a = list(map(lambda x: min(int(x), k+1), input().split()))
a.sort()
mask = (1<<(k+1)) - 1
def sub(ii):
    dp = 1
    for i in range(n):
        if i==ii:
            continue
        dp |= (dp<<a[i]) & mask
#         for j in range(k-1, a[i]-1, -1):
#             dp[j] += dp[j-a[i]]
    val = max(i for i in range(k) if (dp>>i)&1)
    return val+a[ii]>=k
if sub(0):
    ans = 0
elif not sub(n-1):
    ans = n
else:
    l = 0
    r = n-1
    while l<r-1:
        m = (l+r)//2
        if sub(m):
            r = m
        else:
            l = m
    ans = l+1
print(ans)
### BUGGY CODE ###

import statistics

N = int(input())
#N = 200000
X_list = list(map(int, input().split()))
#X_list = [i for i in range(N)]

median_idx = int(len(X_list) / 2) - 1

for idx, v in enumerate(X_list):
    X_copy = X_list.copy()
    X_copy.pop(idx)
    # median_idx = int((len(X_copy) + 1) / 2) - 1
    # print(median_idx)
    # X_copy.sort()
    print(int(statistics.median(X_copy)))


### FIXED CODE ###

N = int(input())
X_list = list(map(int, input().split()))
X_list_copy = X_list.copy()
X_list_copy.sort()

median_idx = int(N / 2)
left_num = X_list_copy[median_idx - 1]
right_num = X_list_copy[median_idx]

for x in X_list:
    if x < right_num:
        print(right_num)
    else:
        print(left_num)
### BUGGY CODE ###

N=int(input())
ls=[int(s) for s in input().split()]
ans=0
for i in range(N):
  for j in range(i,N):
    if j-i==ls[i]+ls[j]:
      ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
ls=[int(s) for s in input().split()]
dicA={}
dicB={}
for i in range(N):
  a=i+ls[i]
  if a in dicA:
    dicA[a]+=1
  else:
    dicA[a]=1
  b=i-ls[i]
  if b in dicB:
    dicB[b]+=1
  else:
    dicB[b]=1
ans=0
for a,na in dicA.items():
  if a in dicB:
    ans+=na*dicB[a]
print(ans)
### BUGGY CODE ###

def main():

    S = input()
    Q = int(input())
    count = 0
    left = ""
    right = ""
    for _ in range(Q):
        U = input()
        if len(U) == 1:
            count += 1
            left, right = right[::-1], left[::-1]
        else:
            _, F, C = U.split()
            F = int(F)
            if F == 1:
                left = C + left
            else:
                right = right + C

    if count % 2 == 1:
        S = S[::-1]
    return left + S + right

if __name__ == '__main__':
    print(main())


### FIXED CODE ###

def main():
    S = input()
    Q = int(input())
    count = 0
    A = []
    B = []
    for _ in range(Q):
        U = input()
        if len(U) == 1:
            count += 1
        else:
            _, F, C = U.split()
            F = int(F)
            if F == 1:
                if count % 2 == 0:
                    A.append(C)
                else:
                    B.append(C)
            else:
                if count % 2 == 0:
                    B.append(C)
                else:
                    A.append(C)

    if count % 2 == 0:
        A = A[::-1]
        return "".join(A) + S + "".join(B)
    else:
        B = B[::-1]
        return "".join(B) + S[::-1] + "".join(A)
        
if __name__ == '__main__':
    print(main())
### BUGGY CODE ###

import math
def gcd3(a, b, c):
    return math.gcd(math.gcd(a, b), c)

n = int(input())

ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            ans += gcd3(i, j, k)

print(ans)


### FIXED CODE ###

import math

sets = dict()

def gcd2(a, b):
    if a > b:
        key = (b, a)
    else:
        key = (a, b)
    
    try:
        # print("cached")
        return sets[key]
    except:
        # print("stored")
        ans = math.gcd(a, b)
        sets[key] = ans
        return ans

n = int(input())

ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        pre = gcd2(i, j)

        for k in range(1, n+1):
            ans += gcd2(pre, k)

print(ans)
### BUGGY CODE ###

while 1:
	try:
		list = str(raw_input()).split()
		x = int(list[0]) + int(list[1])
		print "%d" % len(str(x))

	except:
		print"hoge"

### FIXED CODE ###

while 1:
	try:
		list = str(raw_input()).split()
		x = int(list[0]) + int(list[1])
		print "%d" % len(str(x))

	except:
		break
### BUGGY CODE ###

from collections import deque
s = deque(input())
q = int(input())
work = deque()
workappendleft = work.appendleft
appendleft=s.appendleft
append=s.append
for i in range(q):
    temp = input().split()
    t = temp[0]
    if t == "1":
        for el in s:
            workappendleft(el)
        s.clear()
        for el in work:
            append(el)
        work.clear()
    else:
        f = temp[1]
        c = temp[2]
        if f == "1":
            appendleft(c)
        else:
            append(c)
print("".join(list(s)))

### FIXED CODE ###

from collections import deque
def main():
    s = deque(input())
    q = int(input())
    appendleft=s.appendleft
    append=s.append
    flag = False
    for i in range(q):
        temp = input().split()
        if temp[0] == "1":
            flag = not flag
        else:
            if temp[1] == "1":
                if flag:
                    append(temp[2])
                else:
                    appendleft(temp[2])
            else:
                if flag:
                    appendleft(temp[2])
                else:
                    append(temp[2])
    if flag:
        s.reverse()
    print("".join(list(s)))
if __name__=="__main__":
    main()
### BUGGY CODE ###

N = int(input())

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

import numpy as np

B_list = A_list.copy()

A_list = [np.max(A_list[0:i+1]) for i in range(1, len(A_list)) ]

A_list = [B_list[0]] + A_list

A_array = np.array(A_list)
B_array = np.array(B_list)

print(np.sum(A_array - B_array))   

### FIXED CODE ###

N = int(input())

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

import numpy as np

B_list = A_list.copy()

for i in range(1, len(A_list)):
    if A_list[i] < A_list[i-1]:
        A_list[i] = A_list[i-1]
        
A_array = np.array(A_list)
B_array = np.array(B_list)

print(np.sum(A_array - B_array))
### BUGGY CODE ###

s =str(input())
n = len(s)
ls = [1]*n
for _ in range(2*n):
    new = [0]*n
    for i in range(n):
        if i == 0:
            if s[1] == "L":
                new[0] = ls[1]
        elif i == n-1:
            if s[n-2] == "R":
                new[n-1] = ls[n-2]
        else:
            if s[i-1] == "R":
                new[i] += ls[i-1]
            if s[i+1] == "L":
                new[i] += ls[i+1]
    ls = new
print(*ls)

### FIXED CODE ###

s = str(input())
ls = [0]*len(s)
r = 0
l = 0
ind = 0
if s[0] == "R":
    r = 1
else:
    l = 1
for i in range(1,len(s)):
    if s[i-1] == "L" and s[i] == "R":
        ls[ind] = (l - l//2) + r//2
        if ind > 0:
            ls[ind-1] = (r - r//2) + l//2
        l = 0
        r = 1
    elif s[i-1] == "R" and s[i] == "L":
        ind = i
        l += 1
    else:
        if i == len(s)-1:
            if s[i] == "L":
                l += 1
                ls[ind] = (l - l//2) + r//2
                if ind > 0:
                    ls[ind-1] = (r - r//2) + l//2
                r = 0
                l = 0
            else:
                r += 1
                ls[-1] = r
                r = 0
        else:
            if s[i] == "R":
                r += 1
            else:
                l += 1
if r != 0 and l != 0:
    ls[ind] = (l - l//2) + r//2
    if ind > 0:
        ls[ind-1] = (r - r//2) + l//2
elif r != 0:
    ls[-1] = r
print(*ls)
### BUGGY CODE ###

N=int(input())
res = 0
for i in range(1,N+1):
  if i == N:
    res += 0
  else:
    res += i%(i+1)
print(res)

### FIXED CODE ###

N=int(input())
n=N-1
res = n*(n+1)//2
print(res)
### BUGGY CODE ###

n = int(input())
sn = 0
while n>9:
  sn += n%10
  n = n//10
if (sn+n)%9==0:
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

n = input()
sn = 0
ln = len(n)
for i in range(ln):
  sn += int(n[i])
if sn%9==0:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

import numpy as np

n, nt = map(int, input().split())
ms = np.array(list(sorted(map(int, input().split()))))
fs = np.array(list(reversed(sorted(map(int, input().split())))))

for i in range(nt):
  idx = np.argmax(ms*fs)
  if ms[idx] < 1:
    break
  ms[idx] -= 1

print(np.max(ms*fs))

### FIXED CODE ###

import numpy as np
N, train_max = map(int, input().split())
members = np.sort(list(map(int, input().split())))
members_sum = members.sum()
foods = np.sort(list(map(int, input().split())))[::-1]

inferenced_time_max = int(1e+6 * 1e+6)
inferenced_time_min = -1

while inferenced_time_max > inferenced_time_min+1:
  inferenced_time = (inferenced_time_max + inferenced_time_min) // 2
  inferenced_members = np.minimum(members, inferenced_time // foods)
  if members_sum - inferenced_members.sum() <= train_max:
    inferenced_time_max = inferenced_time
  else:
    inferenced_time_min = inferenced_time

print(inferenced_time_max)
### BUGGY CODE ###

from collections import Counter

s = input()
t = input()
q = int(input())

for i in range(q):
    a, b, c, d = map(int, input().split())
    s_check = s[(a - 1):(b)]
    t_check = t[(c - 1):(d)]
    s_counts = Counter(s_check)
    t_counts = Counter(t_check)
    s_score = (s_counts['A'] * 1 + s_counts['B'] * 2) % 3
    t_score = (t_counts['A'] * 1 + t_counts['B'] * 2) % 3
    print('YES' if s_score == t_score else 'NO')

### FIXED CODE ###

s = input()
t = input()
q = int(input())

ss, tt = [0], [0]
for i in range(len(s)):
    ss.append(ss[i] + (1 if s[i] == 'A' else 2))
for i in range(len(t)):
    tt.append(tt[i] + (1 if t[i] == 'A' else 2))

for i in range(q):
    a, b, c, d = map(int, input().split())
    s_score = (ss[b] - ss[a-1]) % 3
    t_score = (tt[d] - tt[c-1]) % 3
    print('YES' if s_score == t_score else 'NO')
### BUGGY CODE ###

n = int(input())
a_list = [int(input()) for i in range(n)]
for i in range(n):
    dum = a_list[i]
    a_list[i] = 0
    print(max(a_list))
    a_list[i] = dum


### FIXED CODE ###

n = int(input())
a_list = [int(input()) for i in range(n)]
a_list_sort = sorted(a_list)
a_list_max1 = max(a_list)
a_list_max2 = a_list_sort[-2]
for i in range(n):
    if a_list_max1 == a_list[i]:
        print(a_list_max2)
    else:
        print(a_list_max1)
### BUGGY CODE ###

H, W = map(int, input().split())
CH, CW = map(int, input().split())
DH, DW = map(int, input().split())
S = [list(input()) for i in range(H)]

from collections import deque

q = deque([(CH-1, CW-1)])

directions = [(1, 0), (-1, 0), (0, 1), (0, -1)]
warp = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (0, -2), (0, 2), (1, -2), (1, -1), (1, 1), (1, 2), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)]

M = []
for i in range(H):
    M.append([float('inf')] * W)
M[CH-1][CW-1] = 0

while q:
    h, w = q.popleft()
    for dh, dw in directions:
        if 0 <= h+dh < H and 0 <= w+dw < W and S[h+dh][w+dw] == ".":
            if M[h+dh][w+dw] > M[h][w]:
                M[h+dh][w+dw] = M[h][w]
                q.append((h+dh, w+dw))
    for wh, ww in warp:
        if 0 <= h+wh < H and 0 <= w+ww < W and S[h+wh][w+ww] == ".":
            if M[h+wh][w+ww] > M[h][w] + 1:
                M[h+wh][w+ww] = M[h][w] + 1
                q.append((h+wh, w+ww))

if M[DH-1][DW-1] == float('inf'):
    print(-1)
else:
    print(M[DH-1][DW-1])



### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

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

H, W = map(int, input().split())
CH, CW = map(int, input().split())
DH, DW = map(int, input().split())
S = [list(input()) for i in range(H)]
 
from collections import deque
 
q = deque([(CH-1, CW-1)])
 
directions = [(1, 0), (-1, 0), (0, 1), (0, -1)]
warp = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),
        (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2),
        (0, -2), (0, -1), (0, 1), (0, 2), 
        (1, -2), (1, -1), (1, 0), (1, 1), (1, 2),
        (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            S[i][j] = 10**7
S[CH-1][CW-1] = 0

while q:
    h, w = q.popleft()
    for wh, ww in warp:
        if 0 <= h+wh < H and 0 <= w+ww < W and S[h+wh][w+ww] != "#":
            if (wh, ww) in directions:
                if S[h+wh][w+ww] > S[h][w]:
                    S[h+wh][w+ww] = S[h][w]
                    q.appendleft((h+wh, w+ww))
            else:
                if S[h+wh][w+ww] > S[h][w] + 1:
                    S[h+wh][w+ww] = S[h][w] + 1
                    q.append((h+wh, w+ww))

if S[DH-1][DW-1] == 10**7:
    print(-1)
else:
    print(S[DH-1][DW-1])
### BUGGY CODE ###

S=input()
N=len(S)
a=""
b=""
c="01"
for i in range(N):
    a+=str(c[i%2])
    b+=str(c[(i+1)%2])

ans_a=0
ans_b=0


for i in range(N):
    if a[i]!=S[i]:
        ans_a+=1
    if b[i]!=S[i]:
        ans_b+=1
        
print(min(ans_a,ans_b))

### FIXED CODE ###

S=input()
N=len(S)
a=[]
b=[]
c=[0,1]
for i in range(N):
    a.append(c[i%2])
    b.append(c[(i+1)%2])

ans_a=0
ans_b=0


for i in range(N):
    s=int(S[i])
    if a[i]!=s:
        ans_a+=1
    if b[i]!=s:
        ans_b+=1
        
print(min(ans_a,ans_b))
### BUGGY CODE ###

x, n = map(int,input().split())
lst = set(map(int,input().split()))
df = 0
while True:
    if not (x + df) in lst: print(x + df)
    df = -df
    if not (x + df) in lst: print(x + df)
    df = -df
    df += 1

### FIXED CODE ###

x, n = map(int,input().split())
lst = set(map(int,input().split()))
df = 0
while True:
    if not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    if not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    df -= 1
### BUGGY CODE ###

N = int(input()) 
A = list(map(int, input().split()))
Q = int(input()) 
for i in range(Q):
    b, c = map(str, input().split())
    if int(b) in A:
        A = [int(str(a).replace(b, c)) for a in A]
    print(sum(A))

### FIXED CODE ###

#!/usr/bin/env python3
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
d = Counter(A)
Q = int(input())
ans = sum(A)
for i in range(Q):
    b, c = map(int, input().split())
    ans += (c-b) * d[b]
    d[c] += d[b]
    d[b] = 0
    print(ans)
### BUGGY CODE ###

from queue import deque

N, Q = map(int, input().split())
 
AB = []
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    AB.append((a, b))
    graph[a].append(b)
    graph[b].append(a)
AB = sorted(AB, key=lambda x: (x[1], x[0]))
 
root = 0
q = deque([root])
parent = [-1] * N
while q:
    x = q.popleft()
    p = parent[x]
    for y in graph[x]:
        if y == p:
            continue
        parent[y] = x
        q.append(y)

C = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    p = p - 1
    C[p] += x

for a, b in AB:
    if a != parent[b]:
        tmp = a
        a = b
        b = tmp
    C[b] += C[a]

print(*C)

### FIXED CODE ###

from queue import deque


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

graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    graph[a].append(b)
    graph[b].append(a)

C = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    C[p - 1] += x

P = [-1] * N

root = 0
q = deque([root])
while q:
    x = q.popleft()
    for y in graph[x]:
        if y == P[x]:
            continue
        C[y] += C[x]
        q.append(y)
        P[y] = x

print(*C)