Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    try:
        if len(S)<=a_index or len(S) <= b_index:
            return -1
        if S[a_index]=='#' or S[a_index]=='B':
            return 0
        elif S[b_index]=='#' or S[b_index]=='A':
            return 0
        if a_index==g_a and b_index==g_b:
            return 100
    except:
        return -1


    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    try:
        S[before_a] = '.'
        S[before_b] = '.'
        S[a_index] = 'A'
        S[b_index] = 'B'
    except:
        return 0
    try:
        rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    except:
        pass
    try:
        rr2 = move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    except:
        pass
    try:
        rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    except:
        pass
    try:
        rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    except:
        pass
    return max([rr1,rr2,rr3,rr4])

N, A, B, C, D = map(int, input().split())

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

r1 = 0
r2 = 0
r3 = 0
r4 = 0

if len(S)-1>a_index:
    r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
    if r1==100:
        print('Yes')
        exit()
if len(S)-2>a_index:
    r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
    if r2==100:
        print('Yes')
        exit()
if len(S)-1>b_index:
    r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
    if r3==100:
        print('Yes')
        exit()
if len(S)-2>b_index:
    r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)
    if r4==100:
        print('Yes')
        exit()


print('No')


### FIXED CODE ###

#!/usr/bin/env python3

N, A, B, C, D = map(int, input().split())
S = input()

#hunuke

h = S[A-1:D+1].count('##')
m3 = S[B-2:D+1].count('...')

if C < D:
    if h == 0: print('Yes')
    else: print('No')
else:
    if m3 != 0 and h == 0:
        print('Yes')
    else: print('No')
a,b,c,d=map(int,input().split())
if(abs(a-c)<=d):
      print(“Yes”)
elif(abs(a-b)<=d and abs(b-c)<=d):
      print(“Yes”)
else:
      print(“No”)

### FIXED CODE ###

a,b,c,d = map(int,input().split())
if(abs(a-c) <= d):
    print("Yes")
