Harryxun/stf_run huggingface dataset:
# print('input >>')
N, M = map(int,(input().split()))
ABs = [map(int,(input().split())) for _ in range(M)]

INF = 10 ** 10
ds = [0] * (N+1)
marks = [0] * (N+1)

nodes = [None] * (N+1)

for AB in ABs:
    A, B = AB
    if nodes[A] is None:
        nodes[A] = []
    nodes[A].append(B)

    B, A = A, B
    if nodes[A] is None:
        nodes[A] = []
    nodes[A].append(B)

# print(nodes)

checked = [0] * (N+1) 

def dfs(cur, parent, children):
    # print(parent, children)
    if checked[parent] == 1:
        return
    checked[parent] = 1
    for child in children:
        # print(cur, ds)
        if marks[child] == 0 or ds[child] > cur:
            marks[child] = parent
            ds[child] = cur
            # print(marks)
        # if not checked[child] == 0:
        dfs(cur+1, child, nodes[child])

dfs(0, 1, nodes[1])

# print('-----output-----')
print('Yes')
for mark in marks[2:]:
    print(mark)

"""
7 7
1 2
2 5
5 7
3 1
7 3
6 1
2 4
"""

### FIXED CODE ###

from collections import deque

# print('input >>')
N, M = map(int,(input().split()))
ABs = [map(int,(input().split())) for _ in range(M)]

INF = 10 ** 10
ds = [INF] * (N+1)
marks = [0] * (N+1)

nodes = [None] * (N+1)

for AB in ABs:
    A, B = AB
    if nodes[A] is None:
        nodes[A] = []
    nodes[A].append(B)

    B, A = A, B
    if nodes[A] is None:
        nodes[A] = []
    nodes[A].append(B)

# print(nodes)

queue = deque([1])
visited = [0] * (N+1)
visited[1] = 1

# d = 0
# ds = [INF] * (N+1)
marks = [0] * (N+1)
parent = 1

while len(queue) > 0:
    p = queue.popleft()
    # print(p)
    # parent, node = p[0], p[1]
    # visited[node] = 1
    # marks[node] = parent
    for n in nodes[p]:
        if visited[n] == 0:
            visited[n] = 1
            marks[n] = p
            queue.append(n)

print('Yes')
for mark in marks[2:]:
    print(mark)
K, S = map(int, input().split())

result = 0

for x in range(K + 1):
    for y in range(K + 1):
        Z = S - X - Y
        if 0 <= Z and  Z <= K:
            result += 1

print(result)

### FIXED CODE ###

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

result = 0

for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            result += 1

print(result)
N, K = map(int, input().split())
A = list(map(int, input().split()))

zero = [0] * 50
one = [0] * 50

for a in A:
  for d in range(40):
    r = a % 2
    if r:
      one[d] += 1
    else:
      zero[d] += 1
    a = int(a / 2)

k = [0] * 40
d = 0
while K:
  r = K % 2
  if r:
    k[d] = 1
  K = int(K / 2)
  d += 1

d_tmp = d - 1
d = 49
flag = 0
max = 0
while d >= 0:
  if flag == 0 and k[d] == 0:
    max += one[d] * pow(2, d)
  else:
    if zero[d] >= one[d]:
      max += zero[d] * pow(2, d)
      if k[d]:
        flag = 1
    else:
      max += one[d] * pow(2, d)
  d -= 1

print(max)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))

zero = [0] * 50
one = [0] * 50

for a in A:
  for d in range(40):
    r = a % 2
    if r:
      one[d] += 1
    else:
      zero[d] += 1
    a = int(a / 2)

k = [0] * 50
d = 0
while K:
  r = K % 2
  if r:
    k[d] = 1
  K = int(K / 2)
  d += 1

d = 49
flag = 0
max = 0
while d >= 0:
  if flag == 0:
    if k[d] == 0:
      max += one[d] * pow(2, d)
    else:
      if zero[d] >= one[d]:
        max += zero[d] * pow(2, d)
      else:
        max += one[d] * pow(2, d)
        flag = 1
  else:
    if zero[d] >= one[d]:
      max += zero[d] * pow(2, d)
    else:
      max += one[d] * pow(2, d)
  d -= 1

