text:
Obtain a number from 4 numbers using any combination of mathematical operations
Given 4 numbers n1, n2, n3, n4, and a goal n5, obtain n5 using n1 through n4 combined with any operations.
Eg. Given four numbers 2,3,4,5 and the goal as 8, output (one of many) is 2-3+4+5
EDIT: This is a variation of a game played at my son's school. Paranthesis, powers, unary operations (log, factorial) are allowed; the expressions tend to get complicated.
However, unary operations can be applied only once on a number. Essentially, the tree should be:

                          goal
                           /\
                          /  \
                         /    \
                expression1   expression2
                   /\                /\
                  /  \              /  \
                 /    \            /    \
               term1  term2     term3  term4

where term#i  is either
1. one of the numbers, or
2. one of the numbers with an unary operation.

Does factorial count as an operation?

Can output need parentheses? (it seems like a valid way to combine with the operations, but neither your example nor the current posted answers support that)  For example solving 5 with 10,1,1,0.

BTW, is this code golf at all?

@CMR: You are expected to tag a question with a type-of-challange tag; either code-golf or code-challenge (and possibly others eventually). Given the nature of the answers so-far, I'm going to apply [code-golf], and you should change it if that is not what you meant.

I assume "4+4" is invalid since it repeats a number and doesn't use 2,3,5?

All numbers to be used, once and only once.

Python (159)

from itertools import*
f=lambda*l:[a+f+b+g+c+h+d for f,g,h in product('+-/*',repeat=3)for a,b,c,d in permutations(map(str,l[:4]))if eval(a+f+b+g+c+h+d)==l[4]]

Example:

>>> f(2,3,4,5,8)
['2+4+5-3', '2+5+4-3', '4+2+5-3', '4+5+2-3', '5+2+4-3', '5+4+2-3', '2+5+4/3',
'3+5+2/4', '5+2+4/3', '5+3+2/4', '2+4-3+5', '2+5-3+4', '4+2-3+5', '4+5-3+2',
'5+2-3+4', '5+4-3+2', '3+5-2/4', '4+5-3/2', '5+3-2/4', '5+4-3/2', '2+4/3+5',
'3+2/4+5', '5+2/4+3', '5+4/3+2', '2+4*5/3', '2+5*4/3', '2-3+4+5', '2-3+5+4',
'4-3+2+5', '4-3+5+2', '5-3+2+4', '5-3+4+2', '3-2/4+5', '4-3/2+5', '5-2/4+3',
'5-3/2+4', '2/4+3+5', '2/4+5+3', '4/3+2+5', '4/3+5+2', '3/5+2*4', '3/5+4*2',
'5/3*2*4', '5/3*4*2', '2*4+3/5', '4*2+3/5', '2*4-3/5', '4*2-3/5', '4*5/3+2',
'5*4/3+2']

Gotta love itertools.

ZeroDivisionError: integer division or modulo by zero

Python - 146 chars
from itertools import*
f=lambda*l:[s for s in((3*"%s%%s"+"%s")%a%o for o in product(*['+-/*']*3)for a in permutations(l[:4]))if eval(s)==l[4]]

Ruby1.9.1 - 158 chars
g=->a,&b{a.permutation.each &b}
f=->*a{t=a.pop
g.(a){|n|g.(['+','-','*','/']*3){|k|s=[n[0],k[9],n[1],k[10],n[2],k[11],n[3]].join ''
return s if eval(s)==t}}}

Lambda function f returns the first solution it finds. eg.
f[2,3,4,5,8] #gives "2-3+4+5"

Perl
Not golfed as this is a code-challenge and not code-golf.
Aiming for complete solution; uses reverse polish notation.
Enjoy cryptic variable names and weird coding style ;)

#!perl -l
use strict;
use warnings;
use Math'Combinatorics;
use Math'RPN;

my @do=qw(add sub mul div mod pow);
my @uo=qw(sqrt sin cos tan log exp);

sub u(@){my%h;$h{"@$_"}=$_ for@_;values%h}

sub ms ($$$) {
    my($c,$d,$f)=@_; my @r;
    my $o = new Math'Combinatorics count => $c, data => $d, frequency => $f;
    while (my @x = $o->next_multiset) {push @r, [@x]}
    @r;
}

my $r = shift;
my $a = ~~@ARGV;

my @p = u permute @ARGV;
my @d = ms $a-1, \@do, [(~~@do) x @do];
my @u = ms $a, \@uo, [(~~@uo)x@uo];
my @t;

push @t, [unpack "(A)$a", sprintf "%0${a}b", $_] for 0..2**$a-1;

my @pu = ();

for my $pp (@p) {
    for my $uoo (@u) {
        for my $tt (@t) {
            my @opu = ();
            for my $g (0..$a-1) {
                push @opu, $pp->[$g];
                push @opu, $uoo->[$g] if $tt->[$g];
            }
            push @pu, \@opu;
        }
    }
}

@pu = u @pu;

for my $ppu (@pu) {
    for my $doo (@d) {
        my @e = (@$ppu,@$doo); my $z;
        eval {$z=rpn(@e)};
        $z = $r-1 if $@;
        print "@e = $z" if $z==$r;
    }
}

usage example:

> perl ./mc.pl 14 3 4 4
4 sqrt 3 4 add mul = 14
4 sqrt 4 3 add mul = 14
4 exp 3 exp 4 exp mod mod = 14
4 exp 3 exp 4 sqrt mul mod = 14


text:
Solve the 8 Puzzle
The 8 Puzzle is the smaller variant of the 15Puzzle (or the Sliding puzzle).
You have a 3x3 grid which is filled with numbers from 0-8 (0 denotes the blank tile) arranged in a random order.
Your task is to input a 3x3 grid and show the shortest solution (minimum moves) to get to the goal state. Display each boardstate including the first state in the output.
There may be multiple optimal solutions, you just need to print one.
Input: (small example)
1 2 0
4 5 3
7 8 6

Output:
2 <- denotes minimum number of moves required
1 2 0
4 5 3
7 8 6

1 2 3
4 5 0
7 8 6

1 2 3
4 5 6
7 8 0 <- goal state

If the puzzle can't be solved, print just -1 (denoting unsolvable)
Edit: Time limit : < 30seconds.

For those not familiar with the npuzzle, please read the link provided...

in your question , shouldn't grid which is filled with numbers from 0-9 be grid which is filled with numbers from 0-8 ?

@Clyde, Oops! :) Fixed.

Pretty sure it's always possible to solve, right?

@MagicOctopusUrn If you arrived at the initial state from the Goal state using the sliding rules, it's always solvable. If you arbitrarily put in tiles then there are states that cannot be solved. Google for Solvability for n puzzle

@st0le Yeah, you're right. I remember now. I was using my old slide toy as a reference and that does make sense.

Python, 418 characters
The code exhaustively enumerates all positions and makes maps of their depth (D), and a position one closer to solved (E).  Then it looks up the goal state to get the output.
D={(1,2,3,4,5,6,7,8,0):0}
E=D.copy()
def Z(a,d):
 b=list(a);b[i],b[i+d]=b[i+d],0;b=tuple(b)
 if b not in E:E[b]=a;D[b]=D[a]+1
for x in' '*32:
 for a in E.copy():
  i=list(a).index(0)
  if i>2:Z(a,-3)
  if i%3:Z(a,-1)
  if i%3<2:Z(a,1)
  if i<6:Z(a,3)
g=[]
for x in' '*3:g+=map(int,raw_input().split())
g=tuple(g)
if g in E:
 print D[g]
 while g:
  for i in(0,3,6):print'%d %d %d'%g[i:i+3]
  g=E[g];print
else:print -1

like the ' '*3 trick.

source: Stack Exchange

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

sort: votes


text:
Make a number palindrome
Write a function that takes a number as an argument and makes it a palindrome by appending minimum number of digits. The number will be at max of 100 digits.
Sample Inputs
12
122
232
2323
1012121
Sample Outputs
121
1221
232
23232
101212101

http://golf.shinh.org/p.rb?palindromize for reference lengths

Can the sample inputs and outputs include an example where the correct answer is an even number of digits, just to make sure that submitters cover that case?  It would seem to me that some algorithms might fail if the halfway point is between digits instead of on a digit.

@Computronium Done.

