Harryxun/stf_run huggingface dataset:
n = int(input())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    tree[u-1].append((v-1, w))
    tree[v-1].append((u-1, w))

visited = [False for _ in range(n)]
visited[0] = True
ans = [0 for _ in range(n)]

def journey(next, bit):
    for pos in next:
        v, w = pos
        if visited[v]: continue
        visited[v] = True
        if w % 2 == 0: 
            ans[v] = bit
            journey(tree[v], bit)
        else: 
            ans[v] = 1-bit
            journey(tree[v], 1-bit)
    
journey(tree[0], 0)
for x in ans:
    print(x)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

n = int(input())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    tree[u].append((v, w))
    tree[v].append((u, w))

ans = [0 for _ in range(n)]

def journey(u, p, bit):
    ans[u] = bit
    for v, w in tree[u]:
        if v == p: continue
        if w % 2 == 0: journey(v, u, bit)
        else: journey(v, u, 1-bit)
    
journey(0, -1, 0)
[print(x) for x in ans]
for i in range(1,10001):
    line = input()
    if line == 0:
        break
    else:
        print('Case %d: %s', %(i, line))


### FIXED CODE ###

#
# 3b
#

def main():
    i = 1
    while True:
        x = int(input())
        if x == 0:
            break
        print(f"Case {i}: {x}")
        i += 1


if __name__ == '__main__':
    main()
import sys
d={' ':'101',"'":'000000',',':'000011','-':'10010001','.':'010001','?':'000001','A':'100101','B':'10011010','C':'0101','D':'0001','E':'110',
'F':'01001','G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100','M':'10011001','N':'10011110','O':'00101','P':'111',
'Q':'10011111','R':'1000','S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010','Y':'10010011','Z':'10010000'}