print(max)
n, m, x = map(int, input().split())
l = [int(input()) for _ in range(m)]
left = 0
right = 0
i = 0
while i < x:
    if i in l:
        left += 1
    i += 1
j = n-1
while j > x+1:
    if j in l:
        right += 1
    j -= 1

print(max(left, right))

### FIXED CODE ###

n, m, x = map(int, input().split())
l = list(map(int, input().split()))
left = 0
right = 0
i = 0
while i < x:
    if i in l:
        left += 1
    i += 1
j = n-1
while j > x:
    if j in l:
        right += 1
    j -= 1

print(min(left, right))
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())

b = set(int(input() for _ in range(n)))

def check():
    for i in range(3):
        if all(a[i][j] in b for j in range(3)):
            return True
        if all(a[j][i] in b for j in range(3)):
            return True
    return all(a[i][i] in b for i in range(3)) or all(a[2-i][i] in b for i in range(3))

print('Yes' if check() else 'No')

### FIXED CODE ###

grid = list(list(map(int,input().split())) for _ in range(3))

N = int(input())

S = set(int(input()) for _ in range(N))

def check():
    for i in range(3):
        if all(grid[i][j] in S for j in range(3)):
            return True
        if all(grid[j][i] in S for j in range(3)):
            return True
    return all(grid[i][i] in S for i in range(3)) or all(grid[2-i][i] in S for i in range(3))

print('Yes' if check() else 'No')
import itertools
N = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
X = itertools.permutations(range(1, N+1))
a = X.index(A)
b = X.index(B)
print(abs(a-b))

### FIXED CODE ###

import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
A = [i for i in range(1, N+1)]
B = list(itertools.permutations(A))
ans = abs(B.index(P)-B.index(Q))
print(ans)
n = input()
A = list(map(int, input().split()))

N = int(input())
ans = ''
for i in range(1, 99):
    if N <= 26 ** i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N % 26)
            N //= 26
        break
    else:
        N -= 26 ** i
print(ans[::-1]) 

### FIXED CODE ###

N = int(input())
ans = ''
for i in range(1, 99):
    if N <= 26 ** i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N % 26)
            N //= 26
        break
    else:
        N -= 26 ** i
print(ans[::-1])
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse.csgraph import dijkstra
n,m=map(int,input().split())
dis=[[float('inf') for i in range(n)]for j in range(n)]
for i in range(n):
    dis[i][i]=0
for i in range(m):
    a,b,t=map(int,input().split())
    dis[a-1][b-1]=t
    dis[b-1][a-1]=t
cost=dijkstra(dis,directed=False,unweighted=False)
cnt=0
for i,j,k in dis:
    if k>costs[i-1][j-1]:
        cnt+=1
print(cnt)


### FIXED CODE ###

cnt=0
n,m=map(int,input().split())
dis=[[float('inf') for i in range(n)]for j in range(n)]
tmp=[]
for i in range(m):
    tmp.append(list(map(int,input().split())))
for a,b,t in tmp:
    dis[a-1][b-1]=t
    dis[b-1][a-1]=t
for k in range(n):
    for i in range(n):
        for j in range(n):
            dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j])
for a,b,t in tmp:
    if t>dis[a-1][b-1]:
        cnt+=1
print(cnt)
from collections import deque
import sys
from numba import njit

read = sys.stdin.read
readline = sys.stdin.readline

@njit
def solve():
  H,W = map(int,input().split())
  C_h,C_w = map(lambda x:int(x)-1,input().split())
  D_h,D_w = map(lambda x:int(x)-1,input().split())
  S = [readline() for _ in range(H)]

  INF = int(1e7)
  dist = [[INF]*(W) for _ in range(H)]
  dist[C_h][C_w] = 0
  seen = [[False]*(W) for _ in range(H)]
  deq = deque()
  deq.append((C_h,C_w))

  move_a = [(1, 0), (0, 1), (-1, 0), (0, -1)]
  move_b = [(-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)]

  while len(deq):
    h,w = deq.popleft()
    if seen[h][w]:
      continue
      seen[h][w] = True
    for dh,dw in move_a:
      nh,nw = h+dh,w+dw
      if nh>=0 and nw>=0 and nh<H and nw<W and S[nh][nw]!='#' and dist[nh][nw] > dist[h][w]:
        dist[nh][nw] = dist[h][w]
        deq.appendleft((nh,nw))
    for dh,dw in move_b:
      nh,nw = h+dh,w+dw
      if nh>=0 and nw>=0 and nh<H and nw<W and S[nh][nw]!='#' and dist[nh][nw] > dist[h][w]+1:
        dist[nh][nw] = dist[h][w]+1
        deq.append((nh,nw))

  print(dist[D_h][D_w] if dist[D_h][D_w]<INF else -1)