J, 50, 32 26 characters!
f=:{.@(,"1(-:|.)\.#|.@}:\)

eg
f '12'
121
f '232'
232
f '2323'
23232
f '1012121'
101212101

How it works (by example)
y =: '1012121'

[\.y   NB. Sub lists of y
1012121
012121
12121
2121
121
21
1

|.\. y  NB> Reverses of sub lists of y
1212101
121210
12121
1212
121
12
1

([\. y) -:"1 (|. \. y) NB. Which of them are equal? (those are palindromes)
                       NB. ( -:"1 ) checks equality item by item
0 0 1 0 1 0 1

(-:  |.)\. y NB. Shortcut of the above
0 0 1 0 1 0 1

(0 0 1 0 1 0 1) # }:\y NB. Choose (#) the palindrome prefixes (\)
10
1012
101212

y, |.'10'   NB. Reverse and append the first prefix.
101212101

Perl, 32 chars
s/((.)(?1)\2|.?)$/$&.reverse$`/e

Needs Perl 5.10 or later for regex features, but no special command-line switch.
Sample use:
$ perl -pe 's/((.)(?1)\2|.?)$/$&.reverse$`/e' << EOT
> 12
> 232
> 2323
> 1012121
> EOT
121
232
23232
101212101

Uses Perl 5.10's recursive regex extensions to match the longest trailing palindrome as such:
m/
    (      # paren 1 - a palindrome is either:
      (.)  # paren 2 - a character
      (?1) # a palindrome as defined in paren 1
      \2   # the same character as in paren 2
    |        # or:
      .?   # a 0- or 1-character string
    )
    $      # at end of string
/x

It then replaces it with itself ($&) and appends whatever the string started with ($`), reversed.

Brachylog 2, 8 bytes, language postdates challenge
ẹ;AcB↔Bc

Try it online! The question asks for a function, so I provided one; the TIO link takes an argument that runs a function like a full program.
Explanation
ẹ;AcB↔Bc
ẹ          Split {the input} into digits
 ;Ac       Append {the shortest possible} list
    B↔B    to produce a palindrome
       c   then concatenate the resulting list of digits back into a number

Python, 88 chars
def f(x):
 x,y=list(str(x)),[]
 while x!=x[::-1]:y+=x.pop(0)
 return''.join(y+x+y[::-1])

nice with the pop. pity you can't pop from str

Python (101 96)
edit: Shortened based on @gnibbler's solution
def p(n):s=str(n);r=s[::-1];l=len(s);return[int(s+r[l-i:])for i in range(l)if s[i:]==r[:l-i]][0]

Original:
def p(n):
 s=str(n);r=s[::-1];l=len(s)
 for i in range(l):
  if s[i:]==r[:l-i]:return int(s+r[l-i:])

You can replace s=str(n) with s=n.

@fR0DDY, that wont work if n is large enough to need a long

@fR0DDY, Python doesn't care so much about ints vs longs anymore.  int(2346765434567875432456) returns 2346765434567875432456 on v2.6.5. I don't see how s=n helps; I need s to be a string so I can subscript to get digit ranges.  What's the reasoning there?

@Hoa, I think fR0DDY had backticks there but they don't show up in the comments

@Hoa It was s=[tick]n[tick].

Ah, that makes more sense.

Python - 98 chars
Based on Hoa's answer :)
def p(n):s=str(n);r=s[::-1];l=len(s);return next(int(s+r[l-i:])for i in range(l)if s[i:]==r[:l-i])

Not sure I'm using this right, but: "NameError: global name 'next' is not defined"

@J B, Ah, you need python2.6 for that :) otherwise it can be written return(...).next() usually that would cost an extra char, but I get to drop the space after return. Hoa has improved on it again anyhow by using a LC instead of a GE

Golfscript - 32 chars
{`:s-1%:r,,{s<r+..-1%=*}%{}?~}:f

Haskell, 85
Using the same algorithm as most everyone else:
import List
r=reverse
f s=s++(r.snd.head.filter g.zip(tails s)$inits s)
g(s,_)=s==r s

Examples from problem description:
*Main> map (f.show) [12,232,2323,1012121]
["121","232","23232","101212101"]

Ruby 1.9, 72 chars
f=->x{x=x.to_s.split'';99.times{|i|x.insert~i,x[i]if x!=x.reverse};x*''}

x*'' instead of x.join saves 2 chars.

nice one @steenslag, thanks for teaching, I am ruby newbie :-)

JavaScript (ES6), 145 126 chars
 p=a=>{S=x=>x.split``.reverse();for(s=String(a),i=0;i<s.length;i++)if(x=s+S(s.substring(0,i)).join``,x==S(x).join``)return x}

Commented:
function palindrome(n){
  s = String(n);
  for(i=0;i<s.length;i++)
  {
    x=s+s.substring(0,i).split("").reverse().join("") //take first n characters, reverse and append to the end
    if(x==x.split("").reverse().join("")) //is the number a palindrome?
      return x;
  }
}

Ruby, 70 bytes
f=->x{x=x.to_s.chars;99.times{|i|x.insert~i,x[i]if x!=x.reverse};x*''}

Try it online!
Based on YOU'S answer, with chars instead of .split'' to gain 2 chars.
And i'm sure there's way to squeeze just a bit more ><

05AB1E, 27 7 bytes
-18 bytes thanks to @Razetime.
ηí«.ΔÂQ

Try it online!
ηí«.ΔÂQ  # full program
   .Δ    # find first element in...
  «      # joined...
 í       # reversed...
η        # prefixes of...
         # implicit input...
   .Δ    # where...
      Q  # it's equal to...
     Â   # itself reversed
         # implicit output

Isn't this much simpler and shorter?

Yes, thank you! I've made a couple optimizations by replacing DR with Â and removing the implicit }.

Java, 174 bytes
x->{Function<String,String>r=t->new StringBuilder(t).reverse().toString();String y=r.apply(x),z=x;int m=x.length();while(!z.equals(r.apply(z)))z=x+y.substring(--m);return z;}

Ungolfed:
x -> {
        Function<String, String> r = t -> new StringBuilder(t).reverse().toString();
        String y = r.apply(x), z=x;
        int m = x.length();
        while (!z.equals(r.apply(z))) z = x+y.substring(--m);
        return z;
    }

I have a feeling it could be a lot tighter but it's not immediately obvious to me how.  The Function eats up a lot of space but I needed it in two places.
This works for any string, not just numbers, and it can be any length.

PHP, 64 Bytes
for(;strrev($p=$argn.strrev(substr($argn,0,$i++)))!=$p;);echo$p;

Try it online!

Jelly, 11 bytes
D;ⱮUƤ$ŒḂƇḢḌ

Try it online!
How it works
D;ⱮUƤ$ŒḂƇḢḌ - Main link. Takes n on the left
D           - Digits of n
     $      - To the digits of n:
    Ƥ       -   Yield the prefixes
   U        -   Reverse
 ;Ɱ         -   Concatenate with the digits
      ŒḂƇ   - Keep the palindromes
         Ḣ  - Take the first (i.e. the shortest)
          Ḍ - Convert from digits

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

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

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


text:
Percentage of work days in a month
Given a year and a month, find out the percentage of work days in said
month. Work days are Monday through Friday with no regard to holidays or
other special things. The Gregorian calendar is used.
Input
A year and month in ISO 8601 format (YYYY-MM). The year always has four
digits, the month always has two digits. The given year will not be before
1582.
Output
Output is the percentage of work days (according to above definition) in
the given month, rounded to a whole number. No percent sign or fractional
digits follow.
Sample 1
Input                Output

2010-05              68

Sample 2
Input                Output

2010-06              73

Sample 3
Input                Output

1920-10              68

Sample 4
Input                Output

2817-12              68

A week has passed, an answer has been accepted. For the curious, the sizes of the submissions we got in our contest:

129 – Z shell
  174 – VB.NET
  222 – C
  233 – C
  300 – C

As well as our own (unranked) solutions:

  75 – PowerShell
    93 – Ruby
  112 – Bourne shell

I'm a graduate student, so... echo 100

Even grad students cannot escape the fundamental definitions in their line of work. And I defined work days differently ;-)

64-bit Perl, 67 68
Perl 5.10 or later, run with perl -E 'code here' or perl -M5.010 filename
map{$d++,/^S/||$w++if$_=`date -d@ARGV-$_`}1..31;say int.5+100*$w/$d

Concessions to code size:

locale-sensitive: it counts as work days the days whose date output don't start with a capital S.  Run under LC_ALL=C if in doubt.
output is pure and well-formatted, but there's "garbage" on stderr on months shorter than 31.  2> /dev/null if upset.
for some reason, my version of date considers 2817-12 an invalid month.  Who knew, GNU new apocalypse is due! Requires a 64 bit build of date for dates after 2038.  (Thanks Joey)

Apparently it was abolished by "Siphous Hemes" during his rule. ref "A new history of the Holy Bible"

Is every year after 2038 broken? Then switching t a 64-bit build might help due to some braindead-ness with date handling ;-)

@Joey that's exactly it. Thanks for the tip!

JB: Was just a guess and I actually didn't expect anything beyond C to still use solely 32-bit integers that count seconds since a weird epoch. Though, to be honest, I put the requirement about dates > 2038 in there for exactly this purpose ;-)

PHP - 135
I made it in PHP because I had a similar problem to treat a few days ago.
<?php $a=array(2,3,3,3,2,1,1);$t=strtotime($argv[1]);$m=date(t,$t);echo round((20+min($m-28,$a[date(w,strtotime('28day',$t))]))/$m*100)

(Somewhat) More legibly, and without notices about constants being used as strings:
<?php
date_default_timezone_set('America/New_York');
$additionalDays = array(2, 3, 3, 3, 2, 1, 1);
$timestamp = strtotime($argv[1]);
$daysInMonth = date('t', $timestamp);
$limit = $daysInMonth - 28;
$twentyNinthDayIndex = date('w', strtotime("+28 days", $timestamp));
$add = $additionalDays[$twentyNinthDayIndex];
$numberOfWorkDays = 20 + min($limit, $add);
echo round($numberOfWorkDays / $daysInMonth * 100);
?>

This is made possible by a very simple algorithm to compute the number of work days in a month: check for the weekdayness of the 29th, 30th and 31st (if those dates exist), and add 20.

Great algorithm, poor golfing. Using contemporary PHP 5.3.5 and -R, this approach can be golfed down to 86 bytes (63.7%): $a="2333211";echo.5+min(-8+$m=date(t,$t=strtotime($argn)),20+$a[date(w,$t)])/$m*100|0;
See the golfing steps.

80 bytes: <?=.5+min(-8+$m=date(t,$t=strtotime($argn)),20+(5886>>date(w,$t)*2&3))/$m*100|0;

Swift, 346 bytes
Short version:
func f(_ s:String)->Int{let c=Calendar.current,m=Int(s.suffix(2))!,y=Int(s.prefix(4))!,mR=c.range(of:.day,in:.month,for:DateComponents(calendar:c,year:y,month:m).date!)!,n=mR.reduce(0){p,d in let d=c.date(from: DateComponents(year:y,month:m,day:d))!,w=c.component(.weekday,from:d);return(2...6).contains(w) ?p+1:p};return (n*1000/mR.count+5)/10}

Slightly longer version:
func f2(_ s: String) -> Int {
    let c=Calendar.current
    let m=Int(s.suffix(2))!
    let y=Int(s.prefix(4))!
    let mR=c.range(of:.day,in:.month,for:DateComponents(calendar:c,year:y,month:m).date!)!
    let n=mR.reduce(0){p,d in
        let d=c.date(from: DateComponents(year:y,month:m,day:d))!
        let w=c.component(.weekday,from:d)
        return(2...6).contains(w) ?p+1:p
    }
    return (n*1000/mR.count+5)/10
}

That's not the most golf-friendly of languages, is it? ;-)

@Joey yes indeed - sometimes it feels like hoping one does not come in last place :-)

Python 152 Characters
from calendar import*
y,m=map(int,raw_input().split('-'))
c=r=monthrange(y,m)[1]
for d in range(1,r+1):
 if weekday(y,m,d)>4:c-=1
print '%.f'%(c*100./r)

Windows PowerShell, 80
$x=$args;1..31|%{"$x-$_"|date -u %u -ea 0}|%{$a++
$b+=!!($_%6)}
[int]($b*100/$a)

Are you sure [int] really rounds? I'd tend to believe it floors.

@zneak: PowerShell is not C or a C-derived language. It uses the default rounding mode of .NET which is »round to nearest even integer«. Just try it out: Both [int]1.5 and [int]2.5 yield 2. This exact behaviour often causes problems in tasks where floored division is necessary (which then requires an extra [Math]::Floor()), but in this case it doesn't hurt and »round to even« only applies to numbers that end in .5 which cannot happen here.

If you're sure then I believe you. I just expected it to work like C# instead, and I don't have any Windows machine on which to test at home.

@zneak: No, definitely doesn't work like in C#. Something like [int] in PowerShell is usually more a conversion than a cast :-). Things like [int[]][char[]]'abc' also work which you can't get to work in many other languages.

Necrobump but $input -> $args saves a byte.

@Veskah Just curious... did you get here the same way I did? (PPCG Graduation Userscript Challenges of the Day -> Has my milk expired -> related challenges -> here)

@Veskah: Usually on my challenges I'd get in the same arguments with you as with mazzy, but in this case I actually left it unspecified so it's an option here, indeed :-)