elif(abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
else:
    print("No")
def count_bomb(y,x):
    ans=0
    for i in range(y-1,y+2):
        for j in range(x-1,x+2):
            if i>=0 and i<h and j>=0 and j<w:
                if s[i][j]=="#":
                    ans+=1
    return ans
h,w=map(int,input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            s[i][j]=count_bomb(i,j)
for i in range(h):
    print(*s[i],sep="")


### FIXED CODE ###

N=int(input())
S=list(input())
cnt=0
maxcnt=0
for i in range(N):
    if i==0:
        if S[0] in S[1:N]:
            cnt+=1
        if maxcnt<cnt:
            maxcnt=cnt
    elif i == N-1:
        if S[N-1] in S[0:N]:
            cnt-=1
    else:
        if S[i] not in S[0:i] and S[i] in S[i+1:N]:
            cnt+=1
            if maxcnt<cnt:
                maxcnt=cnt
        elif S[i] in S[0:i] and S[i] not in S[i+1:N]:
            cnt-=1
        else:
            pass
print(maxcnt)
import math
N,M=map(int,input().split())
#print(N,M)
a = list(map(float,input().split()))
#print(a)
a.sort(reverse=True)
#print(a)
k=0
maxa=a[0]/2
while M>0:
#  print(M,k,maxa,a)
  if a[k]>=maxa:
    a[k]=a[k]/2
    M=M-1
  if k==len(a)-1:
    a.sort(reverse=True)
    k=0
    maxa=a[0]
    if maxa<1:
      break
    continue
  if a[k]<a[k+1]:
    if maxa<a[k]:
      maxa=a[k]
    k=k+1
  elif a[k]<maxa:
    if maxa<a[k]:
      maxa=a[k]
    k=k+1
#print(a)
total=0
for t in a:
  total+=int(t)
#  print(t,total)
print(total)

### FIXED CODE ###

s=input()
if s=="Sunny":
  print ("Cloudy")
elif s=="Cloudy":
  print ("Rainy")
else:
  print ("Sunny")
A,B,C,D = (int(x) for x in input().split())
n = A
count = 0
while n <= B:
    if n%C != 0 
        if n%D != 0:
            count += 1
    n += 1
print(count)


### FIXED CODE ###

list = input()
chk = 10
for code in list :
    if chk == code :
        print("Bad")
        break
    chk = code
else :
    print("Good")
n,m = map(int,input().split())
path = {}
for i in range(m):
    a,b = map(int,input().split())
    if a not in path:
        path[a] = [b]
    else:
        path[a].append(b)

ns = []
if 1 in path:
    for p in path[1]:
        ns.append(p)

    flag = False
    for mid in ns:
        if n in path[mid]:
            flag = True
            break

    if flag:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

else:
    print("IMPOSSIBLE")



### FIXED CODE ###

n,m = map(int,input().split())
path = {}
for i in range(m):
    a,b = map(int,input().split())
    if a not in path:
        path[a] = [b]
    else:
        path[a].append(b)

ns = []
if 1 in path:
    for p in path[1]:
        ns.append(p)

    flag = False
    for mid in ns:
        if mid in path:
            if n in path[mid]:
                flag = True
                break

    if flag:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

else:
    print("IMPOSSIBLE")
(h,n),*c=[[*map(int,i.split())]for i in open(0)]
dp=[10**9]*h**3
dp[0]=0
for i in range(h):
    for a,b in c:
        dp[i+a]=min(dp[i+a],dp[i]+b)
print(min(dp[h:]))

### FIXED CODE ###

(h,n),*c=[[*map(int,i.split())]for i in open(0)]
dp=[10**9]*(2*10**4+1)
c.sort()
dp[0]=0
for i in range(h):
    for a,b in c:
        if i+a<=2*10**4:
            dp[i+a]=min(dp[i+a],dp[i]+b)
        else:break    
print(min(dp[h:]))
import math

N = int(input())

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

ret = A[0]
for i in range(1,N):
	ret = math.gcd(ret,A[i])

print(ret)


### FIXED CODE ###

import fractions

N = int(input())

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

ret = A[0]
for i in range(1,N):
	ret = fractions.gcd(ret,A[i])

print(ret)
n=int(input())
h=map(int, input().split())
cur=[0]*n
for i in range(1,n):
    if h[i]<=h[i-1]:
        cur[i]=cur[i-1]+1
print(max(cur))


### FIXED CODE ###

n=int(input())
h=[int(x) for x in input().split()]
cur=[0]*n
for i in range(1,n):
    if h[i]<=h[i-1]:
        cur[i]=cur[i-1]+1
print(max(cur))
s = input()
k = int(input())
n = len(s)

if k == 1:
    cnt1 = 0
    cnt2 = 0
    for i in range(n):
        if i == 0:
            if s[i] == s[i+1]:
                cnt1 += 1
        elif i == n-1:
            if i%2 == 0:
                if s[i] == s[i-1]:
                    cnt1 += 1
            else:
                if s[i] == s[i-1]:
                    cnt2 += 1
        else:
            if i%2 == 0:
                if s[i] == s[i-1] or s[i] == s[i+1]:
                    cnt1 += 1
            else:
                if s[i] == s[i-1] or s[i] == s[i+1]:
                    cnt2 += 1
    print(min(cnt1, cnt2))
elif k == 2:
    s += s
    cnt1 = 0
    cnt2 = 0
    for i in range(1, 2*n-1):
        if i % 2 == 0:
            if s[i] == s[i-1] or s[i] == s[i+1]:
                cnt1 += 1
        else:
            if s[i] == s[i-1] or s[i] == s[i+1]:
                cnt2 += 1
    print(min(cnt1, cnt2))
else:
    s *= 3
    s1 = ''
    s2 = ''
    for i in range(3*n):
        if i < 3*n - 1 and i > 0:
            if i % 2 == 0:
                s2 += s[i]
                if s[i] == s[i-1] or s[i] == s[i + 1]:
                    s1 += '0'
                else:
                    s1 += s[i]
            else:
                s1 += s[i]
                if s[i] == s[i-1] or s[i] == s[i + 1]:
                    s2 += '0'
                else:
                    s2 += s[i]
        elif i == 3*n - 1:
            if i % 2 == 0:
                s2 += s[i]
                if s[i] == s[i-1]:
                    s1 += '0'
                else:
                    s1 += s[i]
            else:
                s1 += s[i]
                if s[i] == s[i-1]:
                    s2 += '0'
                else:
                    s2 += s[i]
        else:
            if i % 2 == 0:
                s2 += s[i]
                if s[i] == s[i + 1]:
                    s1 += '0'
                else:
                    s1 += s[i]
                    
    s1_arr = [s1[:n].count('0'), s1[n:2*n].count('0'), s1[2*n:].count('0')]
    s2_arr = [s2[:n].count('0'), s2[n:2*n].count('0'), s2[2*n:].count('0')]
    print(min(s1_arr[0] + s1_arr[1]*(k-2) + s1_arr[2], s2_arr[0] + s2_arr[1]*(k-2) + s2_arr[2]))


### FIXED CODE ###

s = input()
k = int(input())
n = len(s)
if len(set(s)) == 1:
    print((n*k)//2)
else:
    arr = []
    cnt = 0
    last = s[0]
    for i in s + '0':
        if i != last:
            arr.append(cnt)
            cnt = 1
            last = i
        else:
            cnt += 1
    ans = 0
    if s[0] == s[-1]:
        ans += (arr[0] + arr[-1])//2*(k-1) + arr[0]//2 + arr[-1]//2
        for i in arr[1:-1]:
            ans += (i//2)*k
    else:
        for i in arr:
            ans += (i//2)*k
    print(ans)
from collections import Counter

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

b = []
c = []
for i in range(q):
	B, C = map(int, input().split())
	b.append(B)
	c.append(C)

cnt = Counter(a)

s = sum(arr)

for i in range(q):
	s -= b[i]*cnt[b[i]]
	s += c[i]*cnt[b[i]]
	cnt[c[i]] += cnt[b[i]]
	cnt[b[i]] = 0
	print(s)

### FIXED CODE ###

from collections import Counter

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

cnt = Counter(a)

s = sum(a)

for i in range(q):
	b, c = map(int, input().split())
	s = s - b*cnt[b]
	s = s + c*cnt[b]
	cnt[c] += cnt[b]
	cnt[b] = 0
	print(s)
x, y, z = int(input()split())
print(x * y / 2)


### FIXED CODE ###

x, y, z = map(int, input().split())
print(int(x * y / 2))
if a % i == b % i == 0:
        c += 1
    if c == k:
        print(i)
        break

### FIXED CODE ###

a, b, k = map(int, input().split())
c = 0
for i in range(min(a, b), 0, -1):
    if a % i == b % i == 0:
        c += 1
    if c == k:
        print(i)
        break
import sys
        readline = sys.stdin.readline
        
        N, L = map(int, readline().split())
        node = set([1])
        for _ in range(N):
            S = list(map(int, readline().strip()))
            ls = len(S)
            pre = 1
            for s in S:
                vn = 2*pre + s
                if vn not in node:
                    node.add(vn)
                pre = vn
        cnt = 0
        for d in node:
            h = 0
            if 2*d in node:
                h += 1
            if 2*d+1 in node:
                h += 1
            if h == 1:
                depth = L-d.bit_length()+1
                cnt ^= (-depth&depth)
        
        print('Alice' if cnt else 'Bob')        


### FIXED CODE ###

import sys
readline = sys.stdin.readline

class Node:
    def __init__(self, sigma, depth):
        self.end = False
        self.child = [None] * sigma
        self.depth = depth
    def __setitem__(self, i, x):
        self.child[i] = x
    def __getitem__(self, i):
        return self.child[i]

sigma = 2
root = Node(sigma, 0)
def add_trie(S):
    vn = root
    for cs in S:
        if vn[cs] is None:
            vn[cs] = Node(sigma, vn.depth + 1)
        vn = vn[cs]
    vn.end = True

ans = 0

N, L = map(int, readline().split())

for _ in range(N):
    S = list(map(int, readline().strip()))
    add_trie(S)

cnt = 0
stack = [root]
while stack:
    vn = stack.pop()
    for i in range(2):
        if vn[i] is None:
            r = L - vn.depth
            cnt ^= -r&r
        else:
            stack.append(vn[i])

print('Alice' if cnt else 'Bob')
from collections import deque

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

cards = deque()

for i in range(N):
    cards.append(i+1)


for i in range(M):
    Li, Ri = map(int, input().split())
    L = cards.popleft()
    if Li <= L:
        cards.appendleft(L)
    else:
        while Li > L + 1:
            L = cards.popleft()

    R = cards.pop()
    if Ri >= R:
        cards.append(R)
    else:
        while Ri < R - 1:
            R = cards.pop()

print(len(cards))

### FIXED CODE ###

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

maxL=0
minR=N

for i in range(M):
    L, R = map(int, input().split(" "))
    
    if minR < L or R < maxL:
        print("0")
        exit()
    
    maxL=max(maxL, L)
    minR=min(minR, R)


print(minR-maxL+1)
x=int(input())
def hantei(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

if x==2:
    pritn(2)
    exit()

while True:
    if hantei(x)==1:
        print(x)
        break
    x+=1

### FIXED CODE ###

x=int(input())
def hantei(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

if x==2:
    print(2)
    exit()

while True:
    if hantei(x)==1:
        print(x)
        break
    x+=1
N = int(input())
S = str(input())

if N % 2 == 0:
    T = S[:N/2]
    if S == T + T:
        print('Yes')
    else:
      print('No')
else:
    print('No')

### FIXED CODE ###

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

if N % 2 == 0:
    T = S[:int(N/2)]
    if S == T + T:
        print('Yes')
    else:
      print('No')
else:
    print('No')
import math
s = input()
k = int(input())

i = 0
while i < len(s):
    if math.log(int(s[i])) * (500 * 10 **12) >= math.log(k):
#         print(i, s[i], int(s[i]) ** (500 * 10 *12))
        break
    i += 1
print(s[i])

### FIXED CODE ###

s = input()
k = int(input())
if len(s) == 1 or k == 1:
    print(s[0])
else:
    i = 0
    while i < k - 1 and i < len(s):
        if s[i] != '1':
            break
        i += 1
    print(s[i])
#!/usr/bin/env python3
import sys
MOD = 1000000007  # type: int

def permutations_count(n, k):
    if k == 0:
        return 1
    return n * permutations_count(n-1, k-1) % MOD

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    matrix = [[] for _ in range(N+1)]
    for i in range(N-1):
        matrix[a[i]].append(b[i])
        matrix[b[i]].append(a[i])
    
    visited = [0]*(N+1)

    from collections import deque
    queue = deque()
    visited[1]=1
    answer = K

    if K-2 < len(matrix[1])-1:
        print(0)
        return
        
    answer *= permutations_count(K-1,len(matrix[1]))
    for node in matrix[1]:
        queue.append(node)

    while queue:
        q = queue.popleft()

        if visited[q] == 0:
            if K-2 < len(matrix[q])-1:
                print(0)
                return
            answer *= permutations_count(K-2,len(matrix[q])-1) #親ノード引いてる
        else:
            continue

        visited[q] = 1

        for child_node in matrix[q]:
            if child_node != q:
                queue.append(child_node)

    print(answer%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
MOD = 1000000007  

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    matrix = [[] for _ in range(N+1)]
    for i in range(N-1):
        matrix[a[i]].append(b[i])
        matrix[b[i]].append(a[i])
    
    visited = [0]*(N+1)

    from collections import deque
    queue = deque()
    visited[1]=1
    answer = K
    num = K-1
    for node in matrix[1]:
        answer *= num
        answer %= MOD

        num -= 1
        queue.append(node)

    while queue:
        q = queue.popleft()
        if visited[q] != 0:
            continue
        visited[q] = 1

        num = K-2
        for child_node in matrix[q]:
            if visited[child_node] == 0:
                answer *= num
                answer %= MOD
                num -= 1
                queue.append(child_node)
        answer %= MOD

    print(answer%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()
while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
       break
    
    if (h + w) % 2 = 0:
            print('#', end='')
    else:
            print('.', end='')

    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 + w) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')

        print()
    print()
import my_method as my


N = int(input())
s = [sorted([x for x in input()]) for i in range(N)]

check = [False] * N
cnt = 0
for i in range(N - 1):
    part = 0
    if check[i]:
        continue
    for j in range(i + 1, N):
        if check[j]:
            continue
        if s[i] == s[j]:
            part += 1
            check[j] = True
    cnt += (part + 1) * part // 2

print(cnt)


### FIXED CODE ###

def f(array):
    temp = 'abcdefghijklmnopqrstuvwxyz'
    ret = [0] * len(temp)
    cnt = 0
    for x in array:
        ret[temp.index(x)] += 1
        cnt += 1
        if cnt == 10:
            break
    return ret

N = int(input())
s = [''.join(sorted(input())) for i in range(N)]

dic = {}
for i in range(N):
    if s[i] in dic:
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1

cnt = 0
for v in dic.values():
    cnt += v * (v - 1) // 2

print(cnt)
from networkx import *
n,m = map(int, input().split())
G = Graph()
for i in range(m):
    a,b = map(int, input().split())
    G.add_edges_from([(a,b)])

print(len(max(connected_components(G))))

### FIXED CODE ###

from networkx import *
n,m = map(int, input().split())
if m == 0: print(1);exit()
G = Graph()
for i in range(m):
    a,b = map(int, input().split())
    G.add_edges_from([(a,b)])

print(len(max(connected_components(G), key=len)))
n = int(input())
s = list(i, int(j) for i, j in input().split())
ans = [s.index(i)+1 for i in sorted(s, key=lambda x:(x[0], -x[1]))]
print(i) for i in ans


### FIXED CODE ###

n = int(input())
s = list(list(input().split()) for _ in range(n))
ans = [s.index(i)+1 for i in sorted(s, key=lambda x:(x[0], -int(x[1])))]
for i in ans: print(i)
h,w = map(int, input().split())
l = [None]*h
for i in range(h):
    l[i] = list(input())

from collections import deque
def solve():
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    ans=0
    while True:
        Q = deque()
        cnt=0
        for i in range(h):
            for j in range(w):
                if l[j][i] == "#":
                    Q.append([i,j])
                    cnt+=1
        if cnt == h*w:
            return ans

        ans+=1
        while Q:
            p = Q.popleft()
            for i in range(4):
                nx = p[0] + dx[i]
                ny = p[1] + dy[i]

                if 0 <= nx < w and 0 <= ny < h:
                    if l[ny][nx]==".":
                        l[ny][nx] = "#"

print(solve())

### FIXED CODE ###

h,w = map(int, input().split())
l = [None]*h
for i in range(h):
    l[i] = list(input())

from collections import deque
def solve():
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    Q = deque()

    cnt=h*w
    for x in range(w):
        for y in range(h):
            if l[y][x]=="#":
                cnt-=1
                Q.append([x,y])
    if cnt==0:
        return 0

    ans=0
    while True:
        nxtQ = deque()

        ans+=1
        while Q:
            p = Q.popleft()
            for i in range(4):
                nx = p[0] + dx[i]
                ny = p[1] + dy[i]

                if 0 <= nx < w and 0 <= ny < h:
                    if l[ny][nx]==".":
                        l[ny][nx] = "#"
                        nxtQ.append([nx,ny])
                        cnt-=1
        Q=nxtQ
        if cnt<=0:
            return ans

print(solve())
N = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
  s = input()
  if(s == "AC"):
    AC += 1
  elif(s == "WA"):
    WA += 1
  elif(s == "TLE"):
    TLE += 1
  elif(s == "RE"):
    RE += 1
    
print("AC x {}".format(AC))
print("WA x {}".format(WA)
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))


  

### FIXED CODE ###

N = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
  s = input()
  if(s == "AC"):
    AC += 1
  elif(s == "WA"):
    WA += 1
  elif(s == "TLE"):
    TLE += 1
  elif(s == "RE"):
    RE += 1
    
print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))
N,M = map(int,input().split())
from collections import deque
v = [deque([]) for _ in range(N)]

for i in range(M):
    a,b,c = map(int,input().split())
    a,b = a-1,b-1
    v[a].append([b,c])
    v[b].append([a,c])
import math

s = deque([])
for i in range(N):
    ls = [[-1,math.inf]]*N
    ls[i] =  [-1,0]
    q = [deque(j for j in i) for i in v]
    l = deque([i])
    while l:
        u = l.popleft()
        while q[u]:
            e = q[u].popleft()
            if ls[u][1] + e[1] < ls[e[0]][1]:
                ls[e[0]] = [u, ls[u][1] + e[1]]
                l.append(e[0])
    for j,e in enumerate(ls):
        if e[0] != -1:
             s.append([min(j,e[0]),max(j,e[0])])

s = list(map(list, set(map(tuple, s))))
print(M-len(s))


### FIXED CODE ###

N,M = map(int,input().split())
from collections import deque
v = [deque([]) for _ in range(N)]

for i in range(M):
    a,b,c = map(int,input().split())
    a,b = a-1,b-1
    v[a].append([b,c])
    v[b].append([a,c])

s = deque([])
for i in range(N):
    ls = [[-1,M*10000]]*N
    ls[i] =  [-1,0]
    q = [deque(j for j in k) for k in v]
    l = deque([i])
    while l:
        u = l.popleft()
        x = len(q[u])
        for i in range(x):
            e = q[u].popleft()
            if ls[u][1] + e[1] < ls[e[0]][1]:
                ls[e[0]] = [u, ls[u][1] + e[1]]
                l.append(e[0])
            q[u].append(e)
    for j,e in enumerate(ls):
        if e[0] != -1:
             s.append([min(j,e[0]),max(j,e[0])])

s = list(map(list, set(map(tuple, s))))
print(M-len(s))
N = int(input())
p = list(map(int, input().split()))
cnt = 0
for n in range(N):
    if p[n] != i+1:
        cnt+=1

if cnt <= 2:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

N = int(input())
p = list(map(int, input().split()))
cnt = 0
for n in range(N):
    if p[n] != n+1:
        cnt+=1
 
if cnt <= 2:
    print("YES")
else:
    print("NO")
while True:
s = raw_input())

if s.split()[1] = "1"
break
print.eval(s)

### FIXED CODE ###

while True:
    s = raw_input()
    if s.split() [1] == "?" : break
    print eval(s)