Harryxun/stf_run huggingface dataset:
n=int(input())
E=[[] for _ in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    E[a].append([b,i])
    E[b].append([a,i])
k=0
for e in E:
    k=max(k,len(e))
ans=[0]*(n-1)
def dsf(v,p,vp_c):
    c=1
    for u,i in E[v]:
        if u!=p:
            if c==vp_c:
                c+=1
            ans[i]=c
            dsf(u,v,c)
            c+=1
dsf(1,0,0)
print(k)
for i in range(n-1):
    print(ans[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)
n=int(input())
E=[[] for _ in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    E[a].append([b,i])
    E[b].append([a,i])
k=0
for e in E:
    k=max(k,len(e))
ans=[0]*(n-1)
def dsf(v,p,vp_c):
    c=1
    for u,i in E[v]:
        if u!=p:
            if c==vp_c:
                c+=1
            ans[i]=c
            dsf(u,v,c)
            c+=1
dsf(1,0,0)
print(k)
for i in range(n-1):
    print(ans[i])
A, B, C, D = map(int, input().split())
 
flg = true
t = false
while(flg):
  t = true
  C -= B
  if (C <= 0):
    break
  t = false
  A -= D
  if (A <= 0) :
    break

if (t):
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

A, B, C, D = map(int, input().split())
 
flg = True
t = False
while(flg):
  C -= B
  if (C <= 0):
    t = True
    break
  A -= D
  if (A <= 0) :
    t = False
    break

if (t):
  print("Yes")
else:
  print("No")
import math
from itertools import permutations
import numpy as np
#from scipy.sparse import*

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    n=len(d[0])
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

N,M,R=[int(x) for x in input().split()]
r=[int(x)-1 for x in input().split()]

#route_list=[[10*9]*N for i in range(N)]
route_list = np.full(10*8,(N,N),dtype=np.int)


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

wa_list=warshall_floyd(route_list)
ans=10**9

for perm in permutations(r):
    #print(perm)
    cur = sum(wa_list[v][u] for v, u in zip(perm, perm[1:]))
    ans = min(ans, cur)

print(ans)

### FIXED CODE ###

import math
from itertools import permutations

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    n=len(d[0])
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

N,M,R=[int(x) for x in input().split()]
r=[int(x)-1 for x in input().split()]

route_list=[[10**9]*N for i in range(N)]

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

wa_list=warshall_floyd(route_list)
ans=30**9

for perm in permutations(r):
    #print(perm)
    cur = sum(wa_list[v][u] for v, u in zip(perm, perm[1:]))
    ans = min(ans, cur)

print(ans)
from sys import stdin
A, B, C, K = [int(_) for _ in stdin.readline().rstrip().split()]
L = [1]*A+[0]*B+[-1]*C
print(L[:K])

### FIXED CODE ###

from sys import stdin
A, B, C, K = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
if K <= A:
    ans = K
elif K <= A+B:
    ans = A
else:
    ans = A-K+A+B
print(ans)
X = input()
print('Yes' if X % sum(map(int, X)) == 0 else 'No')

### FIXED CODE ###

X = input()
print('Yes' if int(X) % sum(map(int, X)) == 0 else 'No')
from bisect import bisect_right
import sys
input = sys.stdin.readline

class BIT:
    '''
    区間加算BIT(区間加算・区間合計取得) 
    '''
    def __init__(self, N):
        # 添え字0は使えないので1-indexとして扱う
        N += 1
        self.N = N
        self.data0 = [0] * N
        self.data1 = [0] * N

    def _add(self, data, k, x):
        k += 1
        while k < self.N:
            data[k] += x
            k += k & -k

    def _get(self, data, k):
        k += 1
        s = 0
        while k:
            s += data[k]
            k -= k & -k
        return s

    def add(self, l, r, x):
        # 区間[l,r)に値xを追加

        self._add(self.data0, l, -x*(l-1))
        self._add(self.data0, r, -x*(r-1))
        self._add(self.data1, l, x)
        self._add(self.data1, r, -x)

    def query(self, l, r):
        # 区間[l,r)の和を取得
        return self._get(self.data1, r-1) * (r-1) + self._get(self.data0, r-1) \
            - self._get(self.data1, l-1) * (l-1) - self._get(self.data0, l-1)

def main():
    N, D, A = map(int, input().split())
    B = []

    for i in range(N):
        x, h = map(int, input().split())
        B.append((x,h))

    B.sort()
    X = [0] * N
    H = [0] * N
    for i in range(N):
        X[i], H[i] = B[i]

    bit = BIT(N)
    for i in range(N):
        H[i] -= bit.query(i, i+1)
        if H[i] <= 0:
            continue
        cnt = H[i] // A if H[i] % A == 0 else H[i] // A + 1
        index = bisect_right(X, X[i] + 2 * D)
        bit.add(i, index+1, cnt * A)
        ans += cnt

    print(ans)



if __name__ == "__main__":
    main()

### FIXED CODE ###

from bisect import bisect_right
import sys
input = sys.stdin.readline

def main():
    N, D, A = map(int, input().split())
    B = []

    for i in range(N):
        x, h = map(int, input().split())
        B.append((x,h))

    B.sort()
    X = [0] * N
    H = [0] * N
    for i in range(N):
        X[i], H[i] = B[i]
    ans = 0
    ok = [False] * N
    S = [0] * (N + 1)
    for i in range(N):
        if S[i] < H[i]:
            cnt = (H[i] - S[i]) // A if (H[i] - S[i]) % A == 0 else (H[i] - S[i]) // A + 1
            ans += cnt
            search_max = bisect_right(X, X[i] + 2 * D)
            S[i] += cnt * A
            S[search_max] -= cnt * A
        
        S[i+1] += S[i]

    print(ans)



if __name__ == "__main__":
    main()
from collections import defaultdict
from itertools import accumulate
import numpy as np

h, w, d = map(int, input().split())
arr = np.zeros([h, w], dtype=np.int64)

for i in range(h):
    arr[i] = list(map(int, input().split()))

q = int(input())
lr = np.zeros([q, 2], dtype=np.int64)

for i in range(q):
    lr[i] = list(map(int, input().split()))


result = defaultdict(list)

for i in range(d):
    l = i
    while l + d <= h * w:
        if l == 0:
            result[i].append(0)
            l += d
            continue
        u = np.where(arr == l)
        v = np.where(arr == l + d)
        result[i].append(abs(v[0][0] - u[0][0]) + abs(v[1][0] - u[1][0]))
        l += d

for i in range(d):
    result[i] = list(accumulate(result[i]))

ans = []
for l, r in lr:
    arr = result[l % d]
    ans.append(arr[r // d - 1] - arr[l // d - 1])

print(*ans, sep="\n")

### FIXED CODE ###

h, w, d = map(int, input().split())
arr = [0] * (h * w + 1)

a = [list(map(int, input().split())) for _ in range(h)]

for i in range(h):
    for j in range(w):
        s = a[i][j]
        arr[s] = (i, j)

q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

cnt = h * w
result = [[0] for _ in range(d)]
for i in range(d):
    l = i
    score = 0
    while l + d <= cnt:
        if l == 0:
            result[i].append(score)
            l += d
            continue
        (ux, uy) = arr[l]
        (vx, vy) = arr[l + d]
        score += (abs(vx - ux) + abs(vy - uy))
        result[i].append(score)
        l += d


for l, r in lr:
    ans = result[l % d]
    print(ans[r // d] - ans[l // d])
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.insert(場所,要素)
-1で末尾で末尾から一つ前
'''


num = int(stdin.readline().rstrip())
data = stdin.readline().rstrip().split()
res = ''
for el in range(1, num + 1):
    res += str(data.index(str(el)) + 1)
    if (el != num + 1):
        res += ' '
print(res)


### FIXED CODE ###

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.insert(場所,要素)
-1で末尾で末尾から一つ前
'''


N = int(stdin.readline().rstrip())
T = list(range(1, N+1))
t = len([x for x in T if x % 2 == 1])
print(t/len(T))
a,b,k = map(int,input().split())
c = []
for i in range(max(a,b)//2):
  if a%(i+1) == 0 and b%(i+1) == 0:
    c.append(i+1)
c.sort(reverse = True)
print(c[k-1])

### FIXED CODE ###

a,b,k = map(int,input().split())
c = []
for i in range(min(a,b)+1):
  if a%(i+1) == 0 and b%(i+1) == 0:
    c.append(i+1)
c.sort(reverse = True)
print(c[k-1])
import sys
lis =list()
lis.append([0, 0, 0])
sys.stdin.readline()
for e in sys.stdin:
  lis.append(list(map(int, input().split())))
for i in range(len(lis) - 1):
  d_t = lis[i + 1][0] - lis[i][0]
  man_dis = abs(lis[i + 1][1] - lis[i][1]) + abs(lis[i + 1][2] - lis[i][2])
  if d_t < man_dis or d_t % 2 - man_dis % 2 != 0:
    print("No")
    sys.exit()
print("Yes")

### FIXED CODE ###

import sys
lis =list()
lis.append([0, 0, 0])
sys.stdin.readline()
for e in sys.stdin:
  lis.append(list(map(int, e.split())))
for i in range(len(lis) - 1):
  d_t = lis[i + 1][0] - lis[i][0]
  man_dis = abs(lis[i + 1][1] - lis[i][1]) + abs(lis[i + 1][2] - lis[i][2])
  if d_t < man_dis or d_t % 2 - man_dis % 2 != 0:
    print("No")
    sys.exit()
print("Yes")
import collections as c
ip = lambda : map(int, input().split())
# ##############
N = int(input())
l = list(ip())
d = []
for i in range(N-1):
    d.append(l[i+1]-l[i])

ans = 0;mod = 1e9+7;c=0;l=1
for i in range(N-1):
    c = (i+1)*c + l
    ans = (i+1)*ans + c*d[i]
    ans%=mod
    l *= i+1
print(int(ans%mod))

### FIXED CODE ###

import collections as c
ip = lambda : map(int, input().split())
# ##############
N = int(input())
l = list(ip())
d = []
for i in range(N-1):
    d.append(l[i+1]-l[i])

ans = 0
mod = int(1e9+7)
c=0
l=1
for i in range(N-1):
    c = ((i+1)*c + l)%mod
    ans = ((i+1)*ans + c*d[i])%mod
    l = l*(i+1)%mod
print(ans)
import bisect

def LIS(lis):

    seq = []

    for c in lis:
        ind = bisect.bisect_left(seq,c)

        if ind == len(seq):
            seq.append(c)
        else:
            seq[ind] = c

    return len(seq)


N = int(input())

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

lis = [ [] for i in range(N) ]

for i in range(N-1):

    u,v = map(int,input().split())
    u -= 1
    v -= 1

    lis[u].append(v)
    lis[v].append(u)

ans = [None] * N

def dfs(v,p,ln):

    ind = bisect.bisect_left(ln,a[v])

    if ind == len(ln):
        mt = None
        ln.append(a[v])
    else:
        mt = ln[ind]
        ln[ind] = a[v]

    ans[v] = len(ln)

    for nex in lis[v]:

        if nex != p:
            dfs(nex,v,ln)

    if mt == None:
        del ln[-1]
    else:
        ln[ind] = mt

    return

dfs(0,0,[])

for i in range(N):
    print (ans[i])
    

### FIXED CODE ###


import bisect
import sys
sys.setrecursionlimit(500000)

def LIS(lis):

    seq = []

    for c in lis:
        ind = bisect.bisect_left(seq,c)

        if ind == len(seq):
            seq.append(c)
        else:
            seq[ind] = c

    return len(seq)


N = int(input())

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

lis = [ [] for i in range(N) ]

for i in range(N-1):

    u,v = map(int,input().split())
    u -= 1
    v -= 1

    lis[u].append(v)
    lis[v].append(u)

ans = [None] * N

def dfs(v,p,ln):

    ind = bisect.bisect_left(ln,a[v])

    if ind == len(ln):
        mt = None
        ln.append(a[v])
    else:
        mt = ln[ind]
        ln[ind] = a[v]

    ans[v] = len(ln)

    for nex in lis[v]:

        if nex != p:
            dfs(nex,v,ln)

    if mt == None:
        del ln[-1]
    else:
        ln[ind] = mt

    return

dfs(0,0,[])

for i in range(N):
    print (ans[i])
class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]

	def find(self, x):
		while self.table[x] >= 0:
			x = self.table[x]
		return x

	def union(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 == s2:
			return
		else:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
			elif self.table[s1] < self.table[s2]:
				self.table[s1] = s2
			else:
				self.table[s1] = s2
				self.table[s2] -= 1


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

uf = UnionFind(n)

for i in range(m):
	x, y = map(int, input().split())
	uf.union(x - 1, y - 1)

ans = 0
for i, pp in enumerate(p):
	if pp - 1 == i:
		ans += 1
	elif uf.find(pp - 1) == uf.find(i):
		ans += 1

print(ans)

### FIXED CODE ###

s = list(input())
K = int(input())

subs = list()

for k in range(K):
	for i in range(len(s) - k):
		subs.append("".join(s[i : i + k + 1]))

subs = sorted(set(subs))
print(subs[K - 1])
import math
N, a, b = map(int,input().split())
p = 10 ** 9 +7
a_c = 1
b_c = 1
a_m = 1
b_m = 1
for i in range(a):
  a_c = a_c * (N-i) % p
  a_m = a_m * (i+1) % p
  m_a = a_c * pow(a_m, p-2, p) % p
for j in rnage(b):
  b_c = b_c * (N-j) % p
  b_m = b_m * (j+1) % p
  m_b = b_c * pow(b_m,p-2,p) % p
print((pow(2,N, p) - 1 - m_a - m_b) % p)


### FIXED CODE ###

N, a, b = map(int,input().split())
p = pow(10,9) + 7
def comb(n,r):
  bunshi = 1
  for i in range(n-r+1, n+1):
    bunshi =bunshi * i % p
  bunbo = 1
  for i in range(1, r+1):
    bunbo = bunbo * i % p
  return bunshi * pow(bunbo, p-2, p)
print((pow(2,N, p) - 1 - comb(N,a) - comb(N,b)) % p)
N, M = map(int, input().split())
L = []
R = []
D = []
for i in range(M):
    l, r, d = map(int, input().split())
    L.append(l)
    R.append(r)
    D.append(d)

inf = float("inf")


class WDG():  # 重み付き有向グラフ(隣接リスト表現)
    class node():
        def __init__(self, index=0, weight=0, next=None):
            self.index = index
            self.weight = weight
            self.next = next

    def __init__(self, N, M, L, R, D):
        self.heads = []
        self.x = [None] * N
        self.N = N
        for i in range(N):
            head = WDG.node()
            head.next = head
            head.index = i
            self.heads.append(head)
        for i in range(M):
            new1 = WDG.node(R[i] - 1, D[i], head)
            #new2 = WDG.node(L[i] - 1, -D[i], head)
            self.insert(L[i] - 1, new1)
            #self.insert(R[i] - 1, new2)

    def insert(self, start, new):
        new.next = self.heads[start].next
        self.heads[start].next = new

    def show_graph(self):
        for i in self.heads:
            node = i.next
            print("{}=>".format(i.index + 1), end="")
            while node != i:
                print("{}({})".format(node.index + 1, node.weight), end=" ")
                node = node.next
            print("")

    def _DFS(self, s_head):  # 始点sから到達できる連結成分を深さ優先探索
        node = s_head.next
        while node != s_head:
            new_x = self.x[s_head.index] + node.weight
            if self.x[node.index] is not None and self.x[node.index] != new_x:
                return False
            elif self.x[node.index] == new_x:
                pass
            else:
                #print("node{}".format(node.index + 1))
                self.x[node.index] = new_x
                self._DFS(self.heads[node.index])
            node = node.next
        return True

    def DFS(self):  # すべての点を訪れるまで深さ優先探索
        for i in range(self.N):
            #print("{}個目の連結成分".format(i + 1))
            node = self.heads[i]
            if self.x[node.index] is None:
                self.x[node.index] = 0
                if not self._DFS(self.heads[node.index]):
                    return "No"
        return "Yes"


G = WDG(N, M, L, R, D)
# G.show_graph()
print(G.DFS())


### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
    l, r, d = map(int, input().split())
    G[l - 1].append((r - 1, d))
    G[r - 1].append((l - 1, -d))
q = deque()

x = [None] * N


def _BFS(start):
    q.append(start)
    while len(q) != 0:
        p = q.popleft()
        for index, d in G[p]:
            if x[index] is None:
                x[index] = x[p] + d
                q.append(index)
            elif x[index] != x[p] + d:
                return False
    return True


def BFS():
    for i in range(N):
        if x[i] is None:
            x[i] = 0
            if not _BFS(i):
                return "No"
    return "Yes"


print(BFS())
#解答２
N = int(input())
H = list(map(int,input().split()))
stp = 0
for i in range(N-1):
    if H[i] == H[i+1]+1:#そのままforループ。次が１だけ低ければ１足して、
        H[i+1] += 1　　　
    elif H[i+1] >= H[i]:#同じ高さ以上なら無問題、
         pass
    else:#２以上低ければアウト
        stp += 1
        print("No")
        break
if stp == 0:
    print("Yes")

### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
stp=0
for i in range(N-1,0,-1):
    if H[i]+1 == H[i-1]:
        H[i-1]-=1
    elif H[i] >= H[i-1]:
        pass
    elif H[i] < H[i-1]+1:
        print("No")
        stp = 1
        break
if stp != 1:
    print("Yes")
N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    grid.append(array)
list_N = list(range(1,N+1))
grid.sort()
a = 0
count = 0
for j in range(N) :
  list_a = list(range(grid[j][0]-grid[j][1]+1, grid[j][0]+grid[j][1]-1))
  list_b = list(set(list_a) - set(list_N))
  if list_b == []:
    list_N = list(set(list_N) - set(list_a))
    count += 0
  else:
    count += 1
print(count)

### FIXED CODE ###

h = int(input())
w = int(input())
n = int(input())
a = max(h,w)
b = a
count = 0
if h*w == n:
  print(h)
elif b >= n:
  print(1)
else:
 while b*count < n:
   count += 1
 print(count)
import functools
import math

def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(input())
    A = list(map(int, input().split()))
  else:
    # N = 3
    # A = [7,6,8]
    # N = 3
    # A = [12,15,18]
    N = 2
    A = [1000000000,1000000000]

  x = 0
  for i in range(N):
    tmp = functools.reduce(math.gcd, A[0:i]+A[i+1:])
    if tmp > x:
      x = tmp
  
  print(x)
  
main()

### FIXED CODE ###

import functools
import fractions

def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(input())
    A = list(map(int, input().split()))
  else:
    # N = 3
    # A = [7,6,8]
    N = 3
    A = [12,15,18]
    # N = 3
    # A = [1,1000000000,1000000000]

  AL = [0] * N    
  AR = [0] * N
  for i in range(N):
    if i != 0:
      AL[i] = fractions.gcd(AL[i-1],A[i])
    else:
      AL[i] = A[i]
    j = N - i - 1
    if j!= N - 1:
      AR[j] = fractions.gcd(AR[j+1],A[j])
    else:
      AR[j] = A[j]
      
  if 'get_ipython' in globals():   
    print(AL)
    print(AR)
  
  x = 0
  for i in range(N):
    if i == 0:
      tmp = AR[i+1]
    elif i == N - 1:
      tmp = AL[i-1]
    else:
      tmp = fractions.gcd(AL[i-1],AR[i+1])
    if tmp > x: x = tmp
  
  print(x)
    
main()
n = input()
if n = 999:
   print("111")
elif n = 991:
    print("119")
elif n = 911:
    print("199")
elif n = 919:
    print("191")
elif n = 199:
    print("911")
elif n = 191:
    print("919")
elif n = 199:
    print("911")
eise:
    print("999")

### FIXED CODE ###

n = int(input())
if (n == 999):
   print("111")
elif (n == 991):
    print("119")
elif (n == 911):
    print("199")
elif (n == 919):
    print("191")
elif (n == 199):
    print("911")
elif (n == 191):
    print("919")
elif (n == 199):
    print("911")
elif (n == 119):
    print("991")
elif (n == 111):
    print("999")
N, T = map(int, input().split())
min_c = 10**5
for n in range(N):
    c, t = map(int, input().split())
    if t <= T:
        min_c = min(min_c, c)

if count == 1001:
    print(min_c)
else:
    print('TLE')

### FIXED CODE ###

N, T = map(int, input().split())
min_c, count = 1000, 0
for n in range(N):
    c, t = map(int, input().split())
    if t <= T:
        count += 1
        min_c = min(min_c, c)

if count != 0:
    print(min_c)
else:
    print('TLE')
c = input()

print(chr(c + 1))

### FIXED CODE ###

c = input()

print(chr(ord(c) + 1))
N=int(input())
A=int(input())
B=int(input())

if N == 1:
  print("Hello World")
elif N == 2:
  print(A+B)

### FIXED CODE ###

N=int(input())

if N == 1:
  print("Hello World")
elif N == 2:
	A=int(input())
	B=int(input())
	print(A+B)
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if sl[0] != 'A':
    ans = 'WA'
if sl[2:-1].count('C') != 1:
    ans = 'WA'

if sl[1:].replace("C","c",1).islower() == False:
    ans = 'WA'
#print(sl)
print(ans)

### FIXED CODE ###

S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if S[0] != 'A':
    ans = 'WA'
if S[2:-1].count('C') != 1:
    ans = 'WA'

if S[1:].replace("C","c",1).islower() == False:
    ans = 'WA'
#print(sl)
print(ans)
import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
h = logging.FileHandler("logtest.log")
logger.addHandler(h)

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

# ゴーレムのいる位置
# 同じマスに複数いる可能性もあり
s_1 = list(map(str, input()))
s = [[i] for i in s_1]

for i in range(Q):
    # t: name, d: L or R
    t, d = list(map(str, input().split()))
    logger.info("i: {}, t: {}, d: {}".format(i, t, d))
    logger.info("before_s: {}".format(s))

    # tのindex
    t_id_list = []
    for i in range(len(s)):
        if t in s[i]:
            t_id_list.append(i)
    t_id_list = list(set(t_id_list))

    logger.info("t_id_list: {}".format(t_id_list))

    # move
    for t_id in t_id_list:
        logger.info("t_id: {}".format(t_id))
        logger.info("s_now: {}".format(s))

        # 対象のゴーレムtを全て消去する
        for i in range(len(s[t_id])):
            try:
                if s[t_id][i] == t:
                    s[t_id].remove(t)
            except:
                pass
        logger.info("s_remove: {}".format(s))

        if d == "L" and t_id - 1 >= 0:
            s[t_id - 1].append(t)
        elif d == "R" and t_id + 1 <= N:
            s[t_id + 1].append(t)

        logger.info("after_s: {}\n".format(s))

    logger.info("after_s: {}\n".format(s))

cnt = 0
for i in range(len(s)):
    for j in range(len(s[i])):
        if s[i][j] != "":
            cnt += 1
print(cnt)



### FIXED CODE ###

# N, Q = map(int, input().split())
import sys

input = sys.stdin.readline

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

Query = [input().split() for i in range(Q)]

left, right = 0, N - 1

for t, d in reversed(Query):
    if d == "L":
        if t == s[left]:
            left += 1
        if right < N - 1 and t == s[right + 1]:
            right = min(right + 1, N - 1)
    else:
        if left > 0 and t == s[left - 1]:
            left = max(left - 1, 0)
        if t == s[right]:
            right -= 1
print(max(right - left + 1, 0))
def kaijo(x):
    if x>1:
        return x*kaijo(x-1)

    return 1



d=sorted(list(map(int,input().split(" "))))

if abs(d[0]-d[1])>1:
    res=0
elif d[0]==d[1]:

    res=(kaijo(d[0])**2)*2
else:
    res=kaijo(d[1])*kaijo(d[0])

print(res)


### FIXED CODE ###


def Factorial(integer) :
    global M
    product = 1
    if integer == 0 : return 1

    for num in range(1 ,integer + 1):
        product *= num
        product%=M
    return product%M


d=sorted(list(map(int,input().split(" "))))
M=10**9+7

if abs(d[0]-d[1])>1:
    res=0
elif d[0]==d[1]:

    res=((Factorial(d[0])%M)**2)*2
else:
    res=Factorial(d[1])*Factorial(d[0])

print(res%(M))