@Veskah: Apparently parameter validation has become more strict in the meantime and we need a bit more code to remove the error messages, sadly.

Bummer, guess I should've let sleeping dogs lie.

D: 186 Characters
auto f(S)(S s){auto d=Date.fromISOExtendedString(s~"-28"),e=d.endOfMonth;int n=20;while(1){d+=dur!"days"(1);if(d>e)break;int w=d.dayOfWeek;if(w>0&&w<6)++n;}return rndtol(n*100.0/e.day);}

More Legibly:
auto f(S)(S s)
{
    auto d = Date.fromISOExtendedString(s ~ "-28"), e = d.endOfMonth;
    int n = 20;

    while(1)
    {
        d += dur!"days"(1);

        if(d > e)
            break;

        int w = d.dayOfWeek;

        if(w > 0 && w < 6)
            ++n;
    }

    return rndtol(n * 100.0 / e.day);
}

Python - 142
from calendar import*
y,m=map(int,raw_input().split('-'))
f,r=monthrange(y,m)
print'%.f'%((r-sum(weekday(y,m,d+1)>4for d in range(r)))*100./r)

Thanks to fR0DDY for the calendar bit.

Ruby, 124 119 111
require 'date'
e=Date.civil *$*[0].split(?-).map(&:to_i),-1
p ((e+1<<1..e).count{|d|d.cwday<6}*1e2/e.day).round

Requires Ruby 1.9 due to splatting the year and month before the -1 "day" argument and ?- for "-". For Ruby 1.8, we must add 2 characters:
require 'date'
e=Date.civil *$*[0].split('-').map(&:to_i)<<-1
p ((e+1<<1..e).count{|d|d.cwday<6}*1e2/e.day).round

Edit: Shave five characters based on @Dogbert's help.
Edit: Shave eight more characters based on @steenslag's help.

Why are you assigning Date to D?

@Dogbert Whoops! Holdover from a time when I had two Date.civils; thanks!

'-' could be written as ?- in Ruby 1.9

@Dogbert Nice. I'll throw that in, too. I feel there must be a shorter way to pick the week days, but I haven't found it yet.

e+1<<1 is three shorter than e-e.day+1

(d.wday+1)%7>1 can be replaced by d.cwday<6

@steenslag Those are both great, thank you. I didn't know about Date#<< previously; very cool.

Bash + coreutils, 82 bytes
f()(cal -NMd$1|sed -n "s/^$2.//p"|wc -w)
dc -e`f $1 "[^S ]"`d`f $1 S`+r200*r/1+2/p

C#, 158 bytes
s=>{var d=DateTime.Parse(s);int i=0,t=DateTime.DaysInMonth(d.Year,d.Month),w=0;while(i<t)w-=-(int)d.AddDays(i++).DayOfWeek%6>>31;return Math.Round(1e2*w/t);};

Anonymous method which returns the required percentage.
Full program with ungolfed, commented method and test cases:
using System;

class WorkingDayPercentage
{
    static void Main()
    {
        Func <string, double> f =
        s =>
        {
            var d = DateTime.Parse(s);                      // extracts a DateTime object from the supplied string
            int i = 0,                                      // index variable
                t = DateTime.DaysInMonth(d.Year, d.Month),  // number of total number of days in the specified month
                w = 0;                                      // number of working days in the month

            while (i < t)                                   // iterates through the days of the month
                w -= -(int)d.AddDays(i++).DayOfWeek%6 >> 31;// d.AddDays(i) is the current day
                                                            // i++ increments the index variable to go to the next day
                                                            // .DayOfWeek is an enum which hold the weekdays
                                                            // (int)..DayOfWeek gets the days's index in the enum
                                                            // note that 6 is Saturday, 0 is Sunday, 1 is Monday etc.
                                                            // (int)DayOfWeek % 6 converts weekend days to 0
                                                            // while working days stay strictly positive
                                                            // - changes the sign of the positive numbers
                                                            // >> 31 extracts the signum
                                                            // which is -1 for negative numbers (working days)
                                                            // weekend days remain 0
                                                            // w -= substracts the negative numbers
                                                            // equivalent to adding their modulus

            return Math.Round(1e2 * w / t);                 // the Math.round function requires a double or a decimal
                                                            // working days and total number of days are integers
                                                            // also, a percentage must be returned
                                                            // multiplying with 100.0 converts the expression to a double
                                                            // however, 1e2 is used to shorten the code
        };

        // test cases:
        Console.WriteLine(f("2010-05")); // 68
        Console.WriteLine(f("2010-06")); // 73
        Console.WriteLine(f("1920-10")); // 68
        Console.WriteLine(f("2817-12")); // 68
    }
}

Alternative function, which adds negative values to the number of working days, changing the sign in the return with no extra byte cost:
s=>{var d=DateTime.Parse(s);int i=0,t=DateTime.DaysInMonth(d.Year,d.Month),w=0;while(i<t)w+=-(int)d.AddDays(i++).DayOfWeek%6>>31;return-Math.Round(1e2*w/t);};

PHP 5.2, 88 bytes
Although I already golfed zneak´s solution down to 85 bytes (I just found one more), here´s my own:
I doubt that I can squeeze another three bytes out here.
$a=_4444444255555236666304777411;echo$a[date(t,$t=strtotime($argn))%28*7+date(N,$t)]+67;

takes input from STDIN: Run with echo <yyyy>-<mm> | php -nR '<code>'.
The string $a maps days per month (date(t)) and week day of the first day of the month (date(N): Monday=1, Sunday=7) to the percentage of work days-67; strtotime converts the input to a UNIX timestamp; the rest of the code does the hashing.
+1 byte for older PHP 5: Replace N with w and $a=_...; with $a="...".
another +3 bytes for PHP 4: insert .-1 after $argn.
-5 bytes for PHP 5.5 or later (postdates the challenge):
Remove everything before echo and replace $a with "4444444255555236666304777411".

Well ... one byte: %7 instead of %28.

APL (Dyalog Unicode), 55 bytesSBCS
Anonymous tacit prefix function.
⌊.5+100×2÷/(2 5)2{≢⍎⍕↓⍺↓¯2⌽' ',cal⍎' '@5⊢⍵⊣⎕CY'dfns'}¨⊂

⊂ enclose date to treat it as a whole
(2 5)2{…}¨ apply the following function on that, but with the left arguments [2,5] and 2:
 ⎕CY'dfns' copy the "dfns" library
 ⍵⊣ discard the report in favour of the date
 ' '@5⊢ replace the 5th character (-) with a space
 ⍎ execute that to get two-element list
 cal call the calendar function on that
 ' ', prepend a column of spaces to that
 ¯2⌽ rotate the last two columns (Saturday) to the front
 ⍺↓ drop left-argument number of rows (2, headers) and columns (if specified; 5=Sat+Sun)
 ↓ split matrix into list of lines
 ⍕ format (flattens with insertion of double-spacing)
 ⍎ execute (turns remaining day numbers into a flat numeric list)
 ≢ tally those