solve()

### FIXED CODE ###

from collections import deque

H,W = map(int,input().split())
C_h,C_w = map(lambda x:int(x)-1,input().split())
D_h,D_w = map(lambda x:int(x)-1,input().split())
S = [input() for _ in range(H)]

INF = int(1e10)
dist = [[INF]*(W) for _ in range(H)]
deq = deque()
deq.append((C_h,C_w,0))

move_a = [(1,0),(0,1),(-1,0),(0,-1)]
move_b = [(i,j)for i in range(-2,2+1) for j in range(-2,2+1) if abs(i)+abs(j)>=2]

while len(deq):
  h,w,c = deq.popleft()
  if dist[h][w] <= c:
    continue
  dist[h][w] = c
  for dh,dw in move_a:
    nh,nw = h+dh,w+dw
    if nh<0 or nw<0 or nh>=H or nw>=W:
      continue
    if S[nh][nw] == '#':
      continue
    if dist[nh][nw] > c:
      deq.appendleft((nh,nw,c))
  for dh,dw in move_b:
    nh,nw = h+dh,w+dw
    if nh<0 or nw<0 or nh>=H or nw>=W:
      continue
    if S[nh][nw] == '#':
      continue
    if dist[nh][nw] > c+1:
      deq.append((nh,nw,c+1))
  
print(dist[D_h][D_w] if dist[D_h][D_w]<INF else -1)
n=int(input())
l=list(map(int, input().split()))
d={}
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      a,b,c = l[i],l[j],l[k]
      if d[(a,b,c)]: continue
      d[(a,b,c)]=1
      ans+=max(a,b,c)<(b+c+a-max(a,b,c))
print(ans)

### FIXED CODE ###

n=int(input())
l=list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      a,b,c = l[i],l[j],l[k]
      if a != b and b != c and a != c:
        ans+=max(a,b,c)<(b+c+a-max(a,b,c))
print(ans)
tmp = input()
N = int(input().split()[0])
M = int(input().split()[1])
C = int(input().split()[2])
tmp = input()
B = [int(b) for b in tmp.split()]
cnt = 0
for i in range(N):
  tmp = input()
  A = [int(a) for a in tmp.split()]
  sum = 0
  for j in range(M):
    sum += B[j]*A[j]
  sum += C
  if C > 0:
    cnt += 1
print(cnt)


### FIXED CODE ###

tmp = input()
N = int(tmp.split(' ')[0])
M = int(tmp.split(' ')[1])
C = int(tmp.split(' ')[2])
B = [int(b) for b in input().split(' ')]
cnt = 0
for i in range(N):
  A = [int(a) for a in input().split(' ')]
  sum = C
  for j in range(M):
    sum += B[j]*A[j]
  if sum > 0:
    cnt += 1
print(cnt)
from collections import deque
import sys

def my_bfs(field, R, C):
    sy, sx = 1, 1
    gy, gx = R, C
    dxy = [(0,1), (0,-1), (1,0), (-1,0)]
    flg = False
    cnt = 0
    dot_num = sum(r.count('.') for r in field)

    q = deque()
    q.append([sy, sx])
    field[sy][sx] = 0
    while flg == False:
        yx = q.popleft()
        cnt = field[yx[0]][yx[1]]
        for dy, dx in dxy:
            y_n, x_n = yx[0] + dy, yx[1] + dx
            if y_n == gy and x_n == gx:
                field[y_n][x_n] = cnt + 1
                flg = True
                return(dot_num - (cnt+2))
                break
            if field[y_n][x_n] == '#':
                continue
            if field[y_n][x_n] == '.':
                q.append([y_n, x_n])
                field[y_n][x_n] = cnt + 1
        if flg:
            break
    else:
        return(-1)

