text:
Doors doors doors, c'mon down to the door store!
The challenge is twofold:
Make a program that builds a door. ASCII, HTML or otherwise
Make the door functional. Opens and closes
Either open-able through input or interaction!

Non-functional door +5 points.
Just a open-able door +10 points.
Interactive door +15 points.
Fancy door +20 points. This means revolving,bifold etc
Animated +20 points.
<100 characters +50 points.
-100 points for using a program specifically designed for drawing or animation.

If you have criteria suggestions leave them in the comments.
Non-functional open door example:
<?php
$idiots_in_room=true;

if($idiots_in_room)
{

$count=20;
$count2=7;
for($i=0;$i<$count;$i++)
{

if($i==0)
{
echo str_repeat("-",10);
if($i==0){echo ".";}
echo "\n";
}
elseif($i==9)
{
echo str_repeat("-",10);
echo str_repeat("Â ",7)."o"."|";
echo "\n";
}
elseif($i<=9)
{

echo str_repeat("-",1).str_repeat("Â ",8).str_repeat("-",1);

echo ($i<5) ? str_repeat("Â ",$i*2)."\\" : str_repeat("Â ",8)."|";
echo "\n";
}
elseif($i<=14)
{
if($i>9){echo str_repeat("Â ",$i)."\\";}
echo str_repeat("Â ",$count2--)."|";
echo "\n";
}

}
}

Example Output:
----------.
-        -  \
-        -    \
-        -      \
-        -        \
-        -        |
-        -        |
-        -        |
-        -        |
----------       o|
          \       |
           \      |
            \     |
             \    |
              \   |

Do you have any door examples?

@beary605 Non-functional example provided

define a "door"

What about using external files for ASCII code (or images) for the doors? How do they count?

JavaScript, 4380 characters, 65(?) points
ASCII? Check. HTML? Check. Is a door? Check. Openable door? Check. Interactive? Check. Fancy? Double doors with properly positioned hinges, I hope that counts. Animated? Check. Under 100 characters? Ha. Not using facilities intended for drawing? Check.
Live demo. (Note: In my testing with Firefox, clicking the doors more than once doesn't work — for some reason the event handler doesn't fire again and I'm baffled as to why; pointing out what I did wrong would be welcome. Though, you might want to run this in Chrome anyway for decent JS performance.)
<title>Door</title>

Click doors to open or close.

When closed, the doors look like this:

Gotta admit, thats some beautiful work there.

That is awesome.

HTML & CSS3, 55 points
Fancy, interactive, animated door is 55 points, I think.
Yes, this opens like any other door, but if a sliding door counts as fancy, why doesn't a rotating one? If a rotating one isn't fancy, well, a sliding door is no problem :)
A demo is available at http://result.dabblet.com/gist/3132160/ac475112dbba493d2dd7d98493d4f4ceaa209a7c. Click the doorknob to open and close. No JavaScript involved; it's just the magic of CSS3.
#wall {
    background-color: #eee;
    bottom: 0;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transform: rotateX(-10deg);
    transform-origin: 0 100%;
    transform-style: preserve-3d;
}

#door-container {
    background-color: black;
    height: 100%;
    margin: 0 auto;
    width: 300px;
}

#door {
    background-color: brown;
    height: 100%;
    margin: auto;
    position: relative;
    transform-origin: 0 0;
    transition: transform 0.5s ease;
    width: 300px;
}

#door .knob {
    background-color: gold;
    border-radius: 10px;
    height: 20px;
    margin-top: -10px;
    position: absolute;
    right: 10px;
    top: 50%;
    width: 20px;
}

#open:target + #wall #door {
    transform: rotateY(-145deg);
}

#open:target + #wall #open-link {
    display: none;
}

#close-link {
    display: none;
}

#open:target + #wall #close-link {
    display: inline;
}

By Sliding I originally meant "Sliding glass door" like for a patio, but I could see how it wouldn't be considered fancy (especially in coding terms, as its much easier than a rotating). Also, by Rotating door I meant Revolving. Will correct.

Mathematica 271 chars
Manipulate[a = {0, 0, 0}; b = {0, 0, h}; p = Polygon; c = Cuboid; t = Rotate;Graphics3D[{c@{{-w - 1, 0, 0}, {-w, 1, h}}, c@{{w + 1, 0, 0}, {w, 1, h}},t[p@{a, b, {-w, 0, h}, {-w, 0, 0}}, r, {0, 0, 1}, {- 2 w/3, -w/3, 0}], t[p@{a, b, {w, 0, h}, {w, 0, 0}}, -r, {0, 0, 1}, { 2 w/3, -w/3, 0}]}],{{r, 0}, 0, 3/2}, {{w, 2}, 1, 3}, {{h, 4}, 3, 5}]

The double doors

open by rotation from zero to 90 degrees (using the slider r)
can be have their height and width set by sliders (h and w).
are in a 3D lighting environment
can be interactively rotated to be viewed from different angles.

The code is based on a program by Sándor Kabal.

Python - 65 points, 86 chars
Interactive and less than 100 chars.
Waits for input and shows you the door.
Valid input is "open" and "close" and "bye".
g,s=1,'open close'
while g:
 i=raw_input()
 print '_'+'/_ '[s.find(i)/5]+'_'
 g=i in s

You could probably set it to toggle open/close without typing commands and still meet the requirements--it would save you a few chars.

Probably, but then again, this isn't code-golf, so it doesn't really matter ;)

pretty boring looking door, but a great looking mousetrap

Mathematica 127 chars
This is a more streamlined implementation than the one I submitted earlier. It has a single door.
The single door

opens by rotation from zero to 90 degrees (using the slider o)
is in a 3D lighting environment
can be interactively rotated to be viewed from different angles.

However, it uses a fixed door height and width.
Manipulate[a = {0, 0, 0}; Graphics3D[{Tube[{a, {1, 0, 0}, {1, 0, 2}, {0, 0, 2}, a}, .03],Rotate[Cuboid@{a, {1, -.1, 2}}, o, {0, 0, 1}, a]}], {o, 0, -Pi/2}]

You should probably have editted your previous submission, rather than submitting a new one.

@fireDude67 If this had been a Code Golf challenge, I would have simply replaced my earlier entry with the shorter code. However, the SO indicated interest in both short programs and more complicated programs (doors with more features).

oh sorry i got confused then

@fireDude67 No problem.


text:
Day of the week for a given date of this year. Do not use any date tools
Please write a program that takes as input two numbers 'day of the month' and 'month number' for any day of this year (2012) and outputs day of the week.
Examples:
% ruby ./golf.rb 14 07 # 14th of July
"Sat"
% ruby ./golf.rb 14 7  # the same
"Sat"
% ruby ./golf.rb 01 12 # Dec 1
"Sat"
% ruby ./golf.rb 31 12 # Last day of the year
"Mon"