2÷/ divide each pair (there's only one)
100× multiply by a hundred
.5+ add a half
⌊ floor
Try it online!

Go, 243 bytes
import(."time";."math")
func f(s string)int{t,_:=Parse("2006-01",s)
D,o:=Hour*24,0.0
y,m,_:=t.Date()
d:=Date(y,m+1,0,0,0,0,0,UTC).Add(D).Sub(t).Hours()/24
for;t.Month()==m;t=t.Add(D){if w:=t.Weekday();0<w&&w<6{o++}}
return int(Round(100*o/d))}

Attempt This Online!
Loops through the days of the month and checks each for being a weekday (between 0=Sunday and 6=Saturday).

Rebol - 118 113
w: b: 0 o: d: do join input"-01"while[d/2 = o/2][if d/7 < 6[++ w]++ b d: o + b]print to-integer round w / b * 100

Ungolfed:
w: b: 0
o: d: do join input "-01"
while [d/2 = o/2] [
    if d/7 < 6 [++ w]
    ++ b
    d: o + b
]
print to-integer round w / b * 100

Oracle SQL, 110 bytes
select round(100*sum(1-trunc(to_char(x+level-1,'d')/6))/sum(1))from dual,t connect by level<=add_months(x,1)-x

It works with an assumption that input data is stored in a table in using date data type, e.g.
with t as (select to_date('2010-06','yyyy-mm') x from dual)

Perl 6, 78 bytes
{round 100*@_.grep(6>*.day-of-week)/@_}o{Date.new("$_-01")...^*.month-*.month}

Try it online!

Japt, 36 34 bytes
HÆÐU+XnÃf@¤¤ÅÉ¶XÎÃme
èÈ©n6Ã*L/UÊ r

Try it
Not pretty at all! Needs more work.
34 32 bytes
2 bytes can be saved by always rounding down as the challenge doesn't specify that we must round to the nearest integer:
HÆÐU+XnÃf@¤¤ÅÉ¶XÎÃme
èÈ©n6ÃzUÊ/L

Try it

Bash + ncal, 75 70 bytes
m=`ncal ${1#*-} ${1%-*}`
set $m
wc -w<<<${m%%Sa*}|dc -e ?7-A0*$#\ 9-/p

We start by using ncal to print a calendar:
    May 2010
Mo     3 10 17 24 31
Tu     4 11 18 25
We     5 12 19 26
Th     6 13 20 27
Fr     7 14 21 28
Sa  1  8 15 22 29
Su  2  9 16 23 30

The total number of days in the month is the word-count of this output, minus 9 (the seven weekday names and the month and year of the header).  This word-count is obtained using set and $#.
The number of work days is a similar calculation, but we first eliminate everything from Sa onwards (we can't just match S because the month may be Sep), and subtract only 7 surplus words.  We count this using wc.
We then use dc to compute a percentage (using A0 as short form of 100).
Note that this program rounds fractional percentages downwards - the question's examples appear to use a different choice for the rounding, but it didn't impose a specific direction.  Rounding to nearest would cost an additional 7 bytes by executing $#\ 2/+ before we divide by the total: ?7-A0*$#\ 2/+$#\ 9-/p.

GNU date+bc, 56 bytes
Abstract
This Answer demonstrates that the following 56-byte shell pipeline
calculates the percentage of work days in a given month, rounded to
the nearest whole percent:
date -d$1-1month-4week +'70+%d-3*(%w+1<%d)-3*(%u<%d)'|bc

Analysis
There are 28 possible monthly calendars, that can be identified
according to the last day/date of the month:

Mon
Tue
Wed
Thu
Fri
Sat
Sun

28th
20/28
20/28
20/28
20/28
20/28
20/28
20/28

29th
21/29
21/29
21/29
21/29
21/29
20/29
20/29

30th
21/30
22/30
22/30
22/30
22/30
21/30
20/30

31st
21/31
22/31
23/31
23/31
23/31
22/31
21/31

There are nine distinct fractions here, that can be converted to
percentages:

20
21
22
23

28
71

29
69
72

30
67
70
73

31

68
71
74

Substituting these gives our conversion table:

Mon
Tue
Wed
Thu
Fri
Sat
Sun

28th
71
71
71
71
71
71
71

29th
72
72
72
72
72
69
69

30th
70
73
73
73
73
70
67

31st
68
71
74
74
74
71
68

The pattern becomes more clearly evident when we split this into a
basic value for a month containing four weekends, less an amount for a
fifth Saturday and for a fifth Sunday:

Basic
Thu
Fri
Sat
Sun
Mon
Tue
Wed

28th
71
.       .
.       .
.       .
.       .
.       .
.       .
.       .

29th
72
.       .
.       .
.      -3
-3      .
.       .
.       .
.       .

30th
73
.       .
.       .
.      -3
-3    -3
-3      .
.       .
.       .

31st
74
.       .
.       .
.      -3
-3    -3
-3    -3
-3      .
.       .

The basic value is clearly 71 plus one for each day more than 28 days.
And we must then subtract 3 if the last day is in a range beginning
Saturday and having length equal to those excess days, less three for
a similar range beginning Sunday.
Implementation
Firstly, we append a day number to turn year and month into a full
date: $1-01.
Rather than finding the last day of the month, we select a date
nearer the start of the month, by subtracting 28 days from the start
of the following month.  This gives us a day-of-week that's one later
than used in the analysis section:
date -d'$1-01 +1month-4week'

Using this date, we then format a calculation for bc to execute and
print.  The basic percentage is simple; it's just 70 more than the day
number we landed on: 70+%d.
The adjustments for extra weekend days are then computed using a pair
of inequalities, taking advantage of the fact that there are two
representations for day-of-week, with Sunday represented as 0 or
as 7.  We subtract 3 points from the basic percentage for each of
those inequalities.
Demo
We can reproduce the results from the examples in the question:

Command
Result

./1158 2010-05
68

./1158 2010-06
73

./1158 1920-10
68

./1158 2817-12
68

And we can show that we get the correct results for all 28 shapes of
month
shown in the first table:
for i in $(printf '%s\n' 20{{00..03}-{03..12},{00..24}-02}-01+month-1day |
           date -f- +'%Y-%m%t%d %u %a' | sort -k2,3 -u | cut -f1)
do ./1158 $i
done | rs 0 7

71  71  71  71  71  71  71
72  72  72  72  72  69  69
70  73  73  73  73  70  67
68  71  74  74  74  71  68

Scala, 152 bytes
A port of @adrianmp's C# answer in Scala.

Golfed version. Try it online!
s=>{val d=java.time.YearMonth.parse(s);val t=d.lengthOfMonth;var w=0;for(i<-0 to t-1)if(d.atDay(i+1).getDayOfWeek.getValue<6)w+=1;Math.round(100.0*w/t)}

Ungolfed version. Try it online!
import java.time._
import java.time.temporal._

object Main {
  def main(args: Array[String]): Unit = {
    val f: String => Double = s => {
      val d = YearMonth.parse(s)
      val totalDays = d.lengthOfMonth
      var workingDays = 0

      for (i <- 0 until totalDays) {
        val dayOfWeek = d.atDay(i + 1).getDayOfWeek
        if (dayOfWeek.getValue >= DayOfWeek.MONDAY.getValue && dayOfWeek.getValue <= DayOfWeek.FRIDAY.getValue) {
          workingDays += 1
        }
      }

      Math.round(100.0 * workingDays / totalDays)
    }

    // test cases:
    println(f("2010-05")) // 68
    println(f("2010-06")) // 73
    println(f("1920-10")) // 68
    println(f("2817-12")) // 68
  }
}

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


text:
Numbers, Sums, Products
Given a 20×20 grid of non-negative integers, find a 3×3 sub-grid where the
product of the sums of the individual lines hits the maximum. Spoken in
formulas:
Given the 3×3 sub-grid
$$\mathfrak{U} = \left(\begin{matrix}
x_{11} & x_{12} & x_{13} \\
x_{21} & x_{22} & x_{23} \\
x_{31} & x_{32} & x_{33}
\end{matrix}\right)$$
the function to maximize is
$$\begin{align}
f(\mathfrak{U}) & = \left(\begin{matrix}
\underbrace{(x_{11} + x_{12} + x_{13})}_\cdot \\
\overbrace{\underbrace{(x_{21} + x_{22} + x_{23})}}_\cdot \\
\overbrace{(x_{31} + x_{32} + x_{33})} \\
\end{matrix}\right) \\
& = (x_{11} + x_{12} + x_{13}) \cdot (x_{21} + x_{22} + x_{23}) \cdot (x_{31} + x_{32} + x_{33})
\end{align}$$
Per line the sum is calculated and the individual sums are then
multiplied.
An example (only 5×5):
$$\begin{matrix}
 40 &  30 &               42 &               22 &               74 \\
294 &  97 & \color{red} {35} & \color{red}{272} & \color{red}{167} \\
 52 &   8 & \color{red}{163} & \color{red}{270} & \color{red}{242} \\
247 & 130 & \color{red}{216} & \color{red} {68} & \color{red}{266} \\
283 & 245 &              164 &               53 &              148 \\
\end{matrix}$$
The part highlighted in red is the part where the value of the function
\$f(\mathfrak{U})\$ is largest for the entire grid:

\$(35 + 272 + 167) ⋅ (163 + 270 + 242) ⋅ (216 + 68 + 266) = 175972500\$

Input
Input is given on standard input and consists of 20 lines, each containing
20 numbers, separated by a space character (U+0020). The numbers are small
enough that a 32-bit signed integer is sufficient to compute the result.
You may assume input to be given redirected from a file.
Output
Output is the result of the function \$f(\mathfrak{U})\$ for the 3×3 sub-grid that
gives the largest result. In above example this would have been
\$175972500\$.
Sample input 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 5 5 5 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 5 5 5 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 5 5 5 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Sample output 1
3375

Sample input 2
40 30 42 222 74 265 93 209 115 274 139 177 7 274 12 15 103 36 236 91
294 97 35 272 167 126 18 262 292 48 8 296 85 93 245 4 4 240 276 153
52 8 163 270 242 224 142 72 99 240 199 26 224 198 96 242 295 70 56 247
247 130 216 68 266 142 93 214 30 8 12 163 59 84 40 287 233 65 30 242
283 245 164 53 148 282 73 186 296 3 9 233 184 30 205 221 92 96 5 101
132 228 43 91 228 37 266 140 159 109 10 230 40 114 264 3 266 164 219 283
70 207 218 28 299 78 279 30 179 118 196 138 61 229 110 55 203 73 124 112
16 232 28 187 292 78 194 70 65 203 255 227 176 21 32 225 11 15 92 151
58 237 261 41 213 171 170 111 4 209 99 194 40 108 267 137 179 31 35 221
184 209 264 275 163 268 261 40 198 185 45 188 280 273 54 79 270 286 273 121
208 83 66 156 104 62 188 68 53 194 46 279 280 170 266 148 272 285 178 245
210 130 213 118 165 210 213 66 54 189 166 193 57 213 14 101 143 109 172 101
80 193 287 4 140 65 208 111 8 206 107 285 109 29 211 78 170 247 290 193
148 123 15 164 28 153 222 67 156 165 6 163 114 77 165 17 143 209 278 100
3 102 58 148 82 181 84 29 2 236 231 195 118 278 252 257 179 123 276 287
143 141 254 142 200 243 171 32 164 195 235 260 269 191 190 46 65 166 82 146
69 194 65 220 234 110 45 135 125 208 138 20 233 291 256 162 148 216 247 138
10 53 164 107 2 270 226 227 88 206 193 13 41 130 218 249 76 35 207 91
199 36 207 256 58 215 28 277 234 29 198 148 219 244 136 16 30 258 219 264
183 118 48 218 15 125 279 103 73 8 86 113 9 157 239 273 146 208 50 86

Sample output 2
328536000

Sample input 3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Sample output 3
185193

Sample input 4
242 248 292 60 9 45 94 97 294 202 219 118 115 243 207 81 288 289 241 232
236 225 205 227 242 85 139 63 5 162 170 121 208 133 22 235 125 288 209 270
31 182 108 170 88 268 297 66 249 158 285 157 267 117 150 18 44 66 117 223
205 32 93 132 33 99 209 282 222 272 255 1 80 270 202 54 117 35 139 273
87 74 113 146 177 14 154 92 282 4 192 60 171 286 66 299 89 276 138 289
60 16 143 277 202 284 77 296 215 96 200 10 226 143 136 131 218 246 254 20
244 118 299 218 81 195 129 93 205 202 264 141 196 150 214 72 231 136 243 192
236 157 176 187 104 182 134 29 151 234 81 143 22 119 45 241 17 225 197 7
156 284 92 13 131 60 113 77 228 65 200 83 3 63 83 88 241 113 115 198
62 101 242 270 121 122 119 78 105 273 55 7 239 236 37 252 66 164 56 44
70 57 100 87 34 298 140 259 36 257 1 204 110 299 245 56 43 121 192 10
240 36 272 255 10 194 143 66 27 131 22 78 57 71 128 5 1 155 236 122
281 160 42 147 272 151 196 240 291 280 209 245 271 46 103 35 85 145 78 140
155 74 232 205 235 223 147 39 171 240 56 187 184 70 28 81 293 125 283 159
297 203 75 46 221 77 106 12 268 94 220 156 78 97 266 208 228 137 212 49
4 157 69 51 225 23 61 202 19 23 41 260 161 218 142 251 299 187 283 158
118 136 71 77 21 199 110 87 103 120 153 157 213 234 155 141 135 24 120 199
16 204 292 245 54 260 294 159 254 15 209 41 154 54 231 167 87 291 31 26
212 274 99 199 170 184 47 227 64 2 117 275 67 84 143 214 143 125 24 61
205 250 133 88 210 112 4 160 3 287 54 143 293 94 287 42 105 94 76 169

Sample output 4
311042813

For the interested, the lengths of the submissions we got in our contest:

120 – AWK
124 – C
133 – Haskell
174 – C
270 – VB.NET

And our own (unranked) solutions:

  55 – Golfscript
118 – Ruby
192 – PowerShell

J, 38
":@(>./@,@(3*/\3+/\"1".;._2))&.stdin''