sys.setrecursionlimit(10**6)

R, C = map(int, input().split())
field = [["#"] * (C + 2)] + \
        [list("#" + input() + "#") for i in range(R)] + \
        [["#"] * (C + 2)]

out = my_bfs(field, R, C)
print(out)

### FIXED CODE ###

from collections import deque
 
 
def dfs(field):
    q = deque([(0, 0, 0)])
    visited = [[False] * w for _ in range(h)]
    while q:
        i, j, d = q.popleft()
        if i == h - 1 and j == w - 1:
            return d
        if visited[i][j]:
            continue
        visited[i][j] = True
        if i > 0 and field[i - 1][j] == '.':
            q.append((i - 1, j, d + 1))
        if i < h - 1 and field[i + 1][j] == '.':
            q.append((i + 1, j, d + 1))
        if j > 0 and field[i][j - 1] == '.':
            q.append((i, j - 1, d + 1))
        if j < w - 1 and field[i][j + 1] == '.':
            q.append((i, j + 1, d + 1))
    else:
        return -1
 
 
h, w = map(int, input().split())
field = [input() for _ in range(h)]
dot_cnt = sum(r.count('.') for r in field)
d = dfs(field)
if d == -1:
    print(-1)
else:
    print(dot_cnt - (d+1))
N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=0
for i in range(K+1):
    j=K-i
    a=V[:i]
    b=V[N-j:]
    ans=max(ans,sum(a)+sum(b))
    k=sum(a)+sum(b)
    c=a+b
    c.sort(reverse=True)
    W=K
    W-=2
    while(W>0):
        if c==[]:
            break
        t=c.pop()
        if t in a:
            a.remove(t)
        else:
            b.remove(t)
        if a!=[] and b!=[] :
            if a[-1]<=b[0]:
                h=a.pop(-1)
            else:
                h=b.pop(0)
        elif a!=[] and b==[]:
            h=a.pop(-1)
        elif b!=[] and a==[]:
            h=b.pop(0)
        else:
            break
        k=k-t-h
        ans=max(k,ans)
        W-=2
print(ans)


### FIXED CODE ###

N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=0

for i in range(1,N+1):#何個取るか
    if i>K:
        break
    for r in range(i+1):

        l=i-r
        a=V[:r]
        b=V[N-l:]
        f=max(0,K-i)
        c=a+b
        c.sort()
        k=0
        t=0
        for j in c:
            if t<f and j<0:
                t+=1
                continue
            k+=j
        ans=max(ans,k)
print(ans)
import sys

def main(lines):
	n, r = lines[0].split()
    if n >= 10:
      print(r)
    else:
      print(n + 100*(10-n))
    return
    
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)


### FIXED CODE ###

import sys

def main(lines):
  n, r = map(int,lines[0].split())

  if n >= 10:
    print(r)
  else:
    print(r + 100*(10-n))
  return
    
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)
def calculate_happiness(S: str, N: int) -> int:
  if N == 1:
    return 0
  happiness = 0
  if S[0] == S[1] == 'R':
    happiness += 1
  if S[-1] == S[-2] == 'L':
    happiness += 1
  for i in range(1, N-1):
    if S[i] == S[i+1] == 'R':
      happiness += 1
    elif S[i] == S[i-1] == 'L':
      happiness += 1
  return happiness

def change_string(S: str, l: int, r: int) -> str:
  part = S[l:r+1][::-1].replace('R', '_')
  part = part.replace('L', 'R').replace('_', 'L')
  return S[:l] + part + S[r+1:]

N, K = list(map(int, input().split()))
S = input()
happiness = calculate_happiness(S, N)
opt_S = S
opt_happiness = happpiness
for k in range(K):
  S = opt_S
  for l in range(N-1):
    for r in range(l+1:N):
      new_S = change_string(S, l, r)
      happiness = calculate_happiness(new_S, N)
      if happiness > opt_happiness:
        opt_S = new_S
        opt_happiness = happiness
return(opt_happiness)

### FIXED CODE ###

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

happy = 0
for i in range(N-1):
  if S[i] == S[i+1]:
    happy += 1
print(min([N-1, happy + 2 * K]))
n = int(input())
for i in range(n):
	if(int(i * 1.08) == n):
      print(i)
      exit()