a='101'.join(''.join(d[c]for c in e.strip())for e in sys.stdin)
l=len(a)+4
b=a.ljust(l//5*5,'0')
print(''.join("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"[int(b[i:i+5],2)]for i in range(0,l,5)))


### FIXED CODE ###

import sys
d={' ':'101',"'":'000000',',':'000011','-':'10010001','.':'010001','?':'000001','A':'100101','B':'10011010','C':'0101','D':'0001','E':'110',
'F':'01001','G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100','M':'10011001','N':'10011110','O':'00101','P':'111',
'Q':'10011111','R':'1000','S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010','Y':'10010011','Z':'10010000'}
for e in sys.stdin:
 a=''.join(d[c]for c in e[:-1])
 a+='0'*(-len(a)%5)
 print(''.join("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"[int(a[i*5:i*5+5],2)]for i in range(len(a)//5)))
S=input()
hantei=False
if(len(set(S))==2):
    if(SS[0]==SS[1] and SS[0]!=SS[2]):
        hantei=True
    else:
        hantei=False
else:
    hantei=False
SS=sorted(S)

if(hantei==True):
    print("Yes")
else:
    print("No")
    

### FIXED CODE ###

S=input()
hantei=False
SS=sorted(S)
if(len(set(S))==2):
    if(SS[0]==SS[1] and SS[0]!=SS[2]):
        hantei=True
    else:
        hantei=False
else:
    hantei=False


if(hantei==True):
    print("Yes")
else:
    print("No")
n=input()
a=[]
for i in range(1,10**5):
  a+=i
  if a>=n:
    break
print(i)

### FIXED CODE ###

n=int(input())
a=0
for i in range(1,10**5):
  a+=i
  if a>=n:
    break
print(i)
mod=1000000007
n,m=map(int,input().split())
a=[]
af=0
for i in range(m):
    a.append(int(input()))
if len(a)>0:
    a.sort()
    af=1
f=0
for i in range(len(a)):
    if a[i]+1 in a:
        f=1
        break
if f==1:
    print(0)
else:
    dp=[0]*(n+1)
    dp[0]=1
    if 1 in a:
        dp[1]=0
        a.pop(0)
    else:
        dp[1]=1
    
    for i in range(2,n+1):
        if af==1 and i==a[0]:
            dp[i]=0
            a.pop(0)
        else:
            dp[i]=(dp[i-1]+dp[i-2])%mod
    print(dp[n]%mod)
  

### FIXED CODE ###

l=list(map(int,input().split()))
print(sum(l)-max(l))
import math
N = int(input())
S = []
counterBX = 0
counterXA = 0
counterBXA = 0
counterAB = 0
for i in range(N):
    S.append(input())
    if S[i][0] == 'B' and S[i][-1] != 'A':
        counterBX +=1
    if S[i][0] != 'B' and S[i][-1] == 'A':
        counterXA +=1
    if S[i][0] == 'B' and S[i][-1] == 'A':
        counterBXA +=1
    if len(S[i]) > 1:
        for j in range(len(S[i]) - 1):
            if S[i][j] == 'A' and S[i][j+1] == 'B':
                counterAB +=1
minval = min(counterBX,counterXA)
sa = abs(counterBX - counterXA)

if counterBXA == 0:
    ans = counterAB + min(counterXA,counterBX)
elif counterBXA >=1 and counterXA == 0 and counterBX == 0:
    ans = counterAB + counterBXA - 1
elif counterBXA >=1 and counterXA >=1 and counterBX == 0:
    ans = counterAB + (counterBXA - 1) + 1 + min(counterXA - 1,counterBX)
elif counterBXA >=1 and counterXA == 0 and counterBX >=1:
    ans = counterAB + (counterBXA - 1) + 1 +min(counterXA,counterBX - 1)
else:
    ans = counter(BXA - 1) + 2 + min(counterXA - 1, counterBX - 1)
print(ans)

### FIXED CODE ###

import math
N = int(input())
S = []
counterBX = 0
counterXA = 0
counterBXA = 0
counterAB = 0
for i in range(N):
    S.append(input())
    if S[i][0] == 'B' and S[i][-1] != 'A':
        counterBX +=1
    if S[i][0] != 'B' and S[i][-1] == 'A':
        counterXA +=1
    if S[i][0] == 'B' and S[i][-1] == 'A':
        counterBXA +=1
    if len(S[i]) > 1:
        for j in range(len(S[i]) - 1):
            if S[i][j] == 'A' and S[i][j+1] == 'B':
                counterAB +=1
minval = min(counterBX,counterXA)
sa = abs(counterBX - counterXA)

if counterBXA == 0:
    ans = counterAB + min(counterXA,counterBX)
elif counterBXA >=1 and counterXA == 0 and counterBX == 0:
    ans = counterAB + counterBXA - 1
elif counterBXA >=1 and counterXA >=1 and counterBX == 0:
    ans = counterAB + (counterBXA - 1) + 1 + min(counterXA - 1,counterBX)
elif counterBXA >=1 and counterXA == 0 and counterBX >=1:
    ans = counterAB + (counterBXA - 1) + 1 +min(counterXA,counterBX - 1)
else:
    ans = counterAB + (counterBXA - 1) + 2 + min(counterXA - 1, counterBX - 1)
print(ans)
k, x = int(input())
if k*500 >= x:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

k,x = map(int, input().split())
if k*500 >= x:
  print('Yes')
else:
  print('No')
def gcd(A, B):
    while B != 0:
        A, B = B, A%B
    return A
N, X = map(int, input().split())
x = [abs(int(i) - X) for i in input().split()] 
y = x[0]
for i in range(N):
    if x[i] % y == 0:
        continue
    y = gcd(y, x[i])
print(min(gcd_x))

### FIXED CODE ###

def gcd(A, B):
    if A%B == 0:
        return B
    else:
        return gcd(B, A%B)
N, X = map(int, input().split())
x = [abs(int(i) - X) for i in input().split()] 
if N == 1:
    print(x[0])
    exit()
gcd_x = []
for i in range(N-1):
    gcd_x.append(gcd(x[i], x[i+1]))
print(min(gcd_x))
n=int(input())
A=list(map(int,input().split()))
money=1000
stock=0
buy=0
flag=0
sell=300
if A[0]==max(A):
  print(money)
else:
  for i in range(n):
    if A[i]>buy and stock>0:
      money+=stock*A[i]
      stock=0
      sell=A[i]
      if sell==max(A[i:n+1]):
        flag=1
    elif A[i]<sell and flag==0 and A[i]==min(A[i:A.index(max(A[i:n+1]))]):
      stock=money//A[i]
      money-=stock*A[i]
      buy=A[i]
      sell=0
  print(money)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
money=1000
stock=0
for i in range(n-1):
  if A[i]<A[i+1]:
    stock=money//A[i]
    money-=stock*A[i]
    money+=stock*A[i+1]
print(money)
H, W, K = map(int, input().split())
s = [input() for _ in range(H)]

a = [[-1] * W for _ in range(H)]

sbs = []
n = 1
for i in range(H):
  si = s[i]
  for j in range(W):
    if si[j] == '#':
      a[i][j] = n
      n += 1
      sbs.append((i, j))

for sb in sbs:
  i, j = sb
  n = a[i][j]
  t, l = i - 1, j - 1
  r = j + 1
  while t > -1:
    if a[t][j] != -1:
      break
    t -= 1
  t += 1
  while l > -1:
    if a[i][l] != -1:
      break
    l -= 1
  l += 1
  while r < W:
    if a[i][r] != -1:
      break
    r += 1
  r -= 1
  for l in range(y, i + 1):
    al = a[l]
    for m in range(x, r):
      al[m] = n

for h in range(H - 1, -1, -1):
  if a[h][0] != -1:
    break
h += 1

if h != H:
  for i in range(h, H):
    ai1 = a[i - 1]
    ai = a[i]
    for j in range(W):
      ai[j] = ai1[j]

for i in range(H):
  ai = a[i]
  for w in range(W - 1, -1, -1):
    if ai[w] != -1:
      break
  w += 1

  if w != W:
    n = ai[w - 1]
    for j in range(w, W):
      ai[j] = n

for i in range(H):
  print(*a[i])


### FIXED CODE ###

H, W, K = map(int, input().split())
s = [input() for _ in range(H)]

a = [[-1] * W for _ in range(H)]

sbs = []
n = 1
for i in range(H):
  si = s[i]
  for j in range(W):
    if si[j] == '#':
      a[i][j] = n
      n += 1
      sbs.append((i, j))

for sb in sbs:
  i, j = sb
  n = a[i][j]
  t, l = i - 1, j - 1
  r = j + 1
  while t > -1:
    if a[t][j] != -1:
      break
    t -= 1
  t += 1
  while l > -1:
    if a[i][l] != -1:
      break
    l -= 1
  l += 1
  while r < W:
    if a[i][r] != -1:
      break
    r += 1
  r -= 1
  for y in range(t, i + 1):
    ay = a[y]
    for x in range(l, r + 1):
      ay[x] = n

for h in range(H - 1, -1, -1):
  if a[h][0] != -1:
    break
h += 1

if h != H:
  for i in range(h, H):
    ai1 = a[i - 1]
    ai = a[i]
    for j in range(W):
      ai[j] = ai1[j]

for i in range(H):
  ai = a[i]
  for w in range(W - 1, -1, -1):
    if ai[w] != -1:
      break
  w += 1

  if w != W:
    n = ai[w - 1]
    for j in range(w, W):
      ai[j] = n

for i in range(H):
  print(*a[i])
import sys
for a,b,c in map(lambda x:sorted(map(int,x.split())),sys.stdin):
 print(['NO','YES'][a*a+b*b==c*c])


### FIXED CODE ###

import sys
input()
for a,b,c in map(lambda x:sorted(map(int,x.split())),sys.stdin):
 print(['NO','YES'][a*a+b*b==c*c])
S = input()
a = [chr(i) for i in range(97, 97+26)]
for s in S:
    if s in a:
        a.remove(s)

print(a[0])


### FIXED CODE ###

S = input()
a = [chr(i) for i in range(97, 97+26)]
for s in S:
    if s in a:
        a.remove(s)
if len(a) == 0:
    print('None')
else:
    print(a[0])
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=I()
A=LI()
B = []
counts = collections.Counter(A)
for count in counts.items():
    if count[1] >= 2:
        B.append(count)
B.sort(reverse=True)
if len(B) ==0:
    print(0)
elif len(B) == 1:
    if B[0][1] >= 4:
        print(B[0][0]**2)
    else:
        print(0)
else:
    if B[0][1] >= 4:
        print(B[0][0]**2)
    else:
        print(B[0]*B[1])
    

### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=I()
A=LI()
B = []
counts = collections.Counter(A)
for count in counts.items():
    if count[1] >= 2:
        B.append(count)
B.sort(reverse=True)
if len(B) ==0:
    print(0)
elif len(B) == 1:
    if B[0][1] >= 4:
        print(B[0][0]**2)
    else:
        print(0)
else:
    if B[0][1] >= 4:
        print(B[0][0]**2)
    else:
        print(B[0][0]*B[1][0])
a_list = list(input())
b_list = list(input())
c_list = list(input())
x=a_list.pop(0)
while True:
    if x=="a":
        x = a_list.pop(0)
    elif x == "b":
        x = b_list.pop(0)
    else:
        x = c_list.pop(0)
    if len(a_list)==0:
        print("A")
        break
    elif len(b_list)==0:
        print("B")
        break
    elif len(c_list):
        print("C")
        break

### FIXED CODE ###

a_list = list(input())
b_list = list(input())
c_list = list(input())
x=a_list.pop(0)
while True:
    if x=="a":
        if len(a_list)==0:
            print("A")
            break
        else:
            x = a_list.pop(0)
    elif x == "b":
        if len(b_list)==0:
            print("B")
            break
        else:
            x = b_list.pop(0)
    else:
        if len(c_list)==0:
            print("C")
            break
        else:
            x = c_list.pop(0)
mod = 1000000007

# nの素因数分解

def prime(n):
    d = []
    i = 2
    while n != 1:
        s = 0
        while n % i == 0:
            n /= i
            s += 1
        d.append(s)
        i += 1
    return d

# xのn乗を計算する
def mod_pow(x, n):
    if n == 1:
        return x
    elif n % 2 == 0:
        half_x = mod_pow(x, n // 2)
        return half_x * half_x % mod
    else:
        return x * mod_pow(x, n-1) % mod

fact = [0] * 100099
inv = [0] * 100099
frac[0] = 1
inv[0] = 1
for k in range(1, 100099):
    fact[k] = fact[k-1] * k % mod
    inv[k] = mod_pow(fact[k], mod-2)

def nCr(n, r):
    return fact[n] * inv[r] % mod * inv[n-r] % mod

def solve():
    N, M = map(int, input().split())
    p = prime(M)
    s = 1
    for i in p:
        s *= nCr(i + N - 1, N - 1)
        s %= mod
    print(s)

solve()

### FIXED CODE ###

from collections import Counter

mod = 1000000007

# nの素因数分解

def prime(n):
    d = Counter()
    i = 2
    while i*i <= n:
        while n%i == 0:
            n //= i
            d[i] += 1
        i += 1
    if n > 1:
        d[n] += 1
    return d

# xのn乗を計算する
def mod_pow(x, n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        half_x = mod_pow(x, n // 2)
        return half_x * half_x % mod
    else:
        return x * mod_pow(x, n-1) % mod

fact = [1] * 100100
inv = [1] * 100100
for k in range(1, 100100):
    fact[k] = fact[k-1] * k % mod
    inv[k] = mod_pow(fact[k], mod-2)

def nCr(n, r):
    return fact[n] * inv[r] % mod * inv[n-r] % mod

def solve():
    N, M = map(int, input().split())
    p = prime(M)
    s = 1
    for i in p.values():
        s *= nCr(i + N - 1, N - 1)
        s %= mod
    print(s)

solve()
ai = lambda: list(map(int, input().split()))

n,m = ai()
edge = []
for _ in range(m):
    a,b,c = ai()
    edge.append((a-1, b-1, -c))

import networkx as nx
G = nx.DiGraph()
G.add_weighted_edges_from(edge)
if nx.negative_edge_cycle(G):
    print('inf')
else:
    print(-nx.bellman_ford_path_length(G, source=0, target=n-1))


### FIXED CODE ###

ai_ = lambda: [int(x)-1 for x in input().split()]
ai = lambda: list(map(int, input().split()))

n,m = ai()

from collections import defaultdict as dd
edge = dd(list)
for _ in range(m):
    a,b,c = ai()
    edge[a-1].append([b-1, -c])

dist = [float('inf')] * n
dist[0] = 0

for i in range(n):
    for cur_v in range(n):
        for v, c in edge[cur_v]:
            if dist[v] > dist[cur_v] + c:
                dist[v] = dist[cur_v] + c
                if i == n-1 and v == n-1:
                    print('inf')
                    exit()
print(-dist[-1])
r=map(int,input())
print(r*r)

### FIXED CODE ###

r=int(input())
print(int(r**2))
N, K = map(int, input().split())
L = []
for i in range(N):
    a, b = map(int, input().split())
    L.append(a)
    L.append(b)
    
L = sorted(L)
print(L[K+1])

### FIXED CODE ###

N, K = map(int, input().split())
d = [0]*(10**5+1)
sum_d = 0

for _ in range(N):
    a, b = map(int, input().split())
    d[a] += b

for i in range(1, 10**5+1):
    sum_d += d[i]
    if(sum_d >= K):
        print(i)
        break
a,b=map(int,input().split())
x=[0,0,-1,1]
y=[-1,1,0,0]
d=[[0]*a for x in range(b)]
for i in range(b):
    d[i]=list(input())
    
result="Yes"

for i in range(b):
    for j in range(a):
        if d[i][j] == '#':
            check=0
            for xv,yv in zip(x,y):
                if 0 <= xv + j < a  and 0 <= yv + i < b:
                    if d[i+yv][j+xv] == '#':
                        check=1
                        break
            if check==0:
                result="No"
                        
print(result)


### FIXED CODE ###

N,M = map(int, input().split())
boards = [None] * N
passed = [[False] * M for i in range(N)]
for i in range(N):
    boards[i] = list(input())
for i in range(N):
    for j in range(M):
        if boards[i][j] == '#':
            if ((i < N - 1 and boards[i+1][j] == '#') or 
                (i >= 1 and boards [i-1][j] == '#') or 
                (j < M - 1 and boards[i][j+1] == '#') or
                (j >= 1 and boards[i][j-1] == '#')):
                    continue
            else:
                print('No')
                exit()
print('Yes')
a = list(map(int,input().split()))

if sum(a) >=22:
    print(bust)
else:
    print(win)

### FIXED CODE ###

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

if sum(a) >= 22:
    print("bust")
else:
    print("win")
A,B = map(int,input().split())

if A+B>=10:
    print('error')
else:
    print(A+b)

### FIXED CODE ###

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

if A+B>=10:
    print('error')
else:
    print(A+B)
def solve():
    ans = 0
    n=int(input())
    for i in range(1,n+1):
        div_list = []
        for j in range(1,int(i**0.5)+1):
            if i%j!=0:
                continue
            if i//j==j:
                div_list.append(j)
            else:
                div_list.append(i//j)
                div_list.append(j)
        if len(div_list)==8:
            ans=+=1
    print(ans)

if __name__ == '__main__':
    solve()

### FIXED CODE ###

ans = 0
def solve(n):
    global ans
    for i in range(1,n+1,2):
        div_list=[]
        for j in range(1,int((i+1)**0.5)+1):
            if i % j == 0:
                if (i//j)!=j:
                    div_list.append(i//j)
                    div_list.append(j)
                else:
                    div_list.append(j)
        if len(div_list) == 8:
            ans+=1

def main():
    n=int(input())
    solve(n)
    print(ans)

if __name__=='__main__':
    main()
import statistics
while True:
  input()
  print(statistics.stdev(map(int, input().split()))

### FIXED CODE ###

import math

while True:
    n = int(input())
    if n == 0:
        break
    points = list(map(int, input().split()))

    m = sum(points) / n
    variance = sum(map(lambda x: (x - m) ** 2, points)) / n
    standard_deviation = math.sqrt(variance)
    print(standard_deviation)
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
from heapq import heappush,heappop,heapify

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(W) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[(1,1),(-1,1),(1,-1),(-1,-1),(2,0),(-2,0),(0,2),(0,-2),(1,2),(-1,2),(1,-2),(-1,-2),(2,1),(-2,1),(2,-1),(-2,-1),(2,2),(-2,2),(2,-2),(-2,-2)]

#隣接リスト
al=defaultdict(lambda: [])

for h in range(H):
    for w in range(W):
        for dh,dw in D:
            if 0<=h+dh<H and 0<=w+dw<W:
                if S[h+dh][w+dw]==".":
                    al[(h,w)].append((0,h+dh,w+dw))    #コスト,toの座標
        for dh,dw in WARP:
            if 0<=h+dh<H and 0<=w+dw<W:
                if S[h+dh][w+dw]==".":
                    al[(h,w)].append((1,h+dh,w+dw))    #コスト,toの座標 ワープはコスト1

d=defaultdict(lambda: float("inf"))    #(h,w):kyori スタート地点からその点までの距離

def dij(x,y):
	d[(x,y)]=0
	hq=[]
	heappush(hq,(0,x,y))
	while hq:
		cost,fro_x,fro_y=heappop(hq)
		for cost,to_x,to_y in al[(fro_x,fro_y)]:
			alt=d[(fro_x,fro_y)]+cost
			if alt<d[(to_x,to_y)]:
				d[(to_x,to_y)]=alt
				heappush(hq, (alt,to_x,to_y))

dij(CH,CW)
if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((0,CH,CW))
d[(CH,CW)]=0

while q:
    kyori, fro_h, fro_w=q.popleft()
    if d[(fro_h, fro_w)]<kyori: continue
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori
                q.appendleft((kyori, to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori+1 < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori+1
                q.append((kyori+1, to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]
# -*- coding: utf-8 -*-


def linerSearch(S, key):
    tmp = S[::1]
    i = 0
    tmp.append(key)
    while S[i] != key:
        i += 1
    if i == len(tmp)-1:
        return False
    return True

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

count = 0

for i in range(q):
    if linerSearch(S, T[i]):
        count += 1

print(count)

### FIXED CODE ###

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


def linerSearch(S, key):
    i = 0
    S.append(key)
    while S[i] != key:
        i += 1
    if i == len(S)-1:
        S.pop()
        return False
    S.pop()
    return True

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

count = 0

for i in range(q):
    if linerSearch(S, T[i]):
        count += 1

print (count)
n=input()
if n=='AAA' or n=='BBB':
	print('No')
else:
	pritn('Yes')


### FIXED CODE ###

S=input()
if S=="AAA" or S=="BBB":
  print("No")
else:print("Yes")
N, M = map(int, input())

if N == M:
    print("Yes")

else:
    print("No")

### FIXED CODE ###

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

if N == M:
    print("Yes")

else:
    print("No")
from Decimal import *
a,b = map(Decimal,input().split())
print(int(a*b))

### FIXED CODE ###

from decimal import *
a,b = map(Decimal,input().split(' '))
print(int(a*b))
while True:
    a = list(map(int, input().split()))
    b = a[0]
    c = a[1]
    if b == c == 0:
        break
    for i in range(1,b+1):
        if i % 2 != 0:
            if c % 2 == 0:
                print('#.' * (c / 2))
            else:
                print('#.' * ((c - 1) / 2) + '#')
        else:
            if c % 2 == 0:
                print('.#' * (c / 2))
            else:
                print('.#' * ((c - 1) / 2) + '.')
    print()

### FIXED CODE ###

while True:
    a = list(map(int, input().split()))
    b = a[0]
    c = a[1]
    if b == c == 0:
        break
    for i in range(1, b+1):
        if i % 2 != 0:
            if c % 2 == 0:
                print('#.' * (c // 2))
            else:
                print('#.' * (c // 2) + '#')
        else:
            if c % 2 == 0:
                print('.#' * (c // 2))
            else:
                print('.#' * (c // 2) + '.')
    print()
import math
r = int(input())
print(2 * math.pi r)

### FIXED CODE ###

import math
r = int(input())
print(2 * math.pi * r)