text:
number of answers and comments
Write a software that prints on stdout the number of answers and the number of comments(visible and collapsed of question and answers) of this question/page.
Your script must run with this page closed when it starts.
Expected example output:
A12C40

Where A stands for Answers and C for Comments.

Little comment to check something, if you dont mind ;)

Comments on the question only or all comments on the page?

All the comments

Does the code have to handle the case when the comments are collapsed when there are too many? And there is also the case when there are too many answers (though I doubt it will get that many).

(does someone have a link of a multi-page question? lol)

@FezVrasta: Here's one, but that's just making it tedious.

How long until someone writes a program that read the most upvoted answer here, and run it ? :D

Is this a clever scheme to get the most viewed question through people testing their scripts?

For testing: http://stackoverflow.com/questions/6841333/why-is-subtracting-these-two-times-in-1927-giving-a-strange-result and http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript

Is it allowed for the script to add/delete comments itself?

Is it possible to break any of these scripts with cleverly crafted comments? I haven't the time to try it at the moment.

Lot of people have tried to break them, lot of scripts was then broken and lot of them was fixed to work again ^_^

Perl, 91 96  92 chars
$_=`curl -sL qr.net/_9`;s/<[^>]+nt="(.+)/$c+=$1/ge;say"A",s/<td.*"ans//g,C,$c+s/<tr.*"com//g

Some stuff just to break solutions of others ha ha ha :-P
show 93 more comments
href
nt="99" (ha ha crash @Fez Vrasta)
a
,show 99show 99 ha ha
href
href
href
ha ha haha :-D
jeeez, just broke my own answer! I discovered that one of the above tricks, which I thought does nothing, will start working after this answer is not edited for some time! So your solutions will work only for some time. That's why you had seen +1 more answer in your solutions..  It's a timed bomb! My answer is already prone to it :-) Aaah, found a way how to launch it NOW...

In the interest of breaking a few more scripts that use css selectors, perhaps a <a href="" class="comment>comment link might work?

Denis unfortunatelly SE will not allow you to display this. You can test on your own answer :)

I check for > so it's not breakable

@FezVrasta ermm.. not breakable? Then how is it possible than I broke it? ;)

@Tomas good, now I do see a proper output with perl -E. Deleting my comment. Also you can delete your reference to my answer, as you are not broking it any more :)

@Tomas should be fixed now

XQuery, 169, 160, 165
let$d:=html:parse(fetch:binary('http://qr.net/1_'))return"A"||count($d//*[@class="answer"])||"C"||count($d//*[@class="comment"])+sum($d//*[@class="comments-link"]/b)

More readable (with spaces):
let $d:= html:parse(fetch:binary('http://qr.net/1_'))
return "A" || count($d//*[@class="answer"]) || "C" || count($d//*[@class="comment"]) + sum($d//*[@class="comments-link"]/b)

BaseX was used as XQuery processor.

Would be even shorter (by using the doc() function) if this page would be valid XML...

And this seems to be the first answer ever on code-golf using XQuery... turns out to be quite suitable :)

on this site I discover a new language every day, this one is quite interesting, thanks. Does it count hidden comments?

@FezVrasta Yeah, and XQuery isn't even esoteric :) Yes it does, thats what $d//*[@class="comments-link"]/b is for (in the  tag the number of hidden comments is shown)

Python 3, 180
import lxml.html as h
s=h.parse('http://qr.net/1_').find('body').cssselect
print('A',len(s('.answer')),'C',len(s('.comment'))+sum(int(e.text)for e in s('.comments-link b')),sep='')

I'm assuming that this question won't have multiple pages of answers.

blender: no luck even with block code :P

@FezVrasta: I'm getting A13C20. Include an angled bracket in the regex and I think it should be good, as those are escaped.

Yes I've already did it. thanks

Hmmm... "Ignore this stuff" huh? What happens if someone edits that out of the answer, then?

Invalid syntax. ,sep=''

@Sukminder: It's Python 3.

Ah, yes. Should perhaps have seen / deducted that. Now I only have to get rid of 5 bytes in my answer ;)

BASH + AWK 163, 144, 138, 111, 110, 114, 131, 132, 105
curl -sL http://qr.net/_9|awk -F'[<>]' '/^[\t]*>s/{c+=$4}/<tr.*"c/{++c}/<t.*"a/{++a}END{print "A"a"C"c}'

Which is the same as this, but without redirecting to a file:
curl -sL http://qr.net/_9>f
awk -F'[<>]' '/^[\t]*>s/{c+=$4}/<tr.*"c/{++c}/<t.*"a/{++a}END{print "A"a"C"c}' f

Current output
A16C76

Explanation

curl

Transfer a URL.

-s in curl is for silent. And -L to follow redirects.

awk

To parse the file. As some answers had some code to break other answers, the parsing has been changed so that it parses from the beginning of the line (^) to make sure it is not broken.

-F'[<>]' set field separators as < or >. This way the text can be parsed properly for the "show XXX more comments".
/^[\t]*>show <b>/{c+=$4} on lines containing "spaces....>show", get the 4th field (based on <, > separators) and add the value to the comments counter.
/^[ ]*<tr.*s="comm/{++c} on lines containing "spaces...
/^<td.*rcell">/{++a} on lines containing "", increment the counter of answers.
END{print "A"a"C"c} print the output.

so it does not count the collapsed comments?

i think you mixed m and f in your code: echo "A$(grep -c 'rcell">' m)C$(grep -c 'mment">' f)" should be echo "A$(grep -c 'rcell">' f)C$(grep -c 'mment">' f)", no?

@plannapus yes, error from copy paste. Solved, thanks!

@FezVrasta mmm no, now it is returning A6C19 which is apparently fine.

no, there is 1 collapsed comment that your script doesn't count

Well @FezVrasta what I see is that the collapsed comments are not in the HTML, they just get fetched when clicking on "add / show X comments".

Yes exactly but other solutions count them as well, it's perfectly possible.

@FezVrasta ook now I see. Just updated accordingly. 163 chars.

@FezVrasta check updated code, with less characters. I messed with the file name. We can save some chars by making the $( aaa ) be $(aaa) but by now I prefer a expanded version for readibilty sake.

Just tested your code, and it reports "A14C159", which I believe is not quite correct.

Well @Abhijit it happens that people keep updating their posts to break the conditions in the rest o f the answers... And I cannot keep updating my answer every time someone update his :D

OK, now you seem to have a correct solution, finally:-P Gave you a hard time, right? :-) A lot of fixing and +22 chars.. :) You may save 3 by using a pipe: curl -sL http://qr.net/_9|awk...

qr.net shortcut is expired :(

R, 326
library(XML);b=htmlParse("https://codegolf.stackexchange.com/questions/20277");z=xpathApply;x=do.call(sum,sapply(z(b,"//tbody",xmlAttrs),function(x)as.integer(x[[1]])))+length(z(b,"//tr[@class='comment']",xmlValue));y=gsub("[^0-9]","",z(b,"//div[@class='subheader answers-subheader']/h2",xmlValue)[[1]]);cat("A",y,"C",x,sep="")

With indentation and explanations:
library(XML)
b=htmlParse("https://codegolf.stackexchange.com/questions/20277")
z=xpathApply
x=do.call(sum,sapply(z(b,"//tbody",xmlAttrs),  #Take the first attribute of tag tbody
                     function(x)as.integer(x[[1]]))) #And sum them (=nb of hidden comments
  +length(z(b,"//tr[@class='comment']",xmlValue)) #+nb of visible comments
y=gsub("[^0-9]","", #This is more straightforward as the number of answers is given on front page.
        z(b,"//div[@class='subheader answers-subheader']/h2",xmlValue)[[1]])
cat("A",y,"C",x,sep="")

Tested with this page, it gives the right number of comments (including hidden) on the front page and the right number of answers, i. e. A23C63.
And here is a solution at 482 characters  that grab the correct number of comments if the question ends up spreading on several pages:
library(XML);h=htmlParse;z=xpathApply;v=xmlValue;a=xmlAttrs;s=sapply;c="http://codegolf.stackexchange.com";f=function(b,i){do.call(sum,s(z(b,"//tbody",a)[i],function(x)as.integer(x[[1]])))+length(z(b,"//tr[@class='comment']",v))};b=h(paste0(c,"/questions/20277"));x=f(b);u=unique(s(z(b,"//div[@class='pager-answers']/a",a),`[`,1));if(length(u))x=x+sum(s(u,function(x)f(h(paste0(c,x)),-1)));y=gsub("[^0-9]","",z(b,"//div[@id='answers-header']/div/h2",v)[[1]]);cat("A",y,"C",x,sep="")

Indented:
library(XML)
h=htmlParse
z=xpathApply
v=xmlValue
a=xmlAttrs
s=sapply
c="http://codegolf.stackexchange.com"
f=function(b,i){do.call(sum,s(z(b,"//tbody",a)[i],function(x)as.integer(x[[1]])))+length(z(b,"//tr[@class='comment']",v))}
b=h(paste0(c,"/questions/20277"))
x=f(b)
u=unique(s(z(b,"//div[@class='pager-answers']/a",a),`[`,1)) #Grab all URLS of pages
if(length(u))x=x+sum(s(u,function(x)f(h(paste0(c,x)),-1))) #Apply comment computation of all URLs
y=gsub("[^0-9]","",z(b,"//div[@id='answers-header']/div/h2",v)[[1]])
cat("A",y,"C",x,sep="")

Tried on this question and outputted: A125C499.

+1 for using R, clear underdog but beautiful language :)

PHP which actually works (302 chars)
Unlike all of the other answers so far, this returns the correct answer even when the question spills onto more than one page.
<?function g($a,$b,$i){return json_decode(gzinflate(substr(file_get_contents("http://api.stackexchange.com/2.1/$a/$i/$b?site=codegolf"),10,-8)))->items;}$i=array(20277);foreach(g("questions","answers",20277)as$x)$i[]=$x->answer_id;echo"A".(count($i)-1)."C".count(g("posts","comments",implode(";",$i)));

Your number of comments it correct but at the moment there are only 5 answers but you script says there are 6. Is it counting the question?

@FelixEve, I think it's probably counting the deleted answer. (count($i)-1) corrects the count to not include the question.

@PeterTaylor How can the script see the deleted answer? It should only be in the markup if logged in with a user that has privilege.

from PHP 5.4 you can use [] instead of array() to initialize

This one won't actually work if there the joined $i has over 100 items. (My own version of the same in ruby doesn't have this limitation. Though admittedly it may bump into API limits. ;-) )

@Cruncher, API results are cached quite heavily - might be why?

@Denis, valid point.

@Cruncher: count($i)-1 was needed because the array also contains the question_id.

Ruby 175 (counts across pages, using the API instead of the DOM)
require'open-uri';require'json'
q=JSON.parse(open("http://qr.net/oyJn").read)["items"][0];a=q["answers"]
puts"A#{a.count}C#{[q,*a].reduce(0){|m,o|m+o["comments"].to_a.count}}"

That's 242 without the shortened url:
require'open-uri';require'json'
q=JSON.parse(open("http://api.stackexchange.com/2.1/questions/20277?site=codegolf&filter=!azbR89z2Zw*dg.").read)["items"][0]
a=q["answers"]
puts"A#{a.count}C#{[q,*a].reduce(0){|m,o|m+o["comments"].to_a.count}}"

Previous 291 answer:
require'open-uri';require'json'
def g(o,l,f);JSON.parse(open("http://api.stackexchange.com/2.1/#{o}/#{l}/#{f}?site=codegolf").read)["items"];end
q=20277
p=g("questions",q,"answers").inject([q]){|m,o|m<<o["answer_id"]}
puts"A#{p.count-1}C#{p.map{|i|g("posts",i,"comments").count}.reduce(:+)}"

Credits to Peter Tailor for the idea of using the API, and Charles for pointing towards a better API.

damnit, that was my idea!

Actually, your use of the filtered API was better. Doing the same here shaves almost 120 characters off of my original answer. :-)

HTML, 37
Sorry, Blatant rule abuse follows!
<script src=http://q0x.eu/1></script>

Explanation
q0x.eu/1 redirects to: http://api.stackexchange.com/2.1/questions/20277/comments?site=codegolf&callback=...
where the callback is:
(function(d){
    c=d.items.length;
    document.write('<script src="http://q0x.eu/2"></script>')
})

q0x.eu/2 redirects to http://api.stackexchange.com/2.1/questions/20277/answers?site=codegolf&callback=...
(function(d){
    a=0;
    g=[];
    d.items.map(function(f){
        a++;
        g.push(f.answer_id)
    });
    document.write('<script src="http://q0x.eu/3?n='+g.pop()+'"></script>')
})

and q0x.eu/3?n=... redirects to http://api.stackexchange.com/2.1/answers/.../comments?site=codegolf&callback=...
(function(d){
    c+=d.items.length;
    g.length ? document.write('<script src="http://q0x.eu/3?n='+g.pop()+'"></script>') : alert('A'+a+'C'+c)
})

I was originally trying to do it legitimately and might still have a go, but this was fun nevertheless!

Well, why not HTTP, 8 chars q0x.eu/1 then? PS: legitimate solutions can't beat Perl anyways ;-) (blatant challenge)

@Tomas, that would be cheating! ;) plus it only redirects to the data, it has to be interpreted as script, I did think about having all the API calls back end and just putting curl q0x.eu/1 or something, but was too lazy...

Python with stackpy 160
Implementation
s=__import__("stackpy").Site("codegolf");q=s.questions(20277);a=q.answers
print"A%dC%d"%(len(a),sum(len(s.answers(e.id()).comments)for e in a)+len(q.comments))