print(":(")

### FIXED CODE ###

n = int(input())
for i in range(1,n+1):
  if(int(i*1.08) == n):
    print(i)
    exit()
print(":(")
input()
A=list(map(int,input().split()))
d,c,s=0,0,A[0]
for x in A[1:]:
 if x-s<d:
  d,c=x-s,c
 elif x-s==d:
  c+=1
 s=min(s,x)
print(c)

### FIXED CODE ###

print((lambda x:"Yes" if max(x)*2==sum(x) else "No")(list(map(int,input().split()))))
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, m = MAP()
arr = [[] for _ in range(n)]
for _ in range(m):
    s, c = MAP()
    arr[s - 1].append(c)
tmp1 = [len(set(arr[i])) for i in range(n)]
tmp2 = Counter(tmp1)
if tmp2[0] + tmp2[1] != n or (arr[0][0] == 0 and n != 0):
    print(-1)
    exit()
tmp3 = [str(arr[i][0]) if tmp1[i] else '0' for i in range(n)]
if tmp3[0] == '0' and n > 1:
    tmp3[0] = '1'
print(''.join(tmp3))


### FIXED CODE ###

n,m = map(int,input().split())
d = [0 for _ in range(n)]
d[0] = 1
sarr = []
if m == 0 and n == 1:
    d[0] = 0
for i in range(m):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and not n == 1:
        print(-1)
        exit()
    if s in sarr and c != d[s-1]:
        print(-1)
        exit()
    d[s-1] = c
    sarr.append(s)
    #print(sarr)
    #print(d)
ans = ''
for i in range(n):
    ans += str(d[i])
print(ans)
N, K = map(int, input().split())

ans = K
for i in range(N-1):
  K *= (k-1)
  
print(ans)

### FIXED CODE ###

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

ans = K
for i in range(N-1):
  ans *= (K-1)
  
print(ans)
from __future__ import print_function
n = int(input())
s = input()

s = s.rstrip('#')
s = s.lstrip('.')

if len(set(s)) <= 1:
    print(0)
    exit(0)

print(min(s.count('#'), s.count('.')))

### FIXED CODE ###

def seek(n, s):
    s = s.rstrip('#').lstrip('.')
    turn_to_black = s.count('.')
    current_min = turn_to_black
    turn_to_white = 0

    if current_min == 0 or current_min == len(s):
        return 0

    # seek minimum turns to create "^\.*#*$"
    for i in range(len(s)):
        if s[i] == '#':
            turn_to_white += 1
        else:
            turn_to_black -= 1
        current_min = min(current_min, turn_to_black + turn_to_white)
    return current_min


def input_from_console():
    n = int(input())
    s = input()
    return n, s


def main():
    n, s = input_from_console()
    print(seek(n, s))
    

if __name__ == "__main__":
    main()
import math

n, m = map(int, input().split())
item_price = list(map(int, input().split()))
# n, m = (4, 4)
# item_price = [1, 9, 3, 5]
item_price.sort(reverse=True)
devided_two_price = [math.ceil(math.log2(i)) for i in item_price]
use_ticket_list = [0] * n
print(devided_two_price)
sum = 0

x = 0
for i in range(m):
    if devided_two_price[x] == 2:
        x += 1
        use_ticket_list[x] += 1
        devided_two_price[x] -= 1
    elif devided_two_price[x] >= devided_two_price[x+1]:
        use_ticket_list[x] += 1
        devided_two_price[x] -= 1
    else:
        x += 1
        use_ticket_list[x] += 1
        devided_two_price[x] -= 1

print(devided_two_price)
print(use_ticket_list)

for i in range(n):
    sum += item_price[i] // (2**use_ticket_list[i])

print(sum)

### FIXED CODE ###

from heapq import heappush, heappop, heapify
import math

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

item_price_list = list(map(lambda x: x*(-1), item_price_list))
heapify(item_price_list)
for i in range(m):
    a = heappop(item_price_list)
    heappush(item_price_list, math.ceil(a/2))
    
print((-1)*sum(item_price_list))
while True:
    H, W =[int(i) for i in input().split ]
    if H == W == 0:
       break

   for h in range(H):
        for w in range(W):
            if h == 0 or h == h -1 or w == 0 or w == W - 1:
               print('#', end='')
            else:
                print('*', end='')

        print()

    print()