Sample use:
$ jconsole nsp.ijs <g1
3375
$ jconsole nsp.ijs <g2
328536000
$ jconsole nsp.ijs <g3
185193

Rough explanations:

".;._2 converts raw input to matrix, ": converts the result to raw output
3+/\"1 sums column-wise, 3 by 3
3*/\ multiplies row-wise, 3 by 3
, flattens the result
>./ extracts the maximum
&.stdin'' makes a filter out of it

cool__________!

Great  J golfing!

@S.Mark __________!

Python - 146 characters
g=[map(int,raw_input().split(' '))for i in' '*20]
r=range(18)
print max(reduce(int.__mul__,[sum(v[j:j+3])for v in g[i:i+3]])for j in r for i in r)

The argument to split is unnecessary, and can save you three bytes.
An even shorter way of reading input is g=eval('map(int,raw_input().split()),'*20), saving another four bytes for a total of 139.

Java, 299 Chars
    class M{public static void main(String[]a){java.util.Scanner s=new java.util.Scanner(System.in);int i,j,k,p,m,t=20,x[][]=new int[t][t];for(i=m=0;i<t*t;i++)x[i/t][i%t]=s.nextInt();for(i=0;i<18;i++)for(j=0;j<18;j++,m=p>m?p:m)for(p=1,k=i;k<i+3;k++)p*=x[k][j]+x[k][j+1]+x[k][j+2];System.out.print(m);}}

Am I doing something wrong? The given code weighs in at 318 bytes here. In any case, the class does not need to be public, you can pull the array declaration of x into the previous line with x[][]=new int[t][t]. You can use a one-dimensional array which simplifies access greatly. You can remove the import and just inline the java.util. twice which is 5 bytes shorter. You can inline e which saves 3 bytes. With all that I got it down to 290 bytes.

@Joey, sorry about that, was using Notepad++, mistakenly read Char Count (no spaces). Will do most of those changes. The code will prolly change a lot if i used a 1D array.

Well, it changes declaration to x[]=new int[t*t], initialization to x[i]=s.nextInt(); and the update of p to p*=x[t*k+j]+x[t*k+j+1]+x[t*k+j+2];. Nothing too magic, I think :-)

enum M{M;{code;}}, and you can probably merge the increment and loop conditionals.

With class M{static{java.util.Scanner s=... you come to 271. Improvement 10%. :) You get an errormessage after the output, but you may silently ignore it. :)

C#, 324 321 308 chars
using System;using System.Linq;class X{static void Main(){int m=0,v,x=0,y;Func<int[],int>f=t=>t[x]+t[x+1]+t[x+2];var a=Console.In.ReadToEnd().Trim().Split('\n').Select(l=>l.Split(' ').Select(int.Parse).ToArray()).ToList();for(;x<18;x++)for(y=0;y<18;m=m>v?m:v)v=f(a[y])*f(a[++y])*f(a[y+1]);Console.Write(m);}}

Readable:
using System;
using System.Linq;
class X
{
    static void Main()
    {
        int m = 0, v, x = 0, y;
        Func<int[], int> f = t => t[x] + t[x + 1] + t[x + 2];
        var a = Console.In.ReadToEnd().Trim().Split('\n').Select(l =>
            l.Split(' ').Select(int.Parse).ToArray()).ToList();
        for (; x < 18; x++)
            for (y = 0; y < 18; m = m > v ? m : v)
                v = f(a[y]) * f(a[++y]) * f(a[y + 1]);
        Console.Write(m);
    }
}

14 characters could be shaved off by removing both calls to .Trim() if you can guarantee that the input will only use \n (no \r) and there is no newline after the last row of numbers.
Edits

(333 → 324 chars) Realised I could add x, y to the declaration at the top instead of declaring each in the for statement; that I could change one of the ToArrays to ToList; that I could increment y inside the call to f and thus get rid of it in the for.
(324 → 321 chars) Move the assignment to m into the for statement, getting rid of a semicolon and two curlies.
(321 → 308 chars) Joey’s suggestions in the comments. Thanks!

I am tempted to -1 for using technology completely inappropriate for codegolfing... :)

The Trim() within the int.Parse call can indeed be dropped (it ignores trailing whitespace) (314). You can then also call Select with just int.Parse as argument; no need for a lambda there anymore (308). I think this could be made shorter by working on a 400-item 1D array instead of the list of arrays as you have it now, but I'm unable to adapt it right now ;-)

@Joey: Wow... you make me feel noob :) Thanks!

Python (202)

import sys;g=map(lambda l:map(int,l.split()),sys.stdin.readlines())
r=range(18)
for j in range(20):l=g[j];g[j]=[sum(l[i:i+3])for i in r]
g=[g[i][j]*g[i+1][j]*g[i+2][j]for i in r for j in r]
print max(g)

Edit: Fixed r to be range(18) instead of 17.

C 184 171 Characters
#define f(i,b)for(i=0;i<b;i++)
i,j,k,l,m,M,s,a[400];main(){f(i,400)scanf("%d",a+i);f(i,18)f(j,18){m=1;f(k,3){s=0;f(l,3)s+=a[(i+k)*20+j+l];m*=s;}M=m>M?m:M;}printf("%d",M);}

You could squeeze out a few more characters by using #define f(i,b)for(i=0;i<b;i++) and removing 0, from the invocations.

@Joey Oh Ya! I completely missed that. Thanks

Can you use #define f(i,b)for(i=b;--i;) instead?

Windows PowerShell, 116 117 124 152 170
$g=-split$input
(0..359|?{$_%20-le17}|%{$i=$_
(0..2|%{$g[($a=$i+20*$_)..($a+2)]-join'+'|iex})-join'*'|iex}|sort)[-1]

Fairly straightforward, actually.

Ruby, 106 characters
k=$<.read.split.map &:to_i;p (0..358).map{|a|a%20>17?0:(0..2).map{|i|k[20*i+a,3].inject:+}.inject(:*)}.max

Yet another straightforward solution.

Edit: Previous solution produced incorrect results for some edge cases.
Edit: (114 -> 106) Use a flat array, check index%20 to prevent overflows into the next row.

Ruby - 78 chars
g=*$<
p (0..324).map{|i|eval g[i/18,3].map{|r|eval r.split[i%18,3]*?+}*?*}.max

APL (Dyalog Unicode), 22 bytesSBCS
Complete program.
⌈/,{×/+/⍵}⌺3 3↑⍎20⍴'⎕'

Try it online!
20⍴'⎕' reshape the character ⎕ (which stands for evaluated input from stdin) to length 20
⍎ execute that (gives use 20 lists)
↑ mix the lists into a matrix
{…}⌺3 3 on each 3-by-3 sub-matrix:
 +/⍵ sum the rows
 ×/ multiply the sums
, flatten the matrix of sums
⌈/ find the maximum

16 bytes: ⌈/∊3×/{3+/⎕}¨⍳20