Output
A13C60

Note
Yesterday I contemplated in using the stackexchange API but took some time for me to understand how it works. Today, I saw there were couple of answers on the same theme. To make my answer a bit different, I though of using an external library.
Also realize that other answers which relies on parsing  for patterns like

are likely to break at anytime soon, so a more definite answer is to rely on a robust method like this one.

PHP: 184 172
<?$h=file_get_contents('http://qr.net/_9');preg_match_all('/<t.*nt="([0-9]*)/',$h,$c);echo 'A'.substr_count($h,'rcell">').'C'.(array_sum($c[1])+substr_count($h,'mment">'));

Explanation:
<? // short open tag
  $h = file_get_contents('http://qr.net/_9'); // store in $h the content of the shortened url of the page
  preg_match_all('/<t.*nt="([0-9]*)/', $h, $c); // find each "show/hide X more comments" and store the numbers in $c
  echo
    'A' // output A
    .substr_count($h,'rcell">') // output the count of the occurrences of 'rcell">' (short for '"answercell">')
    .'C' // output C
    .(
      array_sum( $c[1] ) // output the sum of the collapsed comments found before
      +
      substr_count( $h, 'mment">') // output the count of the occurrences of 'mment">' (short for '"comment">')
    );

For the first time PHP beats other languages in golf-scripts :')

Some extra markup to this topic to avoid regex "cheats":
show 9999 more comments

123456 more pickles. rcell" rcell" rcell" rcell" rcell" rcell" rcell" rcell" rcell" rcell" rcell" rcell" rcell" rcell" rcell"

damn you, ok will fix it ._.

"for the first time PHP beats other languages in golf-scripts" It's true that it's rare, but there've been a few

Well, nt="99" ... your comment count seems to be wrong... :-P It is especially ironic that someone punishing regex cheaters is cheating as well :-)

should be fixed now :P

are you sure? :-)

no but I'm kinda bored of spend the life here to fix this stupid script :P

Cannot believe that nobody has came up with it until now! Most direct solution to use :-)
jQuery, 116 101 chars (off competition)
Perhaps this doesn't go with the rules, I keep it just for fun - jQuery solution can't be missing :) At least as a reference to test your scripts!!! ;-)
Try running from the FireBug console:
$('.comments-link').click();
setTimeout("alert('A'+$('.answer').length+'C'+$('.comment').length)",999)

If you have slow connection, increase the timeout :-) Thanks @Fez Vrasta for the great idea of clicking the "show more" links!

Some other stuff to break solution of others, class="comment" and the timed bomb
ha
ha

This will not work if the page is closed, like the question requires.

Yeah, jQuery performs poorly on closed pages :-) I guess it's out of competition then, but cannot really be missing! :)

I did that and my answer was deemed invalid. I deleted it.

@Victor, why not keep it just for fun? How many chars did you have?

@Tomas. Ok, I undeleted it.

R 239
library(XML);F=function(x,y,f=length,z='')sum(as.double(xpathSApply(htmlParse('http://qr.net/1_'),sprintf('//%s[@class="%s"]%s',x,y,z),f)));cat("A",F("div","answer"),"C",F("a","comments-link ",xmlValue,"//b")+F("td","comment-text"),sep="")

After I posted my answer, the output is:
A13C60

F("div","answer") and F("td","comment-text") doesn't work for me (Error in F("div", "answer") :    (list) object cannot be coerced to type 'double'). Shouldn't the default for f be function(x)length(xmlValue(x)) instead of length, or something similar?

It works for me... xpathSApply(...,length) should return a vector, not a list. I am not sure why you would get a list. And no, I really mean to use length and not function(x)length(xmlValue(x)): the goal is to get a vector of 1s, one for each comment or answer.

ok turns out the fact that xpathSApply can takes other functions (like length)  than xmlValue and similar ones is a novelty from version 3.94 of the package (if I understand correctly their changelog). That may be why it didn't work for me. Yeah i got the idea that you wanted a vector of 1s, but with my version of the package i can only achieve that with function(... instead of just length.

Node, 403
r=require;m='comments'
r('http').get("http://api.stackexchange.com/2.1/questions/20277?site=codegolf&filter=!azbR89z2Zw*dg.").on('response',function(p){p.pipe(r('zlib').createGunzip(o="")).on('readable',function(){o+=this.read()}).on('end',function(){d=JSON.parse(o).items[0]
r('util').print("A",d.answer_count,"C",(d[m].length+d.answers.reduce(function(p,c){return p+(c[m]?c[m].length:0)},0)))})})

Only hits the API once... can likely be shortened, but I'm new to Node.

153 151 147, C# & CsQuery
C# With CsQuery:
    var d = CsQuery.CQ.CreateFromUrl("http://qr.net/1_");
    Console.Write("A" + d[".answer"].Count() + "C" + d[".comment"].Count());

Full program:
class P{static void Main(){var d =CsQuery.CQ.CreateFromUrl("http://qr.net/1_");Console.Write("A"+d[".answer"].Count()+"C"+d[".comment"].Count());}}

118 C# & CsQuery in LINQPad or in Roslyn
If running through LINQPad is allowed then:
var d =CsQuery.CQ.CreateFromUrl("http://qr.net/1_");Console.Write("A"+d[".answer"].Count()+"C"+d[".comment"].Count());

Produces:

A14C48

Some more fun.
F# with CsQuery, 143:
[<EntryPoint>]
let main x=
 let d=CsQuery.CQ.CreateFromUrl("http://qr.net/1_")
 printfn "A%dC%d" d.[".answer"].Length d.[".comment"].Length
 0

authors: n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳


text:
tree from string
A string like this one:
"a, 4.25, ((true, 5), 3, (false, false, false)), abc"
Describes a tree with 13 nodes, 9 of which are leaf nodes. In C# the leaf nodes in this example would be of types string, float and bool, this differs between languages and depending on your implementation. The important structure forming symbols here are , ( and ) with spaces being ignored.
See the diagram in David Carrahers answer for a tree of the desired shape.
var a = new cake(4, "abc")

The above contains 8 symbols, I'm counting bracket and " pairs as a half and things like . as 1.
The goal is to write code with the fewest symbols which given a string like the one shown above, creates the tree it represents.
For example in the form of arrays inside each other, or interconnecting node objects.
60 extra points if you don't sort of cheat by adjusting the input string slightly then executing it.
I won't count the symbols that define the input string.
daniero
100 - (10 symbols)
+40 points for understanding numbers, strings, bools
    and any other basic types the language understands.
+20 points for using a reasonably general language.
150 total points

fejesjoco
100 - (est 37 symbols)
+20 points for it understanding numbers as well as strings.
+40 points for using a reasonably general language.
97 total points

tomas
100 - (10 symbols)
90 total points

David Carraher
100 - (est 19 symbols)
81 total points

Looks like homework, basic tokenizing as part of writing a script interpreter.

Please define the exact syntax of the string.

I only see 12 nodes, can you explain it a bit better?

@TeunPronk I guess the 13th is the root node.

The 13th node is the root, although this dosn't matter greatly. It's not homework or a part of a course.

Why don't you give examples of the output you are expecting?

"[...] creates the tree it represents." There are a lot of ways to form a tree out of a list. What defines a token (i.e. are your stings comma and space delimited, and why two delimitters)? What imposes structure on the tree (i.e are the parenthesis intended to indicate sub-trees)? Is the tree expected to be binary? This is very weakly specified, and consequently is not going to generate a very interesting set of responses. You can get help with these kinds of problems in chat or by posting to one of the meta sand-boxes.

The question now has more detail. Now I'd like to see your solution dmckee :)

How is "adjusting input string" cheating? How is using symbols a bad thing? I don't understand the purpose of this challenge any more. It started as a good question but then you spoiled it with nonsense - and changed rules on the run! Retracting my upvote and -1!

Symbols is equivalent to characters, see the description for the atomic-code-golf tag, most challenges here are for short code. And a solution like "s.toTree();" where "s" is the input string is not really a solution.

JavaScript
s="a, 4.25, ((true, 5), 3, (false, false, false)), abc"
eval(("["+s+"]").replace(/\(/g,"[").replace(/\)/g,"]").replace(/([a-z]+)/g,"'$1'"))

The exact syntax, input and output format weren't exactly defined... I replace every a-z character to become a string, even true/false, which could be booleans, but there's no indication if there should be a distinction. I don't know if other characters are allowed or not (ő, $, \uFA20, ...), so my code doesn't care about that either.

I tried it in the Firebug console in Firefox. Also works in the developer console of IE.

The result is a recursive array: ["a", 4.25, [["true", 5], 3, ["false", "false", "false"]], "abc"]

It may be bit of cheating, but it's the most straightforward way I can imagine. Writing a parser is a big task, but many languages have eval-like functions, so there's a reusable parser right there.

Oh, you replace some of the brackets in the string with another type then execute the string :P Impressive all the same :) You may win, particularly if no less cheaty solutions are posted.

Mathematica
StringReplace replaces all instances of ( with List[; instances of  ) with ].
The FullForm of List must be used (instead of {…}); otherwise ToExpression will not parse the string correctly.
f@t_:=ToExpression["List["<>StringReplace[t,{"("->"List[",")"->"]"}]<>"]"]

Example
f["a, 4.25, ((true, 5), 3, (false, false, false)), abc"]

{a, 4.25, {{true, 5}, 3, {false, false, false}}, abc}

Verification
TreeForm[<expression>] displays the Mathematica expression as a tree.
TreeForm[f["a, 4.25, ((true, 5), 3, (false, false, false)), abc"]]

R, 36 chars
plot(read.tree(,paste0("(",a,");")))

package ape must be loaded.
Output:

Common Lisp
I think it would count as something around 11 symbols?
Wrap parentheses around the string, remove the commas and evaluate it, and you have a LISP list.
(read-from-string (remove #\, (concatenate 'string "(" s ")" )))

s is the string.
For the given example it returns a list (A 4.25 ((TRUE 5) 3 (FALSE FALSE FALSE)) ABC)

For those not familiar with lisp, it would be helpful to know that the internal representation of s-expressions is a tree. By striping the commas daniero has rendered the input into a s-expression. Then he just internalizes it and ::Bingo!::

source: Stack Exchange

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

sort: votes


text:
Print the time in a digital watch
Write a program that prints the current time in a digital watch.
Rules:

The program must use the local timezone.
Time is expressed between 00:00 to 23:59 (with only hours and minutes).
The program must follow the output rules.
The smallest program wins.

Output (see example):

Each digit is represented by 4×3 matrix of the characters ␣ (space), | (pipe) and _ (underscore).
There are two spaces between two digits.
The : (column) is represented with a 1x3 matrix [␣,.,.] and is separated with the digits on both sides by 2 spaces.
A newline at the end of the output is tolerated.

List of digits:
 __           __    __          __    __    __    __    __
|  |     |    __|   __|  |__|  |__   |__      |  |__|  |__|
|__|     |   |__    __|     |   __|  |__|     |  |__|   __|

Example output: (for 21:08)
 __             __    __
 __|     |  .  |  |  |__|
|__      |  .  |__|  |__|

Go!
EDIT: corrected the spaces for : and 1

"The : is separated with the digits on both sides by 2 spaces." In your example it has 3 spaces on the left.

@Boann Maybe 1 already has 1 space on each side?

@Boann: no, the 1 digit has spaces included.

@mniip didn't see that one, but I believe the "glue" between getting the current time and printing the digits makes the golfing interesting.

@ArlaudPierre Having the segments of '1' in a different places actually eliminates some clever encoding strategies :(

@Boann Okay I've checked in fact there was a missing space. If you look at a digital clock, it usually has 7 segments, and 1 is represented by the two segments on the right so the empty segments on the left add a space (there are 2 spaces before the digit + 1 space for the empty | + 2 spaces for the empty __)

PHP, 229 174
<?php $s=" |.. w\$km<]_d\x7F}";for($r=3;$r--;print'
')foreach(str_split(date('H:i'))as$c)echo$c>'9'?$s[$r+2]:$s[($d=ord($s[$c+5])>>$r*3)/2&1].($d&1?@__:'  ').$s[$d/4&1],'  ';

$s is a lookup table that encodes several things. The first two characters are the vertical segments, when off or on. The next three characters are the characters of the colon on each of the three rows. The character codes of the remaining characters encode in binary the state of the segments of each digit.

Old version, 229 chars:
<?php foreach([strtr(decbin(735),['    ',' __ ']).' ','|  |   | __| __||__||__ |__    ||__||__|.','|__|   ||__  __|   | __||__|   ||__| __|.']as$r){foreach(str_split(date('H:i'))as$c)echo substr($r,ord($c)-48<<2,4).'  ';echo'
';}

Useful fact: the ASCII code of : is one greater than the ASCII code of 9, so 0123456789: are contiguous.

C# (407 418)
namespace System{using z=String;using w=Console;class P{static void Main(){var t=DateTime.Now.ToString("HH:mm");int k=0;z b="17",d=b+23,e=b+3459,f="56",g=e+2680;Action<z,z,z>q=(l,m,r)=>{foreach(var c in t){if(c==':')w.Write(k++>0?".":" ");else{h(c,l);h(c,m,"_");h(c,m,"_");h(c,r);}w.Write("  ");}w.Write("\n");};q(g,"14",g);q(d,b+0,f);q(e,b+4,"2");}static void h(char x,z m,z y="|"){w.Write(m.Contains(""+x)?" ":y);}}}

Edit: digits are now 4x3 instead of 3x3. this adds 11 characters.

Nice, it seems working. Can you explain your calculations (or does it use some conclusions from older questions)?

I use my solution to a previous challenge. The "calculations" are used to determine which segments whould be "lit up" for a certain character.

Perl - 289 291 302
use POSIX;$_=$p=(strftime"%H:%02M\n",localtime)=~s;.;$&  ;rg;s;\S;$&eq':'?'a':$&-1&&$&-4?'abba':'aaaa';eg;$_.=$p;s;\d|:;(caacaaacabbcabbccbbccbbacbbaaaaccbbccbbcd=~/.{0,4}/g)[-48+ord$&];eg;$_.=$p;s;\d|:;(cbbcaaaccbbaabbcaaacabbccbbcaaaccbbcabbcd=~/.{0,4}/g)[-48+ord$&];eg;y;a-d; _|.;;print

strftime"%H:%02M\n",localtime - obtain local time in H:MM format
s;.;$&  ;rg - intersperse with double spaces
the time is saved in $p for later usage
s;\S;$&eq':'?'a':$&==1||$&==4?'aaaa':'abba';eg - replace : with a, 1 and 4 with aaaa and other digits with abba (later a will turn into ,
b - into _, c - |, d - .)
$_.=$p append $p (spaced time)
s;\d|:;(caacaaacabbcabbccbbccbbacbbaaaaccbbccbbcd=~/.{0,4}/g)[-48+ord$&];eg

/.{0,4}/g - turn the preceding string into an array of 4-char strings
-48+ord$& - turn char code into an index, 0 becomes 0, 1 becomes 1, : becomes 10

then append $p again and run a similar substitution
y;a-d; _|.; - replace abcd with  _|.

Javascript (444, 436, 417, 402)
s="\n";q=[];[0x6606,0x66666,0xfee89,0xff877,0x8e78f,0xef8fe].forEach(function(n){for(i=0;i<20;++i)q.push(1&(n>>i))});function f(j){s+=q[j]?'|':' ';s+=q[j+1]?'_':' ';s+=q[j+2]?'_':' ';s+=q[j+3]?'|':' '}function g(n,l){f(4*Math.floor(n/10)+40*l);s+="  ";f(4*(n%10)+40*l)}d=new Date;h=d.getHours();m=d.getMinutes();p="  .  ";g(h,0);s+="     ";g(m,0);s+="\n";g(h,1);s+=p;g(m,1);s+="\n";g(h,2);s+=p;g(m,2);s

How it works :
Each line of a number is encoded with 4 bits, 0 is a space, 1 is _ (for 2nd and 3rd character) or | (for 1st and last character).
For example, 5 is 0110, 0001, 0111.
The goal is to create an array of 120 booleans (10 numbers * 3 lines * 4 bits) containing all the numbers.

At 14:58 it said "14:50", at 49 it said "14:51" and one minute later "15:00".

Yeah there is an issue with 8 and 9 encoding, I work on a fix :)

for whatever reason (haven't looked through the whole code), minutews are runded up I guess?

Sounds like some octal math worked its way in there.

JavaScript, 192
Disclaimer: This one is a JavaScript port of @Boann's answer.
for(o='',D=(o+(new Date)).substr(16,5),s=' |.. w$km<]_d\x7F}',r=3;r--;o+='\n')for(i=0;c=D[i++];o+=c>'9'?s[r+2]:(s[(d=(s[+c+5]).charCodeAt(0)>>r*3)/2&1]+(d&1?'__':'  ')+s[d/4&1])+'  ');alert(o)

JavaScript (ES6), 256
for(t=[v='',v,v],d=(v+(new Date)).substr(16,5),i=0;c=d[i++];)for(j=3;j--;t[j]+='0    00    00000 +|22  1 1|1|__ |__  2|1|1.+|12 |__  1 2 1|1 2|1 1.'.replace(/\d/g,e=>!+e?' __ ':e^2?'__|':'  |').split('+')[j].substr(+c==c?c*4:40,4)+'  ');alert(t.join('\n'))

Ungolfed:
for(
  // Create an array containing 3 empty strings.
  t=[v='',v,v],
  // Convert current date to a string and extract the time part.
  d=(v+(new Date)).substr(16,5),
  i=0;
  // Read current time digit.
  // Break the loop when the end of string is reached.
  c=d[i++];
)
  for(
    // Iterate 3 times in order to fill each line.
    j=3; j--;
    // Append current character.
    t[j]+='0    00    00000 +|22  1 1|1|__ |__  2|1|1.+|12 |__  1 2 1|1 2|1 1.'.replace(
      // Unpack the above string.
      // Convert each digit into a substring as follow:
      /\d/g,e=>
        // 0: Convert current digit into a number and negate it.
        //    Must be done because !'0' equals false.
        !+e?' __ '
        // 1: Convert current digit into a number and check if different than 2.
        //    Since we have handled the 0, we just read a 1.
        :e^2?'__|'
        // 2: Last case.
        :'  |'
    // Split the unpacked string in 3 lines.
    ).split('+')[j]
      // Get the 4 characters representing the current digit.
      .substr(
        // Convert current digit into a number and compare it with itseft.
        // The comparison fails if the digit convertion results in NaN (:).
        +c==c?c*4:40,4
      // Add 2 spaces between each digits
      )+'  '
  );

// Join lines.
// Output ASCII time.
console.log(t.join('\n'))

177 Characters: o='';D=o+Date();s=' |.. w$km<]_d\x7F}';for(r=3;r--;o+='\n')for(i=16;i<21;)o+=(c=D[i++])>'9'?s[r+2]:(s[(d=s[+c+5].charCodeAt(0)>>r*3)/2&1]+(d&1?'__':e='  ')+s[d/4&1])+e;alert(o)

Delphi XE3 (504 495)
Waay to much, but still fun to do :)
Thanks Manatwork for the tip on multidimensional arrays.
const asc:array[0..9,0..2]of string=((' __ ','|  |','|__|'),('    ','   |','   |'),(' __ ',' __|','|__ '),(' __ ',' __|',' __|'),('    ','|__|','   |'),(' __ ','|__ ',' __|'),(' __ ','|__ ','|__|'),(' __ ','   |','   |'),(' __ ','|__|','|__|'),(' __ ','|__|',' __|'));var s,l:string;x,i:int16;begin s:=FormatDateTime('hhnn',now);for I:=0to 2do begin l:='';for x:=1to length(s)do begin l:=l+asc[StrToInt(s[x])][i];if x=2 then if i>0then l:=l+'  .  'else l:=l+'     'end;writeln(l);end;readln;end.

With indent
const
asc: array[0..9,0..2] of string = (
  (' __ ','|  |','|__|'),
  ('    ','   |','   |'),
  (' __ ',' __|','|__ '),
  (' __ ',' __|',' __|'),
  ('    ','|__|','   |'),
  (' __ ','|__ ',' __|'),
  (' __ ','|__ ','|__|'),
  (' __ ','   |','   |'),
  (' __ ','|__|','|__|'),
  (' __ ','|__|',' __|'));
var
s,l:string;
x,i:int16;
begin
    s:=FormatDateTime('hhnn',now);
    for I := 0 to 2 do
    begin
      l:='';
      for x := 1 to length(s) do
      begin
        l := l + asc[StrToInt(s[x])][i];
        if x=2 then
          if i>0then
            l:=l+'  .  '
          else l:=l+'     '
      end;
      writeln(l);
    end;
    readln
end.

asc:array[0..9,0..2]of string…?

Thanks, still fairly new to delphi, didnt know that was possible ^.^

Took a closer look and I observed some problems. Well, at least in Delphi 2007 these are problems: 1) needs compilation directive to be able to use standard output; 2) the use of SysUtils must be declared; 3) No int16 data type – please specify your Delphi version. But there are some minor tricks to reduce the code size: 1) the array contains just a few distinct strings repeated many times, so better declare them separately; 2) due to the fixed “hhmnn” format string s's length will be always 4, so no need for the Length function; and a few minor tweaks. 415 char: http://pastebin.com/uwRPGse1

Thanks, this is very helpful. I wont change it though because its barely my code anymore, but im sure I can use this for other questions too. So thanks a bunch :)

Ruby (239 335)
0.upto(2){|h|s=(0..3).map{|i|'041655023022615032031055011012'.gsub(/./){[' __ ','|__|',' __|','|__ ','|  |','   |',' '*4][$&.to_i]}.scan(/.{12}/)[Time.new.strftime('%H%M').split('')[i].to_i][h*4..h*4+3]}*' ';s[9]='  '+' ..'[h]+'  ';puts s}

Edit: Shorted with @manatwork syntax

The idea is pretty straightforward: make the array with the numbers and substrings (with []) to print each line of the number.

I know is far from perfect, I'm new in Ruby and there is probably a way to make a loop in the printing that takes less chars.

Instead of putting the time in variable t then distributing to 4 variables with 4 separate assignments, you can do it without variable t using a single parallel assignment: m,n,l,k=Time.new.strftime('%H%M').split('').map{|i|i.to_i}. (Just matter of syntax, not checked how good idea is the use of those 4 variables.)

With a few more size optimizations, 240 characters: http://pastebin.com/7XQhXSpU

Replace s[9]='  '+' ..'[h]+'  ' with s[9]='%3s  '%' ..'[h].

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


text:
Linkin Park Logo
Your goal is to draw the Linkin Park Logo in minimum bytes.

Please add a title with the language and the number of bytes in your code.

it's the circle around the logo required?

If its not just for C++ you dont have to tag it with C++ ;)

@FezVrasta I suppose not since he didnt do it either

@FezVrasta Not required! But you can if you want...

@TeunPronk C++ tag removed

So what are the winning criteria?  Is this code golf?

@Josh It's not code golf as you can see I used too much bytes. Just create a copy of what i created and win!

As per the site, all problems must have An objective primary winning criterion.  How how you measuring entries against each other?

@Josh I wrote much lines.. and i cant ask you all to write less bytes but if you want you can consider it as CodeGolf so shall I.

You could also make it a popularity contest, see what twist people will give to it.

If you decide on code-golf, please tag the question as such

@mniip Now, it's not a CodeGolf.  it's a popularity contest to see what twist people will give to it!

@Josh Now, it's not a CodeGolf. it's a popularity contest to see what twist people will give to it!

The question and the goal is all set now!

This question is insufficiently self-contained, and the one rule makes no sense for a [tag:drawing] question.

What does "no rules" but "should use '=' or '+'" really mean?

@Josh can this be reopened now?

PHP
<?=l(11,0).l(3,1)."\n".l(10,0).l(3,1)."\n".l(9,0).l(3,1).l(9,0).l(3,1)."\n".l(8,0).l(3,1).l(9,0).l(5,1)."\n".l(7,0).l(3,1).l(9,0).l(3,1).l(1,0).l(3,1)."\n".l(6,0).l(3,1).l(9,0).l(3,1).l(3,0).l(3,1)."\n".l(5,0).l(3,1).l(9,0).l(3,1).l(5,0).l(3,1)."\n".l(4,0).l(3,1).l(9,0).l(3,1).l(7,0).l(3,1)."\n".l(3,0).l(27,1)."\n".l(14,0).l(3,1)."\n".l(13,0).l(3,1)."\n".l(12,0).l(3,1)."\n".l(11,0).l(3,1)."\n";function l($a,$c,$o=''){if($c){$c='=';}else{$c=' ';};for($i=0;$i<$a;$i++){$o.=$c;}return $o;}

Ok actually it's longer than write an echo with the logo but It's the first thing which has hit my mind.

Python, 169 bytes
e=' '
z=6*e
x='==='
f=z+x
for i in[e*10+x,e*9+x,e*8+x,e*7+x+f,e*6+x+f+'==',e*5+x+f+e+x,e*4+x+f+e*3+x,e*3+x+f+e*5+x,
e*2+x+f+e*7+x,e+x*8,x*8,e*8+x,e*7+x,e*6+x]:
    print i

I'm sure it can (and will be) done in shorter code.
Output:
          ===
         ===
        ===
       ===      ===
      ===      =====
     ===      === ===
    ===      ===   ===
   ===      ===     ===
  ===      ===       ===
 ========================
========================
        ===
       ===
      ===
[Finished in 0.1s]

Try it for yourself, python 2.7.

Well, I submitted code whle the circle was not required. It's invalid now, I presume? :)

that circle is still not required

ah, good. As this way would lead me nowhere with whe circle, however, I'll try to come up with something that does it. Although I doubt I can manage it with Python :)

Using C++ (Answering my own question) ;)
#include<iostream.h>
#include<conio.h>

void linkinparklogo(int posx, int posy) //Linkin Park Logo Starts
{
     highvideo();
     for(int slant=0; slant<=10; slant++) //Slant Part of "L"
     {
     for(int l=1; l<=3; l++)
         {gotoxy(posx+10-slant+l,posy+1+slant); cprintf("=");}
     }
     getch();
     for(int straight=0; straight<=20; straight++) //Lower Part of Horizontal"L"
     {   gotoxy(posx+4+straight,posy+11); cprintf("=");
     }
     getch();
     for(straight=0; straight<=22; straight++) //Upper Part of Horizontal "L"
     {   gotoxy(posx+3+straight,posy+10); cprintf("=");
     }
     getch();
     for(slant=0; slant<=5; slant++) //Right Slant Part of "P"
     {
         for(int p=1; p<=3; p++)
         {gotoxy(posx+21-slant+p,posy+9-slant); cprintf("=");}
     }
     getch();
     gotoxy(posx+17,posy+5); cprintf("=");
     gotoxy(posx+16,posy+5); cprintf("=");
     getch();
     for(slant=0; slant<=9; slant++) //Left Slant Part of "P"
     {
         for(int ps=1; ps<=3; ps++)
         {gotoxy(posx+14-slant+ps,posy+6+slant); cprintf("=");}
     }
} //Linkin Park Logo Created
void main()
{
     clrscr();
     linkinparklogo(0,0);
     getch();
}