Output format should be like Mon, Tue, Wed, Thu, Fri, Sat, Sun, not less than 3 letters
Do not use date libs/modules, just math and logic
Wins the shortest script in any language.

Please post a scoring criteria or use the "code-golf" tag if the shortest code should win. Othwerwise your question might very soon be closed!

GolfScript (46 44 chars)
~.5*1$8>+2/\3<++7%"WedThuFriSatSunMonTue"3/=

Calculation can be more efficient than lookup if the days are rotated. I doubt that the mapping to day names can get shorter, but it may still be possible to shave a character or two off the hash function.
However, my best idea for how to do it, finding a power which starts with a suitable string, doesn't look like a contender. After about 9 CPU-days of brute forcing I found a couple of solutions, but they're also 44 chars. The faster one is
~16795 33303?`=+7%"WedThuFriSatSunMonTue"3/=

C++   (142) (135)    (129 chars)
main(){string s[]={"Mon","Tue","Wen","Thu","Fri","Sat","Sun"};int d,m,t[]={0,5,1,1,4,6,2,4,0,3,5,1,3};cin>>d>>m;cout<<s[(d+t[m]+15-(m<3))%7];}

The requirement that the letters Mon, Tue etc. appear made it quite bad, otherwise it would be only 84 chars. I'll search a golf for the strings...
Hm, trying to golf the string only made it 2 chars longer, but I find it more aesthetically pleasing.
main(){char s[]={"MonTueWenThuFriSatSun"};int d,m,t[]={0,5,1,1,4,6,2,4,0,3,5,1,3};cin>>d>>m;d=((d+t[m]+15-(m<3))%7)*3;s[d+3]=0;printf("%s",s+d);}

Well, this for my first entry at a golf contest, I have still much to learn...
HA! Got it!
main(){char s[]={"MonTueWenThuFriSatSun"},t[]={"0511462403513"};int d,m;cin>>d>>m;d=((d+t[m]-33-(m<3))%7)*3;s[d+3]=0;printf("%s",s+d);}

with a well set compiler and some luck we might chop another 3 characters, by using char* instead of char[], but it will crash on most systems. Anyway, it doesn't matter, as I believe soon someone will post a solution in J or K with less than 10 characters, as usual :P
I'll never give up!
main(){char s[]={"MonTueWenThuFriSatSun0511462403513"};int d,m;cin>>d>>m;d=((d+s[m+21]-33-(m<3))%7)*3;s[d+3]=0;printf("%s",s+d);}

It's a leap year this year... ;-) (and my J solution's currently about 75 chars).

@Gareth: Even if I optimized better for that, there is no chance to beat J. Requiring to write "main(){}", the variable declarations and input/output requires 38 characters, versus nearly nothing in J.

Don't try to beat a non-existent answer, just make your code as small as possible given the questions constraints. In this case the question specifically says "2012" so you could change your month offsets to '401462403513' and take out the -(m<3) to save 6 characters. My C++ is pants but I think you can also use main(d,m){ to initialize your variables and save another 4. If you change your day order so that Wed comes first I think you can get rid of the -33 too.

"char s[]" ==> "char *s"

This isn't a valid C++ program, main needs a return type and you are using cin without std:: and without including iostream.

@Bunnit: I'm sorry, but you are very wrong. Here at codegolf the main objective is not to use best practices, or to write beautiful, maintainable, or platform-independent code. If it can be compiled with at least one notable compiler (even if with hundreds of warnings) and it works, then why shouldn't it be a valid entry? Look at all other C and C++ answers to "code-golf" type questions, and show me one single example where they don't use questionable and dangerous practices to save a few more characters. Yes, at stackoverflow it would be a very bad answer, but this is not stackoverflow.

Questionable and dangerous are fine but if your going to submit code which is clearly incorrect according to the standard then it is no longer C++.

@Bunnit: It compiles with g++. With your argumentation we should disqualify 99% of all C++ (and many C) solutions ever submitted.

ok, I'm clearly not going to convince you.  Personally I believe that an answer should be able to be compiled on any standard conforming compiler without modification and a standard conforming compiler would refuse to compile your answer.  I keep up with most of the questions on here and haven't seen any C++ answers that are non-standard conforming, could you point them out?  Btw C allows implicit int, C++ strictly forbids it, so C answers are ok on that front.

@Bunnit: I agree that the entries should compile with at least one notable compiler without modifications, but in this case it does compile with an unmodified MinGW of a recent version (of course, with a lot of warnings).

We don't agree; standard conforming != notable.  What you've posted isn't valid C++ no matter if MinGW compiles it or not.  I still want to see some of the 99% of C++ answers you are referring to above.

c, 101 chars
d,m;main(){scanf("%d %d",&d,&m);printf("%.3s\n","SunMonTueWedThuFriSat"+(d+".034025036146"[m])%7*3);}

main(d,m) and scanf("%d%d" save 2 chars.

APL (57 56)
D M←⎕⋄3↑'MonTueWedThuFriSatSun'↓⍨3×7|D+⍎M⌷'512503514624'

I reckon it's hard to bit APL with Ruby or Python :-)

Ruby, 75 74
Ok, my ruby:
a,b=$*.map &:to_i;p:MonTueWedThuFriSatSun[(a-:x365274263153[b].to_i)%7*3,3]

Saved one char:
a,b=$*;p:MonTueWedThuFriSatSun[(a.to_i-:x365274263153[b.to_i].to_i)%7*3,3]

Python3 (93) (86)
print("MTWTFSSouehraunenuitn"[eval('%s+%s+14'%(input(),"0512573514624"[int(input())]))%7::7])

Thanks to vsz. That is just his idea translated to python (plus comments, plus python-tricks).
print("MTWTFSSouehraunenuitn"[(int(input())+int("0512573514624"[int(input())]))%7::7])

I don't understand why you're adding 14 if you're just going to do %7 to the result?

Pip, 44
Not a competing entry, language is newer than question.
("SunMonTueWedThuFriSat"<>3a+562361462503@b)

Pip is my imperative code-golf language. The code above requires today's version of the interpreter (0.15.04.23 or newer) for the <> operator.
Command-line arguments are stored into a and b automatically. The program uses a simple lookup-table approach; taking advantage of the fact that numbers and strings are the same data type in Pip, we can define the table via integer literal, get a digit out by subscripting, and again do math with the result. As in CJam, subscripts are cyclic; so when b is 12, 562361462503@b gives 5.
<> is the grouping operator: "Hello"<>2 gives the list ["He";"ll";"o"], for instance. We then use the ( ) alternate subscripting syntax (again taking advantage of cyclic subscripts to avoid needing %7) to grab the appropriate day name, which is auto-printed.
(The main use of the (x y z) syntax--borrowed from Lisp--is to call a function x with args y and z; but if x is a list or string, the operation is subscripting instead. The typical subscript operator, @, is very high-precedence, so when the subscript or list are compound expressions like here, the function-call syntax saves on extra parentheses that @ would require.)

C, 96 chars
Reads from standard input. Usage: echo 23 7 | ./a.out
main(a,b){
    scanf("%d%d",&a,&b);
    a+=b*30.56-(b>2);
    puts("Thu\0Fri\0Sat\0Sun\0Mon\0Tue\0Wed"+a%7*4);
}

The formula b*30.56, rounded down, gives the accumulated number of days before each month, assuming a 30-day February. -(b>2) corrects for 2012's 29-day February.

Python (130 chars)
d=raw_input().split()
n=int(d[0])+sum([31,29,31,30,31,30,31,31,30,31,30,31][:int(d[1])-1])-1
print 'SMTWTFSuouehranneduit'[n%7::7]

It's rather longish for Python, but I like it.

Factor 98
: day ( x x -- x )
{ 0 3 6 5 2 7 4 2 6 3 1 5 3 } nth - 7 mod "MonTueWedThuFriSatSun" 3 group nth ;

Output:
( scratchpad ) 23 7 day

--- Data stack:
"Mon"

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Triangle Puzzle
Triangle Puzzle
Consider the triangle below.
This triangle would be represented by the following input file.

   5
  9 6
 4 6 8
0 7 1 5

By starting at the top and moving to adjacent numbers on the row below, one creates a path to the bottom of the triangle. There are many such paths in a triangle, which may have different weights. The weight of a path is the sum of all numbers encountered along the way. Write a program to find the weight of the path with the highest weight for a given triangle.
In above example, the maximum sum from top to bottom is 27, and is found by following the bold text above path. 5 + 9 + 6 + 7 = 27.
(More formally: The triangle is an acyclic digraph, and each number represents the value of a node. Each node has either two or zero direct successors, as shown by the arrows above. A complete path is a path which begins at the root node—the one with no immediate predecessors—and ends at a node with no immediate successors. The weight of a complete path is the sum of the values of all nodes in the path graph. Write a program which finds the weight of the complete path with the largest weight for a given triangle.)
Bigger test sample data :

9235
9096 637
973 3269 7039
3399 3350 4788 7546
1739 8032 9427 976 2476
703 9642 4232 1890 704 6463
9601 1921 5655 1119 3115 5920 1808
645 3674 246 2023 4440 9607 4112 3215
660 6345 323 1664 2331 7452 3794 7679 3102
1383 3058 755 1677 8032 2408 2592 2138 2373 8718
8117 4602 7324 7545 4014 6970 4342 7682 150 3856 8177
1966 1782 3248 1745 4864 9443 4900 8115 4120 9015 7040 9258
4572 6637 9558 5366 7156 1848 2524 4337 5049 7608 8639 8301 1939
7714 6996 2968 4473 541 3388 5992 2092 2973 9367 2573 2658 9965 8168
67 1546 3243 752 8497 5215 7319 9245 574 7634 2223 8296 3044 9445 120
7064 1045 5210 7347 5870 8487 3701 4301 1899 441 9828 3076 7769 8008 4496 6796

I think you need to decide whether you want a lot of small but probably inefficient solutions ([code-golf]), or efficient but maybe not so small solutions ([code-challenge]/[fastest-code]).

ok, thanks for letting me know as I am new to this site, let me remove code-golf as I want efficient solution.

http://projecteuler.net/problem=67 :D

Stolen from Project Euler. -1

It seems fairly straightforward to get the optimum via a dynamic program. I'd expect that to be asymptotically optimal, though I'm not sure. How are you going to compare among optimal solutions with the same asymptotic running time? Are you going to benchmark actual large test cases?

You need to explicitly provide an objective criteria by which a winner will be chosen. Welcome to the site :)

(More formally: The triangle is an acyclic digraph, and each number represents the value of a node. <snip /> A complete path is a path which begins at the root node—the one with no immediate predecessors—and ends at a node with no immediate successors. The weight of a complete path is the sum of the values of all nodes in the path graph. Write a program which finds the weight of the complete path with the largest weight for a given triangle.)

This easily generalises to any dag G(V,E) with weighted nodes. Perform a topological sort, and then iterate through the nodes in that order setting weight[v] += max {weight[v'] : v' in predecessors(v)}. Assuming a suitable representation, this is O(E).
As an implementation note, it may be convenient to add a dummy "sink" node with weight 0 to which all the successor-less nodes of the original graph gain an edge. Alternatively it might be convenient to iterate through the topologically sorted nodes in reverse order using successors instead of predecessors.
The latter is the case given the special structure of the triangle, for which in addition it's possible to do an implicit topological sort and to use only O(sqrt(V)) extra space (assuming that we mustn't alter the original graph and hence require extra space).
input: a triangular array T of n rows increasing in length from 1 to n

scratch = clone T[n-1]
for y = n-2 downto 0
    for x = 0 to y-1
        scratch[x] = T[y][x] + max(scratch[x], scratch[x+1])

output: scratch[0]

Groovy
Here's a groovy script with two solutions, one using recursion and one using a "bottom-up" approach. The file "test_sample_data.txt" is assumed to be in the classpath.
// Read the sample data file, store as List<List<int>>
def triangle = getClass().
        getResource('test_sample_data.txt').        // get the file resource
        text.                                       // contents as string
        split('\n').                                // split into lines
        collect { line ->                           // collect rows
            line.split().collect { it as int }      // collect columns
        }

println "Recursive: ${findLargestWeightRecursively(triangle)}"
println "Bottom up: ${findLargestWeightBottomUp(triangle)}"

def findLargestWeightRecursively(List triangle, row = 0, col = 0) {
    def current = triangle[row][col]
    if (row < triangle.size() - 1) {
        def w1 = findLargestWeightRecursively(triangle, row + 1, col)
        def w2 = findLargestWeightRecursively(triangle, row + 1, col + 1)
        return Math.max(w1, w2) + current
    } else {
        return current
    }
}

def findLargestWeightBottomUp(List triangle) {
    def weights = triangle[triangle.size() - 1].clone()
    for (int row = triangle.size() - 2; row >= 0; row--) {
        def nextRow = triangle[row]
        for (int col = 0; col < nextRow.size(); col++) {
            def largest = Math.max(weights[col], weights[col + 1])
            weights[col] = nextRow[col] + largest
        }
        weights.remove(weights.size() - 1)
    }
    return weights[0]
}

Output:
Recursive: 108146
Bottom up: 108146

My Perl Solution
input file is named as input.txt
$refarray;
open TRIG, "input.txt";
while(<TRIG>){
$i++;
$_ =~ s/^\s+//g;
$_ =~ s/\s+$//g;
@num=split(/\s+/);
for $j (0...$#num) {
  $refarray[$i]->[$j]=$num[$j];
}
}
close TRIG;
while($i>0){
   for $j (0...$i-2){
      if($refarray[$i]->[$j]>$refarray[$i]->[$j+1])
    {
    $refarray[$i-1]->[$j]+=$refarray[$i]->[$j];
    }
      else{
    $refarray[$i-1]->[$j]+=$refarray[$i]->[$j+1];
    }
      $total=$refarray[$i-1]->[$j]."\t";
   }
$i-=1;
}
print $total;

Ruby, 2nd version
t=%w{
     1
    2 1
   3 2 1
  4 3 2 1
 5 4 3 2 1
1 2 3 4 5 10000
}.map &:to_i

l = []
i=1

loop do
    l.push t.slice!(0,i)
    i += 1
    break if t == []
end
trees = [0, 1].repeated_permutation(l.length-1).to_a.map! do |tree|
    [0].concat tree
end

trees.map! do |tree|
    newt = []
    tree.each_with_index do |e, i|
        newt.push tree.slice(0, i+1).inject :+
    end
    newt
end

rr = []
trees.each do |t|
    r = 0
    t.each_with_index do |v, i|
        r += l[i][v]
    end
    rr.push r
end
p rr.max

Code above outputs: 10005
Sample of data in the question results to 108146

Doesn't always give the correct answer - the input   {1, 2 1, 3 2 1, 4 3 2 1, 5 4 3 2 1, 1 2 3 4 5 10000} gives 17 instead of 10005

I solved this problem many years ago in a training for programming contest. Now I just translated to a modern language as C#.
int MaximumSum(List<List<int>> values)
{
    // Making a copy by values of all list and validating the data at same time.
    var numbers = new List<List<int>>();
    int index = 0;
    while ((index < values.Count) && (values[index] != null) && (values[index].Count == index + 1))
    {
        numbers.Add(new List<int>());
        for (int j = 0; j <= index; j++)
            numbers[index].Add(values[index][j]);
        index++;
    }
    if (index == values.Count)
    {
        /* Applying dinamic programming principles we can obtain the maximum value starting from the last row until the first one.
         * Storing only the optimum result until the specific value being analized.
         * At the end the value on the top of the triangle will be the maximum needed.
         */
        for (int row = numbers.Count - 2; row >= 0; row--)
            for (int col = 0; col <= row; col++)
                numbers[row][col] += (numbers[row + 1][col] > numbers[row + 1][col + 1]) ? numbers[row + 1][col] : numbers[row + 1][col + 1];
        return numbers[0][0];
    }
    else
    {
        throw new Exception("Invalid data");
    }
}

Python
Put the triangle in a file called "triangle.txt", with whitespace only between the numbers.
f=open("triangle.txt", "r")
triangle=eval("[["+f.read().replace(" ", ",").replace("\n", "],[")[:-4]+"]]")
f.close()
for i in range(len(triangle)-2, -1, -1):
    for j in range(len(triangle[i])):
        triangle[i][j]+=max(triangle[i+1][j+1],triangle[i+1][j])
    del triangle[i+1]
print triangle[0][0]

Example Triangle:
1      (   1   )
2 3    (  2 3  )
4 5 6  ( 4 5 6 )

The 2 has 4, 5 below it. 5>4, so replace the 2 with 2+5=7.
The 3 has 5, 6 below it. 6>5, so replace the 3 with 3+6=9.
1    (  1  )
7 9  ( 7 9 )

The 1 has 7, 9 below it. 9>7, so replace the 1 with 1+9=10.
There are no more rows to process, so the maximal sum is 10.

Q
t:"I"$'/:" "vs'read0`t;
{(-2_x),enlist (1_mmax[2;last x])+last -1_x}/[count[t]-1;t]
exit 0