J+tr, 84+10
y=:20 20$".(1!:1)3
s=:3 :'(y&((][;.0~3 3,:~[)~))"1(,."0/~i.18)'
>./,([:*/+/"1)"2 s y

runs like this < golfdata tr \\n ' '| ./test.ijs so I consider the tr \\n ' ' part as part of the program.
y=: 40 30 43 ...
>./,([:*/+/"1)"2 s y
328536000

z =: 20 20 $>:i.20
>./,([:*/+/"1)"2 s z
185193

What's the easiest way to run J answers?

@gnibbler: the only way I know (unfortunately) is to download and install J.

@gnibbler ...which is being open sourced. Yay.

Golfscript, 48 chars
n%"{~}%:^,,{^>3<}%":|~{{+}*}%20/zip|~{{*}*}%$)p;

previous one
n%{' '%"{~}%:^,,{^>3<}%":|~{{+}*}%}%zip|~{{*}*}%$)p;

Some explanations, but I am still newbie in golfscript, some might not be correct, please correct me, if you see something wrong.

n%                 #.lines
{                  #.each
   ' '%               #.split ' '
   "                  #"... literal string start
      {~}%               #.flatten
      :^                 #assign to variable ^
      ,                  #.size
      ,                  #.times
      {                  #.each
         ^>                 #^[n:]
         3<                 #[:3]
      }%                 #.map end
   "                  #..." literal string end
   :|                 #assign literal string to variable | to reuse later
   ~                  #eval
   {                  #.each
      {+}                #sum
      *                  #.fold
   }%                 #.map end
}%                 #.map end
zip                #.zip
|~                 #eval variable | against result of .zip
{                  #.each
   {*}                #product
   *                  #.fold
}%                 #.map end
$                  #.sort
)                  #uncons / .pop
p                  #puts
;                  #discard top item from stack

Tests
$ cat sample-1159-1.txt | golfscript codegolf-1159.gs
3375

$ cat sample-1159-2.txt | golfscript codegolf-1159.gs
328536000

$ cat sample-1159-3.txt | golfscript codegolf-1159.gs
185193

Haskell, 129 characters
import List
t f z@(_:y@(_:x))=zipWith3((f.).f)z y x
main=interact$show.maximum.(t(*)=<<).transpose.map(t(+).map read.words).lines

Jelly, 18 bytes
ƈLÐ¿ḊỴḲ€V+3\€×3\FṀ

Try it online!
Takes input from STDIN, space and newline separated

Jelly, 9 bytes
+3\€×3\FṀ

Try it online!
Takes a 20x20 matrix of integers as input. +4 bytes to input as a space and newline separated grid
How it works
+3\€×3\FṀ - Main link. Takes a matrix M on the left
   €      - Over each row r:
 3\       -   Over each overlapping triple:
+         -     Take the sum
     3\   - Over each overlapping triple:
    ×     -   Take the product
       F  - Flatten
        Ṁ - Take the maximum

The challenge requires to take input from 20 lines of stdin specifically.

@Bubbler God, I hate older challenges sometimes :/

Powershell, 103 bytes
(($x=-split($args-replace'(\d+)(?= (\d+) (\d+))','$1+$2+$3')|iex)|%{$_*$x[$j+20]*$x[$j+++40]}|sort)[-1]

Explanation:

The regexp transforms each string like 1 2 3 4 5 6 to the string like 1+2+3 2+3+4 3+4+5 5 6;
Then the script splits the string 1+2+3 2+3+4 3+4+5 5 6 by spaces and evaluates each element by iex (alias for Invoke-Expression). A result is an array like 6,9,11,5,6;
Finally, the script concatenates all arrays to one, calulates a products and returns a maximum.

It is essential that we need a maximum of products of sum of non-negative integers. So we don't need to filter out the last 2 values in each row and last 2 rows.
Less golfed test script
$f = {

$x=-split($args-replace'(\d+)(?= (\d+) (\d+))','$1+$2+$3')|iex
($x|%{$_*$x[$j+20]*$x[$j+++40]}|sort)[-1]

}

@(
    ,(  3375,
        "1 2 3 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "4 3 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "4 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 5 5 5 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 5 5 5 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 5 5 5 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1",
        "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1")
    ,(  328536000,
        "40 30 42 222 74 265 93 209 115 274 139 177 7 274 12 15 103 36 236 91",
        "294 97 35 272 167 126 18 262 292 48 8 296 85 93 245 4 4 240 276 153",
        "52 8 163 270 242 224 142 72 99 240 199 26 224 198 96 242 295 70 56 247",
        "247 130 216 68 266 142 93 214 30 8 12 163 59 84 40 287 233 65 30 242",
        "283 245 164 53 148 282 73 186 296 3 9 233 184 30 205 221 92 96 5 101",
        "132 228 43 91 228 37 266 140 159 109 10 230 40 114 264 3 266 164 219 283",
        "70 207 218 28 299 78 279 30 179 118 196 138 61 229 110 55 203 73 124 112",
        "16 232 28 187 292 78 194 70 65 203 255 227 176 21 32 225 11 15 92 151",
        "58 237 261 41 213 171 170 111 4 209 99 194 40 108 267 137 179 31 35 221",
        "184 209 264 275 163 268 261 40 198 185 45 188 280 273 54 79 270 286 273 121",
        "208 83 66 156 104 62 188 68 53 194 46 279 280 170 266 148 272 285 178 245",
        "210 130 213 118 165 210 213 66 54 189 166 193 57 213 14 101 143 109 172 101",
        "80 193 287 4 140 65 208 111 8 206 107 285 109 29 211 78 170 247 290 193",
        "148 123 15 164 28 153 222 67 156 165 6 163 114 77 165 17 143 209 278 100",
        "3 102 58 148 82 181 84 29 2 236 231 195 118 278 252 257 179 123 276 287",
        "143 141 254 142 200 243 171 32 164 195 235 260 269 191 190 46 65 166 82 146",
        "69 194 65 220 234 110 45 135 125 208 138 20 233 291 256 162 148 216 247 138",
        "10 53 164 107 2 270 226 227 88 206 193 13 41 130 218 249 76 35 207 91",
        "199 36 207 256 58 215 28 277 234 29 198 148 219 244 136 16 30 258 219 264",
        "183 118 48 218 15 125 279 103 73 8 86 113 9 157 239 273 146 208 50 86")
    ,(  185193,
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20",
        "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20")
    ,(  311042813,
        "242 248 292 60 9 45 94 97 294 202 219 118 115 243 207 81 288 289 241 232",
        "236 225 205 227 242 85 139 63 5 162 170 121 208 133 22 235 125 288 209 270",
        "31 182 108 170 88 268 297 66 249 158 285 157 267 117 150 18 44 66 117 223",
        "205 32 93 132 33 99 209 282 222 272 255 1 80 270 202 54 117 35 139 273",
        "87 74 113 146 177 14 154 92 282 4 192 60 171 286 66 299 89 276 138 289",
        "60 16 143 277 202 284 77 296 215 96 200 10 226 143 136 131 218 246 254 20",
        "244 118 299 218 81 195 129 93 205 202 264 141 196 150 214 72 231 136 243 192",
        "236 157 176 187 104 182 134 29 151 234 81 143 22 119 45 241 17 225 197 7",
        "156 284 92 13 131 60 113 77 228 65 200 83 3 63 83 88 241 113 115 198",
        "62 101 242 270 121 122 119 78 105 273 55 7 239 236 37 252 66 164 56 44",
        "70 57 100 87 34 298 140 259 36 257 1 204 110 299 245 56 43 121 192 10",
        "240 36 272 255 10 194 143 66 27 131 22 78 57 71 128 5 1 155 236 122",
        "281 160 42 147 272 151 196 240 291 280 209 245 271 46 103 35 85 145 78 140",
        "155 74 232 205 235 223 147 39 171 240 56 187 184 70 28 81 293 125 283 159",
        "297 203 75 46 221 77 106 12 268 94 220 156 78 97 266 208 228 137 212 49",
        "4 157 69 51 225 23 61 202 19 23 41 260 161 218 142 251 299 187 283 158",
        "118 136 71 77 21 199 110 87 103 120 153 157 213 234 155 141 135 24 120 199",
        "16 204 292 245 54 260 294 159 254 15 209 41 154 54 231 167 87 291 31 26",
        "212 274 99 199 170 184 47 227 64 2 117 275 67 84 143 214 143 125 24 61",
        "205 250 133 88 210 112 4 160 3 287 54 143 293 94 287 42 105 94 76 169")
) | % {
    $expected, $a = $_
    $result = &$f @a
    "$($result-eq$expected): $result"
}

Output
True: 3375
True: 328536000
True: 185193
True: 311042813

Powershell, 105 bytes, no-regexp alternative
The tribute to the smart expression |?{$_%20-le17} in the Joey's answer:
(($x=($y=-split$args)|?{$i++%20-le17}|%{+$y[$i-1]+$y[$i]+$y[$i+1]})|%{$_*$x[$j+18]*$x[$j+++36]}|sort)[-1]

This does not follow the input specification.

why? ..........

Your script is taking the input as arguments instead of on stdin.

Why do you think the 'standard input' is 'stdin' only?

Stax, 19 bytes
┬░╩íΩ{\ë╔B_m♦½─Γe╧¼

Run and debug it
Input is given directly, no quotes.
Explanation
L{eL3B{|+mmM{3B{:*mm$|M Input: STDIN, auto split on newlines, pushed to stack
L                       listify the stack
 {        m             map each line to:
 {e       m             evaluate it
   L                    listify the stack
    3B                  overlapping slices of length 3
      {|+m              map those to their sums
           M            transpose
            {      m    map to:
             3B         overlapping slices of length 3
               {:*m     mapped to products
                    $   flatten
                     |M maximum

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


text:
Sum of positive integers.
Problem:
Given a set of integers, find the sum of all positive integers in it.
Input:

t – number of test cases [t < 1000]
On each of next t lines, an integer N [-1000 ≤ N ≤ 1000]

Output
The program should output the sum of all the positive integers.
Check your code in online judge
Score
Score is equal to size of source code of your program except symbols with ASCII code ≤ 32.
Here is the best score list: Python Best Scores (Best score is 29)

There are a lot more codegolf challenges at http://www.spoj.pl/SHORTEN/. Don't see the point of duplicating them here though.

why is this question tagged python.. Are we interested in python solution only?

I don't think questions from contest sites should be posted here.

I already did this one on SPOJ. A while ago they promoted all the Python2.6 answers to Python3 even though some of them wont run under Python3 and would be longer in Python3 - eg have to use int(input()) instead of input() and print(x) instead of print x. So I don't take SPOJ very seriously anymore. I'm tied with Tim Peters and that's good enough for me :)

@fR0DDY, Yes, in this case if someone posted the 29 char Python solution, everyone who sees this question can get a good rank on SPOJ without earning it

I just want to point out, that skipping the T (number of ...errr...numbers (?) ) is not an option...since the testcases involve extra data after T numbers...your code will fail at SPOJ. Everyone (3 answers below) seemed to have cleverly skipped the first integer.

Since answers are moving up and down, '3 answers below' is not very precise.

Shouldn't the example on SPOJ provide an output of 15? 4+5+6? Or am I missing something?

Please, check my Python( 41 char) solution, if it correct or not. I had some doubt regarding the use of \n in my source code.

Where's the specification? Nowhere to be found: SE questions should be self-contained.

How is this question unclear? [1, 2, 3, 4] --> 10. I'm voting to close this question not because it's unclear, but because it's a challenge from another site, which is off-topic according to community consensus

Whitespace, 0
I couldn't resist. S= space, T= tab, N = newline, all have ASCII codes <= 32.
SSSSNSSSSNTTSSSSSTNTNTTNSSSNSSSSTNTTTNTSTNSSSSTNSSSSTNTTTSSSSTNTSSTTTSSSSSTSNTNTTSSSSTSNTTTNTTSNSSSSNSSSSTSNTTTSSSSNTTTTSSSTTSNSNSNNSSTNSSSSNTTTTNSTSSSSTSTSNTNSSNNN

Base64 encoded for easy copy & paste.
ICAgIAogICAgCgkJICAgICAJCgkKCQkKICAgCiAgICAJCgkJCQoJIAkKICAgIAkKICAgIAkKCQkJ
ICAgIAkKCSAgCQkJICAgICAJIAoJCgkJICAgIAkgCgkJCQoJCSAKICAgIAogICAgCSAKCQkJICAg
IAoJCQkJICAgCQkgCiAKIAoKICAJCiAgICAKCQkJCQogCSAgICAJIAkgCgkKICAKCgo=

(+1) Nice program! A tiny "FWIW": 9 characters can be removed due to 9 instances of an unneeded S in the binary coding of a number. These are all in push-number-to-stack instructions of the form SSSS...N, where the 4th S codes a superfluous leading 0. (Of course this has no effect on the score.)

Element, 17 characters plus 1 space
_'[_ 2:n;0>[n~+]]`

This is my first constructed language. It is designed to be very compact and human-readable. All of the instructions are one character long and perform a single function.
Element has two stacks and a hash as memory structures. The two stacks are called the main stack and the control stack. The main stack is where arithmetic, I/O, and hash manipulation occurs. The control stack is where logic operations occur, and this stack controls the while and for loops.
The basic idea behind Element is that there is a hash that stores numbers/strings, while the stack is used to perform calculations on these numbers. The results to these calculation can then assigned a certain place in the hash for future use. The different contents of the hash are called elements, so it is similar to an array but can have non-numerical names.
EDIT: You can find an interpreter for Element (written in Perl) here.
Here is the list of operators: In some of these examples, m and n represent numbers already on the stack.
text  --pushes the string "text" onto the main stack
'     --pops from main stack and pushes onto control stack
"     --pops from control stack and pushes onto main stack
#     --pops from main stack and destroys
[]    --FOR statement (view the top number number from control stack and eval those many times)
{}    --WHILE (loop until top number on control stack is 0)
(     --pops from main stack, removes first character, pushes the remaining string onto stack, and pushes the removed character onto stack
)     --pops from main stack, removes last character, pushes the remaining string onto stack, and pushes the removed character onto stack
~     --pops from main stack, pushes contents of the element with that name
+-*/%^ --pops two most recently named elements, adds/negates/multiplies/divides/modulates/exponentiates them, and places the result on the stack
mn;   --pops m and n and assigns element n the value of m
mn@   --pops m and n and moves mth thing in stack to move to place n in stack
m$    --pops m and pushs size of m onto the stack
mn:   --pops m and n and pushes m onto the stack n times
mn.   --pops m and n and pushes m concatonated with n
m?    --pops m and pushes 0 onto control stack if m is '0' or and empty string, else pushes 1
\     --escapes out of next character, so it isn't an operator and con be pushed onto the stack
><=   --pops two numbers off of stack and tests, pushes 1 onto control stack if true and 0 if false
`     --pops from main stack and prints
&|    --pops two items from control stack, performs and/or respectively, and pushes result back onto control stack
!     --pops a number off of control stack, pushes 1 if 0 or empty string, 0 otherwise
_     --inputs a word and pushes onto main stack
m,    --pops m from main stack, coverts it to char and pushes, converts to num and pushes
Newlines and spaces separate different elements to be pushed onto the stack individually, but can pushed onto the stack using \

Here is a walkthrough of how the program works:
_'[    --take the first line of input, transfer it to the control stack, and start a for loop
_ 2:   --take one more line of input, and duplicate it so that there are two copies
n;     --take one copy and put into element n
0>     --push a zero onto the stack, remove the zero and the other copy of the input, and compare. A 1 will be placed on the control stack if the input was greater than zero, a 0 otherwise.
[      --starts another for loop if the comparison was true. This loop will be repeated once if the comparison was true and no times if it was false, so it is the same as an IF statement.
n~     --pushes n onto the main stack, then pops it ans replaces it with the contents of n, which is the number stored earlier
+      --takes the number and adds it to the running total, which is contained as the last item on the stack
]      --ends the inner for loop
]      --ends the outer for loop
`      --print the top item (also the only item) on the stack to output

An entry like this would be much improved with a pointer to a working environment.

I don't think you understand what "human-readable" means.

@WChargin he is used to Perl...

@WChargin Every language is unreadable until you learn it. ;)

Perl, 31
<>;$i+=$_*($_>0)while<>;print$i

Wouldn't using say make this just a bit shorter?  It'd tie with the 29 character best.

No, because say isn’t built-in and (at least) requires a command-line switch which would count towards the character count.

It can be shortened to 29 bytes by using $\  instead of $i: <>;$\+=$_*($_>0)while<>;print

Ruby 1.9.2, 37
p eval [*$<].join.gsub(/\A\d+|-\d+|\n/, '+0')

Call like ruby scriptname file_with_ints .

I can't read much Ruby, but does that even read the number of test cases?

No it doesn't...

@st0le: Just noticed that apparently no solution currently solves the task.

Ruby, 52
t=gets.to_i;s=0;t.times{i=gets.to_i;s+=i if i>0};p s

I don't see where you are printing the value of s.

yeah I forgot

Haskell, 58
Properly operates on only t integers.  Haven't run it against Spoj because I just don't care to register there.
f (x:l) = take x l
main = interact $ show . sum . f . map (max 0.read) . lines

What are "t integers"?

Perl, 33
<>;while(<>){$i+=$_ if$_>0}print$i

Although the space is necessary, so it seems odd not to count it. Oh well, the rules is the rules.
Hmm. I could probably get away with using a variable name which doesn't count towards the total either. The thing is, I'm not sure how I'd paste the code then.

Just show them as $^A-$^Z, but beware that many of that variables have special meanings.

code in C 89 characters

x="%d";  main(b,a,t)  {
  for(scanf(x,&t);t;t--)
    {  scanf(x,&a); a>0?b+=a:a; }  printf(x,b-1);
       return 0; }

I tried a lot to reduce my code less than 63 bytes, but i can reduce it only to 89 bytes. Please help me to reduce it to 63 bytes or even less.

I have counted 90 characters.
return 0; is not necessary, the for cycle may be contracted to for(scanf(x,&t);t--;scanf(x,&a),a>0?b+=a:a); == which make that 78 characters...

Doesn't compiles with gcc 4.8.1 error: initializer element is not computable at load time x="%d"

Clojure, 71
(reduce + (filter pos? (map #(Integer/parseInt %) (next (line-seq *in*)))))

This doesn't produce any output, and fails because *in* is not a java.io.BufferedReader, as required by line-seq.

Also it ignores the number of lines input t.

In memoriam Dennis M. Ritchie
unix 57¹72:
n=$(head -n1 i); echo $(($(head -n $((n+1)) i | tail -n $n | grep -v "-" | tr '\n' '+')0))

assuming i is the file, containing the ints.
¹) was wrong, included the number of lines, and added 1 line too less.
echo $(($(cat i | head -n $(head -n1 i) | grep -v "-" | tr '\n' '+')0))

Haskell, 51
main = interact $ show . f . lines
f (x:l) = foldl (+) 0 $ map read l

(extra spaces for clarity, since they don't count)
Haskell is ... interesting, since you tend to get programs with a significant number of necessary spaces.

You forgot a filter (>0).

C,88

x="%d";  main(b,a,t)  {
for(scanf(x,&t);t--;)
{  scanf(x,&a); a>0?b+=a:0; }  printf(x,b-1);
return 0; }

After another big effort, code is one character less, please help me to reduce it more.

just edit the original answer next time

remove the (return 0;) and ({} for for)

b,x="%d";main(a,t){for(scanf(x,&t);t--&&scanf(x,&a);)b+=(a>0)*a;printf(x,b);} <- 77 bytes

@walpen: they used the fact, that their "argc" like parameter was set to 1, your b is uninitialized...

Befunge-98 (24)
(Make sure you use an interpreter that can read negative numbers (seems to be a somewhat common bug, but RcFunge works))
<;-1\+*`0:&\_\#;.@;:;#&0

Perl (25)
(Perl allows control characters in variable names, I named my variable ^B (ASCII 2) so that it does not count towards the goal.)
<>;$^B+=$_*!/-/for<>;print$^B
(Normal variant (27 chars)):
<>;$B+=$_*!/-/for<>;print$B

i first ignored your perl answer when i saw the variable naming and completely missed the excellent one below it

APL (10)
+/{0⌈⎕}¨⍳⎕

Explanation:

⍳⎕: read a line, gives a list [1..N] for user's input N
¨: for each element in this list... (i.e. do N times)
0⌈⎕: read a line, return the maximum of 0 and the entered N
We now have a list with all positive Ns the user entered, and 0s where the user entered something negative.
+/ gives the sum of this list.
The result is output by default (because we're not doing anything else with it).

Mathematica: 18 16
Boole[#>0]&/@x.x

Nice function, but how does this handle the specified newline-separated input? How does it not incorporate the number of test cases parameter t as part of the sum? How does it sum only up to the number of test cases specified, even if more are given?

PowerShell, 44
($i=$input|%{+$_})[1..$i[0]]-gt0-join'+'|iex

Q,12
{0+/x(&)x>0}

sample usage
q){0+/x(&)x>0} 1 -1 2 3 -1
6

C, 70 72 characters
s;main(i,c){for(;c--;i>0?s+=i:0)scanf("%d",s?&i:&c);printf("%d",s-1);}

The results on the SPOJ site definitely seem unreal - I have no idea how to get this down to 63.
However, 68 characters is reachable on some compilers by abusing undefined behaviour.  The following works on x86 Linux with 32-bit gcc, on which all arguments are passed on the stack.
s;main(i,c){for(;c--;i>0?s+=i:0)scanf("%d",&i+!s);printf("%d",s-1);}

befunge, 3524
:0`j&1-\&:0`*+\:0`3*j$.@

with a little inspiration by seeing marinus answer, I've also managed 24 characters. but I've got a completely different approach.

PYTHON 2.x, 50 chars
r=input
print sum(i for i in (r() for j in range(r())) if i>0)

excel, 27
=SUM(INDIRECT("A2:A"&1+A1))

count t in A1, rest of data a2 and down

Clojure, 108
(let [[n & m] (->> *in* java.io.BufferedReader. line-seq (map read-string))]
  (->> m (take n) (filter pos?) (apply +) println))

I really wish I could avoid the java.io.BufferedReader. part, since it costs 24 chars itself. But AFAIK there's no facility to read lines from STDIN without it.

Perl, 20
I know it is old and trivial, but the Perl answer can be still improved:
#!perl -p
$.<2or$\+=$_*!/-/}{

This is awesome! But what does }{ mean/do?

C
void main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
     {
     if(i>0)
     sum=sum+i;
     }
printf("sum of positive numbers is %d",sum);
}

Welcome to CodeGolf.SE! If you look at the other answer, you'll see that they have formatted code and a minimal header noting the implementation language; on more complicated challenges many also have notes on the implementation and any limits or surprises in the code. Without some of this, you answer is unlikely to be well received.

I counted the chars, added the indentation to make code-layout work, and removed the decoration of the output. Oh - now I have to count again. :)

Added language name. There's a lot of room for reductions here - sum can be reduced to s, the output string can just be "%d", etc.

scala 55 54:
println ((for (r <- 1 to readInt;
  i=readInt;
    if i>0) yield i)sum)

C++:
#include<iostream>
using namespace std;
int main()
{
    int c,n,s=0;cin>>c;
    while(c--)
    {
        cin>>n;s+=n*(n>0);
    }
cout<<s;return 0;
}

115 characters long. Need to optimize it to 90. Any suggestions ?

Just the standard tricks: The return is unnecessary in standard C++ or C99, there is an implicit return 0 in main.  By making the variables global you can drop the =0 initialization.  Finally, for(;;) is the same number of characters as while() but you get two extra places to put an expression in.

This is already old, but also, writing std:: before cin and cout and getting rid of the using namespace std; can save 5 more characters.

PHP, 71
<?for($s=0,$t=fgets(STDIN)+0;$t--;$s+=($n=fgets(STDIN))>0?$n:0);echo$s;

Python: (92 characters)
t = int(raw_input())
n = [int(raw_input()) for i in range(t)]
print(sum([n[i] for i in range(t) if n[i]>0]))

Using a=raw_input and r=range and using a() and r() later can save quite a few characters.

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
 static class Program
 {
   static void Main(string[] args)
   {
     Console.WriteLine(Console.In.ReadToEnd().Split('\n').Sum(l => { Int32 v; return Int32.TryParse(l, out v) ? v.To(1000).Where(x => x > 0).Sum() : 0; }));

    }
    static IEnumerable<int> To(this int a, int b) { for (var i = a; a <= b; a++) { yield return i; } }
  }
}

Ruby, 42
s=0
gets.to_i.times {
    i=gets.to_i
    s+=i if i>0
}
p s

(based on david4dev's answer)
Best score for Ruby on spoj: http://www.spoj.com/ranks/SIZECON/lang=RUBY

45 chars in python
c=0
j=input
for i in j()*[0]:
    b=j()
    c+=b*(b>0)
print c

How you counted that? It gives me 54 characters.

@manatwork, this question has non-standard scoring rules which don't count whitespace.

Oops, sorry. I missed that. Thanks, @PeterTaylor.

Python 3, score: 63 61
r=0
q=input
w=int
for i in[1]*w(q()):
 t=w(q())
 r+=t+abs(t)
print(r/2)

I don't really know python, so I'm having a considerably difficult time making this any smaller.
Python, score: 49 48
r=0
q=input
for i in[1]*q():
 t=q()
 r+=t+abs(t)
print r/2

Same as above, but python 2 doesn't need the casting to int, apparently.

So do I.
I'm not entirely sure where 49 came from.

my mistake -- apparently characters with ascii value < 33 are discounted.

if whitespace etc doesn't count, then it's shorter to put "compound" statements like r,q,w=0,input,int as single statements on separate lines; r=0 q=input w=int (where space is newline)

The reason for casting to int in Python 3 is input is not the same function : see this SO answer

Perl, 30
so close to that python best of 29, but had to add +1 for the -p switch
$s.=$_}{$s=~s/\s\d+/$_+=$&/eg

This can be modified into an alternative 20 char solution: -p0 s/\n\d+/$\+=$&/ge}{. 19 when not counting \n.

Python
One-statement Solution
Python 3 (60 chars, 66 with spaces)
print(sum(x for x in(int(input())for _ in[1]*int(input()))if x>0))

Python 2 (48 chars, 55 with spaces)
print sum(x for x in(input()for _ in[1]*input())if x>0)

May be shortened by one character
i=input
print sum(x for x in(i()for _ in[1]*i())if x>0)

dc, 22 chars
0?[sa?+la1-d0<b]dsbxrp

Negative numbers must be specified in the dc notation, i.e. with underscore: _20.

PERL, 21 chars (score 20)
$a+=<>for 1..<>;say$a

I don't get it, how this eliminates negative numbers from the sum?

Smalltalk, 79
b:=[:x|Number readFrom:Stdin].(((1 to:(b value:1))collect:b)select:[:i|i>0])sum

Windows Batch, 68 (characters >= 32)
I was about to post an extremely simple solution, but then I realised you have to read the number of test cases. Initially I just had for %%a in (%*)do set/a"i+=%%a" echo %i%.
set/p t=
for /l %%i in (1 1 %t%)do call :a
echo %i%
:a
set/p N=
if %n% geq 0 set/a"i+=N"

It reads t, then each N from stdin.

Python, 41
i=input
print sum(len(" "*i())for j in[0]*i())

Python, 42
c=""
i=input
exec'c+=" "*i();'*i()
print len(c)

This is a pretty smart solution. FWIW, I think the \n should count as two characters, as that's what it is in your source code before being executed.

J - 22 char
All these inputs blowing up the character count. Envious of APL here...
+/0>.".1!:1#&1".1!:1]1

Explained:

1!:1]1 - Read in a line of input (1!:1) from input (file handle 1).
#&1". - Convert to an integer (".) and create a list of 1s that long (#&1).
".1!:1 - Read in a line for each 1 in the list, and convert them to integers.
0>. - Take the greater of each integer and 0, effectively zeroing the negative numbers.
+/ - Sum all the integers together.

Usage:
   +/0>.".1!:1#&1".1!:1]1
3
11
909
-67
920

You can use echo for the output.

K - 20 char -2 = 18 pts
Had two 20 char solutions, and this one has more whitespace.
(. 0:`){x+0|. 0:`}/0

Explained:

n f/0 - Apply the function f to 0, n times.
(. 0:`) - Read in a line (0:) from input (file handle `) and convert to integer (.).
{x+0|. 0:`} - Read in an integer (. 0:`), take the greater of it and zero (0|), and add it to the argument (x+).

Usage:
  (. 0:`){x+0|. 0:`}/0
4
123
-99
12
9
144

JavaScript 93
Works for t integers, but said integers need to be entered with spaces in between.
y=(x=prompt().replace(/-\d{1,4}/g,"").replace(/ /g,"")).length;for(s=0;y--;)s+=+x[y];alert(s)
Takes the prompt, strips negative numbers and spaces, and adds the numbers...

Pyth - 7
Input in pyth is only one line, so it accepts comma-delimited instead of newline delimited. Pyth is not on Spoj, but there wasn't any rule saying it had to be.
sf>TZtQ

Very simple:
s      sum
f      filter by
>TZ    filter arg greater than zero
tQ     run filter on all but first element of evaluated input

C#, score: 174
using System;

class P
{
    static void Main(string[] a)
    {
        uint s = 0, t, n;
        for (uint.TryParse(Console.ReadLine(), out t); t-- > 0; uint.TryParse(Console.ReadLine(), out n), s += n) ;
        Console.WriteLine(s);
    }
}

C, 60 characters
There doesn't seem to be much to improve.
c;

main(x)
{
    while (0 < scanf("%d", &x))
        c += x * (x > 0);

    printf("%d", c);
}

Factor, 95 bytes
[ [ readln dup string>number ] [ string>number dup [ 2 * ] [ ] if ] produce [ 0 max ] map sum ]

Like a lambda; use it with call.

C++ (96 points)
#include<iostream>
main()
{
int t,n,s=0;
for(std::cin>>t;t;std::cin>>n, --t, n>0?s+=n:s);
std::cout<<s;
}

Python, 43
c=0
i=input
exec'b=i();c+=b*(b>0);'*i()
print c

Please use code block formatting, so scripts like Code Golf UserScript Enhancement Pack can insert the code block length.

Python 52 Characters
c = 0
for i in range(t):
    k = input()
    if k>0:
        c+=k
print c

Welcome to PPCG! It appears that neither spaces nor newlines should be included in the score, so I count your answer as 43, not 52. Also, it looks like three lines of your code are missing the indentation required by the for loop.

@MartinBüttner Thanks for the correction. When i submitted my code, 52 was what i saw.


text:
Write a program to perform set operations.
Your task is to write a program to perform set operations. The operations and arguments are taken from command line in the format program operation [argument]. There are four operations:

1: clears the set. no arguments. exit code 0.
2 integer: adds the integer into the set. exit code 0.
3 integer: removes the integer from the set. exit code 0.
4 integer: queries the set for integer. exit code 0 if integer exists or 1 otherwise.

The integer is a 64-bits integer. Shortest program wins. You can, of course, use a temporary file. However, watch out the space and time limit.
Example:
$ program 1 ; echo $?
0
$ program 2 10 ; echo $?
0
$ program 4 10 ; echo $?
0
$ program 3 10 ; echo $?
0
$ program 4 10 ; echo $?
1
$ program 2 10 ; echo $?
0
$ program 1 ; echo $?
0
$ program 4 10 ; echo $?
1

@Joey. Yes. That's why you should use a file.

Your 4th test assert an exit code of 1 which is not according to the specification (where 3 would always return 0).

@Joey: thank you. I missed that.

Bash -- 54 chars
case $1 in
1)rm *;w;;
2)>$2;;
3)rm $2;w;;
4)<$2;;
esac

Notes: Outputs to stdout/stderr in some scenarios. Empties working directory when clearing the set. Uses one file for each set element. The purpose of ;w is to exit with status 0.
This appears to comply with all the rules.

I find it brilliant that you use separate files for each argument.

Bash: 106 chars
touch f
case $1 in
1)rm -f f;;
2)echo $2>>f;;
3)grep -vx $2 f>g;mv g f;;
4)grep -x $2 f&>/dev/null;;
esac
Counting newlines as one character. Requires two temp files and POSIX grep. I'm unclear as to the precise constraints on temp files: if I can have two kicking around all the time then I can save 8 chars by writing to g rather than /dev/null in case 4.

If you add number '123' and then query for '23' what's the exit code?

@Eelvex, good catch. I had -x on one grep but not on the other.

Python - 167 chars
import sys,shelve as S
x,A,E=S.open("x"),sys.argv,exit
A[1]<'2'and E(x.clear())or'3'>A[1]and E(x.__setitem__(A[2],1))or'4'>A[1]and E(x.__delitem__(A[2]))or E(A[2]in x)

You need to create the temporary file like this
python -c 'import shelve;shelve.open("x","c")'

bash, 74
case $1 in
1)>f;;
2)echo $2>>f;;
3)sed -i /^$2$/d f;;
4)grep ^$2$ f;;
esac

note I'm not plagiarizing Peter Taylor, it's just that it's not working with [ test ]s

PHP - 204 characters
<?
$s=unserialize(file_get_contents('f'));
$a=$argv;
$o=$a[1]--;
$a=$a[2];
--$o?(--$o?(--$o?die(!isset($s[$a])+0):$s=array_diff_key($s,array($a=>1))):$s[$a]=1):$s=array();
file_put_contents('f',serialize($s));

Added some linebreaks to make it a tad more readable.
This throws a warning to screen when run for the first time, but otherwise, it does as asked.

Ruby - 146 characters
a,b=ARGV
File.open('x','a+'){|f|s=eval(f.read)||[]
s=[]if a=='1'
s+=[b]if a=='2'
s-=[b]if a=='3'
f.puts s.inspect
exit a=='4'?(s.index(b)?0:1):0}