module Main where

import           Data.Char (isLower)

main :: IO ()
main = interact $ show . f

data Result
  = AC
  | WA
  deriving (Show, Eq)

f :: String -> Result
f s = if isHeadA s && containsC s && isRemainLower s then AC else WA

isHeadA :: String -> Bool
isHeadA ('A' : _) = True
isHeadA _         = False

containsC :: String -> Bool
containsC = (1 ==) . length . filter ('C' ==) . init . drop 2

isRemainLower :: String -> Bool
isRemainLower s =
  let
    middle = filter ('C' /=) . init . drop 2
  in
    all isLower $ (s !! 1 : middle s) ++ [last s]

tests :: [Bool]
tests =
  [ test1
  , test2
  , test3
  , test4
  , test5
  ]

test1, test2, test3, test4, test5 :: Bool
test1 = f "AtCoder" == AC
test2 = f "ACoder" == WA
test3 = f "AcycliC" == WA
test4 = f "AtCoCo" == WA
test5 = f "Atcoder" == WA
