Language: C++

import Prelude hiding (elem)
import Control.Applicative
import Control.Monad.State
data LazySegTree a =  Leaf a | Elem { eSize :: Int, elem :: a} | Tree { size :: Int
                                                                      , left :: LazySegTree a
                                                                      , right :: LazySegTree a
                                                                      , lazy :: Bool
                                                                      } deriving (Show)

main = do
    [n, q] <- map read.words<$>getLine
    let init = fromList $ replicate n (2^31 - 1)
    print (n,q)
    evalStateT (query q) init

query :: Int -> StateT (LazySegTree Int) IO ()
query 0 = return ()
query n  = do
    getQuery
    query (n-1)

getQuery :: StateT (LazySegTree Int) IO ()
getQuery = do
    (x:xs) <- lift $ map read.words<$>getLine
    case x of
      0 -> let [s,t,x] = xs in modify (\tr -> updateT tr s t x)
      1 -> let [i] = xs in get >>= \tr -> (lift $ print $ findT tr i)

isElem :: LazySegTree a -> Bool
isElem (Elem _ _) = True
isElem _          = False

fromList :: [a] -> LazySegTree a
fromList xs = fl n xs
    where n = length xs

fl :: Int -> [a] -> LazySegTree a
fl n [x] = Leaf x
fl n xs = Tree n leftT rightT True
    where n' = n `div` 2
          (xsL, xsR) = splitAt n' xs
          leftT = fl n' xsL
          rightT = fl (n-n') xsR

updateT :: LazySegTree a -> Int -> Int -> a -> LazySegTree a
updateT (Leaf a) _ _ x = Leaf x
updateT tr s t x
  | isElem tr = elemUpdateT tr s t x
  | n <= s = tr { lazy = False, right = updateT (right tr) (s-n) (t-n) x }
  | n > t  = tr { lazy = False, left = updateT (left tr) s t x }
  | t-s+1 == size tr = Elem (size tr) x
  | otherwise = tr { lazy = False
                   , left = updateT (left tr) s (n-1) x
                   , right = updateT (right tr) 0 (t-n) x
                   }
    where n = size tr `div` 2

elemUpdateT tr s t x
  | eSize tr == 1 = Leaf x
  | n <= s = Tree { size = eSize tr, lazy = False, left = lt, right = elemUpdateT rt (s-n) (t-n) x}
  | n > t = Tree { size = eSize tr, lazy = False, left = elemUpdateT lt s t x, right = rt }
  | t - s + 1 == eSize tr = tr { elem = x }
  | otherwise = Tree { lazy = False
                     , left = elemUpdateT lt s (n-1) x
                     , right = elemUpdateT rt 0 (t-n) x
                     , size = eSize tr
                     }
    where n = eSize tr `div` 2
          lt = Elem n (elem tr)
          rt = Elem (eSize tr - n) (elem tr)

findT (Leaf x) 0 = x
findT tr i
  | isElem tr = elem tr
  | n <= i = findT (right tr) (i-n)
  | n > i = findT (left tr) i
    where n = size tr `div` 2



Compiler output:
a.cc:26:40: error: stray '\' in program
   26 |       0 -> let [s,t,x] = xs in modify (\tr -> updateT tr s t x)
      |                                        ^
a.cc:27:36: error: stray '\' in program
   27 |       1 -> let [i] = xs in get >>= \tr -> (lift $ print $ findT tr i)
      |                                    ^
a.cc:40:12: warning: missing terminating ' character
   40 |     where n' = n `div` 2
      |            ^
a.cc:40:12: error: missing terminating ' character
   40 |     where n' = n `div` 2
      |            ^~~~~~~~~~~~~
a.cc:41:33: warning: missing terminating ' character
   41 |           (xsL, xsR) = splitAt n' xs
      |                                 ^
a.cc:41:33: error: missing terminating ' character
   41 |           (xsL, xsR) = splitAt n' xs
      |                                 ^~~~
a.cc:42:23: warning: missing terminating ' character
   42 |           leftT = fl n' xsL
      |                       ^
a.cc:42:23: error: missing terminating ' character
   42 |           leftT = fl n' xsL
      |                       ^~~~~
a.cc:43:27: warning: missing terminating ' character
   43 |           rightT = fl (n-n') xsR
      |                           ^
a.cc:43:27: error: missing terminating ' character
   43 |           rightT = fl (n-n') xsR
      |                           ^~~~~~
a.cc:56:23: error: stray '`' in program
   56 |     where n = size tr `div` 2
      |                       ^
a.cc:56:27: error: stray '`' in program
   56 |     where n = size tr `div` 2
      |                           ^
a.cc:68:24: error: stray '`' in program
   68 |     where n = eSize tr `div` 2
      |                        ^
a.cc:68:28: error: stray '`' in program
   68 |     where n = eSize tr `div` 2
      |                            ^
a.cc:77:23: error: stray '`' in program
   77 |     where n = size tr `div` 2
      |                       ^
a.cc:77:27: error: stray '`' in program
   77 |     where n = size tr `div` 2
      |                           ^
a.cc:1:1: error: 'import' does not name a type
    1 | import Prelude hiding (elem)
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:64: error: expected unqualified-id before '|' token
    4 | data LazySegTree a =  Leaf a | Elem { eSize :: Int, elem :: a} | Tree { size :: Int
      |                                                                ^
a.cc:8:82: error: expected constructor, destructor, or type conversion before '(' token
    8 |                                                                       } deriving (Show)
      |                                                                                  ^
a.cc:50:3: error: expected unqualified-id before '|' token
   50 |   | n > t  = tr { lazy = False, left = updateT (left tr) s t x }
      |   ^
a.cc:51:3: error: expected unqualified-id before '|' token
   51 |   | t-s+1 == size tr = Elem (size tr) x
      |   ^
a.cc:56:5: error: 'where' does not name a type
   56 |     where n = size tr `div` 2
      |     ^~~~~
a.cc:61:3: error: expected unqualified-id before '|' token
   61 |   | n > t = Tree { size = eSize tr, lazy = False, left = elemUpdateT lt s t x, right = rt }
      |   ^
a.cc:62:3: error: expected unqualified-id before '|' token
   62 |   | t - s + 1 == eSize tr = tr { elem = x }
      |   ^
a.cc:63:3: error: expected unqualified-id before '|' token
   63 |   | otherwise = Tree { lazy = False
      |   ^
a.cc:68:5: error: 'where' does not name a type
   68 |     where n = eSize tr `div` 2
      |     ^~~~~