It assumes the triangle is a space separated triangle of integers stored in a file called t.
On the second test case:
$ time q tri.q -q
108146

real    0m0.018s
user    0m0.010s
sys     0m0.010s

Haskell solution
maximizeTree tree
    | length tree == 1 = head . head $ tree
    | otherwise = maximizeTree (take (length tree - 2) tree ++ [zipWith (\a b -> maximum a + b) (pairUpList . last $ tree) (tree !! (length tree - 2))])
    where pairUpList list = [[list !! n, list !! (n + 1)] | n <- [0 .. (length list - 2)]]

maximizeTree [[5], [9, 6], [4, 6, 8], [0, 7, 1, 5]]

Here is my solution implementation in java. I got idea from this https://stackoverflow.com/a/8002423/205585
    package com.euler.problems;

    import java.util.*;

    public class Problem18
    {
       private static Map<Integer,List<Integer>> triangle = new HashMap<Integer,List<Integer>>();

       public static void main(String args[])
       {
         _init();
         int res = maxSum(triangle);
         System.out.println("Sum = "+res);
       }

       //max sum from top to bottom of right angled triangle
       public static int maxSum(Map<Integer,List<Integer>> triangle)
       {
         int sum = 0;
         if(triangle == null || triangle.isEmpty())
           return 0;
         int size = triangle.size();
         if(size == 1)
           return triangle.get(0).get(0);
         int i=size-2,tmp,tmp_max,max_value;
         while(i>=0)
         {
           List<Integer> current_row = new ArrayList<Integer>();
           current_row = triangle.get(i);
           for(int index=0; index<current_row.size(); index++)
           {
             tmp = current_row.get(index);
             tmp_max = tmp+triangle.get(i+1).get(index);
             max_value = tmp+triangle.get(i+1).get(index+1);
             if(tmp_max > max_value)
               max_value = tmp_max;
             current_row.set(index,max_value);
           }
           triangle.put(i,current_row);
           current_row = null;
           i--;

        }
      return triangle.get(0).get(0);
    }

    private static void _init()
    {
      List<List<Integer>> tuples = new ArrayList<List<Integer>>();
      tuples.add(Arrays.asList(75));
      tuples.add(Arrays.asList(95,64));
      tuples.add(Arrays.asList(17,47,82));
      tuples.add(Arrays.asList(18,35,87,10));
      tuples.add(Arrays.asList(20,4,82,47,65));
      tuples.add(Arrays.asList(19,1,23,75,3,34));
      tuples.add(Arrays.asList(88,2,77,73,7,63,67));
      tuples.add(Arrays.asList(99,65,4,28,6,16,70,92));
      tuples.add(Arrays.asList(41,41,26,56,83,40,80,70,33));
      tuples.add(Arrays.asList(41,48,72,33,47,32,37,16,94,29));
      tuples.add(Arrays.asList(53,71,44,65,25,43,91,52,97,51,14));
      tuples.add(Arrays.asList(70,11,33,28,77,73,17,78,39,68,17,57));
      tuples.add(Arrays.asList(91,71,52,38,17,14,91,43,58,50,27,29,48));
      tuples.add(Arrays.asList(63,66,4,68,89,53,67,30,73,16,69,87,40,31));
      tuples.add(Arrays.asList(4,62,98,27,23,9,70,98,73,93,38,53,60,4,23));
      int i=0;
      for(List<Integer> tuple : tuples)
      {
        triangle.put(i++,tuple);
      }
      //print
      for(Integer key : triangle.keySet())
     {
       System.out.println(triangle.get(key));
     }
    }
   }

