[Question]
  [
# Introduction
This site is rapidly building up a huge dataset of code snippets, so let's do something with it!
[Here's a data file](https://drive.google.com/file/d/0B3uyVnkMpqbVMGVtMndpbEdlVEE). It contains 9,066 unique language+snippet pairs for 113 languages, all taken from this site. The format is tab-separated (language-TAB-snippet), with all newlines in the snippets replaced with `<LF>`, and all tabs replaced with 4 spaces. There are at least 5 snippets for each language.
[update: I've made a minor change to the data file to merge some Python & RegExp versions I missed before - the link above has been updated]
# Challenge
Write a program or function which takes a code snippet and outputs the language it is written in (see below for details). The total size of your source + any data you require must be 300 bytes or less, and your program **must** output the correct language when given its own source code. Highest accuracy (most correct answers on the dataset above) wins.
# Rules
* The total size of your source code, resources, and any required compilation / runtime flags must not exceed 300 bytes.
* Your answer will be tested against the dataset above; it will be given one of the "Snippet" values as input and its output will be compared against the "correct" output according to the dataset. This will be repeated for all entries in the dataset and the final number of correct answers is your score.
* You can choose the input encoding - I'll assume UTF-8, so if you need another encoding specify it in your answer.
* You don't need to use the `<LF>` replacement for newlines; if your entry expects to receive newlines as literal newlines (char 10), specify it in your answer.
* Your entry must output the language it thinks the input snippet is written in. To avoid the need to compress lots of language strings, I'll allow mappings (If you want to output 3 for "Java", that's fine); just note the mappings in your answer.
* You can only have 1 output mapping for each language (i.e. if 3 means "Java", you can't also have 4 meaning "Java").
* When given its own source code, your program **must** produce the correct answer (must output the language it is written in).
* You don't need to support all languages in the dataset, and you can support extra languages if you want to (e.g. if your entry isn't in one of the languages in the dataset).
* Your program must be deterministic (providing the same input twice must produce the same output).
# Tie-Breaking
* Ties will be decided by reducing the dataset until one entry wins. The dataset will be reduced by removing all snippets for the most popular language (i.e. ties are broken by accuracy on rarer languages). *For example, if A and B score 70% on the full dataset, all Python snippets will be removed. If A and B now both score 60%, CJam will be removed. If A now scores 50% but B scores 55%, B is the winner.*
* If 100% accuracy is achieved, ties will be decided using a second (blind) dataset containing more samples for the same languages.
# Example 1
The Python script:
```
print("python")
```
This script successfully produces "python" when given its own source code, so it is valid. On the dataset, it scores 1008/9066 = 11.1%
# Example 2
The JavaScript function:
```
function f(s){return /function/.test(s)?1:2}
```
With the mappings 1 → javascript, 2 → python. Again it successfully produces 1 ("javascript") for its own source, and on the dataset it scores 1092/9066 = 12.0%
---
Where did the data come from?
I created an [SEDE query](http://data.stackexchange.com/codegolf/query/509563/top-code-golf-answers) to pull samples from [code-golf] challenges on this site. From the resulting 10,000 answers, I used a hacked-together python script to find the code & language name for each, then filtered out any language with less than 5 examples. The data isn't 100% clean (I know there are some non-code snippets it pulled), but should be good enough.
---
Inspired by this challenge from earlier in the year: [Who said that? 2016 Presidential election](https://codegolf.stackexchange.com/q/74585/8927)
Also partly related to [What's the Language?](https://codegolf.stackexchange.com/q/69920/8927)
  
[Answer]
# C, 297 bytes, 43.194351% matched (v2)
This is the first non-golf challenge I've competed in. Surprisingly, golfing languages are actually rather easy to separate, with about 60% matching accuracy per language.
The code requires input as UTF-8 string, results based on version 2 of the supplied dataset. This code does not require `<LF>` to be replaced with actual newlines.
```
#define S(x)!!strstr(p,#x)
f(char*p){return S(#d)?:S(voi)?0:S(mai)|S(utc)?:S(mbd)|S(impor)|S(input)|S(def)|S(rang)?2:S(log)|S(fun)|S(=>)|S(lert)?3:S(<?)?4:S(echo)|S(sed)?5:S(+++)?6:S(<-)?7:S($_)|S(say)?8:S(\342)|S(\303)?9:S(->)|S(map)?10:S(@#)|S(]])|S([#)?11:S(V)|S(Q)?12:S(Z)|S(Y)?13:S(.)?14:15;}
```
Mapping table:
```
 0. java
 1. c
 2. python
 3. javascript
 4. php
 5. bash
 6. brainf*
 7. haskell
 8. perl
 9. apl
10. ruby
11. wolfram
12. pyth
13. matl
14. golfscript
15. cjam
```
The percentage is based on my hits/total calculation: 3916 hits/9066 total.
[Answer]
# Python 3, 271 278 bytes, 25.049636% matched (v2, unverified)
```
def f(c):
 try:compile(c,'','exec');return 5
 except:
  for j in range(9):
   if any(l in c for l in [['echo'],['require'],['Main','string'],['document','alert','var ','function'],['String'],['def ','lambda','print '],['main','int','char'],['+++','<<<'],[]][j]):break
 return j
```
map:
```
0 = bash
1 = ruby
2 = c#
3 = javascript
4 = java
5 = python
6 = c
7 = brainf*
8 = cjam
```
much better golfed (probably still not great), finally broke the 25% barrier! Inputs have `<LF>` replaced with newline (`\n`)
]