import System.Environment
data Piece = R | B deriving Show
combs s [] = [s]
combs s@(x,nr,nb) ((i,j):cs) = (if safe pr x then combs (pr:x,nr+1,nb) cs else [])
++ (if safe pb x then combs (pb:x,nr,nb+1) cs else [])
++ combs s cs
where pr = (R,i,j) ; pb = (B,i,j)
safe p = not . any (unsafePair p)
unsafePair p1 p2 = underAttack p1 p2 || underAttack p2 p1
underAttack (R,i1,j1) (_,i2,j2) = i1 == i2 || j1 == j2
underAttack (B,i1,j1) (_,i2,j2) = abs (i1 - i2) == abs (j1 - j2)
bestComb c1@(x1,r1,b1) c2@(x2,r2,b2)
| r2 /= 0 && b2 /= 0 && r1 + b1 < r2 + b2 = c2
| otherwise = c1
bishopsUndRooks n = foldl1 bestComb $ combs ([],0,0) cells
where boardSize = n
cells = [(i,j) | i <- [1..boardSize], j <- [1..boardSize]]
main = do args <- getArgs
let n = read $ args!!0 :: Int
print $ bishopsUndRooks n
взял с ixbt а вот что за язык не пойму