### FIXED CODE ###

while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break
     
    for h in range(H):
        for w in range(W):
            if h == 0 or h == H-1 or w == 0 or w == W - 1:
                print('#', end='')
            else:
                print('.', end='')
        print()
     
    print()
a,b,k=map(int,input().split())
if a==k:
  print('0',b)

elif a+b<=k:
  print('0','0')

  elif a>k:
  print(a-k,b)
  
else:
  print('0',b+a-k)
  
  
  


### FIXED CODE ###

a,b,k=map(int,input().split())
if a>=k:
  print(a-k,b)
  
else:
  print(0,max(0,a+b-k))
a=input().split()
if a[0]==a[1] and a[1]==a[2] and a[2]!=a[3]:
    print("Yes")
elif a[3]==a[1] and a[1]==a[2] and a[1]!=a[0]:
    print("Yes")
else:
    print("No")
    

### FIXED CODE ###

a=input()
if a[0]==a[1] and a[1]==a[2]:
    print("Yes")
elif a[3]==a[1] and a[1]==a[2]:
    print("Yes")
else:
    print("No")
S = input()
K = int(input())

if len(S) == 1:
    ans = S[0]
else:
    for i in S:
        if not i == "1":
            ans = i
            break
print(ans)

### FIXED CODE ###

S = input()
K = int(input())

ans = 1
count = 0

if len(S) == 1:
    ans = S[0]
else:
    for i in S:
        if i == "1":
            count += 1
        if not i == "1":
            if K > count:
                ans = i
                break
            else:
                ans = 1
print(ans)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())

    answer = sum(A)
    numNumberList = [0] * 100000
        
    for i in range(Q):
        B, C = list(map(int, input().split()))
        answer = answer + (int(C) - int(B)) * numNumberList[B]

        numNumberList[C] = numNumberList[C] + numNumberList[B]
        numNumberList[B] = 0

        print(answer)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())

    answer = sum(A)
    setA = set(A)
    numNumberList = [0] * 100001

    for Ai in A:
        numNumberList[Ai] = numNumberList[Ai] + 1    

    for i in range(Q):
        B, C = list(map(int, sys.stdin.readline().split()))
        answer = answer + (int(C) - int(B)) * numNumberList[B]

        numNumberList[C] = numNumberList[C] + numNumberList[B]
        numNumberList[B] = 0

        print(answer)

if __name__ == "__main__":
    main()
N, _ = (int(i) for i in input().split())
data = [int(int(i) for i in input().split()) for i in range(N)]

import numpy as np
from scipy.spatial import distance

distance = distance.cdist(data, data, metric='euclidean')
count = 0
for n in range(0,N):
  for d in range(n+1,N):
    if distance[n][d].is_integer() and distance[n][d] != 0 :
      count+=1
print(count)

### FIXED CODE ###

N, _ = (int(i) for i in input().split())
data = [[int(i) for i in input().split()] for i in range(N)]

import numpy as np
from scipy.spatial import distance

distance = distance.cdist(data, data, metric='euclidean')
count = 0
for n in range(0,N):
  for d in range(n+1,N):
    if distance[n][d].is_integer() and distance[n][d] != 0 :
      count+=1
print(count)
N,K = map(int, input().split())
 
nlist = [i for i in range(1,N+1)]
 
for i in range(N):
  d = int(input())
  A = list(map(int, input().split()))
  nlist = [a for a in A if a not in nlist]
print(len(nlist))

### FIXED CODE ###

N,K = map(int, input().split())
 
nlist = [i for i in range(1,N+1)]
 
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    if a in nlist:
      nlist.remove(a)
print(len(nlist))
N = int(input())
S = list(input())

import numpy as np

r = (np.array(S) == "R").sum()
g = (np.array(S) == "G").sum()
b = (np.array(S) == "B").sum()

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

### FIXED CODE ###

N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)
import sympy

N = int(input())

output = 0

for i in range(1, N):
    count = sympy.divisor_count(i)
    output += count
    
print(output)

### FIXED CODE ###

n = int(input())
ans = 0
for a in range(1, n):
  ans += (n - 1) // a
print(ans)