Harryxun/stf_run huggingface dataset:
n = int(input())
c = []
for _ in range(n):
    c.append(list(map(int,input().split())))

ans = 0
a = 100000000000000
m = 0
lm = 0
rm = 0
lt  = []
rt  = []
lb = []
rb = []

for l in c:
    m = max(m,l[0]+l[1])
    a = min(a,l[0]+l[1])
    if l[0] > l[1]:
        rm = max(rm,l[0]-l[1])
    if l[0] < l[1]:
        lm = max(lm,l[1]-l[0])

for l in c:
    if l[0] + l[1] == m:
        rt.append(l)
    if l[0] + l[1] == a:
        lb.append(l)
    if l[0] > l[1] and l[0] - l[1] == rm:
        rb.append(l)
    if l[0] < l[1] and l[1] - l[0] == lm:
        lt.append(l)


if lt is not None and rb is not None:
    i = lt[0]
    j = rb[0]
    ans = max(ans,abs(i[0]-j[0])+abs(i[1]-j[1]))

if rt is not None and lb is not None:
    i = rt[0]
    j = lb[0]
    ans = max(ans,abs(i[0]-j[0])+abs(i[1]-j[1]))
print(ans)




### FIXED CODE ###

n = int(input())
c = []
for _ in range(n):
    c.append(list(map(int,input().split())))

ans = 0
a = 100000000000000
m = 0
lm = 0
rm = 0
lt  = []
rt  = []
lb = []
rb = []

for l in c:
    m = max(m,l[0]+l[1])
    a = min(a,l[0]+l[1])
    if l[0] > l[1]:
        rm = max(rm,l[0]-l[1])
    if l[0] < l[1]:
        lm = max(lm,l[1]-l[0])

for l in c:
    if l[0] + l[1] == m:
        rt.append(l)
    if l[0] + l[1] == a:
        lb.append(l)
    if l[0] > l[1] and l[0] - l[1] == rm:
        rb.append(l)
    if l[0] < l[1] and l[1] - l[0] == lm:
        lt.append(l)


if len(lt)>0 and len(rb) > 0:
    i = lt[0]
    j = rb[0]
    ans = max(ans,abs(i[0]-j[0])+abs(i[1]-j[1]))

if len(rt)>0 and len(lb) > 0:
    i = rt[0]
    j = lb[0]
    ans = max(ans,abs(i[0]-j[0])+abs(i[1]-j[1]))
print(ans)
x,a,b=map(int,input().split())
if |x-a|>=|x-b|:
  print('B')
else:
  print('A')

### FIXED CODE ###

x,a,b=map(int,input().split())
if abs(x-a)>=abs(x-b):
  print('B')
else:
  print('A')
import math
import decimal

r = list(map(float,input().split()))

x = decimal.Decimal(str(r[1])).quantize(Decimal('0'),rounding=ROUND_HALF_UP)
y = decimal.Decimal(str(r[1])).quantize(Decimal('0.01'),rounding=ROUND_HALF_UP)

z = x * y

z = math.floor(z)
if r[0] == 0 or r[1] == 0:
    z = int(0)

print(z)

### FIXED CODE ###

import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

r = list(map(float,input().split()))

x = Decimal(str(r[0])).quantize(Decimal('0'),rounding=ROUND_HALF_UP)
y = Decimal(str(r[1])).quantize(Decimal('0.01'),rounding=ROUND_HALF_UP)

z = x * y

z = math.floor(z)

print(z)
lst = input().split()

for i in range(3):
   lst[i] = int(lst[i])
   lst.sort()

print(lst[0] + lst[1])

### FIXED CODE ###

lst = input().split()

for i in range(3):
   lst[i] = int(lst[i])

lst.sort()
print(lst[0] + lst[1])
N = int(input())
a = 1
while a * a <= N:
  if N % a = 0:
    k = a
  a += 1