Python solution where the file is read as list of lists and processed bottom up:
from io import open

def parse_file(fpath):
    return [[int(i) for i in l.strip('\n').split()] for l in open(fpath, "r").readlines()]

def process_row(lower, upper):
    results = []
    for i in range(0,len(upper)):
        results.append(upper[i] + max(lower[i], lower[i+1]))
    return results

def traverse_triangle_bottom_up(triangle):
    triangle.reverse()
    results = triangle.pop(0)
    for row in triangle:
        results = process_row(results, row)
    return results[0]

triangle = parse_file("triangle.txt")
max_weight = traverse_triangle_bottom_up(triangle)
print(max_weight)

Classic case of unnecessary OO.

I have "refactored" to procedural... May I ask you to elaborate on when it is appropriate and when it is not?

A rule of thumb (at least for me) is: If the data should be presented in a boxed form (i.e. a reader or container), use a class. Otherwise I stick to procedural style.

Not very elaborate of an explanation but thank you, nonetheless.

Well, it is completely subjective, which is the reason I'm now wondering why I even said that. So, eh, sorry about that.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
City names game
If you like, write a program which sorts cities according to the rules of city name game.

Each name of the city should start from the last letter in the previous city name. E.g. Lviv -> v -> Viden -> n -> Neapolis -> s -> Sidney -> y -> Yokogama -> a -> Amsterdam -> m -> Madrid -> d -> Denwer
In the sorted list first letter of the first city and last letter of the last shouldn't match anything doesn't have to be the same letter.
You can assume city names have only letters.
Program output should have same capitalization as input

