Check if a string is a shuffle of twins
Haskell, 114

main=getLine&gt;&gt;=putStrLn.f.p;f x=head$[a|(a,b)&lt;-x,a==b]++["0"]
p[]=[([],[])];p(x:y)=do(a,b)&lt;-p y;[(x:a,b),(a,x:b)]


Ungolfed:

main :: IO ()
main = getLine &gt;&gt;= putStrLn . findMatch . partitions

-- | Find the first partition where the two subsequences are
-- equal. If none are, return "0".
findMatch :: [(String, String)] -&gt; String
findMatch ps = head $ [a | (a,b) &lt;- ps, a == b] ++ ["0"]

-- | Return all possible partitions of the input into two
-- subsequences. Preserves the order of each subsequence.
--
-- Example:
-- partitions "AB" == [("AB",""),("B","A"),("A","B"),("","AB")]
partitions :: [a] -&gt; [([a], [a])]
partitions []     = [([], [])]
partitions (x:xs) = do (a, b) &lt;- partitions xs
                       [(x:a, b), (a, x:b)]


Explanation:

Most of the work is being done in the partitions function. It works by
recursively generating all partitions (a, b) of the tail of the list,
and then using the list monad to prepend the initial element x to each of
them and gather all the results.

findMatch works by filtering this list so that only partitions where the
subsequences are equal remain. It then returns the first subsequence in the first
partition. If none remain, the list is empty, so the "0" appended at the
end gets returned instead.

main just reads the input, feeds it through these two functions and prints it.