print(k + (N//k) -2)


### FIXED CODE ###

N = int(input())
a = 1
while a * a <= N:
  if N % a == 0:
    k = a
  a += 1
b = N //k
print(b + k - 2)
i=0
while((a=int(input())!=0):
      i+=1
      print("Case {0}: {1}".format(i,a))

### FIXED CODE ###

i=0
while 1:
    a=int(input())
    if(a==0): break
    i+=1
    print("Case {0}: {1}".format(i,a))
a, b =[int(x) for x in input().split()]
 
import numpy as np
n=a*b
A = np.array(a)
B = np.array(b)
if np.gcd(A, B) == 1:
  print(n)

elif a > b :
  for i in range(a, n+1):
    if (i % a == 0)and(i % b == 0):
      print(i)
      break

else:
  for i in range(b, n+1):
    if (i % a == 0)and(i % b == 0):
      print(i)
      break

### FIXED CODE ###

a, b = [int(x) for x in input().split()]
# a = [int(input()) for _ in range(m)]
# a = [int(x) for x in input().split()]

from fractions import gcd



print((a*b)//gcd(a, b))
A, B, K = map(int, input().split())

List = [x for x in range(min(A,B),1,-1) if A%x ==0 and B%x ==0]
print(List[K-1])

### FIXED CODE ###

A, B, K = map(int, input().split())

List = [x for x in range(min(A,B),0,-1) if A%x ==0 and B%x ==0]
print(List[K-1])
n=int(input())
S=input()
a='abcdefghijklmnopqrstuvwxyz'
ans=1
for i in range(26):
  cnt=S.count(a[i])
  if cnt >0:
    ans=ans*(1.5**(cnt-1))*2
ans-=1
ans=ans%(10**9+7)
print(int(ans))


### FIXED CODE ###

n=int(input())
S=input()
a='abcdefghijklmnopqrstuvwxyz'
ans=1
for i in range(26):
  cnt=S.count(a[i])
  ans=ans*(cnt+1)
ans-=1
ans=ans%(10**9+7)
print(int(ans))
page_N = input("Please Number")
min_page = round(page_N / 2)
print(min_page)

### FIXED CODE ###

import math
N = int(input())
min_page = math.ceil(N/2)
print(min_page)
s = list(input())
if s[7] <= 3 or (s[7] == 4 and s[8] <=3):
  print("Heisei")
else:
  print("TBD")

### FIXED CODE ###

n = input()
n1 = int(n[0:4]+n[5:7]+n[8:10])
if n1 > 20190430:
    print("TBD")
else:
    print("Heisei")
N = int(input())
nums = list(map(int, input().split()))

cumul = 1
if 0 in nums: print(0)
else:
	for i in range(N):
    	cumul *= nums[i]
		if cumul > 10 ** 18:
      		print(-1)
      		break
	if cumul <= 10 ** 18: print(cumul)


### FIXED CODE ###

N = int(input())
nums = list(map(int, input().split()))

cumul = 1
if 0 in nums:
    print(0)
else:
    for i in range(N):
        cumul *= nums[i]
        if cumul > 10 ** 18:
            print(-1)
            break
    if cumul <= 10 ** 18: print(cumul)
#!/usr/bin/env python3

import itertools

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

if N-3 == 1:
    combs = list(range(N))
else:
    combs = list(itertools.combinations(range(N), N-3))

l_pw = []
for comb in combs:
    l_S = list(S)
    for idx in sorted(comb, reverse=True):
        l_S.pop(idx)
    l_pw.append(','.join(l_S))

# print(l_pw)

print(len(set(l_pw)))


### FIXED CODE ###

#!/usr/bin/env python3

import itertools

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

# 暗証番号Vを000から999まで決め打ちすると、次の問題を1000回解けば良いことになる。
# SからN-3桁を消して、Vを作ることができるか。
# この問題は貪欲法で解くことができる。
# - 1. S_i = V_1であるようなiのうち、最小のiをp_1とする。そのようなiが存在しなければ、Vを作ることはできない。
# - 2. S_i = V_2であるようなiのうち、p_1より大きい、かつ最も小さいiをp_2とする。そのようなiが存在しなければ、Vを作ることはできない。
# - 3. S_i = V_3であるようなiのうち、p_2より大きい、かつ最も小さいiをp_3とする。そのようなiが存在しなければ、Vを作ることはできない。
# e.g., S = 869120, V = 812
# - V_1 = 8より、p_1 = 0
# - V_2 = 1, p_1 = 0より、p_2 = 3
# - V_3 = 2, p_2 = 3より、p_3 = 4

def can_make_pw(S, password):
    # step1
    v1 = password[0]
    p1 = S.find(v1)
    if p1 == -1:
        return False
    # step2
    v2 = password[1]
    p2 = S.find(v2, p1+1)
    if p2 == -1:
        return False
    # step3
    v3 = password[2]
    p3 = S.find(v3, p2+1)
    if p3 == -1:
        return False
    return True

passwords = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            password = str(i) + str(j) + str(k)
            passwords.append(password)
# print(passwords)

count = 0
for password in passwords:
    if can_make_pw(S, password):
        # print(f"You can make {password} from {S}")
        count += 1

print(count)

# 全探索はTLE
# l_pw = []
# if N-3 == 1:
#     for i in range(N):
#         l_S = list(S)
#         l_S.pop(i)
#         l_pw.append(','.join(l_S))
# else:
#     combs = list(itertools.combinations(range(N), N-3))
#     for comb in combs:
#         l_S = list(S)
#         for i in sorted(comb, reverse=True):
#             l_S.pop(i)
#         l_pw.append(','.join(l_S))
# print(len(set(l_pw)))
n = int(input())
c = str(input())

r_m = c.count('R')
w_m = c.count('W')
wr_m = c.count('WR')

print(min(r_m, w_m) - wr_m //2)
s = 0
if r_m >= w_m:
    for i in range(len(c) - 1):
    if c[i] == 'W' and c[i + 1] == 'R':
        c[i + 1] = 'W'
        s += 1

### FIXED CODE ###

n = int(input())
c = str(input())

r_m = c.count('R')
w_m = 0
out = max(r_m, w_m)
for i in range(n):
    if c[i] == 'W':
        w_m += 1
    else:
        r_m -= 1
    out = min(out, max(w_m, r_m))
print(out)
# -*- coding: utf-8 -*-
N = int(input())
G = [None for i in range(N)]
for i in range(N):
  temp = list(map(int, input().split()))
  G[i] = temp[1:]
  
INF = 2**31 -1

temp = 1
while temp < N:
  temp *= 2

lis = [INF for i in range(2*temp-1)]

def getSum(x):
  x += temp-1
  w_sum = lis[x]
  while x > 0:
    x = (x-1) // 2
    w_sum += lis[x]
  return w_sum

def add(a, b, x, k=0, l=0, r=temp):
  if r <= a or b <= l:
    return 0

  if a <= l and r <= b:
    lis[k] += x
    return 0
  
  add(a, b, k*2+1, l, (l+r)//2)
  add(a, b, k*2+2, (l+r)//2, r)

def dfs(k, a=0):
  arr[0][k] = a
  a += 1
  for i in range(len(G[k])):
    dfs(G[k][i])
  arr[1][k] = a
  
arr = [[0,0] for i in range(200010)]


  
dfs()
Q = int(input())
for i in range(Q):
  querry = list(map(int, input().split()))
  if querry[0] == 0:
    add(arr[0][querry[1]], arr[1][querry[1]],w)
  else:
    print(getSum(arr[0][querry[1]])


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(1000000)

class weightRtree:
    def __init__(self, num):
        self.num = num
        self.weight = [0] * (num+1) 
      
    def add(self, v, w):
        if v == 0:
            return 0
        while v <= self.num:
            self.weight[v] += w
            v += (-v) & v    

    def getSum(self, u):
        temp = 0
        while u > 0:
            temp += self.weight[u]
            u -= (-u) & u
        return temp

N = int(input())
left = [0] * N
right = [0] * N
Tree = [set(map(int, input().split()[1:])) for i in range(N)]

def DFS(count, source):
    count += 1
    left[source] = count
    for item in Tree[source]:
        count = DFS(count, item)
    count += 1
    right[source] = count
    return count

Object = weightRtree(DFS(1, 0))

Q = int(input())
for i in range(Q):
    alist = list(map(int, input().split()))
    if not alist[0]:
        Object.add(left[alist[1]], alist[2])
        Object.add(right[alist[1]], -alist[2])
    else:
        print(Object.getSum(right[alist[1]] - 1))
if(S[1]=="B"):
    result = S.replace("B","R")
else:
    result = S.replace("R","B")
print(result)

### FIXED CODE ###

S = input()
if(S[1]=="B"):
    result = S.replace("B","R")
else:
    result = S.replace("R","B")
print(result)
N = int(input())

def dfs(s):
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0
  for c in s:
    ret += dfs(s + c)
  return ret

print(dfs('0'))

### FIXED CODE ###

N = int(input())

def dfs(s):
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0
  for c in '753':
    ret += dfs(s + c)
  return ret

print(dfs('0'))
k,n=map(int,input().split())
a=[int(i) for i in input().split()]
array=[a[n-1]-a[0]]
array.append(result)
for i in range(1,n):
  array.append(k+a[i-1]-a[i])
print(min(array))


### FIXED CODE ###

k,n=map(int,input().split())
a=[int(i) for i in input().split()]
array=[]
result=a[n-1]-a[0]
array.append(result)
for i in range(1,n):
    result=k+a[i-1]-a[i]
    array.append(result)
print(min(array))
n, k = map(int, input().split())
pn = list(map(int, input().split()))
cn = list(map(int, input().split()))

ans = -float('inf')

for i in range(n): #start
    start = i
    now = start
    total = 0
    ls = [0]

    for j in range(1, k+1):
        now = pn[now]-1
        total += cn[now]
        ans = max(ans, total)
        ls.append(total)
        if now == start:
            rp = j
            break
    else:
        continue

    if total <= 0:
        continue
    else:
        s = k % rp
        ans2 = total * (k//rp) + max(ls[:s])
        ans = max(ans, ans2)
print(ans)

### FIXED CODE ###

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

ans = -float('inf')

for i in range(n): #start
    start = i
    now = start
    total = 0
    ls = [0]

    for j in range(1, k+1):
        now = pn[now]-1
        total += cn[now]
        ans = max(ans, total)
        ls.append(total)
        if now == start:
            rp = j
            break
    else:
        continue

    if total <= 0:
        continue
    else:
        if k % rp == 0:
            s = k % rp
            ans2 = total * (k // rp-1) + max(ls)
            ans = max(ans, ans2)
        else:
            s = k % rp
            ans2 = total * (k//rp) + max(ls[:s+1])
            ans = max(ans, ans2)
print(ans)
n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")] * n #dpテーブル
#dp[i]メモ化テーブル

def rec(i):
    res = float("inf")
    if i<=0:
        return 0
    return min(rec(i-1) + abs(h[i]-h[i-1]),rec(i-2) + abs(h[i]-h[i-2]))

print(rec(n-1))

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")] * n #dpテーブル
#dp[i]:=i番目の足場まで来るのに必要な最小コスト

#初期条件
dp[0]=0
dp[1]=abs(h[1]-h[0])

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

print(dp[n-1])
from collections import deque
N=int(input())
T=[[] for _ in range(N)]
for i in range(N-1):
    a,b,c=map(int, input().split())
    T[a-1].append((b-1,c))
    T[b-1].append((a-1,c))

Q,K=map(int, input().split())
que=[(K-1,0)
done=[-1]*N
while que:
    t=que.pop(0)
    now,nowd=t
    done[now]=nowd
    for nex in T[now]:
        nexnode,nexd=nex
        if done[nexnode]!=-1:
            continue
        else:
            que.append((nexnode, nowd+nexd))

#print(done)
for i in range(Q):
    x,y=map(int, input().split())
    print(done[x-1]+done[y-1])

### FIXED CODE ###

N=int(input())
import sys
sys.setrecursionlimit(10**6)
T=[[] for _ in range(N)]
for i in range(N-1):
    a,b,c=map(int, input().split())
    T[a-1].append((b-1,c))
    T[b-1].append((a-1,c))

Q,K=map(int, input().split())
D=[-1]*N
D[K-1]=0
def dfs(start, nowd):
    to=T[start]
    for t in to:
        next_node,c=t
        if D[next_node]!=-1:
            continue
        nextd=nowd+c
        D[next_node]=nextd
        dfs(next_node, nextd)
dfs(K-1,0)
for i in range(Q):
    x,y=map(int, input().split())
    print(D[x-1]+D[y-1])
import numpy as np
N, W = map(int, input().split())

dp=np.zeros((N+1, W+1), dtype=np.int64)

for i in range(1, N+1):
	w, v = map(int, input().split())
	dp[i]=dp[i-1]
	dp[i][w:]=np.maximum(dp[i-1][:W-w+1]+v, dp[i-1][w:])
print(np.max(dp))

### FIXED CODE ###

N, W = map(int, input().split())
w=[]
v=[]
for i in range(N):
	a, b = map(int, input().split())
	w.append(a)
	v.append(b)
#dp[i+1][j] := i番目までの品物から総和がjとなるように選んだ時の重さの総和の最小値
dp=[[float("inf")]*(max(v)*N+1) for _ in range(N+1)]
#初期条件
dp[0][0]=0
for i in range(N):
	for j in range(max(v)*N+1):
		if v[i]>j:
			dp[i+1][j] = dp[i][j]
		else:
			dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i])

ans=0
for j in range(max(v)*N+1):
	if dp[N][j]<=W:
		ans=j
print(ans)
n,k = map(int,input().split(' '))
A = list(map(int,input().split(' ')))
B = []
b = 1
ans = 1
while ans:
  a = b
  b = A[a-1]
  B.append(b)
  if len(B) == len(A):
    ans = 0
  else:
    continue

print(B[k-1])


### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
pos = 0
visit = [0] * N
move = []
roop = []
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos] += 1
    pos = A[pos] - 1
if len(move)>K:
    print(move[K]+1)
else:
    print(roop[(K-(len(move)-len(roop)))%len(roop)]+1)
H, W = int(input()), int(input())
h, w = int(input()), int(input())
print((H - h) * (W - w))

### FIXED CODE ###

H, W = (int(x) for x in raw_input().split())
h, w = (int(x) for x in raw_input().split())
print((H - h) * (W - w))
n = input()
m = [0] * n
max = [0] * n
kijun = [0] * n
rieki = [0] * n
max_rieki = 0
for i in xrange(n):
 m[i] = input()
 
 
for i in xrange(n-1):
 max[i] = m[i+1] 
 kijun[i] = m[i]
 for j in xrange(i+1,n): 
  if max[i] < m[j]:
      max[i] = m[j]
 rieki[i] = max[i] - kijun[i]
 if i == 0:
  max_rieki = rieki[0]
 if rieki[i] > max_rieki:
  max_rieki = rieki[i]

print max_rieki

### FIXED CODE ###

n = input()
m = [0] * n
max_rieki = -1000000000



for i in xrange(n):
 m[i] = input()

min_rieki = m[0]
for i in xrange(1,n): 
  if max_rieki < m[i] - min_rieki:
     max_rieki = m[i] - min_rieki
  if min_rieki > m[i]:
     min_rieki = m[i]

print max_rieki
import sys
input = sys.stdin.readline 
N, K = map(int, input().split())
S = list(map(int, input()))

cnt = 0
now = 1
Nums = []

for i in range(N):
    if S[i] == now:
        cnt += 1
    else:
        Nums.append(cnt)
        now = 1 - now
        cnt = 1

if cnt != 0:
    Nums.append(cnt)
if len(Nums) % 2 == 0:
    Nums.append(0)

add = 2*K+1
ans = 0
left = right = 0
tmp = 0    # [left, right)

for i in range(0, len(Nums), 2):
    Nextleft = i
    Nextright = min(i+add, len(Nums))
    
    while Nextleft > left:
        tmp -= Nums[left]
        left += 1
    
    while Nextright > right:
        tmp += Nums[right]
        right += 1
    
    ans = max(tmp, ans)

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
S = list(input())
left = 0
right = 0
onecnt = 0
zerocnt = 0
zeroflag = False
leftflag = False
ans = 0

while right < N:
    if S[right] == '0' and not zeroflag:
        zerocnt += 1
        zeroflag = True
    elif S[right] == '1' and zeroflag:
        zeroflag = False
        
    if zerocnt > K and zeroflag:
        tmp = right - left
        if tmp > ans:
            ans = tmp
        while True:
            if S[left] == '0' and not leftflag:
                leftflag = True
            elif S[left] == '1' and leftflag:
                leftflag = False
                break
            left += 1
        zerocnt -= 1
    right += 1

if right - left > ans:
    ans = right - left

print(ans)
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
  print(-1)
  exit()
ans = 1
for i in A:
  ans *= i
  if ans >= 10 ** 18:
    print(-1)
	exit()
print(ans)

         

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
if 0 in A:
  print(0)
  exit(0)
ans = 1
for i in A:
  ans *= i
  if ans > 10 ** 18:
    print(-1)
    exit(0)
print(ans)
from collections import deque

def dfs(stage , visited , start_x,start_y,goal_x,goal_y):
    queue = deque([[start_x,start_y]])
    visited[start_x][start_y] = 1
    while queue:
        x , y = queue.popleft()
        if [x , y] == [goal_x,goal_y]:
            return visited[x][y]
        for dx , dy in ([1,0],[-1,0],[0,1],[0,-1]):
            new_x , new_y = x + dx , dy + y
            #print(new_x,new_y)
            if 0 <= new_x <= goal_x and 0 <= new_y <= goal_y  and stage[new_x][new_y] == "." and visited[new_x][new_y] == -1:
                #print(new_x , new_y)
                visited[new_x][new_y] = visited[x][y] + 1
                queue.append([new_x,new_y])
        #print(queue)
if __name__ == "__main__":
    H , W = map(int , input().split())
    stage = []
    for _ in range(H):
        stage.append(list(input()))
    start_x,start_y ,goal_x,goal_y = 0,0,H-1,W-1
    visited = [[-1] * W for _ in range(H)]
    #print(visited)
    #print(stage)
    #print(visited[0][1])
    sum = 0
    for value in stage:
        sum += value.count('.')
    #print(sum)
    print(sum - dfs(stage,visited,start_x,start_y,goal_x,goal_y))


### FIXED CODE ###

from collections import deque

def dfs(stage , visited , start_x,start_y,goal_x,goal_y):
    queue = deque([[start_x,start_y]])
    visited[start_x][start_y] = 1
    while queue:
        x , y = queue.popleft()
        if [x , y] == [goal_x,goal_y]:
            return visited[x][y]

        for dx , dy in ([1,0],[-1,0],[0,1],[0,-1]):
            new_x , new_y = x + dx , dy + y
            #print(new_x,new_y)
            if 0 <= new_x <= goal_x and 0 <= new_y <= goal_y  and stage[new_x][new_y] == "." and visited[new_x][new_y] == -1:
                #print(new_x , new_y)
                visited[new_x][new_y] = visited[x][y] + 1
                queue.append([new_x,new_y])
    print("-1")
    exit(0)
if __name__ == "__main__":
    H , W = map(int , input().split())
    stage = []
    for _ in range(H):
        stage.append(list(input()))
    start_x,start_y ,goal_x,goal_y = 0,0,H-1,W-1
    visited = [[-1] * W for _ in range(H)]
    #print(visited)
    #print(stage)
    #print(visited[0][1])
    sum = 0
    for value in stage:
        sum += value.count('.')
    #print(sum)
    print(sum - dfs(stage,visited,start_x,start_y,goal_x,goal_y))
from collections import deque

N, M = map(int, input().split())
s = [list(input()) for i in range(N)]

S = []
for i in s: #S[i]=0なら頂点iのラベルは"A"、S[i]=1なら頂点iのラベルは"B"
    if i == "A": S.append(0)
    else: S.append(1)

#R[i]には頂点iと辺でつながっている頂点を入れる
R = [list() for _ in range(N)]
#C[i][0]には頂点iと辺でつながっているラベル"A"の数
#C[i][1]には頂点iと辺でつながっているラベル"B"の数
C = [[0, 0] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    R[a-1].append(b-1)
    R[b-1].append(a-1)
    C[a-1][S[b-1]] += 1
    C[b-1][S[a-1]] += 1

O = [0] * N #ダメな頂点には1を入れる
q = deque() #調べる頂点の候補リスト
for i in range(N):
    if C[i][0] * C[i][1] == 0: #もし少なくとも"A","B"どちらかに行けないなら
        q.append(i)
        O[i] = 1

while q:
    x = q.popleft()
    for v in R[x]:
        C[v][S[x]] -= 1
        if C[v][S[x]] == 0 and O[v] != 0:
            O[v] = 1
            q.append(v)

if sum(O) == N:
    answer = "No"
else:
    answer = "Yes"

print(answer)


### FIXED CODE ###

from collections import deque

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

S = []
for i in s: #S[i]=0なら頂点iのラベルは"A"、S[i]=1なら頂点iのラベルは"B"
    if i == "A": S.append(0)
    else: S.append(1)

#R[i]には頂点iと辺でつながっている頂点を入れる
R = [list() for _ in range(N)]
#C[i][0]には頂点iと辺でつながっているラベル"A"の数
#C[i][1]には頂点iと辺でつながっているラベル"B"の数
C = [[0, 0] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    R[a-1].append(b-1)
    R[b-1].append(a-1)
    C[a-1][S[b-1]] += 1
    C[b-1][S[a-1]] += 1

O = [0] * N #ダメな頂点には1を入れる
q = deque() #調べる頂点の候補リスト
for i in range(N):
    if C[i][0] * C[i][1] == 0: #もし少なくとも"A","B"どちらかに行けないなら
        q.append(i)
        O[i] = 1

while q:
    x = q.popleft()
    for v in R[x]:
        C[v][S[x]] -= 1
        if C[v][S[x]] == 0 and O[v] == 0:
            O[v] = 1
            q.append(v)

if sum(O) == N:
    answer = "No"
else:
    answer = "Yes"

print(answer)
import sys
sample = sys.stdin.read().splitlines()
n, stones = int(sample[0]), list(map(int, sample[1].split()))

def frog_jump(n, stones):
    dp = [float('inf')] * n
    jumps = (1, 2)
    dp[0] = 0
    for idx in range(len(dp)):
        for jump in jumps:
            if idx+jump < len(dp):
                dp[idx+jump] =  min(dp[idx]+abs(stones[idx+jump]-stones[idx]), dp[idx+jump])
    return dp[-1]
 
 frog_jump(n, stones)

### FIXED CODE ###

import sys
sample = sys.stdin.read().splitlines()
n, stones = int(sample[0]), list(map(int, sample[1].split()))
dp = [float('inf')] * n
jumps = (1, 2)
dp[0] = 0
for idx in range(len(dp)):
  for jump in jumps:
    if idx+jump < len(dp):
      dp[idx+jump] =  min(dp[idx]+abs(stones[idx+jump]-stones[idx]), dp[idx+jump])
print(dp[-1])
N = int(input())
C=list(input())
L=0
R=0
RR=0
X=0
    for i in range(N):
      L=i
      R=RR
      if L>=N-1-R:
        break
      if C[i]=='W':
          for ii in range(N-L-R):
            if C[N-1-R-ii]=='R':
              C[L]='R'
              C[N-1-R-ii]='W'
              X+=1
              break
            RR+=1
            if L>=N-1-R:
              break
print(X)

### FIXED CODE ###

N = int(input())
C=list(input())
type=set(C)
L=0
R=0
RR=0
X=0
if 'R' in type and 'W' in type:
    for i in range(N):
      L=i
      R=RR
      if L>=N-1-R:
        break
      if C[i]=='W':
          for ii in range(N-L-R):
            if C[N-1-R-ii]=='R':
              C[L]='R'
              C[N-1-R-ii]='W'
              X+=1
              break
            RR+=1
            if L>=N-1-R:
              break
print(X)