Output:

Delphi
User gives 2 characters which will be used as foreground and background, spaces will work too.
uses idglobal;//Required for IIF function
var
i:int8;
s:string;
fg,bg:char; //Foreground + Background
function soc(c:char;Cnt:integer=3):string;
begin
  Result:=StringOfChar(c, cnt)
end;
begin
writeln('Give foreground and background characters');
Readln(fg,bg);
  for I:=0to 16do
  begin
    s:='';
    if i in[0,16]then
    begin
      s:=soc(bg,29);
      WriteLn(s);
      continue
    end;
    if i in[1,2,3,4,5,6,7,8,9,10,11]then
      s:=soc(bg,17-i-3)+iif(i in[10,11],soc(fg,24),soc(fg))
    else if i in[12,13,14,15]then
      s:=soc(bg,(17-i-3)+8)+soc(fg);
    if i in[4,5,6,7,8,9]then
      s:=s+soc(bg,6);
    case i of
      4:s:=s+soc(fg);
      5:s:=s+soc(fg,5);
      6:s:=s+soc(fg)+bg+soc(fg);
      7:s:=s+soc(fg)+soc(bg)+soc(fg);
      8:s:=s+soc(fg)+soc(bg,5)+soc(fg);
      9:s:=s+soc(fg)+soc(bg,7)+soc(fg);
    end;
    s:=s+soc(bg,29-length(s));
    WriteLn(s);
  end;
  readln;
end.

Results
I must add to this that it looks much better in console lol.
Input: $/                       Input: (space)=
Output:                         Output:
/////////////////////////////   =============================
/////////////$$$/////////////   =============   =============
////////////$$$//////////////   ============   ==============
///////////$$$///////////////   ===========   ===============
//////////$$$//////$$$///////   ==========   ======   =======
/////////$$$//////$$$$$//////   =========   ======     ======
////////$$$//////$$$/$$$/////   ========   ======   =   =====
///////$$$//////$$$///$$$////   =======   ======   ===   ====
//////$$$//////$$$/////$$$///   ======   ======   =====   ===
/////$$$//////$$$///////$$$//   =====   ======   =======   ==
////$$$$$$$$$$$$$$$$$$$$$$$$/   ====                        =
///$$$$$$$$$$$$$$$$$$$$$$$$//   ===                        ==
//////////$$$////////////////   ==========   ================
/////////$$$/////////////////   =========   =================
////////$$$//////////////////   ========   ==================
///////$$$///////////////////   =======   ===================
/////////////////////////////   =============================

Dont look to long to the first image.
Feels weird :P
Images:


text:
Calculate the super root of a number
In mathematics, tetration is the next hyper operator after exponentiation, and is defined as iterated exponentiation.
Addition (a succeeded n times)

Multiplication (a added to itself, n times)

Exponentiation (a multiplied by itself, n times)

Tetration (a exponentiated by itself, n times)

The inverse relations of tetration are called the super-root, and the super-logarithm.
Your task is to write a program that, given A and B, prints out the Bnd-order super-root of A.
For example:

if A = 65,536 and B = 4 it prints 2
if A = 7,625,597,484,987 and B = 3 it prints 3

A and B are positive integers and the result must be floating point number with a precision of 5 digits after the decimal point.
The result belongs to the real domain.
Be careful, super-roots may have many solutions.

Are there minimum/maximum bounds on the input numbers?  Should a valid answer support floating point answers, or only integer?

If multiple solutions, should the program find all or just one?

If answers must support floating point results, how many decimal places are required? Could you provide sample input/output for a few test cases?

I've edited the question, I'm sorry but I can't provide any input/output sample.

So what is your winning criteria?

Can you give a simple example of a super-root that has more than one solution for a given A and B ≥ 1?

@Tobia - I think there is only one solution in the real domain for that input range. In the complex domain there might be many solutions, but I let the MathLab folks deal with that...

@Tobia - And there is a limit of 1 for n0 for even n, so for A = 1, B = 2m there could be two roots: 0 or 1 (I think, but I'm not sure).

Ops, I've chosen the wrong tag, this is a code golf. @YiminRong - You're right, I've changed the question, now the program must find the only solution in the real domain.

Can you give the mathematical representation of a super-root? I'm afraid I still don't understand how it is defined.

@user8777 The Bth super-root of A is equal to x if x^^B = A.

C — aiming for clarity, didn't attempt to squeeze the code
Considering input:
A: A ∈ ℝ, A ≥ 1.0
B: B ∈ ℕ, B ≥ 1

Then there should usually be only one solution in ℝ, which simplifies the problem considerably.
Code is:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#define TOLERANCE    1.0e-09

double tetrate(double, int);

int main(int argc, char **argv)
{
    double target, max, min, mid, working;
    int levels;

    if (argc == 3)
    {
        target = atof(argv[1]); // A
        levels = atoi(argv[2]); // B

        // Shortcut if B == 1
        if (levels == 1)
        {
            printf("%f\n", target);
            return 0;
        }

        // Get a first approximation
        max = 2.0;
        while (tetrate(max, levels) < target)
            max *= 2.0;

        min = max / 2.0;

        // printf("Answer is between %g and %g\n", min, max);

        // Use bisection to get a closer approximation
        do
        {
            mid = (min + max) / 2.0;
            working = tetrate(mid, levels);
            if (working > target)
                max = mid;
            else if (working < target)
                min = mid;
            else
                break;
        }
        while (max - min > TOLERANCE);

        // printf("%g: %f = %f tetrate %d\n", target, tetrate(mid, levels), mid, levels);
        printf("%f\n", mid);
    }

    return 0;
}

double tetrate(double d, int i)
{
    double result = d;

    // If the result is already infinite, don't tetrate any more
    while (--i && isfinite(result))
        result = pow(d, result);

    return result;
}

To compile:
gcc -o tet_root tet_root.c -lm

To run:
./tet_root A B

E.g.:
42
$ ./tet_root 65536 4
2.000000

33
$ ./tet_root 7625597484987 3
3.000000

3π
$ ./tet_root 1.340164183e18 3
3.141593

n(2½) ➙ 2 as n ➙ ∞ ? (well known limit)
$ ./tet_root 2 10
1.416190

$ ./tet_root 2 100
1.414214

$ ./tet_root 2 1000
1.414214

Yes!
n(e1/e) ➙ ∞ as n ➙ ∞ ? (upper bounds)
$ ./tet_root 9.999999999e199 100
1.445700

$ ./tet_root 9.999999999e199 1000
1.444678

$ ./tet_root 9.999999999e199 10000
1.444668

$ ./tet_root 9.999999999e199 100000
1.444668

Cool! (e1/e ≅ 1.44466786101...)

You actually know a lot about math I can tell :) (This answer) ∈ (ℝeally impressive stuff)

@AlbertRenshaw This is just an implementation of bisection. Not very hard at all.

Python, 87 chars
E=lambda x,n:x**E(x,n-1)if n else 1
def S(A,B):
 x=1.
 while E(x,B)<A:x+=1e-5
 return x

A simple linear search for the answer.
Off-topic, but what the *#$(@! is up with the python ** operator?
>>> 1e200*1e200
inf
>>> 1e200**2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: (34, 'Numerical result out of range')

Worthy of a bug report?

Is associativity getting in the way? Perhaps you are comparing (1e200)**2 to 1e(200**2)?

@Josh: I reported a bug: http://bugs.python.org/issue20543  Basically, working as intended - they are not much for IEEE float.  If they were to fix anything, it would be to generate an OverflowError in the first case.