Example:
% ./script Neapolis Yokogama Sidney Amsterdam Madrid Lviv Viden Denwer
["Lviv", "Viden", "Neapolis", "Sidney", "Yokogama", "Amsterdam", "Madrid", "Denwer"]

Can we assume that there will always be a valid solution?

@Gareth yes, you can

the second rule - "[...] shouldn't match anything" - is it a requirement or just a statement saying that it's OK to have mismatch between the first and last letter? (ex: is a list like ["Viden" ... "Lviv"] invalid?)

@w0lf by "shouldn't" I meant it doesn't have to, it is not compulsory. So your example is valid.

Hint: If you want a nice solution, you can reduce this to the calculation of eulerian paths, where each letter is a vertex and each word is an edge. (For instance, Berlin is the edge B → N) This is solvable in O(n), where n is the number of edges.

Ruby, 58 55 44 characters
p$*.permutation.find{|i|i*?,!~/(.),(?!\1)/i}

Yet another ruby implementation. Uses also case insensitive regex (as Ventero's old solution) but the test is done differently.
Previous version:
p$*.permutation.find{|i|(i*?,).gsub(/(.),\1/i,"")!~/,/}

Very nice! And I think you can get this down to 55 if you use !~ instead of negating the whole expression.

That is smart regexp

@w0lf Of course! How could I not think of that?

Python (162 141 124)
Brute force for the win.
from itertools import*
print[j for j in permutations(raw_input().split())if all(x[-1]==y[0].lower()for x,y in zip(j,j[1:]))]

I think you can remove the &(j[0][0]!=j[-1][-1]) condition; see the question comments above.

124 from itertools import*;print[j for j in permutations(raw_input().split())if all(x[-1]==y[0].lower()for x,y in zip(j,j[1:]))]

I'm trying to wrap my head around what's going on in this function.  What exactly are j, x, y?  How are they defined?  I'm sorry if these questions are lame, I'm new to Python and would like to work with it some more.

@MikeDtrick: j contains a permutation of the cities, which is generated with the permutations command. The big if on the end basically validates that for all values in j, the last letter of one value in j is the same as the first letter of the next value in j. Honestly, I don't know either what the zip does, zip works in mysterious ways.

Okay, thank you for the explanation!  +1

Actually that was my +1 but I'm not greedy )). zip takes pair of lists and outputs list of pairs. j is permutation, j[1:] if permutation without first element. So zip(j,j[1:]) is list of pairs: current word x and next word y).

I should use zip more, lol.

Python, 113
Very similar to @beary605's answer, and even more brute-forced.
from random import*
l=raw_input().split()
while any(x[-1]!=y[0].lower()for x,y in zip(l,l[1:])):
 shuffle(l)
print l

Woohoo, bogo-sort style!

Ruby 1.9, 63 54 characters
New solution is based on Howard's solution:
p$*.permutation.max_by{|i|(i*?,).scan(/(.),\1/i).size}

This uses the fact that there'll always be a valid solution.
Old solution, based on w0lf's solution:
p$*.permutation.find{|i|i.inject{|a,e|a&&e[0]=~/#{a[-1]}/i&&e}}

Nice idea with the max_by. And your new version inspired myself for an even newer (and shorter) one.

@Howard Thanks! Your new solution is really awesome, will be difficult to beat that. ;)

Ruby 74 72 104 103 71 70
p$*.permutation.find{|i|i.inject{|a,e|a[-1].casecmp(e[0])==0?e:?,}>?,}

Demo: http://ideone.com/MDK5c (in the demo I've used gets().split() instead of $*; I don't know if Ideone can simulate command-line args).

looks similar to my variant $*.permutation{|p|p p if p.inject(p[0][0]){|m,e|m.casecmp(e[0])==0?e[-1]:?_}>?_} but yours is 9 characters shorter!

p$*.permutation.find{|i|i.inject{|a,e|a&&e[0]=~/#{a[-1]}/i&&e}} is quite a bit shorter. A Ruby 1.8(!) solution which is even shorter: p$*.permutation.find{|i|i.inject{|a,e|a&&a[-1]-32==e[0]&&e}}

@Ventero Using case-insensitive regex is a brilliant idea! Please post this as your own answer; I'm not worthy to use that. :)

@Ventero the -32 solution is also very ingenious, but it relies on the fact that names start with an uppercase letter and end with a lowercase, which may not always be the case.

@w0lf You're right, I thought I read in the specs that it would be the case, but obviously I'm mistaken. ;)

Haskell, 94 74 bytes
g[a]=[[a]]
g c=[b:r|b<-c,r<-g[x|x<-c,x/=b],last b==[r!!0!!0..]!!32]
head.g

Recursively finds all solutions. -7 bytes if it's ok to output all solutions instead of the first. Thanks to @Lynn for getting rid of the pesky import, shaving 18 bytes off the score!
Try it online!

You can get rid of the Data.Char import with last b==[r!!0!!0..]!!32. Also, you don't need parens in g[x|x<-c,x/=b]

@Lynn nice, I somehow thought fromEnum would be a must. Funny, I took those parentheses away already once, but I must have copied from the wrong tab…

GolfScript, 78 characters
" ":s/.{1${1$=!},{:h.,{1$-1={1$0=^31&!{[1$1$]s*[\](\h\-c}*;}+/}{;.p}if}:c~;}/;

A first version in GolfScript. It also does a brute force approach. You can see the script running on the example input online.

Jelly, 25 18 bytes (Improvements welcome!)
UżḢŒuE
ḲŒ!çƝẠ$ÐfḢK

Try it online!
UżḢŒuE        dyadic (2-arg) "check two adjacent city names" function:
Uż            pair (żip) the letters of the reversed left argument with the right argument,
  Ḣ           get the Ḣead of that pairing to yield just the last letter of left and the first letter of right,
   Œu         capitalize both letters,
     E       and check that they're equal!
ḲŒ!çƝẠ$ÐfḢK    i/o and check / fold function:
ḲŒ!            split the input on spaces and get all permutations of it,
   çƝẠ$        run the above function on every adjacent pair (çƝ), and return true if Ȧll pairs are true
       Ðf      filter the permutations to only get the correct ones,
         ḢK    take the first of those, and join by spaces!

Thanks to @Lynn for most of these improvements!
25-byte solution:
Uḣ1Œu=⁹ḣ1
çƝȦ
ḲŒ!©Ç€i1ị®K

Try it online!
Uḣ1Œu=⁹ḣ1      dyadic (2-arg) "check two adjacent city names" function:
Uḣ1Œu          reverse the left arg, get the ḣead, and capitalize it (AKA capitalize the last letter),
     =⁹ḣ1      and check if it's equal to the head (first letter) of the right argument.
çƝȦ            run the above function on every adjacent pair (çƝ), and return true if Ȧll pairs are true
ḲŒ!©Ç€i1ị®K     main i/o function:
ḲŒ!©           split the input on spaces and get all its permutations, ©opy that to the register
    Ç€         run the above link on €ach permutation,
      i1       find the index of the first "successful" permutation,
        ị®K    and ®ecall the permutation list to get the actual ordering at that ịndex, separating output by spaces

Some improvements: Try it online! I wrote a little changelog in the "Input" field. (Oh, after Ðf I use X to pick a random solution instead of the first one, but Ḣ works just as well.)

@Lynn Thank you so much! The zip part was very clever, and I think I can use that Ðf quick in a lot of my other programs to save some space!

Husk, 10 bytes
←fΛ~=o_←→P

Try it online!
Explanation
←fΛ~=(_←)→P  -- example input: ["Xbc","Abc","Cba"]
          P  -- all permutations: [["Xbc","Abc","Cba"],…,[Xbc","Cba","Abc"]]
 f           -- filter by the following (example with ["Xbc","Cba","Abc"])
  Λ          -- | all adjacent pairs ([("Xbc","Cba"),("Cba","Abc")])
   ~=        -- | | are they equal when..
     (_←)    -- | | .. taking the first character lower-cased
         →   -- | | .. taking the last character
             -- | : ['c'=='c','a'=='a'] -> 4
             -- : [["Xbc","Cba","Abc"]]
←            -- take the first element: ["Xbc","Cba","Abc"]

Alternatively, 10 bytes
We could also count the number of adjacent pairs which satisfy the predicate (#), sort on (Ö) that and take the last element (→) for the same number of bytes:
→Ö#~=o_←→P

Try it online!

Mathematica 236 chars
Define the list of cities:
d = {"Neapolis", "Yokogama", "Sidney", "Amsterdam", "Madrid", "Lviv", "Viden", "Denver"}

Find the path that includes all cities:
c = Characters; f = Flatten;
w = Outer[List, d, d]~f~1;
p = Graph[Cases[w, {x_, y_} /;x != y \[And] (ToUpperCase@c[x][[-1]]== c[y][[1]]) :> (x->y)]];
v = f[Cases[{#[[1]], #[[2]], GraphDistance[p, #[[1]], #[[2]]]} & /@  w, {_, _, Length[d] - 1}]];
FindShortestPath[p, v[[1]], v[[2]]]

Output:
{"Lviv", "Viden", "Neapolis", "Sidney", "Yokogama", "Amsterdam","Madrid", "Denver"}

The above approach assumes that the cities can be arranged as a path graph.

The graph p is shown below:

C, 225
#define S t=v[c];v[c]=v[i];v[i]=t
#define L(x)for(i=x;i<n;i++)
char*t;f;n=0;main(int c,char**v){int i;if(!n)n=c,c=1;if(c==n-1){f=1;L(2){for(t=v[i-1];t[1];t++);if(v[i][0]+32-*t)f=n;}L(f)puts(v[i]);}else L(c){S;main(c+1,v);S;}}

Run with country names as the command line arguments
Note:

brute force generation of permutations
for checking it assumes that country names start with an upper case and end in lower case.
assumes there is only one answer
In C, assumes that the **v array of main() is writable

Not sure it is exactly valid, but if you do #define L(x)for(int i=x;i<n;i++) and don't declare i at the beginning of main you save 1 byte.

J, 69 65 60 59 54 characters
Somewhat off the pace.
{.l\:+/2=/\|:tolower;"2({.,{:)@>l=.(i.@!@#A.]);:1!:1[1

Example:
   {.l\:+/2=/\|:tolower;"2({.,{:)@>l=.(i.@!@#A.]);:1!:1[1
Neapolis Yokogama Sydney Amsterdam Madrid Lviv Viden Denwer
+----+-----+--------+------+--------+---------+------+------+
|Lviv|Viden|Neapolis|Sydney|Yokogama|Amsterdam|Madrid|Denwer|
+----+-----+--------+------+--------+---------+------+------+

C#, 398
And here is C# with Linq 5 cents
IEnumerable<string>CityNameGame(string[]input){var cities=new List<string>(input);string lastCity=null;while(cities.Any()){var city=lastCity??cities.First();lastCity=cities.First(name=>string.Equals(city.Substring(city.Length-1),name.Substring(0,1),StringComparison.CurrentCultureIgnoreCase));cities.RemoveAll(name=>name==city||name==lastCity);yield return string.Format("{0}→{1}",city,lastCity);}}

C# (.NET Core), 374 bytes 302 bytes
using System;using System.Linq;class Program{static void Main(string[] s){Func<char, char>u=(c)=>char.ToUpperInvariant(c);var S="";int I=0,C=s.Count();for(;I<C;I++)S=Array.Find(s,x=>u(s[I][0])==u(x[^1]))==null?s[I]:S;for(I=0;I<C;I++){Console.Write(S+" ");S=C>I?Array.Find(s,x=>u(S[^1])==u(x[0])):"";}}}

Try it online!
using System;
using System.Linq;

class Program
{
    static void Main(string[] s)
    {
        Func<char, char> u = (c) => char.ToUpperInvariant(c);
        var S = "";
        int I = 0, C = s.Count();

        for (; I < C; I++)
            S = Array.Find(s, x => u(s[I][0]) == u(x[^1])) == null ? s[I] : S;

        for (I = 0; I < C; I++)
        {
            Console.Write(S + " ");
            S = C > I ? Array.Find(s, x => u(S[^1]) == u(x[0])) : "";
        }
    }
}

Try it online!
using System;
using System.Linq;

var S = "";
int I = 0, C = s.Count();
for (; I < C; I++)
    S = Array.Find(
        s, x =>
        s[I].Substring(0, 1).ToUpper() == x.Substring(x.Length - 1).ToUpper()
    ) == null ?
    s[I] :
    S;
for (I = 0; I < C; I++) {
    Console.Write(S + " ");
    S = C > I ? Array.Find(s, x => S.Substring(S.Length - 1).ToUpper() == x.Substring(0, 1).ToUpper()) : "";
}

279 bytes

Japt -g, 12 bytes
á kÈäÈÌkYÎÃd

Try it

K, 96
{m@&{&/(~).'+(,_1_1#'x),,-1_-1#'x}@'$m:{$[x=1;y;,/.z.s[x-1;y]{x,/:{x@&~x in y}[y;x]}\:y]}[#x;x]}

.
k){m@&{&/(~).'+(,_1_1#'x),,-1_-1#'x}@'$m:{$[x=1;y;,/.z.s[x-1;y]{x,/:{x@&~x in y}[y;x]}\:y]}[#x;x]}`Neapolis`Yokogama`Sidney`Amsterdam`Madrid`Lviv`Viden`Denver
Lviv Viden Neapolis Sidney Yokogama Amsterdam Madrid Denver

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Underhanded contest: The OS war
We all know how the discussion about which is the best operating system caused a lot of flame-wars. Your goal is now, to provide decisive "proof" that your favorite operating system is better... ah, no, much better, to provide decisive "proof" that another operating system is bad.
The task:
Write a program, that does some calculations, and it works correctly on at least one OS and incorrectly on at least another one.

the program should do at least some calculations, so it has to read some simple input (preferably on the standard input, or if from files if you want, but misusing little endian/big endian would not only be cheap, but also obvious), and provide some output depending on the input. The calculations should be meaningful and justified, for example solving a real life or a mathematical problem.
you should specify both operating systems, stating on which one it will work correctly, and on which one it won't. Both operating systems should be well known, and from roughly the same time (so no DOS 1.0 versus a modern OS). It is advised to provide a short description about the cause of the difference (especially if you suspect many people would not realize it) in spoiler tags.

 like this

the cause of the difference has to be subtle, so no #ifdef _WIN32 or similar, please! Remember, your goal is to "prove" that this specific system is bad, so people should not be able to (immediately) spot your trick!
if there is a very strange or very unusual part in your code, you have to justify it in comments why it is there. Of course, this "justification" can/will be a big lie.

Scoring:
This is not a golf! The code should be well organized, and kept simple. Remember, your goal is to hide a bug into it so that people won't suspect it. The simpler the code, the less suspicious it is.
The winner will be decided by votes. The most votes after approximately 10 days after the first valid submission wins. Generally, answers where the code is easy to read and understand, yet the bug is well hidden, and even if discovered, can be attributed to a mistake rather than malice, should be voted up. Similarly, it should be worth much more if the bug just causes an incorrect result, rather than just causing the program to crash or to not do anything.
As usual, I withhold the right to choose an answer as a winner if it is not more than either 10% or 1 point below the one with the most votes, on any subjective criteria.

Interestingly make (1) works properly on essentially every unix box and improperly some windows boxes. Not because of the OSes, but because of the filesystems. Any filesystem that keeps file modification dates to low precision may fail to make properly on a fast machine.

@dmckee: this is why I'm glad that I did not leave everything open, and you have to read in some input and do some simple calculations.

That is my point: make does read input and do some calculations (and interact with the filesystem and launch other processes). These types of programs exist in the real world.

Here is one that works in openbsd but not linux http://stackoverflow.com/a/2455223/174728

I only figured it now, that this quest for evil code has the Id of 6666

Here's to hoping for an answer that works on Windows and , but not on Mac.

@dmckee: NTFS has I think a 100 ns resolution, so wouldn't that be only if you're running off an old FAT disk?

Just write a program that uses all of the system's memory minus about 20mb, then FreeBSD will run it and Windows and some Linuxes won't. :D

One idea might be to use IntPtr.Size, because that's 8 on 64 bit machines, but 4 on 32 bit machines. However, it depends on how you compile your code, and 64 bit applications won't run on 32 bit machines.

I'm voting to close this question as off-topic because underhanded challenges are no longer on-topic on this site. http://meta.codegolf.stackexchange.com/a/8326/20469

Unix shell + standard utilities
Let's write a shell script that finds the process (owned by any user) that has used the most CPU time, and kills all processes with the same name. I suppose that counts as reading in data (from the system) and performing a calculation. (That behavior could be useful for processes that fork off many processes, such as fork bombs and Google Chromium.)
The following should be a portable way to get the name of the process with the greatest CPU time (I tried to avoid obvious Linuxisms but haven't tested it on Solaris):
ps -A -o time= -o comm= | sort | tail -n 1 | cut -d ' ' -f 2

So our script is simply
killall `ps -A -o time= -o comm= | sort | tail -n 1 | cut -d ' ' -f 2`

Run as root for best results, so that it can kill processes from other users.
Linux and BSD
This works on Linux and should work on the BSDs, because killall arg kills processes named arg.
Solaris
However, on Solaris, if a user happens to be running a program named 9 in an infinite loop, the script will bring down the system. This is because:

 On Solaris, killall arg means to kill all processes with the signal arg. So the command line becomes killall 9. As 9 is the number for SIGKILL on Solaris, this will kill all processes and thereby bring down the system.

N.B.

 This shell injection issue doesn't apply on Linux, because even though the malicious user could supply some special argument like -KILL as a process name, killall -KILL will harmlessly print a usage message.

killall is not an example. That just two different programs with the same name. Each version is working properly.

Yes, but the shell script is not working properly.

Did you notice how Chromium and fork bombs are comparable? ;)

@kaoD: The key difference is that fork bombs use less memory.

This is a bad example because cut -d ' ' -f 2 is the wrong way to extract the process name. At this moment in my OpenBSD machine, the process with the most CPU time is is (space)(space)1:1.11.70(space)enlightenment, so I would need cut -d ' ' -f 4 to get its name. After it passes 10 minutes of CPU time, I might need cut -d ' ' -f 3. This script has cut -d ' ' -f 2, which must be wrong unless a process passes 100 minutes. This script can only work if the user can interactively change the -f value.

Just noting that there's no such thing as "Google Chromium": The Google Chrome browser is based on the open-source Chromium browser, but only the former contains Google-specific code and has Google's name attached.

Python
This program opens the image specified on the command line and displays it.
import Image
import sys

with open(sys.argv[1]) as f:
    im = Image.open(f)
    im.show()

Works on linux, does not work on windows.
This is due to the way windows opens files. Binary mode must be specified for this to work properly on all operating systems.

The program should do some calculations and display the results. On a specific operating system it should also display some results, but incorrect ones. Yes, with some clever wordplay you could argue that this is exactly what your program is doing, but I think it's a deliberate misinterpretation of the rules. However, ultimately, the voters decide.

GTB
:"-→_[_+_→_]

On the computer it works, but on my TI-84 calculator it doesn't. Why?

 On the calculator RAM overflows and is potentially cleared, while on the emulator for Windows, RAM cannot be overflown by the emulator because of limited allocation.

What does it do?

There is a spoiler (yellow box) in the question that you can mouse over to see the hidden text.

Yes, but what does it do what RAM doesn't overflow? Does it actually "do some calculations", like the question asks for, and if so, what?

@IlmariKaronen It just concatenates the strings. (You can specify, of course)

Little Endian (Intel x86) vs. Big Endian (IBM Power7)
Any file format where there are multi-byte binary quantities in non-host order runs the risk of being misinterpreted. Here's a function which takes raw audio, say extracted from a WAV file (which is a Microsoft little endian file format), halves the amplitude and outputs the attenuated audio.
#include <stdio.h>

int main()
{
    short audio;
    while (fread(&audio, sizeof(short), 1, stdin))
    {
        audio >>= 1;
        fwrite(&audio, sizeof(short), 1, stdout);
    }
    return 0;
}

In little endian machines, this works great, but in big endian machines, it's a disaster. E.g.
01001101 11001110 -> CE4D (little endian format)

Shift right on little endian:
00100110 01100111 -> 8726 (correct)

Shift right on big endian:
00100110 11100111 -> E726 (not correct)

Note that some of the nybbles are correct! In fact, it's a 50:50 chance that the output will be correct, depending on whether the least significant bit of the sound sample is 0 or 1!
So when you listen to this audio, it's like half amplitude but with some jarring loud high pitched noise overlaid. Quite startling if you're not prepared for it!

C
This solution to problem 100 (about Collatz sequence) is accepted by UVa Online Judge.
However, this code only works correctly on *nix platform since long type is implemented as 64-bit signed integer. On Windows, the code invokes undefined behavior, since long type is implemented as 32-bit signed integer, while one of the intermediate value in cyc() function needs at least 32-bit to represent.
#include <stdio.h>

#define swap(a, b, t) t __tmp__ = a; a = b; b = __tmp__;
#define M 1000000

short l[M] = {0, 1};

int cyc(long n) { // HERE
    if (n < M && l[n]) return l[n];
    n = n & 0x1 ? 3 * n + 1 : n >> 1;
    return n < M ? (l[n] = cyc(n)) + 1 : cyc(n) + 1;
}

int max(int a, int b) { return a > b ? a : b; }

int main() {
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    #endif
    int i, j, m;
    while (scanf("%d %d", &i, &j) == 2) {
          printf("%d %d ", i, j);
          if (i > j) { swap(i, j, int); }
          for (m = 0; i <= j; i++)
              m = max(m, cyc(i));
          printf("%d\n", m);
    }

    return 0;
}

Another way to make this further incompatible is to put the array l inside main() and make corresponding changes to cyc() function. Since the executable is set to request for 2 MB stack by default on Windows, the program crashes right away.

Python
I came across this on StackOverflow when looking for input timeouts.
 import signal
 TIMEOUT = 5

 def interrupted(signum, frame):
     print 'interrupted!'
 signal.signal(signal.SIGALRM, interrupted)

 def input():
     try:
         print 'You have 5 seconds to type in your stuff...'
         foo = raw_input()
         return foo
     except:
         return

 signal.alarm(TIMEOUT)
 s = input()
 signal.alarm(0)
 print 'You typed', s

This does not work for Windows.

Why is this not working in Windows? Am I right guessing it's because Windows doesn't support POSIX SIGs? Then it's just a matter of Python's standard libraries exposing functionality to both OSes. I don't think it follows the spirit of the challenge (e.g. Python's fork won't work either for obvious reasons) but that's Python's flaw (plus the fact that it's interpreted), not Windows'. E.g.: including conio.h would have the same effect, but C won't even compile.

@kaoD: Honestly, I'm not sure why it doesn't work in Windows either. Maybe Linux has some features in it that Windows doesn't, so this is able to be implemented into Linux and not Windows.

Then it's what I guessed: you're using POSIX functionality exposed by Python. IMHO this doesn't fit as an answer because of the previously stated reason, but hey, I'm just another ant in the colony ;) What you see is Python's "fault", not Windows. See this: http://docs.python.org/library/signal.html#signal.signal

The Windows API does not provide cancellable read on a pipe from within the thread.

Linux + bash + GNU coreutils
rm --no-preserve-root -R -dir /

This will erase the root folder and everything in it which doesn't exist in Windows, even if you install bash for Windows :)

This works on Windows now that Windows has a Linux subsystem built in. (I think, won't try it)

@Pavel Pretty simple to open up cmd.exe and type rm to see that it doesn't work.