[Question]
  [
Countries own a series of territories on a 1D world. Each country is uniquely identified by a number. Ownership of the territories can be represented by a list as follows:
```
1 1 2 2 1 3 3 2 4
```
We define a country's edgemost territories as the two territories closest to either edge. If the above list was zero indexed, country `1`'s edgemost territories occur at position `0` and `4`.
A country *surrounds* another if the sublist between its two edgemost territories contains all the territories of another country. In the above example, the sublist between country `2`'s edgemost territories is:
```
2 2 1 3 3 2
```
And we see that all the territories of country `3` are between the edgemost territories of country `2`, so country `2` surrounds country `3`.
A country with only one element will never surround another.
## Challenge
Take a list of integers as input (in any format) and output a *truthy* value if any country is surrounded by another, and a *falsy* value otherwise.
You can assume that the input list is nonempty, only contains positive integers, and does not 'skip' any numbers: for example, `1 2 1 5` would be invalid input.
## Test Cases
```
+----------------------+--------+
|        Input         | Output |
+----------------------+--------+
| 1                    | False  |
| 2 1 3 2              | True   |
| 2 1 2 1 2            | True   |
| 1 2 3 1 2 3          | False  |
| 1 3 1 2 2 3 2 3      | True   |
| 1 2 2 1 3 2 3 3 4    | False  |
| 1 2 3 4 5 6 7 8 9 10 | False  |
+----------------------+--------+
```
  
[Answer]
## Pyth, 7 bytes
```
n{Q_{_Q
```
[Run the code on test cases.](https://pyth.herokuapp.com/?code=n%7BQ_%7B_Q&input=%5B2%2C1%2C3%2C2%5D%0A%5B1%2C2%2C3%2C1%2C2%2C3%5D%0A%5B1%2C%203%2C%201%2C%202%2C%202%2C%203%2C%202%2C%203%5D%0A%5B1%2C%202%2C%202%2C%201%2C%203%2C%202%2C%203%2C%203%2C%204%5D%0A%5B2%2C1%2C2%2C1%2C2%5D&test_suite=1&test_suite_input=%5B1%5D%0A%5B2%2C1%2C3%2C2%5D%0A%5B2%2C1%2C2%2C1%2C2%5D%0A%5B1%2C2%2C3%2C1%2C2%2C3%5D%0A%5B1%2C%203%2C%201%2C%202%2C%202%2C%203%2C%202%2C%203%5D%0A%5B1%2C%202%2C%202%2C%201%2C%203%2C%202%2C%203%2C%203%2C%204%5D%0A%5B1%2C%202%2C%203%2C%204%2C%205%2C%206%2C%207%2C%208%2C%209%2C%2010%5D&debug=1)
```
n      Check whether the following are not equal:
 {Q     The unique elements in order of first appearance
 _{_Q   The unique elements in order of last appearance
         (done by reversing, taking unique elts, then reversing again)
```
The only way to avoid surrounding is for the countries' leftmost territories to be sorted in the same order as their rightmost territories. If two countries are swapped in this order, one has a territory both further left and further right than the other, and so surrounds it.
To obtain the unique countries in order of leftmost territory, we simply deduplicate, which preserves this order. The same is done for the rightmost territory by reversing, deduplicating, then reversing again. If these give different results, then a country is surrounded.
[Answer]
## [Retina](https://github.com/mbuettner/retina), ~~61~~ 60 bytes
Much longer than I would like...
```
(\b(\d+)\b.* (?!\2 )(\d+) .*\b\2\b)(?!.* \3\b)(?<!\b\3 .*\1)
```
Prints the number of countries that surround at least one other country.
[Try it online.](http://retina.tryitonline.net/#code=KFxiKFxkKylcYi4qICg_IVwyICkoXGQrKSAuKlxiXDJcYikoPyEuKiBcM1xiKSg_PCFcYlwzIC4qXDEp&input=MSAgICAgICAgICAgICAgICAgICAgfCBGYWxzZSAgfAoyIDEgMyAyICAgICAgICAgICAgICB8IFRydWUgICB8CjIgMSAyIDEgMiAgICAgICAgICAgIHwgVHJ1ZSAgIHwKMSAyIDMgMSAyIDMgICAgICAgICAgfCBGYWxzZSAgfAoxIDMgMSAyIDIgMyAyIDMgICAgICB8IFRydWUgICB8CjEgMiAyIDEgMyAyIDMgMyA0ICAgIHwgRmFsc2UgIHwKMSAyIDMgNCA1IDYgNyA4IDkgMTAgfCBGYWxzZSAgfA)
It's a very straightforward implementation of the spec: we look for the pattern `A...B...A` such that `B` appears neither before or after the match. 
[Answer]
## Python, 64 bytes
```
lambda l,S=sorted:S(l,key=l.index)!=S(l,key=l[::-1].index)[::-1]
```
The only way to avoid surrounding is for the countries' leftmost territories to be sorted in the same order as their rightmost territories. If two countries are swapped in this order, one has a territory both further left and further right than the other, and so surrounds it.
The function checks that sorting the territories by leftmost appearance and rightmost appearance gives the same results. Unfortunately, Python lists don't have `rindex` analogous to `rfind`, so we reverse the list, then reverse the sorted output.
Same length (64) with an auxiliary function:
```
g=lambda l:sorted(l,key=l.index)
lambda l:g(l)[::-1]!=g(l[::-1])
```
[Answer]
# C#, 113 bytes
```
public bool V(int[] n){var u1=n.Distinct();var u2=n.Reverse().Distinct().Reverse();return !u1.SequenceEqual(u2);}
```
Ungolfed:
```
public bool ContainsSurroundedCountry(int[] numbers)
{
    int[] uniqueLeftmost = numbers.Distinct().ToArray();
    int[] uniqueRightmost = numbers.Reverse().Distinct().Reverse().ToArray();
    return !uniqueLeftmost.SequenceEqual(uniqueRightmost);
}
```
Using a concise `LINQ` approach.
[Answer]
## CJam (14 13 bytes)
```
{__&\W%_&W%#}
```
[Online demo](http://cjam.aditsu.net/#code=%7B__%26%5CW%25_%26W%25%23%7D%0A%0A%5B%5B1%5D%0A%20%5B2%201%203%202%5D%0A%20%5B2%201%202%201%202%5D%0A%20%5B1%202%203%201%202%203%5D%0A%20%5B1%203%201%202%202%203%202%203%5D%0A%20%5B1%202%202%201%203%202%203%203%204%5D%0A%20%5B1%202%203%204%205%206%207%208%209%2010%5D%5D%25%60&input=%0A)
Thanks to [Martin Büttner](https://codegolf.stackexchange.com/users/8478/martin-b%c3%bcttner) for a one-char saving.
[Answer]
# Japt, 12 bytes
```
Uâ ¬¦Uw â ¬w
```
[Try it online!](http://ethproductions.github.io/japt?v=master&code=VeIgrKZVdyDiIKx3&input=WzEgMyAxIDIgMiAzIDMgM10=)
Thanks to @xnor for figuring out the algorithm. Input array is automatically stored in `U`, `â` is uniqify, `w` is reverse, and `¦` is `!=`. `¬` joins with the empty string (`[1,2,3] => "123"`); this is necessary because JavaScript's comparsion counts two arrays as not equal unless they are the same object. For example (JS code, not Japt):
```
var a = [1], b = [1]; alert(a==b); // false
var a = [1], b = a;   alert(a==b); // true
```
If this was not the case, we could remove two bytes by simply not joining each array:
```
Uâ ¦Uw â w
```
[Answer]
## ES6, ~~76~~ ~~75~~ ~~65~~ 64 bytes
```
 a=>(f=r=>a.filter((x,i)=>a.indexOf(x,r&&i+1)==(r|i))+a)()!=f(-1)
```
Straightforward port of @xnor's answers.
Edit: Saved 1 byte by replacing `a.lastIndexOf(x)==i` with `a.indexOf(x,i+1)<0`.
Edit: Saved 10 bytes thanks to @user81655.
Edit: Saved 1 byte by replacing `r||i` with `r|i`.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 4 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ÙIÚÊ
```
[Try it online](https://tio.run/##MzBNTDJM/f//8EzPw7MOd/3/H22oY6xjqGMEhMYgHAsA) or [verify all test cases](https://tio.run/##MzBNTDJM/X9u66GV/w/PPLTu8KzDXf9rD@3@Hx1tGKujEG2kY6hjrANngjGIA2IagwWMIVwIByQIFzLSgegGCRrrmCC0meiY6pjpmOtY6FjqGBrExgIA).
Port of [*@xnor*'s Pyth answer](https://codegolf.stackexchange.com/a/69125/52210).
**Explanation:**
```
Ù       # Uniquified
 IÚ     # Reversed uniquified on the input again
   Ê    # Check if the two lists are not equal
```
[Answer]
## Java, 281 Characters
```
class K{public static void main(String[]a){System.out.println(!k(a[0]).equals(new StringBuffer(k(new StringBuffer(a[0]).reverse().toString())).reverse().toString()));}static String k(String k){for(char i=49;i<58;i++){k=k.replaceFirst(""+i,""+(i-9)).replaceAll(""+i,"");}return k;}}
```
[Answer]
## Python 3, 90 bytes
This function that takes the input as a Python list. Sadly, Python lists don't directly support searching from the end like strings do with `rindex()`, but oh well.
```
def t(c):i,I=c.index,c[::-1].index;return any(i(n)<i(m)and I(n)<I(m)for m in c for n in c)
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
UQU⁻Q
```
[Try it online!](https://tio.run/##y0rNyan8/z80MPRR4@7A/4fbHzWt@f8/2lBHwVhHAUgagZExhIzVUYiGixnChcHIJBYA "Jelly – Try It Online")
Just another port of [xnor's answer](https://codegolf.stackexchange.com/a/69125/66833), so go upvote that.
## How it works
```
UQU⁻Q - Main link. Takes a list l on the left
U     - rev(l)
 Q    - unique(rev(l))
  U   - rev(unique(rev(l)))
    Q - unique(l)
   ⁻  - rev(unique(rev(l)) ≠ unique(l)
```
]