Mathematica, 35 40
n /. Solve[Nest[#^(1/n) &, a, b] == n]~N~5

Generates a list of all solutions, with 5 digit precision.
n /. Last@Solve[Nest[#^(1/n) &, a, b] == n]~N~5

5 more characters to get only the real solution, which the updated rules demand.

When did this become a code golf? I thought it was a code challenge to come up with the best algorithm!

code-golf
APL, 33 chars
{r←⍵⋄⍺{1≥⍵⍟⍣⍺⊢r:⍵⋄⍺∇⍵+i}1+i←1e¯6}

This is a simple linear search, starting from C = 1 + 10-6 and incrementing it by 10-6 until
    logC logC logC ⋯ A ≤ 1
where the logC function is applied recursively B times.
Examples
      4 {r←⍵⋄⍺{1≥⍵⍟⍣⍺⊢r:⍵⋄⍺∇⍵+i}1+i←1e¯6} 65536
2.0000009999177335
      3 {r←⍵⋄⍺{1≥⍵⍟⍣⍺⊢r:⍵⋄⍺∇⍵+i}1+i←1e¯6} 7625597484987
3.0000000000575113

This code is very slow, but for small bases such as 2 or 3 it completes in a few seconds. See below for a better thing.

code-challenge
APL, logarithmic complexity
Actually linear complexity on the root order, logarithmic on the result size and precision:
    time = O(B × log(C) + B × log(D))
where B is the root order, C is the tetration base being asked for, and D is the number of digits of precision asked. This complexity is my intuitive understanding, I have not produced a formal proof.
This algorithm does not require big integers, it only uses the log function on regular floating point numbers, therefore it's quite efficient on very large numbers, up to the limit of the floating point implementation (either double precision, or arbitrary large FP numbers on the APL implementations that offer them.)
The precision of the result can be controlled by setting ⎕CT (comparison tolerance) to the desired acceptable error (on my system it defaults to 1e¯14, roughly 14 decimal digits)
sroot←{              ⍝ Compute the ⍺-th order super-root of ⍵:
  n←⍺ ⋄ r←⍵          ⍝ n is the order, r is the result of the tetration.
  u←{                ⍝ Compute u, the upper bound, a base ≥ the expected result:
    1≥⍵⍟⍣n⊢r:⍵       ⍝   apply ⍵⍟ (log base ⍵) n times; if ≤1 then upper bound found
    ∇2×⍵             ⍝   otherwise double the base and recurse
  }2                 ⍝ start the search with ⍵=2 as a first guess.
  (u÷2){             ⍝ Perform a binary search (bisection) to refine the base:
    b←(⍺+⍵)÷2        ⍝   b is the middle point between ⍺ and ⍵
    t←b⍟⍣n⊢r         ⍝   t is the result of applying b⍟ n times, starting with r;
    t=1:b            ⍝   if t=1 (under ⎕CT), then b is the super-root wanted;
    t<1:⍺∇b          ⍝   if t<1, recurse between ⍺ and b
    b∇⍵              ⍝   otherwise (t>1) returse between b and ⍵
  }u                 ⍝ begin the search between u as found earlier and its half.
}

I'm not sure whether 1≥⍵⍟⍣n above could fail with a Domain Error (because the log of a negative argument could either fail immediately, or give a complex result, which would not be in the domain of ≥) but I haven't been able to find a case that fails.
Examples
      4 sroot 65536
1.9999999999999964
      4 sroot 65537
2.000000185530773
      3 sroot 7625597484987
3
      3 sroot 7625597400000
2.999999999843567
      3 sroot 7625597500000
3.000000000027626

'3' comes out as an exact value because it happens to be one of the values directly hit by the binary search (starting from 2, doubled to 4, bisect to 3). In the general case that does not happen, so the result will approximate the root value with a ⎕CT error (more precisely, the logarithmic test of every candidate base is performed with ⎕CT tolerance.)

Julia
julia> t(a,b)=(c=a;for j=1:b-1;c=a^c;end;c)
julia> s(c,b)=(i=1;while t(i,b)!=c;i+=1;end;i)
julia> s(65536,4)
2
julia> s(7625597484987,3)
3

Ignored floating point instruction since the the question only defines behavior for integers.

Ruby, 79 bytes
->a,b{x=y=1.0;z=a;eval"y=(x+z)/2;x,z=a<eval('y**'*~-b+?y)?[x,y]:[y,z];"*99;p y}

This is the same as the below program, but less accurate since it only runs 99 loops.
Ruby, 87 bytes
->a,b{x=y=1.0;z=a;(y=(x+z)/2;x,z=a<eval("y**"*~-b+?y)?[x,y]:[y,z])while y!=(x+z)/2;p y}

Try it online
This is simply bisection. Ungolfed:
-> a, b {
    # y^^b by evaluating the string "y ** y ** ..."
    tetration =-> y {eval "y ** " * (b-1) + ?y}

    lower = middle = 1.0
    upper = a

    while middle != (lower + upper) / 2 do
        middle = (lower + upper) / 2

        if tetration[middle] > a
            upper = middle
        else
            lower = middle
        end
    end

    print middle
}

k [52 chars]
{{{((%x)*(z*x-1)+y%z xexp x-1)}[x;y]/[2]}[y]/[y<;x]}

A modified version of my own post nth root
Example:
{{{((%x)*(z*x-1)+y%z xexp x-1)}[x;y]/[2]}[y]/[y<;x]}[7625597484987;3]
3f

{{{((%x)*(z*x-1)+y%z xexp x-1)}[x;y]/[2]}[y]/[y<;x]}[65536;4]
2f

Mathematica, 41 bytes without optimization
Mathematica was basically invented to solve problems like this. One easy solution is to construct the problem as a nested power series and pass it to the built-in Reduce function, which seeks analytical solutions to equations. As a result, the following, in addition to being unusually concise code, is also not brute force.
Reduce[Nest[Power[#, 1/x] &, a, b] == x, x, Reals]

You can remove the restriction to provide only Real number solutions if you're patient and want to save six bytes. You can also express some of the nested functions in abbreviated form to save a few more bytes. As given, it returns thusly

Haskell
Simple linear search, returns first, smallest match found.
{-
    The value of a is the result of exponentiating b some number of times.
    This function computes that number.
-}
superRoot a b = head [x | x<-[2..a], tetrate x b == a]

{-
    compute b^b^...^b repeated n times
-}
tetrate b 1 = b
tetrate b n = b^(tetrate b (n-1))

Example
*Main> superRoot 65536 4
2
*Main> superRoot 7625597484987 3
3

05AB1E, 16 bytes
1[ÐU²FXm}¹@#5(°+

Port of @KeithRandall's Python answer.
Try it online.
Explanation:
1                 # Push a 1
 [                # Start an infinite loop:
  Ð               #  Triplicate the top value on the stack
   U              #  Pop and store one in variable `X`
    ²F            #  Inner loop the second input amount of times:
      Xm          #   And take the top value to the power `X`
        }         #  After the inner loop:
         ¹@       #  If the resulting value is larger than or equal to the first input:
           #      #   Stop the infinite loop
                  #   (after which the top of the stack is output implicitly as result)
            5(°+  #  If not: increase the top value by 10^-5

ÐU²FXm} could also be D²>и.»m for the same byte-count:
  D               #   Duplicate the top value on the stack
   ²>             #   Push the second input + 1
     и            #   Repeat the top value that many times as list
      .»          #   Reduce it by:
        m         #    Taking the power

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


text:
Output in the Correct Order
Ok lets say we get a input the following csv file (all entries are quoted strings)
ID,    Before,   After,   Value
 1,         3,       5,    Cat
 2,         5,        ,    Apple
 3,         4,       1,    Dog
 4,          ,       3,    Elephant
 5,         1,       2,    Banana

Output a csv file in which the entries are usage sequence order.
ID,    Before,   After,   Value
 2,         5,        ,    Apple
 5,         1,       2,    Banana
 1,         3,       5,    Cat
 3,         4,       1,    Dog
 4,          ,       3,    Elephant

Notes:
The Values may not necessarily appear in alphabetical order all the time, just that in this example they are.
No revaluing of the IDs being use. They must be the same as input.
Input and Output files will be pass as args to program.

What column are we ordering on?  Will there always be the same columns?

@Josh We're not ordering on any column, just using the Before and After values to figure it out. First 3 columns will always be the same.

I'm still not grasping the concept.  What do before and after refer to?  How are they ordered in the example solution?  They look out of order to me.

@Josh The before and after refer to which ID that this entry appears before and after. Take a look at the first and last entries of the output.

I see now.  What do we do if the input has no possible solution?

@Josh There will alway be a solution.

Can we please have a sample of an actual input and output file?  You say the input is quoted strings, but it's a lot easier if we can see it.

@Hand-E-Food Just use the example give above.

So they're not quoted strings and we have to add padding to the output table, is that right?

@Hand-E-Food Yes they are quoted strings. It doesn't take that long to add them.

Ruby 109 108
Saved one whole character by using randomization instead of searching!
h,*t=[*$<]
t.shuffle!until t.each_cons(2).all?{|c|a,b=c.map{|y|y.lstrip.split /[,\s]+/}
a[1]==b[0]}
puts h,t

This only prints to stdout, so to save to a file use ruby csv.rb in.csv > out.csv.
$ cat test.csv
ID,    Before,   After,   Value
 1,         3,       5,    Cat
 2,         5,        ,    Apple
 3,         4,       1,    Dog
 4,          ,       3,    Elephant
 5,         1,       2,    Banana
$ ruby csv.rb test.csv
ID,    Before,   After,   Value
 2,         5,        ,    Apple
 5,         1,       2,    Banana
 1,         3,       5,    Cat
 3,         4,       1,    Dog
 4,          ,       3,    Elephant

Old version
puts gets,[*$<].permutation.find{|x|x.each_cons(2).all?{|c|a,b=c.map{|y|y.lstrip.split /[,\s]+/}
a[1]==b[0]}}

It simply finds the permutation of the lines where, for each line, the second column (Before) equals the first column (ID) of the next line.

C#, 272 bytes
Not a great answer, but it works.  If I understand Linq correctly, this opens the input file repeatedly, once for each line it writes to the output.
namespace System.Linq{
    class P{
        static void Main(string[]a)
        {
            var v=IO.File.ReadAllLines(a[0]).Select(y=>y.Split(',').ToList());
            var l=v.First();
            var s="\"\"";
            for(;;){
                IO.File.AppendAllText(a[1],string.Join(",",l)+"\n");
                l=v.FirstOrDefault(x=>x[2]==s);
                if(l==null)break;
                s=l[0];
            }
        }
    }
}

Input file:
"ID","Before","After","Value"
"1","3","5","Cat"
"2","5","","Apple"
"3","4","1","Dog"
"4","","3","Elephant"
"5","1","2","Banana"

Output file:
"ID","Before","After","Value"
"2","5","","Apple"
"5","1","2","Banana"
"1","3","5","Cat"
"3","4","1","Dog"
"4","","3","Elephant"

VB.net (Non-Golfed)
Module Module3
  Public Sub Main(ParamArray args() As String)
    Dim items = CSVFileReader(args(0)).ToDictionary(Function(x) x(0))
    Dim Current = items.First(Function(kvp) kvp.Value(2) = "").Value
    Using out As New IO.StreamWriter(args(1), False) With {.AutoFlush=True }
      Do
        out.WriteLine("""{0}"",""{1}"",""{2}"",""{3}""", Current(0), Current(1), Current(2), Current(3))
        If Current(1) <> "" Then Current = items(Current(1))
      Loop Until Current(1) = ""
      out.WriteLine("""{0}"",""{1}"",""{2}"",""{3}""", Current(0), Current(1), Current(2), Current(3))
    End Using
  End Sub

  Public Iterator Function CSVFileReader(fn As String) As IEnumerable(Of String())
    Using t As New FileIO.TextFieldParser(fn) With {.Delimiters ={","},.HasFieldsEnclosedInQuotes = True, .TextFieldType=FileIO.FieldType.Delimited }
      While Not t.EndOfData
        Yield t.ReadFields
      End While
    End Using
  End Function
End Module

Probably a lot of room to golf that code.


text:
C code indenter
Situation: You are a high school teacher, teaching your computing class how to write C programs. However, since it is just the beginning of the term, you haven't taught them about the importance of indentation and spacing. As you are marking their work, your eyes hurt so much you scream in agony, and realise that this can't go on.
Task: You have decided to write a program, in any language, that takes a valid C sourcecode as input and output it nicely formatted. You should decide what is a nicely formatted code, as it is a popularity contest. You are encouraged to implement as many features as you can, the following are some examples:

Add proper indentation at the front of each line
Add spaces after , and other operators, e.g. converting int a[]={1,2,3}; to int a[] = {1, 2, 3};. Remember not to process operators within string literals though.
Remove trailing spaces after each line
Separating statements into several lines, e.g. the student may write tmp=a;a=b;b=tmp; or int f(int n){if(n==1||n==2)return 1;else return f(n-1)+f(n-2);} all in one line, you can separate them into different lines. Be aware of for loops though, they have semicolons in them but I really don't think you should split them up.
Add a new line after defining each function
Another other features you can come up with the help you comprehend your students' codes.

Winning criteria: This is a popularity contest, so the answer with most upvotes wins. In case of a tie, the answer with the most features implemented wins. If that is a tie again then shortest code wins.
You are suggested to include in your answer a list of features that you have implemented, as well as a sample input and output.
Edit: As requested in the comments here is a sample input, though keep in mind that it is only for reference and you are recommended to implement as many features as possible.
Input:
#include <stdio.h>
#include<string.h>
int main() {
int i;
char s[99];
     printf("----------------------\n;;What is your name?;;\n----------------------\n"); //Semicolon added in the string just to annoy you
             /* Now we take the input: */
    scanf("%s",s);
    for(i=0;i<strlen(s);i++){if(s[i]>='a'&&s[i]<='z'){
        s[i]-=('a'-'A'); //this is same as s[i]=s[i]-'a'+'A'
}}printf("Your name in upper case is:\n%s\n",s);
   return 0;}

This is how I would normally format this code: (I'm a lazy person)
#include <stdio.h>
#include <string.h>
int main() {
    int i;
    char s[99];
    printf("----------------------\n;;What is your name?;;\n----------------------\n"); //Semicolon added in the string just to annoy you
    /* Now we take the input: */
    scanf("%s",s);
    for(i=0;i<strlen(s);i++) {
        if(s[i]>='a'&&s[i]<='z') {
            s[i]-=('a'-'A'); //this is same as s[i]=s[i]-'a'+'A'
        }
    }
    printf("Your name in upper case is:\n%s\n",s);
    return 0;
}

This is how I think is easier to read:
#include <stdio.h>
#include <string.h>
int main() {
    int i;
    char s[99];
    printf("----------------------\n;;What is your name?;;\n----------------------\n"); //Semicolon added in the string just to annoy you
    /* Now we take the input: */
    scanf("%s", s);
    for(i = 0; i < strlen(s); i++) {
        if(s[i] >= 'a' && s[i] <= 'z') {
            s[i] -= ('a' - 'A'); //this is same as s[i]=s[i]-'a'+'A'
        }
    }
    printf("Your name in upper case is:\n%s\n", s);
    return 0;
}

Also, now that I start having answers, the answer with the highest vote count will be accepted 5 days after the last answer, i.e. if there are no more new answers within 5 days, this contest will end.

Any reasons for the down votes?

I could remove all unnecessary whitespace (s/\s+/ /) and call it a day

@ratchet freak you could, but I don't think this would be an answer with a lot of upvotes.

I think you should provide an example of input.

@BenH You mean you haven't heard of C?! Well, here is a sample program: (I think the #include<stdio.h> needs to be on its own line for this to work) /* Hai Worldz. This code is to prevent formatting: if(this_code_is_touched){,then+your*program_"doesn't({work)}correctl"y.} */ #include<stdio.h> main(){printf("Hello World");}

No, I mean that if we have to write an indenter, at least provide in the main post a good example of C code containing every kind of cases we could see. Like a for loop, while, do while, if else, function, pointers maybe (but if students can't even indent, I guess they don't know what's a pointer), single and multi lines comments etc... I hope it's more clear.

Can you give some example C code? I do not program C but I would like to join the contest.

@Quincunx thanks for setting up the bounty. I thought my question sucked.

@BenH and CousinCocaine there you go. Also, just to clarify, your program should be able to implement the features in ALL valid C code, and you are recommended to implement as many features as you can. But keep in mind that this is a popularity contest, i.e. the answer with most votes wins, so essentially there is only one requirement: impress your fellow code-golfers.

Seriously? I'd download gnu-indent if not on a unix box

@TomTanner, I posted your solution as an answer, but seriously I think this is not a 'problem' at all, tons of solutions out there that do not need a Bounty or a program to be written. We are reinventing the wheel... ;)

@ace No problem; I thought this question was great. I was sad to see it stay in the dark for so long (or were you hoping to get tumbleweed?).

@CousinCocaine: this is a popularity context. They are not designed to solve the problem in an elegant, or standard way. They are designed to solve the problem in the coolest way you can possibly imagine.

@SztupY, you are right and my sincere excuses for the demotivating words!

Because we are talking about indentation and whitespaces we just have to write the code in a programming a language that is actually designed around whitespace, as that has to be easiest, right?
So the solution is:

Here it is in base64:
ICAgCQogICAgCgkJICAgIAkgCiAgICAKCQkgICAgCQkKICAgIAoJCSAgICAJICAKICAgIAoJCSAgICAJIAkKICAgIAoJCSAKIAogCQoKICAgCSAKICAgCQoJCQkgICAJCQkgCQkKCSAgCQoJICAJICAKICAgCQoJCQkgICAJIAkgCgkgIAkKCSAgCSAJCiAgIAkKCQkJICAgCSAgCQoJICAJCgkgIAkgCQogICAJCgkJCSAgIAkgICAgIAoJICAJCgkgIAkgCQogICAJCgkJCSAgIAkJCQkJIAkKCSAgCQoJICAJCSAKICAgCQoJCQkgICAJICAgCSAKCSAgCQoJICAJICAgIAogICAJCgkJCSAgIAkgCSAgIAoJICAJCgkgIAkgICAJCQogICAJCgkJCSAgIAkgCSAgCQoJICAJCgkgIAkgIAkgIAogICAJIAogICAJCgkJIAogCSAJCQkKICAgCQoJCQkJCiAgCgkKCiAgIAkgIAogICAJCgkJCQkKICAKCQoKICAgCSAJCgoJCgogICAJCSAKICAgCQkKICAgCQkKCQkJICAgCQoJICAJCQkgICAgCSAKICAgCQoJCSAKIAkgCQkJCiAgIAkKCQkJCQogIAoJCgogICAJICAgIAogICAJIAogICAJIAoJCSAKIAkgCQkJCiAgIAkKCQkJCQogIAoJCgogICAJICAgCQkKICAgCSAJCiAgIAkgCQoJCQkgICAJCgkgICAJCSAgICAJIAogICAJCgkJIAogCSAJCQkKICAgCQoJCQkJCiAgCgkKCiAgIAkgIAkgIAogICAJIAkKICAgCSAJCgkJCSAgIAkKCSAgCQkJICAgIAkgCiAgIAkKCQkgCiAJIAkJCQogICAJCgkJCQkKICAKCQoKICAgCQkKICAgCQoJCQkgICAJIAkgCgkgIAkKCSAgCQkgIAogICAJCgkJCSAgIAkJCQkgCQkKCSAgCQoJICAJCSAJCiAgIAkKCQkJICAgCQkJCQkgCQoJICAJCgkgIAkJCSAKICAgCQoJCQkgICAJCQkgCQkKCSAgCQoJICAJCQkJCiAgIAkKCQkJICAgCSAgIAkgCgkgIAkKCSAgCQkgCQkKICAgCQoJCQkgICAJIAkgCSAKCSAgCQoJICAJCQkgIAogICAJCgkJCSAgIAkgCQkJCQoJICAJCgkgIAkJCSAJCiAgIAkKCQkJICAgCSAJICAgCgkgIAkKCSAgCSAgCSAJCiAgIAkKCQkJICAgCSAJICAJCgkgIAkKCSAgCSAgCQkgCiAgIAkKCQkJCQogIAoJCgogICAJCSAgCiAgIAkgCiAgICAKCQkgCgkKCiAgIAkJIAkKICAgCQoJCQkJCiAgICAgCSAKICAgIAoJCSAgICAJCQogICAJCQoJCQkgICAJCgkgICAJCSAKCQoKICAgCQkJIAogICAJCQogICAJCQoJCQkgICAJCgkgIAkJCSAKIAkgCQkJCiAgIAkKCQkJCQogICAgIAkgCiAgICAKCQkgCgkKCiAgIAkJCQkKICAgCQoJCQkJCiAgICAgCSAJCgkJCQoJICAJIAkgCgoJCgogICAJICAJCQkKICAgCSAKICAgIAoJCSAKCQoKICAgCQkgCQkKICAgCQoJCQkJCiAgICAgCSAKICAgCSAKCQkgCgkKCiAgIAkJCSAgCiAgIAkgIAoJCQkgICAJIAkJCQkKCSAgCQoJICAJCQkJIAogICAJCgkJCQkKICAKCQoKICAgCQkJIAkKICAgCSAgCgkJCSAgIAkgCQkJCQoJICAJCgkgIAkJCQkJCiAgIAkKCQkJCQogIAoJCgogICAJCQkJIAogICAJCgkJCQkKICAgICAJIAogICAJCQoJCSAKCQoKICAgCQkJCQkKICAgCQoJCQkJCiAgICAgCSAKICAgCSAgCgkJIAoJCgogICAJICAJIAkKICAgCSAJCiAgIAkgCQoJCQkgICAJCgkgICAJCSAgICAJCgkJCQkKICAKCQoKICAgCSAgCQkgCiAgIAkgCQogICAJIAkKCQkJICAgCQoJICAJCQkgICAgCQoJCQkJCiAgCgkKCiAgIAkJCQogICAJIAkgCgkKICAgICAJCQoJCQkKICAgCSAgCQogCiAKCSAgCSAgIAogCiAKCQkgCSAgIAogICAJICAgICAKCQogICAgIAkgICAgIAoJCiAgICAgCQoJICAJCiAKIAkgIAkKCiAgIAkgICAKCgkKCiAgIAkgCSAJCiAgIAkKCQkJICAgCSAJIAoJICAJCgkgIAkJICAgCiAgIAkKCQkJICAgCSAgIAkgCgkgIAkKCSAgCQkgIAkKICAgCQoJCQkJCiAgCgkKCiAgIAkJICAgCiAgIAkgCiAgICAKCQkgCgkKCiAgIAkJICAJCiAgIAkgIAoJCQkgICAJIAkJCSAgCgkgIAkKCSAgCQkgCSAKICAgCSAKICAgCQoJCSAgICAJCgkJCQkKICAKCQoKICAgCQkgCSAKICAgCQoJCQkJCiAgCgkKCiAgIAkgCQkgCiAgIAkKCQkJICAgCSAJCQkJCgkgIAkKCSAgCSAgICAgCiAgIAkKCQkJCQogIAoJCgogICAJICAgICAKICAgCSAgCgkJCSAgIAkgCSAJIAoJICAJCgkgIAkgICAgCQogICAJCgkJCQkKICAKCQoKICAgCSAgICAJCiAgIAkKCQkJCQogICAgIAkgCiAgIAkKCQkgCgkKCiAgIAkgCQkJCiAgIAkKCQkJICAgCSAJIAoJICAJCgkgIAkgICAJIAogICAJCgkJCQkKICAKCQoKICAgCSAgIAkgCiAgIAkgCiAgICAKCQkgCgkKCiAgIAkKICAgCSAgCiAgIAkKCQkJCQkgICAgCQoJCgkgICAgCSAKCQkJCgkgIAkgCSAKICAgCSAKCQkJICAgCQoJICAJCgkgIAkgICAJCiAgIAkgCgkJCSAgIAkgCgkgIAkKCSAgCSAgCSAKICAgCSAKCQkJICAgCQkKCSAgCQoJICAJICAJCQogICAJIAoJCQkgICAJICAKCSAgCQoJICAJIAkgIAoKICAgCSAgIAkKCiAJIAkJCgogCiAJIAkJCgogICAJIAkgCgogCSAJIAoKIAogCSAJCQoKICAgCSAgCSAKCiAJIAkgCSAJCgogCiAJIAkJCgogICAJICAJCQoKIAkgCSAJCSAKCiAKIAkgCQkKCiAgIAkgCSAgCgogCSAJIAkJCQoKICAgCSAJCQoKIAogCQoKCgo=

For those who have issues printing out the code on a paper here is the annotated version (you can find a compiler for this at the end of the answer):
# heap structure:
# 1: read buffer
# 2: parser state
#   0: before indentation
#   1: after indentation
#   2: inside a string literal
#   3: inside a multiline comment
#   4: inside a single line comment
# 3: identation
# 4: old read buffer
# 5: parenthesis nesting amount

# -------------------
# initialize heap
# -------------------
SS 1 | SS 0 | TTS # [1] := 0
SS 2 | SS 0 | TTS # [2] := 0
SS 3 | SS 0 | TTS # [3] := 0
SS 4 | SS 0 | TTS # [4] := 0
SS 5 | SS 0 | TTS # [5] := 0
LSL 1 # goto L1

# -------------------
# sub: determine what to do in state 0
# -------------------
LSS 2 # LABEL L2
SS 1 | TTT | SS  59 | TSST | LTS 4 # if [1] == ; GOTO L4
SS 1 | TTT | SS  10 | TSST | LTS 5 # if [1] == \n GOTO L5
SS 1 | TTT | SS   9 | TSST | LTS 5 # if [1] == \t GOTO L5
SS 1 | TTT | SS  32 | TSST | LTS 5 # if [1] == ' ' GOTO L5
SS 1 | TTT | SS 125 | TSST | LTS 6 # if [1] == } GOTO L6
SS 1 | TTT | SS  34 | TSST | LTS 16 # if [1] == " GOTO L16
SS 1 | TTT | SS  40 | TSST | LTS 35 # if [1] == ( GOTO L35
SS 1 | TTT | SS  41 | TSST | LTS 36 # if [1] == ) GOTO L36

SS 2 | SS 1 | TTS # [2] := 1
LST 7 # call L7
SS 1 | TTT | TLSS # print [1]
LTL # return

LSS 4 # label L4 - ; handler
SS 1 | TTT | TLSS # print [1]
LTL # return

LSS 5 # label L5 - WS handler
LTL # return

LSS 6 # label L6 - } handler
# decrease identation by one
SS 3 | SS 3 | TTT | SS 1 | TSST | TTS # [3] := [3] - 1
SS 2 | SS 1 | TTS # [2] := 1
LST 7 # call L7
SS 1 | TTT | TLSS # print [1]
LTL # return

LSS 16 # label L16 - " handler
SS2 | SS 2 | TTS # [2] := 2
LST 7 # call L7
SS1 | TTT | TLSS # print [1]
LTL

LSS 35
SS 5 | SS 5 | TTT | SS 1 | TSSS | TTS # [5] := [5] + 1
SS 2 | SS 1 | TTS # [2] := 1
LST 7 # call L7
SS1 | TTT | TLSS # print [1]
LTL

LSS 36
SS 5 | SS 5 | TTT | SS 1 | TSST | TTS # [5] := [5] - 1
SS 2 | SS 1 | TTS # [2] := 1
LST 7 # call L7
SS1 | TTT | TLSS # print [1]
LTL

# -------------------
# sub: determine what to do in state 1
# -------------------
LSS 3 # LABEL L3
SS 1 | TTT | SS  10 | TSST | LTS 12 # if [1] == \n GOTO L12
SS 1 | TTT | SS 123 | TSST | LTS 13 # if [1] == { GOTO L13
SS 1 | TTT | SS 125 | TSST | LTS 14 # if [1] == } GOTO L14
SS 1 | TTT | SS  59 | TSST | LTS 15 # if [1] == ; GOTO L15
SS 1 | TTT | SS  34 | TSST | LTS 27 # if [1] == " GOTO L27
SS 1 | TTT | SS  42 | TSST | LTS 28 # if [1] == * GOTO L28
SS 1 | TTT | SS  47 | TSST | LTS 29 # if [1] == / GOTO L29
SS 1 | TTT | SS  40 | TSST | LTS 37 # if [1] == ( GOTO L37
SS 1 | TTT | SS  41 | TSST | LTS 38 # if [1] == ) GOTO L38
SS 1 | TTT | TLSS # print [1]
LTL # return

LSS 12 # LABEL L12 - \n handler
SS 2 | SS 0 | TTS # [2] := 0
LTL # return

LSS 13 # LABEL L13 - { handler
SS 1 | TTT | TLSS # print [1]
SS 2 | SS 0 | TTS # [2] := 0
SS 3 | SS 3 | TTT | SS 1 | TSSS | TTS # [3] := [3] + 1
LTL # return

LSS 14 # LABEL L14 - } handler
SS 3 | SS 3 | TTT | SS 1 | TSST | TTS # [3] := [3] - 1
LST 7 # call L7
SS 1 | TTT | TLSS # print [1]
SS 2 | SS 0 | TTS # [2] := 0
LTL # return

LSS 15 # LABEL L15 - ; handler
SS 1 | TTT | TLSS # print [1]
SS 5 | TTT | LTS 10 # if [5] == 0 GOTO L39
LTL

LSS 39
SS 2 | SS 0 | TTS # [2] := 0
LTL # return

LSS 27 # label L27 - " handler
SS1 | TTT | TLSS # print [1]
SS2 | SS 2 | TTS # [2] := 2
LTL

LSS 28 # label L28 - * handler - this might start a comment
SS 4 | TTT | SS  47 | TSST | LTS 30 # if [4] == / GOTO L30
SS1 | TTT | TLSS # print [1]
LTL

LSS 29 # label L29 - / handler - this might start a comment
SS 4 | TTT | SS  47 | TSST | LTS 31 # if [4] == / GOTO L31
SS1 | TTT | TLSS # print [1]
LTL

LSS 30 # label L30 - /* handler
SS1 | TTT | TLSS # print [1]
SS2 | SS 3 | TTS # [2] := 3
LTL

LSS 31 # label L31 - // handler
SS1 | TTT | TLSS # print [1]
SS2 | SS 4 | TTS # [2] := 4
LTL

LSS 37
SS 5 | SS 5 | TTT | SS 1 | TSSS | TTS # [5] := [5] + 1
SS1 | TTT | TLSS # print [1]
LTL

LSS 38
SS 5 | SS 5 | TTT | SS 1 | TSST | TTS # [5] := [5] - 1
SS1 | TTT | TLSS # print [1]
LTL

# -------------------
# sub: print identation
# -------------------
LSS 7 # label L7 - print identation
SS 10 | TLSS # print \n
SS 3 | TTT # push [3]
LSS 9 # label L9 - start loop
SLS | LTS 8 # if [3] == 0 GOTO L8
SLS | LTT 8 # if [3] < 0 GOTO L8 - for safety
SS 32 | TLSS # print ' '
SS 32 | TLSS # print ' '
SS 1  | TSST # i := i - 1
LSL 9 # GOTO L9
LSS 8 # label L8 - end loop
LTL #

# -------------------
# sub: L21 - string literal handler
# -------------------
LSS 21
SS 1 | TTT | SS  10 | TSST | LTS 24 # if [1] == \n GOTO L24
SS 1 | TTT | SS  34 | TSST | LTS 25 # if [1] == " GOTO L25
SS 1 | TTT | TLSS # print [1]
LTL

LSS 24 # \n handler - this should never happen, but let's be prepared and reset the parser
SS 2 | SS 0 | TTS # [2] := 0
LTL # return

LSS 25 # " handler - this might be escaped, so be prepared
SS 4 | TTT | SS  92 | TSST | LTS 26 # if [4] == \ GOTO L26
SS 2 | SS 1 | TTS # [2] := 1
SS 1 | TTT | TLSS # print [1]
LTL

LSS 26 # \\" handler - escaped quotes don't finish the literal
SS 1 | TTT | TLSS # print [1]
LTL

# -------------------
# sub: L22 - multiline comment handler
# -------------------
LSS 22
SS 1 | TTT | SS  47 | TSST | LTS 32 # if [1] == / GOTO L32
SS 1 | TTT | TLSS # print [1]
LTL

LSS 32
SS 4 | TTT | SS  42 | TSST | LTS 33 # if [4] == * GOTO L33
SS 1 | TTT | TLSS # print [1]
LTL

LSS 33
SS 1 | TTT | TLSS # print [1]
SS 2 | SS 1 | TTS # [2] := 1
LTL
# -------------------
# sub: L23 - singleline comment handler
# -------------------
LSS 23
SS 1 | TTT | SS  10 | TSST | LTS 34 # if [1] == \n GOTO L34
SS 1 | TTT | TLSS # print [1]
LTL

LSS 34
SS 2 | SS 0 | TTS # [2] := 0
LTL

# -------------------
# main loop
# -------------------
LSS 1 # LABEL L1
SS 4 | SS 1 | TTT | TTS # [4] := [1]
SS 1 | TLTS # [1] := read

SS 2 | TTT | LTS 10 # if [2] == 0 GOTO L10
SS 2 | TTT | SS 1 | TSST | LTS 17 # if [2] == 1 GOTO L17
SS 2 | TTT | SS 2 | TSST | LTS 18 # if [2] == 2 GOTO L18
SS 2 | TTT | SS 3 | TSST | LTS 19 # if [2] == 3 GOTO L19
SS 2 | TTT | SS 4 | TSST | LTS 20 # if [2] == 4 GOTO L20

LSS 17
LST 3  # call L3
LSL 11 # GOTO L11

LSS 10 # label L10
LST 2  # call L2
LSL 11

LSS 18
LST 21
LSL 11

LSS 19
LST 22
LSL 11

LSS 20
LST 23

LSS 11 # label L11
LSL 1  # goto L1
LLL # END

This is still work in progress, although hopefully it should pass most of the criterias!
Currently supported features:

fix identation based on the { and } characters.
add a newline after ;
handle indentation characters inside string literals (including the fact that string literals are not closed when encountering a \")
handle indentation characters inside single and multiline comments
doesn't add newline characters if inside parentheses (like a for block)

Example input (I added some edge cases based Quincunx's comment, so you can check that it behaves properly):
    /* Hai Worldz. This code is to prevent formatting: if(this_code_is_touched){,then+your*program_"doesn't({work)}correctl"y.} */
#include<stdio.h>
#include<string.h>
int main() {
int i;
char s[99];
     printf("----------------------\n;;What is your name?;;\n----------------------\n\""); //Semicolon added in the {;} string just to annoy you
             /* Now we take the {;} input: */
    scanf("%s",s);
    for(i=0;i<strlen(s);i++){if(s[i]>='a'&&s[i]<='z'){
        s[i]-=('a'-'A'); //this is same as s[i]=s[i]-'a'+'A'
}}printf("Your \"name\" in upper case is:\n%s\n",s);
   return 0;}

Example output:
[~/projects/indent]$ cat example.c | ./wspace indent.ws 2>/dev/null

/* Hai Worldz. This code is to prevent formatting: if(this_code_is_touched){,then+your*program_"doesn't({work)}correctl"y.} */
#include<stdio.h>
#include<string.h>
int main() {
  int i;;
  char s[99];;
  printf("----------------------\n;;What is your name?;;\n----------------------\n\"");; //Semicolon added in the {;} string just to annoy you
  /* Now we take the {;} input: */
  scanf("%s",s);;
  for(i=0;i<strlen(s);i++){
    if(s[i]>='a'&&s[i]<='z'){
      s[i]-=('a'-'A');; //this is same as s[i]=s[i]-'a'+'A'
    }
  }
  printf("Your \"name\" in upper case is:\n%s\n",s);;
  return 0;;
}

Note, that because whitespace doesn't support EOF checking the intepreter throws an exception, which we need to suppress. As there is no way in whitespace to check for EOF (as far as I know as this is my first whitespace program) this is something unavoidable, I hope the solution still counts.
This is the script I used to compile the annotated version into proper whitespace:
#!/usr/bin/env ruby
ARGF.each_line do |line|
  data = line.gsub(/'.'/) { |match| match[1].ord }
  data = data.gsub(/[^-LST0-9#]/,'').split('#').first
  if data
    data.tr!('LST',"\n \t")
    data.gsub!(/[-0-9]+/){|m| "#{m.to_i<0?"\t":" "}#{m.to_i.abs.to_s(2).tr('01'," \t")}\n" }
    print data
  end
end

To run:
./wscompiler.rb annotated.ws > indent.ws

Note that this, apart from converting the S, L and T characters, also allow single line comments with #, and can automatically convert numbers and simple character literals into their whitespace representation. Feel free to use it for other whitespace projects if you want

Not bad! :) but it would be nicer if it doesn't split up a for loop into three lines (in my opinion at least... it's still up to the voters to decide). As a reminder, the for loop in C has the syntax for(i=0;i<10;i++)

@ace: as Whitespace is not exactly a high-level language adding these kind of exception is not that easy. That said I still try to fix the two issues with comments and literals, and try to manage to fix the loops as well (I think ignoring ; inside (/) blocks would be enough). I think those should be enough to consider the solution "usable".

@ace: I think I managed to add the exceptions, so now the generated code seems to be indented properly. Changed the example to your one

Vim  the easy way, technically using only one character: =
I am not a vim guru, but I do never underestimate it's power and some consider it as a programming language. For me this solution is a winner anyway.
Open the file in vim:
vim file.c

Within vim press the following keys
gg=G
Explanation:
gg goes to the top of the file
= is a command to fix the indentation
G tells it to perform the operation to the end of the file.
You can save and quit with :wq
It is possible to let vim run command from the command-line, so this can also be done in a one-liner, but I leave that to people who know vim better than I do.

Vim example
a valid input file (fibonacci.c) with bad indent.
/* Fibonacci Series c language */
#include<stdio.h>

int main()
{
int n, first = 0, second = 1, next, c;

            printf("Enter the number of terms\n");
scanf("%d",&n);
  printf("First %d terms of Fibonacci series are :-\n",n);

          for ( c = 0 ; c < n ; c++ )
   {
if ( c <= 1 )
         next = c;
 else
                                     {
next = first +    second;
              first = second;
        second = next;
      }
      printf("%d\n",next);
   }
 return 0;
}

Open in vim: vim fibonacci.c press gg=G
/* Fibonacci Series c language */
#include<stdio.h>

int main()
{
  int n, first = 0, second = 1, next, c;

  printf("Enter the number of terms\n");
  scanf("%d",&n);
  printf("First %d terms of Fibonacci series are :-\n",n);

  for ( c = 0 ; c < n ; c++ )
  {
    if ( c <= 1 )
      next = c;
    else
    {
      next = first +    second;
      first = second;
      second = next;
    }
    printf("%d\n",next);
  }
  return 0;
}

Source: http://stackoverflow.com/a/2355848/1919382

This can be shortened to =GZZ. (Vim golf ftw!)

Since this will be used to help the teacher understand the student's code better it is important to sanitize the input first. Pre-processor directives are unneeeded, as they just intruduce clutter, and macros can also introduce malicious code into the file. We don't want that! Also, it is completely unnecessary to retain the original comments the student wrote, as they are probably completely useless anyway.
Instead, as everyone knows good code needs good comments, apart from fixing the indentation, and the structure, why not add some highly useful comments around main points of the code to make the result even more understandable! This will definitely help the teacher in assessing the work the student has done!
So from this:
    /* Hai Worldz. This code is to prevent formatting: if(this_code_is_touched){,then+your*program_"doesn't({work)}correctl"y.} */
#include<stdio.h>
#include<string.h>
int main() {
int i;
char s[99];
     printf("----------------------\n;;What is your name?;;\n----------------------\n\""); //Semicolon added in the {;} string just to annoy you
             /* Now we take the {;} input: */
    scanf("%s",s);
    for(i=0;i<strlen(s);i++){if(s[i]>='a'&&s[i]<='z'){
        s[i]-=('a'-'A'); //this is same as s[i]=s[i]-'a'+'A'
}}printf("Your \"name\" in upper case is:\n%s\n",s);
   return 0;}

Let's produce this:
int main() {
    /* This will declare i. */
    int i;
    /* This will declare s[99]. */
    char s[99];
    /* This will call the function called printf with 1 parameters */
    printf("----------------------\n;;What is your name?;;\n----------------------\n\"");
    /* This will call the function called scanf with 2 parameters */
    scanf("%s", s);
    /* This will start a for loop, with initializator i = 0. It will loop until i < strlen(s), and will i++ at each iteration */
    for (i = 0; i < strlen(s); i++) {
        /* This will check, whether s[i] >= 'a' && s[i] <= 'z' is true or not. */
        if (s[i] >= 'a' && s[i] <= 'z') {
            s[i] -= 'a' - 'A';
        }
    }
    /* This will call the function called printf with 2 parameters */
    printf("Your \"name\" in upper case is:\n%s\n", s);
    /* This will return from the function. */
    return 0;
}

Isn't it much better, with all of the useful comments around the expressions?

So this is a ruby solution utilizing the cast gem, which is a C parser(Yes, I'm cheating). As this will parse the code, and re-print it from scratch it means the result will be perfectly indented and also consistent, e.g.:

Proper indentation across the code based on block level
Consistent whitespacing around expressions, statements, conditions, etc.
Complete re-indenting based on the structure of the code
etc.

And also it will contain highly useful comments about how the code works, which will super useful for both the students and the teacher!
indent.rb
#!/usr/bin/env ruby
require 'cast'

code = ''
ARGF.each_line do |line|
  if line=~/\A#/
    code << "// #{line.strip}\n"
  else
    code << line
  end
end

class Comment < C::Literal
  field :val
  initializer :val
  def to_s
    "/* #{val} */"
  end
end

tree = C.parse(code)
tree.preorder do |n|
  break if n.kind_of?(Comment)
  if n.kind_of?(C::Declaration)
    dd = []
    n.declarators.each do |d|
      dd << "declare #{d.indirect_type ? d.indirect_type.to_s(d.name) : d.name}"
      dd.last << " and set it to #{d.init}" if d.init
    end
    unless dd.empty?
      n.insert_prev(Comment.new("This will #{dd.join(", ")}."))
    end
  end rescue nil
  n.parent.insert_prev(Comment.new("This will call the function called #{n.expr} with #{n.args.length} parameters")) if n.kind_of?(C::Call) rescue nil
  n.insert_prev(Comment.new("This will start a for loop, with initializator #{n.init}. It will loop until #{n.cond}, and will #{n.iter} at each iteration")) if n.kind_of?(C::For) rescue nil
  n.insert_prev(Comment.new("This will check, whether #{n.cond} is true or not.")) if n.kind_of?(C::If) rescue nil
  n.insert_prev(Comment.new("This will return from the function.")) if n.kind_of?(C::Return) rescue nil
end

puts tree

Gemfile
source "http://rubygems.org"
gem 'cast', '0.2.1'

+1 for it is completely unnecessary to retain the original comments the student wrote, as they are probably completely useless anyway

Those comments are undescriptive to me. They introduce clutter because they simply restate the following line.

@Quincunx I think you missed the sarcasm tag. This is a popularity contest.

Bash, 35 characters
Input file must be named "input.c" and placed in the current working directory.
sh <(wget -q -O- http://x.co/3snpk)

Example output, having been fed the input in the original question:

It may take a few seconds to run depending on your hardware, so be patient :)

You know that this is not code-golf, right?

+1 for downloading and compiling AStyle on the fly O.o Wouldn't you just leave AStyle there for the convenience of the user though? So remove the rm?

Since this is not code-golf I think it would be better to just put the contents of your pastebin here, as from a quick look I didn't even notice you are actually formatting the code properly with an external command

@Quincunx: it's meant to be a bit of a troll answer :P

@tomsmeding: I wouldn't want my code to have side effects, such as taking up the user's disk space unexpectedly...

@Riot then you would also need to rm input.c.orig...

Backing up your original file is not unusual behaviour though, it's not the same as leaving an entire cloned svn repository hanging about :)

This is written in python and based on the GNU Coding Standards.
Features so far:

Indenting blocks
Splitting lines (may split things that shouldn't be)
GNU-style function definitions

Code:
import sys

file_in = sys.argv[1]

# Functions, for, if, while, and switch statements
def func_def(string):
    ret = ["", "", ""]
    func_name = ""
    paren_level = -1
    consume_id = False

    for x in string[::-1]:
        if x == "{":
            ret[2] = "{"
        elif ret[1] == "":
            if x == "(":
                paren_level -= 1
                func_name += x
            elif x == ")":
                paren_level += 1
                func_name += x
            elif paren_level == -1 and x.isspace():
                if consume_id:
                    ret[1] = func_name[::-1]
            elif paren_level == -1:
                consume_id = True
                func_name += x
            else:
                func_name += x
        else:
            # Return Type
            ret[0] += x
    else:
        ret[1] = func_name[::-1]

    ret[0] = ret[0][::-1]

    # Handle the case in which this is just a statement
    if ret[1].split("(")[0].strip() in ["for", "if", "while", "switch"]:
        ret = [ret[1], ret[2]] # Don't print an extra line

    return ret

with open(file_in) as file_obj_in:
    line_len = 0
    buffer = ""
    in_str = False
    no_newline = False
    indent_level = 0
    tab = " " * 4
    no_tab = False
    brace_stack = [-1]

    while True:
        buffer += file_obj_in.read(1)
        if buffer == "":
            break
        elif "\n" in buffer:
            if not no_newline:
                print(("" if no_tab else indent_level * tab) + buffer, end="")
                buffer = ""
                line_len = indent_level * 4
                no_tab = False
                continue
            else:
                buffer = ""
                line_len = indent_level * 4
                no_newline = False
                continue
        elif buffer[-1] == '"':
            in_str = not in_str
        elif buffer.isspace():
            buffer = ""
            continue

        if "){" in "".join(buffer.split()) and not in_str:
            for x in func_def(buffer):
                print(indent_level * tab + x)
            buffer = ""
            line_len = indent_level * 4
            no_newline = True
            indent_level += 1
            brace_stack[0] += 1
            brace_stack.append((brace_stack[0], True))
            continue
        elif buffer[-1] == "}" and not in_str:
            brace_stack[0] -= 1
            if brace_stack[-1][1]: # If we must print newline and indent
                if not buffer == "}":
                    print(indent_level * tab + buffer[:-1].rstrip("\n"))
                indent_level -= 1
                print(indent_level * tab + "}")
                buffer = ""
                line_len = indent_level * 4
            else:
                pass
            brace_stack.pop()
        line_len += 1

        if line_len == 79 and not in_str:
            print(indent_level * tab + buffer)
            buffer = ""
            line_len = indent_level * 4
            continue
        elif line_len == 78 and in_str:
            print(indent_level * tab + buffer + "\\")
            buffer = ""
            line_len = indent_level * 4
            no_tab = True
            continue

Example input (pass a filename as argument):
#include <stdio.h>
#include<string.h>
int main() {
int i;
char s[99];
     printf("----------------------\n;;What is your name?;;\n----------------------\n"); //Semicolon added in the string just to annoy you
             /* Now we take the input: */
    scanf("%s",s);
    for(i=0;i<strlen(s);i++){if(s[i]>='a'&&s[i]<='z'){
        s[i]-=('a'-'A'); //this is same as s[i]=s[i]-'a'+'A'
}}printf("Your name in upper case is:\n%s\n",s);
   return 0;}

Example output:
#include <stdio.h>
#include<string.h>
int
main()
{
    int i;
    char s[99];
    printf("----------------------\n;;What is your name?;;\n------------------\
----\n"); //Semicolon added in the string just to annoy you
    /* Now we take the input: */
    scanf("%s",s);
    for(i=0;i<strlen(s);i++)
    {
        if(s[i]>='a'&&s[i]<='z')
        {
            s[i]-=('a'-'A'); //this is same as s[i]=s[i]-'a'+'A'
        }
    }
    printf("Your name in upper case is:\n%s\n",s);
    return 0;
}

This will have bugs.

Ruby
code = DATA.read

# first, we need to replace strings and comments with tilde escapes to avoid parsing them
code.gsub! '~', '~T'
lineComments = []
code.gsub!(/\/\/.*$/) { lineComments.push $&; '~L' }
multilineComments = []
code.gsub!(/\/\*.*?\*\//m) { multilineComments.push $&; '~M' }
strs = []
code.gsub!(/"(\\.|[^"])*"|'.'/) { strs.push $&; '~S' } # character literals are considered strings

# also, chop out preprocessor stuffs
preprocessor = ''
code.gsub!(/(^#.*\n)+/) { preprocessor = $&; '' }

# clean up newlines and excess whitespace
code.gsub! "\n", ' '
code.gsub! /\s+/, ' '
code.gsub!(/[;{}]/) { "#{$&}\n" }
code.gsub!(/[}]/) { "\n#{$&}" }
code.gsub! /^\s*/, ''
code.gsub! /\s+$/, ''

# fix for loops (with semicolons)
code.gsub!(/^for.*\n.*\n.*/) { $&.gsub ";\n", '; ' }

# now it's time for indenting; add indent according to {}
indentedCode = ''
code.each_line { |l|
    indentedCode += ('    ' * [indentedCode.count('{') - indentedCode.count('}') - (l =~ /^\}/ ? 1 : 0), 0].max) + l
}
code = indentedCode

# finally we're adding whitespace for more readability. first get a list of all operators
opsWithEq = '= + - * / % ! > < & | ^ >> <<'
opsNoEq = '++ -- && ||'
ops = opsWithEq.split + opsWithEq.split.map{|o| o + '=' } + opsNoEq.split
ops = ops.sort_by(&:length).reverse
# now whitespace-ize them
code.gsub!(/(.)(#{ops.map{|o| Regexp.escape o }.join '|'})(.)/m) { "#{$1 == ' ' ? ' ' : ($1 + ' ')}#{$2}#{$3 == ' ' ? ' ' : (' ' + $3)}" }

# special-cases: only add whitespace to the right
ops = ','.split
code.gsub!(/(#{ops.map{|o| Regexp.escape o }.join '|'})(.)/m) { "#{$1}#{$2 == ' ' ? ' ' : (' ' + $2)}" }
# special-cases: only add whitespace to the left
ops = '{'.split
code.gsub!(/(.)(#{ops.map{|o| Regexp.escape o }.join '|'})/m) { "#{$1 == ' ' ? ' ' : ($1 + ' ')}#{$2}" }

# replace the tilde escapes and preprocessor stuffs
stri = lci = mci = -1
code.gsub!(/~(.)/) {
    case $1
    when 'T'
        '~'
    when 'S'
        strs[stri += 1]
    when 'L'
        lineComments[lci += 1] + "\n#{code[0, $~.begin(0)].split("\n").last}"
    when 'M'
        multilineComments[mci += 1]
    end
}
code = (preprocessor + "\n" + code).gsub /^ +\n/, ''

puts code
__END__
    /* Hai Worldz. This code is to prevent formatting: if(this_code_is_touched){,then+your*program_"doesn't({work)}correctl"y.} */
#include<stdio.h>
#include<string.h>
int main() {
int i;
char s[99];
     printf("----------------------\n;;What is your name?;;\n----------------------\n\""); //Semicolon added in the {;} string just to annoy you
             /* Now we take the {;} input: */
    scanf("%s",s);
    for(i=0;i<strlen(s);i++){if(s[i]>='a'&&s[i]<='z'){
        s[i]-=('a'-'A'); //this is same as s[i]=s[i]-'a'+'A'
}}printf("Your \"name\" in upper case is:\n%s\n",s);
   return 0;}

Output:
#include <stdio.h>
#include<string.h>

int main() {
    int i;
    char s[99];
    printf("----------------------\n;;What is your name?;;\n----------------------\n");
    //Semicolon added in the string just to annoy you
     /* Now we take the input: */ scanf("%s", s);
    for(i = 0; i < strlen(s); i ++ ) {
        if(s[i] >= 'a' && s[i] <= 'z') {
            s[i] -= ('a' - 'A');
            //this is same as s[i]=s[i]-'a'+'A'
        }
    }
    printf("Your name in upper case is:\n%s\n", s);
    return 0;
}

Output for @SztupY's edge case input:
#include<stdio.h>
#include<string.h>

/* Hai Worldz. This code is to prevent formatting: if(this_code_is_touched){,then+your*program_"doesn't({work)}correctl"y.} */ int main() {
    int i;
    char s[99];
    printf("----------------------\n;;What is your name?;;\n----------------------\n\"");
    //Semicolon added in the {;} string just to annoy you
     /* Now we take the {;} input: */ scanf("%s", s);
    for(i = 0; i < strlen(s); i ++ ) {
        if(s[i] >= 'a' && s[i] <= 'z') {
            s[i] -= ('a' - 'A');
            //this is same as s[i]=s[i]-'a'+'A'
        }
    }
    printf("Your \"name\" in upper case is:\n%s\n", s);
    return 0;
}

Features so far:

[x] Add proper indentation at the front of each line
[x] Add spaces after , and other operators, e.g. converting int a[]={1,2,3}; to int a[] = {1, 2, 3};. Remember not to process operators within string literals though.
[x] Remove trailing spaces after each line
[x] Separating statements into several lines, e.g. the student may write tmp=a;a=b;b=tmp; or int f(int n){if(n==1||n==2)return 1;else return f(n-1)+f(n-2);} all in one line, you can separate them into different lines. Be aware of for loops though, they have semicolons in them but I really don't think you should split them up.
[ ] Add a new line after defining each function
[ ] Another other features you can come up with the help you comprehend your students' codes.

.Net
Open that file using Visual Studio
Input:
#include<stdio.h>
#include<string.h>
int main() {
int i;
char s[99];
     printf("----------------------\n;;What is your name?;;\n----------------------\n\""); //Semicolon added in the {;} string just to annoy you
             /* Now we take the {;} input: */
    scanf("%s",s);
    for(i=0;i<strlen(s);i++){if(s[i]>='a'&&s[i]<='z'){
            s[i]-=('a'-'A'); //this is same as s[i]=s[i]-'a'+'A'
    }
}printf("Your \"name\" in upper case is:\n%s\n",s);
       return 0;}

Output:

This is a good idea, but the challenge is a programming contest. Can you write a program that opens this file with visual studios, then saves it in pretty print?


text:
Match strings whose length is isolated prime
Isolated prime definition from Wikipedia:

An isolated prime is a prime number p such that neither p − 2 nor p + 2 is prime. In other words, p is not part of a twin prime pair. For example, 23 is an isolated prime since 21 and 25 are both composite.

Consider strings which consists of character x repeated n times, where n ≥ 0. You shall write a regex which matches strings whose length is an isolated prime, and rejects strings whose length is not an isolated prime.
Same rule as my previous question Match strings whose length is a fourth power:

Any (ir)regular expression syntax is allowed, except for arbitrary code execution (to Perl users).
Your solution should logically1 work correctly for large number. This means that an answer that lists out all the lengths within certain range is disqualified.
Please also include a short explanation about your approach to the problem (something like this).

1 Some engine implements * with an upper limit. This question assumes that * doesn't have an upper limit (and the only limit is the length of the input string).
This question on SO might be useful as a starting point. How to determine if a number is a prime with regex?
Do you know?
If you can solve this problem, with trivial modification, you can check whether a number is part of a twin prime, since isolated prime has opposite definition of a twin prime.

Perl, 54
/^(?!(..+)\1+$)(?=..(?:|(..+)\2+)$)(?=(..(.*))\4\3*$)/

I think this is not possible without the Perl look-ahead expression... Firstly, there is no positive regex to match the prime number. You can only match a non-prime by simulating multiplication: (..+)\1+. To negate it, I use negative look-ahead: /^(?!(..+)\1+$)/ matches prime numbers (neglecting the 0, 1 case).
The beauty of the look-ahead is that it is zero-width, i.e. eats no characters. This means you can actually AND those conditions! My regex is composed of 3 look-aheads, corresponding to AND-ing 3 conditions:

(?!(..+)\1+$) - N (length of the string) is the prime number
(?=..(?:|(..+)\2+)$) - N-2 is a non-prime - this is a trival modification of the basic non-prime expression - (..+)\1+) - just add two characters. The (?:|...) is included to also match an empty string (case N=2 should match too).
(?=(..(.*))\4\3*$) - N+2 is a non-prime - again, trivial modification of the basic non-prime expression - cut two characters out of one repetition.

Test:
$ perl -E'($"x$_)=~/^(?!(..+)\1+$)(?=..(?:|(..+)\2+)$)(?=(..(.*))\4\3*$)/&&say for(2..200)'
2
23
37
47
53
67
79
83
89
97
113
127
131
157
163
167
173

Instant accept. Don't think there is any other answer. I kinda expect this to be easy. My solution is the same, except that I also test for 1 in p-2 (you only test for composite and 0), but it doesn't affect the final result.

Well, easy... it seemed pretty impossible, until I got the idea to use look-aheads ;-)

authors: n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳


text:
Create a sophisticated livelock
The point of the puzzle is to learn about livelocks:
Create a multi-threaded (or a multi-process) program, whose threads (processes) indefinitely try to wait for each other and never finish. Unlike a deadlock situation, the state of threads (processes) in a livelock constantly change as they try to resolve the situation, but never succeeding.
The task isn't to create a shortest or a simplest solution. Try to create a solution that resembles a real situation, something that looks like a genuine piece of code, but with some kind of an error that creates the livelock.
This is a popularity contest. The most up-voted answer in ~10 days wins.

Ruby
Based on the Dining Philosophers tale - 4 philosophers:

Five silent philosophers sit at a table around a bowl of spaghetti. A
  fork is placed between each pair of adjacent philosophers. (An
  alternative problem formulation uses rice and chopsticks instead of
  spaghetti and forks.)
Each philosopher must alternately think and eat. However, a
  philosopher can only eat spaghetti when he has both left and right
  forks. Each fork can be held by only one philosopher and so a
  philosopher can use the fork only if it's not being used by another
  philosopher. After he finishes eating, he needs to put down both forks
  so they become available to others. A philosopher can grab the fork on
  his right or the one on his left as they become available, but can't
  start eating before getting both of them.

class Fork

  attr_reader :owner
  def initialize
   @mutex = Mutex.new
  end

  def pickup(new_owner)
    @mutex.synchronize do
      if @owner.nil?
        @owner = new_owner
    return true
      end
      return false
    end
  end

  def release(owner)
     @mutex.synchronize do
      if @owner == owner
        @owner = nil
    return true
      end
      return false
    end
  end
end

class Philosopher

  attr_reader :name, :hungry
  attr_accessor :left_fork, :right_fork

  def initialize(name, left_fork, right_fork)
    @name = name
    @hungry = true
    @left_fork = left_fork
    @right_fork = right_fork
  end

  def eat
    while hungry
      got_left = left_fork.pickup(self)
      think
      got_right = right_fork.pickup(self)
      if got_left && got_right
        @hungry = false
    puts "#{name} has eaten!"
      end
      right_fork.release(self)
      think
      left_fork.release(self)
    end
    puts "#{name} ended"
  end

  def think
    puts "#{name} thinks..."
    sleep 1
  end
end

fork = nil
philosophers = %w(aristotle plato confucius descartes).map { |p| Philosopher.new(p, fork, fork = Fork.new) }
philosophers[0].left_fork = fork

threads = philosophers.map do |p|
  puts p.left_fork.pickup(p)
  Thread.new {
    p.eat
  }
end

threads.map(&:join)

Game Maker Language
Script add:
subtract=argument0
add(not(subtract))